Skip to content

Commit 2795955

Browse files
committed
add All Snoozed button and Icon to left menu
1 parent b5b97f5 commit 2795955

File tree

12 files changed

+134
-5
lines changed

12 files changed

+134
-5
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ DEFAULT_SETTING_SENT_PER_SOURCE=20
9999
DEFAULT_SETTING_SENT_SINCE='-1 week'
100100
DEFAULT_SETTING_JUNK_PER_SOURCE=20
101101
DEFAULT_SETTING_JUNK_SINCE='-1 week'
102+
DEFAULT_SETTING_SNOOZED_PER_SOURCE=20
103+
DEFAULT_SETTING_SNOOZED_SINCE='-1 week'
102104
DEFAULT_SETTING_TAGS_PER_SOURCE=20
103105
DEFAULT_SETTING_TAGS_SINCE='-1 week'
104106
DEFAULT_SETTING_TRASH_PER_SOURCE=20

config/app.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,20 @@
10531053
*/
10541054
'default_setting_junk_per_source' => env('DEFAULT_SETTING_JUNK_PER_SOURCE', 20),
10551055

1056+
/*
1057+
|
1058+
| Per source time limit for snoozed page
1059+
| Defaults to 1 week
1060+
*/
1061+
'default_setting_snoozed_since' => env('DEFAULT_SETTING_SNOOZED_SINCE', '-1 week'),
1062+
1063+
/*
1064+
|
1065+
| Per source number limit for snoozed page
1066+
| Defaults 20
1067+
*/
1068+
'default_setting_snoozed_per_source' => env('DEFAULT_SETTING_SNOOZED_PER_SOURCE', 20),
1069+
10561070
/*
10571071
|
10581072
| Per source time limit for tags page

lib/environment.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public function define_default_constants($config) {
5656
define('DEFAULT_IMAP_PER_PAGE', $config->get('default_setting_imap_per_page', 20));
5757
define('DEFAULT_JUNK_SINCE', $config->get('default_setting_junk_since', '-1 week'));
5858
define('DEFAULT_JUNK_PER_SOURCE', $config->get('default_setting_junk_per_source', 20));
59+
define('DEFAULT_SNOOZED_SINCE', $config->get('default_setting_snoozed_since', '-1 week'));
60+
define('DEFAULT_SNOOZED_PER_SOURCE', $config->get('default_setting_snoozed_per_source', 20));
5961
define('DEFAULT_TAGS_SINCE', $config->get('default_setting_tags_since', '-1 week'));
6062
define('DEFAULT_TAGS_PER_SOURCE', $config->get('default_setting_tags_per_source', 20));
6163
define('DEFAULT_TRASH_SINCE', $config->get('default_setting_trash_since', '-1 week'));

modules/core/handler_modules.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,32 @@ public function process() {
397397
}
398398
}
399399

400+
/**
401+
* Process input from the max per source setting for the Snoozed page in the settings page
402+
* @subpackage core/handler
403+
*/
404+
class Hm_Handler_process_snoozed_source_max_setting extends Hm_Handler_Module {
405+
/**
406+
* Allowed values are greater than zero and less than MAX_PER_SOURCE
407+
*/
408+
public function process() {
409+
process_site_setting('snoozed_per_source', $this, 'max_source_setting_callback', DEFAULT_SNOOZED_PER_SOURCE);
410+
}
411+
}
412+
413+
/**
414+
* Process "since" setting for the Snoozed page in the settings page
415+
* @subpackage core/handler
416+
*/
417+
class Hm_Handler_process_snoozed_since_setting extends Hm_Handler_Module {
418+
/**
419+
* valid values are defined in the process_since_argument function
420+
*/
421+
public function process() {
422+
process_site_setting('snoozed_since', $this, 'since_setting_callback', DEFAULT_SNOOZED_SINCE);
423+
}
424+
}
425+
400426
/**
401427
* Process "since" setting for the Everything page in the settings page
402428
* @subpackage core/handler

modules/core/message_list_functions.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ function get_message_list_settings($path, $handler) {
5050
$per_source_limit = $handler->user_config->get('junk_per_source_setting', DEFAULT_JUNK_PER_SOURCE);
5151
$mailbox_list_title = array('Junk');
5252
}
53+
elseif ($path == 'snoozed') {
54+
$list_path = 'snoozed';
55+
$message_list_since = $handler->user_config->get('snoozed_since_setting', DEFAULT_SNOOZED_SINCE);
56+
$per_source_limit = $handler->user_config->get('snoozed_per_source_setting', DEFAULT_SNOOZED_PER_SOURCE);
57+
$mailbox_list_title = array('Snoozed');
58+
}
5359
elseif ($path == 'trash') {
5460
$list_path = 'trash';
5561
$message_list_since = $handler->user_config->get('trash_since_setting', DEFAULT_TRASH_SINCE);

modules/core/output_modules.php

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,11 @@ protected function output() {
13841384
$res .= '<i class="bi bi-pencil-square menu-icon"></i>';
13851385
}
13861386
$res .= '<span class="nav-label">'.$this->trans('Drafts').'</span></a></li>';
1387+
$res .= '<li class="menu_snoozed"><a class="unread_link" href="?page=message_list&amp;list_path=snoozed">';
1388+
if (!$this->get('hide_folder_icons')) {
1389+
$res .= '<i class="bi bi-clock-fill menu-icon"></i>';
1390+
}
1391+
$res .= '<span class="nav-label">'.$this->trans('Snoozed').'</span></a></li>';
13871392

13881393
if ($this->format == 'HTML5') {
13891394
return $res;
@@ -2146,7 +2151,62 @@ protected function output() {
21462151
'<td>'.message_since_dropdown($since, 'trash_since', $this, DEFAULT_TRASH_SINCE).'</td></tr>';
21472152
}
21482153
}
2149-
2154+
/**
2155+
* Starts the Snoozed section on the settings page
2156+
* @subpackage core/output
2157+
*/
2158+
class Hm_Output_start_snoozed_settings extends Hm_Output_Module {
2159+
/**
2160+
* Settings in this section control the snoozed messages view
2161+
*/
2162+
protected function output() {
2163+
return '<tr><td data-target=".snoozed_setting" colspan="2" class="settings_subtitle cursor-pointer border-bottom p-2">'.
2164+
'<i class="bi bi-clock-fill fs-5 me-2"></i>'.
2165+
$this->trans('Snoozed').'</td></tr>';
2166+
}
2167+
}
2168+
/**
2169+
* Option for the maximum number of messages per source for the Snoozed page
2170+
* @subpackage core/output
2171+
*/
2172+
class Hm_Output_snoozed_source_max_setting extends Hm_Output_Module {
2173+
/**
2174+
* Processed by Hm_Handler_process_snoozed_source_max_setting
2175+
*/
2176+
protected function output() {
2177+
$sources = DEFAULT_SNOOZED_PER_SOURCE;
2178+
$settings = $this->get('user_settings', array());
2179+
$reset = '';
2180+
if (array_key_exists('snoozed_per_source', $settings)) {
2181+
$sources = $settings['snoozed_per_source'];
2182+
}
2183+
if ($sources != DEFAULT_SNOOZED_PER_SOURCE) {
2184+
$reset = '<span class="tooltip_restore" restore_aria_label="Restore default value"><i class="bi bi-arrow-repeat refresh_list reset_default_value_input"></i></span>';
2185+
}
2186+
return '<tr class="snoozed_setting"><td><label for="snoozed_per_source">'.
2187+
$this->trans('Max messages per source for Snoozed').'</label></td>' .
2188+
'<td class="d-flex"><input class="form-control form-control-sm w-auto" type="text" size="2" id="snoozed_per_source" name="snoozed_per_source" value="'.$this->html_safe($sources).'" data-default-value="'.DEFAULT_SNOOZED_PER_SOURCE.'" />'.$reset.'</td></tr>';
2189+
}
2190+
}
2191+
/**
2192+
* Option for the snoozed messages date range
2193+
* @subpackage core/output
2194+
*/
2195+
class Hm_Output_snoozed_since_setting extends Hm_Output_Module {
2196+
/**
2197+
* Processed by Hm_Handler_process_snoozed_since_setting
2198+
*/
2199+
protected function output() {
2200+
$since = DEFAULT_SNOOZED_SINCE;
2201+
$settings = $this->get('user_settings', array());
2202+
if (array_key_exists('snoozed_since', $settings) && $settings['snoozed_since']) {
2203+
$since = $settings['snoozed_since'];
2204+
}
2205+
return '<tr class="snoozed_setting"><td><label for="snoozed_since">'.
2206+
$this->trans('Show snoozed messages since').'</label></td>'.
2207+
'<td>'.message_since_dropdown($since, 'snoozed_since', $this, DEFAULT_SNOOZED_SINCE).'</td></tr>';
2208+
}
2209+
}
21502210
/**
21512211
* Starts the Draft section on the settings page
21522212
* @subpackage core/output

modules/core/setup.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
add_handler('settings', 'process_all_email_source_max_setting', true, 'core', 'date', 'after');
5151
add_handler('settings', 'process_junk_since_setting', true, 'core', 'date', 'after');
5252
add_handler('settings', 'process_junk_source_max_setting', true, 'core', 'date', 'after');
53+
add_handler('settings', 'process_snoozed_since_setting', true, 'core', 'date', 'after');
54+
add_handler('settings', 'process_snoozed_source_max_setting', true, 'core', 'date', 'after');
5355
add_handler('settings', 'process_trash_since_setting', true, 'core', 'date', 'after');
5456
add_handler('settings', 'process_trash_source_max_setting', true, 'core', 'date', 'after');
5557
add_handler('settings', 'process_drafts_since_setting', true, 'core', 'date', 'after');
@@ -89,7 +91,10 @@
8991
add_output('settings', 'start_junk_settings', true, 'core', 'flagged_source_max_setting', 'after');
9092
add_output('settings', 'junk_since_setting', true, 'core', 'start_junk_settings', 'after');
9193
add_output('settings', 'junk_source_max_setting', true, 'core', 'junk_since_setting', 'after');
92-
add_output('settings', 'start_trash_settings', true, 'core', 'junk_source_max_setting', 'after');
94+
add_output('settings', 'start_snoozed_settings', true, 'core', 'junk_source_max_setting', 'after');
95+
add_output('settings', 'snoozed_since_setting', true, 'core', 'start_snoozed_settings', 'after');
96+
add_output('settings', 'snoozed_source_max_setting', true, 'core', 'snoozed_since_setting', 'after');
97+
add_output('settings', 'start_trash_settings', true, 'core', 'snoozed_source_max_setting', 'after');
9398
add_output('settings', 'trash_since_setting', true, 'core', 'start_trash_settings', 'after');
9499
add_output('settings', 'trash_source_max_setting', true, 'core', 'trash_since_setting', 'after');
95100
add_output('settings', 'start_drafts_settings', true, 'core', 'trash_source_max_setting', 'after');
@@ -315,6 +320,8 @@
315320
'stay_logged_in' => FILTER_VALIDATE_BOOLEAN,
316321
'junk_per_source' => FILTER_VALIDATE_INT,
317322
'junk_since' => FILTER_DEFAULT,
323+
'snoozed_per_source' => FILTER_VALIDATE_INT,
324+
'snoozed_since' => FILTER_DEFAULT,
318325
'trash_per_source' => FILTER_VALIDATE_INT,
319326
'trash_since' => FILTER_DEFAULT,
320327
'drafts_per_source' => FILTER_DEFAULT,

modules/core/site.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ button {
699699
.flagged_setting,
700700
.general_setting,
701701
.junk_setting,
702+
.snoozed_setting,
702703
.trash_setting,
703704
.drafts_setting,
704705
.privacy_setting {

modules/core/site.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ function Message_List() {
477477
'unread': 'formatted_unread_data',
478478
'flagged': 'formatted_flagged_data',
479479
'junk': 'formatted_junk_data',
480+
'snoozed': 'formatted_snoozed_data',
480481
'trash': 'formatted_trash_data',
481482
'sent': 'formatted_sent_data',
482483
'drafts': 'formatted_drafts_data',
@@ -617,6 +618,9 @@ function Message_List() {
617618
if (action_type == 'unflag' && getListPathParam() == 'flagged') {
618619
remove = true;
619620
}
621+
if (action_type == 'unsnooze' && getListPathParam() == 'snoozed') {
622+
remove = true;
623+
}
620624
else if (action_type == 'delete' || action_type == 'archive') {
621625
remove = true;
622626
}
@@ -1052,6 +1056,7 @@ function Message_List() {
10521056
this.set_unread_state = function() { self.set_message_list_state('formatted_unread_data'); };
10531057
this.set_search_state = function() { self.set_message_list_state('formatted_search_data'); };
10541058
this.set_junk_state = function() { self.set_message_list_state('formatted_junk_data'); };
1059+
this.set_snoozed_state = function() { self.set_message_list_state('formatted_snoozed_data'); };
10551060
this.set_trash_state = function() { self.set_message_list_state('formatted_trash_data'); };
10561061
this.set_draft_state = function() { self.set_message_list_state('formatted_drafts_data'); };
10571062
this.set_tag_state = function() { self.set_message_list_state('formatted_tag_data'); };
@@ -1447,7 +1452,7 @@ var Hm_Utils = {
14471452
var results = {}
14481453
var i;
14491454
var hash = window.location.hash;
1450-
var sections = ['.wp_notifications_setting', '.github_all_setting', '.tfa_setting', '.sent_setting', '.general_setting', '.unread_setting', '.flagged_setting', '.all_setting', '.email_setting', '.junk_setting', '.trash_setting', '.drafts_setting','.tag_setting'];
1455+
var sections = ['.wp_notifications_setting', '.github_all_setting', '.tfa_setting', '.sent_setting', '.general_setting', '.unread_setting', '.flagged_setting', '.all_setting', '.email_setting', '.junk_setting', '.snoozed_setting', '.trash_setting', '.drafts_setting','.tag_setting'];
14511456
for (i=0;i<sections.length;i++) {
14521457
dsp = Hm_Utils.get_from_local_storage(sections[i]);
14531458
if (hash) {

modules/imap/functions.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ function imap_sources($callback, $mod, $folder = 'sent') {
3434
elseif ($inbox) {
3535
$sources[] = array('callback' => $callback, 'folder' => bin2hex('INBOX'), 'type' => 'imap', 'name' => $vals['name'], 'id' => $index);
3636
}
37+
elseif ($folder=="snoozed"){
38+
$sources[] = array('callback' => $callback, 'folder' => bin2hex('Snoozed'), 'type' => 'imap', 'name' => $vals['name'], 'id' => $index);
39+
}
3740
else {
3841
$sources[] = array('callback' => $callback, 'folder' => bin2hex('SPECIAL_USE_CHECK'), 'nodisplay' => true, 'type' => 'imap', 'name' => $vals['name'], 'id' => $index);
3942
}

0 commit comments

Comments
 (0)