redirect() 공개 메소드

Sends a redirect request to the browser to the URL in this object.
public redirect ( )
예제 #1
0
 public function testEmptyRedirect()
 {
     $url = new Horde_Url('');
     try {
         $url->redirect();
         $this->fail();
     } catch (Horde_Url_Exception $e) {
     }
 }
예제 #2
0
 /**
  * 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';
             $title = _("Adding A New Gallery");
         }
         // Create the new gallery.
         $perm = !empty($parent) ? $parent->getPermission() : null;
         try {
             $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->createGallery(array('name' => $gallery_name, 'desc' => $gallery_desc, 'tags' => explode(',', $gallery_tags), 'style' => $style, 'slug' => $gallery_slug, 'age' => $gallery_age, 'download' => $gallery_download, 'view_mode' => $gallery_mode, 'passwd' => $gallery_passwd), $perm, $gallery_parent);
             $galleryId = $gallery->id;
             $msg = sprintf(_("The gallery \"%s\" was created successfully."), $gallery_name);
             $GLOBALS['notification']->push($msg, 'horde.success');
             Horde::url('img/upload.php')->add('gallery', $galleryId)->redirect();
         } catch (Ansel_Exception $e) {
             $galleryId = null;
             $error = sprintf(_("The gallery \"%s\" couldn't be created: %s"), $gallery_name, $e->getMessage());
             Horde::log($error, 'ERR');
             $GLOBALS['notification']->push($error, 'horde.error');
             Horde::url(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect();
             exit;
         }
     }
     // Make sure that the style hash is recorded, ignoring non-styled thumbs
     if ($style->thumbstyle != 'Thumb') {
         $GLOBALS['injector']->getInstance('Ansel_Storage')->ensureHash($gallery->getStyle()->getHash('thumb'));
     }
     // Clear the OtherGalleries widget cache
     if ($GLOBALS['conf']['ansel_cache']['usecache']) {
         $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_OtherGalleries' . $gallery->get('owner'));
     }
     // Return to the last view.
     $url = Horde_Util::getFormData('url');
     if (empty($url) && empty($exists)) {
         // Redirect to the images upload page for newly creted galleries
         $url = Horde::url('img/upload.php')->add('gallery', $galleryId);
     } elseif (empty($url)) {
         $url = Horde::url('index.php', true);
     } else {
         $url = new Horde_Url($url);
     }
     $url->redirect();
 }
예제 #3
0
파일: Horde.php 프로젝트: jubinpatel/horde
 /**
  * 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
0
파일: delete.php 프로젝트: horde/horde
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
0
파일: Basic.php 프로젝트: jubinpatel/horde
 /**
  * @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
0
 * 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 <*****@*****.**>
 * @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
0
파일: StoryList.php 프로젝트: horde/horde
 /**
  * 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();
 }