本文整理汇总了PHP中eZUser::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP eZUser::fetch方法的具体用法?PHP eZUser::fetch怎么用?PHP eZUser::fetch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZUser
的用法示例。
在下文中一共展示了eZUser::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modifier
function modifier()
{
if (isset($this->ModifierID) and $this->ModifierID) {
return eZUser::fetch($this->ModifierID);
}
return null;
}
示例2: 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;
}
}
示例3: getUser
/**
* Returns user who requested the import
* @return eZUser
*/
public function getUser()
{
if (!$this->user instanceof eZUser) {
$this->user = eZUser::fetch($this->attribute('user_id'));
}
return $this->user;
}
示例4: siteaccessCallFunction
public static function siteaccessCallFunction($siteaccesses = array(), $fnc = null)
{
$old_access = $GLOBALS['eZCurrentAccess'];
$ini = eZINI::instance('site.ini');
foreach ($siteaccesses as $siteaccess) {
/* Change the siteaccess */
self::changeAccess(array("name" => $siteaccess, "type" => EZ_ACCESS_TYPE_URI));
if ($ini->hasVariable('UserSettings', 'AnonymousUserID')) {
$user_id = $ini->variable('UserSettings', 'AnonymousUserID');
$user = eZUser::fetch($user_id);
if ($user instanceof eZUser) {
$user->loginCurrent();
try {
call_user_func($fnc);
} catch (Exception $e) {
eZCLI::instance()->output("Skipping access {$siteaccess}");
continue;
}
} else {
continue;
}
}
}
self::changeAccess($old_access);
}
示例5: creator
function creator()
{
if (isset($this->CreatorID) and $this->CreatorID) {
return eZUser::fetch($this->CreatorID);
}
return null;
}
示例6: setValue
static function setValue( $name, $value, $storeUserID = false )
{
$db = eZDB::instance();
$name = $db->escapeString( $name );
$rawValue = $value;
$value = $db->escapeString( $value );
$isCurrentUser = true;
if ( $storeUserID === false )
{
$user = eZUser::currentUser();
}
else
{
$currentID = eZUser::currentUserID();
if ( $currentID != $storeUserID )
$isCurrentUser = false;
$user = eZUser::fetch( $storeUserID );
if ( !is_object( $user ) )
{
eZDebug::writeError( "Cannot set preference for user $storeUserID, the user does not exist" );
return false;
}
}
// We must store the database changes if:
// a - The current user is logged in (ie. not anonymous)
// b - We have specified a specific user (not the current).
// in which case isLoggedIn() will fail.
if ( $storeUserID !== false or $user->isLoggedIn() )
{
// Only store in DB if user is logged in or we have
// a specific user ID defined
$userID = $user->attribute( 'contentobject_id' );
$existingRes = $db->arrayQuery( "SELECT * FROM ezpreferences WHERE user_id = $userID AND name='$name'" );
if ( count( $existingRes ) > 0 )
{
$prefID = $existingRes[0]['id'];
$query = "UPDATE ezpreferences SET value='$value' WHERE id = $prefID AND name='$name'";
$db->query( $query );
}
else
{
$query = "INSERT INTO ezpreferences ( user_id, name, value ) VALUES ( $userID, '$name', '$value' )";
$db->query( $query );
}
}
// We also store in session if this is the current user (anonymous or normal user)
// use $rawValue as value will be escaped by session code (see #014520)
if ( $isCurrentUser )
{
eZPreferences::storeInSession( $name, $rawValue );
}
return true;
}
示例7: address
/**
* Returns the email address of the user associated with the digest
* settings.
*
* @return string
*/
protected function address()
{
$user = eZUser::fetch($this->UserID);
if ($user instanceof eZUser) {
return $user->attribute('email');
}
return '';
}
示例8: authenticate
/**
* @see ezpRestAuthenticationStyleInterface::authenticate()
*/
public function authenticate(ezcAuthentication $auth, ezcMvcRequest $request)
{
if (!$auth->run() && $request->uri !== "{$this->prefix}/fatal") {
throw new ezpUserNotFoundException($auth->credentials->id);
} else {
return eZUser::fetch($auth->credentials->id);
}
}
示例9: userHasConnection
/**
* Returns if eZ Publish user has connection to specified social network
*
* @param int $userID
* @param string $loginMethod
*
* @return bool
*/
static function userHasConnection($userID, $loginMethod)
{
$count = eZPersistentObject::count(self::definition(), array('user_id' => $userID, 'login_method' => $loginMethod));
if ($count > 0) {
return true;
}
$user = eZUser::fetch($userID);
if (substr($user->Login, 0, 10 + strlen($loginMethod)) === 'ngconnect_' . $loginMethod) {
return true;
}
return false;
}
示例10: getAttributeContent
/**
* @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
* @param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
* @return array
*/
public static function getAttributeContent( eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute )
{
$user = eZUser::fetch( $contentObjectAttribute->attribute( "contentobject_id" ) );
return array(
'content' => array(
'id' => $user->attribute( 'id' ),
'login' => $user->attribute( 'login' ),
'email' => $user->attribute( 'email' ),
),
'has_rendered_content' => false,
'rendered' => null,
);
}
示例11: setAttribute
function setAttribute($attr, $val)
{
switch ($attr) {
case 'is_enabled':
if (!$val) {
$user = eZUser::fetch($this->UserID);
if ($user) {
eZUser::removeSessionData($this->UserID);
}
}
eZUser::purgeUserCacheByUserId($this->UserID);
break;
}
parent::setAttribute($attr, $val);
}
示例12: __construct
public function __construct()
{
$cli = eZCLI::instance();
$standard_options = "[h|help][legacy-help][q|quiet][d;*|debug;*][c|colors][no-colors][logfiles][no-logfiles][s:|siteaccess:][l:|login:][p:|password:][v*|verbose*]";
$script_options = "[f:|filter:*][o:|operation:*][and][or]";
// Fetch all command line options
$options = $cli->getOptions($standard_options . $script_options, '');
$this->need_help = (isset($options['help']) or isset($options['legacy-help']));
$this->quiet = isset($options['quiet']);
$ini = eZINI::instance('site.ini');
$iniBT = eZINI::instance('batchtool.ini');
// User to run the specified commands with (set to admin pr.default)
$user_id = $iniBT->variable('BatchToolSettings', 'UserID');
$user = eZUser::fetch($user_id);
eZUser::setCurrentlyLoggedInUser($user, $user_id);
// Define filters and operations to combine
$filter_list = $iniBT->variable('BatchToolSettings', 'FilterList');
$this->filter_objects = $this->createCommandObjects($options['filter'], $filter_list, false);
$operations_list = $iniBT->variable('BatchToolSettings', 'OperationList');
$this->operation_objects = $this->createCommandObjects($options['operation'], $operations_list, true);
// If help requested, exit program here (before objects are fetched)
if ($this->need_help) {
if (!isset($options['filter']) and !isset($options['operation'])) {
$cli->output('
php runcronjobs.php batchtool --filter="..." --operation="..." [--and|--or] [--legacy-help|--help]
--and - combine multiple filters with a logical and
--or - combine multiple filters with a logical or
--filter - filter to specify objects to run operations on
--operation - do something on the objects specified by any filter
Enabled filters:
' . implode("\n", $filter_list) . '
Enabled operations:
' . implode("\n", $operations_list) . '
');
}
return;
}
// Get objects requested by the specified filters
$this->object_list = $this->getObjectsFromFilters($options['and']);
unset($this->filter_objects);
}
示例13: execute
function execute( $xml )
{
$template = $xml->getAttribute( 'template' );
$receiverID = $xml->getAttribute( 'receiver' );
$nodeID = $xml->getAttribute( 'node' );
$ini = eZINI::instance();
$mail = new eZMail();
$tpl = eZTemplate::factory();
$node = eZContentObjectTreeNode::fetch( $nodeID );
if ( !$node )
{
$node = eZContentObjectTreeNode::fetch( 2 );
}
$emailSender = $ini->variable( 'MailSettings', 'EmailSender' );
if ( !$emailSender )
$emailSender = $ini->variable( "MailSettings", "AdminEmail" );
$receiver = eZUser::fetch( $receiverID );
if ( !$receiver )
{
$emailReceiver = $emailSender;
}
else
{
$emailReceiver = $receiver->attribute( 'email' );
}
$tpl->setVariable( 'node', $node );
$tpl->setVariable( 'receiver', $receiver );
$body = $tpl->fetch( 'design:' . $template );
$subject = $tpl->variable( 'subject' );
$mail->setReceiver( $emailReceiver );
$mail->setSender( $emailSender );
$mail->setSubject( $subject );
$mail->setBody( $body );
$mailResult = eZMailTransport::send( $mail );
return $mailResult;
}
示例14: addNews
function addNews(eZContentObjectTreeNode $node)
{
$ini = eZINI::instance('xrowsitemap.ini');
$news = new xrowSitemapItemNews();
$images = array();
// Adding the root node
$object = $node->object();
$news->publication_date = new DateTime('@' . $object->attribute('published'));
$news->title = $object->attribute('name');
$user = eZUser::fetch(eZUser::anonymousId());
if (!xrowSitemapTools::checkAccess($object, $user, 'read')) {
$news->access = 'Subscription';
}
// Get Genres, if enable
if ((!$ini->hasVariable('NewsSitemapSettings', 'UseGenres') || $ini->hasVariable('NewsSitemapSettings', 'UseGenres') && $ini->variable('NewsSitemapSettings', 'UseGenres') != 'disable') && $ini->hasVariable('NewsSitemapSettings', 'Genres')) {
$genres_array = $ini->variable('NewsSitemapSettings', 'Genres');
// set genre if set
if (isset($genres_array[$node->ClassIdentifier])) {
$news->genres = array($genres_array[$node->ClassIdentifier]);
}
}
$dm = $node->dataMap();
$news->keywords = array();
foreach ($dm as $attribute) {
switch ($attribute->DataTypeString) {
case 'xrowmetadata':
if ($attribute->hasContent()) {
$keywordattribute = $attribute->content();
$news->keywords = array_merge($news->keywords, $keywordattribute->keywords);
}
break;
case 'ezkeyword':
if ($attribute->hasContent()) {
$keywordattribute = $attribute->content();
$news->keywords = array_merge($news->keywords, $keywordattribute->KeywordArray);
}
break;
}
}
if ($ini->hasVariable('NewsSitemapSettings', 'AdditionalKeywordList')) {
$news->keywords = array_merge($news->keywords, $ini->variable('NewsSitemapSettings', 'AdditionalKeywordList'));
}
return $news;
}
示例15: afterUpdatingComment
/**
* clean up subscription after updating comment
* @see extension/ezcomments/classes/ezcomCommentManager#afterUpdatingComment($comment, $notified)
*/
public function afterUpdatingComment($comment, $notified, $time)
{
$user = eZUser::fetch($comment->attribute('user_id'));
// if notified is true, add subscription, else cleanup the subscription on the user and content
$contentID = $comment->attribute('contentobject_id');
$languageID = $comment->attribute('language_id');
$subscriptionType = 'ezcomcomment';
if (!is_null($notified)) {
$subscriptionManager = ezcomSubscriptionManager::instance();
if ($notified === true) {
//add subscription but not send activation
try {
$subscriptionManager->addSubscription($comment->attribute('email'), $user, $contentID, $languageID, $subscriptionType, $time, false);
} catch (Exception $e) {
eZDebug::writeError($e->getMessage(), __METHOD__);
switch ($e->getCode()) {
case ezcomSubscriptionManager::ERROR_SUBSCRIBER_DISABLED:
return 'The subscriber is disabled.';
default:
return false;
}
}
} else {
$subscriptionManager->deleteSubscription($comment->attribute('email'), $comment->attribute('contentobject_id'), $comment->attribute('language_id'));
}
}
//3. update queue. If there is subscription, add one record into queue table
// if there is subcription on this content, add one item into queue
if (ezcomSubscription::exists($contentID, $languageID, $subscriptionType)) {
$notification = ezcomNotification::create();
$notification->setAttribute('contentobject_id', $comment->attribute('contentobject_id'));
$notification->setAttribute('language_id', $comment->attribute('language_id'));
$notification->setAttribute('comment_id', $comment->attribute('id'));
$notification->store();
eZDebugSetting::writeNotice('extension-ezcomments', 'There are subscriptions, added an update notification to the queue.', __METHOD__);
} else {
// todo: if there is no subscription on this content, consider to clean up the queue
}
return true;
}