Esempio n. 1
0
 /**
 * vBForum_Search_Type_Post::fetch_validated_list()
 * When displaying results we get passed a list of id's. This
 * function determines which are viewable by the user.
 *
 * @param object $user
 * @param array $ids : the postid's returned from a search
 * @param array $gids : the group id's for the posts
 * @return array (array of viewable posts, array of rejected posts)
 */
 public function fetch_validated_list($user, $ids, $gids)
 {
     require_once DIR . '/includes/functions_forumlist.php';
     cache_moderators_once();
     $map = array();
     foreach ($ids as $i => $id) {
         $map[$gids[$i]][] = $id;
     }
     $threads = vB_Legacy_Thread::create_array(array_unique($gids));
     $rejected_groups = array();
     foreach ($threads as $thread) {
         if (!$thread->can_search($user)) {
             $rejected_groups[] = $thread->get_field('threadid');
             unset($map[$thread->get_field('threadid')]);
         }
     }
     $searchids = array();
     foreach ($map as $gid => $value) {
         $searchids = array_merge($searchids, $value);
     }
     $list = array_fill_keys($ids, false);
     if (count($searchids)) {
         $posts = vB_Legacy_Post::create_array($searchids, $threads);
         foreach ($posts as $id => $post) {
             $item = vBForum_Search_Result_Post::create_from_object($post);
             if ($item->can_search($user)) {
                 $list[$id] = $item;
             }
         }
     }
     $retval = array('list' => $list, 'groups_rejected' => $rejected_groups);
     ($hook = vBulletinHook::fetch_hook('search_validated_list')) ? eval($hook) : false;
     return $retval;
 }
Esempio n. 2
0
 public function fetch_validated_list($user, $ids, $gids)
 {
     require_once DIR . '/includes/functions_forumlist.php';
     cache_moderators();
     $list = array_fill_keys($ids, false);
     foreach (vB_Legacy_Thread::create_array($ids) as $key => $thread) {
         $item = vBForum_Search_Result_Thread::create_from_thread($thread);
         if ($item->can_search($user)) {
             $list[$key] = $item;
         }
     }
     $retval = array('list' => $list, 'groups_rejected' => $rejected_groups);
     ($hook = vBulletinHook::fetch_hook('search_validated_list')) ? eval($hook) : false;
     return $retval;
 }