当前位置: 首页>>代码示例>>PHP>>正文


PHP eZUser::logoutCurrent方法代码示例

本文整理汇总了PHP中eZUser::logoutCurrent方法的典型用法代码示例。如果您正苦于以下问题:PHP eZUser::logoutCurrent方法的具体用法?PHP eZUser::logoutCurrent怎么用?PHP eZUser::logoutCurrent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZUser的用法示例。


在下文中一共展示了eZUser::logoutCurrent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testLoginUserUseGroupAttributeEditUserObject

 /**
  * Test scenario for LDAP login using UseGroupAttribute, and editing the local user object
  *
  * Test Outline
  * ------------
  * 1. Set correct LDAPGroupMappingType
  * 2. Login with username and password
  * 3. Check parent nodes of user object
  * 4. Edit the object, verify it has changed
  * 5. Login again, verify that the locally changed data was overwritten by LDAP data and that the version number has increased
  *
  * @result:
  *   User is placed in the StarWars, Rogues and RebelAlliance groups.
  *   Last name is 'Cola'
  *   Version number is '2'
  *   Last name is 'Solo'
  *   Version number is '2'
  *   (Meaning: The object was updated, but no new version created.)
  * @expected:
  *   User is placed in the StarWars, Rogues and RebelAlliance groups.
  *   Last name is 'Cola'
  *   Version number is '2'
  *   Last name is 'Solo'
  *   Version number is '3'
  */
 public function testLoginUserUseGroupAttributeEditUserObject()
 {
     $this->ldapINI->setVariable('LDAPSettings', 'LDAPGroupMappingType', 'UseGroupAttribute');
     $this->ldapINI->setVariable('LDAPSettings', 'LDAPCreateMissingGroups', 'disabled');
     $this->ldapINI->setVariable('LDAPSettings', 'LDAPUserGroupAttributeType', 'name');
     $this->ldapINI->setVariable('LDAPSettings', 'LDAPUserGroupAttribute', 'ou');
     $user = eZLDAPUser::loginUser('han.solo', 'leiaishot');
     $contentObject = $user->attribute('contentobject');
     $parentNodeIDs = $contentObject->attribute('parent_nodes');
     sort($parentNodeIDs);
     self::assertEquals(array($this->starWarsGroupNodeId, $this->rebelGroupNodeId, $this->rogueGroupNodeId), $parentNodeIDs);
     // Edit the local user object, change last name
     $version = $contentObject->createNewVersion();
     $contentObjectAttributes = $version->contentObjectAttributes();
     foreach ($contentObjectAttributes as $attribute) {
         if ($attribute->attribute('contentclass_attribute_identifier') == 'last_name') {
             $attribute->setAttribute('data_text', 'Cola');
             $attribute->store();
             break;
         }
     }
     $contentObjectID = $contentObject->attribute('id');
     $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => $version->attribute('version')));
     $contentObject = eZContentObject::fetch($contentObjectID);
     $dataMap = $contentObject->dataMap();
     self::assertEquals('Cola', $dataMap['last_name']->attribute('data_text'));
     self::assertEquals('2', $version->attribute('version'));
     // Login again, verify that the locally changed data was overwritten by LDAP data and that the version number has increased
     eZUser::logoutCurrent();
     $user = eZLDAPUser::loginUser('han.solo', 'leiaishot');
     $contentObject = $user->attribute('contentobject');
     $dataMap = $contentObject->dataMap();
     $version = $contentObject->currentVersion();
     self::assertEquals('Solo', $dataMap['last_name']->attribute('data_text'));
     self::assertEquals('3', $version->attribute('version'));
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:61,代码来源:ezldapuser_test.php

