Remove Horde_Util::closeWindowJS()
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 4 Mar 2010 19:18:27 +0000 (12:18 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 4 Mar 2010 19:21:35 +0000 (12:21 -0700)
16 files changed:
ansel/edit_dates.php
ansel/image.php
ansel/img/ecard.php
folks/perms.php
framework/Util/lib/Horde/Util.php
gollem/edit.php
horde/services/shares/edit.php
imp/compose.php
imp/lib/Crypt/Pgp.php
imp/lib/Crypt/Smime.php
imp/pgp.php
imp/saveimage.php
imp/smime.php
kronolith/attendees.php
kronolith/contacts.php
kronolith/perms.php

index bc84c09..c8f43b5 100644 (file)
@@ -21,7 +21,10 @@ if (!empty($gallery_id)) {
     $gallery = $ansel_storage->getGallery($gallery_id);
     if (!$gallery->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
         $notification->push(_("You are not allowed to edit these photos."), 'horde.error');
-        Horde_Util::closeWindowJS('window.opener.location.href = window.opener.location.href; window.close();');
+        echo Horde::wrapInlineScript(array(
+            'window.opener.location.href = window.opener.location.href;',
+            'window.close();'
+        ));
         exit;
     }
 }
@@ -29,7 +32,10 @@ if (!empty($gallery_id)) {
 /* Make sure we have at least one image */
 if (!count($images)) {
     echo $notification->push(_("You must select at least on photo to edit."), 'horde.error');
-    Horde_Util::closeWindowJS('window.opener.location.href = window.opener.location.href; window.close();');
+    echo Horde::wrapInlineScript(array(
+        'window.opener.location.href = window.opener.location.href;',
+        'window.close();'
+    ));
     exit;
 }
 
@@ -56,14 +62,20 @@ if ($actionID == 'edit_dates') {
             ++$count;
         } else {
            $notification->push(sprintf(_("There was an error editing the dates: %s"), $image->getMessage()), 'horde.error');
-           Horde_Util::closeWindowJS('window.opener.location.href = window.opener.location.href; window.close();');
+            echo Horde::wrapInlineScript(array(
+                'window.opener.location.href = window.opener.location.href;',
+                'window.close();'
+            ));
            exit;
         }
 
     }
 
     $notification->push(sprintf(_("Successfully modified the date on %d photos."), $count), 'horde.success');
-    Horde_Util::closeWindowJS('window.opener.location.href = window.opener.location.href; window.close();');
+    echo Horde::wrapInlineScript(array(
+        'window.opener.location.href = window.opener.location.href;',
+        'window.close();'
+    ));
     exit;
 }
 
index ba9fc8f..69dd740 100644 (file)
@@ -260,9 +260,15 @@ case 'save':
             /* Return to the image view. */
             header('Location: ' . $imageurl);
         } elseif ($actionID == 'saveclose') {
-            Horde_Util::closeWindowJS('window.opener.location.href = window.opener.location.href; window.close();');
+            echo Horde::wrapInlineScript(array(
+                'window.opener.location.href = window.opener.location.href;',
+                'window.close();'
+            ));
         } else {
-            Horde_Util::closeWindowJS('window.opener.location.href = \'' . $imageurl . '\'; window.close();');
+            echo Horde::wrapInlineScript(array(
+                'window.opener.location.href = "' . $imageurl . '";',
+                'window.close();'
+            ));
         }
         exit;
     }
@@ -478,9 +484,10 @@ case 'previewcustomwatermark':
                                          'actionID' => 'previewwatermark'),
                                    $date));
 
-    $url = Horde::applicationUrl($imageurl);
-    $url = str_replace('&amp;', '&', $url);
-    Horde_Util::closeWindowJS('window.opener.location.href = "' . $url . '";');
+    echo Horde::wrapInlineScript(array(
+        'window.opener.location.href = "' . Horde::applicationUrl($imageurl)->setRaw(true) . '";',
+        'window.close();'
+    ));
     exit;
 
 case 'previewgrayscale':
index 861e24f..14a62ef 100644 (file)
@@ -87,7 +87,7 @@ case 'send':
     if (is_a($result, 'PEAR_Error')) {
         $notification->push(sprintf(_("There was an error sending your message: %s"), $result->getMessage()), 'horde.error');
     } else {
-        Horde_Util::closeWindowJS();
+        echo Horde::wrapInlineScript(array('window.close();'));
         exit;
     }
 }
