diff --git a/CHANGELOG.md b/CHANGELOG.md index a25f32954..9c458403b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Store uploads metadata in a separate sql database table instead of a session (#8415) - Mouse-over menu on messages list (#7141) - Advanced mail search syntax with more possibilities (without UI) (#8502) +- Added an option for a default mail search scope (#9077, #7556) - Support for HAproxy protocol header in IMAP connections (#8625) - Change 'smtp_log' option default value to False - Delete messages directly from Junk on folder purge if delete_junk is enabled (#8766) diff --git a/config/defaults.inc.php b/config/defaults.inc.php index 43a38750e..d6ac40850 100644 --- a/config/defaults.inc.php +++ b/config/defaults.inc.php @@ -1434,13 +1434,18 @@ $config['force_7bit'] = false; // The entry with key '*' stands for all folders which do not have a specific list set. // Supported fields: subject, from, to, cc, bcc, replyto, followupto, body, text. // Please note that folder names should to be in sync with $config['*_mbox'] options -$config['search_mods'] = null; // Example: ['*' => ['subject'=>1, 'from'=>1], 'Sent' => ['subject'=>1, 'to'=>1]]; +// Example: ['*' => ['subject'=>1, 'from'=>1], 'Sent' => ['subject'=>1, 'to'=>1]]; +$config['search_mods'] = null; -// Default search scope -$config['search_scope'] = null; // Example: 'all' - for all folders, 'base' - for current folder, 'sub' - for this and subfolders +// Default search scope. Supported values: +// 'base' - for current folder (default), +// 'sub' - for current folder and subfolders, +// 'all' - for all folders +$config['search_scope'] = null; // Defaults of the addressbook search field configuration. -$config['addressbook_search_mods'] = null; // Example: ['name'=>1, 'firstname'=>1, 'surname'=>1, 'email'=>1, '*'=>1]; +// Example: ['name'=>1, 'firstname'=>1, 'surname'=>1, 'email'=>1, '*'=>1]; +$config['addressbook_search_mods'] = null; // Directly delete messages in Junk instead of moving to Trash $config['delete_junk'] = false; diff --git a/program/actions/mail/index.php b/program/actions/mail/index.php index 6c1f69dac..26a8bf09b 100644 --- a/program/actions/mail/index.php +++ b/program/actions/mail/index.php @@ -97,16 +97,7 @@ class rcmail_action_mail_index extends rcmail_action if (empty($rcmail->action)) { $rcmail->output->set_env('search_mods', self::search_mods()); - - $scope = rcube_utils::get_input_string('_scope', rcube_utils::INPUT_GET); - if (!$scope && isset($_SESSION['search_scope']) && $rcmail->output->get_env('search_request')) { - $scope = $_SESSION['search_scope']; - } - - if (!$scope) { - $scope = self::search_scope(); - } - $rcmail->output->set_env('search_scope', strtolower($scope)); + $rcmail->output->set_env('search_scope', self::search_scope()); self::list_pagetitle(); } @@ -278,18 +269,26 @@ class rcmail_action_mail_index extends rcmail_action } /** - * Returns default search scopes - */ + * Returns a requested or default search scope + */ public static function search_scope() { $rcmail = rcmail::get_instance(); - $scope = $rcmail->config->get('search_scope'); + $scope = rcube_utils::get_input_string('_scope', rcube_utils::INPUT_GET); - if (empty($scope)) { + if (!$scope && isset($_SESSION['search_scope']) && $rcmail->output->get_env('search_request')) { + $scope = $_SESSION['search_scope']; + } + + if (!$scope) { + $scope = $rcmail->config->get('search_scope'); + } + + if (!$scope || !preg_match('/^(all|sub|base)$/i', $scope)) { $scope = 'base'; } - return $scope; + return strtolower($scope); } /**