$permission = $perms->getPermissionById($perm_id);
} catch (Exception $e) {
$notification->push(_("Invalid parent permission."), 'horde.error');
- $url = Horde::applicationUrl('admin/perms/index.php', true);
- header('Location: ' . $url);
- exit;
+ Horde::applicationUrl('admin/perms/index.php', true)->redirect();
}
/* Set up form. */
$result = $perms->addPermission($child);
}
$notification->push(sprintf(_("\"%s\" was added to the permissions system."), $perms->getTitle($child->getName())), 'horde.success');
- $url = Horde::applicationUrl('admin/perms/edit.php', true);
- $url = Horde_Util::addParameter($url, 'perm_id', $child->getId(), false);
- header('Location: ' . $url);
- exit;
+ Horde::applicationUrl('admin/perms/edit.php', true)->add('perm_id', $child->getId())->redirect();
} catch (Exception $e) {
Horde::logMessage($e, 'ERR');
$notification->push(sprintf(_("\"%s\" was not created: %s."), $perms->getTitle($child->getName()), $e->getMessage()), 'horde.error');
} catch (Exception $e) {
/* If the permission fetched is an error return to permissions list. */
$notification->push(_("Attempt to delete a non-existent permission."), 'horde.error');
- $url = Horde::applicationUrl('admin/perms/index.php', true);
- header('Location: ' . $url);
- exit;
+ Horde::applicationUrl('admin/perms/index.php', true)->redirect();
}
/* Set up form. */
try {
$result = $perms->removePermission($permission, true);
$notification->push(sprintf(_("Successfully deleted \"%s\"."), $perms->getTitle($permission->getName())), 'horde.success');
- $url = Horde::applicationUrl('admin/perms/index.php', true);
- header('Location: ' . $url);
- exit;
+ Horde::applicationUrl('admin/perms/index.php', true)->redirect();
} catch (Exception $e) {
$notification->push(sprintf(_("Unable to delete \"%s\": %s."), $perms->getTitle($permission->getName()), $result->getMessage()), 'horde.error');
}
} elseif ($confirmed === false) {
$notification->push(sprintf(_("Permission \"%s\" not deleted."), $perms->getTitle($permission->getName())), 'horde.success');
- $url = Horde::applicationUrl('admin/perms/index.php', true);
- header('Location: ' . $url);
- exit;
+ Horde::applicationUrl('admin/perms/index.php', true)->redirect();
}
$title = _("Permissions Administration");
* @author Jan Schneider <jan@horde.org>
*/
-function _redirect()
-{
- $GLOBALS['notification']->push(_("Attempt to edit a non-existent permission."), 'horde.error');
- header('Location: ' . Horde::applicationUrl('admin/perms/index.php', true));
- exit;
-}
-
require_once dirname(__FILE__) . '/../../lib/Application.php';
Horde_Registry::appInit('horde', array('admin' => true));
$category = $vars->get('category');
/* See if we need to (and are supposed to) autocreate the permission. */
+$redirect = false;
if ($category !== null) {
try {
$permission = $perms->getPermission($category);
}
$permission->save();
} else {
- _redirect();
+ $redirect = true;
}
} catch (Exception $e) {
- _redirect();
+ $redirect = true;
}
$vars->set('perm_id', $perm_id);
} else {
try {
$permission = $perms->getPermissionById($perm_id);
} catch (Exception $e) {
- _redirect();
+ $redirect = true;
}
}
+if ($redirect) {
+ $notification->push(_("Attempt to edit a non-existent permission."), 'horde.error');
+ Horde::applicationUrl('admin/perms/index.php', true)->redirect();
+}
+
$ui = new Horde_Core_Perms_Ui($perms);
$ui->setVars($vars);
$ui->setupEditForm($permission);
if (empty($app) || !in_array($app, $registry->listAllApps())) {
$notification->push(_("Invalid application."), 'horde.error');
- $url = Horde::applicationUrl('admin/setup/index.php', true);
- header('Location: ' . $url);
- exit;
+ Horde::applicationUrl('admin/setup/index.php', true)->redirect();
}
$vars = Horde_Variables::getDefaultVariables();
fclose($fp);
$notification->push(sprintf(_("Successfully wrote %s"), Horde_Util::realPath($path . '/conf.php')), 'horde.success');
$registry->clearCache();
- header('Location: ' . Horde::applicationUrl('admin/setup/index.php', true));
- exit;
+ Horde::applicationUrl('admin/setup/index.php', true)->redirect();
} else {
/* Cannot write. */
$notification->push(sprintf(_("Could not save the configuration file %s. You can either use one of the options to save the code back on %s or copy manually the code below to %s."), Horde_Util::realPath($path . '/conf.php'), Horde::link(Horde::url('index.php') . '#update', _("Setup")) . _("Setup") . '</a>', Horde_Util::realPath($path . '/conf.php')), 'horde.warning', array('content.raw'));
$upload = _uploadFTP($info);
if ($upload) {
$notification->push(_("Uploaded all application setup files to the server."), 'horde.success');
- $url = Horde::applicationUrl('admin/setup/index.php', true);
- header('Location: ' . $url);
- exit;
+ Horde::applicationUrl('admin/setup/index.php', true)->redirect();
}
}
/* Render the form. */
$notification->push(sprintf(_("Could not delete setup upgrade script \"%s\"."), Horde_Util::realPath($path)), 'horde.error');
}
$registry->clearCache();
- $url = Horde::applicationUrl('admin/setup/index.php', true);
- header('Location: ' . $url);
- exit;
+ Horde::applicationUrl('admin/setup/index.php', true)->redirect();
}
$data = '';
} else {
$notification->push(sprintf(_("Could not save setup upgrade script to: \"%s\"."), $path), 'horde.error');
}
-header('Location: ' . Horde::applicationUrl('admin/setup/index.php', true));
+
+Horde::applicationUrl('admin/setup/index.php', true)->redirect();
}
}
-if (!$main_page) {
+if ($main_page) {
+ $main_page = new Horde_Url($main_page);
+} else {
/* Always redirect to login page if there is no incoming URL and nobody
* is authenticated. */
if (!$registry->getAuth()) {
if (!empty($initial_app) &&
($initial_app != 'horde') &&
$registry->hasPermission($initial_app)) {
- $main_page = Horde::url($initial_app, true) . '/';
+ $main_page = Horde::url($initial_app, true);
} else {
/* Next, try the initial horde page if it is something other than
* index.php or login.php, since that would lead to inifinite
}
}
-header('Location: ' . $main_page);
-exit;
+$main_page->redirect();
if (!isset($_COOKIE[session_name()])) {
$logout_url->add(session_name(), session_id());
}
- header('Location: ' . _addAnchor($logout_url, 'url', $vars, $url_anchor));
- exit;
+ _addAnchor($logout_url, 'url', $vars, $url_anchor)->redirect();
}
$registry->setupSessionHandler();
$change_url->add('return_to', $horde_login_url);
}
- header('Location: ' . $change_url->setRaw(true));
- exit;
+ $change_url->redirect();
}
}
exit;
} elseif ($url_in &&
$registry->isAuthenticated(array('app' => $vars->app))) {
- header('Location: ' . _addAnchor($url_in, 'param', null, $url_anchor));
- exit;
+ _addAnchor($url_in, 'param', null, $url_anchor)->redirect();
}
}
if (!$found) {
$url->add('url', $anchor);
}
- header('Location: ' . _addAnchor($url, 'url', $vars, $url_anchor));
- exit;
+ _addAnchor($url, 'url', $vars, $url_anchor)->redirect();
}
/* Build the <select> widget containing the available languages. */
}
if ($url = Horde_Util::getFormData('url')) {
- header('Location: ' . $url);
+ $url = new Horde_Url($url);
} else {
- header('Location: ' . Horde::applicationUrl('login.php'));
+ $url = Horde::applicationUrl('login.php');
}
+
+$url->redirect();
$auth = $injector->getInstance('Horde_Auth')->getAuth();
if (!$auth->hasCapability('update')) {
$notification->push(_("Changing your password is not supported with the current configuration. Contact your administrator."), 'horde.error');
- header('Location: ' . Horde::getServiceLink('login')->add('url', Horde_Util::getFormData('url'))->setRaw(true));
- exit;
+ Horde::getServiceLink('login')->add('url', Horde_Util::getFormData('url'))->redirect();
}
$vars = Horde_Variables::getDefaultVariables();
$index_url = Horde::applicationUrl('index.php', true);
if (!empty($info['return_to'])) {
- $index_url = Horde_Util::addParameter($index_url, array('url' => $info['return_to']));
+ $index_url->add('url', $info['return_to']);
}
- header('Location: ' . $index_url);
- exit;
+ $index_url->redirect();
} catch (Horde_Auth_Exception $e) {
$notification->push(sprintf(_("Error updating password: %s"), $e->getMessage()), 'horde.error');
}
try {
$facebook = $GLOBALS['injector']->getInstance('Horde_Service_Facebook');
} catch (Horde_Exception $e) {
- $horde_url = Horde::url($registry->get('webroot', 'horde') . '/index.php');
- header('Location: ' . $horde_url);
+ Horde::url($registry->get('webroot', 'horde') . '/index.php')->redirect();
}
/* See why we are here. */
$uid = $facebook->auth->getUser();
$prefs->setValue('facebook', serialize(array('uid' => $uid, 'sid' => $sid)));
$notification->push(_("Succesfully connected your Facebook account."), 'horde.success');
- $url = Horde::url('services/prefs.php', true)->add(array('group' => 'facebook', 'app' => 'horde'));
- header('Location: ' . $url);
+ Horde::url('services/prefs.php', true)->add(array('group' => 'facebook', 'app' => 'horde'))->redirect();
}
-
} else {
/* We are here for an Action request */
/* Redirect to the url or login page if none given. */
$url = Horde_Util::getFormData('url');
-if (empty($url)) {
- $url = Horde::applicationUrl('index.php', true);
-}
-header('Location: ' . $url);
+$url = empty($url)
+ ? Horde::applicationUrl('index.php', true)
+ : $url;
+
+$url->redirect();
/* Send the browser back to the correct page. */
function _returnToPage()
{
- $url = Horde_Util::getFormData('return_url', Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/login.php', true));
- header('Location: ' . str_replace('&', '&', $url));
- exit;
+ (new Horde_Url(Horde_Util::getFormData('return_url', Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/login.php', true))))->redirect();
}
require_once dirname(__FILE__) . '/../lib/Application.php';
$auth = $injector->getInstance('Horde_Auth')->getAuth();
if (!$auth->hasCapability('resetpassword')) {
$notification->push(_("Cannot reset password automatically, contact your administrator."), 'horde.error');
- header('Location: ' . Horde::getServiceLink('login')->add('url', Horde_Util::getFormData('url'))->setRaw(true));
- exit;
+ Horde::getServiceLink('login')->add('url', Horde_Util::getFormData('url'))->redirect();
}
$vars = Horde_Variables::getDefaultVariables();
try {
$mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
$notification->push(_("Your password has been reset, check your email and log in with your new password."), 'horde.success');
- header('Location: ' . Horde::getServiceLink('login')->add('url', $info['url'])->setRaw(true));
+ Horde::getServiceLink('login')->add('url', $info['url'])->redirect();
exit;
} catch (Horde_Exception $e) {
Horde::logMessage($e, 'ERR');
Horde_Registry::appInit('horde');
if (empty($conf['twitter']['enabled'])) {
- $horde_url = Horde::url($registry->get('webroot', 'horde') . '/index.php');
- header('Location: ' . $horde_url);
- exit;
+ Horde::url($registry->get('webroot', 'horde') . '/index.php')->redirect();
}
$twitter = $GLOBALS['injector']->getInstance('Horde_Service_Twitter');
if ($conf['signup']['allow'] !== true ||
!$auth->hasCapability('add')) {
$notification->push(_("User Registration has been disabled for this site."), 'horde.error');
- header('Location: ' . Horde::getServiceLink('login')->setRaw(true));
- exit;
+ Horde::getServiceLink('login')->redirect();
}
try {
} catch (Horde_Exception $e) {
Horde::logMessage($e, 'ERR');
$notification->push(_("User Registration is not properly configured for this site."), 'horde.error');
- header('Location: ' . Horde::getServiceLink('login')->setRaw(true));
- exit;
+ Horde::getServiceLink('login')->redirect();
}
$vars = Horde_Variables::getDefaultVariables();
$notification->push(sprintf(_("There was a problem adding \"%s\" to the system: %s"), $info['user_name'], $e->getMessage()), 'horde.error');
} else {
$notification->push($success_message, 'horde.success');
- header('Location: ' . Horde::getServiceLink('login')->add('url', $info['url'])->setRaw(true));
- exit;
+ Horde::getServiceLink('login')->add('url', $info['url'])->redirect();
}
}
}