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


PHP eZUser类代码示例

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


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

示例1: updateUser

 /**
  * Updates user with provided auth data
  *
  * @param eZUser $user
  * @param array $authResult
  *
  * @return bool
  */
 public static function updateUser($user, $authResult)
 {
     $currentTimeStamp = eZDateTime::currentTimeStamp();
     $contentObject = $user->contentObject();
     if (!$contentObject instanceof eZContentObject) {
         return false;
     }
     /** @var eZContentObjectVersion $version */
     $version = $contentObject->currentVersion();
     $db = eZDB::instance();
     $db->begin();
     $version->setAttribute('modified', $currentTimeStamp);
     $version->store();
     self::fillUserObject($version->dataMap(), $authResult);
     if ($authResult['email'] != $user->Email) {
         $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->setAttribute('email', $email);
         $user->store();
     }
     $contentObject->setName($contentObject->contentClass()->contentObjectName($contentObject));
     $contentObject->store();
     $db->commit();
     return $user;
 }
开发者ID:netgen,项目名称:ngconnect,代码行数:40,代码来源:ngconnectfunctions.php

示例2: fetchForClientUser

 /**
  * Returns the authorization object for a user & application
  * @param ezpRestClient $client
  * @param eZUser $user
  */
 public static function fetchForClientUser(ezpRestClient $client, eZUser $user)
 {
     $session = ezcPersistentSessionInstance::get();
     $q = $session->createFindQuery(__CLASS__);
     $q->where($q->expr->eq('rest_client_id', $q->bindValue($client->id)))->where($q->expr->eq('user_id', $q->bindValue($user->attribute('contentobject_id'))));
     $results = $session->find($q, __CLASS__);
     if (count($results) != 1) {
         return false;
     } else {
         return array_shift($results);
     }
 }
开发者ID:legende91,项目名称:ez,代码行数:17,代码来源:restauthorizedclient.php

