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');
     }
 }
Пример #2
0
        eZSession::garbageCollector();
        $activeCount = eZSession::countActive();
        $cli->output( " " . $cli->stylize( 'emphasize', $activeCount ) . " left" );
    }
}

if ( $clean['preferences'] )
{
    $cli->output( "Removing all preferences" );
    eZPreferences::cleanup();
}

if ( $clean['browse'] )
{
    $cli->output( "Removing all recent items and bookmarks for browse page" );
    eZContentBrowseRecent::cleanup();
    eZContentBrowseBookmark::cleanup();
}

if ( $clean['tipafriend'] )
{
    $cli->output( "Removing all counters for tip-a-friend" );
    eZTipafriendCounter::cleanup();
}

if ( $clean['shop'] )
{
    $cli->output( "Removing all baskets" );
    eZBasket::cleanup();
    $cli->output( "Removing all wishlists" );
    eZWishList::cleanup();
 function removeThis()
 {
     $ini = eZINI::instance();
     $object = $this->object();
     $nodeID = $this->attribute('node_id');
     $objectID = $object->attribute('id');
     if (eZAudit::isAuditEnabled()) {
         // Set audit params.
         $objectName = $object->attribute('name');
         eZAudit::writeAudit('content-delete', array('Node ID' => $nodeID, 'Object ID' => $objectID, 'Content Name' => $objectName, 'Comment' => 'Removed the current node: eZContentObjectTreeNode::removeNode()'));
     }
     $db = eZDB::instance();
     $db->begin();
     $nodePath = $this->attribute('path_string');
     $childrensPath = $nodePath;
     $pathString = " path_string like '{$childrensPath}%' ";
     $urlAlias = $this->attribute('url_alias');
     // Remove static cache
     if ($ini->variable('ContentSettings', 'StaticCache') == 'enabled') {
         $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler');
         $options = new ezpExtensionOptions($optionArray);
         $staticCacheHandler = eZExtension::getHandlerClass($options);
         $staticCacheHandler->removeURL("/" . $urlAlias);
         $staticCacheHandler->generateAlwaysUpdatedCache();
         $parent = $this->fetchParent();
     }
     $db->query("DELETE FROM ezcontentobject_tree\n                            WHERE {$pathString} OR\n                            path_string = '{$nodePath}'");
     // Re-cache parent node
     if ($ini->variable('ContentSettings', 'StaticCache') == 'enabled') {
         if ($parent) {
             $staticCacheHandler->cacheURL("/" . $parent->urlAlias());
         }
     }
     // Clean up URL alias entries
     eZURLAliasML::removeByAction('eznode', $nodeID);
     // Clean up content cache
     eZContentCacheManager::clearContentCacheIfNeeded($this->attribute('contentobject_id'));
     // clean up user cache
     if (in_array($object->attribute('contentclass_id'), eZUser::contentClassIDs())) {
         eZUser::removeSessionData($objectID);
         eZUser::purgeUserCacheByUserId($objectID);
     }
     $parentNode = $this->attribute('parent');
     if (is_object($parentNode)) {
         eZContentCacheManager::clearContentCacheIfNeeded($parentNode->attribute('contentobject_id'));
         $parentNode->updateAndStoreModified();
         eZNodeAssignment::purgeByParentAndContentObjectID($parentNode->attribute('node_id'), $objectID);
     }
     // Clean up policies and limitations
     eZRole::cleanupByNode($this);
     // Clean up recent items
     eZContentBrowseRecent::removeRecentByNodeID($nodeID);
     // Clean up bookmarks
     eZContentBrowseBookmark::removeByNodeID($nodeID);
     // Clean up tip-a-friend counter
     eZTipafriendCounter::removeForNode($nodeID);
     // Clean up view counter
     eZViewCounter::removeCounter($nodeID);
     $db->commit();
 }
 public static function fetchRecent()
 {
     $user = eZUser::currentUser();
     return array('result' => eZContentBrowseRecent::fetchListForUser($user->id()));
 }
 static function createNew($userID, $nodeID, $nodeName)
 {
     $recentCountList = eZPersistentObject::fetchObjectList(eZContentBrowseRecent::definition(), array(), array('user_id' => $userID), false, null, false, false, array(array('operation' => 'count( * )', 'name' => 'count')));
     $matchingRecentList = eZPersistentObject::fetchObjectList(eZContentBrowseRecent::definition(), null, array('user_id' => $userID, 'node_id' => $nodeID), null, null, true);
     // If we already have the node in the list just return
     if (count($matchingRecentList) > 0) {
         $oldItem = $matchingRecentList[0];
         $oldItem->setAttribute('created', time());
         $oldItem->store();
         return $oldItem;
     }
     $recentCount = 0;
     if (isset($recentCountList[0]) and count($recentCountList[0]) > 0) {
         $recentCount = $recentCountList[0]['count'];
     }
     $maximumCount = eZContentBrowseRecent::maximumRecentItems($userID);
     // Remove oldest item
     $db = eZDB::instance();
     $db->begin();
     if ($recentCount > $maximumCount) {
         $recentCountList = eZPersistentObject::fetchObjectList(eZContentBrowseRecent::definition(), null, array('user_id' => $userID), array('created' => 'asc'), array('length' => $recentCount - $maximumCount, 'offset' => 0), true);
         foreach ($recentCountList as $countList) {
             $eldest = $countList;
             $eldest->remove();
         }
     }
     $recent = new eZContentBrowseRecent(array('user_id' => $userID, 'node_id' => $nodeID, 'name' => $nodeName, 'created' => time()));
     $recent->store();
     $db->commit();
     return $recent;
 }