function execute($process, $event)
 {
     // get object being published
     $parameters = $process->attribute('parameter_list');
     $objectID = $parameters['object_id'];
     eZDebug::writeDebug('Update object state for object: ' . $objectID);
     $object = eZContentObject::fetch($objectID);
     $state_before = $event->attribute('state_before');
     $state_after = $event->attribute('state_after');
     if ($object == null) {
         eZDebug::writeError('Update object state failed for inexisting object: ' . $objectID, __METHOD__);
         return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     if ($state_before == null || $state_after == null) {
         eZDebug::writeError('Update object state failed: badly configured states', __METHOD__);
         return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     $currentStateIDArray = $object->attribute('state_id_array');
     if (in_array($state_before->attribute('id'), $currentStateIDArray)) {
         $canAssignStateIDList = $object->attribute('allowed_assign_state_id_list');
         if (!in_array($state_after->attribute('id'), $canAssignStateIDList)) {
             eZDebug::writeWarning("Not enough rights to assign state to object {$objectID}: " . $state_after->attribute('id'), __METHOD__);
         } else {
             eZDebug::writeDebug('Changing object state from ' . $state_before->attribute('name') . ' to ' . $state_after->attribute('name'), __METHOD__);
             if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) {
                 $operationResult = eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $objectID, 'state_id_list' => array($state_after->attribute('id'))));
             } else {
                 eZContentOperationCollection::updateObjectState($objectID, array($state_after->attribute('id')));
             }
         }
     }
     return eZWorkflowType::STATUS_ACCEPTED;
 }
 function runOperation(&$node)
 {
     $object = $node->attribute('object');
     $object_id = $object->attribute('id');
     $objectLocales = $object->attribute('available_languages');
     // If the alternative locale does not exist for object, create it
     if (!in_array($this->altLocale, $objectLocales)) {
         // The only translation is in locate to be removed - create a version in another locale first.
         echo "Copying the single translation in " . $this->remLocale . " to " . $this->altLocale . " so former could be removed.\n";
         $newVersion = $object->createNewVersionIn($this->altLocale, $this->remLocale, false, true, eZContentObjectVersion::STATUS_DRAFT);
         $publishResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $object_id, 'version' => $newVersion->attribute('version')));
         eZContentObject::clearCache();
         $object = eZContentObject::fetch($object_id);
     }
     // Change objects main language to alternative language, if its current main language is to be removed.
     if ($object->attribute('initial_language_code') == $this->remLocale) {
         eZContentObject::clearCache();
         $object = eZContentObject::fetch($object_id);
         echo "Switching initial language to {$this->altLocale} so that " . $this->remLocale . " could be removed.\n";
         $updateResult = eZContentOperationCollection::updateInitialLanguage($object_id, $this->altLangID);
         $object->store();
         eZContentObject::clearCache();
         $object = eZContentObject::fetch($object_id);
     }
     // Now it should be safe to remove translation.
     return $object->removeTranslation($this->remLangID);
 }
 public function execute($process, $event)
 {
     $params = $process->attribute('parameter_list');
     $object_id = $params['object_id'];
     $object = eZContentObject::fetch($object_id);
     if (!is_object($object)) {
         eZDebug::writeError("Unable to fetch object: '{$object_id}'", __METHOD__);
         return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     // current parent node(s)
     $parentNodeIds = $object->attribute('parent_nodes');
     $checkedObjs = array();
     foreach ($parentNodeIds as $parentNodeId) {
         //eZDebug::writeDebug( "Checking parent node: " . $parentNodeId, __METHOD__ );
         $parentNode = eZContentObjectTreeNode::fetch($parentNodeId);
         $parentObj = $parentNode->attribute('object');
         if (!in_array($parentObj->attribute('id'), $checkedObjs)) {
             //eZDebug::writeDebug( "Checking all nodes of parent obj: " . $parentObj->attribute( 'id' ), __METHOD__ );
             foreach ($parentObj->attribute('assigned_nodes') as $node) {
                 if (!in_array($node->attribute('node_id'), $parentNodeIds)) {
                     //eZDebug::writeDebug( "Found a node which is not parent of current obj: " . $node->attribute( 'node_id' ), __METHOD__ );
                     // the current obj has no node which is children of the given node of one of its parent objects
                     $operationResult = eZOperationHandler::execute('content', 'addlocation', array('node_id' => $object->attribute('main_node_id'), 'object_id' => $object->attribute('id'), 'select_node_id_array' => array($node->attribute('node_id'))), null, true);
                     if ($operationResult == null || $operationResult['status'] != true) {
                         eZDebug::writeError("Unable to add new location to object: " . $object->attribute('id'), __METHOD__);
                     }
                 } else {
                     //eZDebug::writeDebug( "Found a node which is already parent of current obj: " . $node->attribute( 'node_id' ), __METHOD__ );
                 }
             }
         }
         $checkedObjs[] = $parentObj->attribute('id');
     }
     return eZWorkflowType::STATUS_ACCEPTED;
 }
示例#4
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;
 }
function sectionEditActionCheck( $module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage )
{
    if ( $module->isCurrentAction( 'SectionEdit' ) )
    {
        $http = eZHTTPTool::instance();
        if ( $http->hasPostVariable( 'SelectedSectionId' ) )
        {
            $selectedSectionID = (int) $http->postVariable( 'SelectedSectionId' );
            $selectedSection = eZSection::fetch( $selectedSectionID );
            if ( is_object( $selectedSection ) )
            {
                $currentUser = eZUser::currentUser();
                if ( $currentUser->canAssignSectionToObject( $selectedSectionID, $object ) )
                {
                    $db = eZDB::instance();
                    $db->begin();
                    $assignedNodes = $object->attribute( 'assigned_nodes' );
                    if ( count( $assignedNodes ) > 0 )
                    {
                        foreach ( $assignedNodes as $node )
                        {
                            if ( eZOperationHandler::operationIsAvailable( 'content_updatesection' ) )
                            {
                                $operationResult = eZOperationHandler::execute( 'content',
                                                                                'updatesection',
                                                                                array( 'node_id'             => $node->attribute( 'node_id' ),
                                                                                       'selected_section_id' => $selectedSectionID ),
                                                                                null,
                                                                                true );

                            }
                            else
                            {
                                eZContentOperationCollection::updateSection( $node->attribute( 'node_id' ), $selectedSectionID );
                            }
                        }
                    }
                    else
                    {
                        // If there are no assigned nodes we should update db for the current object.
                        $objectID = $object->attribute( 'id' );
                        $db->query( "UPDATE ezcontentobject SET section_id='$selectedSectionID' WHERE id = '$objectID'" );
                        $db->query( "UPDATE ezsearch_object_word_link SET section_id='$selectedSectionID' WHERE  contentobject_id = '$objectID'" );
                    }
                    $object->expireAllViewCache();
                    $db->commit();
                }
                else
                {
                    eZDebug::writeError( "You do not have permissions to assign the section <" . $selectedSection->attribute( 'name' ) .
                                         "> to the object <" . $object->attribute( 'name' ) . ">." );
                }
                $module->redirectToView( 'edit', array( $object->attribute( 'id' ), $editVersion, $editLanguage, $fromLanguage ) );
            }
        }
    }
}
 function runOperation(&$node)
 {
     if (eZOperationHandler::operationIsAvailable('content_updatealwaysavailable')) {
         $operationResult = eZOperationHandler::execute('content', 'updatealwaysavailable', array('object_id' => $node->attribute('contentobject_id'), 'new_always_available' => $this->available, 'node_id' => $node->attribute('node_id')));
     } else {
         eZContentOperationCollection::updateAlwaysAvailable($node->attribute('contentobject_id'), $this->available);
     }
     return true;
 }
示例#7
0
 static function execute($moduleName, $operationName, $operationParameters, $lastTriggerName = null, $useTriggers = true)
 {
     $moduleOperationInfo = eZOperationHandler::moduleOperationInfo($moduleName, $useTriggers);
     if (!$moduleOperationInfo->isValid()) {
         eZDebug::writeError("Cannot execute operation '{$operationName}' in module '{$moduleName}', no valid data", __METHOD__);
         return null;
     }
     return $moduleOperationInfo->execute($operationName, $operationParameters, $lastTriggerName);
 }
 public function execute($process, $event)
 {
     $parameters = $process->attribute('parameter_list');
     try {
         // WORKFLOW HERE
         if ($parameters['trigger_name'] == 'post_updateobjectstate') {
             $objectId = $parameters['object_id'];
             $object = eZContentObject::fetch($objectId);
             $parentStateIDArray = $object->stateIDArray();
             $fetch_parameters = array('parent_node_id' => $object->mainNodeID());
             $childs = eZFunctionHandler::execute('content', 'list', $fetch_parameters);
             $stateGroups = eZINI::instance('patbase.ini')->variable('ChildsPropagationState', 'StateGroupID');
             foreach ($childs as $child) {
                 $childStateIDArray = $child->object()->stateIDArray();
                 $stateChanged = FALSE;
                 foreach ($stateGroups as $stateGroup) {
                     if ($childStateIDArray[$stateGroup] !== $parentStateIDArray[$stateGroup]) {
                         $stateChanged = TRUE;
                         $childStateIDArray[$stateGroup] = $parentStateIDArray[$stateGroup];
                     }
                 }
                 if ($stateChanged) {
                     eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $child->ContentObjectID, 'state_id_list' => $childStateIDArray));
                 }
             }
         } else {
             if ($parameters['trigger_name'] == 'post_publish') {
                 if ($parameters['version'] === '1') {
                     $objectId = $parameters['object_id'];
                     $object = eZContentObject::fetch($objectId);
                     $objectStateIDArray = $object->stateIDArray();
                     $fetch_parameters = array('node_id' => $object->mainParentNodeID());
                     $parent = eZFunctionHandler::execute('content', 'node', $fetch_parameters);
                     $stateGroups = eZINI::instance('patbase.ini')->variable('ChildsPropagationState', 'StateGroupID');
                     $parentStateIDArray = $parent->object()->stateIDArray();
                     $stateChanged = FALSE;
                     foreach ($stateGroups as $stateGroup) {
                         if ($objectStateIDArray[$stateGroup] !== $parentStateIDArray[$stateGroup]) {
                             $stateChanged = TRUE;
                             $objectStateIDArray[$stateGroup] = $parentStateIDArray[$stateGroup];
                         }
                     }
                     if ($stateChanged) {
                         eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $objectId, 'state_id_list' => $objectStateIDArray));
                     }
                 }
             }
         }
         //
         return eZWorkflowType::STATUS_ACCEPTED;
     } catch (Exception $e) {
         eZDebug::writeError($e->getMessage(), __METHOD__);
         return eZWorkflowType::STATUS_REJECTED;
     }
 }
示例#9
0
 function execute($process, $event)
 {
     //execute user register operation
     $parameterList = $process->attribute('parameter_list');
     $objectID = $parameterList['object_id'];
     $object = eZContentObject::fetch($objectID);
     // @todo: improve the possible performance.
     if ($object->attribute('class_identifier') == 'user') {
         $result = eZOperationHandler::execute('user', 'register', array('user_id' => $objectID));
         return $result['status'];
     }
 }
 /**
  * Test scenario for issue #15883: Enable only before (or after) operation doesn't work (patch)
  *
  * Test outline
  * -------------
  * 1. Enable a partial operation in workflow.ini (before_content_read)
  * 2. Call eZOperationHandler::isOperationAvailable( 'content_read' )
  *
  * @result: false
  * @expected: true
  * @link http://issues.ez.no/15883
  * @group issue_15883
  */
 function testEnablingPartialOperation()
 {
     $wfINI = eZINI::instance('workflow.ini');
     // before
     $wfINI->setVariable('OperationSettings', 'AvailableOperationList', array('before_content_read'));
     $this->assertTrue(eZOperationHandler::operationIsAvailable('content_read'));
     // after
     $wfINI->setVariable('OperationSettings', 'AvailableOperationList', array('after_content_read'));
     $this->assertTrue(eZOperationHandler::operationIsAvailable('content_read'));
     // complete
     $wfINI->setVariable('OperationSettings', 'AvailableOperationList', array('content_read'));
     $this->assertTrue(eZOperationHandler::operationIsAvailable('content_read'));
     // unknown one
     $this->assertFalse(eZOperationHandler::operationIsAvailable('foo_bar'));
 }
