Exemplo n.º 1
0
 function modify($tpl, $operatorName, $operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
 {
     $canCreateClassList = $namedParameters['can_create_class_list'];
     switch ($operatorName) {
         case 'ezcreateclasslistgroups':
             $groupArray = array();
             $ini = eZINI::instance('websitetoolbar.ini');
             foreach ($canCreateClassList as $class) {
                 $contentClass = eZContentClass::fetch($class['id']);
                 if (!$contentClass) {
                     return false;
                 }
                 foreach ($contentClass->fetchGroupList() as $group) {
                     $isHidden = false;
                     if (in_array($contentClass->attribute('identifier'), $ini->variable('WebsiteToolbarSettings', 'HiddenContentClasses'))) {
                         $isHidden = true;
                     }
                     if (array_key_exists($group->attribute('group_id'), $groupArray)) {
                         if (!$isHidden) {
                             $groupArray[$group->attribute('group_id')]['items'][] = $contentClass;
                         }
                     } else {
                         if (!$isHidden) {
                             $groupArray[$group->attribute('group_id')]['items'] = array($contentClass);
                             $groupArray[$group->attribute('group_id')]['group_name'] = $group->attribute('group_name');
                         }
                     }
                 }
             }
             $operatorValue = $groupArray;
             break;
     }
 }
 static function remove($classID)
 {
     $contentClass = eZContentClass::fetch($classID);
     if ($contentClass == null or !$contentClass->isRemovable()) {
         return false;
     }
     // Remove all objects
     $contentObjects = eZContentObject::fetchSameClassList($classID);
     foreach ($contentObjects as $contentObject) {
         eZContentObjectOperations::remove($contentObject->attribute('id'));
     }
     if (count($contentObjects) == 0) {
         eZContentObject::expireAllViewCache();
     }
     eZContentClassClassGroup::removeClassMembers($classID, 0);
     eZContentClassClassGroup::removeClassMembers($classID, 1);
     // Fetch real version and remove it
     $contentClass->remove(true);
     // Fetch temp version and remove it
     $tempDeleteClass = eZContentClass::fetch($classID, true, 1);
     if ($tempDeleteClass != null) {
         $tempDeleteClass->remove(true, 1);
     }
     return true;
 }
    static function removeGroup( $classID, $classVersion, $selectedGroup )
    {
        $class = eZContentClass::fetch( $classID, true, eZContentClass::VERSION_STATUS_DEFINED );
        if ( !$class )
            return false;
        $groups = $class->attribute( 'ingroup_list' );
        foreach ( array_keys( $groups ) as $key )
        {
            if ( in_array( $groups[$key]->attribute( 'group_id' ), $selectedGroup ) )
            {
                unset( $groups[$key] );
            }
        }

        if ( count( $groups ) == 0 )
        {
            return false;
        }
        else
        {
            foreach(  $selectedGroup as $group_id )
            {
                eZContentClassClassGroup::removeGroup( $classID, $classVersion, $group_id );
            }
        }
        return true;
    }
    /**
     * Test that saving a content class in DEFINED version status
     * correctly manipulate associated class groups
     *
     * @link http://issues.ez.no/16197
     */
    public function testContentClassStillInGroupAfterEdition()
    {
        $class = eZContentClass::fetch( $this->class->id );
        // This is logic contained in kernel/class/edit.php
        foreach ( eZContentClassClassGroup::fetchGroupList( $class->attribute( 'id' ),
                                                            eZContentClass::VERSION_STATUS_DEFINED )  as $classGroup )
        {
            eZContentClassClassGroup::create( $class->attribute( 'id' ),
                                              eZContentClass::VERSION_STATUS_TEMPORARY,
                                              $classGroup->attribute( 'group_id' ),
                                              $classGroup->attribute( 'group_name' ) )
                ->store();
        }

        $attributes = $class->fetchAttributes();
        $class->setAttribute( 'version', eZContentClass::VERSION_STATUS_TEMPORARY );
        $class->NameList->setHasDirtyData();

        foreach ( $attributes as $attribute )
        {
            $attribute->setAttribute( 'version', eZContentClass::VERSION_STATUS_TEMPORARY );
            if ( $dataType = $attribute->dataType() )
                $dataType->initializeClassAttribute( $attribute );
        }

        $class->store( $attributes );
        $db = eZDB::instance();
        $db->begin();
        $class->storeVersioned( $attributes, eZContentClass::VERSION_STATUS_DEFINED );
        $db->commit();

        $this->assertTrue( eZContentClassClassGroup::classInGroup( $class->attribute( 'id' ),
                                                                   eZContentClass::VERSION_STATUS_DEFINED,
                                                                   1 ) );
    }
Exemplo n.º 5
0
 /**
  * Creates a user with provided auth data
  *
  * @param array $authResult
  *
  * @return bool|eZUser
  */
 public static function createUser($authResult)
 {
     $ngConnectINI = eZINI::instance('ngconnect.ini');
     $siteINI = eZINI::instance('site.ini');
     $defaultUserPlacement = $ngConnectINI->variable('LoginMethod_' . $authResult['login_method'], 'DefaultUserPlacement');
     $placementNode = eZContentObjectTreeNode::fetch($defaultUserPlacement);
     if (!$placementNode instanceof eZContentObjectTreeNode) {
         $defaultUserPlacement = $siteINI->variable('UserSettings', 'DefaultUserPlacement');
         $placementNode = eZContentObjectTreeNode::fetch($defaultUserPlacement);
         if (!$placementNode instanceof eZContentObjectTreeNode) {
             return false;
         }
     }
     $contentClass = eZContentClass::fetch($siteINI->variable('UserSettings', 'UserClassID'));
     $userCreatorID = $siteINI->variable('UserSettings', 'UserCreatorID');
     $defaultSectionID = $siteINI->variable('UserSettings', 'DefaultSectionID');
     $db = eZDB::instance();
     $db->begin();
     $contentObject = $contentClass->instantiate($userCreatorID, $defaultSectionID);
     $contentObject->store();
     $nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => 1, 'parent_node' => $placementNode->attribute('node_id'), 'is_main' => 1));
     $nodeAssignment->store();
     $currentTimeStamp = eZDateTime::currentTimeStamp();
     /** @var eZContentObjectVersion $version */
     $version = $contentObject->currentVersion();
     $version->setAttribute('modified', $currentTimeStamp);
     $version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
     $version->store();
     $dataMap = $version->dataMap();
     self::fillUserObject($version->dataMap(), $authResult);
     if (!isset($dataMap['user_account'])) {
         $db->rollback();
         return false;
     }
     $userLogin = '******' . $authResult['login_method'] . '_' . $authResult['id'];
     $userPassword = (string) rand() . 'ngconnect_' . $authResult['login_method'] . '_' . $authResult['id'] . (string) rand();
     $userExists = false;
     if (eZUser::requireUniqueEmail()) {
         $userExists = eZUser::fetchByEmail($authResult['email']) instanceof eZUser;
     }
     if (empty($authResult['email']) || $userExists) {
         $email = md5('ngconnect_' . $authResult['login_method'] . '_' . $authResult['id']) . '@localhost.local';
     } else {
         $email = $authResult['email'];
     }
     $user = new eZUser(array('contentobject_id' => $contentObject->attribute('id'), 'email' => $email, 'login' => $userLogin, 'password_hash' => md5("{$userLogin}\n{$userPassword}"), 'password_hash_type' => 1));
     $user->store();
     $userSetting = new eZUserSetting(array('is_enabled' => true, 'max_login' => 0, 'user_id' => $contentObject->attribute('id')));
     $userSetting->store();
     $dataMap['user_account']->setContent($user);
     $dataMap['user_account']->store();
     $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObject->attribute('id'), 'version' => $version->attribute('version')));
     if (array_key_exists('status', $operationResult) && $operationResult['status'] == eZModuleOperationInfo::STATUS_CONTINUE) {
         $db->commit();
         return $user;
     }
     $db->rollback();
     return false;
 }
Exemplo n.º 6
0
 function className()
 {
     if ($this->ClassName === null) {
         $contentClass = eZContentClass::fetch($this->attribute('contentclass_id'));
         $this->ClassName = $contentClass->attribute('name');
     }
     return $this->ClassName;
 }
