Example #1
0
 /**
  * Initialize ezpClass object
  *
  * @param string $name
  * @param string $identifier
  * @param string $contentObjectName
  * @param int $creatorID
  * @param string $language
  * @param int $groupID
  * @param string $groupName
  */
 public function __construct($name = 'Test class', $identifier = 'test_class', $contentObjectName = '<test_attribute>', $creatorID = 14, $language = 'eng-GB', $groupID = 1, $groupName = 'Content')
 {
     if (eZContentLanguage::fetchByLocale($language) === false) {
         $topPriorityLanguage = eZContentLanguage::topPriorityLanguage();
         if ($topPriorityLanguage) {
             $language = $topPriorityLanguage->attribute('locale');
         }
     }
     $this->language = $language;
     $this->class = eZContentClass::create($creatorID, array(), $this->language);
     $this->class->setName($name, $this->language);
     $this->class->setAttribute('contentobject_name', $contentObjectName);
     $this->class->setAttribute('identifier', $identifier);
     $this->class->store();
     $languageID = eZContentLanguage::idByLocale($this->language);
     $this->class->setAlwaysAvailableLanguageID($languageID);
     $this->classGroup = eZContentClassClassGroup::create($this->id, $this->version, $groupID, $groupName);
     $this->classGroup->store();
 }
