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)
 {
     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;
 }
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 ) );
            }
        }
    }
}
 /**
  * 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'));
 }
示例#5
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);
            }
        }
    }
}
    /**
     * 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 );
        }
    }
示例#7
0
/**
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version //autogentag//
 * @package kernel
 */
$Module = $Params['Module'];
$NodeID = $Params['NodeID'];
$curNode = eZContentObjectTreeNode::fetch($NodeID);
if (!$curNode) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
if (!$curNode->attribute('can_hide')) {
    return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
}
if (eZOperationHandler::operationIsAvailable('content_hide')) {
    $operationResult = eZOperationHandler::execute('content', 'hide', array('node_id' => $NodeID), null, true);
} else {
    eZContentOperationCollection::changeHideStatus($NodeID);
}
$hasRedirect = eZRedirectManager::redirectTo($Module, false);
if (!$hasRedirect) {
    // redirect to the parent node
    if (($parentNodeID = $curNode->attribute('parent_node_id')) == 1) {
        $redirectNodeID = $NodeID;
    } else {
        $redirectNodeID = $parentNodeID;
    }
    return $Module->redirectToView('view', array('full', $redirectNodeID));
}
示例#8
0
if (isset($Params['AttributeValidation'])) {
    $validation = $Params['AttributeValidation'];
}
$res = eZTemplateDesignResource::instance();
$keys = $res->keys();
if (isset($keys['layout'])) {
    $layout = $keys['layout'];
} else {
    $layout = false;
}
$viewParameters = array('offset' => $Offset, 'year' => $Year, 'month' => $Month, 'day' => $Day, 'namefilter' => false);
$viewParameters = array_merge($viewParameters, $UserParameters);
$user = eZUser::currentUser();
eZDebugSetting::addTimingPoint('kernel-content-view', 'Operation start');
$operationResult = array();
if (eZOperationHandler::operationIsAvailable('content_read')) {
    $operationResult = eZOperationHandler::execute('content', 'read', array('node_id' => $NodeID, 'user_id' => $user->id(), 'language_code' => $LanguageCode), null, true);
}
if (isset($operationResult['status']) && $operationResult['status'] != eZModuleOperationInfo::STATUS_CONTINUE) {
    switch ($operationResult['status']) {
        case eZModuleOperationInfo::STATUS_HALTED:
        case eZModuleOperationInfo::STATUS_REPEAT:
            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'])) {
示例#9
0
 /**
  * Does the remove job.
  * Will use content_delete operation if available (workflow support)
  * @param array $aNodeID
  * @param bool $moveToTrash Indicates if we move content to trash or not. True by default
  * @internal
  */
 private function doRemove(array $aNodeID, $moveToTrash = true)
 {
     if (eZOperationHandler::operationIsAvailable('content_delete')) {
         $operationResult = eZOperationHandler::execute('content', 'delete', array('node_id_list' => $aNodeID, 'move_to_trash' => $moveToTrash), null, true);
     } else {
         eZContentOperationCollection::deleteObject($aNodeID, $moveToTrash);
     }
 }
示例#10
0
         return $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
     }
     // 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) {
示例#11
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));
 /**
  * Processes user activation
  *
  * @param eZUser $user
  * @param string $password
  */
 public static function processUserActivation($user, $password)
 {
     $ini = eZINI::instance();
     $tpl = eZTemplate::factory();
     $tpl->setVariable('user', $user);
     $tpl->setVariable('object', $user->contentObject());
     $tpl->setVariable('hostname', eZSys::hostname());
     $tpl->setVariable('password', $password);
     // Check whether account activation is required.
     $verifyUserType = $ini->variable('UserSettings', 'VerifyUserType');
     $sendUserMail = !!$verifyUserType;
     // For compatibility with old setting
     if ($verifyUserType === 'email' && $ini->hasVariable('UserSettings', 'VerifyUserEmail') && $ini->variable('UserSettings', 'VerifyUserEmail') !== 'enabled') {
         $verifyUserType = false;
     }
     if ($verifyUserType === 'email') {
         // Disable user account and send verification mail to the user
         $userID = $user->attribute('contentobject_id');
         // Create enable account hash and send it to the newly registered user
         $hash = md5(mt_rand() . time() . $userID);
         if (eZOperationHandler::operationIsAvailable('user_activation')) {
             eZOperationHandler::execute('user', 'activation', array('user_id' => $userID, 'user_hash' => $hash, 'is_enabled' => false));
         } else {
             eZUserOperationCollection::activation($userID, $hash, false);
         }
         // Log out current user
         eZUser::logoutCurrent();
         $tpl->setVariable('hash', $hash);
         $sendUserMail = true;
     } else {
         if ($verifyUserType) {
             $verifyUserTypeClass = false;
             // load custom verify user settings
             if ($ini->hasGroup('VerifyUserType_' . $verifyUserType)) {
                 if ($ini->hasVariable('VerifyUserType_' . $verifyUserType, 'File')) {
                     include_once $ini->variable('VerifyUserType_' . $verifyUserType, 'File');
                 }
                 $verifyUserTypeClass = $ini->variable('VerifyUserType_' . $verifyUserType, 'Class');
             }
             // try to call the verify user class with function verifyUser
             if ($verifyUserTypeClass && method_exists($verifyUserTypeClass, 'verifyUser')) {
                 $sendUserMail = call_user_func(array($verifyUserTypeClass, 'verifyUser'), $user, $tpl);
             } else {
                 eZDebug::writeWarning("Unknown VerifyUserType '{$verifyUserType}'", 'ngconnect/profile');
             }
         }
     }
     // send verification mail to user if email type or custom verify user type returned true
     if ($sendUserMail) {
         $mail = new eZMail();
         $templateResult = $tpl->fetch('design:user/registrationinfo.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');
             }
         }
         $mail->setSender($emailSender);
         if ($tpl->hasVariable('subject')) {
             $subject = $tpl->variable('subject');
         } else {
             $subject = ezpI18n::tr('kernel/user/register', 'Registration info');
         }
         $mail->setSubject($subject);
         $mail->setReceiver($user->attribute('email'));
         $mail->setBody($templateResult);
         eZMailTransport::send($mail);
     }
 }