示例2: checkUser

 function checkUser(&$siteBasics, $uri)
 {
     $http = eZHTTPTool::instance();
     $check = array("module" => "user", "function" => "login");
     if (eZSession::issetkey('eZUserLoggedInID', false) && $http->sessionVariable("eZUserLoggedInID") != '' && $http->sessionVariable("eZUserLoggedInID") != self::anonymousId()) {
         $currentUser = eZUser::currentUser();
         if (!$currentUser->isEnabled()) {
             eZUser::logoutCurrent();
             $currentUser = eZUser::currentUser();
         } else {
             return null;
         }
     }
     $ini = eZINI::instance();
     $moduleName = $uri->element();
     $viewName = $uri->element(1);
     $anonymousAccessList = $ini->variable("SiteAccessSettings", "AnonymousAccessList");
     foreach ($anonymousAccessList as $anonymousAccess) {
         $elements = explode('/', $anonymousAccess);
         if (!isset($elements[1])) {
             if ($moduleName == $elements[0]) {
                 return null;
             }
         } else {
             if ($moduleName == $elements[0] and $viewName == $elements[1]) {
                 return null;
             }
         }
     }
     return $check;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:31,代码来源:ezuser.php

示例3: processUserActivation

 /**
  * 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);
     }
 }
开发者ID:netgen,项目名称:ngconnect,代码行数:80,代码来源:ngconnectuseractivation.php

示例4: shutdown

 function shutdown($exitCode = false, $exitText = false)
 {
     $cli = eZCLI::instance();
     if (class_exists('eZDB') and eZDB::hasInstance()) {
         $db = eZDB::instance(false, array('show_errors' => false));
         // Perform transaction check
         $transactionCounterCheck = eZDB::checkTransactionCounter();
         if (isset($transactionCounterCheck['error'])) {
             $cli->error($transactionCounterCheck['error']);
         }
         if ($this->UseSession and $db->isConnected()) {
             eZUser::logoutCurrent();
             eZSession::remove();
         }
     }
     $webOutput = $cli->isWebOutput();
     if ($this->UseDebugOutput or eZDebug::isDebugEnabled()) {
         if ($this->DebugMessage) {
             fputs(STDERR, $this->DebugMessage);
         }
         fputs(STDERR, eZDebug::printReport(false, $webOutput, true, $this->AllowedDebugLevels, $this->UseDebugAccumulators, $this->UseDebugTimingPoints, $this->UseIncludeFiles));
     }
     eZExecution::cleanup();
     eZExecution::setCleanExit();
     $this->setIsInitialized(false);
     if ($exitCode !== false) {
         $this->ExitCode = $exitCode;
     }
     if ($this->ExitCode !== false) {
         if ($exitText !== false) {
             $cli->output($exitText);
         }
         exit($this->ExitCode);
     }
 }
开发者ID:nlescure,项目名称:ezpublish,代码行数:35,代码来源:ezscript.php

示例5: foreach

            foreach ($languageDataMap as $languageCode => $objectAttributes) {
                if ($languageCode != $initialLanguageCode && isset($objectAttributes[$sourceClassAttributeIdentifier]) && isset($objectAttributes[$destClassAttributeIdentifier])) {
                    $sourceObjectAttribute = $objectAttributes[$sourceClassAttributeIdentifier];
                    $destObjectAttribute = $objectAttributes[$destClassAttributeIdentifier];
                    if ($isDestClassAttributeTranslatable) {
                        if ($sourceObjectAttribute->hasContent()) {
                            $keywordArray = $sourceObjectAttribute->content()->keywordArray();
                            $tagsArray = array_merge(array_fill(0, count($keywordArray), '0'), $keywordArray, array_fill(0, count($keywordArray), $parentTagID));
                            $destObjectAttribute->fromString(implode('|#', $tagsArray));
                            $destObjectAttribute->store();
                        }
                    } else {
                        $destObjectAttribute->fromString($languageDataMap[$initialLanguageCode][$destClassAttributeIdentifier]->toString());
                        $destObjectAttribute->store();
                    }
                    unset($sourceObjectAttribute);
                    unset($destObjectAttribute);
                }
            }
            $db->commit();
            unset($languageDataMap);
            $cli->output("Converted object ID " . $object->attribute('id'));
        }
    }
    unset($objects);
    $offset += $limit;
}
$cli->output("Done!\n");
$cli->warning("For changes to take effect, please clear the caches, reindex your content and so on.\n");
eZUser::logoutCurrent();
$script->shutdown(0);
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:31,代码来源:convertezkeyword.php

示例6: testRunRegression

    /**
     * Runs the $file (.request file from $this->files) as a PHPUnit test.
     *
     * Steps performed:
     *  - setUp() is called automatically before this function
     *  - skip the test $file if declared. See {@link skip()}
     *  - identify test files attached to the .request file $file (.expected, .body)
     *  - initialize various global variables (together with $GLOBALS from setUp())
     *  - create an eZ Publish folder with the name $file
     *  - include $file (the .request file) as PHP code. $GLOBALS and $_SERVER values set in there
     *    will be used further on
     *  - initialize the WebDAV system like in webdav.php (it does NOT go through webdav.php)
     *  - create an eZWebDAVContentBackend object and use ezcWebdavServer to handle the
     *    WebDAV request specified in the .request file $file (through $_SERVER variables
     *    'REQUEST_METHOD' and 'REQUEST_URI' and others.
     *  - the output from the WebDAV system is collected in $GLOBALS['ezc_response_body']
     *    (through hacks in wrappers.php).
     *  - append the .body file contents to the $GLOBALS['ezc_response_body'] if it exists
     *  - clean the response and the .expected file with cleanForCompare() (eg. creation date, etags etc)
     *  - compare the response and the .expected file with assertEquals(). Same contents means the test passed.
     *  - tearDown() is called automatically after this function
     *
     * See doc/specifications/trunk/webdav/testing.txt for detailed information
     * about each $GLOBALS and $_SERVER variables.
     *
     * @param string $file
     */
    public function testRunRegression( $file )
    {
        // 'ezc' = use eZWebDAVContentBackend (new eZ Publish WebDAV based on ezcWebdav)
        // 'ezp' = use eZWebDAVContentServer  (old eZ Publish WebDAV)
        // Only 'ezc' is supported for now
        $system = 'ezc';

        // uncomment the tests that you want to skip in the skip() function
        $this->skip( $file );

        $error = '';
        $response = null;

        $outFile = $this->outFileName( $file, '.request', '.expected' );
        $bodyFile = $this->outFileName( $file, '.request', '.body' );

        $parts = pathinfo( $file );
        $GLOBALS['ezc_webdav_testfolder'] = $parts['filename'];

        // Create an eZ Publish folder for each test with the name of the test
        // $GLOBALS['ezc_webdav_testfolderid'] can be used in the .request file
        // to create file, image, folder etc under the test folder.
        $folder = new ezpObject( "folder", 2 );
        $folder->name = $GLOBALS['ezc_webdav_testfolder'];
        $folder->publish();
        $GLOBALS['ezc_webdav_testfolderobject'] = $folder;
        $GLOBALS['ezc_webdav_testfolderid'] = $folder->mainNode->node_id;

        // var_dump( $GLOBALS['ezc_webdav_testfolder'] . ' (' . $GLOBALS['ezc_webdav_testfolderid'] . ')' );

        //eZExtension::activateExtensions( 'default' );

        //eZModule::setGlobalPathList( array( "kernel" ) );

        eZUser::logoutCurrent();

        eZSys::init( 'webdav.php' );

        // include the .request file. $GLOBALS and $_SERVER defined in the file
        // will be used in the test
        include $file;

        // var_dump( '--- After include' );
        // These values can be overwritten in the included $file which contains the WebDAV request
        $username = $GLOBALS['ezc_webdav_username'];
        $password = $GLOBALS['ezc_webdav_password'];

        // Set the HTTP_AUTHORIZATION header
        $_SERVER['HTTP_AUTHORIZATION'] = 'Basic ' . base64_encode( "{$username}:{$password}" );
        // var_dump( 'Default REQUEST_URI: ' . $_SERVER['REQUEST_URI'] );

        if ( $system === 'ezc' )
        {
            // Use eZ Components
            // clean the REQUEST_URI and HTTP_DESTINATION
            $_SERVER['REQUEST_URI'] = urldecode( $_SERVER['REQUEST_URI'] );
            if ( isset( $_SERVER['HTTP_DESTINATION'] ) )
            {
                $_SERVER['HTTP_DESTINATION'] = urldecode( $_SERVER['HTTP_DESTINATION'] );
            }

            $server = ezcWebdavServer::getInstance();

            $backend = new eZWebDAVContentBackend();
            $server->configurations = new ezcWebdavServerConfigurationManagerWrapper();

            $server->init( new ezcWebdavBasicPathFactory( $GLOBALS['ezc_webdav_url'] ),
                           new ezcWebdavXmlTool(),
                           new ezcWebdavPropertyHandler(),
                           new ezcWebdavHeaderHandler(),
                           new ezcWebdavTransportWrapper() );

            $server->auth = new eZWebDAVContentBackendAuth();
//.........这里部分代码省略.........
开发者ID:nottavi,项目名称:ezpublish,代码行数:101,代码来源:backend_content_regression_test.php

示例7: checkContentActions

 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');
             }
//.........这里部分代码省略.........
开发者ID:rmiguel,项目名称:ezpublish,代码行数:101,代码来源:register.php


注:本文中的eZUser::logoutCurrent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。