[vhffs-dev] [2188] removed cookie parameter from $panel->redirect, now using $panel-> add_cookie method before

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 2188
Author:   gradator
Date:     2012-05-12 16:02:23 +0200 (Sat, 12 May 2012)
Log Message:
-----------
removed cookie parameter from $panel->redirect, now using $panel->add_cookie method before

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Panel/Auth.pm
    trunk/vhffs-api/src/Vhffs/Panel.pm

Modified: trunk/vhffs-api/src/Vhffs/Panel/Auth.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Auth.pm	2012-05-12 11:09:47 UTC (rev 2187)
+++ trunk/vhffs-api/src/Vhffs/Panel/Auth.pm	2012-05-12 14:02:23 UTC (rev 2188)
@@ -106,18 +106,17 @@
 	$session->param('uid', $user->get_uid);
 	$session->flush();
 
-	my @cookies;
-	push @cookies, new CGI::Cookie(-name => $session->name, -value => $session->id);
+	$panel->add_cookie( $cgi->cookie( -name=>$session->name, -value=>$session->id ) );
 
 	# Refresh cookies (avoid theme and language loss when user deletes cookies).
-	push @cookies, new CGI::Cookie( -name=> 'theme', -value=>$user->get_theme, -expires=>'+10y' );
-	push @cookies, new CGI::Cookie( -name=>'language', -value=>$user->get_lang, -expires=>'+10y' );
+	$panel->add_cookie( $cgi->cookie( -name=>'theme', -value=>$user->get_theme, -expires=>'+10y' ) );
+	$panel->add_cookie( $cgi->cookie( -name=>'language', -value=>$user->get_lang, -expires=>'+10y' ) );
 
 	# Set last login panel to current time
 	$user->update_lastloginpanel;
 	$user->commit;
 
-	$panel->redirect('?do=groupindex', \@cookies);
+	$panel->redirect('?do=groupindex');
 	return;
 }
 

Modified: trunk/vhffs-api/src/Vhffs/Panel.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel.pm	2012-05-12 11:09:47 UTC (rev 2187)
+++ trunk/vhffs-api/src/Vhffs/Panel.pm	2012-05-12 14:02:23 UTC (rev 2188)
@@ -221,7 +221,7 @@
 	my $lang = $cgi->param('lang');
 	$self->add_cookie( $cgi->cookie( -name=>'language', -value=>$lang, -expires=>'+10y' ) ) if defined $lang;
 	$lang = $cgi->cookie('language') unless defined $lang;
-	$lang = $vhffs->get_config->get_default_language unless defined $lang;
+	$lang = $vhffs->get_config->get_default_language unless( defined $lang and grep { $_ eq $lang } $vhffs->get_config->get_available_languages );
 	$lang = 'en_US' unless defined $lang;
 	$self->{lang} = $lang;
 
@@ -504,37 +504,18 @@
 
 =head2 redirect
 
-	$panel->redirect($page, $cookies);
+	$panel->redirect($dest);
 
-Issues a redirection header sending to $page
-(you can specify additional cookies to be sent).
+Issues a redirection header sending to $dest.
 
-This function never returns.
-
-B<C<$page> should be an absolute path>
-
-B<C<$cookies>> can be a CGI::Cookie or a reference
-to a CGI::Cookie array.
-
 =cut
 sub redirect {
-	my ($panel, $dest, $cookies) = @_;
+	my ($panel, $dest) = @_;
 	my $vhffs = $panel->{vhffs};
 	my $cgi = $panel->{cgi};
 	$vhffs->clear_current_user;
 
-	$dest = Encode::encode_utf8( $dest );
-
-	if(defined $cookies) {
-		if(ref($cookies)) {
-			foreach(@$cookies) {
-				print "Set-Cookie: $_\n";
-			}
-		} else {
-			print "Set-Cookie: $cookies\n";
-		}
-	}
-	print $cgi->redirect($dest);
+	print $cgi->redirect( -uri=>Encode::encode_utf8($dest), -cookie=>[ @{$panel->{cookies}} ] );
 }
 
 1;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/