index 187f167..8a901b2 100644 (file)
@@ -207,7 +207,7 @@ case 'editform':
                 $notification->push($result, 'horde.error');
             } else {
                 if (Horde_Util::getFormData('save_and_finish')) {
-                    Horde_Util::closeWindowJS();
+                    echo Horde::wrapInlineScript(array('window.close();'));
                     exit;
                 }
                 $notification->push(sprintf(_("Updated \"%s\"."), $share->get('name')), 'horde.success');
index b8ab56d..0f88af7 100644 (file)
@@ -706,19 +706,6 @@ class Horde_Util
     }
 
     /**
-     * Outputs javascript code to close the current window.
-     *
-     * @param string $code  Any additional javascript code to run before
-     *                      closing the window.
-     */
-    static public function closeWindowJS($code = '')
-    {
-        echo "<script type=\"text/javascript\">//<![CDATA[\n" .
-            $code .
-            "window.close();\n//]]></script>\n";
-    }
-
-    /**
      * Caches the result of extension_loaded() calls.
      *
      * @param string $ext  The extension name.
index bd9121f..85846f1 100644 (file)
@@ -21,7 +21,7 @@ $filename = Horde_Util::getFormData('file');
 $type = Horde_Util::getFormData('type');
 
 if ($driver != $GLOBALS['gollem_be']['driver']) {
-    Horde_Util::closeWindowJS();
+    echo Horde::wrapInlineScript(array('window.close();'));
     exit;
 }
 
@@ -35,18 +35,24 @@ case 'save_file':
     } else {
         $message = sprintf(_("%s successfully saved."), $filename);
     }
-    Horde_Util::closeWindowJS('alert(\'' . addslashes($message) . '\');');
+    echo Horde::wrapInlineScript(array(
+        'alert("' . addslashes($message) . '");',
+        'window.close();'
+    ));
     exit;
 
 case 'edit_file':
     $data = $gollem_vfs->read($filedir, $filename);
     if (is_a($data, 'PEAR_Error')) {
-        Horde_Util::closeWindowJS('alert(\'' . addslashes(sprintf(_("Access denied to %s"), $filename)) . '\');');
+        echo Horde::wrapInlineScript(array(
+            'alert("' . addslashes(sprintf(_("Access denied to %s"), $filename)) . '");',
+            'window.close();'
+        ));
         exit;
     }
     $mime_type = Horde_Mime_Magic::extToMIME($type);
     if (strpos($mime_type, 'text/') !== 0) {
-        Horde_Util::closeWindowJS();
+        echo Horde::wrapInlineScript(array('window.close();'));
     }
     if ($mime_type == 'text/html') {
         $editor = Horde_Editor::singleton('ckeditor', array('id' => 'content'));
@@ -58,4 +64,4 @@ case 'edit_file':
     exit;
 }
 
-Horde_Util::closeWindowJS();
+wcho Horde::wrapInlineScript(array('window.close();'));
index 0fa50b9..ae7dbd6 100644 (file)
@@ -243,7 +243,7 @@ case 'editform':
                 $notification->push($result, 'horde.error');
             } else {
                 if (Horde_Util::getFormData('save_and_finish')) {
-                    Horde_Util::closeWindowJS();
+                    echo Horde::wrapInlineScript(array('window.close();'));
                     exit;
                 }
                 $notification->push(sprintf(_("Updated \"%s\"."), $share->get('name')), 'horde.success');
index cfa57c1..3270f72 100644 (file)
@@ -327,7 +327,7 @@ case 'redirect_send':
                 $notification->push(_("Message redirected successfully."), 'horde.success');
                 $imp_ui->popupSuccess();
             } else {
-                Horde_Util::closeWindowJS();
+                echo Horde::wrapInlineScript(array('window.close();'));
             }
         } else {
             if ($prefs->getValue('compose_confirm')) {
@@ -382,7 +382,7 @@ case 'send_message':
                     if ($isPopup) {
                         if ($prefs->getValue('close_draft')) {
                             $imp_compose->destroy();
-                            Horde_Util::closeWindowJS();
+                            echo Horde::wrapInlineScript(array('window.close();'));
                             exit;
                         } else {
                             $notification->push($result, 'horde.success');
@@ -462,7 +462,7 @@ case 'send_message':
             }
             $imp_ui->popupSuccess();
         } else {
-            Horde_Util::closeWindowJS();
+            echo Horde::wrapInlineScript(array('window.close();'));
         }
     } else {
         if ($prefs->getValue('compose_confirm') && $sent) {
@@ -485,7 +485,7 @@ case 'fwd_digest':
 case 'cancel_compose':
     $imp_compose->destroy(false);
     if ($isPopup) {
-        Horde_Util::closeWindowJS();
+        echo Horde::wrapInlineScript(array('window.close();'));
     } else {
         header('Location: ' . $imp_ui->mailboxReturnUrl(false));
     }
index c995eee..b8f940f 100644 (file)
@@ -679,7 +679,11 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp
         $cacheSess = Horde_SessionObjects::singleton();
         $href = $cacheSess->query($reload);
         $cacheSess->prune($reload);
-        Horde_Util::closeWindowJS('opener.focus();opener.location.href="' . $href . '";');
+        echo Horde::wrapInlineScript(array(
+            'opener.focus();'.
+            'opener.location.href="' . $href . '";',
+            'window.close();'
+        ));
     }
 
 }
index f2bcb13..b094c3c 100644 (file)
@@ -514,7 +514,11 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
         $cacheSess = Horde_SessionObjects::singleton();
         $href = $cacheSess->query($reload);
         $cacheSess->prune($reload);
-        Horde_Util::closeWindowJS('opener.focus();opener.location.href="' . $href . '";');
+        echo Horde::wrapInlineScript(array(
+            'opener.focus();',
+            'opener.location.href="' . $href . '";',
+            'window.close();'
+        ));
     }
 
 }
index 7410291..751cc8a 100644 (file)
@@ -198,7 +198,7 @@ case 'save_attachment_public_key':
     /* Add the public key to the storage system. */
     try {
         $imp_pgp->addPublicKey($mime_part->getContents());
-        Horde_Util::closeWindowJS();
+        echo Horde::wrapInlineScript(array('window.close();'));
     } catch (Horde_Exception $e) {
         $notification->push($e, $key_info->getCode());
     }
