Use Horde_Url::redirect()
authorMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 30 Jul 2010 23:13:38 +0000 (19:13 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 30 Jul 2010 23:13:38 +0000 (19:13 -0400)
26 files changed:
ansel/disclamer.php
ansel/faces/claim.php
ansel/faces/custom.php
ansel/faces/face.php
ansel/faces/gallery.php
ansel/faces/report.php
ansel/faces/savecustom.php
ansel/faces/search/image.php
ansel/faces/search/image_define.php
ansel/faces/search/image_save.php
ansel/faces/search/image_search.php
ansel/gallery.php
ansel/gallery/captions.php
ansel/gallery/delete.php
ansel/gallery/sort.php
ansel/group.php
ansel/image.php
ansel/img/upload.php
ansel/index.php
ansel/lib/Ansel.php
ansel/lib/View/Gallery.php
ansel/lib/View/Image.php
ansel/lib/View/List.php
ansel/lib/View/Results.php
ansel/protect.php
ansel/report.php

index 09989e9..edde5df 100644 (file)
@@ -16,7 +16,7 @@ try {
     $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($vars->get('gallery'));
 } catch (Ansel_Exception $e) {
     $notification->push($gallery->getMessage());
-    header('Location: ' . Horde::applicationUrl('view.php?view=List', true));
+    Horde::applicationUrl('view.php?view=List', true)->redirect();
     exit;
 }
 $url = $vars->get('url');
@@ -32,11 +32,11 @@ $form->setButtons(array(sprintf(_("Continue - I'm over %d"), $gallery->get('age'
 if ($form->isSubmitted()) {
     if (Horde_Util::getFormData('submitbutton') == _("Cancel")) {
         $notification->push("You are not authorised to view this photo.", 'horde.warning');
-        header('Location: ' . Horde::applicationUrl('view.php?view=List', true));
+        Horde::applicationUrl('view.php?view=List', true)->redirect();
         exit;
     } else {
         $_SESSION['ansel']['user_age'] = (int)$gallery->get('age');
-        header('Location: ' . $url, true);
+        $url->redirect();
         exit;
     }
 }
index c74cdac..f48e2a2 100644 (file)
@@ -19,7 +19,7 @@ try {
     $face = $faces->getFaceById($face_id);
 } catch (Horde_Exception $e) {
     $notification->push($e->getMessage());
-    header('Location: ' . Horde::applicationUrl('faces/search/all.php'));
+    Horde::applicationUrl('faces/search/all.php')->redirect();
     exit;
 }
 
@@ -58,7 +58,7 @@ if ($form->validate()) {
         }
     }
 
-    header('Location: ' . Ansel_Faces::getLink($face));
+    Ansel_Faces::getLink($face)->redirect();
     exit;
 }
 
index e6c65d9..ea5a29a 100644 (file)
@@ -27,14 +27,14 @@ try {
     $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
 } catch (Ansel_Exception $e) {
     $notification->push($image);
-    header('Location: ' . Horde::applicationUrl('list.php'));
+    Horde::applicationUrl('list.php')->redirect();
     exit;
 }
 
 $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
 if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
     $notification->push(_("Access denied editing the photo."));
-    header('Location: ' . Ansel::getUrlFor('view', array('gallery' => $image->gallery)));
+    Ansel::getUrlFor('view', array('gallery' => $image->gallery))->redirect();
     exit;
 }
 
@@ -57,7 +57,7 @@ if ($face_id) {
         }
     } catch (Horde_Exception $e) {
         $notification->push($e->getMessage());
-        header('Location: ' . Horde::applicationUrl('list.php'));
+        Horde::applicationUrl('list.php')->redirect();
     }
 }
 
index 38856da..b8d0cc8 100644 (file)
@@ -22,7 +22,7 @@ try {
     $face = $faces->getFaceById($face_id);
 } catch (Horde_Exception $e) {
     $notification->push($face->getMessage());
-    header('Location: ' . Horde::applicationUrl('faces/index.php'));
+    Horde::applicationUrl('faces/index.php')->redirect();
     exit;
 }
 
index 7ff5e2f..d59fddd 100644 (file)
@@ -18,19 +18,19 @@ Horde_Registry::appInit('ansel');
 $gallery_id = (int)Horde_Util::getFormData('gallery');
 if (empty($gallery_id)) {
     $notification->push(_("No gallery specified"), 'horde.error');
-    header('Location: ' . Ansel::getUrlFor('default_view', array()));
+    Ansel::getUrlFor('default_view', array())->redirect();
     exit;
 }
 try {
     $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
 } catch (Ansel_Exception $e) {
     $notification->push($e->getMessage(), 'horde.error');
-    header('Location: ' . Ansel::getUrlFor('view', array('gallery' => $gallery_id)));
+    Ansel::getUrlFor('view', array('gallery' => $gallery_id))->redirect();
     exit;
 }
 if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
     $notification->push(sprintf(_("Access denied editing gallery \"%s\"."), $gallery->get('name')), 'horde.error');