示例#13
0
    $function = $http->postVariable('Function');
} else {
    $function = $Params['Function'];
}
if ($http->hasPostVariable('Key')) {
    $key = $http->postVariable('Key');
} else {
    $key = $Params['Key'];
}
if ($http->hasPostVariable('Value')) {
    $value = $http->postVariable('Value');
} else {
    $value = $Params['Value'];
}
// Set user preferences
if (eZOperationHandler::operationIsAvailable('user_preferences')) {
    $operationResult = eZOperationHandler::execute('user', 'preferences', array('key' => $key, 'value' => $value));
} else {
    eZPreferences::setValue($key, $value);
}
// For use by ajax calls
if ($function === 'set_and_exit') {
    eZDB::checkTransactionCounter();
    eZExecution::cleanExit();
}
if ($http->hasPostVariable('RedirectURIAfterSet')) {
    $url = $http->postVariable('RedirectURIAfterSet');
} else {
    // Extract URL to redirect to from user parameters.
    $urlArray = array_splice($Params['Parameters'], 3);
    foreach ($urlArray as $key => $val) {
示例#14
0
// - The total child count must be zero
// - There must be no object removal (i.e. it is the only node for the object)
if ( $totalChildCount == 0 )
{
    $canRemove = true;
    foreach ( $deleteResult as $item )
    {
        if ( $item['object_node_count'] <= 1 )
        {
            $canRemove = false;
            break;
        }
    }
    if ( $canRemove )
    {
        if ( eZOperationHandler::operationIsAvailable( 'content_removelocation' ) )
        {
            $operationResult = eZOperationHandler::execute( 'content',
                                                            'removelocation',
                                                             array( 'node_list' => array_keys( $deleteNodeIdArray ),
                                                                    'move_to_trash' => $moveToTrash ),
                                                              null, true );
        }
        else
        {
            eZContentOperationCollection::removeNodes( array_keys( $deleteNodeIdArray ) );
        }

        if ( $http->hasSessionVariable( 'RedirectURIAfterRemove' )
          && $http->sessionVariable( 'RedirectURIAfterRemove' ) )
        {
示例#15
0
$accountActivated = false;
$alreadyActive = false;
$isPending = false;
$accountKey = $hash ? eZUserAccountKey::fetchByKey($hash) : false;
if ($accountKey) {
    $accountActivated = true;
    $userID = $accountKey->attribute('user_id');
    $userContentObject = eZContentObject::fetch($userID);
    if (!$userContentObject instanceof eZContentObject) {
        return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
    }
    if ($userContentObject->attribute('main_node_id') != $mainNodeID) {
        return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
    }
    // Enable user account
    if (eZOperationHandler::operationIsAvailable('user_activation')) {
        $operationResult = eZOperationHandler::execute('user', 'activation', array('user_id' => $userID, 'user_hash' => $hash, 'is_enabled' => true));
    } else {
        eZUserOperationCollection::activation($userID, $hash, true);
    }
    // execute operation to publish the user object
    $publishResult = eZOperationHandler::execute('user', 'register', array('user_id' => $userID));
    if ($publishResult['status'] === eZModuleOperationInfo::STATUS_HALTED) {
        $isPending = true;
    } else {
        // Log in user
        $user = eZUser::fetch($userID);
        if ($user === null) {
            return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
        }
        $user->loginCurrent();
示例#16
0
$userObject = $user->attribute('contentobject');
if (!$userObject) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$userSetting = eZUserSetting::fetch($UserID);
if ($http->hasPostVariable("UpdateSettingButton")) {
    $isEnabled = 0;
    if ($http->hasPostVariable('max_login')) {
        $maxLogin = $http->postVariable('max_login');
    } else {
        $maxLogin = $userSetting->attribute('max_login');
    }
    if ($http->hasPostVariable('is_enabled')) {
        $isEnabled = 1;
    }
    if (eZOperationHandler::operationIsAvailable('user_setsettings')) {
        $operationResult = eZOperationHandler::execute('user', 'setsettings', array('user_id' => $UserID, 'is_enabled' => $isEnabled, 'max_login' => $maxLogin));
    } else {
        eZUserOperationCollection::setSettings($UserID, $isEnabled, $maxLogin);
    }
    $Module->redirectTo('/content/view/full/' . $userObject->attribute('main_node_id'));
    return;
}
if ($http->hasPostVariable("CancelSettingButton")) {
    $Module->redirectTo('/content/view/full/' . $userObject->attribute('main_node_id'));
    return;
}
if ($http->hasPostVariable("ResetFailedLoginButton")) {
    // Reset number of failed login attempts
    eZUser::setFailedLoginAttempts($UserID, 0, true);
}
 /**
  * Adds a location to provided content.
  * Prefer using SQLIContent::addLocation() instead of calling this method directly
  * @param SQLILocation $location
  * @param SQLIContent $content
  * @internal
  */
 public function addLocationToContent(SQLILocation $location, SQLIContent $content)
 {
     $nodeID = $content->attribute('main_node_id');
     if (!$nodeID) {
         // No main node ID, object has not been published at least once
         throw new SQLIContentException(__METHOD__ . ' => Cannot directly add a location to a not-yet-published content. Content Object ID = ' . $content->attribute('id') . '. Try to use SQLIContent::addLocation()');
     }
     $objectID = $content->attribute('id');
     $locationNodeID = $location->getNodeID();
     // Check first if content has already an assigned node in provided location
     $assignedNodes = $content->assignedNodes(false);
     for ($i = 0, $iMax = count($assignedNodes); $i < $iMax; ++$i) {
         if ($locationNodeID == $assignedNodes[$i]['parent_node_id']) {
             eZDebug::writeWarning(__METHOD__ . ' => Content with ObjectID #' . $objectID . ' already has a location as a child of node #' . $locationNodeID);
             return;
         }
     }
     eZDebug::accumulatorStart('sqlicontentpublisher_add_location', 'sqlicontentpublisher', 'Adding a location for object #' . $objectID);
     $selectedNodeIDArray = array($locationNodeID);
     if (eZOperationHandler::operationIsAvailable('content_addlocation')) {
         $operationResult = eZOperationHandler::execute('content', 'addlocation', array('node_id' => $nodeID, 'object_id' => $objectID, 'select_node_id_array' => $selectedNodeIDArray), null, true);
     } else {
         eZContentOperationCollection::addAssignment($nodeID, $objectID, $selectedNodeIDArray);
     }
     $content->refreshLocations();
     eZDebug::accumulatorStop('sqlicontentpublisher_add_location');
 }
示例#18
0
     $Module->hasActionParameter( 'SelectedStateIDList' ) and
     $Module->hasActionParameter( 'ObjectID' ) )
{
    $selectedStateIDList = $Module->actionParameter( 'SelectedStateIDList' );
    $objectID = $Module->actionParameter( 'ObjectID' );
}
else
{
    $objectID = isset( $Params['ObjectID'] ) ? $Params['ObjectID'] : false;
    $selectedStateIDList = isset( $Params['SelectedStateID'] ) ? array( $Params['SelectedStateID'] ) : false ;
}

// Change object's state
if ( $objectID and $selectedStateIDList )
{
    if ( eZOperationHandler::operationIsAvailable( 'content_updateobjectstate' ) )
    {
        $operationResult = eZOperationHandler::execute( 'content', 'updateobjectstate',
                                                        array( 'object_id'     => $objectID,
                                                               'state_id_list' => $selectedStateIDList ) );
    }
    else
    {
        eZContentOperationCollection::updateObjectState( $objectID, $selectedStateIDList );
    }

    // Redirect to the provided URI, or to the root if not provided.
    // @TODO : in case this view is called through Ajax, make sure the module ends another way.
    $Module->hasActionParameter( 'RedirectRelativeURI' ) ? $Module->redirectTo( $Module->actionParameter( 'RedirectRelativeURI' ) ) : $Module->redirectTo( '/' );
}
elseif ( $objectID )
 /**
  * Updating priority sorting for given node
  *
  * @since 1.2
  * @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 instanceof eZContentObjectTreeNode) {
         throw new InvalidArgumentException("Argument ContentNodeID: '{$contentNodeID}' does not exist");
     } else {
         if (!$contentNode->canEdit()) {
             throw new InvalidArgumentException("Argument ContentNodeIDs: '{$contentNodeID}' is not available");
         }
     }
     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::clearContentCacheIfNeeded($objectID);
     }
 }
 /**
  * Send activativation to the user
  *
  * If the user is enabled, igore
  */
 public static function sendActivationEmail($userID)
 {
     eZDebugSetting::writeNotice('kernel-user', 'Sending activation email.', 'user register');
     $ini = eZINI::instance();
     $tpl = eZTemplate::factory();
     $user = eZUser::fetch($userID);
     $tpl->setVariable('user', $user);
     $object = eZContentObject::fetch($userID);
     $tpl->setVariable('object', $object);
     $hostname = eZSys::hostname();
     $tpl->setVariable('hostname', $hostname);
     // Check whether account activation is required.
     $verifyUserType = $ini->variable('UserSettings', 'VerifyUserType');
     $sendUserMail = !!$verifyUserType;
     if ($verifyUserType === 'email') {
         // Disable user account and send verification mail to the user
         // Create enable account hash and send it to the newly registered user
         $hash = md5(mt_rand() . time() . $userID);
         if (eZOperationHandler::operationIsAvailable('user_activation')) {
             $operationResult = eZOperationHandler::execute('user', 'activation', array('user_id' => $userID, 'user_hash' => $hash, 'is_enabled' => false));
         } else {
             eZUserOperationCollection::activation($userID, $hash, false);
         }
         $tpl->setVariable('hash', $hash);
         $sendUserMail = true;
     } else {
         if ($verifyUserType) {
             $verifyUserTypeClass = false;
             // load custom verify user settings
             if ($ini->hasGroup('VerifyUserType_' . $verifyUserType)) {
                 if ($ini->hasVariable('VerifyUserType_' . $verifyUserType, 'File')) {
                     include_once $ini->variable('VerifyUserType_' . $verifyUserType, 'File');
                 }
                 $verifyUserTypeClass = $ini->variable('VerifyUserType_' . $verifyUserType, 'Class');
             }
             // try to call the verify user class with function verifyUser
             $user = eZContentObject::fetch($userID);
             if ($verifyUserTypeClass && method_exists($verifyUserTypeClass, 'verifyUser')) {
                 $sendUserMail = call_user_func(array($verifyUserTypeClass, 'verifyUser'), $user, $tpl);
             } else {
                 eZDebug::writeWarning("Unknown VerifyUserType '{$verifyUserType}'", 'user/register');
             }
         }
     }
     // send verification mail to user if email type or custum verify user type returned true
     if ($sendUserMail) {
         $templateResult = $tpl->fetch('design:user/registrationinfo.tpl');
         if ($tpl->hasVariable('content_type')) {
             $contentType = $tpl->variable('content_type');
         } else {
             $contentType = $ini->variable('MailSettings', 'ContentType');
         }
         $emailSender = $ini->variable('MailSettings', 'EmailSender');
         if ($tpl->hasVariable('email_sender')) {
             $emailSender = $tpl->variable('email_sender');
         } else {
             if (!$emailSender) {
                 $emailSender = $ini->variable('MailSettings', 'AdminEmail');
             }
         }
         if ($tpl->hasVariable('subject')) {
             $subject = $tpl->variable('subject');
         } else {
             $subject = ezpI18n::tr('kernel/user/register', 'Registration info');
         }
         $mail = new eZMail();
         $mail->setSender($emailSender);
         $mail->setContentType($contentType);
         $user = eZUser::fetch($userID);
         $receiver = $user->attribute('email');
         $mail->setReceiver($receiver);
         $mail->setSubject($subject);
         $mail->setBody($templateResult);
         $mailResult = eZMailTransport::send($mail);
     }
     return array('status' => eZModuleOperationInfo::STATUS_CONTINUE);
 }
示例#21
0
 public function applyTo(eZContentObject $object)
 {
     $sectionID = $this->attribute("id");
     $currentUser = eZUser::currentUser();
     if (!$currentUser->canAssignSectionToObject($sectionID, $object)) {
         eZDebug::writeError("You do not have permissions to assign the section <" . $selectedSection->attribute("name") . "> to the object <" . $object->attribute("name") . ">.");
         return false;
     }
     $db = eZDB::instance();
     $db->begin();
     $assignedNodes = $object->attribute("assigned_nodes");
     if (!empty($assignedNodes)) {
         if (eZOperationHandler::operationIsAvailable("content_updatesection")) {
             foreach ($assignedNodes as $node) {
                 eZOperationHandler::execute("content", "updatesection", array("node_id" => $node->attribute("node_id"), "selected_section_id" => $sectionID), null, true);
             }
         } else {
             foreach ($assignedNodes as $node) {
                 eZContentOperationCollection::updateSection($node->attribute("node_id"), $sectionID);
             }
         }
     } 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='{$sectionID}' WHERE id = '{$objectID}'");
         $db->query("UPDATE ezsearch_object_word_link SET section_id='{$sectionID}' WHERE  contentobject_id = '{$objectID}'");
     }
     eZContentCacheManager::clearContentCacheIfNeeded($object->attribute("id"));
     $object->expireAllViewCache();
     $db->commit();
 }
示例#22
0
            $users = eZPersistentObject::fetchObjectList( eZUser::definition(),
                                                       null,
                                                       array( 'email' => $email ),
                                                       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();
示例#23
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')) {
         $http = eZHTTPTool::instance();
         $user = eZUser::currentUser();
         $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $object->attribute('id'), 'version' => $version->attribute('version')));
         // Break here if the publishing failed
         if ($operationResult['status'] !== eZModuleOperationInfo::STATUS_CONTINUE) {
             eZDebug::writeError('User object(' . $object->attribute('id') . ') could not be published.', 'user/register');
             $module->redirectTo('/user/register/3');
             return;
         }
         $object = eZContentObject::fetch($object->attribute('id'));
         // Check if user should be enabled and logged in
         unset($user);
         $user = eZUser::fetch($object->attribute('id'));
         $user->loginCurrent();
         $receiver = $user->attribute('email');
         $mail = new eZMail();
         if (!$mail->validate($receiver)) {
         }
         $ini = eZINI::instance();
         $tpl = eZTemplate::factory();
         $tpl->setVariable('user', $user);
         $tpl->setVariable('object', $object);
         $hostname = eZSys::hostname();
         $tpl->setVariable('hostname', $hostname);
         $password = $http->sessionVariable("GeneratedPassword");
         $tpl->setVariable('password', $password);
         // Check whether account activation is required.
         $verifyUserType = $ini->variable('UserSettings', 'VerifyUserType');
         $sendUserMail = !!$verifyUserType;
         // For compatibility with old setting
         if ($verifyUserType === 'email' && $ini->hasVariable('UserSettings', 'VerifyUserEmail') && $ini->variable('UserSettings', 'VerifyUserEmail') !== 'enabled') {
             $verifyUserType = false;
         }
         if ($verifyUserType === 'email') {
             // Disable user account and send verification mail to the user
             $userID = $object->attribute('id');
             // Create enable account hash and send it to the newly registered user
             $hash = md5(mt_rand() . time() . $userID);
             if (eZOperationHandler::operationIsAvailable('user_activation')) {
                 $operationResult = eZOperationHandler::execute('user', 'activation', array('user_id' => $userID, 'user_hash' => $hash, 'is_enabled' => false));
             } else {
                 eZUserOperationCollection::activation($userID, $hash, false);
             }
             // Log out current user
             eZUser::logoutCurrent();
             $tpl->setVariable('hash', $hash);
             $sendUserMail = true;
         } else {
             if ($verifyUserType) {
                 $verifyUserTypeClass = false;
                 // load custom verify user settings
                 if ($ini->hasGroup('VerifyUserType_' . $verifyUserType)) {
                     if ($ini->hasVariable('VerifyUserType_' . $verifyUserType, 'File')) {
                         include_once $ini->variable('VerifyUserType_' . $verifyUserType, 'File');
                     }
                     $verifyUserTypeClass = $ini->variable('VerifyUserType_' . $verifyUserType, 'Class');
                 }
                 // try to call the verify user class with function verifyUser
                 if ($verifyUserTypeClass && method_exists($verifyUserTypeClass, 'verifyUser')) {
                     $sendUserMail = call_user_func(array($verifyUserTypeClass, 'verifyUser'), $user, $tpl);
                 } else {
                     eZDebug::writeWarning("Unknown VerifyUserType '{$verifyUserType}'", 'user/register');
                 }
             }
         }
         // send verification mail to user if email type or custum verify user type returned true
         if ($sendUserMail) {
             $templateResult = $tpl->fetch('design:user/registrationinfo.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');
                 }
             }
             if ($tpl->hasVariable('subject')) {
                 $subject = $tpl->variable('subject');
             } else {
                 $subject = ezpI18n::tr('kernel/user/register', 'Registration info');
             }
             $mail->setSender($emailSender);
             $mail->setReceiver($receiver);
             $mail->setSubject($subject);
             $mail->setBody($templateResult);
             $mailResult = eZMailTransport::send($mail);
         }
         $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->removeSessionVariable("GeneratedPassword");
         $http->removeSessionVariable("RegisterUserID");
         $http->removeSessionVariable('StartedRegistration');
         // check for redirectionvariable
         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/');
             }
         }
     }
 }