Fix selfUrl generation in Mime_Viewers
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 25 Feb 2009 04:37:57 +0000 (21:37 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 25 Feb 2009 04:37:57 +0000 (21:37 -0700)
imp/lib/IMP.php
imp/lib/Mime/Viewer/html.php
imp/lib/Mime/Viewer/images.php
imp/lib/Mime/Viewer/itip.php
imp/lib/Mime/Viewer/pgp.php
imp/lib/Mime/Viewer/smime.php
imp/message.php

index c4426c6..3a2197b 100644 (file)
@@ -53,6 +53,9 @@ class IMP
     /* Are we currently in "print" mode? */
     static public $printMode = false;
 
+    /* Storage place for an altered version of the current URL. */
+    static public $newUrl = null;
+
     /* displayFolder() cache. */
     static private $_displaycache = array();
 
@@ -1986,7 +1989,7 @@ class IMP
         return $cache;
     }
 
-   /**
+    /**
      * Generate the JS code necessary to open a passphrase dialog. Adds the
      * necessary JS files to open the dialog.
      *
@@ -2030,4 +2033,17 @@ class IMP
 
         return 'IMPDialog.display(\'' . IMP::escapeJSON($js_params) . '\')';
     }
+
+    /**
+     * Return a selfURL that has had index/mailbox/actionID information
+     * removed/altered based on an action that has occurred on the present
+     * page.
+     *
+     * @return string  The self URL.
+     */
+    static public function selfUrl()
+    {
+        return self::$newUrl ? self::$newUrl : Horde::selfUrl(true);
+    }
+
 }
index a3c8522..ebb72b1 100644 (file)
@@ -208,7 +208,7 @@ class IMP_Horde_Mime_Viewer_html extends Horde_Mime_Viewer_html
             preg_match($this->_img_regex, $data)) {
             /* Make sure the URL parameters are correct for the current
              * message. */
-            $url = Util::removeParameter(Horde::selfUrl(true), array('actionID', 'index'));
+            $url = Util::removeParameter(IMP::selfUrl(), array('actionID', 'index'));
             $url = Util::addParameter($url, 'index', $this->_params['contents']->getIndex());
 
             $view_img = Util::getFormData('view_html_images');
index 46c79e0..8c6816a 100644 (file)
@@ -163,7 +163,7 @@ class IMP_Horde_Mime_Viewer_images extends Horde_Mime_Viewer_images
      */
     protected function _popupImageWindow()
     {
-        $self_url = Util::addParameter(Horde::selfUrl(true), array('imp_img_view' => ((Util::getFormData('imp_img_view') == 'load_convert') ? 'view_convert' : 'data')));
+        $self_url = Util::addParameter(IMP::selfUrl(), array('imp_img_view' => ((Util::getFormData('imp_img_view') == 'load_convert') ? 'view_convert' : 'data')));
         $title = $this->_mimepart->getName(true);
 
         $str = <<<EOD
index 7256b84..93f57ff 100644 (file)
@@ -463,7 +463,7 @@ class IMP_Horde_Mime_Viewer_itip extends Horde_Mime_Viewer_Driver
         // Create the HTML to display the iCal file.
         $html = '';
         if ($_SESSION['imp']['view'] == 'imp') {
-            $html .= '<form method="post" name="iCal" action="' . Horde::selfUrl(true) . '">';
+            $html .= '<form method="post" name="iCal" action="' . (IMP::selfUrl()) . '">';
         }
 
         foreach ($components as $key => $component) {
index 0d0d48e..1eb7ee5 100644 (file)
@@ -349,7 +349,7 @@ class IMP_Horde_Mime_Viewer_pgp extends Horde_Mime_Viewer_Driver
         } else {
             switch ($_SESSION['imp']['view']) {
             case 'imp':
-                $status[] = Horde::link(Util::addParameter(Horde::selfUrl(true), array('pgp_verify_msg' => 1))) . _("Click HERE to verify the message.") . '</a>';
+                $status[] = Horde::link(Util::addParameter(IMP::selfUrl(), array('pgp_verify_msg' => 1))) . _("Click HERE to verify the message.") . '</a>';
                 break;
 
             case 'dimp':
index c47b969..7d27ee3 100644 (file)
@@ -245,7 +245,7 @@ class IMP_Horde_Mime_Viewer_smime extends Horde_Mime_Viewer_Driver
         } else {
             switch ($_SESSION['imp']['view']) {
             case 'imp':
-                $status[] = Horde::link(Util::addParameter(Horde::selfUrl(true), 'smime_verify_msg', 1)) . _("Click HERE to verify the message.") . '</a>';
+                $status[] = Horde::link(Util::addParameter(IMP::selfUrl(), 'smime_verify_msg', 1)) . _("Click HERE to verify the message.") . '</a>';
                 break;
 
             case 'dimp':
index 55fded4..b24beb1 100644 (file)
@@ -361,7 +361,7 @@ ksort($full_headers);
  * stuff in the query string, so we need to do an add/remove of 'index'. */
 $selfURL = Util::removeParameter(Horde::selfUrl(true), array('index', 'actionID', 'mailbox', 'thismailbox'));
 $selfURL = IMP::generateIMPUrl($selfURL, $imp_mbox['mailbox'], $index, $mailbox_name);
-$selfURL = html_entity_decode(Util::addParameter($selfURL, 'message_token', $message_token));
+IMP::$newUrl = $selfURL = html_entity_decode(Util::addParameter($selfURL, 'message_token', $message_token));
 $headersURL = htmlspecialchars(Util::removeParameter($selfURL, array('show_all_headers', 'show_list_headers')));
 
 /* Generate previous/next links. */