static function fetchForUser( $address, $asObject = true ) { return eZPersistentObject::fetchObject( eZGeneralDigestUserSettings::definition(), null, array( 'address' => $address ), $asObject ); }
/** * 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 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); }
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(); } }
function fetchClassListByGroups( $groupFilter, $groupFilterType = 'include' ) { $notIn = ( $groupFilterType == 'exclude' ); if ( is_array( $groupFilter ) && count( $groupFilter ) > 0 ) { $db = eZDB::instance(); $groupFilter = $db->generateSQLINStatement( $groupFilter, 'ccg.group_id', $notIn ); $classNameFilter = eZContentClassName::sqlFilter( 'cc' ); $version = eZContentClass::VERSION_STATUS_DEFINED; $sql = "SELECT DISTINCT cc.*, $classNameFilter[nameField] " . "FROM ezcontentclass cc, ezcontentclass_classgroup ccg, $classNameFilter[from] " . "WHERE cc.version = $version" . " AND cc.id = ccg.contentclass_id" . " AND $groupFilter" . " AND $classNameFilter[where] " . "ORDER BY $classNameFilter[nameField] ASC"; $rows = $db->arrayQuery( $sql ); $classes = eZPersistentObject::handleRows( $rows, 'eZContentClass', true ); } else { $classes = eZContentClass::fetchList( eZContentClass::VERSION_STATUS_DEFINED, true, false, array( 'name' => 'asc' ) ); } return array( 'result' => $classes ); }
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); }
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; }
/** * 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); }
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); }
static function removeByID($id, $version) { if ($version == null) { eZPersistentObject::removeObject(eZBinaryFile::definition(), array('contentobject_attribute_id' => $id)); } else { eZPersistentObject::removeObject(eZBinaryFile::definition(), array('contentobject_attribute_id' => $id, 'version' => $version)); } }
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(); } }
/** * 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(); }
/** * Removes the data from the table by attribute * * @param int $contentObjectAttributeId * @param int $contentObjectAttributeVersion */ static function removeByAttribute($contentObjectAttributeId, $contentObjectAttributeVersion = null) { $conditions = array('contentobject_attribute_id' => $contentObjectAttributeId); if ($contentObjectAttributeVersion !== null) { $conditions['contentobject_attribute_version'] = $contentObjectAttributeVersion; } eZPersistentObject::removeObject(self::definition(), $conditions); }
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); }
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); }
static function fetchList() { $result = array(); $conditions = array(); $limitation = null; $asObject = true; return eZPersistentObject::fetchObjectList(eZSurveyRelatedConfig::definition(), null, $conditions, null, $limitation, $asObject); }
/** * Return valid eZRSSExport object for a specific node if it exists. * * @param int $nodeID * @return eZRSSExport|false Return value is inside a array with return value on result, as this is used as template fetch function. */ static function exportByNode($nodeID) { if (!$nodeID) { return array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND)); } $rssExport = eZPersistentObject::fetchObject(eZRSSExport::definition(), null, array('node_id' => $nodeID, 'status' => eZRSSExport::STATUS_VALID), true); return array('result' => $rssExport); }
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); }
/** * Fetches the eZTagsAttributeLinkObject object based on provided content object params and keyword ID * * @param integer $objectAttributeID * @param integer $objectAttributeVersion * @param integer $objectID * @param integer $keywordID * @return eZTagsAttributeLinkObject if found, false otherwise */ static function fetchByObjectAttributeAndKeywordID($objectAttributeID, $objectAttributeVersion, $objectID, $keywordID) { $objects = eZPersistentObject::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]; } else { return false; } }
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 __construct($row) { $this->Path = null; $this->PathArray = null; if (array_key_exists('always_available', $row)) { $this->AlwaysAvailable = $row['always_available']; } parent::__construct($row); }
/** * Will check if UserID provided in credentials is valid * @see ezcAuthenticationFilter::run() */ public function run($credentials) { $status = self::STATUS_INVALID_USER; $count = eZPersistentObject::count(eZUser::definition(), array('contentobject_id' => (int) $credentials->id)); if ($count > 0) { $status = self::STATUS_OK; } return $status; }
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; }
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']); }
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); }
static function fetchByUserID($userID, $approveID, $approveStatus, $hash = false, $asObject = true) { $cond = array('user_id' => $userID, 'approve_id' => $approveID); if ($approveStatus !== false) { $cond['approve_role'] = $approveStatus; } if ($hash !== false) { $cond['hash'] = $hash; } return eZPersistentObject::fetchObject(eZXApproveStatusUserLink::definition(), null, $cond, $asObject); }
/** * Removes the objects from persistence which are related to content object attribute * defined by attribute ID and attribute version * * @static * * @param int $objectAttributeID * @param int|null $objectAttributeVersion */ public static function removeByAttribute($objectAttributeID, $objectAttributeVersion = null) { if (!is_numeric($objectAttributeID)) { return; } $conditions = array('objectattribute_id' => (int) $objectAttributeID); if (is_numeric($objectAttributeVersion)) { $conditions['objectattribute_version'] = (int) $objectAttributeVersion; } parent::removeObject(self::definition(), $conditions); }
static function removeByOAID($objectAttributeID, $objectAttributeVersion = null) { $db = eZDB::instance(); $db->begin(); if ($objectAttributeVersion == null) { eZPersistentObject::removeObject(eZMultiPriceData::definition(), array('contentobject_attr_id' => $objectAttributeID)); } else { eZPersistentObject::removeObject(eZMultiPriceData::definition(), array('contentobject_attr_id' => $objectAttributeID, 'contentobject_attr_version' => $objectAttributeVersion)); } $db->commit(); }
static function updateFields($collaborationID, $userID = false, $fields) { if ($userID === false) { $userID = eZUser::currentUserID(); } eZPersistentObject::updateObjectList(array('definition' => eZCollaborationItemStatus::definition(), 'update_fields' => $fields, 'conditions' => array('collaboration_id' => $collaborationID, 'user_id' => $userID))); $statusObject =& $GLOBALS['eZCollaborationItemStatusCache'][$collaborationID][$userID]; if (isset($statusObject)) { foreach ($fields as $field => $value) { $statusObject->setAttribute($field, $value); } } }