/** * 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; }
/** * @deprecated since eZ Find 2.1 * Get collection data. Returns list of ezfSolrDocumentFieldBase documents. * * @return array List of ezfSolrDocumentFieldBase objects. */ public function getCollectionData() { $returnList = array(); switch( $this->ContentObjectAttribute->attribute( 'data_type_string' ) ) { case 'ezobjectrelation': { $returnList = $this->getBaseList( $this->ContentObjectAttribute->attribute( 'object_version' ) ); } break; case 'ezobjectrelationlist': { $content = $this->ContentObjectAttribute->content(); foreach ( $content['relation_list'] as $relationItem ) { $subObjectID = $relationItem['contentobject_id']; if ( !$subObjectID ) continue; $subObject = eZContentObjectVersion::fetchVersion( $relationItem['contentobject_version'], $subObjectID ); if ( !$subObject ) continue; $returnList = array_merge( $this->getBaseList( $subObject ), $returnList ); } } break; } return $returnList; }
/** * 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); }
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; }
/** * Fetches a process by its content object ID + version * @param int $contentObjectId * @param int $version * @return ezpContentPublishingProcess */ public static function fetchByContentObjectVersion($contentObjectId, $version) { $contentObjectVersion = eZContentObjectVersion::fetchVersion($version, $contentObjectId); if ($contentObjectVersion instanceof eZContentObjectVersion) { $return = self::fetchByContentVersionId($contentObjectVersion->attribute('id')); return $return; } else { return false; } }
public static function fetchNonTranslationList($objectID, $version) { $version = eZContentObjectVersion::fetchVersion($version, $objectID); if (!$version) { return array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND)); } $nonTranslationList = $version->nonTranslationList(); if ($nonTranslationList === null) { return array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND)); } return array('result' => $nonTranslationList); }
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; } }
// // 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__); } } }
/** * 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; }
if ($options['current_hostname']) { $currentHostName = $options['current_hostname']; } if ($options['www_dir']) { $wwwDir = $options['www_dir']; } if ($options['skin_name']) { $skinName = $options['skin_name']; } //$iniName = $options['arguments'][0]; $ini = eZINI::instance('site.ini'); $siteUrl = $ini->variable('SiteSettings', 'SiteURL'); $locale = $ini->variable('RegionalSettings', 'Locale'); $outputContent = ''; // fetch objectversion $contentObject = eZContentObjectVersion::fetchVersion($objectVersion, $objectId); $tpl = templateInit(); $tpl->setVariable('contentobject', $contentObject); if (!is_object($contentObject)) { $script->shutdown(); } $contentType = 'text/html'; $newsletterEditionContent = array('html' => '', 'text' => ''); $htmlMailImageInclude = 0; $urlArray = getUrlArray($siteUrl, $currentHostName, $wwwDir); switch ($outputFormatId) { default: // html 0 // html 0 case CjwNewsletterSubscription::OUTPUT_FORMAT_HTML: // textpart
/** * Test regression for issue #14371 in a module/view context: * Workflow template repeat broken by security patch. * * Test Outline * ------------ * 1. Setup a workflow that features a custom workflow event that expects a * value to be submitted before * 2. Create & publish an article * 3. Add a global POST variable that would be sent interactively from POST * 4. Publish again with this variable * * @result: Redirection to content/history * @expected: The object gets published without being redirected * @link http://issues.ez.no/14371 */ public function testEditAfterFetchTemplateRepeatOperation() { // first, we need to create an appropriate test workflow $adminUser = eZUser::fetchByName('admin'); $adminUserID = $adminUser->attribute('contentobject_id'); // Create approval workflow and set up pre publish trigger $this->workflow = $this->createWorkFlow($adminUserID); $this->trigger = $this->createTrigger($this->workflow->attribute('id')); // Log in as a user who's allowed to publish content $this->currentUser = eZUser::currentUser(); eZUser::setCurrentlyLoggedInUser($adminUser, $adminUserID); // required to avoid a notice $GLOBALS['eZSiteBasics']['user-object-required'] = false; $contentModule = eZModule::findModule('content'); $adminUserID = eZUser::fetchByName('admin')->attribute('contentobject_id'); // STEP 1: Create an article // This should start the publishing process, and interrupt it because // of the fetch template repeat workflow (expected) $article = new ezpObject("article", 2, $adminUserID); $article->name = "Article (with interactive workflow) for issue/regression #14371"; $objectID = $article->publish(); $version = eZContentObjectVersion::fetchVersion(1, $objectID); // STEP 2: Add the POST variables that will allow the operation to continue $_POST['CompletePublishing'] = 1; // STEP 3: run content/edit again in order to simulate a POST from the custom TPL $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $objectID, 'version' => 1)); $this->assertInternalType('array', $operationResult); $this->assertEquals($operationResult['status'], eZModuleOperationInfo::STATUS_CONTINUE, "The operation result wasn't CONTINUE"); $this->removeWorkflow($this->workflow); // Log in as whoever was logged in eZUser::setCurrentlyLoggedInUser($this->currentUser, $this->currentUser->attribute('id')); }
/** * 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); } }
function eventContent($event) { return eZContentObjectVersion::fetchVersion($event->attribute('data_int2'), $event->attribute('data_int1')); }
break; } } } if ($fileExists) { $isValid = true; $info = getimagesize($filePath); if ($info) { $width = $info[0]; $height = $info[1]; } $mimeInfo = eZMimeType::findByFileContents($filePath); $mimeType = $mimeInfo['name']; $newFilePath = $filePath; $newSuffix = $suffix; $contentVersion = eZContentObjectVersion::fetchVersion($attributeVersion, $objectID); if ($contentVersion) { $objectName = $imageAliasHandler->imageName($contentObjectAttribute, $contentVersion); $objectPathString = $imageAliasHandler->imagePath($contentObjectAttribute, $contentVersion); $newDirPath = $objectPathString; $newFileName = $objectName . '.' . $mimeInfo['suffix']; $newSuffix = $mimeInfo['suffix']; $newFilePath = $newDirPath . '/' . $newFileName; $newBaseName = $objectName; } if ($newFilePath != $filePath) { if (!file_exists($newDirPath)) { eZDir::mkdir($newDirPath, false, true); } eZFileHandler::copy($filePath, $newFilePath); $filePath = $newFilePath;
function initializeFromFile($filename, $imageAltText = false, $originalFilename = false) { if (!file_exists($filename)) { $contentObjectID = isset($this->ContentObjectAttributeData['contentobject_id']) ? $this->ContentObjectAttributeData['contentobject_id'] : 0; $contentObjectAttributeID = isset($this->ContentObjectAttributeData['id']) ? $this->ContentObjectAttributeData['id'] : 0; $version = isset($this->ContentObjectAttributeData['version']) ? $this->ContentObjectAttributeData['version'] : 0; $contentObject = eZContentObject::fetch($contentObjectID); $contentObjectAttribute = eZContentObjectAttribute::fetch($contentObjectAttributeID, $version); $contentObjectAttributeName = ''; $contentObjectName = ''; if ($contentObject instanceof eZContentObject) { $contentObjectName = $contentObject->attribute('name'); } if ($contentObjectAttribute instanceof eZContentObjectAttribute) { $contentObjectAttributeName = $contentObjectAttribute->attribute('contentclass_attribute_name'); } eZDebug::writeError("The image '{$filename}' does not exist, cannot initialize image attribute: '{$contentObjectAttributeName}' (id: {$contentObjectAttributeID}) for content object: '{$contentObjectName}' (id: {$contentObjectID})", __METHOD__); return false; } $this->increaseImageSerialNumber(); if (!$originalFilename) { $originalFilename = basename($filename); } $mimeData = eZMimeType::findByFileContents($filename); if (!$mimeData['is_valid'] and $originalFilename != $filename) { $mimeData = eZMimeType::findByFileContents($originalFilename); } $attr = false; $this->removeAliases($attr); $this->setOriginalAttributeDataValues($this->ContentObjectAttributeData['id'], $this->ContentObjectAttributeData['version'], $this->ContentObjectAttributeData['language_code']); $contentVersion = eZContentObjectVersion::fetchVersion($this->ContentObjectAttributeData['version'], $this->ContentObjectAttributeData['contentobject_id']); $objectName = $this->imageName($this->ContentObjectAttributeData, $contentVersion); $objectPathString = $this->imagePath($this->ContentObjectAttributeData, $contentVersion, true); eZMimeType::changeBaseName($mimeData, $objectName); eZMimeType::changeDirectoryPath($mimeData, $objectPathString); if (!file_exists($mimeData['dirpath'])) { eZDir::mkdir($mimeData['dirpath'], false, true); } eZFileHandler::copy($filename, $mimeData['url']); return $this->initialize($mimeData, $originalFilename, $imageAltText); }
static function contentObjectVersion($collaborationItem) { $contentObjectID = $collaborationItem->contentAttribute('content_object_id'); $contentObjectVersion = $collaborationItem->contentAttribute('content_object_version'); return eZContentObjectVersion::fetchVersion($contentObjectVersion, $contentObjectID); }
echo ezpI18n::tr('design/standard/error/kernel', 'Your current user does not have the proper privileges to access this page.'); eZExecution::cleanExit(); } $object = eZContentObject::fetch($objectID); $http = eZHTTPTool::instance(); $imageIni = eZINI::instance('image.ini'); $params = array('dataMap' => array('image')); if (!$object instanceof eZContentObject || !$object->canEdit()) { echo ezpI18n::tr('design/standard/ezoe', 'Invalid parameter: %parameter = %value', null, array('%parameter' => 'ObjectId', '%value' => $objectID)); eZExecution::cleanExit(); } // is this a upload? // forcedUpload is needed since hasPostVariable returns false if post size exceeds // allowed size set in max_post_size in php.ini if ($http->hasPostVariable('uploadButton') || $forcedUpload) { $version = eZContentObjectVersion::fetchVersion($objectVersion, $objectID); if (!$version) { echo ezpI18n::tr('design/standard/ezoe', 'Invalid parameter: %parameter = %value', null, array('%parameter' => 'ObjectVersion', '%value' => $objectVersion)); eZExecution::cleanExit(); } $upload = new eZContentUpload(); $location = false; if ($http->hasPostVariable('location')) { $location = $http->postVariable('location'); if ($location === 'auto' || trim($location) === '') { $location = false; } } $objectName = ''; if ($http->hasPostVariable('objectName')) { $objectName = trim($http->postVariable('objectName'));
/** * @see ezfSolrDocumentFieldBase::getData() */ public function getData() { /** @var eZContentClassAttribute $contentClassAttribute */ $contentClassAttribute = $this->ContentObjectAttribute->attribute('contentclass_attribute'); switch ($contentClassAttribute->attribute('data_type_string')) { case 'ezobjectrelation': $returnArray = array(); /** @var eZContentObject $relatedObject */ $relatedObject = $this->ContentObjectAttribute->content(); if ($relatedObject) { $returnArray = $this->getArrayRelatedObject($relatedObject, $contentClassAttribute); eZContentObject::clearCache(array($relatedObject->attribute('id'))); } return $returnArray; break; case 'ezobjectrelationlist': $returnArray = array(); $returnArrayRelatedObject = array(); $content = $this->ContentObjectAttribute->content(); $relationCount = count($content['relation_list']); foreach ($content['relation_list'] as $relationItem) { $subObjectID = $relationItem['contentobject_id']; if (!$subObjectID) { continue; } /** @var eZContentObjectVersion $subObject */ $subObject = eZContentObjectVersion::fetchVersion($relationItem['contentobject_version'], $subObjectID); if (!$subObject instanceof eZContentObjectVersion) { $subObjectWrapper = eZContentObject::fetch($subObjectID); if ($subObjectWrapper instanceof eZContentObject) { $subObject = $subObjectWrapper->currentVersion(); } else { continue; } } /** @var eZContentObject $subContentObject */ $subContentObject = $subObject->attribute('contentobject'); if (intval($subContentObject->attribute('main_node_id')) == 0) { continue; } $metaAttributeValues = eZSolr::getMetaAttributesForObject($subContentObject); foreach ($metaAttributeValues as $metaInfo) { $submetaFieldName = ezfSolrDocumentFieldBase::generateSubmetaFieldName($metaInfo['name'], $contentClassAttribute); if (isset($returnArray[$submetaFieldName])) { $returnArray[$submetaFieldName] = array_merge($returnArray[$submetaFieldName], array(ezfSolrDocumentFieldBase::preProcessValue($metaInfo['value'], $metaInfo['fieldType']))); } else { $returnArray[$submetaFieldName] = array(ezfSolrDocumentFieldBase::preProcessValue($metaInfo['value'], $metaInfo['fieldType'])); } } $nodeAttributeValues = array(); $nodePathArray = array(); /** @var eZContentObjectTreeNode $contentNode */ foreach ($subContentObject->attribute('assigned_nodes') as $contentNode) { foreach (eZSolr::nodeAttributes() as $attributeName => $fieldType) { $nodeAttributeValues[] = array('name' => $attributeName, 'value' => $contentNode->attribute($attributeName), 'fieldType' => $fieldType); } $nodePathArray[] = $contentNode->attribute('path_array'); } //@todo questo non va... occorre correggere schema.xml? //foreach ( $nodeAttributeValues as $metaInfo ) //{ // $submetaFieldName = ezfSolrDocumentFieldBase::generateSubmetaFieldName( $metaInfo['name'], $contentClassAttribute ); // if ( isset( $returnArray[$submetaFieldName] ) ) // { // $returnArray[$submetaFieldName] = array_merge( $returnArray[$submetaFieldName], // array( ezfSolrDocumentFieldBase::preProcessValue( $metaInfo['value'], $metaInfo['fieldType'] ) ) ); // } // else // { // $returnArray[$submetaFieldName] = array( ezfSolrDocumentFieldBase::preProcessValue( $metaInfo['value'], $metaInfo['fieldType'] ) ); // } //} foreach ($nodePathArray as $pathArray) { $submetaFieldName = ezfSolrDocumentFieldBase::generateSubmetaFieldName('path', $contentClassAttribute); foreach ($pathArray as $pathNodeID) { if (isset($returnArray[$submetaFieldName])) { $returnArray[$submetaFieldName] = array_merge($returnArray[$submetaFieldName], array($pathNodeID)); } else { $returnArray[$submetaFieldName] = array($pathNodeID); } } } if ($relationCount < 200) { $returnArrayRelatedObject = $this->getArrayRelatedObject($subContentObject, $contentClassAttribute, $returnArrayRelatedObject); } else { $objectName = $subContentObject->name(false, $this->ContentObjectAttribute->attribute('language_code')); $fieldName = parent::generateSubattributeFieldName($contentClassAttribute, 'name', self::DEFAULT_SUBATTRIBUTE_TYPE); if (isset($returnArrayRelatedObject[$fieldName])) { $returnArrayRelatedObject[$fieldName][] = $objectName; } else { $returnArrayRelatedObject[$fieldName] = array($objectName); } } $returnArray = array_merge_recursive($returnArray, $returnArrayRelatedObject); eZContentObject::clearCache(array($subContentObject->attribute('id'))); } $defaultFieldName = parent::generateAttributeFieldName($contentClassAttribute, self::$subattributesDefinition[self::DEFAULT_SUBATTRIBUTE]); $stringFieldName = parent::generateAttributeFieldName($contentClassAttribute, 'string'); $returnArray[$defaultFieldName] = $this->getPlainTextRepresentation(); $returnArray[$stringFieldName] = $this->getPlainTextRepresentation(); $result = array(); foreach ($returnArray as $key => $value) { if (is_array($value)) { $value = array_unique($value); } $result[$key] = $value; } return $result; break; } return array(); }
function objectVersion() { return eZContentObjectVersion::fetchVersion($this->Version, $this->ContentObjectID); }
/** * @see ezfSolrDocumentFieldBase::getData() */ public function getData() { $contentClassAttribute = $this->ContentObjectAttribute->attribute( 'contentclass_attribute' ); switch ( $contentClassAttribute->attribute( 'data_type_string' ) ) { case 'ezobjectrelation' : $returnArray = array(); $defaultFieldName = parent::generateAttributeFieldName( $contentClassAttribute, self::$subattributesDefinition[self::DEFAULT_SUBATTRIBUTE] ); $returnArray[$defaultFieldName] = $this->getPlainTextRepresentation(); $relatedObject = $this->ContentObjectAttribute->content(); if ( $relatedObject && $relatedObject->attribute( 'status' ) == eZContentObject::STATUS_PUBLISHED ) { // 1st, add content fields of the related object. $baseList = $this->getBaseList( $relatedObject->attribute( 'current' ) ); foreach ( $baseList as $field ) { $tmpClassAttribute = $field->ContentObjectAttribute->attribute( 'contentclass_attribute' ); $fieldName = $field->ContentObjectAttribute->attribute( 'contentclass_attribute_identifier' ); $fieldName = parent::generateSubattributeFieldName( $contentClassAttribute, $fieldName, self::getClassAttributeType( $tmpClassAttribute ) ); $finalValue = ''; if ( $tmpClassAttribute->attribute( 'data_type_string' ) == 'ezobjectrelation' or $tmpClassAttribute->attribute( 'data_type_string' ) == 'ezobjectrelationlist' ) { // The subattribute is in turn an object relation. Stop recursion and get full text representation. $finalValue = $field->getPlainTextRepresentation(); } else { $values = array_values( $field->getData() ); foreach ( $values as $value ) { if ( is_array( $value ) ) { $finalValue .= implode( ' ', $value ); } else { $finalValue .= ' ' . $value; } } } $returnArray[$fieldName] = trim( $finalValue, "\t\r\n " ); } // 2ndly, add meta fields of the related object. $metaAttributeValues = eZSolr::getMetaAttributesForObject( $relatedObject ); foreach ( $metaAttributeValues as $metaInfo ) { $returnArray[ezfSolrDocumentFieldBase::generateSubmetaFieldName( $metaInfo['name'], $contentClassAttribute )] = ezfSolrDocumentFieldBase::preProcessValue( $metaInfo['value'], $metaInfo['fieldType'] ); } return $returnArray; } break; case 'ezobjectrelationlist' : { $returnArray = array(); $content = $this->ContentObjectAttribute->content(); foreach ( $content['relation_list'] as $relationItem ) { $subObjectID = $relationItem['contentobject_id']; if ( !$subObjectID ) continue; $subObject = eZContentObjectVersion::fetchVersion( $relationItem['contentobject_version'], $subObjectID ); if ( !$subObject || $relationItem['in_trash'] ) continue; // 1st create aggregated metadata fields $metaAttributeValues = eZSolr::getMetaAttributesForObject( $subObject->attribute( 'contentobject' ) ); foreach ( $metaAttributeValues as $metaInfo ) { $submetaFieldName = ezfSolrDocumentFieldBase::generateSubmetaFieldName( $metaInfo['name'], $contentClassAttribute ); if ( isset( $returnArray[$submetaFieldName] ) ) { $returnArray[$submetaFieldName] = array_merge( $returnArray[$submetaFieldName], array( ezfSolrDocumentFieldBase::preProcessValue( $metaInfo['value'], $metaInfo['fieldType'] ) ) ); } else { $returnArray[$submetaFieldName] = array( ezfSolrDocumentFieldBase::preProcessValue( $metaInfo['value'], $metaInfo['fieldType'] ) ); } } } $defaultFieldName = parent::generateAttributeFieldName( $contentClassAttribute, self::$subattributesDefinition[self::DEFAULT_SUBATTRIBUTE] ); $returnArray[$defaultFieldName] = $this->getPlainTextRepresentation(); return $returnArray; } break; default: { } break; } }
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'] ); }
* @subpackage modules * @filesource */ require_once 'kernel/common/i18n.php'; $http = eZHTTPTool::instance(); $module = $Params["Module"]; $editionContentObjectId = $Params['EditionContentObjectId']; $versionId = $Params['VersionId']; $outputFormat = $Params['OutputFormat']; $siteAccess = $Params['SiteAccess']; $skinName = $Params['SkinName']; // show mailcontent inline to get debug messages if ($http->hasVariable('ShowXmlTemplate')) { $showXmlTemplateValue = (int) $http->variable('ShowXmlTemplate'); if ($showXmlTemplateValue == 1 || $showXmlTemplateValue == 2) { $objectVersion = eZContentObjectVersion::fetchVersion($versionId, $editionContentObjectId, true); if (is_object($objectVersion)) { $editionDataMap = $objectVersion->attribute('data_map'); $attributeEdition = $editionDataMap['newsletter_edition']; $attributeEditionContent = $attributeEdition->attribute('content'); $outputXml = $attributeEditionContent->createOutputXml(); if ($showXmlTemplateValue == 2) { header("Content-type: text/html; charset=utf-8"); echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>newsletter - outputformat - text</title></head><body><pre>' . $outputXml . '</pre></body></html>'; return eZExecution::cleanExit(); } else { header("Content-type: text/xml; charset=utf-8"); echo $outputXml; return eZExecution::cleanExit(); }
/** * Returns the given object version. False is returned if the versions does not exist. * * @param int $version * @param bool $asObject If true, returns an eZContentObjectVersion; if false, returns an array * @return eZContentObjectVersion|array|bool */ function version( $version, $asObject = true ) { if ( $asObject ) { global $eZContentObjectVersionCache; if ( !isset( $eZContentObjectVersionCache ) ) // prevent PHP warning below $eZContentObjectVersionCache = array(); if ( isset( $eZContentObjectVersionCache[$this->ID][$version] ) ) { return $eZContentObjectVersionCache[$this->ID][$version]; } else { $eZContentObjectVersionCache[$this->ID][$version] = eZContentObjectVersion::fetchVersion( $version, $this->ID, $asObject ); return $eZContentObjectVersionCache[$this->ID][$version]; } } else { return eZContentObjectVersion::fetchVersion( $version, $this->ID, $asObject ); } }
function execute($process, $event) { eZDebugSetting::writeDebug('kernel-workflow-approve', $process, 'eZApprove2Type::execute'); eZDebugSetting::writeDebug('kernel-workflow-approve', $event, 'eZApprove2Type::execute'); $parameters = $process->attribute('parameter_list'); $versionID = $parameters['version']; $object = eZContentObject::fetch($parameters['object_id']); if (!$object) { eZDebugSetting::writeError('kernel-workflow-approve', $parameters['object_id'], 'eZApprove2Type::execute'); return eZWorkflowType::STATUS_WORKFLOW_CANCELLED; } /* If we run event first time ( when we click publish in admin ) we do not have user_id set in workflow process, so we take current user and store it in workflow process, so next time when we run event from cronjob we fetch user_id from there. */ if ($process->attribute('user_id') == 0) { $user = eZUser::currentUser(); $process->setAttribute('user_id', $user->id()); } else { $user = eZUser::instance($process->attribute('user_id')); } $eventData = eZApprove2Event::fetch($event->attribute('id'), $event->attribute('version')); $userGroups = array_merge((array) $user->attribute('groups'), (array) $user->attribute('contentobject_id')); $workflowSections = explode(',', $eventData->attribute('selected_sections')); $workflowGroups = explode(',', $eventData->attribute('selected_usergroups')); $editors = explode(',', $eventData->attribute('approve_users')); $approveGroups = explode(',', $eventData->attribute('approve_groups')); eZDebugSetting::writeDebug('kernel-workflow-approve', $user, 'eZApprove2Type::execute::user'); eZDebugSetting::writeDebug('kernel-workflow-approve', $userGroups, 'eZApprove2Type::execute::userGroups'); eZDebugSetting::writeDebug('kernel-workflow-approve', $editors, 'eZApprove2Type::execute::editor'); eZDebugSetting::writeDebug('kernel-workflow-approve', $workflowSections, 'eZApprove2Type::execute::workflowSections'); eZDebugSetting::writeDebug('kernel-workflow-approve', $workflowGroups, 'eZApprove2Type::execute::workflowGroups'); eZDebugSetting::writeDebug('kernel-workflow-approve', $object->attribute('section_id'), 'eZApprove2Type::execute::section_id'); $section = $object->attribute('section_id'); $correctSection = false; if (!in_array($section, $workflowSections) && !in_array(-1, $workflowSections)) { $assignedNodes = $object->attribute('assigned_nodes'); if ($assignedNodes) { foreach ($assignedNodes as $assignedNode) { $parent = $assignedNode->attribute('parent'); $parentObject = $parent->object(); $section = $parentObject->attribute('section_id'); if (in_array($section, $workflowSections)) { $correctSection = true; break; } } } } else { $correctSection = true; } switch ($eventData->attribute('approve_type')) { case eZApprove2Event::ApproveTypeUser: $inExcludeGroups = false; $userIsEditor = false; break; default: case eZApprove2Event::ApproveTypePredefined: $inExcludeGroups = count(array_intersect($userGroups, $workflowGroups)) != 0; $userIsEditor = in_array($user->id(), $editors) || count(array_intersect($userGroups, $approveGroups)) != 0; break; } if (!$inExcludeGroups && !$userIsEditor && $correctSection) { switch ($eventData->attribute('approve_type')) { case eZApprove2Event::ApproveTypeUser: $contentObjectVersionID = $parameters['version']; $contentObjectID = $parameters['object_id']; $approveStatus = eZXApproveStatus::fetchByContentObjectID($contentObjectID, $contentObjectVersionID); if (!$approveStatus || $approveStatus->attribute('approve_status') == eZXApproveStatus::StatusSelectApprover) { if (!$approveStatus) { $approveStatus = eZXApproveStatus::create($contentObjectID, $contentObjectVersionID, $process->attribute('id'), $process->attribute('event_position')); $approveStatus->store(); $approveStatus->setCreator($user->attribute('contentobject_id')); } $approveStatus->setAttribute('active_version', $contentObjectVersionID); $approveStatus->sync(); $process->Template = array(); $process->Template['templateName'] = 'design:workflow/eventtype/ezapprove2/select_approver.tpl'; $process->Template['templateVars'] = array('event' => $event, 'approval_status' => $approveStatus, 'object' => $object); // Set object version to draft untill approvers are selected successfully in case user exists in the wrong way. #include_once( 'kernel/classes/ezcontentobjectversion.php' ); $contentObjectVersion = eZContentObjectVersion::fetchVersion($contentObjectVersionID, $contentObjectID); $contentObjectVersion->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT); $contentObjectVersion->sync(); return eZWorkflowType::STATUS_FETCH_TEMPLATE_REPEAT; } else { switch ($approveStatus->attribute('approve_status')) { case eZXApproveStatus::StatusSelectApprover: // Do nothing, continue processing in next cronjob run. return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT; break; case eZXApproveStatus::StatusInApproval: // Check if enough users have approves the workflow, or any has discarded it. $discardCount = $approveStatus->discardedUserCount(); $collaborationItem = $approveStatus->attribute('collaboration_item'); #include_once( eZExtension::baseDirectory() . '/ezapprove2/collaboration/ezapprove2/ezapprove2collaborationhandler.php' ); if ($discardCount > 0) { $approveStatus->cancel(); $approveINI = eZINI::instance('ezapprove2.ini'); if ($approveINI->variable('ApproveSettings', 'NodeCreationOnDraft') == 'true') { $db = eZDB::instance(); $db->query('UPDATE ezcontentobject_version SET status = ' . eZContentObjectVersion::STATUS_REJECTED . ' WHERE contentobject_id = ' . $approveStatus->attribute('contentobject_id') . ' AND version = ' . $approveStatus->attribute('active_version')); $db->query('DELETE FROM ezcontentobject_tree where contentobject_id = ' . $approveStatus->attribute('contentobject_id') . ' AND contentobject_version = ' . $approveStatus->attribute('active_version')); $db->query('DELETE FROM ezurlalias WHERE destination_url=\'content/versionview/' . $approveStatus->attribute('contentobject_id') . '/' . $approveStatus->attribute('active_version') . '\''); } return eZWorkflowType::STATUS_WORKFLOW_CANCELLED; } $numRequired = $approveStatus->attribute('num_approve_required'); $numApproved = $approveStatus->attribute('num_approved'); if ($numApproved >= $numRequired) { $collaborationItem->setAttribute('data_int3', eZApprove2CollaborationHandler::STATUS_ACCEPTED); $collaborationItem->setAttribute('status', eZCollaborationItem::STATUS_INACTIVE); $timestamp = time(); $collaborationItem->setAttribute('modified', $timestamp); $collaborationItem->setIsActive(false); $collaborationItem->sync(); $approveStatus->setAttribute('approve_status', eZXApproveStatus::StatusApproved); $approveStatus->store(); $approveINI = eZINI::instance('ezapprove2.ini'); if ($approveINI->variable('ApproveSettings', 'ObjectLockOnEdit') == 'true') { // Unlock related objects $object = $approveStatus->attribute('contentobject'); // #HACK# if ($object->attribute('contentclass_id') == 17) { foreach ($object->relatedContentObjectList($approveStatus->attribute('active_version'), false, false) as $relatedObject) { $relatedObject->setAttribute('flags', $relatedObject->attribute('flags') ^ EZ_CONTENT_OBJECT_FLAG_LOCK_EDIT ^ EZ_CONTENT_OBJECT_FLAG_LOCK_REMOVE); $relatedObject->sync(); } } } return eZWorkflowType::STATUS_ACCEPTED; } else { // Still need more approvers. return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT; } break; case eZXApproveStatus::StatusDiscarded: $approveINI = eZINI::instance('ezapprove2.ini'); if ($approveINI->variable('ApproveSettings', 'NodeCreationOnDraft') == 'true') { $db = eZDB::instance(); $db->arrayQuery('DELETE FROM ezcontentobject_tree where contentobject_id = ' . $approveStatus->attribute('contentobject_id') . ' AND contentobject_version = ' . $approveStatus->attribute('active_version')); } return eZWorkflowType::STATUS_WORKFLOW_CANCELLED; break; case eZXApproveStatus::StatusApproved: case eZXApproveStatus::StatusFinnished: // Nothing special to do. break; } } break; case eZApprove2Event::ApproveTypePredefined: $approveStatus = eZXApproveStatus::fetchByWorkflowProcessID($process->attribute('id'), $process->attribute('event_position')); if (!$approveStatus) { $contentObjectVersionID = $parameters['version']; $contentObjectID = $parameters['object_id']; $db = eZDB::instance(); $db->begin(); // CREATE APPROVE STATUS $approveStatus = eZXApproveStatus::create($contentObjectID, $contentObjectVersionID, $process->attribute('id'), $process->attribute('event_position')); $approveStatus->store(); $approveStatus->setCreator($user->attribute('contentobject_id')); // ADD APPROVERS foreach ($approveGroups as $userGroupID) { $userGroupObject = eZContentObject::fetch($userGroupID); if ($userGroupObject) { $userGroupNode = $userGroupObject->attribute('main_node'); if ($userGroupNode) { foreach ($userGroupNode->subTree(array('Depth' => 1, 'DepthOperator' => 'eq', 'Limitation' => array())) as $userNode) { $approveStatus->addApproveUser($userNode->attribute('contentobject_id')); } } } } foreach ($editors as $userID) { $approveStatus->addApproveUser($userID); } $approveStatus->setAttribute('approve_status', eZXApproveStatus::StatusInApproval); $approveStatus->store(); $approveStatus->createCollaboration(false, $user->attribute('contentobject_id')); $approveStatus->store(); $db->commit(); } $discardCount = $approveStatus->discardedUserCount(); $collaborationItem = $approveStatus->attribute('collaboration_item'); #include_once( eZExtension::baseDirectory() . '/ezapprove2/collaboration/ezapprove2/ezapprove2collaborationhandler.php' ); if ($discardCount > 0) { $approveStatus->cancel(); return eZWorkflowType::STATUS_WORKFLOW_CANCELLED; } $numApproved = $approveStatus->attribute('num_approved'); if ($numApproved >= 1) { $collaborationItem->setAttribute('data_int3', eZApprove2CollaborationHandler::STATUS_ACCEPTED); $collaborationItem->setAttribute('status', eZCollaborationItem::STATUS_INACTIVE); $timestamp = time(); $collaborationItem->setAttribute('modified', $timestamp); $collaborationItem->setIsActive(false); $collaborationItem->sync(); $approveStatus->setAttribute('approve_status', eZXApproveStatus::StatusApproved); $approveStatus->store(); return eZWorkflowType::STATUS_ACCEPTED; } else { // Still need more approvers. return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT; } break; } } else { eZDebugSetting::writeDebug('kernel-workflow-approve', $workflowSections, "we are not going to create approval " . $object->attribute('section_id')); eZDebugSetting::writeDebug('kernel-workflow-approve', $userGroups, "we are not going to create approval"); eZDebugSetting::writeDebug('kernel-workflow-approve', $workflowGroups, "we are not going to create approval"); eZDebugSetting::writeDebug('kernel-workflow-approve', $user->id(), "we are not going to create approval "); return eZWorkflowType::STATUS_ACCEPTED; } }
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 ) ); } }
function onPublish($attribute, $contentObject, $publishedNodes) { $http = eZHTTPTool::instance(); $userID = $attribute->attribute('contentobject_id'); $data = unserialize($attribute->attribute('data_text')); $avialable = array_merge($data['unregister'], $data['register']); foreach ($avialable as $id) { $subscription = eZSubscription::fetchByUserSubscriptionListID($userID, $id); if (isset($subscription) and $subscription->attribute('status') == eZSubscription::StatusApproved and in_array($id, $data['unregister'])) { $subscription->unsubscribe(); } elseif (isset($subscription) and $subscription->attribute('status') == eZSubscription::StatusRemovedSelf and in_array($id, $data['register'])) { $subscription->setAttribute('status', eZSubscription::StatusApproved); $subscription->sync(); } elseif (!isset($subscription) and in_array($id, $data['register'])) { $list = eZSubscriptionList::fetch($id, eZSubscriptionList::StatusPublished, true, true); if ($list) { $subscription = $list->registerUser($userID); } } if ($subscription) { $version = eZContentObjectVersion::fetchVersion($attribute->attribute('version'), $attribute->attribute('contentobject_id')); $user = eZUser::fetch($attribute->attribute('contentobject_id')); $userData = eZUserSubscriptionData::fetch($user->attribute('email')); $dm = $version->attribute('data_map'); if (!$userData) { $userData = eZUserSubscriptionData::create('', '', '', $user->attribute('email')); } if ($user->attribute('email')) { $userData->updateAttribute('email', $user->attribute('email')); $userData->store(); } if (isset($dm['last_name'])) { $userData->setAttribute('name', $dm['last_name']->attribute('data_text')); $userData->store(); } if (isset($dm['first_name'])) { $userData->setAttribute('firstname', $dm['first_name']->attribute('data_text')); $userData->store(); } if (isset($dm['mobile'])) { $userData->setAttribute('mobile', $dm['mobile']->attribute('data_text')); $userData->store(); } } } $http->removeSessionVariable('register_subscription'); $http->removeSessionVariable('unregister_subscription'); }
$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'); }
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; }