$searchterms['searchdate'] = $_REQUEST['do'] == 'getnew' ? 'lastvisit' : 1; $searchterms['contenttypeid'] = $type; $searchterms['search_type'] = 1; $searchterms['showposts'] = $vbulletin->GPC['showposts']; $criteria->set_search_terms($searchterms); } $criteria->add_contenttype_filter($type); $criteria->set_grouped($vbulletin->GPC['showposts'] ? vB_Search_Core::GROUP_NO : vB_Search_Core::GROUP_YES); //set critieria and sort set_newitem_forums($criteria); set_newitem_date($criteria, $current_user, $_REQUEST['do']); set_getnew_sort($criteria, $vbulletin->GPC['sortby']); //check for any errors $errors = $criteria->get_errors(); if ($errors) { standard_error(fetch_error($errors[0])); } try { $search_controller = $search_core->get_newitem_search_controller_by_id($type); } catch (Exception $e) {
function do_new_posts_search(&$searchid, &$reterrors) { global $vbulletin, $db, $vbphrase, $search_core, $current_user; $errors = array(); //f is an auto variable that is already registered. We include it here for //clarity and to guard against the day that we don't automatically process //the forum/thread/post variables on init $vbulletin->input->clean_array_gpc('r', array('f' => TYPE_UINT, 'days' => TYPE_UINT, 'exclude' => TYPE_NOHTML, 'include' => TYPE_NOHTML, 'showposts' => TYPE_BOOL, 'oldmethod' => TYPE_BOOL, 'sortby' => TYPE_NOHTML, 'noannounce' => TYPE_BOOL, 'contenttype' => TYPE_NOHTML, 'type' => TYPE_STR)); $criteria = $search_core->create_criteria(vB_Search_Core::SEARCH_NEW); //default to post to preserve existing links if (!$vbulletin->GPC_exists['contenttypeid']) { $type = $vbulletin->GPC['contenttypeid']; } if (!$vbulletin->GPC_exists['contenttype']) { $type = 'vBForum_Post'; } else { $type = $vbulletin->GPC['contenttype']; } $type = vB_Types::instance()->getContentTypeId($type); if (!$type) { //todo, do we need a seperate error for this? $errors[] = 'searchnoresults'; } //hack, we have a getnew controller for events, but they are not actually //indexed. For now we need to skip the search backlink for events because //there isn't anywhere for them to go. if ($type != vB_Types::instance()->getContentTypeId('vBForum_Event')) { $searchterms['searchdate'] = $_REQUEST['do'] == 'getnew' ? 'lastvisit' : 1; $searchterms['contenttypeid'] = $type; $searchterms['search_type'] = 1; $searchterms['showposts'] = $vbulletin->GPC['showposts']; $criteria->set_search_terms($searchterms); } $criteria->add_contenttype_filter($type); $criteria->set_grouped($vbulletin->GPC['showposts'] ? vB_Search_Core::GROUP_NO : vB_Search_Core::GROUP_YES); //set critieria and sort set_newitem_forums($criteria); set_newitem_date($criteria, $current_user, $_REQUEST['do']); set_getnew_sort($criteria, $vbulletin->GPC['sortby']); //check for any errors $errors = array_merge($errors, $criteria->get_errors()); if (count($errors) > 0) { $reterrors = $errors; return; } try { $search_controller = $search_core->get_newitem_search_controller_by_id($type); } catch (Exception $e) { $errors[] = 'searchnoresults'; $reterrors = $errors; return; } $results = vB_Search_Results::create_from_criteria($current_user, $criteria, $search_controller); $searchid = $results->get_searchid(); }