"; echo "POST DATA:\n
";
print_r($_POST);
echo "
"; // Load the XML configuration file into a SimpleXML Object $xml_config = simplexml_load_file('content-submission-config.xml.php'); // Load the configuration information into php variables $cascade_server = (string)$xml_config->{"cms-login-info"}->server; // The location of the Cascade instance $cascade_user = (string)$xml_config->{"cms-login-info"}->username; // The username to login to the Cascade instance above $cascade_password = (string)$xml_config->{"cms-login-info"}->password; // The username's password $workflowName = (string)$xml_config->{"workflow-definition"}->name; // The name of the workflow to be instantiated $workflowDefinitionPath = (string)$xml_config->{"workflow-definition"}->path; // The path of the workflow definition to be used $workflowComments = (string)$xml_config->{"workflow-definition"}->comments; // Comments for the operation which will be recorded with the workflow // Construct a SOAP client connecting to Cascade instance $client = new SoapClient($cascade_server."/ws/services/AssetOperationService?wsdl", array('trace' => 1)); makeEvent($client); exit; function makeEvent($client) { global $cascade_user, $cascade_password, $workflowName, $workflowDefinitionPath, $workflowComments; $params = array ( 'authentication' => array ( 'username' => $cascade_user, 'password' => $cascade_password ), 'asset' => array ( 'workflowConfiguration' => array ( 'workflowName' => stripslashes($workflowName), 'workflowDefinitionPath' => stripslashes($workflowDefinitionPath), 'workflowComments' => stripslashes($workflowComments) ), 'page' => array ( 'configurationSetPath' => '/Intranet/Calendar Event', 'metadata' => array ( 'displayName' => stripslashes($_POST['display-name']), 'title' => stripslashes($_POST['title']), 'summary' => stripslashes($_POST['summary']) ), 'metadataSetPath' => '/Types/Common Inline Required', 'name' => $_POST["system-name"], 'parentFolderPath' => '/intranet/calendar/events', 'shouldBeIndexed' => 'true', 'shouldBePublished' => 'false', 'structuredData' => array ( 'definitionPath' => '/General/Calendar Event', 'structuredDataNodes' => array ( 'structuredDataNode' => array ( array ( 'identifier' => 'date', 'text' => $_POST["date"], 'type' => 'text' ), array ( 'identifier' => 'time', 'text' => $_POST["time"], 'type' => 'text' ), array ( 'identifier' => 'contact', 'text' => stripslashes($_POST["contact"]), 'type' => 'text' ), array ( 'identifier' => 'category', 'text' => stripslashes($_POST["category"]), 'type' => 'text' ), array ( 'identifier' => 'details', 'text' => stripslashes($_POST["details"]), 'type' => 'text' ), array ( 'identifier' => 'location', 'text' => stripslashes($_POST["location"]), 'type' => 'text' ), array ( 'identifier' => 'contact-website', 'text' => $_POST["contact-website"], 'type' => 'text' ), array ( 'identifier' => 'contact-phone', 'text' => $_POST["contact-phone"], 'type' => 'text' ) ) ) ) ) ) ); try { $response = $client->create($params); } catch(Exception $e) { print_r($client->__getLastRequest()); print_r($client->__getLastResponse()); //$mesg = $config->get_var("strings.edit_error"); return false; } if ($response->editReturn->success != "true") { print_r($client->__getLastRequest()); print_r($client->__getLastResponse()); //$mesg = $config->get_var("strings.edit_error"); return false; } return true; } function formatWysiwyg($input) { return $input; } $authType = (string)$xml_config->{"authentication-type"}; // The authentication type for importing each user $enableUsers = ((string)$xml_config->{"enable-users"} == 'Yes') ? "true" : "false"; // Whether to enable the imported users or not $xml_feed_path = (string)$xml_config->{"xml-feed"}; // The path to the XML feed relative to the PHP script // Load the XML file holding the information to the users and groups to be imported into the CMS $import_xml = simplexml_load_file($xml_feed_path); // Construct a SOAP client connecting to Cascade instance $client = new SoapClient($cascade_server."/ws/services/AssetOperationService?wsdl", array('trace' => 1)); // Import each group from the XML file foreach($import_xml->group as $group){ importGroup($group); } // Then import each user from the XML file foreach($import_xml->user as $user){ importUser($user); } /** * Retrieve a SimpleXML Object containing data from the CMS for the asset with * the provided $path. */ function read_asset($path, $type, $client) { global $cascade_user, $cascade_password; $params = array ( 'authentication' => array ( 'username' => $cascade_user, 'password' => $cascade_password ), 'identifier' => array ( 'path' => $path, 'type' => $type ) ); try { $response = $client->read($params); } catch(Exception $e) { //$mesg = $config->get_var("strings.read_error"); new Error($mesg); return FALSE; } $xml = $client->__getLastResponse(); $xml = str_replace("xsi:", "", $xml); preg_match("&<$type>.*&is", $xml, $matches); $simplexml = simplexml_load_string($matches[0], 'SimpleXMLElement', LIBXML_NOCDATA); return $simplexml; } /** * Update the asset's review-date information using web services */ function write_asset($asset_xml, $type, $client) { global $cascade_user, $cascade_password; $params = array ( 'authentication' => array ( 'username' => $cascade_user, 'password' => $cascade_password ), 'asset' => array() ); $params['asset']["$type"] = array ( 'configurationSetId' => (string)$asset_xml->configurationSetId, 'configurationSetPath' => (string)$asset_xml->configurationSetPath, 'expirationFolderId' => (string)$asset_xml->expirationFolderId, 'id' => (string)$asset_xml->id, 'metadataSetId' => (string)$asset_xml->metadataSetId, 'metadataSetPath' => (string)$asset_xml->metadataSetPath, 'parentFolderId' => (string)$asset_xml->parentFolderId, 'parentFolderPath' => (string)$asset_xml->parentFolderPath, 'name' => (string)$asset_xml->name, 'path' => (string)$asset_xml->path, 'shouldBeIndexed' => (string)$xasset_ml->shouldBeIndexed, 'shouldBePublished' => (string)$asset_xml->shouldBePublished ); if($type == 'page'){ $params['asset']['page']['xhtml'] = (string)$asset_xml->xhtml; } else if($type == 'file'){ $params['asset']['file']['data'] = (string)$asset_xml->data; $params['asset']['file']['text'] = (string)$asset_xml->text; } else if($type == 'symlink'){ $params['asset']['symlink']['linkURL'] = (string)$asset_xml->linkURL; } $metadata = array(); if (count($asset_xml->metadata->author->attributes()) == 0) $metadata['author'] = (string)$asset_xml->metadata->author; if (count($asset_xml->metadata->displayName->attributes()) == 0) $metadata['displayName'] = (string)$asset_xml->metadata->displayName; if (count($asset_xml->metadata->endDate->attributes()) == 0) $metadata['endDate'] = (string)$asset_xml->metadata->endDate; if (count($asset_xml->metadata->keywords->attributes()) == 0) $metadata['keywords'] = (string)$asset_xml->metadata->keywords; if (count($asset_xml->metadata->metaDescription->attributes()) == 0) $metadata['metaDescription'] = (string)$asset_xml->metadata->metaDescription; if (count($asset_xml->metadata->reviewDate->attributes()) == 0) $metadata['reviewDate'] = changeReviewDate((string)$asset_xml->metadata->reviewDate); if (count($asset_xml->metadata->startDate->attributes()) == 0) $metadata['startDate'] = (string)$asset_xml->metadata->startDate; if (count($asset_xml->metadata->summary->attributes()) == 0) $metadata['summary'] = (string)$asset_xml->metadata->summary; if (count($asset_xml->metadata->teaser->attributes()) == 0) $metadata['teaser'] = (string)$asset_xml->metadata->teaser; if (count($asset_xml->metadata->title->attributes()) == 0) $metadata['title'] = (string)$asset_xml->metadata->title; $params['asset']["$type"]['metadata'] = $metadata; if ($xml->structuredData->definitionId) { $datadef = array(); $datadef['definitionId'] = (string)$asset_xml->structuredData->definitionId; $datadef['definitionPath'] = (string)$asset_xml->structuredData->definitionPath; $datadef['structuredDataNodes'] = array(); $datadef['structuredDataNodes']['structuredDataNode'] = get_structured_nodes($asset_xml->structuredData->structuredDataNodes); $params['asset']['page']['structuredData'] = $datadef; } try { $response = $client->edit($params); } catch (Exception $e) { print_r($client->__getLastRequest()); print_r($client->__getLastResponse()); //$mesg = $config->get_var("strings.edit_error"); return FALSE; } if ($response->editReturn->success != "true") { print_r($client->__getLastRequest()); print_r($client->__getLastResponse()); //$mesg = $config->get_var("strings.edit_error"); return FALSE; } return TRUE; } function get_structured_nodes($xml) { $datadef = array(); foreach($xml->structuredDataNodes as $node) { $new_node = array(); $text = true; if (count($node->blockId->attributes()) == 0) { $new_node['blockId'] = (string)$node->blockId; $text = false; } if (count($node->blockPath->attributes()) == 0) { $new_node['blockPath'] = (string)$node->blockPath; $text = false; } if (count($node->fileId->attributes()) == 0) { $new_node['fileId'] = (string)$node->fileId; $text = false; } if (count($node->filePath->attributes()) == 0) { $new_node['filePath'] = (string)$node->filePath; $text = false; } if (count($node->pageId->attributes()) == 0) { $new_node['pageId'] = (string)$node->pageId; $text = false; } if (count($node->pagePath->attributes()) == 0) { $new_node['pagePath'] = (string)$node->pagePath; $text = false; } if (count($node->symlinkId->attributes()) == 0) { $new_node['symlinkId'] = (string)$node->symlinkId; $text = false; } if (count($node->symlinkPath->attributes()) == 0) { $new_node['symlinkPath'] = (string)$node->symlinkPath; $text = false; } if (count($node->structuredDataNodes->attributes()) == 0) { $new_node['structuredDataNodes'] = array(); $new_node['structuredDataNodes']['structuredDataNode'] = get_structured_nodes($node->structuredDataNodes); $text = false; } if ($text == true && count($node->text->attributes()) == 0) $new_node['text'] = s((string)$node->text); if (count($node->identifier->attributes()) == 0) $new_node['identifier'] = (string)$node->identifier; if (count($node->symlinkId->attributes()) == 0) $new_node['symlinkId'] = (string)$node->symlinkId; if (count($node->type->attributes()) == 0) $new_node['type'] = (string)$node->type; if ($new_node['type'] == "text" && !isset($new_node['text'])) $new_node['text'] = ""; if ($new_node['type'] == "asset" && !isset($new_node['filePath']) && !isset($new_node['fileId']) && !isset($new_node['symlinkPath']) && !isset($new_node['symlinkId']) && !isset($new_node['blockPath']) && !isset($new_node['blockId']) && !isset($new_node['pagePath']) && !isset($new_node['pageId'])) { $new_node['filePath'] = ""; } $datadef[] = $new_node; } return $datadef; } /** * Returns the date that is $month_difference number of months in advance of (or behind) $date. */ function changeReviewDate($date) { $month_difference = 6; $year = intval(substr($date, 0, 4)); $month = intval(substr($date, 5, 2)); $new_month = (($month - 1 + $month_difference) % 12) + 1; $new_month = ($new_month < 10) ? "0".$new_month : $new_month; $year += intval(floor(($month - 1 + $month_difference) / 12)); $rest_of_date = substr($date, 7); $new_date = $year."-".$new_month.$rest_of_date; //echo "\$date = $date\n
"; //echo "\$new_date = $new_date\n
"; return $new_date; } /** * Retrieve an array of SimpleXML Objects for all the CMS assets contained * within the system-folder with the provided $path. */ function read_folder($path, $client) { global $cascade_server, $cascade_user, $cascade_password; $params = array ( 'authentication' => array ( 'username' => $cascade_user, 'password' => $cascade_password ), 'identifier' => array ( 'path' => $path, 'type' => "folder" ) ); try { $response = $client->read($params); } catch(Exception $e) { //$mesg = $config->get_var("strings.read_error"); new Error($mesg); return FALSE; } $xml = $client->__getLastResponse(); preg_match("&.*&is", $xml, $matches); $simplexml = simplexml_load_string($matches[0], 'SimpleXMLElement', LIBXML_NOCDATA); return $simplexml; } /** * Import a user into the Cascade instance with the provided SimpleXML Object * containing the user's information. */ function importUser($user) { global $cascade_user, $cascade_password, $authType, $enableUsers, $client; $params = array ( 'authentication' => array ( 'username' => $cascade_user, 'password' => $cascade_password ), 'asset' => array( 'user' => array() ) ); $params['asset']['user']['username'] = (string)$user->username; $params['asset']['user']['fullName'] = (string)$user->fullName; $params['asset']['user']['email'] = (string)$user->email; $params['asset']['user']['authType'] = $authType; $params['asset']['user']['password'] = (string)$user->password; $params['asset']['user']['enabled'] = $enableUsers; $params['asset']['user']['groups'] = (string)$user->groups; if((string)$user->defaultGroup != '') $params['asset']['user']['defaultGroup'] = (string)$user->defaultGroup; $params['asset']['user']['role'] = (string)$user->role; try { $response = $client->create($params); } catch(Exception $e) { print_r($client->__getLastRequest()); print_r($client->__getLastResponse()); //$mesg = $config->get_var("strings.edit_error"); return FALSE; } if($response->editReturn->success != "true") { print_r($client->__getLastRequest()); print_r($client->__getLastResponse()); //$mesg = $config->get_var("strings.edit_error"); return FALSE; } return TRUE; } /** * Import a group into the Cascade instance with the provided SimpleXML Object * containing the group's information. */ function importGroup($group) { global $cascade_user, $cascade_password, $client; $params = array ( 'authentication' => array ( 'username' => $cascade_user, 'password' => $cascade_password ), 'asset' => array ( 'group' => array() ) ); $params['asset']['group']['groupName'] = (string)$group->groupName; if((string)$group->groupStartingPageId != '') $params['asset']['group']['groupStartingPageId'] = (string)$group->groupStartingPageId; elseif((string)$group->groupStartingPagePath != '') $params['asset']['group']['groupStartingPagePath'] = (string)$group->groupStartingPagePath; if((string)$group->groupBaseFolderId != '') $params['asset']['group']['groupBaseFolderId'] = (string)$group->groupBaseFolderId; elseif((string)$group->groupBaseFolderPath != '') $params['asset']['group']['groupBaseFolderPath'] = (string)$group->groupBaseFolderPath; if((string)$group->groupAssetFactoryContainerId != '') $params['asset']['group']['groupAssetFactoryContainerId'] = (string)$group->groupAssetFactoryContainerId; elseif((string)$group->groupAssetFactoryContainerPath != '') $params['asset']['group']['groupAssetFactoryContainerPath'] = (string)$group->groupAssetFactoryContainerPath; if((string)$group->cssClasses != '') $params['asset']['group']['cssClasses'] = (string)$group->cssClasses; if((string)$group->wysiwygAllowFontAssignment != '') $params['asset']['group']['wysiwygAllowFontAssignment'] = (strtolower((string)$group->wysiwygAllowFontAssignment) == 'true') ? "true" : "false"; if((string)$group->wysiwygAllowFontFormatting != '') $params['asset']['group']['wysiwygAllowFontFormatting'] = (strtolower((string)$group->wysiwygAllowFontFormatting) == 'true') ? "true" : "false"; if((string)$group->wysiwygAllowTextFormatting != '') $params['asset']['group']['wysiwygAllowTextFormatting'] = (strtolower((string)$group->wysiwygAllowTextFormatting) == 'true') ? "true" : "false"; if((string)$group->wysiwygAllowViewSource != '') $params['asset']['group']['wysiwygAllowViewSource'] = (strtolower((string)$group->wysiwygAllowViewSource) == 'true') ? "true" : "false"; if((string)$group->wysiwygAllowImageInsertion != '') $params['asset']['group']['wysiwygAllowImageInsertion'] = (strtolower((string)$group->wysiwygAllowImageInsertion) == 'true') ? "true" : "false"; if((string)$group->wysiwygAllowTableInsertion != '') $params['asset']['group']['wysiwygAllowTableInsertion'] = (strtolower((string)$group->wysiwygAllowTableInsertion) == 'true') ? "true" : "false"; $params['asset']['group']['role'] = (string)$group->role; try { $response = $client->create($params); } catch(Exception $e) { print_r($client->__getLastRequest()); print_r($client->__getLastResponse()); //$mesg = $config->get_var("strings.edit_error"); return FALSE; } if($response->editReturn->success != "true") { print_r($client->__getLastRequest()); print_r($client->__getLastResponse()); //$mesg = $config->get_var("strings.edit_error"); return FALSE; } return TRUE; } echo "Done."; ?>