Ejemplo n.º 1
0
    /**
     * Fetches a pending actions list by action name
     * @param string $action
     * @param array $aCreationDateFilter Created date filter array (default is empty array). Must be a 2 entries array.
     *                                   First entry is the filter token (can be '=', '<', '<=', '>', '>=')
     *                                   Second entry is the filter value (timestamp)
     * @return array|null Array of eZPendingActions or null if no entry has been found
     */
    public static function fetchByAction( $action, array $aCreationDateFilter = array() )
    {
        $filterConds = array( 'action' => $action );

        // Handle creation date filter
        if( !empty( $aCreationDateFilter ) )
        {
            if( count( $aCreationDateFilter ) != 2 )
            {
                eZDebug::writeError( __CLASS__.'::'.__METHOD__.' : Wrong number of entries for Creation date filter array' );
                return null;
            }

            list( $filterToken, $filterValue ) = $aCreationDateFilter;
            $aAuthorizedFilterTokens = array( '=', '<', '>', '<=', '>=' );
            if( !is_string( $filterToken ) || !in_array( $filterToken, $aAuthorizedFilterTokens ) )
            {
                eZDebug::writeError( __CLASS__.'::'.__METHOD__.' : Wrong filter type for creation date filter' );
                return null;
            }

            $filterConds['created'] = array( $filterToken, $filterValue );
        }

        $result = parent::fetchObjectList( self::definition(), null, $filterConds );

        return $result;
    }
 static function fetchList($mementoKey, $asObject = true)
 {
     if (is_array($mementoKey)) {
         $mementoKey = eZOperationMemento::createKey($mementoKey);
     }
     return eZPersistentObject::fetchObjectList(eZOperationMemento::definition(), null, array('memento_key' => $mementoKey, 'main' => 0), null, null, $asObject);
 }
Ejemplo n.º 3
0
 static function fetch($contentAttributeID, $contentObjectVersion, $currencyCode = false, $type = false, $asObjects = true)
 {
     $priceList = null;
     $conds = array();
     $conds['contentobject_attr_id'] = $contentAttributeID;
     $conds['contentobject_attr_version'] = $contentObjectVersion;
     if (is_array($currencyCode)) {
         $conds['currency_code'] = array($currencyCode);
     } else {
         if ($currencyCode != false) {
             $conds['currency_code'] = $currencyCode;
         }
     }
     if (is_array($type)) {
         $conds['type'] = array($type);
     } else {
         if ($type != false) {
             $conds['type'] = $type;
         }
     }
     $sort = null;
     $limitation = null;
     $rows = eZPersistentObject::fetchObjectList(eZMultiPriceData::definition(), null, $conds, $sort, $limitation, $asObjects);
     if (count($rows) > 0) {
         $keys = array_keys($rows);
         foreach ($keys as $key) {
             if ($asObjects) {
                 $priceList[$rows[$key]->attribute('currency_code')] = $rows[$key];
             } else {
                 $priceList[$rows[$key]['currency_code']] = $rows[$key];
             }
         }
     }
     return $priceList;
 }