-    header('Location: ' . Ansel::getUrlFor('view', array('gallery' => $gallery_id)));
+    Ansel::getUrlFor('view', array('gallery' => $gallery_id))->redirect();
     exit;
 }
 $gallery->setDate(Ansel::getDateParameter());
index 59a1122..9a93931 100644 (file)
@@ -20,7 +20,7 @@ try {
     $face = $faces->getFaceById($face_id);
 } catch (Horde_Exception $e) {
     $notification->push($e->getMessage());
-    header('Location: ' . Horde::applicationUrl('faces/search/all.php'));
+    Horde::applicationUrl('faces/search/all.php')->redirect();
     exit;
 }
 
@@ -61,7 +61,7 @@ if ($form->validate()) {
         $notification->push(_("The owner of the photo was notified."), 'horde.success');
     }
 
-    header('Location: ' . Ansel_Faces::getLink($face));
+    Ansel_Faces::getLink($face)->redirect();
     exit;
 }
 
index b2a0e0f..ccd6c0a 100644 (file)
@@ -27,7 +27,7 @@ $back_url = empty($url)
 
 if (Horde_Util::getPost('submit') == _("Cancel")) {
     $notification->push(_("Changes cancelled."), 'horde.warning');
-    header('Location: ' . $back_url);
+    $back_url->redirect();
     exit;
 }
 try {
@@ -42,7 +42,7 @@ try {
                            Horde_Util::getFormData('name'));
 } catch (Horde_Exception $e) {
     $notification->push($e->getMessage());
-    header('Location: ' . $back_url);
+    $back_url->redirect();
     exit;
 }
 
@@ -52,5 +52,5 @@ if ($face_id == 0) {
     $notification->push(_("Face successfuly updated"), 'horde.success');
 }
 
-header('Location: ' . $back_url);
+$back_url->redirect();
 exit;
index c2edb41..45245ce 100644 (file)
@@ -28,13 +28,13 @@ if ($form->validate()) {
         $dimensions = $img->getDimensions();
     } catch (Horde_Image_Exception $e) {
         $notification->push($e->getMessage());
-        header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+        Horde::applicationUrl('faces/search/image.php')->redirect();
         exit;
     }
 
     if ($dimensions['width'] < 50 || $dimensions['height'] < 50) {
         $notification->push(_("Photo is too small. Search photo must be at least 50x50 pixels."));
-        header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+        Horde::applicationUrl('faces/search/image.php')->redirect();
         exit;
     }
 
@@ -43,16 +43,16 @@ if ($form->validate()) {
                      min($conf['screen']['height'], $dimensions['height']));
     } catch (Horde_Image_Exception $e) {
         $notification->push($e->getMessage());
-        header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+        Horde::applicationUrl('faces/search/image.php')->redirect();
         exit;
     }
 
     $path = $tmp . '/search_face_' . $registry->getAuth() . Ansel_Faces::getExtension();
     if (file_put_contents($path, $img->raw())) {
-        header('Location: ' . Horde::applicationUrl('faces/search/image_define.php'));
+        Horde::applicationUrl('faces/search/image_define.php')->redirect();
     } else {
         $notification->push(_("Cannot store search photo"));
-        header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+        Horde::applicationUrl('faces/search/image.php')->redirect();
     }
     exit;
 
index 2feef1a..1d608f6 100644 (file)
@@ -17,7 +17,7 @@ $path = $tmp . '/search_face_' . $registry->getAuth() . Ansel_Faces::getExtensio
 
 if (file_exists($path) !== true) {
     $notification->push(_("You must upload the search photo first"));
-    header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+    Horde::applicationUrl('faces/search/image.php')->redirect();
 }
 
 $title = _("Create a new face");
index 8fc5fdd..6ca94b5 100644 (file)
@@ -17,7 +17,7 @@ $path = $tmp . '/search_face_' . $registry->getAuth() . Ansel_Faces::getExtensio
 
 if (!file_exists($path)) {
     $notification->push(_("You must upload the search photo first"));
-    header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+    Horde::applicationUrl('faces/search/image.php')->redirect();
 }
 
 $x1 = (int)Horde_Util::getFormData('x1');
@@ -27,7 +27,7 @@ $y2 = (int)Horde_Util::getFormData('y2');
 
 if ($x2 - $x1 < 50 || $y2 - $y1 < 50) {
     $notification->push(_("Photo is too small. Search photo must be at least 50x50 pixels."));
-    header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+    Horde::applicationUrl('faces/search/image.php')->redirect();
     exit;
 }
 
@@ -37,7 +37,7 @@ try {
     $result = $img->loadFile($path);
 } catch (Horde_Image_Exception $e) {
     $notification->push($e->getMessage());
-    header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+    Horde::applicationUrl('faces/search/image.php')->redirect();
     exit;
 }
 
@@ -46,7 +46,7 @@ try {
     $result = $img->crop($x1, $y1, $x2, $y2);
 } catch (Horde_Image_Exception $e) {
     $notification->push($e->getMessage());
-    header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+    Horde::applicationUrl('faces/search/image.php')->redirect();
     exit;
 }
 