示例#11
0
function stateEditActionCheck($module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage)
{
    if ($module->isCurrentAction('StateEdit')) {
        $http = eZHTTPTool::instance();
        if ($http->hasPostVariable('SelectedStateIDList')) {
            $selectedStateIDList = $http->postVariable('SelectedStateIDList');
            $objectID = $object->attribute('id');
            if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) {
                $operationResult = eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $objectID, 'state_id_list' => $selectedStateIDList));
            } else {
                eZContentOperationCollection::updateObjectState($objectID, $selectedStateIDList);
            }
        }
    }
}
 protected function createNewVersionWithImage(eZContentObject $object)
 {
     $version = $object->createNewVersion(false, true, false, false, eZContentObjectVersion::STATUS_INTERNAL_DRAFT);
     $contentObjectAttributes = $version->contentObjectAttributes();
     foreach ($contentObjectAttributes as $contentObjectAttribute) {
         if ($contentObjectAttribute->attribute('contentclass_attribute_identifier') != 'image') {
             continue;
         }
         $contentObjectAttribute->fromString(self::IMAGE_FILE_PATH);
         $contentObjectAttribute->store();
         break;
     }
     $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $object->attribute('id'), 'version' => $version->attribute('version')));
     self::assertEquals(1, $operationResult['status']);
     return $this->forceFetchContentObject($object->attribute('id'));
 }
 function runOperation(&$node)
 {
     $object = $node->attribute('object');
     $object_id = $object->attribute('id');
     $objectLocales = $object->attribute('available_languages');
     // If the new locale does not exist for object, create it
     if (!in_array($this->newLocale, $objectLocales)) {
         // Create a new version of the original in another locale.
         $cli = eZCLI::instance();
         $cli->output("Copying the single translation in {$this->orgLocale} to {$this->newLocale}");
         $newVersion = $object->createNewVersionIn($this->newLocale, $this->orgLocale, false, true, eZContentObjectVersion::STATUS_DRAFT);
         $publishResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $object_id, 'version' => $newVersion->attribute('version')));
         eZContentObject::clearCache();
         $object = eZContentObject::fetch($object_id);
     }
     return true;
 }
示例#14
0
文件: index.php 项目: truffo/eep
 public function create($parentNodeId, $classIdentifier, $dataSet)
 {
     $result = array("result" => false);
     $parentNode = eZContentObjectTreeNode::fetch($parentNodeId);
     if (!is_object($parentNode)) {
         throw new Exception("createObject::create(): Failed to locate parent node. id='" . $parentNodeId . "'");
     }
     $contentClass = eZContentClass::fetchByIdentifier($classIdentifier);
     if (!$contentClass) {
         throw new Exception("Failed to instantiate content class [" . $classIdentifier . "]");
     }
     // take care over clustered setups
     $db = eZDB::instance();
     $db->begin();
     $contentObject = $contentClass->instantiate(false, 0, false);
     $dataMap = $contentObject->attribute('data_map');
     foreach ($dataSet as $key => $value) {
         // attributes are lower case
         $key = strtolower($key);
         // if the field exists in the object, write to it
         if (isset($dataMap[$key])) {
             $dataMap[$key]->fromString($value);
             $dataMap[$key]->store();
         }
     }
     $contentObject->store();
     $result["objectid"] = $contentObject->attribute('id');
     $nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => 1, 'parent_node' => $parentNodeId, 'is_main' => 1));
     if (!$nodeAssignment) {
         throw new Exception("createObject::create(): Failed to create matching node for object of class '" . $classIdentifier . "'");
     }
     $nodeAssignment->store();
     $obj_version = $contentObject->currentVersion();
     $publish = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObject->attribute('id'), 'version' => $obj_version->attribute('version')));
     $db->commit();
     $result["publish"] = $publish;
     $result["parentnodeid"] = $parentNodeId;
     $result["mainnodeid"] = $contentObject->mainNodeID();
     $result["contentclass"] = $classIdentifier;
     $result["contentobjectid"] = $contentObject->attribute('id');
     $result["result"] = true;
     return $result;
 }
示例#15
0
文件: copy.php 项目: legende91/ez
function copyObject($Module, $object, $allVersions, $newParentNodeID)
{
    if (!$newParentNodeID) {
        return $Module->redirectToView('view', array('full', 2));
    }
    // check if we can create node under the specified parent node
    if (($newParentNode = eZContentObjectTreeNode::fetch($newParentNodeID)) === null) {
        return $Module->redirectToView('view', array('full', 2));
    }
    $classID = $object->attribute('contentclass_id');
    if (!$newParentNode->checkAccess('create', $classID)) {
        $objectID = $object->attribute('id');
        eZDebug::writeError("Cannot copy object {$objectID} to node {$newParentNodeID}, " . "the current user does not have create permission for class ID {$classID}", 'content/copy');
        return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
    }
    $db = eZDB::instance();
    $db->begin();
    $newObject = $object->copy($allVersions);
    // We should reset section that will be updated in updateSectionID().
    // If sectionID is 0 then the object has been newly created
    $newObject->setAttribute('section_id', 0);
    $newObject->store();
    $curVersion = $newObject->attribute('current_version');
    $curVersionObject = $newObject->attribute('current');
    $newObjAssignments = $curVersionObject->attribute('node_assignments');
    unset($curVersionObject);
    // remove old node assignments
    foreach ($newObjAssignments as $assignment) {
        $assignment->purge();
    }
    // and create a new one
    $nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $newObject->attribute('id'), 'contentobject_version' => $curVersion, 'parent_node' => $newParentNodeID, 'is_main' => 1));
    $nodeAssignment->store();
    // publish the newly created object
    eZOperationHandler::execute('content', 'publish', array('object_id' => $newObject->attribute('id'), 'version' => $curVersion));
    // Update "is_invisible" attribute for the newly created node.
    $newNode = $newObject->attribute('main_node');
    eZContentObjectTreeNode::updateNodeVisibility($newNode, $newParentNode);
    $db->commit();
    return $Module->redirectToView('view', array('full', $newParentNodeID));
}
    /**
     * Updating priority sorting for given node
     *
     * @param mixed $args
     * @return array
     */
    public static function updatePriority( $args )
    {
        $http = eZHTTPTool::instance();

        if ( !$http->hasPostVariable('ContentNodeID')
                || !$http->hasPostVariable('PriorityID')
                    || !$http->hasPostVariable('Priority') )
        {
            return array();
        }

        $contentNodeID = $http->postVariable('ContentNodeID');
        $priorityArray = $http->postVariable('Priority');
        $priorityIDArray = $http->postVariable('PriorityID');

        $contentNode = eZContentObjectTreeNode::fetch( $contentNodeID );
        if ( !$contentNode->attribute( 'can_edit' ) )
        {
            eZDebug::writeError( 'Current user can not update the priorities because he has no permissions to edit the node' );
            return array();
        }

        if ( eZOperationHandler::operationIsAvailable( 'content_updatepriority' ) )
        {
            $operationResult = eZOperationHandler::execute( 'content', 'updatepriority',
                                                             array( 'node_id' => $contentNodeID,
                                                                    'priority' => $priorityArray,
                                                                    'priority_id' => $priorityIDArray ), null, true );
        }
        else
        {
            eZContentOperationCollection::updatePriority( $contentNodeID, $priorityArray, $priorityIDArray );
        }

        if ( $http->hasPostVariable( 'ContentObjectID' ) )
        {
            $objectID = $http->postVariable( 'ContentObjectID' );
            eZContentCacheManager::clearContentCache( $objectID );
        }
    }
 function createObject($classIdentifier, $parentNodeID, $name)
 {
     $user = eZUser::currentUser();
     $Class = eZContentClass::fetchByIdentifier($classIdentifier);
     if (!$Class) {
         eZDebug::writeError("No class with identifier {$classIdentifier}", "classCreation");
         return false;
     }
     $contentObject = $Class->instantiate($user->attribute('contentobject_id'));
     $nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => $contentObject->attribute('current_version'), 'parent_node' => $parentNodeID, 'is_main' => 1));
     $nodeAssignment->store();
     $version = $contentObject->version(1);
     $version->setAttribute('modified', eZDateTime::currentTimeStamp());
     $version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
     $version->store();
     $contentObjectID = $contentObject->attribute('id');
     $attributes = $contentObject->attribute('contentobject_attributes');
     $attributes[0]->fromString($name);
     $attributes[0]->store();
     $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => 1));
     return true;
 }
 * @subpackage content
 */
/**
 * This script, given a queued contentobject_id + version, will resume the publishing operation on it
 * @package kernel
 * @subpackage content
 */