Ejemplo n.º 4
0
 /**
  * Looks up ezcontentobjectattribute entries matching an image filepath and
  * a contentobjectattribute ID
  *
  * @param string $filePath file path to look up as URL in the XML string
  * @param int $contentObjectAttributeID
  *
  * @return array An array of content object attribute ids and versions of
  *               image files where the url is referenced
  *
  * @todo Rewrite ! A where data_text LIKE '%xxx%' is a resource hog !
  */
 static function fetchImageAttributesByFilepath($filepath, $contentObjectAttributeID)
 {
     $db = eZDB::instance();
     $contentObjectAttributeID = (int) $contentObjectAttributeID;
     $cond = array('id' => $contentObjectAttributeID);
     $fields = array('contentobject_id', 'contentclassattribute_id');
     $limit = array('offset' => 0, 'length' => 1);
     $rows = eZPersistentObject::fetchObjectList(eZContentObjectAttribute::definition(), $fields, $cond, null, $limit, false);
     if (count($rows) != 1) {
         return array();
     }
     $contentObjectID = (int) $rows[0]['contentobject_id'];
     $contentClassAttributeID = (int) $rows[0]['contentclassattribute_id'];
     // Transform ", &, < and > to entities since they are being transformed in entities by DOM
     // See eZImageAliasHandler::initialize()
     // Ref https://jira.ez.no/browse/EZP-20090
     $filepath = $db->escapeString(htmlspecialchars($filepath, version_compare(PHP_VERSION, '5.4.0', '>=') ? ENT_COMPAT | ENT_HTML401 : ENT_COMPAT, 'UTF-8'));
     // Escape _ in like to avoid it to act as a wildcard !
     $filepath = addcslashes($filepath, "_");
     $query = "SELECT id, version\n                  FROM   ezcontentobject_attribute\n                  WHERE  contentobject_id = {$contentObjectID} AND\n                         contentclassattribute_id = {$contentClassAttributeID} AND\n                         data_text LIKE '%url=\"{$filepath}\"%'";
     if ($db->databaseName() == 'oracle') {
         $query .= " ESCAPE '\\'";
     }
     $rows = $db->arrayQuery($query);
     return $rows;
 }
 static function fetchParticipantList($parameters = array())
 {
     $parameters = array_merge(array('as_object' => true, 'item_id' => false, 'offset' => false, 'limit' => false, 'sort_by' => false), $parameters);
     $cacheHashKey = md5(serialize($parameters));
     if (isset($GLOBALS['eZCollaborationItemParticipantLinkListCache'][$cacheHashKey])) {
         return $GLOBALS['eZCollaborationItemParticipantLinkListCache'][$cacheHashKey];
     }
     $itemID = $parameters['item_id'];
     $asObject = $parameters['as_object'];
     $offset = $parameters['offset'];
     $limit = $parameters['limit'];
     $linkList = null;
     $limitArray = null;
     if ($offset and $limit) {
         $limitArray = array('offset' => $offset, 'length' => $limit);
     }
     $linkList = eZPersistentObject::fetchObjectList(eZCollaborationItemParticipantLink::definition(), null, array("collaboration_id" => $itemID), null, $limitArray, $asObject);
     foreach ($linkList as $linkItem) {
         if ($asObject) {
             $participantID = $linkItem->attribute('participant_id');
         } else {
             $participantID = $linkItem['participant_id'];
         }
         if (!isset($GLOBALS["eZCollaborationItemParticipantLinkCache"][$itemID][$participantID])) {
             $GLOBALS["eZCollaborationItemParticipantLinkCache"][$itemID][$participantID] = $linkItem;
         }
     }
     return $GLOBALS['eZCollaborationItemParticipantLinkListCache'][$cacheHashKey] = $linkList;
 }
Ejemplo n.º 6
0
 /**
  * Used in datatype cjwnewsletter_list
  *
  * @param unknown_type $attributeId
  * @param unknown_type $version
  * @return CjwNewsletterEdition
  */
 static function fetch($attributeId, $version)
 {
     $objectList = eZPersistentObject::fetchObjectList(CjwNewsletterEdition::definition(), null, array('contentobject_attribute_id' => $attributeId, 'contentobject_attribute_version' => $version), null, null, true);
     if (count($objectList) > 0) {
         return $objectList[0];
     }
 }
 /**
  * @return array
  */
 static function groupedUserDrafts()
 {
     $return = array();
     $user = eZUser::currentUser();
     $fetchParameters = array('status' => array(array(eZContentObjectVersion::STATUS_DRAFT, eZContentObjectVersion::STATUS_INTERNAL_DRAFT)), 'creator_id' => $user->attribute('contentobject_id'));
     $versions = eZPersistentObject::fetchObjectList(eZContentObjectVersion::definition(), null, $fetchParameters);
     $return = array();
     foreach ($versions as $version) {
         $return[$version->attribute('contentobject_id')] = array('version' => $version, 'related' => array());
     }
     foreach ($return as $id => $entry) {
         $eZObj = $entry['version']->attribute('contentobject');
         switch ($eZObj->attribute('class_identifier')) {
             case 'image':
                 $revese_related_objects = $eZObj->reverseRelatedObjectList(false, 0, false, array('AllRelations' => true));
                 foreach ($revese_related_objects as $rr_eZObj) {
                     if (isset($return[$rr_eZObj->attribute('id')])) {
                         $return[$rr_eZObj->attribute('id')]['related'][] = $entry['version'];
                         unset($return[$eZObj->attribute('id')]);
                     }
                 }
         }
     }
     return array('result' => $return);
 }
 function fetchList($collaborationID, $userID = false, $asObject = true)
 {
     if ($userID == false) {
         $userID == eZUser::currentUserID();
     }
     return eZPersistentObject::fetchObjectList(eZCollaborationItemGroupLink::definition(), null, array('collaboration_id' => $collaborationID, 'user_id' => $userID), null, null, $asObject);
 }