@@ -58,14 +58,14 @@ try {
     }
 } catch (Horde_Image_Exception $e) {
     $notification->push($e->getMessage());
-    header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+    Horde::applicationUrl('faces/search/image.php')->redirect();
 }
 
 /* Save image. */
 $path = $tmp . '/search_face_thumb_' . $registry->getAuth() . Ansel_Faces::getExtension();
 if (!file_put_contents($path, $img->raw())) {
     $notification->push(_("Cannot store search photo"));
-    header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+    Horde::applicationUrl('faces/search/image.php')->redirect();
     exit;
 }
 
@@ -73,17 +73,17 @@ if (!file_put_contents($path, $img->raw())) {
 $signature = $faces->getSignatureFromFile($path);
 if (empty($signature)) {
     $notification->push(_("Cannot read photo signature"));
-    header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+    Horde::applicationUrl('faces/search/image.php')->redirect();
     exit;
 }
 
 /* Save signature. */
 $path = $tmp . '/search_face_' . $registry->getAuth() . '.sig';
 if (file_put_contents($path, $signature)) {
-    header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+    Horde::applicationUrl('faces/search/image.php')->redirect();
     exit;
 }
 
 $notification->push(_("Cannot save photo signature"));
-header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+Horde::applicationUrl('faces/search/image.php')->redirect();
 exit;
index 99114bb..939abee 100644 (file)
@@ -21,14 +21,14 @@ if (($face_id = Horde_Util::getGet('face_id')) !== null) {
         $results = $faces->getSignatureMatches($signature, $face_id, $perpage * $page, $perpage);
     } catch (Ansel_Exception $e) {
         $notification->push($e->getMessage());
-        header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+        Horde::applicationUrl('faces/search/image.php')->redirect();
     }
 } else {
     $tmp = Horde::getTempDir();
     $path = $tmp . '/search_face_' . $registry->getAuth() . '.sig';
     if (file_exists($path) !== true) {
         $notification->push(_("You must upload the search photo first"));
-        header('Location: ' . Horde::applicationUrl('faces/search/image.php'));
+        Horde::applicationUrl('faces/search/image.php')->redirect();
     }
     $signature = file_get_contents($path);
     try {
index 28dbf3f..1e615a2 100644 (file)
@@ -14,7 +14,7 @@ Horde_Registry::appInit('ansel');
 // Redirect to the gallery list if no action has been requested.
 $actionID = Horde_Util::getFormData('actionID');
 if (is_null($actionID)) {
-    header('Location: ' . Horde::applicationUrl('view.php?view=List', true));
+    Horde::applicationUrl('view.php?view=List', true)->redirect();
     exit;
 }
 
@@ -50,14 +50,14 @@ case 'addchild':
         $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($parentId);
     } catch (Ansel_Exception $e) {
         $notification->push($e->getMessage(), 'horde.error');
-        header('Location: ' . Horde::applicationUrl('view.php?view=List', true));
+        Horde::applicationUrl('view.php?view=List', true)->redirect();
         exit;
     }
 
     if (!$parent->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
         $notification->push(sprintf(_("Access denied adding a gallery to \"%s\"."),
                             $parent->get('name')), 'horde.error');
-        header('Location: ' . Horde::applicationUrl('view.php?view=List', true));
+        Horde::applicationUrl('view.php?view=List', true)->redirect();
         exit;
     }
 
@@ -89,7 +89,7 @@ case 'downloadzip':
         !$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
 
         $notification->push(sprintf(_("Access denied downloading photos from \"%s\"."), $gallery->get('name')), 'horde.error');
-        header('Location: ' . Horde::applicationUrl('view.php?view=List', true));
+        Horde::applicationUrl('view.php?view=List', true)->redirect();
         exit;
     }
 
@@ -129,7 +129,7 @@ case 'save':
         ($injector->getInstance('Horde_Perms')->exists('ansel') &&
          !$injector->getInstance('Horde_Perms')->hasPermission('ansel', $registry->getAuth(), Horde_Perms::EDIT))) {
         $notification->push(_("Access denied editing galleries."), 'horde.error');
-        header('Location: ' . Horde::applicationUrl('view.php?view=List', true));
+        Horde::applicationUrl('view.php?view=List', true)->redirect();
         exit;
     }
 
@@ -202,7 +202,7 @@ case 'save':
                     $result = $gallery->setParent($new_parent);
                 } catch (Ansel_Exception $e) {
                     $notification->push($e->getMessage(), 'horde.error');
-                    header('Location: ' . Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true)));
+                    Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect();
                     exit;
                 }
             }
@@ -220,7 +220,7 @@ case 'save':
                 $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_parent);
             } catch (Ansel_Exception $e) {
                 $notification->push($e->getMessage(), 'horde.error');
-                header('Location: ' . Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true)));
+                Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect();
                 exit;
             }
             if (!$parent->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
@@ -228,7 +228,7 @@ case 'save':
                     _("You do not have permission to add children to %s."),
                     $parent->get('name')), 'horde.error');
 