Exemplo n.º 7
0
function updateClass($classId, $scheduledScript)
{
    $cli = eZCLI::instance();
    /*
    // If the class is not stored yet, store it now
    $class = eZContentClass::fetch( $classId, true, eZContentClass::VERSION_STATUS_TEMPORARY );
    if ( $class )
    {
        $cli->output( "Storing class" );
        $class->storeDefined( $class->fetchAttributes() );
    }
    */
    // Fetch the stored class
    $class = eZContentClass::fetch($classId, true, eZContentClass::VERSION_STATUS_MODIFIED);
    if (!$class) {
        $cli->error('No class in a modified version status with ID: ' . $classId);
        return;
    }
    // Fetch attributes and definitions
    $attributes = $class->fetchAttributes($classId, true, eZContentClass::VERSION_STATUS_MODIFIED);
    $oldClassAttributes = $class->fetchAttributes($classId, true, eZContentClass::VERSION_STATUS_DEFINED);
    // Delete object attributes which have been removed.
    foreach ($oldClassAttributes as $oldClassAttribute) {
        $attributeExist = false;
        $oldClassAttributeID = $oldClassAttribute->attribute('id');
        foreach ($attributes as $newClassAttribute) {
            if ($oldClassAttributeID == $newClassAttribute->attribute('id')) {
                $attributeExist = true;
            }
        }
        if (!$attributeExist) {
            foreach (eZContentObjectAttribute::fetchSameClassAttributeIDList($oldClassAttributeID) as $objectAttribute) {
                $objectAttribute->removeThis($objectAttribute->attribute('id'));
            }
        }
    }
    $class->storeVersioned($attributes, eZContentClass::VERSION_STATUS_DEFINED);
    // Add object attributes which have been added.
    foreach ($attributes as $newClassAttribute) {
        $attributeExist = false;
        foreach ($oldClassAttributes as $oldClassAttribute) {
            if ($oldClassAttribute->attribute('id') == $newClassAttribute->attribute('id')) {
                $attributeExist = true;
                break;
            }
        }
        if (!$attributeExist) {
            $objects = null;
            $newClassAttribute->initializeObjectAttributes($objects);
        }
    }
    if ($scheduledScript !== false) {
        $scheduledScript->updateProgress(100);
    }
}
Exemplo n.º 8
0
 private function contentClassList()
 {
     $db = eZDB::instance();
     $query = "SELECT ezcontentclass.id\n                  FROM   ezcontentclass,\n                         ezcontentclass_attribute ezcontentclass_attribute1,\n                         ezcontentclass_attribute ezcontentclass_attribute2\n                  WHERE  ezcontentclass.version='0' AND\n                         ezcontentclass.id=ezcontentclass_attribute1.contentclass_id AND\n                         ezcontentclass_attribute1.is_information_collector='0' AND\n                         ezcontentclass.id=ezcontentclass_attribute2.contentclass_id AND\n                         ezcontentclass_attribute2.is_information_collector='0' AND\n                         ezcontentclass_attribute1.contentclass_id=ezcontentclass_attribute2.contentclass_id AND\n                         ezcontentclass_attribute1.data_type_string='ezxmltext' AND\n                         ezcontentclass_attribute2.data_type_string='eztext'";
     $contentClassArray = $db->arrayQuery($query);
     $retArray = array();
     foreach ($contentClassArray as $contentClass) {
         $retArray[] = eZContentClass::fetch($contentClass['id']);
     }
     return $retArray;
 }
 function className()
 {
     if ($this->ClassName === null) {
         $contentClass = eZContentClass::fetch($this->attribute('contentclass_id'));
         if (!$contentClass instanceof eZContentClass) {
             eZDebug::writeError('Unable to find eZContentClass #' . $this->attribute('contentclass_id'), __METHOD__);
             return null;
         }
         $this->ClassName = $contentClass->attribute('name');
     }
     return $this->ClassName;
 }
Exemplo n.º 10
0
 function &classAttributes()
 {
     if (isset($this->ClassID) and $this->ClassID) {
         $contentClass = eZContentClass::fetch($this->ClassID);
         if ($contentClass) {
             $attributes = $contentClass->fetchAttributes();
         } else {
             $attributes = null;
         }
     } else {
         $attributes = null;
     }
     return $attributes;
 }
function getClassConstraintListAsArray($class_identifier = false, $contentclass_id = false, $debug = false)
{
    //todo debug
    if (!$contentclass_id && !$class_identifier) {
        return;
    }
    if ($contentclass_id && $class_identifier) {
        return;
    }
    $ezobjectrelationlist = eZContentClassAttribute::fetchFilteredList(array('data_type_string' => 'ezobjectrelationlist'));
    $return = array();
    if ($contentclass_id) {
        foreach ($ezobjectrelationlist as $attribute) {
            if ($attribute->attribute('contentclass_id') == $contentclass_id) {
                $attributeContent = $attribute->content();
                if (!empty($attributeContent['class_constraint_list'])) {
                    $return = array_merge($return, $attributeContent['class_constraint_list']);
                }
            }
        }
        if (!empty($return)) {
            return $return;
        } else {
            return false;
        }
    }
    if ($class_identifier) {
        foreach ($ezobjectrelationlist as $attribute) {
            $attributeContent = $attribute->content();
            if (!empty($attributeContent['class_constraint_list'])) {
                if (in_array($class_identifier, $attributeContent['class_constraint_list'])) {
                    $class = eZContentClass::fetch($attribute->attribute('contentclass_id'));
                    $classIdentifier = eZContentClass::classIdentifierByID($attribute->attribute('contentclass_id'));
                    $return[$classIdentifier][] = array('class_id' => $attribute->attribute('contentclass_id'), 'class_name' => $class->attribute('name'), 'attribute_identifier' => $attribute->attribute('identifier'), 'attribute_name' => $attribute->attribute('name'), 'class_constraint_list' => $attributeContent['class_constraint_list'], 'search_filter' => $classIdentifier . '/' . $attribute->attribute('identifier') . '/main_node_id');
                }
            }
        }
        //eZDebug::writeNotice( $return, __METHOD__ );
        if (!empty($return)) {
            return $return;
        } else {
            return false;
        }
    }
    return false;
}
Exemplo n.º 12
0
 /**
  * Retrieve mapping between content attribute css id and swarm attribute identifier
  *
  * @return array
  */
 public function getFieldMapping()
 {
     $siteIni = eZINI::instance('site.ini');
     $swarmIni = eZINI::instance('ezswarm.ini');
     $userAttribMapping = $swarmIni->variable('SwarmSettings', 'UserAttributeMapping');
     $userClassId = $siteIni->variable('UserSettings', 'UserClassID');
     $userAccountAttribute = $swarmIni->variable('SwarmSettings', 'UserAccountAttribute');
     $userClass = eZContentClass::fetch($userClassId);
     $userClassAttributes = $userClass->dataMap();
     $fieldMapping = array();
     $userAccountAttributeId = $userClassAttributes[$userAccountAttribute]->attribute('id');
     $fieldMapping["#ezcoa-" . $userAccountAttributeId . "_" . $userAccountAttribute . "_email"] = 'email';
     if ($siteIni->variable('UserSettings', 'RequireConfirmEmail') == 'true') {
         $fieldMapping["#ezcoa-" . $userAccountAttributeId . "_" . $userAccountAttribute . "_email_confirm"] = 'email';
     }
     foreach ($userAttribMapping as $attribIdentifier => $swarmField) {
         $attributeId = $userClassAttributes[$attribIdentifier]->attribute('id');
         $fieldMapping["#ezcoa-" . $attributeId . "_" . $attribIdentifier] = $swarmField;
     }
     return $fieldMapping;
 }
 function fetchOverrideTemplateList($classID)
 {
     $class = eZContentClass::fetch($classID);
     $classIdentifier = $class->attribute('identifier');
     $result = array();
     $ini = eZINI::instance();
     $siteAccessArray = $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList');
     foreach ($siteAccessArray as $siteAccess) {
         $overrides = eZTemplateDesignResource::overrideArray($siteAccess);
         foreach ($overrides as $override) {
             if (isset($override['custom_match'])) {
                 foreach ($override['custom_match'] as $customMatch) {
                     if (isset($customMatch['conditions']['class_identifier']) && $customMatch['conditions']['class_identifier'] == $classIdentifier) {
                         $result[] = array('siteaccess' => $siteAccess, 'block' => $customMatch['override_name'], 'source' => $override['template'], 'target' => $customMatch['match_file']);
                     }
                     if (isset($customMatch['conditions']['class']) && $customMatch['conditions']['class'] == $classID) {
                         $result[] = array('siteaccess' => $siteAccess, 'block' => $customMatch['override_name'], 'source' => $override['template'], 'target' => $customMatch['match_file']);
                     }
                 }
             }
         }
     }
     return array('result' => $result);
 }
