本文整理汇总了PHP中eZOperationHandler::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP eZOperationHandler::execute方法的具体用法?PHP eZOperationHandler::execute怎么用?PHP eZOperationHandler::execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZOperationHandler
的用法示例。
在下文中一共展示了eZOperationHandler::execute方法的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)
{
$params = $process->attribute('parameter_list');
$object_id = $params['object_id'];
$object = eZContentObject::fetch($object_id);
if (!is_object($object)) {
eZDebug::writeError("Unable to fetch object: '{$object_id}'", __METHOD__);
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
}
// current parent node(s)
$parentNodeIds = $object->attribute('parent_nodes');
$checkedObjs = array();
foreach ($parentNodeIds as $parentNodeId) {
//eZDebug::writeDebug( "Checking parent node: " . $parentNodeId, __METHOD__ );
$parentNode = eZContentObjectTreeNode::fetch($parentNodeId);
$parentObj = $parentNode->attribute('object');
if (!in_array($parentObj->attribute('id'), $checkedObjs)) {
//eZDebug::writeDebug( "Checking all nodes of parent obj: " . $parentObj->attribute( 'id' ), __METHOD__ );
foreach ($parentObj->attribute('assigned_nodes') as $node) {
if (!in_array($node->attribute('node_id'), $parentNodeIds)) {
//eZDebug::writeDebug( "Found a node which is not parent of current obj: " . $node->attribute( 'node_id' ), __METHOD__ );
// the current obj has no node which is children of the given node of one of its parent objects
$operationResult = eZOperationHandler::execute('content', 'addlocation', array('node_id' => $object->attribute('main_node_id'), 'object_id' => $object->attribute('id'), 'select_node_id_array' => array($node->attribute('node_id'))), null, true);
if ($operationResult == null || $operationResult['status'] != true) {
eZDebug::writeError("Unable to add new location to object: " . $object->attribute('id'), __METHOD__);
}
} else {
//eZDebug::writeDebug( "Found a node which is already parent of current obj: " . $node->attribute( 'node_id' ), __METHOD__ );
}
}
}
$checkedObjs[] = $parentObj->attribute('id');
}
return eZWorkflowType::STATUS_ACCEPTED;
}
示例4: createUser
/**
* Creates a user with provided auth data
*
* @param array $authResult
*
* @return bool|eZUser
*/
public static function createUser($authResult)
{
$ngConnectINI = eZINI::instance('ngconnect.ini');
$siteINI = eZINI::instance('site.ini');
$defaultUserPlacement = $ngConnectINI->variable('LoginMethod_' . $authResult['login_method'], 'DefaultUserPlacement');
$placementNode = eZContentObjectTreeNode::fetch($defaultUserPlacement);
if (!$placementNode instanceof eZContentObjectTreeNode) {
$defaultUserPlacement = $siteINI->variable('UserSettings', 'DefaultUserPlacement');
$placementNode = eZContentObjectTreeNode::fetch($defaultUserPlacement);
if (!$placementNode instanceof eZContentObjectTreeNode) {
return false;
}
}
$contentClass = eZContentClass::fetch($siteINI->variable('UserSettings', 'UserClassID'));
$userCreatorID = $siteINI->variable('UserSettings', 'UserCreatorID');
$defaultSectionID = $siteINI->variable('UserSettings', 'DefaultSectionID');
$db = eZDB::instance();
$db->begin();
$contentObject = $contentClass->instantiate($userCreatorID, $defaultSectionID);
$contentObject->store();
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => 1, 'parent_node' => $placementNode->attribute('node_id'), 'is_main' => 1));
$nodeAssignment->store();
$currentTimeStamp = eZDateTime::currentTimeStamp();
/** @var eZContentObjectVersion $version */
$version = $contentObject->currentVersion();
$version->setAttribute('modified', $currentTimeStamp);
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
$dataMap = $version->dataMap();
self::fillUserObject($version->dataMap(), $authResult);
if (!isset($dataMap['user_account'])) {
$db->rollback();
return false;
}
$userLogin = 'ngconnect_' . $authResult['login_method'] . '_' . $authResult['id'];
$userPassword = (string) rand() . 'ngconnect_' . $authResult['login_method'] . '_' . $authResult['id'] . (string) rand();
$userExists = false;
if (eZUser::requireUniqueEmail()) {
$userExists = eZUser::fetchByEmail($authResult['email']) instanceof eZUser;
}
if (empty($authResult['email']) || $userExists) {
$email = md5('ngconnect_' . $authResult['login_method'] . '_' . $authResult['id']) . '@localhost.local';
} else {
$email = $authResult['email'];
}
$user = new eZUser(array('contentobject_id' => $contentObject->attribute('id'), 'email' => $email, 'login' => $userLogin, 'password_hash' => md5("{$userLogin}\n{$userPassword}"), 'password_hash_type' => 1));
$user->store();
$userSetting = new eZUserSetting(array('is_enabled' => true, 'max_login' => 0, 'user_id' => $contentObject->attribute('id')));
$userSetting->store();
$dataMap['user_account']->setContent($user);
$dataMap['user_account']->store();
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObject->attribute('id'), 'version' => $version->attribute('version')));
if (array_key_exists('status', $operationResult) && $operationResult['status'] == eZModuleOperationInfo::STATUS_CONTINUE) {
$db->commit();
return $user;
}
$db->rollback();
return false;
}
示例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: 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 ) );
}
}
}
}
示例7: execute
public function execute($process, $event)
{
$parameters = $process->attribute('parameter_list');
try {
// WORKFLOW HERE
if ($parameters['trigger_name'] == 'post_updateobjectstate') {
$objectId = $parameters['object_id'];
$object = eZContentObject::fetch($objectId);
$parentStateIDArray = $object->stateIDArray();
$fetch_parameters = array('parent_node_id' => $object->mainNodeID());
$childs = eZFunctionHandler::execute('content', 'list', $fetch_parameters);
$stateGroups = eZINI::instance('patbase.ini')->variable('ChildsPropagationState', 'StateGroupID');
foreach ($childs as $child) {
$childStateIDArray = $child->object()->stateIDArray();
$stateChanged = FALSE;
foreach ($stateGroups as $stateGroup) {
if ($childStateIDArray[$stateGroup] !== $parentStateIDArray[$stateGroup]) {
$stateChanged = TRUE;
$childStateIDArray[$stateGroup] = $parentStateIDArray[$stateGroup];
}
}
if ($stateChanged) {
eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $child->ContentObjectID, 'state_id_list' => $childStateIDArray));
}
}
} else {
if ($parameters['trigger_name'] == 'post_publish') {
if ($parameters['version'] === '1') {
$objectId = $parameters['object_id'];
$object = eZContentObject::fetch($objectId);
$objectStateIDArray = $object->stateIDArray();
$fetch_parameters = array('node_id' => $object->mainParentNodeID());
$parent = eZFunctionHandler::execute('content', 'node', $fetch_parameters);
$stateGroups = eZINI::instance('patbase.ini')->variable('ChildsPropagationState', 'StateGroupID');
$parentStateIDArray = $parent->object()->stateIDArray();
$stateChanged = FALSE;
foreach ($stateGroups as $stateGroup) {
if ($objectStateIDArray[$stateGroup] !== $parentStateIDArray[$stateGroup]) {
$stateChanged = TRUE;
$objectStateIDArray[$stateGroup] = $parentStateIDArray[$stateGroup];
}
}
if ($stateChanged) {
eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $objectId, 'state_id_list' => $objectStateIDArray));
}
}
}
}
//
return eZWorkflowType::STATUS_ACCEPTED;
} catch (Exception $e) {
eZDebug::writeError($e->getMessage(), __METHOD__);
return eZWorkflowType::STATUS_REJECTED;
}
}
示例8: 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);
}
}
}
}
示例9: createNewVersionWithImage
protected function createNewVersionWithImage(eZContentObject $object)
{
$version = $object->createNewVersion(false, true, false, false, eZContentObjectVersion::STATUS_INTERNAL_DRAFT);
$contentObjectAttributes = $version->contentObjectAttributes();
foreach ($contentObjectAttributes as $contentObjectAttribute) {
if ($contentObjectAttribute->attribute('contentclass_attribute_identifier') != 'image') {
continue;
}
$contentObjectAttribute->fromString(self::IMAGE_FILE_PATH);
$contentObjectAttribute->store();
break;
}
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $object->attribute('id'), 'version' => $version->attribute('version')));
self::assertEquals(1, $operationResult['status']);
return $this->forceFetchContentObject($object->attribute('id'));
}
示例10: runOperation
function runOperation(&$node)
{
$object = $node->attribute('object');
$object_id = $object->attribute('id');
$objectLocales = $object->attribute('available_languages');
// If the new locale does not exist for object, create it
if (!in_array($this->newLocale, $objectLocales)) {
// Create a new version of the original in another locale.
$cli = eZCLI::instance();
$cli->output("Copying the single translation in {$this->orgLocale} to {$this->newLocale}");
$newVersion = $object->createNewVersionIn($this->newLocale, $this->orgLocale, 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);
}
return true;
}
示例11: create
public function create($parentNodeId, $classIdentifier, $dataSet)
{
$result = array("result" => false);
$parentNode = eZContentObjectTreeNode::fetch($parentNodeId);
if (!is_object($parentNode)) {
throw new Exception("createObject::create(): Failed to locate parent node. id='" . $parentNodeId . "'");
}
$contentClass = eZContentClass::fetchByIdentifier($classIdentifier);
if (!$contentClass) {
throw new Exception("Failed to instantiate content class [" . $classIdentifier . "]");
}
// take care over clustered setups
$db = eZDB::instance();
$db->begin();
$contentObject = $contentClass->instantiate(false, 0, false);
$dataMap = $contentObject->attribute('data_map');
foreach ($dataSet as $key => $value) {
// attributes are lower case
$key = strtolower($key);
// if the field exists in the object, write to it
if (isset($dataMap[$key])) {
$dataMap[$key]->fromString($value);
$dataMap[$key]->store();
}
}
$contentObject->store();
$result["objectid"] = $contentObject->attribute('id');
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => 1, 'parent_node' => $parentNodeId, 'is_main' => 1));
if (!$nodeAssignment) {
throw new Exception("createObject::create(): Failed to create matching node for object of class '" . $classIdentifier . "'");
}
$nodeAssignment->store();
$obj_version = $contentObject->currentVersion();
$publish = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObject->attribute('id'), 'version' => $obj_version->attribute('version')));
$db->commit();
$result["publish"] = $publish;
$result["parentnodeid"] = $parentNodeId;
$result["mainnodeid"] = $contentObject->mainNodeID();
$result["contentclass"] = $classIdentifier;
$result["contentobjectid"] = $contentObject->attribute('id');
$result["result"] = true;
return $result;
}
示例12: copyObject
function copyObject($Module, $object, $allVersions, $newParentNodeID)
{
if (!$newParentNodeID) {
return $Module->redirectToView('view', array('full', 2));
}
// check if we can create node under the specified parent node
if (($newParentNode = eZContentObjectTreeNode::fetch($newParentNodeID)) === null) {
return $Module->redirectToView('view', array('full', 2));
}
$classID = $object->attribute('contentclass_id');
if (!$newParentNode->checkAccess('create', $classID)) {
$objectID = $object->attribute('id');
eZDebug::writeError("Cannot copy object {$objectID} to node {$newParentNodeID}, " . "the current user does not have create permission for class ID {$classID}", 'content/copy');
return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
}
$db = eZDB::instance();
$db->begin();
$newObject = $object->copy($allVersions);
// We should reset section that will be updated in updateSectionID().
// If sectionID is 0 then the object has been newly created
$newObject->setAttribute('section_id', 0);
$newObject->store();
$curVersion = $newObject->attribute('current_version');
$curVersionObject = $newObject->attribute('current');
$newObjAssignments = $curVersionObject->attribute('node_assignments');
unset($curVersionObject);
// remove old node assignments
foreach ($newObjAssignments as $assignment) {
$assignment->purge();
}
// and create a new one
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $newObject->attribute('id'), 'contentobject_version' => $curVersion, 'parent_node' => $newParentNodeID, 'is_main' => 1));
$nodeAssignment->store();
// publish the newly created object
eZOperationHandler::execute('content', 'publish', array('object_id' => $newObject->attribute('id'), 'version' => $curVersion));
// Update "is_invisible" attribute for the newly created node.
$newNode = $newObject->attribute('main_node');
eZContentObjectTreeNode::updateNodeVisibility($newNode, $newParentNode);
$db->commit();
return $Module->redirectToView('view', array('full', $newParentNodeID));
}
示例13: 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 );
}
}
示例14: createObject
function createObject($classIdentifier, $parentNodeID, $name)
{
$user = eZUser::currentUser();
$Class = eZContentClass::fetchByIdentifier($classIdentifier);
if (!$Class) {
eZDebug::writeError("No class with identifier {$classIdentifier}", "classCreation");
return false;
}
$contentObject = $Class->instantiate($user->attribute('contentobject_id'));
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => $contentObject->attribute('current_version'), 'parent_node' => $parentNodeID, 'is_main' => 1));
$nodeAssignment->store();
$version = $contentObject->version(1);
$version->setAttribute('modified', eZDateTime::currentTimeStamp());
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
$contentObjectID = $contentObject->attribute('id');
$attributes = $contentObject->attribute('contentobject_attributes');
$attributes[0]->fromString($name);
$attributes[0]->store();
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => 1));
return true;
}
示例15: array
// Check if the object exists on disc
if (!eZContentObject::exists($ObjectID)) {
return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
// Check if the user can read the object
$object = eZContentObject::fetch($ObjectID);
if (!$object->canRead()) {
return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel', array('AccessList' => $object->accessList('read')));
}
// Check if the object has a price datatype, if not it cannot be used in the basket
$error = $basket->canAddProduct($object);
if ($error !== eZError::SHOP_OK) {
return $Module->handleError($error, 'shop');
}
$OptionList = $http->sessionVariable("AddToBasket_OptionList_" . $ObjectID);
$operationResult = eZOperationHandler::execute('shop', 'addtobasket', array('basket_id' => $basket->attribute('id'), 'object_id' => $ObjectID, 'quantity' => $quantity, 'option_list' => $OptionList));
switch ($operationResult['status']) {
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'];