-                header('Location: ' . Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true)));
+                Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect();
                 exit;
             }
         }
@@ -289,7 +289,7 @@ case 'save':
     } elseif (empty($url)) {
         $url = Horde::applicationUrl('index.php', true);
     }
-    header('Location: ' . $url);
+    $url->redirect();
     exit;
 
 case 'delete':
@@ -310,7 +310,7 @@ case 'empty':
     }
 
     // Return to the gallery list.
-    header('Location: ' . Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true)));
+    Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect();
     exit;
 
 case 'generateDefault':
@@ -320,11 +320,11 @@ case 'generateDefault':
         $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
         $gallery->clearStacks();
         $notification->push(_("The gallery's default photo has successfully been reset."), 'horde.success');
-        header('Location: ' . Horde::applicationUrl('view.php', true)->add('gallery', $galleryId));
+        Horde::applicationUrl('view.php', true)->add('gallery', $galleryId)->redirect();
         exit;
     } catch (Ansel_Exception $e) {
         $notification->push($e->getMessage(), 'horde.error');
-        header('Location: ' . Horde::applicationUrl('index.php', true));
+        Horde::applicationUrl('index.php', true)->redirect();
         exit;
     }
 
@@ -335,12 +335,12 @@ case 'generateThumbs':
         $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
     } catch (Ansel_Exception $e) {
         $notification->push($gallery->getMessage(), 'horde.error');
-        header('Location: ' . Horde::applicationUrl('index.php', true));
+        Horde::applicationUrl('index.php', true)->redirect();
         exit;
     }
     $gallery->clearThumbs();
     $notification->push(_("The gallery's thumbnails have successfully been reset."), 'horde.success');
-    header('Location: ' . Horde::applicationUrl('view.php', true)->add('gallery', $galleryId));
+    Horde::applicationUrl('view.php', true)->add('gallery', $galleryId)->redirect();
     exit;
 
 case 'deleteCache':
@@ -350,16 +350,16 @@ case 'deleteCache':
         $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
     } catch (Ansel_Exception $e) {
         $notification->push($gallery->getMessage(), 'horde.error');
-        header('Location: ' . Horde::applicationUrl('index.php', true));
+        Horde::applicationUrl('index.php', true)->redirect();
         exit;
     }
     $gallery->clearViews();
     $notification->push(_("The gallery's views have successfully been reset."), 'horde.success');
-    header('Location: ' . Horde::applicationUrl('view.php', true)->add('gallery', $galleryId));
+    Horde::applicationUrl('view.php', true)->add('gallery', $galleryId)->redirect();
     exit;
 
 default:
-    header('Location: ' . Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true)));
+    Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect();
     exit;
 }
 
index c4db7cd..3657a3a 100644 (file)
@@ -13,21 +13,20 @@ Horde_Registry::appInit('ansel');
 
 $galleryId = Horde_Util::getFormData('gallery');
 if (!$galleryId) {
-    header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'),
-                                           true));
+    Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
     exit;
 }
 try {
     $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
 } catch (Ansel_Exception $e) {
     $notification->push(sprintf(_("Error accessing %s: %s"), $galleryId, $e->getMessage()), 'horde.error');
-    header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true));
+    Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
     exit;
 }
 
 if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
     $notification->push(sprintf(_("Access denied setting captions for %s."), $gallery->get('name')), 'horde.error');
-    header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true));
+    Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
     exit;
 }
 
@@ -50,11 +49,10 @@ case 'save':
 
     $notification->push(_("Captions Saved."), 'horde.success');
     $style = $gallery->getStyle();
-    header('Location: ' . Ansel::getUrlFor('view', array_merge(
-                                           array('gallery' => $galleryId,
-                                                 'slug' => $gallery->get('slug'),
-                                                 'view' => 'Gallery'),
-                                           $date), true));
+    Ansel::getUrlFor('view', array_merge(array('gallery' => $galleryId,
+                                               'slug' => $gallery->get('slug'),
+                                               'view' => 'Gallery'),
+                                         $date), true)->redirect();
     exit;
 }
 
index 46a16c6..9befd25 100644 (file)
@@ -21,7 +21,7 @@ if ($galleryId) {
     } catch (Ansel_Exception $e) {
         $notification->push($e->getMessage(), 'horde.error');
         // Return to the default view.
-        header('Location: ' . Ansel::getUrlFor('default_view', array()));
+        Ansel::getUrlFor('default_view', array())->redirect();
         exit;
     }
     switch ($actionID) {
@@ -49,7 +49,7 @@ if ($galleryId) {
         }
 
         // Return to the default view.
-        header('Location: ' . Ansel::getUrlFor('default_view', array()));
+        Ansel::getUrlFor('default_view', array())->redirect();
         exit;
 
     case 'empty':
@@ -61,12 +61,11 @@ if ($galleryId) {
             $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->emptyGallery($gallery);
             $notification->push(sprintf(_("Successfully emptied \"%s\""), $gallery->get('name')));
         }
-        header('Location: '
-               . Ansel::getUrlFor('view',
-                                  array('view' => 'Gallery',
-                                        'gallery' => $galleryId,
-                                        'slug' => $gallery->get('slug')),
-                                  true));
+        Ansel::getUrlFor('view',
+                         array('view' => 'Gallery',
+                               'gallery' => $galleryId,
+                               'slug' => $gallery->get('slug')),
+                         true)->redirect();
         exit;
     }
 }
