コード例 #1
0
 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
0
ファイル: User.php プロジェクト: VoDongMy/xenforo-laravel5.1
 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
0
 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
0
ファイル: Callback.php プロジェクト: Sywooch/forums
 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
0
ファイル: Forum.php プロジェクト: namgiangle90/tokyobaito
 /**
  * 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
0
ファイル: Resource.php プロジェクト: Sywooch/forums
 /**
  * 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
0
ファイル: Draft.php プロジェクト: Sywooch/forums
 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
0
ファイル: Media.php プロジェクト: VoDongMy/xenforo-laravel5.1
 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
0
ファイル: Media.php プロジェクト: VoDongMy/xenforo-laravel5.1
 /**
  * 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
0
ファイル: ProfilePost.php プロジェクト: Sywooch/forums
 /**
  * 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
0
 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
0
ファイル: Post.php プロジェクト: Sywooch/forums
 /**
  * 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
0
 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
0
 /**
  * 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
0
ファイル: Post.php プロジェクト: Sywooch/forums
 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;
 }
コード例 #16
0
ファイル: Perms.php プロジェクト: Sywooch/forums
 public function getPermissions(array $viewingUser = null)
 {
     $this->standardizeViewingUserReference($viewingUser);
     $perms['custom'] = XenForo_Permission::hasPermission($viewingUser['permissions'], 'EWRporta', 'canCustom') ? true : false;
     $perms['promote'] = XenForo_Permission::hasPermission($viewingUser['permissions'], 'EWRporta', 'canPromote') ? true : false;
     return $perms;
 }
コード例 #17
0
 /**
  * Gets visible moderation queue entries for specified user.
  *
  * @see XenForo_ModerationQueueHandler_Abstract::getVisibleModerationQueueEntriesForUser()
  */
 public function getVisibleModerationQueueEntriesForUser(array $contentIds, array $viewingUser)
 {
     /** @var XenForo_Model_ProfilePost $profilePostModel */
     $profilePostModel = XenForo_Model::create('XenForo_Model_ProfilePost');
     $comments = $profilePostModel->getProfilePostCommentsByIds($contentIds);
     $profilePostIds = XenForo_Application::arrayColumn($comments, 'profile_post_id');
     $profilePosts = $profilePostModel->getProfilePostsByIds($profilePostIds, array('join' => XenForo_Model_ProfilePost::FETCH_USER_RECEIVER | XenForo_Model_ProfilePost::FETCH_USER_RECEIVER_PRIVACY | XenForo_Model_ProfilePost::FETCH_USER_POSTER, 'visitingUser' => $viewingUser));
     $output = array();
     foreach ($comments as $key => &$comment) {
         if (isset($profilePosts[$comment['profile_post_id']])) {
             $comment['profilePost'] = $profilePosts[$comment['profile_post_id']];
             $comment['profileUser'] = $profilePostModel->getProfileUserFromProfilePost($comment['profilePost'], $viewingUser);
             if (!$comment['profilePost'] || !$comment['profileUser']) {
                 continue;
             }
             $canManage = true;
             if (!$profilePostModel->canViewProfilePostAndContainer($comment['profilePost'], $comment['profileUser'], $null, $viewingUser)) {
                 $canManage = false;
             } else {
                 if (!$profilePostModel->canViewProfilePostComment($comment, $comment['profilePost'], $comment['profileUser'], $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[$comment['profile_post_comment_id']] = array('message' => $comment['message'], 'user' => array('user_id' => $comment['user_id'], 'username' => $comment['username']), 'title' => new XenForo_Phrase('profile_post_comment_by_x', array('username' => $comment['username'])), 'link' => XenForo_Link::buildPublicLink('profile-posts/comments', $comment), 'contentTypeTitle' => new XenForo_Phrase('profile_post_comment'), 'titleEdit' => false);
             }
         }
     }
     return $output;
 }
コード例 #18
0
ファイル: Media.php プロジェクト: VoDongMy/xenforo-laravel5.1
 protected function _getContent(array $contentIds, array $viewingUser)
 {
     $mediaModel = $this->_getMediaModel();
     $conditions = array('media_id' => $contentIds, 'privacyUserId' => $viewingUser['user_id'], 'deleted' => $mediaModel->canViewDeletedMedia($null, $viewingUser), 'moderated' => $mediaModel->canViewUnapprovedMedia($null, $viewingUser), 'viewAlbums' => XenForo_Permission::hasPermission($viewingUser['permissions'], 'xengallery', 'viewAlbums'), 'viewCategoryIds' => $mediaModel->getViewableCategoriesForVisitor($viewingUser));
     $fetchOptions = array('join' => XenGallery_Model_Media::FETCH_USER | XenGallery_Model_Media::FETCH_ALBUM | XenGallery_Model_Media::FETCH_CATEGORY | XenGallery_Model_Media::FETCH_PRIVACY);
     return $mediaModel->getMedia($conditions, $fetchOptions);
 }
コード例 #19
0
ファイル: User.php プロジェクト: ThemeHouse-XF/SimilarUsernam
 /**
  * Determines if permissions are sufficient to view similar usernames for
  * the given user.
  *
  * @param array $user User being viewed
  * @param string $errorPhraseKey Returned by ref. Phrase key of more
  * specific error
  * @param array|null $viewingUser Viewing user ref
  *
  * @return boolean
  */
 public function canViewSimilarUsernames(array $user, &$errorPhraseKey = '', array $viewingUser = null)
 {
     if (empty($user['user_id'])) {
         return false;
     }
     $this->standardizeViewingUserReference($viewingUser);
     return XenForo_Permission::hasPermission($viewingUser['permissions'], 'general', 'similarUsernames');
 }
コード例 #20
0
 /**
  * Determines if a user can view the lists of threads in watched forums
  *
  * @param string $errorPhraseKey
  * @param array|null $viewingUser
  *
  * @return boolean
  */
 public function canViewThreadsInWatchedForums(&$errorPhraseKey = '', array $viewingUser = null)
 {
     $this->standardizeViewingUserReference($viewingUser);
     if (!$viewingUser['user_id'] || !XenForo_Permission::hasPermission($viewingUser['permissions'], 'general', 'viewThreadsWatchedForums')) {
         return false;
     }
     return true;
 }
コード例 #21
0
ファイル: Post.php プロジェクト: ThemeHouse-XF/AnonymousPosts
 protected function _canMakeAnonymousPost($userId, $nodeId)
 {
     $userFetchOptions = array('join' => XenForo_Model_User::FETCH_USER_PERMISSIONS);
     $user = $this->_getUserModel()->getUserById($userId, $userFetchOptions);
     $user['permissions'] = @unserialize($user['global_permission_cache']);
     $nodePermissions = $this->_getNodeModel()->getNodePermissionsForPermissionCombination($user['permission_combination_id']);
     return XenForo_Permission::hasContentPermission($nodePermissions[$nodeId], 'postAnonymousReply');
 }
コード例 #22
0
ファイル: Forum.php プロジェクト: Sywooch/forums
 public function Tinhte_XenTag_getMaximumHashtags(array $forum, array $nodePermissions = null, array $viewingUser = null)
 {
     if (!Tinhte_XenTag_Option::get('useHashtag')) {
         return 0;
     }
     $this->standardizeViewingUserReferenceForNode($forum['node_id'], $viewingUser, $nodePermissions);
     return XenForo_Permission::hasContentPermission($nodePermissions, 'Tinhte_XenTag_maximumHts');
 }
コード例 #23
0
ファイル: User.php プロジェクト: AndroidOS/SocialGroups
 /**
  * Determines the maximum number of secondary social forums for the specified user.
  *
  * @param string $errorPhraseKey Returned by ref. Phrase key of more specific error
  * @param array|null $viewingUser Viewing user ref
  *
  * @return integer
  */
 public function getMaximumSecondarySocialForums(&$errorPhraseKey = '', array $viewingUser = null)
 {
     $this->standardizeViewingUserReference($viewingUser);
     if (!$viewingUser['user_id']) {
         return 0;
     }
     return XenForo_Permission::hasPermission($viewingUser['permissions'], 'general', 'maxSecondarySocialForums');
 }
コード例 #24
0
ファイル: User.php プロジェクト: ThemeHouse-XF/TempUserChange
 /**
  * Determines if a user can edit the temporary user changes
  *
  * @param string $errorPhraseKey
  * @param array|null $viewingUser
  *
  * @return boolean
  */
 public function canEditTempUserChanges(&$errorPhraseKey = '', array $viewingUser = null)
 {
     $this->standardizeViewingUserReference($viewingUser);
     if (!$viewingUser['user_id'] || !XenForo_Permission::hasPermission($viewingUser['permissions'], 'general', 'editTempUserChange')) {
         return false;
     }
     return true;
 }
コード例 #25
0
 /**
  *
  * @see XenForo_Model_UserProfile
  */
 public function canViewProfilePosts(array $user, &$errorPhraseKey = '', array $viewingUser = null)
 {
     $this->standardizeViewingUserReference($viewingUser);
     if ($user['user_id'] == $viewingUser['user_id']) {
         return XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'viewOwnStatus');
     }
     return parent::canViewProfilePosts($user, $errorPhraseKey, $viewingUser);
 }
コード例 #26
0
ファイル: Resource.php プロジェクト: Sywooch/forums
 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);
 }
