From fdf19b0d9590bb3de3078adb86ba080afe2acc34 Mon Sep 17 00:00:00 2001
From: Meik Sievertsen <acydburn@phpbb.com>
Date: Mon, 7 Sep 2009 12:39:37 +0000
Subject: [PATCH] since we now have several search_ids, all with different
 default results modes we now always add the sr variable to the URL - Bug
 #50775

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10117 89ea8834-ac86-4346-8a33-228a782c2dd0
---
 phpBB/search.php | 47 ++++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 23 deletions(-)

diff --git a/phpBB/search.php b/phpBB/search.php
index 66323e5d1d..efe5c247cb 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -372,30 +372,31 @@ if ($keywords || $author || $author_id || $search_id || $submit)
 			break;
 
 			case 'unreadposts':
-					$l_search_title = $user->lang['SEARCH_UNREAD'];
-					// 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) : '');
+				$l_search_title = $user->lang['SEARCH_UNREAD'];
+				// 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');
 
-					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);
+				$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) : '');
 
-					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';
-					}
+				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';
+				}
 			break;
 
 			case 'newposts':
@@ -541,7 +542,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
 	$hilit = (strspn($hilit, '*') === strlen($hilit)) ? '' : $hilit;
 
 	$u_hilit = urlencode(htmlspecialchars_decode(str_replace('|', ' ', $hilit)));
-	$u_show_results = ($show_results != 'posts') ? '&amp;sr=' . $show_results : '';
+	$u_show_results = '&amp;sr=' . $show_results;
 	$u_search_forum = implode('&amp;fid%5B%5D=', $search_forum);
 
 	$u_search = append_sid("{$phpbb_root_path}search.$phpEx", $u_sort_param . $u_show_results);