{"cms-login-info"}->server; // The location of the Cascade instance $cascade_user = $xml_config->{"cms-login-info"}->username; // The username to login to the Cascade instance above $cascade_password = $xml_config->{"cms-login-info"}->password; // The username's password $update_folder = $xml_config->{"update-folder"}; // The folder whose assets need their review-date updated $month_difference = $xml_config->{"month-difference"}; // The month difference to update each asset's review-date with $idStack = array(); // Construct a SOAP client connecting to Cascade instance $serv = new AssetOperationHandlerService(); $serv->url = "$cascade_server/ws/services/AssetOperationService?wsdl"; $auth = new authentication(); $auth->username = "$cascade_user"; $auth->password = "$cascade_password"; $id = new identifier(); $id->path = "$update_folder"; $id->type = "folder"; readAsset($id); /** * Reads the asset with the given id, then writes it back out with a changed reviewDate, if applicable * Also, if it's a folder, it then goes deeper and does the same. Reflections are fun/efficient, so I went * ahead and used them for grabbing the assets */ function readAsset($id) { global $serv; global $auth; global $idStack; $serv->read($auth, $id); //if the read was successfull... if (isset ($serv->asset)) { //grab the current asset $asset = $serv->asset; $reflect = new ReflectionObject($asset); $vars = $reflect->getProperties(); for ($i = 0; $i < count($vars); $i++) { if ($vars[$i]->name != 'fullXML') { $curVar = $reflect->getProperty($vars[$i]->name)->getValue($asset); if (isset($curVar)) { //grab its metadata $meta = $curVar->metadata; //if the meta reviewDate != "" if ($meta->reviewDate != "") { //change it $meta->reviewDate = changeReviewDate($meta->reviewDate); //and write back out $serv->edit($auth, $asset); } //now if we're on a folder... if ($vars[$i]->name == 'folder') { //iterate over the children if (isset ($asset->folder->children)) { foreach ($asset->folder->children->child as $id) { //If they're of a type that has metadata, add it if ($id->type == "feedBlock" || $id->type == "file" || $id->type == "folder" || $id->type == "indexBlock" || $id->type == "page" || $id->type == "symlink" || $id->type == "textBlock" || $id->type == "xhtmlBlock" || $id->type == "xmlBlock") { $idStack []= $id; } while ($id = array_pop($idStack)) { readAsset($id); } } } } } } } } } /** * Returns the date that is $month_difference number of months in advance of (or behind) $date. */ function changeReviewDate($date) { global $month_difference; $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; } echo "Done."; ?>