示例3: passwordHasExpired

 /**
  * Writes audit information and redirects the user to the password change form.
  *
  * @param eZUser $user
  */
 protected static function passwordHasExpired($user)
 {
     $userID = $user->attribute('contentobject_id');
     // Password expired
     eZDebugSetting::writeDebug('kernel-user', $user, 'user password expired');
     // Failed login attempts should be logged
     $userIDAudit = isset($userID) ? $userID : 'null';
     $loginEscaped = eZDB::instance()->escapeString($user->attribute('login'));
     eZAudit::writeAudit('user-failed-login', array('User id' => $userIDAudit, 'User login' => $loginEscaped, 'Comment' => 'Failed login attempt: Password Expired. eZPaExUser::loginUser()'));
     // Redirect user to password change form
     self::redirectToChangePasswordForm($userID);
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:17,代码来源:ezpaexuser.php

示例4: create

    static function create( $name, $command, $userID = false )
    {
        if ( trim( $name ) == '' )
        {
            eZDebug::writeError( 'Empty name. You must supply a valid script name string.', 'ezscriptmonitor' );
            return false;
        }

        if ( trim( $command ) == '' )
        {
            eZDebug::writeError( 'Empty command. You must supply a valid command string.', 'ezscriptmonitor' );
            return false;
        }

        if ( !$userID )
        {
            $userID = eZUser::currentUserID();
        }

        $scriptMonitorIni = eZINI::instance( 'ezscriptmonitor.ini' );
        $scriptSiteAccess = $scriptMonitorIni->variable( 'GeneralSettings', 'ScriptSiteAccess' );
        $command = str_replace( self::SCRIPT_NAME_STRING, $name, $command );
        $command = str_replace( self::SITE_ACCESS_STRING, $scriptSiteAccess, $command );

        // Negative progress means not started yet
        return new self( array( 'name' => $name,
                                'command' => $command,
                                'last_report_timestamp' => time(),
                                'progress' => -1,
                                'user_id' => $userID ) );
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:31,代码来源:ezscheduledscript.php

示例5: fetchIDListByUserID

 static function fetchIDListByUserID($userID)
 {
     if ($userID == eZUser::anonymousId()) {
         $userCache = eZUSer::getUserCacheByAnonymousId();
         $ruleArray = $userCache['discount_rules'];
     } else {
         $http = eZHTTPTool::instance();
         $handler = eZExpiryHandler::instance();
         $expiredTimeStamp = 0;
         if ($handler->hasTimestamp('user-discountrules-cache')) {
             $expiredTimeStamp = $handler->timestamp('user-discountrules-cache');
         }
         $ruleTimestamp =& $http->sessionVariable('eZUserDiscountRulesTimestamp');
         $ruleArray = false;
         // check for cached version in session
         if ($ruleTimestamp > $expiredTimeStamp) {
             if ($http->hasSessionVariable('eZUserDiscountRules' . $userID)) {
                 $ruleArray =& $http->sessionVariable('eZUserDiscountRules' . $userID);
             }
         }
         if (!is_array($ruleArray)) {
             $ruleArray = self::generateIDListByUserID((int) $userID);
             $http->setSessionVariable('eZUserDiscountRules' . $userID, $ruleArray);
             $http->setSessionVariable('eZUserDiscountRulesTimestamp', time());
         }
     }
     $rules = array();
     foreach ($ruleArray as $ruleRow) {
         $rules[] = $ruleRow['id'];
     }
     return $rules;
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:32,代码来源:ezuserdiscountrule.php

示例6: authenticate

    public function authenticate( ezcAuthentication $auth, ezcMvcRequest $request )
    {
        if ( !$auth->run() )
        {
            $aStatuses = $auth->getStatus();
            $statusCode = null;
            foreach ( $aStatuses as $status )
            {
                if ( key( $status ) === 'ezpOauthFilter' )
                {
                    $statusCode = current( $status );
                    break;
                }
            }

            $request->variables['ezpAuth_redirUrl'] = $request->uri;
            $request->variables['ezpAuth_reason'] = $statusCode;
            $request->uri = "{$this->prefix}/auth/oauth/login";
            return new ezcMvcInternalRedirect( $request );
        }
        else
        {
            $user = eZUser::fetch( ezpOauthFilter::$tokenInfo->user_id );
            if ( !$user instanceof eZUser )
            {
                throw new ezpUserNotFoundException( ezpOauthFilter::$tokenInfo->user_id );
            }

            return $user;
        }
    }
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:31,代码来源:oauth.php

示例7: akismet_ContentActionHandler

function akismet_ContentActionHandler($module, $http, $objectID)
{
    $object = eZContentObject::fetch($objectID);
    $version = $object->attribute('current');
    if ($http->hasPostVariable('AkismetSubmitSpam')) {
        $user = eZUser::currentUser();
        $accessResult = $user->hasAccessTo('akismet', 'submit');
        if ($accessResult['accessWord'] === 'yes') {
            $mainNode = $object->attribute('main_node');
            $module->redirectTo($mainNode->attribute('url_alias'));
            $akismetObject = new eZContentObjectAkismet();
            $comment = $akismetObject->akismetInformationExtractor($version);
            if ($comment) {
                $akismet = new eZAkismet($comment);
                if ($akismet) {
                    $feedback = $akismet->submitSpam();
                    $response[] = $feedback[1];
                } else {
                    $response[] = ezi18n('extension/contactivity/akismet/submit', "An error has occured, unable to submit spam to Akismet.");
                }
            } else {
                $response[] = ezi18n('extension/contactivity/akismet/submit', "An error has occured, unable to submit spam to Akismet.");
            }
        }
        $mainNode = $object->attribute('main_node');
        $module->redirectTo($mainNode->attribute('url_alias'));
        return true;
    }
}
开发者ID:BGCX067,项目名称:ezakismet-svn-to-git,代码行数:29,代码来源:content_actionhandler.php

示例8: reCAPTCHAValidate

 static function reCAPTCHAValidate($http)
 {
     // check if the current user is able to bypass filling in the captcha and
     // return true without checking if so
     $currentUser = eZUser::currentUser();
     $accessAllowed = $currentUser->hasAccessTo('recaptcha', 'bypass_captcha');
     if ($accessAllowed["accessWord"] == 'yes') {
         return true;
     }
     $ini = eZINI::instance('recaptcha.ini');
     // If PrivateKey is an array try and find a match for the current host
     $privatekey = $ini->variable('Keys', 'PrivateKey');
     if (is_array($privatekey)) {
         $hostname = eZSys::hostname();
         if (isset($privatekey[$hostname])) {
             $privatekey = $privatekey[$hostname];
         } else {
             // try our luck with the first entry
             $privatekey = array_shift($privatekey);
         }
     }
     $recaptcha_challenge_field = $http->postVariable('recaptcha_challenge_field');
     $recaptcha_response_field = $http->postVariable('recaptcha_response_field');
     $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $recaptcha_challenge_field, $recaptcha_response_field);
     return $resp->is_valid;
 }
开发者ID:nfrp,项目名称:ezpublish-recaptcha,代码行数:26,代码来源:recaptchatype.php

示例9: testFetchUserList

    /**
     * Unit test for eZSubtreeNotificationRule::fetchUserList()
     */
    public function testFetchUserList()
    {
        // Add a notification rule for admin on root
        $adminUserID = eZUser::fetchByName( 'admin' )->attribute( 'contentobject_id' );
        $rule = new eZSubtreeNotificationRule( array(
            'user_id' => $adminUserID,
            'use_digest' => 0,
            'node_id' => 2 ) );
        $rule->store();

        // Create a content object below node #2
        $article = new ezpObject( 'article', 2 );
        $article->title = __FUNCTION__;
        $article->publish();
        $articleContentObject = $article->object;

        $list = eZSubtreeNotificationRule::fetchUserList( array( 2, 43 ), $articleContentObject );
        $this->assertInternalType( 'array', $list,
            "Return value should have been an array" );
        $this->assertEquals( 1, count( $list ),
            "Return value should have one item" );
        $this->assertInternalType( 'array', $list[0] );
        $this->assertArrayHasKey( 'user_id', $list[0] );
        $this->assertArrayHasKey( 'use_digest', $list[0] );
        $this->assertArrayHasKey( 'address', $list[0] );
        $this->assertEquals( 14, $list[0]['user_id'] );
        $this->assertEquals( 0, $list[0]['use_digest'] );
        $this->assertEquals( 'nospam@ez.no', $list[0]['address'] );
    }
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:32,代码来源:ezsubtreenotificationrule_test.php

示例10: tearDown

    /**
     * Called by PHPUnit after each test.
     */
    public function tearDown()
    {
        // Log in as whoever was logged in
        eZUser::setCurrentlyLoggedInUser( $this->currentUser, $this->currentUser->attribute( 'id' ) );

        parent::tearDown();
    }
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:10,代码来源:ezrss_export_test.php

示例11: getUserData

 public function getUserData()
 {
     $connection = $this->getFacebookConnection();
     $uid = $connection->getUser();
     if ($uid === 0) {
         throw new Exception('Could not get user ID. Refresh the page or try again later.');
     }
     $picture = 'var/cache/fb_profile_' . $uid . '.jpg';
     $fp = fopen($picture, 'w');
     $ch = curl_init(BaseFacebook::$DOMAIN_MAP['graph'] . '/' . $uid . '/picture?type=large');
     curl_setopt($ch, CURLOPT_TIMEOUT, 10);
     curl_setopt($ch, CURLOPT_FILE, $fp);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_exec($ch);
     curl_close($ch);
     fclose($fp);
     $data = $connection->api('/' . $uid);
     $login = $data['username'];
     $email = $data['email'];
     if (empty($login) || eZUser::fetchByName($login) instanceof eZUser) {
         $login = 'FacebookUser_' . $uid;
     }
     if (empty($email)) {
         $email = $uid . '@nospam.facebook.com';
     }
     return array('image' => $picture, 'user_account' => self::getUserAccountString($login, $email), 'first_name' => $data['first_name'], 'last_name' => $data['last_name']);
 }
开发者ID:sdaoudi,项目名称:nxc_social_networks,代码行数:27,代码来源:facebook.php

示例12: __construct

 /**
  * @param int $objectID ContentObjectID
  */
 public function __construct($objectID)
 {
     $userID = eZUser::currentUserID();
     $message = ezpI18n::tr('design/standard/error/kernel', 'Access denied') . '. ' . ezpI18n::tr('design/standard/error/kernel', 'You do not have permission to access this area.');
     eZLog::write("Access denied to content object #{$objectID} for user #{$userID}", 'error.log');
     parent::__construct($message);
 }
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:10,代码来源:access_denied.php

示例13: writeAudit

    /**
     * Writes $auditName with $auditAttributes as content
     * to file name that will be fetched from ini settings by auditNameSettings() for logging.
     *
     * @param string $auditName
     * @param array $auditAttributes
     * @return bool
     */
    static function writeAudit( $auditName, $auditAttributes = array() )
    {
        $enabled = eZAudit::isAuditEnabled();
        if ( !$enabled )
            return false;

        $auditNameSettings = eZAudit::auditNameSettings();

        if ( !isset( $auditNameSettings[$auditName] ) )
            return false;

        $ip = eZSys::clientIP();
        if ( !$ip )
            $ip = eZSys::serverVariable( 'HOSTNAME', true );

        $user = eZUser::currentUser();
        $userID = $user->attribute( 'contentobject_id' );
        $userLogin = $user->attribute( 'login' );

        $message = "[$ip] [$userLogin:$userID]\n";

        foreach ( array_keys( $auditAttributes ) as $attributeKey )
        {
            $attributeValue = $auditAttributes[$attributeKey];
            $message .= "$attributeKey: $attributeValue\n";
        }

        $logName = $auditNameSettings[$auditName]['file_name'];
        $dir = $auditNameSettings[$auditName]['dir'];
        eZLog::write( $message, $logName, $dir );

        return true;
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:41,代码来源:ezaudit.php

示例14: process

 /**
  * Main method to process current row returned by getNextRow() method.
  * You may throw an exception if something goes wrong. It will be logged but won't break the import process
  * @param mixed $row Depending on your data format, can be DOMNode, SimpleXMLIterator, SimpleXMLElement, CSV row...
  */
 public function process($row)
 {
     $contentOptions = new SQLIContentOptions(array('class_identifier' => 'user', 'remote_id' => (string) $row->login));
     $content = SQLIContent::create($contentOptions);
     $content->fields->first_name = (string) $row->firstName;
     $content->fields->last_name = (string) $row->lastName;
     $userParts = array((string) $row->login, (string) $row->email);
     //password management : if empty, generate it, use custom default or fixed default
     $password = $row->password;
     if (!$password) {
         if (isset($this->options->generate_password) && $this->options->generate_password) {
             $password = eZUser::createPassword(6);
         } elseif (isset($this->options->default_password) && $this->options->default_password) {
             $password = $this->options->default_password;
         } else {
             $password = '_ezpassword';
         }
     }
     $userParts[] = $password;
     $userParts[] = eZUser::createHash((string) $row->login, $password, eZUser::site(), eZUser::hashType());
     $userParts[] = eZUser::hashType();
     $content->fields->user_account = implode('|', $userParts);
     // Now publish content
     $content->addLocation(SQLILocation::fromNodeID($this->handlerConfArray['DefaultParentNodeID']));
     $publisher = SQLIContentPublisher::getInstance();
     $publisher->publish($content);
     // Free some memory. Internal methods eZContentObject::clearCache() and eZContentObject::resetDataMap() will be called
     // @see SQLIContent::__destruct()
     unset($content);
     $this->csv->rows->next();
 }
开发者ID:heliopsis,项目名称:SQLIImport,代码行数:36,代码来源:sqliusersimporthandler.php

示例15: enabled

    static function enabled()
    {
        if ( isset( $GLOBALS['eZHTTPHeaderCustom'] ) )
        {
            return $GLOBALS['eZHTTPHeaderCustom'];
        }

        $ini = eZINI::instance();
        if ( !$ini->hasVariable( 'HTTPHeaderSettings', 'CustomHeader' ) )
        {
            $GLOBALS['eZHTTPHeaderCustom'] = false;
        }
        else
        {
            if ( $ini->variable( 'HTTPHeaderSettings', 'CustomHeader' ) === 'enabled'
                 && $ini->hasVariable( 'HTTPHeaderSettings', 'OnlyForAnonymous' )
                 && $ini->variable( 'HTTPHeaderSettings', 'OnlyForAnonymous' ) === 'enabled' )
            {
                $user = eZUser::currentUser();
                $GLOBALS['eZHTTPHeaderCustom'] = !$user->isLoggedIn();
            }
            else
            {
                $GLOBALS['eZHTTPHeaderCustom'] = $ini->variable( 'HTTPHeaderSettings', 'CustomHeader' ) == 'enabled';
            }
        }

        return $GLOBALS['eZHTTPHeaderCustom'];
    }
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:29,代码来源:ezhttpheader.php


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