From: Jan Schneider Date: Tue, 3 Aug 2010 22:43:06 +0000 (+0200) Subject: Use Horde_Url#redirect(). X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=7f7a4300f16b429ed645bc3e2af2cedffc70ce3e;p=horde.git Use Horde_Url#redirect(). --- diff --git a/agora/ban.php b/agora/ban.php index b8336bf29..eba6e7186 100644 --- a/agora/ban.php +++ b/agora/ban.php @@ -16,15 +16,13 @@ list($forum_id, , $scope) = Agora::getAgoraId(); $forums = &Agora_Messages::singleton($scope, $forum_id); if ($forums instanceof PEAR_Error) { $notification->push($forums->message, 'horde.error'); - header('Location: ' . Horde::applicationUrl('forums.php')); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Check permissions */ if (!$forums->hasPermission(Horde_Perms::DELETE)) { $notification->push(sprintf(_("You don't have permissions to ban users from forum %s."), $forum_id), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('forums.php')); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Ban action */ diff --git a/agora/deleteforum.php b/agora/deleteforum.php index 60da3d8b0..d4b5ada0e 100644 --- a/agora/deleteforum.php +++ b/agora/deleteforum.php @@ -17,13 +17,11 @@ Horde_Registry::appInit('agora'); /* Set up the forums object. */ $scope = Horde_Util::getFormData('scope', 'agora'); $forums = &Agora_Messages::singleton($scope); -$url = Horde::applicationUrl('forums.php'); /* Check permissions */ if (!$forums->hasPermission(Horde_Perms::DELETE)) { $notification->push(sprintf(_("You don't have permissions to delete forums in %s"), $registry->get('name', $scope)), 'horde.warning'); - header('Location: ' . $url); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Get forum. */ @@ -31,8 +29,7 @@ list($forum_id) = Agora::getAgoraId(); $forum = $forums->getForum($forum_id); if ($forum instanceof PEAR_Error) { $notification->push($forum->message, 'horde.error'); - header('Location: ' . $url); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Prepare forum. */ @@ -67,8 +64,7 @@ if ($form->validate()) { } else { $notification->push(_("Forum not deleted."), 'horde.message'); } - header('Location: ' . $url); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Set up template variables. */ diff --git a/agora/editforum.php b/agora/editforum.php index 80ed3d102..13de19684 100644 --- a/agora/editforum.php +++ b/agora/editforum.php @@ -25,12 +25,11 @@ $vars->set('forum_id', $forum_id); /* Check permissions */ if ($forum_id && !$registry->isAdmin(array('permission' => 'agora:admin'))) { $notification->push(sprintf(_("You don't have permissions to edit forum %s"), $registry->get('name', $scope)), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('forums.php', true)); - exit; -} elseif (!$registry->isAdmin(array('permission' => 'agora:admin'))) { + Horde::applicationUrl('forums.php', true)->redirect(); +} +if (!$registry->isAdmin(array('permission' => 'agora:admin'))) { $notification->push(sprintf(_("You don't have permissions to create a new forum in %s"), $registry->get('name', $scope)), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('forums.php', true)); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } $form = new ForumForm($vars, $title); @@ -38,11 +37,10 @@ if ($form->validate()) { $forum_id = $form->execute($vars); if ($forum_id instanceof PEAR_Error) { $notification->push(sprintf(_("Could not create the forum. %s"), $forum_id->message), 'horde.error'); - header('Location: ' . Horde::applicationUrl('forums.php', true)); - } else { - $notification->push($vars->get('forum_id') ? _("Forum Modified") : _("Forum created."), 'horde.success'); - header('Location: ' . Agora::setAgoraId($forum_id, null, Horde::applicationUrl('threads.php', true))); + Horde::applicationUrl('forums.php', true)->redirect(); } + $notification->push($vars->get('forum_id') ? _("Forum Modified") : _("Forum created."), 'horde.success'); + header('Location: ' . Agora::setAgoraId($forum_id, null, Horde::applicationUrl('threads.php', true))); exit; } diff --git a/agora/messages/abuse.php b/agora/messages/abuse.php index 282e4b36f..7d31ac3ab 100644 --- a/agora/messages/abuse.php +++ b/agora/messages/abuse.php @@ -16,17 +16,14 @@ list($forum_id, $message_id, $scope) = Agora::getAgoraId(); $messages = &Agora_Messages::singleton($scope, $forum_id); if ($messages instanceof PEAR_Error) { $notification->push($messages->getMessage(), 'horde.warning'); - $url = Horde::applicationUrl('forums.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Get requested message, if fail then back to forums list. */ $message = $messages->getMessage($message_id); if ($message instanceof PEAR_Error) { $notification->push(sprintf(_("Could not open the message. %s"), $message->getMessage()), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('forums.php', true)); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* We have any moderators? */ diff --git a/agora/messages/delete.php b/agora/messages/delete.php index 014cdd067..c6881c514 100644 --- a/agora/messages/delete.php +++ b/agora/messages/delete.php @@ -18,17 +18,14 @@ list($forum_id, $message_id, $scope) = Agora::getAgoraId(); $messages = &Agora_Messages::singleton($scope, $forum_id); if ($messages instanceof PEAR_Error) { $notification->push($messages->getMessage(), 'horde.warning'); - $url = Horde::applicationUrl('forums.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Get requested message, if fail then back to forums list. */ $message = $messages->getMessage($message_id); if ($message instanceof PEAR_Error) { $notification->push(sprintf(_("Could not open the message. %s"), $message->getMessage()), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('forums.php', true)); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Check delete permissions */ diff --git a/agora/messages/edit.php b/agora/messages/edit.php index 464781158..7a1ce5c34 100644 --- a/agora/messages/edit.php +++ b/agora/messages/edit.php @@ -25,9 +25,7 @@ $formname = $vars->get('formname'); $messages = &Agora_Messages::singleton($scope, $forum_id); if ($messages instanceof PEAR_Error) { $notification->push(_("Could not post the message: ") . $messages->getMessage(), 'horde.warning'); - $url = Horde::applicationUrl('forums.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Check edit permissions */ diff --git a/agora/messages/index.php b/agora/messages/index.php index 60959d029..c60e3f08a 100644 --- a/agora/messages/index.php +++ b/agora/messages/index.php @@ -18,17 +18,14 @@ list($forum_id, $message_id, $scope) = Agora::getAgoraId(); $messages = &Agora_Messages::singleton($scope, $forum_id); if ($messages instanceof PEAR_Error) { $notification->push($messages->getMessage(), 'horde.warning'); - $url = Horde::applicationUrl('forums.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Get requested message, if fail then back to forums list. */ $message = $messages->getMessage($message_id); if ($message instanceof PEAR_Error) { $notification->push(sprintf(_("Could not open the message. %s"), $message->getMessage()), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('forums.php', true)); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Check if we must show bodies */ @@ -127,8 +124,7 @@ if ($messages->hasPermission(Horde_Perms::DELETE)) { $threads_list = $messages->getThreads($message['message_thread'], true, $sort_by, $sort_dir, ($view_bodies ? 1 : 0), '', null, $thread_start, $thread_per_page); if ($threads_list instanceof PEAR_Error) { $notification->push($threads_list->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl('forums.php', true)); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Set up pager. */ diff --git a/agora/messages/lock.php b/agora/messages/lock.php index ab8322743..b25b85109 100644 --- a/agora/messages/lock.php +++ b/agora/messages/lock.php @@ -18,17 +18,14 @@ list($forum_id, $message_id, $scope) = Agora::getAgoraId(); $messages = &Agora_Messages::singleton($scope, $forum_id); if ($messages instanceof PEAR_Error) { $notification->push($messages->getMessage(), 'horde.warning'); - $url = Horde::applicationUrl('forums.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Get requested message, if fail then back to forums list. */ $message = $messages->getMessage($message_id); if ($message instanceof PEAR_Error) { $notification->push(sprintf(_("Could not open the message. %s"), $message->getMessage()), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('forums.php', true)); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Check delete permissions */ diff --git a/agora/messages/merge.php b/agora/messages/merge.php index bbe125d8d..77d751ac8 100644 --- a/agora/messages/merge.php +++ b/agora/messages/merge.php @@ -16,17 +16,14 @@ list($forum_id, $message_id, $scope) = Agora::getAgoraId(); $messages = &Agora_Messages::singleton($scope, $forum_id); if ($messages instanceof PEAR_Error) { $notification->push($messages->getMessage(), 'horde.warning'); - $url = Horde::applicationUrl('forums.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Get requested message, if fail then back to forums list. */ $message = $messages->getMessage($message_id); if ($message instanceof PEAR_Error) { $notification->push(sprintf(_("Could not open the message. %s"), $message->getMessage()), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('forums.php', true)); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Check delete permissions */ diff --git a/agora/messages/move.php b/agora/messages/move.php index 4daf3f5d0..4d23c2d2a 100644 --- a/agora/messages/move.php +++ b/agora/messages/move.php @@ -16,17 +16,14 @@ list($forum_id, $message_id, $scope) = Agora::getAgoraId(); $messages = &Agora_Messages::singleton($scope, $forum_id); if ($messages instanceof PEAR_Error) { $notification->push($messages->getMessage(), 'horde.warning'); - $url = Horde::applicationUrl('forums.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Get requested message, if fail then back to forums list. */ $message = $messages->getMessage($message_id); if ($message instanceof PEAR_Error) { $notification->push(sprintf(_("Could not open the message. %s"), $message->getMessage()), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('forums.php', true)); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Check delete permissions */ diff --git a/agora/messages/split.php b/agora/messages/split.php index a0d7752b3..14ced754f 100644 --- a/agora/messages/split.php +++ b/agora/messages/split.php @@ -16,17 +16,14 @@ list($forum_id, $message_id, $scope) = Agora::getAgoraId(); $messages = &Agora_Messages::singleton($scope, $forum_id); if ($messages instanceof PEAR_Error) { $notification->push($messages->getMessage(), 'horde.warning'); - $url = Horde::applicationUrl('forums.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Get requested message, if fail then back to forums list. */ $message = $messages->getMessage($message_id); if ($message instanceof PEAR_Error) { $notification->push(sprintf(_("Could not open the message. %s"), $message->getMessage()), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('forums.php', true)); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Check delete permissions */ diff --git a/agora/moderate.php b/agora/moderate.php index abec4396b..302ad75fd 100644 --- a/agora/moderate.php +++ b/agora/moderate.php @@ -43,8 +43,7 @@ case _("Delete"): $messages_list = $messages->getModerateList($sort_by, $sort_dir); if ($messages_list instanceof PEAR_Error) { $notification->push($messages_list->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl('forums.php', true)); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } elseif (empty($messages_list)) { $messages_count = 0; $notification->push(_("No messages are waiting for moderation."), 'horde.message'); diff --git a/agora/moderators.php b/agora/moderators.php index 30dce9f4e..c299d9eb1 100644 --- a/agora/moderators.php +++ b/agora/moderators.php @@ -15,8 +15,7 @@ require_once dirname(__FILE__) . '/lib/Application.php'; Horde_Registry::appInit('agora'); if (!$registry->isAdmin()) { - header('Location: ' . Horde::applicationUrl('forums.php')); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Set up the messages object. */ @@ -24,9 +23,7 @@ $scope = Horde_Util::getFormData('scope', 'agora'); $messages = &Agora_Messages::singleton($scope); if ($messages instanceof PEAR_Error) { $notification->push($messages->getMessage(), 'horde.warning'); - $url = Horde::applicationUrl('forums.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Moderator action */ @@ -39,16 +36,14 @@ if ($action) { $notification->push($result->getMessage(), 'horde.error'); } - header('Location: ' . Horde::applicationUrl('moderators.php', true)); - exit; + Horde::applicationUrl('moderators.php', true)->redirect(); } /* Get the list of forums. */ $forums_list = $messages->getForums(0, true, 'forum_name'); if ($forums_list instanceof PEAR_Error) { $notification->push($forums_list->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl('forums.php', true)); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Add delete links to moderators */ diff --git a/agora/search.php b/agora/search.php index e03be900e..b32a2352e 100644 --- a/agora/search.php +++ b/agora/search.php @@ -40,8 +40,7 @@ if ($form->isSubmitted() || $thread_page != null) { $searchResults = $messages->search($info, $sort_by, $sort_dir, $thread_start, $thread_per_page); if ($searchResults instanceof PEAR_Error) { $notification->push($searchResults->getMessage(), 'horde.error'); - header('Location:' . Horde::applicationUrl('search.php')); - exit; + Horde::applicationUrl('search.php')->redirect(); } if ($searchResults['total'] > count($searchResults['results'])) { diff --git a/agora/threads.php b/agora/threads.php index e300818c5..0606cadbd 100644 --- a/agora/threads.php +++ b/agora/threads.php @@ -17,16 +17,14 @@ Horde_Registry::appInit('agora', array('authentication' => 'none', 'cli' => true /* Make sure we have a forum id. */ list($forum_id, , $scope) = Agora::getAgoraId(); if (empty($forum_id)) { - header('Location: ' . Horde::applicationUrl('forums.php', true)); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Check if this is a valid thread, otherwise show the forum list. */ $threads = &Agora_Messages::singleton($scope, $forum_id); if ($threads instanceof PEAR_Error) { $notification->push(sprintf(_("Could not list threads. %s"), $threads->getMessage()), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('forums.php', true)); - exit; + Horde::applicationUrl('forums.php', true)->redirect(); } /* Which thread page are we on? Default to page 0. */ @@ -45,9 +43,9 @@ $sort_dir = Agora::getSortDir('threads'); $threads_list = $threads->getThreads(0, false, $sort_by, $sort_dir, false, '', null, $thread_start, $threads_per_page); if ($threads_list instanceof PEAR_Error) { $notification->push($threads_list->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl('forums.php', true)); - exit; -} elseif (empty($threads_list)) { + Horde::applicationUrl('forums.php', true)->redirect(); +} +if (empty($threads_list)) { $threads_count = 0; } else { $threads_count = $threads->_forum['thread_count']; diff --git a/ansel/gallery/sort.php b/ansel/gallery/sort.php index d2f9a518c..e743d90d2 100644 --- a/ansel/gallery/sort.php +++ b/ansel/gallery/sort.php @@ -28,8 +28,7 @@ try { 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('view' => 'List'), true)); - exit; + Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); } $style = $gallery->getStyle(); diff --git a/babel/edit.php b/babel/edit.php index fa824fb4c..12de055f1 100644 --- a/babel/edit.php +++ b/babel/edit.php @@ -66,10 +66,7 @@ if ($app && Horde_Util::getFormData('submitbutton') == _("Save")) { $po->save($pofile); if (Horde_Util::getFormData('url') == 'view') { - $url = Horde::applicationUrl('view.php'); - $url = Horde_Util::addParameter($url, array('module' => $app)); - header('Location: ' . $url); - exit; + Horde::applicationUrl('view.php')->add('module' => $app)->redirect(); } } } diff --git a/babel/upload.php b/babel/upload.php index 69d4ebfcb..2a6468c91 100644 --- a/babel/upload.php +++ b/babel/upload.php @@ -46,10 +46,8 @@ if (Horde_Util::getFormData('submitbutton') == _("Upload")) { $cmd = "cp $po_file_path " . HORDE_BASE . "/$mod/po/$lang.po"; system($cmd); - $url = Horde::applicationUrl('upload.php'); // Redirect to page URL - header('Location: ' . $url); - exit; + Horde::applicationUrl('upload.php')->redirect(); } } } diff --git a/beatnik/autogenerate.php b/beatnik/autogenerate.php index ad5bc0ef1..5ba37bb28 100644 --- a/beatnik/autogenerate.php +++ b/beatnik/autogenerate.php @@ -26,15 +26,13 @@ if ($form->validate($vars)) { $result = Beatnik::autogenerate($vars); } catch (Exception $e) { $notification->push($e->getMessage(), 'horde.error'); - header('Location:' . Horde::applicationUrl('listzones.php')); - exit; + Horde::applicationUrl('listzones.php')->redirect(); } } else { $notification->push(_("Autogeneration not performed"), 'horde.warning'); } - header('Location: ' . $viewurl); - exit; + $viewurl->redirect(); } $title = _("Autogenerate"); diff --git a/beatnik/commit.php b/beatnik/commit.php index 23768b850..a115fadc8 100644 --- a/beatnik/commit.php +++ b/beatnik/commit.php @@ -49,5 +49,4 @@ foreach ($domains as $domain) { } } -header('Location: ' . $url); -exit; +$url->redirect(); diff --git a/beatnik/delete.php b/beatnik/delete.php index 0c426c091..6da1e2b20 100644 --- a/beatnik/delete.php +++ b/beatnik/delete.php @@ -25,20 +25,18 @@ if ($form->validate($vars)) { $result = $beatnik->driver->deleteRecord($info); } catch (Exception $e) { $notification->push($e->getMessage(), 'horde.error'); - header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('viewzone.php'), $info)); - exit; + Horde::applicationUrl('viewzone.php')->add($info)->redirect(); } $notification->push(_("Record deleted"), 'horde.success'); if ($info['rectype'] == 'soa') { - header('Location: ' . Horde::applicationUrl('listzones.php')); + Horde::applicationUrl('listzones.php')->redirect(); } else { - header('Location: ' . Horde::applicationUrl('viewzone.php')); + Horde::applicationUrl('viewzone.php')->redirect(); } } else { $notification->push(_("Record not deleted"), 'horde.warning'); - header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('viewzone.php'), $info)); + Horde::applicationUrl('viewzone.php')->add($info)->redirect(); } - exit; } elseif (!$form->isSubmitted() && $record) { foreach ($record as $field => $value) { $vars->set($field, $value); diff --git a/beatnik/editrec.php b/beatnik/editrec.php index e1afc6d50..2b99ee6ea 100644 --- a/beatnik/editrec.php +++ b/beatnik/editrec.php @@ -32,14 +32,12 @@ if ($form->validate($vars)) { $edit = $vars->get('id'); if ($info['rectype'] == 'soa' && !$edit) { // if added a soa redirect to the autogeneration page - $url = Horde_Util::addParameter(Horde::applicationUrl('autogenerate.php'), - array('rectype' => 'soa', 'curdomain' => $info['zonename']), false, false); + $url = Horde::applicationUrl('autogenerate.php')->add(array('rectype' => 'soa', 'curdomain' => $info['zonename'])); } else { $url = Horde::applicationUrl('viewzone.php'); } - header('Location: ' . $url); - exit; + $url->redirect(); } elseif (!$form->isSubmitted() && $record) { foreach ($record as $field => $value) { diff --git a/beatnik/lib/Driver.php b/beatnik/lib/Driver.php index fa7b395b1..03515a87f 100644 --- a/beatnik/lib/Driver.php +++ b/beatnik/lib/Driver.php @@ -165,8 +165,7 @@ class Beatnik_Driver { $zonedata = $this->getRecords($_SESSION['beatnik']['curdomain']['zonename']); } catch (Exception $e) { $notification->push($e, 'horde.error'); - header('Location:' . Horde::applicationUrl('listzones.php')); - exit; + Horde::applicationUrl('listzones.php')->redirect); } if (isset($zonedata[$rectype])) { diff --git a/beatnik/viewzone.php b/beatnik/viewzone.php index 5acf527f8..b99c4aa17 100644 --- a/beatnik/viewzone.php +++ b/beatnik/viewzone.php @@ -13,8 +13,7 @@ try { $zonedata = $beatnik->driver->getRecords($_SESSION['beatnik']['curdomain']['zonename']); } catch (Exception $e) { $notification->push($e, 'horde.error'); - header('Location:' . Horde::applicationUrl('listzones.php')); - exit; + Horde::applicationUrl('listzones.php')->redirect(); } $title = $_SESSION['beatnik']['curdomain']['zonename']; diff --git a/chora/cvsgraph.php b/chora/cvsgraph.php index 5be547f11..a341b0f3a 100644 --- a/chora/cvsgraph.php +++ b/chora/cvsgraph.php @@ -17,8 +17,7 @@ Horde_Registry::appInit('chora'); // Exit if cvsgraph isn't active or it's not supported. if (empty($conf['paths']['cvsgraph']) || !$VC->hasFeature('branches')) { - header('Location: ' . Chora::url('browsefile', $where)); - exit; + Chora::url('browsefile', $where)->redirect(); } if (!is_file($fullname . ',v')) { diff --git a/chora/history.php b/chora/history.php index 6e2a5ece6..e73245303 100644 --- a/chora/history.php +++ b/chora/history.php @@ -17,8 +17,7 @@ Chora::fatal('History display is currently broken', '500 Internal Server Error') /* Exit if it's not supported. */ if (!$VC->hasFeature('branches')) { - header('Location: ' . Chora::url('browsefile', $where)); - exit; + Chora::url('browsefile', $where)->redirect(); } $colset = array('#ccdeff', '#ecf', '#fec', '#efc', '#cfd', '#dcdba0'); diff --git a/chora/patchsets.php b/chora/patchsets.php index 7bc7196c0..b240d3d74 100644 --- a/chora/patchsets.php +++ b/chora/patchsets.php @@ -18,8 +18,7 @@ Horde_Registry::appInit('chora'); // Exit if patchset feature is not available. if (!$GLOBALS['VC']->hasFeature('patchsets')) { - header('Location: ' . Chora::url('browsefile', $where)); - exit; + Chora::url('browsefile', $where)->redirect(); } $ps_opts = array(); diff --git a/fima/account.php b/fima/account.php index 62306942a..be7ead928 100644 --- a/fima/account.php +++ b/fima/account.php @@ -14,8 +14,7 @@ $vars = Horde_Variables::getDefaultVariables(); /* Redirect to the account list if no action has been requested. */ $actionID = $vars->get('actionID'); if (is_null($actionID)) { - header('Location: ' . Horde::applicationUrl('accounts.php', true)); - exit; + Horde::applicationUrl('accounts.php', true)->redirect(); } /* Get ledger. */ @@ -23,8 +22,7 @@ $ledger = Fima::getActiveLedger(); $share = &$GLOBALS['fima_shares']->getShare($ledger); if (is_a($share, 'PEAR_Error')) { $notification->push(sprintf(_("Access denied on account: %s"), $share->getMessage()), 'horde.error'); - header('Location: ' . Horde::applicationUrl('accounts.php', true)); - exit; + Horde::applicationUrl('accounts.php', true)->redirect(); } $ledger_name = $share->get('name'); @@ -83,8 +81,7 @@ case 'modify_account': } /* Return to the accounts. */ - header('Location: ' . Horde::applicationUrl('accounts.php', true)); - exit; + Horde::applicationUrl('accounts.php', true)->redirect(); case 'save_account': if ($vars->get('submitbutton') == _("Delete this account")) { @@ -102,8 +99,7 @@ case 'save_account': $form->getInfo($vars, $info); if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $notification->push(sprintf(_("Access denied saving account to %s."), $share->get('name')), 'horde.error'); - header('Location: ' . Horde::applicationUrl('accounts.php', true)); - exit; + Horde::applicationUrl('accounts.php', true)->redirect(); } $storage = &Fima_Driver::singleton($ledger); @@ -159,10 +155,9 @@ case 'save_account': /* Return to the accounts. */ if ($vars->get('submitbutton') == _("Save and New")) { header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('account.php', true), array('account' => $vars->get('parent_id'), 'actionID' => 'add_account'), null, false)); - } else { - header('Location: ' . Horde::applicationUrl('accounts.php', true)); + exit; } - exit; + Horde::applicationUrl('accounts.php', true)->redirect(); } break; @@ -186,8 +181,7 @@ case 'delete_account': } /* Return to the accounts. */ - header('Location: ' . Horde::applicationUrl('accounts.php', true)); - exit; + Horde::applicationUrl('accounts.php', true)->redirect(); case 'purge_account': if ($vars->get('submitbutton') == _("Edit this account")) { @@ -205,8 +199,7 @@ case 'purge_account': $form->getInfo($vars, $info); if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) { $notification->push(sprintf(_("Access denied deleting account from %s."), $share->get('name')), 'horde.error'); - header('Location: ' . Horde::applicationUrl('accounts.php', true)); - exit; + Horde::applicationUrl('accounts.php', true)->redirect(); } $storage = &Fima_Driver::singleton($ledger); @@ -220,15 +213,13 @@ case 'purge_account': } else { $notification->push(sprintf(_("Deleted %s."), trim($info['number_new'] . ' ' . $info['name'])), 'horde.success'); /* Return to the accounts. */ - header('Location: ' . Horde::applicationUrl('accounts.php', true)); - exit; + Horde::applicationUrl('accounts.php', true)->redirect(); } break; default: - header('Location: ' . Horde::applicationUrl('accounts.php', true)); - exit; + Horde::applicationUrl('accounts.php', true)->redirect(); } $title = $form->getTitle(); diff --git a/fima/ledgers/create.php b/fima/ledgers/create.php index 2587c810d..80d451429 100644 --- a/fima/ledgers/create.php +++ b/fima/ledgers/create.php @@ -13,8 +13,7 @@ require_once FIMA_BASE . '/lib/Forms/CreateLedger.php'; // Exit if this isn't an authenticated user or if the user can't // create new task lists (default share is locked). if (!$GLOBALS['registry']->getAuth() || $prefs->isLocked('active_ledger')) { - header('Location: ' . Horde::applicationUrl('postings.php', true)); - exit; + Horde::applicationUrl('postings.php', true)->redirect(); } $vars = Horde_Variables::getDefaultVariables(); @@ -29,8 +28,7 @@ if ($form->validate($vars)) { $notification->push(sprintf(_("The ledger \"%s\" has been created."), $vars->get('name')), 'horde.success'); } - header('Location: ' . Horde::applicationUrl('ledgers/', true)); - exit; + Horde::applicationUrl('ledgers/', true)->redirect(); } $title = $form->getTitle(); diff --git a/fima/ledgers/delete.php b/fima/ledgers/delete.php index 94398c16c..3634b2deb 100644 --- a/fima/ledgers/delete.php +++ b/fima/ledgers/delete.php @@ -12,27 +12,24 @@ require_once FIMA_BASE . '/lib/Forms/DeleteLedger.php'; // Exit if this isn't an authenticated user. if (!$GLOBALS['registry']->getAuth()) { - header('Location: ' . Horde::applicationUrl('postings.php', true)); - exit; + Horde::applicationUrl('postings.php', true)->redirect(); } $vars = Horde_Variables::getDefaultVariables(); $ledger_id = $vars->get('l'); if ($ledger_id == $GLOBALS['registry']->getAuth()) { $notification->push(_("This ledger cannot be deleted."), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('ledgers/', true)); - exit; + Horde::applicationUrl('ledgers/', true)->redirect(); } $ledger = $fima_shares->getShare($ledger_id); if (is_a($ledger, 'PEAR_Error')) { $notification->push($ledger, 'horde.error'); - header('Location: ' . Horde::applicationUrl('ledgers/', true)); - exit; -} elseif ($ledger->get('owner') != $GLOBALS['registry']->getAuth()) { + Horde::applicationUrl('ledgers/', true)->redirect(); +} +if ($ledger->get('owner') != $GLOBALS['registry']->getAuth()) { $notification->push(_("You are not allowed to delete this ledger."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('ledgers/', true)); - exit; + Horde::applicationUrl('ledgers/', true)->redirect(); } $form = new Fima_DeleteLedgerForm($vars, $ledger); @@ -46,8 +43,7 @@ if ($form->validate(new Horde_Variables($_POST))) { $notification->push(sprintf(_("The ledger \"%s\" has been deleted."), $ledger->get('name')), 'horde.success'); } - header('Location: ' . Horde::applicationUrl('ledgers/', true)); - exit; + Horde::applicationUrl('ledgers/', true)->redirect(); } $title = $form->getTitle(); diff --git a/fima/ledgers/edit.php b/fima/ledgers/edit.php index c606e04e0..782b4e892 100644 --- a/fima/ledgers/edit.php +++ b/fima/ledgers/edit.php @@ -12,20 +12,18 @@ require_once FIMA_BASE . '/lib/Forms/EditLedger.php'; // Exit if this isn't an authenticated user. if (!$GLOBALS['registry']->getAuth()) { - header('Location: ' . Horde::applicationUrl('postings.php', true)); - exit; + Horde::applicationUrl('postings.php', true)->redirect(); } $vars = Horde_Variables::getDefaultVariables(); $ledger = $fima_shares->getShare($vars->get('l')); if (is_a($ledger, 'PEAR_Error')) { $notification->push($ledger, 'horde.error'); - header('Location: ' . Horde::applicationUrl('ledgers/', true)); - exit; -} elseif ($ledger->get('owner') != $GLOBALS['registry']->getAuth()) { + Horde::applicationUrl('ledgers/', true)->redirect(); +} +if ($ledger->get('owner') != $GLOBALS['registry']->getAuth()) { $notification->push(_("You are not allowed to change this ledger."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('ledgers/', true)); - exit; + Horde::applicationUrl('ledgers/', true)->redirect(); } $form = new Fima_EditLedgerForm($vars, $ledger); @@ -43,8 +41,7 @@ if ($form->validate($vars)) { } } - header('Location: ' . Horde::applicationUrl('ledgers/', true)); - exit; + Horde::applicationUrl('ledgers/', true)->redirect(); } $vars->set('name', $ledger->get('name')); diff --git a/fima/postings.php b/fima/postings.php index 00d6c73ff..5e138ff26 100644 --- a/fima/postings.php +++ b/fima/postings.php @@ -169,9 +169,9 @@ case 'save_postings': $share = &$GLOBALS['fima_shares']->getShare($ledger); if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $notification->push(sprintf(_("Access denied saving postings to %s."), $share->get('name')), 'horde.error'); - header('Location: ' . Horde::applicationUrl('postings.php', true)); - exit; - } elseif ($postingset !== null) { + Horde::applicationUrl('postings.php', true)->redirect(); + } + if ($postingset !== null) { $pageOb['mode'] = 'edit'; $title = _("Edit Postings"); $posting_owner = $ledger; @@ -267,13 +267,11 @@ case 'save_postings': $notification->push(sprintf(_("%d postings not saved."), count($postings)), 'horde.error'); } else { /* Return to the posting list. */ - header('Location: ' . Horde::applicationUrl('postings.php', true)); - exit; + Horde::applicationUrl('postings.php', true)->redirect(); } } else { /* Return to the posting list. */ - header('Location: ' . Horde::applicationUrl('postings.php', true)); - exit; + Horde::applicationUrl('postings.php', true)->redirect(); } break; @@ -284,9 +282,9 @@ case 'delete_postings': $share = &$GLOBALS['fima_shares']->getShare($ledger); if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) { $notification->push(sprintf(_("Access denied deleting postings from %s."), $share->get('name')), 'horde.error'); - header('Location: ' . Horde::applicationUrl('postings.php', true)); - exit; - } elseif ($postingset !== null) { + Horde::applicationUrl('postings.php', true)->redirect(); + } + if ($postingset !== null) { $storage = &Fima_Driver::singleton($ledger); $delcount = 0; foreach($postingset as $index => $posting_id) { @@ -304,9 +302,7 @@ case 'delete_postings': } /* Return to the posting list. */ - header('Location: ' . Horde::applicationUrl('postings.php', true)); - exit; - break; + Horde::applicationUrl('postings.php', true)->redirect(); case 'update_postings': /* Get the form values. */ @@ -315,9 +311,9 @@ case 'update_postings': $share = &$GLOBALS['fima_shares']->getShare($ledger); if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $notification->push(sprintf(_("Access denied shifting postings in %s."), $share->get('name')), 'horde.error'); - header('Location: ' . Horde::applicationUrl('postings.php', true)); - exit; - } elseif ($postingset !== null) { + Horde::applicationUrl('postings.php', true)->redirect(); + } + if ($postingset !== null) { $posting_type = Horde_Util::getFormData('type'); $posting_asset = Horde_Util::getFormData('asset'); $posting_account = Horde_Util::getFormData('account'); @@ -342,161 +338,155 @@ case 'update_postings': } /* Return to the posting list. */ - header('Location: ' . Horde::applicationUrl('postings.php', true)); - exit; - break; + Horde::applicationUrl('postings.php', true)->redirect(); case 'copymove_postings': $share = &$GLOBALS['fima_shares']->getShare($ledger); if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $notification->push(sprintf(_("Access denied transfering postings in %s."), $share->get('name')), 'horde.error'); - header('Location: ' . Horde::applicationUrl('postings.php', true)); - exit; - } elseif (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE) && (!Horde_Util::getFormData('keep') || Horde_Util::getFormData('delete'))) { + Horde::applicationUrl('postings.php', true)->redirect(); + } + if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE) && (!Horde_Util::getFormData('keep') || Horde_Util::getFormData('delete'))) { $notification->push(sprintf(_("Access denied transfering postings in %s."), $share->get('name')), 'horde.error'); - header('Location: ' . Horde::applicationUrl('postings.php', true)); - exit; - } else { - $type_from = Horde_Util::getFormData('type_from'); - $period_from = Horde_Util::getFormData('period_from'); - $keep = Horde_Util::getFormData('keep'); - $summarize = Horde_Util::getFormData('summarize'); - $summarize_account = Horde_Util::getFormData('summarize_post_account'); - $type_to = Horde_Util::getFormData('type_to'); - $period_to = Horde_Util::getFormData('period_to'); - $delete = Horde_Util::getFormData('delete'); - - $period_from_start = mktime(0, 0, 0, ($period_from['month'] === '') ? 1 : $period_from['month'], 1, (int)$period_from['year']); - $period_from_end = mktime(0, 0, 0, ($period_from['month'] === '') ? 12 : $period_from['month'] + 1, ($period_from['month'] === '') ? 31 : 0, (int)$period_from['year']); - $period_to_start = mktime(0, 0, 0, ($period_to['month'] === '') ? 1 : $period_to['month'], 1, (int)$period_to['year']); - $period_to_end = mktime(0, 0, 0, ($period_to['month'] === '') ? 12 : $period_to['month'] + 1, ($period_to['month'] === '') ? 31 : 0, (int)$period_to['year']); - - $storage = &Fima_Driver::singleton($ledger); - - /* Delete existing. */ - if ($delete) { - $transferfilters = array(array('type', $type_to), - array('date', $period_to_start, '>='), - array('date', $period_to_end, '<=')); - $postings = Fima::listPostings($transferfilters); - $delcount = 0; - foreach ($postings as $postingId => $posting) { - $result = $storage->deletePosting($postingId); - if (is_a($result, 'PEAR_Error')) { - $notification->push(sprintf(_("There was a problem deleting an existing posting: %s"), - $result->getMessage()), 'horde.error'); - } else { - $delcount++; - } - } - if ($delcount > 0) { - $notification->push(sprintf(_("Deleted %d existing postings."), $delcount), 'horde.success'); + Horde::applicationUrl('postings.php', true)->redirect(); + } + $type_from = Horde_Util::getFormData('type_from'); + $period_from = Horde_Util::getFormData('period_from'); + $keep = Horde_Util::getFormData('keep'); + $summarize = Horde_Util::getFormData('summarize'); + $summarize_account = Horde_Util::getFormData('summarize_post_account'); + $type_to = Horde_Util::getFormData('type_to'); + $period_to = Horde_Util::getFormData('period_to'); + $delete = Horde_Util::getFormData('delete'); + + $period_from_start = mktime(0, 0, 0, ($period_from['month'] === '') ? 1 : $period_from['month'], 1, (int)$period_from['year']); + $period_from_end = mktime(0, 0, 0, ($period_from['month'] === '') ? 12 : $period_from['month'] + 1, ($period_from['month'] === '') ? 31 : 0, (int)$period_from['year']); + $period_to_start = mktime(0, 0, 0, ($period_to['month'] === '') ? 1 : $period_to['month'], 1, (int)$period_to['year']); + $period_to_end = mktime(0, 0, 0, ($period_to['month'] === '') ? 12 : $period_to['month'] + 1, ($period_to['month'] === '') ? 31 : 0, (int)$period_to['year']); + + $storage = &Fima_Driver::singleton($ledger); + + /* Delete existing. */ + if ($delete) { + $transferfilters = array(array('type', $type_to), + array('date', $period_to_start, '>='), + array('date', $period_to_end, '<=')); + $postings = Fima::listPostings($transferfilters); + $delcount = 0; + foreach ($postings as $postingId => $posting) { + $result = $storage->deletePosting($postingId); + if (is_a($result, 'PEAR_Error')) { + $notification->push(sprintf(_("There was a problem deleting an existing posting: %s"), + $result->getMessage()), 'horde.error'); + } else { + $delcount++; } } + if ($delcount > 0) { + $notification->push(sprintf(_("Deleted %d existing postings."), $delcount), 'horde.success'); + } + } - /* Copy postings. */ - $transferfilters = array(array('type', $type_from), - array('date', $period_from_start, '>='), - array('date', $period_from_end, '<=')); - $postings = Fima::listPostings($transferfilters); - - if ($summarize != 'none') { - $accounts = Fima::listAccounts(); - $postingscopy = array(); - - foreach ($postings as $postingId => $posting) { - $asset = (isset($accounts[$posting['asset']])) - ? (($accounts[$posting['asset']]['parent_id'] !== null) ? $accounts[$posting['asset']]['parent_id'] : $accounts[$posting['asset']]['account_id']) - : $posting['asset']; - $account = (isset($accounts[$posting['account']])) - ? (($accounts[$posting['account']]['parent_id'] !== null) ? $accounts[$posting['account']]['parent_id'] : $accounts[$posting['account']]['account_id']) - : $posting['account']; + /* Copy postings. */ + $transferfilters = array(array('type', $type_from), + array('date', $period_from_start, '>='), + array('date', $period_from_end, '<=')); + $postings = Fima::listPostings($transferfilters); - if ($summarize == 'combine') { - $copyId = $asset . '_' . $account . '_' . strftime('%Y%m', $posting['date']); + if ($summarize != 'none') { + $accounts = Fima::listAccounts(); + $postingscopy = array(); - if (isset($postingscopy[$copyId])) { - $postingscopy[$copyId]['amount'] += $posting['amount']; - } else { - $postingscopy[$copyId] = $posting; - $postingscopy[$copyId]['date'] = mktime(0, 0, 0, ($period_to['month'] === '') ? strftime('%m', $posting['date']) : $period_to['month'], 1, (int)$period_to['year']); - $postingscopy[$copyId]['asset'] = $asset; - $postingscopy[$copyId]['account'] = $account; - $postingscopy[$copyId]['eo'] = 0; - $postingscopy[$copyId]['desc'] = _("Summarized"); - } - } elseif ($summarize == 'post') { - $copyIdAsset = $asset . '_' . strftime('%Y%m', $posting['date']); - $copyIdAccount = $account . '_' . strftime('%Y%m', $posting['date']); + foreach ($postings as $postingId => $posting) { + $asset = (isset($accounts[$posting['asset']])) + ? (($accounts[$posting['asset']]['parent_id'] !== null) ? $accounts[$posting['asset']]['parent_id'] : $accounts[$posting['asset']]['account_id']) + : $posting['asset']; + $account = (isset($accounts[$posting['account']])) + ? (($accounts[$posting['account']]['parent_id'] !== null) ? $accounts[$posting['account']]['parent_id'] : $accounts[$posting['account']]['account_id']) + : $posting['account']; + + if ($summarize == 'combine') { + $copyId = $asset . '_' . $account . '_' . strftime('%Y%m', $posting['date']); + + if (isset($postingscopy[$copyId])) { + $postingscopy[$copyId]['amount'] += $posting['amount']; + } else { + $postingscopy[$copyId] = $posting; + $postingscopy[$copyId]['date'] = mktime(0, 0, 0, ($period_to['month'] === '') ? strftime('%m', $posting['date']) : $period_to['month'], 1, (int)$period_to['year']); + $postingscopy[$copyId]['asset'] = $asset; + $postingscopy[$copyId]['account'] = $account; + $postingscopy[$copyId]['eo'] = 0; + $postingscopy[$copyId]['desc'] = _("Summarized"); + } + } elseif ($summarize == 'post') { + $copyIdAsset = $asset . '_' . strftime('%Y%m', $posting['date']); + $copyIdAccount = $account . '_' . strftime('%Y%m', $posting['date']); - if (isset($postingscopy[$copyIdAsset])) { - $postingscopy[$copyIdAsset]['amount'] += $posting['amount']; - } else { - $postingscopy[$copyIdAsset] = $posting; - $postingscopy[$copyIdAsset]['date'] = mktime(0, 0, 0, ($period_to['month'] === '') ? strftime('%m', $posting['date']) : $period_to['month'], 1, (int)$period_to['year']); - $postingscopy[$copyIdAsset]['asset'] = $asset; - $postingscopy[$copyIdAsset]['account'] = $summarize_account; - $postingscopy[$copyIdAsset]['eo'] = 0; - $postingscopy[$copyIdAsset]['desc'] = _("Summarized"); - } + if (isset($postingscopy[$copyIdAsset])) { + $postingscopy[$copyIdAsset]['amount'] += $posting['amount']; + } else { + $postingscopy[$copyIdAsset] = $posting; + $postingscopy[$copyIdAsset]['date'] = mktime(0, 0, 0, ($period_to['month'] === '') ? strftime('%m', $posting['date']) : $period_to['month'], 1, (int)$period_to['year']); + $postingscopy[$copyIdAsset]['asset'] = $asset; + $postingscopy[$copyIdAsset]['account'] = $summarize_account; + $postingscopy[$copyIdAsset]['eo'] = 0; + $postingscopy[$copyIdAsset]['desc'] = _("Summarized"); + } - if (isset($postingscopy[$copyIdAccount])) { - $postingscopy[$copyIdAccount]['amount'] += $posting['amount']; - } else { - $postingscopy[$copyIdAccount] = $posting; - $postingscopy[$copyIdAccount]['date'] = mktime(0, 0, 0, ($period_to['month'] === '') ? strftime('%m', $posting['date']) : $period_to['month'], 1, (int)$period_to['year']); - $postingscopy[$copyIdAccount]['asset'] = $summarize_account; - $postingscopy[$copyIdAccount]['account'] = $account; - $postingscopy[$copyIdAccount]['eo'] = 0; - $postingscopy[$copyIdAccount]['desc'] = _("Summarized"); - } + if (isset($postingscopy[$copyIdAccount])) { + $postingscopy[$copyIdAccount]['amount'] += $posting['amount']; + } else { + $postingscopy[$copyIdAccount] = $posting; + $postingscopy[$copyIdAccount]['date'] = mktime(0, 0, 0, ($period_to['month'] === '') ? strftime('%m', $posting['date']) : $period_to['month'], 1, (int)$period_to['year']); + $postingscopy[$copyIdAccount]['asset'] = $summarize_account; + $postingscopy[$copyIdAccount]['account'] = $account; + $postingscopy[$copyIdAccount]['eo'] = 0; + $postingscopy[$copyIdAccount]['desc'] = _("Summarized"); } } - } else { - $postingscopy = &$postings; - foreach ($postingscopy as $postingId => $posting) { - $postingscopy[$postingId]['date'] = mktime(0, 0, 0, ($period_to['month'] === '') ? strftime('%m', $posting['date']) : $period_to['month'], strftime('%d', $posting['date']), (int)$period_to['year']); - } } - - $addcount = 0; + } else { + $postingscopy = &$postings; foreach ($postingscopy as $postingId => $posting) { - $result = $storage->addPosting($type_to, $posting['date'], $posting['asset'], $posting['account'], - $posting['eo'], $posting['amount'], $posting['desc']); + $postingscopy[$postingId]['date'] = mktime(0, 0, 0, ($period_to['month'] === '') ? strftime('%m', $posting['date']) : $period_to['month'], strftime('%d', $posting['date']), (int)$period_to['year']); + } + } - // Check our results. + $addcount = 0; + foreach ($postingscopy as $postingId => $posting) { + $result = $storage->addPosting($type_to, $posting['date'], $posting['asset'], $posting['account'], + $posting['eo'], $posting['amount'], $posting['desc']); + + // Check our results. + if (is_a($result, 'PEAR_Error')) { + $notification->push(sprintf(_("There was a problem saving the posting: %s."), $result->getMessage()), 'horde.error'); + } else { + $addcount++; + } + } + if ($addcount > 0) { + $notification->push(sprintf($summarize ? _("Summarized %d postings.") : _("Transfered %d postings."), $addcount), 'horde.success'); + } + + /* Delete original postings. */ + if (!$keep) { + $delcount = 0; + foreach ($postings as $postingId => $posting) { + $result = $storage->deletePosting($postingId); if (is_a($result, 'PEAR_Error')) { - $notification->push(sprintf(_("There was a problem saving the posting: %s."), $result->getMessage()), 'horde.error'); + $notification->push(sprintf(_("There was a problem deleting an original posting: %s"), + $result->getMessage()), 'horde.error'); } else { - $addcount++; + $delcount++; } } - if ($addcount > 0) { - $notification->push(sprintf($summarize ? _("Summarized %d postings.") : _("Transfered %d postings."), $addcount), 'horde.success'); - } - - /* Delete original postings. */ - if (!$keep) { - $delcount = 0; - foreach ($postings as $postingId => $posting) { - $result = $storage->deletePosting($postingId); - if (is_a($result, 'PEAR_Error')) { - $notification->push(sprintf(_("There was a problem deleting an original posting: %s"), - $result->getMessage()), 'horde.error'); - } else { - $delcount++; - } - } - if ($delcount > 0) { - $notification->push(sprintf(_("Deleted %d original postings."), $delcount), 'horde.success'); - } + if ($delcount > 0) { + $notification->push(sprintf(_("Deleted %d original postings."), $delcount), 'horde.success'); } } /* Return to the posting list. */ - header('Location: ' . Horde::applicationUrl('postings.php', true)); - exit; - break; + Horde::applicationUrl('postings.php', true)->redirect(); default: break; diff --git a/folks/account/resetpassword.php b/folks/account/resetpassword.php index 6849e6689..323abada4 100644 --- a/folks/account/resetpassword.php +++ b/folks/account/resetpassword.php @@ -30,8 +30,7 @@ function _getCAPTCHA($new = false) // We are already logged if ($registry->isAuthenticated()) { - header('Location: ' . Folks::getUrlFor('user', $GLOBALS['registry']->getAuth())); - exit; + Folks::getUrlFor('user', $GLOBALS['registry']->getAuth())->redirect(); } // Make sure auth backend allows passwords to be reset. diff --git a/folks/config/hooks.php.dist b/folks/config/hooks.php.dist index d49051e08..9f2346b63 100644 --- a/folks/config/hooks.php.dist +++ b/folks/config/hooks.php.dist @@ -219,8 +219,9 @@ class Folks_Hooks require $GLOBALS['registry']->get('fileroot', 'gollem') . '/redirect.php'; exit; } else { - header('Location: ' . $GLOBALS['registry']->link('wiki/show', array('page' => 'PaidFiles'))); - exit; + $GLOBALS['registry'] + ->link('wiki/show', array('page' => 'PaidFiles')) + ->redirect(); } break; diff --git a/folks/edit/activity.php b/folks/edit/activity.php index 7a1b9392c..31101df31 100644 --- a/folks/edit/activity.php +++ b/folks/edit/activity.php @@ -26,8 +26,7 @@ if ($activity_scope && $activity_date) { $notification->push($result); } else { $notification->push(_("Activity successfully deleted"), 'horde.success'); - header('Location: ' . Horde::applicationUrl('edit/activity.php')); - exit; + Horde::applicationUrl('edit/activity.php')->redirect(); } } @@ -38,16 +37,14 @@ if ($form->validate()) { $notification->push($result); } else { $notification->push(_("Activity successfully posted"), 'horde.success'); - header('Location: ' . Horde::applicationUrl('edit/activity.php')); - exit; + Horde::applicationUrl('edit/activity.php')->redirect(); } } $activities = $folks_driver->getActivity($GLOBALS['registry']->getAuth()); if ($activities instanceof PEAR_Error) { $notification->push($activities); - header('Location: ' . Folks::getUrlFor('list', 'list')); - exit; + Folks::getUrlFor('list', 'list')->redirect(); } $delete_url = Horde::applicationUrl('edit/activity.php'); diff --git a/folks/edit/comments.php b/folks/edit/comments.php index 196c3aa2f..7caac6493 100644 --- a/folks/edit/comments.php +++ b/folks/edit/comments.php @@ -19,8 +19,7 @@ $title = _("Comments"); $profile = $folks_driver->getProfile(); if ($profile instanceof PEAR_Error) { $notification->push($profile); - header('Location: ' . Folks::getUrlFor('list', 'list')); - exit; + Folks::getUrlFor('list', 'list')->redirect(); } $comments = array( diff --git a/folks/edit/edit.php b/folks/edit/edit.php index 6b3a4bb8a..3fc31e8e8 100644 --- a/folks/edit/edit.php +++ b/folks/edit/edit.php @@ -20,8 +20,7 @@ $title = _("Edit my profile"); $profile = $folks_driver->getRawProfile($GLOBALS['registry']->getAuth()); if ($profile instanceof PEAR_Error) { $notification->push($profile); - header('Location: ' . Folks::getUrlFor('list', 'list')); - exit; + Folks::getUrlFor('list', 'list')->redirect(); } $form = new Horde_Form($vars, $title, 'editprofile'); @@ -69,8 +68,7 @@ if ($form->validate()) { } else { $folks_driver->logActivity(_("Updated his/her profile picture.")); } - header('Location: ' . Horde::applicationUrl('edit/edit.php')); - exit; + Horde::applicationUrl('edit/edit.php')->redirect(); } break; diff --git a/folks/edit/facebook.php b/folks/edit/facebook.php index 9220ce503..53efe7f87 100644 --- a/folks/edit/facebook.php +++ b/folks/edit/facebook.php @@ -20,8 +20,7 @@ $title = _("Facebook"); // Check FB installation if (!$conf['facebook']['enabled']) { $notification->push(sprintf(_("Could not find authorization for %s to interact with your Facebook account."), $GLOBALS['registry']->get('name', 'horde'))); - header('Location: ' . Horde::applicationUrl('user.php')); - exit; + Horde::applicationUrl('user.php')->redirect(); } // Load horde central block @@ -29,15 +28,11 @@ try { $block = $registry->call('horde/blockContent', array('horde', 'fb_summary')); } catch (Horde_Exception $e) { $notification->push($e); - header('Location: ' . Horde::applicationUrl('user.php')); - exit; + Horde::applicationUrl('user.php')->redirect(); } require FOLKS_TEMPLATES . '/common-header.inc'; require FOLKS_TEMPLATES . '/menu.inc'; - echo $tabs->render('facebook'); - echo $block; - require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/folks/edit/friends/add.php b/folks/edit/friends/add.php index 892af7d45..93ff9cd49 100644 --- a/folks/edit/friends/add.php +++ b/folks/edit/friends/add.php @@ -30,8 +30,7 @@ if ($user) { $notification->push($result); } else { $notification->push(sprintf(_("User \"%s\" was removed from your friend list."), $user), 'horde.success'); - header('Location: ' . Horde::applicationUrl('edit/friends/index.php')); - exit; + Horde::applicationUrl('edit/friends/index.php')->redirect(); } } else { $result = $friends->addFriend($user); @@ -53,12 +52,10 @@ if ($user) { } else { $notification->push(sprintf(_("A confirmation was send to \"%s\"."), $user), 'horde.warning'); } - header('Location: ' . Horde::applicationUrl('edit/friends/index.php')); - exit; + Horde::applicationUrl('edit/friends/index.php')->redirect(); } else { $notification->push(sprintf(_("User \"%s\" was added as your friend."), $user), 'horde.success'); - header('Location: ' . Horde::applicationUrl('edit/friends/index.php')); - exit; + Horde::applicationUrl('edit/friends/index.php')->redirect(); } } } @@ -66,13 +63,10 @@ if ($user) { $friend_form = new Folks_AddFriend_Form($vars, _("Add or remove user"), 'blacklist'); Horde::addScriptFile('tables.js', 'horde'); - require FOLKS_TEMPLATES . '/common-header.inc'; require FOLKS_TEMPLATES . '/menu.inc'; - echo $tabs->render('add'); require FOLKS_TEMPLATES . '/edit/header.php'; require FOLKS_TEMPLATES . '/edit/add.php'; require FOLKS_TEMPLATES . '/edit/footer.php'; - require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/folks/edit/friends/approve.php b/folks/edit/friends/approve.php index 5f2709271..ad67b8226 100644 --- a/folks/edit/friends/approve.php +++ b/folks/edit/friends/approve.php @@ -21,8 +21,7 @@ if (!$registry->isAuthenticated()) { $user = Horde_Util::getGet('user'); if (empty($user)) { $notification->push(_("You must supply a username.")); - header('Location: ' . Horde::applicationUrl('edit/friends/index.php')); - exit; + Horde::applicationUrl('edit/friends/index.php')->redirect(); } $friends = Folks_Friends::singleton(); @@ -30,8 +29,7 @@ $result = $friends->approveFriend($user); if ($result instanceof PEAR_Error) { $notification->push($result); $notification->push($result->getDebugInfo()); - header('Location: ' . Horde::applicationUrl('edit/friends/index.php')); - exit; + Horde::applicationUrl('edit/friends/index.php')->redirect(); } $notification->push(sprintf(_("User \"%s\" was confirmed as a friend."), $user), 'horde.success'); @@ -50,5 +48,4 @@ $friends->sendNotification($user, $title, $body); $link = '' . $user . ''; $folks_driver->logActivity(sprintf(_("Added user %s as a friend."), $link)); -header('Location: ' . Horde::applicationUrl('edit/friends/index.php')); -exit; +Horde::applicationUrl('edit/friends/index.php')->redirect(); diff --git a/folks/edit/friends/blacklist.php b/folks/edit/friends/blacklist.php index 1b17397ba..eb4913f63 100644 --- a/folks/edit/friends/blacklist.php +++ b/folks/edit/friends/blacklist.php @@ -30,8 +30,7 @@ if ($user) { $notification->push($result); } else { $notification->push(sprintf(_("User \"%s\" was removed from your blacklist."), $user), 'horde.success'); - header('Location: ' . Horde::applicationUrl('edit/friends/blacklist.php')); - exit; + Horde::applicationUrl('edit/friends/blacklist.php')->redirect(); } } else { $result = $friends->addBlacklisted($user); @@ -39,8 +38,7 @@ if ($user) { $notification->push($result); } else { $notification->push(sprintf(_("User \"%s\" was added to your blacklist."), $user), 'horde.success'); - header('Location: ' . Horde::applicationUrl('edit/friends/blacklist.php')); - exit; + Horde::applicationUrl('edit/friends/blacklist.php')->redirect(); } } } diff --git a/folks/edit/friends/groups.php b/folks/edit/friends/groups.php index 53daea977..c49ec4f6a 100644 --- a/folks/edit/friends/groups.php +++ b/folks/edit/friends/groups.php @@ -41,8 +41,7 @@ case 'delete': $notification->push(sprintf(_("Group \"%s\" has been deleted."), $groups[$g]), 'horde.success'); } - header('Location: ' . Horde::applicationUrl('edit/groups.php')); - exit; + Horde::applicationUrl('edit/groups.php')->redirect(); break; @@ -60,8 +59,7 @@ case 'edit': if (Horde_Util::getFormData('submitbutton') == _("Cancel")) { $notification->push(sprintf(_("Group \"%s\" has not been renamed."), $groups[$g]), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('edit/groups.php')); - exit; + Horde::applicationUrl('edit/groups.php')->redirect(); } elseif (Horde_Util::getFormData('submitbutton') == _("Rename")) { $new_name = Horde_Util::getFormData('new_name'); $result = $friends->renameGroup($g, $new_name); @@ -69,8 +67,7 @@ case 'edit': $notification->push($result); } else { $notification->push(sprintf(_("Group \"%s\" has been renamed to \"%s\"."), $groups[$g], $new_name), 'horde.success'); - header('Location: ' . Horde::applicationUrl('edit/groups.php')); - exit; + Horde::applicationUrl('edit/groups.php')->redirect(); } } @@ -101,8 +98,7 @@ default: $name = $translated[$info['translated_name']]; } $notification->push(sprintf(_("Group \"%s\" was success added."), $name), 'horde.success'); - header('Location: ' . Horde::applicationUrl('edit/groups.php')); - exit; + Horde::applicationUrl('edit/groups.php')->redirect(); } } diff --git a/folks/edit/friends/reject.php b/folks/edit/friends/reject.php index 4eeed9325..022f6dff2 100644 --- a/folks/edit/friends/reject.php +++ b/folks/edit/friends/reject.php @@ -21,16 +21,14 @@ if (!$registry->isAuthenticated()) { $user = Horde_Util::getGet('user'); if (empty($user)) { $notification->push(_("You must supply a username.")); - header('Location: ' . Horde::applicationUrl('edit/friends/index.php')); - exit; + Horde::applicationUrl('edit/friends/index.php')->redirect(); } $friends = Folks_Friends::singleton(null, array('user' => $user)); $result = $friends->removeFriend($GLOBALS['registry']->getAuth()); if ($result instanceof PEAR_Error) { $notification->push($result); - header('Location: ' . Horde::applicationUrl('edit/friends/index.php')); - exit; + Horde::applicationUrl('edit/friends/index.php')->redirect(); } $notification->push(sprintf(_("User \"%s\" was rejected as a friend."), $user), 'horde.success'); @@ -46,5 +44,4 @@ $body = sprintf(_("User %s rejected you as a friend on %s.. \nTo see to his prof $friends->sendNotification($user, $title, $body); -header('Location: ' . Horde::applicationUrl('edit/friends/index.php')); -exit; +Horde::applicationUrl('edit/friends/index.php')->redirect(); diff --git a/folks/edit/privacy.php b/folks/edit/privacy.php index f3ab1625f..05a919db9 100644 --- a/folks/edit/privacy.php +++ b/folks/edit/privacy.php @@ -20,8 +20,7 @@ $title = _("Privacy"); $profile = $folks_driver->getRawProfile($GLOBALS['registry']->getAuth()); if ($profile instanceof PEAR_Error) { $notification->push($profile); - header('Location: ' . Folks::getUrlFor('list', 'list')); - exit; + Folks::getUrlFor('list', 'list')->redirect(); } $statuses = array('public' => _("Public"), @@ -63,16 +62,13 @@ if ($form->validate()) { $notification->push($result); } else { $notification->push(_("Your data were successfully updated."), 'horde.success'); - header('Location: ' . Horde::applicationUrl('edit/privacy.php')); - exit; + Horde::applicationUrl('edit/privacy.php')->redirect(); } } require FOLKS_TEMPLATES . '/common-header.inc'; require FOLKS_TEMPLATES . '/menu.inc'; - echo $tabs->render('privacy'); $form->renderActive(null, null, null, 'post'); - require $registry->get('templates', 'horde') . '/common-footer.inc'; \ No newline at end of file diff --git a/folks/friends.php b/folks/friends.php index b4db40213..c61d63e41 100644 --- a/folks/friends.php +++ b/folks/friends.php @@ -28,8 +28,7 @@ if ($form->validate()) { $notification->push($result); } else { $notification->push(_("Activity successfully posted"), 'horde.success'); - header('Location: ' . Horde::applicationUrl('friends.php')); - exit; + Horde::applicationUrl('friends.php')->redirect(); } } @@ -62,15 +61,11 @@ $firendActivities = array_slice($firendActivities, 0, 30); $activities = $folks_driver->getActivity($GLOBALS['registry']->getAuth()); if ($activities instanceof PEAR_Error) { $notification->push($activities); - header('Location: ' . Folks::getUrlFor('list', 'list')); - exit; + Folks::getUrlFor('list', 'list')->redirect(); } Horde::addScriptFile('stripe.js', 'horde'); - require FOLKS_TEMPLATES . '/common-header.inc'; require FOLKS_TEMPLATES . '/menu.inc'; - require FOLKS_TEMPLATES . '/friends/friends.php'; - require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/folks/report.php b/folks/report.php index 02a8d7907..20b059cd7 100644 --- a/folks/report.php +++ b/folks/report.php @@ -16,8 +16,7 @@ require_once dirname(__FILE__) . '/lib/base.php'; $user = Horde_Util::getFormData('user'); if (empty($user)) { $notification->push(_("User is not selected"), 'horde.warning'); - header('Location: ' . Folks::getUrlFor('list', 'list')); - exit; + Folks::getUrlFor('list', 'list')->redirect(); } $title = _("Do you really want to report this user?"); @@ -60,8 +59,7 @@ if ($form->validate()) { } else { $notification->push(_("User was not reported."), 'horde.warning'); } - header('Location: ' . Folks::getUrlFor('user', $user)); - exit; + Folks::getUrlFor('user', $user)->redirect(); } require FOLKS_TEMPLATES . '/common-header.inc'; diff --git a/folks/save_search.php b/folks/save_search.php index e307fea40..25c5d7bed 100644 --- a/folks/save_search.php +++ b/folks/save_search.php @@ -25,8 +25,7 @@ if (Horde_Util::getFormData('submitbutton') == _("Close")) { $notification->push($result); } else { $notification->push(_("Search criteria saved successfuly"), 'horde.success'); - header('Location: ' . Horde::applicationUrl('search.php')); - exit; + Horde::applicationUrl('search.php')->redirect(); } } elseif ((Horde_Util::getGet('delete') == 1) && Horde_Util::getGet('query')) { @@ -36,8 +35,7 @@ if (Horde_Util::getFormData('submitbutton') == _("Close")) { $notification->push($result); } else { $notification->push(_("Search criteria deleted."), 'horde.success'); - header('Location: ' . Horde::applicationUrl('search.php')); - exit; + Horde::applicationUrl('search.php')->redirect(); } } diff --git a/folks/user.php b/folks/user.php index 76793925c..7dcaaae9c 100644 --- a/folks/user.php +++ b/folks/user.php @@ -18,8 +18,7 @@ $user = Horde_Util::getFormData('user', $GLOBALS['registry']->getAuth()); $profile = $folks_driver->getProfile($user); if ($profile instanceof PEAR_Error) { $notification->push($profile); - header('Location: ' . Folks::getUrlFor('list', 'list')); - exit; + Folks::getUrlFor('list', 'list')->redirect(); } // Load its friend list @@ -55,8 +54,7 @@ if ($user == $GLOBALS['registry']->getAuth()) { $notification->push($result); } else { $notification->push(_("Activity successfully posted"), 'horde.success'); - header('Location: ' . Horde::applicationUrl('user.php')); - exit; + Horde::applicationUrl('user.php')->redirect(); } } } diff --git a/framework/Block/lib/Horde/Block/Layout/Manager.php b/framework/Block/lib/Horde/Block/Layout/Manager.php index 743aae3fe..36de35eff 100644 --- a/framework/Block/lib/Horde/Block/Layout/Manager.php +++ b/framework/Block/lib/Horde/Block/Layout/Manager.php @@ -295,7 +295,7 @@ class Horde_Block_Layout_Manager extends Horde_Block_Layout if (!empty($url)) { $url = new Horde_Url($url); - header('Location: ' . strval($url->unique()->setRaw(true))); + $url->unique()->redirect(); } } diff --git a/framework/Service_Twitter/doc/twitter.php.example b/framework/Service_Twitter/doc/twitter.php.example index 2580f3b2c..d6eff8552 100644 --- a/framework/Service_Twitter/doc/twitter.php.example +++ b/framework/Service_Twitter/doc/twitter.php.example @@ -79,4 +79,4 @@ $results = $twitter->auth->getRequestToken(); $_SESSION['twitter_request_secret'] = $results->secret; // Redirect to auth url -header('Location:' . Horde::externalUrl($twitter->auth->getUserAuthorizationUrl($results), false)); +Horde::externalUrl($twitter->auth->getUserAuthorizationUrl($results), false)->redirect(); diff --git a/gollem/lib/Auth.php b/gollem/lib/Auth.php index d918169b7..ba9294ca6 100644 --- a/gollem/lib/Auth.php +++ b/gollem/lib/Auth.php @@ -124,12 +124,9 @@ class Gollem_Auth } else { $url = Horde_Auth::addLogoutParameters(self::logoutUrl()); } - $url = Horde_Util::addParameter($url, 'url', Horde::selfUrl(true, true, true), false); - header('Location: ' . $url); - exit; - } else { - return false; + $url->add('url', Horde::selfUrl(true, true, true))->redirect(); } + return false; } return true; diff --git a/gollem/permissions.php b/gollem/permissions.php index 794382271..db9b4670a 100644 --- a/gollem/permissions.php +++ b/gollem/permissions.php @@ -36,13 +36,13 @@ if ($perms->exists($backendTag)) { $result = $perms->addPermission($permission, $app); if ($result instanceof PEAR_Error) { $notification->push(sprintf(_("Unable to create backend permission: %s"), $result->getMessage()), 'horde.error'); - header('Location: ' . Horde::applicationUrl('redirect.php', true)); - exit; + Horde::applicationUrl('redirect.php', true)->redirect(); } $perm_id = $perms->getPermissionId($permission); $notification->push(sprintf(_("Created empty permissions for \"%s\". You must explicitly grant access to this backend now."), $key), 'horde.warning'); } /* Redirect to horde permissions administration interface. */ -$url = Horde_Util::addParameter($registry->get('webroot', 'horde') . '/admin/perms/edit.php', 'perm_id', $permission->getId()); -header('Location: ' . Horde::url($url, true)); +Horde::url($registry->get('webroot', 'horde') . '/admin/perms/edit.php', true) + ->add('perm_id', $permission->getId()) + ->redirect(); diff --git a/gollem/view.php b/gollem/view.php index 9bc2caab8..75f6098ba 100644 --- a/gollem/view.php +++ b/gollem/view.php @@ -21,9 +21,11 @@ $filename = Horde_Util::getFormData('file'); $type = Horde_Util::getFormData('type'); if ($driver != $GLOBALS['gollem_be']['driver']) { - $url = Horde_Util::addParameter(Horde::applicationUrl('login.php'), array('backend_key' => $driver, 'change_backend' => 1, 'url' => Horde::selfURL(true)), null, false); - header('Location: ' . $url); - exit; + Horde::applicationUrl('login.php') + ->add(array('backend_key' => $driver, + 'change_backend' => 1, + 'url' => Horde::selfURL(true))) + ->redirect(); } $stream = null; diff --git a/hermes/entry.php b/hermes/entry.php index bb3e6fe23..4da546568 100644 --- a/hermes/entry.php +++ b/hermes/entry.php @@ -69,8 +69,7 @@ default: $id = $vars->get('id'); if (!Hermes::canEditTimeslice($id)) { $notification->push(_("Access denied; user cannot modify this timeslice."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('time.php')); - exit; + Horde::applicationUrl('time.php')->redirect(); } $myhours = $hermes->driver->getHours(array('id' => $id)); if (is_array($myhours)) { diff --git a/hermes/invoicing.php b/hermes/invoicing.php index 43dca1c25..0ad2c2d08 100644 --- a/hermes/invoicing.php +++ b/hermes/invoicing.php @@ -19,16 +19,15 @@ $hours = $hermes->driver->getHours(array('billable' => true, 'submitted' => true)); if (is_a($hours, 'PEAR_Error')) { $notification->push($hours->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl('time.php')); - exit; -} elseif (empty($hours)) { + Horde::applicationUrl('time.php')->redirect(); +} +if (empty($hours)) { $notification->push(_("There is no submitted billable hours."), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('time.php')); - exit; -} elseif (!$registry->hasMethod('invoices/save')) { + Horde::applicationUrl('time.php')->redirect(); +} +if (!$registry->hasMethod('invoices/save')) { $notification->push(_("Invoicing system is not installed."), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('time.php')); - exit; + Horde::applicationUrl('time.php')->redirect(); } $headers = array( @@ -121,8 +120,7 @@ if ($form->validate()) { } } - header('Location: ' . Horde::applicationUrl('time.php')); - exit; + Horde::applicationUrl('time.php')->redirect(); } require HERMES_TEMPLATES . '/common-header.inc'; diff --git a/horde/admin/perms/edit.php b/horde/admin/perms/edit.php index 10347464c..6525e78c5 100644 --- a/horde/admin/perms/edit.php +++ b/horde/admin/perms/edit.php @@ -102,10 +102,9 @@ if ($ui->validateEditForm($info)) { $permission->updatePermissions($info); $permission->save(); $notification->push(sprintf(_("Updated \"%s\"."), $perms->getTitle($permission->getName())), 'horde.success'); - $url = Horde_Util::addParameter('admin/perms/edit.php', 'perm_id', $permission->getId()); - $url = Horde::applicationUrl($url, true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('admin/perms/edit.php', true) + ->add('perm_id', $permission->getId()) + ->redirect(); } $title = _("Permissions Administration"); diff --git a/hylax/print.php b/hylax/print.php index e088c8dab..c67f8d600 100644 --- a/hylax/print.php +++ b/hylax/print.php @@ -19,6 +19,4 @@ if (is_a($print, 'PEAR_Error')) { } /* Redirect back. */ -$url = Horde::applicationUrl($url, true); -header('Location: ' . $url); -exit; +Horde::applicationUrl($url, true)->redirect(); diff --git a/hylax/send.php b/hylax/send.php index 7ea2b8d10..577f30bd0 100644 --- a/hylax/send.php +++ b/hylax/send.php @@ -21,14 +21,10 @@ $url = $vars->get('url', 'folder.php'); $fax = $hylax->storage->getFax($fax_id); if (is_a($fax, 'PEAR_Error')) { $notification->push(sprintf(_("Could not open fax ID \"%s\". %s"), $fax_id, $fax->getMessage()), 'horde.error'); - $url = Horde::applicationUrl($url, true); - header('Location: ' . $url); - exit; + Horde::applicationUrl($url, true)->redirect(); } elseif (!empty($fax['fax_number'])) { $notification->push(sprintf(_("Fax ID \"%s\" already has a fax number set."), $fax_id), 'horde.error'); - $url = Horde::applicationUrl($url, true); - header('Location: ' . $url); - exit; + Horde::applicationUrl($url, true)->redirect(); } $title = _("Send Fax"); @@ -48,9 +44,7 @@ if ($form->validate($vars)) { } else { $notification->push(sprintf(_("Fax ID \"%s\" submitted successfully."), $info['fax_id']), 'horde.success'); } - $url = Horde::applicationUrl($url, true); - header('Location: ' . $url); - exit; + Horde::applicationUrl($url, true)->redirect(); } /* Get the preview pages. */ diff --git a/hylax/view.php b/hylax/view.php index 1619f22d3..ba2a08a79 100644 --- a/hylax/view.php +++ b/hylax/view.php @@ -27,9 +27,10 @@ if (is_a($fax, 'PEAR_Error')) { $notification->push(sprintf(_("Could not open fax ID \"%s\". %s"), $fax_id, $fax->getMessage()), 'horde.error'); if (empty($url)) { $url = Horde::applicationUrl('folder.php', true); + } else { + $url = new Horde_Url($url); } - header('Location: ' . $url); - exit; + $url->redirect(); } $title = _("View Fax"); diff --git a/ingo/blacklist.php b/ingo/blacklist.php index 944331d28..be679b8d2 100644 --- a/ingo/blacklist.php +++ b/ingo/blacklist.php @@ -17,8 +17,7 @@ Horde_Registry::appInit('ingo'); /* Redirect if blacklist is not available. */ if (!in_array(Ingo_Storage::ACTION_BLACKLIST, $_SESSION['ingo']['script_categories'])) { $notification->push(_("Blacklist is not supported in the current filtering driver."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('filters.php', true)); - exit; + Horde::applicationUrl('filters.php', true)->redirect(); } /* Get the backend. */ diff --git a/ingo/filters.php b/ingo/filters.php index 685dde6ec..427e4f655 100644 --- a/ingo/filters.php +++ b/ingo/filters.php @@ -42,15 +42,13 @@ case 'rule_disable': case 'rule_enable': if (!$edit_allowed) { $notification->push(_("You do not have permission to edit filter rules."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('filters.php', true)); - exit; + Horde::applicationUrl('filters.php', true)->redirect(); } switch ($vars->actionID) { case 'rule_delete': if (!$delete_allowed) { $notification->push(_("You do not have permission to delete filter rules."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('filters.php', true)); - exit; + Horde::applicationUrl('filters.php', true)->redirect(); } $tmp = $filters->getFilter($vars->rulenumber); @@ -116,8 +114,7 @@ case 'rule_enable': case 'settings_save': if (!$edit_allowed) { $notification->push(_("You do not have permission to edit filter rules."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('filters.php', true)); - exit; + Horde::applicationUrl('filters.php', true)->redirect(); } $prefs->setValue('show_filter_msg', $vars->show_filter_msg); $prefs->setValue('filter_seen', $vars->filter_seen); @@ -127,8 +124,7 @@ case 'settings_save': case 'apply_filters': if (!$edit_allowed) { $notification->push(_("You do not have permission to edit filter rules."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('filters.php', true)); - exit; + Horde::applicationUrl('filters.php', true)->redirect(); } $ingo_script->apply(); break; diff --git a/ingo/forward.php b/ingo/forward.php index 608064852..27fd9890f 100644 --- a/ingo/forward.php +++ b/ingo/forward.php @@ -16,8 +16,7 @@ Horde_Registry::appInit('ingo'); /* Redirect if forward is not available. */ if (!in_array(Ingo_Storage::ACTION_FORWARD, $_SESSION['ingo']['script_categories'])) { $notification->push(_("Forward is not supported in the current filtering driver."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('filters.php', true)); - exit; + Horde::applicationUrl('filters.php', true)->redirect(); } /* Get the forward object and rule. */ @@ -29,8 +28,7 @@ $fwd_rule = $filters->getRule($fwd_id); /* Load libraries. */ $vars = Horde_Variables::getDefaultVariables(); if ($vars->submitbutton == _("Return to Rules List")) { - header('Location: ' . Horde::applicationUrl('filters.php', true)); - exit; + Horde::applicationUrl('filters.php', true)->redirect(); } /* Build form. */ diff --git a/ingo/rule.php b/ingo/rule.php index a0f53660c..83bb2ce8e 100644 --- a/ingo/rule.php +++ b/ingo/rule.php @@ -23,8 +23,7 @@ if (!$perms->hasAppPermission('allow_rules')) { $message = @htmlspecialchars(_("You are not allowed to create or edit custom rules."), ENT_COMPAT, $GLOBALS['registry']->getCharset()); } $notification->push($message, 'horde.error', array('content.raw')); - header('Location: ' . Horde::applicationUrl('filters.php', true)); - exit; + Horde::applicationUrl('filters.php', true)->redirect(); } /* Load the Ingo_Script:: driver. */ @@ -34,8 +33,7 @@ $ingo_script = Ingo::loadIngoScript(); $availActions = $ingo_script->availableActions(); if (empty($availActions)) { $notification->push(_("Individual rules are not supported in the current filtering driver."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('filters.php', true)); - exit; + Horde::applicationUrl('filters.php', true)->redirect(); } /* This provides the $ingo_fields array. */ diff --git a/ingo/script.php b/ingo/script.php index 77a3b5d38..737626857 100644 --- a/ingo/script.php +++ b/ingo/script.php @@ -13,8 +13,7 @@ Horde_Registry::appInit('ingo'); /* Redirect if script updating is not available. */ if (!$_SESSION['ingo']['script_generate']) { - header('Location: ' . Horde::applicationUrl('filters.php', true)); - exit; + Horde::applicationUrl('filters.php', true)->redirect(); } $script = ''; diff --git a/ingo/spam.php b/ingo/spam.php index 999404ea6..b42cc300c 100644 --- a/ingo/spam.php +++ b/ingo/spam.php @@ -43,8 +43,7 @@ class Horde_Form_Type_ingo_folders extends Horde_Form_Type { if (!in_array(Ingo_Storage::ACTION_SPAM, $_SESSION['ingo']['script_categories'])) { $notification->push(_("Simple spam filtering is not supported in the current filtering driver."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('filters.php', true)); - exit; + Horde::applicationUrl('filters.php', true)->redirect(); } /* Get the spam object and rule. */ @@ -55,8 +54,7 @@ $spam_rule = $filters->getRule($spam_id); $vars = Horde_Variables::getDefaultVariables(); if ($vars->submitbutton == _("Return to Rules List")) { - header('Location: ' . Horde::applicationUrl('filters.php', true)); - exit; + Horde::applicationUrl('filters.php', true)->redirect(); } /* Build form. */ diff --git a/ingo/vacation.php b/ingo/vacation.php index 22d091c4a..ae2187d1c 100644 --- a/ingo/vacation.php +++ b/ingo/vacation.php @@ -16,8 +16,7 @@ Horde_Registry::appInit('ingo'); /* Redirect if vacation is not available. */ if (!in_array(Ingo_Storage::ACTION_VACATION, $_SESSION['ingo']['script_categories'])) { $notification->push(_("Vacation is not supported in the current filtering driver."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('filters.php', true)); - exit; + Horde::applicationUrl('filters.php', true)->redirect(); } /* Get vacation object and rules. */ @@ -29,8 +28,7 @@ $vac_rule = $filters->getRule($vac_id); /* Load libraries. */ $vars = Horde_Variables::getDefaultVariables(); if ($vars->submitbutton == _("Return to Rules List")) { - header('Location: ' . Horde::applicationUrl('filters.php', true)); - exit; + Horde::applicationUrl('filters.php', true)->redirect(); } /* Build form. */ diff --git a/ingo/whitelist.php b/ingo/whitelist.php index dfec2721a..8968b7766 100644 --- a/ingo/whitelist.php +++ b/ingo/whitelist.php @@ -18,8 +18,7 @@ Horde_Registry::appInit('ingo'); /* Redirect if whitelist not available. */ if (!in_array(Ingo_Storage::ACTION_WHITELIST, $_SESSION['ingo']['script_categories'])) { $notification->push(_("Whitelist is not supported in the current filtering driver."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('filters.php', true)); - exit; + Horde::applicationUrl('filters.php', true)->redirect(); } $whitelist = $ingo_storage->retrieve(Ingo_Storage::ACTION_WHITELIST); diff --git a/jonah/channels/aggregate.php b/jonah/channels/aggregate.php index 60db93aa4..feea1ffa7 100644 --- a/jonah/channels/aggregate.php +++ b/jonah/channels/aggregate.php @@ -38,8 +38,9 @@ $ids = preg_split('/:/', $channel['channel_url'], -1, PREG_SPLIT_NO_EMPTY); $channel_type = $channel['channel_type']; if ($channel_type != Jonah::AGGREGATED_CHANNEL) { $notification->push(_("This is no aggregated channel."), 'horde.error'); - header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('channels/edit.php', true), 'channel_id', $channel_id)); - exit; + Horde::applicationUrl('channels/edit.php', true) + ->add('channel_id', $channel_id) + ->redirect(); } /* Check permissions and deny if not allowed. */ @@ -82,8 +83,9 @@ if ($form->validate($vars)) { } } - header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('channels/aggregate.php', true), 'channel_id', $channel_id)); - exit; + Horde::applicationUrl('channels/aggregate.php', true) + ->add('channel_id', $channel_id) + ->redirect(); } } elseif ($vars->get('action') == 'delete') { $subchannel = $news->getChannel($vars->get('subchannel_id')); @@ -102,8 +104,9 @@ if ($form->validate($vars)) { } } - header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('channels/aggregate.php', true), 'channel_id', $channel_id)); - exit; + Horde::applicationUrl('channels/aggregate.php', true) + ->add('channel_id', $channel_id) + ->redirect(); } elseif ($vars->get('action') == 'edit') { $form->addHidden('', 'subchannel_id', 'int', false); $form->setButtons(_("Update")); diff --git a/jonah/channels/delete.php b/jonah/channels/delete.php index 0efe92e9a..61cc7b957 100644 --- a/jonah/channels/delete.php +++ b/jonah/channels/delete.php @@ -26,9 +26,7 @@ $channel_id = $vars->get('channel_id'); $channel = $news->getChannel($channel_id); if (is_a($channel, 'PEAR_Error')) { $notification->push(_("Invalid channel specified for deletion."), 'horde.message'); - $url = Horde::applicationUrl('channels/index.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('channels/index.php', true)->redirect(); } /* Check permissions and deny if not allowed. */ @@ -65,16 +63,12 @@ if ($form_submit == _("Delete")) { $notification->push(sprintf(_("There was an error deleting the channel: %s"), $delete->getMessage()), 'horde.error'); } else { $notification->push(_("The channel has been deleted."), 'horde.success'); - $url = Horde::applicationUrl('channels/index.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('channels/index.php', true)->redirect(); } } } elseif (!empty($form_submit)) { $notification->push(_("Channel has not been deleted."), 'horde.message'); - $url = Horde::applicationUrl('channels/index.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('channels/index.php', true)->redirect(); } $template = new Horde_Template(); diff --git a/jonah/channels/edit.php b/jonah/channels/edit.php index 189a96a69..2180991e9 100644 --- a/jonah/channels/edit.php +++ b/jonah/channels/edit.php @@ -69,8 +69,7 @@ if ($formname && !$changed_type) { if ($channel_type == Jonah::AGGREGATED_CHANNEL) { $notification->push(_("You can now edit the sub-feeds."), 'horde.message'); } else { - header('Location: ' . Horde::applicationUrl('channels/index.php', true)); - exit; + Horde::applicationUrl('channels/index.php', true)->redirect(); } } } diff --git a/jonah/channels/index.php b/jonah/channels/index.php index ab8684f37..2ea722205 100644 --- a/jonah/channels/index.php +++ b/jonah/channels/index.php @@ -22,9 +22,7 @@ if (!Jonah::checkPermissions('jonah:news', Horde_Perms::EDIT)) { $have_news = Jonah_News::getAvailableTypes(); if (empty($have_news)) { $notification->push(_("News is not enabled."), 'horde.warning'); - $url = Horde::applicationUrl('index.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('index.php', true)->redirect(); } $news = Jonah_News::factory(); diff --git a/jonah/delivery/html.php b/jonah/delivery/html.php index c2cfbcf87..7373e736e 100644 --- a/jonah/delivery/html.php +++ b/jonah/delivery/html.php @@ -39,9 +39,7 @@ $channel = $news->getChannel($criteria['channel_id']); if (is_a($channel, 'PEAR_Error')) { Horde::logMessage($channel, 'ERR'); $notification->push(_("Invalid channel."), 'horde.error'); - $url = Horde::applicationUrl('delivery/index.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('delivery/index.php', true)->redirect(); } $title = sprintf(_("HTML Delivery for \"%s\""), $channel['channel_name']); diff --git a/jonah/stories/delete.php b/jonah/stories/delete.php index 10132700f..eb670b26c 100644 --- a/jonah/stories/delete.php +++ b/jonah/stories/delete.php @@ -28,9 +28,7 @@ $news = Jonah_News::factory(); $channel = $news->isChannelEditable($channel_id); if (is_a($channel, 'PEAR_Error')) { $notification->push(sprintf(_("Story editing failed: %s"), $channel->getMessage()), 'horde.error'); - $url = Horde::applicationUrl('channels/index.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('channels/index.php', true)->redirect(); } /* Check permissions. */ @@ -42,9 +40,7 @@ if (!Jonah::checkPermissions(Jonah::typeToPermName($channel['channel_type']), Ho $story = $news->getStory($channel_id, $story_id); if (is_a($story, 'PEAR_Error')) { $notification->push(_("No valid story requested for deletion."), 'horde.message'); - $url = Horde::applicationUrl('channels/index.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('channels/index.php', true)->redirect(); } /* If not yet submitted set up the form vars from the fetched story. */ @@ -69,18 +65,16 @@ if ($form_submit == _("Delete")) { $notification->push(sprintf(_("There was an error deleting the story: %s"), $delete->getMessage()), 'horde.error'); } else { $notification->push(_("The story has been deleted."), 'horde.success'); - $url = Horde::applicationUrl('stories/index.php', true); - $url = Horde_Util::addParameter($url, 'channel_id', $channel_id, false); - header('Location: ' . $url); - exit; + Horde::applicationUrl('stories/index.php', true) + ->add('channel_id', $channel_id) + ->redirect(); } } } elseif (!empty($form_submit)) { $notification->push(_("Story has not been deleted."), 'horde.message'); - $url = Horde::applicationUrl('stories/index.php', true); - $url = Horde_Util::addParameter($url, 'channel_id', $channel_id, false); - header('Location: ' . $url); - exit; + Horde::applicationUrl('stories/index.php', true) + ->add('channel_id', $channel_id) + ->redirect(); } $template = new Horde_Template(); diff --git a/jonah/stories/edit.php b/jonah/stories/edit.php index 5bb7332dc..96454c63f 100644 --- a/jonah/stories/edit.php +++ b/jonah/stories/edit.php @@ -30,9 +30,7 @@ $channel_id = $vars->get('channel_id'); $channel = $news->isChannelEditable($channel_id); if (is_a($channel, 'PEAR_Error')) { $notification->push(sprintf(_("Story editing failed: %s"), $channel->getMessage()), 'horde.error'); - $url = Horde::applicationUrl('channels/index.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('channels/index.php', true)->redirect(); } /* Check permissions. */ @@ -58,9 +56,9 @@ if ($form->validate($vars)) { $notification->push(sprintf(_("There was an error saving the story: %s"), $result->getMessage()), 'horde.error'); } else { $notification->push(sprintf(_("The story \"%s\" has been saved."), $info['story_title']), 'horde.success'); - $url = Horde_Util::addParameter('stories/index.php', 'channel_id', $channel_id); - header('Location: ' . Horde::applicationUrl($url, true)); - exit; + Horde::applicationUrl('stories/index.php', true) + ->add('channel_id', $channel_id) + ->redirect(); } } diff --git a/jonah/stories/index.php b/jonah/stories/index.php index 00fad84d8..5e3b19c97 100644 --- a/jonah/stories/index.php +++ b/jonah/stories/index.php @@ -17,9 +17,7 @@ $news = Jonah_News::factory(); $channel_id = Horde_Util::getFormData('channel_id'); if (empty($channel_id)) { $notification->push(_("No channel requested."), 'horde.error'); - $url = Horde::applicationUrl('channels/index.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('channels/index.php', true)->redirect(); } $channel = $news->getChannel($channel_id); @@ -37,9 +35,7 @@ $url = Horde_Util::getFormData('url'); $stories = $news->getStories($channel_id, null, 0, !empty($refresh), null, true); if (is_a($stories, 'PEAR_Error')) { $notification->push(sprintf(_("Invalid channel requested. %s"), $stories->getMessage()), 'horde.error'); - $url = Horde::applicationUrl('channels/index.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('channels/index.php', true)->redirect(); } /* Do some state tests. */ diff --git a/jonah/stories/results.php b/jonah/stories/results.php index 53f00bc98..e3e001acc 100644 --- a/jonah/stories/results.php +++ b/jonah/stories/results.php @@ -35,18 +35,14 @@ if (!is_null($channel_id)) { /* Make sure we actually requested a tag search */ if (empty($tag_id)) { $notification->push(_("No tag requested."), 'horde.error'); - $url = Horde::applicationUrl('channels/index.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('channels/index.php', true)->redirect(); } $tag_name = array_shift($news->getTagNames(array($tag_id))); $stories = $news->searchTagsById(array($tag_id), 10, 0, $channel_ids); if (is_a($stories, 'PEAR_Error')) { $notification->push(sprintf(_("Invalid channel requested. %s"), $stories->getMessage()), 'horde.error'); - $url = Horde::applicationUrl('channels/index.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('channels/index.php', true)->redirect(); } /* Do some state tests. */ diff --git a/jonah/stories/share.php b/jonah/stories/share.php index 5e5389857..a03a57a8d 100644 --- a/jonah/stories/share.php +++ b/jonah/stories/share.php @@ -56,10 +56,9 @@ $channel_id = $vars->get('channel_id'); $story_id = $vars->get('story_id'); if (!$conf['sharing']['allow']) { - $url = Horde::applicationUrl('stories/view.php', true); - $url = Horde_Util::addParameter($url, array('story_id' => $story_id, 'channel_id' => $channel_id)); - header('Location: ' . $url); - exit; + Horde::applicationUrl('stories/view.php', true) + ->add(array('story_id' => $story_id, 'channel_id' => $channel_id)) + ->redirect(); } $story = $news->getStory($channel_id, $story_id); diff --git a/jonah/stories/view.php b/jonah/stories/view.php index 994d42f76..f75ca57e8 100644 --- a/jonah/stories/view.php +++ b/jonah/stories/view.php @@ -36,8 +36,7 @@ if (is_a($story, 'PEAR_Error')) { require $registry->get('templates', 'horde') . '/common-footer.inc'; exit; } elseif (empty($story['story_body']) && !empty($story['story_url'])) { - header('Location: ' . Horde::externalUrl($story['story_url'])); - exit; + Horde::externalUrl($story['story_url'])->redirect(); } /* Grab tag related content for entire channel */ diff --git a/koward/lib/Koward/Cli.php b/koward/lib/Koward/Cli.php index f08990f61..520863afb 100644 --- a/koward/lib/Koward/Cli.php +++ b/koward/lib/Koward/Cli.php @@ -94,8 +94,8 @@ class Koward_Cli extends Horde_Controller_Request_Base || $this->auth_handler != $this->params[':action']); } catch (Horde_Exception $e) { if ($e->getCode() == 'permission_denied') { - header('Location: ' . $this->urlFor(array('controller' => 'index', 'action' => 'login'))); - exit; + $this->urlFor(array('controller' => 'index', 'action' => 'login')) + ->redirect(); } } diff --git a/koward/lib/Koward/Controller/Application.php b/koward/lib/Koward/Controller/Application.php index d6661cba8..dcb345c03 100644 --- a/koward/lib/Koward/Controller/Application.php +++ b/koward/lib/Koward/Controller/Application.php @@ -14,8 +14,8 @@ class Koward_Controller_Application extends Horde_Controller_Base || $this->auth_handler != $this->params[':action']); } catch (Horde_Exception $e) { if ($e->getCode() == 'permission_denied') { - header('Location: ' . $this->urlFor(array('controller' => 'index', 'action' => 'login'))); - exit; + $this->urlFor(array('controller' => 'index', 'action' => 'login')) + ->redirect(); } } @@ -104,8 +104,7 @@ class Koward_Controller_Application extends Horde_Controller_Base } else { $url = $this->urlFor(array('controller' => 'index', 'action' => 'login')); } - header('Location: ' . $url); - exit; + $url->redirect(); } } } diff --git a/koward/lib/Koward/Controller/IndexController.php b/koward/lib/Koward/Controller/IndexController.php index ec6413b72..b21d2f8d7 100644 --- a/koward/lib/Koward/Controller/IndexController.php +++ b/koward/lib/Koward/Controller/IndexController.php @@ -19,8 +19,8 @@ class IndexController extends Koward_Controller_Application { $auth = $GLOBALS['registry']->getAuth(); if (!empty($auth)) { - header('Location: ' . $this->urlFor(array('controller' => 'index', 'action' => 'index'))); - exit; + $this->urlFor(array('controller' => 'index', 'action' => 'index')) + ->redirect(); } $this->title = _("Login"); @@ -46,13 +46,11 @@ class IndexController extends Koward_Controller_Application } else { $url = $this->urlFor(array('controller' => 'index', 'action' => 'index')); } - header('Location: ' . $url); - exit; - } else { - $entry = sprintf('FAILED LOGIN for %s [%s] to Horde', - Horde_Util::getFormData('horde_user'), $_SERVER['REMOTE_ADDR']); - Horde::logMessage($entry, 'ERR'); + $url->redirect(); } + $entry = sprintf('FAILED LOGIN for %s [%s] to Horde', + Horde_Util::getFormData('horde_user'), $_SERVER['REMOTE_ADDR']); + Horde::logMessage($entry, 'ERR'); } if ($reason = $this->koward->auth->getLogoutReasonString()) { @@ -68,7 +66,7 @@ class IndexController extends Koward_Controller_Application Horde::logMessage($entry, 'NOTICE'); $GLOBALS['registry']->clearAuth(); - header('Location: ' . $this->urlFor(array('controller' => 'index', 'action' => 'login'))); - exit; + $this->urlFor(array('controller' => 'index', 'action' => 'login')) + ->redirect(); } } diff --git a/koward/lib/Koward/Controller/ObjectController.php b/koward/lib/Koward/Controller/ObjectController.php index a22cf2b66..9a84b9ba0 100644 --- a/koward/lib/Koward/Controller/ObjectController.php +++ b/koward/lib/Koward/Controller/ObjectController.php @@ -115,9 +115,9 @@ class ObjectController extends Koward_Controller_Application $this->koward->notification->push(_("Failed to delete the object."), 'horde.error'); } - header('Location: ' . $this->urlFor(array('controller' => 'object', - 'action' => 'listall'))); - exit; + $this->urlFor(array('controller' => 'object', + 'action' => 'listall')) + ->redirect(); } } } catch (Exception $e) { @@ -171,11 +171,12 @@ class ObjectController extends Koward_Controller_Application $this->koward->notification->push(_("Failed to delete the object."), 'horde.error'); } - header('Location: ' . $this->urlFor(array('controller' => 'object', - 'action' => 'view', - 'id' => $this->params->id))); - exit; - } else if ($this->actions->validate()) { + $this->urlFor(array('controller' => 'object', + 'action' => 'view', + 'id' => $this->params->id)) + ->redirect(); + } + if ($this->actions->validate()) { $action = $this->actions->execute(); //FIXME: Hack $result = $this->object->$action(); @@ -292,10 +293,10 @@ class ObjectController extends Koward_Controller_Application $object = $this->form->execute(); if (!empty($object)) { - header('Location: ' . $this->urlFor(array('controller' => 'object', - 'action' => 'view', - 'id' => $object->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID)))); - exit; + $this->urlFor(array('controller' => 'object', + 'action' => 'view', + 'id' => $object->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID))) + ->redirect(); } } } catch (Exception $e) { @@ -338,11 +339,12 @@ class ObjectController extends Koward_Controller_Application $uids = array_keys($this->objectlist); if (count($uids) == 1) { - header('Location: ' . $this->urlFor(array('controller' => 'object', - 'action' => 'view', - 'id' => $uids[0]))); - exit; - } else if (count($uids) == 0) { + $this->urlFor(array('controller' => 'object', + 'action' => 'view', + 'id' => $uids[0])) + ->redirect(); + } + if (count($uids) == 0) { $this->koward->notification->push(_("No results found!"), 'horde.message'); } else { foreach ($this->objectlist as $uid => $info) { diff --git a/koward/www/htdocs/koward/koward.php b/koward/www/htdocs/koward/koward.php index b7297109f..fced4e3be 100644 --- a/koward/www/htdocs/koward/koward.php +++ b/koward/www/htdocs/koward/koward.php @@ -25,6 +25,6 @@ try { } if (isset($registry)) { - header('Location: ' . $registry->get('webroot', 'koward')); + $registry->get('webroot', 'koward')->redirect(); } } diff --git a/luxor/search.php b/luxor/search.php index 707e53bc1..8dfe8bd73 100644 --- a/luxor/search.php +++ b/luxor/search.php @@ -14,15 +14,13 @@ Horde_Registry::appInit('luxor'); $symbol = Horde_Util::getFormData('s'); if (!$symbol) { - header('Location: ' . Horde::applicationUrl('source.php', true)); - exit; + Horde::applicationUrl('source.php', true)->redirect(); } $ids = $index->searchSymbols($symbol); if (count($ids) == 1) { $id = current($ids); - header('Location: ' . Horde::applicationUrl('symbol.php?i=' . $id, true)); - exit; + Horde::applicationUrl('symbol.php', true)->add('i', $id)->redirect(); } // If there are multiple search results, display some info for all of them. diff --git a/mnemo/memo.php b/mnemo/memo.php index df414632a..0a199f72a 100644 --- a/mnemo/memo.php +++ b/mnemo/memo.php @@ -60,8 +60,7 @@ $memo_id = Horde_Util::getFormData('memo'); $memolist_id = Horde_Util::getFormData('memolist'); $actionID = Horde_Util::getFormData('actionID'); if (is_null($actionID)) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } /* Load category manager. */ @@ -78,8 +77,7 @@ case 'add_memo': $message = Horde::callHook('_perms_hook_denied', array('mnemo:max_notes'), 'horde', $message); } $notification->push($message, 'horde.error', array('content.raw')); - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } /* Set up the note attributes. */ if (empty($memolist_id)) { @@ -104,8 +102,7 @@ case 'modify_memo': $memo = Mnemo::getMemo($memolist_id, $memo_id, $passphrase); if (!$memo || !isset($memo['memo_id'])) { $notification->push(_("Note not found."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $storage = &Mnemo_Driver::singleton($memolist_id); @@ -146,8 +143,7 @@ case 'save_memo': $memo = Mnemo::getMemo($memolist_original, $memo_id); if (!$memo || !isset($memo['memo_id'])) { $notification->push(_("Note not found."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $title = sprintf(_("Edit: %s"), $memo['desc']); $show_passphrase = showPassphrase($memo); @@ -203,8 +199,7 @@ case 'save_memo': /* Check permissions. */ if ($injector->getInstance('Horde_Perms')->hasAppPermission('max_notes') !== true && $injector->getInstance('Horde_Perms')->hasAppPermission('max_notes') <= Mnemo::countMemos()) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } /* Creating a new note. */ $storage = Mnemo_Driver::singleton($notepad_target); @@ -223,8 +218,7 @@ case 'save_memo': } /* Return to the notepad view. */ - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); case 'delete_memos': /* Delete the note if we're provided with a valid note ID. */ @@ -251,12 +245,10 @@ case 'delete_memos': } /* Return to the notepad. */ - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); default: - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $notepads = Mnemo::listNotepads(false, Horde_Perms::EDIT); diff --git a/mnemo/note/pdf.php b/mnemo/note/pdf.php index 6f73d6a5d..e0673d5c4 100644 --- a/mnemo/note/pdf.php +++ b/mnemo/note/pdf.php @@ -21,8 +21,7 @@ $storage = &Mnemo_Driver::singleton(); if ($uid = Horde_Util::getFormData('uid')) { $note = $storage->getByUID($uid, $passphrase); if ($note instanceof PEAR_Error) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $note_id = $note['memo_id']; @@ -33,8 +32,7 @@ if ($uid = Horde_Util::getFormData('uid')) { $note_id = Horde_Util::getFormData('note'); $notelist_id = Horde_Util::getFormData('notepad'); if (!isset($note_id) || !$notelist_id) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } /* Get the current memo. */ @@ -44,20 +42,17 @@ try { $share = $GLOBALS['mnemo_shares']->getShare($notelist_id); } catch (Horde_Share_Exception $e) { $notification->push(sprintf(_("There was an error viewing this notepad: %s"), $e->getMessage()), 'horde.error'); - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) { $notification->push(sprintf(_("You do not have permission to view the notepad %s."), $share->get('name')), 'horde.error'); - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } /* If the requested note doesn't exist, display an error message. */ if (!$note || !isset($note['memo_id'])) { $notification->push(_("Note not found."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } /* Let's assume that the note content can be converted to ISO-8859-1 if this diff --git a/mnemo/notepads/create.php b/mnemo/notepads/create.php index 402f23d39..e6c2c8bcf 100644 --- a/mnemo/notepads/create.php +++ b/mnemo/notepads/create.php @@ -17,8 +17,7 @@ require_once MNEMO_BASE . '/lib/Forms/CreateNotepad.php'; // Exit if this isn't an authenticated user or if the user can't // create new notepads (default share is locked). if (!$GLOBALS['registry']->getAuth() || $prefs->isLocked('default_notepad')) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $vars = Horde_Variables::getDefaultVariables(); @@ -33,8 +32,7 @@ if ($form->validate($vars)) { $notification->push(sprintf(_("The notepad \"%s\" has been created."), $vars->get('name')), 'horde.success'); } - header('Location: ' . Horde::applicationUrl('notepads/', true)); - exit; + Horde::applicationUrl('notepads/', true)->redirect(); } $title = $form->getTitle(); diff --git a/mnemo/notepads/delete.php b/mnemo/notepads/delete.php index 2deadf8dd..cf7ca3172 100644 --- a/mnemo/notepads/delete.php +++ b/mnemo/notepads/delete.php @@ -16,28 +16,24 @@ require_once MNEMO_BASE . '/lib/Forms/DeleteNotepad.php'; // Exit if this isn't an authenticated user. if (!$GLOBALS['registry']->getAuth()) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $vars = Horde_Variables::getDefaultVariables(); $notepad_id = $vars->get('n'); if ($notepad_id == $GLOBALS['registry']->getAuth()) { $notification->push(_("This notepad cannot be deleted"), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('notepads/', true)); - exit; + Horde::applicationUrl('notepads/', true)->redirect(); } try { $notepad = $mnemo_shares->getShare($notepad_id); } catch (Horde_Share_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl('notepads/', true)); - exit; + Horde::applicationUrl('notepads/', true)->redirect(); } if (!$GLOBALS['registry']->getAuth() || $notepad->get('owner') != $GLOBALS['registry']->getAuth()) { $notification->push(_("You are not allowed to delete this notepad."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('notepads/', true)); - exit; + Horde::applicationUrl('notepads/', true)->redirect(); } $form = new Mnemo_DeleteNotepadForm($vars, $notepad); @@ -51,8 +47,7 @@ if ($form->validate(new Horde_Variables($_POST))) { $notification->push(sprintf(_("The notepad \"%s\" has been deleted."), $notepad->get('name')), 'horde.success'); } - header('Location: ' . Horde::applicationUrl('notepads/', true)); - exit; + Horde::applicationUrl('notepads/', true)->redirect(); } $title = $form->getTitle(); diff --git a/mnemo/notepads/edit.php b/mnemo/notepads/edit.php index 5cb9196e9..836b6c534 100644 --- a/mnemo/notepads/edit.php +++ b/mnemo/notepads/edit.php @@ -16,8 +16,7 @@ require_once MNEMO_BASE . '/lib/Forms/EditNotepad.php'; // Exit if this isn't an authenticated user. if (!$GLOBALS['registry']->getAuth()) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $vars = Horde_Variables::getDefaultVariables(); @@ -25,15 +24,13 @@ try { $notepad = $mnemo_shares->getShare($vars->get('n')); } catch (Horde_Share_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl('notepads/', true)); - exit; + Horde::applicationUrl('notepads/', true)->redirect(); } if (!$GLOBALS['registry']->getAuth() || $notepad->get('owner') != $GLOBALS['registry']->getAuth()) { $notification->push(_("You are not allowed to change this notepad."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('notepads/', true)); - exit; + Horde::applicationUrl('notepads/', true)->redirect(); } $form = new Mnemo_EditNotepadForm($vars, $notepad); @@ -51,8 +48,7 @@ if ($form->validate($vars)) { } } - header('Location: ' . Horde::applicationUrl('notepads/', true)); - exit; + Horde::applicationUrl('notepads/', true)->redirect(); } $vars->set('name', $notepad->get('name')); diff --git a/mnemo/notes/index.php b/mnemo/notes/index.php index 228c83880..613b14635 100644 --- a/mnemo/notes/index.php +++ b/mnemo/notes/index.php @@ -30,8 +30,9 @@ foreach ($memos as $memo_id => $memo) { if (count($search_results) == 1) { $note = array_shift($search_results); - header('Location: ' . Horde::applicationUrl(Horde_Util::addParameter('view.php', array('memo' => $note['memo_id'], 'memolist' => $note['memolist_id'])), true)); - exit; + Horde::applicationUrl('view.php', true) + ->add(array('memo' => $note['memo_id'], 'memolist' => $note['memolist_id'])) + ->redirect(); } $title = _("Search Results"); diff --git a/mnemo/view.php b/mnemo/view.php index a21d94fd7..756447850 100644 --- a/mnemo/view.php +++ b/mnemo/view.php @@ -19,8 +19,7 @@ $storage = Mnemo_Driver::singleton(); if ($uid = Horde_Util::getFormData('uid')) { $memo = $storage->getByUID($uid, $passphrase); if (is_a($memo, 'PEAR_Error')) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $memo_id = $memo['memo_id']; @@ -31,8 +30,7 @@ if ($uid = Horde_Util::getFormData('uid')) { $memo_id = Horde_Util::getFormData('memo'); $memolist_id = Horde_Util::getFormData('memolist'); if (!isset($memo_id) || !$memolist_id) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } /* Get the current memo. */ @@ -42,20 +40,17 @@ try { $share = $GLOBALS['mnemo_shares']->getShare($memolist_id); } catch (Horde_Share_Exception $e) { $notification->push(sprintf(_("There was an error viewing this notepad: %s"), $e->getMessage()), 'horde.error'); - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) { $notification->push(sprintf(_("You do not have permission to view the notepad %s."), $share->get('name')), 'horde.error'); - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } /* If the requested note doesn't exist, display an error message. */ if (!$memo || !isset($memo['memo_id'])) { $notification->push(_("Note not found."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } /* Get the note's history. */ diff --git a/nag/quick.php b/nag/quick.php index 720568643..5b6fe3db0 100644 --- a/nag/quick.php +++ b/nag/quick.php @@ -11,9 +11,7 @@ if ($quickText = Horde_Util::getPost('quickText')) { } else { $notification->push(sprintf(_("Added %s tasks"), count($result)), 'horde.success'); } - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit(0); - } else { - Horde::fatal($result); + Horde::applicationUrl('list.php', true)->redirect(); } + Horde::fatal($result); } diff --git a/nag/task.php b/nag/task.php index 6566656ce..d425706dc 100644 --- a/nag/task.php +++ b/nag/task.php @@ -44,10 +44,9 @@ function _delete($task_id, $tasklist_id) /* Return to the last page or to the task list. */ if ($url = Horde_Util::getFormData('url')) { header('Location: ' . $url); - } else { - header('Location: ' . Horde::applicationUrl('list.php', true)); + exit; } - exit; + Horde::applicationUrl('list.php', true)->redirect(); } require_once dirname(__FILE__) . '/lib/Application.php'; @@ -59,8 +58,7 @@ $vars = Horde_Variables::getDefaultVariables(); /* Redirect to the task list if no action has been requested. */ $actionID = $vars->get('actionID'); if (is_null($actionID)) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } /* Run through the action handlers. */ @@ -76,8 +74,7 @@ case 'add_task': $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), $perms->hasAppPermission('max_tasks')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); } $notification->push($message, 'horde.error', array('content.raw')); - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $vars->set('actionID', 'save_task'); @@ -114,8 +111,7 @@ case 'modify_task': } /* Return to the task list. */ - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); case 'save_task': if ($vars->get('submitbutton') == _("Delete this task")) { @@ -136,13 +132,11 @@ case 'save_task': $share = $GLOBALS['nag_shares']->getShare($info['tasklist_id']); } catch (Horde_Share_Exception $e) { $notification->push(sprintf(_("Access denied saving task: %s"), $e->getMessage()), 'horde.error'); - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $notification->push(sprintf(_("Access denied saving task to %s."), $share->get('name')), 'horde.error'); - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } /* Add new category. */ @@ -171,8 +165,7 @@ case 'save_task': $perms = $GLOBALS['injector']->getInstance('Horde_Perms'); if ($perms->hasAppPermission('max_tasks') !== true && $perms->hasAppPermission('max_tasks') <= Nag::countTasks()) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } /* Creating a new task. */ @@ -195,10 +188,9 @@ case 'save_task': /* Return to the last page or to the task list. */ if ($url = Horde_Util::getFormData('url')) { header('Location: ' . $url); - } else { - header('Location: ' . Horde::applicationUrl('list.php', true)); + exit; } - exit; + Horde::applicationUrl('list.php', true)->redirect(); } break; @@ -241,14 +233,12 @@ case 'complete_task': $url = $vars->get('url'); if (!empty($url)) { header('Location: ' . $url); - } else { - header('Location: ' . Horde::applicationUrl('list.php', true)); + exit; } - exit; + Horde::applicationUrl('list.php', true)->redirect(); default: - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $title = $form->getTitle(); diff --git a/nag/tasklists/create.php b/nag/tasklists/create.php index b7d3aabf9..413f74584 100644 --- a/nag/tasklists/create.php +++ b/nag/tasklists/create.php @@ -14,8 +14,7 @@ require_once NAG_BASE . '/lib/Forms/CreateTaskList.php'; // Exit if this isn't an authenticated user or if the user can't // create new task lists (default share is locked). if (!$GLOBALS['registry']->getAuth() || $prefs->isLocked('default_tasklist')) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $vars = Horde_Variables::getDefaultVariables(); @@ -30,8 +29,7 @@ if ($form->validate($vars)) { $notification->push($e, 'horde.error'); } - header('Location: ' . Horde::applicationUrl('tasklists/', true)); - exit; + Horde::applicationUrl('tasklists/', true)->redirect(); } $title = $form->getTitle(); diff --git a/nag/tasklists/delete.php b/nag/tasklists/delete.php index 28f24eae3..4c43289f1 100644 --- a/nag/tasklists/delete.php +++ b/nag/tasklists/delete.php @@ -13,29 +13,25 @@ require_once NAG_BASE . '/lib/Forms/DeleteTaskList.php'; // Exit if this isn't an authenticated user. if (!$GLOBALS['registry']->getAuth()) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $vars = Horde_Variables::getDefaultVariables(); $tasklist_id = $vars->get('t'); if ($tasklist_id == $GLOBALS['registry']->getAuth()) { $notification->push(_("This task list cannot be deleted."), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('tasklists/', true)); - exit; + Horde::applicationUrl('tasklists/', true)->redirect(); } try { $tasklist = $nag_shares->getShare($tasklist_id); } catch (Horde_Share_Exception $e) { $notification->push($tasklist, 'horde.error'); - header('Location: ' . Horde::applicationUrl('tasklists/', true)); - exit; + Horde::applicationUrl('tasklists/', true)->redirect(); } if ($tasklist->get('owner') != $GLOBALS['registry']->getAuth() && (!is_null($tasklist->get('owner')) || !$GLOBALS['registry']->isAdmin())) { $notification->push(_("You are not allowed to delete this task list."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('tasklists/', true)); - exit; + Horde::applicationUrl('tasklists/', true)->redirect(); } $form = new Nag_DeleteTaskListForm($vars, $tasklist); @@ -49,8 +45,7 @@ if ($form->validate(new Horde_Variables($_POST))) { $notification->push($e, 'horde.error'); } - header('Location: ' . Horde::applicationUrl('tasklists/', true)); - exit; + Horde::applicationUrl('tasklists/', true)->redirect(); } $title = $form->getTitle(); diff --git a/nag/tasklists/edit.php b/nag/tasklists/edit.php index a49c8c157..784218568 100644 --- a/nag/tasklists/edit.php +++ b/nag/tasklists/edit.php @@ -13,8 +13,7 @@ require_once NAG_BASE . '/lib/Forms/EditTaskList.php'; // Exit if this isn't an authenticated user. if (!$GLOBALS['registry']->getAuth()) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $vars = Horde_Variables::getDefaultVariables(); @@ -22,14 +21,12 @@ try { $tasklist = $nag_shares->getShare($vars->get('t')); } catch (Horde_Share_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl('tasklists/', true)); - exit; + Horde::applicationUrl('tasklists/', true)->redirect(); } if ($tasklist->get('owner') != $GLOBALS['registry']->getAuth() && (!is_null($tasklist->get('owner')) || !$GLOBALS['registry']->isAdmin())) { $notification->push(_("You are not allowed to change this task list."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('tasklists/', true)); - exit; + Horde::applicationUrl('tasklists/', true)->redirect(); } $form = new Nag_EditTaskListForm($vars, $tasklist); @@ -47,8 +44,7 @@ if ($form->validate($vars)) { $notification->push($e, 'horde.error'); } - header('Location: ' . Horde::applicationUrl('tasklists/', true)); - exit; + Horde::applicationUrl('tasklists/', true)->redirect(); } $vars->set('name', $tasklist->get('name')); diff --git a/nag/tasks/index.php b/nag/tasks/index.php index 16dfc98e1..45cc4dde4 100644 --- a/nag/tasks/index.php +++ b/nag/tasks/index.php @@ -37,8 +37,7 @@ while ($task = &$tasks->each()) { $search_results->reset(); if ($search_results->count() == 1) { $task = $search_results->each(); - header('Location: ' . Horde::url($task->view_link, true)); - exit; + Horde::url($task->view_link, true)->redirect(); } $tasks = $search_results; diff --git a/nag/view.php b/nag/view.php index 8cecc65e3..6c850ad13 100644 --- a/nag/view.php +++ b/nag/view.php @@ -15,8 +15,7 @@ if ($uid = Horde_Util::getFormData('uid')) { $storage = Nag_Driver::singleton(); $task = $storage->getByUID($uid); if ($task instanceof PEAR_Error) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $task_id = $task->id; @@ -27,8 +26,7 @@ if ($uid = Horde_Util::getFormData('uid')) { $task_id = Horde_Util::getFormData('task'); $tasklist_id = Horde_Util::getFormData('tasklist'); if (!isset($task_id) || !$tasklist_id) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } /* Get the current task. */ @@ -38,8 +36,7 @@ if ($uid = Horde_Util::getFormData('uid')) { /* If the requested task doesn't exist, display an error message. */ if (!isset($task) || !isset($task->id)) { $notification->push(_("Task not found."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } /* Load child tasks */ @@ -49,8 +46,7 @@ $task->loadChildren(); $share = $GLOBALS['nag_shares']->getShare($tasklist_id); if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) { $notification->push(_("You do not have permission to view this tasklist."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } /* Get the task's history. */ diff --git a/news/add.php b/news/add.php index b56da9dc9..355150c5c 100644 --- a/news/add.php +++ b/news/add.php @@ -106,8 +106,7 @@ if ($id && Horde_Util::getFormData('submitbutton') == _("Delete existing picture $notification->push($sources); } else { News::deleteImage($id); - header('Location: ' . News::getUrlFor('news', $id)); - exit; + News::getUrlFor('news', $id)->redirect(); } } @@ -335,8 +334,7 @@ if ($form->validate()) { $id = $news->write_db->nextID($news->prefix); if ($id instanceof PEAR_Error) { $notification->push($id); - header('Location: ' . Horde::applicationUrl('browse.php')); - exit; + Horde::applicationUrl('browse.php')->redirect(); } $query = 'INSERT INTO ' . $news->prefix @@ -396,8 +394,7 @@ if ($form->validate()) { $result = $news->write_db->query($query, $data); if ($result instanceof PEAR_Error) { $notification->push($result->getDebugInfo(), 'horde.error'); - header('Location: ' . Horde::applicationUrl('edit.php')); - exit; + Horde::applicationUrl('edit.php')->redirect(); } // Picture @@ -553,8 +550,7 @@ if ($form->validate()) { $notification->push(_("News updated."), 'horde.success'); } - header('Location: ' . $url); - exit; + $url->redirect(); } elseif ($id && !$form->isSubmitted()) { diff --git a/news/admin/categories/delete.php b/news/admin/categories/delete.php index 85c969f40..aa92471c6 100644 --- a/news/admin/categories/delete.php +++ b/news/admin/categories/delete.php @@ -31,8 +31,7 @@ if ($form->validate()) { } else { $notification->push(_("Category was not deleted."), 'horde.warning'); } - header('Location: ' . Horde::applicationUrl('admin/categories/index.php')); - exit; + Horde::applicationUrl('admin/categories/index.php')->redirect(); } require NEWS_BASE . '/templates/common-header.inc'; diff --git a/news/admin/categories/edit.php b/news/admin/categories/edit.php index 1e0d83cc9..33fdefb4e 100644 --- a/news/admin/categories/edit.php +++ b/news/admin/categories/edit.php @@ -44,9 +44,7 @@ if ($form->validate()) { $notification->push($result->getMessage() . ': ' . $result->getDebugInfo(), 'horde.error'); } else { $notification->push(sprintf(_("Category succesfully saved."))); - $url = Horde::applicationUrl('admin/categories/index.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('admin/categories/index.php', true)->redirect(); } } diff --git a/news/admin/sources/delete.php b/news/admin/sources/delete.php index 861788ffc..968db2895 100644 --- a/news/admin/sources/delete.php +++ b/news/admin/sources/delete.php @@ -32,8 +32,7 @@ if ($form->validate()) { } else { $notification->push(_("Source was not deleted."), 'horde.warning'); } - header('Location: ' . Horde::applicationUrl('admin/sources/index.php')); - exit; + Horde::applicationUrl('admin/sources/index.php')->redirect(); } require NEWS_BASE . '/templates/common-header.inc'; diff --git a/news/admin/sources/edit.php b/news/admin/sources/edit.php index aa69e69a1..e99fe7825 100644 --- a/news/admin/sources/edit.php +++ b/news/admin/sources/edit.php @@ -43,8 +43,7 @@ if ($form->validate()) { $notification->push($result->getMessage() . ': ' . $result->getDebugInfo(), 'horde.error'); } else { $notification->push(_("Source saved succesfully.")); - header('Location: ' . Horde::applicationUrl('admin/sources/index.php')); - exit; + Horde::applicationUrl('admin/sources/index.php')->redirect(); } } diff --git a/news/browse.php b/news/browse.php index 68e1256a1..deaf0891f 100644 --- a/news/browse.php +++ b/news/browse.php @@ -46,8 +46,7 @@ if ($rows instanceof PEAR_Error) { // If we have only one row redirect ot it if ($count == 1 && sizeof($cats) < 2 && $page < 1) { - header('Location: '. News::getUrlFor('news', $rows[0]['id'])); - exit; + News::getUrlFor('news', $rows[0]['id'])->redirect(); } // Get pager diff --git a/news/delete.php b/news/delete.php index ff0368425..e8f26ff96 100644 --- a/news/delete.php +++ b/news/delete.php @@ -17,8 +17,7 @@ require_once dirname(__FILE__) . '/lib/base.php'; if (!$registry->isAdmin(array('permission' => 'news:admin'))) { $notification->push(_("Only admin can delete a news.")); - header('Location: ' . Horde::applicationUrl('edit.php')); - exit; + Horde::applicationUrl('edit.php')->redirect(); } $vars = Horde_Variables::getDefaultVariables(); @@ -86,13 +85,10 @@ if ($form->validate()) { $notification->push(sprintf(_("News %s: %s"), $id, _("not deleted")), 'horde.warning'); } - header('Location: ' . Horde::applicationUrl('edit.php')); - exit; + Horde::applicationUrl('edit.php')->redirect(); } require NEWS_TEMPLATES . '/common-header.inc'; require NEWS_TEMPLATES . '/menu.inc'; - $form->renderActive(null, null, null, 'post'); - require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/news/delete_file.php b/news/delete_file.php index 4078fcd07..0615d8d1d 100644 --- a/news/delete_file.php +++ b/news/delete_file.php @@ -17,8 +17,7 @@ require_once dirname(__FILE__) . '/lib/base.php'; if (!$registry->isAdmin(array('permission' => 'news:admin'))) { $notification->push(_("Only admin can delete a news.")); - header('Location: ' . Horde::applicationUrl('edit.php')); - exit; + Horde::applicationUrl('edit.php')->redirect(); } $vars = Horde_Variables::getDefaultVariables(); @@ -83,13 +82,10 @@ if ($form->validate()) { } - header('Location: ' . News::getUrlFor('news', $news_id)); - exit; + News::getUrlFor('news', $news_id)->redirect(); } require NEWS_TEMPLATES . '/common-header.inc'; require NEWS_TEMPLATES . '/menu.inc'; - $form->renderActive(null, null, null, 'post'); - require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/news/edit.php b/news/edit.php index c4ac01c89..57b7deaf3 100644 --- a/news/edit.php +++ b/news/edit.php @@ -19,8 +19,7 @@ require_once dirname(__FILE__) . '/lib/base.php'; $allowed_cats = $news_cat->getAllowed(Horde_Perms::DELETE); if (empty($allowed_cats)) { $notification->push(_("You have not editor permission on any category.")); - header('Location: ' . Horde::applicationUrl('add.php')); - exit; + Horde::applicationUrl('add.php')->redirect(); } $id = (int)Horde_Util::getFormData('id', 0); @@ -57,8 +56,7 @@ case 'deletepicture'; $notification->push(sprintf(_("News \"%s\" (%s): %s"), $article['title'], $id, _("picture deleted")), 'horde.success'); } - header('Location: ' . $browse_url); - exit; + $browse_url->redirect(); break; @@ -70,8 +68,7 @@ case 'deactivate'; } $notification->push(sprintf(_("News \"%s\" (%s): %s"), $article['title'], $id, _("deactivated")), 'horde.success'); - header('Location: ' . $browse_url); - exit; + $browse_url->redirect(); break; case 'activate'; @@ -82,8 +79,7 @@ case 'activate'; } $notification->push(sprintf(_("News \"%s\" (%s): %s"), $article['title'], $id, _("activated")), 'horde.success'); - header('Location: ' . $browse_url); - exit; + $browse_url->redirect(); break; case 'lock'; @@ -94,8 +90,7 @@ case 'lock'; } $notification->push(sprintf(_("News \"%s\" (%s): %s"), $article['title'], $id, _("locked")), 'horde.success'); - header('Location: ' . $browse_url); - exit; + $browse_url->redirect(); break; case 'unlock'; @@ -106,8 +101,8 @@ case 'unlock'; } $notification->push(sprintf(_("News \"%s\" (%s): %s"), $article['title'], $id, _("unlocked")), 'horde.success'); - header('Location: ' . $browse_url); - exit; + $browse_url->redirect(); + break; case 'renew'; @@ -145,10 +140,7 @@ case 'renew'; array($id, $version, $GLOBALS['registry']->getAuth(), serialize($new_version))); $notification->push(sprintf(_("News \"%s\" (%s): %s"), $article['title'], $id, _("renewed")), 'horde.success'); - header('Location: ' . $browse_url); - exit; - -break; + $browse_url->redirect(); } $title = _("Edit"); diff --git a/news/mail.php b/news/mail.php index 7202734b5..90e76a1da 100644 --- a/news/mail.php +++ b/news/mail.php @@ -19,16 +19,14 @@ $id = Horde_Util::getFormData('id'); $row = $news->get($id); if ($row instanceof PEAR_Error) { $notification->push($row); - header('Location: ' . Horde::applicationUrl('browse.php')); - exit; + Horde::applicationUrl('browse.php')->redirect(); } /* Error handler */ function _error($msg) { $GLOBALS['notification']->push($msg, 'horde.error'); - header('Location: ' . News::getUrlFor('news', $GLOBALS['id'])); - exit; + News::getUrlFor('news', $GLOBALS['id'])->redirect(); } if (!$registry->isAuthenticated()) { @@ -61,5 +59,4 @@ try { $notification->push($e); } -header('Location: ' . News::getUrlFor('news', $id)); -exit; +News::getUrlFor('news', $id)->redirect(); diff --git a/news/news.php b/news/news.php index 022624333..c508b4d72 100644 --- a/news/news.php +++ b/news/news.php @@ -21,8 +21,7 @@ $row = $news->get($id); // check if the news exists if ($row instanceof PEAR_Error) { $notification->push($row); - header('Location: ' . Horde::applicationUrl('index.php')); - exit; + Horde::applicationUrl('index.php')->redirect(); } // check if the news exists diff --git a/news/note.php b/news/note.php index a5fcf30eb..e482d7926 100644 --- a/news/note.php +++ b/news/note.php @@ -19,8 +19,7 @@ $id = Horde_Util::getFormData('id'); $row = $news->get($id); if ($row instanceof PEAR_Error) { $notification->push($row); - header('Location: ' . Horde::applicationUrl('browse.php')); - exit; + Horde::applicationUrl('browse.php')->redirect(); } $body = $row['title'] . "\n\n" @@ -40,5 +39,5 @@ try { header('Location: ' . $registry->getInitialPage('mnemo')); } catch (Horde_Exception $e) { $notification->push($e); - header('Location: ' . News::getUrlFor('news', $id)); + News::getUrlFor('news', $id)->redirect(); } diff --git a/news/pdf.php b/news/pdf.php index bc4a252c7..42be47b7e 100644 --- a/news/pdf.php +++ b/news/pdf.php @@ -22,8 +22,7 @@ $row = $news->get($id); // Check if the news exists if ($row instanceof PEAR_Error) { $notification->push($row); - header('Location: ' . Horde::applicationUrl('browse.php')); - exit; + Horde::applicationUrl('browse.php')->redirect(); } // Set up the PDF object. diff --git a/news/search.php b/news/search.php index e6bb543d5..76ff68561 100644 --- a/news/search.php +++ b/news/search.php @@ -44,8 +44,7 @@ $pager->preserve($criteria); // If we have only one row redirect ot it if ($count == 1 && sizeof($cats) < 2 && $page < 1) { - header('Location: '. News::getUrlFor('news', $rows[0]['id'])); - exit; + News::getUrlFor('news', $rows[0]['id'])->redirect(); } diff --git a/pastie/paste.php b/pastie/paste.php index c35dd8534..ae98e9d15 100644 --- a/pastie/paste.php +++ b/pastie/paste.php @@ -28,9 +28,7 @@ if ($form->validate($vars)) { $notification->push(sprintf('Paste saved. %s', $uuid), 'horde.success'); - $url = Horde::applicationUrl('uuid/' . $uuid, true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('uuid/' . $uuid, true)->redirect(); } catch (Exception $e) { $notification->push($e->getMessage(), 'horde.error'); } diff --git a/shout/dialplan.php b/shout/dialplan.php index 42041e679..4eb0b762b 100644 --- a/shout/dialplan.php +++ b/shout/dialplan.php @@ -20,7 +20,7 @@ $curaccount = $_SESSION['shout']['curaccount']; $menus = $shout->storage->getMenus($curaccount['code']); if (empty($menus)) { - header('Location: ' . Horde::applicationUrl('wizard.php', true)); + Horde::applicationUrl('wizard.php', true)->redirect(); } switch($action) { diff --git a/shout/index.php b/shout/index.php index 1bf919351..8d07accc0 100644 --- a/shout/index.php +++ b/shout/index.php @@ -19,8 +19,6 @@ $curaccount = $_SESSION['shout']['curaccount']; $menus = $shout->storage->getMenus($curaccount['code']); if (empty($menus)) { - header('Location: ' . Horde::applicationUrl('wizard.php', true)); -} else { - header('Location: ' . Horde::applicationUrl('dialplan.php', true)); - exit; -} \ No newline at end of file + Horde::applicationUrl('wizard.php', true)->redirect(); +} +Horde::applicationUrl('dialplan.php', true)->redirect(); diff --git a/shout/wizard.php b/shout/wizard.php index 6f7f6e2a2..a0e124ec8 100644 --- a/shout/wizard.php +++ b/shout/wizard.php @@ -29,8 +29,7 @@ try { $menus = $shout->storage->getMenus($curaccount['code']); if (!empty($menus) && !empty($menus[Shout::MAIN_MENU])) { - header('Location: ' . Horde::applicationUrl('dialplan.php', true)); - exit; + Horde::applicationUrl('dialplan.php', true)->redirect(); } // Create the default recording for the main menu diff --git a/skoli/add.php b/skoli/add.php index bc78aa899..ef695365b 100644 --- a/skoli/add.php +++ b/skoli/add.php @@ -15,8 +15,7 @@ require_once SKOLI_BASE . '/lib/Forms/Entry.php'; /* Redirect to create a new class if we don't have access to any class */ if (count(Skoli::listClasses(false, Horde_Perms::EDIT)) == 0 && $GLOBALS['registry']->getAuth()) { $notification->push(_("Please create a new Class first."), 'horde.message'); - header('Location: ' . Horde::applicationUrl('classes/create.php', true)); - exit; + Horde::applicationUrl('classes/create.php', true)->redirect(); } $vars = Horde_Variables::getDefaultVariables(); @@ -31,7 +30,9 @@ if ($form->validate($vars)) { $notification->push(sprintf(_("The new entry for \"%s\" has been added."), $result), 'horde.success'); } - header('Location: ' . Horde::applicationUrl(Horde_Util::addParameter('add.php', 'class', $vars->get('class_id')), true)); + Horde::applicationUrl('add.php', true) + ->add('class', $vars->get('class_id')) + ->redirect(); exit; } diff --git a/skoli/classes/create.php b/skoli/classes/create.php index 4cab4e3bf..c8019fdc8 100644 --- a/skoli/classes/create.php +++ b/skoli/classes/create.php @@ -12,16 +12,14 @@ require_once SKOLI_BASE . '/lib/Forms/CreateClass.php'; // Exit if this isn't an authenticated user. if (!$GLOBALS['registry']->getAuth()) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } // Exit if we don't have access to addressbooks. require_once SKOLI_BASE . '/lib/School.php'; if (!count(Skoli_School::listAddressBooks())) { $notification->push(_("You don't have access to any valid addressbook."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('classes/', true)); - exit; + Horde::applicationUrl('classes/', true)->redirect(); } $vars = Horde_Variables::getDefaultVariables(); @@ -38,8 +36,7 @@ if ($form->validate($vars)) { $prefs->setValue('display_classes', serialize($GLOBALS['display_classes'])); } - header('Location: ' . Horde::applicationUrl('classes/', true)); - exit; + Horde::applicationUrl('classes/', true)->redirect(); } $title = $form->getTitle(); diff --git a/skoli/classes/delete.php b/skoli/classes/delete.php index e043597b0..3860f1f3c 100644 --- a/skoli/classes/delete.php +++ b/skoli/classes/delete.php @@ -12,8 +12,7 @@ require_once SKOLI_BASE . '/lib/Forms/DeleteClass.php'; // Exit if this isn't an authenticated user. if (!$GLOBALS['registry']->getAuth()) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $vars = Horde_Variables::getDefaultVariables(); @@ -22,12 +21,10 @@ $class_id = $vars->get('c'); $class = $skoli_shares->getShare($class_id); if (is_a($class, 'PEAR_Error')) { $notification->push($class, 'horde.error'); - header('Location: ' . Horde::applicationUrl('classes/', true)); - exit; + Horde::applicationUrl('classes/', true)->redirect(); } elseif (!$class->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) { $notification->push(_("You are not allowed to delete this class."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('classes/', true)); - exit; + Horde::applicationUrl('classes/', true)->redirect(); } $form = new Skoli_DeleteClassForm($vars, $class); @@ -41,8 +38,7 @@ if ($form->validate(new Horde_Variables($_POST))) { $notification->push(sprintf(_("The class \"%s\" has been deleted."), $class->get('name')), 'horde.success'); } - header('Location: ' . Horde::applicationUrl('classes/', true)); - exit; + Horde::applicationUrl('classes/', true)->redirect(); } $title = $form->getTitle(); diff --git a/skoli/classes/edit.php b/skoli/classes/edit.php index 02423dbb3..33b84fcc3 100644 --- a/skoli/classes/edit.php +++ b/skoli/classes/edit.php @@ -12,20 +12,17 @@ require_once SKOLI_BASE . '/lib/Forms/EditClass.php'; // Exit if this isn't an authenticated user. if (!$GLOBALS['registry']->getAuth()) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $vars = Horde_Variables::getDefaultVariables(); $class = $skoli_shares->getShare($vars->get('c')); if (is_a($class, 'PEAR_Error')) { $notification->push($class, 'horde.error'); - header('Location: ' . Horde::applicationUrl('classes/', true)); - exit; + Horde::applicationUrl('classes/', true)->redirect(); } elseif (!$class->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $notification->push(_("You are not allowed to change this class."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('classes/', true)); - exit; + Horde::applicationUrl('classes/', true)->redirect(); } $vars->set('school', $class->get('school')); if (!$vars->exists('marks')) { @@ -51,8 +48,7 @@ if ($form->validate($vars)) { } } - header('Location: ' . Horde::applicationUrl('classes/', true)); - exit; + Horde::applicationUrl('classes/', true)->redirect(); } if (!$vars->exists('name')) { diff --git a/skoli/classes/index.php b/skoli/classes/index.php index 459df3137..95ef7217f 100644 --- a/skoli/classes/index.php +++ b/skoli/classes/index.php @@ -11,8 +11,7 @@ require_once SKOLI_BASE . '/lib/base.php'; // Exit if this isn't an authenticated user. if (!$GLOBALS['registry']->getAuth()) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $edit_url_base = Horde::applicationUrl('classes/edit.php'); diff --git a/skoli/data.php b/skoli/data.php index 627a10f4c..301f53ab6 100644 --- a/skoli/data.php +++ b/skoli/data.php @@ -11,8 +11,7 @@ require_once dirname(__FILE__) . '/lib/base.php'; if (!$conf['menu']['export']) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $classes = Skoli::listClasses(); diff --git a/skoli/entry.php b/skoli/entry.php index b10ee2ae2..4a19a47d1 100644 --- a/skoli/entry.php +++ b/skoli/entry.php @@ -13,8 +13,7 @@ require_once SKOLI_BASE . '/lib/base.php'; // Exit if this isn't an authenticated user. if (!$GLOBALS['registry']->getAuth()) { - header('Location: ' . Horde::applicationUrl('list.php', true)); - exit; + Horde::applicationUrl('list.php', true)->redirect(); } $vars = Horde_Variables::getDefaultVariables(); @@ -22,16 +21,16 @@ $driver = &Skoli_Driver::singleton(); $entry = $driver->getEntry($vars->get('entry')); if (is_a($entry, 'PEAR_Error') || !count($entry)) { $notification->push(_("Entry not found."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('search.php', true)); - exit; + Horde::applicationUrl('search.php', true)->redirect(); } $share = $GLOBALS['skoli_shares']->getShare($entry['class_id']); // Check permissions if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) { $notification->push(_("You are not allowed to view this entry."), 'horde.error'); - header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('search.php', true), 'actionID', 'search')); - exit; + Horde::applicationUrl('search.php', true) + ->add('actionID', 'search') + ->redirect(); } $studentdetails = Skoli::getStudent($share->get('address_book'), $entry['student_id']); @@ -60,8 +59,9 @@ if ($viewName != 'DeleteEntry') { $notification->push(sprintf(_("Couldn't update this entry: %s"), $result->getMessage()), 'horde.error'); } else { $notification->push(sprintf(_("The entry for \"%s\" has been saved."), $studentdetails[$conf['addresses']['name_field']]), 'horde.success'); - header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('search.php', true), 'actionID', 'search')); - exit; + Horde::applicationUrl('search.php', true) + ->add('actionID', 'search') + ->redirect(); } } } @@ -74,8 +74,9 @@ if ($actionID == 'delete') { $notification->push(sprintf(_("There was an error deleting this entry: %s"), $deleted->getMessage()), 'horde.error'); } else { $notification->push(sprintf(_("The entry for \"%s\" has been deleted."), $studentdetails[$conf['addresses']['name_field']]), 'horde.success'); - header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('search.php', true), 'actionID', 'search')); - exit; + Horde::applicationUrl('search.php', true) + ->add('actionID', 'search') + ->redirect(); } } diff --git a/skoli/list.php b/skoli/list.php index 2c8680d0a..09a578749 100644 --- a/skoli/list.php +++ b/skoli/list.php @@ -54,8 +54,7 @@ if ($app == false || $registry->get('status', $app) == 'inactive' || !$registry- /* Redirect to create a new class if we don't have access to any class */ if (count(Skoli::listClasses()) == 0 && $GLOBALS['registry']->getAuth()) { $notification->push(_("Please create a new Class first."), 'horde.message'); - header('Location: ' . Horde::applicationUrl('classes/create.php', true)); - exit; + Horde::applicationUrl('classes/create.php', true)->redirect(); } switch ($actionID) { diff --git a/trean/add.php b/trean/add.php index 45e967397..e6c143979 100644 --- a/trean/add.php +++ b/trean/add.php @@ -25,8 +25,7 @@ case 'add_bookmark': $message = Horde::callHook('_perms_hook_denied', array('trean:max_bookmarks'), 'horde', $message); } $notification->push($message, 'horde.error', array('content.raw')); - header('Location: ' . Horde::applicationUrl('browse.php', true)); - exit; + Horde::applicationUrl('browse.php', true)->redirect(); } $folderId = Horde_Util::getFormData('f'); @@ -66,9 +65,10 @@ case 'add_bookmark': $notification->push(_("Bookmark Added"), 'horde.success'); require TREAN_TEMPLATES . '/common-header.inc'; $notification->notify(); - exit; } else { - header('Location: ' . Horde::applicationUrl(Horde_Util::addParameter('browse.php', 'f', $folderId), true)); + Horde::applicationUrl('browse.php', true) + ->add('f', $folderId) + ->redirect(); } exit; } @@ -88,8 +88,9 @@ case 'add_folder': $message = Horde::callHook('_perms_hook_denied', array('trean:max_folders'), 'horde', $message); } $notification->push($message, 'horde.error', array('content.raw')); - header('Location: ' . Horde::applicationUrl(Horde_Util::addParameter('browse.php', 'f', $parent_id), true)); - exit; + Horde::applicationUrl('browse.php', true) + ->add('f', $parent_id) + ->redirect(); } $parent = &$trean_shares->getFolder($parent_id); @@ -101,8 +102,9 @@ case 'add_folder': if (is_a($result, 'PEAR_Error')) { $notification->push(sprintf(_("There was an error adding the folder: %s"), $result->getMessage()), 'horde.error'); } else { - header('Location: ' . Horde::applicationUrl(Horde_Util::addParameter('browse.php', 'f', $result), true)); - exit; + Horde::applicationUrl('browse.php', true) + ->add('f', $result) + ->redirect(); } break; } diff --git a/trean/bookmark.php b/trean/bookmark.php index cf0733f0c..ee777c775 100644 --- a/trean/bookmark.php +++ b/trean/bookmark.php @@ -44,5 +44,7 @@ if (Horde_Util::getFormData('partial')) { if (!is_null($url = Horde_Util::getFormData('nu'))) { header('Location: ' . $url); } else { - header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('browse.php', true), 'f', $bookmark->folder)); + Horde::applicationUrl('browse.php', true) + ->add('f', $bookmark->folder) + ->redirect(); } diff --git a/trean/browse.php b/trean/browse.php index 746ce9387..f212500ae 100644 --- a/trean/browse.php +++ b/trean/browse.php @@ -44,8 +44,7 @@ if (empty($folderId) && $registry->getAuth()) { /* Make sure user has permission to view this folder. */ if (!$folder->hasPermission($registry->getAuth(), Horde_Perms::READ)) { $notification->push(_("You do not have permission to view this folder."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('browse.php', true)); - exit; + Horde::applicationUrl('browse.php', true)->redirect(); } } diff --git a/trean/data.php b/trean/data.php index e544b0be5..5cd6e04a5 100644 --- a/trean/data.php +++ b/trean/data.php @@ -155,9 +155,9 @@ case 'import': $notification->push(sprintf(_("%d Folders and %d Bookmarks imported."), $folders, $bookmarks), 'horde.success'); - $url = Horde_Util::addParameter('browse.php', 'f', $root->getId()); - header('Location: ' . Horde::applicationUrl($url, true)); - exit; + Horde::applicationUrl('browse.php', true) + ->add('f', $root->getId()) + ->redirect(); case 'export': $folderId = Horde_Util::getFormData('export_folder'); diff --git a/trean/edit.php b/trean/edit.php index e0a60f2db..29632038a 100644 --- a/trean/edit.php +++ b/trean/edit.php @@ -17,14 +17,14 @@ $folderId = Horde_Util::getFormData('f', $trean_shares->getId($GLOBALS['registry $actionID = Horde_Util::getFormData('actionID'); if ($actionID == 'button') { - if (Horde_Util::getFormData('new_bookmark') - || !is_null(Horde_Util::getFormData('new_bookmark_x'))) { - header('Location: ' . Horde::applicationUrl('add.php?f=' . $folderId, true)); - exit; - } elseif (Horde_Util::getFormData('edit_bookmarks')) { + if (Horde_Util::getFormData('new_bookmark') || + !is_null(Horde_Util::getFormData('new_bookmark_x'))) { + Horde::applicationUrl('add.php', true)->add('f', $folderId)->redirect(); + } + if (Horde_Util::getFormData('edit_bookmarks')) { $actionID = null; - } elseif (Horde_Util::getFormData('delete_bookmarks') - || !is_null(Horde_Util::getFormData('delete_bookmarks_x'))) { + } elseif (Horde_Util::getFormData('delete_bookmarks') || + !is_null(Horde_Util::getFormData('delete_bookmarks_x'))) { $actionID = 'delete'; } } @@ -96,8 +96,9 @@ case 'save': $notification->notify(); } } else { - $url = Horde_Util::addParameter('browse.php', 'f', $folderId); - header('Location: ' . Horde::applicationUrl($url, true)); + Horde::applicationUrl('browse.php', true) + ->add('f', $folderId) + ->redirect(); } exit; @@ -129,9 +130,7 @@ case 'delete': } // Return to the folder listing - $url = Horde_Util::addParameter('browse.php', 'f', $folderId); - header('Location: ' . Horde::applicationUrl($url, true)); - exit; + Horde::applicationUrl('browse.php', true)->add('f', $folderId)->redirect(); case 'move': $create_folder = Horde_Util::getFormData('create_folder'); @@ -180,9 +179,7 @@ case 'move': } // Return to the folder listing - $url = Horde_Util::addParameter('browse.php', 'f', $folderId); - header('Location: ' . Horde::applicationUrl($url, true)); - exit; + Horde::applicationUrl('browse.php', true)->add('f', $folderId)->redirect(); case 'copy': $create_folder = Horde_Util::getFormData('create_folder'); @@ -223,9 +220,7 @@ case 'copy': } // Return to the folder listing - $url = Horde_Util::addParameter('browse.php', 'f', $folderId); - header('Location: ' . Horde::applicationUrl($url, true)); - exit; + Horde::applicationUrl('browse.php', true)->add('f', $folderId)->redirect(); case 'rename': /* Rename a Bookmark Folder. */ @@ -236,9 +231,7 @@ case 'rename': if (is_a($result, 'PEAR_Error')) { $notification->push(sprintf(_("\"%s\" was not renamed: %s."), $name, $result->getMessage()), 'horde.error'); } else { - $url = Horde_Util::addParameter('browse.php', 'f', $folderId); - header('Location: ' . Horde::applicationUrl($url, true)); - exit; + Horde::applicationUrl('browse.php', true)->add('f', $folderId)->redirect(); } break; @@ -260,33 +253,27 @@ case 'del_folder_confirmed': $folder = &$trean_shares->getFolder($folderId); if (is_a($folder, 'PEAR_Error')) { $notification->push($folder->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl('browse.php')); - exit; + Horde::applicationUrl('browse.php')->redirect(); } $parent = $folder->getParent(); $result = $folder->delete(); if (is_a($result, 'PEAR_Error')) { $notification->push($result->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl(Horde_Util::addParameter('browse.php', 'f', $folderId), true)); } else { $notification->push(sprintf(_("Deleted the folder \"%s\""), $folder->get('name')), 'horde.success'); - header('Location: ' . Horde::applicationUrl(Horde_Util::addParameter('browse.php', 'f', $parent), true)); } + Horde::applicationUrl('browse.php', true)->add('f', $folderId)->redirect(); exit; case 'cancel': - $url = Horde_Util::addParameter('browse.php', 'f', $folderId); - header('Location: ' . Horde::applicationUrl($url, true)); - exit; + Horde::applicationUrl('browse.php', true)->add('f', $folderId)->redirect(); } // Return to browse if there is nothing to edit. if (!count($bookmarks) && !count($folder)) { $notification->push(_("Nothing to edit."), 'horde.message'); - $url = Horde_Util::addParameter('browse.php', 'f', $folderId); - header('Location: ' . Horde::applicationUrl($url, true)); - exit; + Horde::applicationUrl('browse.php', true)->add('f', $folderId)->redirect(); } $title = _("Edit Bookmark"); diff --git a/trean/redirect.php b/trean/redirect.php index 179df7683..89a1de9b8 100644 --- a/trean/redirect.php +++ b/trean/redirect.php @@ -27,4 +27,4 @@ if (is_a($bookmark, 'PEAR_Error')) { ++$bookmark->clicks; $bookmark->save(); -header('Location: ' . Horde::externalUrl($bookmark->url)); +Horde::externalUrl($bookmark->url)->redirect(); diff --git a/turba/add.php b/turba/add.php index 4cbbc5d5a..cb8c0edd5 100644 --- a/turba/add.php +++ b/turba/add.php @@ -28,8 +28,7 @@ if (!$addSources) { $url = $url ? Horde::url($url, true) : Horde::applicationUrl('index.php', true); - header('Location: ' . $url); - exit; + $url->redirect(); } /* A source has been selected, connect and set up the fields. */ @@ -51,8 +50,7 @@ if ($source) { $url = $url ? Horde::url($url, true) : Horde::applicationUrl('index.php', true); - header('Location: ' . $url); - exit; + $url->redirect(); } $contact = new Turba_Object($driver); diff --git a/turba/addressbooks/create.php b/turba/addressbooks/create.php index a5695ca03..ae6c462c6 100644 --- a/turba/addressbooks/create.php +++ b/turba/addressbooks/create.php @@ -31,8 +31,7 @@ if ($form->validate($vars)) { $notification->push(sprintf(_("The address book \"%s\" has been created."), $vars->get('name')), 'horde.success'); } - header('Location: ' . Horde::applicationUrl('addressbooks/', true)); - exit; + Horde::applicationUrl('addressbooks/', true)->redirect(); } $title = $form->getTitle(); diff --git a/turba/addressbooks/delete.php b/turba/addressbooks/delete.php index 340bb792f..2665ecf17 100644 --- a/turba/addressbooks/delete.php +++ b/turba/addressbooks/delete.php @@ -23,23 +23,20 @@ $vars = Horde_Variables::getDefaultVariables(); $addressbook_id = $vars->get('a'); if ($addressbook_id == $GLOBALS['registry']->getAuth()) { $notification->push(_("This addressbook cannot be deleted"), 'horde.warning'); - header('Location: ' . Horde::applicationUrl('addressbooks/', true)); - exit; + Horde::applicationUrl('addressbooks/', true)->redirect(); } try { $addressbook = $turba_shares->getShare($addressbook_id); } catch (Horde_Share_Exception $e) { $notification->push($e, 'horde.error'); - header('Location: ' . Horde::applicationUrl('addressbooks/', true)); - exit; + Horde::applicationUrl('addressbooks/', true)->redirect(); } if (!$GLOBALS['registry']->getAuth() || $addressbook->get('owner') != $GLOBALS['registry']->getAuth()) { $notification->push(_("You are not allowed to delete this addressbook."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('addressbooks/', true)); - exit; + Horde::applicationUrl('addressbooks/', true)->redirect(); } $form = new Turba_Form_DeleteAddressBook($vars, $addressbook); @@ -53,8 +50,7 @@ if ($form->validate(new Horde_Variables($_POST))) { $notification->push(sprintf(_("The addressbook \"%s\" has been deleted."), $addressbook->get('name')), 'horde.success'); } - header('Location: ' . Horde::applicationUrl('addressbooks/', true)); - exit; + Horde::applicationUrl('addressbooks/', true)->redirect(); } $title = $form->getTitle(); diff --git a/turba/addressbooks/edit.php b/turba/addressbooks/edit.php index 502a81a9a..18c670fde 100644 --- a/turba/addressbooks/edit.php +++ b/turba/addressbooks/edit.php @@ -24,15 +24,13 @@ try { $addressbook = $turba_shares->getShare($vars->get('a')); } catch (Horde_Share_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl('addressbooks/', true)); - exit; + Horde::applicationUrl('addressbooks/', true)->redirect(); } if (!$GLOBALS['registry']->getAuth() || $addressbook->get('owner') != $GLOBALS['registry']->getAuth()) { $notification->push(_("You are not allowed to change this addressbook."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('addressbooks/', true)); - exit; + Horde::applicationUrl('addressbooks/', true)->redirect(); } $form = new Turba_Form_EditAddressBook($vars, $addressbook); @@ -50,8 +48,7 @@ if ($form->validate($vars)) { } } - header('Location: ' . Horde::applicationUrl('addressbooks/', true)); - exit; + Horde::applicationUrl('addressbooks/', true)->redirect(); } $vars->set('name', $addressbook->get('name')); diff --git a/turba/contact.php b/turba/contact.php index 42ab9d96a..2b52407b0 100644 --- a/turba/contact.php +++ b/turba/contact.php @@ -17,16 +17,14 @@ $vars = Horde_Variables::getDefaultVariables(); $source = $vars->get('source'); if (!isset($GLOBALS['cfgSources'][$source])) { $notification->push(_("The contact you requested does not exist.")); - header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true)); - exit; + Horde::applicationUrl($prefs->getValue('initial_page'), true)->redirect(); } /* Set the contact from the key requested. */ $driver = Turba_Driver::singleton($source); if ($driver instanceof PEAR_Error) { $notification->push($driver->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true)); - exit; + Horde::applicationUrl($prefs->getValue('initial_page'), true)->redirect(); } $contact = null; @@ -42,8 +40,7 @@ if (!$contact || ($contact instanceof PEAR_Error)) { $contact = $driver->getObject($vars->get('key')); if ($contact instanceof PEAR_Error) { $notification->push($contact->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true)); - exit; + Horde::applicationUrl($prefs->getValue('initial_page'), true)->redirect(); } } diff --git a/turba/delete.php b/turba/delete.php index 0ccca965a..f2931d000 100644 --- a/turba/delete.php +++ b/turba/delete.php @@ -21,13 +21,11 @@ if ($conf['documents']['type'] != 'none') { $object = $driver->getObject($key); if (is_a($object, 'PEAR_Error')) { $notification->push($object->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true)); - exit; + Horde::applicationUrl($prefs->getValue('initial_page'), true)->redirect(); } if (is_a($deleted = $object->deleteFiles(), 'PEAR_Error')) { $notification->push($deleted, 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true)); - exit; + Horde::applicationUrl($prefs->getValue('initial_page'), true)->redirect(); } } diff --git a/turba/deletefile.php b/turba/deletefile.php index 9eeafbb4d..775acc12f 100644 --- a/turba/deletefile.php +++ b/turba/deletefile.php @@ -20,22 +20,19 @@ if ($conf['documents']['type'] == 'none') { $source = Horde_Util::getPost('source'); if ($source === null || !isset($cfgSources[$source])) { $notification->push(_("Not found"), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true)); - exit; + Horde::applicationUrl($prefs->getValue('initial_page'), true)->redirect(); } $driver = Turba_Driver::singleton($source); $contact = $driver->getObject(Horde_Util::getPost('key')); if (is_a($contact, 'PEAR_Error')) { $notification->push($contact, 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true)); - exit; + Horde::applicationUrl($prefs->getValue('initial_page'), true)->redirect(); } if (!$contact->isEditable()) { $notification->push(_("Permission denied"), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true)); - exit; + Horde::applicationUrl($prefs->getValue('initial_page'), true)->redirect(); } $file = Horde_Util::getPost('file'); @@ -45,4 +42,4 @@ if (is_a($result, 'PEAR_Error')) { } else { $notification->push(sprintf(_("The file \"%s\" has been deleted."), $file), 'horde.success'); } -$url = header('Location: ' . $contact->url('Contact', true)); +$contact->url('Contact', true)->redirect(); diff --git a/turba/edit.php b/turba/edit.php index dd9893ec6..c8bd0a5a8 100644 --- a/turba/edit.php +++ b/turba/edit.php @@ -20,14 +20,13 @@ $original_source = $vars->get('original_source'); $key = $vars->get('key'); $groupedit = $vars->get('actionID') == 'groupedit'; $objectkeys = $vars->get('objectkeys'); -$url = Horde_Util::getFormData('url', Horde::applicationUrl($prefs->getValue('initial_page'), true)); +$url = new Horde_Url(Horde_Util::getFormData('url', Horde::applicationUrl($prefs->getValue('initial_page'), true)); /* Edit the first of a list of contacts? */ if ($groupedit && (!$key || $key == '**search')) { if (!count($objectkeys)) { $notification->push(_("You must select at least one contact first."), 'horde.warning'); - header('Location: ' . $url); - exit; + $url->redirect(); } if ($key == '**search') { $original_source = $key; @@ -43,8 +42,7 @@ if ($groupedit && (!$key || $key == '**search')) { if ($source === null || !isset($cfgSources[$source])) { $notification->push(_("Not found"), 'horde.error'); - header('Location: ' . $url); - exit; + $url->redirect(); } $driver = Turba_Driver::singleton($source); @@ -53,20 +51,17 @@ $driver = Turba_Driver::singleton($source); $contact = $driver->getObject($key); if (is_a($contact, 'PEAR_Error')) { $notification->push($contact, 'horde.error'); - header('Location: ' . $url); - exit; + $url->redirect(); } /* Check permissions on this contact. */ if (!$contact->hasPermission(Horde_Perms::EDIT)) { if (!$contact->hasPermission(Horde_Perms::READ)) { $notification->push(_("You do not have permission to view this contact."), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true)); - exit; + $url->redirect(); } else { $notification->push(_("You only have permission to view this contact."), 'horde.error'); - header('Location: ' . $contact->url('Contact', true)); - exit; + $contact->url('Contact', true)->redirect(); } } @@ -86,8 +81,7 @@ if (!is_a($edited, 'PEAR_Error')) { } else { $url = new Horde_Url($url, true); } - header('Location: ' . $url->unique()); - exit; + $url->unique()->redirect(); } $title = sprintf(_("Edit \"%s\""), $contact->getValue('name')); diff --git a/turba/lib/Form/AddContact.php b/turba/lib/Form/AddContact.php index 5c3b0f892..05dd7e9a9 100644 --- a/turba/lib/Form/AddContact.php +++ b/turba/lib/Form/AddContact.php @@ -80,8 +80,10 @@ class Turba_Form_AddContact extends Turba_Form_Contact $ob = $driver->getObject($key); if (!is_a($ob, 'PEAR_Error')) { $notification->push(sprintf(_("%s added."), $ob->getValue('name')), 'horde.success'); - header('Location: ' . (!empty($info['url']) ? $info['url'] : $ob->url('Contact', true))); - exit; + $url = empty($info['url']) + ? $ob->url('Contact', true) + : new Horde_Url($info['url']); + $url->redirect(); } sleep(1); } diff --git a/turba/lib/Form/EditContactGroup.php b/turba/lib/Form/EditContactGroup.php index a443caa8c..d175b98a2 100644 --- a/turba/lib/Form/EditContactGroup.php +++ b/turba/lib/Form/EditContactGroup.php @@ -88,8 +88,7 @@ class Turba_Form_EditContactGroup extends Turba_Form_EditContact } } - header('Location: ' . $next_page->setRaw(true)); - exit; + $next_page->redirect(); } } diff --git a/turba/lib/View/Browse.php b/turba/lib/View/Browse.php index 3bf8c33a9..6c71b5ead 100644 --- a/turba/lib/View/Browse.php +++ b/turba/lib/View/Browse.php @@ -331,8 +331,8 @@ class Turba_View_Browse { // We might get here from the search page but are not allowed to browse // the current address book. if ($actionID && empty($cfgSources[$source]['browse'])) { - header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true)); - exit; + Horde::applicationUrl($prefs->getValue('initial_page'), true) + ->redirect(); } } diff --git a/turba/merge.php b/turba/merge.php index 00b1a3edc..10a285247 100644 --- a/turba/merge.php +++ b/turba/merge.php @@ -25,28 +25,23 @@ if ($url = Horde_Util::getFormData('url')) { $contact = $driver->getObject($mergeInto); if (is_a($contact, 'PEAR_Error')) { $notification->push($contact); - header('Location: ' . $url); - exit; + $url->redirect(); } $toMerge = $driver->getObject($key); if (is_a($toMerge, 'PEAR_Error')) { $notification->push($toMerge); - header('Location: ' . $url); - exit; + $url->redirect(); } $contact->merge($toMerge); if (is_a($result = $contact->store(), 'PEAR_Error')) { $notification->push($result); - header('Location: ' . $url); - exit; + $url->redirect(); } if (is_a($result = $driver->delete($key), 'PEAR_Error')) { $notification->push($result); - header('Location: ' . $url); - exit; + $url->redirect(); } $notification->push(_("Successfully merged two contacts."), 'horde.success'); -header('Location: ' . $url); -exit; +$url->redirect(); diff --git a/turba/search.php b/turba/search.php index cf1b60d49..4e3608e6b 100644 --- a/turba/search.php +++ b/turba/search.php @@ -141,8 +141,7 @@ if (is_a($driver, 'PEAR_Error')) { $vname = Horde_Util::getFormData('vbook_name'); if (empty($vname)) { $notification->push(_("You must provide a name for virtual address books."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('search.php', true)); - exit; + Horde::applicationUrl('search.php', true)->redirect(); } /* Create the vbook. */ @@ -154,14 +153,13 @@ if (is_a($driver, 'PEAR_Error')) { $vid = _createVBook($params); if (is_a($vid, 'PEAR_Error')) { $notification->push(sprintf(_("There was a problem creating the virtual address book: %s"), $vid->getMessage()), 'horde.error'); - header('Location: ' . Horde::applicationUrl('search.php', true)); - exit; + Horde::applicationUrl('search.php', true)->redirect(); } $notification->push(sprintf(_("Successfully created virtual address book \"%s\""), $vname), 'horde.success'); - $url = Horde::applicationURL('browse.php', true)->add('source', $vid);; - header('Location: ' . $url->setRaw(true)); - exit; + Horde::applicationUrl('browse.php', true) + ->add('source', $vid) + ->redirect(); } /* Perform a search. */ diff --git a/turba/vcard.php b/turba/vcard.php index 0a5a46914..e2168da44 100644 --- a/turba/vcard.php +++ b/turba/vcard.php @@ -16,8 +16,7 @@ Horde_Registry::appInit('turba'); $source = Horde_Util::getFormData('source'); if (!isset($cfgSources[$source])) { $notification->push(_("The contact you requested does not exist."), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true)); - exit; + Horde::applicationUrl($prefs->getValue('initial_page'), true)->redirect(); } $driver = Turba_Driver::singleton($source); @@ -27,15 +26,13 @@ $key = Horde_Util::getFormData('key'); $object = $driver->getObject($key); if (is_a($object, 'PEAR_Error')) { $notification->push($object->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true)); - exit; + Horde::applicationUrl($prefs->getValue('initial_page'), true)->redirect(); } /* Check permissions on this contact. */ if (!$object->hasPermission(Horde_Perms::READ)) { $notification->push(_("You do not have permission to view this object."), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('initial_page'), true)); - exit; + Horde::applicationUrl($prefs->getValue('initial_page'), true)->redirect(); } $filename = str_replace(' ', '_', $object->getValue('name')); diff --git a/vilma/domains/delete.php b/vilma/domains/delete.php index 185cde495..6b0d2a521 100644 --- a/vilma/domains/delete.php +++ b/vilma/domains/delete.php @@ -30,15 +30,12 @@ if ($vars->get('submitbutton') == _("Delete")) { $notification->push(sprintf(_("Error deleting domain. %s."), $delete->getMessage()), 'horde.error'); } else { $notification->push(_("Domain deleted."), 'horde.success'); - $url = Horde::applicationUrl('domains/index.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('domains/index.php', true)->redirect(); } } } elseif ($vars->get('submitbutton') == _("Do not delete")) { $notification->push(_("Domain not deleted."), 'horde.message'); - header('Location: ' . Horde::applicationUrl('domains/index.php')); - exit; + Horde::applicationUrl('domains/index.php', true)->redirect(); } /* Render the form. */ diff --git a/vilma/domains/edit.php b/vilma/domains/edit.php index d45a86f1d..32cc2c79d 100644 --- a/vilma/domains/edit.php +++ b/vilma/domains/edit.php @@ -31,9 +31,7 @@ if ($form->validate($vars)) { $notification->push(sprintf(_("Error saving domain: %s."), $domain_id->getMessage()), 'horde.error'); } else { $notification->push(_("Domain saved."), 'horde.success'); - $url = Horde::applicationUrl('domains/index.php', true); - header('Location: ' . $url); - exit; + Horde::applicationUrl('domains/index.php', true)->redirect(); } } diff --git a/vilma/users/delete.php b/vilma/users/delete.php index 2a7c9d48a..46d1e114b 100644 --- a/vilma/users/delete.php +++ b/vilma/users/delete.php @@ -105,28 +105,25 @@ if($groupsCount > 0) { } $form->addVariable(sprintf(_($desc), $user_name), 'description', 'description', false); if ($vars->get('submitbutton') == _("Delete")) { - if($type == 'alias') { + if ($type == 'alias') { if ($form->validate($vars)) { $form->getInfo($vars, $info); $deleteInfo = array(); - $deleteInfo['address'] = $address['destination']; - $deleteInfo['alias'] = $user_id; - $delete = $vilma->driver->deleteAlias($deleteInfo); + $deleteInfo['address'] = $address['destination']; + $deleteInfo['alias'] = $user_id; + $delete = $vilma->driver->deleteAlias($deleteInfo); if (is_a($delete, 'PEAR_Error')) { Horde::logMessage($delete, 'ERR'); - $notification->push(sprintf(_("Error deleting alias. %s."), $delete->getMessage()), 'horde.error'); - $url = Util::addParameter(Horde::applicationUrl('users/index.php'), 'domain_id', $domain['id'], false); - header('Location: ' . $url); - exit; - } else { - $notification->push(_("Alias deleted."), 'horde.success'); - $url = Util::addParameter(Horde::applicationUrl('users/index.php'), 'domain_id', $domain['id'], false); - header('Location: ' . $url); - exit; - } - } - } elseif ($type == 'forward') { - if ($form->validate($vars)) { + $notification->push(sprintf(_("Error deleting alias. %s."), $delete->getMessage()), 'horde.error'); + } else { + $notification->push(_("Alias deleted."), 'horde.success'); + } + Horde::applicationUrl('users/index.php') + ->add('domain_id', $domain['id']) + ->redirect(); + } + } elseif ($type == 'forward') { + if ($form->validate($vars)) { $form->getInfo($vars, $info); $deleteInfo = array(); $deleteInfo['address'] = $address['destination']; @@ -135,15 +132,12 @@ if ($vars->get('submitbutton') == _("Delete")) { if (is_a($delete, 'PEAR_Error')) { Horde::logMessage($delete, 'ERR'); $notification->push(sprintf(_("Error deleting forward. %s."), $delete->getMessage()), 'horde.error'); - $url = Horde_Util::addParameter(Horde::applicationUrl('users/index.php'), 'domain_id', $domain['id'], false); - header('Location: ' . $url); - exit; } else { $notification->push(_("Forward deleted."), 'horde.success'); - $url = Horde_Util::addParameter(Horde::applicationUrl('users/index.php'), 'domain_id', $domain['id'], false); - header('Location: ' . $url); - exit; } + Horde::applicationUrl('users/index.php') + ->add('domain_id', $domain['id']) + ->redirect(); } } else { if ($form->validate($vars)) { @@ -153,22 +147,19 @@ if ($vars->get('submitbutton') == _("Delete")) { if (is_a($delete, 'PEAR_Error')) { Horde::logMessage($delete, 'ERR'); $notification->push(sprintf(_("Error deleting user. %s."), $delete->getMessage()), 'horde.error'); - $url = Horde_Util::addParameter(Horde::applicationUrl('users/index.php'), 'domain_id', $domain['id'], false); - header('Location: ' . $url); - exit; } else { $notification->push(_("$type deleted."), 'horde.success'); - $url = Horde_Util::addParameter(Horde::applicationUrl('users/index.php'), 'domain_id', $domain['id'], false); - header('Location: ' . $url); - exit; } + Horde::applicationUrl('users/index.php') + ->add('domain_id', $domain['id']) + ->redirect(); } } } elseif ($vars->get('submitbutton') == _("Do not delete")) { $notification->push(_("User not deleted."), 'horde.message'); - $url = Horde_Util::addParameter(Horde::applicationUrl('users/index.php'), 'domain_id', $domain['domain_id'], false); - header('Location: ' . $url); - exit; + Horde::applicationUrl('users/index.php') + ->add('domain_id', $domain['id']) + ->redirect(); } /* Render the form. */ diff --git a/vilma/users/editAlias.php b/vilma/users/editAlias.php index c38bf7c7a..83dfd956d 100644 --- a/vilma/users/editAlias.php +++ b/vilma/users/editAlias.php @@ -23,36 +23,37 @@ $vars = Variables::getDefaultVariables(); /* If the form is submitted, $vars['mode'] will be set. Catch this and process the submission so that the displayed form accurately indicates the result of the transaction. */ if ($vars->exists('mode')) { - Horde::logMessage("Submit Detected: " . print_r(serialize($vars), true), 'DEBUG'); - $form = &new EditAliasForm($vars); + Horde::logMessage("Submit Detected: " . print_r(serialize($vars), true), 'DEBUG'); + $form = &new EditAliasForm($vars); - if ($form->validate($vars)) { - $form->getInfo($vars, $info); - $alias_id = $vilma->driver->saveAlias($info); - if (is_a($alias_id, 'PEAR_Error')) { - Horde::logMessage($user_id, 'ERR'); - $notification->push(sprintf(_("Error saving alias. %s"), $alias_id->getMessage()), 'horde.error'); - // remove the mode, and rearrange the alias information to clean up the form. - $vars->remove('mode'); - $vars->add('retry', true); - if ($vars->exists('alias')) { - $vars->remove('alias_address'); - } elseif ($vars->exists('address')) { - $vars->remove('alias_address'); - $vars->remove('alias'); - } - } else { - $notification->push(_("Alias saved."), 'horde.success'); - $url = Util::addParameter(Horde::applicationUrl('users/index.php'), 'domain_id', $domain['id'], false); - header('Location: ' . $url); - exit; - } - } -} // if + if ($form->validate($vars)) { + $form->getInfo($vars, $info); + $alias_id = $vilma->driver->saveAlias($info); + if (is_a($alias_id, 'PEAR_Error')) { + Horde::logMessage($user_id, 'ERR'); + $notification->push(sprintf(_("Error saving alias. %s"), $alias_id->getMessage()), 'horde.error'); + // remove the mode, and rearrange the alias information to clean + // up the form. + $vars->remove('mode'); + $vars->add('retry', true); + if ($vars->exists('alias')) { + $vars->remove('alias_address'); + } elseif ($vars->exists('address')) { + $vars->remove('alias_address'); + $vars->remove('alias'); + } + } else { + $notification->push(_("Alias saved."), 'horde.success'); + Horde::applicationUrl('users/index.php') + ->add('domain_id', $domain['id']) + ->redirect(); + } + } +} /* Check if a form is being edited. */ if (!$vars->exists('mode') || $vars->getExists('retry')) { - Horde::logMessage("No-Submit Detected: " . print_r(serialize($vars), true), 'DEBUG'); + Horde::logMessage("No-Submit Detected: " . print_r(serialize($vars), true), 'DEBUG'); if ($vars->exists("alias")) { $alias = $vars->get("alias"); Horde::logMessage("Alias Detected: $alias", 'DEBUG'); diff --git a/vilma/users/index.php b/vilma/users/index.php index 0affc5d1d..7bfe881a9 100644 --- a/vilma/users/index.php +++ b/vilma/users/index.php @@ -31,7 +31,7 @@ $tabs = Vilma::getUserMgrTabs($vars); $addresses = $vilma->driver->getAddresses($curdomain['domain_name'], $section); if (is_a($addresses, 'PEAR_Error')) { $notification->push($addresses); - header('Location: ' . Horde::applicationUrl('index.php')); + Horde::applicationUrl('index.php')->redirect(); } // Page results diff --git a/vilma/virtuals/delete.php b/vilma/virtuals/delete.php index a73fdfda9..1b35457a8 100644 --- a/vilma/virtuals/delete.php +++ b/vilma/virtuals/delete.php @@ -40,16 +40,16 @@ if ($vars->get('submitbutton') == _("Delete")) { $notification->push(sprintf(_("Error deleting virtual email. %s."), $delete->getMessage()), 'horde.error'); } else { $notification->push(_("Virtual email deleted."), 'horde.success'); - $url = Horde_Util::addParameter(Horde::applicationUrl('virtuals/index.php'), 'domain_id', $domain['domain_id'], false); - header('Location: ' . $url); - exit; + Horde::applicationUrl('virtuals/index.php') + ->add('domain_id', $domain['domain_id']) + ->redirect(); } } } elseif ($vars->get('submitbutton') == _("Do not delete")) { $notification->push(_("Virtual email not deleted."), 'horde.message'); - $url = Horde_Util::addParameter(Horde::applicationUrl('virtuals/index.php'), 'domain_id', $domain['domain_id'], false); - header('Location: ' . $url); - exit; + Horde::applicationUrl('virtuals/index.php') + ->add('domain_id', $domain['domain_id']) + ->redirect(); } /* Render the form. */ diff --git a/vilma/virtuals/edit.php b/vilma/virtuals/edit.php index 987f86609..245fdefa1 100644 --- a/vilma/virtuals/edit.php +++ b/vilma/virtuals/edit.php @@ -72,9 +72,9 @@ if ($form->validate($vars)) { $notification->push(sprintf(_("Error saving virtual email. %s."), $virtual_id->getMessage()), 'horde.error'); } else { $notification->push(_("Virtual email saved."), 'horde.success'); - $url = Horde::applicationUrl('virtuals/index.php', true); - header('Location: ' . Horde_Util::addParameter($url, 'user', $info['virtual_destination'], false)); - exit; + Horde::applicationUrl('virtuals/index.php') + ->add('user', $info['virtual_destination']) + ->redirect(); } } diff --git a/vilma/virtuals/index.php b/vilma/virtuals/index.php index f8e9bb8f5..9632583d5 100644 --- a/vilma/virtuals/index.php +++ b/vilma/virtuals/index.php @@ -27,7 +27,7 @@ if (!empty($user)) { if (is_a($virtuals, 'PEAR_Error')) { $notification->push($virtuals); - header('Location: ' . Horde::applicationUrl('index.php')); + Horde::applicationUrl('index.php')->redirect(); } foreach ($virtuals as $id => $virtual) { diff --git a/whups/admin/index.php b/whups/admin/index.php index 3c6413bdc..0949ea224 100644 --- a/whups/admin/index.php +++ b/whups/admin/index.php @@ -195,8 +195,7 @@ case 'clonetypeform': $notification->push(sprintf(_("Successfully Cloned %s to %s."), $type['name'], $vars->get('name')), 'horde.success'); - header('Location: ' . Horde::applicationUrl('admin/?action=type', true)); - exit; + Horde::applicationUrl('admin/?action=type', true)->redirect(); } else { _open(); $form->renderActive($renderer, $vars, $adminurl, 'post'); diff --git a/whups/data.php b/whups/data.php index 6a5b28298..4c84a0f09 100644 --- a/whups/data.php +++ b/whups/data.php @@ -14,8 +14,7 @@ Horde_Registry::appInit('whups'); require WHUPS_BASE . '/config/templates.php'; if (!$GLOBALS['registry']->getAuth()) { - header('Location: ' . Horde::applicationUrl('search.php', true)); - exit; + Horde::applicationUrl('search.php', true)->redirect(); } $tpl = Horde_Util::getFormData('template'); diff --git a/whups/lib/Ticket.php b/whups/lib/Ticket.php index 5b0780927..8ca2731a1 100644 --- a/whups/lib/Ticket.php +++ b/whups/lib/Ticket.php @@ -529,8 +529,7 @@ class Whups_Ticket { */ function show() { - header('Location: ' . Whups::urlFor('ticket', $this->_id, true)); - exit; + Whups::urlFor('ticket', $this->_id, true)->redirect(); } /** diff --git a/whups/lib/Whups.php b/whups/lib/Whups.php index d3724707a..5b88390c1 100644 --- a/whups/lib/Whups.php +++ b/whups/lib/Whups.php @@ -261,8 +261,8 @@ class Whups { $id = preg_replace('|\D|', '', Horde_Util::getFormData('id')); if (!$id) { $GLOBALS['notification']->push(_("Invalid Ticket Id"), 'horde.error'); - header('Location: ' . Horde::applicationUrl($GLOBALS['prefs']->getValue('whups_default_view') . '.php', true)); - exit; + Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true) + ->redirect(); } $ticket = Whups_Ticket::makeTicket($id); @@ -270,14 +270,11 @@ class Whups { if ($ticket->code === 0) { // No permissions to this ticket. $GLOBALS['notification']->push($ticket->getMessage(), 'horde.warning'); - $url = Horde::applicationUrl($GLOBALS['prefs']->getValue('whups_default_view') . '.php', true); } else { $GLOBALS['notification']->push($ticket->getMessage(), 'horde.error'); - $url = Horde::applicationUrl($GLOBALS['prefs']->getValue('whups_default_view') . '.php', true); } - - header('Location: ' . $url); - exit; + Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true) + ->redirect(); } return $ticket; diff --git a/whups/query/index.php b/whups/query/index.php index 1ef651a52..aae50286e 100644 --- a/whups/query/index.php +++ b/whups/query/index.php @@ -28,8 +28,8 @@ if (isset($_SESSION['whups']['query'])) { $whups_query = unserialize($_SESSION['whups']['query']); if (!$whups_query->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) { $notification->push(_("Permission denied."), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true)); - exit; + Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true) + ->redirect(); } } else { $whups_query = $qManager->newQuery(); diff --git a/whups/query/run.php b/whups/query/run.php index 863114992..1dd7d2a8f 100644 --- a/whups/query/run.php +++ b/whups/query/run.php @@ -42,8 +42,8 @@ if (!isset($whups_query) || } elseif (isset($whups_query)) { $notification->push(_("Permission denied."), 'horde.error'); } - header('Location: ' . Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true)); - exit; + Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true) + ->redirect(); } // Query actions. diff --git a/whups/queue/index.php b/whups/queue/index.php index ccffc79ca..c580a4e53 100644 --- a/whups/queue/index.php +++ b/whups/queue/index.php @@ -25,8 +25,8 @@ if ($slug) { if (!$id || is_a($queue, 'PEAR_Error')) { $notification->push(_("Invalid queue"), 'horde.error'); - header('Location: ' . Horde::applicationUrl(basename($prefs->getValue('whups_default_view')) . '.php', true)); - exit; + Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true) + ->redirect(); } // Update sorting preferences. diff --git a/whups/search.php b/whups/search.php index a0a7d363a..bb7c62294 100644 --- a/whups/search.php +++ b/whups/search.php @@ -130,8 +130,9 @@ if (($vars->get('formname') || $vars->get('summary') || $vars->get('states') || } } $_SESSION['whups']['query'] = serialize($whups_query); - header('Location: ' . Horde::applicationUrl(Horde_Util::addParameter('query/index.php', 'action', 'save'), true)); - exit; + Horde::applicationUrl('query/index.php', true) + ->add('action', 'save') + ->redirect(); } $tickets = $whups_driver->getTicketsByProperties($info); if (is_a($tickets, 'PEAR_Error')) { diff --git a/whups/ticket/create.php b/whups/ticket/create.php index e2d3d17a3..473316336 100644 --- a/whups/ticket/create.php +++ b/whups/ticket/create.php @@ -52,11 +52,10 @@ if ($valid1 && $valid2 && $valid3 && $notification->push(sprintf(_("Adding your ticket failed: %s."), $ticket->getMessage()), 'horde.error'); - header('Location: ' . Horde::applicationUrl('ticket/create.php', true)); - } else { - $notification->push(sprintf(_("Your ticket ID is %s. An appropriate person has been notified of this request."), $ticket->getId()), 'horde.success'); - $ticket->show(); + Horde::applicationUrl('ticket/create.php', true)->redirect(); } + $notification->push(sprintf(_("Your ticket ID is %s. An appropriate person has been notified of this request."), $ticket->getId()), 'horde.success'); + $ticket->show(); exit; } diff --git a/whups/ticket/delete.php b/whups/ticket/delete.php index d0c65cf53..973c99e8b 100644 --- a/whups/ticket/delete.php +++ b/whups/ticket/delete.php @@ -45,8 +45,8 @@ $ticket = Whups::getCurrentTicket(); $details = $ticket->getDetails(); if (!Whups::hasPermission($details['queue'], 'queue', Horde_Perms::DELETE)) { $notification->push(_("Permission Denied"), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true)); - exit; + Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true) + ->redirect(); } $vars = Horde_Variables::getDefaultVariables(); @@ -65,11 +65,10 @@ if ($vars->get('formname') == 'deleteticketform') { if (!is_a($result, 'PEAR_Error')) { $notification->push(sprintf(_("Ticket %d has been deleted."), $info['id']), 'horde.success'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true)); - exit; - } else { - $notification->push(_("There was an error deleting the ticket:") . ' ' . $result->getMessage(), 'horde.error'); + Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true) + ->redirect(); } + $notification->push(_("There was an error deleting the ticket:") . ' ' . $result->getMessage(), 'horde.error'); } else { $notification->push(_("The ticket was not deleted."), 'horde.message'); } diff --git a/whups/ticket/delete_attachment.php b/whups/ticket/delete_attachment.php index d9b0edb9c..aef069531 100644 --- a/whups/ticket/delete_attachment.php +++ b/whups/ticket/delete_attachment.php @@ -15,8 +15,8 @@ Horde_Registry::appInit('whups'); $ticket = Whups::getCurrentTicket(); if (!Whups::hasPermission($ticket->get('queue'), 'queue', Horde_Perms::DELETE)) { $notification->push(_("Permission Denied"), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true)); - exit; + Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true) + ->redirect(); } $file = basename(Horde_Util::getFormData('file')); @@ -31,5 +31,6 @@ if (is_a($result, 'PEAR_Error')) { if ($url = Horde_Util::getFormData('url')) { header('Location: ' . $url); } else { - header('Location: ' . Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true)); + Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true) + ->redirect(); } diff --git a/whups/ticket/delete_history.php b/whups/ticket/delete_history.php index b7973d327..da984b8f0 100644 --- a/whups/ticket/delete_history.php +++ b/whups/ticket/delete_history.php @@ -14,8 +14,8 @@ Horde_Registry::appInit('whups'); $ticket = Whups::getCurrentTicket(); if (!Whups::hasPermission($ticket->get('queue'), 'queue', Horde_Perms::DELETE)) { $notification->push(_("Permission Denied"), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true)); - exit; + Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true) + ->redirect(); } $vars = Horde_Variables::getDefaultVariables(); @@ -29,5 +29,6 @@ if (is_a($result, 'PEAR_Error')) { if ($url = Horde_Util::getFormData('url')) { header('Location: ' . $url); } else { - header('Location: ' . Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true)); + Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true) + ->redirect(); } diff --git a/whups/ticket/queue.php b/whups/ticket/queue.php index 3bdfb4d05..078731414 100644 --- a/whups/ticket/queue.php +++ b/whups/ticket/queue.php @@ -125,8 +125,8 @@ foreach ($ticket->getDetails() as $varname => $value) { // Check permissions on this ticket. if (!Whups::hasPermission($ticket->get('queue'), 'queue', Horde_Perms::DELETE)) { $notification->push(_("Permission Denied"), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true)); - exit; + Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true) + ->redirect(); } $form = $vars->get('formname'); diff --git a/whups/ticket/type.php b/whups/ticket/type.php index 6e2fee0ae..03bb182ff 100644 --- a/whups/ticket/type.php +++ b/whups/ticket/type.php @@ -68,8 +68,8 @@ $ticket = Whups::getCurrentTicket(); $details = $ticket->getDetails(); if (!Whups::hasPermission($details['queue'], 'queue', 'update')) { $notification->push(_("Permission Denied"), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true)); - exit; + Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true) + ->redirect(); } $vars = Horde_Variables::getDefaultVariables(); diff --git a/whups/ticket/update.php b/whups/ticket/update.php index e7ee12ce7..318aae335 100644 --- a/whups/ticket/update.php +++ b/whups/ticket/update.php @@ -16,8 +16,8 @@ $ticket = Whups::getCurrentTicket(); if (!Whups::hasPermission($ticket->get('queue'), 'queue', 'update')) { $notification->push(_("Permission Denied"), 'horde.error'); - header('Location: ' . Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true)); - exit; + Horde::applicationUrl($prefs->getValue('whups_default_view') . '.php', true) + ->redirect(); } $vars = Horde_Variables::getDefaultVariables(); diff --git a/whups/view.php b/whups/view.php index a0c442d3d..a90fee505 100644 --- a/whups/view.php +++ b/whups/view.php @@ -24,10 +24,9 @@ $details = $whups_driver->getTicketDetails($id); if (is_a($details, 'PEAR_Error')) { if ($details->code === 0) { // No permissions to this ticket. - $url = Horde::url($registry->get('webroot', 'horde') . '/login.php', true); - $url = Horde_Util::addParameter($url, 'url', Horde::selfUrl(true)); - header('Location: ' . $url); - exit; + Horde::url($registry->get('webroot', 'horde') . '/login.php', true) + ->add('url', Horde::selfUrl(true)) + ->redirect(); } else { Horde::fatal($details->getMessage(), __FILE__, __LINE__); } diff --git a/wicked/diff.php b/wicked/diff.php index 233537526..f72164dfe 100644 --- a/wicked/diff.php +++ b/wicked/diff.php @@ -17,10 +17,9 @@ $v2 = Horde_Util::getFormData('v2'); /* Bail out if we didn't get any versions - at least one of these has * to be non-empty. */ if (!$v1 && !$v2) { - $url = Horde::applicationUrl('history.php', true); - $url = Horde_Util::addParameter($url, 'page', Horde_Util::getFormData('page')); - header('Location: ' . $url); - exit; + Horde::applicationUrl('history.php', true) + ->add('page', Horde_Util::getFormData('page')) + ->redirect(); } /* Make sure that $v2 is a higher version than $v1. Empty string is @@ -35,8 +34,7 @@ if (!$v1 || ($v2 && version_compare($v1, $v2) > 0) || $v2 == '?') { $page = Page::getPage(Horde_Util::getFormData('page'), $v2); if (is_a($page, 'PEAR_Error')) { $notification->push(sprintf(_("Internal error viewing requested page: %s"), $page->getMessage()), 'horde.error'); - header('Location: ' . Wicked::url('WikiHome', true)); - exit; + Wicked::url('WikiHome', true)->redirect(); } if ($v1 == '?') { @@ -46,9 +44,9 @@ if ($v1 == '?') { /* Kick back to the display page if we're not allowed to diff this * page. */ if (!$page->allows(WICKED_MODE_DIFF)) { - $url = Horde_Util::addParameter(Wicked::url($page->pageName(), true), 'actionID', 'diff'); - header('Location: ' . $url); - exit; + Wicked::url($page->pageName(), true) + ->add('actionID', 'diff') + ->redirect(); } $title = sprintf(_("Diff for %s between %s and %s"), $page->pageName(), $v1, $page->version()); diff --git a/wicked/display.php b/wicked/display.php index f7a258c0e..17a1fbb9f 100644 --- a/wicked/display.php +++ b/wicked/display.php @@ -50,10 +50,9 @@ case 'unlock': case 'history': if ($page->allows(WICKED_MODE_HISTORY)) { /* Redirect to history page. */ - $url = Horde::applicationUrl('history.php', true); - $url = Horde_Util::addParameter($url, 'page', $page->pageName()); - header('Location: ' . $url); - exit; + Horde::applicationUrl('history.php') + ->add('page', $page->pageName()) + ->redirect(); } $notification->push(_("This page does not have a history"), 'horde.error'); break; @@ -68,10 +67,8 @@ case 'export': 'horde.error'); if ($page->pageName() == 'WikiHome') { Horde::fatal(_("You don't have permission to view this page."), __FILE__, __LINE__); - } else { - header('Location: ' . Wicked::url('WikiHome', true)); } - exit; + Wicked::url('WikiHome', true)->redirect(); } switch (Horde_Util::getGet('format')) { @@ -114,10 +111,8 @@ if (!$page->allows(WICKED_MODE_DISPLAY)) { 'horde.error'); if ($page->pageName() == 'WikiHome') { Horde::fatal(_("You don't have permission to view this page."), __FILE__, __LINE__); - } else { - header('Location: ' . Wicked::url('WikiHome', true)); } - exit; + Wicked::url('WikiHome', true)->redirect(); } $params = Horde_Util::getFormData('params'); diff --git a/wicked/history.php b/wicked/history.php index d84900cc1..808561e71 100644 --- a/wicked/history.php +++ b/wicked/history.php @@ -14,15 +14,12 @@ Horde_Registry::appInit('wicked'); $page = Page::getCurrentPage(); if (is_a($page, 'PEAR_Error')) { $notification->push(_("Internal error viewing requested page"), 'horde.error'); - header('Location: ' . Wicked::url('WikiHome', true)); - exit; + Wicked::url('WikiHome', true)->redirect(); } if (!$page->allows(WICKED_MODE_HISTORY)) { /* Redirect to display page and force it to display an error. */ - $url = Horde_Util::addParameter(Wicked::url($page->pageName(), true), 'actionID', 'history'); - header('Location: ' . $url); - exit; + Wicked::url($page->pageName(), true)->add('actionID', 'history')->redirect(); } $title = sprintf(_("History: %s"), $page->pageName()); diff --git a/wicked/lib/Page/AddPage.php b/wicked/lib/Page/AddPage.php index 95afcb6f2..83ce23c43 100644 --- a/wicked/lib/Page/AddPage.php +++ b/wicked/lib/Page/AddPage.php @@ -49,8 +49,7 @@ class AddPage extends Page { { if (!strlen($this->referrer())) { $GLOBALS['notification']->push(_("Page name must not be empty")); - header('Location: ' . Wicked::url('', true)); - exit; + Wicked::url('', true)->redirect(); } } diff --git a/wicked/lib/Page/DeletePage.php b/wicked/lib/Page/DeletePage.php index 2fa29bb78..313bd3ecd 100644 --- a/wicked/lib/Page/DeletePage.php +++ b/wicked/lib/Page/DeletePage.php @@ -58,8 +58,7 @@ class DeletePage extends Page { { $page = Page::getPage($this->referrer()); if (!$page->allows(WICKED_MODE_REMOVE)) { - header('Location: ' . Wicked::url($this->referrer(), true)); - exit; + Wicked::url($this->referrer(), true)->redirect(); } } @@ -73,8 +72,7 @@ class DeletePage extends Page { $version = Horde_Util::getFormData('version'); $page = Page::getPage($this->referrer(), $version); if (!$page->isValid()) { - header('Location: ' . Wicked::url('WikiHome', true)); - exit; + Wicked::url('WikiHome', true)->redirect(); } if (empty($version)) { @@ -134,20 +132,17 @@ class DeletePage extends Page { $GLOBALS['notification']->push(sprintf(_("Successfully deleted \"%s\"."), $pagename), 'horde.success'); Wicked::mail("Deleted page: $pagename\n", array('Subject' => '[' . $GLOBALS['registry']->get('name') . '] deleted: ' . $pagename)); - header('Location: ' . Wicked::url('WikiHome', true)); - } else { - $GLOBALS['wicked']->removeVersion($pagename, $version); - $GLOBALS['notification']->push(sprintf(_("Deleted version %s of \"%s\"."), $version, $pagename), 'horde.success'); - Wicked::mail("Deleted version: $version of $pagename\n", - array('Subject' => '[' . $GLOBALS['registry']->get('name') . '] deleted: ' . $pagename . ' [' . $version . ']')); - header('Location: ' . Wicked::url($pagename, true)); + Wicked::url('WikiHome', true)->redirect(); } - exit; + $GLOBALS['wicked']->removeVersion($pagename, $version); + $GLOBALS['notification']->push(sprintf(_("Deleted version %s of \"%s\"."), $version, $pagename), 'horde.success'); + Wicked::mail("Deleted version: $version of $pagename\n", + array('Subject' => '[' . $GLOBALS['registry']->get('name') . '] deleted: ' . $pagename . ' [' . $version . ']')); + Wicked::url($pagename, true)->redirect(); } $GLOBALS['notification']->push(sprintf(_("You don't have permission to delete \"%s\"."), $pagename), 'horde.warning'); - header('Location: ' . Wicked::url($this->referrer(), true)); - exit; + Wicked::url($this->referrer(), true)->redirect(); } } diff --git a/wicked/lib/Page/EditPage.php b/wicked/lib/Page/EditPage.php index 72fb40bf4..9fd3db4e7 100644 --- a/wicked/lib/Page/EditPage.php +++ b/wicked/lib/Page/EditPage.php @@ -83,8 +83,7 @@ class EditPage extends Page { function preDisplay() { if (!$this->allows(WICKED_MODE_EDIT)) { - header('Location: ' . Wicked::url($this->referrer(), true)); - exit; + Wicked::url($this->referrer(), true)->redirect(); } if ($this->allows(WICKED_MODE_LOCKING)) { $page = Page::getPage($this->referrer()); @@ -193,8 +192,7 @@ class EditPage extends Page { } // Show the newly saved page. - header('Location: ' . Wicked::url($this->referrer(), true)); - exit; + Wicked::url($this->referrer(), true)->redirect(); } } diff --git a/wicked/lib/Page/MergeOrRename.php b/wicked/lib/Page/MergeOrRename.php index f92d6f524..b0fcf476f 100644 --- a/wicked/lib/Page/MergeOrRename.php +++ b/wicked/lib/Page/MergeOrRename.php @@ -158,8 +158,7 @@ class MergeOrRename extends Page { global $wicked, $notification, $registry; if (Horde_Util::getFormData('submit') == _("Cancel")) { - header('Location: ' . Wicked::url($this->referrer(), true)); - exit; + Wicked::url($this->referrer(), true)->redirect(); } $referrer = $this->referrer(); @@ -298,8 +297,7 @@ class MergeOrRename extends Page { } } - header('Location: ' . Wicked::url($new_name, true)); - exit; + Wicked::url($new_name, true)->redirect(); } } diff --git a/wicked/lib/Page/NewPage.php b/wicked/lib/Page/NewPage.php index e5cbe4c8d..a81d4da4f 100644 --- a/wicked/lib/Page/NewPage.php +++ b/wicked/lib/Page/NewPage.php @@ -68,13 +68,11 @@ class NewPage extends Page { { if (!strlen($this->referrer())) { $GLOBALS['notification']->push(_("Page name must not be empty")); - header('Location: ' . Wicked::url('', true)); - exit; + Wicked::url('', true)->redirect(); } if (!$this->allows(WICKED_MODE_EDIT)) { - header('Location: ' . Wicked::url($this->referrer(), true)); - exit; + Wicked::url($this->referrer(), true)->redirect(); } } @@ -139,8 +137,7 @@ class NewPage extends Page { } // Show the newly created page. - header('Location: ' . Wicked::url($this->referrer(), true)); - exit; + Wicked::url($this->referrer(), true)->redirect(); } } diff --git a/wicked/lib/Page/RevertPage.php b/wicked/lib/Page/RevertPage.php index 76af97af8..b06ddd452 100644 --- a/wicked/lib/Page/RevertPage.php +++ b/wicked/lib/Page/RevertPage.php @@ -52,8 +52,7 @@ class RevertPage extends Page { { $page = Page::getPage($this->referrer()); if (!$page->allows(WICKED_MODE_EDIT)) { - header('Location: ' . Wicked::url($this->referrer(), true)); - exit; + Wicked::url($this->referrer(), true)->redirect(); } } @@ -116,21 +115,18 @@ class RevertPage extends Page { $version = Horde_Util::getPost('version'); if (empty($version)) { $notification->push(sprintf(_("Can't revert to an unknown version.")), 'horde.error'); - header('Location: ' . Wicked::url($this->referrer(), true)); - } else { - $oldpage = Page::getPage($this->referrer(), $version); - $minor = substr($page->version(), 0, strpos($page->version(), '.')) == - substr($oldpage->version(), 0, strpos($oldpage->version(), '.')); - $page->updateText($oldpage->getText(), 'Revert', $minor); - $notification->push(sprintf(_("Reverted to version %s of \"%s\"."), $version, $page->pageName())); - header('Location: ' . Wicked::url($page->pageName(), true)); + Wicked::url($this->referrer(), true)->redirect(); } - exit; + $oldpage = Page::getPage($this->referrer(), $version); + $minor = substr($page->version(), 0, strpos($page->version(), '.')) == + substr($oldpage->version(), 0, strpos($oldpage->version(), '.')); + $page->updateText($oldpage->getText(), 'Revert', $minor); + $notification->push(sprintf(_("Reverted to version %s of \"%s\"."), $version, $page->pageName())); + Wicked::url($page->pageName(), true)->redirect(); } $notification->push(sprintf(_("You don't have permission to edit \"%s\"."), $page->pageName()), 'horde.warning'); - header('Location: ' . Wicked::url($this->referrer(), true)); - exit; + Wicked::url($this->referrer(), true)->redirect(); } } diff --git a/wicked/lib/Page/SyncPages.php b/wicked/lib/Page/SyncPages.php index fe2ef3e92..01b56c24c 100644 --- a/wicked/lib/Page/SyncPages.php +++ b/wicked/lib/Page/SyncPages.php @@ -291,8 +291,7 @@ class SyncPages extends Page { $GLOBALS['prefs']->setValue('sync_data', serialize($data)); $GLOBALS['notification']->push(_("Sync login info was stored"), 'horde.success'); - header('Location: ' . Wicked::url('SyncPages', true)); - exit; + Wicked::url('SyncPages', true)->redirect(); case _("Remove login info"): $data = unserialize($GLOBALS['prefs']->getValue('sync_data')); @@ -301,8 +300,7 @@ class SyncPages extends Page { $GLOBALS['prefs']->setValue('sync_data', serialize($data)); $GLOBALS['notification']->push(_("Sync login info was removed."), 'horde.success'); - header('Location: ' . Wicked::url('SyncPages', true)); - exit; + Wicked::url('SyncPages', true)->redirect(); } } @@ -394,8 +392,7 @@ class SyncPages extends Page { $GLOBALS['notification']->push(sprintf(_("Page \"%s\" was sucessfuly downloaded from remote to local wiki."), $pageName), 'horde.success'); // Show the newly saved page. - header('Location: ' . Wicked::url($pageName, true)); - exit; + Wicked::url($pageName, true)->redirect(); } /** @@ -424,8 +421,7 @@ class SyncPages extends Page { $GLOBALS['notification']->push(sprintf(_("Page \"%s\" was sucessfully uploaded from local to remote wiki."), $pageName), 'horde.success'); // Show the newly updated page. - header('Location: ' . Wicked::url($pageName, true)); - exit; + Wicked::url($pageName, true)->redirect(); } /**