本文整理汇总了PHP中XenForo_Permission::unserializePermissions方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Permission::unserializePermissions方法的具体用法?PHP XenForo_Permission::unserializePermissions怎么用?PHP XenForo_Permission::unserializePermissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Permission
的用法示例。
在下文中一共展示了XenForo_Permission::unserializePermissions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: publishPendingDrafts
public function publishPendingDrafts()
{
$GLOBALS[bdSocialShare_Listener::XI_BLOG_MODEL_DRAFT_PUBLISH_PENDING] = $this;
$response = parent::publishPendingDrafts();
/* @var $publisherModel bdSocialShare_Model_Publisher */
$publisherModel = $this->getModelFromCache('bdSocialShare_Model_Publisher');
/* @var $userModel XenForo_Model_User */
$userModel = $this->getModelFromCache('XenForo_Model_User');
foreach ($this->_bdSocialShare_publishPendingDrafts_drafts as $hash => &$draftDw) {
$entryDw =& $this->_bdSocialShare_publishPendingDrafts_entries[$hash];
$scheduled = bdSocialShare_Helper_Common::unserializeOrFalse($draftDw->get('bdsocialshare_scheduled'));
if (!empty($scheduled) and !empty($scheduled['targets'])) {
if (empty($users[$entryDw->get('user_id')])) {
$users[$entryDw->get('user_id')] = $userModel->getVisitingUserById($entryDw->get('user_id'));
$users[$entryDw->get('user_id')] = $userModel->prepareUser($users[$entryDw->get('user_id')]);
$users[$entryDw->get('user_id')]['permissions'] = XenForo_Permission::unserializePermissions($users[$entryDw->get('user_id')]['global_permission_cache']);
}
if (!empty($users[$entryDw->get('user_id')])) {
$shareable = new bdSocialShare_Shareable_XI_Blog_Entry($entryDw);
$publisherModel->publishScheduled($scheduled, $shareable, $users[$entryDw->get('user_id')]);
$publisherModel->postPublish($shareable, false, $users[$entryDw->get('user_id')]);
}
}
}
return $response;
}
示例2: getVisibleModerationQueueEntriesForUser
/**
* Gets visible moderation queue entries for specified user.
*
* @see XenForo_ModerationQueueHandler_Abstract::getVisibleModerationQueueEntriesForUser()
*/
public function getVisibleModerationQueueEntriesForUser(array $contentIds, array $viewingUser)
{
/* @var $resourceModel XenResource_Model_Resource */
$resourceModel = XenForo_Model::create('XenResource_Model_Resource');
$resources = $resourceModel->getResourcesByIds($contentIds, array('join' => XenResource_Model_Resource::FETCH_DESCRIPTION));
$categories = XenForo_Model::create('XenResource_Model_Category')->getAllCategories(array('permissionCombinationId' => $viewingUser['permission_combination_id']));
$output = array();
foreach ($resources as $resource) {
if (!isset($categories[$resource['resource_category_id']])) {
continue;
}
$category = $categories[$resource['resource_category_id']];
$categoryPermissions = XenForo_Permission::unserializePermissions($category['category_permission_cache']);
$canManage = true;
if (!$resourceModel->canViewResourceAndContainer($resource, $category, $null, $viewingUser, $categoryPermissions)) {
$canManage = false;
} else {
if (!XenForo_Permission::hasContentPermission($categoryPermissions, 'editAny') || !XenForo_Permission::hasContentPermission($categoryPermissions, 'deleteAny') || !XenForo_Permission::hasContentPermission($categoryPermissions, 'approveUnapprove')) {
$canManage = false;
}
}
if ($canManage) {
$output[$resource['resource_id']] = array('message' => $resource['description'], 'user' => array('user_id' => $resource['user_id'], 'username' => $resource['username']), 'title' => $resource['title'], 'link' => XenForo_Link::buildPublicLink('resources', $resource), 'contentTypeTitle' => new XenForo_Phrase('resource'), 'titleEdit' => true);
}
}
return $output;
}
示例3: canViewResult
public function canViewResult(array $result, array $viewingUser)
{
$categoryPermissions = null;
if (!empty($result['category_permission_cache'])) {
// XenForo Resource Manager 1.1 support
$categoryPermissions = XenForo_Permission::unserializePermissions($result['category_permission_cache']);
}
return $this->_getResourceModel()->canViewResource($result, $result, $errorPhraseKey, $viewingUser, $categoryPermissions);
}
示例4: getContentPermissionsForItem
/**
* Gets the content permissions for a specified item.
*
* @param integer $permissionCombinationId Permission combination to read
* @param string $contentType Permission content type
* @param integer $contentId
*
* @return array
*/
public function getContentPermissionsForItem($permissionCombinationId, $contentType, $contentId)
{
return XenForo_Permission::unserializePermissions($this->_getDb()->fetchOne('
SELECT cache_value
FROM xf_permission_cache_content
WHERE permission_combination_id = ?
AND content_type = ?
AND content_id = ?
', array($permissionCombinationId, $contentType, $contentId)));
}
示例5: canViewContent
public function canViewContent(array $content)
{
/* @var $threadModel XenForo_Model_Thread */
$threadModel = XenForo_Model::create('XenForo_Model_Thread');
$errorPhraseKey = 'null';
if (!$threadModel->canViewThreadAndContainer($content, $content, $errorPhraseKey, XenForo_Permission::unserializePermissions($content['node_permission_cache']))) {
return false;
}
return true;
}
示例6: _getContent
protected function _getContent($contentId, array $viewingUser)
{
/* @var $postModel XenForo_Model_Post */
$postModel = XenForo_Model::create('XenForo_Model_Post');
$post = $postModel->getPostById($contentId, array('join' => XenForo_Model_Post::FETCH_THREAD | XenForo_Model_Post::FETCH_FORUM | XenForo_Model_Post::FETCH_USER, 'permissionCombinationId' => $viewingUser['permission_combination_id']));
if ($post) {
$post['permissions'] = XenForo_Permission::unserializePermissions($post['node_permission_cache']);
}
return $post;
}
示例7: actionLogin
public function actionLogin()
{
if (!$this->_request->isPost()) {
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL, XenForo_Link::buildAdminLink('index'));
}
$data = $this->_input->filter(array('login' => XenForo_Input::STRING, 'password' => XenForo_Input::STRING, 'redirect' => XenForo_Input::STRING, 'cookie_check' => XenForo_Input::UINT));
$redirect = $data['redirect'] ? $data['redirect'] : XenForo_Link::buildAdminLink('index');
$loginModel = $this->_getLoginModel();
if ($data['cookie_check'] && count($_COOKIE) == 0) {
// login came from a page, so we should at least have a session cookie.
// if we don't, assume that cookies are disabled
return $this->responseError(new XenForo_Phrase('cookies_required_to_log_in_to_site'));
}
$needCaptcha = $loginModel->requireLoginCaptcha($data['login']);
if ($needCaptcha) {
// just block logins here instead of using the captcha
return $this->responseError(new XenForo_Phrase('your_account_has_temporarily_been_locked_due_to_failed_login_attempts'));
}
$userModel = $this->_getUserModel();
$userId = $userModel->validateAuthentication($data['login'], $data['password'], $error);
if (!$userId) {
$loginModel->logLoginAttempt($data['login']);
if ($loginModel->requireLoginCaptcha($data['login'])) {
return $this->responseError(new XenForo_Phrase('your_account_has_temporarily_been_locked_due_to_failed_login_attempts'));
}
if ($this->_input->filterSingle('upgrade', XenForo_Input::UINT)) {
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $redirect);
} else {
// note - JSON view will return responseError($text)
return $this->responseView('XenForo_ViewAdmin_Login_Error', 'login_form', array('text' => $error, 'defaultLogin' => $data['login'], 'redirect' => $redirect), array('containerTemplate' => 'LOGIN_PAGE'));
}
}
$loginModel->clearLoginAttempts($data['login']);
$user = $this->_getUserModel()->getFullUserById($userId, array('join' => XenForo_Model_User::FETCH_USER_PERMISSIONS));
// now check that the user will be able to get into the ACP (is_admin)
if (!$user['is_admin']) {
return $this->responseError(new XenForo_Phrase('your_account_does_not_have_admin_privileges'));
}
/** @var XenForo_ControllerHelper_Login $loginHelper */
$loginHelper = $this->getHelper('Login');
if ($loginHelper->userTfaConfirmationRequired($user)) {
$loginHelper->setTfaSessionCheck($user['user_id']);
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildAdminLink('login/two-step', null, array('redirect' => $redirect)));
} else {
$permissions = XenForo_Permission::unserializePermissions($user['global_permission_cache']);
if (empty($user['use_tfa']) && (XenForo_Application::getOptions()->adminRequireTfa || XenForo_Permission::hasPermission($permissions, 'general', 'requireTfa'))) {
return $this->responseError(new XenForo_Phrase('you_must_enable_two_step_access_control_panel', array('link' => XenForo_Link::buildPublicLink('account/two-step'))));
}
$postVars = $this->_input->filterSingle('postVars', XenForo_Input::JSON_ARRAY);
return $this->completeLogin($userId, $redirect, $postVars);
}
}
示例8: _canUploadAndManageAttachments
/**
* Determines if attachments and be uploaded and managed in this context.
*
* @see XenForo_AttachmentHandler_Abstract::_canUploadAndManageAttachments()
*/
protected function _canUploadAndManageAttachments(array $contentData, array $viewingUser)
{
$forumModel = $this->_getForumModel();
if (!empty($contentData['node_id'])) {
$forum = $forumModel->getForumById($contentData['node_id'], array('permissionCombinationId' => $viewingUser['permission_combination_id']));
if ($forum) {
$permissions = XenForo_Permission::unserializePermissions($forum['node_permission_cache']);
return $forumModel->canViewForum($forum, $null, $permissions, $viewingUser) && $forumModel->canUploadAndManageAttachment($forum, $null, $permissions, $viewingUser);
}
}
return false;
// invalid content data
}
示例9: XenForo_DataWriter_DiscussionMessage_Post
public static function XenForo_DataWriter_DiscussionMessage_Post(XenForo_Model_User $userModel, array $user, array $options)
{
if (empty($user['node_permission_cache'])) {
return false;
}
if (empty($options['post']) or empty($options['thread']) or empty($options['forum'])) {
return false;
}
$permissions = XenForo_Permission::unserializePermissions($user['node_permission_cache']);
/** @var XenForo_Model_Post $postModel */
$postModel = $userModel->getModelFromCache('XenForo_Model_Post');
return $postModel->canViewPostAndContainer($options['post'], $options['thread'], $options['forum'], $null, $permissions, $user);
}
示例10: _canViewAttachment
/**
* Determines if the specified attachment can be viewed.
*
* @see XenForo_AttachmentHandler_Abstract::_canViewAttachment()
*/
protected function _canViewAttachment(array $attachment, array $viewingUser)
{
$postModel = $this->_getPostModel();
$post = $postModel->getPostById($attachment['content_id'], array('join' => XenForo_Model_Post::FETCH_THREAD | XenForo_Model_Post::FETCH_FORUM | XenForo_Model_Post::FETCH_USER, 'permissionCombinationId' => $viewingUser['permission_combination_id']));
if (!$post) {
return false;
}
$permissions = XenForo_Permission::unserializePermissions($post['node_permission_cache']);
$canViewPost = $postModel->canViewPostAndContainer($post, $post, $post, $null, $permissions, $viewingUser);
if (!$canViewPost) {
return false;
}
return $postModel->canViewAttachmentOnPost($post, $post, $post, $null, $permissions, $viewingUser);
}
示例11: getContentData
/**
* Gets content data (if viewable).
* @see XenForo_LikeHandler_Abstract::getContentData()
*/
public function getContentData(array $contentIds, array $viewingUser)
{
/* @var $updateModel XenResource_Model_Update */
$updateModel = XenForo_Model::create('XenResource_Model_Update');
$updates = $updateModel->getUpdatesByIds($contentIds, array('join' => XenResource_Model_Update::FETCH_RESOURCE | XenResource_Model_Update::FETCH_CATEGORY, 'permissionCombinationId' => $viewingUser['permission_combination_id']));
foreach ($updates as $updateId => &$update) {
$categoryPermissions = XenForo_Permission::unserializePermissions($update['category_permission_cache']);
if (!$updateModel->canViewUpdate($update, $update, $update, $null, $viewingUser, $categoryPermissions)) {
unset($updates[$updateId]);
} else {
$update = $updateModel->prepareUpdate($update, $update, $update, $viewingUser);
}
}
return $updates;
}
示例12: renderTagSigPic
public function renderTagSigPic(array $tag, array $user)
{
$user = false;
if (array_key_exists('0', $tag['children'])) {
$user = XenForo_Model::create('XenForo_Model_User')->getUserById($tag['children'][0], array('join' => XenForo_Model_User::FETCH_USER_PERMISSIONS));
} else {
$user = XenForo_Visitor::getInstance()->toArray();
}
// For signature preview to not fail
if ($user) {
$user['permissions'] = XenForo_Permission::unserializePermissions($user['global_permission_cache']);
if (XenForo_Permission::hasPermission($user['permissions'], 'signature', 'sigpic')) {
return XenForo_Template_Helper_Core::callHelper('sigpic', array($user));
}
}
return '';
}
示例13: _canUploadAndManageAttachments
/**
* Determines if attachments and be uploaded and managed in this context.
*
* @see XenForo_AttachmentHandler_Abstract::_canUploadAndManageAttachments()
*/
protected function _canUploadAndManageAttachments(array $contentData, array $viewingUser)
{
$resourceModel = $this->_getResourceModel();
/** @var XenResource_Model_Category $categoryModel */
$categoryModel = XenForo_Model::create('XenResource_Model_Category');
if (!empty($contentData['resource_id'])) {
$resource = $resourceModel->getResourceById($contentData['resource_id']);
if ($resource) {
$category = $categoryModel->getCategoryById($resource['resource_category_id'], array('permissionCombinationId' => $viewingUser['permission_combination_id']));
if ($category) {
$categoryPermissions = XenForo_Permission::unserializePermissions($category['category_permission_cache']);
return XenForo_Model::create('XenResource_Model_Version')->canAddVersion($resource, $category, $null, $viewingUser, $categoryPermissions);
} else {
return false;
}
}
}
return $categoryModel->canAddResource(null, $null, $viewingUser);
}
示例14: getVisibleModerationQueueEntriesForUser
/**
* Gets visible moderation queue entries for specified user.
*
* @see XenForo_ModerationQueueHandler_Abstract::getVisibleModerationQueueEntriesForUser()
*/
public function getVisibleModerationQueueEntriesForUser(array $contentIds, array $viewingUser)
{
$socialForumModel = ThemeHouse_SocialGroups_SocialForum::getSocialForumModel();
$socialForums = $socialForumModel->getSocialForumsByIds($contentIds, array('join' => ThemeHouse_SocialGroups_Model_SocialForum::FETCH_FORUM | ThemeHouse_SocialGroups_Model_SocialForum::FETCH_USER, 'permissionCombinationId' => $viewingUser['permission_combination_id']));
$output = array();
foreach ($socialForums as $socialForum) {
$socialForum['permissions'] = XenForo_Permission::unserializePermissions($socialForum['node_permission_cache']);
$canManage = true;
if (!$socialForumModel->canViewSocialForum($socialForum, $null, $socialForum['permissions'], $viewingUser)) {
$canManage = false;
} elseif (!XenForo_Permission::hasContentPermission($socialForum['permissions'], 'editSocialForum') || !XenForo_Permission::hasContentPermission($socialForum['permissions'], 'deleteSocialForum')) {
$canManage = false;
}
if ($canManage) {
$output[$socialForum['social_forum_id']] = array('message' => $socialForum['description'], 'user' => array('user_id' => $socialForum['user_id'], 'username' => $socialForum['username']), 'title' => $socialForum['title'], 'link' => XenForo_Link::buildPublicLink('social-forums', $socialForum), 'contentTypeTitle' => new XenForo_Phrase('th_social_forum_socialgroups'), 'titleEdit' => true);
}
}
return $output;
}
示例15: findNewPosts
public function findNewPosts()
{
$threadModel = $this->_getThreadModel();
$searchModel = $this->_getSearchModel();
$userId = XenForo_Visitor::getUserId();
$visitor = XenForo_Visitor::getInstance();
$limitOptions = array('limit' => XenForo_Application::get('options')->maximumSearchResults);
$days = $this->_input->filterSingle('days', XenForo_Input::UINT);
$recent = $this->_input->filterSingle('recent', XenForo_Input::UINT);
$watched = $this->_input->filterSingle('watched', XenForo_Input::UINT);
if ($userId && !$days && !$recent) {
$threadIds = $threadModel->getUnreadThreadIds($userId, $limitOptions, $watched);
$searchType = 'new-posts';
} else {
if ($days < 1) {
$days = max(7, XenForo_Application::get('options')->readMarkingDataLifetime);
}
$fetchOptions = $limitOptions + array('order' => 'last_post_date', 'orderDirection' => 'desc', 'watchUserId' => $userId, 'forumWatchUserId' => $userId, 'join' => XenForo_Model_Thread::FETCH_FORUM_OPTIONS);
$threadIds = array_keys($threadModel->getThreads(array('last_post_date' => array('>', XenForo_Application::$time - 86400 * $days), 'not_discussion_type' => 'redirect', 'deleted' => false, 'moderated' => false, 'find_new' => true, 'watch_only' => $watched), $fetchOptions));
$searchType = 'recent-posts';
}
$threads = $threadModel->getThreadsByIds($threadIds, array('join' => XenForo_Model_Thread::FETCH_FORUM | XenForo_Model_Thread::FETCH_USER, 'permissionCombinationId' => $visitor['permission_combination_id']));
foreach ($threads as $key => $thread) {
$thread['permissions'] = XenForo_Permission::unserializePermissions($thread['node_permission_cache']);
if (!$threadModel->canViewThreadAndContainer($thread, $thread, $null, $thread['permissions']) || $visitor->isIgnoring($thread['user_id'])) {
unset($threads[$key]);
}
}
$results = array();
foreach ($threadIds as $threadId) {
if (isset($threads[$threadId])) {
$results[] = array(XenForo_Model_Search::CONTENT_TYPE => 'thread', XenForo_Model_Search::CONTENT_ID => $threadId);
}
}
if (!$results) {
return $this->getNoPostsResponse();
}
$search = $searchModel->insertSearch($results, $searchType, '', array(), 'date', false);
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('find-new/posts', $search));
}