function execute($process, $event) { // get object being published $parameters = $process->attribute('parameter_list'); $objectID = $parameters['object_id']; eZDebug::writeDebug('Update object state for object: ' . $objectID); $object = eZContentObject::fetch($objectID); $state_before = $event->attribute('state_before'); $state_after = $event->attribute('state_after'); if ($object == null) { eZDebug::writeError('Update object state failed for inexisting object: ' . $objectID, __METHOD__); return eZWorkflowType::STATUS_WORKFLOW_CANCELLED; } if ($state_before == null || $state_after == null) { eZDebug::writeError('Update object state failed: badly configured states', __METHOD__); return eZWorkflowType::STATUS_WORKFLOW_CANCELLED; } $currentStateIDArray = $object->attribute('state_id_array'); if (in_array($state_before->attribute('id'), $currentStateIDArray)) { $canAssignStateIDList = $object->attribute('allowed_assign_state_id_list'); if (!in_array($state_after->attribute('id'), $canAssignStateIDList)) { eZDebug::writeWarning("Not enough rights to assign state to object {$objectID}: " . $state_after->attribute('id'), __METHOD__); } else { eZDebug::writeDebug('Changing object state from ' . $state_before->attribute('name') . ' to ' . $state_after->attribute('name'), __METHOD__); if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) { $operationResult = eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $objectID, 'state_id_list' => array($state_after->attribute('id')))); } else { eZContentOperationCollection::updateObjectState($objectID, array($state_after->attribute('id'))); } } } return eZWorkflowType::STATUS_ACCEPTED; }
function runOperation(&$node) { $object = $node->attribute('object'); $object_id = $object->attribute('id'); $objectLocales = $object->attribute('available_languages'); // If the alternative locale does not exist for object, create it if (!in_array($this->altLocale, $objectLocales)) { // The only translation is in locate to be removed - create a version in another locale first. echo "Copying the single translation in " . $this->remLocale . " to " . $this->altLocale . " so former could be removed.\n"; $newVersion = $object->createNewVersionIn($this->altLocale, $this->remLocale, false, true, eZContentObjectVersion::STATUS_DRAFT); $publishResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $object_id, 'version' => $newVersion->attribute('version'))); eZContentObject::clearCache(); $object = eZContentObject::fetch($object_id); } // Change objects main language to alternative language, if its current main language is to be removed. if ($object->attribute('initial_language_code') == $this->remLocale) { eZContentObject::clearCache(); $object = eZContentObject::fetch($object_id); echo "Switching initial language to {$this->altLocale} so that " . $this->remLocale . " could be removed.\n"; $updateResult = eZContentOperationCollection::updateInitialLanguage($object_id, $this->altLangID); $object->store(); eZContentObject::clearCache(); $object = eZContentObject::fetch($object_id); } // Now it should be safe to remove translation. return $object->removeTranslation($this->remLangID); }
public function execute($process, $event) { $processParameters = $process->attribute('parameter_list'); $object = eZContentObject::fetch($processParameters['object_id']); $targetClassIdentifier = $object->contentClass()->attribute('identifier'); $iniGroups = eZINI::instance('ngindexer.ini')->groups(); $targets = array(); foreach ($iniGroups as $iniGroupName => $iniGroup) { $iniGroupNameArray = explode('/', $iniGroupName); if (is_array($iniGroupNameArray) && count($iniGroupNameArray) == 3) { $class = eZContentClass::fetchByIdentifier($iniGroupNameArray[0]); if ($class instanceof eZContentClass) { $classAttribute = $class->fetchAttributeByIdentifier($iniGroupNameArray[1]); if ($classAttribute instanceof eZContentClassAttribute) { $indexTarget = isset($iniGroup['IndexTarget']) ? trim($iniGroup['IndexTarget']) : ''; $referencedClassIdentifiers = isset($iniGroup['ClassIdentifiers']) && is_array($iniGroup['ClassIdentifiers']) ? $iniGroup['ClassIdentifiers'] : null; if ($referencedClassIdentifiers != null && (empty($referencedClassIdentifiers) || in_array($targetClassIdentifier, $referencedClassIdentifiers))) { switch ($indexTarget) { case 'parent': case 'parent_line': $children = eZContentObjectTreeNode::subTreeByNodeID(array('ClassFilterType' => 'include', 'ClassFilterArray' => array($iniGroupNameArray[0]), 'Depth' => $indexTarget == 'parent' ? 1 : false), $object->mainNode()->attribute('node_id')); if (is_array($children)) { $targets = array_merge($targets, $children); } break; case 'children': $parentNode = $object->mainNode()->fetchParent(); if ($parentNode->classIdentifier() == $iniGroupNameArray[0]) { $targets[] = $parentNode; } break; case 'subtree': $path = $object->mainNode()->fetchPath(); foreach ($path as $pathNode) { if ($pathNode->classIdentifier() == $iniGroupNameArray[0]) { $targets[] = $parentNode; } } break; default: continue; } } } } } } $filteredTargets = array(); foreach ($targets as $target) { $objectID = $target->attribute('contentobject_id'); $version = $target->object()->attribute('current_version'); if (!isset($filteredTargets[$objectID])) { $filteredTargets[$objectID] = $version; eZContentOperationCollection::registerSearchObject($objectID, $version); } } return eZWorkflowType::STATUS_ACCEPTED; }
function sectionEditActionCheck( $module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage ) { if ( $module->isCurrentAction( 'SectionEdit' ) ) { $http = eZHTTPTool::instance(); if ( $http->hasPostVariable( 'SelectedSectionId' ) ) { $selectedSectionID = (int) $http->postVariable( 'SelectedSectionId' ); $selectedSection = eZSection::fetch( $selectedSectionID ); if ( is_object( $selectedSection ) ) { $currentUser = eZUser::currentUser(); if ( $currentUser->canAssignSectionToObject( $selectedSectionID, $object ) ) { $db = eZDB::instance(); $db->begin(); $assignedNodes = $object->attribute( 'assigned_nodes' ); if ( count( $assignedNodes ) > 0 ) { foreach ( $assignedNodes as $node ) { if ( eZOperationHandler::operationIsAvailable( 'content_updatesection' ) ) { $operationResult = eZOperationHandler::execute( 'content', 'updatesection', array( 'node_id' => $node->attribute( 'node_id' ), 'selected_section_id' => $selectedSectionID ), null, true ); } else { eZContentOperationCollection::updateSection( $node->attribute( 'node_id' ), $selectedSectionID ); } } } else { // If there are no assigned nodes we should update db for the current object. $objectID = $object->attribute( 'id' ); $db->query( "UPDATE ezcontentobject SET section_id='$selectedSectionID' WHERE id = '$objectID'" ); $db->query( "UPDATE ezsearch_object_word_link SET section_id='$selectedSectionID' WHERE contentobject_id = '$objectID'" ); } $object->expireAllViewCache(); $db->commit(); } else { eZDebug::writeError( "You do not have permissions to assign the section <" . $selectedSection->attribute( 'name' ) . "> to the object <" . $object->attribute( 'name' ) . ">." ); } $module->redirectToView( 'edit', array( $object->attribute( 'id' ), $editVersion, $editLanguage, $fromLanguage ) ); } } } }
function runOperation(&$node) { if (eZOperationHandler::operationIsAvailable('content_updatealwaysavailable')) { $operationResult = eZOperationHandler::execute('content', 'updatealwaysavailable', array('object_id' => $node->attribute('contentobject_id'), 'new_always_available' => $this->available, 'node_id' => $node->attribute('node_id'))); } else { eZContentOperationCollection::updateAlwaysAvailable($node->attribute('contentobject_id'), $this->available); } return true; }
/** * Test to verify that eznode_assignment entres get removed. * * @link http://issues.ez.no/15478 */ public function testRemoveAssignments() { $db = eZDB::instance(); $testSet = array(); $folder = new ezpObject( "folder", 2 ); $folder->name = __FUNCTION__; $folder->publish(); $testSet[] = $folder; $childOne = new ezpObject( "folder", $folder->mainNode->node_id ); $childOne->name = "ChildOne"; $childOne->publish(); $testSet[] = $childOne; $childTwo = new ezpObject( "folder", $folder->mainNode->node_id ); $childTwo->name = "ChildTwo"; $childTwo->publish(); $testSet[] = $childTwo; $subChildOne = new ezpObject( 'article', $childOne->mainNode->node_id ); $subChildOne->title = "SubChild"; $subChildOne->publish(); $testSet[] = $subChildOne; $subChildTwo = new ezpObject( 'article', $childOne->mainNode->node_id ); $subChildTwo->title = "SubChildOther"; $subChildTwo->publish(); $testSet[] = $subChildTwo; $subChildThree = new ezpObject( 'article', $childOne->mainNode->node_id ); $subChildThree->title = "SubChildThird"; $subChildThree->publish(); $testSet[] = $subChildThree; // Let's add another placement here $newPlacementSubChildOne = $subChildOne->addNode( $childTwo->mainNode->node_id ); $testSet[] = $newPlacementSubChildOne; // $this->debugBasicNodeInfo( $testSet ); $coId = $newPlacementSubChildOne->attribute( 'contentobject_id' ); eZContentOperationCollection::removeAssignment( $childTwo->mainNode->node_id, $childTwo->id, array( $newPlacementSubChildOne ), false ); $checkSql = "SELECT * FROM eznode_assignment WHERE contentobject_id = {$coId}"; $result = $db->arrayQuery( $checkSql ); // After removing one of the assignments, the number of node // assignments for the content object should be only one. $numberOfAssignments = count( $result ); self::assertEquals( 1, $numberOfAssignments, "The number of node assignments are not correct, eznode_assignment table not cleaned up correctly." ); }
function stateEditActionCheck($module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage) { if ($module->isCurrentAction('StateEdit')) { $http = eZHTTPTool::instance(); if ($http->hasPostVariable('SelectedStateIDList')) { $selectedStateIDList = $http->postVariable('SelectedStateIDList'); $objectID = $object->attribute('id'); if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) { $operationResult = eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $objectID, 'state_id_list' => $selectedStateIDList)); } else { eZContentOperationCollection::updateObjectState($objectID, $selectedStateIDList); } } } }
/** * @param int $nodeID * @param string $action */ public function updateNodeVisibility( $nodeID, $action ) { $node = eZContentObjectTreeNode::fetch( $nodeID ); eZContentOperationCollection::registerSearchObject($node->attribute( 'contentobject_id' )); if ( $node->childrenCount( false ) ) { $pendingAction = new eZPendingActions( array( 'action' => self::PENDING_ACTION_INDEX_SUBTREE, 'created' => time(), 'param' => $nodeID ) ); $pendingAction->store(); } }
/** * 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 ); } }
public function execute($process, $event) { //echo('*** workflow importcomunicati ***<pre>'); $parameters = $process->attribute('parameter_list'); try { $object = eZContentObject::fetch($parameters['object_id']); // if a newer object is the current version, abort this workflow. $currentVersion = $object->attribute('current_version'); $version = $object->version($parameters['version']); $classIdentifier = $version->ContentObject->ClassIdentifier; // Verifica se la classe è corretta if ($classIdentifier == self::PUBLISH_CLASS) { $objectAttributes = $version->attribute('contentobject_attributes'); // cicla sugl iattributi foreach ($objectAttributes as $objectAttribute) { $contentClassAttributeIdentifier = $objectAttribute->ContentClassAttributeIdentifier; if ($contentClassAttributeIdentifier == 'published') { // recupera la data di pubblicazione $publisheddate = $objectAttribute->attribute('content'); } } // set della data di pubblicazione if ($publisheddate instanceof eZDateTime || $publisheddate instanceof eZDate) { $object->setAttribute('published', $publisheddate->timeStamp()); $object->store(); eZContentOperationCollection::registerSearchObject($object->attribute('id')); eZDebug::writeNotice('Workflow change object publish date', __METHOD__); } //echo('<br>*** die workflow ***'); //die(); } return eZWorkflowType::STATUS_ACCEPTED; } catch (Exception $e) { eZDebug::writeError($e->getMessage(), __METHOD__); return eZWorkflowType::STATUS_REJECTED; } }
/** * Executes an operation trigger * * @param array $bodyReturnValue The current return value * @param array $body Body data for the trigger being executed * @param array $operationParameterDefinitions Operation parameters definition * @param array $operationParameters Operation parameters values * @param int $bodyCallCount Number of times the body was called * @param array $currentLoopData Memento data for the operation * @param bool $triggerRestored Boolean that indicates if operation data (memento) was restored * @param string $operationName The operation name * @param array $operationKeys Additional parameters. Only used by looping so far. * @return */ function executeTrigger(&$bodyReturnValue, $body, $operationParameterDefinitions, $operationParameters, &$bodyCallCount, $currentLoopData, $triggerRestored, $operationName, &$operationKeys) { $triggerName = $body['name']; $triggerKeys = $body['keys']; $status = eZTrigger::runTrigger($triggerName, $this->ModuleName, $operationName, $operationParameters, $triggerKeys); if ($status['Status'] == eZTrigger::WORKFLOW_DONE || $status['Status'] == eZTrigger::NO_CONNECTED_WORKFLOWS) { ++$bodyCallCount['loop_run'][$triggerName]; return eZModuleOperationInfo::STATUS_CONTINUE; } else { if ($status['Status'] == eZTrigger::STATUS_CRON_JOB || $status['Status'] == eZTrigger::FETCH_TEMPLATE || $status['Status'] == eZTrigger::FETCH_TEMPLATE_REPEAT || $status['Status'] == eZTrigger::REDIRECT) { $bodyMemento = $this->storeBodyMemento($triggerName, $triggerKeys, $operationKeys, $operationParameterDefinitions, $operationParameters, $bodyCallCount, $currentLoopData, $operationName); $workflowProcess = $status['WorkflowProcess']; if ($workflowProcess !== null) { $workflowProcess->setAttribute('memento_key', $bodyMemento->attribute('memento_key')); $workflowProcess->store(); } $bodyReturnValue['result'] = $status['Result']; if ($status['Status'] == eZTrigger::REDIRECT) { $bodyReturnValue['redirect_url'] = $status['Result']; } if ($status['Status'] == eZTrigger::FETCH_TEMPLATE_REPEAT) { // Hack for project issue #14371 (fetch template repeat) // The object version's status is set to REPEAT so that it can // be submitted again if ($operationName == 'publish' && $this->ModuleName == 'content') { eZContentOperationCollection::setVersionStatus($operationParameters['object_id'], $operationParameters['version'], eZContentObjectVersion::STATUS_REPEAT); } return eZModuleOperationInfo::STATUS_REPEAT; } else { return eZModuleOperationInfo::STATUS_HALTED; } } else { if ($status['Status'] == eZTrigger::WORKFLOW_CANCELLED or $status['Status'] == eZTrigger::WORKFLOW_RESET) { return eZModuleOperationInfo::STATUS_CANCELLED; $bodyReturnValue['result'] = $status['Result']; } } } }
// to do this the following must be true: // - The total child count must be zero // - There must be no object removal (i.e. it is the only node for the object) if ($totalChildCount == 0) { $canRemove = true; foreach ($deleteResult as $item) { if ($item['object_node_count'] <= 1) { $canRemove = false; break; } } if ($canRemove) { if (eZOperationHandler::operationIsAvailable('content_removelocation')) { $operationResult = eZOperationHandler::execute('content', 'removelocation', array('node_list' => array_keys($deleteNodeIdArray), 'move_to_trash' => $moveToTrash), null, true); } else { eZContentOperationCollection::removeNodes(array_keys($deleteNodeIdArray)); } if ($http->hasSessionVariable('RedirectURIAfterRemove') && $http->sessionVariable('RedirectURIAfterRemove')) { $Module->redirectTo($http->sessionVariable('RedirectURIAfterRemove')); $http->removeSessionVariable('RedirectURIAfterRemove'); return $http->removeSessionVariable('RedirectIfCancel'); } else { return $Module->redirectToView('view', array($viewMode, $contentNodeID, $contentLanguage)); } } } $tpl = eZTemplate::factory(); $tpl->setVariable('reverse_related', $info['reverse_related_count']); $tpl->setVariable('module', $Module); $tpl->setVariable('moveToTrashAllowed', $moveToTrashAllowed); // Backwards compatibility
/** * Fatal Error when calling eZContentOperationCollection::removeOldNodes() * with inexistant object/object version * * @link http://issues.ez.no/22232 */ public function testRemoveOldNodes() { eZContentOperationCollection::removeOldNodes(1234, 1234); }
/** * Update search index when object state changes * * @param int $objectID * @param array $objectStateList */ public function updateObjectState($objectID, $objectStateList) { eZContentOperationCollection::registerSearchObject($objectID); }
$cli->output('Published : Starting.'); $cli->output('Supported Classes : ' . implode(', ', $unpublishClasses)); foreach ($rootNodeIDList as $nodeID) { $rootNode = eZContentObjectTreeNode::fetch($nodeID); $articleNodeArray = $rootNode->subTree(array('ClassFilterType' => 'include', 'ClassFilterArray' => $unpublishClasses)); foreach ($articleNodeArray as $articleNode) { $article = $articleNode->attribute('object'); // Si le contenu est à l'état Mise en ligne programmée 'publish_chain/waituntildate' if (in_array($ini->variable('UpdateObjectStatesSettings', 'PendingObjectState'), $article->attribute('state_id_array'))) { $dataMap = $article->attribute('data_map'); $dateAttribute = $dataMap['publish_date']; if ($dateAttribute === null) { continue; } $date = $dateAttribute->content(); $articleRetractDate = $date->attribute('timestamp'); if ($articleRetractDate > 0 && $articleRetractDate < $currrentDate) { $ok = "NOT-OK"; // Switch Object state to Published if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) { $operationResult = eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $articleNode->attribute('contentobject_id'), 'state_id_list' => array($targetState))); $ok = "OK"; } else { eZContentOperationCollection::updateObjectState($articleNode->attribute('contentobject_id'), array($targetState)); $ok = "OK"; } $cli->output('Archived : ' . $ok . ' - ' . $articleNode->attribute('name')); } } } }
/** * Same test as {@link self::testRemovePendingSearchSeveralNodesForObject()}, with not all nodes removed * Use case * -------- * 1. If all nodes are removed, pending action must also be removed * 2. If NOT all nodes are removed (at least one node remaining for object), pending action must NOT be removed (case tested here) * * @group issue_17932 */ public function testRemovePendingSearchNotAllNodesRemoved() { $this->folder->addNode( 43 ); $folderObjectID = $this->folder->object->attribute( 'id' ); $aNodeID = array( $this->folder->nodes[0]->attribute( 'node_id' ) ); // Only delete the first node eZContentOperationCollection::deleteObject( $aNodeID ); $filterConds = array( 'action' => 'index_object', 'param' => $folderObjectID ); $pendingCount = eZPersistentObject::count( eZPendingActions::definition(), $filterConds ); self::assertGreaterThan( 0, $pendingCount, "eZContentOperationCollection::deleteObject() must remove pending action for object #$folderObjectID as all nodes have been removed" ); }
if ( empty($rows) ) { $continue = false; break; } foreach( $rows as $row ) { $remoteId = $row['remote_id']; $object = eZContentObject::fetchByRemoteID($remoteId); //if eZ Publish object if ($object) { $counter++; eZContentOperationCollection::registerSearchObject($object->attribute("id"), false); $varnishNodeIds[] = $object->mainNode()->attribute('parent_node_id'); } else { $counter++; //test if solrObject $fields = array( 'rating' => 'attr_content_rating_'.$row['cluster_identifier'].'_f', ); $params = array( 'indent' => 'on', 'q' => '*:*', 'start' => 0,
/** * Ensures that eZURLAliasML::fetchPathByActionList() always uses prioritized languages, * even if a locale is enforced (3rd param) and always available flag is false. * * @see http://issues.ez.no/19055 * @group issue19055 * @covers eZURLAliasML::fetchPathByActionList */ public function testFetchPathByActionListWithFallback() { $frenchLocale = $this->frenchLanguage->attribute('locale'); ezpINIHelper::setINISettings(array(array('site.ini', 'RegionalSettings', 'ContentObjectLocale', $frenchLocale), array('site.ini', 'RegionalSettings', 'Locale', $frenchLocale), array('site.ini', 'RegionalSettings', 'SiteLanguageList', array($frenchLocale, 'eng-GB')), array('site.ini', 'RegionalSettings', 'ShowUntranslatedObjects', 'disabled'))); eZContentOperationCollection::updateAlwaysAvailable(1, false); /* * - Create a content object in Norsk * - Remove AlwaysAvailable flag * - Add a translation in english * - Try to fetch path for this content in French (fallback is eng-GB as configured above) */ $folder = new ezpObject('folder', 2, 14, 1, $this->norskLanguage->attribute('locale')); $folder->name = 'norsk folder'; $folder->publish(); eZContentOperationCollection::updateAlwaysAvailable($folder->object->attribute('id'), false); $folder->refresh(); $folder->addTranslation('eng-GB', array('name' => 'english translation')); $folder->publish(); $generatedPath = eZURLAliasML::fetchPathByActionList('eznode', array($folder->mainNode->node_id), $frenchLocale); self::assertNotNull($generatedPath); self::assertEquals('english-translation', $generatedPath); eZContentOperationCollection::updateAlwaysAvailable(1, true); ezpINIHelper::restoreINISettings(); $folder->remove(); }
public function applyTo(eZContentObject $object) { $sectionID = $this->attribute("id"); $currentUser = eZUser::currentUser(); if (!$currentUser->canAssignSectionToObject($sectionID, $object)) { eZDebug::writeError("You do not have permissions to assign the section <" . $selectedSection->attribute("name") . "> to the object <" . $object->attribute("name") . ">."); return false; } $db = eZDB::instance(); $db->begin(); $assignedNodes = $object->attribute("assigned_nodes"); if (!empty($assignedNodes)) { if (eZOperationHandler::operationIsAvailable("content_updatesection")) { foreach ($assignedNodes as $node) { eZOperationHandler::execute("content", "updatesection", array("node_id" => $node->attribute("node_id"), "selected_section_id" => $sectionID), null, true); } } else { foreach ($assignedNodes as $node) { eZContentOperationCollection::updateSection($node->attribute("node_id"), $sectionID); } } } else { // If there are no assigned nodes we should update db for the current object. $objectID = $object->attribute("id"); $db->query("UPDATE ezcontentobject SET section_id='{$sectionID}' WHERE id = '{$objectID}'"); $db->query("UPDATE ezsearch_object_word_link SET section_id='{$sectionID}' WHERE contentobject_id = '{$objectID}'"); } eZContentCacheManager::clearContentCacheIfNeeded($object->attribute("id")); $object->expireAllViewCache(); $db->commit(); }
/** * Called when a node assignement is added to an object. * Simply re-index for now. * * @todo: defer to cron if there are children involved and re-index these too * @todo when Solr supports it: update fields only * * @param $mainNodeID * @param $objectID * @param $nodeAssignmentIDList * @return unknown_type * @see eZSearch::addNodeAssignment() */ public function addNodeAssignment( $mainNodeID, $objectID, $nodeAssignmentIDList ) { eZContentOperationCollection::registerSearchObject( $objectID ); }
/** * Does the remove job. * Will use content_delete operation if available (workflow support) * @param array $aNodeID * @param bool $moveToTrash Indicates if we move content to trash or not. True by default * @internal */ private function doRemove(array $aNodeID, $moveToTrash = true) { if (eZOperationHandler::operationIsAvailable('content_delete')) { $operationResult = eZOperationHandler::execute('content', 'delete', array('node_id_list' => $aNodeID, 'move_to_trash' => $moveToTrash), null, true); } else { eZContentOperationCollection::deleteObject($aNodeID, $moveToTrash); } }
/** * Adds a location to provided content. * Prefer using SQLIContent::addLocation() instead of calling this method directly * @param SQLILocation $location * @param SQLIContent $content * @internal */ public function addLocationToContent(SQLILocation $location, SQLIContent $content) { $nodeID = $content->attribute('main_node_id'); if (!$nodeID) { // No main node ID, object has not been published at least once throw new SQLIContentException(__METHOD__ . ' => Cannot directly add a location to a not-yet-published content. Content Object ID = ' . $content->attribute('id') . '. Try to use SQLIContent::addLocation()'); } $objectID = $content->attribute('id'); $locationNodeID = $location->getNodeID(); // Check first if content has already an assigned node in provided location $assignedNodes = $content->assignedNodes(false); for ($i = 0, $iMax = count($assignedNodes); $i < $iMax; ++$i) { if ($locationNodeID == $assignedNodes[$i]['parent_node_id']) { eZDebug::writeWarning(__METHOD__ . ' => Content with ObjectID #' . $objectID . ' already has a location as a child of node #' . $locationNodeID); return; } } eZDebug::accumulatorStart('sqlicontentpublisher_add_location', 'sqlicontentpublisher', 'Adding a location for object #' . $objectID); $selectedNodeIDArray = array($locationNodeID); if (eZOperationHandler::operationIsAvailable('content_addlocation')) { $operationResult = eZOperationHandler::execute('content', 'addlocation', array('node_id' => $nodeID, 'object_id' => $objectID, 'select_node_id_array' => $selectedNodeIDArray), null, true); } else { eZContentOperationCollection::addAssignment($nodeID, $objectID, $selectedNodeIDArray); } $content->refreshLocations(); eZDebug::accumulatorStop('sqlicontentpublisher_add_location'); }
/** * @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. * @version //autogentag// * @package kernel */ $Module = $Params['Module']; $NodeID = $Params['NodeID']; $curNode = eZContentObjectTreeNode::fetch($NodeID); if (!$curNode) { return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'); } if (!$curNode->attribute('can_hide')) { return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel'); } if (eZOperationHandler::operationIsAvailable('content_hide')) { $operationResult = eZOperationHandler::execute('content', 'hide', array('node_id' => $NodeID), null, true); } else { eZContentOperationCollection::changeHideStatus($NodeID); } $hasRedirect = eZRedirectManager::redirectTo($Module, false); if (!$hasRedirect) { // redirect to the parent node if (($parentNodeID = $curNode->attribute('parent_node_id')) == 1) { $redirectNodeID = $NodeID; } else { $redirectNodeID = $parentNodeID; } return $Module->redirectToView('view', array('full', $redirectNodeID)); }
$operationResult = eZOperationHandler::execute('content', 'updatealwaysavailable', array('object_id' => $objectID, 'new_always_available' => $newAlwaysAvailable, 'node_id' => $nodeID)); } else { eZContentOperationCollection::updateAlwaysAvailable($objectID, $newAlwaysAvailable); } return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode)); } else { if ($module->isCurrentAction('RemoveTranslation')) { if (!$module->hasActionParameter('LanguageID')) { return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode)); } $languageIDArray = $module->actionParameter('LanguageID'); if ($module->hasActionParameter('ConfirmRemoval') && $module->actionParameter('ConfirmRemoval')) { if (eZOperationHandler::operationIsAvailable('content_removetranslation')) { $operationResult = eZOperationHandler::execute('content', 'removetranslation', array('object_id' => $objectID, 'language_id_list' => $languageIDArray, 'node_id' => $nodeID)); } else { eZContentOperationCollection::removeTranslation($objectID, $languageIDArray); } return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode)); } $languages = array(); foreach ($languageIDArray as $languageID) { $language = eZContentLanguage::fetch($languageID); if ($language) { $languages[] = $language; } } if (!$languages) { return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode)); } $tpl = eZTemplate::factory(); $tpl->setVariable('object_id', $objectID);
$objectID = isset( $Params['ObjectID'] ) ? $Params['ObjectID'] : false; $selectedStateIDList = isset( $Params['SelectedStateID'] ) ? array( $Params['SelectedStateID'] ) : false ; } // Change object's state if ( $objectID and $selectedStateIDList ) { if ( eZOperationHandler::operationIsAvailable( 'content_updateobjectstate' ) ) { $operationResult = eZOperationHandler::execute( 'content', 'updateobjectstate', array( 'object_id' => $objectID, 'state_id_list' => $selectedStateIDList ) ); } else { eZContentOperationCollection::updateObjectState( $objectID, $selectedStateIDList ); } // Redirect to the provided URI, or to the root if not provided. // @TODO : in case this view is called through Ajax, make sure the module ends another way. $Module->hasActionParameter( 'RedirectRelativeURI' ) ? $Module->redirectTo( $Module->actionParameter( 'RedirectRelativeURI' ) ) : $Module->redirectTo( '/' ); } elseif ( $objectID ) { // Propose an interface. The end-user probably accessed this view through a simple URL like // '/state/assign/<object_id>' if ( ( $object = eZContentObject::fetch( $objectID ) ) !== null ) { $tpl = eZTemplate::factory(); $tpl->setVariable( 'node', $object->attribute( 'main_node' ) ); $Result['content'] = $tpl->fetch( 'design:state/assign.tpl' );
if (!$http->hasPostVariable('NodeID')) { eZDebug::writeError('Create/ Remove NodeFeed: missing node ID parameter.', 'content-action-handler'); return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'); } $nodeID = $http->postVariable('NodeID'); if ($http->hasPostVariable('CreateNodeFeed')) { if (eZOperationHandler::operationIsAvailable('content_createnodefeed')) { $operationResult = eZOperationHandler::execute('content', 'createnodefeed', array('node_id' => $nodeID), null, true); } else { $operationResult = eZContentOperationCollection::createFeedForNode($nodeID); } } else { if (eZOperationHandler::operationIsAvailable('content_removenodefeed')) { $operationResult = eZOperationHandler::execute('content', 'removenodefeed', array('node_id' => $nodeID), null, true); } else { $operationResult = eZContentOperationCollection::removeFeedForNode($nodeID); } } if (!isset($operationResult['status']) || !$operationResult['status']) { return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'); } return $module->redirectToView('view', array('full', $nodeID)); } else { // Check if there are any custom actions to handle $customActions = eZINI::instance('datatype.ini')->variable('ViewSettings', 'CustomActionMap'); foreach ($customActions as $customActionName => $customActionUrl) { if ($http->hasPostVariable($customActionName)) { if (strpos($customActionUrl, '/') !== false) { list($customActionModuleName, $customActionViewName) = explode('/', $customActionUrl); $customActionModule = eZModule::exists($customActionModuleName); if (!$customActionModule instanceof eZModule) {
function checkContentActions( $module, $class, $object, $version, $contentObjectAttributes, $EditVersion, $EditLanguage, $FromLanguage, &$Result ) { if ( $module->isCurrentAction( 'Preview' ) ) { $module->redirectToView( 'versionview', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) ); return eZModule::HOOK_STATUS_CANCEL_RUN; } if ( $module->isCurrentAction( 'Translate' ) ) { $module->redirectToView( 'translate', array( $object->attribute( 'id' ), $EditVersion, $EditLanguage, $FromLanguage ) ); return eZModule::HOOK_STATUS_CANCEL_RUN; } if ( $module->isCurrentAction( 'VersionEdit' ) ) { if ( isset( $GLOBALS['eZRequestedURI'] ) and is_object( $GLOBALS['eZRequestedURI'] ) ) { $uri = $GLOBALS['eZRequestedURI']; $uri = $uri->originalURIString(); $http = eZHTTPTool::instance(); $http->setSessionVariable( 'LastAccessesVersionURI', $uri ); } $module->redirectToView( 'history', array( $object->attribute( 'id' ), $EditVersion, $EditLanguage ) ); return eZModule::HOOK_STATUS_CANCEL_RUN; } if ( $module->isCurrentAction( 'EditLanguage' ) ) { if ( $module->hasActionParameter( 'SelectedLanguage' ) ) { $EditLanguage = $module->actionParameter( 'SelectedLanguage' ); // We reset the from language to disable the translation look $FromLanguage = false; $module->redirectToView( 'edit', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) ); return eZModule::HOOK_STATUS_CANCEL_RUN; } } if ( $module->isCurrentAction( 'TranslateLanguage' ) ) { if ( $module->hasActionParameter( 'SelectedLanguage' ) ) { $FromLanguage = $EditLanguage; $EditLanguage = $module->actionParameter( 'SelectedLanguage' ); $module->redirectToView( 'edit', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) ); return eZModule::HOOK_STATUS_CANCEL_RUN; } } if ( $module->isCurrentAction( 'FromLanguage' ) ) { $FromLanguage = $module->actionParameter( 'FromLanguage' ); $module->redirectToView( 'edit', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) ); return eZModule::HOOK_STATUS_CANCEL_RUN; } if ( $module->isCurrentAction( 'Discard' ) ) { $http = eZHTTPTool::instance(); $objectID = $object->attribute( 'id' ); $discardConfirm = true; if ( $http->hasPostVariable( 'DiscardConfirm' ) ) $discardConfirm = $http->postVariable( 'DiscardConfirm' ); $http->setSessionVariable( 'DiscardObjectID', $objectID ); $http->setSessionVariable( 'DiscardObjectVersion', $EditVersion ); $http->setSessionVariable( 'DiscardObjectLanguage', $EditLanguage ); $http->setSessionVariable( 'DiscardConfirm', $discardConfirm ); $module->redirectTo( $module->functionURI( 'removeeditversion' ) . '/' ); return eZModule::HOOK_STATUS_CANCEL_RUN; } // helper function which computes the redirect after // publishing and final store of a draft. function computeRedirect( $module, $object, $version, $EditLanguage = false ) { $http = eZHTTPTool::instance(); $node = $object->mainNode(); if ( $http->hasSessionVariable( 'RedirectIfDiscarded' ) ) { $http->removeSessionVariable( 'RedirectIfDiscarded' ); } $hasRedirected = false; if ( $http->hasSessionVariable( 'ParentObject' ) && $http->sessionVariable( 'NewObjectID' ) == $object->attribute( 'id' ) ) { $parentArray = $http->sessionVariable( 'ParentObject' ); $parentURL = $module->redirectionURI( 'content', 'edit', $parentArray ); $parentObject = eZContentObject::fetch( $parentArray[0] ); $db = eZDB::instance(); $db->begin(); $parentObject->addContentObjectRelation( $object->attribute( 'id' ), $parentArray[1] ); $db->commit(); $http->removeSessionVariable( 'ParentObject' ); $http->removeSessionVariable( 'NewObjectID' ); $module->redirectTo( $parentURL ); $hasRedirected = true; } if ( $http->hasSessionVariable( 'RedirectURIAfterPublish' ) && !$hasRedirected ) { $uri = $http->sessionVariable( 'RedirectURIAfterPublish' ); $http->removeSessionVariable( 'RedirectURIAfterPublish' ); $module->redirectTo( $uri ); $hasRedirected = true; } if ( $http->hasPostVariable( 'RedirectURIAfterPublish' ) && !$hasRedirected ) { $uri = $http->postVariable( 'RedirectURIAfterPublish' ); $module->redirectTo( $uri ); $hasRedirected = true; } if ( $http->hasPostVariable( "BackToEdit" ) && $http->postVariable( "BackToEdit" ) ) { $uri = $module->redirectionURI( 'content', 'edit', array( $object->attribute( 'id'), 'f', $EditLanguage ) ); $module->redirectTo( $uri ); eZDebug::writeDebug( $uri, "uri " . $object->attribute( 'id') ); $hasRedirected = true; } if ( !$hasRedirected ) { if ( $http->hasPostVariable( 'RedirectURI' ) ) { $uri = $http->postVariable( 'RedirectURI' ); $module->redirectTo( $uri ); } else if ( $node !== null ) { $parentNode = $node->attribute( 'parent_node_id' ); if ( $parentNode == 1 ) { $parentNode = $node->attribute( 'node_id' ); } $module->redirectToView( 'view', array( 'full', $parentNode ) ); } else { $module->redirectToView( 'view', array( 'full', $version->attribute( 'main_parent_node_id' ) ) ); } } } if( $module->isCurrentAction( 'StoreExit' ) ) { computeRedirect( $module, $object, $version, $EditLanguage ); return eZModule::HOOK_STATUS_CANCEL_RUN; } if ( $module->isCurrentAction( 'Publish' ) ) { // Checking the source and destination language from the url, // if they are the same no confirmation is needed. if ( $EditLanguage != $FromLanguage ) { $conflictingVersions = $version->hasConflicts( $EditLanguage ); if ( $conflictingVersions ) { $tpl = eZTemplate::factory(); $res = eZTemplateDesignResource::instance(); $res->setKeys( array( array( 'object', $object->attribute( 'id' ) ), array( 'remote_id', $object->attribute( 'remote_id' ) ), array( 'class', $class->attribute( 'id' ) ), array( 'class_identifier', $class->attribute( 'identifier' ) ), array( 'class_group', $class->attribute( 'match_ingroup_id_list' ) ) ) ); $tpl->setVariable( 'edit_language', $EditLanguage ); $tpl->setVariable( 'current_version', $version->attribute( 'version' ) ); $tpl->setVariable( 'object', $object ); $tpl->setVariable( 'draft_versions', $conflictingVersions ); $Result = array(); $Result['content'] = $tpl->fetch( 'design:content/edit_conflict.tpl' ); return eZModule::HOOK_STATUS_CANCEL_RUN; } } eZDebug::accumulatorStart( 'publish', '', 'publish' ); $oldObjectName = $object->name(); $behaviour = new ezpContentPublishingBehaviour(); $behaviour->isTemporary = true; $behaviour->disableAsynchronousPublishing = false; ezpContentPublishingBehaviour::setBehaviour( $behaviour ); $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $object->attribute( 'id' ), 'version' => $version->attribute( 'version' ) ) ); eZDebug::accumulatorStop( 'publish' ); if ( ( array_key_exists( 'status', $operationResult ) && $operationResult['status'] != eZModuleOperationInfo::STATUS_CONTINUE ) ) { eZDebug::writeDebug( $operationResult, __FILE__ ); switch( $operationResult['status'] ) { case eZModuleOperationInfo::STATUS_REPEAT: { eZContentOperationCollection::setVersionStatus( $object->attribute( 'id' ), $version->attribute( 'version' ), eZContentObjectVersion::STATUS_REPEAT ); } case eZModuleOperationInfo::STATUS_HALTED: { if ( isset( $operationResult['redirect_url'] ) ) { $module->redirectTo( $operationResult['redirect_url'] ); return; } else if ( isset( $operationResult['result'] ) ) { $result = $operationResult['result']; $resultContent = false; if ( is_array( $result ) ) { if ( isset( $result['content'] ) ) { $resultContent = $result['content']; } if ( isset( $result['path'] ) ) { $Result['path'] = $result['path']; } } else { $resultContent = $result; } // Temporary fix to make approval workflow work with edit. if ( strpos( $resultContent, 'Deffered to cron' ) === 0 ) { $Result = null; } else { $Result['content'] = $resultContent; } } }break; case eZModuleOperationInfo::STATUS_CANCELLED: { $Result = array(); $Result['content'] = "Content publish cancelled<br/>"; } } /* If we already have a correct module result * we don't need to continue module execution. */ if ( is_array( $Result ) ) return eZModule::HOOK_STATUS_CANCEL_RUN; } // update content object attributes array by refetching them from database $object = eZContentObject::fetch( $object->attribute( 'id' ) ); $contentObjectAttributes = $object->attribute( 'contentobject_attributes' ); // set chosen hidden/invisible attributes for object nodes $http = eZHTTPTool::instance(); $assignedNodes = $object->assignedNodes( true ); foreach ( $assignedNodes as $node ) { $nodeID = $node->attribute( 'node_id' ); $parentNodeID = $node->attribute( 'parent_node_id' ); $updateNodeVisibility = false; $postVarName = "FutureNodeHiddenState_$parentNodeID"; if ( !$http->hasPostVariable( $postVarName ) ) $updateNodeVisibility = true; else { $futureNodeHiddenState = $http->postVariable( $postVarName ); $db = eZDB::instance(); $db->begin(); if ( $futureNodeHiddenState == 'hidden' ) eZContentObjectTreeNode::hideSubTree( $node ); else if ( $futureNodeHiddenState == 'visible' ) eZContentObjectTreeNode::unhideSubTree( $node ); else if ( $futureNodeHiddenState == 'unchanged' ) $updateNodeVisibility = true; else eZDebug::writeWarning( "Unknown value for the future node hidden state: '$futureNodeHiddenState'" ); $db->commit(); } if ( $updateNodeVisibility ) { // this might be redundant $db = eZDB::instance(); $db->begin(); $parentNode = eZContentObjectTreeNode::fetch( $parentNodeID ); eZContentObjectTreeNode::updateNodeVisibility( $node, $parentNode, /* $recursive = */ false ); $db->commit(); unset( $node, $parentNode ); } } unset( $assignedNodes ); $object = eZContentObject::fetch( $object->attribute( 'id' ) ); $newObjectName = $object->name(); $http = eZHTTPTool::instance(); computeRedirect( $module, $object, $version, $EditLanguage ); // we have set redirection URI for module so we don't need to continue module execution return eZModule::HOOK_STATUS_CANCEL_RUN; } }
$module = $Params['Module']; $objectID = $module->actionParameter( 'ContentObjectID' ); $nodeID = $module->actionParameter( 'NodeID' ); $languageCode = $module->actionParameter( 'LanguageCode' ); $viewMode = 'full'; if ( !$module->hasActionParameter( 'ViewMode' ) ) { $viewMode = $module->actionParameter( 'ViewMode' ); } if ( $module->isCurrentAction( 'IndexObject' ) || $module->isCurrentAction( 'IndexSubtree' )) { eZContentOperationCollection::registerSearchObject( $objectID ); } if ( $module->isCurrentAction( 'IndexSubtree' ) ) { $pendingAction = new eZPendingActions( array( 'action' => eZSolr::PENDING_ACTION_INDEX_SUBTREE, 'created' => time(), 'param' => $nodeID ) ); $pendingAction->store(); } if ( $module->isCurrentAction( 'RemoveObject' ) ) { $object = eZContentObject::fetch($objectID);
/** * Removes a translation for a contentobject * * @param int $objectID * @param array * @return array An array with operation status, always true */ public static function removeTranslation($objectID, $languageIDArray) { $object = eZContentObject::fetch($objectID); foreach ($languageIDArray as $languageID) { if (!$object->removeTranslation($languageID)) { eZDebug::writeError("Object with id {$objectID}: cannot remove the translation with language id {$languageID}!", __METHOD__); } } eZContentOperationCollection::registerSearchObject($objectID); eZContentCacheManager::clearContentCacheIfNeeded($objectID); return array('status' => true); }
/** * 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::clearContentCacheIfNeeded($objectID); } }