static function createNew($userID, $nodeID, $nodeName)
 {
     $db = eZDB::instance();
     $db->begin();
     $userID = (int) $userID;
     $nodeID = (int) $nodeID;
     $nodeName = $db->escapeString($nodeName);
     $db->query("DELETE FROM ezcontentbrowsebookmark WHERE node_id={$nodeID} and user_id={$userID}");
     $bookmark = new eZContentBrowseBookmark(array('user_id' => $userID, 'node_id' => $nodeID, 'name' => $nodeName));
     $bookmark->store();
     $db->commit();
     return $bookmark;
 }
Пример #2
0
 /**
  * Gets current users bookmarks by offset and limit
  *
  * @param array $args  0 => offset:0, 1 => limit:10
  * @return hash
  */
 public static function bookmarks($args)
 {
     $offset = isset($args[0]) ? (int) $args[0] : 0;
     $limit = isset($args[1]) ? (int) $args[1] : 10;
     $http = eZHTTPTool::instance();
     $user = eZUser::currentUser();
     $sort = 'desc';
     if (!$user instanceof eZUser) {
         throw new ezcBaseFunctionalityNotSupportedException('Bookmarks retrival', 'current user object is not of type eZUser');
     }
     $userID = $user->attribute('contentobject_id');
     if ($http->hasPostVariable('SortBy') && $http->postVariable('SortBy') !== 'asc') {
         $sort = 'asc';
     }
     // fetch bookmarks
     $count = eZPersistentObject::count(eZContentBrowseBookmark::definition(), array('user_id' => $userID));
     if ($count) {
         $objectList = eZPersistentObject::fetchObjectList(eZContentBrowseBookmark::definition(), null, array('user_id' => $userID), array('id' => $sort), array('offset' => $offset, 'length' => $limit), true);
     } else {
         $objectList = false;
     }
     // Simplify node list so it can be encoded
     if ($objectList) {
         $list = ezjscAjaxContent::nodeEncode($objectList, array('loadImages' => true, 'fetchNodeFunction' => 'fetchNode', 'fetchChildrenCount' => true), 'raw');
     } else {
         $list = array();
     }
     return array('list' => $list, 'count' => $count ? count($objectList) : 0, 'total_count' => (int) $count, 'offset' => $offset, 'limit' => $limit);
 }