require 'autoload.php';
$pid = getmypid();
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => 'Asynchronous publishing handler, not meant to be used directly', 'use-session' => false, 'use-modules' => true, 'use-extensions' => true));
$script->startup();
$argumentConfig = '[OBJECT_ID] [VERSION_ID]';
$optionsConfig = '';
$options = $script->getOptions($optionsConfig, $argumentConfig);
$script->initialize();
if (count($options['arguments']) != 2) {
    eZLog::write("Wrong arguments count", 'publishqueue.log');
    $script->shutdown(1, 'wrong argument count');
}
$objectId = $options['arguments'][0];
$version = $options['arguments'][1];
eZLog::write("[{$pid}] Publishing #{$objectId}/{$version}", 'async.log');
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $objectId, 'version' => $version));
if (isset($operationResult['status']) && $operationResult['status'] == eZModuleOperationInfo::STATUS_CONTINUE) {
    eZLog::write("[{$pid}] Published #{$objectId}/{$version}", 'async.log');
    $script->shutdown(0);
} else {
    eZLog::write("[{$pid}] Operation result for #{$objectId}/{$version}: " . print_r($operationResult, true), 'async.log');
    $script->shutdown(2, 'Publishing did not complete');
}
示例#19
0
     }
     // Then make sure we have node id parameter
     if (!$http->hasPostVariable('NodeID')) {
         eZDebug::writeError('Create/ Remove NodeFeed: missing node ID parameter.', 'content-action-handler');
         return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
     }
     $nodeID = $http->postVariable('NodeID');
     if ($http->hasPostVariable('CreateNodeFeed')) {
         if (eZOperationHandler::operationIsAvailable('content_createnodefeed')) {
             $operationResult = eZOperationHandler::execute('content', 'createnodefeed', array('node_id' => $nodeID), null, true);
         } else {
             $operationResult = eZContentOperationCollection::createFeedForNode($nodeID);
         }
     } else {
         if (eZOperationHandler::operationIsAvailable('content_removenodefeed')) {
             $operationResult = eZOperationHandler::execute('content', 'removenodefeed', array('node_id' => $nodeID), null, true);
         } else {
             $operationResult = eZContentOperationCollection::removeFeedForNode($nodeID);
         }
     }
     if (!isset($operationResult['status']) || !$operationResult['status']) {
         return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
     }
     return $module->redirectToView('view', array('full', $nodeID));
 } else {
     // Check if there are any custom actions to handle
     $customActions = eZINI::instance('datatype.ini')->variable('ViewSettings', 'CustomActionMap');
     foreach ($customActions as $customActionName => $customActionUrl) {
         if ($http->hasPostVariable($customActionName)) {
             if (strpos($customActionUrl, '/') !== false) {
                 list($customActionModuleName, $customActionViewName) = explode('/', $customActionUrl);
示例#20
0
// Check if the object exists on disc
if (!eZContentObject::exists($ObjectID)) {
    return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
// Check if the user can read the object
$object = eZContentObject::fetch($ObjectID);
if (!$object->canRead()) {
    return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel', array('AccessList' => $object->accessList('read')));
}
// Check if the object has a price datatype, if not it cannot be used in the basket
$error = $basket->canAddProduct($object);
if ($error !== eZError::SHOP_OK) {
    return $Module->handleError($error, 'shop');
}
$OptionList = $http->sessionVariable("AddToBasket_OptionList_" . $ObjectID);
$operationResult = eZOperationHandler::execute('shop', 'addtobasket', array('basket_id' => $basket->attribute('id'), 'object_id' => $ObjectID, 'quantity' => $quantity, 'option_list' => $OptionList));
switch ($operationResult['status']) {
    case eZModuleOperationInfo::STATUS_HALTED:
        if (isset($operationResult['redirect_url'])) {
            $module->redirectTo($operationResult['redirect_url']);
            return;
        } else {
            if (isset($operationResult['result'])) {
                $result = $operationResult['result'];
                $resultContent = false;
                if (is_array($result)) {
                    if (isset($result['content'])) {
                        $resultContent = $result['content'];
                    }
                    if (isset($result['path'])) {
                        $Result['path'] = $result['path'];
示例#21
0
    function checkContentActions( $module, $class, $object, $version, $contentObjectAttributes, $EditVersion, $EditLanguage, $FromLanguage, &$Result )
    {
        if ( $module->isCurrentAction( 'Preview' ) )
        {
            $module->redirectToView( 'versionview', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) );
            return eZModule::HOOK_STATUS_CANCEL_RUN;
        }

        if ( $module->isCurrentAction( 'Translate' ) )
        {
            $module->redirectToView( 'translate', array( $object->attribute( 'id' ), $EditVersion, $EditLanguage, $FromLanguage ) );
            return eZModule::HOOK_STATUS_CANCEL_RUN;
        }

        if ( $module->isCurrentAction( 'VersionEdit' ) )
        {
            if ( isset( $GLOBALS['eZRequestedURI'] ) and is_object( $GLOBALS['eZRequestedURI'] ) )
            {
                $uri = $GLOBALS['eZRequestedURI'];
                $uri = $uri->originalURIString();
                $http = eZHTTPTool::instance();
                $http->setSessionVariable( 'LastAccessesVersionURI', $uri );
            }
            $module->redirectToView( 'history', array( $object->attribute( 'id' ), $EditVersion, $EditLanguage ) );
            return eZModule::HOOK_STATUS_CANCEL_RUN;
        }

        if ( $module->isCurrentAction( 'EditLanguage' ) )
        {
            if ( $module->hasActionParameter( 'SelectedLanguage' ) )
            {
                $EditLanguage = $module->actionParameter( 'SelectedLanguage' );
                // We reset the from language to disable the translation look
                $FromLanguage = false;
                $module->redirectToView( 'edit', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) );
                return eZModule::HOOK_STATUS_CANCEL_RUN;
            }
        }

        if ( $module->isCurrentAction( 'TranslateLanguage' ) )
        {
            if ( $module->hasActionParameter( 'SelectedLanguage' ) )
            {
                $FromLanguage = $EditLanguage;
                $EditLanguage = $module->actionParameter( 'SelectedLanguage' );
                $module->redirectToView( 'edit', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) );
                return eZModule::HOOK_STATUS_CANCEL_RUN;
            }
        }

        if ( $module->isCurrentAction( 'FromLanguage' ) )
        {
            $FromLanguage = $module->actionParameter( 'FromLanguage' );
            $module->redirectToView( 'edit', array( $object->attribute('id'), $EditVersion, $EditLanguage, $FromLanguage ) );
            return eZModule::HOOK_STATUS_CANCEL_RUN;
        }

        if ( $module->isCurrentAction( 'Discard' ) )
        {
            $http = eZHTTPTool::instance();
            $objectID = $object->attribute( 'id' );
            $discardConfirm = true;
            if ( $http->hasPostVariable( 'DiscardConfirm' ) )
                $discardConfirm = $http->postVariable( 'DiscardConfirm' );
            $http->setSessionVariable( 'DiscardObjectID', $objectID );
            $http->setSessionVariable( 'DiscardObjectVersion', $EditVersion );
            $http->setSessionVariable( 'DiscardObjectLanguage', $EditLanguage );
            $http->setSessionVariable( 'DiscardConfirm', $discardConfirm );
            $module->redirectTo( $module->functionURI( 'removeeditversion' ) . '/' );
            return eZModule::HOOK_STATUS_CANCEL_RUN;
        }

        // helper function which computes the redirect after
        // publishing and final store of a draft.
        function computeRedirect( $module, $object, $version, $EditLanguage = false )
        {
            $http = eZHTTPTool::instance();

            $node = $object->mainNode();

            if ( $http->hasSessionVariable( 'RedirectIfDiscarded' ) )
            {
                $http->removeSessionVariable( 'RedirectIfDiscarded' );
            }

            $hasRedirected = false;
            if ( $http->hasSessionVariable( 'ParentObject' ) && $http->sessionVariable( 'NewObjectID' ) == $object->attribute( 'id' ) )
            {
                $parentArray = $http->sessionVariable( 'ParentObject' );
                $parentURL = $module->redirectionURI( 'content', 'edit', $parentArray );
                $parentObject = eZContentObject::fetch( $parentArray[0] );
                $db = eZDB::instance();
                $db->begin();
                $parentObject->addContentObjectRelation( $object->attribute( 'id' ), $parentArray[1] );
                $db->commit();
                $http->removeSessionVariable( 'ParentObject' );
                $http->removeSessionVariable( 'NewObjectID' );
                $module->redirectTo( $parentURL );
                $hasRedirected = true;
            }
            if ( $http->hasSessionVariable( 'RedirectURIAfterPublish' ) && !$hasRedirected )
            {
                $uri = $http->sessionVariable( 'RedirectURIAfterPublish' );
                $http->removeSessionVariable( 'RedirectURIAfterPublish' );
                $module->redirectTo( $uri );
                $hasRedirected = true;
            }
            if ( $http->hasPostVariable( 'RedirectURIAfterPublish' )  && !$hasRedirected )
            {
                $uri = $http->postVariable( 'RedirectURIAfterPublish' );
                $module->redirectTo( $uri );
                $hasRedirected = true;
            }
            if ( $http->hasPostVariable( "BackToEdit" ) && $http->postVariable( "BackToEdit" ) )
            {
                $uri = $module->redirectionURI( 'content', 'edit', array( $object->attribute( 'id'), 'f', $EditLanguage ) );
                $module->redirectTo( $uri );
                eZDebug::writeDebug( $uri, "uri  " .  $object->attribute( 'id')  );
                $hasRedirected = true;
            }

            if ( !$hasRedirected )
            {
                if ( $http->hasPostVariable( 'RedirectURI' ) )
                {
                    $uri = $http->postVariable( 'RedirectURI' );
                    $module->redirectTo( $uri );
                }
                else if ( $node !== null )
                {
                    $parentNode = $node->attribute( 'parent_node_id' );
                    if ( $parentNode == 1 )
                    {
                        $parentNode = $node->attribute( 'node_id' );
                    }
                    $module->redirectToView( 'view', array( 'full', $parentNode ) );
                }
                else
                {
                    $module->redirectToView( 'view', array( 'full', $version->attribute( 'main_parent_node_id' ) ) );
                }
            }

        }

        if( $module->isCurrentAction( 'StoreExit' ) )
        {
            computeRedirect( $module, $object, $version, $EditLanguage );
            return eZModule::HOOK_STATUS_CANCEL_RUN;
        }

        if ( $module->isCurrentAction( 'Publish' ) )
        {
            // Checking the source and destination language from the url,
            // if they are the same no confirmation is needed.
            if ( $EditLanguage != $FromLanguage )
            {
                $conflictingVersions = $version->hasConflicts( $EditLanguage );
                if ( $conflictingVersions )
                {
                    $tpl = eZTemplate::factory();
                    $res = eZTemplateDesignResource::instance();
                    $res->setKeys( array( array( 'object', $object->attribute( 'id' ) ),
                                        array( 'remote_id', $object->attribute( 'remote_id' ) ),
                                        array( 'class', $class->attribute( 'id' ) ),
                                        array( 'class_identifier', $class->attribute( 'identifier' ) ),
                                        array( 'class_group', $class->attribute( 'match_ingroup_id_list' ) ) ) );

                    $tpl->setVariable( 'edit_language', $EditLanguage );
                    $tpl->setVariable( 'current_version', $version->attribute( 'version' ) );
                    $tpl->setVariable( 'object', $object );
                    $tpl->setVariable( 'draft_versions', $conflictingVersions );

                    $Result = array();
                    $Result['content'] = $tpl->fetch( 'design:content/edit_conflict.tpl' );
                    return eZModule::HOOK_STATUS_CANCEL_RUN;
                }
            }

            eZDebug::accumulatorStart( 'publish', '', 'publish' );
            $oldObjectName = $object->name();

            $behaviour = new ezpContentPublishingBehaviour();
            $behaviour->isTemporary = true;
            $behaviour->disableAsynchronousPublishing = false;
            ezpContentPublishingBehaviour::setBehaviour( $behaviour );

            $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $object->attribute( 'id' ),
                                                                                         'version' => $version->attribute( 'version' ) ) );
            eZDebug::accumulatorStop( 'publish' );

            if ( ( array_key_exists( 'status', $operationResult ) && $operationResult['status'] != eZModuleOperationInfo::STATUS_CONTINUE ) )
            {
                eZDebug::writeDebug( $operationResult, __FILE__ );
                switch( $operationResult['status'] )
                {
                    case eZModuleOperationInfo::STATUS_REPEAT:
                    {
                        eZContentOperationCollection::setVersionStatus( $object->attribute( 'id' ),
                            $version->attribute( 'version' ), eZContentObjectVersion::STATUS_REPEAT );
                    }
                    case eZModuleOperationInfo::STATUS_HALTED:
                    {
                        if ( isset( $operationResult['redirect_url'] ) )
                        {
                            $module->redirectTo( $operationResult['redirect_url'] );
                            return;
                        }
                        else if ( isset( $operationResult['result'] ) )
                        {
                            $result = $operationResult['result'];
                            $resultContent = false;
                            if ( is_array( $result ) )
                            {
                                if ( isset( $result['content'] ) )
                                {
                                    $resultContent = $result['content'];
                                }
                                if ( isset( $result['path'] ) )
                                {
                                    $Result['path'] = $result['path'];
                                }
                            }
                            else
                            {
                                $resultContent = $result;
                            }
                            // Temporary fix to make approval workflow work with edit.
                            if ( strpos( $resultContent, 'Deffered to cron' ) === 0 )
                            {
                                $Result = null;
                            }
                            else
                            {
                                $Result['content'] = $resultContent;
                            }
                        }
                    }break;
                    case eZModuleOperationInfo::STATUS_CANCELLED:
                    {
                        $Result = array();
                        $Result['content'] = "Content publish cancelled<br/>";
                    }
                }

                /* If we already have a correct module result
                 * we don't need to continue module execution.
                 */
                if ( is_array( $Result ) )
                    return eZModule::HOOK_STATUS_CANCEL_RUN;
            }

            // update content object attributes array by refetching them from database
            $object = eZContentObject::fetch( $object->attribute( 'id' ) );
            $contentObjectAttributes = $object->attribute( 'contentobject_attributes' );

            // set chosen hidden/invisible attributes for object nodes
            $http          = eZHTTPTool::instance();
            $assignedNodes = $object->assignedNodes( true );
            foreach ( $assignedNodes as $node )
            {
                $nodeID               = $node->attribute( 'node_id' );
                $parentNodeID         = $node->attribute( 'parent_node_id' );
                $updateNodeVisibility =  false;
                $postVarName          = "FutureNodeHiddenState_$parentNodeID";

                if ( !$http->hasPostVariable( $postVarName ) )
                    $updateNodeVisibility = true;
                else
                {
                    $futureNodeHiddenState = $http->postVariable( $postVarName );
                    $db = eZDB::instance();
                    $db->begin();
                    if ( $futureNodeHiddenState == 'hidden' )
                        eZContentObjectTreeNode::hideSubTree( $node );
                    else if ( $futureNodeHiddenState == 'visible' )
                        eZContentObjectTreeNode::unhideSubTree( $node );
                    else if ( $futureNodeHiddenState == 'unchanged' )
                        $updateNodeVisibility = true;
                    else
                        eZDebug::writeWarning( "Unknown value for the future node hidden state: '$futureNodeHiddenState'" );
                    $db->commit();
                }

                if ( $updateNodeVisibility )
                {
                    // this might be redundant
                    $db = eZDB::instance();
                    $db->begin();
                    $parentNode = eZContentObjectTreeNode::fetch( $parentNodeID );
                    eZContentObjectTreeNode::updateNodeVisibility( $node, $parentNode, /* $recursive = */ false );
                    $db->commit();
                    unset( $node, $parentNode );
                }
            }
            unset( $assignedNodes );

            $object = eZContentObject::fetch( $object->attribute( 'id' ) );

            $newObjectName = $object->name();

            $http = eZHTTPTool::instance();

            computeRedirect( $module, $object, $version, $EditLanguage );
            // we have set redirection URI for module so we don't need to continue module execution
            return eZModule::HOOK_STATUS_CANCEL_RUN;
        }
    }
 /**
  *  publish the object
  */
 public static function publishUserContentObject($userID)
 {
     $object = eZContentObject::fetch($userID);
     if ($object->attribute('current_version') !== '1') {
         eZDebug::writeError('Current version is wrong for the user object. User ID: ' . $userID, 'user/register');
         return array('status' => eZModuleOperationInfo::STATUS_CANCELLED);
     }
     eZDebugSetting::writeNotice('kernel-user', 'publishing user object', 'user register');
     // if the object is already published, continue the operation
     if ($object->attribute('status')) {
         eZDebugSetting::writeNotice('kernel-user', 'User object publish is published.', 'user register');
         return array('status' => eZModuleOperationInfo::STATUS_CONTINUE);
     }
     $result = eZOperationHandler::execute('content', 'publish', array('object_id' => $userID, 'version' => 1));
     if ($result['status'] === eZModuleOperationInfo::STATUS_HALTED) {
         eZDebugSetting::writeNotice('kernel-user', 'User object publish is in pending.', 'user register');
         return array('status' => eZModuleOperationInfo::STATUS_HALTED);
     }
     return $result;
 }
示例#23
0
     $newAlwaysAvailable = $module->hasActionParameter('AlwaysAvailable');
     if (eZOperationHandler::operationIsAvailable('content_updatealwaysavailable')) {
         $operationResult = eZOperationHandler::execute('content', 'updatealwaysavailable', array('object_id' => $objectID, 'new_always_available' => $newAlwaysAvailable, 'node_id' => $nodeID));
     } else {
         eZContentOperationCollection::updateAlwaysAvailable($objectID, $newAlwaysAvailable);
     }
     return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
 } else {
     if ($module->isCurrentAction('RemoveTranslation')) {
         if (!$module->hasActionParameter('LanguageID')) {
             return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
         }
         $languageIDArray = $module->actionParameter('LanguageID');
         if ($module->hasActionParameter('ConfirmRemoval') && $module->actionParameter('ConfirmRemoval')) {
             if (eZOperationHandler::operationIsAvailable('content_removetranslation')) {
                 $operationResult = eZOperationHandler::execute('content', 'removetranslation', array('object_id' => $objectID, 'language_id_list' => $languageIDArray, 'node_id' => $nodeID));
             } else {
                 eZContentOperationCollection::removeTranslation($objectID, $languageIDArray);
             }
             return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
         }
         $languages = array();
         foreach ($languageIDArray as $languageID) {
             $language = eZContentLanguage::fetch($languageID);
             if ($language) {
                 $languages[] = $language;
             }
         }
         if (!$languages) {
             return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
         }
 function initializePackage($siteType, &$accessMap, $charset, &$extraLanguageCodes, &$allLanguages, &$primaryLanguage, &$admin, &$resultArray)
 {
     // Time limit #3:
     // We set the time limit to 5 minutes to ensure we have enough time
     // to initialize the site. However we only set if the current limit
     // is too small
     $maxTime = ini_get('max_execution_time');
     if ($maxTime != 0 and $maxTime < 5 * 60) {
         @set_time_limit(5 * 60);
     }
     switch ($siteType['access_type']) {
         case 'port':
             $userSiteaccessName = $siteType['identifier'] . '_' . 'user';
             $adminSiteaccessName = $siteType['identifier'] . '_' . 'admin';
             $accessMap['port'][$siteType['access_type_value']] = $userSiteaccessName;
             $accessMap['port'][$siteType['admin_access_type_value']] = $adminSiteaccessName;
             break;
         case 'hostname':
             $userSiteaccessName = $siteType['identifier'] . '_' . 'user';
             $adminSiteaccessName = $siteType['identifier'] . '_' . 'admin';
             $accessMap['hostname'][$siteType['access_type_value']] = $userSiteaccessName;
             $accessMap['hostname'][$siteType['admin_access_type_value']] = $adminSiteaccessName;
             break;
         case 'url':
         default:
             $userSiteaccessName = $siteType['access_type_value'];
             $adminSiteaccessName = $siteType['admin_access_type_value'];
             $accessMap['url'][$siteType['access_type_value']] = $userSiteaccessName;
             $accessMap['url'][$siteType['admin_access_type_value']] = $adminSiteaccessName;
             break;
     }
     $accessMap['accesses'][] = $userSiteaccessName;
     $accessMap['accesses'][] = $adminSiteaccessName;
     $accessMap['sites'][] = $userSiteaccessName;
     $userDesignName = $siteType['identifier'];
     $languageObjects = $allLanguages;
     $databaseMap = eZSetupDatabaseMap();
     $databaseInfo = $this->PersistenceList['database_info'];
     $databaseInfo['info'] = $databaseMap[$databaseInfo['type']];
     $dbServer = $databaseInfo['server'];
     $dbPort = $databaseInfo['port'];
     //        $dbName = $databaseInfo['dbname'];
     $dbSocket = $databaseInfo['socket'];
     $dbUser = $databaseInfo['user'];
     $dbPwd = $databaseInfo['password'];
     $dbCharset = $charset;
     $dbDriver = $databaseInfo['info']['driver'];
     $dbName = $siteType['database'];
     $dbParameters = array('server' => $dbServer, 'port' => $dbPort, 'user' => $dbUser, 'password' => $dbPwd, 'socket' => $dbSocket, 'database' => $dbName, 'charset' => $dbCharset);
     $db = eZDB::instance($dbDriver, $dbParameters, true);
     if (!$db->isConnected()) {
         $resultArray['errors'][] = array('code' => 'EZSW-005', 'text' => "Failed connecting to database {$dbName}\n" . $db->errorMessage());
         return false;
     }
     eZDB::setInstance($db);
     $result = true;
     // Initialize the database by inserting schema and data
     if (!isset($siteType['existing_database'])) {
         $siteType['existing_database'] = false;
     }
     if ($siteType['existing_database'] == eZStepInstaller::DB_DATA_REMOVE) {
         eZDBTool::cleanup($db);
     }
     if ($siteType['existing_database'] != eZStepInstaller::DB_DATA_KEEP) {
         $result = true;
         $schemaArray = eZDbSchema::read('share/db_schema.dba', true);
         if (!$schemaArray) {
             $resultArray['errors'][] = array('code' => 'EZSW-001', 'message' => "Failed loading database schema file share/db_schema.dba");
             $result = false;
         }
         if ($result) {
             $result = true;
             $dataArray = eZDbSchema::read('share/db_data.dba', true);
             if (!$dataArray) {
                 $resultArray['errors'][] = array('code' => 'EZSW-002', 'text' => "Failed loading database data file share/db_data.dba");
                 $result = false;
             }
             if ($result) {
                 $schemaArray = array_merge($schemaArray, $dataArray);
                 $schemaArray['type'] = strtolower($db->databaseName());
                 $schemaArray['instance'] = $db;
                 $result = true;
                 $dbSchema = eZDbSchema::instance($schemaArray);
                 if (!$dbSchema) {
                     $resultArray['errors'][] = array('code' => 'EZSW-003', 'text' => "Failed loading " . $db->databaseName() . " schema handler");
                     $result = false;
                 }
                 if ($result) {
                     $result = true;
                     // This will insert the schema, then the data and
                     // run any sequence value correction SQL if required
                     $params = array('schema' => true, 'data' => true);
                     if ($db->databaseName() == 'mysql') {
                         $engines = $db->arrayQuery('SHOW ENGINES');
                         foreach ($engines as $engine) {
                             if ($engine['Engine'] == 'InnoDB' && in_array($engine['Support'], array('YES', 'DEFAULT'))) {
                                 $params['table_type'] = 'innodb';
                                 break;
                             }
                         }
                     }
                     if (!$dbSchema->insertSchema($params)) {
                         $resultArray['errors'][] = array('code' => 'EZSW-004', 'text' => "Failed inserting data to " . $db->databaseName() . "\n" . $db->errorMessage());
                         $result = false;
                     }
                 }
             }
         }
         if ($result) {
             // Inserting data from the dba-data files of the datatypes
             eZDataType::loadAndRegisterAllTypes();
             $registeredDataTypes = eZDataType::registeredDataTypes();
             foreach ($registeredDataTypes as $dataType) {
                 if (!$dataType->importDBDataFromDBAFile()) {
                     $resultArray['errors'][] = array('code' => 'EZSW-002', 'text' => "Failed importing datatype related data into database: \n" . 'datatype - ' . $dataType->DataTypeString . ", \n" . 'dba-data file - ' . $dataType->getDBAFilePath());
                 }
             }
         }
     }
     if (!$result) {
         return false;
     }
     // Database initialization done
     // Prepare languages
     $primaryLanguageLocaleCode = $primaryLanguage->localeCode();
     $primaryLanguageName = $primaryLanguage->languageName();
     $prioritizedLanguages = array_merge(array($primaryLanguageLocaleCode), $extraLanguageCodes);
     $installParameters = array('path' => '.');
     $installParameters['ini'] = array();
     $siteINIChanges = array();
     $url = $siteType['url'];
     if (preg_match("#^[a-zA-Z0-9]+://(.*)\$#", $url, $matches)) {
         $url = $matches[1];
     }
     $siteINIChanges['SiteAccessSettings'] = array('RelatedSiteAccessList' => $accessMap['accesses']);
     $siteINIChanges['ContentSettings'] = array('TranslationList' => implode(';', $extraLanguageCodes));
     $siteINIChanges['SiteSettings'] = array('SiteName' => $siteType['title'], 'SiteURL' => $url);
     $siteINIChanges['DatabaseSettings'] = array('DatabaseImplementation' => $dbDriver, 'Server' => $dbServer, 'Port' => $dbPort, 'Database' => $dbName, 'User' => $dbUser, 'Password' => $dbPwd, 'Charset' => false);
     $siteINIChanges['FileSettings'] = array('VarDir' => 'var/' . $siteType['identifier']);
     if (trim($dbSocket) != '') {
         $siteINIChanges['DatabaseSettings']['Socket'] = $dbSocket;
     } else {
         $siteINIChanges['DatabaseSettings']['Socket'] = 'disabled';
     }
     if ($admin['email']) {
         $siteINIChanges['InformationCollectionSettings'] = array('EmailReceiver' => false);
         $siteINIChanges['UserSettings'] = array('RegistrationEmail' => false);
         $siteINIChanges['MailSettings'] = array('AdminEmail' => $admin['email'], 'EmailSender' => false);
     }
     $siteINIChanges['RegionalSettings'] = array('Locale' => $primaryLanguage->localeFullCode(), 'ContentObjectLocale' => $primaryLanguage->localeCode(), 'SiteLanguageList' => $prioritizedLanguages);
     if ($primaryLanguage->localeCode() == 'eng-GB') {
         $siteINIChanges['RegionalSettings']['TextTranslation'] = 'disabled';
     } else {
         $siteINIChanges['RegionalSettings']['TextTranslation'] = 'enabled';
     }
     $installParameters['ini']['siteaccess'][$adminSiteaccessName]['site.ini.append'] = $siteINIChanges;
     $installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini.append'] = $siteINIChanges;
     $installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini']['DesignSettings'] = array('SiteDesign' => $userDesignName);
     $installParameters['variables']['user_siteaccess'] = $userSiteaccessName;
     $installParameters['variables']['admin_siteaccess'] = $adminSiteaccessName;
     $installParameters['variables']['design'] = $userDesignName;
     $tmpSiteINI = eZINI::create('site.ini');
     // Set ReadOnlySettingsCheck to false: towards
     // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
     $tmpSiteINI->setReadOnlySettingsCheck(false);
     $tmpSiteINI->setVariable('FileSettings', 'VarDir', $siteINIChanges['FileSettings']['VarDir']);
     // Change the current translation variables, before other parts start using them
     $tmpSiteINI->setVariable('RegionalSettings', 'Locale', $siteINIChanges['RegionalSettings']['Locale']);
     $tmpSiteINI->setVariable('RegionalSettings', 'ContentObjectLocale', $siteINIChanges['RegionalSettings']['ContentObjectLocale']);
     $tmpSiteINI->setVariable('RegionalSettings', 'TextTranslation', $siteINIChanges['RegionalSettings']['TextTranslation']);
     $tmpSiteINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}");
     /*
     $typeFunctionality = eZSetupFunctionality( $siteType['identifier'] );
     $extraFunctionality = array_merge( isset( $this->PersistenceList['additional_packages'] ) ?
                                        $this->PersistenceList['additional_packages'] :
                                        array(),
                                        $typeFunctionality['required'] );
     $extraFunctionality = array_unique( $extraFunctionality );
     */
     // Add a policy to permit editors using OE
     eZPolicy::createNew(3, array('ModuleName' => 'ezoe', 'FunctionName' => '*'));
     // Install site package and it's required packages
     $sitePackageName = $this->chosenSitePackage();
     $sitePackage = eZPackage::fetch($sitePackageName);
     if (!is_object($sitePackage)) {
         $resultArray['errors'][] = array('code' => 'EZSW-041', 'text' => " Could not fetch site package: '{$sitePackageName}'");
         return false;
     }
     $dependecies = $sitePackage->attribute('dependencies');
     $requires = $dependecies['requires'];
     $requiredPackages = array();
     // Include setting files
     $settingsFiles = $sitePackage->attribute('settings-files');
     foreach ($settingsFiles as $settingsFileName) {
         if (file_exists($sitePackage->path() . '/settings/' . $settingsFileName)) {
             include_once $sitePackage->path() . '/settings/' . $settingsFileName;
         }
     }
     // Call user function for additional setup tasks.
     if (function_exists('eZSitePreInstall')) {
         eZSitePreInstall($siteType);
     }
     // Make sure objects use the selected main language instead of eng-GB
     if ($primaryLanguageLocaleCode != 'eng-GB') {
         $engLanguageObj = eZContentLanguage::fetchByLocale('eng-GB');
         $engLanguageID = (int) $engLanguageObj->attribute('id');
         $updateSql = "UPDATE ezcontent_language\nSET\nlocale='{$primaryLanguageLocaleCode}',\nname='{$primaryLanguageName}'\nWHERE\nid={$engLanguageID}";
         $db->query($updateSql);
         eZContentLanguage::expireCache();
         $primaryLanguageObj = eZContentLanguage::fetchByLocale($primaryLanguageLocaleCode);
         // Add it if it is missing (most likely)
         if (!$primaryLanguageObj) {
             $primaryLanguageObj = eZContentLanguage::addLanguage($primaryLanguageLocaleCode, $primaryLanguageName);
         }
         $primaryLanguageID = (int) $primaryLanguageObj->attribute('id');
         // Find objects which are always available
         if ($db->databaseName() == 'oracle') {
             $sql = "SELECT id\nFROM\nezcontentobject\nWHERE\nbitand( language_mask, 1 ) = 1";
         } else {
             $sql = "SELECT id\nFROM\nezcontentobject\nWHERE\nlanguage_mask & 1 = 1";
         }
         $objectList = array();
         $list = $db->arrayQuery($sql);
         foreach ($list as $row) {
             $objectList[] = (int) $row['id'];
         }
         $inSql = 'IN ( ' . implode(', ', $objectList) . ')';
         // Updates databases that have eng-GB data to the new locale.
         $updateSql = "UPDATE ezcontentobject_name\nSET\ncontent_translation='{$primaryLanguageLocaleCode}',\nreal_translation='{$primaryLanguageLocaleCode}',\nlanguage_id={$primaryLanguageID}\nWHERE\ncontent_translation='eng-GB' OR\nreal_translation='eng-GB'";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject_name\nSET\nlanguage_id=language_id+1\nWHERE\ncontentobject_id {$inSql}";
         $db->query($updateSql);
         // attributes
         $updateSql = "UPDATE ezcontentobject_attribute\nSET\nlanguage_code='{$primaryLanguageLocaleCode}',\nlanguage_id={$primaryLanguageID}\nWHERE\nlanguage_code='eng-GB'";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject_attribute\nSET\nlanguage_id=language_id+1\nWHERE\ncontentobject_id {$inSql}";
         $db->query($updateSql);
         // version
         $updateSql = "UPDATE ezcontentobject_version\nSET\ninitial_language_id={$primaryLanguageID},\nlanguage_mask={$primaryLanguageID}\nWHERE\ninitial_language_id={$engLanguageID}";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject_version\nSET\nlanguage_mask=language_mask+1\nWHERE\ncontentobject_id {$inSql}";
         $db->query($updateSql);
         // object
         $updateSql = "UPDATE ezcontentobject\nSET\ninitial_language_id={$primaryLanguageID},\nlanguage_mask={$primaryLanguageID}\nWHERE\ninitial_language_id={$engLanguageID}";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject\nSET\nlanguage_mask=language_mask+1\nWHERE\nid {$inSql}";
         $db->query($updateSql);
         // content object state groups & states
         $mask = $primaryLanguageID | 1;
         $db->query("UPDATE ezcobj_state_group\n                         SET language_mask = {$mask}, default_language_id = {$primaryLanguageID}\n                         WHERE default_language_id = {$engLanguageID}");
         $db->query("UPDATE ezcobj_state\n                         SET language_mask = {$mask}, default_language_id = {$primaryLanguageID}\n                         WHERE default_language_id = {$engLanguageID}");
         $db->query("UPDATE ezcobj_state_group_language\n                         SET language_id = {$primaryLanguageID}\n                         WHERE language_id = {$engLanguageID}");
         $db->query("UPDATE ezcobj_state_language\n                         SET language_id = {$primaryLanguageID}\n                         WHERE language_id = {$engLanguageID}");
         // ezcontentclass_name
         $updateSql = "UPDATE ezcontentclass_name\nSET\nlanguage_locale='{$primaryLanguageLocaleCode}'\nWHERE\nlanguage_locale='eng-GB'";
         $db->query($updateSql);
         // use high-level api, because it's impossible to update serialized names with direct sqls.
         // use direct access to 'NameList' to avoid unnecessary sql-requests and because
         // we do 'replacement' of existing language(with some 'id') with another language code.
         $contentClassList = eZContentClass::fetchList();
         foreach ($contentClassList as $contentClass) {
             $classAttributes = $contentClass->fetchAttributes();
             foreach ($classAttributes as $classAttribute) {
                 $classAttribute->NameList->setName($classAttribute->NameList->name('eng-GB'), $primaryLanguageLocaleCode);
                 $classAttribute->NameList->setAlwaysAvailableLanguage($primaryLanguageLocaleCode);
                 $classAttribute->NameList->removeName('eng-GB');
                 $classAttribute->store();
             }
             $contentClass->NameList->setName($contentClass->NameList->name('eng-GB'), $primaryLanguageLocaleCode);
             $contentClass->NameList->setAlwaysAvailableLanguage($primaryLanguageLocaleCode);
             $contentClass->NameList->removeName('eng-GB');
             $contentClass->NameList->setHasDirtyData(false);
             // to not update 'ezcontentclass_name', because we've already updated it.
             $contentClass->store();
         }
     }
     // Setup all languages
     foreach ($allLanguages as $languageObject) {
         $primaryLanguageObj = eZContentLanguage::fetchByLocale($languageObject->localeCode());
         // Add it if it is missing (most likely)
         if (!$primaryLanguageObj) {
             $primaryLanguageObj = eZContentLanguage::addLanguage($languageObject->localeCode(), $languageObject->internationalLanguageName());
         }
     }
     eZContentLanguage::expireCache();
     // Make sure priority list is changed to the new chosen languages
     eZContentLanguage::setPrioritizedLanguages($prioritizedLanguages);
     if ($siteType['existing_database'] != eZStepInstaller::DB_DATA_KEEP) {
         $user = eZUser::instance(14);
         // Must be initialized to make node assignments work correctly
         if (!is_object($user)) {
             $resultArray['errors'][] = array('code' => 'EZSW-020', 'text' => "Could not fetch administrator user object");
             return false;
         }
         // Make sure Admin is the currently logged in user
         // This makes sure all new/changed objects get this as creator
         $user->loginCurrent();
         // by default(if 'language_map' is not set) create all necessary languages
         $languageMap = isset($this->PersistenceList['package_info']) && isset($this->PersistenceList['package_info']['language_map']) ? $this->PersistenceList['package_info']['language_map'] : true;
         if (is_array($languageMap) && count($languageMap) > 0) {
             //
             // Create necessary languages and set them as "prioritized languages" to avoid
             // drawbacks in fetch functions, like eZContentObjectTreeNode::fetch().
             //
             $prioritizedLanguageObjects = eZContentLanguage::prioritizedLanguages();
             // returned objects
             foreach ($languageMap as $fromLanguage => $toLanguage) {
                 if ($toLanguage != 'skip') {
                     $prioritizedLanguageObjects[] = eZContentLanguage::fetchByLocale($toLanguage, true);
                 }
             }
             $prioritizedLanguageLocales = array();
             foreach ($prioritizedLanguageObjects as $language) {
                 $locale = $language->attribute('locale');
                 if (!in_array($locale, $prioritizedLanguageLocales)) {
                     $prioritizedLanguageLocales[] = $locale;
                 }
             }
             eZContentLanguage::setPrioritizedLanguages($prioritizedLanguageLocales);
         }
         foreach ($requires as $require) {
             if ($require['type'] != 'ezpackage') {
                 continue;
             }
             $packageName = $require['name'];
             $package = eZPackage::fetch($packageName, false, false, false);
             if (is_object($package)) {
                 $requiredPackages[] = $package;
                 if ($package->attribute('install_type') == 'install') {
                     $installParameters = array('use_dates_from_package' => true, 'site_access_map' => array('*' => $userSiteaccessName), 'top_nodes_map' => array('*' => 2), 'design_map' => array('*' => $userDesignName), 'language_map' => $languageMap, 'restore_dates' => true, 'user_id' => $user->attribute('contentobject_id'), 'non-interactive' => true);
                     $status = $package->install($installParameters);
                     if (!$status) {
                         $errorText = "Unable to install package '{$packageName}'";
                         if (isset($installParameters['error']['description'])) {
                             $errorText .= ": " . $installParameters['error']['description'];
                         }
                         $resultArray['errors'][] = array('code' => 'EZSW-051', 'text' => $errorText);
                         return false;
                     }
                 }
             } else {
                 $resultArray['errors'][] = array('code' => 'EZSW-050', 'text' => "Could not fetch required package: '{$packageName}'");
                 return false;
             }
             unset($package);
         }
     }
     $GLOBALS['eZContentObjectDefaultLanguage'] = $primaryLanguageLocaleCode;
     $nodeRemoteMap = array();
     $rows = $db->arrayQuery("SELECT node_id, remote_id FROM ezcontentobject_tree");
     foreach ($rows as $row) {
         $remoteID = $row['remote_id'];
         if (strlen(trim($remoteID)) > 0) {
             $nodeRemoteMap[$remoteID] = $row['node_id'];
         }
     }
     $objectRemoteMap = array();
     $rows = $db->arrayQuery("SELECT id, remote_id FROM ezcontentobject");
     foreach ($rows as $row) {
         $remoteID = $row['remote_id'];
         if (strlen(trim($remoteID)) > 0) {
             $objectRemoteMap[$remoteID] = $row['id'];
         }
     }
     $classRemoteMap = array();
     $rows = $db->arrayQuery("SELECT id, identifier, remote_id FROM ezcontentclass");
     foreach ($rows as $row) {
         $remoteID = $row['remote_id'];
         if (strlen(trim($remoteID)) > 0) {
             $classRemoteMap[$remoteID] = array('id' => $row['id'], 'identifier' => $row['identifier']);
         }
     }
     $siteCSS = false;
     $classesCSS = false;
     foreach ($requiredPackages as $package) {
         if ($package->attribute('type') == 'sitestyle') {
             $fileList = $package->fileList('default');
             foreach ($fileList as $file) {
                 $fileIdentifier = $file["variable-name"];
                 if ($fileIdentifier == 'sitecssfile') {
                     $siteCSS = $package->fileItemPath($file, 'default');
                 } else {
                     if ($fileIdentifier == 'classescssfile') {
                         $classesCSS = $package->fileItemPath($file, 'default');
                     }
                 }
             }
         }
     }
     $parameters = array('node_remote_map' => $nodeRemoteMap, 'object_remote_map' => $objectRemoteMap, 'class_remote_map' => $classRemoteMap, 'preview_design' => $userDesignName, 'design_list' => array($userDesignName, 'admin2', 'admin'), 'user_siteaccess' => $userSiteaccessName, 'admin_siteaccess' => $adminSiteaccessName, 'package_object' => $sitePackage, 'siteaccess_urls' => $this->siteaccessURLs(), 'access_map' => $accessMap, 'site_type' => $siteType, 'all_language_codes' => $prioritizedLanguages);
     $siteINIStored = false;
     $siteINIAdminStored = false;
     $designINIStored = false;
     if (function_exists('eZSiteINISettings')) {
         $extraSettings = eZSiteINISettings($parameters);
     } else {
         $extraSettings = array();
     }
     if (function_exists('eZSiteAdminINISettings')) {
         $extraAdminSettings = eZSiteAdminINISettings($parameters);
     } else {
         $extraAdminSettings = array();
     }
     if (function_exists('eZSiteCommonINISettings')) {
         $extraCommonSettings = eZSiteCommonINISettings($parameters);
     } else {
         $extraCommonSettings = array();
     }
     $isUntranslatedSettingAdded = false;
     foreach ($extraAdminSettings as $key => $extraAdminSetting) {
         if ($extraAdminSetting['name'] == 'site.ini') {
             $extraAdminSettings[$key]['settings']['RegionalSettings']['ShowUntranslatedObjects'] = 'enabled';
             $isUntranslatedSettingAdded = true;
             break;
         }
     }
     if (!$isUntranslatedSettingAdded) {
         $extraAdminSettings[] = array('name' => 'site.ini', 'settings' => array('RegionalSettings' => array('ShowUntranslatedObjects' => 'enabled')));
     }
     // Enable OE and ODF extensions by default
     $extensionsToEnable = array();
     // Included in "fat" install, needs to override $extraCommonSettings extensions
     $extensionsPrepended = array('ezjscore', 'ezoe', 'ezformtoken');
     foreach (array('ezie', 'ezodf', 'ezprestapiprovider', 'ezmultiupload', 'eztags', 'ezautosave', 'ez_network', 'ez_network_demo') as $extension) {
         if (file_exists("extension/{$extension}")) {
             $extensionsToEnable[] = $extension;
         }
     }
     $settingAdded = false;
     foreach ($extraCommonSettings as $key => $extraCommonSetting) {
         if ($extraCommonSetting['name'] == 'site.ini' && isset($extraCommonSettings[$key]['settings']['ExtensionSettings']['ActiveExtensions'])) {
             $settingAdded = true;
             $extraCommonSettings[$key]['settings']['ExtensionSettings']['ActiveExtensions'] = array_merge($extensionsPrepended, $extraCommonSettings[$key]['settings']['ExtensionSettings']['ActiveExtensions'], $extensionsToEnable);
             break;
         }
     }
     if (!$settingAdded) {
         $extraCommonSettings[] = array('name' => 'site.ini', 'settings' => array('ExtensionSettings' => array('ActiveExtensions' => array_merge($extensionsPrepended, $extensionsToEnable))));
     }
     // Enable dynamic tree menu for the admin interface by default
     $enableDynamicTreeMenuAdded = false;
     foreach ($extraAdminSettings as $key => $extraSetting) {
         if ($extraSetting['name'] == 'contentstructuremenu.ini') {
             if (isset($extraSetting['settings']['TreeMenu'])) {
                 $extraAdminSettings[$key]['settings']['TreeMenu']['Dynamic'] = 'enabled';
             } else {
                 $extraAdminSettings[$key]['settings'] = array('TreeMenu' => array('Dynamic' => 'enabled'));
             }
             $enableDynamicTreeMenuAdded = true;
             break;
         }
     }
     if (!$enableDynamicTreeMenuAdded) {
         $extraAdminSettings[] = array('name' => 'contentstructuremenu.ini', 'settings' => array('TreeMenu' => array('Dynamic' => 'enabled')));
     }
     $resultArray['common_settings'] = $extraCommonSettings;
     foreach ($extraSettings as $extraSetting) {
         if ($extraSetting === false) {
             continue;
         }
         $iniName = $extraSetting['name'];
         $settings = $extraSetting['settings'];
         $resetArray = false;
         if (isset($extraSetting['reset_arrays'])) {
             $resetArray = $extraSetting['reset_arrays'];
         }
         $tmpINI = eZINI::create($iniName);
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $tmpINI->setReadOnlySettingsCheck(false);
         $tmpINI->setVariables($settings);
         if ($iniName == 'site.ini') {
             $siteINIStored = true;
             $tmpINI->setVariables($siteINIChanges);
             $tmpINI->setVariable('DesignSettings', 'SiteDesign', $userDesignName);
             $tmpINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('base'));
         } else {
             if ($iniName == 'design.ini') {
                 if ($siteCSS) {
                     $tmpINI->setVariable('StylesheetSettings', 'SiteCSS', $siteCSS);
                 }
                 if ($classesCSS) {
                     $tmpINI->setVariable('StylesheetSettings', 'ClassesCSS', $classesCSS);
                 }
                 $designINIStored = true;
             }
         }
         $tmpINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}", $resetArray);
         if ($siteType['existing_database'] != eZStepInstaller::DB_DATA_KEEP) {
             // setting up appropriate data in look&feel object
             $templateLookClass = eZContentClass::fetchByIdentifier('template_look', true);
             if ($templateLookClass) {
                 $objectList = $templateLookClass->objectList();
                 if ($objectList and count($objectList) > 0) {
                     $templateLookObject = current($objectList);
                     $dataMap = $templateLookObject->fetchDataMap();
                     if (isset($dataMap['title'])) {
                         $dataMap['title']->setAttribute('data_text', $siteINIChanges['SiteSettings']['SiteName']);
                         $dataMap['title']->store();
                     }
                     if (isset($dataMap['siteurl'])) {
                         $dataMap['siteurl']->setAttribute('data_text', $siteINIChanges['SiteSettings']['SiteURL']);
                         $dataMap['siteurl']->store();
                     }
                     if (isset($dataMap['email'])) {
                         $dataMap['email']->setAttribute('data_text', $siteINIChanges['MailSettings']['AdminEmail']);
                         $dataMap['email']->store();
                     }
                     $objectName = $templateLookClass->contentObjectName($templateLookObject);
                     $templateLookObject->setName($objectName);
                     $templateLookObject->store();
                 }
             }
         }
     }
     foreach ($extraAdminSettings as $extraSetting) {
         if ($extraSetting === false) {
             continue;
         }
         $iniName = $extraSetting['name'];
         $settings = $extraSetting['settings'];
         $resetArray = false;
         if (isset($extraSetting['reset_arrays'])) {
             $resetArray = $extraSetting['reset_arrays'];
         }
         $tmpINI = eZINI::create($iniName);
         $tmpINI->setVariables($settings);
         if ($iniName == 'site.ini') {
             $siteINIAdminStored = true;
             $tmpINI->setVariables($siteINIChanges);
             $tmpINI->setVariable('SiteAccessSettings', 'RequireUserLogin', 'true');
             $tmpINI->setVariable('DesignSettings', 'SiteDesign', 'admin2');
             $tmpINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('admin'));
             $tmpINI->setVariable('SiteSettings', 'LoginPage', 'custom');
             $tmpINI->setVariable('SiteSettings', 'DefaultPage', 'content/dashboard');
         }
         $tmpINI->save(false, '.append.php', false, true, "settings/siteaccess/{$adminSiteaccessName}", $resetArray);
     }
     if (!$siteINIAdminStored) {
         $siteINI = eZINI::create('site.ini');
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $siteINI->setReadOnlySettingsCheck(false);
         $siteINI->setVariables($siteINIChanges);
         $siteINI->setVariable('SiteAccessSettings', 'RequireUserLogin', 'true');
         $siteINI->setVariable('DesignSettings', 'SiteDesign', 'admin2');
         $tmpINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('admin'));
         $siteINI->setVariable('SiteSettings', 'LoginPage', 'custom');
         $siteINI->setVariable('SiteSettings', 'DefaultPage', 'content/dashboard');
         $siteINI->save(false, '.append.php', false, false, "settings/siteaccess/{$adminSiteaccessName}", true);
     }
     if (!$siteINIStored) {
         $siteINI = eZINI::create('site.ini');
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $siteINI->setReadOnlySettingsCheck(false);
         $siteINI->setVariables($siteINIChanges);
         $siteINI->setVariable('DesignSettings', 'SiteDesign', $userDesignName);
         $siteINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('base'));
         $siteINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}", true);
     }
     if (!$designINIStored) {
         $designINI = eZINI::create('design.ini');
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $designINI->setReadOnlySettingsCheck(false);
         if ($siteCSS) {
             $designINI->setVariable('StylesheetSettings', 'SiteCSS', $siteCSS);
         }
         if ($classesCSS) {
             $designINI->setVariable('StylesheetSettings', 'ClassesCSS', $classesCSS);
         }
         $designINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}");
     }
     eZDir::mkdir("design/" . $userDesignName);
     eZDir::mkdir("design/" . $userDesignName . "/templates");
     eZDir::mkdir("design/" . $userDesignName . "/stylesheets");
     eZDir::mkdir("design/" . $userDesignName . "/images");
     eZDir::mkdir("design/" . $userDesignName . "/override");
     eZDir::mkdir("design/" . $userDesignName . "/override/templates");
     if ($siteType['existing_database'] == eZStepInstaller::DB_DATA_KEEP) {
         return true;
     }
     // Try and remove user/login without limitation from the anonymous user
     $anonRole = eZRole::fetchByName('Anonymous');
     if (is_object($anonRole)) {
         $anonPolicies = $anonRole->policyList();
         foreach ($anonPolicies as $anonPolicy) {
             if ($anonPolicy->attribute('module_name') == 'user' and $anonPolicy->attribute('function_name') == 'login') {
                 $anonPolicy->removeThis();
                 break;
             }
         }
     }
     // Setup all roles according to site chosen and addons
     if (function_exists('eZSiteRoles')) {
         $extraRoles = eZSiteRoles($parameters);
         foreach ($extraRoles as $extraRole) {
             if (!$extraRole) {
                 continue;
             }
             $extraRoleName = $extraRole['name'];
             $role = eZRole::fetchByName($extraRoleName);
             if (!is_object($role)) {
                 $role = eZRole::create($extraRoleName);
                 $role->store();
             }
             $roleID = $role->attribute('id');
             if (isset($extraRole['policies'])) {
                 $extraPolicies = $extraRole['policies'];
                 foreach ($extraPolicies as $extraPolicy) {
                     if (isset($extraPolicy['limitation'])) {
                         $role->appendPolicy($extraPolicy['module'], $extraPolicy['function'], $extraPolicy['limitation']);
                     } else {
                         $role->appendPolicy($extraPolicy['module'], $extraPolicy['function']);
                     }
                 }
             }
             if (isset($extraRole['assignments'])) {
                 $roleAssignments = $extraRole['assignments'];
                 foreach ($roleAssignments as $roleAssignment) {
                     $assignmentIdentifier = false;
                     $assignmentValue = false;
                     if (isset($roleAssignment['limitation'])) {
                         $assignmentIdentifier = $roleAssignment['limitation']['identifier'];
                         $assignmentValue = $roleAssignment['limitation']['value'];
                     }
                     $role->assignToUser($roleAssignment['user_id'], $assignmentIdentifier, $assignmentValue);
                 }
             }
         }
     }
     // Setup user preferences based on the site chosen and addons
     if (function_exists('eZSitePreferences')) {
         $prefs = eZSitePreferences($parameters);
         foreach ($prefs as $prefEntry) {
             if (!$prefEntry) {
                 continue;
             }
             $prefUserID = $prefEntry['user_id'];
             foreach ($prefEntry['preferences'] as $pref) {
                 $prefName = $pref['name'];
                 $prefValue = $pref['value'];
                 if (!eZPreferences::setValue($prefName, $prefValue, $prefUserID)) {
                     $resultArray['errors'][] = array('code' => 'EZSW-070', 'text' => "Could not create ezpreference '{$prefValue}' for {$prefUserID}");
                     return false;
                 }
             }
         }
     }
     $publishAdmin = false;
     $userAccount = eZUser::fetch(14);
     if (!is_object($userAccount)) {
         $resultArray['errors'][] = array('code' => 'EZSW-020', 'text' => "Could not fetch administrator user object");
         return false;
     }
     $userObject = $userAccount->attribute('contentobject');
     if (!is_object($userObject)) {
         $resultArray['errors'][] = array('code' => 'EZSW-021', 'text' => "Could not fetch administrator content object");
         return false;
     }
     $newUserObject = $userObject->createNewVersion(false, false);
     if (!is_object($newUserObject)) {
         $resultArray['errors'][] = array('code' => 'EZSW-022', 'text' => "Could not create new version of administrator content object");
         return false;
     }
     $dataMap = $newUserObject->attribute('data_map');
     $error = false;
     if (trim($admin['email'])) {
         if (!isset($dataMap['user_account'])) {
             $resultArray['errors'][] = array('code' => 'EZSW-023', 'text' => "Administrator content object does not have a 'user_account' attribute");
             return false;
         }
         $userAccount->setInformation(14, 'admin', $admin['email'], $admin['password'], $admin['password']);
         $dataMap['user_account']->setContent($userAccount);
         $dataMap['user_account']->store();
         $publishAdmin = true;
         $userAccount->store();
     }
     if (trim($admin['first_name']) or trim($admin['last_name'])) {
         if (!isset($dataMap['first_name'])) {
             $resultArray['errors'][] = array('code' => 'EZSW-023', 'text' => "Administrator content object does not have a 'first_name' field");
             $error = true;
         }
         if (!isset($dataMap['last_name'])) {
             $resultArray['errors'][] = array('code' => 'EZSW-024', 'text' => "Administrator content object does not have a 'last_name' field");
             $error = true;
         }
         if ($error) {
             return false;
         }
         $dataMap['first_name']->setAttribute('data_text', $admin['first_name']);
         $dataMap['first_name']->store();
         $dataMap['last_name']->setAttribute('data_text', $admin['last_name']);
         $dataMap['last_name']->store();
         $newUserObject->store();
         $publishAdmin = true;
     }
     if ($publishAdmin) {
         $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $newUserObject->attribute('contentobject_id'), 'version' => $newUserObject->attribute('version')));
         if ($operationResult['status'] != eZModuleOperationInfo::STATUS_CONTINUE) {
             $resultArray['errors'][] = array('code' => 'EZSW-025', 'text' => "Failed to properly publish the administrator object");
             return false;
         }
     }
     // Call user function for additional setup tasks.
     if (function_exists('eZSitePostInstall')) {
         eZSitePostInstall($parameters);
     }
     // get all siteaccesses. do it via 'RelatedSiteAccessesList' settings.
     $adminSiteINI = eZINI::instance('site.ini' . '.append.php', "settings/siteaccess/{$adminSiteaccessName}");
     $relatedSiteAccessList = $adminSiteINI->variable('SiteAccessSettings', 'RelatedSiteAccessList');
     // Adding override for 'tiny_image' view for 'multi-option2' datatype
     foreach ($relatedSiteAccessList as $siteAccess) {
         $tmpOverrideINI = new eZINI('override.ini' . '.append.php', "settings/siteaccess/{$siteAccess}", null, null, null, true, true);
         $tmpOverrideINI->setVariable('tiny_image', 'Source', 'content/view/tiny.tpl');
         $tmpOverrideINI->setVariable('tiny_image', 'MatchFile', 'tiny_image.tpl');
         $tmpOverrideINI->setVariable('tiny_image', 'Subdir', 'templates');
         $tmpOverrideINI->setVariable('tiny_image', 'Match', array('class_identifier' => 'image'));
         $tmpOverrideINI->save();
     }
     $accessMap = $parameters['access_map'];
     // Call user function for some text which will be displayed at 'Finish' screen
     if (function_exists('eZSiteFinalText')) {
         $text = eZSiteFinalText($parameters);
         if (!isset($this->PersistenceList['final_text'])) {
             $this->PersistenceList['final_text'] = array();
         }
         $this->PersistenceList['final_text'][] = $text;
     }
     // ensure that evaluated policy wildcards in the user info cache
     // will be up to date with the currently activated modules
     eZCache::clearByID('user_info_cache');
     return true;
 }
