Any idea's?
On Sun, Oct 24, 2010 at 9:52 AM, Jigal sanders <jigalroecha@gmail.com>wrote:
> Hello,
>
> With some help I have created the action helper below, but i don't know
> when to call the saveOriginalUrl function:
>
>
> <?php
> class SF_Controller_Action_Helper_Referrer extends Zend_Controller_Action_Helper_Abstract
> {
> public function saveOriginalUrl(){
> $session = new Zend_Session_Namespace('login');
> $request = $this->getRequest();
> $session->goToAfterLogin = array(
> $request->getActionName(),
> $request->getControllerName(),
> $request->getModuleName(),
>
> );
> return $this->_getRedirect()->gotoSimple('login','user','eventManager');
> }
>
> public function getOriginalUrl(){
> $session = new Zend_Session_Namespace('login');
> if(isset($session->goToAfterLogin)){
> $gotoAfterLogin = $session->goToAfterLogin;
> unset($session->goToAfterLogin);
> return $this->_getRedirect->gotoSimple($gotoAfterLogin);
> }
> return $this->_getRedirect()->gotoUrl('/');
> }
>
> protected function _getRedirect(){
> return Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
> }
> }
>
>
> On Fri, Oct 22, 2010 at 7:12 PM, Hector Virgen <djvirgen@gmail.com> wrote:
>
>> You can avoid the referrer if you keep track of the current page before
>> redirecting to login. Once of the solutions I've used goes a little
>> something like this:
>>
>> // on page that needs login
>> $session = new Zend_Session_Namespace('login');
>> $session->gotoAfterLogin = $this->_request->getRequestUri();
>> return $this->_redirect('login');
>>
>> // on successful login
>> $session = new Zend_Session_Namespace('login');
>> if (isset($session->gotoAfterLogin)) {
>> $gotoAfterLogin = $session->gotoAfterLogin;
>> unset($session->gotoAfterLogin);
>> return $this->_redirect($gotoAfterLogin);
>> }
>> return $this->_redirect('/');
>>
>> To avoid copy/pasting that first bit of code in all of your controllers
>> you
>> can move it to an action helper. Also note the unset() prior to the
>> redirect
>> -- if the user logs out and back in you don't want that redirect to occur
>> again.
>>
>> --
>> *Hector Virgen*
>> Sr. Web Developer
>> Walt Disney Parks and Resorts Online
>> http://www.virgentech.com
>>
>
>
>
> --
> Met vriendelijke groet,
>
> Jigal Sanders
> A.J. Ernststraat 739
> 1082 LK Amsterdam
> Mobiel: 06-42111489
>
--
Met vriendelijke groet,
Jigal Sanders
A.J. Ernststraat 739
1082 LK Amsterdam
Mobiel: 06-42111489
没有评论:
发表评论