Aha, thanks orban. What I want to do is this:
If an user wants to search for all threads/posts related to a specific user, he enters a username then leaves the search field empty. The results will show all threads started by that user, ordered the way you like it in Sphinx.
Anyone wants to work with me on this project? I PM'ed kmike, hoping he will join us... since he is the only one who managed to fix this, not to mention other little extras.
Quote:
Originally Posted by DaiTengu
You wouldn't happen to have an easy way to implement that, would you? My PHP knowledge is somewhat lacking 
|
Code:
/***
* Removes duplicate keys and orders thread id's by lastpost
*
* @param array record id's to be ordered
*
* @return array
*/
function sort_thread_ids($keys)
{
global $vbulletin;
$itemids = array();
$items = $vbulletin->db->query_read_slave("
SELECT threadid FROM " . TABLE_PREFIX . "thread AS thread
WHERE threadid IN (" . implode(',', array_keys($keys)) . ")
ORDER BY lastpost " . $vbulletin->GPC['sortorder'] . "
");
while ($item = $vbulletin->db->fetch_array($items))
{
$itemids[] = $item['threadid'];
}
unset($item);
$vbulletin->db->free_result($items);
return $itemids;
}
Then you call it anywhere you like:
Code:
if (!$vbulletin->GPC['showposts'] AND $vbulletin->GPC['sortby'] == 'lastpost')
{
$orderedids = sort_thread_ids($orderedids);
}
Can you post results on your busy boards and let me know how it impacts the performance?
The function above has less processing code then the original sort_search_items() function.
The PHP BBCode at vb.org is screwed, it breaks the code lines. Switched back to Code, much better.