[pLog-svn] Rewrite of getSessionValue()

Jon Daley plogworld at jon.limedaley.com
Sat Jul 8 13:06:46 GMT 2006


 	It looks alright, though I don't think it changes anything.  A 
even simpler version is below.  We don't have a place to check stuff in 
for fixes to 1.0.6, do we?  This particular fix should not be the one to 
open a new branch, though if we do end up using one, this might as well 
get checked in.  I can put this in 1.1, definitely.

>       function getSessionValue( $param, $defaultValue = "" )
>       {
>           $session = HttpVars::getSession();
>           $viewName = $this->className();
>           $keyName = "{$viewName}_{$param}";
>
>           if ( isset($session[$keyName]) && $session[$keyName] != '' ){
>               return $session[$keyName];
>           } else {
>               return $defaultValue;
>           }
>       }



On Sat, 8 Jul 2006, Ammar Ibrahim wrote:

> While reading some code, I stumbled across getSessionValue() in
> class/view/view.class.php . And I think the logic implemented is quite
> complicated to do a really simple thing and there were a few mistakes like
> putting a string variable between quotes. Here's a rewrite, could someone
> please update the 1.0.6 branch, because I don't have SVN accesss.
>
>       /**
>        * retrieves a parameter from the session
>        *
>        * @param param
>        * @param defaultValue
>        * @return The value associated to the parameter or empty if not
>        * found
>        */
>
>       function getSessionValue( $param, $defaultValue = "" )
>       {
>           $session = HttpVars::getSession();
>           $viewName = $this->className();
>           $keyName = "{$viewName}_{$param}";
>
>           $value = '';
>           if ( isset($session[$keyName]) && $session[$keyName] != '' ){
>               $value = $session[$keyName];
>           } else {
>               $value = $defaultValue;
>           }
>
>           return $value;
>       }

-- 
Jon Daley
http://jon.limedaley.com/

There is forgiveness through the cross.


More information about the pLog-svn mailing list