コード例 #1
0
ファイル: ezoeserverfunctions.php プロジェクト: legende91/ez
 /**
  * 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);
 }
コード例 #2
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;
 }
コード例 #3
0
 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;
     }
 }
コード例 #4
0
 static function fetchListForUser($userID, $offset = false, $limit = false)
 {
     $objectList = eZPersistentObject::fetchObjectList(eZContentBrowseBookmark::definition(), null, array('user_id' => $userID), array('id' => 'desc'), array('offset' => $offset, 'length' => $limit), true);
     return $objectList;
 }
コード例 #5
0
ファイル: star.php プロジェクト: EVE-Corp-Center/ECC-Website
<?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();