From 88d390978c1e5215b066ab54b71a9bdb2374afbc Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Sat, 26 Sep 2015 22:56:03 +0200 Subject: [PATCH] create more basic available values --- www/inc/classes/basevars.php | 35 ++++++++++++++++++++++++++++++++++- www/index.php | 6 ++---- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/www/inc/classes/basevars.php b/www/inc/classes/basevars.php index 7a1796a..8183721 100644 --- a/www/inc/classes/basevars.php +++ b/www/inc/classes/basevars.php @@ -34,6 +34,15 @@ There are some variables available for all templates.

\param cartcookie variable contains the name of the cookie that contains the cart ID.

\param lang variable is an object of type LanguageManager - it represents translations done for the language the user has chosen.

+\param sessionid contains the ID of the current session as it is stored in a cookie and the session table. + +\param user.* contains basic data about the web user. + + + + + +
user.namethe (family) name of the user
user.firstnamethe first name of the user
user.titlethe title of the user
user.emailthe e-mail and login name of the user
\section tpl_error error.html @@ -161,9 +170,33 @@ private static function initBaseUrlPriv(){ $BaseUrl.=$path; } +public static function initCartAndUserData() +{ + global $websession,$basevars; + $basevars['inputnames']['cartid']=WebCart::cartIdName; + $basevars['cartcookie']=WebCart::cartIdName; + $basevars['sessionid']=$websession->getsessionid(); + $cust=$websession->getcustomer(); + if($cust!==false){ + $basevars['user']=array( + 'name'=>$cust->getname(), + 'firstname'=>$cust->getfirstname(), + 'title'=>$cust->gettitle(), + 'email'=>$cust->getemail() + ); + }else{ + $basevars['user']=array( + 'name'=>"", + 'firstname'=>"", + 'title'=>"", + 'email'=>"" + ); + } +} + //end of class } //eof return; -?> \ No newline at end of file +?> diff --git a/www/index.php b/www/index.php index 2b020b3..d823865 100644 --- a/www/index.php +++ b/www/index.php @@ -34,9 +34,7 @@ BaseVars::initTwig(); //initialize basevars BaseVars::init(); -$basevars['inputnames']['cartid']=WebCart::cartIdName; -$basevars['cartcookie']=WebCart::cartIdName; -$basevars['sessionid']=$websession->getsessionid(); +BaseVars::initCartAndUserData(); // other info $basevars['lang']=LanguageManager::singleton(); @@ -146,4 +144,4 @@ print($page); // code below here (some bots add harmful code to index.php) exit(0); -?> \ No newline at end of file +?> -- 1.7.2.5