本文整理汇总了PHP中eZUser::currentUser方法的典型用法代码示例。如果您正苦于以下问题:PHP eZUser::currentUser方法的具体用法?PHP eZUser::currentUser怎么用?PHP eZUser::currentUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZUser
的用法示例。
在下文中一共展示了eZUser::currentUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onPublish
function onPublish($attribute, $contentObject, $publishedNodes)
{
$user = eZUser::currentUser();
$address = $user->attribute('email');
$userID = $user->attribute('contentobject_id');
$nodeIDList = eZSubtreeNotificationRule::fetchNodesForUserID($user->attribute('contentobject_id'), false);
if ($attribute->attribute('data_int') == '1') {
$newSubscriptions = array();
foreach ($publishedNodes as $node) {
if (!in_array($node->attribute('node_id'), $nodeIDList)) {
$newSubscriptions[] = $node->attribute('node_id');
}
}
foreach ($newSubscriptions as $nodeID) {
$rule = eZSubtreeNotificationRule::create($nodeID, $userID);
$rule->store();
}
} else {
foreach ($publishedNodes as $node) {
if (in_array($node->attribute('node_id'), $nodeIDList)) {
eZSubtreeNotificationRule::removeByNodeAndUserID($user->attribute('contentobject_id'), $node->attribute('node_id'));
}
}
}
return true;
}
示例2: 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;
}
示例3: 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;
}
}
示例4: checkIfLoggedIn
protected static function checkIfLoggedIn()
{
$ini = eZINI::instance('cookielaw.ini');
if (eZUser::currentUser()->isLoggedIn() && ($ini->hasVariable('UriExcludeList', 'ExcludeUserLoggedIn') && $ini->variable('UriExcludeList', 'ExcludeUserLoggedIn') == 'enabled')) {
self::$isActive = false;
}
}
示例5: 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;
}
}
示例6: 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;
}
示例7: 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'];
}
示例8: 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;
}
}
}
示例9: 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);
}
示例10: store
function store($fieldFilters = null)
{
$dateTime = time();
$user = eZUser::currentUser();
$this->setAttribute('modifier_id', $user->attribute('contentobject_id'));
$this->setAttribute('modified', $dateTime);
parent::store($fieldFilters);
}
示例11: sectionEditActionCheck
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 ) );
}
}
}
}
示例12: create
static function create($type, $text = false, $creatorID = false)
{
$date_time = time();
if ($creatorID === false) {
$user = eZUser::currentUser();
$creatorID = $user->attribute('contentobject_id');
}
return new eZCollaborationSimpleMessage(array('message_type' => $type, 'data_text1' => $text, 'creator_id' => $creatorID, 'created' => $date_time, 'modified' => $date_time));
}
示例13: eZOOImport
function eZOOImport()
{
$this->ERROR['number'] = 0;
$this->ERROR['value'] = '';
$this->ERROR['description'] = '';
$currentUser = eZUser::currentUser();
$this->currentUserID = $currentUser->id();
$this->ImportDir .= md5(time()) . "/";
}
示例14: setUp
public function setUp()
{
parent::setUp();
$currentUser = eZUser::currentUser();
$anonymousID = eZUser::anonymousId();
if ($currentUser->isRegistered()) {
self::$previousUserID = $currentUser->attribute('contentobject_id');
eZUser::setCurrentlyLoggedInUser(eZUser::fetch($anonymousID), $anonymousID);
}
}
示例15: eZOOImport
function eZOOImport()
{
$this->ERROR['number'] = 0;
$this->ERROR['value'] = '';
$this->ERROR['description'] = '';
$currentUser = eZUser::currentUser();
$this->currentUserID = $currentUser->id();
$this->ImportDir .= md5(time()) . "/";
$this->ooINI = eZINI::instance('odf.ini');
}