Exemplo n.º 14
0
function importRSSItem($item, $rssImport, $cli, $channel)
{
    $rssImportID = $rssImport->attribute('id');
    $rssOwnerID = $rssImport->attribute('object_owner_id');
    // Get owner user id
    $parentContentObjectTreeNode = eZContentObjectTreeNode::fetch($rssImport->attribute('destination_node_id'));
    // Get parent treenode object
    if ($parentContentObjectTreeNode == null) {
        $cli->output('RSSImport ' . $rssImport->attribute('name') . ': Destination tree node seems to be unavailable');
        return 0;
    }
    $parentContentObject = $parentContentObjectTreeNode->attribute('object');
    // Get parent content object
    $titleElement = $item->getElementsByTagName('title')->item(0);
    $title = is_object($titleElement) ? $titleElement->textContent : '';
    // Test for link or guid as unique identifier
    $link = $item->getElementsByTagName('link')->item(0);
    $guid = $item->getElementsByTagName('guid')->item(0);
    $rssId = '';
    if ($link->textContent) {
        $rssId = $link->textContent;
    } elseif ($guid->textContent) {
        $rssId = $guid->textContent;
    } else {
        $cli->output('RSSImport ' . $rssImport->attribute('name') . ': Item has no unique identifier. RSS guid or link missing.');
        return 0;
    }
    $md5Sum = md5($rssId);
    // Try to fetch RSSImport object with md5 sum matching link.
    $existingObject = eZPersistentObject::fetchObject(eZContentObject::definition(), null, array('remote_id' => 'RSSImport_' . $rssImportID . '_' . $md5Sum));
    // if object exists, continue to next import item
    if ($existingObject != null) {
        $cli->output('RSSImport ' . $rssImport->attribute('name') . ': Object ( ' . $existingObject->attribute('id') . ' ) with ID: "' . $rssId . '" already exists');
        unset($existingObject);
        // delete object to preserve memory
        return 0;
    }
    // Fetch class, and create ezcontentobject from it.
    $contentClass = eZContentClass::fetch($rssImport->attribute('class_id'));
    // Instantiate the object with user $rssOwnerID and use section id from parent. And store it.
    $contentObject = $contentClass->instantiate($rssOwnerID, $parentContentObject->attribute('section_id'));
    $db = eZDB::instance();
    $db->begin();
    $contentObject->store();
    $contentObjectID = $contentObject->attribute('id');
    // Create node assignment
    $nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObjectID, 'contentobject_version' => $contentObject->attribute('current_version'), 'is_main' => 1, 'parent_node' => $parentContentObjectTreeNode->attribute('node_id')));
    $nodeAssignment->store();
    $version = $contentObject->version(1);
    $version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
    $version->store();
    // Get object attributes, and set their values and store them.
    $dataMap = $contentObject->dataMap();
    $importDescription = $rssImport->importDescription();
    // Set content object attribute values.
    $classAttributeList = $contentClass->fetchAttributes();
    foreach ($classAttributeList as $classAttribute) {
        $classAttributeID = $classAttribute->attribute('id');
        if (isset($importDescription['class_attributes'][$classAttributeID])) {
            if ($importDescription['class_attributes'][$classAttributeID] == '-1') {
                continue;
            }
            $importDescriptionArray = explode(' - ', $importDescription['class_attributes'][$classAttributeID]);
            if (count($importDescriptionArray) < 1) {
                $cli->output('RSSImport ' . $rssImport->attribute('name') . ': Invalid import definition. Please redit.');
                break;
            }
            $elementType = $importDescriptionArray[0];
            array_shift($importDescriptionArray);
            switch ($elementType) {
                case 'item':
                    setObjectAttributeValue($dataMap[$classAttribute->attribute('identifier')], recursiveFindRSSElementValue($importDescriptionArray, $item));
                    break;
                case 'channel':
                    setObjectAttributeValue($dataMap[$classAttribute->attribute('identifier')], recursiveFindRSSElementValue($importDescriptionArray, $channel));
                    break;
            }
        }
    }
    $contentObject->setAttribute('remote_id', 'RSSImport_' . $rssImportID . '_' . $md5Sum);
    $contentObject->store();
    $db->commit();
    // Publish new object. The user id is sent to make sure any workflow
    // requiring the user id has access to it.
    $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObject->attribute('id'), 'version' => 1, 'user_id' => $rssOwnerID));
    if (!isset($operationResult['status']) || $operationResult['status'] != eZModuleOperationInfo::STATUS_CONTINUE) {
        if (isset($operationResult['result']) && isset($operationResult['result']['content'])) {
            $failReason = $operationResult['result']['content'];
        } else {
            $failReason = "unknown error";
        }
        $cli->error("Publishing failed: {$failReason}");
        unset($failReason);
    }
    $db->begin();
    unset($contentObject);
    unset($version);
    $contentObject = eZContentObject::fetch($contentObjectID);
    $version = $contentObject->attribute('current');
    // Set object Attributes like modified and published timestamps
    $objectAttributeDescription = $importDescription['object_attributes'];
    foreach ($objectAttributeDescription as $identifier => $objectAttributeDefinition) {
        if ($objectAttributeDefinition == '-1') {
            continue;
        }
        $importDescriptionArray = explode(' - ', $objectAttributeDefinition);
        $elementType = $importDescriptionArray[0];
        array_shift($importDescriptionArray);
        switch ($elementType) {
            default:
            case 'item':
                $domNode = $item;
                break;
            case 'channel':
                $domNode = $channel;
                break;
        }
        switch ($identifier) {
            case 'modified':
                $dateTime = recursiveFindRSSElementValue($importDescriptionArray, $domNode);
                if (!$dateTime) {
                    break;
                }
                $contentObject->setAttribute($identifier, strtotime($dateTime));
                $version->setAttribute($identifier, strtotime($dateTime));
                break;
            case 'published':
                $dateTime = recursiveFindRSSElementValue($importDescriptionArray, $domNode);
                if (!$dateTime) {
                    break;
                }
                $contentObject->setAttribute($identifier, strtotime($dateTime));
                $version->setAttribute('created', strtotime($dateTime));
                break;
        }
    }
    $version->store();
    $contentObject->store();
    $db->commit();
    $cli->output('RSSImport ' . $rssImport->attribute('name') . ': Object created; ' . $title);
    return 1;
}
Exemplo n.º 15
0
 static function storeRSSExport($Module, $http, $publish = false, $skipValuesID = null)
 {
     $valid = true;
     $validationErrors = array();
     /* Kill the RSS cache in all siteaccesses */
     $config = eZINI::instance('site.ini');
     $cacheDir = eZSys::cacheDirectory();
     $availableSiteAccessList = $config->variable('SiteAccessSettings', 'AvailableSiteAccessList');
     foreach ($availableSiteAccessList as $siteAccess) {
         $cacheFilePath = $cacheDir . '/rss/' . md5($siteAccess . $http->postVariable('Access_URL')) . '.xml';
         $cacheFile = eZClusterFileHandler::instance($cacheFilePath);
         if ($cacheFile->exists()) {
             $cacheFile->delete();
         }
     }
     $db = eZDB::instance();
     $db->begin();
     /* Create the new RSS feed */
     for ($itemCount = 0; $itemCount < $http->postVariable('Item_Count'); $itemCount++) {
         if ($skipValuesID == $http->postVariable('Item_ID_' . $itemCount)) {
             continue;
         }
         $rssExportItem = eZRSSExportItem::fetch($http->postVariable('Item_ID_' . $itemCount), true, eZRSSExport::STATUS_DRAFT);
         if ($rssExportItem == null) {
             continue;
         }
         // RSS is supposed to feed certain objects from the subnodes
         if ($http->hasPostVariable('Item_Subnodes_' . $itemCount)) {
             $rssExportItem->setAttribute('subnodes', 1);
         } else {
             $rssExportItem->setAttribute('subnodes', 0);
         }
         $rssExportItem->setAttribute('class_id', $http->postVariable('Item_Class_' . $itemCount));
         $class = eZContentClass::fetch($http->postVariable('Item_Class_' . $itemCount));
         $titleClassAttributeIdentifier = $http->postVariable('Item_Class_Attribute_Title_' . $itemCount);
         $descriptionClassAttributeIdentifier = $http->postVariable('Item_Class_Attribute_Description_' . $itemCount);
         $categoryClassAttributeIdentifier = $http->postVariable('Item_Class_Attribute_Category_' . $itemCount);
         if (!$class) {
             $validated = false;
             $validationErrors[] = ezpI18n::tr('kernel/rss/edit_export', 'Selected class does not exist');
         } else {
             $dataMap = $class->attribute('data_map');
             if (!isset($dataMap[$titleClassAttributeIdentifier])) {
                 $valid = false;
                 $validationErrors[] = ezpI18n::tr('kernel/rss/edit_export', 'Invalid selection for title class %1 does not have attribute "%2"', null, array($class->attribute('name'), $titleClassAttributeIdentifier));
             }
             if ($descriptionClassAttributeIdentifier != '' && !isset($dataMap[$descriptionClassAttributeIdentifier])) {
                 $valid = false;
                 $validationErrors[] = ezpI18n::tr('kernel/rss/edit_export', 'Invalid selection for description class %1 does not have attribute "%2"', null, array($class->attribute('name'), $descriptionClassAttributeIdentifier));
             }
             if ($categoryClassAttributeIdentifier != '' && !isset($dataMap[$categoryClassAttributeIdentifier])) {
                 $valid = false;
                 $validationErrors[] = ezpI18n::tr('kernel/rss/edit_export', 'Invalid selection for category class %1 does not have attribute "%2"', null, array($class->attribute('name'), $categoryClassAttributeIdentifier));
             }
         }
         $rssExportItem->setAttribute('title', $http->postVariable('Item_Class_Attribute_Title_' . $itemCount));
         $rssExportItem->setAttribute('description', $http->postVariable('Item_Class_Attribute_Description_' . $itemCount));
         $rssExportItem->setAttribute('category', $http->postVariable('Item_Class_Attribute_Category_' . $itemCount));
         if ($http->hasPostVariable('Item_Class_Attribute_Enclosure_' . $itemCount)) {
             $rssExportItem->setAttribute('enclosure', $http->postVariable('Item_Class_Attribute_Enclosure_' . $itemCount));
         }
         if ($publish && $valid) {
             $rssExportItem->setAttribute('status', eZRSSExport::STATUS_VALID);
             $rssExportItem->store();
             // delete drafts
             $rssExportItem->setAttribute('status', eZRSSExport::STATUS_DRAFT);
             $rssExportItem->remove();
         } else {
             $rssExportItem->store();
         }
     }
     $rssExport = eZRSSExport::fetch($http->postVariable('RSSExport_ID'), true, eZRSSExport::STATUS_DRAFT);
     $rssExport->setAttribute('title', $http->postVariable('title'));
     $rssExport->setAttribute('url', $http->postVariable('url'));
     // $rssExport->setAttribute( 'site_access', $http->postVariable( 'SiteAccess' ) );
     $rssExport->setAttribute('description', $http->postVariable('Description'));
     $rssExport->setAttribute('rss_version', $http->postVariable('RSSVersion'));
     $rssExport->setAttribute('number_of_objects', $http->postVariable('NumberOfObjects'));
     $rssExport->setAttribute('image_id', $http->postVariable('RSSImageID'));
     if ($http->hasPostVariable('active')) {
         $rssExport->setAttribute('active', 1);
     } else {
         $rssExport->setAttribute('active', 0);
     }
     $rssExport->setAttribute('access_url', str_replace(array('/', '?', '&', '>', '<'), '', $http->postVariable('Access_URL')));
     if ($http->hasPostVariable('MainNodeOnly')) {
         $rssExport->setAttribute('main_node_only', 1);
     } else {
         $rssExport->setAttribute('main_node_only', 0);
     }
     $published = false;
     if ($publish && $valid) {
         $rssExport->store(true);
         // remove draft
         $rssExport->remove();
         $published = true;
     } else {
         $rssExport->store();
     }
     $db->commit();
     return array('valid' => $valid, 'published' => $published, 'validation_errors' => $validationErrors);
 }
 /**
 * 
 * Récupère l'id numérique correspondant à un identifiant de classe
 * @param $classIdentifier : un identifiant de classe 
 * @return l'ID numérique de la classe (0 si la classe n'existe pas)
 *
 */
 public static function getClassID( $classIdentifier )
 {
     $classID = 0;
     $class = is_numeric( $classIdentifier ) ? 
     eZContentClass::fetch( $classIdentifier ) : 
     eZContentClass::fetchByIdentifier( $classIdentifier );
     if ( ! empty( $class ) )
     {
         $classID = (int)$class->ID;
     }
     return $classID;
 }
 public static function fetchClassAttributeList($classID, $versionID)
 {
     $objectList = eZContentClass::fetch($classID)->fetchAttributes(false, true, $versionID);
     if ($objectList === null) {
         $result = array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND));
     } else {
         $result = array('result' => $objectList);
     }
     return $result;
 }
