/** * 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); }
/** * 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; }
/** * Returns if eZ Publish user has connection to specified social network * * @param int $userID * @param string $loginMethod * * @return bool */ static function userHasConnection($userID, $loginMethod) { $count = eZPersistentObject::count(self::definition(), array('user_id' => $userID, 'login_method' => $loginMethod)); if ($count > 0) { return true; } $user = eZUser::fetch($userID); if (substr($user->Login, 0, 10 + strlen($loginMethod)) === 'ngconnect_' . $loginMethod) { return true; } return false; }
static function fetchDeliveriesByContentobjectIdCount($object_id, $status = array()) { $conds = array('contentobject_id' => $object_id); if (is_string($status)) { $status = array($status); } if (is_array($status)) { $status = array_intersect(jajNewsletterDelivery::states(), $status); } if (count($status)) { $conds['state'] = array($status); } $rows = eZPersistentObject::count(jajNewsletterDelivery::definition(), $conds); return $rows; }
static function countByRecipientsLists($lists, $status = array()) { $list_ids = array(); foreach ($lists as $list) { if (is_a($list, 'jajNewsletterRecipientsList')) { array_push($list_ids, $list->SubscriptionListID); } } if (count($list_ids)) { $conditions = array('subscription_list_id' => array($list_ids)); if (is_string($status)) { $status = array($status); } if (is_array($status)) { $status = array_intersect(jajNewsletterSubscription::states(), $status); } if (count($status)) { $conditions['jaj_newsletter_subscription.state'] = array($status); } return eZPersistentObject::count(jajNewsletterSubscription::definition(), $conditions, "email"); } return 0; }
/** * Checks if an import is pending (waiting to start) * @return bool */ public static function importIsPending() { $conds = array('name' => self::STATUS_FIELD_NAME, 'value' => self::IMPORT_STATUS_PENDING); $statusCount = parent::count(self::definition(), $conds); return $statusCount > 0; }
/** * Figgure out if current user has rated, since eZ Publish changes session id as of 4.1 * on login / logout, a couple of things needs to be checked. * 1. Session variable 'ezsrRatedAttributeIdList' for list of attribute_id's * 2a. (annonymus user) check against session key * 2b. (logged in user) check against user id * * @param bool $returnRatedObject Return object if user has rated and [eZStarRating]AllowChangeRating=enabled * @return bool|ezsrRatingDataObject */ function userHasRated($returnRatedObject = false) { if ($this->currentUserHasRated === null) { $http = eZHTTPTool::instance(); if ($http->hasSessionVariable('ezsrRatedAttributeIdList')) { $attributeIdList = explode(',', $http->sessionVariable('ezsrRatedAttributeIdList')); } else { $attributeIdList = array(); } $ini = eZINI::instance(); $contentobjectAttributeId = $this->attribute('contentobject_attribute_id'); if (in_array($contentobjectAttributeId, $attributeIdList) && $ini->variable('eZStarRating', 'UseUserSession') === 'enabled') { $this->currentUserHasRated = true; } $returnRatedObject = $returnRatedObject && $ini->variable('eZStarRating', 'AllowChangeRating') === 'enabled'; if ($this->currentUserHasRated === null || $returnRatedObject) { $sessionKey = $this->attribute('session_key'); $userId = $this->attribute('user_id'); if ($userId == eZUser::anonymousId()) { $cond = array('user_id' => $userId, 'session_key' => $sessionKey, 'contentobject_id' => $this->attribute('contentobject_id'), 'contentobject_attribute_id' => $contentobjectAttributeId); } else { $cond = array('user_id' => $userId, 'contentobject_id' => $this->attribute('contentobject_id'), 'contentobject_attribute_id' => $contentobjectAttributeId); } if ($returnRatedObject) { $this->currentUserHasRated = eZPersistentObject::fetchObject(self::definition(), null, $cond); if ($this->currentUserHasRated === null) { $this->currentUserHasRated = false; } } else { $this->currentUserHasRated = eZPersistentObject::count(self::definition(), $cond, 'id') != 0; } } } return $this->currentUserHasRated; }
/** * Get actual values for PaEx data for the given contentobject id. * If not defined for the given coID, use defaults. * * @param int $ezcoid Contentobject id (user id) to get PaEx for * @param bool $checkIfUserHasDatatype See if user has paex datatype, default false * @return eZPaEx|null Actual PaEx applicable data, null if $checkIfUserHasDatatype = true * and object does not have ezpaex datatype */ static function getPaEx($ezcoid, $checkIfUserHasDatatype = false) { $currentPaex = eZPaEx::fetch($ezcoid); // If we don't have paex object for the current object id, create a default one if (!$currentPaex instanceof eZPaEx) { // unless user does not have paex datatype if ($checkIfUserHasDatatype) { //eZContentObject::fetch( $ezcoid ); $paexDataTypeCount = eZPersistentObject::count(eZContentObjectAttribute::definition(), array('contentobject_id' => $ezcoid, 'data_type_string' => ezpaextype::DATA_TYPE_STRING), 'id'); if (!$paexDataTypeCount) { eZDebug::writeDebug("User id {$ezcoid} does not have paex datatype", __METHOD__); return null; } } return eZPaEx::create($ezcoid); } // Get default paex values from ini to use in case there is anyone missing in the object $ini = eZINI::instance('mbpaex.ini'); $iniPasswordValidationRegexp = $ini->variable('mbpaexSettings', 'PasswordValidationRegexp'); $iniDefaultPasswordLifeTime = $ini->variable('mbpaexSettings', 'DefaultPasswordLifeTime'); $iniExpirationNotification = $ini->variable('mbpaexSettings', 'ExpirationNotification'); // If still any empty values in the paex object, set defaults from ini if (!$currentPaex->hasRegexp()) { $currentPaex->setAttribute('passwordvalidationregexp', $iniPasswordValidationRegexp); eZDebug::writeDebug('Regexp empty, used default: "' . $iniPasswordValidationRegexp . '"', 'eZPaEx::getPaEx'); } if (!$currentPaex->hasLifeTime()) { $currentPaex->setAttribute('passwordlifetime', $iniDefaultPasswordLifeTime); eZDebug::writeDebug('PasswordLifeTime empty, used default: "' . $iniDefaultPasswordLifeTime . '"', 'eZPaEx::getPaEx'); } if (!$currentPaex->hasNotification()) { $currentPaex->setAttribute('expirationnotification', $iniExpirationNotification); eZDebug::writeDebug('ExpirationNotification empty, used default: "' . $iniPasswordValidationRegexp . '"', 'eZPaEx::getPaEx'); } eZDebug::writeDebug('PasswordLastUpdated value: "' . $currentPaex->attribute('password_last_updated') . '"', 'eZPaEx::getPaEx'); return $currentPaex; }
eZDB::setInstance($db); } $db->setIsSQLOutputEnabled($showSQL); $searchEngine = eZSearch::getEngine(); if (!$searchEngine instanceof ezpSearchEngine) { $cli->error("The configured search engine does not implement the ezpSearchEngine interface or can't be found."); $script->shutdown(1); } if ($cleanupSearch) { $cli->output("{eZSearchEngine: Cleaning up search data", false); $searchEngine->cleanup(); $cli->output("}"); } $def = eZContentObject::definition(); $conds = array('status' => eZContentObject::STATUS_PUBLISHED); $count = eZPersistentObject::count($def, $conds, 'id'); $cli->output("Number of objects to index: {$count}"); $length = 50; $limit = array('offset' => 0, 'length' => $length); $script->resetIteration($count); $needRemoveWithUpdate = $searchEngine->needRemoveWithUpdate(); do { // clear in-memory object cache eZContentObject::clearCache(); $objects = eZPersistentObject::fetchObjectList($def, null, $conds, null, $limit); foreach ($objects as $object) { if ($needRemoveWithUpdate || !$cleanupSearch) { $searchEngine->removeObjectById($object->attribute("id"), false); } if (!$searchEngine->addObject($object, false)) { $cli->warning("\tFailed indexing object ID #" . $object->attribute("id") . ".");
/** * Retrieves the content objects elevated by a given query string, possibly per language. * * @param mixed $searchQuery Can be a string containing the search_query to filter on. * Can also be an array looking like the following, supporting fuzzy search optionnally. * <code> * array( 'searchQuery' => ( string ) 'foo bar', * 'fuzzy' => ( boolean ) true ) * </code> * * @param string $languageCode if filtering on language-code is required * @param array $limit Associative array containing the 'offset' and 'limit' keys, with integers as values, framing the result set. Example : * <code> * array( 'offset' => 0, * 'limit' => 10 ) * </code> * * @param boolean $countOnly If only the count of matching results is needed * @return mixed An array containing the content objects elevated by the query string, optionnally sorted by language code, null if error. If $countOnly is true, * only the result count is returned. */ public static function fetchObjectsForQueryString($queryString, $groupByLanguage = true, $languageCode = null, $limit = null, $countOnly = false) { if (is_string($queryString) and $queryString === '' or is_array($queryString) and array_key_exists('searchQuery', $queryString) and $queryString['searchQuery'] == '') { return null; } $fieldFilters = $custom = null; $objects = array(); $conds = array(); $sortClause = $groupByLanguage ? array('language_code' => 'asc') : null; if (!is_array($queryString)) { $conds['search_query'] = $queryString; } else { $conds['search_query'] = @$queryString['fuzzy'] === true ? array('like', "%{$queryString['searchQuery']}%") : $queryString['searchQuery']; } if ($languageCode and $languageCode !== '') { $conds['language_code'] = array(array($languageCode, self::WILDCARD)); } if ($countOnly) { return parent::count(self::definition(), $conds); } else { $rows = parent::fetchObjectList(self::definition(), $fieldFilters, $conds, $sortClause, $limit, false, false, $custom); foreach ($rows as $row) { if (($obj = eZContentObject::fetch($row['contentobject_id'])) !== null) { if ($groupByLanguage) { $objects[$row['language_code']][] = $obj; } else { $objects[] = $obj; } } } return $objects; } }
/** * Clears view cache for imported content objects. * ObjectIDs are stored in 'ezpending_actions' table, with {@link SQLIContent::ACTION_CLEAR_CACHE} action */ public static function viewCacheClear() { $db = eZDB::instance(); $isCli = isset($_SERVER['argv']); $output = null; $progressBar = null; $i = 0; $conds = array('action' => SQLIContent::ACTION_CLEAR_CACHE); $limit = array('offset' => 0, 'length' => 50); $count = (int) eZPersistentObject::count(eZPendingActions::definition(), $conds); if ($isCli && $count > 0) { // Progress bar implementation $output = new ezcConsoleOutput(); $output->outputLine('Starting to clear view cache for imported objects...'); $progressBarOptions = array('emptyChar' => ' ', 'barChar' => '='); $progressBar = new ezcConsoleProgressbar($output, $count, $progressBarOptions); $progressBar->start(); } /* * To avoid fatal errors due to memory exhaustion, pending actions are fetched by packets */ do { $aObjectsToClear = eZPendingActions::fetchObjectList(eZPendingActions::definition(), null, $conds, null, $limit); $jMax = count($aObjectsToClear); if ($jMax > 0) { for ($j = 0; $j < $jMax; ++$j) { if ($isCli) { $progressBar->advance(); } $db->begin(); eZContentCacheManager::clearContentCacheIfNeeded((int) $aObjectsToClear[$j]->attribute('param')); $aObjectsToClear[$j]->remove(); $db->commit(); $i++; } } unset($aObjectsToClear); eZContentObject::clearCache(); if (eZINI::instance('site.ini')->variable('ContentSettings', 'StaticCache') == 'enabled') { $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler'); $options = new ezpExtensionOptions($optionArray); $staticCacheHandler = eZExtension::getHandlerClass($options); $staticCacheHandler::executeActions(); } } while ($i < $count); if ($isCli && $count > 0) { $progressBar->finish(); $output->outputLine(); } }
/** * Count all user who subscripe to list * * @param integer $importId * @param integer Subscirpiton STATUS * @return integer */ static function fetchSubscriptionListByImportIdAndStatusCount($importId, $status) { $count = eZPersistentObject::count(self::definition(), array('import_id' => (int) $importId, 'status' => (int) $status), 'id'); return $count; }
/** * count all bounces for a edition send id * * @param integer $editionSendId * @return integer */ public static function fetchBounceCountByEditionSendId($editionSendId) { $count = eZPersistentObject::count(self::definition(), array('edition_send_id' => (int) $editionSendId, 'bounced' => array('>', 0)), 'id'); return $count; }
public function fetchSubscribersCount($state = null) { $conditions = array('subscription_list_id' => $this->ID); if ($state) { $conditions['state'] = $state; } return eZPersistentObject::count(jajNewsletterSubscription::definition(), $conditions); }
static function removeRelationObject($contentObjectAttribute, $deletionItem) { if (self::isItemPublished($deletionItem)) { return; } $hostObject = $contentObjectAttribute->attribute('object'); $hostObjectID = $hostObject->attribute('id'); // Do not try removing the object if present in trash // Only objects being really orphaned (not even being in trash) should be removed by this method. // See issue #019457 if ((int) eZPersistentObject::count(eZContentObjectTrashNode::definition(), array("contentobject_id" => $hostObjectID)) > 0) { return; } $hostObjectVersions = $hostObject->versions(); $isDeletionAllowed = true; // check if the relation item to be deleted is unique in the domain of all host-object versions foreach ($hostObjectVersions as $version) { if ($isDeletionAllowed and $version->attribute('version') != $contentObjectAttribute->attribute('version')) { $relationAttribute = eZPersistentObject::fetchObjectList(eZContentObjectAttribute::definition(), null, array('version' => $version->attribute('version'), 'contentobject_id' => $hostObjectID, 'contentclassattribute_id' => $contentObjectAttribute->attribute('contentclassattribute_id'))); if (count($relationAttribute) > 0) { $relationContent = $relationAttribute[0]->content(); if (is_array($relationContent) and is_array($relationContent['relation_list'])) { foreach ($relationContent['relation_list'] as $relationItem) { if ($deletionItem['contentobject_id'] == $relationItem['contentobject_id'] && $deletionItem['contentobject_version'] == $relationItem['contentobject_version']) { $isDeletionAllowed = false; break 2; } } } } } } if ($isDeletionAllowed) { $subObjectVersion = eZContentObjectVersion::fetchVersion($deletionItem['contentobject_version'], $deletionItem['contentobject_id']); if ($subObjectVersion instanceof eZContentObjectVersion) { $subObjectVersion->removeThis(); } else { eZDebug::writeError('Cleanup of subobject-version failed. Could not fetch object from relation list.\\n' . 'Requested subobject id: ' . $deletionItem['contentobject_id'] . '\\n' . 'Requested Subobject version: ' . $deletionItem['contentobject_version'], __METHOD__); } } }
/** * Same test as {@link self::testRemovePendingSearchSeveralNodesForObject()}, with not all nodes removed * Use case * -------- * 1. If all nodes are removed, pending action must also be removed * 2. If NOT all nodes are removed (at least one node remaining for object), pending action must NOT be removed (case tested here) * * @group issue_17932 */ public function testRemovePendingSearchNotAllNodesRemoved() { $this->folder->addNode( 43 ); $folderObjectID = $this->folder->object->attribute( 'id' ); $aNodeID = array( $this->folder->nodes[0]->attribute( 'node_id' ) ); // Only delete the first node eZContentOperationCollection::deleteObject( $aNodeID ); $filterConds = array( 'action' => 'index_object', 'param' => $folderObjectID ); $pendingCount = eZPersistentObject::count( eZPendingActions::definition(), $filterConds ); self::assertGreaterThan( 0, $pendingCount, "eZContentOperationCollection::deleteObject() must remove pending action for object #$folderObjectID as all nodes have been removed" ); }
/** * Returns count of eZTagsKeyword objects for supplied tag ID * * @static * * @param int $tagID * * @return int */ public static function fetchCountByTagID($tagID) { return parent::count(self::definition(), array('keyword_id' => (int) $tagID)); }
* @copyright Copyright (C) eZ Systems AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. * @version 2014.11.1 */ require_once 'autoload.php'; $cli = eZCLI::instance(); $script = eZScript::instance(array('description' => "Updates 'parent_remote_id' column in 'eznode_assignment' table.\n" . "Can be used on a live site to update node assignments for Locations of unpublished Content, see https://jira.ez.no/browse/EZP-22260.", 'use-session' => false, 'use-modules' => false, 'use-extensions' => true)); $script->startup(); $options = $script->getOptions("[n][iteration-sleep:][iteration-limit:]", "", array('iteration-sleep' => 'Sleep duration between batches, in seconds (default: 1)', 'iteration-limit' => 'Batch size (default: 100)', 'n' => 'Do not wait 30 seconds before starting')); $optIterationSleep = (int) $options['iteration-sleep'] ?: 1; $optIterationLimit = (int) $options['iteration-limit'] ?: 100; $script->initialize(); $condition = array("op_code" => eZNodeAssignment::OP_CODE_CREATE, "parent_remote_id" => ""); $limit = array("offset" => 0, "limit" => $optIterationLimit); $count = 0; $totalCount = eZPersistentObject::count(eZNodeAssignment::definition(), $condition); $cli->warning("This script will update empty 'parent_remote_id' of all node assignments with OP_CODE_CREATE."); $cli->warning("If node assignment's 'remote_id' is not empty its value will be copied to 'parent_remote_id' and set to 0."); $cli->warning("Otherwise new hash for 'parent_remote_id' will be calculated."); $cli->output(); $cli->warning("For more details about this cleanup, see https://jira.ez.no/browse/EZP-22260"); $cli->output(); $cli->output("Found total of {$totalCount} node assignments to be updated"); $cli->output(); if ($totalCount == 0) { $cli->output("Nothing to process, exiting"); $script->shutdown(0); } if (!isset($options['n'])) { $cli->warning("You have 30 seconds to break the script before actual processing starts (press Ctrl-C)"); $cli->warning("(execute the script with '-n' switch to skip this delay)");
/** * Checks if an object is already being processed * @param eZContentObjectVersion $versionObject * @return bool */ public static function isProcessing( eZContentObjectVersion $versionObject ) { $count = parent::count( self::definition(), array( 'ezcontentobject_version_id' => $versionObject->attribute( 'id' ), // 'status' => self::STATUS_WORKING // not used yet ) ); return ( $count != 0 ); }
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" ); eZOrder::cleanup(); $productCount = eZPersistentObject::count( eZProductCollection::definition() ); if ( $productCount > 0 ) { $cli->warning( "$productCount product collections still exists, must be a leak" ); } } if ( $clean['forgotpassword'] ) { $cli->output( "Removing all forgot password requests" ); eZForgotPassword::cleanup(); } if ( $clean['workflow'] ) { $cli->output( "Removing all workflow processes and operation mementos" );
/** * Checks if an object is already being processed * @param eZContentObjectVersion $versionObject * @return bool */ public static function isProcessing(eZContentObjectVersion $versionObject) { $count = parent::count(self::definition(), array('ezcontentobject_version_id' => $versionObject->attribute('id'))); return $count != 0; }
$cli->output("Invalid parent tag."); $script->shutdown(1); } $cli->warning("This script will NOT republish objects, but rather update the CURRENT"); $cli->warning("version of published objects. If you do not wish to do that, you have"); $cli->warning("15 seconds to cancel the script! (press Ctrl-C)\n"); sleep(15); $sourceClassAttributeIdentifier = $sourceClassAttribute->attribute('identifier'); $destClassAttributeIdentifier = $destClassAttribute->attribute('identifier'); $isDestClassAttributeTranslatable = (bool) $destClassAttribute->attribute('can_translate'); $adminUser = eZUser::fetchByName('admin'); $adminUser->loginCurrent(); $db = eZDB::instance(); $offset = 0; $limit = 50; $objectCount = eZPersistentObject::count(eZContentObject::definition(), array('contentclass_id' => $sourceClassAttribute->attribute('contentclass_id'), 'status' => eZContentObject::STATUS_PUBLISHED)); while ($offset < $objectCount) { $objects = eZContentObject::fetchFilteredList(array('contentclass_id' => $sourceClassAttribute->attribute('contentclass_id'), 'status' => eZContentObject::STATUS_PUBLISHED), $offset, $limit); foreach ($objects as $object) { foreach ($object->availableLanguages() as $languageCode) { $object->fetchDataMap(false, $languageCode); } if (isset($object->DataMap[$object->attribute('current_version')])) { $db->begin(); $languageDataMap = $object->DataMap[$object->attribute('current_version')]; $initialLanguageCode = $object->initialLanguageCode(); // first convert the initial (main) language $objectAttributes = $languageDataMap[$initialLanguageCode]; if (isset($objectAttributes[$sourceClassAttributeIdentifier]) && isset($objectAttributes[$destClassAttributeIdentifier])) { $sourceObjectAttribute = $objectAttributes[$sourceClassAttributeIdentifier]; $destObjectAttribute = $objectAttributes[$destClassAttributeIdentifier];
/** * count all mail items in mailbox * * @return uinteger */ public static function fetchAllMailboxItemsCount() { $count = eZPersistentObject::count(self::definition(), array(), 'id'); return $count; }
/** * Fetches the count of created roles * * @static * @param boolean $ignoreNew Wether to ignore draft roles * * @return int */ static function roleCount($ignoreNew = true) { $conds = array('version' => 0); if ($ignoreNew === true) { $conds['is_new'] = 0; } return eZPersistentObject::count(eZRole::definition(), $conds); }
/** * get the count of subscription in a subscriber ID * @param $subscriberID * @param $status * @return unknown_type */ static function countWithSubscriberID($subscriberID, $languageID = false, $enabled = false) { $cond = array(); $cond['subscriber_id'] = $subscriberID; if ($enabled !== false) { $cond['enabled'] = $enabled; } if ($languageID !== false) { $cond['language_id'] = $languageID; } $count = eZPersistentObject::count(self::definition(), $cond); return $count; }
#!/usr/bin/env php <?php require 'autoload.php'; $cli = eZCLI::instance(); $script = eZScript::instance(array('description' => "Migrates sckenhancedselection datatype to version which stores content object data to database table.", 'use-session' => true, 'use-modules' => false, 'use-extensions' => true)); $script->startup(); $script->getOptions(); $script->initialize(); $cli->warning("This script will NOT republish objects, but rather update ALL versions"); $cli->warning("of content objects. If you do not wish to do that, you have"); $cli->warning("15 seconds to cancel the script! (press Ctrl-C)\n"); sleep(15); $db = eZDB::instance(); $offset = 0; $limit = 50; $attributeCount = (int) eZPersistentObject::count(eZContentObjectAttribute::definition(), array('data_type_string' => 'sckenhancedselection')); while ($offset < $attributeCount) { eZContentObject::clearCache(); /** @var eZContentObjectAttribute[] $attributes */ $attributes = eZPersistentObject::fetchObjectList(eZContentObjectAttribute::definition(), null, array('data_type_string' => 'sckenhancedselection'), null, array('offset' => $offset, 'length' => $limit)); foreach ($attributes as $attribute) { SckEnhancedSelection::removeByAttribute($attribute->attribute('id'), $attribute->attribute('version')); $identifiers = unserialize((string) $attribute->attribute('data_text')); if (is_array($identifiers) && !empty($identifiers)) { foreach ($identifiers as $identifier) { $sckEnhancedSelection = new SckEnhancedSelection(array('contentobject_attribute_id' => $attribute->attribute('id'), 'contentobject_attribute_version' => $attribute->attribute('version'), 'identifier' => $identifier)); $sckEnhancedSelection->store(); } } $attribute->setAttribute('data_text', null); $attribute->store();
static function removeUser($userID) { $user = eZUser::fetch($userID); if (!$user) { eZDebug::writeError("unable to find user with ID {$userID}", __METHOD__); return false; } eZUser::removeSessionData($userID); eZSubtreeNotificationRule::removeByUserID($userID); eZCollaborationNotificationRule::removeByUserID($userID); eZUserSetting::removeByUserID($userID); eZUserAccountKey::removeByUserID($userID); eZForgotPassword::removeByUserID($userID); eZWishList::removeByUserID($userID); // only remove general digest setting if there are no other users with the same e-mail $email = $user->attribute('email'); $usersWithEmailCount = eZPersistentObject::count(eZUser::definition(), array('email' => $email)); if ($usersWithEmailCount == 1) { eZGeneralDigestUserSettings::removeByAddress($email); } eZPersistentObject::removeObject(eZUser::definition(), array('contentobject_id' => $userID)); return true; }
default: $limit = 10; break; } $languages = eZContentLanguage::fetchList(); $tpl = eZTemplate::factory(); eZDebug::writeDebug($Module->currentAction()); if ($Module->isCurrentAction('Remove') && $Module->hasActionParameter('RemoveIDList')) { $removeIDList = $Module->actionParameter('RemoveIDList'); foreach ($removeIDList as $removeID) { $group = eZContentObjectStateGroup::fetchById($removeID); if ($group && !$group->isInternal()) { eZContentObjectStateGroup::removeByID($removeID); } } } else { if ($Module->isCurrentAction('Create')) { return $Module->redirectTo('state/group_edit'); } } $groups = eZContentObjectStateGroup::fetchByOffset($limit, $offset); $groupCount = eZPersistentObject::count(eZContentObjectStateGroup::definition()); $viewParameters = array('offset' => $offset); $tpl->setVariable('limit', $limit); $tpl->setVariable('list_limit_preference_name', $listLimitPreferenceName); $tpl->setVariable('list_limit_preference_value', $listLimitPreferenceValue); $tpl->setVariable('groups', $groups); $tpl->setVariable('group_count', $groupCount); $tpl->setVariable('view_parameters', $viewParameters); $tpl->setVariable('languages', $languages); $Result = array('content' => $tpl->fetch('design:state/groups.tpl'), 'path' => array(array('url' => false, 'text' => ezpI18n::tr('kernel/state', 'State')), array('url' => false, 'text' => ezpI18n::tr('kernel/state', 'Groups'))));
public function fetchElevateConfiguration( $countOnly = false, $offset = 0, $limit = 10, $searchQuery = null, $languageCode = null ) { $conds = null; $limit = array( 'offset' => $offset, 'limit' => $limit ); $fieldFilters = null; $custom = null; // START polymorphic part if ( $searchQuery !== null ) { $results = eZFindElevateConfiguration::fetchObjectsForQueryString( $searchQuery, false, $languageCode, $limit, $countOnly ); } else { if ( $languageCode ) $conds = array( 'language_code' => $languageCode ); if ( $countOnly ) { $results = eZPersistentObject::count( eZFindElevateConfiguration::definition(), $conds ); } else { $sorts = array( 'search_query' => 'asc' ); $results = eZPersistentObject::fetchObjectList( eZFindElevateConfiguration::definition(), $fieldFilters, $conds, $sorts, $limit, false, false, $custom ); } } // END polymorphic part if ( $results === null ) { // @TODO : return a more explicit error code and info. return array( 'error' => array( 'error_type' => 'extension/ezfind/elevate', 'error_code' => eZError::KERNEL_NOT_FOUND ) ); } else { return array( 'result' => $results ); } }
/** * Count the comments by content object id * @param integer $contentObjectID * @param integer $languageID * @param integer $status * @return count of comments */ static function countByContent($contentObjectID = false, $languageID = false, $status = null) { $cond = array(); if ($contentObjectID !== false) { $cond['contentobject_id'] = $contentObjectID; } if ($languageID !== false) { $cond['language_id'] = $languageID; } if (!is_null($status)) { $cond['status'] = $status; } return eZPersistentObject::count(self::definition(), $cond); }