Example #1
0
 /**
  * Fetches related content (profile posts) by IDs
  *
  * @param array $contentIds
  * @param XenForo_Model_NewsFeed $model
  * @param array $viewingUser Information about the viewing user (keys: user_id, permission_combination_id, permissions)
  *
  * @return array
  */
 public function getContentByIds(array $contentIds, $model, array $viewingUser)
 {
     $profilePosts = $this->_getProfilePostModel()->getProfilePostsByIds($contentIds, array('join' => XenForo_Model_ProfilePost::FETCH_USER_RECEIVER));
     $userIds = array();
     foreach ($profilePosts as $profilePost) {
         $userIds[$profilePost['profile_user_id']] = true;
     }
     $users = $model->getModelFromCache('XenForo_Model_User')->getUsersByIds(array_keys($userIds), array('join' => XenForo_Model_User::FETCH_USER_PRIVACY, 'followingUserId' => $viewingUser['user_id']));
     foreach ($profilePosts as $key => &$profilePost) {
         if (!isset($users[$profilePost['profile_user_id']])) {
             unset($profilePosts[$key]);
         } else {
             $profilePost['profileUser'] = $users[$profilePost['profile_user_id']];
         }
     }
     return $profilePosts;
 }
Example #2
0
 /**
  * Fetches related content (threads) by IDs
  *
  * @param array $contentIds
  * @param XenForo_Model_NewsFeed $model
  * @param array $viewingUser Information about the viewing user (keys: user_id, permission_combination_id, permissions)
  *
  * @return array
  */
 public function getContentByIds(array $contentIds, $model, array $viewingUser)
 {
     $threadModel = $this->_getThreadModel();
     $threads = $threadModel->getThreadsByIds($contentIds, array('join' => XenForo_Model_Thread::FETCH_FORUM | XenForo_Model_Thread::FETCH_FIRSTPOST, 'permissionCombinationId' => $viewingUser['permission_combination_id']));
     $hasAttachments = array();
     foreach ($threads as &$thread) {
         $thread['hasPreview'] = $threadModel->hasPreview($thread);
         if ($thread['attach_count']) {
             $hasAttachments[$thread['first_post_id']] = $thread['thread_id'];
             $thread['attachments'] = array();
         }
     }
     if ($hasAttachments) {
         $attachmentModel = XenForo_Model::create('XenForo_Model_Attachment');
         foreach ($attachmentModel->getAttachmentsByContentIds('post', array_keys($hasAttachments)) as $attachmentId => $attachment) {
             $threadId = $hasAttachments[$attachment['content_id']];
             $threads[$threadId]['attachments'][$attachmentId] = $attachmentModel->prepareAttachment($attachment);
         }
     }
     return $model->unserializePermissionsInList($threads, 'node_permission_cache');
 }