Exemplo n.º 18
0
 /**
  * Get attribute value
  *
  * @param string Attribute name
  *
  * @return mixed Attribute value. null if attribute does not exist.
  */
 public function attribute($attr)
 {
     switch ($attr) {
         case 'responseHeader':
             return $this->ResultArray['responseHeader'];
             break;
         case 'hasError':
             return !empty($this->ResultArray['error']);
             break;
         case 'error':
             if (!empty($this->ResultArray['error'])) {
                 return $this->ResultArray['error'];
             }
             break;
         case 'facet_queries':
             if (!empty($this->FacetQueries)) {
                 return $this->FacetQueries;
             }
             // If the facets count is empty, an error has occured.
             if (empty($this->ResultArray['facet_counts'])) {
                 return null;
             }
             $facetArray = array();
             foreach ($this->ResultArray['facet_counts']['facet_queries'] as $query => $count) {
                 list($field, $fieldValue) = explode(':', $query);
                 $fieldInfo = array('field' => $field, 'count' => $count, 'queryLimit' => $query, 'fieldValue' => $fieldValue);
                 $facetArray[] = $fieldInfo;
             }
             $this->FacetQueries = $facetArray;
             return $this->FacetQueries;
             break;
         case 'facet_fields':
             if (!empty($this->FacetFields)) {
                 return $this->FacetFields;
             }
             // If the facets count is empty, an error has occured.
             if (empty($this->ResultArray['facet_counts'])) {
                 return null;
             }
             $facetArray = array();
             foreach ($this->ResultArray['facet_counts']['facet_fields'] as $field => $facetField) {
                 switch ($field) {
                     // class facet field
                     case eZSolr::getMetaFieldName('contentclass_id'):
                         $fieldInfo = array('field' => 'class', 'count' => count($facetField), 'nameList' => array(), 'queryLimit' => array(), 'fieldList' => array(), 'countList' => array());
                         foreach ($facetField as $contentClassID => $count) {
                             if ($contentClass = eZContentClass::fetch($contentClassID)) {
                                 $fieldInfo['nameList'][$contentClassID] = $contentClass->attribute('name');
                                 $fieldInfo['queryLimit'][$contentClassID] = 'contentclass_id:' . $contentClassID;
                                 $fieldInfo['countList'][$contentClassID] = $count;
                                 $fieldInfo['fieldList'][$contentClassID] = 'contentclass_id';
                             } else {
                                 eZDebug::writeWarning('Could not fetch eZContentClass: ' . $contentClassID, __METHOD__);
                             }
                         }
                         $facetArray[] = $fieldInfo;
                         break;
                         // instalaltion facet field
                     // instalaltion facet field
                     case eZSolr::getMetaFieldName('installation_id'):
                         $findINI = eZINI::instance('ezfind.ini');
                         $siteNameMapList = $findINI->variable('FacetSettings', 'SiteNameList');
                         $fieldInfo = array('field' => 'installation', 'count' => count($facetField), 'nameList' => array(), 'queryLimit' => array(), 'fieldList' => array(), 'countList' => array());
                         foreach ($facetField as $installationID => $count) {
                             $fieldInfo['nameList'][$installationID] = isset($siteNameMapList[$installationID]) ? $siteNameMapList[$installationID] : $installationID;
                             $fieldInfo['queryLimit'][$installationID] = 'installation_id:' . $installationID;
                             $fieldInfo['countList'][$installationID] = $count;
                             $fieldInfo['fieldList'][$installationID] = 'installation_id';
                         }
                         $facetArray[] = $fieldInfo;
                         break;
                         // author facet field
                     // author facet field
                     case eZSolr::getMetaFieldName('owner_id'):
                         $fieldInfo = array('field' => 'author', 'count' => count($facetField), 'nameList' => array(), 'queryLimit' => array(), 'fieldList' => array(), 'countList' => array());
                         foreach ($facetField as $ownerID => $count) {
                             if ($owner = eZContentObject::fetch($ownerID)) {
                                 $fieldInfo['nameList'][$ownerID] = $owner->attribute('name');
                                 $fieldInfo['queryLimit'][$ownerID] = 'owner_id:' . $ownerID;
                                 $fieldInfo['countList'][$ownerID] = $count;
                                 $fieldInfo['fieldList'][$ownerID] = 'owner_id';
                             } else {
                                 eZDebug::writeWarning('Could not fetch owner ( eZContentObject ): ' . $ownerID, __METHOD__);
                             }
                         }
                         $facetArray[] = $fieldInfo;
                         break;
                         // translation facet field
                     // translation facet field
                     case eZSolr::getMetaFieldName('language_code'):
                         $fieldInfo = array('field' => 'translation', 'count' => count($facetField), 'nameList' => array(), 'queryLimit' => array(), 'fieldList' => array(), 'countList' => array());
                         foreach ($facetField as $languageCode => $count) {
                             $fieldInfo['nameList'][$languageCode] = $languageCode;
                             $fieldInfo['queryLimit'][$languageCode] = 'language_code:' . $languageCode;
                             $fieldInfo['fieldList'][$languageCode] = 'language_code';
                             $fieldInfo['countList'][$languageCode] = $count;
                         }
                         $facetArray[] = $fieldInfo;
                         break;
                     default:
                         $fieldInfo = array('field' => $attr, 'count' => count($facetField), 'queryLimit' => array(), 'fieldList' => array(), 'nameList' => array(), 'countList' => array());
                         foreach ($facetField as $value => $count) {
                             $fieldInfo['nameList'][$value] = $value;
                             $fieldInfo['fieldList'][$value] = $field;
                             $fieldInfo['queryLimit'][$value] = $field . ':' . $value;
                             $fieldInfo['countList'][$value] = $count;
                         }
                         $facetArray[] = $fieldInfo;
                         break;
                 }
             }
             $this->FacetFields = $facetArray;
             return $this->FacetFields;
             break;
         case 'engine':
             return eZSolr::engineText();
             break;
             //may or may not be active, so returns false if not present
         //may or may not be active, so returns false if not present
         case 'spellcheck':
             if (isset($this->ResultArray['spellcheck']) && $this->ResultArray['spellcheck']['suggestions'] > 0) {
                 return $this->ResultArray['spellcheck']['suggestions'];
             } else {
                 return false;
             }
             break;
         case 'spellcheck_collation':
             if (isset($this->ResultArray['spellcheck']['suggestions']['collation'])) {
                 // work around border case if 'collation' is searched for but does not exist in the spell check index
                 // the collation string is the last element of the suggestions array
                 return end($this->ResultArray['spellcheck']['suggestions']);
             } else {
                 return false;
             }
             break;
             //only relevant for MoreLikeThis queries
         //only relevant for MoreLikeThis queries
         case 'interestingTerms':
             if (isset($this->ResultArray['interestingTerms'])) {
                 return $this->ResultArray['interestingTerms'];
             } else {
                 return false;
             }
             break;
         case 'facet_dates':
             if (isset($this->ResultArray['facet_dates'])) {
                 return $this->ResultArray['facet_dates'];
             } else {
                 return false;
             }
             break;
         case 'facet_ranges':
             if (isset($this->ResultArray['facet_counts']['facet_ranges'])) {
                 return $this->ResultArray['facet_counts']['facet_ranges'];
             } else {
                 return false;
             }
             break;
         case 'clusters':
             if (isset($this->ResultArray['clusters'])) {
                 return $this->ResultArray['clusters'];
             } else {
                 return false;
             }
             break;
         default:
             break;
     }
     return null;
 }
