本文整理汇总了PHP中eZContentOperationCollection类的典型用法代码示例。如果您正苦于以下问题:PHP eZContentOperationCollection类的具体用法?PHP eZContentOperationCollection怎么用?PHP eZContentOperationCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZContentOperationCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
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;
}
示例2: runOperation
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);
}
示例3: execute
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;
}
示例4: sectionEditActionCheck
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 ) );
}
}
}
}
示例5: runOperation
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;
}
示例6: testRemoveAssignments
/**
* 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." );
}
示例7: stateEditActionCheck
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);
}
}
}
}
示例8: updateNodeVisibility
/**
* @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();
}
}
示例9: updatePriority
/**
* 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 );
}
}
示例10: execute
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;
}
}
示例11: executeTrigger
/**
* 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'];
}
}
}
}
示例12: foreach
// 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
示例13: testRemoveOldNodes
/**
* Fatal Error when calling eZContentOperationCollection::removeOldNodes()
* with inexistant object/object version
*
* @link http://issues.ez.no/22232
*/
public function testRemoveOldNodes()
{
eZContentOperationCollection::removeOldNodes(1234, 1234);
}
示例14: updateObjectState
/**
* Update search index when object state changes
*
* @param int $objectID
* @param array $objectStateList
*/
public function updateObjectState($objectID, $objectStateList)
{
eZContentOperationCollection::registerSearchObject($objectID);
}
示例15: implode
$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'));
}
}
}
}