本文整理汇总了PHP中XenForo_Permission类的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Permission类的具体用法?PHP XenForo_Permission怎么用?PHP XenForo_Permission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XenForo_Permission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFloodingLimitForAction
public function getFloodingLimitForAction($action, &$viewingUser = null)
{
$this->standardizeViewingUserReference($viewingUser);
if (!$viewingUser['user_id']) {
return null;
}
switch ($action) {
case 'conversation':
$floodingLimit = XenForo_Permission::hasPermission($viewingUser['permissions'], 'conversation', 'floodCheckLength');
break;
case 'post':
$floodingLimit = XenForo_Permission::hasPermission($viewingUser['permissions'], 'general', 'floodCheckPostLength');
break;
case 'contact':
$floodingLimit = XenForo_Permission::hasPermission($viewingUser['permissions'], 'general', 'floodCheckContactLength');
break;
case 'report':
$floodingLimit = XenForo_Permission::hasPermission($viewingUser['permissions'], 'general', 'floodCheckReportLength');
break;
default:
$floodingLimit = null;
break;
}
if ($floodingLimit === false) {
return null;
}
return $floodingLimit;
}
示例2: actionContent
public function actionContent()
{
$noWrapper = $this->_input->filterSingle('no_wrapper', XenForo_Input::STRING);
$defaultOrder = 'media_date';
$order = $this->_input->filterSingle('order', XenForo_Input::STRING, array('default' => $defaultOrder));
$container = $this->_input->filterSingle('container', XenForo_Input::STRING);
$type = $this->_input->filterSingle('type', XenForo_Input::STRING);
$userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT);
$userFetchOptions = array('join' => XenForo_Model_User::FETCH_LAST_ACTIVITY);
$user = $this->getHelper('UserProfile')->assertUserProfileValidAndViewable($userId, $userFetchOptions);
$this->canonicalizeRequestUrl(XenForo_Link::buildPublicLink('xengallery/users', $user));
$mediaModel = $this->_getMediaModel();
$page = $this->_input->filterSingle('page', XenForo_Input::UINT);
$perPage = XenForo_Application::getOptions()->xengalleryMediaMaxPerPage;
$visitor = XenForo_Visitor::getInstance();
$conditions = array('user_id' => $user['user_id'], 'container' => $container, 'type' => $type, 'deleted' => XenForo_Permission::hasPermission(XenForo_Visitor::getInstance()->permissions, 'xengallery', 'viewDeleted'), 'privacyUserId' => $visitor->user_id, 'viewAlbums' => XenForo_Permission::hasPermission($visitor->permissions, 'xengallery', 'viewAlbums'), 'viewCategoryIds' => $mediaModel->getViewableCategoriesForVisitor($visitor->toArray()));
$fetchOptions = $this->_getMediaFetchOptions() + array('order' => $order ? $order : $defaultOrder, 'orderDirection' => 'desc', 'page' => $page, 'perPage' => $perPage);
$fetchOptions['join'] |= XenGallery_Model_Media::FETCH_ALBUM | XenGallery_Model_Media::FETCH_PRIVACY;
$totalCount = $mediaModel->countMedia($conditions, $fetchOptions);
$media = $mediaModel->getMedia($conditions, $fetchOptions);
$media = $mediaModel->prepareMediaItems($media);
$userPage = false;
if ($userId == $visitor->user_id) {
$userPage = true;
}
$inlineModOptions = $mediaModel->prepareInlineModOptions($media, $userPage);
$pageNavParams = array('order' => $order != $defaultOrder ? $order : false, 'container' => $container ? $container : false, 'type' => $type ? $type : false);
$viewParams = array('canViewComments' => $this->_getCommentModel()->canViewComments(), 'media' => $media, 'user' => $user, 'page' => $page <= 1 ? '' : $page, 'perPage' => $perPage, 'pageNavParams' => $pageNavParams, 'order' => $order, 'defaultOrder' => $defaultOrder, 'container' => $container, 'containerFilter' => $container, 'type' => $type, 'typeFilter' => $type, 'mediaCount' => count($media), 'totalCount' => $totalCount, 'noWrapper' => $noWrapper, 'showFilterTabs' => true, 'inlineModOptions' => $inlineModOptions);
$view = $this->responseView('XenGallery_ViewPublic_User_Media', 'xengallery_media_user', $viewParams);
if ($noWrapper) {
return $view;
} else {
return $this->_getSiteMediaWrapper('', $view);
}
}
示例3: findNewMedia
public function findNewMedia()
{
$mediaModel = $this->_getMediaModel();
/** @var $searchModel XenForo_Model_Search */
$searchModel = $this->_getSearchModel();
$visitor = XenForo_Visitor::getInstance();
$limitOptions = array('limit' => XenForo_Application::getOptions()->maximumSearchResults, 'viewCategoryIds' => $mediaModel->getViewableCategoriesForVisitor($visitor->toArray()), 'viewAlbums' => XenForo_Permission::hasPermission($visitor->permissions, 'xengallery', 'viewAlbums'), 'privacyUserId' => $visitor->user_id);
if ($visitor->user_id) {
$mediaIds = $mediaModel->getUnviewedMediaIds($visitor->user_id, $limitOptions);
} else {
$conditions = $limitOptions + array('media_date' => array('>', XenForo_Application::$time - 86400 * 7), 'deleted' => false, 'moderated' => false);
$fetchOptions = $limitOptions + array('order' => 'media_date', 'orderDirection' => 'desc', 'join' => XenGallery_Model_Media::FETCH_USER | XenGallery_Model_Media::FETCH_ATTACHMENT | XenGallery_Model_Media::FETCH_CATEGORY | XenGallery_Model_Media::FETCH_ALBUM | XenGallery_Model_Media::FETCH_PRIVACY);
$mediaIds = array_keys($mediaModel->getMedia($conditions, $fetchOptions));
}
if ($mediaIds) {
$media = $mediaModel->getMedia(array('media_id' => $mediaIds, 'view_user_id' => $visitor->getUserId()), array('join' => XenGallery_Model_Media::FETCH_USER | XenGallery_Model_Media::FETCH_ATTACHMENT | XenGallery_Model_Media::FETCH_CATEGORY | XenGallery_Model_Media::FETCH_ALBUM | XenGallery_Model_Media::FETCH_LAST_VIEW));
$media = $mediaModel->prepareMedia($media);
}
$results = array();
foreach ($mediaIds as $mediaId) {
if (isset($media[$mediaId])) {
$results[] = array(XenForo_Model_Search::CONTENT_TYPE => 'xengallery_media', XenForo_Model_Search::CONTENT_ID => $mediaId);
}
}
$search = $searchModel->insertSearch($results, 'xengallery_media', '', array('findNew'), 'date', false);
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('find-new/media', $search));
}
示例4: getImage
public static function getImage($content, $params, XenForo_Template_Abstract $template)
{
$posts = $template->getParam('posts');
if (!count($posts)) {
return $content;
}
$visitor = XenForo_Visitor::getInstance();
$matches = array();
foreach ($posts as $post) {
if (XenForo_Permission::hasPermission($visitor['permissions'], 'forum', 'viewAttachment')) {
preg_match('#\\[attach(=[^\\]]*)?\\](?P<id>\\d+)(\\D.*)?\\[/attach\\]#iU', $post['message'], $matches);
if (!empty($matches[2])) {
$link = XenForo_Link::buildPublicLink('full:attachments', array('attachment_id' => $matches[2]));
if (!empty($link)) {
return $link;
}
}
}
preg_match('/\\[(img|IMG)\\]\\s*(https?:\\/\\/([^*\\r\\n]+|[a-z0-9\\/\\\\._\\- !]+))\\[\\/(img|IMG)\\]/', $post['message'], $matches);
if (!empty($matches[2])) {
return $matches[2];
}
}
return $content;
}
示例5: getPushableDataForNode
/**
* Gets the effective data that can be pushed up to a parent node.
*
* @param array $node Current node info
* @param array $childPushable List of pushable data from all child nodes: [node id] => pushable data
* @param array $permissions Permissions for this node
*
* @return array List of pushable data (key-value pairs)
*/
public function getPushableDataForNode(array $node, array $childPushable, array $permissions)
{
if (!XenForo_Permission::hasContentPermission($permissions, 'viewOthers')) {
return $this->_compileForumLikePushableData(array('privateInfo' => true), $childPushable);
}
return $this->_getForumLikePushableData($node, $childPushable);
}
示例6: 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;
}
示例7: 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;
}
示例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: _canViewAttachment
/**
* Determines if the specified attachment can be viewed.
*
* @see XenForo_AttachmentHandler_Abstract::_canViewAttachment()
*/
protected function _canViewAttachment(array $attachment, array $viewingUser)
{
$mediaModel = $this->_getMediaModel();
$fetchOptions = array('join' => XenGallery_Model_Media::FETCH_USER | XenGallery_Model_Media::FETCH_ATTACHMENT | XenGallery_Model_Media::FETCH_CATEGORY | XenGallery_Model_Media::FETCH_ALBUM, 'watchUserId' => $viewingUser['user_id']);
if (XenForo_Permission::hasPermission($viewingUser['permissions'], 'xengallery', 'viewDeleted')) {
$fetchOptions['join'] |= XenGallery_Model_Media::FETCH_DELETION_LOG;
}
$mediaId = $mediaModel->getMediaIdByAttachmentId($attachment['attachment_id']);
$media = $mediaModel->getMediaById($mediaId, $fetchOptions);
if (!$media) {
return false;
}
if (!empty($media['album_id'])) {
$albumModel = $this->_getAlbumModel();
$media = $albumModel->prepareAlbumWithPermissions($media);
if (!$albumModel->canViewAlbum($media, $null, $viewingUser)) {
return false;
}
}
if (!empty($media['category_id'])) {
if (!$this->_getCategoryModel()->canViewCategory($media, $null, $viewingUser)) {
return false;
}
}
if (!$mediaModel->canViewDeletedMedia($error, $viewingUser) && $media['media_state'] == 'deleted') {
return false;
}
if (!$mediaModel->canViewUnapprovedMedia($error, $viewingUser) && $media['media_state'] == 'moderated') {
return false;
}
return true;
}
示例10: getVisibleModerationQueueEntriesForUser
/**
* Gets visible moderation queue entries for specified user.
*
* @see XenForo_ModerationQueueHandler_Abstract::getVisibleModerationQueueEntriesForUser()
*/
public function getVisibleModerationQueueEntriesForUser(array $contentIds, array $viewingUser)
{
/* @var $profilePostModel XenForo_Model_ProfilePost */
$profilePostModel = XenForo_Model::create('XenForo_Model_ProfilePost');
$profilePosts = $profilePostModel->getProfilePostsByIds($contentIds);
$profileUserIds = array();
foreach ($profilePosts as $profilePost) {
$profileUserIds[] = $profilePost['profile_user_id'];
}
$users = XenForo_Model::create('XenForo_Model_User')->getUsersByIds($profileUserIds, array('join' => XenForo_Model_User::FETCH_USER_PRIVACY, 'followingUserId' => $viewingUser['user_id']));
$output = array();
foreach ($profilePosts as $profilePost) {
if (!isset($users[$profilePost['profile_user_id']])) {
continue;
}
$user = $users[$profilePost['profile_user_id']];
$canManage = true;
if (!$profilePostModel->canViewProfilePostAndContainer($profilePost, $user, $null, $viewingUser)) {
$canManage = false;
} else {
if (!XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'editAny') || !XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'deleteAny')) {
$canManage = false;
}
}
if ($canManage) {
$output[$profilePost['profile_post_id']] = array('message' => $profilePost['message'], 'user' => array('user_id' => $profilePost['user_id'], 'username' => $profilePost['username']), 'title' => new XenForo_Phrase('profile_post_for_x', array('username' => $user['username'])), 'link' => XenForo_Link::buildPublicLink('profile-posts', $profilePost), 'contentTypeTitle' => new XenForo_Phrase('profile_post'), 'titleEdit' => false);
}
}
return $output;
}
示例11: getPermissionsFromContext
public function getPermissionsFromContext(array $context, array $parentContext = null)
{
if (isset($context['thread_id'])) {
$thread = $context;
$forum = $parentContext;
} else {
$thread = null;
$forum = $context;
}
if (!$forum || !isset($forum['node_id'])) {
throw new Exception("Context must be a thread and a forum or just a forum");
}
$visitor = XenForo_Visitor::getInstance();
// creating a new thread (all tags would be by us)
$nodePermissions = $visitor->getNodePermissions($forum['node_id']);
if ($thread) {
if ($thread['user_id'] == $visitor['user_id'] && XenForo_Permission::hasContentPermission($nodePermissions, 'manageOthersTagsOwnThread')) {
$removeOthers = true;
} else {
$removeOthers = XenForo_Permission::hasContentPermission($nodePermissions, 'manageAnyTag');
}
} else {
$removeOthers = false;
}
return array('edit' => $this->_getThreadModel()->canEditTags($thread, $forum), 'removeOthers' => $removeOthers, 'minTotal' => $forum['min_tags']);
}
示例12: getVisibleReportsForUser
/**
* Gets the visible reports of this content type for the viewing user.
*
* @see XenForo_ReportHandler_Abstract:getVisibleReportsForUser()
*/
public function getVisibleReportsForUser(array $reports, array $viewingUser)
{
$reportsByForum = array();
foreach ($reports as $reportId => $report) {
$info = unserialize($report['content_info']);
$reportsByForum[$info['node_id']][] = $reportId;
}
/* @var $forumModel XenForo_Model_Forum */
$forumModel = XenForo_Model::create('XenForo_Model_Forum');
$forums = $forumModel->getForumsByIds(array_keys($reportsByForum), array('permissionCombinationId' => $viewingUser['permission_combination_id']));
$forums = $forumModel->unserializePermissionsInList($forums, 'node_permission_cache');
foreach ($reportsByForum as $forumId => $forumReports) {
$remove = false;
if (!isset($forums[$forumId])) {
$remove = true;
} else {
$forum = $forums[$forumId];
if (!XenForo_Permission::hasContentPermission($forum['permissions'], 'editAnyPost') && !XenForo_Permission::hasContentPermission($forum['permissions'], 'deleteAnyPost')) {
$remove = true;
}
}
if ($remove) {
foreach ($forumReports as $reportId) {
unset($reports[$reportId]);
}
}
}
return $reports;
}
示例13: actionAlbums
public function actionAlbums()
{
$this->_routeMatch->setSections('xengallery');
$albumWatchModel = $this->_getAlbumWatchModel();
$albumModel = $this->_getAlbumModel();
if (!$albumModel->canWatchAlbum()) {
throw $this->getErrorOrNoPermissionResponseException();
}
$visitor = XenForo_Visitor::getInstance();
$defaultOrder = 'album_date';
$order = $this->_input->filterSingle('order', XenForo_Input::STRING, array('default' => $defaultOrder));
$page = $this->_input->filterSingle('page', XenForo_Input::UINT);
$perPage = XenForo_Application::getOptions()->xengalleryMediaMaxPerPage;
$albums = array();
$conditions = array();
$fetchOptions = array();
$albumIds = $albumWatchModel->getUserAlbumWatchByUser($visitor['user_id']);
if ($albumIds) {
$conditions = array('deleted' => XenForo_Permission::hasPermission($visitor->permissions, 'xengallery', 'viewDeleted'), 'privacyUserId' => $visitor->user_id, 'viewCategoryIds' => $this->getModelFromCache('XenGallery_Model_Media')->getViewableCategoriesForVisitor(), 'album_id' => array_keys($albumIds));
$fetchOptions = array('order' => $order ? $order : $defaultOrder, 'orderDirection' => 'desc', 'page' => $page, 'perPage' => $perPage, 'join' => XenGallery_Model_Album::FETCH_PRIVACY | XenGallery_Model_Album::FETCH_USER);
$albums = $albumModel->getAlbums($conditions, $fetchOptions);
$albums = $albumModel->prepareAlbums($albums);
foreach ($albums as $albumId => &$album) {
$album = array_merge($albumIds[$albumId], $album);
}
}
$pageNavParams = array('order' => $order != $defaultOrder ? $order : false);
$viewParams = array('albums' => $albums, 'albumCount' => $albums ? $albumModel->countAlbums($conditions, $fetchOptions) : 0, 'canViewRatings' => $this->_getMediaModel()->canViewRatings(), 'canViewComments' => $this->_getCommentModel()->canViewComments(), 'order' => $order, 'defaultOrder' => $defaultOrder, 'page' => $page, 'perPage' => $perPage, 'pageNavParams' => $pageNavParams, 'watchPage' => true, 'hideFilterMenu' => true);
return $this->responseView('XenGallery_ViewPublic_Watched_Albums', 'xengallery_watch_albums', $viewParams);
}
示例14: getVisibleReportsForUser
/**
* Gets the visible reports of this content type for the viewing user.
*
* @see XenForo_ReportHandler_Abstract:getVisibleReportsForUser()
*/
public function getVisibleReportsForUser(array $reports, array $viewingUser)
{
$reportsByUser = array();
foreach ($reports as $reportId => $report) {
$info = unserialize($report['content_info']);
$reportsByUser[$info['profile_user_id']][] = $reportId;
}
$users = XenForo_Model::create('XenForo_Model_User')->getUsersByIds(array_keys($reportsByUser), array('join' => XenForo_Model_User::FETCH_USER_PRIVACY, 'followingUserId' => $viewingUser['user_id']));
$userProfileModel = XenForo_Model::create('XenForo_Model_UserProfile');
foreach ($reportsByUser as $userId => $userReports) {
$remove = false;
if (isset($users[$userId]) && !$userProfileModel->canViewFullUserProfile($users[$userId], $null, $viewingUser)) {
$remove = true;
} else {
if (!XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'editAny') && !XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'deleteAny')) {
$remove = true;
}
}
if ($remove) {
foreach ($userReports as $reportId) {
unset($reports[$reportId]);
}
}
}
return $reports;
}
示例15: getVisibleReportsForUser
public function getVisibleReportsForUser(array $reports, array $viewingUser)
{
$teamIds = array();
foreach ($reports as $reportId => $report) {
$info = unserialize($report['content_info']);
$teamIds[$info['team_id']][] = $reportId;
}
$teamModel = XenForo_Model::create('Nobita_Teams_Model_Team');
$teams = $teamModel->getTeamsByIds(array_keys($teamIds), array('join' => Nobita_Teams_Model_Team::FETCH_CATEGORY | Nobita_Teams_Model_Team::FETCH_PRIVACY | Nobita_Teams_Model_Team::FETCH_PROFILE));
foreach ($teamIds as $teamId => $teamReports) {
$remove = false;
if (!isset($teams[$teamId])) {
$remove = true;
} else {
$team = $teams[$teamId];
if (!XenForo_Permission::hasPermission($viewingUser['permissions'], 'Teams', 'editPostAny') && !XenForo_Permission::hasPermission($viewingUser['permissions'], 'Teams', 'deletePostAny')) {
$remove = true;
}
}
if ($remove) {
foreach ($teamReports as $reportId) {
unset($teamReports[$reportId]);
}
}
}
return $reports;
}