Ejemplo n.º 9
0
 static function fetchItemTypeList($collaborationIdentifier, $userIDList, $asObject = true)
 {
     if (is_array($collaborationIdentifier)) {
         $collaborationIdentifier = array($collaborationIdentifier);
     }
     return eZPersistentObject::fetchObjectList(eZCollaborationNotificationRule::definition(), null, array('user_id' => array($userIDList), 'collab_identifier' => $collaborationIdentifier), null, null, $asObject);
 }
Ejemplo n.º 10
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);
 }
 function removeDrafts($user)
 {
     $list = eZPersistentObject::fetchObjectList(eZContentObjectVersion::definition(), null, array('creator_id' => $user->id(), 'status' => array(EZ_VERSION_STATUS_DRAFT, EZ_VERSION_STATUS_INTERNAL_DRAFT)), null, null, true);
     foreach ($list as $item) {
         $item->remove();
     }
 }
Ejemplo n.º 12
0
 static function fetchAllElements($classAttributeID, $version, $asObject = true)
 {
     if ($classAttributeID === null) {
         return array();
     }
     return eZPersistentObject::fetchObjectList(eZEnumValue::definition(), null, array("contentclass_attribute_id" => $classAttributeID, "contentclass_attribute_version" => $version), null, null, $asObject);
 }
Ejemplo n.º 13
0
 public static function fetchList($classAttributeID, $typeID = null)
 {
     $filters = array('class_attribute_id' => $classAttributeID);
     if ($typeID !== null) {
         $filters['type'] = $typeID;
     }
     return eZPersistentObject::fetchObjectList(self::definition(), null, $filters, true);
 }
Ejemplo n.º 14
0
 static function fetchList()
 {
     $result = array();
     $conditions = array();
     $limitation = null;
     $asObject = true;
     return eZPersistentObject::fetchObjectList(eZSurveyRelatedConfig::definition(), null, $conditions, null, $limitation, $asObject);
 }
 static function fetchList($newsletterTypeID, $subscriptionListID = false, $status = eZNewsletterType::StatusPublished, $asObject = true)
 {
     $condArray = array('newsletter_id' => $newsletterTypeID, 'status' => $status);
     if ($subscriptionListID !== false) {
         $condArray['subscription_id'] = $subscriptionListID;
     }
     return eZPersistentObject::fetchObjectList(eZNewsletterTypeSubscription::definition(), null, $condArray, null, null, $asObject);
 }
 static function fetchByFileName($filename, $version = null, $asObject = true)
 {
     if ($version == null) {
         return eZPersistentObject::fetchObjectList(eZBinaryFile::definition(), null, array('filename' => $filename), null, null, $asObject);
     } else {
         return eZPersistentObject::fetchObject(eZBinaryFile::definition(), null, array('filename' => $filename, 'version' => $version), $asObject);
     }
 }
Ejemplo n.º 17
0
 /**
  * Returns eZTagsKeyword list for given tag ID
  *
  * @static
  *
  * @param int $tagID
  *
  * @return eZTagsKeyword[]
  */
 public static function fetchByTagID($tagID)
 {
     $tagKeywordList = parent::fetchObjectList(self::definition(), null, array('keyword_id' => $tagID));
     if (is_array($tagKeywordList)) {
         return $tagKeywordList;
     }
     return array();
 }
 /**
  * Returns records from the table by attribute
  *
  * @param int $contentObjectAttributeId
  * @param int $contentObjectAttributeVersion
  *
  * @return SckEnhancedSelection[]
  */
 static function fetchByAttribute($contentObjectAttributeId, $contentObjectAttributeVersion)
 {
     $result = eZPersistentObject::fetchObjectList(self::definition(), null, array('contentobject_attribute_id' => $contentObjectAttributeId, 'contentobject_attribute_version' => $contentObjectAttributeVersion));
     if (is_array($result) && !empty($result)) {
         return $result;
     }
     return array();
 }
Ejemplo n.º 19
0
 /**
  * Fetch map location by attribute id and version
  *
  * @param int $attributeId
  * @param int $version
  * @param bool $asObject
  * @return eZGmapLocation|null
  */
 public static function fetch($attributeId, $version, $asObject = true)
 {
     $list = eZPersistentObject::fetchObjectList(self::definition(), null, array('contentobject_attribute_id' => $attributeId, 'contentobject_version' => $version), null, null, $asObject);
     if (isset($list[0])) {
         return $list[0];
     }
     return null;
 }
Ejemplo n.º 20
0
 /**
  * Returns all of eZ Publish users connections to social networks
  *
  * @param int $userID
  *
  * @return bool
  */
 static function connections($userID)
 {
     $result = eZPersistentObject::fetchObjectList(self::definition(), null, array('user_id' => $userID));
     if (is_array($result) && !empty($result)) {
         return $result;
     }
     return array();
 }