Exemplo n.º 19
0
}
if ($http->hasPostVariable("ConfirmButton")) {
    foreach ($deleteIDArray as $deleteID) {
        eZContentClassOperations::remove($deleteID);
    }
    return $Module->redirectTo('/class/classlist/' . $GroupID);
}
if ($http->hasPostVariable("CancelButton")) {
    return $Module->redirectTo('/class/classlist/' . $GroupID);
}
$canRemoveCount = 0;
foreach ($deleteIDArray as $deleteID) {
    $ClassObjectsCount = 0;
    $class = eZContentClass::fetch($deleteID);
    if ($class != null) {
        $class = eZContentClass::fetch($deleteID);
        $ClassID = $class->attribute('id');
        $ClassName = $class->attribute('name');
        if (!$class->isRemovable()) {
            $item = array("className" => $ClassName, 'objectCount' => 0, "is_removable" => false, 'reason' => $class->removableInformation());
            $DeleteResult[] = $item;
            continue;
        }
        ++$canRemoveCount;
        $classObjects = eZContentObject::fetchSameClassList($ClassID);
        $ClassObjectsCount = count($classObjects);
        $item = array("className" => $ClassName, "is_removable" => true, "objectCount" => $ClassObjectsCount);
        $DeleteResult[] = $item;
    }
}
$canRemove = $canRemoveCount > 0;
Exemplo n.º 20
0
 * @version  2012.6
 * @package kernel
 * @subpackage content
 */
