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(); } }
/** * @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); }
/** * Test scenario for issue #13492: Links are lost after removing version * * Test Outline * ------------ * 1. Create a Folder in English containing a link (in the short_description attribute). * 2. Translate Folder into Norwegian containing another link (not the same link as above.) * 3. Remove Folder version 1. (Version 2 is created when translating). * * @result: short_description in version 2 will have an empty link. * @expected: short_description should contain same link as in version 1. * @link http://issues.ez.no/13492 */ public function testLinksAcrossTranslations() { ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'ContentObjectLocale', 'eng-GB'); $xmlDataEng = '<link href="/some-where-random">a link</link>'; $xmlDataNor = '<link href="/et-tilfeldig-sted">en link</link>'; // Step 1: Create folder $folder = new ezpObject("folder", 2); $folder->name = "Folder Eng"; $folder->short_description = $xmlDataEng; $folder->publish(); $version1Xml = $folder->short_description->attribute('output')->attribute('output_text'); // Step 2: Translate folder $trData = array("name" => "Folder Nor", "short_description" => $xmlDataNor); $folder->addTranslation("nor-NO", $trData); // addTranslation() publishes too. // Step 3: Remove version 1 $version1 = eZContentObjectVersion::fetchVersion(1, $folder->id); $version1->removeThis(); // Grab current versions data and make sure it's fresh. $folder->refresh(); $version2Xml = $folder->short_description->attribute('output')->attribute('output_text'); $folder->remove(); ezpINIHelper::restoreINISettings(); self::assertEquals($version1Xml, $version2Xml); }
/** * Adds a draft to the publishing queue * * @param int $objectId * @param int $version * * @return ezpContentPublishingProcess */ public static function add($objectId, $version) { self::init(); self::signals()->emit('preQueue', $version, $objectId); $processObject = ezpContentPublishingProcess::queue(eZContentObjectVersion::fetchVersion($version, $objectId)); return $processObject; }
public static function status( $args ) { if ( count( $args ) != 2 ) { throw new ezcBaseFunctionalityNotSupportedException( 'status', 'Missing argument(s)' ); } list( $contentObjectId, $version ) = $args; $process = ezpContentPublishingProcess::fetchByContentObjectVersion( $contentObjectId, $version ); // No process: check if the object's still a draft // @todo Change to a PENDING check when applied (operation => step 2) if ( $process instanceof ezpContentPublishingProcess ) { $return = array(); $status = $process->attribute( 'status' ) == ezpContentPublishingProcess::STATUS_WORKING ? 'working' : 'finished'; switch( $process->attribute( 'status' ) ) { case ezpContentPublishingProcess::STATUS_WORKING: $status = 'working'; break; case ezpContentPublishingProcess::STATUS_FINISHED: $status = 'finished'; $objectVersion = $process->attribute( 'version' ); $object = $objectVersion->attribute( 'contentobject' ); $node = $object->attribute( 'main_node' ); $uri = $node->attribute( 'url_alias' ); eZURI::transformURI( $uri ); $return['node_uri'] = $uri; break; case ezpContentPublishingProcess::STATUS_PENDING: $status = 'pending'; break; case ezpContentPublishingProcess::STATUS_DEFERRED: $status = 'deferred'; $versionViewUri = "content/versionview/{$contentObjectId}/{$version}"; eZURI::transformURI( $versionViewUri ); $return['versionview_uri'] = $versionViewUri; break; } $return['status'] = $status; } else { $version = eZContentObjectVersion::fetchVersion( $version, $contentObjectId ); if ( $version === null ) throw new ezcBaseFunctionalityNotSupportedException( 'status', 'Object version not found' ); else $return = array( 'status' => 'queued' ); } return $return; }
public function getDraftVersions($objects) { $return = array(); $user = eZUser::currentUser(); foreach ($objects as $object) { // If this user already has a draft in this language $filters = array('contentobject_id' => $object->attribute('id'), 'status' => array(array(eZContentObjectVersion::STATUS_DRAFT, eZContentObjectVersion::STATUS_INTERNAL_DRAFT)), 'creator_id' => $user->attribute('contentobject_id')); $existingDrafts = eZContentObjectVersion::fetchFiltered($filters, 0, 1); if (!empty($existingDrafts)) { $return[] = $existingDrafts[0]; } else { $return[] = $object->createNewVersion(false, true); } } return $return; }
public function execute($process, $event) { $processParameters = $process->attribute('parameter_list'); $object = eZContentObject::fetch($processParameters['object_id']); $node = $object->mainNode(); $href = '/push/node/' . $node->attribute('node_id'); $version = eZContentObjectVersion::fetchVersion($processParameters['version'], $processParameters['object_id']); if ($version instanceof eZContentObjectVersion) { $language = eZContentLanguage::fetch($version->attribute('initial_language_id')); if ($language instanceof eZContentLanguage) { $href .= '/' . $language->attribute('locale'); } } eZURI::transformURI($href, false, 'full'); $http = eZHTTPTool::instance(); $http->setSessionVariable('RedirectURIAfterPublish', $href); return eZWorkflowType::STATUS_ACCEPTED; }
/** * Spezific function to fetch NL list * if it is an Virtual List return a CjwNewsletterListVirtual object * otherwise CjwNewsletterList * * @param int $listContentObjectId * @param int $listContentObjectVersion */ static function fetchByListObjectVersion($listContentObjectId, $listContentObjectVersion) { if ((int) $listContentObjectVersion == 0) { $listContentObject = eZContentObject::fetch($listContentObjectId, true); if (!is_object($listContentObject)) { return false; } $listContentObjectVersion = $listContentObject->attribute('current'); } else { $listContentObjectVersion = eZContentObjectVersion::fetchVersion($listContentObjectVersion, $listContentObjectId); } if (is_object($listContentObjectVersion)) { $dataMap = $listContentObjectVersion->attribute('data_map'); if (isset($dataMap['newsletter_list'])) { $newsletterListAttribute = $dataMap['newsletter_list']; $newsletterListAttributeContent = $newsletterListAttribute->attribute('content'); return $newsletterListAttributeContent; } else { return false; } } else { return false; } }
$ini = eZINI::instance('content.ini'); $internalDraftsCleanUpLimit = $ini->hasVariable('VersionManagement', 'InternalDraftsCleanUpLimit') ? $ini->variable('VersionManagement', 'InternalDraftsCleanUpLimit') : 0; $durationSetting = $ini->hasVariable('VersionManagement', 'InternalDraftsDuration') ? $ini->variable('VersionManagement', 'InternalDraftsDuration') : array('hours' => 24); // by default, only remove drafts older than 1 day $isDurationSet = false; $duration = 0; if (is_array($durationSetting)) { if (isset($durationSetting['days']) and is_numeric($durationSetting['days'])) { $duration += $durationSetting['days'] * 60 * 60 * 24; $isDurationSet = true; } if (isset($durationSetting['hours']) and is_numeric($durationSetting['hours'])) { $duration += $durationSetting['hours'] * 60 * 60; $isDurationSet = true; } if (isset($durationSetting['minutes']) and is_numeric($durationSetting['minutes'])) { $duration += $durationSetting['minutes'] * 60; $isDurationSet = true; } if (isset($durationSetting['seconds']) and is_numeric($durationSetting['seconds'])) { $duration += $durationSetting['seconds']; $isDurationSet = true; } } if ($isDurationSet) { $expiryTime = time() - $duration; $processedCount = eZContentObjectVersion::removeVersions(eZContentObjectVersion::STATUS_INTERNAL_DRAFT, $internalDraftsCleanUpLimit, $expiryTime); $cli->output("Cleaned up " . $processedCount . " internal drafts"); } else { $cli->output("Lifetime is not set for internal drafts (see your ini-settings, content.ini, VersionManagement section)."); }
function objectAttributes($asObject = true) { return eZContentObjectVersion::fetchAttributes($this->Version, $this->ContentObjectID, $this->LanguageCode, $asObject); }
// // The "eZ publish professional licence" version 2 is available at // http://ez.no/ez_publish/licences/professional/ and in the file // PROFESSIONAL_LICENCE included in the packaging of this file. // For pricing of this licence please contact us via e-mail to licence@ez.no. // Further contact information is available at http://ez.no/company/contact/. // // The "GNU General Public License" (GPL) is available at // http://www.gnu.org/copyleft/gpl.html. // // Contact licence@ez.no if any conditions of this licencing isn't clear to // you. // $ObjectID = $Params['ObjectID']; $ObjectVersion = $Params['ObjectVersion']; $object = eZContentObjectVersion::fetchVersion($ObjectVersion, $ObjectID); $newsletter = eZNewsletter::fetchByContentObject($ObjectID, $ObjectVersion, false, true); $tpl = eZNewsletterTemplateWrapper::templateInit(); $tpl->setVariable('object', $object); $tpl->setVariable('contentobject', $object); $tpl->setVariable('newsletter', $newsletter); if (!$newsletter) { return false; } //skin selection $skin_prefix = 'eznewsletter'; $custom_skin = $newsletter->attribute('design_to_use'); $Result = array(); if ($custom_skin) { $skin_prefix = $custom_skin; }
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__); } } }
} else { $domain = getenv('HTTP_HOST'); $protocol = eZSys::serverProtocol(); $preFix = $protocol . "://" . $domain; $preFix .= eZSys::wwwDir(); $link = preg_replace("/^\\//e", "", $link); $link = $preFix . "/" . $link; } $viewParameters = array('offset' => $offset, 'limit' => $limit); $http = eZHTTPTool::instance(); $objectList = eZURLObjectLink::fetchObjectVersionList($urlID, $viewParameters); $urlViewCount = eZURLObjectLink::fetchObjectVersionCount($urlID); if ($Module->isCurrentAction('EditObject')) { if ($http->hasPostVariable('ObjectList')) { $versionID = $http->postVariable('ObjectList'); $version = eZContentObjectVersion::fetch($versionID); $contentObjectID = $version->attribute('contentobject_id'); $versionNr = $version->attribute('version'); $Module->redirect('content', 'edit', array($contentObjectID, $versionNr)); } } $tpl = eZTemplate::factory(); $tpl->setVariable('Module', $Module); $tpl->setVariable('url_object', $url); $tpl->setVariable('full_url', $link); $tpl->setVariable('object_list', $objectList); $tpl->setVariable('view_parameters', $viewParameters); $tpl->setVariable('url_view_count', $urlViewCount); $Result = array(); $Result['content'] = $tpl->fetch('design:url/view.tpl'); $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('kernel/url', 'URL')), array('url' => false, 'text' => ezpI18n::tr('kernel/url', 'View')));
function eventContent($event) { return eZContentObjectVersion::fetchVersion($event->attribute('data_int2'), $event->attribute('data_int1')); }
foreach ( $deleteIDArray as $deleteID ) { $version = eZContentObjectVersion::fetch( $deleteID ); if ( $version instanceof eZContentObjectVersion ) { eZDebug::writeNotice( $deleteID, "deleteID" ); $version->removeThis(); } } $db->commit(); } } if ( $http->hasPostVariable( 'EmptyButton' ) ) { $versions = eZContentObjectVersion::fetchForUser( $userID ); $db = eZDB::instance(); $db->begin(); foreach ( $versions as $version ) { $version->removeThis(); } $db->commit(); } $tpl = eZTemplate::factory(); $tpl->setVariable('view_parameters', $viewParameters ); $Result = array(); $Result['content'] = $tpl->fetch( 'design:content/draft.tpl' );
/** * @param int|bool $versionStatus * @deprecated This method is left here only for backward compatibility. Use eZContentObjectVersion::removeVersions() method instead. */ static function removeVersions( $versionStatus = false ) { eZContentObjectVersion::removeVersions( $versionStatus ); }
// Cleaning up usual drafts $ini = eZINI::instance('content.ini'); $draftsCleanUpLimit = $ini->hasVariable('VersionManagement', 'DraftsCleanUpLimit') ? $ini->variable('VersionManagement', 'DraftsCleanUpLimit') : 0; $durationSetting = $ini->hasVariable('VersionManagement', 'DraftsDuration') ? $ini->variable('VersionManagement', 'DraftsDuration') : array('days' => 90); $isDurationSet = false; $duration = 0; if (is_array($durationSetting)) { if (isset($durationSetting['days']) and is_numeric($durationSetting['days'])) { $duration += $durationSetting['days'] * 60 * 60 * 24; $isDurationSet = true; } if (isset($durationSetting['hours']) and is_numeric($durationSetting['hours'])) { $duration += $durationSetting['hours'] * 60 * 60; $isDurationSet = true; } if (isset($durationSetting['minutes']) and is_numeric($durationSetting['minutes'])) { $duration += $durationSetting['minutes'] * 60; $isDurationSet = true; } if (isset($durationSetting['seconds']) and is_numeric($durationSetting['seconds'])) { $duration += $durationSetting['seconds']; $isDurationSet = true; } } if ($isDurationSet) { $expiryTime = time() - $duration; $processedCount = eZContentObjectVersion::removeVersions(eZContentObjectVersion::STATUS_DRAFT, $draftsCleanUpLimit, $expiryTime); $cli->output("Cleaned up " . $processedCount . " drafts"); } else { $cli->output("Lifetime is not set for user's drafts (see your ini-settings, content.ini, VersionManagement section)."); }
function execute($process, $event) { $parameters = $process->attribute('parameter_list'); eZDebug::writeDebug($parameters, 'CreateSubtreeNotificationRuleType::execute process parameter_list'); include_once 'kernel/classes/ezcontentobject.php'; $object = eZContentObject::fetch($parameters['object_id']); $datamap = $object->attribute('data_map'); $attributeIDList = $event->attribute('selected_attributes'); $mainNodeID = $object->attribute('main_node_id'); foreach ($datamap as $attribute) { if (in_array($attribute->attribute('contentclassattribute_id'), $attributeIDList)) { eZDebug::writeDebug('found matching attribute: ' . $attribute->attribute('contentclassattribute_id'), 'CreateSubtreeNotificationRuleType'); // get related objects $relatedObjects = $object->relatedContentObjectList(false, false, $attribute->attribute('contentclassattribute_id')); include_once 'kernel/classes/datatypes/ezuser/ezuser.php'; foreach ($relatedObjects as $relatedObject) { // check if the related object is a user $userID = $relatedObject->attribute('id'); $relatedUser = eZUser::fetch($userID); if ($relatedUser) { CreateSubtreeNotificationRuleType::createNotificationRuleIfNeeded($userID, $mainNodeID); } } } } $ownerID = $object->attribute('owner_id'); if ($event->attribute('use_owner')) { CreateSubtreeNotificationRuleType::createNotificationRuleIfNeeded($ownerID, $mainNodeID); } if ($event->attribute('use_creator')) { $version = eZContentObjectVersion::fetchVersion($parameters['version'], $parameters['object_id']); $creatorID = $version->attribute('creator_id'); if (!$event->attribute('use_owner') || $creatorID != $ownerID) { CreateSubtreeNotificationRuleType::createNotificationRuleIfNeeded($creatorID, $mainNodeID); } } return eZWorkflowType::STATUS_ACCEPTED; }
if ($dbUser !== false) { $params['user'] = $dbUser; $params['password'] = ''; } if ($dbPassword !== false) { $params['password'] = $dbPassword; } if ($dbName !== false) { $params['database'] = $dbName; } $db = eZDB::instance($dbImpl, $params, true); eZDB::setInstance($db); } $db->setIsSQLOutputEnabled($showSQL); if ($flatten['contentobject']) { $cli->output("Removing non-published content object versions"); eZContentObjectVersion::removeVersions(); } if ($flatten['contentclass']) { $cli->output("Removing temporary content classes"); eZContentClass::removeTemporary(); } if ($flatten['workflow']) { $cli->output("Removing temporary workflows"); eZWorkflow::removeTemporary(); } if ($flatten['role']) { $cli->output("Removing temporary roles"); eZRole::removeTemporary(); } $script->shutdown();
function objectVersion() { return eZContentObjectVersion::fetchVersion($this->Version, $this->ContentObjectID); }
function installSuspendedObjectRelations( &$installParameters ) { if ( !isset( $installParameters['suspended-relations'] ) ) { return; } foreach( $installParameters['suspended-relations'] as $suspendedObjectRelation ) { $contentObjectID = $suspendedObjectRelation['contentobject-id']; $contentObjectVersionID = $suspendedObjectRelation['contentobject-version']; $contentObjectVersion = eZContentObjectVersion::fetchVersion( $contentObjectVersionID, $contentObjectID ); if ( is_object( $contentObjectVersion ) ) { $relatedObjectRemoteID = $suspendedObjectRelation['related-object-remote-id']; $relatedObject = eZContentObject::fetchByRemoteID( $relatedObjectRemoteID ); $relatedObjectID = ( $relatedObject !== null ) ? $relatedObject->attribute( 'id' ) : null; if ( $relatedObjectID ) { $relatedObject->addContentObjectRelation( $relatedObjectID, $contentObjectVersionID, $contentObjectID ); } else { eZDebug::writeError( 'Can not find related object by remote-id ID = ' . $relatedObjectRemoteID, __METHOD__ ); } } } unset( $installParameters['suspended-relations'] ); }
function instantiate($userID = false, $sectionID = 0, $versionNumber = false, $languageCode = false, $versionStatus = eZContentObjectVersion::STATUS_INTERNAL_DRAFT) { $attributes = $this->fetchAttributes(); if ($userID === false) { $user = eZUser::currentUser(); $userID = $user->attribute('contentobject_id'); } if ($languageCode == false) { $languageCode = eZContentObject::defaultLanguage(); } $object = eZContentObject::create(ezpI18n::tr("kernel/contentclass", "New %1", null, array($this->name($languageCode))), $this->attribute("id"), $userID, $sectionID, 1, $languageCode); if ($this->attribute('always_available')) { $object->setAttribute('language_mask', (int) $object->attribute('language_mask') | 1); } $db = eZDB::instance(); $db->begin(); $object->store(); $object->assignDefaultStates(); $object->setName(ezpI18n::tr("kernel/contentclass", "New %1", null, array($this->name($languageCode))), false, $languageCode); if (!$versionNumber) { $version = $object->createInitialVersion($userID, $languageCode); } else { $version = eZContentObjectVersion::create($object->attribute("id"), $userID, $versionNumber, $languageCode); } if ($versionStatus !== false) { $version->setAttribute('status', $versionStatus); } $version->store(); foreach ($attributes as $attribute) { $attribute->instantiate($object->attribute('id'), $languageCode); } if (isset($user) && $user instanceof eZUser && $user->isAnonymous()) { $createdObjectIDList = eZPreferences::value('ObjectCreationIDList'); if (!$createdObjectIDList) { $createdObjectIDList = array($object->attribute('id')); } else { $createdObjectIDList = unserialize($createdObjectIDList); $createdObjectIDList[] = $object->attribute('id'); } eZPreferences::setValue('ObjectCreationIDList', serialize($createdObjectIDList)); } $db->commit(); return $object; }
public static function fetchVersionCount($contentObject) { if (!is_object($contentObject)) { return array('result' => 0); } $versionList = eZPersistentObject::fetchObjectList(eZContentObjectVersion::definition(), array(), array('contentobject_id' => $contentObject->attribute('id')), false, null, false, false, array(array('operation' => 'count( * )', 'name' => 'count'))); return array('result' => $versionList[0]['count']); }
/** * Sends the published object/version for publishing to the queue * Used by the content/publish operation * @param int $objectId * @param int $version * * @return array( status => int ) * @since 4.5 */ public static function sendToPublishingQueue($objectId, $version) { $behaviour = ezpContentPublishingBehaviour::getBehaviour(); if ($behaviour->disableAsynchronousPublishing) { $asyncEnabled = false; } else { $asyncEnabled = eZINI::instance('content.ini')->variable('PublishingSettings', 'AsynchronousPublishing') == 'enabled'; } $accepted = true; if ($asyncEnabled === true) { // Filter handlers $ini = eZINI::instance('content.ini'); $filterHandlerClasses = $ini->variable('PublishingSettings', 'AsynchronousPublishingFilters'); if (count($filterHandlerClasses)) { $versionObject = eZContentObjectVersion::fetchVersion($version, $objectId); foreach ($filterHandlerClasses as $filterHandlerClass) { if (!class_exists($filterHandlerClass)) { eZDebug::writeError("Unknown asynchronous publishing filter handler class '{$filterHandlerClass}'", __METHOD__); continue; } $handler = new $filterHandlerClass($versionObject); if (!$handler instanceof ezpAsynchronousPublishingFilterInterface) { eZDebug::writeError("Asynchronous publishing filter handler class '{$filterHandlerClass}' does not implement ezpAsynchronousPublishingFilterInterface", __METHOD__); continue; } $accepted = $handler->accept(); if (!$accepted) { eZDebugSetting::writeDebug("Object #{$objectId}/{$version} was excluded from asynchronous publishing by {$filterHandlerClass}", __METHOD__); break; } } } unset($filterHandlerClasses, $handler); } if ($asyncEnabled && $accepted) { // if the object is already in the process queue, we move ahead // this test should NOT be necessary since http://issues.ez.no/17840 was fixed if (ezpContentPublishingQueue::isQueued($objectId, $version)) { return array('status' => eZModuleOperationInfo::STATUS_CONTINUE); } else { ezpContentPublishingQueue::add($objectId, $version); return array('status' => eZModuleOperationInfo::STATUS_HALTED, 'redirect_url' => "content/queued/{$objectId}/{$version}"); } } else { return array('status' => eZModuleOperationInfo::STATUS_CONTINUE); } }
/** * Get ezfSolrDocumentFieldBase instances for all attributes of specified eZContentObjectVersion * * @param eZContentObjectVersion Instance of eZContentObjectVersion to fetch attributes from. * * @return array List of ezfSolrDocumentFieldBase instances. */ function getBaseList( eZContentObjectVersion $objectVersion ) { $returnList = array(); // Get ezfSolrDocumentFieldBase instance for all attributes in related object if ( eZContentObject::recursionProtect( $this->ContentObjectAttribute->attribute( 'contentobject_id' ) ) ) { foreach ( $objectVersion->contentObjectAttributes( $this->ContentObjectAttribute->attribute( 'language_code' ) ) as $attribute ) { if ( $attribute->attribute( 'contentclass_attribute' )->attribute( 'is_searchable' ) ) { $returnList[] = ezfSolrDocumentFieldBase::getInstance( $attribute ); } } } return $returnList; }
} $res = eZTemplateDesignResource::instance(); $res->setKeys(array(array('object', $object->attribute('id')), array('remote_id', $object->attribute('remote_id')), array('class', $object->attribute('contentclass_id')), array('class_identifier', $object->attribute('class_identifier')), array('section_id', $object->attribute('section_id')), array('section', $object->attribute('section_id')))); // Section ID, 0 so far $section = eZSection::fetch($object->attribute('section_id')); if ($section) { $res->setKeys(array(array('section_identifier', $section->attribute('identifier')))); } $versionArray = isset($versionArray) && is_array($versionArray) ? array_unique($versionArray, SORT_REGULAR) : array(); $LastAccessesVersionURI = $http->hasSessionVariable('LastAccessesVersionURI') ? $http->sessionVariable('LastAccessesVersionURI') : null; $explodedURI = $LastAccessesVersionURI ? explode('/', $LastAccessesVersionURI) : null; if ($LastAccessesVersionURI and is_array($versionArray) and !in_array($explodedURI[3], $versionArray)) { $tpl->setVariable('redirect_uri', $http->sessionVariable('LastAccessesVersionURI')); } //Fetch newer drafts and count of newer drafts. $newerDraftVersionList = eZPersistentObject::fetchObjectList(eZContentObjectVersion::definition(), null, array('contentobject_id' => $object->attribute('id'), 'status' => eZContentObjectVersion::STATUS_DRAFT, 'version' => array('>', $object->attribute('current_version'))), array('modified' => 'asc', 'initial_language_id' => 'desc'), null, true); $newerDraftVersionListCount = is_array($newerDraftVersionList) ? count($newerDraftVersionList) : 0; $versions = $object->versions(); $tpl->setVariable('newerDraftVersionList', $newerDraftVersionList); $tpl->setVariable('newerDraftVersionListCount', $newerDraftVersionListCount); $tpl->setVariable('view_parameters', $viewParameters); $tpl->setVariable('object', $object); $tpl->setVariable('edit_version', $EditVersion); $tpl->setVariable('versions', $versions); $tpl->setVariable('edit_warning', $editWarning); $tpl->setVariable('can_edit', $canEdit); //$tpl->setVariable( 'can_remove', $canRemove ); $tpl->setVariable('user_id', $user->attribute('contentobject_id')); $Result = array(); $Result['content'] = $tpl->fetch('design:content/history.tpl'); $Result['path'] = array(array('text' => ezpI18n::tr('kernel/content', 'History'), 'url' => false));
if ( !$obj->canEdit( false, false, false, $EditLanguage ) ) { return $Module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel', array( 'AccessList' => $obj->accessList( 'edit' ) ) ); } $isAccessChecked = true; $version = $obj->createNewVersionIn( $EditLanguage, false, false, true, eZContentObjectVersion::STATUS_INTERNAL_DRAFT ); return $Module->redirectToView( "edit", array( $ObjectID, $version->attribute( "version" ), $EditLanguage ) ); } } } elseif ( is_numeric( $EditVersion ) ) { // Fetch version $version = eZContentObjectVersion::fetchVersion( $EditVersion, $obj->attribute( 'id' ) ); if ( !is_object( $version ) ) { return $Module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' ); } $user = eZUser::currentUser(); // Check if $user can edit the current version. // We should not allow to edit content without creating a new version. if ( ( $version->attribute( 'status' ) != eZContentObjectVersion::STATUS_INTERNAL_DRAFT and $version->attribute( 'status' ) != eZContentObjectVersion::STATUS_DRAFT and $version->attribute( 'status' ) != eZContentObjectVersion::STATUS_REPEAT ) or $version->attribute( 'creator_id' ) != $user->id() ) { return $Module->redirectToView( 'history', array( $ObjectID, $version->attribute( "version" ), $EditLanguage ) ); } }
/** * Adds a version to the publishing queue * @param eZContentObjectVersion $version * @return ezpContentPublishingProcess */ public static function queue(eZContentObjectVersion $version) { $row = array('ezcontentobject_version_id' => $version->attribute('id'), 'created' => time(), 'status' => self::STATUS_PENDING); $processObject = new self($row); $processObject->store(); return $processObject; }
$ownerNodeAssignments = $owner->attribute('assigned_nodes'); $nodeAssignments = array_merge($nodeAssignments, $ownerNodeAssignments); } } } // If exists location that current user has access to and location is visible. $canAccess = false; $isContentDraft = $contentObject->attribute('status') == eZContentObject::STATUS_DRAFT; foreach ($nodeAssignments as $nodeAssignment) { if (eZContentObjectTreeNode::showInvisibleNodes() || !$nodeAssignment->attribute('is_invisible') and $nodeAssignment->canRead()) { $canAccess = true; break; } } if (!$canAccess && !$isContentDraft) { return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'); } // If $version is not current version (published) // we should check permission versionRead for the $version. if ($version != $currentVersion || $isContentDraft) { $versionObj = eZContentObjectVersion::fetchVersion($version, $contentObjectID); if (is_object($versionObj) and !$versionObj->canVersionRead()) { return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'); } } $fileHandler = eZBinaryFileHandler::instance(); $result = $fileHandler->handleDownload($contentObject, $contentObjectAttribute, eZBinaryFileHandler::TYPE_FILE); if ($result == eZBinaryFileHandler::RESULT_UNAVAILABLE) { eZDebug::writeError("The specified file could not be found."); return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'); }
/** * Returns the eZContentObjectVersionObject of the current node * * @param bool $asObject * @return eZContentObjectVersion|array|bool */ function contentObjectVersionObject($asObject = true) { $version = eZContentObjectVersion::fetchVersion($this->ContentObjectVersion, $this->ContentObjectID, $asObject); if ($this->CurrentLanguage != false) { $version->CurrentLanguage = $this->CurrentLanguage; } return $version; }