Line 337 | Line 337 |
---|
}
// define some variables needed for retrieving post_id/topic_id information
|
}
// define some variables needed for retrieving post_id/topic_id information
|
$sort_by_sql = array('a' => 'u.username_clean', 't' => (($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'), 'f' => 'f.forum_id', 'i' => 't.topic_title', 's' => (($show_results == 'posts') ? 'p.post_subject' : 't.topic_title'));
| $sort_by_sql = [ 'a' => 'u.username_clean', 't' => (($show_results == 'posts') ? 'p.post_time' : 't.topic_last_post_time'), 'f' => 'f.forum_id', 'i' => 't.topic_title', 's' => (($show_results == 'posts') ? 'p.post_subject' : 't.topic_title') ];
|
/** * Event to modify the SQL parameters before pre-made searches
| /** * Event to modify the SQL parameters before pre-made searches
|
Line 403 | Line 409 |
---|
$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
$sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : '';
|
$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
$sort_join = ($sort_key == 'f') ? FORUMS_TABLE . ' f, ' : '';
|
$sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = p.forum_id ' . $sql_sort : $sql_sort;
| $sql_sort = ($sort_key == 'f') ? ' AND f.forum_id = t.forum_id ' . $sql_sort : $sql_sort;
|
if ($sort_days) {
|
if ($sort_days) {
|
$last_post_time = 'AND p.post_time > ' . (time() - ($sort_days * 24 * 3600));
| $last_post_time = 'AND ' . ($show_results == 'posts' ? 'p.post_time' : 't.topic_last_post_time') . ' > ' . (time() - ($sort_days * 24 * 3600));
|
} else {
| } else {
|
Line 417 | Line 423 |
---|
if ($sort_key == 'a') { $sort_join = USERS_TABLE . ' u, ';
|
if ($sort_key == 'a') { $sort_join = USERS_TABLE . ' u, ';
|
$sql_sort = ' AND u.user_id = p.poster_id ' . $sql_sort;
| $sql_sort = ' AND u.user_id = ' . ($show_results == 'posts' ? 'p.poster_id ' : 't.topic_last_poster_id ') . $sql_sort;
|
} if ($show_results == 'posts') {
| } if ($show_results == 'posts') {
|
Line 433 | Line 439 |
---|
} else {
|
} else {
|
$sql = 'SELECT DISTINCT ' . $sort_by_sql[$sort_key] . ", p.topic_id FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
| $sql = 'SELECT DISTINCT ' . $sort_by_sql[$sort_key] . ", t.topic_id FROM $sort_join" . TOPICS_TABLE . " t
|
WHERE t.topic_posts_approved = 1 AND t.topic_moved_id = 0
|
WHERE t.topic_posts_approved = 1 AND t.topic_moved_id = 0
|
AND p.topic_id = t.topic_id
| |
$last_post_time AND $m_approve_topics_fid_sql
|
$last_post_time AND $m_approve_topics_fid_sql
|
" . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '') . "
| " . ((count($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . "
|
$sql_sort"; $field = 'topic_id'; }
| $sql_sort"; $field = 'topic_id'; }
|