本文整理汇总了PHP中XenForo_Visitor::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Visitor::getInstance方法的具体用法?PHP XenForo_Visitor::getInstance怎么用?PHP XenForo_Visitor::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Visitor
的用法示例。
在下文中一共展示了XenForo_Visitor::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDiscordLink
public function actionDiscordLink()
{
$this->_assertPostOnly();
$visitor = XenForo_Visitor::getInstance();
if (!$visitor->hasPermission('general', 'linkDiscord')) {
return $this->responseNoPermission();
}
$tokenModel = $this->_getTokenmodel();
$generate = $this->_input->filterSingle('create', XenForo_Input::STRING, array('default' => ''));
if (strlen($generate)) {
$dw = XenForo_DataWriter::create('DiscordAuth_DataWriter_Token');
$existing = $tokenModel->getTokenByUserId($visitor['user_id']);
if ($existing === false || !$existing['valid']) {
if ($existing !== false) {
$dw->setExistingData($existing, true);
}
try {
$dw->set('user_id', $visitor['user_id']);
$dw->set('token', self::generateToken());
$dw->save();
// self::generateToken may throw Exception
} catch (Exception $e) {
XenForo_Error::logException($e, false);
}
}
}
$unlink = $this->_input->filterSingle('unlink', XenForo_Input::STRING, array('default' => ''));
if (strlen($unlink)) {
$dw = XenForo_DataWriter::create('XenForo_DataWriter_User');
$dw->setExistingData($visitor['user_id']);
$dw->set('da_discord_id', null);
$dw->save();
}
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(XenForo_Link::buildPublicLink('account/discord')));
}
示例2: getUser
public function getUser()
{
$visitor = XenForo_Visitor::getInstance();
$userModel = XenForo_Model::create('XenForo_Model_User');
$userInfo = $userModel->getFullUserById($visitor->getUserId());
return $userInfo;
}
示例3: actionErrorServer
public function actionErrorServer()
{
$upgradePending = false;
try {
$db = XenForo_Application::getDb();
if ($db->isConnected()) {
$dbVersionId = $db->fetchOne("SELECT option_value FROM xf_option WHERE option_id = 'currentVersionId'");
if ($dbVersionId && $dbVersionId != XenForo_Application::$versionId) {
$upgradePending = true;
}
}
} catch (Exception $e) {
}
if (XenForo_Application::debugMode()) {
$showDetails = true;
} else {
if (XenForo_Visitor::hasInstance() && XenForo_Visitor::getInstance()->is_admin) {
$showDetails = true;
} else {
$showDetails = false;
}
}
if ($upgradePending && !$showDetails) {
return $this->responseMessage(new XenForo_Phrase('board_currently_being_upgraded'));
} else {
if ($showDetails) {
$view = $this->responseView('XenForo_ViewPublic_Error_ServerError', 'error_server_error', array('exception' => $this->_request->getParam('_exception')));
$view->responseCode = 500;
return $view;
} else {
return $this->responseError(new XenForo_Phrase('server_error_occurred'), 500);
}
}
}
示例4: actionTrash
public function actionTrash()
{
if (!XenForo_Visitor::getInstance()->hasPermission('forum', 'trashThreads')) {
throw $this->getErrorOrNoPermissionResponseException(false);
}
if (!($targetNode = XenForo_Application::getOptions()->nixfifty_trash_can)) {
return $this->responseError(new XenForo_Phrase('trash_can_node_not_set'));
}
$threadId = $this->_input->filterSingle('thread_id', XenForo_Input::UINT);
list($thread, $forum) = $this->getHelper('ForumThreadPost')->assertThreadValidAndViewable($threadId);
if ($this->isConfirmedPost()) {
$softDelete = $this->_input->filterSingle('trash_type', XenForo_Input::UINT);
$trashType = $softDelete ? 'move' : 'soft';
$options = array('reason' => $this->_input->filterSingle('reason', XenForo_Input::STRING));
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
$dw->setExistingData($threadId);
$dw->set('node_id', $targetNode);
$dw->save();
if ($trashType == 'soft' && XenForo_Visitor::getInstance()->hasPermission('forum', 'softDeleteTrashedThreads')) {
$this->_getThreadModel()->deleteThread($threadId, $trashType, $options);
XenForo_Model_Log::logModeratorAction('thread', $thread, 'delete_' . $trashType, array('reason' => $options['reason']));
}
XenForo_Model_Log::logModeratorAction('thread', $thread, 'move', array('from' => $forum['title']));
$this->_updateModeratorLogThreadEdit($thread, $dw, array('node_id'));
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('forums', $forum));
} else {
return $this->responseView('', 'trash_thread', array('thread' => $thread));
}
}
示例5: _messagePreSave
/**
*
* @see XenForo_DataWriter_DiscussionMessage_Post::_messagePreSave()
*/
protected function _messagePreSave()
{
if ($this->isDiscussionFirstMessage() && isset($GLOBALS['XenForo_ControllerPublic_Forum'])) {
$visitor = XenForo_Visitor::getInstance();
$this->set('original_poster_th', array('user_id' => $visitor->user_id, 'username' => $visitor->username));
}
if (!empty($GLOBALS['XenForo_ControllerPublic_Thread'])) {
/* @var $controller XenForo_ControllerPublic_Thread */
$controller = $GLOBALS['XenForo_ControllerPublic_Thread'];
$this->set('original_poster_th', array('user_id' => $this->get('user_id'), 'username' => $this->get('username')));
/* @var $userModel XenForo_Model_User */
$userModel = XenForo_Model::create('XenForo_Model_User');
$input = $controller->getInput()->filter(array('post_as_user_id' => XenForo_Input::UINT, 'post_as_username' => XenForo_Input::STRING));
if ($input['post_as_username']) {
$user = $userModel->getUserByName($input['post_as_username']);
$input['post_as_user_id'] = $user['user_id'];
}
if (!isset($user) && $input['post_as_user_id']) {
$user = $userModel->getUserById($input['post_as_user_id']);
}
if (isset($user) && $userModel->canPostAsDifferentUser($user)) {
$this->set('user_id', $user['user_id']);
$this->set('username', $user['username']);
if (XenForo_Application::get('options')->th_postAsUser_updateLastActivity) {
/* @var $userModel XenForo_Model_User */
$userModel = $this->getModelFromCache('XenForo_Model_User');
$request = $controller->getRequest();
$routeMatch = $controller->getRouteMatch();
$userModel->updateSessionActivity($user['user_id'], $request->getClientIp(false), $routeMatch->getControllerName(), $routeMatch->getAction(), 'valid', $request->getUserParams());
}
}
}
parent::_messagePreSave();
}
示例6: _getSessionActivityList
protected function _getSessionActivityList()
{
$visitor = XenForo_Visitor::getInstance();
/** @var $sessionModel XenForo_Model_Session */
$sessionModel = $this->getModelFromCache('XenForo_Model_Session');
return $sessionModel->getSessionActivityQuickList($visitor->toArray(), array('cutOff' => array('>', $sessionModel->getOnlineStatusTimeout())), $visitor['user_id'] ? $visitor->toArray() : null);
}
示例7: actionIndex
/**
* Single-stage logout procedure
*/
public function actionIndex()
{
$csrfToken = $this->_input->filterSingle('_xfToken', XenForo_Input::STRING);
$redirectResponse = $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(false, false));
$userId = XenForo_Visitor::getUserId();
if (!$userId) {
return $redirectResponse;
}
if ($this->_noRedirect() || !$csrfToken) {
// request is likely from JSON, probably XenForo.OverlayTrigger, so show a confirmation dialog
return $this->responseView('XenForo_ViewPublic_LogOut', 'log_out');
} else {
$this->_checkCsrfFromToken($csrfToken);
// remove an admin session if we're logged in as the same person
if (XenForo_Visitor::getInstance()->get('is_admin')) {
$class = XenForo_Application::resolveDynamicClass('XenForo_Session');
$adminSession = new $class(array('admin' => true));
$adminSession->start();
if ($adminSession->get('user_id') == $userId) {
$adminSession->delete();
}
}
$this->getModelFromCache('XenForo_Model_Session')->processLastActivityUpdateForLogOut(XenForo_Visitor::getUserId());
XenForo_Application::get('session')->delete();
XenForo_Helper_Cookie::deleteAllCookies($this->_getRetainedCookies(), array('user' => array('httpOnly' => false)));
XenForo_Visitor::setup(0);
return $redirectResponse;
}
}
示例8: getPermissionsFromContext
public function getPermissionsFromContext(array $context, array $parentContext = null)
{
// Context could be some previously fetched permissions, media, album or category...
if (isset($context['tagger_permissions'])) {
return $context['tagger_permissions'];
} else {
if (isset($context['media_id'])) {
$media = $context;
$container = $parentContext;
} else {
$media = null;
$container = $context;
}
}
if (!$container || empty($container['album_id']) && empty($container['category_id'])) {
throw new Exception("Context must be a media item and an album/category or just an album/category");
}
$visitor = XenForo_Visitor::getInstance();
if ($media) {
if ($media['user_id'] == $visitor['user_id'] && XenForo_Permission::hasPermission($visitor['permissions'], 'xengallery', 'manageOthersTagsOwnMedia')) {
$removeOthers = true;
} else {
$removeOthers = XenForo_Permission::hasPermission($visitor['permissions'], 'xengallery', 'manageAnyTag');
}
} else {
$removeOthers = false;
}
return array('edit' => $this->_getMediaModel()->canEditTags($media), 'removeOthers' => $removeOthers, 'minTotal' => isset($container['min_tags']) ? $container['min_tags'] : XenForo_Application::getOptions()->xengalleryAlbumMinTags);
}
示例9: _thSocialForumDescriptionAboveSocialgroups
protected function _thSocialForumDescriptionAboveSocialgroups()
{
$viewParams = $this->_fetchViewParams();
if ($viewParams['socialForum']['social_forum_type'] == 'resource') {
/* @var $resourceModel XenResource_Model_Resource */
$resourceModel = XenForo_Model::create('XenResource_Model_Resource');
$fetchOptions = array('join' => XenResource_Model_Resource::FETCH_CATEGORY | XenResource_Model_Resource::FETCH_USER | XenResource_Model_Resource::FETCH_ATTACHMENT | XenResource_Model_Resource::FETCH_VERSION, 'watchUserId' => XenForo_Visitor::getUserId());
if (XenForo_Visitor::getInstance()->hasPermission('resource', 'viewDeleted')) {
$fetchOptions['join'] |= XenResource_Model_Resource::FETCH_DELETION_LOG;
}
$resource = $resourceModel->getResourceBySocialForumId($viewParams['socialForum']['social_forum_id'], $fetchOptions);
if ($resource && $resourceModel->canViewResourceAndContainer($resource, $resource)) {
/* @var $categoryModel XenResource_Model_Category */
$categoryModel = XenForo_Model::create('XenResource_Model_Category');
$updateConditions = $categoryModel->getPermissionBasedFetchConditions($resource);
if ($updateConditions['deleted'] === true || $updateConditions['moderated'] === true || $updateConditions['moderated'] == $resource['user_id']) {
/* @var $updateModel XenResource_Model_Update */
$updateModel = XenForo_Model::create('XenResource_Model_Update');
$resourceUpdateCount = $updateModel->countUpdates($updateConditions + array('resource_id' => $resource['resource_id'], 'resource_update_id_not' => $resource['description_update_id']));
} else {
$resourceUpdateCount = $resource['update_count'];
}
$resource = $resourceModel->prepareResource($resource, $resource);
$this->_appendTemplate('resource_view_tabs', $viewParams + array('resource' => $resource, 'resourceUpdateCount' => $resourceUpdateCount, 'selectedTab' => 'discussion'));
ThemeHouse_SocialGroups_SocialForum::getInstance()->setResource($resource);
}
}
}
示例10: controllerPreDispatch
public static function controllerPreDispatch(XenForo_Controller $controller, $action)
{
if ($controller instanceof XenForo_ControllerPublic_Abstract) {
if (self::$_updatedMediaCounts === false) {
self::$_updatedMediaCounts = true;
$options = XenForo_Application::getOptions();
$visitor = XenForo_Visitor::getInstance();
if ($options->xengalleryUnviewedCounter['enabled'] && $visitor->xengallery_unviewed_media_count && XenForo_Application::isRegistered('session')) {
$time = XenForo_Application::$time;
$session = XenForo_Application::get('session');
$mediaUnviewed = $session->get('mediaUnviewed');
if ($mediaUnviewed === false || $mediaUnviewed['lastUpdateDate'] < $time - $options->xengalleryUnviewedCounter['length'] * 60) {
/** @var $mediaModel XenGallery_Model_Media */
$mediaModel = XenForo_Model::create('XenGallery_Model_Media');
$unviewedIds = $mediaModel->getUnviewedMediaIds($visitor->user_id, array('viewCategoryIds' => $mediaModel->getViewableCategoriesForVisitor($visitor->toArray()), 'viewAlbums' => XenForo_Permission::hasPermission($visitor->permissions, 'xengallery', 'viewAlbums')));
if ($unviewedIds !== false) {
if (sizeof($unviewedIds)) {
$mediaUnviewed = array('unviewed' => array_combine($unviewedIds, $unviewedIds), 'lastUpdateDate' => $time);
} else {
$mediaUnviewed = self::_getDefaultUnviewedArray();
}
}
} elseif (!$visitor->user_id) {
$mediaUnviewed = self::_getDefaultUnviewedArray();
}
$session->set('mediaUnviewed', $mediaUnviewed);
}
}
}
}
示例11: getWrapper
public function getWrapper($selectedGroup, $selectedLink, XenForo_ControllerResponse_View $subView)
{
$viewParams = array('selectedGroup' => $selectedGroup, 'selectedLink' => $selectedLink, 'selectedKey' => "{$selectedGroup}/{$selectedLink}", 'canStartConversation' => $this->_controller->getModelFromCache('XenForo_Model_Conversation')->canStartConversations(), 'canEditSignature' => XenForo_Visitor::getInstance()->canEditSignature(), 'canEditProfile' => XenForo_Visitor::getInstance()->canEditProfile());
$wrapper = $this->_controller->responseView('XenForo_ViewPublic_Account_Wrapper', 'account_wrapper', $viewParams);
$wrapper->subView = $subView;
return $wrapper;
}
示例12: actionIndex
public function actionIndex()
{
// styles
$styleModel = $this->getModelFromCache('XenForo_Model_Style');
$styles = $styleModel->getAllStylesAsFlattenedTree();
$styles = $styleModel->countCustomTemplatesPerStyle($styles);
if ($styleModel->showMasterStyle()) {
$masterStyle = $styleModel->getStyleById(0, true);
$masterTemplates = $styleModel->countMasterTemplates();
} else {
$masterStyle = null;
$masterTemplates = 0;
}
// languages
$languageModel = $this->getModelFromCache('XenForo_Model_Language');
$languages = $languageModel->getAllLanguagesAsFlattenedTree();
$languages = $languageModel->countTranslatedPhrasesPerLanguage($languages);
if ($languageModel->showMasterLanguage()) {
$masterLanguage = $languageModel->getLanguageById(0, true);
$masterPhrases = $languageModel->countMasterPhrases();
} else {
$masterLanguage = null;
$masterPhrases = 0;
}
$visitor = XenForo_Visitor::getInstance();
$viewParams = array('canEditStyles' => $visitor->hasAdminPermission('style'), 'canEditLanguages' => $visitor->hasAdminPermission('language'), 'styles' => $styles, 'masterStyle' => $masterStyle, 'masterTemplates' => $masterTemplates, 'languages' => $languages, 'masterLanguage' => $masterLanguage, 'masterPhrases' => $masterPhrases);
return $this->responseView('XenForo_ViewAdmin_Appearance_Splash', 'appearance_splash', $viewParams);
}
示例13: get
public static function get($key)
{
if (self::$_options === null) {
self::$_options = XenForo_Application::get('options');
}
switch ($key) {
case 'applicationVersionId':
return XenForo_Application::$versionId;
case 'cacheCutoffDays':
return 7;
case 'indexTabId':
return 'WidgetFramework_home';
case 'layoutEditorEnabled':
if (self::$_layoutEditorEnabled === null) {
if (!XenForo_Application::isRegistered('session')) {
// no session yet...
return false;
}
$session = XenForo_Application::getSession();
self::$_layoutEditorEnabled = $session->get('_WidgetFramework_layoutEditor') === true;
if (!self::$_layoutEditorEnabled and !empty($_REQUEST['_layoutEditor'])) {
$visitor = XenForo_Visitor::getInstance();
if ($visitor->hasAdminPermission('style')) {
self::$_layoutEditorEnabled = true;
}
}
}
// use the cached value
return self::$_layoutEditorEnabled;
}
return self::$_options->get('wf_' . $key);
}
示例14: actionGuide
public function actionGuide()
{
$options = XenForo_Application::get('options');
if (!XenForo_Visitor::getInstance()->hasPermission('games', 'labdefence') && !XenForo_Visitor::getInstance()->isSuperAdmin() || !$options->displayLabDefence && !XenForo_Visitor::getInstance()->isSuperAdmin() || !$options->displayLabDefenceGuide && !XenForo_Visitor::getInstance()->isSuperAdmin()) {
return $this->responseNoPermission();
}
/* Set the ID of the post to be loaded */
$postId = $options->labDefenceGuidePostId;
/* Create a new ControllerHelper that will help us to get the post */
$ftpHelper = new XenForo_ControllerHelper_ForumThreadPost($this);
/* Use the ControllerHelper to see if the post we want to get is viewable by the user browsing */
list($post, $thread) = $ftpHelper->assertPostValidAndViewable($postId);
/* If the post has attachments */
if ($post['attach_count'] > 0) {
/* Let's get all the attachments of this post, if exists */
$attachmentModel = XenForo_Model::create('XenForo_Model_Attachment');
$attachments = $attachmentModel->getAttachmentsByContentId('post', $postId);
foreach ($attachments as $attachment) {
/* Insert into the post data the attachments */
$post['attachments'][$attachment['attachment_id']] = $attachmentModel->prepareAttachment($attachment);
}
}
/* These parameters will be used in our template. We need to pass them into the response view. The $post param will be used too in the XenForo_ViewPublic instance */
$viewParams = array('post' => $post);
return $this->responseView('QCGames_ViewPublic_LabDefence_Guide', 'labdefence_guide', $viewParams);
}
示例15: actionProfileresultsdisplay
public function actionProfileresultsdisplay()
{
$maxRes = 100;
$visitor = XenForo_Visitor::getInstance();
if (!$visitor['user_id']) {
throw $this->getNoPermissionResponseException();
}
$uid = $visitor['user_id'];
unset($visitor);
$query = mb_strtolower($this->_input->filterSingle('q', XenForo_Input::STRING), 'UTF-8');
$q = substr($query, 0, 255);
ProfileNdx_search_engine::cleanOldsFromLimit();
ProfileNdx_search_engine::cleanOldsFromCache();
$permission = ProfileNdx_search_engine::userCanSearch($uid, $q);
if (!$permission['status']) {
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('search/profileresultswait/', '', array('redirect' => XenForo_Link::buildPublicLink('search/profileresultsdisplay/', '', array('q' => $query)), 'wait' => $permission['wait'])), '');
}
$viewpar = ProfileNdx_search_engine::getFromCache($q);
if ($viewpar == null) {
$results = (new ProfileNdx_search_engine())->search($q);
$viewpar = array('search' => array('search_query' => $query), 'results' => array_slice($results, 0, $maxRes), 'totalResults' => count($results), 'resultStartOffset' => 0, 'resultEndOffset' => min(count($results), $maxRes));
$results = (new ProfileNdx_search_engine())->toHtml($viewpar['results']);
$viewpar['results'] = $results;
ProfileNdx_search_engine::saveToCache($q, $viewpar);
}
return $this->responseView('XenForo_ViewPublic_Base', 'kiror_search_results', $viewpar);
}