Example #2
0
     }
 } else {
     if ($http->hasPostVariable('ClassIdentifier')) {
         $contentClassIdentifier = $http->postVariable('ClassIdentifier');
         $class = eZContentClass::fetchByIdentifier($contentClassIdentifier);
         if (is_object($class)) {
             $contentClassID = $class->attribute('id');
             if ($contentClassID) {
                 $hasClassInformation = true;
             }
         }
     }
 }
 if ($http->hasPostVariable('ContentLanguageCode')) {
     $languageCode = $http->postVariable('ContentLanguageCode');
     $languageID = eZContentLanguage::idByLocale($languageCode);
     if ($languageID === false) {
         eZDebug::writeError("The language code [{$languageCode}] specified in ContentLanguageCode does not exist in the system.");
         return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
     }
 } else {
     $allLanguages = eZContentLanguage::prioritizedLanguages();
     // Only show language selection if there are more than 1 languages.
     if (count($allLanguages) > 1 && $hasClassInformation) {
         $tpl = eZTemplate::factory();
         $tpl->setVariable('node_id', $http->postVariable('NodeID'));
         $tpl->setVariable('class_id', $contentClassID);
         $tpl->setVariable('assignment_remote_id', $http->postVariable('AssignmentRemoteID', false));
         $tpl->setVariable('redirect_uri_after_publish', $http->postVariable('RedirectURIAfterPublish', false));
         $tpl->setVariable('redirect_uri_after_discard', $http->postVariable('RedirectIfDiscarded', false));
         $Result = array();
 public function translationByLocale($locale)
 {
     $languageID = eZContentLanguage::idByLocale($locale);
     if ($languageID) {
         $translations = $this->allTranslations();
         foreach ($translations as $translation) {
             if ($translation->realLanguageID() == $languageID) {
                 return $translation;
             }
         }
     }
     return false;
 }
Example #4
0
 function setName($name, $languageLocale = false)
 {
     if (!$languageLocale) {
         $languageLocale = $this->topPriorityLanguageLocale();
     }
     $this->NameList->setNameByLanguageLocale($name, $languageLocale);
     $languageID = eZContentLanguage::idByLocale($languageLocale);
     $languageMask = $this->attribute('language_mask');
     $this->setAttribute('language_mask', $languageMask | $languageID);
 }
Example #5
0
 function translateTo($languageCode, $updateLanguageMask = true)
 {
     $languageID = eZContentLanguage::idByLocale($languageCode);
     $tmp = clone $this;
     $tmp->setAttribute('id', null);
     $tmp->setAttribute('language_code', $languageCode);
     $tmp->setAttribute('language_id', $languageID);
     $db = eZDB::instance();
     $db->begin();
     $tmp->sync();
     $currentVersionNumber = $this->attribute('version');
     $tmp->initialize($currentVersionNumber, $this);
     $tmp->sync();
     $tmp->postInitialize($currentVersionNumber, $this);
     if ($updateLanguageMask) {
         $version = $tmp->objectVersion();
         $version->updateLanguageMask((int) $version->languageMask() | (int) $languageID, false);
     }
     $db->commit();
     // Clear in-memory content cache
     $tmpnull = null;
     $tmp->setContent($tmpnull);
     return $tmp;
 }
 function checkAccess($functionName, $originalClassID = false, $parentClassID = false, $returnAccessList = false, $language = false)
 {
     $classID = $originalClassID;
     $user = eZUser::currentUser();
     $userID = $user->attribute('contentobject_id');
     // Fetch the ID of the language if we get a string with a language code
     // e.g. 'eng-GB'
     $originalLanguage = $language;
     if (is_string($language) && strlen($language) > 0) {
         $language = eZContentLanguage::idByLocale($language);
     } else {
         $language = false;
     }
     // This will be filled in with the available languages of the object
     // if a Language check is performed.
     $languageList = false;
     // This will be filled if parent object is needed.
     $parentObject = false;
     $origFunctionName = $functionName;
     // The 'move' function simply reuses 'edit' for generic access
     // but adds another top-level check below
     // The original function is still available in $origFunctionName
     if ($functionName == 'move') {
         $functionName = 'edit';
     }
     // Manage locations depends if it's removal or not.
     if ($functionName == 'can_add_location' || $functionName == 'can_remove_location') {
         $functionName = 'manage_locations';
     }
     $accessResult = $user->hasAccessTo('content', $functionName);
     $accessWord = $accessResult['accessWord'];
     if ($origFunctionName == 'can_remove_location') {
         if ($this->ParentNodeID <= 1) {
             return 0;
         }
         $currentNode = eZContentObjectTreeNode::fetch($this->ParentNodeID);
         if (!$currentNode instanceof eZContentObjectTreeNode) {
             return 0;
         }
         $contentObject = $currentNode->attribute('object');
     } else {
         $currentNode = $this;
         $contentObject = $this->attribute('object');
     }
     /*
     // Uncomment this part if 'create' permissions should become implied 'edit'.
     // Merges in 'create' policies with 'edit'
     if ( $functionName == 'edit' &&
          !in_array( $accessWord, array( 'yes', 'no' ) ) )
     {
         // Add in create policies.
         $accessExtraResult = $user->hasAccessTo( 'content', 'create' );
         if ( $accessExtraResult['accessWord'] != 'no' )
         {
             $accessWord = $accessExtraResult['accessWord'];
             if ( isset( $accessExtraResult['policies'] ) )
             {
                 $accessResult['policies'] = array_merge( $accessResult['policies'],
                                                          $accessExtraResult['policies'] );
             }
             if ( isset( $accessExtraResult['accessList'] ) )
             {
                 $accessResult['accessList'] = array_merge( $accessResult['accessList'],
                                                            $accessExtraResult['accessList'] );
             }
         }
     }
     */
     if ($origFunctionName == 'remove' or $origFunctionName == 'move' or $origFunctionName == 'can_remove_location') {
         // We do not allow these actions on top-level nodes
         // - remove
         // - move
         if ($this->ParentNodeID <= 1) {
             return 0;
         }
     }
     if ($classID === false) {
         $classID = $contentObject->attribute('contentclass_id');
     }
     if ($accessWord == 'yes') {
         return 1;
     } else {
         if ($accessWord == 'no') {
             if ($functionName == 'edit') {
                 // Check if we have 'create' access under the main parent
                 $object = $currentNode->object();
                 if ($object && $object->attribute('current_version') == 1 && !$object->attribute('status')) {
                     $mainNode = eZNodeAssignment::fetchForObject($object->attribute('id'), $object->attribute('current_version'));
                     $parentObj = $mainNode[0]->attribute('parent_contentobject');
                     if ($parentObj instanceof eZContentObject) {
                         $result = $parentObj->checkAccess('create', $object->attribute('contentclass_id'), $parentObj->attribute('contentclass_id'), false, $originalLanguage);
                         return $result;
                     } else {
                         eZDebug::writeError("Error retrieving parent object of main node for object id: " . $object->attribute('id'), __METHOD__);
                     }
                 }
             }
             return 0;
         } else {
             $policies = $accessResult['policies'];
             $access = 'denied';
             foreach ($policies as $pkey => $limitationArray) {
                 if ($access == 'allowed') {
                     break;
                 }
                 $limitationList = array();
                 if (isset($limitationArray['Subtree'])) {
                     $checkedSubtree = false;
                 } else {
                     $checkedSubtree = true;
                     $accessSubtree = false;
                 }
                 if (isset($limitationArray['Node'])) {
                     $checkedNode = false;
                 } else {
                     $checkedNode = true;
                     $accessNode = false;
                 }
                 foreach ($limitationArray as $key => $valueList) {
                     $access = 'denied';
                     switch ($key) {
                         case 'Class':
                             if ($functionName == 'create' and !$originalClassID) {
                                 $access = 'allowed';
                             } else {
                                 if ($functionName == 'create' and in_array($classID, $valueList)) {
                                     $access = 'allowed';
                                 } else {
                                     if ($functionName != 'create' and in_array($contentObject->attribute('contentclass_id'), $valueList)) {
                                         $access = 'allowed';
                                     } else {
                                         $access = 'denied';
                                         $limitationList = array('Limitation' => $key, 'Required' => $valueList);
                                     }
                                 }
                             }
                             break;
                         case 'ParentClass':
                             if (in_array($contentObject->attribute('contentclass_id'), $valueList)) {
                                 $access = 'allowed';
                             } else {
                                 $access = 'denied';
                                 $limitationList = array('Limitation' => $key, 'Required' => $valueList);
                             }
                             break;
                         case 'Section':
                         case 'User_Section':
                             if (in_array($contentObject->attribute('section_id'), $valueList)) {
                                 $access = 'allowed';
                             } else {
                                 $access = 'denied';
                                 $limitationList = array('Limitation' => $key, 'Required' => $valueList);
                             }
                             break;
                         case 'Language':
                             $languageMask = 0;
                             // If we don't have a language list yet we need to fetch it
                             // and optionally filter out based on $language.
                             if ($functionName == 'create') {
                                 // If the function is 'create' we do not use the language_mask for matching.
                                 if ($language !== false) {
                                     $languageMask = $language;
                                 } else {
                                     // If the create is used and no language specified then
                                     // we need to match against all possible languages (which
                                     // is all bits set, ie. -1).
                                     $languageMask = -1;
                                 }
                             } else {
                                 if ($language !== false) {
                                     if ($languageList === false) {
                                         $languageMask = $contentObject->attribute('language_mask');
                                         // We are restricting language check to just one language
                                         $languageMask &= $language;
                                         // If the resulting mask is 0 it means that the user is trying to
                                         // edit a language which does not exist, ie. translating.
                                         // The mask will then become the language trying to edit.
                                         if ($languageMask == 0) {
                                             $languageMask = $language;
                                         }
                                     }
                                 } else {
                                     $languageMask = -1;
                                 }
                             }
                             // Fetch limit mask for limitation list
                             $limitMask = eZContentLanguage::maskByLocale($valueList);
                             if (($languageMask & $limitMask) != 0) {
                                 $access = 'allowed';
                             } else {
                                 $access = 'denied';
                                 $limitationList = array('Limitation' => $key, 'Required' => $valueList);
                             }
                             break;
                         case 'Owner':
                         case 'ParentOwner':
                             // if limitation value == 2, anonymous limited to current session.
                             if (in_array(2, $valueList) && $user->isAnonymous()) {
                                 $createdObjectIDList = eZPreferences::value('ObjectCreationIDList');
                                 if ($createdObjectIDList && in_array($contentObject->attribute('id'), unserialize($createdObjectIDList))) {
                                     $access = 'allowed';
                                 }
                             } else {
                                 if ($contentObject->attribute('owner_id') == $userID || $contentObject->attribute('id') == $userID) {
                                     $access = 'allowed';
                                 }
                             }
                             if ($access != 'allowed') {
                                 $access = 'denied';
                                 $limitationList = array('Limitation' => $key);
                             }
                             break;
                         case 'Group':
                         case 'ParentGroup':
                             $access = $contentObject->checkGroupLimitationAccess($valueList, $userID);
                             if ($access != 'allowed') {
                                 $access = 'denied';
                                 $limitationList = array('Limitation' => $key, 'Required' => $valueList);
                             }
                             break;
                         case 'State':
                             if (count(array_intersect($valueList, $contentObject->attribute('state_id_array'))) == 0) {
                                 $access = 'denied';
                                 $limitationList = array('Limitation' => $key, 'Required' => $valueList);
                             } else {
                                 $access = 'allowed';
                             }
                             break;
                         case 'ParentDepth':
                             if (in_array($currentNode->attribute('depth'), $valueList)) {
                                 $access = 'allowed';
                             } else {
                                 $access = 'denied';
                                 $limitationList = array('Limitation' => $key, 'Required' => $valueList);
                             }
                             break;
                         case 'Node':
                             $accessNode = false;
                             $mainNodeID = $currentNode->attribute('main_node_id');
                             foreach ($valueList as $nodeID) {
                                 $node = eZContentObjectTreeNode::fetch($nodeID, false, false);
                                 $limitationNodeID = $node['main_node_id'];
                                 if ($mainNodeID == $limitationNodeID) {
                                     $access = 'allowed';
                                     $accessNode = true;
                                     break;
                                 }
                             }
                             if ($access != 'allowed' && $checkedSubtree && !$accessSubtree) {
                                 $access = 'denied';
                                 // ??? TODO: if there is a limitation on Subtree, return two limitations?
                                 $limitationList = array('Limitation' => $key, 'Required' => $valueList);
                             } else {
                                 $access = 'allowed';
                             }
                             $checkedNode = true;
                             break;
                         case 'Subtree':
                             $accessSubtree = false;
                             $path = $currentNode->attribute('path_string');
                             $subtreeArray = $valueList;
                             foreach ($subtreeArray as $subtreeString) {
                                 if (strstr($path, $subtreeString)) {
                                     $access = 'allowed';
                                     $accessSubtree = true;
                                     break;
                                 }
                             }
                             if ($access != 'allowed' && $checkedNode && !$accessNode) {
                                 $access = 'denied';
                                 // ??? TODO: if there is a limitation on Node, return two limitations?
                                 $limitationList = array('Limitation' => $key, 'Required' => $valueList);
                             } else {
                                 $access = 'allowed';
                             }
                             $checkedSubtree = true;
                             break;
                         case 'User_Subtree':
                             $path = $currentNode->attribute('path_string');
                             $subtreeArray = $valueList;
                             foreach ($subtreeArray as $subtreeString) {
                                 if (strstr($path, $subtreeString)) {
                                     $access = 'allowed';
                                 }
                             }
                             if ($access != 'allowed') {
                                 $access = 'denied';
                                 $limitationList = array('Limitation' => $key, 'Required' => $valueList);
                             }
                             break;
                         default:
                             if (strncmp($key, 'StateGroup_', 11) === 0) {
                                 if (count(array_intersect($valueList, $contentObject->attribute('state_id_array'))) == 0) {
                                     $access = 'denied';
                                     $limitationList = array('Limitation' => $key, 'Required' => $valueList);
                                 } else {
                                     $access = 'allowed';
                                 }
                             }
                     }
                     if ($access == 'denied') {
                         break;
                     }
                 }
                 $policyList[] = array('PolicyID' => $pkey, 'LimitationList' => $limitationList);
             }
             if ($access == 'denied') {
                 $accessList = array('FunctionRequired' => array('Module' => 'content', 'Function' => $origFunctionName, 'ClassID' => $classID, 'MainNodeID' => $currentNode->attribute('main_node_id')), 'PolicyList' => $policyList);
                 return 0;
             } else {
                 return 1;
             }
         }
     }
 }
 function createNewRelatedObject($http, $action, $objectAttribute, $parameters)
 {
     $hasClassInformation = false;
     $contentClassID = false;
     $contentClassIdentifier = false;
     $languageCode = false;
     $class = false;
     $languageCode = $objectAttribute->attribute('language_code');
     $originalContentObjectID = $objectAttribute->attribute('contentobject_id');
     $originalContentObjectVersion = $objectAttribute->attribute('version');
     $contentObject = false;
     $addVersion = false;
     if ($this->Num != 0) {
         $contentObject = eZContentObject::fetch($this->Num);
     }
     if ($this->Num == 0 or !(get_class($contentObject) == 'eZContentObject')) {
         $addVersion = true;
         $ini = eZINI::instance('ezsurvey.ini');
         $configList = eZSurveyRelatedConfig::fetchList();
         if (count($configList) > 0) {
             $config = $configList[0];
             $contentClassID = $config->attribute('contentclass_id');
             $contentClass = eZContentClass::fetch($contentClassID);
             $nodeID = $config->attribute('node_id');
             $attributeParentNode = eZContentObjectTreeNode::fetch($nodeID);
             if (get_class($contentClass) == 'eZContentClass' and get_class($attributeParentNode) == 'eZContentObjectTreeNode') {
                 $languageID = eZContentLanguage::idByLocale($languageCode);
                 $contentObject = eZContentObject::fetch($objectAttribute->attribute('contentobject_id'));
                 $node = eZContentObjectTreeNode::fetch($nodeID, $languageCode);
                 if (get_class($node) == "eZContentObjectTreeNode") {
                     $contentObject = eZContentObject::createWithNodeAssignment($node, $contentClassID, $languageCode, false);
                 } else {
                     eZDebug::writeWarning('node is not a valid eZContentObjectTreeNode', 'eZSurveyRelatedObject::createNewRelatedObject');
                 }
             } else {
                 eZDebug::writeWarning('Config is not valid', 'eZSurveyRelatedObject::createNewRelatedObject');
             }
         }
     }
     if ($contentObject) {
         $redirectHref = 'content/edit/' . $originalContentObjectID . '/' . $originalContentObjectVersion;
         $http->setSessionVariable('LastAccessesURI_Backup_' . $originalContentObjectID . '_' . $this->ID, array('content' => $http->sessionVariable('LastAccessesURI')));
         $http->setSessionVariable('RedirectURIAfterPublish_Backup_' . $originalContentObjectID . '_' . $this->ID, array('content' => $http->sessionVariable('RedirectURIAfterPublish')));
         $http->setSessionVariable('RedirectIfDiscarded_Backup_' . $originalContentObjectID . '_' . $this->ID, array('content' => $http->sessionVariable('RedirectIfDiscarded')));
         $http->setSessionVariable('LastAccessesURI', $redirectHref);
         $http->setSessionVariable('RedirectURIAfterPublish', $redirectHref);
         $http->setSessionVariable('RedirectIfDiscarded', $redirectHref);
         $this->Num = $contentObject->attribute('id');
         $this->store();
         $parameters = array($contentObject->attribute('id'));
         if ($addVersion === true) {
             $parameters[] = $contentObject->attribute('current_version');
         }
         $module = $GLOBALS['module'];
         $module->redirectToView('edit', $parameters);
     }
     return true;
 }
Example #8
0
        $language = eZContentLanguage::topPriorityLanguage();
        if ($language) {
            $EditLanguage = $language->attribute('locale');
        } else {
            eZDebug::writeError('Undefined default language', 'class/edit.php');
            $Module->setExitStatus(eZModule::STATUS_FAILED);
            return;
        }
    }
    if (is_numeric($GroupID) and is_string($GroupName) and $GroupName != '') {
        $user = eZUser::currentUser();
        $user_id = $user->attribute('contentobject_id');
        $class = eZContentClass::create($user_id, array(), $EditLanguage);
        $class->setName(ezpI18n::tr('kernel/class/edit', 'New Class'), $EditLanguage);
        $class->store();
        $editLanguageID = eZContentLanguage::idByLocale($EditLanguage);
        $class->setAlwaysAvailableLanguageID($editLanguageID);
        $ClassID = $class->attribute('id');
        $ClassVersion = $class->attribute('version');
        $ingroup = eZContentClassClassGroup::create($ClassID, $ClassVersion, $GroupID, $GroupName);
        $ingroup->store();
        $Module->redirectTo($Module->functionURI('edit') . '/' . $ClassID . '/(language)/' . $EditLanguage);
        return;
    } else {
        $errorResponseGroupName = $GroupName == '' ? '<Empty name>' : $GroupName;
        $errorResponseGroupID = !is_numeric($GroupID) ? '<Empty ID>' : $GroupID;
        eZDebug::writeError("Unknown class group: {$errorResponseGroupName} (ID: {$errorResponseGroupID})", 'Kernel - Class - Edit');
        $Module->setExitStatus(eZModule::STATUS_FAILED);
        return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
    }
}
Example #9
0
    static function create( $contentobjectID, $userID = false, $version = 1, $initialLanguageCode = false )
    {
        if ( $userID === false )
        {
            $user = eZUser::currentUser();
            $userID = $user->attribute( 'contentobject_id' );
        }
        $time = time();

        if ( $initialLanguageCode == false )
        {
            $initialLanguageCode = eZContentObject::defaultLanguage();
        }

        $initialLanguageID = eZContentLanguage::idByLocale( $initialLanguageCode );

        $row = array(
            "contentobject_id" => $contentobjectID,
            'initial_language_id' => $initialLanguageID,
            'language_mask' => $initialLanguageID,
            "version" => $version,
            "created" => $time,
            "modified" => $time,
            'creator_id' => $userID );
        return new eZContentObjectVersion( $row );
    }
 function languageMask()
 {
     $mask = 0;
     foreach ($this->NameList as $languageLocale => $name) {
         if ($languageLocale == eZSerializedObjectNameList::ALWAYS_AVAILABLE_STR) {
             $mask += 1;
         } else {
             $languageID = eZContentLanguage::idByLocale($languageLocale);
             $mask += $languageID;
         }
     }
     return $mask;
 }