index 7b1d44c..d2f9a51 100644 (file)
@@ -15,15 +15,14 @@ Horde_Registry::appInit('ansel');
  * list. */
 $galleryId = Horde_Util::getFormData('gallery');
 if (!isset($galleryId)) {
-    header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'),
-                                           true));
+    Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
     exit;
 }
 try {
     $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
 } catch (Ansel_Excception $e) {
     $notification->push(_("There was an error accessing the gallery."), 'horde.error');
-    header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true));
+    Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
     exit;
 }
 
@@ -48,12 +47,14 @@ case 'Sort':
     $notification->push(_("Gallery sorted."), 'horde.success');
     $style = $gallery->getStyle();
 
-    header('Location: ' . Ansel::getUrlFor('view', array_merge(
-                                           array('view' => 'Gallery',
-                                                 'gallery' => $galleryId,
-                                                 'slug' => $gallery->get('slug')),
-                                           $date),
-                                           true));
+    Ansel::getUrlFor('view',
+                     array_merge(
+                           array('view' => 'Gallery',
+                                 'gallery' => $galleryId,
+                                 'slug' => $gallery->get('slug')),
+                           $date
+                     ),
+                     true)->redirect();
     exit;
 }
 
index 93b7a79..27abb99 100644 (file)
@@ -64,12 +64,12 @@ case 'owner':
     break;
 
 default:
-    header('Location: ' . Ansel::getUrlFor('view',
-                                           array(
-                                               'view' => 'List',
-                                               'groupby' => $groupby
-                                           ),
-                                           true));
+    Ansel::getUrlFor('view',
+                     array(
+                         'view' => 'List',
+                         'groupby' => $groupby
+                     ),
+                     true)->redirect();
     exit;
 }
 
index d87a71c..5aaf5c5 100644 (file)
@@ -47,8 +47,7 @@ $tags = Horde_Util::getFormData('addtag');
 
 /* Redirect to the image list if no other action has been requested. */
 if (is_null($actionID) && is_null($tags)) {
-    header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'),
-                                           true));
+    Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
     exit;
 }
 
@@ -57,7 +56,7 @@ try {
     $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
 } catch (Ansel_Exception $e) {
     $notification->push(sprintf(_("Gallery %s not found."), $gallery_id), 'horde.error');
-    header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true));
+    Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
     exit;
 }
 
@@ -92,7 +91,7 @@ if (!is_null($tags) && strlen($tags)) {
 
                                     true);
         }
-        header('Location: ' . $url);
+        $url->redirect();
         exit;
     }
 }
@@ -122,7 +121,7 @@ case 'deletetags':
     $eTags = $resource->getTags();
     unset($eTags[$tag]);
     $resource->setTags($eTags);
-    header('Location: ' . $url);
+    $url->redirect();
     exit;
 
 case 'modify':
@@ -131,7 +130,7 @@ case 'modify':
         $ret = Horde_Util::getFormData('ret', 'gallery');
     } catch (Ansel_Exception $e) {
         $notification->push(_("Photo not found."), 'horde.error');
-        header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true));
+        Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
         exit;
     }
 
@@ -166,14 +165,13 @@ case 'save':
     if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
         $notification->push(sprintf(_("Access denied saving photo to \"%s\"."), $gallery->get('name')),
                             'horde.error');
-        $imageurl = Ansel::getUrlFor('view', array_merge(
-                array('gallery' => $gallery_id,
-                      'slug' => $gallery->get('slug'),
-                      'view' => 'Gallery',
-                      'page' => $page),
-                $date),
-            true);
-        header('Location: ' . $imageurl);
+        Ansel::getUrlFor('view',
+                         array_merge(array('gallery' => $gallery_id,
+                                           'slug' => $gallery->get('slug'),
+                                           'view' => 'Gallery',
+                                           'page' => $page),
+                                     $date),
+                         true)->redirect();
         exit;
     }
 
@@ -258,7 +256,7 @@ case 'save':
                                      true);
         if ($actionID == 'save') {
             /* Return to the image view. */
-            header('Location: ' . $imageurl);
+            $imageurl->redirect();
         } elseif ($actionID == 'saveclose') {
             echo Horde::wrapInlineScript(array(
                 'window.opener.location.href = window.opener.location.href;',
@@ -304,7 +302,7 @@ case 'resizeedit':
                             'horde.error');
 
         /* Return to the image view. */
-        header('Location: ' . $ImageGenerator_url);
+        $ImageGenerator_url->redirect();
         exit;
     }
 
@@ -356,29 +354,27 @@ case 'watermark':
                                     $gallery->get('name')),
                             'horde.error');
         /* Return to the image view. */
