From d4783319a086b09eb50ac6ad5da93eb1eeb771ca Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Mon, 28 Jul 2014 03:39:43 -0400
Subject: [PATCH] Set 'compose_extwin' env property on every step; accept a list of URL parameters for the 'compose' command

---
 program/include/rcmail.php         |    3 +++
 program/steps/addressbook/func.inc |    1 -
 program/steps/mail/func.inc        |    2 +-
 program/steps/addressbook/show.inc |    1 -
 program/steps/mail/show.inc        |    2 +-
 program/js/app.js                  |    8 ++++++--
 6 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index ed5fedb..ceb369a 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -427,6 +427,9 @@
             $this->output->set_env('user_id', $this->user->get_hash());
         }
 
+        // set compose mode for all tasks (message compose step can be triggered from everywhere)
+        $this->output->set_env('compose_extwin', $this->config->get('compose_extwin',false));
+
         // add some basic labels to client
         $this->output->add_label('loading', 'servererror', 'connerror', 'requesttimedout',
             'refreshing', 'windowopenerror');
diff --git a/program/js/app.js b/program/js/app.js
index e00479f..b4e11b9 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -1052,7 +1052,7 @@
         if (this.task == 'mail') {
           url._mbox = this.env.mailbox;
           if (props)
-             url._to = props;
+            url._to = props;
           // also send search request so we can go back to search result after message is sent
           if (this.env.search_request)
             url._search = this.env.search_request;
@@ -1080,8 +1080,12 @@
             break;
           }
         }
-        else if (props)
+        else if (props && typeof props == 'string') {
           url._to = props;
+        }
+        else if (props && typeof props == 'object') {
+          $.extend(url, props);
+        }
 
         this.open_compose_step(url);
         break;
diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc
index f56e071..d4c57cc 100644
--- a/program/steps/addressbook/func.inc
+++ b/program/steps/addressbook/func.inc
@@ -81,7 +81,6 @@
     $OUTPUT->set_env('search_mods', $search_mods);
     $OUTPUT->set_env('address_sources', $js_list);
     $OUTPUT->set_env('writable_source', $writeable);
-    $OUTPUT->set_env('compose_extwin', $RCMAIL->config->get('compose_extwin',false));
 
     $OUTPUT->set_pagetitle($RCMAIL->gettext('addressbook'));
     $_SESSION['addressbooks_count'] = $count;
diff --git a/program/steps/addressbook/show.inc b/program/steps/addressbook/show.inc
index 4471ea6..8f357cd 100644
--- a/program/steps/addressbook/show.inc
+++ b/program/steps/addressbook/show.inc
@@ -32,7 +32,6 @@
 if ($cid && ($record = $CONTACTS->get_record($cid, true))) {
     $OUTPUT->set_env('readonly', $CONTACTS->readonly || $record['readonly']);
     $OUTPUT->set_env('cid', $record['ID']);
-    $OUTPUT->set_env('compose_extwin', $RCMAIL->config->get('compose_extwin',false));
 }
 
 // get address book name (for display)
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 77f1172..8774c08 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -110,7 +110,7 @@
 
     // set configuration
     $RCMAIL->set_env_config(array('delete_junk', 'flag_for_deletion', 'read_when_deleted',
-        'skip_deleted', 'display_next', 'message_extwin', 'compose_extwin', 'forward_attachment'));
+        'skip_deleted', 'display_next', 'message_extwin', 'forward_attachment'));
 
     if (!$OUTPUT->ajax_call) {
         $OUTPUT->add_label('checkingmail', 'deletemessage', 'movemessagetotrash',
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index e6ab489..4b2d78d 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -80,7 +80,7 @@
 
     // set configuration
     $RCMAIL->set_env_config(array('delete_junk', 'flag_for_deletion', 'read_when_deleted',
-        'skip_deleted', 'display_next', 'compose_extwin', 'forward_attachment'));
+        'skip_deleted', 'display_next', 'forward_attachment'));
 
     // set special folders
     foreach (array('drafts', 'trash', 'junk') as $mbox) {

--
Gitblit v1.9.1