Example #11
0
File: index.php Project: truffo/eep
 private function createClass($displayName, $classIdentifier, $groupIdentifier, $groupId)
 {
     $adminUserObject = eZUser::fetchByName("admin");
     $adminUserObject->loginCurrent();
     $adminUserId = $adminUserObject->attribute('contentobject_id');
     $language = eZContentLanguage::topPriorityLanguage();
     $editLanguage = $language->attribute('locale');
     $class = eZContentClass::create($adminUserId, array(), $editLanguage);
     // this is the display name, ez automatically creates the content-class-identifier from it
     $class->setName($displayName, $editLanguage);
     $class->setAttribute("identifier", $classIdentifier);
     // default naming for objects - content classes should update this value once they have attributes added
     $class->setAttribute('contentobject_name', 'eep-created-content-class');
     $class->store();
     $editLanguageID = eZContentLanguage::idByLocale($editLanguage);
     $class->setAlwaysAvailableLanguageID($editLanguageID);
     $ClassID = $class->attribute('id');
     $ClassVersion = $class->attribute('version');
     $ingroup = eZContentClassClassGroup::create($ClassID, $ClassVersion, $groupId, $groupIdentifier);
     $ingroup->store();
     // clean up the content class status
     $class->storeDefined(array());
     $adminUserObject->logoutCurrent();
 }
 protected function createNew($identifier)
 {
     $remote = self::fetchRemoteByIdentifier($identifier);
     if ($remote === null) {
         throw new Exception("Classe remota non trovata");
     }
     $this->syncAllGroups($remote);
     $classGroup = false;
     foreach ($remote->InGroups as $group) {
         $classGroup = eZContentClassGroup::fetchByName($group->GroupName);
         if ($classGroup instanceof eZContentClassGroup) {
             break;
         }
     }
     if (!$classGroup instanceof eZContentClassGroup) {
         throw new Exception('Errore creando la nuova classe');
     }
     $db = eZDB::instance();
     $db->begin();
     $options = array('serialized_name_list' => $remote->SerializedNameList, 'serialized_description_list' => $remote->SerializedDescriptionList);
     $user = eZUser::currentUser();
     $userID = $user->attribute('contentobject_id');
     $class = eZContentClass::create($userID, $options, $this->EditLanguage);
     $class->setName('New automatic', $this->EditLanguage);
     $class->store();
     $editLanguageID = eZContentLanguage::idByLocale($this->EditLanguage);
     $class->setAlwaysAvailableLanguageID($editLanguageID);
     $ClassID = $class->attribute('id');
     $ClassVersion = $class->attribute('version');
     $ingroup = eZContentClassClassGroup::create($ClassID, $ClassVersion, $classGroup->attribute('id'), $classGroup->attribute('name'));
     $ingroup->store();
     $class->setAttribute('identifier', $identifier);
     foreach ($this->properties as $identifier => $remoteProperty) {
         $class->setAttribute($identifier, $remote->{$remoteProperty});
     }
     $class->storeVersioned(array(), eZContentClass::VERSION_STATUS_DEFINED);
     $db->commit();
     return $class;
 }