$tpl = eZTemplate::factory();
$module = $Params['Module'];
$http = eZHTTPTool::instance();
$pContentObjectId = $Params['ContentObjectID'];
$pVersion = $Params['version'];
$tpl->setVariable('contentObjectId', $pContentObjectId);
$tpl->setVariable('version', $pVersion);
$virtualNodeID = 0;
$contentObject = eZContentObject::fetch($pContentObjectId);
$contentObjectVersion = $contentObject->version($pVersion);
$nodeAssignments = $contentObjectVersion->attribute('node_assignments');
$contentClass = eZContentClass::fetch($contentObject->attribute('contentclass_id'));
$section = eZSection::fetch($contentObject->attribute('section_id'));
$navigationPartIdentifier = $section->attribute('navigation_part_identifier');
$res = eZTemplateDesignResource::instance();
$designKeys = array(array('object', $contentObject->attribute('id')), array('node', $virtualNodeID), array('remote_id', $contentObject->attribute('remote_id')), array('class', $contentClass->attribute('id')), array('class_identifier', $contentClass->attribute('identifier')), array('class_group', $contentObject->attribute('match_ingroup_id_list')), array('state', $contentObject->attribute('state_id_array')), array('state_identifier', $contentObject->attribute('state_identifier_array')), array('section', $contentObject->attribute('section_id')), array('section_identifier', $section->attribute('identifier')));
$res->setKeys($designKeys);
if ($http->hasSessionVariable('RedirectURIAfterPublish')) {
    $tpl->setVariable('redirect_uri', $http->sessionVariable('RedirectURIAfterPublish'));
}
$tpl->setVariable('content_object', $contentObject);
$tpl->setVariable('content_object_version', $contentObjectVersion);
$tpl->setVariable('content_class', $contentClass);
$Result['path'] = array(array('text' => ezpI18n::tr('kernel/content', 'Content'), 'url' => false), array('text' => ezpI18n::tr('kernel/content', 'Publishing queue'), 'url' => false), array('text' => $contentObject->attribute('name'), 'url' => false));
$Result['content'] = $tpl->fetch('design:content/queued.tpl');
$Result['navigation_part'] = $navigationPartIdentifier;
return $Result;
Exemplo n.º 21
0
 function handleParameters($packageType, $package, $cli, $type, $arguments)
 {
     $classList = false;
     foreach ($arguments as $argument) {
         if ($argument[0] == '-') {
             if (strlen($argument) > 1 and $argument[1] == '-') {
             } else {
             }
         } else {
             if ($classList === false) {
                 $classList = array();
                 $classArray = explode(',', $argument);
                 $error = false;
                 foreach ($classArray as $classID) {
                     if (in_array($classID, $classList)) {
                         $cli->notice("Content class {$classID} already in list");
                         continue;
                     }
                     if (is_numeric($classID)) {
                         if (!eZContentClass::exists($classID, 0, false, false)) {
                             $cli->error("Content class with ID {$classID} does not exist");
                             $error = true;
                         } else {
                             unset($class);
                             $class = eZContentClass::fetch($classID);
                             $classList[] = array('id' => $classID, 'identifier' => $class->attribute('identifier'), 'value' => $classID);
                         }
                     } else {
                         $realClassID = eZContentClass::exists($classID, 0, false, true);
                         if (!$realClassID) {
                             $cli->error("Content class with identifier {$classID} does not exist");
                             $error = true;
                         } else {
                             unset($class);
                             $class = eZContentClass::fetch($realClassID);
                             $classList[] = array('id' => $realClassID, 'identifier' => $class->attribute('identifier'), 'value' => $classID);
                         }
                     }
                 }
                 if ($error) {
                     return false;
                 }
             }
         }
     }
     if ($classList === false) {
         $cli->error("No class ids chosen");
         return false;
     }
     return array('class-list' => $classList);
 }
    function generatePackageInformation( &$packageInformation, $package, $http, $step, &$persistentData )
    {
        $classList = $persistentData['classlist'];

        if ( count( $classList ) == 1 )
        {
            $classID = $classList[0];
            $class = eZContentClass::fetch( $classID );
            if ( $class )
            {
                $packageInformation['name'] = $class->attribute( 'name' );
                $packageInformation['summary'] = 'Export of content class ' . $class->attribute( 'name' );
                $packageInformation['description'] = 'This package contains an exported definition of the content class ' . $class->attribute( 'name' ) . ' which can be imported to another eZ Publish site';
            }
        }
        else if ( count( $classList ) > 1 )
        {
            $classNames = array();
            foreach ( $classList as $classID )
            {
                $class = eZContentClass::fetch( $classID );
                if ( $class )
                {
                    $classNames[] = $class->attribute( 'name' );
                }
            }
            $packageInformation['name'] = count( $classList ) . ' Classes';
            $packageInformation['summary'] = 'Export of ' . count( $classList ) . ' content classes';
            $description = 'This package contains exported definitions of the following content classes:' . "\n";
            foreach ( $classNames as $className )
            {
                $description .= '- ' . $className . "\n";
            }
            $packageInformation['description'] = $description;
        }
    }
 function execute()
 {
     foreach ($this->AttributeArray as $classAttribute) {
         $contentClass = eZContentClass::fetch($classAttribute->attribute('contentclass_id'));
         $this->Cli->output("Process class: " . $this->Cli->stylize('strong', $classAttribute->attribute('contentclass_id')) . " (" . $contentClass->attribute('name') . "), attribute id: " . $this->Cli->stylize('strong', $classAttribute->attribute('id')) . " (" . $classAttribute->attribute('name') . "):");
         $this->updateContentFromClassAttribute($classAttribute->attribute('id'));
         $this->updateClassAttributeToISBN13($classAttribute->attribute('id'));
         $this->Cli->output(" Finished.");
     }
 }
