本文整理汇总了PHP中eZUser类的典型用法代码示例。如果您正苦于以下问题:PHP eZUser类的具体用法?PHP eZUser怎么用?PHP eZUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZUser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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( '[email protected]', $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
示例16: checkAccess
function checkAccess( $functionName, $contentObject )
{
if( $contentObject instanceof feZMetaData and $functionName)
{
$result = $contentObject->checkAccess( $functionName );
return array( 'result' => $result );
}
else
{
$user = eZUser::currentUser();
$userID = $user->attribute( 'contentobject_id' );
$accessResult = $user->hasAccessTo( 'fezmetadata', $functionName );
$accessWord = $accessResult['accessWord'];
if( $accessWord == 'yes' )
{
return 1;
}
else
{
return 0;
}
}
}
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:25,代码来源:fezmetadata_fetch_collection.php
示例17: testApprovalFatalErrorWhenMoving
/**
* Test regression for issue #13952: Workflow cronjob gives fatal error if
* node is moved to different location before approval.
*
* Test Outline
* ------------
* 1. Create a folder
* 2. Approve folder
* 3. Create child of folder
* 4. Approve child
* 5. Create a new version and re-publish the child
* 6. Move child to root
* 7. Approve child
* 8. Run approval cronjob
*
* @result: Fatal error: Call to a member function attribute() on a non-object in
* /www/trunk/kernel/content/ezcontentoperationcollection.php on line 313
* @expected: No fatal error
* @link http://issues.ez.no/13952
*/
public function testApprovalFatalErrorWhenMoving()
{
$anonymousObjectID = eZUser::fetchByName('anonymous')->attribute('contentobject_id');
// STEP 1: Create a folder
$folder = new ezpObject("folder", 2, $anonymousObjectID);
$folder->name = "Parent folder (needs approval)";
$folder->publish();
// STEP 2: Approve folder
$collaborationItem = eZCollaborationItem::fetch(1);
$this->approveCollaborationItem($collaborationItem);
$this->runWorkflow();
// STEP 3: Create child of folder
$child = new ezpObject("folder", $folder->mainNode->node_id, $anonymousObjectID);
$child->name = "Child folder (needs approval)";
$child->publish();
// STEP 4: Approve child
$collaborationItem = eZCollaborationItem::fetch(2);
$this->approveCollaborationItem($collaborationItem);
$this->runWorkflow();
// STEP 5: Re-publish child
$newVersion = $child->createNewVersion();
ezpObject::publishContentObject($child->object, $newVersion);
// STEP 6: Move child to root
$child->mainNode->move(2);
// STEP 7: Approve child again
$collaborationItem = eZCollaborationItem::fetch(3);
$this->approveCollaborationItem($collaborationItem);
// STEP 8: Run approval cronjob
$this->runWorkflow();
}
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:50,代码来源:ezapprovetype_regression.php
示例18: creator
function creator()
{
if (isset($this->CreatorID) and $this->CreatorID) {
return eZUser::fetch($this->CreatorID);
}
return null;
}
开发者ID:legende91,项目名称:ez,代码行数:7,代码来源:ezcontentclassgroup.php
示例19: modify
function modify(&$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
{
switch ($operatorName) {
case 'recaptcha_get_html':
include_once 'extension/recaptcha/classes/recaptchalib.php';
// Retrieve the reCAPTCHA public key from the ini file
$ini = eZINI::instance('recaptcha.ini');
$key = $ini->variable('Keys', 'PublicKey');
if (is_array($key)) {
$hostname = eZSys::hostname();
if (isset($key[$hostname])) {
$key = $key[$hostname];
} else {
// try our luck with the first entry
$key = array_shift($key);
}
}
// check if the current user is able to bypass filling in the captcha and
// return nothing so that no captcha is displayed
$currentUser = eZUser::currentUser();
$accessAllowed = $currentUser->hasAccessTo('recaptcha', 'bypass_captcha');
if ($accessAllowed["accessWord"] == 'yes') {
$operatorValue = 'User bypasses CAPTCHA';
} else {
// Run the HTML generation code from the reCAPTCHA PHP library
$operatorValue = recaptcha_get_html($key);
}
break;
}
}
开发者ID:landinsicht,项目名称:ezpublish-recaptcha,代码行数:30,代码来源:recaptchatemplateoperator.php
示例20: bookmarks
/**
* Gets current users bookmarks by offset and limit
*
* @param array $args 0 => offset:0, 1 => limit:10
* @return hash
*/
public static function bookmarks($args)
{
$offset = isset($args[0]) ? (int) $args[0] : 0;
$limit = isset($args[1]) ? (int) $args[1] : 10;
$http = eZHTTPTool::instance();
$user = eZUser::currentUser();
$sort = 'desc';
if (!$user instanceof eZUser) {
throw new ezcBaseFunctionalityNotSupportedException('Bookmarks retrival', 'current user object is not of type eZUser');
}
$userID = $user->attribute('contentobject_id');
if ($http->hasPostVariable('SortBy') && $http->postVariable('SortBy') !== 'asc') {
$sort = 'asc';
}
// fetch bookmarks
$count = eZPersistentObject::count(eZContentBrowseBookmark::definition(), array('user_id' => $userID));
if ($count) {
$objectList = eZPersistentObject::fetchObjectList(eZContentBrowseBookmark::definition(), null, array('user_id' => $userID), array('id' => $sort), array('offset' => $offset, 'length' => $limit), true);
} else {
$objectList = false;
}
// Simplify node list so it can be encoded
if ($objectList) {
$list = ezjscAjaxContent::nodeEncode($objectList, array('loadImages' => true, 'fetchNodeFunction' => 'fetchNode', 'fetchChildrenCount' => true), 'raw');
} else {
$list = array();
}
return array('list' => $list, 'count' => $count ? count($objectList) : 0, 'total_count' => (int) $count, 'offset' => $offset, 'limit' => $limit);
}
开发者ID:legende91,项目名称:ez,代码行数:35,代码来源:ezoeserverfunctions.php
注:本文中的eZUser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论