Example #13
0
 /**
  * Links the content object attribute and tag
  *
  * @static
  *
  * @param eZContentObjectAttribute $attribute
  * @param eZTagsObject $tagObject
  * @param string $keyword
  * @param string $locale
  */
 private static function linkTag(eZContentObjectAttribute $attribute, eZTagsObject $tagObject, $keyword, $locale, $priority)
 {
     $languageID = eZContentLanguage::idByLocale($locale);
     if ($languageID === false) {
         return;
     }
     if ($locale == $attribute->attribute('language_code')) {
         if (!$tagObject->hasTranslation($locale)) {
             $tagKeywordObject = new eZTagsKeyword(array('keyword_id' => $tagObject->attribute('id'), 'language_id' => $languageID, 'keyword' => $keyword, 'locale' => $locale, 'status' => eZTagsKeyword::STATUS_PUBLISHED));
             $tagKeywordObject->store();
             $tagObject->updateLanguageMask();
         }
     }
     $linkObject = new eZTagsAttributeLinkObject(array('keyword_id' => $tagObject->attribute('id'), 'objectattribute_id' => $attribute->attribute('id'), 'objectattribute_version' => $attribute->attribute('version'), 'object_id' => $attribute->attribute('contentobject_id'), 'priority' => $priority));
     $linkObject->store();
 }