コード例 #27
0
ファイル: Forum.php プロジェクト: Sywooch/forums
 public function canViewForum(array $forum, &$errorPhraseKey = '', array $nodePermissions = null, array $viewingUser = null)
 {
     $canView = parent::canViewForum($forum, $errorPhraseKey, $nodePermissions, $viewingUser);
     if ($canView && isset($GLOBALS['BRETI_ExtraThreadItem'])) {
         $this->standardizeViewingUserReferenceForNode($forum['node_id'], $viewingUser, $nodePermissions);
         $canView = XenForo_Permission::hasContentPermission($nodePermissions, 'viewOthers');
     }
     return $canView;
 }
コード例 #28
0
ファイル: Perms.php プロジェクト: samuelsweet/xf
 public function getPermissions(array $viewingUser = null)
 {
     $this->standardizeViewingUserReference($viewingUser);
     $perms['post'] = XenForo_Permission::hasPermission($viewingUser['permissions'], 'GeekListings', 'canPost') ? true : false;
     $perms['bypass'] = XenForo_Permission::hasPermission($viewingUser['permissions'], 'GeekListings', 'canBypass') ? true : false;
     $perms['rsvp'] = XenForo_Permission::hasPermission($viewingUser['permissions'], 'GeekListings', 'canRSVP') ? true : false;
     $perms['mod'] = XenForo_Permission::hasPermission($viewingUser['permissions'], 'GeekListings', 'canMod') ? true : false;
     return $perms;
 }
コード例 #29
0
 /**
  *
  * @see XenForo_Model_ProfilePost::getPermissionBasedProfilePostConditions()
  */
 public function getPermissionBasedProfilePostConditions(array $user, array $viewingUser = null)
 {
     $conditions = parent::getPermissionBasedProfilePostConditions($user, $viewingUser);
     $this->standardizeViewingUserReference($viewingUser);
     if ($user['user_id'] == $viewingUser['user_id'] && !XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'view') && XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'viewOwnStatus')) {
         $conditions['profile_post_user_id'] = $viewingUser['user_id'];
     }
     return $conditions;
 }
コード例 #30
0
 /**
  * 
  * @see XenForo_Model_Attachment::canDeleteAttachment()
  */
 public function canDeleteAttachment(array $attachment, $tempHash = '', array $viewingUser = null)
 {
     $this->standardizeViewingUserReference($viewingUser);
     if (empty($attachment['temp_hash']) || !empty($attachment['content_id'])) {
         if (!XenForo_Permission::hasPermission($viewingUser['permissions'], 'general', 'deleteAttachment')) {
             return false;
         }
     }
     return parent::canDeleteAttachment($attachment, $tempHash, $viewingUser);
 }