本文整理汇总了PHP中eZUser::anonymousId方法的典型用法代码示例。如果您正苦于以下问题:PHP eZUser::anonymousId方法的具体用法?PHP eZUser::anonymousId怎么用?PHP eZUser::anonymousId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZUser
的用法示例。
在下文中一共展示了eZUser::anonymousId方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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);
}
}
示例3: 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;
}
示例4: anonymousId
/**
* Gets the id of the anonymous user.
*
* @static
* @return int User id of anonymous user.
*/
public static function anonymousId()
{
if (self::$anonymousId === null) {
$ini = eZINI::instance();
self::$anonymousId = (int) $ini->variable('UserSettings', 'AnonymousUserID');
$GLOBALS['eZUserBuiltins'] = array(self::$anonymousId);
}
return self::$anonymousId;
}
示例5: update
/**
* Do all time based operations on block pool such as rotation, updating
* the queue, overflow as well as executes fetch interfaces.
*
* @static
*/
public static function update($nodeArray = array())
{
// log in user as anonymous if another user is logged in
$currentUser = eZUser::currentUser();
if ($currentUser->isLoggedIn()) {
$loggedInUser = $currentUser;
$anonymousUserId = eZUser::anonymousId();
$anonymousUser = eZUser::instance($anonymousUserId);
eZUser::setCurrentlyLoggedInUser($anonymousUser, $anonymousUserId);
unset($currentUser, $anonymousUser, $anonymousUserId);
}
include_once 'kernel/classes/ezcontentcache.php';
$ini = eZINI::instance('block.ini');
$db = eZDB::instance();
// Remove the blocks and items for the block if marked for removal
$res = $db->arrayQuery("SELECT id\n FROM ezm_block\n WHERE is_removed=1");
foreach ($res as $row) {
$blockID = $row['id'];
$db->begin();
$db->query("DELETE FROM ezm_pool\n WHERE block_id='{$blockID}'");
$db->query("DELETE FROM ezm_block\n WHERE id='{$blockID}'");
$db->commit();
}
if (!$nodeArray) {
// Update pool and pages for all nodes
$res = $db->arrayQuery("SELECT DISTINCT node_id FROM ezm_block");
foreach ($res as $row) {
$nodeArray[] = $row['node_id'];
}
}
foreach ($nodeArray as $nodeID) {
$time = time() - 5;
// a safety margin
$nodeChanged = false;
$blocks = $db->arrayQuery("SELECT *\n FROM ezm_block\n WHERE node_id={$nodeID}");
$blockByID = array();
// Determine the order of updating
$correctOrder = array();
$next = array();
foreach ($blocks as $block) {
$next[$block['id']] = trim($block['overflow_id']);
// Make sure that block ID does not any have spaces
$blockByID[$block['id']] = $block;
}
$nextIDs = array_keys($next);
foreach ($nextIDs as $id) {
if (in_array($id, $correctOrder, true)) {
continue;
}
if (!$next[$id]) {
$correctOrder[] = $id;
continue;
}
$subCorrectOrder = array($id);
$currentID = $id;
while ($nextID = $next[$currentID]) {
if (!in_array($nextID, $nextIDs, true)) {
eZDebug::writeWarning("Overflow for {$currentID} is {$nextID}, but no such block was found for the given node", __METHOD__);
break;
}
if (in_array($nextID, $subCorrectOrder, true)) {
eZDebug::writeWarning("Loop detected, ignoring ({$nextID} should be after {$currentID} and vice versa)", __METHOD__);
break;
}
if (in_array($nextID, $correctOrder, true)) {
break;
}
$subCorrectOrder[] = $nextID;
$currentID = $nextID;
}
if (!$nextID || !in_array($nextID, $correctOrder, true)) {
foreach ($subCorrectOrder as $element) {
$correctOrder[] = $element;
}
} else {
$newCorrectOrder = array();
foreach ($correctOrder as $element) {
if ($element === $nextID) {
foreach ($subCorrectOrder as $element2) {
$newCorrectOrder[] = $element2;
}
}
$newCorrectOrder[] = $element;
}
$correctOrder = $newCorrectOrder;
}
}
// Loop through all block in determined order
foreach ($correctOrder as $blockID) {
if ($blockByID[$blockID]) {
$block = $blockByID[$blockID];
} else {
continue;
}
//.........这里部分代码省略.........
示例6: userHasRated
/**
* Figgure out if current user has rated, since eZ Publish changes session id as of 4.1
* on login / logout, a couple of things needs to be checked.
* 1. Session variable 'ezsrRatedAttributeIdList' for list of attribute_id's
* 2a. (annonymus user) check against session key
* 2b. (logged in user) check against user id
*
* @param bool $returnRatedObject Return object if user has rated and [eZStarRating]AllowChangeRating=enabled
* @return bool|ezsrRatingDataObject
*/
function userHasRated($returnRatedObject = false)
{
if ($this->currentUserHasRated === null) {
$http = eZHTTPTool::instance();
if ($http->hasSessionVariable('ezsrRatedAttributeIdList')) {
$attributeIdList = explode(',', $http->sessionVariable('ezsrRatedAttributeIdList'));
} else {
$attributeIdList = array();
}
$ini = eZINI::instance();
$contentobjectAttributeId = $this->attribute('contentobject_attribute_id');
if (in_array($contentobjectAttributeId, $attributeIdList) && $ini->variable('eZStarRating', 'UseUserSession') === 'enabled') {
$this->currentUserHasRated = true;
}
$returnRatedObject = $returnRatedObject && $ini->variable('eZStarRating', 'AllowChangeRating') === 'enabled';
if ($this->currentUserHasRated === null || $returnRatedObject) {
$sessionKey = $this->attribute('session_key');
$userId = $this->attribute('user_id');
if ($userId == eZUser::anonymousId()) {
$cond = array('user_id' => $userId, 'session_key' => $sessionKey, 'contentobject_id' => $this->attribute('contentobject_id'), 'contentobject_attribute_id' => $contentobjectAttributeId);
} else {
$cond = array('user_id' => $userId, 'contentobject_id' => $this->attribute('contentobject_id'), 'contentobject_attribute_id' => $contentobjectAttributeId);
}
if ($returnRatedObject) {
$this->currentUserHasRated = eZPersistentObject::fetchObject(self::definition(), null, $cond);
if ($this->currentUserHasRated === null) {
$this->currentUserHasRated = false;
}
} else {
$this->currentUserHasRated = eZPersistentObject::count(self::definition(), $cond, 'id') != 0;
}
}
}
return $this->currentUserHasRated;
}
示例7: fetchObjectAttributeHTTPInput
/**
* Fetches all variables from the object
*
* @return bool true if fetching of class attributes are successfull, false if not
*/
function fetchObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
$contentObjectID = $contentObjectAttribute->attribute("contentobject_id");
// check if paex object for the current coID exists, create if needed.
$paex = $contentObjectAttribute->content();
if ($paex === null) {
$paex = eZPaEx::create($contentObjectID);
}
// Set current values as default ones
$passwordvalidationregexp = $paex->attribute('passwordvalidationregexp');
$passwordlifetime = $paex->attribute('passwordlifetime');
$expirationnotification = $paex->attribute('expirationnotification');
$passwordLastUpdated = $paex->attribute('password_last_updated');
$updatechildren = $paex->attribute('updatechildren');
$expirationnotificationSent = $paex->attribute('expirationnotification_sent');
// Update current values with new ones entered in the form if there are any
if ($http->hasPostVariable($base . "_data_paex_passwordvalidationregexp_" . $contentObjectAttribute->attribute("id"))) {
$passwordvalidationregexp = $http->postVariable($base . "_data_paex_passwordvalidationregexp_" . $contentObjectAttribute->attribute("id"));
}
if ($http->hasPostVariable($base . "_data_paex_passwordlifetime_" . $contentObjectAttribute->attribute("id"))) {
$passwordlifetime = $http->postVariable($base . "_data_paex_passwordlifetime_" . $contentObjectAttribute->attribute("id"));
}
if ($http->hasPostVariable($base . "_data_paex_expirationnotification_" . $contentObjectAttribute->attribute("id"))) {
$expirationnotification = $http->postVariable($base . "_data_paex_expirationnotification_" . $contentObjectAttribute->attribute("id"));
}
// Be sure passwordlifetime is set
if (trim($passwordlifetime) == '') {
$passwordlifetime = eZPaEx::NOT_DEFINED;
}
// Be sure expirationnotification is set
if (trim($expirationnotification) == '') {
$expirationnotification = eZPaEx::NOT_DEFINED;
}
// If we are editing a user account set it's password_last_updated as needed.
if ($paex->isUser()) {
// Search for password entered in the form
$newPassword = "";
foreach ($http->postVariable($base . '_id') as $coaid) {
if ($http->hasPostVariable($base . '_data_user_password_' . $coaid)) {
$newPassword = $http->postVariable($base . '_data_user_password_' . $coaid);
break;
}
}
// Check if the password has changed
if (trim($newPassword) && $newPassword != "_ezpassword") {
$currentUserID = eZUser::currentUserID();
if ($currentUserID == $contentObjectID) {
// If self editing, set last_updated to current time
$passwordLastUpdated = time();
// if audit is enabled password changes should be logged
eZAudit::writeAudit('user-password-change-self', array());
} else {
if ($currentUserID == eZUser::anonymousId()) {
// register, @see http://issues.ez.no/15391
$passwordLastUpdated = time();
} else {
// If changing other user's password, set last_updated to 0 to force
// password change in the next connection
$passwordLastUpdated = 0;
// if audit is enabled password changes should be logged
$targetUser = eZUser::fetch($contentObjectID);
eZAudit::writeAudit('user-password-change', array('User id' => $targetUser->attribute('contentobject_id'), 'User login' => $targetUser->attribute('login')));
}
}
// Password has changed, reset expirationnotification_sent flag to send again a notification when this new password be about to expire
$expirationnotificationSent = 0;
}
} else {
// If we are updating a user group and don't have the updatechildren post var, set updatechildren flag to disabled
if ($http->hasPostVariable($base . "_data_paex_updatechildren_" . $contentObjectAttribute->attribute("id"))) {
$updatechildren = $http->postVariable($base . "_data_paex_updatechildren_" . $contentObjectAttribute->attribute("id"));
} else {
$updatechildren = 0;
}
}
if ($paex->canEdit()) {
// If user has permission, update full paex object with possible new values
$paex->setInformation($contentObjectID, $passwordvalidationregexp, $passwordlifetime, $expirationnotification, $passwordLastUpdated, $updatechildren, $expirationnotificationSent);
} else {
// If user don't have permission to update paex data, only update the password_last_updated and expirationnotification_sent fields
$paex->setAttribute('password_last_updated', $passwordLastUpdated);
$paex->setAttribute('expirationnotification_sent', $expirationnotificationSent);
}
$contentObjectAttribute->setContent($paex);
return true;
}
示例8: definition
static function definition()
{
$def = array('fields' => array('id' => array('name' => 'ID', 'datatype' => 'integer', 'default' => 0, 'required' => true), 'survey_id' => array('name' => 'SurveyID', 'datatype' => 'integer', 'default' => 0, 'required' => true), 'user_id' => array('name' => 'UserID', 'datatype' => 'integer', 'default' => eZUser::anonymousId(), 'required' => false), 'tstamp' => array('name' => 'TStamp', 'datatype' => 'integer', 'default' => 0, 'required' => false), 'user_session_id' => array('name' => 'UserSessionID', 'datatype' => 'string', 'default' => '', 'required' => false)), 'keys' => array('id'), 'function_attributes' => array('question_results' => 'fetchQuestionResultList'), 'increment_key' => 'id', 'class_name' => 'eZSurveyResult', 'sort' => array('id' => 'asc'), 'name' => 'ezsurveyresult');
return $def;
}
示例9: eZFetchActiveSessionCount
function eZFetchActiveSessionCount($params = array())
{
$filterType = $params['filter_type'];
switch ($filterType) {
case 'registered':
$filterSQL = ' ezsession.user_id != ' . eZUser::anonymousId();
break;
case 'anonymous':
$filterSQL = ' ezsession.user_id = ' . eZUser::anonymousId();
break;
case 'everyone':
default:
$filterSQL = '';
break;
}
$expirationFilterType = $params['expiration_filter'];
$userID = $params['user_id'];
if ($userID) {
$filterSQL = ' ezsession.user_id = ' . (int) $userID;
}
switch ($expirationFilterType) {
case 'active':
$ini = eZINI::instance();
$time = time();
$activityTimeout = $ini->variable('Session', 'ActivityTimeout');
$sessionTimeout = $ini->variable('Session', 'SessionTimeout');
$time = $time + $sessionTimeout - $activityTimeout;
$expirationFilterSQL = '';
if (strlen($filterSQL) > 0) {
$expirationFilterSQL .= ' AND ';
}
$expirationFilterSQL .= ' ezsession.expiration_time > ' . $time;
break;
case 'all':
default:
$expirationFilterSQL = '';
break;
}
$whereSQL = '';
if (strlen($filterSQL) + strlen($expirationFilterSQL) > 0) {
$whereSQL = 'WHERE';
}
$db = eZDB::instance();
$query = "SELECT count( DISTINCT ezsession.user_id ) AS count\n FROM ezsession\n {$whereSQL}\n {$filterSQL}\n {$expirationFilterSQL}";
$rows = $db->arrayQuery($query);
return $rows[0]['count'];
}
示例10: is_object
}
// Check if content class for newsletter exists
$setup["content_classes_ok"] = is_object(eZContentClass::fetchByIdentifier('jaj_newsletter'));
// Check for newsletter folder
$newsletter_id = $newsletter_ini->variable('NewsletterSettings', 'RootFolderNodeId');
$newsletter_node = eZContentObject::fetchByNodeID($newsletter_id);
$setup["newsletter_folder_ok"] = $newsletter_id && is_object($newsletter_node);
$setup["newsletter_settings_ok"] = $newsletter_ini->variable('NewsletterSettings', 'FromEmail') && $newsletter_ini->variable('NewsletterSettings', 'FromName') && $newsletter_ini->variable('NewsletterSettings', 'ReplyEmail');
// Check for newsletter section
// And check that newsletter node is assigned to section
//$section = eZSection::fetchByIdentifier("jaj_newsletter");
$sections = eZSection::fetchList();
foreach ($sections as $s) {
if ($s->attribute("identifier") == "jaj_newsletter") {
$section = $s;
break;
}
}
if (is_object($newsletter_node) && is_object($section)) {
$setup["newsletter_section_ok"] = $newsletter_node->SectionID == $section->ID;
} else {
$setup["newsletter_section_ok"] = false;
}
// TODO: Add check for access rights for section
$anonymous = eZUser::fetch(eZUser::anonymousId());
//var_dump( $anonymous );
$jaj_subscription_access = $anonymous->hasAccessTo('jaj_newsletter', 'manage_subscription');
$setup["newsletter_sub_access_ok"] = $jaj_subscription_access["accessWord"] == "yes";
$tpl = eZTemplate::factory();
$tpl->setVariable('setup', $setup);
$Result = array('content' => $tpl->fetch('design:jaj_newsletter/settings/view.tpl'), 'path' => array(array('url' => 'jaj_newsletter/index', 'text' => ezpI18n::tr('jaj_newsletter/navigation', 'Newsletter')), array('url' => false, 'text' => ezpI18n::tr('jaj_newsletter/navigation', 'Settings'))));
示例11: get
/**
* @todo we should return an error if the scalar values are queried without a .0 appendeded...
*/
function get($oid)
{
// warm up list of existing oids, if not yet done
$this->oidList();
$internaloid = preg_replace('/\\.0$/', '', $oid);
if (array_key_exists($internaloid, self::$simplequeries)) {
$count = -1;
if (strpos($internaloid, '2.1.4.') === 0) {
// session-related queries: return -1 if not using db-based storage
$ini = eZINI::instance();
$sessionHandler = $ini->variable('Session', 'Handler');
if ($sessionHandler != 'ezpSessionHandlerDB') {
return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $count);
}
}
if (strpos($internaloid, '2.1.6.') === 0) {
// async-publication-related queries: return -1 if not using it
$ini = eZINI::instance('content.ini');
if ($ini->variable('PublishingSettings', 'AsynchronousPublishing') != 'enabled') {
return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $count);
}
}
$db = self::eZDBinstance();
if ($db) {
$results = $db->arrayQuery(str_replace('/*anonymousId*/', eZUser::anonymousId(), self::$simplequeries[$internaloid]));
$db->close();
if (is_array($results) && count($results)) {
$count = $results[0]['count'];
}
}
return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $count);
}
if (array_key_exists($internaloid, self::$orderstatuslist)) {
$oids = explode('.', $internaloid);
switch ($oids[5]) {
case '1':
return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => self::$orderstatuslist[$internaloid]);
case '2':
return array('oid' => $oid, 'type' => eZSNMPd::TYPE_STRING, 'value' => self::$orderstatuslist[$internaloid]);
case '3':
case '4':
$count = -1;
$db = self::eZDBinstance();
if ($db) {
$status = $db->arrayQuery('select count(*) as num from ezorder where is_temporary=0 and is_archived=' . ($oids[5] + 1) % 2 . ' and status_id=' . self::$orderstatuslist[$internaloid], array('column' => 'num'));
$db->close();
if (is_array($status) && count($status)) {
$count = $status[0];
}
}
return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $count);
}
}
if (array_key_exists($internaloid, self::$cachelist)) {
$cacheinfo = eZCache::fetchByID(self::$cachelist[$internaloid]);
$oids = explode('.', $internaloid);
switch ($oids[3]) {
case '1':
return array('oid' => $oid, 'type' => eZSNMPd::TYPE_STRING, 'value' => $cacheinfo['name']);
case '2':
return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => (int) $cacheinfo['enabled']);
case '3':
case '4':
$fileINI = eZINI::instance('file.ini');
$handlerName = $fileINI->variable('ClusteringSettings', 'FileHandler');
switch ($handlerName) {
case 'ezfs':
case 'eZFSFileHandler':
case 'eZFS2FileHandler':
break;
default:
// the db-based filehandlers + dfs one not yet supported
return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => -1);
}
// take care: this is hardcoded from knowledge of cache structure...
if (strpos($cacheinfo['path'], 'var/cache/') === 0) {
$cachedir = $cacheinfo['path'];
} else {
$cachedir = eZSys::cacheDirectory() . '/' . $cacheinfo['path'];
}
if ($oids[3] == '3') {
$out = (int) eZsnmpdTools::countFilesInDir($cachedir);
} else {
$out = (int) eZsnmpdTools::countFilesSizeInDir($cachedir);
}
return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $out);
}
}
if (array_key_exists($internaloid, self::$storagedirlist)) {
$oids = explode('.', $internaloid);
switch ($oids[3]) {
case '1':
return array('oid' => $oid, 'type' => eZSNMPd::TYPE_STRING, 'value' => self::$storagedirlist[$internaloid]);
case '2':
case '3':
$fileINI = eZINI::instance('file.ini');
$handlerName = $fileINI->variable('ClusteringSettings', 'FileHandler');
//.........这里部分代码省略.........