-        $imageurl = Ansel::getUrlFor('view', array_merge(
+        Ansel::getUrlFor('view', array_merge(
                                      array('gallery' => $gallery_id,
                                            'image' => $image_id,
                                            'view' => 'Image',
                                            'page' => $page,
                                            'slug' => $gallery->get('slug')),
                                      $date),
-                                     true);
-        header('Location: ' . $imageurl);
+                                     true)->redirect();
         exit;
     } else {
         $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
         $image->watermark('screen', $watermark, $watermark_halign,
                                 $watermark_valign, $watermark_font);
         $image->updateData($image->raw('screen'), 'screen');
-        $imageurl = Horde::applicationUrl('image.php', true)->add(
+        Horde::applicationUrl('image.php', true)->add(
                 array_merge(
                        array('gallery' => $gallery_id,
                              'image' => $image_id,
                              'actionID' => 'editimage',
                              'page' => $page),
-                       $date));
-        header('Location: ' . $imageurl);
+                       $date))->redirect();
         exit;
     }
 
@@ -399,7 +395,7 @@ case 'resize':
             $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
         } catch (Ansel_Exception $e) {
             $notification->push($e->getMessage(), 'horde.error');
-            header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true));
+            Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
             exit;
         }
 
@@ -447,14 +443,13 @@ case 'resize':
         }
     }
 
-    $imageurl = Horde::applicationUrl('image.php', true)->add(
+    Horde::applicationUrl('image.php', true)->add(
             array_merge(
                     array('gallery' => $gallery_id,
                           'image' => $image_id,
                           'actionID' => 'editimage',
                           'page' => $page),
-                    $date));
-    header('Location: ' . $imageurl);
+                    $date))->redirect();
     exit;
 
 case 'setwatermark':
@@ -463,7 +458,7 @@ case 'setwatermark':
         $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
     } catch (Ansel_Exception $e) {
         $notification->push($image->getMessage(), 'horde.error');
-        header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true));
+        Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
         exit;
     }
     /* Set up the form object. */
@@ -594,14 +589,14 @@ case 'delete':
     }
 
     /* Return to the image list. */
-    $imageurl = Ansel::getUrlFor('view', array_merge(
-                                 array('gallery' => $gallery_id,
-                                       'view' => 'Gallery',
-                                       'page' => $page,
-                                       'slug' => $gallery->get('slug')),
-                                 $date),
-                                 true);
-    header('Location: ' . $imageurl);
+    Ansel::getUrlFor('view',
+                     array_merge(
+                         array('gallery' => $gallery_id,
+                               'view' => 'Gallery',
+                               'page' => $page,
+                               'slug' => $gallery->get('slug')),
+                         $date),
+                     true)->redirect();
     exit;
 
 case 'move':
@@ -638,14 +633,13 @@ case 'move':
     }
 
     /* Return to the image list. */
-    $imageurl = Ansel::getUrlFor('view', array_merge(
+    Ansel::getUrlFor('view', array_merge(
                                  array('gallery' => $gallery_id,
                                        'view' => 'Gallery',
                                        'page' => $page,
                                        'slug' => $gallery->get('slug')),
                                  $date),
-                                 true);
-    header('Location: ' . $imageurl);
+                                 true)->redirect();
     exit;
 
 case 'copy':
@@ -674,14 +668,14 @@ case 'copy':
     }
 
     /* Return to the image list. */
-    $imageurl = Ansel::getUrlFor('view', array_merge(
-                                 array('gallery' => $gallery_id,
-                                       'view' => 'Gallery',
-                                       'page' => $page,
-                                       'slug' => $gallery->get('slug')),
-                                 $date),
-                                 true);
-    header('Location: ' . $imageurl);
+    Ansel::getUrlFor('view',
+                     array_merge(
+                         array('gallery' => $gallery_id,
+                               'view' => 'Gallery',
+                               'page' => $page,
+                               'slug' => $gallery->get('slug')),
+                         $date),
+                     true)->redirect();
     exit;
 
 case 'downloadzip':
@@ -693,7 +687,7 @@ case 'downloadzip':
             $gallery->hasPasswd() || !$gallery->isOldEnough()) {
 
             $notification->push(sprintf(_("Access denied downloading photos from \"%s\"."), $gallery->get('name')), 'horde.error');
-            header('Location: ' . Horde::applicationUrl('view.php?view=List', true));
+            Horde::applicationUrl('view.php?view=List', true)->redirect();
             exit;
         }
     }
@@ -709,7 +703,7 @@ case 'downloadzip':
         } else {
             $url = Ansel::getUrlFor('view', array('view' => 'List'));
         }
-        header('Location: ' . $url);
+        $url->redirect();
         exit;
     }
     exit;
@@ -719,12 +713,11 @@ case 'previewcrop':
 
     if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
         $notification->push(_("Access denied editing the photo."), 'horde.error');
