本文整理汇总了PHP中XenForo_Visitor::_instance方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Visitor::_instance方法的具体用法?PHP XenForo_Visitor::_instance怎么用?PHP XenForo_Visitor::_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Visitor
的用法示例。
在下文中一共展示了XenForo_Visitor::_instance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
/**
* Setup the visitor singleton.
*
* @param integer $userId User ID to setup as
* @param array $options
*
* @return XenForo_Visitor
*/
public static function setup($userId, array $options = array())
{
$userId = intval($userId);
$options = array_merge(array('languageId' => 0, 'permissionUserId' => 0), $options);
/* @var $userModel XenForo_Model_User */
$userModel = XenForo_Model::create('XenForo_Model_User');
$class = XenForo_Application::resolveDynamicClass('XenForo_Visitor');
$object = new $class();
if ($userId && ($user = $userModel->getVisitingUserById($userId))) {
if ($user['is_admin']) {
if ($options['permissionUserId']) {
// force permissions for testing
$user = $userModel->setPermissionsFromUserId($user, $options['permissionUserId']);
}
if ($options['languageId']) {
$user['admin_language_id'] = $user['language_id'] = $options['languageId'];
}
}
$object->_user = $user;
} else {
$object->_user = $userModel->getVisitingGuestUser();
if ($options['languageId']) {
$object->_user['language_id'] = $options['languageId'];
}
}
$object->_user = $userModel->prepareUser($object->_user);
$object->_user['referer'] = !empty($options['referer']) ? $options['referer'] : null;
$object->_user['from_search'] = !empty($options['fromSearch']);
if (!empty($object->_user['ignored'])) {
$ignored = XenForo_Helper_Php::safeUnserialize($object->_user['ignored']);
$object->_user['ignoredUsers'] = $ignored;
} else {
$object->_user['ignoredUsers'] = array();
}
if (!$object->_user['global_permission_cache']) {
// force a rebuild if we don't have the perm cache
$perms = XenForo_Model::create('XenForo_Model_Permission')->rebuildPermissionCombinationById($object->_user['permission_combination_id']);
$object->_user['permissions'] = $perms ? $perms : array();
} else {
$object->_user['permissions'] = XenForo_Permission::unserializePermissions($object->_user['global_permission_cache']);
}
$object->setVisitorLanguage($object->_user['language_id']);
XenForo_Locale::setDefaultTimeZone($object->_user['timezone']);
self::$_instance = $object;
self::$_setupOptions = $options;
XenForo_CodeEvent::fire('visitor_setup', array(&self::$_instance));
return self::$_instance;
}
示例2: setup
/**
* Setup the visitor singleton.
*
* @param integer $userId User ID to setup as
* @param array $options
*
* @return XenForo_Visitor
*/
public static function setup($userId, array $options = array())
{
$userId = intval($userId);
$options = array_merge(array('languageId' => 0, 'permissionUserId' => 0), $options);
/* @var $userModel XenForo_Model_User */
$userModel = XenForo_Model::create('XenForo_Model_User');
$object = new self();
if ($userId && ($user = $userModel->getVisitingUserById($userId))) {
if ($user['is_admin'] && $options['permissionUserId']) {
// force permissions for testing
$user = $userModel->setPermissionsFromUserId($user, $options['permissionUserId']);
}
$object->_user = $user;
} else {
$object->_user = $userModel->getVisitingGuestUser();
if ($options['languageId']) {
$object->_user['language_id'] = $options['languageId'];
}
}
$object->_user['referer'] = !empty($options['referer']) ? $options['referer'] : null;
$object->_user['from_search'] = !empty($options['fromSearch']);
$object->_user['is_robot'] = !empty($options['isRobot']);
$object->_user['permissions'] = XenForo_Permission::unserializePermissions($object->_user['global_permission_cache']);
$object->setVisitorLanguage($object->_user['language_id']);
XenForo_Locale::setDefaultTimeZone($object->_user['timezone']);
self::$_instance = $object;
XenForo_CodeEvent::fire('visitor_setup', array(&self::$_instance));
return self::$_instance;
}