Allow searching for all folders

This patch allows to search for all folders in roundcube. By default, the search option “All folders” only searches accross all subscribed folders. This patch changes the meaning and adds the new one.

It also indicates in the search result in which folder the e-mail is located, regardless of the search option.

Software
Roundcube
Tested software versions for the patch
Patch author
Immae
Patch license
GNU General Public License v3
Patch date
2022
Original sources
Patches
  • roundcube-1.4.15_search_all.patch
    diff --git a/program/js/app.js b/program/js/app.js
    index 2094b7b7b..06fe96a80 100644
    --- a/program/js/app.js
    +++ b/program/js/app.js
    @@ -2277,6 +2277,9 @@ function rcube_webmail()
         }
     
         tree += '<span id="msgicn'+row.id+'" class="'+css_class+status_class+'" title="'+status_label+'"></span>';
    +    if (flags.mbox != this.env.mailbox) {
    +      tree += '<span style="color:#737677">' + flags.mbox + '&nbsp;<span>';
    +    }
         row.className = row_class;
     
         // build subject link
    diff --git a/program/localization/en_CA/labels.inc b/program/localization/en_CA/labels.inc
    index 03c1c8e11..8d67a49ac 100644
    --- a/program/localization/en_CA/labels.inc
    +++ b/program/localization/en_CA/labels.inc
    @@ -128,6 +128,7 @@ $labels['markunread'] = 'As unread';
     $labels['markflagged'] = 'As flagged';
     $labels['markunflagged'] = 'As unflagged';
     $labels['moreactions'] = 'More actions...';
    +$labels['folders-allsubscribed'] = 'All subscribed folders';
     $labels['folders-all'] = 'All folders';
     $labels['more'] = 'More';
     $labels['back'] = 'Back';
    @@ -184,6 +185,7 @@ $labels['namex'] = 'Name';
     $labels['searchscope'] = 'Scope';
     $labels['currentfolder'] = 'Current folder';
     $labels['subfolders'] = 'This and subfolders';
    +$labels['allsubscribedfolders'] = 'All subscribed folders';
     $labels['allfolders'] = 'All folders';
     $labels['openinextwin'] = 'Open in new window';
     $labels['emlsave'] = 'Download (.eml)';
    diff --git a/program/localization/en_GB/labels.inc b/program/localization/en_GB/labels.inc
    index a442965de..b5b4839e3 100644
    --- a/program/localization/en_GB/labels.inc
    +++ b/program/localization/en_GB/labels.inc
    @@ -135,6 +135,7 @@ $labels['moreactions'] = 'More actions...';
     $labels['markallread'] = 'Mark all as read';
     $labels['folders-cur'] = 'Selected folder only';
     $labels['folders-sub'] = 'Selected folder and its subfolders';
    +$labels['folders-allsubscribed'] = 'All subscribed folders';
     $labels['folders-all'] = 'All folders';
     $labels['more'] = 'More';
     $labels['back'] = 'Back';
    @@ -221,6 +222,7 @@ $labels['namex'] = 'Name';
     $labels['searchscope'] = 'Scope';
     $labels['currentfolder'] = 'Current folder';
     $labels['subfolders'] = 'This and subfolders';
    +$labels['allsubscribedfolders'] = 'All subscribed folders';
     $labels['allfolders'] = 'All folders';
     $labels['searchinterval-1W'] = 'older than a week';
     $labels['searchinterval-1M'] = 'older than a month';
    diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
    index 2e8ec8009..c7736557f 100644
    --- a/program/localization/en_US/labels.inc
    +++ b/program/localization/en_US/labels.inc
    @@ -158,6 +158,7 @@ $labels['moreactions'] = 'More actions...';
     $labels['markallread'] = 'Mark all as read';
     $labels['folders-cur'] = 'Selected folder only';
     $labels['folders-sub'] = 'Selected folder and its subfolders';
    +$labels['folders-allsubscribed'] = 'All subscribed folders';
     $labels['folders-all'] = 'All folders';
     $labels['more'] = 'More';
     $labels['back'] = 'Back';
    @@ -249,6 +250,7 @@ $labels['namex'] = 'Name';
     $labels['searchscope'] = 'Scope';
     $labels['currentfolder'] = 'Current folder';
     $labels['subfolders'] = 'This and subfolders';
    +$labels['allsubscribedfolders'] = 'All subscribed folders';
     $labels['allfolders'] = 'All folders';
     $labels['searchinterval-1W'] = 'older than a week';
     $labels['searchinterval-1M'] = 'older than a month';
    diff --git a/program/localization/fr_FR/labels.inc b/program/localization/fr_FR/labels.inc
    index 6db44f95c..ad83e15d8 100644
    --- a/program/localization/fr_FR/labels.inc
    +++ b/program/localization/fr_FR/labels.inc
    @@ -135,6 +135,7 @@ $labels['moreactions'] = 'Plus d’actions…';
     $labels['markallread'] = 'Tout marquer comme lu';
     $labels['folders-cur'] = 'Dossier sélectionné seulement';
     $labels['folders-sub'] = 'Dossier sélectionné et ses sous-dossiers';
    +$labels['folders-allsubscribed'] = 'Tous les dossiers souscrits';
     $labels['folders-all'] = 'Tous les dossiers';
     $labels['more'] = 'Plus';
     $labels['back'] = 'Retour';
    @@ -221,6 +222,7 @@ $labels['namex'] = 'Nom';
     $labels['searchscope'] = 'Portée';
     $labels['currentfolder'] = 'Répertoire actuel';
     $labels['subfolders'] = 'Ceci et les sous-dossiers';
    +$labels['allsubscribedfolders'] = 'Tous les dossiers souscrits';
     $labels['allfolders'] = 'Tous les dossiers';
     $labels['searchinterval-1W'] = 'plus d’une semaine';
     $labels['searchinterval-1M'] = 'plus d’un mois';
    diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
    index 8e0c642f6..ac79780e0 100644
    --- a/program/steps/mail/func.inc
    +++ b/program/steps/mail/func.inc
    @@ -110,8 +110,8 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') {
                 'copy', 'move', 'quota', 'replyall', 'replylist', 'stillsearching',
                 'flagged', 'unflagged', 'unread', 'deleted', 'replied', 'forwarded',
                 'priority', 'withattachment', 'fileuploaderror', 'mark', 'markallread',
    -            'folders-cur', 'folders-sub', 'folders-all', 'cancel', 'bounce', 'bouncemsg',
    -            'sendingmessage');
    +            'folders-cur', 'folders-sub', 'folders-allsubscribed', 'folder-all',
    +            'cancel', 'bounce', 'bouncemsg', 'sendingmessage');
         }
     }
     
    diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc
    index f60528835..836a715b0 100644
    --- a/program/steps/mail/search.inc
    +++ b/program/steps/mail/search.inc
    @@ -86,7 +86,7 @@ else if (strlen(trim($str))) {
             }
     
             // save search modifiers for the current folder to user prefs
    -        $mkey               = $scope == 'all' ? '*' : $mbox;
    +        $mkey               = ($scope == 'all' || $scope == 'allsubscribed') ? '*' : $mbox;
             $search_mods        = rcmail_search_mods();
             $search_mods[$mkey] = array_fill_keys(array_keys($subject), 1);
     
    @@ -124,6 +124,10 @@ if (!empty($continue) && isset($_SESSION['search']) && $_SESSION['search_request
     if ($search_str) {
         // search all, current or subfolders folders
         if ($scope == 'all') {
    +        $mboxes = $RCMAIL->storage->list_folders('', '*', 'mail', null, true);
    +        natcasesort($mboxes);  // we want natural alphabetic sorting of folders in the result set
    +    }
    +    else if ($scope == 'allsubscribed') {
             $mboxes = $RCMAIL->storage->list_folders_subscribed('', '*', 'mail', null, true);
             natcasesort($mboxes);  // we want natural alphabetic sorting of folders in the result set
         }
    @@ -133,7 +137,7 @@ if ($search_str) {
             array_unshift($mboxes, $mbox);
         }
     
    -    if ($scope != 'all') {
    +    if ($scope != 'all' && $scope != 'allsubscribed') {
             // Remember current folder, it can change in meantime (plugins)
             // but we need it to e.g. recognize Sent folder to handle From/To column later
             $RCMAIL->output->set_env('mailbox', $mbox);
    @@ -194,7 +198,7 @@ else {
         $count = 0;
         $OUTPUT->show_message('searchnomatch', 'notice');
         $OUTPUT->set_env('multifolder_listing', (bool)$result->multi);
    -    if ($result->multi && $scope == 'all') {
    +    if ($result->multi && ($scope == 'all' || $scope == 'allsubscribed')) {
             $OUTPUT->command('select_folder', '');
         }
     }
    diff --git a/skins/classic/templates/mail.html b/skins/classic/templates/mail.html
    index 666adf606..23d12a275 100644
    --- a/skins/classic/templates/mail.html
    +++ b/skins/classic/templates/mail.html
    @@ -106,6 +106,7 @@
         <li><label class="comment"><roundcube:label name="searchscope" /></label></li>
         <li><label><input type="radio" name="s_scope" value="base" id="s_scope_base" onclick="rcmail.set_searchscope(this.value)" /> <span><roundcube:label name="currentfolder" /></span></label></li>
         <li><label><input type="radio" name="s_scope" value="sub" id="s_scope_sub" onclick="rcmail.set_searchscope(this.value)" /> <span><roundcube:label name="subfolders" /></span></label></li>
    +    <li><label><input type="radio" name="s_scope" value="allsubscribed" id="s_scope_allsubscribed" onclick="rcmail.set_searchscope(this.value)" /> <span><roundcube:label name="allsubscribedfolders" /></span></label></li>
         <li><label><input type="radio" name="s_scope" value="all" id="s_scope_all" onclick="rcmail.set_searchscope(this.value)" /> <span><roundcube:label name="allfolders" /></span></label></li>
       </ul>
     </div>
    diff --git a/skins/elastic/templates/mail.html b/skins/elastic/templates/mail.html
    index 51dbfcd30..4c2281281 100644
    --- a/skins/elastic/templates/mail.html
    +++ b/skins/elastic/templates/mail.html
    @@ -77,6 +77,7 @@
     				<select name="s_scope" id="s_scope">
     					<option value="base"><roundcube:label name="currentfolder" /></option>
     					<option value="sub"><roundcube:label name="subfolders" /></option>
    +					<option value="allsubscribed"><roundcube:label name="allsubscribedfolders" /></option>
     					<option value="all"><roundcube:label name="allfolders" /></option>
     				</select>
     			</div>
    diff --git a/skins/larry/templates/mail.html b/skins/larry/templates/mail.html
    index 5ef0bc211..e0e8280ad 100644
    --- a/skins/larry/templates/mail.html
    +++ b/skins/larry/templates/mail.html
    @@ -56,6 +56,7 @@
     		<li role="separator" class="separator"><label><roundcube:label name="searchscope" /></label></li>
     		<li role="menuitem"><label><input type="radio" name="s_scope" value="base" id="s_scope_base" onclick="UI.set_searchscope(this)" /> <span><roundcube:label name="currentfolder" /></span></label></li>
     		<li role="menuitem"><label><input type="radio" name="s_scope" value="sub" id="s_scope_sub" onclick="UI.set_searchscope(this)" /> <span><roundcube:label name="subfolders" /></span></label></li>
    +		<li role="menuitem"><label><input type="radio" name="s_scope" value="allsubscribed" id="s_scope_allsubscribed" onclick="UI.set_searchscope(this)" /> <span><roundcube:label name="allsubscribedfolders" /></span></label></li>
     		<li role="menuitem"><label><input type="radio" name="s_scope" value="all" id="s_scope_all" onclick="UI.set_searchscope(this)" /> <span><roundcube:label name="allfolders" /></span></label></li>
     	</ul>
     	<div class="buttons"><a class="button" href="#" onclick="if (rcmail.command('search')) UI.show_popup('searchmenu',false)"><roundcube:label name="search" /></a></div>
  • roundcube-1.6.8_search_all.patch
    diff --git a/program/actions/mail/index.php b/program/actions/mail/index.php
    --- a/program/actions/mail/index.php	1970-01-01 01:00:01.000000000 +0100
    +++ b/program/actions/mail/index.php	2024-08-10 01:49:10.362367233 +0200
    @@ -146,7 +146,7 @@
                         'copy', 'move', 'quota', 'replyall', 'replylist', 'stillsearching',
                         'flagged', 'unflagged', 'unread', 'deleted', 'replied', 'forwarded',
                         'priority', 'withattachment', 'fileuploaderror', 'mark', 'markallread',
    -                    'folders-cur', 'folders-sub', 'folders-all', 'cancel', 'bounce', 'bouncemsg',
    +                    'folders-cur', 'folders-sub', 'folders-allsubscribed', 'folders-all', 'cancel', 'bounce', 'bouncemsg',
                         'sendingmessage');
                 }
             }
    diff --git a/program/actions/mail/search.php b/program/actions/mail/search.php
    --- a/program/actions/mail/search.php	1970-01-01 01:00:01.000000000 +0100
    +++ b/program/actions/mail/search.php	2024-08-10 01:53:20.152011854 +0200
    @@ -83,6 +83,10 @@
     
                 // search all, current or subfolders folders
                 if ($scope == 'all') {
    +                $mboxes = $RCMAIL->storage->list_folders('', '*', 'mail', null, true);
    +                natcasesort($mboxes);  // we want natural alphabetic sorting of folders in the result set
    +            }
    +            else if ($scope == 'allsubscribed') {
                     $mboxes = $rcmail->storage->list_folders_subscribed('', '*', 'mail', null, true);
                     // we want natural alphabetic sorting of folders in the result set
                     natcasesort($mboxes);
    @@ -93,7 +97,7 @@
                     array_unshift($mboxes, $mbox);
                 }
     
    -            if ($scope != 'all') {
    +            if ($scope != 'all' && $scope != 'allsubscribed') {
                     // Remember current folder, it can change in meantime (plugins)
                     // but we need it to e.g. recognize Sent folder to handle From/To column later
                     $rcmail->output->set_env('mailbox', $mbox);
    @@ -158,7 +162,7 @@
                 $rcmail->output->show_message('searchnomatch', 'notice');
                 $rcmail->output->set_env('multifolder_listing', isset($result) ? !empty($result->multi) : false);
     
    -            if (isset($result) && !empty($result->multi) && $scope == 'all') {
    +            if (isset($result) && !empty($result->multi) && ($scope == 'all' || $scope == 'allsubscribed')) {
                     $rcmail->output->command('select_folder', '');
                 }
             }
    @@ -266,7 +270,7 @@
                     }
     
                     // save search modifiers for the current folder to user prefs
    -                if ($scope != 'all') {
    +                if ($scope != 'all' && $scope != 'allsubscribed') {
                         $search_mods       = self::search_mods();
                         $search_mods_value = array_fill_keys(array_keys($subject), 1);
     
    diff --git a/program/js/app.js b/program/js/app.js
    --- a/program/js/app.js	1970-01-01 01:00:01.000000000 +0100
    +++ b/program/js/app.js	2024-08-10 01:44:57.834696269 +0200
    @@ -2311,6 +2311,9 @@
         }
     
         tree += '<span id="msgicn'+row.id+'" class="'+css_class+status_class+'" title="'+status_label+'"></span>';
    +    if (flags.mbox != this.env.mailbox) {
    +      tree += '<span style="color:#737677">' + flags.mbox + '&nbsp;<span>';
    +    }
         row.className = row_class;
     
         // build subject link
    diff --git a/program/localization/en_CA/labels.inc b/program/localization/en_CA/labels.inc
    --- a/program/localization/en_CA/labels.inc	1970-01-01 01:00:01.000000000 +0100
    +++ b/program/localization/en_CA/labels.inc	2024-08-10 01:46:39.151767483 +0200
    @@ -128,6 +128,7 @@
     $labels['markflagged'] = 'As flagged';
     $labels['markunflagged'] = 'As unflagged';
     $labels['moreactions'] = 'More actions...';
    +$labels['folders-allsubscribed'] = 'All subscribed folders';
     $labels['folders-all'] = 'All folders';
     $labels['more'] = 'More';
     $labels['back'] = 'Back';
    @@ -184,6 +185,7 @@
     $labels['searchscope'] = 'Scope';
     $labels['currentfolder'] = 'Current folder';
     $labels['subfolders'] = 'This and subfolders';
    +$labels['allsubscribedfolders'] = 'All subscribed folders';
     $labels['allfolders'] = 'All folders';
     $labels['openinextwin'] = 'Open in new window';
     $labels['emlsave'] = 'Download (.eml)';
    diff --git a/program/localization/en_GB/labels.inc b/program/localization/en_GB/labels.inc
    --- a/program/localization/en_GB/labels.inc	1970-01-01 01:00:01.000000000 +0100
    +++ b/program/localization/en_GB/labels.inc	2024-08-10 01:47:14.141137558 +0200
    @@ -139,6 +139,7 @@
     $labels['markallread'] = 'Mark all as read';
     $labels['folders-cur'] = 'Selected folder only';
     $labels['folders-sub'] = 'Selected folder and its subfolders';
    +$labels['folders-allsubscribed'] = 'All subscribed folders';
     $labels['folders-all'] = 'All folders';
     $labels['more'] = 'More';
     $labels['back'] = 'Back';
    @@ -225,6 +226,7 @@
     $labels['searchscope'] = 'Scope';
     $labels['currentfolder'] = 'Current folder';
     $labels['subfolders'] = 'This and subfolders';
    +$labels['allsubscribedfolders'] = 'All subscribed folders';
     $labels['allfolders'] = 'All folders';
     $labels['searchinterval-1W'] = 'older than a week';
     $labels['searchinterval-1M'] = 'older than a month';
    diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
    --- a/program/localization/en_US/labels.inc	1970-01-01 01:00:01.000000000 +0100
    +++ b/program/localization/en_US/labels.inc	2024-08-10 01:47:40.749419031 +0200
    @@ -162,6 +162,7 @@
     $labels['markallread'] = 'Mark all as read';
     $labels['folders-cur'] = 'Selected folder only';
     $labels['folders-sub'] = 'Selected folder and its subfolders';
    +$labels['folders-allsubscribed'] = 'All subscribed folders';
     $labels['folders-all'] = 'All folders';
     $labels['more'] = 'More';
     $labels['back'] = 'Back';
    @@ -253,6 +254,7 @@
     $labels['searchscope'] = 'Scope';
     $labels['currentfolder'] = 'Current folder';
     $labels['subfolders'] = 'This and subfolders';
    +$labels['allsubscribedfolders'] = 'All subscribed folders';
     $labels['allfolders'] = 'All folders';
     $labels['searchinterval-1W'] = 'older than a week';
     $labels['searchinterval-1M'] = 'older than a month';
    diff --git a/program/localization/fr_FR/labels.inc b/program/localization/fr_FR/labels.inc
    --- a/program/localization/fr_FR/labels.inc	1970-01-01 01:00:01.000000000 +0100
    +++ b/program/localization/fr_FR/labels.inc	2024-08-10 01:48:22.494860699 +0200
    @@ -139,6 +139,7 @@
     $labels['markallread'] = 'Tout marquer comme lu';
     $labels['folders-cur'] = 'Dossier sélectionné seulement';
     $labels['folders-sub'] = 'Dossier sélectionné et ses sous-dossiers';
    +$labels['folders-allsubscribed'] = 'Tous les dossiers souscrits';
     $labels['folders-all'] = 'Tous les dossiers';
     $labels['more'] = 'Plus';
     $labels['back'] = 'Retour';
    @@ -225,6 +226,7 @@
     $labels['searchscope'] = 'Portée';
     $labels['currentfolder'] = 'Répertoire actuel';
     $labels['subfolders'] = 'Ceci et les sous-dossiers';
    +$labels['allsubscribedfolders'] = 'Tous les dossiers souscrits';
     $labels['allfolders'] = 'Tous les dossiers';
     $labels['searchinterval-1W'] = 'plus d’une semaine';
     $labels['searchinterval-1M'] = 'plus d’un mois';
    diff --git a/skins/elastic/templates/mail.html b/skins/elastic/templates/mail.html
    --- a/skins/elastic/templates/mail.html	1970-01-01 01:00:01.000000000 +0100
    +++ b/skins/elastic/templates/mail.html	2024-08-10 01:55:08.812162821 +0200
    @@ -91,6 +91,7 @@
     				<select name="s_scope" id="s_scope" class="custom-select">
     					<option value="base"><roundcube:label name="currentfolder" /></option>
     					<option value="sub"><roundcube:label name="subfolders" /></option>
    +					<option value="allsubscribed"><roundcube:label name="allsubscribedfolders" /></option>
     					<option value="all"><roundcube:label name="allfolders" /></option>
     				</select>
     			</div>