本文整理汇总了PHP中eZNodeAssignment::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP eZNodeAssignment::fetch方法的具体用法?PHP eZNodeAssignment::fetch怎么用?PHP eZNodeAssignment::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZNodeAssignment
的用法示例。
在下文中一共展示了eZNodeAssignment::fetch方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: move
static function move($nodeID, $newParentNodeID)
{
$result = false;
if (!is_numeric($nodeID) || !is_numeric($newParentNodeID)) {
return false;
}
$node = eZContentObjectTreeNode::fetch($nodeID);
if (!$node) {
return false;
}
$object = $node->object();
if (!$object) {
return false;
}
$objectID = $object->attribute('id');
$oldParentNode = $node->fetchParent();
$oldParentObject = $oldParentNode->object();
// clear user policy cache if this is a user object
if (in_array($object->attribute('contentclass_id'), eZUser::contentClassIDs())) {
eZUser::purgeUserCacheByUserId($object->attribute('id'));
}
// clear cache for old placement.
eZContentCacheManager::clearContentCacheIfNeeded($objectID);
$db = eZDB::instance();
$db->begin();
$node->move($newParentNodeID);
$newNode = eZContentObjectTreeNode::fetchNode($objectID, $newParentNodeID);
if ($newNode) {
$newNode->updateSubTreePath(true, true);
if ($newNode->attribute('main_node_id') == $newNode->attribute('node_id')) {
// If the main node is moved we need to check if the section ID must change
$newParentNode = $newNode->fetchParent();
$newParentObject = $newParentNode->object();
if ($object->attribute('section_id') != $newParentObject->attribute('section_id')) {
eZContentObjectTreeNode::assignSectionToSubTree($newNode->attribute('main_node_id'), $newParentObject->attribute('section_id'), $oldParentObject->attribute('section_id'));
}
}
// modify assignment
$curVersion = $object->attribute('current_version');
$nodeAssignment = eZNodeAssignment::fetch($objectID, $curVersion, $oldParentNode->attribute('node_id'));
if ($nodeAssignment) {
$nodeAssignment->setAttribute('parent_node', $newParentNodeID);
$nodeAssignment->setAttribute('op_code', eZNodeAssignment::OP_CODE_MOVE);
$nodeAssignment->store();
// update search index
$nodeIDList = array($nodeID);
eZSearch::removeNodeAssignment($node->attribute('main_node_id'), $newNode->attribute('main_node_id'), $object->attribute('id'), $nodeIDList);
eZSearch::addNodeAssignment($newNode->attribute('main_node_id'), $object->attribute('id'), $nodeIDList);
}
$result = true;
} else {
eZDebug::writeError("Node {$nodeID} was moved to {$newParentNodeID} but fetching the new node failed");
}
$db->commit();
// clear cache for new placement.
eZContentCacheManager::clearContentCacheIfNeeded($objectID);
return $result;
}
示例2: publishNode
public static function publishNode($parentNodeID, $objectID, $versionNum, $mainNodeID)
{
$object = eZContentObject::fetch($objectID);
$nodeAssignment = eZNodeAssignment::fetch($objectID, $versionNum, $parentNodeID);
$version = $object->version($versionNum);
$fromNodeID = $nodeAssignment->attribute('from_node_id');
$originalObjectID = $nodeAssignment->attribute('contentobject_id');
$nodeID = $nodeAssignment->attribute('parent_node');
$opCode = $nodeAssignment->attribute('op_code');
$parentNode = eZContentObjectTreeNode::fetch($nodeID);
// if parent doesn't exist, return. See issue #18320
if (!$parentNode instanceof eZContentObjectTreeNode) {
eZDebug::writeError("Parent node doesn't exist. object id: {$objectID}, node_assignment id: " . $nodeAssignment->attribute('id'), __METHOD__);
return;
}
$parentNodeID = $parentNode->attribute('node_id');
$existingNode = null;
$db = eZDB::instance();
$db->begin();
if (strlen($nodeAssignment->attribute('parent_remote_id')) > 0) {
$existingNode = eZContentObjectTreeNode::fetchByRemoteID($nodeAssignment->attribute('parent_remote_id'));
}
if (!$existingNode) {
}
$existingNode = eZContentObjectTreeNode::findNode($nodeID, $object->attribute('id'), true);
$updateSectionID = false;
// now we check the op_code to see what to do
if (($opCode & 1) == eZNodeAssignment::OP_CODE_NOP) {
// There is nothing to do so just return
$db->commit();
if ($mainNodeID == false) {
return $object->attribute('main_node_id');
}
return;
}
$updateFields = false;
if ($opCode == eZNodeAssignment::OP_CODE_MOVE || $opCode == eZNodeAssignment::OP_CODE_CREATE) {
// if ( $fromNodeID == 0 || $fromNodeID == -1)
if ($opCode == eZNodeAssignment::OP_CODE_CREATE || $opCode == eZNodeAssignment::OP_CODE_SET) {
// If the node already exists it means we have a conflict (for 'CREATE').
// We resolve this by leaving node-assignment data be.
if ($existingNode == null) {
$parentNode = eZContentObjectTreeNode::fetch($nodeID);
$user = eZUser::currentUser();
if (!eZSys::isShellExecution() and !$user->isAnonymous()) {
eZContentBrowseRecent::createNew($user->id(), $parentNode->attribute('node_id'), $parentNode->attribute('name'));
}
$updateFields = true;
$existingNode = $parentNode->addChild($object->attribute('id'), true);
if ($fromNodeID == -1) {
$updateSectionID = true;
}
} elseif ($opCode == eZNodeAssignment::OP_CODE_SET) {
$updateFields = true;
}
} elseif ($opCode == eZNodeAssignment::OP_CODE_MOVE) {
if ($fromNodeID == 0 || $fromNodeID == -1) {
eZDebug::writeError("NodeAssignment '" . $nodeAssignment->attribute('id') . "' is marked with op_code='{$opCode}' but has no data in from_node_id. Cannot use it for moving node.", __METHOD__);
} else {
// clear cache for old placement.
$additionalNodeIDList = array($fromNodeID);
eZContentCacheManager::clearContentCacheIfNeeded($objectID, $versionNum, $additionalNodeIDList);
$originalNode = eZContentObjectTreeNode::fetchNode($originalObjectID, $fromNodeID);
if ($originalNode->attribute('main_node_id') == $originalNode->attribute('node_id')) {
$updateSectionID = true;
}
$originalNode->move($parentNodeID);
$existingNode = eZContentObjectTreeNode::fetchNode($originalObjectID, $parentNodeID);
$updateFields = true;
}
}
} elseif ($opCode == eZNodeAssignment::OP_CODE_REMOVE) {
$db->commit();
return;
}
if ($updateFields) {
if (strlen($nodeAssignment->attribute('parent_remote_id')) > 0) {
$existingNode->setAttribute('remote_id', $nodeAssignment->attribute('parent_remote_id'));
}
$existingNode->setAttribute('sort_field', $nodeAssignment->attribute('sort_field'));
$existingNode->setAttribute('sort_order', $nodeAssignment->attribute('sort_order'));
}
$existingNode->setAttribute('contentobject_is_published', 1);
eZDebug::createAccumulatorGroup('nice_urls_total', 'Nice urls');
if ($mainNodeID > 0) {
$existingNodeID = $existingNode->attribute('node_id');
if ($existingNodeID != $mainNodeID) {
eZContentBrowseRecent::updateNodeID($existingNodeID, $mainNodeID);
}
$existingNode->setAttribute('main_node_id', $mainNodeID);
} else {
$existingNode->setAttribute('main_node_id', $existingNode->attribute('node_id'));
}
$existingNode->store();
if ($updateSectionID) {
eZContentOperationCollection::updateSectionID($objectID, $versionNum);
}
$db->commit();
if ($mainNodeID == false) {
return $existingNode->attribute('node_id');
//.........这里部分代码省略.........
示例3: checkNodeActions
//.........这里部分代码省略.........
// If node assignment handling is diabled we return
$useNodeAssigments = true;
if ( $http->hasPostVariable( 'UseNodeAssigments' ) )
$useNodeAssigments = (bool)$http->postVariable( 'UseNodeAssigments' );
if ( !$useNodeAssigments )
return;
// Remove custom actions from attribute editing.
$http->removeSessionVariable( 'BrowseCustomAction' );
if ( $module->isCurrentAction( 'ConfirmAssignmentDelete' ) && $http->hasPostVariable( 'RemoveNodeID' ) )
{
$nodeID = $http->postVariable( 'RemoveNodeID' );
$db = eZDB::instance();
$db->begin();
$version->removeAssignment( $nodeID );
$db->commit();
}
if ( $module->isCurrentAction( 'DeleteNode' ) )
{
if ( $http->hasPostVariable( 'RemoveNodeID' ) )
{
$nodeID = $http->postVariable( 'RemoveNodeID' );
}
$mainNodeID = $http->postVariable( 'MainNodeID' );
// if ( $nodeID != $mainNodeID )
{
$objectID = $object->attribute( 'id' );
$publishedNode = eZContentObjectTreeNode::fetchNode( $objectID, $nodeID );
if ( $publishedNode != null )
{
$publishParentNodeID = $publishedNode->attribute( 'parent_node_id' );
if ( $publishParentNodeID > 1 )
{
$childrenCount = $publishedNode->childrenCount();
if ( $childrenCount != 0 )
{
$module->redirectToView( 'removenode', array( $objectID, $editVersion, $editLanguage, $nodeID ) );
return eZModule::HOOK_STATUS_CANCEL_RUN;
}
else
{
$db = eZDB::instance();
$db->begin();
$version->removeAssignment( $nodeID );
$db->commit();
}
}
}
else
{
$nodeAssignment = eZNodeAssignment::fetch( $objectID, $version->attribute( 'version' ), $nodeID );
if ( $nodeAssignment->attribute( 'from_node_id' ) != 0 )
{
$publishedNode = eZContentObjectTreeNode::fetchNode( $objectID, $nodeAssignment->attribute( 'from_node_id' ) );
$childrenCount = 0;
if ( $publishedNode !== null )
$childrenCount = $publishedNode->childrenCount();
if ( $childrenCount != 0 )
{
$module->redirectToView( 'removenode', array( $objectID, $editVersion, $editLanguage, $nodeID ) );
示例4: onPublish
function onPublish($contentObjectAttribute, $contentObject, $publishedNodes)
{
$content = $contentObjectAttribute->content();
foreach ($content['relation_list'] as $key => $relationItem) {
if ($relationItem['is_modified']) {
$subObjectID = $relationItem['contentobject_id'];
$subObjectVersion = $relationItem['contentobject_version'];
$object = eZContentObject::fetch($subObjectID);
$time = time();
$version = eZContentObjectVersion::fetchVersion($subObjectVersion, $subObjectID);
$version->setAttribute('modified', $time);
$version->store();
if ($relationItem['parent_node_id'] > 0) {
// action 1: edit a normal object
if (!eZNodeAssignment::fetch($object->attribute('id'), $object->attribute('current_version'), $relationItem['parent_node_id'], false)) {
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $object->attribute('id'), 'contentobject_version' => $object->attribute('current_version'), 'parent_node' => $relationItem['parent_node_id'], 'sort_field' => eZContentObjectTreeNode::SORT_FIELD_PUBLISHED, 'sort_order' => eZContentObjectTreeNode::SORT_ORDER_DESC, 'is_main' => 1));
$nodeAssignment->store();
}
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $object->attribute('id'), 'version' => $subObjectVersion));
$objectNodeID = $object->attribute('main_node_id');
$content['relation_list'][$key]['node_id'] = $objectNodeID;
} else {
// action 2: edit a nodeless object (or creating a new node
// Make the previous version archived
$currentVersion = $object->currentVersion();
$currentVersion->setAttribute('status', eZContentObjectVersion::STATUS_ARCHIVED);
$currentVersion->setAttribute('modified', $time);
$currentVersion->store();
$version->setAttribute('status', eZContentObjectVersion::STATUS_PUBLISHED);
$version->store();
$object->setAttribute('status', eZContentObject::STATUS_PUBLISHED);
if (!$object->attribute('published')) {
$object->setAttribute('published', $time);
}
$object->setAttribute('modified', $time);
$object->setAttribute('current_version', $subObjectVersion);
$class = $object->contentClass();
$objectName = $class->contentObjectName($object, $version->attribute('version'));
$object->setName($objectName, $version->attribute('version'));
$object->store();
if (!eZNodeAssignment::fetch($object->attribute('id'), $object->attribute('current_version'), $contentObject->attribute('main_node_id'), false)) {
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $object->attribute('id'), 'contentobject_version' => $object->attribute('current_version'), 'parent_node' => $contentObject->attribute('main_node_id'), 'sort_field' => eZContentObjectTreeNode::SORT_FIELD_PUBLISHED, 'sort_order' => eZContentObjectTreeNode::SORT_ORDER_DESC, 'is_main' => 1));
$nodeAssignment->store();
}
}
$content['relation_list'][$key]['is_modified'] = false;
}
}
$this->storeObjectAttributeContent($contentObjectAttribute, $content);
$contentObjectAttribute->setContent($content);
$contentObjectAttribute->store();
}
示例5: foreach
eZNodeAssignment::removeByID($nodeAssignment->attribute('id'));
}
}
if ($hasOtherNodeType) {
foreach ($otherNodeArray as $otherNode) {
if (!in_array($otherNode['parent_node_id'], $noAddAssignmentList)) {
$newVersion->assignToNode($otherNode['parent_node_id'], $otherNode['is_main']);
}
}
}
if ($hasLDAPNodeType) {
foreach ($newLDAPNodeArray as $newLDAPNode) {
if (!in_array($newLDAPNode['parent_node_id'], $noAddAssignmentList)) {
$newVersion->assignToNode($newLDAPNode['parent_node_id'], $newLDAPNode['is_main']);
}
$assignment = eZNodeAssignment::fetch($contentObject->attribute('id'), $newVersionNr, $newLDAPNode['parent_node_id']);
$assignment->setAttribute('parent_remote_id', uniqid('LDAP_'));
$assignment->store();
}
}
if (!$hasOtherNodeType and !$hasLDAPNodeType) {
if (!in_array($defaultUserPlacement, $noAddAssignmentList)) {
$newVersion->assignToNode($defaultUserPlacement, 1);
}
}
$adminUser = eZUser::fetchByName('admin');
$adminUserContentObjectID = $adminUser->attribute('contentobject_id');
eZUser::setCurrentlyLoggedInUser($adminUser, $adminUserContentObjectID);
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $userID, 'version' => $newVersionNr));
$cli->output($cli->stylize('emphasize', $existUser->attribute('login')) . " has changed group, updated.");
}
示例6: removeNodeAssignments
/**
* Removes previously selected, now unselected assignments.
*
* This hook is run at "post_store" time.
*
* @param mixed $module Is eZModule.
* @param mixed $class Is eZContentClass.
* @param mixed $object Is eZContentObject.
* @param mixed $version Is eZContentObjectVersion.
* @param mixed $contentObjectAttributes Is eZContentObjectAttribute.
* @param string $editVersion Number as String.
* @param string $editLanguage E.g. eng-GB.
* @param mixed $fromLanguage Or false.
* @param mixed &$validation Array.
*
* @return int eZModule::HOOK_STATUS_CANCEL_RUN
*/
public function removeNodeAssignments($module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage, &$validation)
{
$http = eZHTTPTool::instance();
if (!$http->hasPostVariable('ymcNodeAssignmentsPool')) {
return eZModule::HOOK_STATUS_OK;
}
$ymcActiveNodeAssignmentsPool = $http->postVariable('ymcActiveNodeAssignmentsPool');
$ymcNodeAssignmentsPool = $http->postVariable('ymcNodeAssignmentsPool');
if (!is_array($ymcActiveNodeAssignmentsPool)) {
$ymcActiveNodeAssignmentsPool = array();
}
if (!is_array($ymcNodeAssignmentsPool)) {
$ymcNodeAssignmentsPool = array();
}
$selected = array();
foreach ($ymcNodeAssignmentsPool as $ymcAllNodeAssignment) {
if ((int) $ymcAllNodeAssignment > 0 and !in_array($ymcAllNodeAssignment, $ymcActiveNodeAssignmentsPool)) {
$selected[] = (int) $ymcAllNodeAssignment;
}
}
$objectID = $object->attribute('id');
$versionInt = $version->attribute('version');
$hasChildren = false;
$assignmentsIDs = array();
$assignments = array();
// Determine if at least one node of ones we remove assignments for has children.
foreach ($selected as $parentNodeID) {
$assignment = eZNodeAssignment::fetch($objectID, $versionInt, $parentNodeID);
if (!$assignment) {
eZDebug::writeWarning("[ymcEdit] No assignment found for object {$objectID} version {$versionInt},\n parent node {$parentNodeID}");
continue;
}
$assignmentID = $assignment->attribute('id');
$assignmentsIDs[] = $assignmentID;
$assignments[] =& $assignment;
$node =& $assignment->attribute('node');
if (!$node) {
continue;
}
if ($node->childrenCount(false) > 0) {
$hasChildren = true;
}
unset($assignment);
}
if ($hasChildren) {
// We need user confirmation if at least one node we want to
// remove assignment for contains children. Aactual removal is
// done in content/removeassignment in this case.
$http->setSessionVariable('AssignmentRemoveData', array('remove_list' => $assignmentsIDs, 'object_id' => $objectID, 'edit_version' => $versionInt, 'edit_language' => $editLanguage, 'from_language' => $fromLanguage));
$module->redirectToView('removeassignment');
return eZModule::HOOK_STATUS_CANCEL_RUN;
} else {
// Just remove all the selected locations.
$mainNodeChanged = false;
$db = eZDB::instance();
$db->begin();
foreach ($assignments as $assignment) {
$assignmentID = $assignment->attribute('id');
if ($assignment->attribute('is_main')) {
$mainNodeChanged = true;
}
eZNodeAssignment::removeByID($assignmentID);
}
if ($mainNodeChanged) {
eZNodeAssignment::setNewMainAssignment($objectID, $versionInt);
}
$db->commit();
unset($mainNodeChanged);
}
unset($assignmentsIDs, $assignments);
}
示例7: onPublish
function onPublish($contentObjectAttribute, $contentObject, $publishedNodes)
{
$content = $contentObjectAttribute->content();
foreach ($content['relation_browse'] as $key => $relationItem) {
if ($relationItem['is_modified']) {
$subObjectID = $relationItem['contentobject_id'];
$subObjectVersion = $relationItem['contentobject_version'];
$object = eZContentObject::fetch($subObjectID);
if ($object) {
$class = $object->contentClass();
$time = time();
// Make the previous version archived
$currentVersion = $object->currentVersion();
$currentVersion->setAttribute('status', eZContentObjectVersion::STATUS_ARCHIVED);
$currentVersion->setAttribute('modified', $time);
$currentVersion->store();
$version = eZContentObjectVersion::fetchVersion($subObjectVersion, $subObjectID);
$version->setAttribute('modified', $time);
$version->setAttribute('status', eZContentObjectVersion::STATUS_PUBLISHED);
$version->store();
$object->setAttribute('status', eZContentObject::STATUS_PUBLISHED);
if (!$object->attribute('published')) {
$object->setAttribute('published', $time);
}
$object->setAttribute('modified', $time);
$object->setAttribute('current_version', $version->attribute('version'));
$object->setAttribute('is_published', true);
$objectName = $class->contentObjectName($object, $version->attribute('version'));
$object->setName($objectName, $version->attribute('version'));
$object->store();
}
if ($relationItem['parent_node_id'] > 0) {
if (!eZNodeAssignment::fetch($object->attribute('id'), $object->attribute('current_version'), $relationItem['parent_node_id'], false)) {
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $object->attribute('id'), 'contentobject_version' => $object->attribute('current_version'), 'parent_node' => $relationItem['parent_node_id'], 'sort_field' => 2, 'sort_order' => 0, 'is_main' => 1));
$nodeAssignment->store();
}
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $object->attribute('id'), 'version' => $object->attribute('current_version')));
$objectNodeID = $object->attribute('main_node_id');
$content['relation_browse'][$key]['node_id'] = $objectNodeID;
} else {
if (!eZNodeAssignment::fetch($object->attribute('id'), $object->attribute('current_version'), $contentObject->attribute('main_node_id'), false)) {
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $object->attribute('id'), 'contentobject_version' => $object->attribute('current_version'), 'parent_node' => $contentObject->attribute('main_node_id'), 'sort_field' => 2, 'sort_order' => 0, 'is_main' => 1));
$nodeAssignment->store();
}
}
$content['relation_browse'][$key]['is_modified'] = false;
}
}
eZObjectRelationBrowseType::storeObjectAttributeContent($contentObjectAttribute, $content);
$contentObjectAttribute->setContent($content);
$contentObjectAttribute->store();
}