-        $imageurl = Ansel::getUrlFor(
+        Ansel::getUrlFor(
             'view', array('gallery' => $gallery_id,
                           'image' => $image_id,
                           'view' => 'Image',
-                          'page' => $page));
-        header('Location: ' . $imageurl);
+                          'page' => $page))->redirect();
     } else {
         $x1 = (int)Horde_Util::getFormData('x1');
         $y1 = (int)Horde_Util::getFormData('y1');
@@ -760,7 +753,7 @@ case 'imagecrop':
         exit;
 
 default:
-    header('Location: ' . Ansel::getUrlFor('default_view', array()));
+    Ansel::getUrlFor('default_view', array())->redirect();
     exit;
 }
 
index 1655484..d490f69 100644 (file)
@@ -16,7 +16,7 @@ try {
     $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
 } catch (Ansel_Exception $e) {
     $notification->push(sprintf(_("Gallery %s not found."), $gallery_id), 'horde.error');
-    header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true));
+    Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
     exit;
 }
 
@@ -227,14 +227,12 @@ if ($form->validate($vars)) {
 
     if ($valid) {
         /* Return to the gallery view. */
-        $imageurl = Ansel::getUrlFor('view',
-                                     array('gallery' => $gallery_id,
-                                           'slug' => $gallery->get('slug'),
-                                           'view' => 'Gallery',
-                                           'page' => $page),
-                                     true);
-
-        header('Location: ' . $imageurl);
+        Ansel::getUrlFor('view',
+                         array('gallery' => $gallery_id,
+                               'slug' => $gallery->get('slug'),
+                               'view' => 'Gallery',
+                               'page' => $page),
+                         true)->redirect();
         exit;
     }
 }
index 689c022..2674cfc 100644 (file)
@@ -10,5 +10,4 @@
 
 require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('ansel');
-
-header('Location: ' . Ansel::getUrlFor('default_view', array()));
+Ansel::getUrlFor('default_view', array())->redirect();
index fa0dc15..07780e0 100644 (file)
@@ -120,7 +120,7 @@ class Ansel
             $parent = (empty($params['parent'])) ? null : $params['parent']->id;
             if ((!empty($params['parent']) && !empty($galleries[$params['parent']])) ||
                 (empty($params['parent']))) {
-                
+
                 $tree->addNode($gallery->id, $parent, $label, $indents, true, $treeparams);
             }
         }
@@ -258,7 +258,7 @@ class Ansel
                     if (count($extras)) {
                         $url->add($extras);
                     }
-                    
+
                     /* Slight hack until we delegate at least some of the url
                      * generation to the gallery/image/view object. */
                     if ($data['view'] == 'Image' &&
@@ -294,10 +294,10 @@ class Ansel
                 }
 
                 return Horde::applicationUrl($url, $full, $append_session);
-            
+
             } else {
                 $url = Horde::applicationUrl('view.php', $full, $append_session);
-                
+
                 /* See note above about delegating url generation to gallery/view */
                 if ($data['view'] == 'Image' &&
                     !empty($data['gallery_view']) &&
@@ -919,7 +919,7 @@ class Ansel
 
         if (empty($GLOBALS['conf']['gallery']['downloadzip'])) {
             $GLOBALS['notification']->push(_("Downloading zip files is not enabled. Talk to your server administrator."));
-            header('Location: ' . Horde::applicationUrl('view.php?view=List', true));
+            Horde::applicationUrl('view.php?view=List', true)->redirect();
             exit;
         }
 
@@ -942,7 +942,8 @@ class Ansel
         if (!count($images)) {
             $notification->push(sprintf(_("There are no photos in %s to download."),
                                 $gallery->get('name')), 'horde.message');
-            header('Location: ' . Horde::applicationUrl('view.php?view=List', true));
+
+            Horde::applicationUrl('view.php?view=List', true)->redirect();
             exit;
         }
 
index 1f2d163..cdba189 100644 (file)
@@ -55,7 +55,8 @@ class Ansel_View_Gallery extends Ansel_View_Base
                                    true);
 
             $params = array('gallery' => $this->gallery->id, 'url' => $galleryurl);
-            header('Location: ' . Horde::applicationUrl('disclamer.php')->add($params)->setRaw(true));
+
+            Horde::applicationUrl('disclamer.php')->add($params)->setRaw(true)->redirect();
             exit;
         }
 
@@ -77,7 +78,7 @@ class Ansel_View_Gallery extends Ansel_View_Base
                                    true);
 
             $params = array('gallery' => $this->gallery->id, 'url' => $galleryurl);
-            header('Location: ' . Horde::applicationUrl('protect.php')->add($params)->setRaw(true));
+            Horde::applicationUrl('protect.php')->add($params)->setRaw(true)->redirect();
             exit;
         }
 
index 3d63608..da0fcc6 100644 (file)
@@ -61,7 +61,7 @@ class Ansel_View_Image extends Ansel_View_Base
 
             $params = array('gallery' => $this->gallery->id, 'url' => $url);
 
-            header('Location: ' . Horde::applicationUrl('disclamer.php')->add($params)->setRaw(true));
+            Horde::applicationUrl('disclamer.php')->add($params)->setRaw(true)->redirect();
             exit;
         }
 
