本文整理汇总了PHP中Horde_Url::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Url::redirect方法的具体用法?PHP Horde_Url::redirect怎么用?PHP Horde_Url::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Url
的用法示例。
在下文中一共展示了Horde_Url::redirect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testEmptyRedirect
public function testEmptyRedirect()
{
$url = new Horde_Url('');
try {
$url->redirect();
$this->fail();
} catch (Horde_Url_Exception $e) {
}
}
示例2: _runSave
/**
* Handles saving the gallery information from the form submission, and
* redirects back to previous view when complete.
*
* @return void
*/
private function _runSave()
{
// Check general permissions.
if (!$GLOBALS['registry']->isAdmin() && ($GLOBALS['injector']->getInstance('Horde_Perms')->exists('ansel') && !$GLOBALS['injector']->getInstance('Horde_Perms')->hasPermission('ansel', $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT))) {
$GLOBALS['notification']->push(_("Access denied editing galleries."), 'horde.error');
Horde::url('view.php?view=List', true)->redirect();
exit;
}
// Get the form values.
$galleryId = Horde_Util::getFormData('gallery');
$gallery_name = Horde_Util::getFormData('gallery_name');
$gallery_desc = Horde_Util::getFormData('gallery_desc');
$gallery_slug = Horde_Util::getFormData('gallery_slug');
$gallery_age = (int) Horde_Util::getFormData('gallery_age', 0);
$gallery_download = Horde_Util::getFormData('gallery_download');
$gallery_mode = Horde_Util::getFormData('view_mode', 'Normal');
$gallery_passwd = Horde_Util::getFormData('gallery_passwd');
$gallery_tags = Horde_Util::getFormData('gallery_tags');
$gallery_thumbstyle = Horde_Util::getFormData('gallery_style');
$gallery_parent = Horde_Util::getFormData('gallery_parent');
// Style
$style = new Ansel_Style(array('thumbstyle' => Horde_Util::getFormData('thumbnail_style'), 'background' => Horde_Util::getFormData('background_color'), 'gallery_view' => Horde_Util::getFormData('gallery_view'), 'widgets' => array('Tags' => array('view' => 'gallery'), 'OtherGalleries' => array(), 'Geotag' => array(), 'Links' => array(), 'GalleryFaces' => array(), 'OwnerFaces' => array())));
// Double check for an empty string instead of null
if (empty($gallery_parent)) {
$gallery_parent = null;
}
if ($galleryId && ($exists = $GLOBALS['injector']->getInstance('Ansel_Storage')->galleryExists($galleryId) === true)) {
// Modifying an existing gallery.
$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($galleryId);
if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
$GLOBALS['notification']->push(_("Access denied saving this gallery."), 'horde.error');
} else {
// Don't allow the display name to be nulled out.
if ($gallery_name) {
$gallery->set('name', $gallery_name);
}
$gallery->set('desc', $gallery_desc);
$gallery->setTags(!empty($gallery_tags) ? explode(',', $gallery_tags) : array());
$gallery->set('style', $style);
$gallery->set('slug', $gallery_slug);
$gallery->set('age', $gallery_age);
$gallery->set('download', $gallery_download);
$gallery->set('view_mode', $gallery_mode);
if ($GLOBALS['registry']->getAuth() && $gallery->get('owner') == $GLOBALS['registry']->getAuth()) {
$gallery->set('passwd', $gallery_passwd);
}
// Did the parent change?
$old_parent = $gallery->getParent();
if (!is_null($old_parent)) {
$old_parent_id = $old_parent->id;
} else {
$old_parent_id = null;
}
if ($gallery_parent != $old_parent_id) {
if (!is_null($gallery_parent)) {
$new_parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_parent);
} else {
$new_parent = null;
}
try {
$result = $gallery->setParent($new_parent);
} catch (Ansel_Exception $e) {
$GLOBALS['notification']->push($e->getMessage(), 'horde.error');
Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect();
exit;
}
}
try {
$result = $gallery->save();
$GLOBALS['notification']->push(_("The gallery was saved."), 'horde.success');
} catch (Ansel_Exception $e) {
$GLOBALS['notification']->push($e->getMessage(), 'horde.error');
}
}
} else {
// Is this a new subgallery?
if ($gallery_parent) {
try {
$parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_parent);
} catch (Ansel_Exception $e) {
$GLOBALS['notification']->push($e->getMessage(), 'horde.error');
Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect();
exit;
}
if (!$parent->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
$GLOBALS['notification']->push(_("You do not have permission to add sub galleries to this gallery."), 'horde.error');
Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect();
exit;
}
}
// Require a display name.
if (!$gallery_name) {
$GLOBALS['notification']->push(_("You must provide a display name for your new gallery."), 'horde.warning');
$actionId = 'add';
//.........这里部分代码省略.........
示例3: redirect
/**
* Redirect to the given URL.
*
* @param Horde_Url|string $url The URL to redirect to.
*/
public function redirect($url)
{
$url = new Horde_Url($url);
$url->redirect();
}
示例4: catch
if (Kronolith::showAjaxView()) {
Horde::url('', true)->redirect();
}
$c = Horde_Util::getFormData('calendar');
$driver = Horde_Util::getFormData('type');
$kronolith_driver = Kronolith::getDriver($driver, $c);
if ($eventID = Horde_Util::getFormData('eventID')) {
try {
$event = $kronolith_driver->getEvent($eventID);
} catch (Exception $e) {
if (($url = Horde_Util::getFormData('url')) === null) {
$url = Horde::url($prefs->getValue('defaultview') . '.php', true);
} else {
$url = new Horde_Url($url);
}
$url->redirect();
}
if ($driver != 'resource') {
if ($driver == 'remote') {
/* The remote server is doing the permission checks for us. */
$have_perms = true;
} else {
$share = $injector->getInstance('Kronolith_Shares')->getShare($event->calendar);
if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE, $event->creator)) {
$notification->push(_("You do not have permission to delete this event."), 'horde.warning');
} else {
$have_perms = true;
}
}
} else {
if (!$registry->isAdmin()) {
示例5: _changePassword
/**
* @param string $backend_key Backend key.
*/
private function _changePassword($backend_key)
{
global $conf, $injector, $notification, $registry;
// Check for users that cannot change their passwords.
if (in_array($this->_userid, $conf['user']['refused'])) {
$notification->push(sprintf(_("You can't change password for user %s"), $userid), 'horde.error');
return;
}
// We must be passed the old (current) password.
if (!isset($this->_vars->oldpassword)) {
$notification->push(_("You must give your current password"), 'horde.warning');
return;
}
if (!isset($this->_vars->newpassword0)) {
$notification->push(_("You must give your new password"), 'horde.warning');
return;
}
if (!isset($this->_vars->newpassword1)) {
$notification->push(_("You must verify your new password"), 'horde.warning');
return;
}
if ($this->_vars->newpassword0 != $this->_vars->newpassword1) {
$notification->push(_("Your new passwords didn't match"), 'horde.warning');
return;
}
if ($this->_vars->newpassword0 == $this->_vars->oldpassword) {
$notification->push(_("Your new password must be different from your current password"), 'horde.warning');
return;
}
$b_ptr = $this->_backends[$backend_key];
try {
Horde_Auth::checkPasswordPolicy($this->_vars->newpassword0, isset($b_ptr['policy']) ? $b_ptr['policy'] : array());
} catch (Horde_Auth_Exception $e) {
$notification->push($e, 'horde.warning');
return;
}
// Do some simple strength tests, if enabled in the config file.
if (!empty($conf['password']['strengthtests'])) {
try {
Horde_Auth::checkPasswordSimilarity($this->_vars->newpassword0, array($this->_userid, $this->_vars->oldpassword));
} catch (Horde_Auth_Exception $e) {
$notification->push($e, 'horde.warning');
return;
}
}
try {
$driver = $injector->getInstance('Passwd_Factory_Driver')->create($backend_key);
} catch (Passwd_Exception $e) {
Horde::log($e);
$notification->push(_("Password module is not properly configured"), 'horde.error');
return;
}
try {
$driver->changePassword($this->_userid, $this->_vars->oldpassword, $this->_vars->newpassword0);
} catch (Exception $e) {
$notification->push(sprintf(_("Failure in changing password for %s: %s"), $b_ptr['name'], $e->getMessage()), 'horde.error');
return;
}
$notification->push(sprintf(_("Password changed on %s."), $b_ptr['name']), 'horde.success');
try {
Horde::callHook('password_changed', array($this->_userid, $this->_vars->oldpassword, $this->_vars->newpassword0), 'passwd');
} catch (Horde_Exception_HookNotSet $e) {
}
if (!empty($b_ptr['logout'])) {
$logout_url = $registry->getLogoutUrl(array('msg' => _("Your password has been succesfully changed. You need to re-login to the system with your new password."), 'reason' => Horde_Auth::REASON_MESSAGE));
$registry->clearAuth();
$logout_url->redirect();
}
if ($this->_vars->return_to) {
$url = new Horde_Url($return_to);
$url->redirect();
}
}
示例6: array
* Copyright 1999-2014 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL-2). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl.
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/lgpl LGPL-2
* @package Horde
*/
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('horde', array('authentication' => 'none'));
$vars = $injector->getInstance('Horde_Variables');
$redirect_url = new Horde_Url($vars->get('return_url', Horde::url('login.php', true, array('app' => 'horde'))));
if (!$registry->showService('problem')) {
$redirect_url->redirect();
}
$identity = $injector->getInstance('Horde_Core_Factory_Identity')->create();
$email = $identity->getValue('from_addr');
if (!$email) {
$email = $vars->get('email', $registry->getAuth());
}
$message = $vars->message;
$name = $vars->get('name', $identity->getValue('fullname'));
$subject = $vars->subject;
switch ($vars->actionID) {
case 'send_problem_report':
if ($subject && $message) {
/* This is not a gettext string on purpose. */
$remote = empty($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_ADDR'] : $_SERVER['REMOTE_HOST'];
$user_agent = $_SERVER['HTTP_USER_AGENT'];
示例7: run
/**
* expects
* $registry
* $notification
* $prefs
* $conf
* $channel_id
*/
public function run()
{
extract($this->_params, EXTR_REFS);
$channel = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($channel_id);
if (!Jonah::checkPermissions('channels', Horde_Perms::EDIT, array($channel_id))) {
$notification->push(_("You are not authorised for this action."), 'horde.warning');
throw new Horde_Exception_AuthenticationFailure();
}
/* Check if a URL has been passed. */
$url = Horde_Util::getFormData('url');
if ($url) {
$url = new Horde_Url($url);
}
try {
$stories = $GLOBALS['injector']->getInstance('Jonah_Driver')->getStories(array('channel_id' => $channel_id));
} catch (Exception $e) {
$notification->push(sprintf(_("Invalid channel requested. %s"), $e->getMessage()), 'horde.error');
Horde::url('channels/index.php', true)->redirect();
exit;
}
/* Do some state tests. */
if (empty($stories)) {
$notification->push(_("No available stories."), 'horde.warning');
}
if (!empty($refresh)) {
$notification->push(_("Channel refreshed."), 'horde.success');
}
if (!empty($url)) {
$url->redirect();
exit;
}
/* Build story specific fields. */
foreach ($stories as $key => $story) {
/* published is the publication/release date, updated is the last change date. */
if (!empty($stories[$key]['published'])) {
$stories[$key]['published_date'] = strftime($prefs->getValue('date_format') . ', ' . ($prefs->getValue('twentyFour') ? '%H:%M' : '%I:%M%p'), $stories[$key]['published']);
} else {
$stories[$key]['published_date'] = '';
}
/* Default to no links. */
$stories[$key]['pdf_link'] = '';
$stories[$key]['edit_link'] = '';
$stories[$key]['delete_link'] = '';
$stories[$key]['view_link'] = Horde::link($GLOBALS['injector']->getInstance('Jonah_Driver')->getStoryLink($channel, $story), $story['description']) . htmlspecialchars($story['title']) . '</a>';
/* PDF link. */
$url = Horde::url('stories/pdf.php')->add(array('id' => $story['id'], 'channel_id' => $channel_id));
$stories[$key]['pdf_link'] = $url->link(array('title' => _("PDF version"))) . Horde::img('mime/pdf.png') . '</a>';
/* Edit story link. */
$url = Horde::url('stories/edit.php')->add(array('id' => $story['id'], 'channel_id' => $channel_id));
$stories[$key]['edit_link'] = $url->link(array('title' => _("Edit story"))) . Horde::img('edit.png') . '</a>';
/* Delete story link. */
if (Jonah::checkPermissions('channels', Horde_Perms::DELETE, array($channel_id))) {
$url = Horde::url('stories/delete.php')->add(array('id' => $story['id'], 'channel_id' => $channel_id));
$stories[$key]['delete_link'] = $url->link(array('title' => _("Delete story"))) . Horde::img('delete.png') . '</a>';
}
/* Comment counter. */
if ($conf['comments']['allow'] && $registry->hasMethod('forums/numMessages')) {
$comments = $registry->call('forums/numMessages', array($stories[$key]['id'], 'jonah'));
if (!is_a($comments, 'PEAR_Error')) {
$stories[$key]['comments'] = $comments;
}
}
}
/* Render page */
$title = $channel['channel_name'];
$view = new Horde_View(array('templatePath' => JONAH_TEMPLATES . '/stories'));
$view->stories = $stories;
$view->read = true;
$view->comments = $conf['comments']['allow'] && $registry->hasMethod('forums/numMessages');
$GLOBALS['page_output']->header(array('title' => $title));
$notification->notify(array('listeners' => 'status'));
echo $view->render('index');
$GLOBALS['page_output']->footer();
}