gianlucagiacometti / roundcube-toolbox

Set of tools for Roundcube webmail
15 stars 10 forks source link

roundcube-toolbox-1.4.10.1, malfunctional aliases + out of office #24

Closed stepan56 closed 1 year ago

stepan56 commented 2 years ago

On Debian 11, Roundcube 1.4.12 is malfunctional "aliases" + "out of office". Here is diff

diff -aur /usr/src/roundcube-toolbox-1.4.10.1/lib/Roundcube/rcube_toolbox_storage_sql_helper.php /usr/share/roundcube/plugins/toolbox/lib/Roundcube/rcube_toolbox_storage_sql_helper.php
--- /usr/src/roundcube-toolbox-1.4.10.1/lib/Roundcube/rcube_toolbox_storage_sql_helper.php      2021-01-22 14:08:58.000000000 +0100
+++ /usr/share/roundcube/plugins/toolbox/lib/Roundcube/rcube_toolbox_storage_sql_helper.php     2021-12-14 17:34:02.925234763 +0100
@@ -157,7 +157,8 @@
     // convert formatted string into timestamp/datetime
     public function to_timestamp($field, $format)
     {
-        $date = DateTime::createFromFormat($format['php'], $date);
+        //$date = DateTime::createFromFormat($format['php'], $date);
+        $date = DateTime::createFromFormat($format['php'], $field);
         $dsn = $this->db::parse_dsn($this->dsn);
         $format = $format[$dsn['phptype']];
         switch ($dsn['phptype']) {
diff -aur /usr/src/roundcube-toolbox-1.4.10.1/lib/Roundcube/rcube_toolbox_storage_sql.php /usr/share/roundcube/plugins/toolbox/lib/Roundcube/rcube_toolbox_storage_sql.php
--- /usr/src/roundcube-toolbox-1.4.10.1/lib/Roundcube/rcube_toolbox_storage_sql.php     2021-01-22 14:08:58.000000000 +0100
+++ /usr/share/roundcube/plugins/toolbox/lib/Roundcube/rcube_toolbox_storage_sql.php    2021-12-17 01:11:46.186899190 +0100
@@ -607,13 +607,15 @@
                     rcube::write_log($this->logfile, "SQL in [storage].[sql].[function save_tool_data]: execute query [INSERT INTO `{$this->postfix_sql_alias_table_name}` (`{$this->postfix_sql_address_field_in_alias}`, `{$this->postfix_sql_goto_field_in_alias}`, `{$this->postfix_sql_domain_field_in_alias}`, `{$this->postfix_sql_created_field_in_alias}`, `{$this->postfix_sql_modified_field_in_alias}`, `{$this->postfix_sql_active_field_in_alias}`) VALUES ('{$address}', '{$user}', '{$parts[1]}', '{$this->db->now()}', '{$this->db->now()}', '{$settings['main']['active']}');]");
                 }
                 $this->db->query(
-                    "INSERT INTO `{$this->postfix_sql_alias_table_name}` (`{$this->postfix_sql_address_field_in_alias}`, `{$this->postfix_sql_goto_field_in_alias}`, `{$this->postfix_sql_domain_field_in_alias}`, `{$this->postfix_sql_created_field_in_alias}`, `{$this->postfix_sql_modified_field_in_alias}`, `{$this->postfix_sql_active_field_in_alias}`) VALUES (?, ?, ?, ?, ?, ?);",
+                    //"INSERT INTO `{$this->postfix_sql_alias_table_name}` (`{$this->postfix_sql_address_field_in_alias}`, `{$this->postfix_sql_goto_field_in_alias}`, `{$this->postfix_sql_domain_field_in_alias}`, `{$this->postfix_sql_created_field_in_alias}`, `{$this->postfix_sql_modified_field_in_alias}`, `{$this->postfix_sql_active_field_in_alias}`) VALUES (?, ?, ?, ?, ?, ?);",
+                    "INSERT INTO `{$this->postfix_sql_alias_table_name}` (`{$this->postfix_sql_address_field_in_alias}`, `{$this->postfix_sql_goto_field_in_alias}`, `{$this->postfix_sql_domain_field_in_alias}`, `{$this->postfix_sql_created_field_in_alias}`, `{$this->postfix_sql_modified_field_in_alias}`, `{$this->postfix_sql_active_field_in_alias}`) VALUES (?, ?, ?, {$this->db->now()}, {$this->db->now()}, {$settings['main']['active']});",
                     $address,
                     $user,
                     $parts[1],
-                    $this->db->now(),
-                    $this->db->now(),
-                    $settings['main']['active']);
+                    //$this->db->now(),
+                    //$this->db->now(),
+                    //$settings['main']['active']
+                    );
                 if ($this->loglevel > 0) {
                     if ($err_str = $this->db->is_error()) {
                         rcube::write_log($this->logfile, "ERROR in [storage].[sql].[function save_tool_data]: cannot insert into alias: " . $err_str);
@@ -776,8 +778,9 @@
                 else {
                     $settings['main']['created'] = $this->db->now();
                     $queries[] = [
-                                'sql' => "INSERT INTO {$this->postfix_sql_vacation_table_name} (" . implode(', ', array_keys($settings['main'])) . ") VALUES (" . implode(',',array_values($settings['main'])) . ");",
-                                'data' => [],
+                                //'sql' => "INSERT INTO {$this->postfix_sql_vacation_table_name} (" . implode(', ', array_keys($settings['main'])) . ") VALUES (" . implode(',',array_values($settings['main'])) . ");",
+                                'sql' => "INSERT INTO {$this->postfix_sql_vacation_table_name} (`{$this->postfix_sql_email_field_in_vacation}`, `{$this->postfix_sql_domain_field_in_vacation}`, " . implode(', ', array_keys($settings['main'])) . ") VALUES (?,?," . implode(',',array_values($settings['main'])) . ");",
+                                'data' => [$user, $parts[1]],
                                 'type' => 'insert'
                     ];
                 }
@@ -790,6 +793,18 @@
                 ];

                 //remove autoreply address from alias list, but keep custom aliases
+                $concat = $this->db->concat($this->db->quote($parts[0]),$this->db->quote('#'),$this->db->quote($parts[1]),$this->db->quote('@'),$this->db->quote($this->postfixadmin_vacation_domain),$this->db->quote(','));
+                $queries[] = [
+                                'sql' => "UPDATE {$this->postfix_sql_alias_table_name} SET `{$this->postfix_sql_goto_field_in_alias}` = replace({$this->postfix_sql_goto_field_in_alias}, {$concat}, ''), `{$this->postfix_sql_modified_field_in_alias}` = {$this->db->now()} WHERE `{$this->postfix_sql_address_field_in_alias}` = ? AND `{$this->postfix_sql_domain_field_in_alias}` = ?;",
+                                'data' => [$user, $parts[1]],
+                                'type' => 'update'
+                ];
+                $concat = $this->db->concat($this->db->quote(','),$this->db->quote($parts[0]),$this->db->quote('#'),$this->db->quote($parts[1]),$this->db->quote('@'),$this->db->quote($this->postfixadmin_vacation_domain));
+                $queries[] = [
+                                'sql' => "UPDATE {$this->postfix_sql_alias_table_name} SET `{$this->postfix_sql_goto_field_in_alias}` = replace({$this->postfix_sql_goto_field_in_alias}, {$concat}, ''), `{$this->postfix_sql_modified_field_in_alias}` = {$this->db->now()} WHERE `{$this->postfix_sql_address_field_in_alias}` = ? AND `{$this->postfix_sql_domain_field_in_alias}` = ?;",
+                                'data' => [$user, $parts[1]],
+                                'type' => 'update'
+                ];
                 $concat = $this->db->concat($this->db->quote($parts[0]),$this->db->quote('#'),$this->db->quote($parts[1]),$this->db->quote('@'),$this->db->quote($this->postfixadmin_vacation_domain));
                 $queries[] = [
                                 'sql' => "UPDATE {$this->postfix_sql_alias_table_name} SET `{$this->postfix_sql_goto_field_in_alias}` = replace({$this->postfix_sql_goto_field_in_alias}, {$concat}, ''), `{$this->postfix_sql_modified_field_in_alias}` = {$this->db->now()} WHERE `{$this->postfix_sql_address_field_in_alias}` = ? AND `{$this->postfix_sql_domain_field_in_alias}` = ?;",
@@ -798,12 +813,13 @@
                 ];

                 //add autoreply address as alias
-                $concat = $this->db->concat($this->postfix_sql_goto_field_in_alias,$this->db->quote($parts[0]),$this->db->quote('#'),$this->db->quote($parts[1]),$this->db->quote('@'),$this->db->quote($this->postfixadmin_vacation_domain));
-                $queries[] = [
+                //$concat = $this->db->concat($this->postfix_sql_goto_field_in_alias,$this->db->quote($parts[0]),$this->db->quote('#'),$this->db->quote($parts[1]),$this->db->quote('@'),$this->db->quote($this->postfixadmin_vacation_domain));
+                $concat = $this->db->concat($this->postfix_sql_goto_field_in_alias,$this->db->quote(','),$this->db->quote($parts[0]),$this->db->quote('#'),$this->db->quote($parts[1]),$this->db->quote('@'),$this->db->quote($this->postfixadmin_vacation_domain));
+                if ( $settings['main']['active'] == 'true' ) { $queries[] = [
                                 'sql' => "UPDATE {$this->postfix_sql_alias_table_name} SET `{$this->postfix_sql_goto_field_in_alias}` = {$concat}, `{$this->postfix_sql_modified_field_in_alias}` = {$this->db->now()} WHERE `{$this->postfix_sql_address_field_in_alias}` = ? AND `{$this->postfix_sql_domain_field_in_alias}` = ? AND `{$this->postfix_sql_active_field_in_alias}` = true;",
                                 'data' => [$user, $parts[1]],
                                 'type' => 'update'
-                ];
+                ]; }

                 foreach ($queries as $query) {

@@ -860,11 +876,12 @@
                             rcube::write_log($this->logfile, "SQL in [storage].[sql].[function save_tool_data]: execute query [INSERT INTO `toolbox_customise_domains` (`domain_name`, `purge_trash`, `purge_junk`, `modified`, `modified_by`) VALUES ('{$parts[1]}', '{$settings['domain']['purge_trash']}', '{$settings['domain']['purge_junk']}', '{$this->db->now()}', '{$user}');]");
                         }
                         $this->db->query(
-                            "INSERT INTO `toolbox_customise_domains` (`domain_name`, `purge_trash`, `purge_junk`, `modified`, `modified_by`) VALUES (?, ?, ?, ?, ?);",
+                            //"INSERT INTO `toolbox_customise_domains` (`domain_name`, `purge_trash`, `purge_junk`, `modified`, `modified_by`) VALUES (?, ?, ?, ?, ?);",
+                            "INSERT INTO `toolbox_customise_domains` (`domain_name`, `purge_trash`, `purge_junk`, `modified`, `modified_by`) VALUES (?, ?, ?, {$this->db->now()}, ?);",
                             $parts[1],
                             $settings['domain']['purge_trash'],
                             $settings['domain']['purge_junk'],
-                            $this->db->now(),
+                            //$this->db->now(),
                             $user);
                         if ($this->loglevel > 0) {
                             if ($err_str = $this->db->is_error()) {
@@ -957,7 +974,8 @@
                                 rcube::write_log($this->logfile, "SQL in [storage].[sql].[function save_tool_data]: execute query [INSERT INTO `toolbox_customise_skins` (`toolbox_customise_domain_id`, `skin`, `blankpage_type`, `blankpage_image`, `blankpage_url`, `blankpage_custom`, `additional_css`, `modified`, `modified_by`) VALUES ('{$domain_id}', '{$skin}', '{$values['blankpage_type']}', '{$values['blankpage_image']}', '{$values['blankpage_url']}', '{$values['blankpage_custom']}', '{$values['additional_css']}', '{$this->db->now()}', '{$user}');]");
                             }
                             $this->db->query(
-                                "INSERT INTO `toolbox_customise_skins` (`toolbox_customise_domain_id`, `skin`, `customise_blankpage`, `blankpage_type`, `blankpage_image`, `blankpage_url`, `blankpage_custom`, `customise_css`, `additional_css`, `customise_logo`, `customised_logo`, `modified`, `modified_by`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
+                                //"INSERT INTO `toolbox_customise_skins` (`toolbox_customise_domain_id`, `skin`, `customise_blankpage`, `blankpage_type`, `blankpage_image`, `blankpage_url`, `blankpage_custom`, `customise_css`, `additional_css`, `customise_logo`, `customised_logo`, `modified`, `modified_by`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
+                                "INSERT INTO `toolbox_customise_skins` (`toolbox_customise_domain_id`, `skin`, `customise_blankpage`, `blankpage_type`, `blankpage_image`, `blankpage_url`, `blankpage_custom`, `customise_css`, `additional_css`, `customise_logo`, `customised_logo`, `modified`, `modified_by`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, {$this->db->now()}, ?);",
                                 $domain_id,
                                 $skin,
                                 $values['customise_blankpage'],
@@ -969,7 +987,7 @@
                                 $values['additional_css'],
                                 $values['customise_logo'],
                                 $values['customised_logo'],
-                                $this->db->now(),
+                                //$this->db->now(),
                                 $user);
                             if ($this->loglevel > 0) {
                                 if ($err_str = $this->db->is_error()) {
Pouze v /usr/share/roundcube/plugins/toolbox/localization: cs_CZ.inc
diff -aur /usr/src/roundcube-toolbox-1.4.10.1/toolbox.php /usr/share/roundcube/plugins/toolbox/toolbox.php
--- /usr/src/roundcube-toolbox-1.4.10.1/toolbox.php     2021-01-22 14:08:58.000000000 +0100
+++ /usr/share/roundcube/plugins/toolbox/toolbox.php    2021-12-16 12:11:09.818875392 +0100
@@ -1193,8 +1193,8 @@
                     rcube::write_log($this->logfile, "STEP in [function save]: prepare vacation settings");
                 }
                 $new_settings['main']['active'] = rcube_utils::get_input_value('_vacationactive', rcube_utils::INPUT_POST) ?: false;
-                $new_settings['main']['activefrom'] = rcube_utils::get_input_value('_vacationactivefrom', rcube_utils::INPUT_POST) ?: date("Y-m-d H:i:s");
-                $new_settings['main']['activeuntil'] = rcube_utils::get_input_value('_vacationactiveuntil', rcube_utils::INPUT_POST) ?: date('"Y-m-d H:i:s"', strtotime("+1 week"));
+                $new_settings['main']['activefrom'] = rcube_utils::get_input_value('_vacationactivefrom', rcube_utils::INPUT_POST) ?: date($this->rcube->config->get('toolbox_vacation_dateformat')['php']);
+                $new_settings['main']['activeuntil'] = rcube_utils::get_input_value('_vacationactiveuntil', rcube_utils::INPUT_POST) ?: date($this->rcube->config->get('toolbox_vacation_dateformat')['php'], strtotime("+1 week"));
                 $new_settings['main']['interval_time'] = rcube_utils::get_input_value('_vacationintervaltime', rcube_utils::INPUT_POST) ?: $this->rcube->config->get('toolbox_vacation_interval_time')['replyonce'];
                 $new_settings['main']['subject'] = rcube_utils::get_input_value('_vacationsubject', rcube_utils::INPUT_POST) ?: $this->rcube->config->get('toolbox_vacation_subject');
                 $new_settings['main']['body'] = rcube_utils::get_input_value('_vacationbody', rcube_utils::INPUT_POST) ?: $this->rcube->config->get('toolbox_vacation_body');

Best Regards, Stepan Brajko

gianlucagiacometti commented 2 years ago

Are you using the Debian distro version of postfixadmin?

stepan56 commented 2 years ago

I use the postfixadmin version 3.3.8 from github.com.

Best regards Štěpán Brajko

From: Gianluca Giacometti @.> Sent: Tuesday, December 21, 2021 12:54 PM To: gianlucagiacometti/roundcube-toolbox @.> Cc: stepan56 @.>; Author @.> Subject: Re: [gianlucagiacometti/roundcube-toolbox] roundcube-toolbox-1.4.10.1, malfunctional aliases + out of office (Issue #24)

Are you using the Debian distro version of postfixadmin? — Reply to this email directly, https://github.com/gianlucagiacometti/roundcube-toolbox/issues/24#issuecomment-998717518, or https://github.com/notifications/unsubscribe-auth/AW5PIDKXBGXGQOB445XWRPDUSBTHLANCNFSM5KBPRONQ. Triage notifications on the go with GitHub Mobile for https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you authored the thread.Message ID: @.***>