Пример #3
0
 function runOperation(&$node)
 {
     $target_parent_node_id = $this->target_id;
     if (empty($target_parent_node_id)) {
         if ($this->move_to_depth >= $node->attribute('depth')) {
             return false;
         }
         // Find the correct target node for the specified depth
         $path_array = $node->attribute('path_array');
         $target_parent_node_id = $path_array[$this->move_to_depth - 1];
     }
     $assigned_nodes = $node->attribute('object')->attribute('assigned_nodes');
     // Find the target node
     foreach ($assigned_nodes as $target_node) {
         if ($target_node->attribute('parent_node_id') == $target_parent_node_id) {
             $target_node_id = $target_node->attribute('node_id');
             // Make sure target node is not us
             if ($node->attribute('node_id') == $target_node_id) {
                 return false;
             }
             $urlalias_list = eZURLAliasML::fetchByAction('eznode', $node->attribute('node_id'));
             $target_node_urlalias_list = eZURLAliasML::fetchByAction('eznode', $target_node_id);
             // Sanity check, this should never happen
             if (!isset($target_node_urlalias_list[0])) {
                 eZDebug::writeError('Found no url alias records for node with id ' . $target_node_id, 'batchtool/nodemerge');
                 return false;
             }
             $target_node_urlalias_id = $target_node_urlalias_list[0]->attribute('id');
             $target_parent_urlalias_id = $target_node_urlalias_list[0]->attribute('parent');
             $db = eZDB::instance();
             $db->begin();
             // Make sure any children nodes are moved to the new node
             foreach ($node->attribute('children') as $child) {
                 moveNode($child, $target_node_id);
             }
             // Make sure any bookmarks are moved to the new node
             $bookmark_list = eZPersistentObject::fetchObjectList(eZContentBrowseBookmark::definition(), null, array('node_id' => $node->attribute('node_id')));
             foreach ($bookmark_list as $bookmark) {
                 $bookmark->setAttribute('node_id', $target_node_id);
                 $bookmark->store();
             }
             // Remove the node in question
             $node->removeNodeFromTree(true);
             // Set up url alias redirects to the new node
             foreach ($urlalias_list as $url_alias) {
                 $url_alias->setAttribute('action', 'eznode:' . $target_node_id);
                 $url_alias->setAttribute('action_type', 'eznode');
                 $url_alias->setAttribute('link', $target_node_urlalias_id);
                 $url_alias->setAttribute('is_original', 0);
                 $url_alias->store();
             }
             $db->commit();
             return true;
         }
     }
     return false;
 }
 function modify($tpl, $operatorName, $operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
 {
     switch ($operatorName) {
         case 'is_bookmarked':
             $bookmarkList = eZPersistentObject::fetchObjectList(eZContentBrowseBookmark::definition(), null, array('user_id' => eZUser::currentUserID(), 'node_id' => $namedParameters['node_id']), array('id' => 'desc'), array('offset' => 0, 'length' => '10'), true);
             if (count($bookmarkList) > 0) {
                 $operatorValue = 1;
             } else {
                 $operatorValue = 0;
             }
             break;
         case 'is_in_subscribed_nodes':
             $subscriptionList = eZPersistentObject::fetchObjectList(eZSubtreeNotificationRule::definition(), array('node_id'), array('user_id' => eZUser::currentUserID(), 'node_id' => $namedParameters['node_id']), null, null, false);
             if (count($subscriptionList) > 0) {
                 $operatorValue = 1;
             } else {
                 $operatorValue = 0;
             }
             break;
     }
 }
Пример #5
0
         $objectID = $http->postVariable('ContentObjectID');
         eZContentCacheManager::clearContentCache($objectID);
     }
     if ($http->hasPostVariable('RedirectURIAfterPriority')) {
         return $module->redirectTo($http->postVariable('RedirectURIAfterPriority'));
     }
     $module->redirectTo($module->functionURI('view') . '/' . $viewMode . '/' . $contentNodeID . '/');
     return;
 } else {
     if ($http->hasPostVariable("ActionAddToBookmarks")) {
         $user = eZUser::currentUser();
         $nodeID = false;
         if ($http->hasPostVariable('ContentNodeID')) {
             $nodeID = $http->postVariable('ContentNodeID');
             $node = eZContentObjectTreeNode::fetch($nodeID);
             $bookmark = eZContentBrowseBookmark::createNew($user->id(), $nodeID, $node->attribute('name'));
         }
         if (!$nodeID) {
             $contentINI = eZINI::instance('content.ini');
             $nodeID = $contentINI->variable('NodeSettings', 'RootNode');
         }
         $viewMode = $http->postVariable('ViewMode', 'full');
         $module->redirectTo($module->functionURI('view') . '/' . $viewMode . '/' . $nodeID . '/');
         return;
     } else {
         if ($http->hasPostVariable("ActionAddToNotification")) {
             $nodeID = $http->postVariable('ContentNodeID');
             $module->redirectTo('notification/addtonotification/' . $nodeID . '/');
             return;
         } else {
             if ($http->hasPostVariable("ContentObjectID")) {
Пример #6
0
        $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();
    $cli->output( "Removing all orders" );
Пример #7
0
                                    $Module );
}
else if ( $Module->isCurrentAction( 'AddBookmark' )  )
{
    $nodeList = eZContentBrowse::result( 'AddBookmark' );
    if ( $nodeList )
    {
        $db = eZDB::instance();
        $db->begin();
        foreach ( $nodeList as $nodeID )
        {
            $node = eZContentObjectTreeNode::fetch( $nodeID );
            if ( $node )
            {
                $nodeName = $node->attribute( 'name' );
                eZContentBrowseBookmark::createNew( $userID, $nodeID, $nodeName );
            }
        }
        $db->commit();
    }
}

$tpl = eZTemplate::factory();
$tpl->setVariable('view_parameters', $viewParameters );

$Result = array();
$Result['content'] = $tpl->fetch( 'design:content/bookmark.tpl' );
$Result['path'] = array( array( 'text' => ezpI18n::tr( 'kernel/content', 'My bookmarks' ),
                                'url' => false ) );

 public static function fetchBookmarks($offset, $limit)
 {
     $user = eZUser::currentUser();
     return array('result' => eZContentBrowseBookmark::fetchListForUser($user->id(), $offset, $limit));
 }
 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();
 }
Пример #10
0
<?php

$http = eZHTTPTool::instance();
$tpl = eZTemplate::factory();
$module = $Params['Module'];
$nodeID = $Params['NodeID'];
$node = eZContentObjectTreeNode::fetch($nodeID, false, false);
$userID = eZUser::currentUserID();
$bookmarkList = eZPersistentObject::fetchObjectList(eZContentBrowseBookmark::definition(), null, array('user_id' => $userID, 'node_id' => $nodeID), array('id' => 'desc'), array('offset' => 0, 'length' => '10'), true);
if (count($bookmarkList) > 0) {
    foreach ($bookmarkList as $bookmark) {
        $bookmark->remove();
    }
    $star = '0';
} else {
    eZContentBrowseBookmark::createNew($userID, $nodeID, $node['name']);
    /*
    	$notificationList = eZPersistentObject::fetchObjectList(  eZSubtreeNotificationRule::definition(),
    	                                                 array( 'node_id' ),
    	                                                 array( 'user_id' => $userID , 'node_id' => $node['parent_node_id'] ),
                                                         null,
                                                         null,
                                                         false );
    
       if( count($notificationList) == 0 )
    	{
    	$notificationRules = new eZSubtreeNotificationRule( array(	'node_id' =>  $node['parent_node_id'],
    																'user_id' => $userID,
    																'use_digest' => 0
    	) );
    	$notificationRules->store();