[TikiWiki-commits] [Git][tikiwiki/tiki][master] [ENH] Add email-to-tracker mode preference and update SieveFiltersCommand and...

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <68ded48d6b474_2c14668b4801ab@gitlab-sidekiq-low-urgency-cpu-bound-v2-58457f7db6-8plkn.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
33f1150a by Joseph Lwanzo Kausi at 2025-10-02T19:29:38+00:00
[ENH] Add email-to-tracker mode preference and update SieveFiltersCommand and...
---
* [ENH] Add email-to-tracker mode preference and update SieveFiltersCommand and functions for handling email actions

See merge request tikiwiki/tiki!8646

- - - - -


4 changed files:

- lib/core/Tiki/Command/SieveFiltersCommand.php
- lib/cypht/modules/tiki/functions.php
- lib/prefs/email.php
- templates/admin/include_general.tpl


Changes:

=====================================
lib/core/Tiki/Command/SieveFiltersCommand.php
=====================================
@@ -359,7 +359,11 @@ class SieveFiltersCommand extends Command
                 'data' => [$field]
             ]);
 
-            if ($action == 'move') {
+            // Check system preference for email-to-tracker mode
+            global $prefs;
+            $email_mode = $prefs['email_to_tracker_mode'] ?? 'move';
+
+            if ($action == 'move' && $email_mode == 'move') {
                 $output->writeln(tr("Moved msg uid %0 to tracker %1, field %2, item %3", $msg['uid'], $item['trackerId'], $field['fieldId'], $item['itemId']));
                 $this->action_discard($imap, $msg, $output);
             } else {


=====================================
lib/cypht/modules/tiki/functions.php
=====================================
@@ -436,8 +436,14 @@ if (! hm_exists('bind_tracker_item_update_event')) {
             $old = $args['old_values'][$form['tracker_field_id']];
             $new = $args['values'][$form['tracker_field_id']];
             if ($old != $new) {
-                foreach ($args['msg_ids'] as $msg_id) {
-                    $mailbox->delete_message($folder, $msg_id, false);
+                // Check system preference for email-to-tracker mode
+                global $prefs;
+                $email_mode = $prefs['email_to_tracker_mode'] ?? 'move';
+
+                if ($email_mode == 'move') {
+                    foreach ($args['msg_ids'] as $msg_id) {
+                        $mailbox->delete_message($folder, $msg_id, false);
+                    }
                 }
             }
         }, ['mailbox' => $mailbox, 'folder' => $folder, 'form' => $form, 'msg_ids' => $msg_ids]);


=====================================
lib/prefs/email.php
=====================================
@@ -31,5 +31,16 @@ function prefs_email_list()
             //'help' => '', TODO
             'default' => 'n',
         ],
+        'email_to_tracker_mode' => [
+            'name' => tra('When creating tracker items from email'),
+            'description' => tra('Choose whether emails are deleted (move mode) or kept on the original server (copy mode)'),
+            'type' => 'list',
+            'options' => [
+                'move' => tra('Delete from server (move)'),
+                'copy' => tra('Keep on server (copy)'),
+            ],
+            'default' => 'move',
+            'tags' => ['advanced', 'email'],
+        ],
     ];
 }


=====================================
templates/admin/include_general.tpl
=====================================
@@ -82,8 +82,9 @@
                         <input type="text" name="testMail" id="testMail" class="form-control">
                     </div>
                 </div>
-                {preference name=email_footer}
-                {preference name=mail_template_custom_text}
+                    {preference name=email_footer}
+                    {preference name=mail_template_custom_text}
+                    {preference name=email_to_tracker_mode}
             </fieldset>
             <fieldset>
                 <legend class="h3">{tr}Newsletter{/tr}</legend>



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/33f1150ae9dfb085c16edc097d9f5420402e5444

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/33f1150ae9dfb085c16edc097d9f5420402e5444
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.