Ejemplo n.º 21
0
function unLock(eZContentObject $object)
{
    $filterConds = array('action' => 'creating_translation', 'param' => $object->attribute('id'));
    $rows = eZPersistentObject::fetchObjectList(eZPendingActions::definition(), null, $filterConds);
    foreach ($rows as $row) {
        $row->remove();
    }
}
 static function fetchList($conditions = null, $asObjects = true, $offset = false, $limit = false)
 {
     $limitation = null;
     if ($offset !== false or $limit !== false) {
         $limitation = array('offset' => $offset, 'length' => $limit);
     }
     return eZPersistentObject::fetchObjectList(eZProductCollectionItem::definition(), null, $conditions, null, $limitation, $asObjects);
 }
Ejemplo n.º 23
0
 /**
  * Fetches the eZTagsAttributeLinkObject object based on provided content object params and keyword ID
  *
  * @static
  *
  * @param int $objectAttributeID
  * @param int $objectAttributeVersion
  * @param int $objectID
  * @param int $keywordID
  *
  * @return eZTagsAttributeLinkObject if found, false otherwise
  */
 public static function fetchByObjectAttributeAndKeywordID($objectAttributeID, $objectAttributeVersion, $objectID, $keywordID)
 {
     $objects = parent::fetchObjectList(self::definition(), null, array('objectattribute_id' => $objectAttributeID, 'objectattribute_version' => $objectAttributeVersion, 'object_id' => $objectID, 'keyword_id' => $keywordID));
     if (is_array($objects) && !empty($objects)) {
         return $objects[0];
     }
     return false;
 }
Ejemplo n.º 24
0
 static function fetchList($user_id = false, $asObject = true)
 {
     $conds = array();
     if ($user_id !== false and is_numeric($user_id)) {
         $conds["creator_id"] = $user_id;
     }
     return eZPersistentObject::fetchObjectList(eZContentClassGroup::definition(), null, $conds, null, null, $asObject);
 }
Ejemplo n.º 25
0
 static function fetch($id, $version, $asObject = true)
 {
     if ($version == null) {
         return eZPersistentObject::fetchObjectList(ezflowMedia::definition(), null, array("contentobject_attribute_id" => $id), null, null, $asObject);
     } else {
         return eZPersistentObject::fetchObject(ezflowMedia::definition(), null, array("contentobject_attribute_id" => $id, "version" => $version), $asObject);
     }
 }
Ejemplo n.º 26
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;
 }
Ejemplo n.º 27
0
 static function fetchValues($type, $global)
 {
     $robinsonlistEntrys = eZPersistentObject::fetchObjectList(eZRobinsonListEntry::definition(), array('value'), array('type' => $type, 'global' => $global), array('value' => 'ASC'), null, $asObject);
     $result = array();
     foreach ($robinsonlistEntrys as $entry) {
         $result = array_merge($result, $entry['value']);
     }
     return $result;
 }
Ejemplo n.º 28
0
 static function fetchByGroup($groupNumber, $asObject = true)
 {
     $conditions = array('group_number' => $groupNumber);
     $group = false;
     $groupArray = eZPersistentObject::fetchObjectList(eZISBNGroup::definition(), null, $conditions, null, null, $asObject);
     if (count($groupArray) == 1) {
         $group = $groupArray[0];
     }
     return $group;
 }
 static function fetchList($classID, $classVersion, $languageLocaleList, $asObjects = true, $fields = null, $sorts = null, $limit = null)
 {
     $conds = array();
     if (is_array($languageLocaleList) && count($languageLocaleList) > 0) {
         $conds['language_locale'] = array($languageLocaleList);
     }
     $conds['contentclass_id'] = $classID;
     $conds['contentclass_version'] = $classVersion;
     return eZPersistentObject::fetchObjectList(eZContentClassName::definition(), $fields, $conds, $sorts, $limit, $asObjects);
 }
Ejemplo n.º 30
0
 function fetchObjectListCount($sectionID, $status = false)
 {
     if ($status == 'archived') {
         $status = eZContentObject::STATUS_ARCHIVED;
     } else {
         $status = eZContentObject::STATUS_PUBLISHED;
     }
     $rows = eZPersistentObject::fetchObjectList(eZContentObject::definition(), array(), array('section_id' => $sectionID, 'status' => $status), false, null, false, false, array(array('operation' => 'count( id )', 'name' => 'count')));
     return array('result' => $rows[0]['count']);
 }