Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$_SESSION['DefaultTheme'] is never initialized
03-24-2014, 10:34 PM (This post was last modified: 03-24-2014 10:48 PM by serakfalcon.)
Post: #1
$_SESSION['DefaultTheme'] is never initialized
While working on integrating the theme code into my Views project, I've come to find that while $_SESSION['DefaultTheme'] is referenced multiple times (line 245, CustLoginSetup.php,line 263, SuppLoginSetup.php, Lines 111 & 389, SystemParameters.php, line 625 WWW_Users.php, session.inc 199 & 200), however it is never actually initialized.

instead, $Theme is set to 'gel' if $_SESSION['Theme'] is not initialized (only applies to the login screen (line 99, session.inc) and, if the user logs in, the session is set according to what is saved in their preferences. At no point is $_SESSION['DefaultTheme'] set to a value.

Likely this error has gone unnoticed since $Theme and $_SESSION['Theme'] are always initialized to something.

Suggestion:
a) remove it entirely, it's confusing and doesn't do anything.
b) make it do what it's supposed to, aka represent the default system theme, in which case the login screen should reflect that. I don't see how it is really useful beyond that though.
OK so looking closer it should theoretically be set by GetConfig.php but for some reason it's not being set, and in any case isn't used for anything.
Find all posts by this user
Quote this message in a reply
03-24-2014, 11:04 PM
Post: #2
RE: $_SESSION['DefaultTheme'] is never initialized
Hi serakfalcon, it is one of the config table variables. GetConfig.php loads the values of the config table into the session variable in the form $_SESSION[confname]=confvalue. This appears to work ok on my system (I get the correct value in $_SESSION['DefaultTheme'] anyway. Whether its worse having a config value for it is another matter.

Thanks
Tim
Visit this user's website Find all posts by this user
Quote this message in a reply
03-25-2014, 03:39 AM
Post: #3
RE: $_SESSION['DefaultTheme'] is never initialized
Hey Tim,
yeah, $_SESSION['DefaultTheme'] not being set seems to have been my problem, regardless, in line 195-203 of session.inc:

Code:
If (isset($_POST['Theme']) AND ($_SESSION['UsersRealName'] == $_POST['RealName'])) {
    $_SESSION['Theme'] = $_POST['Theme'];
    $Theme = $_POST['Theme'];
} elseif (!isset($_SESSION['Theme'])) {
    $Theme = $_SESSION['DefaultTheme'];
    $_SESSION['Theme'] = $_SESSION['DefaultTheme'];

} else {
    $Theme = $_SESSION['Theme'];
}

The elseif will never happen because $_SESSION['Theme'] is always set prior- it's not possible to add a user without a theme, and the user settings are loaded before that statement runs. Basically the only time $_SESSION['DefaultTheme'] is used is on the WWW_Users.php & SystemParamaters.php page, to make sure the select box is set to the default.

likewise, on line 98,

Code:
$Theme = (isset($_SESSION['Theme'])) ? $_SESSION['Theme'] : 'gel';

Why gel? this could be a use for $_SESSION['DefaultTheme'].
Find all posts by this user
Quote this message in a reply
03-25-2014, 06:08 AM
Post: #4
RE: $_SESSION['DefaultTheme'] is never initialized
To be honest I can't see the point of it at all.

It's not possible to sign on without having a theme setup in your user record, so what point does a default theme serve?. It would be nice to remove one of the config options.

Tim
Visit this user's website Find all posts by this user
Quote this message in a reply
03-25-2014, 07:02 AM
Post: #5
RE: $_SESSION['DefaultTheme'] is never initialized
Agreed - think we can ditch the config parameter and remove the code in SystemParameters and modify session.inc to avoid references to SESSION['DefaultTheme']

Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)