示例#25
0
            $basket = eZBasket::currentBasket();
            $basket->remove();
        }
        $module->redirectTo('/shop/checkout/');
        return;
    }
    if ($http->hasPostVariable("CancelButton")) {
        $order->purge(false);
        $module->redirectTo('/shop/basket/');
        return;
    }
    $tpl->setVariable("order", $order);
}
$basket = eZBasket::currentBasket();
$basket->updatePrices();
$operationResult = eZOperationHandler::execute('shop', 'confirmorder', array('order_id' => $order->attribute('id')));
switch ($operationResult['status']) {
    case eZModuleOperationInfo::STATUS_CONTINUE:
        if ($operationResult != null && !isset($operationResult['result']) && (!isset($operationResult['redirect_url']) || $operationResult['redirect_url'] == null)) {
            $order = eZOrder::fetch($order->attribute('id'));
            $tpl->setVariable("order", $order);
            $Result = array();
            $Result['content'] = $tpl->fetch("design:shop/confirmorder.tpl");
            $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('kernel/shop', 'Confirm order')));
        }
        break;
    case eZModuleOperationInfo::STATUS_HALTED:
    case eZModuleOperationInfo::STATUS_REPEAT:
        if (isset($operationResult['redirect_url'])) {
            $module->redirectTo($operationResult['redirect_url']);
            return;
示例#26
0
 function checkContentActions($module, $class, $object, $version, $contentObjectAttributes, $EditVersion, $EditLanguage)
 {
     if ($module->isCurrentAction('Cancel')) {
         $http = eZHTTPTool::instance();
         if ($http->hasPostVariable('RedirectIfDiscarded')) {
             eZRedirectManager::redirectTo($module, $http->postVariable('RedirectIfDiscarded'));
         } else {
             eZRedirectManager::redirectTo($module, '/');
         }
         $version->removeThis();
         $http = eZHTTPTool::instance();
         $http->removeSessionVariable("RegisterUserID");
         $http->removeSessionVariable('StartedRegistration');
         return eZModule::HOOK_STATUS_CANCEL_RUN;
     }
     if ($module->isCurrentAction('Publish')) {
         $userID = $object->attribute('id');
         $operationResult = eZOperationHandler::execute('user', 'register', array('user_id' => $userID));
         // send feedback
         $ini = eZINI::instance();
         $tpl = eZTemplate::factory();
         $hostname = eZSys::hostname();
         $user = eZUser::fetch($userID);
         $feedbackTypes = $ini->variableArray('UserSettings', 'RegistrationFeedback');
         foreach ($feedbackTypes as $feedbackType) {
             switch ($feedbackType) {
                 case 'email':
                     // send feedback with the default email type
                     $mail = new eZMail();
                     $tpl->resetVariables();
                     $tpl->setVariable('user', $user);
                     $tpl->setVariable('object', $object);
                     $tpl->setVariable('hostname', $hostname);
                     $templateResult = $tpl->fetch('design:user/registrationfeedback.tpl');
                     if ($tpl->hasVariable('content_type')) {
                         $mail->setContentType($tpl->variable('content_type'));
                     }
                     $emailSender = $ini->variable('MailSettings', 'EmailSender');
                     if ($tpl->hasVariable('email_sender')) {
                         $emailSender = $tpl->variable('email_sender');
                     } else {
                         if (!$emailSender) {
                             $emailSender = $ini->variable('MailSettings', 'AdminEmail');
                         }
                     }
                     $feedbackReceiver = $ini->variable('UserSettings', 'RegistrationEmail');
                     if ($tpl->hasVariable('email_receiver')) {
                         $feedbackReceiver = $tpl->variable('email_receiver');
                     } else {
                         if (!$feedbackReceiver) {
                             $feedbackReceiver = $ini->variable('MailSettings', 'AdminEmail');
                         }
                     }
                     if ($tpl->hasVariable('subject')) {
                         $subject = $tpl->variable('subject');
                     } else {
                         $subject = ezpI18n::tr('kernel/user/register', 'New user registered');
                     }
                     $mail->setSender($emailSender);
                     $mail->setReceiver($feedbackReceiver);
                     $mail->setSubject($subject);
                     $mail->setBody($templateResult);
                     $mailResult = eZMailTransport::send($mail);
                     break;
                 default:
                     $registrationFeedbackClass = false;
                     // load custom registration feedback settings
                     if ($ini->hasGroup('RegistrationFeedback_' . $feedbackType)) {
                         if ($ini->hasVariable('RegistrationFeedback_' . $feedbackType, 'File')) {
                             include_once $ini->variable('RegistrationFeedback_' . $feedbackType, 'File');
                         }
                         $registrationFeedbackClass = $ini->variable('RegistrationFeedback_' . $feedbackType, 'Class');
                     }
                     // try to call the registration feedback class with function registrationFeedback
                     if ($registrationFeedbackClass && method_exists($registrationFeedbackClass, 'registrationFeedback')) {
                         call_user_func(array($registrationFeedbackClass, 'registrationFeedback'), $user, $tpl, $object, $hostname);
                     } else {
                         eZDebug::writeWarning("Unknown feedback type '{$feedbackType}'", 'user/register');
                     }
             }
         }
         $http = eZHTTPTool::instance();
         $http->removeSessionVariable("GeneratedPassword");
         $http->removeSessionVariable("RegisterUserID");
         $http->removeSessionVariable('StartedRegistration');
         // if everything is passed, login the user
         if ($operationResult['status'] === eZModuleOperationInfo::STATUS_CONTINUE) {
             $user->loginCurrent();
         }
         // check for redirectionvariable
         if ($operationResult['status'] === eZModuleOperationInfo::STATUS_CONTINUE || $operationResult['status'] === eZModuleOperationInfo::STATUS_HALTED) {
             if ($http->hasSessionVariable('RedirectAfterUserRegister')) {
                 $module->redirectTo($http->sessionVariable('RedirectAfterUserRegister'));
                 $http->removeSessionVariable('RedirectAfterUserRegister');
             } else {
                 if ($http->hasPostVariable('RedirectAfterUserRegister')) {
                     $module->redirectTo($http->postVariable('RedirectAfterUserRegister'));
                 } else {
                     $module->redirectTo('/user/success/');
                 }
             }
         } else {
             eZDebug::writeError('Unexpected operation status: ' . $operationResult['status'], 'user/register');
             // @todo: finish the failure code
             $module->redirectTo('/user/register/5');
         }
     }
 }
示例#27
0
        if ( !$mainMemento )
        {
            $db->commit();
            continue;
        }

        $mementoData = $bodyMemento->data();
        $mainMementoData = $mainMemento->data();
        $mementoData['main_memento'] = $mainMemento;
        $mementoData['skip_trigger'] = true;
        $mementoData['memento_key'] = $process->attribute( 'memento_key' );
        $bodyMemento->remove();
        $operationParameters = array();
        if ( isset( $mementoData['parameters'] ) )
            $operationParameters = $mementoData['parameters'];
        $operationResult = eZOperationHandler::execute( $mementoData['module_name'], $mementoData['operation_name'], $operationParameters, $mementoData );
        ++$removedProcessCount;
        $process->removeThis();
    }

    $db->commit();

    eZStaticCache::executeActions();
}
if ( !$isQuiet )
{
    $cli->output( $cli->stylize( 'emphasize', "Status list" ) );
    $statusTextList = array();
    $maxStatusTextLength = 0;
    foreach ( $statusMap as $statusID => $statusCount )
    {
function copyPublishContentObject($sourceObject, $sourceSubtreeNodeIDList, &$syncNodeIDListSrc, &$syncNodeIDListNew, &$syncObjectIDListSrc, &$syncObjectIDListNew, $objectIDBlackList, &$nodeIDBlackList, &$notifications, $allVersions = false, $keepCreator = false, $keepTime = false)
{
    $sourceObjectID = $sourceObject->attribute('id');
    $key = array_search($sourceObjectID, $syncObjectIDListSrc);
    if ($key !== false) {
        eZDebug::writeDebug("Object (ID = {$sourceObjectID}) has been already copied.", "Subtree copy: copyPublishContentObject()");
        return 1;
        // object already copied
    }
    $srcNodeList = $sourceObject->attribute('assigned_nodes');
    // if we already failed to copy that contentobject, then just skip it:
    if (in_array($sourceObjectID, $objectIDBlackList)) {
        return 0;
    }
    // if we already failed to copy that node, then just skip it:
    //if ( in_array( $sourceNodeID, $nodeIDBlackList ) )
    //    return 0;
    // if cannot read contentobject then remember it and all its nodes (nodes
    // which are inside subtree being copied) in black list, and skip current node:
    if (!$sourceObject->attribute('can_read')) {
        $objectIDBlackList[] = $sourceObjectID;
        $notifications['Warnings'][] = ezpI18n::tr('kernel/content/copysubtree', "Object (ID = %1) was not copied: you do not have permission to read the object.", null, array($sourceObjectID));
        $srcNodeList = $sourceObject->attribute('assigned_nodes');
        foreach ($srcNodeList as $srcNode) {
            $srcNodeID = $srcNode->attribute('node_id');
            $sourceParentNodeID = $srcNode->attribute('parent_node_id');
            $key = array_search($sourceParentNodeID, $sourceSubtreeNodeIDList);
            if ($key !== false) {
                $nodeIDBlackList[] = $srcNodeID;
                $notifications['Warnings'][] = ezpI18n::tr('kernel/content/copysubtree', "Node (ID = %1) was not copied: you do not have permission to read object (ID = %2).", null, array($srcNodeID, $sourceObjectID));
            }
        }
        return 0;
    }
    // check if all possible parent nodes for given contentobject are already published:
    $isReadyToPublish = false;
    foreach ($srcNodeList as $srcNode) {
        $srcNodeID = $srcNode->attribute('node_id');
        if (in_array($srcNodeID, $nodeIDBlackList)) {
            continue;
        }
        $srcParentNodeID = $srcNode->attribute('parent_node_id');
        // if parent node for this node is outside
        // of subtree being copied, then skip this node:
        $key = array_search($srcParentNodeID, $sourceSubtreeNodeIDList);
        if ($key === false) {
            continue;
        }
        // if parent node for this node wasn't copied yet and is in black list
        // then add that node in black list and just skip it:
        $key = array_search($srcParentNodeID, $nodeIDBlackList);
        if ($key !== false) {
            $nodeIDBlackList[] = $srcNodeID;
            $notifications['Warnings'][] = ezpI18n::tr('kernel/content/copysubtree', "Node (ID = %1) was not copied: parent node (ID = %2) was not copied.", null, array($srcNodeID, $srcParentNodeID));
            continue;
        }
        $key = array_search($srcParentNodeID, $syncNodeIDListSrc);
        if ($key === false) {
            // if parent node is not copied yet and not in black list,
            // then just skip sourceObject from copying for next time
            eZDebug::writeDebug("Parent node (ID = {$srcParentNodeID}) for contentobject (ID = {$sourceObjectID}) is not published yet.", "Subtree copy: copyPublishContentObject()");
            return 2;
        } else {
            $newParentNodeID = $syncNodeIDListNew[$key];
            $newParentNode = eZContentObjectTreeNode::fetch($newParentNodeID);
            if ($newParentNode === null) {
                eZDebug::writeError("Cannot fetch one of parent nodes. Error are somewhere above", "Subtree copy error: copyPublishContentObject()");
                return 3;
            }
            if ($newParentNode->checkAccess('create', $sourceObject->attribute('contentclass_id')) != 1) {
                $nodeIDBlackList[] = $srcNodeID;
                $notifications['Warnings'][] = ezpI18n::tr('kernel/content/copysubtree', "Node (ID = %1) was not copied: you do not have permission to create.", null, array($srcNodeID));
                continue;
            } else {
                $isReadyToPublish = true;
            }
        }
    }
    // if all nodes of sourceObject were skiped as black list entry or
    // as outside of subtree being copied, then sourceObject cannot be
    // copied and published in any new location. So insert sourceObject
    // in a black list and skip it.
    if ($isReadyToPublish == false) {
        $objectIDBlackList[] = $sourceObjectID;
        $notifications['Warnings'][] = ezpI18n::tr('kernel/content/copysubtree', "Object (ID = %1) was not copied: no one nodes of object was not copied.", null, array($sourceObjectID));
        return 0;
    }
    // make copy of source object
    $newObject = $sourceObject->copy($allVersions);
    // insert source and new object's ids in $syncObjectIDList
    // We should reset section that will be updated in updateSectionID().
    // If sectionID is 0 than the object has been newly created
    $newObject->setAttribute('section_id', 0);
    $newObject->store();
    $syncObjectIDListSrc[] = $sourceObjectID;
    $curVersion = $newObject->attribute('current_version');
    $curVersionObject = $newObject->attribute('current');
    $newObjAssignments = $curVersionObject->attribute('node_assignments');
    // copy nodeassigments:
    $assignmentsForRemoving = array();
    $foundMainAssignment = false;
    foreach ($newObjAssignments as $assignment) {
        $parentNodeID = $assignment->attribute('parent_node');
        // if assigment is outside of subtree being copied then do not copy this assigment
        $key1 = array_search($parentNodeID, $sourceSubtreeNodeIDList);
        $key2 = array_search($parentNodeID, $nodeIDBlackList);
        if ($key1 === false or $key2 !== false) {
            $assignmentsForRemoving[] = $assignment->attribute('id');
            continue;
        }
        $key = array_search($parentNodeID, $syncNodeIDListSrc);
        if ($key === false) {
            eZDebug::writeError("Cannot publish contentobject (ID={$sourceObjectID}). Parent is not published yet.", "Subtree Copy error: copyPublishContentObject()");
            return 4;
        }
        if ($assignment->attribute('is_main')) {
            $foundMainAssignment = true;
        }
        $newParentNodeID = $syncNodeIDListNew[$key];
        $assignment->setAttribute('parent_node', $newParentNodeID);
        $assignment->store();
    }
    // remove assigments which are outside of subtree being copied:
    eZNodeAssignment::purgeByID($assignmentsForRemoving);
    // if main nodeassigment was not copied then set as main first nodeassigment
    if ($foundMainAssignment == false) {
        $newObjAssignments = $curVersionObject->attribute('node_assignments');
        // We need to check if it has any assignments before changing the data.
        if (isset($newObjAssignments[0])) {
            $newObjAssignments[0]->setAttribute('is_main', 1);
            $newObjAssignments[0]->store();
        }
    }
    // publish the newly created object
    $result = eZOperationHandler::execute('content', 'publish', array('object_id' => $newObject->attribute('id'), 'version' => $curVersion));
    // Refetch the object data since it might change in the database.
    $newObjectID = $newObject->attribute('id');
    $newObject = eZContentObject::fetch($newObjectID);
    $newNodeList = $newObject->attribute('assigned_nodes');
    if (count($newNodeList) == 0) {
        $newObject->purge();
        eZDebug::writeError("Cannot publish contentobject.", "Subtree Copy Error!");
        $sourceObjectName = $srcNode->getName();
        $notifications['Warnings'][] = ezpI18n::tr('kernel/content/copysubtree', "Cannot publish object (Name: %1, ID: %2).", null, array($sourceObjectName, $sourceObjectID));
        return -1;
    }
    // Only if the object has been published successfully, the object id can be added into $syncObjectIDListNew
    $syncObjectIDListNew[] = $newObject->attribute('id');
    $objAssignments = $curVersionObject->attribute('node_assignments');
    foreach ($newNodeList as $newNode) {
        $newParentNode = $newNode->fetchParent();
        $newParentNodeID = $newParentNode->attribute('node_id');
        $keyA = array_search($newParentNodeID, $syncNodeIDListNew);
        if ($keyA === false) {
            eZDebug::writeError("Algoritm ERROR! Cannot find new parent node ID in new ID's list", "Subtree Copy Error!");
            return -2;
        }
        $srcParentNodeID = $syncNodeIDListSrc[$keyA];
        // Update attributes of node
        $bSrcParentFound = false;
        foreach ($srcNodeList as $srcNode) {
            if ($srcNode->attribute('parent_node_id') == $srcParentNodeID) {
                $newNode->setAttribute('priority', $srcNode->attribute('priority'));
                $newNode->setAttribute('is_hidden', $srcNode->attribute('is_hidden'));
                // Update node visibility
                if ($newParentNode->attribute('is_invisible') or $newParentNode->attribute('is_hidden')) {
                    $newNode->setAttribute('is_invisible', 1);
                } else {
                    $newNode->setAttribute('is_invisible', $srcNode->attribute('is_invisible'));
                }
                $syncNodeIDListSrc[] = $srcNode->attribute('node_id');
                $syncNodeIDListNew[] = $newNode->attribute('node_id');
                $bSrcParentFound = true;
                break;
            }
        }
        if ($bSrcParentFound == false) {
            eZDebug::writeError("Cannot find source parent node in list of nodes already copied.", "Subtree Copy Error!");
        }
        // Create unique remote_id
        $newRemoteID = eZRemoteIdUtility::generate('node');
        $oldRemoteID = $newNode->attribute('remote_id');
        $newNode->setAttribute('remote_id', $newRemoteID);
        // Change parent_remote_id for object assignments
        foreach ($objAssignments as $assignment) {
            if ($assignment->attribute('parent_remote_id') == $oldRemoteID) {
                $assignment->setAttribute('parent_remote_id', $newRemoteID);
                $assignment->store();
            }
        }
        $newNode->store();
    }
    // if $keepCreator == true then keep owner of contentobject being
    // copied and creator of its published version Unchaged
    $isModified = false;
    if ($keepTime) {
        $srcPublished = $sourceObject->attribute('published');
        $newObject->setAttribute('published', $srcPublished);
        $srcModified = $sourceObject->attribute('modified');
        $newObject->setAttribute('modified', $srcModified);
        $isModified = true;
    }
    if ($keepCreator) {
        $srcOwnerID = $sourceObject->attribute('owner_id');
        $newObject->setAttribute('owner_id', $srcOwnerID);
        $isModified = true;
    }
    if ($isModified) {
        $newObject->store();
    }
    if ($allVersions) {
        // copy time of creation and midification and creator id for
        // all versions of content object being copied.
        $srcVersionsList = $sourceObject->versions();
        foreach ($srcVersionsList as $srcVersionObject) {
            $newVersionObject = $newObject->version($srcVersionObject->attribute('version'));
            if (!is_object($newVersionObject)) {
                continue;
            }
            $isModified = false;
            if ($keepTime) {
                $srcVersionCreated = $srcVersionObject->attribute('created');
                $newVersionObject->setAttribute('created', $srcVersionCreated);
                $srcVersionModified = $srcVersionObject->attribute('modified');
                $newVersionObject->setAttribute('modified', $srcVersionModified);
                $isModified = true;
            }
            if ($keepCreator) {
                $srcVersionCreatorID = $srcVersionObject->attribute('creator_id');
                $newVersionObject->setAttribute('creator_id', $srcVersionCreatorID);
                $isModified = true;
            }
            if ($isModified) {
                $newVersionObject->store();
            }
        }
    } else {
        $srcVersionObject = $sourceObject->attribute('current');
        $newVersionObject = $newObject->attribute('current');
        $isModified = false;
        if ($keepTime) {
            $srcVersionCreated = $srcVersionObject->attribute('created');
            $newVersionObject->setAttribute('created', $srcVersionCreated);
            $srcVersionModified = $srcVersionObject->attribute('modified');
            $newVersionObject->setAttribute('modified', $srcVersionModified);
            $isModified = true;
        }
        if ($keepCreator) {
            $srcVersionCreatorID = $srcVersionObject->attribute('creator_id');
            $newVersionObject->setAttribute('creator_id', $srcVersionCreatorID);
            $isModified = true;
        }
        if ($isModified) {
            $newVersionObject->store();
        }
    }
    return 0;
    // source object was copied successfully.
}
示例#29
0
                                                       null,
                                                       null,
                                                       true );
        }
        if ( isset($users) && count($users) > 0 )
        {
            $user   = $users[0];
            $time   = time();
            $userID = $user->id();
            $hashKey = md5( $userID . ':' . $time . ':' . mt_rand() );

            // Create forgot password object
            if ( eZOperationHandler::operationIsAvailable( 'user_forgotpassword' ) )
            {
                $operationResult = eZOperationHandler::execute( 'user',
                                                                'forgotpassword', array( 'user_id'    => $userID,
                                                                                         'password_hash'  => $hashKey,
                                                                                         'time' => $time ) );
            }
            else
            {
                eZUserOperationCollection::forgotpassword( $userID, $hashKey, $time );
            }

            $userToSendEmail = $user;
            $receiver = $email;

            $mail = new eZMail();
            if ( !$mail->validate( $receiver ) )
            {
            }
示例#30
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;
}