function feZMetaData_ContentActionHandler( &$module, &$http, &$objectID )
{
	// Action when user clicks on the Add Button
	if( $http->hasPostVariable( 'AddMetaDataButton' ) )
	{
		$link = 'fezmetadata/edit/0/(contentObjectID)/'.$objectID;
		$link .= '/(metaDataName)/'.$_POST['metaDataName'];
		$link .= '/(language)/'.$_POST['language'];
		eZURI::transformURI( $link );
		$http->redirect( $link );
	}

	// Action when user clicks on the Remove Button
	if( $http->hasPostVariable( 'RemoveMetaDataButton' ) and $http->hasPostVariable( 'MetaDataIDSelection' ) )
	{
		$metaDataSelection = $http->postVariable( 'MetaDataIDSelection' );
		foreach( $metaDataSelection as $metaData )
		{
			$metaDataObject = feZMetaData::fetch( $metaData );
			$metaDataObject->remove();
		}
		eZContentCacheManager::clearContentCache( $objectID );
		$ContentObject = eZContentObject::fetch( $objectID );
		$ContentNodeID = $ContentObject->mainNodeID();
		return $module->redirect( 'content', 'view', array( 'full', $ContentNodeID ) );
	}
}
    /**
     * Updating priority sorting for given node
     *
     * @param mixed $args
     * @return array
     */
    public static function updatePriority( $args )
    {
        $http = eZHTTPTool::instance();

        if ( !$http->hasPostVariable('ContentNodeID')
                || !$http->hasPostVariable('PriorityID')
                    || !$http->hasPostVariable('Priority') )
        {
            return array();
        }

        $contentNodeID = $http->postVariable('ContentNodeID');
        $priorityArray = $http->postVariable('Priority');
        $priorityIDArray = $http->postVariable('PriorityID');

        $contentNode = eZContentObjectTreeNode::fetch( $contentNodeID );
        if ( !$contentNode->attribute( 'can_edit' ) )
        {
            eZDebug::writeError( 'Current user can not update the priorities because he has no permissions to edit the node' );
            return array();
        }

        if ( eZOperationHandler::operationIsAvailable( 'content_updatepriority' ) )
        {
            $operationResult = eZOperationHandler::execute( 'content', 'updatepriority',
                                                             array( 'node_id' => $contentNodeID,
                                                                    'priority' => $priorityArray,
                                                                    'priority_id' => $priorityIDArray ), null, true );
        }
        else
        {
            eZContentOperationCollection::updatePriority( $contentNodeID, $priorityArray, $priorityIDArray );
        }

        if ( $http->hasPostVariable( 'ContentObjectID' ) )
        {
            $objectID = $http->postVariable( 'ContentObjectID' );
            eZContentCacheManager::clearContentCache( $objectID );
        }
    }
    /**
     * @param eZWorkflowProcess $process
     * @param eZWorkflowEvent $event
     * @return int
     */
    function execute( $process, $event )
    {
        // Get some information about the object being passed
        $parameters = $process->attribute( 'parameter_list' );
        $object     = eZContentObject::fetch( $parameters['object_id'] );

        if($object->ClassIdentifier != 'article')
            return self::STATUS_ACCEPTED;

        /* @type $dataMap eZContentObjectAttribute[] */
        $dataMap = $object->dataMap();

        if(isset($dataMap['source']))
        {
            $sourceString = MMNewsSource::getSourceString($object);
            if($sourceString)
            {
                $dataMap['source']->setAttribute('data_text', $sourceString);
                $dataMap['source']->store();
            }
            eZContentCacheManager::clearContentCache($object->attribute('id'));
        }
        return self::STATUS_ACCEPTED;
    }
 /**
  * Changes the sort order for a node
  *
  * @param int $nodeID
  * @param string $sortingField
  * @param bool $sortingOrder
  *
  * @return array An array with operation status, always true
  */
 public static function changeSortOrder($nodeID, $sortingField, $sortingOrder = false)
 {
     $curNode = eZContentObjectTreeNode::fetch($nodeID);
     if (is_object($curNode)) {
         $db = eZDB::instance();
         $db->begin();
         $curNode->setAttribute('sort_field', $sortingField);
         $curNode->setAttribute('sort_order', $sortingOrder);
         $curNode->store();
         $db->commit();
         $object = $curNode->object();
         eZContentCacheManager::clearContentCache($object->attribute('id'));
     }
     return array('status' => true);
 }
         if (!$contentNode->attribute('can_edit')) {
             eZDebug::writeError('Current user can not update the priorities because he has no permissions to edit the node');
             $module->redirectTo($module->functionURI('view') . '/' . $viewMode . '/' . $contentNodeID . '/');
             return;
         }
         $priorityArray = $http->postVariable('Priority');
         $priorityIDArray = $http->postVariable('PriorityID');
         if (eZOperationHandler::operationIsAvailable('content_updatepriority')) {
             $operationResult = eZOperationHandler::execute('content', 'updatepriority', array('node_id' => $contentNodeID, 'priority' => $priorityArray, 'priority_id' => $priorityIDArray), null, true);
         } else {
             eZContentOperationCollection::updatePriority($contentNodeID, $priorityArray, $priorityIDArray);
         }
     }
     if ($http->hasPostVariable('ContentObjectID')) {
         $objectID = $http->postVariable('ContentObjectID');
         eZContentCacheManager::clearContentCache($objectID);
     }
     if ($http->hasPostVariable('RedirectURIAfterPriority')) {
         return $module->redirectTo($http->postVariable('RedirectURIAfterPriority'));
     }
     $module->redirectTo($module->functionURI('view') . '/' . $viewMode . '/' . $contentNodeID . '/');
     return;
 } else {
     if ($http->hasPostVariable("ActionAddToBookmarks")) {
         $user = eZUser::currentUser();
         $nodeID = false;
         if ($http->hasPostVariable('ContentNodeID')) {
             $nodeID = $http->postVariable('ContentNodeID');
             $node = eZContentObjectTreeNode::fetch($nodeID);
             $bookmark = eZContentBrowseBookmark::createNew($user->id(), $nodeID, $node->attribute('name'));
         }
 /**
  * Forza l'impostazione del colore di base di un site
  * 
  * Ritorna true se il colore è stato modificato
  * 
  * @param int $currentColor
  * @return boolean
  */
 public static function forceSiteColor($currentColor)
 {
     //
     // lettura variabili per individuare file scss
     $designINIinstance = eZINI::instance('design.ini', 'settings', null, FALSE);
     $_stylesheetBaseFile = $designINIinstance->variable('StylesheetSettings', 'StylesheetBaseFile');
     $_stylesheetDestFile = $designINIinstance->variable('StylesheetSettings', 'StylesheetDestinationFile');
     $_stylesheetCluster = $designINIinstance->variable('StylesheetSettings', 'StylesheetCluster');
     // Cicla sui file di origine
     for ($i = 0; $i < count($_stylesheetBaseFile); $i++) {
         foreach ($_stylesheetCluster as $itemCluster) {
             // File da sostituire.
             $curFile = $itemCluster . $_stylesheetBaseFile[$i];
             $curDestinationFile = $itemCluster . $_stylesheetDestFile[$i];
             //print_r('File :<br><b>');
             //print_r($curFile);
             //print_r('<br>in:<br><b>');
             //print_r($curDestinationFile);
             //die();
             // recupera i valori del eZPersistentObject sinet_site_colors
             $colorList = Sinetsitecolors_PstObject::fetchHandlerList();
             $fh = fopen($curFile, 'r');
             $newRow = '';
             // Legge ogni singola riga del file origine
             $arrayOriginalColor = explode("-", $currentColor);
             while (!feof($fh)) {
                 $tmpRow = fgets($fh);
                 $indiceColore = 0;
                 foreach ($colorList as $objColor) {
                     // per ogni riga del pesisten object sostituisce il name_tag con il colore letto
                     $curname_tag = $objColor['name_tag'];
                     if (count($arrayOriginalColor) > $indiceColore) {
                         $tmpRow = PatBaseColorFunctions::replaceCssInLine($tmpRow, $arrayOriginalColor[$indiceColore], $curname_tag);
                     }
                     $indiceColore++;
                 }
                 $newRow .= $tmpRow;
             }
             // set del colore nel persistent object
             $indiceColore = 0;
             foreach ($colorList as $objColor) {
                 $curname_tag = $objColor['name_tag'];
                 $curId = $objColor['id'];
                 if (count($arrayOriginalColor) > $indiceColore) {
                     $simpleObj = Sinetsitecolors_PstObject::fetchById($curId);
                     $simpleObj->setAttribute('color', $arrayOriginalColor[$indiceColore]);
                     $simpleObj->store();
                 }
                 $indiceColore++;
             }
             // Scrive il file di destinazione
             $fw = fopen($curDestinationFile, 'w');
             if (!$fw) {
                 echo '</b><font color=red>Errore Open W</font></pre>';
             } else {
                 $bytes = fwrite($fw, $newRow);
                 fclose($fw);
             }
             fclose($fh);
             // echo('</b><font color=red>OK</font></pre>');
         }
     }
     // Prova la pulizia della cache dei template
     eZContentCacheManager::clearAllContentCache();
     eZContentCacheManager::clearContentCache(2);
     //die();
     return true;
 }
Exemple #7
0
 /**
  * Do all time based operations on block pool such as rotation, updating
  * the queue, overflow as well as executes fetch interfaces.
  *
  * @static
  */
 public static function update($nodeArray = array())
 {
     // log in user as anonymous if another user is logged in
     $currentUser = eZUser::currentUser();
     if ($currentUser->isLoggedIn()) {
         $loggedInUser = $currentUser;
         $anonymousUserId = eZUser::anonymousId();
         $anonymousUser = eZUser::instance($anonymousUserId);
         eZUser::setCurrentlyLoggedInUser($anonymousUser, $anonymousUserId);
         unset($currentUser, $anonymousUser, $anonymousUserId);
     }
     include_once 'kernel/classes/ezcontentcache.php';
     $ini = eZINI::instance('block.ini');
     $db = eZDB::instance();
     // Remove the blocks and items for the block if marked for removal
     $res = $db->arrayQuery("SELECT id\n                         FROM ezm_block\n                         WHERE is_removed=1");
     foreach ($res as $row) {
         $blockID = $row['id'];
         $db->begin();
         $db->query("DELETE FROM ezm_pool\n                 WHERE block_id='{$blockID}'");
         $db->query("DELETE FROM ezm_block\n                 WHERE id='{$blockID}'");
         $db->commit();
     }
     if (!$nodeArray) {
         // Update pool and pages for all nodes
         $res = $db->arrayQuery("SELECT DISTINCT node_id FROM ezm_block");
         foreach ($res as $row) {
             $nodeArray[] = $row['node_id'];
         }
     }
     foreach ($nodeArray as $nodeID) {
         $time = time() - 5;
         // a safety margin
         $nodeChanged = false;
         $blocks = $db->arrayQuery("SELECT *\n                                FROM ezm_block\n                                WHERE node_id={$nodeID}");
         $blockByID = array();
         // Determine the order of updating
         $correctOrder = array();
         $next = array();
         foreach ($blocks as $block) {
             $next[$block['id']] = trim($block['overflow_id']);
             // Make sure that block ID does not any have spaces
             $blockByID[$block['id']] = $block;
         }
         $nextIDs = array_keys($next);
         foreach ($nextIDs as $id) {
             if (in_array($id, $correctOrder, true)) {
                 continue;
             }
             if (!$next[$id]) {
                 $correctOrder[] = $id;
                 continue;
             }
             $subCorrectOrder = array($id);
             $currentID = $id;
             while ($nextID = $next[$currentID]) {
                 if (!in_array($nextID, $nextIDs, true)) {
                     eZDebug::writeWarning("Overflow for {$currentID} is {$nextID}, but no such block was found for the given node", __METHOD__);
                     break;
                 }
                 if (in_array($nextID, $subCorrectOrder, true)) {
                     eZDebug::writeWarning("Loop detected, ignoring ({$nextID} should be after {$currentID} and vice versa)", __METHOD__);
                     break;
                 }
                 if (in_array($nextID, $correctOrder, true)) {
                     break;
                 }
                 $subCorrectOrder[] = $nextID;
                 $currentID = $nextID;
             }
             if (!$nextID || !in_array($nextID, $correctOrder, true)) {
                 foreach ($subCorrectOrder as $element) {
                     $correctOrder[] = $element;
                 }
             } else {
                 $newCorrectOrder = array();
                 foreach ($correctOrder as $element) {
                     if ($element === $nextID) {
                         foreach ($subCorrectOrder as $element2) {
                             $newCorrectOrder[] = $element2;
                         }
                     }
                     $newCorrectOrder[] = $element;
                 }
                 $correctOrder = $newCorrectOrder;
             }
         }
         // Loop through all block in determined order
         foreach ($correctOrder as $blockID) {
             if ($blockByID[$blockID]) {
                 $block = $blockByID[$blockID];
             } else {
                 continue;
             }
             // Do we need to update block? No, continue to process next block
             $ttl = 0;
             if ($ini->hasVariable($block['block_type'], 'TTL')) {
                 $ttl = $ini->variable($block['block_type'], 'TTL');
             }
             if ($ttl + $block['last_update'] >= $time) {
                 continue;
             }
             // For "rotating blocks", does the rotation_interval has passed from the last update?
             if ($block['rotation_type'] != self::ROTATION_NONE && $block['last_update'] + $block['rotation_interval'] >= $time) {
                 continue;
             }
             $blockChanged = false;
             // Fetch new objects and add them to the queue of the current block
             eZFlowOperations::updateBlockPoolByBlockID($block, $time);
             $db->begin();
             // We need to find out if there are any items to move from the queue
             $movingFromQueue = $db->arrayQuery("SELECT object_id\n                                             FROM ezm_pool\n                                             WHERE block_id='{$blockID}'\n                                               AND ts_visible=0\n                                               AND ts_hidden=0\n                                               AND ts_publication<={$time}\n                                             ORDER BY ts_publication ASC, priority ASC");
             if ($movingFromQueue) {
                 $blockChanged = true;
                 // Find out a number of items in "valid" state and the max. priority used
                 $countMaxPriorityValid = $db->arrayQuery("SELECT count(*) AS count, max(priority) AS priority\n                                                       FROM ezm_pool\n                                                       WHERE block_id='{$blockID}'\n                                                         AND ts_visible>0\n                                                         AND ts_hidden=0");
                 $countValid = $countMaxPriorityValid[0]['count'];
                 $maxPriorityValid = $countMaxPriorityValid[0]['priority'];
                 if ($countValid == 0) {
                     $maxPriorityValid = 0;
                 }
                 $priority = $maxPriorityValid + 1;
                 // Move objects waiting in queue to the "valid ones"
                 foreach ($movingFromQueue as $itemToMove) {
                     $objectID = $itemToMove['object_id'];
                     $db->query("UPDATE ezm_pool\n                             SET ts_visible={$time}, priority={$priority}\n                             WHERE block_id='{$blockID}'\n                               AND object_id={$objectID}");
                     $priority++;
                 }
                 $countValid += count($movingFromQueue);
                 // Compare this number to the given and archive the oldest (order by ts_visible)
                 $numberOfValidItems = $ini->variable($block['block_type'], 'NumberOfValidItems');
                 if (!$numberOfValidItems) {
                     $numberOfValidItems = 20;
                     eZDebug::writeWarning('Number of valid items for ' . $block['block_type'] . ' is not set; using the default value (' . $numberOfValidItems . ')', __METHOD__);
                 }
                 $countToRemove = $countValid - $numberOfValidItems;
                 if ($countToRemove > 0) {
                     $overflowID = $block['overflow_id'];
                     $items = $db->arrayQuery("SELECT node_id, object_id, rotation_until\n                                           FROM ezm_pool\n                                           WHERE block_id='{$blockID}'\n                                             AND ts_visible>0\n                                             AND ts_hidden=0\n                                           ORDER BY priority ASC", array('limit' => $countToRemove));
                     if ($items) {
                         $itemArray = array();
                         $priority = 0;
                         foreach ($items as $item) {
                             $objectID = $item['object_id'];
                             if ($block['rotation_type'] != self::ROTATION_NONE && ($item['rotation_until'] > $time || $item['rotation_until'] == 0)) {
                                 if ($block['rotation_type'] == self::ROTATION_SIMPLE) {
                                     // Simple rotation
                                     $newPublicationTS = -$time;
                                     $priority++;
                                 } else {
                                     // Random rotation/Shuffle
                                     $newPublicationTS = 0;
                                     $priority = mt_rand();
                                 }
                                 // Move item back to queue
                                 $db->query("UPDATE ezm_pool\n                                         SET ts_visible=0,\n                                             ts_publication=-{$time},\n                                             priority={$priority}\n                                         WHERE block_id='{$blockID}'\n                                           AND object_id={$objectID}");
                             } else {
                                 $itemArray[] = $objectID;
                             }
                         }
                         if ($itemArray) {
                             if ($overflowID) {
                                 // Put $itemArray items into pool of different block
                                 $priority = 0;
                                 foreach ($items as $item) {
                                     $itemObjectID = $item['object_id'];
                                     $itemNodeID = $item['node_id'];
                                     // Check if the object_id is not already in the new block
                                     $duplicityCheck = $db->arrayQuery("SELECT object_id\n                                                                    FROM ezm_pool\n                                                                    WHERE block_id='{$overflowID}'\n                                                                      AND object_id={$itemObjectID}", array('limit' => 1));
                                     if ($duplicityCheck) {
                                         eZDebug::writeNotice("Object {$itemObjectID} is already available in the block {$overflowID}.", __METHOD__);
                                     } else {
                                         $db->query("INSERT INTO ezm_pool(block_id,object_id,node_id,ts_publication,priority)\n                                                 VALUES ('{$overflowID}',{$itemObjectID},{$itemNodeID},{$time},{$priority})");
                                         $priority++;
                                     }
                                 }
                                 $db->query("UPDATE ezm_pool\n                                         SET ts_hidden={$time},\n                                             moved_to='{$overflowID}',\n                                             priority=0\n                                         WHERE block_id='{$blockID}'\n                                           AND " . $db->generateSQLINStatement($itemArray, 'object_id'));
                             } else {
                                 $db->query("UPDATE ezm_pool\n                                         SET ts_hidden={$time},\n                                             priority=0\n                                         WHERE block_id='{$blockID}'\n                                           AND " . $db->generateSQLINStatement($itemArray, 'object_id'));
                             }
                         }
                     }
                 }
                 // Cleanup in archived items
                 $countArchived = $db->arrayQuery("SELECT count(*) AS count\n                                               FROM ezm_pool\n                                               WHERE block_id='{$blockID}'\n                                                 AND ts_hidden>0");
                 $countArchived = $countArchived[0]['count'];
                 // Compare this number to the given and remove the oldest ones
                 $numberOfArchivedItems = $ini->variable($block['block_type'], 'NumberOfArchivedItems');
                 if ($numberOfArchivedItems < 0) {
                     $numberOfArchivedItems = 50;
                     eZDebug::writeWarning('Number of archived items for ' . $block['block_type'] . ' is not set; using the default value (' . $numberOfArchivedItems . ')', __METHOD__);
                 }
                 $countToRemove = $countArchived - $numberOfArchivedItems;
                 if ($countToRemove > 0) {
                     $items = $db->arrayQuery("SELECT object_id\n                                           FROM ezm_pool\n                                           WHERE block_id='{$blockID}'\n                                             AND ts_hidden>0\n                                           ORDER BY ts_hidden ASC", array('limit' => $countToRemove));
                     if ($items) {
                         $itemArray = array();
                         foreach ($items as $item) {
                             $itemArray[] = $item['object_id'];
                         }
                         $db->query("DELETE FROM ezm_pool\n                                 WHERE block_id='{$blockID}'\n                                   AND " . $db->generateSQLINStatement($itemArray, 'object_id'));
                     }
                 }
             }
             // If the block changed, we need to update whole node
             if ($blockChanged) {
                 $nodeChanged = true;
             }
             $db->commit();
         }
         if ($nodeChanged) {
             $contentObject = eZContentObject::fetchByNodeID($nodeID);
             if ($contentObject) {
                 eZContentCacheManager::clearContentCache($contentObject->attribute('id'));
             }
         }
     }
     // log the previously logged in user if it was changed to anonymous earlier
     if (isset($loggedInUser)) {
         eZUser::setCurrentlyLoggedInUser($loggedInUser, $loggedInUser->attribute('contentobject_id'));
     }
 }
            $cli->output("Clearing cache for subtree {$nodeName} ({$nodeSubtree})");
            $objectID = $node->attribute('contentobject_id');
            $offset = 0;
            $params = array('AsObject' => false, 'Depth' => false, 'Limitation' => array());
            // Empty array means no permission checking
            $subtreeCount = $node->subTreeCount($params);
            $script->resetIteration($subtreeCount / $limit);
            while ($offset < $subtreeCount) {
                $params['Offset'] = $offset;
                $params['Limit'] = $limit;
                $subtree = $node->subTree($params);
                $offset += count($subtree);
                if (count($subtree) == 0) {
                    break;
                }
                $objectIDList = array();
                foreach ($subtree as $subtreeNode) {
                    $objectIDList[] = $subtreeNode['contentobject_id'];
                }
                $objectIDList = array_unique($objectIDList);
                unset($subtree);
                $script->iterate($cli, eZContentCacheManager::clearContentCache($objectIDList), "Cleared view cache for object(s): " . implode(", ", $objectIDList));
                eZContentObject::clearCache();
                // Clear all object memory cache to free memory
            }
        }
        $script->shutdown(0);
    }
}
$cli->output("You will need to specify what to clear, either with --clear-node or --clear-subtree");
$script->shutdown(1);
 /**
  * Updating priority sorting for given node
  *
  * @since 1.2
  * @param mixed $args
  * @return array
  */
 public static function updatePriority($args)
 {
     $http = eZHTTPTool::instance();
     if (!$http->hasPostVariable('ContentNodeID') || !$http->hasPostVariable('PriorityID') || !$http->hasPostVariable('Priority')) {
         return array();
     }
     $contentNodeID = $http->postVariable('ContentNodeID');
     $priorityArray = $http->postVariable('Priority');
     $priorityIDArray = $http->postVariable('PriorityID');
     $contentNode = eZContentObjectTreeNode::fetch($contentNodeID);
     if (!$contentNode instanceof eZContentObjectTreeNode) {
         throw new InvalidArgumentException("Argument ContentNodeID: '{$contentNodeID}' does not exist");
     } else {
         if (!$contentNode->canEdit()) {
             throw new InvalidArgumentException("Argument ContentNodeIDs: '{$contentNodeID}' is not available");
         }
     }
     if (eZOperationHandler::operationIsAvailable('content_updatepriority')) {
         $operationResult = eZOperationHandler::execute('content', 'updatepriority', array('node_id' => $contentNodeID, 'priority' => $priorityArray, 'priority_id' => $priorityIDArray), null, true);
     } else {
         eZContentOperationCollection::updatePriority($contentNodeID, $priorityArray, $priorityIDArray);
     }
     if ($http->hasPostVariable('ContentObjectID')) {
         $objectID = $http->postVariable('ContentObjectID');
         eZContentCacheManager::clearContentCache($objectID);
     }
 }
 function execute($process, $event)
 {
     // Get some information about the object being passed
     $parameters = $process->attribute('parameter_list');
     $object = eZContentObject::fetch($parameters['object_id']);
     // Because this is also run by the cronjob, check to make sure the object hasn't been deleted
     if (!$object) {
         eZDebugSetting::writeError('workflow-hideuntildate', 'The object with ID ' . $parameters['object_id'] . ' does not exist.', 'eZApproveType::execute() object is unavailable');
         return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     // if the current version of an object is not the version the workflow pertains to, cancel the workflow
     $currentVersion = $object->attribute('current_version');
     $version = $parameters['version'];
     if ($currentVersion != $version) {
         return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     // Get the data map for this object
     $objectAttributes = $object->attribute('data_map');
     // Get the user configuration with class and attribute mapping and the boolean modify publish date setting
     $workflowSettings = $this->getWorkflowSettings($event);
     foreach ($objectAttributes as $objectAttribute) {
         if (in_array($objectAttribute->attribute('contentclassattribute_id'), $workflowSettings['classattribute_map'])) {
             // Make sure this is of a date or datetime attribute
             if (in_array($objectAttribute->attribute('data_type_string'), array('ezdate', 'ezdatetime'))) {
                 // If the publish date is in the future, hide the node
                 if (time() < $objectAttribute->toString()) {
                     // Set a time for when this workflow should be tested again via the cronjob
                     // Store a description to be displayed in the Setup > Workflow processes list
                     // This must also be accompanied by overriding the workflow/processlist.tpl template
                     $parameters = array_merge($parameters, array('event_description' => 'Publishing of object delayed until ' . $objectAttribute->attribute('content')->toString(true)));
                     $process->setParameters($parameters);
                     $process->store();
                     // Hide the object's nodes
                     $nodes = $object->attribute('assigned_nodes');
                     foreach ($nodes as $node) {
                         if (!$node->attribute('is_hidden')) {
                             eZContentObjectTreeNode::hideSubTree($node);
                         }
                     }
                     return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
                 } elseif ($objectAttribute->hasContent()) {
                     if ($workflowSettings['modify_publish_date']) {
                         $object->setAttribute('published', $objectAttribute->toString());
                         $object->store();
                     }
                     $nodes = $object->attribute('assigned_nodes');
                     foreach ($nodes as $node) {
                         eZContentObjectTreeNode::unhideSubTree($node);
                         eZContentCacheManager::clearContentCache($parameters['object_id']);
                         eZContentCacheManager::clearObjectViewCache($parameters['object_id']);
                     }
                     return eZWorkflowType::STATUS_ACCEPTED;
                 }
             } else {
                 // Attribute that matched was not a valid date or datetime attribute, so ignore
                 return eZWorkflowType::STATUS_ACCEPTED;
             }
         }
     }
     // No attributes matched the workflow configured by the user
     return eZWorkflowType::STATUS_ACCEPTED;
 }
Exemple #11
0
            $remoteIDNodeList = $http->postVariable($inputNodeListName);
            foreach ($object->attribute('assigned_nodes') as $node_item) {
                $node_item_id = $node_item->attribute('node_id');
                if (isset($remoteIDNodeList[$node_item_id]) && jcRemoteID::isValidNodeRemoteID($remoteIDNodeList[$node_item_id], $node_item_id, $errors)) {
                    $node_item->setAttribute('remote_id', $remoteIDNodeList[$node_item_id]);
                    $node_item->store();
                    if ($node_item_id == $NodeID) {
                        //update $node for template if errors
                        $node = $node_item;
                    }
                }
            }
        }
        // If ok -> send data
        if (empty($errors)) {
            //Clear cache of this object
            eZContentCacheManager::clearContentCache($object->attribute('id'));
            //Redirect to node
            $Module->redirectTo('content/view/full/' . $NodeID);
            return;
        }
        $tpl->setVariable('errors', $errors);
        $tpl->setVariable('new_object_remote_id', $http->postVariable($inputObjectName));
        $tpl->setVariable('new_node_remote_id_list', $remoteIDNodeList);
    }
} else {
    //Wrong parameters
}
$tpl->setVariable('node', $node);
$tpl->setVariable('error_list', $errors);
$Result['content'] = $tpl->fetch('design:remoteid/update.tpl');
	/**
	* 
	* Modifie les données (dataMap) de la version courante d'un objet eZ
	* Cette méthode délègue chaque phase de la création aux API bas niveau d'eZ.
	* (NB : cette méthode modifie la version courante. Elle ne crée pas de nouvelle version !)
	*
	* @todo : Gérer les exceptions
	*
	* @param $contentObject : l'objet eZ.
	* @param $attributes : un tableau associatif des attributs à initialiser \
	*                                      (clé : attribute_id ; valeur : chaine de caractères utilisé comme paramètre de la méthode 'eZDataType::fromString()')
	* @param: $clearcontentcache : true => vider le cache lié à l'objjet - false : ne rien faire (défaut : true)
	* @param: $languageCode : le code de la version linguistique à modifier (ex: fre-FR). Si false, la langue par défaut de l'objet est modifiée.
	*
	* @return void
	*
	*/
	public static function updateEzContentObject( &$contentObject, $attributes, $clearcontentcache=true, $languageCode = false )
	{
		// Récupération de la version courante :
		$version = $contentObject->createNewVersion( false, true, $languageCode );
		$version->setAttribute( 'modified', time() );
		$version->store();
		
		$dataMap = $version->dataMap();
		self::setDataMapInfos( $dataMap, $attributes );

		// Publication de l'objet :
		eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObject->attribute('id'), 
		                                                         'version' => $version->attribute('version') ) );

		// Vidage du cache associé à l'objet :
		if ( $clearcontentcache )
		{
		  eZContentCacheManager::clearContentCache($contentObject->ID);
		}
		
		$contentObject = eZContentObject::fetch( $contentObject->ID );
	}