@@ -86,7 +86,7 @@ class Ansel_View_Image extends Ansel_View_Base
 
             $params = array('gallery' => $this->gallery->id, 'url' => $url);
 
-            header('Location: ' . Horde::applicationUrl('protect.php')->add($params)->setRaw(true));
+            Horde::applicationUrl('protect.php')->add($params)->setRaw(true)->redirect();
             exit;
         }
 
index 076023d..5403e1e 100644 (file)
@@ -79,7 +79,7 @@ class Ansel_View_List extends Ansel_View_Base
             $this->_category = $this->_params['category'];
         }
         if (!$this->_owner && !$this->_category && !$this->_special && $this->_groupby != 'none' ) {
-            header('Location: ' . Ansel::getUrlFor('group', array('groupby' => $this->_groupby), true));
+            Ansel::getUrlFor('group', array('groupby' => $this->_groupby))->redirect();
             exit;
         }
 
@@ -90,7 +90,7 @@ class Ansel_View_List extends Ansel_View_Base
             $this->_page = Horde_Util::getFormData('page', 0);
         }
         $this->_g_perPage = $prefs->getValue('tilesperpage');
-        
+
         // If we are calling from the api, we can just pass a list of gallery
         // ids instead of doing grouping stuff.
         if (!empty($this->_params['api']) &&
@@ -127,9 +127,8 @@ class Ansel_View_List extends Ansel_View_Base
 
             if ($this->_numGalleries == 0 && empty($this->_params['api'])) {
                 if ($this->_owner && $filter == $this->_owner && $this->_owner == $GLOBALS['registry']->getAuth()) {
-                    $notification->push(_("You have no photo galleries, add one!"),
-                                        'horde.message');
-                    header('Location: ' .Horde::applicationUrl('gallery.php')->add('actionID', 'add'));
+                    $notification->push(_("You have no photo galleries, add one!"), 'horde.message');
+                    Horde::applicationUrl('gallery.php')->add('actionID', 'add')->redirect();
                     exit;
                 }
                 $notification->push(_("There are no photo galleries available."), 'horde.message');
index 3b00675..2275552 100644 (file)
@@ -76,9 +76,7 @@ class Ansel_View_Results extends Ansel_View_Base
                  }
              }
 
-             header('Location: ' . Ansel::getUrlFor('view',
-                                                    array('view' => 'Results'),
-                                                    true));
+             Ansel::getUrlFor('view', array('view' => 'Results'), true)->redirect();
              exit;
 
         case 'move':
@@ -119,9 +117,8 @@ class Ansel_View_Results extends Ansel_View_Base
                     $notification->push(_("Bad input."), 'horde.error');
                 }
             }
-            header('Location: ' . Ansel::getUrlFor('view',
-                                                   array('view' => 'Results'),
-                                                   true));
+
+            Ansel::getUrlFor('view', array('view' => 'Results'), true)->redirect();
             exit;
 
         case 'copy':
@@ -160,7 +157,7 @@ class Ansel_View_Results extends Ansel_View_Base
                     $notification->push(_("Bad input."), 'horde.error');
                 }
             }
-            header('Location: ' . Ansel::getUrlFor('view', array('view' => 'Results'), true));
+            Ansel::getUrlFor('view', array('view' => 'Results'), true)->redirect();
             exit;
 
         /* Tag related actions */
@@ -188,7 +185,7 @@ class Ansel_View_Results extends Ansel_View_Base
 
         /* Check for empty tag search and redirect if empty */
         if ($this->_search->tagCount() < 1) {
-            header('Location: ' . Horde::applicationUrl('browse.php', true));
+            Horde::applicationUrl('browse.php', true)->redirect();
             exit;
         }
     }
index e8a98c0..0a061c0 100644 (file)
@@ -16,7 +16,7 @@ try {
     $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($vars->get('gallery'));
 } catch (Ansel_Exception $e) {
     $notification->push($e->getMessage());
-    header('Location: ' . Horde::applicationUrl('list.php'));
+    Horde::applicationUrl('list.php')->redirect();
     exit;
 }
 $form = new Horde_Form($vars, _("This gallery is protected by a password. Please enter it below."));
@@ -34,7 +34,7 @@ if ($form->validate()) {
         if (empty($url)) {
             $url = Horde::applicationUrl('view.php')->add('gallery', $gallery->id);
         }
-        header('Location: ' . $url);
+        $url->redirect();
         exit;
     }
 }
index 205ba3a..a882182 100644 (file)
@@ -20,7 +20,7 @@ try {
     $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id);
 } catch (Ansel_Exception $e) {
     $notification->push($gallery->getMessage());
-    header('Location: ' . Horde::applicationUrl('view.php?view=List', true));
+    Horde::applicationUrl('view.php?view=List', true)->redirect();
     exit;
 }
 
@@ -78,7 +78,7 @@ if ($form->validate()) {
     } else {
         $notification->push(_("Gallery was not reported."), 'horde.warning');
     }
-    header('Location: ' . $return_url);
+    $return_url->redirect();
     exit;
 }