当前位置: 首页>>代码示例>>PHP>>正文


PHP eZNodeAssignment::purgeByID方法代码示例

本文整理汇总了PHP中eZNodeAssignment::purgeByID方法的典型用法代码示例。如果您正苦于以下问题:PHP eZNodeAssignment::purgeByID方法的具体用法?PHP eZNodeAssignment::purgeByID怎么用?PHP eZNodeAssignment::purgeByID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZNodeAssignment的用法示例。


在下文中一共展示了eZNodeAssignment::purgeByID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: copyPublishContentObject


//.........这里部分代码省略.........
    // We should reset section that will be updated in updateSectionID().
    // If sectionID is 0 than the object has been newly created
    $newObject->setAttribute('section_id', 0);
    $newObject->store();
    $syncObjectIDListSrc[] = $sourceObjectID;
    $curVersion = $newObject->attribute('current_version');
    $curVersionObject = $newObject->attribute('current');
    $newObjAssignments = $curVersionObject->attribute('node_assignments');
    // copy nodeassigments:
    $assignmentsForRemoving = array();
    $foundMainAssignment = false;
    foreach ($newObjAssignments as $assignment) {
        $parentNodeID = $assignment->attribute('parent_node');
        // if assigment is outside of subtree being copied then do not copy this assigment
        $key1 = array_search($parentNodeID, $sourceSubtreeNodeIDList);
        $key2 = array_search($parentNodeID, $nodeIDBlackList);
        if ($key1 === false or $key2 !== false) {
            $assignmentsForRemoving[] = $assignment->attribute('id');
            continue;
        }
        $key = array_search($parentNodeID, $syncNodeIDListSrc);
        if ($key === false) {
            eZDebug::writeError("Cannot publish contentobject (ID={$sourceObjectID}). Parent is not published yet.", "Subtree Copy error: copyPublishContentObject()");
            return 4;
        }
        if ($assignment->attribute('is_main')) {
            $foundMainAssignment = true;
        }
        $newParentNodeID = $syncNodeIDListNew[$key];
        $assignment->setAttribute('parent_node', $newParentNodeID);
        $assignment->store();
    }
    // remove assigments which are outside of subtree being copied:
    eZNodeAssignment::purgeByID($assignmentsForRemoving);
    // if main nodeassigment was not copied then set as main first nodeassigment
    if ($foundMainAssignment == false) {
        $newObjAssignments = $curVersionObject->attribute('node_assignments');
        // We need to check if it has any assignments before changing the data.
        if (isset($newObjAssignments[0])) {
            $newObjAssignments[0]->setAttribute('is_main', 1);
            $newObjAssignments[0]->store();
        }
    }
    // publish the newly created object
    $result = eZOperationHandler::execute('content', 'publish', array('object_id' => $newObject->attribute('id'), 'version' => $curVersion));
    // Refetch the object data since it might change in the database.
    $newObjectID = $newObject->attribute('id');
    $newObject = eZContentObject::fetch($newObjectID);
    $newNodeList = $newObject->attribute('assigned_nodes');
    if (count($newNodeList) == 0) {
        $newObject->purge();
        eZDebug::writeError("Cannot publish contentobject.", "Subtree Copy Error!");
        $sourceObjectName = $srcNode->getName();
        $notifications['Warnings'][] = ezpI18n::tr('kernel/content/copysubtree', "Cannot publish object (Name: %1, ID: %2).", null, array($sourceObjectName, $sourceObjectID));
        return -1;
    }
    // Only if the object has been published successfully, the object id can be added into $syncObjectIDListNew
    $syncObjectIDListNew[] = $newObject->attribute('id');
    $objAssignments = $curVersionObject->attribute('node_assignments');
    foreach ($newNodeList as $newNode) {
        $newParentNode = $newNode->fetchParent();
        $newParentNodeID = $newParentNode->attribute('node_id');
        $keyA = array_search($newParentNodeID, $syncNodeIDListNew);
        if ($keyA === false) {
            eZDebug::writeError("Algoritm ERROR! Cannot find new parent node ID in new ID's list", "Subtree Copy Error!");
            return -2;
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:67,代码来源:copysubtree.php

示例2: removeNodes

 /**
  * Removes nodes
  *
  * This function does not check about permissions, this is the responsibility of the caller!
  *
  * @param array $removeNodeIdList Array of Node ID to remove
  *
  * @return array An array with operation status, always true
  */
 public static function removeNodes(array $removeNodeIdList)
 {
     $mainNodeChanged = array();
     $nodeAssignmentIdList = array();
     $objectIdList = array();
     $db = eZDB::instance();
     $db->begin();
     foreach ($removeNodeIdList as $nodeId) {
         $node = eZContentObjectTreeNode::fetch($nodeId);
         $objectId = $node->attribute('contentobject_id');
         foreach (eZNodeAssignment::fetchForObject($objectId, eZContentObject::fetch($objectId)->attribute('current_version'), 0, false) as $nodeAssignmentKey => $nodeAssignment) {
             if ($nodeAssignment['parent_node'] == $node->attribute('parent_node_id')) {
                 $nodeAssignmentIdList[$nodeAssignment['id']] = 1;
             }
         }
         if ($nodeId == $node->attribute('main_node_id')) {
             $mainNodeChanged[$objectId] = 1;
         }
         $node->removeThis();
         if (!isset($objectIdList[$objectId])) {
             $objectIdList[$objectId] = eZContentObject::fetch($objectId);
         }
     }
     eZNodeAssignment::purgeByID(array_keys($nodeAssignmentIdList));
     foreach (array_keys($mainNodeChanged) as $objectId) {
         $allNodes = $objectIdList[$objectId]->assignedNodes();
         // Registering node that will be promoted as 'main'
         $mainNodeChanged[$objectId] = $allNodes[0];
         eZContentObjectTreeNode::updateMainNodeID($allNodes[0]->attribute('node_id'), $objectId, false, $allNodes[0]->attribute('parent_node_id'));
     }
     // Give other search engines that the default one a chance to reindex
     // when removing locations.
     if (!eZSearch::getEngine() instanceof eZSearchEngine) {
         foreach (array_keys($objectIdList) as $objectId) {
             eZContentOperationCollection::registerSearchObject($objectId);
         }
     }
     $db->commit();
     //call appropriate method from search engine
     eZSearch::removeNodes($removeNodeIdList);
     $userClassIdList = eZUser::contentClassIDs();
     foreach ($objectIdList as $objectId => $object) {
         eZContentCacheManager::clearObjectViewCacheIfNeeded($objectId);
         // clear user policy cache if this was a user object
         if (in_array($object->attribute('contentclass_id'), $userClassIdList)) {
             eZUser::purgeUserCacheByUserId($object->attribute('id'));
         }
     }
     // we don't clear template block cache here since it's cleared in eZContentObjectTreeNode::removeNode()
     return array('status' => true);
 }
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:60,代码来源:ezcontentoperationcollection.php

示例3: array

    eZDebug::writeError("No assignments passed to content/removeassignment");
    return $module->redirectToView('view', array('full', 2));
}
// process current action
if ($module->isCurrentAction('ConfirmRemoval')) {
    $http->removeSessionVariable('AssignmentRemoveData');
    $assignments = eZNodeAssignment::fetchListByID($removeList);
    $mainNodeChanged = false;
    $db = eZDB::instance();
    $db->begin();
    foreach ($assignments as $assignment) {
        $assignmentID = $assignment->attribute('id');
        if ($assignment->attribute('is_main')) {
            $mainNodeChanged = true;
        }
        eZNodeAssignment::purgeByID($assignmentID);
    }
    if ($mainNodeChanged) {
        eZNodeAssignment::setNewMainAssignment($objectID, $editVersion);
    }
    $db->commit();
    return $module->redirectToView('edit', array($objectID, $editVersion, $editLanguage, $fromLanguage));
} else {
    if ($module->isCurrentAction('CancelRemoval')) {
        $http->removeSessionVariable('AssignmentRemoveData');
        return $module->redirectToView('edit', array($objectID, $editVersion, $editLanguage, $fromLanguage));
    }
}
// default action: show the confirmation dialog
$assignmentsToRemove = eZNodeAssignment::fetchListByID($removeList);
$removeList = array();
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:31,代码来源:removeassignment.php

示例4: copyPublishContentObject

function copyPublishContentObject($sourceObject, $sourceSubtreeNodeIDList, &$syncNodeIDListSrc, &$syncNodeIDListNew, &$syncObjectIDListSrc, &$syncObjectIDListNew, $allVersions = false, $keepCreator = false, $keepTime = false)
{
    global $cli;
    $sourceObjectID = $sourceObject->attribute('id');
    $key = array_search($sourceObjectID, $syncObjectIDListSrc);
    if ($key !== false) {
        return 1;
        // object already copied
    }
    $srcNodeList = $sourceObject->attribute('assigned_nodes');
    // check if all parent nodes for given contentobject are already published:
    foreach ($srcNodeList as $srcNode) {
        $sourceParentNodeID = $srcNode->attribute('parent_node_id');
        // if parent node for this node is outside
        // of subtree being copied, then skip this node.
        $key = array_search($sourceParentNodeID, $sourceSubtreeNodeIDList);
        if ($key === false) {
            continue;
        }
        $key = array_search($sourceParentNodeID, $syncNodeIDListSrc);
        if ($key === false) {
            return 2;
            // one of parent nodes is not published yet - have to try to publish later.
        } else {
            $newParentNodeID = $syncNodeIDListNew[$key];
            if (($newParentNode = eZContentObjectTreeNode::fetch($newParentNodeID)) === null) {
                return 3;
                // cannot fetch one of parent nodes - must be error somewhere above.
            }
        }
    }
    // make copy of source object
    $newObject = $sourceObject->copy($allVersions);
    // insert source and new object's ids in $syncObjectIDList
    // We should reset section that will be updated in updateSectionID().
    // If sectionID is 0 than the object has been newly created
    $newObject->setAttribute('section_id', 0);
    $newObject->store();
    $syncObjectIDListSrc[] = $sourceObjectID;
    $syncObjectIDListNew[] = $newObject->attribute('id');
    $curVersion = $newObject->attribute('current_version');
    $curVersionObject = $newObject->attribute('current');
    $newObjAssignments = $curVersionObject->attribute('node_assignments');
    // copy nodeassigments:
    $assignmentsForRemoving = array();
    $foundMainAssignment = false;
    foreach ($newObjAssignments as $assignment) {
        $parentNodeID = $assignment->attribute('parent_node');
        // if assigment is outside of subtree being copied then do not copy this assigment
        $key = array_search($parentNodeID, $sourceSubtreeNodeIDList);
        if ($key === false) {
            $assignmentsForRemoving[] = $assignment->attribute('id');
            continue;
        }
        $key = array_search($parentNodeID, $syncNodeIDListSrc);
        if ($key === false) {
            $cli->error("Subtree Copy Error!\nOne of parent nodes for contentobject (ID = {$sourceObjectID}) is not published yet.");
            return 4;
        }
        if ($assignment->attribute('is_main')) {
            $foundMainAssignment = true;
        }
        $newParentNodeID = $syncNodeIDListNew[$key];
        $assignment->setAttribute('parent_node', $newParentNodeID);
        $assignment->store();
    }
    // remove assigments which are outside of subtree being copied:
    eZNodeAssignment::purgeByID($assignmentsForRemoving);
    // JB valid
    // if main nodeassigment was not copied then set as main first nodeassigment
    if ($foundMainAssignment == false) {
        $newObjAssignments = $curVersionObject->attribute('node_assignments');
        // JB start
        // We need to check if it has any assignments before changing the data.
        if (isset($newObjAssignments[0])) {
            $newObjAssignments[0]->setAttribute('is_main', 1);
            $newObjAssignments[0]->store();
        }
        // JB end
    }
    // publish the newly created object
    $result = eZOperationHandler::execute('content', 'publish', array('object_id' => $newObject->attribute('id'), 'version' => $curVersion));
    // JB start
    // Refetch the object data since it might change in the database.
    $newObjectID = $newObject->attribute('id');
    $newObject = eZContentObject::fetch($newObjectID);
    // JB end
    $newNodeList = $newObject->attribute('assigned_nodes');
    if (count($newNodeList) == 0) {
        $newObject->purge();
        $cli->error("Subtree Copy Error!\nCannot publish contentobject.");
        return 5;
    }
    $objAssignments = $curVersionObject->attribute('node_assignments');
    foreach ($newNodeList as $newNode) {
        $newParentNodeID = $newNode->attribute('parent_node_id');
        $keyA = array_search($newParentNodeID, $syncNodeIDListNew);
        if ($keyA === false) {
            die("Copy Subtree Error: Algoritm ERROR! Cannot find new parent node ID in new ID's list");
        }
//.........这里部分代码省略.........
开发者ID:nlescure,项目名称:ezpublish,代码行数:101,代码来源:ezsubtreecopy.php

示例5: addNodeAssignments

 /**
  * Add an object to an array of nodes.
  *
  * The array of nodes, is given by the post field ymcActiveNodeAssignmentsPool[]
  *
  * This hook is run at "post_fetch" 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 void
  */
 public function addNodeAssignments($module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage, &$validation)
 {
     $http = eZHTTPTool::instance();
     // UseNodeAssignments is only set in two templates, where it is 0:
     // design/admin/templates/content/edit.tpl
     // design/admin/override/templates/content/template_look_edit.tpl
     //
     // This means, that we exit here, if we come from these templates.
     if ($http->hasPostVariable('UseNodeAssigments')) {
         //@todo: Should we really return here? Wouldn't it be better to trigger the
         //add and removal actions also from the admin interface?
         //            return;
     }
     $ObjectID = $object->attribute('id');
     // Assign to nodes
     if ($http->hasPostVariable('ymcActiveNodeAssignmentsPool') && is_array($http->postVariable('ymcActiveNodeAssignmentsPool'))) {
         $selectedNodeIDArray = $http->postVariable('ymcActiveNodeAssignmentsPool');
         $assignedIDArray = array();
         $setMainNode = false;
         $hasMainNode = false;
         // * Get all nodes, to which the object is already assigned to and
         //   put them in $assignedIDArray[]
         //
         // * Also removed assignments, but did not understant this.
         //
         // nodeAssignments returns array of eZNodeAssignment
         foreach ($version->nodeAssignments() as $assignedNode) {
             $assignedNodeID = $assignedNode->attribute('parent_node');
             if ($assignedNode->attribute('is_main')) {
                 $hasMainNode = true;
             }
             if ($assignedNode->attribute('op_code') === eZNodeAssignment::OP_CODE_REMOVE && in_array($assignedNodeID, $selectedNodeIDArray)) {
                 if ($assignedNode->attribute('is_main')) {
                     $hasMainNode = false;
                 }
                 eZNodeAssignment::purgeByID($assignedNode->attribute('id'));
             } else {
                 $assignedIDArray[] = $assignedNodeID;
             }
         }
         if (!$hasMainNode) {
             $setMainNode = true;
         }
         foreach ($selectedNodeIDArray as $nodeID) {
             if ((int) $nodeID > 0 and !in_array((int) $nodeID, $assignedIDArray)) {
                 $nodeID = (int) $nodeID;
                 $isPermitted = true;
                 // Check access
                 $newNode = eZContentObjectTreeNode::fetch($nodeID);
                 if (is_object($newNode)) {
                     $newNodeObject = $newNode->attribute('object');
                     $canCreate = $newNodeObject->checkAccess('create', $class->attribute('id'), $newNodeObject->attribute('contentclass_id')) == 1;
                     if (!$canCreate) {
                         $isPermitted = false;
                     } else {
                         $canCreateClassList = $newNodeObject->attribute('can_create_class_list');
                         $objectClassID = $object->attribute('contentclass_id');
                         $canCreateClassIDList = array();
                         foreach (array_keys($canCreateClassList) as $key) {
                             $canCreateClassIDList[] = $canCreateClassList[$key]['id'];
                         }
                         if (!in_array($objectClassID, $canCreateClassIDList)) {
                             $isPermitted = false;
                         }
                     }
                     if (!$isPermitted) {
                         eZDebug::writeError($newNode->attribute('path_identification_string'), "[ymcEdit] You are not allowed to place this object under:");
                         $validation['placement'][] = array('text' => ezi18n('kernel/content', 'You are not allowed to place this object under: %1', null, array($newNode->attribute('url_alias'))));
                         $validation['processed'] = true;
                         // Error message.
                     } else {
                         $isMain = 0;
                         $db = eZDB::instance();
                         $db->begin();
                         $version->assignToNode($nodeID, $isMain);
                         $db->commit();
                     }
                 } else {
                     eZDebug::writeError($nodeID, "[ymcEdit] Tried to place an object on a non existing node with id:");
                     $validation['placement'][] = array('text' => ezi18n('kernel/content', 'You can not place this object on a non existing location'));
                     $validation['processed'] = true;
//.........这里部分代码省略.........
开发者ID:kmajkowski,项目名称:ymc-ezp-datatypes,代码行数:101,代码来源:ymc_edit_hooks.php


注:本文中的eZNodeAssignment::purgeByID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。