Exemplo n.º 24
0
//
// ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
//
$Module = $Params['Module'];
$LanguageCode = $Params['Language'];
$http = eZHTTPTool::instance();
$ClassID = null;
$validation = array('processed' => false, 'groups' => array());
if (isset($Params["ClassID"])) {
    $ClassID = $Params["ClassID"];
}
$ClassVersion = null;
if (!is_numeric($ClassID)) {
    return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
$class = eZContentClass::fetch($ClassID, true, eZContentClass::VERSION_STATUS_DEFINED);
if (!$class) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
if (!$LanguageCode) {
    $LanguageCode = $class->attribute('top_priority_language_locale');
}
if ($http->hasPostVariable('AddGroupButton') && $http->hasPostVariable('ContentClass_group')) {
    eZClassFunctions::addGroup($ClassID, $ClassVersion, $http->postVariable('ContentClass_group'));
}
if ($http->hasPostVariable('RemoveGroupButton') && $http->hasPostVariable('group_id_checked')) {
    if (!eZClassFunctions::removeGroup($ClassID, $ClassVersion, $http->postVariable('group_id_checked'))) {
        $validation['groups'][] = array('text' => ezpI18n::tr('kernel/class', 'You have to have at least one group that the class belongs to!'));
        $validation['processed'] = true;
    }
}
 public static function setObjectStatusPublished($objectID, $versionNum)
 {
     $object = eZContentObject::fetch($objectID);
     $version = $object->version($versionNum);
     $db = eZDB::instance();
     $db->begin();
     $object->publishContentObjectRelations($versionNum);
     $object->setAttribute('status', eZContentObject::STATUS_PUBLISHED);
     $version->setAttribute('status', eZContentObjectVersion::STATUS_PUBLISHED);
     $object->setAttribute('current_version', $versionNum);
     $objectIsAlwaysAvailable = $object->isAlwaysAvailable();
     $object->setAttribute('language_mask', eZContentLanguage::maskByLocale($version->translationList(false, false), $objectIsAlwaysAvailable));
     if ($object->attribute('published') == 0) {
         $object->setAttribute('published', time());
     }
     $object->setAttribute('modified', time());
     $classID = $object->attribute('contentclass_id');
     $class = eZContentClass::fetch($classID);
     $objectName = $class->contentObjectName($object);
     $object->setName($objectName, $versionNum);
     $existingTranslations = $version->translations(false);
     foreach ($existingTranslations as $translation) {
         $translatedName = $class->contentObjectName($object, $versionNum, $translation);
         $object->setName($translatedName, $versionNum, $translation);
     }
     if ($objectIsAlwaysAvailable) {
         $initialLanguageID = $object->attribute('initial_language_id');
         $object->setAlwaysAvailableLanguageID($initialLanguageID);
     }
     $version->store();
     $object->store();
     eZContentObjectTreeNode::setVersionByObjectID($objectID, $versionNum);
     $nodes = $object->assignedNodes();
     foreach ($nodes as $node) {
         $node->setName($object->attribute('name'));
         $node->updateSubTreePath();
     }
     $db->commit();
     /* Check if current class is the user class, and if so, clean up the user-policy cache */
     if (in_array($classID, eZUser::contentClassIDs())) {
         eZUser::purgeUserCacheByUserId($object->attribute('id'));
     }
 }
    function &generateFetchAliasArray()
    {
        $dom = new DOMDocument( '1.0', 'utf-8' );
        $fetchAliasListDOMNode = $dom->createElement( 'fetch-alias-list' );
        $registeredAliases = array();

        foreach( array_keys( $this->TemplateFileArray ) as $siteAccess )
        {
            $aliasINI = eZINI::instance( 'fetchalias.ini', 'settings', null, null, true );
            $aliasINI->prependOverrideDir( "siteaccess/$siteAccess", false, 'siteaccess' );
            $aliasINI->loadCache();

            foreach ( $this->TemplateFileArray[$siteAccess] as $filename )
            {
                $fp = fopen( $filename, 'r' );
                if ( !$fp )
                {
                    eZDebug::writeError( 'Could not open ' . $filename . ' during content object export.', __METHOD__ );
                    continue;
                }

                $str = fread( $fp, filesize( $filename ) );

                $matchArray = array();
                preg_match_all( "#.*fetch_alias\([ ]*([a-zA-Z0-9_]+)[ |,|)]+.*#U", $str, $matchArray, PREG_PATTERN_ORDER );

                foreach( $matchArray[1] as $fetchAlias )
                {
                    if ( isset( $registeredAliases[$fetchAlias] ) )
                    {
                        continue;
                    }
                    $registeredAliases[$fetchAlias] = true;

                    unset( $fetchAliasDOMNode );
                    $fetchAliasDOMNode = $dom->createElement( 'fetch-alias' );
                    $fetchAliasDOMNode->setAttribute( 'name', $fetchAlias );
                    $fetchAliasDOMNode->setAttribute( 'site-access', $siteAccess );

                    $fetchBlock = $aliasINI->group( $fetchAlias );
                    if ( isset( $fetchBlock['Constant'] ) )
                    {
                        foreach ( $fetchBlock['Constant'] as $matchKey => $value )
                        {
                            if ( strpos( $matchKey, 'class_' ) === 0 &&
                                 is_int( $value ) )
                            {
                                $contentClass = eZContentClass::fetch( $value );
                                $fetchBlock['Constant']['class_remote_id'] = $contentClass->attribute( 'remote_id' );
                            }
                            if ( strpos( $matchKey, 'node_' ) === 0 &&
                                 is_int( $value ) )
                            {
                                $contentTreeNode = eZContentObjectTreeNode::fetch( $value );
                                $fetchBlock['Constant']['node_remote_id'] = $contentTreeNode->attribute( 'remote_id' );
                            }
                            if ( strpos( $matchKey, 'parent_node_' ) === 0 &&
                                 is_int( $value ) )
                            {
                                $contentTreeNode = eZContentObjectTreeNode::fetch( $value );
                                $fetchBlock['Constant']['parent_node_remote_id'] = $contentTreeNode->attribute( 'remote_id' );
                            }
                            if ( strpos( $matchKey, 'object_' ) === 0 &&
                                 is_int( $value ) )
                            {
                                $contentObject = eZContentObject::fetch( $value );
                                $fetchBlock['Constant']['object_remote_id'] = $contentObject->attribute( 'remote_id' );
                            }
                        }
                    }
                    $importedNode = $dom->importNode( eZContentObjectPackageHandler::createElementNodeFromArray( $fetchAlias,  $fetchBlock ), true );
                    $fetchAliasDOMNode->appendChild( $importedNode );
                    $fetchAliasListDOMNode->appendChild( $fetchAliasDOMNode );
                }
            }
        }
        return $fetchAliasListDOMNode;
    }
Exemplo n.º 27
0
$fullSearchText = '';
if ($http->hasVariable('SearchText')) {
    if ($searchText != '') {
        $searchText .= ' ';
    }
    $originalSearchText = $http->variable('SearchText');
    $searchText .= $originalSearchText;
    $fullSearchText = $http->variable('SearchText');
}
$searchContentClassID = -1;
$searchContentClassAttributes = 0;
$searchContentClassAttributeArray = array();
if ($http->hasVariable('SearchContentClassID') and $http->variable('SearchContentClassID') != -1) {
    $searchContentClassID = $http->variable('SearchContentClassID');
    if ((int) $searchContentClassID > 0) {
        $searchContentClass = eZContentClass::fetch((int) $searchContentClassID);
        if (is_object($searchContentClass)) {
            $searchContentClassAttributeArray = $searchContentClass->fetchSearchableAttributes();
        }
    }
}
$searchContentClassAttributeID = -1;
if ($http->hasVariable('SearchContentClassAttributeID') and $http->variable('SearchContentClassAttributeID') != -1) {
    $searchContentClassAttributeID = $http->variable('SearchContentClassAttributeID');
}
$searchDate = -1;
if ($http->hasVariable('SearchDate') and $http->variable('SearchDate') != -1) {
    $searchDate = $http->variable('SearchDate');
}
$searchTimestamp = false;
if ($http->hasVariable('SearchTimestamp') and $http->variable('SearchTimestamp')) {
Exemplo n.º 28
0
 function customObjectAttributeHTTPAction($http, $action, $contentObjectAttribute, $parameters)
 {
     $contentobjectID = false;
     if (eZDataType::fetchActionValue($action, 'new_class', $classID) or $action == 'new_class') {
         if ($action == 'new_class') {
             $base = $parameters['base_name'];
             $classVariableName = $base . '_new_class';
             if ($http->hasPostVariable($classVariableName)) {
                 $classVariable = $http->postVariable($classVariableName);
                 $classID = $classVariable[$contentObjectAttribute->attribute('id')];
                 $class = eZContentClass::fetch($classID);
             } else {
                 return false;
             }
         } else {
             $class = eZContentClass::fetch($classID);
         }
         if ($class) {
             $classAttribute = $contentObjectAttribute->attribute('contentclass_attribute');
             $class_content = $classAttribute->content();
             $content = $contentObjectAttribute->content();
             $priority = 0;
             for ($i = 0; $i < count($content['relation_list']); ++$i) {
                 if ($content['relation_list'][$i]['priority'] > $priority) {
                     $priority = $content['relation_list'][$i]['priority'];
                 }
             }
             $base = $parameters['base_name'];
             $nodePlacement = false;
             $nodePlacementName = $base . '_object_initial_node_placement';
             if ($http->hasPostVariable($nodePlacementName)) {
                 $nodePlacementMap = $http->postVariable($nodePlacementName);
                 if (isset($nodePlacementMap[$contentObjectAttribute->attribute('id')])) {
                     $nodePlacement = $nodePlacementMap[$contentObjectAttribute->attribute('id')];
                 }
             }
             $relationItem = $this->createInstance($class, $priority + 1, $contentObjectAttribute, $nodePlacement);
             if ($class_content['default_placement']) {
                 $relationItem['parent_node_id'] = $class_content['default_placement']['node_id'];
             }
             $content['relation_list'][] = $relationItem;
             $hasAttributeInput = false;
             $attributeInputVariable = $base . '_has_attribute_input';
             if ($http->hasPostVariable($attributeInputVariable)) {
                 $attributeInputMap = $http->postVariable($attributeInputVariable);
                 if (isset($attributeInputMap[$contentObjectAttribute->attribute('id')])) {
                     $hasAttributeInput = $attributeInputMap[$contentObjectAttribute->attribute('id')];
                 }
             }
             if ($hasAttributeInput) {
                 $object = $relationItem['object'];
                 $attributes = $object->contentObjectAttributes();
                 foreach ($attributes as $attribute) {
                     $attributeBase = $base . '_ezorl_init_class_' . $object->attribute('contentclass_id') . '_attr_' . $attribute->attribute('contentclassattribute_id');
                     $oldAttributeID = $attribute->attribute('id');
                     $attribute->setAttribute('id', false);
                     if ($attribute->fetchInput($http, $attributeBase)) {
                         $attribute->setAttribute('id', $oldAttributeID);
                         $attribute->store();
                     }
                 }
             }
             $contentObjectAttribute->setContent($content);
             $contentObjectAttribute->store();
         } else {
             eZDebug::writeError("Unknown class ID {$classID}, cannot instantiate object", __METHOD__);
         }
     } else {
         if (eZDataType::fetchActionValue($action, 'edit_objects', $contentobjectID) or $action == 'edit_objects' or $action == 'remove_objects') {
             $base = $parameters['base_name'];
             $selectionBase = $base . '_selection';
             $selections = array();
             $http = eZHTTPTool::instance();
             if ($http->hasPostVariable($selectionBase)) {
                 $selectionMap = $http->postVariable($selectionBase);
                 $selections = $selectionMap[$contentObjectAttribute->attribute('id')];
             }
             if ($contentobjectID !== false) {
                 $selections[] = $contentobjectID;
             }
             if ($action == 'edit_objects' or eZDataType::fetchActionValue($action, 'edit_objects', $contentobjectID)) {
                 $content = $contentObjectAttribute->content();
                 foreach ($content['relation_list'] as $key => $relationItem) {
                     if (!$relationItem['is_modified'] and in_array($relationItem['contentobject_id'], $selections)) {
                         $object = eZContentObject::fetch($relationItem['contentobject_id']);
                         if ($object->attribute('can_edit')) {
                             $content['relation_list'][$key]['is_modified'] = true;
                             $translationSourceBase = $base . '_translation_source_' . $contentObjectAttribute->attribute('id') . '_' . $relationItem['contentobject_id'];
                             $languageFrom = false;
                             if ($http->hasPostVariable($translationSourceBase) && $http->postVariable($translationSourceBase) !== '') {
                                 $languageFrom = $http->postVariable($translationSourceBase);
                             }
                             $version = $object->createNewVersionIn($contentObjectAttribute->attribute('language_code'), $languageFrom);
                             $content['relation_list'][$key]['contentobject_version'] = $version->attribute('version');
                         }
                     }
                 }
                 $contentObjectAttribute->setContent($content);
                 $contentObjectAttribute->store();
             } else {
                 if ($action == 'remove_objects') {
                     $content = $contentObjectAttribute->content();
                     $relationList = $content['relation_list'];
                     $newRelationList = array();
                     foreach ($relationList as $relationItem) {
                         if (in_array($relationItem['contentobject_id'], $selections)) {
                             $this->removeRelationObject($contentObjectAttribute, $relationItem);
                         } else {
                             $newRelationList[] = $relationItem;
                         }
                     }
                     $content['relation_list'] = $newRelationList;
                     $contentObjectAttribute->setContent($content);
                     $contentObjectAttribute->store();
                 }
             }
         } else {
             if ($action == 'browse_objects') {
                 $module = $parameters['module'];
                 $redirectionURI = $parameters['current-redirection-uri'];
                 $ini = eZINI::instance('content.ini');
                 $browseType = 'AddRelatedObjectListToDataType';
                 $browseTypeINIVariable = $ini->variable('ObjectRelationDataTypeSettings', 'ClassAttributeStartNode');
                 foreach ($browseTypeINIVariable as $value) {
                     list($classAttributeID, $type) = explode(';', $value);
                     if (is_numeric($classAttributeID) and $classAttributeID == $contentObjectAttribute->attribute('contentclassattribute_id') and strlen($type) > 0) {
                         $browseType = $type;
                         break;
                     }
                 }
                 // Fetch the list of "allowed" classes .
                 // A user can select objects of only those allowed classes when browsing.
                 $classAttribute = $contentObjectAttribute->attribute('contentclass_attribute');
                 $classContent = $classAttribute->content();
                 if (isset($classContent['class_constraint_list'])) {
                     $classConstraintList = $classContent['class_constraint_list'];
                 } else {
                     $classConstraintList = array();
                 }
                 $browseParameters = array('action_name' => 'AddRelatedObject_' . $contentObjectAttribute->attribute('id'), 'type' => $browseType, 'browse_custom_action' => array('name' => 'CustomActionButton[' . $contentObjectAttribute->attribute('id') . '_set_object_relation_list]', 'value' => $contentObjectAttribute->attribute('id')), 'persistent_data' => array('HasObjectInput' => 0), 'from_page' => $redirectionURI);
                 $base = $parameters['base_name'];
                 $nodePlacementName = $base . '_browse_for_object_start_node';
                 if ($http->hasPostVariable($nodePlacementName)) {
                     $nodePlacement = $http->postVariable($nodePlacementName);
                     if (isset($nodePlacement[$contentObjectAttribute->attribute('id')])) {
                         $browseParameters['start_node'] = eZContentBrowse::nodeAliasID($nodePlacement[$contentObjectAttribute->attribute('id')]);
                     }
                 }
                 if (count($classConstraintList) > 0) {
                     $browseParameters['class_array'] = $classConstraintList;
                 }
                 eZContentBrowse::browse($browseParameters, $module);
             } else {
                 if ($action == 'set_object_relation_list') {
                     if (!$http->hasPostVariable('BrowseCancelButton')) {
                         $selectedObjectIDArray = $http->postVariable("SelectedObjectIDArray");
                         $content = $contentObjectAttribute->content();
                         $priority = 0;
                         for ($i = 0; $i < count($content['relation_list']); ++$i) {
                             if ($content['relation_list'][$i]['priority'] > $priority) {
                                 $priority = $content['relation_list'][$i]['priority'];
                             }
                         }
                         if ($selectedObjectIDArray !== null) {
                             foreach ($selectedObjectIDArray as $objectID) {
                                 // Check if the given object ID has a numeric value, if not go to the next object.
                                 if (!is_numeric($objectID)) {
                                     eZDebug::writeError("Related object ID (objectID): '{$objectID}', is not a numeric value.", __METHOD__);
                                     continue;
                                 }
                                 /* Here we check if current object is already in the related objects list.
                                  * If so, we don't add it again.
                                  * FIXME: Stupid linear search. Maybe there's some better way?
                                  */
                                 $found = false;
                                 foreach ($content['relation_list'] as $i) {
                                     if ($i['contentobject_id'] == $objectID) {
                                         $found = true;
                                         break;
                                     }
                                 }
                                 if ($found) {
                                     continue;
                                 }
                                 ++$priority;
                                 $content['relation_list'][] = $this->appendObject($objectID, $priority, $contentObjectAttribute);
                                 $contentObjectAttribute->setContent($content);
                                 $contentObjectAttribute->store();
                             }
                         }
                     }
                 } else {
                     eZDebug::writeError("Unknown custom HTTP action: " . $action, 'eZObjectRelationListType');
                 }
             }
         }
     }
 }
}
$ruleList = eZDiscountSubRule::fetchByRuleID($discountGroupID);
$ruleArray = array();
foreach ($ruleList as $rule) {
    $name = $rule->attribute('name');
    $percent = $rule->attribute('discount_percent');
    $limitation = $rule->attribute('limitation');
    $discountRuleID = $rule->attribute('id');
    if ($limitation != '*') {
        $ruleValues = eZDiscountSubRuleValue::fetchBySubRuleID($discountRuleID);
        if ($ruleValues != null) {
            $limitation = ezpI18n::tr('kernel/shop', 'Classes') . ' ';
            $firstLoop = true;
            foreach ($ruleValues as $ruleValue) {
                $classID = $ruleValue->attribute('value');
                $class = eZContentClass::fetch($classID);
                if ($class) {
                    if (!$firstLoop) {
                        $limitation .= ', ';
                    } else {
                        $firstLoop = false;
                    }
                    $className = $class->attribute('name');
                    $limitation .= "'" . $className . "'";
                }
            }
        } else {
            $limitation = ezpI18n::tr('kernel/shop', 'Any class');
        }
        $sectionRuleValues = eZDiscountSubRuleValue::fetchBySubRuleID($discountRuleID, 1);
        if ($sectionRuleValues != null) {
Exemplo n.º 30
0
            $deletedClassName = ezpI18n::tr('kernel/class', '(no classes)');
        }
        $deleteResult[] = array('groupName' => $GroupName, 'deletedClassName' => $deletedClassName);
        $groupsInfo[] = array('group_name' => $GroupName, 'class_list' => $groupClassesInfo);
    }
}
if ($http->hasPostVariable("ConfirmButton")) {
    foreach ($deleteIDArray as $deleteID) {
        eZContentClassGroup::removeSelected($deleteID);
        eZContentClassClassGroup::removeGroupMembers($deleteID);
        foreach ($deleteClassIDList as $deleteClassID) {
            $deleteClass = eZContentClass::fetch($deleteClassID);
            if ($deleteClass) {
                $deleteClass->remove(true);
            }
            $deleteClass = eZContentClass::fetch($deleteClassID, true, eZContentClass::VERSION_STATUS_TEMPORARY);
            if ($deleteClass) {
                $deleteClass->remove(true);
            }
        }
    }
    $Module->redirectTo('/class/grouplist/');
}
if ($http->hasPostVariable("CancelButton")) {
    $Module->redirectTo('/class/grouplist/');
}
$Module->setTitle(ezpI18n::tr('kernel/class', 'Remove class groups') . ' ' . $GroupName);
$tpl = eZTemplate::factory();
$tpl->setVariable("DeleteResult", $deleteResult);
$tpl->setVariable("module", $Module);
$tpl->setVariable("groups_info", $groupsInfo);