From b7932388922062ea03a980b81f87da5f98baf76f Mon Sep 17 00:00:00 2001 From: ner0 <2269603+ner00@users.noreply.github.com> Date: Thu, 27 Feb 2025 12:33:25 +0000 Subject: [PATCH 1/3] PHP Notice: Only variables should be passed by reference in... The array_pop() function's parameter is passed 'by reference', meaning the function directly modifies the variable that is passed into the function (https://github.com/stremlau/html5_notifier/blob/5d85947e16ea9cac4544c59666fe0ff13ba2a44a/html5_notifier.php#L59). Due to this behaviour, you can't pass a function directly into array_pop(), you have to store the output of explode() into a variable first, then pass that variable into array_pop(). source: https://stackoverflow.com/a/45109918/924855 --- html5_notifier.php | 77 ++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 36 deletions(-) diff --git a/html5_notifier.php b/html5_notifier.php index 882eb7c..708219c 100644 --- a/html5_notifier.php +++ b/html5_notifier.php @@ -44,22 +44,27 @@ function show_notification($args) $RCMAIL = rcmail::get_instance(); //$search = $RCMAIL->config->get('html5_notifier_only_new', false) ?'NEW' : 'RECENT'; - $deleted = $RCMAIL->config->get('skip_deleted') ? 'UNDELETED ' : ''; - $search = $deleted . 'UNSEEN UID ' . $args['diff']['new']; - - $RCMAIL->storage->set_folder($args['mailbox']); - $RCMAIL->storage->search($args['mailbox'], $search, null); - $msgs = (array) $RCMAIL->storage->list_messages($args['mailbox']); - $excluded_directories = preg_split("/(,|;| )+/", $RCMAIL->config->get('html5_notifier_excluded_directories')); - - foreach ($msgs as $msg) { - $from = $msg->get('from'); - $mbox = ''; - switch ($RCMAIL->config->get('html5_notifier_smbox')) { - case 1: $mbox = array_pop(explode('.', str_replace('INBOX.', '', $args['mailbox']))); break; - case 2: $mbox = str_replace('.', '/', str_replace('INBOX.', '', $args['mailbox'])); break; - } - $subject = ((!empty($mbox)) ? rcube_charset::convert($mbox, 'UTF7-IMAP') . ': ' : '') . $msg->get('subject'); + $deleted = $RCMAIL->config->get('skip_deleted') ? 'UNDELETED ' : ''; + $search = $deleted . 'UNSEEN UID ' . $args['diff']['new']; + + $RCMAIL->storage->set_folder($args['mailbox']); + $RCMAIL->storage->search($args['mailbox'], $search, null); + $msgs = (array) $RCMAIL->storage->list_messages($args['mailbox']); + $excluded_directories = preg_split("/(,|;| )+/", $RCMAIL->config->get('html5_notifier_excluded_directories')); + + foreach ($msgs as $msg) { + $from = $msg->get('from'); + $mbox = ''; + switch ($RCMAIL->config->get('html5_notifier_smbox')) { + case 1: + $mbox = explode('.', str_replace('INBOX.', '', $args['mailbox'])); + $mbox = array_pop($mbox); + break; + case 2: + $mbox = str_replace('.', '/', str_replace('INBOX.', '', $args['mailbox'])); + break; + } + $subject = ((!empty($mbox)) ? rcube_charset::convert($mbox, 'UTF7-IMAP') . ': ' : '') . $msg->get('subject'); if(strtolower($_SESSION['username']) == strtolower($RCMAIL->user->data['username']) && !in_array($args['mailbox'], $excluded_directories)) { @@ -72,7 +77,7 @@ function show_notification($args) )); } } - $RCMAIL->storage->search($args['mailbox'], "ALL", null); + $RCMAIL->storage->search($args['mailbox'], "ALL", null); } function prefs_list($args) @@ -82,21 +87,21 @@ function prefs_list($args) $RCMAIL = rcmail::get_instance(); $field_id = 'rcmfd_html5_notifier'; - + $select_duration = new html_select(array('name' => '_html5_notifier_duration', 'id' => $field_id)); $select_duration->add($this->gettext('off'), '0'); $times = array('3', '5', '8', '10', '12', '15', '20', '25', '30'); foreach ($times as $time) $select_duration->add($time.' '.$this->gettext('seconds'), $time); $select_duration->add($this->gettext('durable'), '-1'); - - $select_smbox = new html_select(array('name' => '_html5_notifier_smbox', 'id' => $field_id)); + + $select_smbox = new html_select(array('name' => '_html5_notifier_smbox', 'id' => $field_id)); $select_smbox->add($this->gettext('no_mailbox'), '0'); - $select_smbox->add($this->gettext('short_mailbox'), '1'); - $select_smbox->add($this->gettext('full_mailbox'), '2'); + $select_smbox->add($this->gettext('short_mailbox'), '1'); + $select_smbox->add($this->gettext('full_mailbox'), '2'); $content = $select_duration->show($RCMAIL->config->get('html5_notifier_duration').''); - $content .= $select_smbox->show($RCMAIL->config->get('html5_notifier_smbox').''); + $content .= $select_smbox->show($RCMAIL->config->get('html5_notifier_smbox').''); $content .= html::a(array('href' => '#', 'id' => 'rcmfd_html5_notifier_browser_conf', 'onclick' => 'rcmail_browser_notifications(); return false;'), $this->gettext('conf_browser')).' '; $content .= html::a(array('href' => '#', 'onclick' => 'rcmail_browser_notifications_test(); return false;'), $this->gettext('test_browser')); $args['blocks']['new_message']['options']['html5_notifier'] = array( @@ -111,19 +116,19 @@ function prefs_list($args) 'content' => $content, ); - $input_excluded = new html_inputfield(array('name' => '_html5_notifier_excluded_directories', 'id' => $field_id . '_excluded')); - $args['blocks']['new_message']['options']['html5_notifier_excluded_directories'] = array( + $input_excluded = new html_inputfield(array('name' => '_html5_notifier_excluded_directories', 'id' => $field_id . '_excluded')); + $args['blocks']['new_message']['options']['html5_notifier_excluded_directories'] = array( 'title' => html::label($field_id, rcube::Q($this->gettext('excluded_directories'))), 'content' => $input_excluded->show($RCMAIL->config->get('html5_notifier_excluded_directories').''), ); - $select_type = new html_select(array('name' => '_html5_notifier_popuptype', 'id' => $field_id . '_popuptype')); - $select_type->add($this->gettext('new_tab'), '0'); - $select_type->add($this->gettext('new_window'), '1'); - $args['blocks']['new_message']['options']['html5_notifier_popuptype'] = array( - 'title' => html::label($field_id, rcube::Q($this->gettext('notifier_popuptype'))), - 'content' => $select_type->show($RCMAIL->config->get('html5_notifier_popuptype').'') - ); + $select_type = new html_select(array('name' => '_html5_notifier_popuptype', 'id' => $field_id . '_popuptype')); + $select_type->add($this->gettext('new_tab'), '0'); + $select_type->add($this->gettext('new_window'), '1'); + $args['blocks']['new_message']['options']['html5_notifier_popuptype'] = array( + 'title' => html::label($field_id, rcube::Q($this->gettext('notifier_popuptype'))), + 'content' => $select_type->show($RCMAIL->config->get('html5_notifier_popuptype').'') + ); $RCMAIL->output->add_script("$(document).ready(function(){ rcmail_browser_notifications_colorate(); });"); } @@ -136,10 +141,10 @@ function prefs_save($args) { $args['prefs']['html5_notifier_only_new'] = !empty($_POST['_html5_notifier_only_new']); $args['prefs']['html5_notifier_duration'] = rcube_utils::get_input_value('_html5_notifier_duration', rcube_utils::INPUT_POST); - $args['prefs']['html5_notifier_smbox'] = rcube_utils::get_input_value('_html5_notifier_smbox', rcube_utils::INPUT_POST); - $args['prefs']['html5_notifier_excluded_directories'] = rcube_utils::get_input_value('_html5_notifier_excluded_directories', rcube_utils::INPUT_POST); - $args['prefs']['html5_notifier_popuptype'] = rcube_utils::get_input_value('_html5_notifier_popuptype', rcube_utils::INPUT_POST); - return $args; + $args['prefs']['html5_notifier_smbox'] = rcube_utils::get_input_value('_html5_notifier_smbox', rcube_utils::INPUT_POST); + $args['prefs']['html5_notifier_excluded_directories'] = rcube_utils::get_input_value('_html5_notifier_excluded_directories', rcube_utils::INPUT_POST); + $args['prefs']['html5_notifier_popuptype'] = rcube_utils::get_input_value('_html5_notifier_popuptype', rcube_utils::INPUT_POST); + return $args; } } } From 2b93c9255753742d3d09a64e2fa369642fc5f421 Mon Sep 17 00:00:00 2001 From: ner0 <2269603+ner00@users.noreply.github.com> Date: Thu, 27 Feb 2025 12:46:58 +0000 Subject: [PATCH 2/3] Add Portuguese (Portugal) language --- localization/pt_PT.inc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 localization/pt_PT.inc diff --git a/localization/pt_PT.inc b/localization/pt_PT.inc new file mode 100644 index 0000000..5cea6da --- /dev/null +++ b/localization/pt_PT.inc @@ -0,0 +1,26 @@ + From 62fc510347f2a4ef462c600ba8fdab32fdc4b85e Mon Sep 17 00:00:00 2001 From: ner0 <2269603+ner00@users.noreply.github.com> Date: Thu, 27 Feb 2025 12:52:35 +0000 Subject: [PATCH 3/3] Fix preg_split() deprecation message https://github.com/stremlau/html5_notifier/issues/54 --- html5_notifier.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/html5_notifier.php b/html5_notifier.php index 708219c..74986fa 100644 --- a/html5_notifier.php +++ b/html5_notifier.php @@ -50,7 +50,10 @@ function show_notification($args) $RCMAIL->storage->set_folder($args['mailbox']); $RCMAIL->storage->search($args['mailbox'], $search, null); $msgs = (array) $RCMAIL->storage->list_messages($args['mailbox']); - $excluded_directories = preg_split("/(,|;| )+/", $RCMAIL->config->get('html5_notifier_excluded_directories')); + $excluded_directories = array(); + if (!empty($RCMAIL->config->get('html5_notifier_excluded_directories'))) { + $excluded_directories = preg_split("/(,|;| )+/", $RCMAIL->config->get('html5_notifier_excluded_directories')); + } foreach ($msgs as $msg) { $from = $msg->get('from');