本文整理汇总了PHP中XenForo_Visitor::getUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Visitor::getUserId方法的具体用法?PHP XenForo_Visitor::getUserId怎么用?PHP XenForo_Visitor::getUserId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Visitor
的用法示例。
在下文中一共展示了XenForo_Visitor::getUserId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCheckInOutAsUser
public function actionCheckInOutAsUser()
{
$userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT);
$username = $this->_input->filterSingle('username', XenForo_Input::STRING);
if ($userId && !($user = $this->_getUserModel()->getUserById($userId))) {
return $this->responseError(new XenForo_Phrase('requested_user_not_found'));
} elseif ($username && !($user = $this->_getUserModel()->getUserByName($username))) {
return $this->responseError(new XenForo_Phrase('requested_user_not_found'));
}
if (!$this->_getUserModel()->canChangeCheckInOutUser()) {
return $this->responseNoPermission();
}
if ($this->isConfirmedPost()) {
if (!empty($user)) {
$this->_getUserModel()->setCheckInOutUser($user['user_id']);
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect());
}
return $this->responseError(new XenForo_Phrase('requested_user_not_found'));
}
$visitor = XenForo_Visitor::getUserId();
$username = '';
if ($visitor['check_in_out_user_id_th'] && !$userId) {
$username = $visitor['username'];
} elseif (!empty($user)) {
$username = $user['username'];
}
$viewParams = array('username' => $username);
return $this->responseView('ThemeHouse_ResCheckInOut_ViewPublic_CheckInOutAsUser', 'th_check_in_out_as_user_rescheckinout', $viewParams);
}
示例2: 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;
}
}
示例3: actionView
public function actionView()
{
$cameraPortion = $this->_input->filterSingle('camera_url', XenForo_Input::STRING);
$cameraPortion = sonnb_XenGallery_Model_Gallery::getTitleForUrl($cameraPortion);
if (!$cameraPortion) {
return $this->responseReroute(__CLASS__, 'index');
}
$cameraModel = $this->_getCameraModel();
$photoModel = $this->_getPhotoModel();
$xenOptions = XenForo_Application::getOptions();
$page = max(1, $this->_input->filterSingle('page', XenForo_Input::UINT));
$photosPerPage = $xenOptions->sonnbXG_photoPerPage;
list($defaultOrder, $defaultOrderDirection) = $this->_getDefaultPhotoSort();
$order = $this->_input->filterSingle('order', XenForo_Input::STRING, array('default' => $defaultOrder));
$orderDirection = $this->_input->filterSingle('direction', XenForo_Input::STRING, array('default' => $defaultOrderDirection));
$conditions = array('camera_url' => $cameraPortion);
$fetchOptions = array('join' => sonnb_XenGallery_Model_Camera::FETCH_CAMERA, 'perPage' => $photosPerPage, 'page' => $page, 'order' => 'camera_id', 'orderDirection' => 'desc');
$cameras = $cameraModel->getCameras($conditions, $fetchOptions);
$camera = reset($cameras);
if ($camera) {
$camera = $cameraModel->prepareCamera($camera);
}
$photoFetchOptions = array('join' => sonnb_XenGallery_Model_Photo::FETCH_USER | sonnb_XenGallery_Model_Photo::FETCH_DATA | sonnb_XenGallery_Model_Photo::FETCH_ALBUM, 'likeUserId' => XenForo_Visitor::getUserId(), 'followingUserId' => XenForo_Visitor::getUserId());
$photos = $cameraModel->getPhotosByCameras($cameras, $photoFetchOptions);
$totalPhotos = $cameraModel->countCameras($conditions, $fetchOptions);
foreach ($photos as $_photoId => $_photo) {
if (!$photoModel->canViewContentAndContainer($_photo, $_photo['album'], $errorKey)) {
unset($photos[$_photoId]);
}
}
$pageNavParams = array();
$pageNavParams['order'] = $order != $defaultOrder ? $order : false;
$pageNavParams['direction'] = $orderDirection != $defaultOrderDirection ? $orderDirection : false;
return $this->responseView('sonnb_XenGallery_ViewPublic_Camera_View', 'sonnb_xengallery_camera_view', array('camera' => $camera, 'contents' => $photos, 'page' => $page, 'photosPerPage' => $photosPerPage, 'order' => $order, 'orderDirection' => $orderDirection, 'pageNavParams' => $pageNavParams, 'totalPhotos' => $totalPhotos, 'breadCrumbs' => $cameraModel->getCameraBreadCrumbs($camera)));
}
示例4: prepareThreadFetchOptions
public function prepareThreadFetchOptions(array $fetchOptions)
{
$fetchOptions = array_merge($fetchOptions, array(self::FETCH_TEAM_DISCUSSION => 1, self::FETCH_TEAM_BLOCK_USERID => XenForo_Visitor::getUserId()));
$result = parent::prepareThreadFetchOptions($fetchOptions);
extract($result);
if (!empty($fetchOptions[self::FETCH_TEAM_DISCUSSION])) {
$selectFields .= ',team.custom_url, team.team_state, team.user_id as team_user_id, team_privacy.privacy_state';
$joinTables .= '
LEFT JOIN xf_team AS team ON (team.team_id = thread.team_id AND thread.discussion_type = \'team\')
LEFT JOIN xf_team_privacy AS team_privacy ON (team_privacy.team_id = team.team_id)
';
}
if (isset($fetchOptions[self::FETCH_TEAM_BLOCK_USERID])) {
if (empty($fetchOptions[self::FETCH_TEAM_BLOCK_USERID])) {
$selectFields .= ',team_block.end_date AS block_end_date, team_block.user_reason as block_user_reason';
$joinTables .= '
LEFT JOIN xf_team_ban AS team_block ON (
team_block.team_id = thread.team_id AND team_block.user_id = ' . $this->_getDb()->quote($fetchOptions[self::FETCH_TEAM_BLOCK_USERID]) . '
)
';
} else {
$selectFields .= ',0 AS block_end_date';
}
}
return compact("selectFields", "joinTables", "orderClause");
}
示例5: _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);
}
}
}
示例6: getExtraDataForNodes
/**
* Gets the extra, node-type-specified data for the list of nodes.
*
* @param array $nodeIds
*
* @return array Format: [node id] => info
*/
public function getExtraDataForNodes(array $nodeIds)
{
$userId = XenForo_Visitor::getUserId();
// TODO: ideally this should be passed in
$forumFetchOptions = array('readUserId' => $userId);
return $this->_getForumModel()->getExtraForumDataForNodes($nodeIds, $forumFetchOptions);
}
示例7: allowedByPrivacyOptions
/**
* Check if the user is authorized to view the blog, per the privacy
* permissions
* @param array $blog blog contents
*/
protected function allowedByPrivacyOptions(array $blog, array $blogPermissions)
{
$visitorUserId = XenForo_Visitor::getUserId();
if ($blog['user_id'] == $visitorUserId) {
return parent::allowedByPrivacyOptions($blog, $blogPermissions);
}
if ($blogPermissions['xfa_blogs_bypass_privacy']) {
return parent::allowedByPrivacyOptions($blog, $blogPermissions);
}
if (empty($blog['allow_view_blog'])) {
return parent::allowedByPrivacyOptions($blog, $blogPermissions);
}
if ($blog['allow_view_blog'] != 'group') {
return parent::allowedByPrivacyOptions($blog, $blogPermissions);
}
if (empty($blog['allow_view_blog_group'])) {
return true;
}
/* @var $privacyGroupModel ThemeHouse_PrivacyGroups_Model_PrivacyGroup */
$privacyGroupModel = $this->getModelFromCache('ThemeHouse_PrivacyGroups_Model_PrivacyGroup');
$privacyGroup = $privacyGroupModel->getPrivacyGroupById($blog['allow_view_blog_group']);
if (!$privacyGroup) {
return true;
}
return XenForo_Helper_Criteria::userMatchesCriteria($privacyGroup['user_criteria'], true);
}
示例8: actionSocialForumsUpdate
public function actionSocialForumsUpdate()
{
$this->_assertPostOnly();
$input = $this->_input->filter(array('social_forum_ids' => array(XenForo_Input::UINT, 'array' => true), 'do' => XenForo_Input::STRING));
$watch = $this->_getForumWatchModel()->getUserSocialForumWatchBySocialForumIds(XenForo_Visitor::getUserId(), $input['social_forum_ids']);
foreach ($watch as $forumWatch) {
$dw = XenForo_DataWriter::create('ThemeHouse_SocialGroups_DataWriter_SocialForumWatch');
$dw->setExistingData($forumWatch, true);
switch ($input['do']) {
case 'stop':
$dw->delete();
break;
case 'email':
$dw->set('send_email', 1);
$dw->save();
break;
case 'no_email':
$dw->set('send_email', 0);
$dw->save();
break;
case 'alert':
$dw->set('send_alert', 1);
$dw->save();
break;
case 'no_alert':
$dw->set('send_alert', 0);
$dw->save();
break;
}
}
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(XenForo_Link::buildPublicLink('watched/social-forums')));
}
示例9: actionGetLogin
public function actionGetLogin()
{
$redirectUri = $this->_input->filterSingle('redirect_uri', XenForo_Input::STRING);
if (empty($redirectUri)) {
return $this->responseError(new XenForo_Phrase('bdapi_slash_tools_login_requires_redirect_uri'), 400);
}
/* @var $session bdApi_Session */
$session = XenForo_Application::getSession();
$clientId = $session->getOAuthClientId();
if (empty($clientId)) {
$this->_response->setHeader('X-Api-Login-Error', 'client_id');
return $this->responseNoPermission();
}
if (!$session->isValidRedirectUri($redirectUri)) {
$this->_response->setHeader('X-Api-Login-Error', 'redirect_uri');
return $this->responseNoPermission();
}
$userId = XenForo_Visitor::getUserId();
if (empty($userId)) {
$this->_response->setHeader('X-Api-Login-Error', 'oauth_token');
return $this->responseNoPermission();
}
$loginLinkData = array('redirect' => $redirectUri, 'timestamp' => XenForo_Application::$time + 10);
$loginLinkData['user_id'] = bdApi_Crypt::encryptTypeOne($userId, $loginLinkData['timestamp']);
$loginLink = XenForo_Link::buildPublicLink('login/api', '', $loginLinkData);
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL_PERMANENT, $loginLink);
}
示例10: actionTest
public function actionTest()
{
$this->assertAdminPermission('user');
$this->_routeMatch->setSections('testPermissions');
$class = XenForo_Application::resolveDynamicClass('XenForo_Session');
$publicSession = new $class();
$publicSession->start();
if ($publicSession->get('user_id') != XenForo_Visitor::getUserId()) {
return $this->responseError(new XenForo_Phrase('please_login_via_public_login_page_before_testing_permissions'));
}
if ($this->_request->isPost()) {
$username = $this->_input->filterSingle('username', XenForo_Input::STRING);
/* @var $userModel XenForo_Model_User */
$userModel = $this->getModelFromCache('XenForo_Model_User');
$user = $userModel->getUserByName($username);
if (!$user) {
return $this->responseError(new XenForo_Phrase('requested_user_not_found'), 404);
}
$publicSession->set('permissionTest', array('user_id' => $user['user_id'], 'username' => $user['username']));
$publicSession->save();
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('index'));
} else {
return $this->responseView('XenForo_ViewAdmin_Permission_Test', 'permission_test');
}
}
示例11: actionUpload
/**
* Displays a form to allow choice of content type and upload box.
*
* @return XenForo_ControllerResponse_Abstract
*/
public function actionUpload()
{
$adminImageModel = $this->_getAdminImageModel();
$adminImages = XenForo_Upload::getUploadedFiles('admin_image');
$input = $this->_input->filter(array('type' => XenForo_Input::STRING, 'type_id' => array(XenForo_Input::UINT, 'array' => true)));
if (empty($adminImages) || !$input['type'] || !$input['type_id']) {
$typeHandlers = $this->_getAdminImageModel()->getAdminImageHandlers();
$contentTypes = array_keys($typeHandlers);
if (!$input['type']) {
$input['type'] = reset($contentTypes);
}
$viewParams = array('type' => $input['type'], 'typeId' => $input['type_id'], 'typeHandlers' => $typeHandlers);
return $this->responseView('ThemeHouse_AdminImages_ViewAdmin_AdminImage_Upload', 'th_admin_image_upload_adminimages', $viewParams);
}
$this->_assertPostOnly();
$handler = $adminImageModel->getAdminImageHandlers($input['type']);
$contentId = isset($input['type_id'][$input['type']]) ? $input['type_id'][$input['type']] : 0;
if (!$handler->getContentTitle($contentId)) {
return $this->responseError(new XenForo_Phrase('th_please_select_a_valid_attach_to_item_adminimages'), 404);
}
$adminImage = reset($adminImages);
$attachmentModel = $this->_getAttachmentModel();
if ($adminImage->isImage()) {
$dataId = $attachmentModel->insertUploadedAttachmentData($adminImage, XenForo_Visitor::getUserId());
$attachmentId = $attachmentModel->insertTemporaryAttachment($dataId, 'adminimage-' . $input['type'] . '-' . $input['type_id'][$input['type']]);
$this->_getAdminImageModel()->associateAttachment($input['type'], $input['type_id'][$input['type']]);
} else {
throw $this->responseException($this->responseError(new XenForo_Phrase('th_uploaded_file_is_not_an_image_adminimages')));
}
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('images'));
}
示例12: couldBeSpammer
/**
*
* @see XenForo_Model_User::couldBeSpammer()
*/
public function couldBeSpammer(array $user, &$errorKey = '')
{
$xenOptions = XenForo_Application::get('options');
if ($xenOptions->th_noForo_noMessageCount) {
// self
if ($user['user_id'] == XenForo_Visitor::getUserId()) {
$errorKey = 'sorry_dave';
return false;
}
// staff
if ($user['is_admin'] || $user['is_moderator']) {
$errorKey = 'spam_cleaner_no_admins_or_mods';
return false;
}
$criteria = XenForo_Application::get('options')->spamUserCriteria;
if ($criteria['register_date'] && $user['register_date'] < XenForo_Application::$time - $criteria['register_date'] * 86400) {
$errorKey = array('spam_cleaner_registered_too_long', 'register_days' => $criteria['register_date']);
return false;
}
if ($criteria['like_count'] && $user['like_count'] > $criteria['like_count']) {
$errorKey = array('spam_cleaner_too_many_likes', 'like_count' => $criteria['like_count']);
return false;
}
return true;
}
return parent::couldBeSpammer($user, $errorKey);
}
示例13: getRSVPsByEvent
public function getRSVPsByEvent(&$event)
{
$rsvps = array('yes' => array(), 'maybe' => array(), 'no' => array(), 'user');
$event['event_rsvps'] = 0;
$event['event_guests'] = 0;
if (!($guests = $this->_getDb()->fetchAll("\n\t\t\tSELECT EWRatendo_rsvps.*, xf_user.*\n\t\t\t\tFROM EWRatendo_rsvps\n\t\t\t\tLEFT JOIN xf_user ON (xf_user.user_id = EWRatendo_rsvps.user_id)\n\t\t\tWHERE event_id = ?\n\t\t\tORDER BY xf_user.username\n\t\t", $event['event_id']))) {
return false;
}
foreach ($guests as $guest) {
switch ($guest['rsvp_state']) {
case "yes":
$event['event_guests'] += $guest['rsvp_guests'];
$event['event_rsvps']++;
$rsvps['yes'][] = $guest;
break;
case "maybe":
$rsvps['maybe'][] = $guest;
break;
case "no":
$rsvps['no'][] = $guest;
break;
}
if ($guest['user_id'] == XenForo_Visitor::getUserId()) {
$rsvps['user'] = $guest;
}
}
return $rsvps;
}
示例14: actionAdd
public function actionAdd()
{
$this->_assertPostOnly();
list($team, $category) = $this->_getTeamHelper()->assertTeamValidAndViewable();
$teamId = $team['team_id'];
$this->_assertCanViewMemberTab($team, $category);
$username = $this->_input->filterSingle('username', XenForo_Input::STRING);
$user = $this->getModelFromCache('XenForo_Model_User')->getUserByName($username);
if (!$user) {
return $this->responseError(new XenForo_Phrase('requested_member_not_found'), 404);
}
$memberModel = $this->_getMemberModel();
$existing = $memberModel->getRecordByKeys($user['user_id'], $team['team_id']);
if ($existing) {
return $this->responseError(new XenForo_Phrase('Teams_user_already_joined_in_team'));
}
if (XenForo_Visitor::getUserId() == $team['user_id']) {
$defaultstate = 'accept';
} else {
if ($memberModel->assertPermissionActionViewable($team, "canAssign")) {
$defaultstate = 'accept';
} else {
$defaultstate = 'request';
}
}
$visitor = XenForo_Visitor::getInstance();
$actionUser = array('action' => 'add', 'action_user_id' => $visitor['user_id'], 'action_username' => $visitor['username']);
$memberModel->insertMember($user['user_id'], $teamId, 'member', $defaultstate, $actionUser);
$hash = '#member-' . $teamId . '-' . $user['user_id'];
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_UPDATED, XenForo_Link::buildPublicLink(TEAM_ROUTE_PREFIX . '/members', $team) . $hash);
}
示例15: actionAddThread
/**
* Write to the database for whatever was written in the form
*/
public function actionAddThread()
{
// get parent
$parent = parent::actionAddThread();
$userId = XenForo_Visitor::getUserId();
$visitor = XenForo_Visitor::getInstance();
$styleId = $visitor->style_id;
// print_r($styleId);
// get all necessary inputs from this form
$dbtc_thread_id = XenForo_Application::get('last_thread');
$dbtc_donor_id = $userId;
$dbtc_date = $this->_input->filterSingle('dbtc_date', XenForo_Input::DATE_TIME);
$dbtc_type_id = $this->_input->filterSingle('dbtc_type_id', XenForo_Input::UINT);
$dbtc_description = $this->_input->filterSingle('dbtc_description', XenForo_Input::STRING);
# make sure we've got dbtc data
# TEMP WE NEED BETTER CHECK. MAKE SURE WE ARE SUBMITTING FROM DBTC STYLE
if (empty($dbtc_description)) {
return $parent;
}
//Create a instance of our DataWriter for the catalog
$dwDBTCcatalog = XenForo_DataWriter::create('DBTC_DataWriter_DBTCCatalogEntry');
$dwDBTCtrans = XenForo_DataWriter::create('DBTC_DataWriter_DBTCNodeEntry');
$dataCatalog = array('dbtc_thread_id' => $dbtc_thread_id, 'dbtc_donor_id' => $dbtc_donor_id, 'dbtc_type_id' => $dbtc_type_id, 'dbtc_description' => $dbtc_description, 'dbtc_date' => $dbtc_date);
$dataTrans = array('dbtc_thread_id' => $dbtc_thread_id, 'dbtc_receiver_id' => $dbtc_donor_id, 'dbtc_status_id' => "0", 'dbtc_donor_id' => "0", 'dbtc_date' => $dbtc_date, 'dbtc_parent_transaction_id' => 0);
$dwDBTCcatalog->bulkSet($dataCatalog);
$dwDBTCcatalog->save();
$dwDBTCtrans->bulkSet($dataTrans);
$dwDBTCtrans->save();
return $parent;
}