Bug #6832: Add confirm dialog when moving to notepad/tasklist
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 7 Jul 2010 05:15:18 +0000 (23:15 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 7 Jul 2010 05:21:55 +0000 (23:21 -0600)
imp/js/mailbox.js
imp/js/message.js
imp/mailbox.php
imp/message.php
imp/templates/imp/javascript_defs.php

index b01ca5f..0744645 100644 (file)
@@ -105,26 +105,35 @@ var ImpMailbox = {
 
     _transfer: function(actID)
     {
-        var newFolder, tmbox;
+        var newFolder, target, tmbox;
 
         if (this.anySelected()) {
+            target = $F('targetMailbox1');
             tmbox = $('targetMbox');
-            tmbox.setValue($F('targetMailbox1'));
+            tmbox.setValue(target);
 
             // Check for a mailbox actually being selected.
-            if ($F(tmbox) == "\0create") {
+            if (target == "\0create") {
                 newFolder = prompt(IMP.text.newfolder, '');
                 if (newFolder != null && newFolder != '') {
                     $('newMbox').setValue(1);
                     tmbox.setValue(newFolder);
                     this.submit(actID);
                 }
+            } else if (target.empty()) {
+                alert(IMP.text.target_mbox);
+            } else if (target.startsWith("\0notepad_") ||
+                       target.startsWith("\0tasklist_")) {
+                this.actIDconfirm = actID;
+                IMPDialog.display({
+                    cancel_text: IMP.text.no,
+                    form_id: 'RB_ImpMailboxConfirm',
+                    noinput: true,
+                    ok_text: IMP.text.yes,
+                    text: IMP.text.moveconfirm
+                });
             } else {
-                if ($F(tmbox) == '') {
-                    alert(IMP.text.target_mbox);
-                } else {
-                    this.submit(actID);
-                }
+                this.submit(actID);
             }
         } else {
             alert(IMP.text.mailbox_selectone);
@@ -379,7 +388,13 @@ document.observe('dom:loaded', function() {
 });
 
 document.observe('IMPDialog:onClick', function(e) {
-    if (e.element().identify() == 'RB_ImpMailbox') {
+    switch (e.element().identify()) {
+    case 'RB_ImpMailbox':
         window.location = this.lastclick;
+        break;
+
+    case 'RB_ImpMailboxConfirm':
+        this.submit(this.actIDconfirm);
+        break;
     }
 }.bindAsEventListener(ImpMailbox));
index 4714fea..2e84c49 100644 (file)
@@ -61,23 +61,34 @@ var ImpMessage = {
 
     _transfer: function(actID)
     {
-        var newFolder, tmbox = $('targetMbox');
-        tmbox.setValue($F('target1'));
+        var newFolder,
+            target = $F('target1'),
+            tmbox = $('targetMbox');
+
+        tmbox.setValue(target);
 
         // Check for a mailbox actually being selected.
-        if ($F(tmbox) == "\0create") {
+        if (target == "\0create") {
             newFolder = window.prompt(IMP.text.newfolder, '');
             if (newFolder != null && newFolder != '') {
                 $('newMbox').setValue(1);
                 tmbox.setValue(newFolder);
                 this.submit(actID);
             }
+        } else if (target.empty()) {
+            window.alert(IMP.text.target_mbox);
+        } else if (target.startsWith("\0notepad_") ||
+                   target.startsWith("\0tasklist_")) {
+            this.actIDconfirm = actID;
+            IMPDialog.display({
+                cancel_text: IMP.text.no,
+                form_id: 'RB_ImpMessageConfirm',
+                noinput: true,
+                ok_text: IMP.text.yes,
+                text: IMP.text.moveconfirm
+            });
         } else {
-            if (!$F(tmbox)) {
-                window.alert(IMP.text.target_mbox);
-            } else {
-                this.submit(actID);
-            }
+            this.submit(actID);
         }
     },
 
@@ -187,3 +198,11 @@ var ImpMessage = {
 };
 
 document.observe('dom:loaded', ImpMessage.onDomLoad.bind(ImpMessage));
+
+document.observe('IMPDialog:onClick', function(e) {
+    switch (e.element().identify()) {
+    case 'RB_ImpMessageConfirm':
+        this.submit(this.actIDconfirm);
+        break;
+    }
+}.bindAsEventListener(ImpMessage));
index c5e40fc..8dfafee 100644 (file)
@@ -309,7 +309,7 @@ $vtrash = $imp_search->isVTrashFolder()
     ? $imp_search->createSearchID($search_mbox)
     : null;
 
-horde::addInlineScript(array(
+Horde::addInlineScript(array(
     'ImpMailbox.unread = ' . intval($unread)
 ));
 
index d7aa9d4..d6f98cd 100644 (file)
@@ -664,6 +664,12 @@ Horde::addInlineScript($inlineout['js_onload'], 'dom');
 Horde::addScriptFile('effects.js', 'horde');
 Horde::addScriptFile('imp.js', 'imp');
 Horde::addScriptFile('message.js', 'imp');
+
+if ($conf['tasklist']['use_notepad'] || $conf['tasklist']['use_tasklist']) {
+    Horde::addScriptFile('dialog.js', 'imp');
+    Horde::addScriptFile('redbox.js', 'horde');
+}
+
 IMP::prepareMenu();
 Horde::noDnsPrefetch();
 
index c088c2d..6b26710 100644 (file)
@@ -62,6 +62,7 @@ $code = array(
         'login_password' => _("Please provide your password."),
 
         /* Strings used in multiple pages. */
+        'moveconfirm' => _("Are you sure you want to move the message(s)? (Some message information might get lost, like message headers, text formatting or attachments!)"),
         'spam_report' => _("Are you sure you wish to report this message as spam?"),
         'notspam_report' => _("Are you sure you wish to report this message as innocent?"),
         'newfolder' => _("You are copying/moving to a new folder.") . "\n" . _("Please enter a name for the new folder:") . "\n",