--- SessionPlugin.pm.orig 2005-01-21 23:01:33.000000000 -0200 +++ SessionPlugin.pm 2005-01-22 01:41:40.000000000 -0200 @@ -35,6 +35,7 @@ $query $session $sessionId $authUser $doSessionIpMatching $useTransSID $sessionIsAuthenticated $authUserSessionVar $stickskin $sessionLogonUrl $sessionLogonUrlPath + $sticklanguage $stickLanguageVar $stickLanguageOffValue ); #use strict; @@ -194,8 +195,10 @@ # And now setup any explicit session variables specified via CGI _init_cgi_set_and_clear_session_variables() or return 0; - # Now that we're configured, reconfigure our SKIN with stickskin information + # Now that we're configured, reconfigure our SKIN/LANGWEB with + # stickskin/sticklanguage information _init_stickskin() or return 0; + _init_sticklanguage() or return 0; # Plugin correctly initialized (finally) TWiki::Func::writeDebug( "- TWiki::Plugins::${pluginName}::initPlugin( $web.$topic ) is OK" ) if $debug; @@ -284,6 +287,7 @@ $_[0] =~ s/%SESSIONVAR%/$SESSIONVAR/geo if defined( $SESSIONVAR ); $_[0] =~ s/%SESSION_IS_AUTHENTICATED%/$sessionIsAuthenticated/geo if defined( $sessionIsAuthenticated ); $_[0] =~ s/%STICKSKIN%/$stickskin/geo if defined($stickskin); + $_[0] =~ s/%STICKLANGWEB%/$sticklanguage/geo if defined($sticklanguage); $_[0] =~ s/%AUTHUSER_SESSIONVAR%/$authUserSessionVar/geo if defined( $authUserSessionVar ); @@ -291,6 +295,8 @@ $_[0] =~ s/%USE_TRANS_SESSIONID%/$useTransSessionId/geo if defined( $useTransSessionId ); $_[0] =~ s/%STICKSKINVAR%/$stickSkinVar/geo if defined( $stickSkinVar ); $_[0] =~ s/%STICKSKINOFFVALUE%/$stickSkinOffValue/geo if defined( $stickSkinOffValue ); + $_[0] =~ s/%STICKLANGWEBVAR%/$stickLanguageVar/geo if defined( $stickLanguageVar ); + $_[0] =~ s/%STICKLANGWEBOFFVALUE%/$stickLanguageOffValue/geo if defined( $stickLanguageOffValue ); } @@ -581,6 +587,7 @@ my $done_init_authuser; my $done_init_preferences; my $done_init_stickskin; + my $done_init_sticklanguage; my $done_init_cgi_set_and_clear_session_variables; # Calling this sub forces a run of all initialization @@ -598,6 +605,7 @@ undef( $done_init_authuser ); undef( $done_init_preferences ); undef( $done_init_stickskin ); + undef( $done_init_sticklanguage ); undef( $done_init_cgi_set_and_clear_session_variables ); } # end sub _clear_init_function_history @@ -757,11 +765,13 @@ # %USE_TRANS_SESSIONID% is set to $useTransSessionId $useTransSID = $query->cookie( $SESSIONVAR ) ? 0 : $useTransSessionId; - # Get CGI variable to use for sticky skins + # Get CGI variable to use for sticky skins/languages $stickSkinVar = TWiki::Func::getPreferencesValue( "\U$pluginName\E_STICKSKINVAR" ) || "stickskin"; + $stickLanguageVar = TWiki::Func::getPreferencesValue( "\U$pluginName\E_STICKLANGWEBVAR" ) || "sticklanguage"; - # Get value to set STICKSKINVAR variable to in order to "unstick" skins + # Get value to set STICKSKINVAR/LANGWEBVAR variable to in order to "unstick" skins/languages $stickSkinOffValue = TWiki::Func::getPreferencesValue( "\U$pluginName\E_STICKSKINOFFVALUE" ) || "default"; + $stickLanguageOffValue = TWiki::Func::getPreferencesValue( "\U$pluginName\E_STICKLANGWEBOFFVALUE" ) || "default"; return 1; @@ -804,6 +814,42 @@ return 1; } # end of sub _init_stickskin + + # Sets up LANGUAGE corresponding to requested sticky language (if any) + # + # This can (and MUST) be completed in init right after configuration. + # That is, it requires values from user configuration to figure out + # which CGI variable to look at. + sub _init_sticklanguage() + { + return 1 if $done_init_sticklanguage; + return 0 if ! $done_init_globals; # need globals to continue + + $done_init_sticklanguage = 1; + + # See whether user has decided to set a sticklanguage + $sticklanguage = $query->param( $stickLanguageVar ); + + # If a sticklanguage has been selected, save it in the session + if( $sticklanguage ) { + + if( $stickLanguageOffValue ne $sticklanguage ) { + setSessionValueHandler( "LANGWEB", $sticklanguage ); + } + else { + clearSessionValueHandler( "LANGWEB" ); + $sticklanguage = ""; + } + + } + else + { + $sticklanguage = getSessionValueHandler( "LANGWEB" ) || ""; + } + + return 1; + + } # end of sub _init_sticklanguage # =========================