From 0c2ffb57a11f4a417ed2d48eea882d92c7ded3ca Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 29 Aug 2013 05:27:02 -0400
Subject: [PATCH] Allow setting INBOX as Sent folder (#1489219)

---
 CHANGELOG                       |    1 +
 program/steps/mail/func.inc     |    4 +++-
 program/steps/settings/func.inc |   13 +++++++------
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index d5e5f90..21f617e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Allow setting INBOX as Sent folder (#1489219)
 - Fix setting of Junk and NonJunk flags by markasjunk plugin (#1489285)
 - Fix lack of Reply-To address in header of forwarded message body (#1489298)
 - Fix bugs when invoking contact creation form when read-only addressbook is selected (#1489296)
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index e14d25e..d18f50f 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -177,7 +177,9 @@
   $sent_mbox   = $RCMAIL->config->get('sent_mbox');
   $drafts_mbox = $RCMAIL->config->get('drafts_mbox');
 
-  if (strpos($mbox.$delim, $sent_mbox.$delim) === 0 || strpos($mbox.$delim, $drafts_mbox.$delim) === 0) {
+  if ((strpos($mbox.$delim, $sent_mbox.$delim) === 0 || strpos($mbox.$delim, $drafts_mbox.$delim) === 0)
+    && strtoupper($mbox) != 'INBOX'
+  ) {
     return 'to';
   }
 
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index f6ea79e..fdc07be 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -987,10 +987,11 @@
                     'maxlength'     => 30,
                     'folder_filter' => 'mail',
                     'folder_rights' => 'w',
-                    // #1486114, #1488279
-                    'onchange'      => "if ($(this).val() == 'INBOX') $(this).val('')",
                 ));
             }
+
+            // #1486114, #1488279, #1489219
+            $onchange = "if ($(this).val() == 'INBOX') $(this).val('')";
 
             if (!isset($no_override['drafts_mbox'])) {
                 if (!$current) {
@@ -999,7 +1000,7 @@
 
                 $blocks['main']['options']['drafts_mbox'] = array(
                     'title'   => Q(rcube_label('drafts')),
-                    'content' => $select->show($config['drafts_mbox'], array('name' => "_drafts_mbox")),
+                    'content' => $select->show($config['drafts_mbox'], array('name' => "_drafts_mbox", 'onchange' => $onchange)),
                 );
             }
 
@@ -1010,7 +1011,7 @@
 
                 $blocks['main']['options']['sent_mbox'] = array(
                     'title'   => Q(rcube_label('sent')),
-                    'content' => $select->show($config['sent_mbox'], array('name' => "_sent_mbox")),
+                    'content' => $select->show($config['sent_mbox'], array('name' => "_sent_mbox", 'onchange' => '')),
                 );
             }
 
@@ -1021,7 +1022,7 @@
 
                 $blocks['main']['options']['junk_mbox'] = array(
                     'title'   => Q(rcube_label('junk')),
-                    'content' => $select->show($config['junk_mbox'], array('name' => "_junk_mbox")),
+                    'content' => $select->show($config['junk_mbox'], array('name' => "_junk_mbox", 'onchange' => $onchange)),
                 );
             }
 
@@ -1032,7 +1033,7 @@
 
                 $blocks['main']['options']['trash_mbox'] = array(
                     'title'   => Q(rcube_label('trash')),
-                    'content' => $select->show($config['trash_mbox'], array('name' => "_trash_mbox")),
+                    'content' => $select->show($config['trash_mbox'], array('name' => "_trash_mbox", 'onchange' => $onchange)),
                 );
             }
         break;

--
Gitblit v1.9.1