|
From: Ruslan U. <rx...@ph...> - 2009-08-25 13:53:29
|
Author: rxu
Date: Tue Aug 25 14:52:35 2009
New Revision: 10057
Log:
One more unread posts search adjustment.
Authorised by: AcydBurn
Modified:
branches/phpBB-3_0_0/phpBB/includes/functions.php
branches/phpBB-3_0_0/phpBB/search.php
Modified: branches/phpBB-3_0_0/phpBB/includes/functions.php
==============================================================================
*** branches/phpBB-3_0_0/phpBB/includes/functions.php (original)
--- branches/phpBB-3_0_0/phpBB/includes/functions.php Tue Aug 25 14:52:35 2009
***************
*** 1649,1660 ****
*
* @param int $user_id User ID (or false for current user)
* @param string $sql_extra Extra WHERE SQL statement
! * @param string $sql_limit Limits the size of unread topics list
*
* @return array[int][int] Topic ids as keys, mark_time of topic as value
* @author rxu
*/
! function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_limit = 1001)
{
global $config, $db, $user;
--- 1649,1661 ----
*
* @param int $user_id User ID (or false for current user)
* @param string $sql_extra Extra WHERE SQL statement
! * @param string $sql_sort ORDER BY SQL sorting statement
! * @param string $sql_limit Limits the size of unread topics list, 0 for unlimited query
*
* @return array[int][int] Topic ids as keys, mark_time of topic as value
* @author rxu
*/
! function get_unread_topics_list($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001)
{
global $config, $db, $user;
***************
*** 1663,1668 ****
--- 1664,1674 ----
$user_id = (int) $user->data['user_id'];
}
+ if (empty($sql_sort))
+ {
+ $sql_sort = 'ORDER BY t.topic_last_post_time DESC';
+ }
+
$tracked_topics_list = $unread_topics_list = $read_topics_list = array();
$tracked_forums_list = $mark_time = array();
***************
*** 1674,1680 ****
WHERE t.topic_id = tt.topic_id
AND tt.user_id = $user_id
$sql_extra
! ORDER BY t.topic_last_post_time DESC";
$result = $db->sql_query_limit($sql, $sql_limit);
while ($row = $db->sql_fetchrow($result))
--- 1680,1686 ----
WHERE t.topic_id = tt.topic_id
AND tt.user_id = $user_id
$sql_extra
! $sql_sort";
$result = $db->sql_query_limit($sql, $sql_limit);
while ($row = $db->sql_fetchrow($result))
***************
*** 1706,1712 ****
AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . "
AND ft.user_id = $user_id
$sql_extra
! ORDER BY t.topic_last_post_time DESC";
$result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count));
while ($row = $db->sql_fetchrow($result))
--- 1712,1718 ----
AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . "
AND ft.user_id = $user_id
$sql_extra
! $sql_sort";
$result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count));
while ($row = $db->sql_fetchrow($result))
***************
*** 1742,1748 ****
AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . '
AND ' . $db->sql_in_set('t.forum_id', $tracked_forums_list, true, true) . "
$sql_extra
! ORDER BY t.topic_last_post_time DESC";
$result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count));
while ($row = $db->sql_fetchrow($result))
--- 1748,1754 ----
AND ' . $db->sql_in_set('t.topic_id', $tracked_topics_list, true, true) . '
AND ' . $db->sql_in_set('t.forum_id', $tracked_forums_list, true, true) . "
$sql_extra
! $sql_sort";
$result = $db->sql_query_limit($sql, ($sql_limit - $unread_list_count));
while ($row = $db->sql_fetchrow($result))
***************
*** 1776,1784 ****
FROM ' . TOPICS_TABLE . ' t
WHERE t.topic_last_post_time > ' . $user_lastmark . "
$sql_extra
! ORDER BY t.topic_last_post_time DESC";
! $result = $db->sql_query_limit($sql, 1000);
while ($row = $db->sql_fetchrow($result))
{
--- 1782,1790 ----
FROM ' . TOPICS_TABLE . ' t
WHERE t.topic_last_post_time > ' . $user_lastmark . "
$sql_extra
! $sql_sort";
! $result = $db->sql_query_limit($sql, $sql_limit);
while ($row = $db->sql_fetchrow($result))
{
Modified: branches/phpBB-3_0_0/phpBB/search.php
==============================================================================
*** branches/phpBB-3_0_0/phpBB/search.php (original)
--- branches/phpBB-3_0_0/phpBB/search.php Tue Aug 25 14:52:35 2009
***************
*** 376,399 ****
// force sorting
$show_results = 'topics';
$sort_key = 't';
- $sort_dir = 'd';
$sort_by_sql['t'] = 't.topic_last_post_time';
$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
$s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = '';
$unread_list = array();
! $unread_list = get_unread_topics_list();
if (!empty($unread_list))
{
$sql = 'SELECT t.topic_id
FROM ' . TOPICS_TABLE . ' t
! WHERE ' . $db->sql_in_set('t.topic_id', array_keys($unread_list)) . '
! AND t.topic_moved_id = 0
! ' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
! ' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '') . "
$sql_sort";
$field = 'topic_id';
}
--- 376,398 ----
// force sorting
$show_results = 'topics';
$sort_key = 't';
$sort_by_sql['t'] = 't.topic_last_post_time';
$sql_sort = 'ORDER BY ' . $sort_by_sql[$sort_key] . (($sort_dir == 'a') ? ' ASC' : ' DESC');
+ $sql_where = 'AND t.topic_moved_id = 0
+ ' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
+ ' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
$s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = '';
$unread_list = array();
! $unread_list = get_unread_topics_list($user->data['user_id'], $sql_where, $sql_sort);
if (!empty($unread_list))
{
$sql = 'SELECT t.topic_id
FROM ' . TOPICS_TABLE . ' t
! WHERE ' . $db->sql_in_set('t.topic_id', array_keys($unread_list)) . "
$sql_sort";
$field = 'topic_id';
}
|