index 8fc09a8..94ab971 100644 (file)
@@ -34,7 +34,7 @@ case 'save_image':
         $notification->push($e);
         break;
     }
-    Horde_Util::closeWindowJS();
+    echo Horde::wrapInlineScript(array('window.close();'));
     exit;
 }
 
index c8737d1..4d14fd0 100644 (file)
@@ -112,7 +112,7 @@ case 'save_attachment_public_key':
     /* Add the public key to the storage system. */
     try {
         $imp_smime->addPublicKey($mime_part);
-        Horde_Util::closeWindowJS();
+        echo Horde::wrapInlineScript(array('window.close();'));
     } catch (Horde_Exception $e) {
         $notification->push(_("No Certificate found"), 'horde.error');
     }
index 398c739..57215c4 100644 (file)
@@ -62,7 +62,7 @@ case 'add':
     }
 
     if (Horde_Util::getFormData('addNewClose')) {
-        Horde_Util::closeWindowJS();
+        echo Horde::wrapInlineScript(array('window.close();'));
         exit;
     }
     break;
@@ -144,7 +144,7 @@ case 'changeresp':
 case 'dismiss':
     // Close the attendee window.
     if ($browser->hasFeature('javascript')) {
-        Horde_Util::closeWindowJS();
+        echo Horde::wrapInlineScript(array('window.close();'));
         exit;
     }
 
index 7db6ce1..2a64ed1 100644 (file)
@@ -10,7 +10,7 @@ require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('kronolith');
 
 if (!Horde_Auth::getAuth()) {
-    Horde_Util::closeWindowJS();
+    echo Horde::wrapInlineScript(array('window.close();'));
     exit;
 }
 
index 0914b3f..661ee19 100644 (file)
@@ -254,7 +254,7 @@ case 'editform':
                 $notification->push($result, 'horde.error');
             } else {
                 if (Horde_Util::getFormData('save_and_finish')) {
-                    Horde_Util::closeWindowJS();
+                    echo Horde::wrapInlineScript(array('window.close();'));
                     exit;
                 }
                 $notification->push(sprintf(_("Updated \"%s\"."), $share->get('name')), 'horde.success');