From: Michael M Slusarz Date: Tue, 13 Jul 2010 01:51:29 +0000 (-0600) Subject: IMP::composeLink() always returns a Horde_Url object. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5d365dac5c0677af0dba884864092918c12c7245;p=horde.git IMP::composeLink() always returns a Horde_Url object. --- diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index e23a8ac9f..f721d16ad 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -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); diff --git a/imp/lib/Api.php b/imp/lib/Api.php index 78ce258bf..e69f22e7c 100644 --- a/imp/lib/Api.php +++ b/imp/lib/Api.php @@ -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()) { diff --git a/imp/lib/Block/tree_folders.php b/imp/lib/Block/tree_folders.php index d601923ca..30ee00ffb 100644 --- a/imp/lib/Block/tree_folders.php +++ b/imp/lib/Block/tree_folders.php @@ -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. */ diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 879fe1c52..c1b5fbf74 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -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)); } /**