IMP::composeLink() always returns a Horde_Url object.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 13 Jul 2010 01:51:29 +0000 (19:51 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 13 Jul 2010 01:57:12 +0000 (19:57 -0600)
imp/compose-dimp.php
imp/lib/Api.php
imp/lib/Block/tree_folders.php
imp/lib/IMP.php

index e23a8ac..f721d16 100644 (file)
@@ -41,7 +41,7 @@ $compose_disable = !IMP::canCompose();
 /* The headers of the message. */
 $header = array();
 foreach (array('to', 'cc', 'bcc', 'subject') as $v) {
-    $header[$v] = rawurldecode($vars->$v);
+    $header[$v] = $vars->$v;
 }
 
 $fillform_opts = array('noupdate' => 1);
index 78ce258..e69f22e 100644 (file)
@@ -35,7 +35,7 @@ class IMP_Api extends Horde_Registry_Api
      * @param array $extra        Hash of extra, non-standard arguments to
      *                            pass to compose.php.
      *
-     * @return string  The link to the message composition screen.
+     * @return Horde_Url  The link to the message composition screen.
      */
     public function compose($args = array(), $extra = array())
     {
@@ -54,7 +54,8 @@ class IMP_Api extends Horde_Registry_Api
      * @param array $extra        List of hashes of extra, non-standard
      *                            arguments to pass to compose.php.
      *
-     * @return string  The list of links to the message composition screen.
+     * @return array  The list of Horde_Url objects with links to the message
+     *                composition screen.
      */
     public function batchCompose($args = array(), $extra = array())
     {
index d601923..30ee00f 100644 (file)
@@ -35,7 +35,7 @@ class Horde_Block_imp_tree_folders extends Horde_Block
                        $indent, false,
                        array('icon' => 'compose.png',
                              'icondir' => $image_dir,
-                             'url' => IMP::composeLink(),
+                             'url' => strval(IMP::composeLink()),
                              'target' => $GLOBALS['prefs']->getValue('compose_popup') ? 'horde_menu' : 'horde_main'));
 
         /* Add link to the search page. */
index 879fe1c..c1b5fbf 100644 (file)
@@ -386,7 +386,7 @@ class IMP
      *                      compose.php.
      * @param string $view  The IMP view to create a link for.
      *
-     * @return string|Horde_Url  The link to the message composition screen.
+     * @return Horde_Url  The link to the message composition screen.
      */
     static public function composeLink($args = array(), $extra = array(),
                                        $view = null)
@@ -398,28 +398,48 @@ class IMP
         }
 
         if ($view == 'dimp') {
-            // IE 6 & 7 handles window.open() URL param strings differently if
-            // triggered via an href or an onclick.  Since we have no hint
-            // at this point where this link will be used, we have to always
-            // encode the params and explicitly call rawurlencode() in
-            // compose.php.
-            $encode_args = array('popup' => 1);
-            foreach ($args as $k => $v) {
-                $encode_args[$k] = rawurlencode($v);
-            }
-            return 'javascript:void(window.open(\'' . Horde::applicationUrl('compose-dimp.php')->setRaw(true)->add($encode_args) . '\', \'\', \'width=820,height=610,status=1,scrollbars=yes,resizable=yes\'));';
-        }
+            $args['popup'] = 1;
 
-        if (($view != 'mimp') &&
-            $GLOBALS['prefs']->getValue('compose_popup') &&
-            $GLOBALS['browser']->hasFeature('javascript')) {
+            $url = Horde::applicationUrl('compose-dimp.php')->setRaw(true)->add($args);
+            $url->toStringCallback = array(__CLASS__, 'composeLinkDimpCallback');
+        } elseif (($view != 'mimp') &&
+                  $GLOBALS['prefs']->getValue('compose_popup') &&
+                  $GLOBALS['browser']->hasFeature('javascript')) {
             if (isset($args['to'])) {
                 $args['to'] = addcslashes($args['to'], '\\"');
             }
-            return 'javascript:' . Horde::popupJs(Horde::applicationUrl('compose.php'), array('params' => $args, 'urlencode' => true));
+
+            $url = Horde::applicationUrl('compose.php')->add($args);
+            $url->toStringCallback = array(__CLASS__, 'composeLinkJsCallback');
+        } else {
+            $url = Horde::applicationUrl(($view == 'mimp') ? 'compose-mimp.php' : 'compose.php')->add($args);
         }
 
-        return Horde::applicationUrl(($view == 'mimp') ? 'compose-mimp.php' : 'compose.php')->add($args);
+        return $url;
+    }
+
+    /**
+     * Callback for Horde_Url when generating DIMP compose links.
+     *
+     * @param Horde_Url $url  URL object.
+     *
+     * @return string  URL string representation.
+     */
+    static public function composeLinkDimpCallback($url)
+    {
+        return "javascript:void(window.open('" . strval($url) . "', '', 'width=820,height=610,status=1,scrollbars=yes,resizable=yes'));";
+    }
+
+    /**
+     * Callback for Horde_Url when generating javascript compose links.
+     *
+     * @param Horde_Url $url  URL object.
+     *
+     * @return string  URL string representation.
+     */
+    static public function composeLinkJsCallback($url)
+    {
+        return 'javascript:' . Horde::popupJs(strval($url), array('urlencode' => true));
     }
 
     /**