From b693138a0beaf432e674659526c21a911eacb194 Mon Sep 17 00:00:00 2001 From: skeeter Date: Sat, 30 Dec 2000 17:10:20 +0000 Subject: [PATCH] sessions should work correctly/restructure of code --- admin/editgroup.php | 6 ++- phpgwapi/inc/phpgw.inc.php | 54 ++++++++++++---------- phpgwapi/inc/phpgw_accounts_shared.inc.php | 34 +++++++++----- 3 files changed, 56 insertions(+), 38 deletions(-) diff --git a/admin/editgroup.php b/admin/editgroup.php index 789f55a9c8..f4ed616c09 100755 --- a/admin/editgroup.php +++ b/admin/editgroup.php @@ -48,14 +48,18 @@ . "' where group_id=$group_id"); for ($i=0; $idb->query("SELECT account_groups FROM accounts WHERE account_id=".$n_users[$i]); + $phpgw->db->query("SELECT account_groups, account_lid FROM accounts WHERE account_id=".$n_users[$i]); $phpgw->db->next_record(); + $account_lid = $phpgw->db->f("account_lid"); if(strpos($phpgw->db->f("account_groups"),$group_id.":0,") == 0) { $user_groups = $phpgw->db->f("account_groups") . ",$group_id:0,"; $user_groups = ereg_replace(",,",",",$user_groups); $phpgw->db->query("UPDATE accounts SET account_groups='$user_groups' WHERE account_id=".$n_users[$i]); } + // If the user is logged in, it will force a refresh of the session_info + $phpgw->db->query("update phpgw_sessions set session_info='' where session_lid='$account_lid@" . $phpgw_info["user"]["domain"] . "'",__LINE__,__FILE__); + // The following sets any default preferences needed for new applications.. // This is smart enough to know if previous preferences were selected, use them. $pref = new preferences(intval($n_users[$i])); diff --git a/phpgwapi/inc/phpgw.inc.php b/phpgwapi/inc/phpgw.inc.php index 46938a5c02..076f1a18f5 100644 --- a/phpgwapi/inc/phpgw.inc.php +++ b/phpgwapi/inc/phpgw.inc.php @@ -147,9 +147,16 @@ $phpgw_info["server"][$this->db->f("config_name")] = $this->db->f("config_value"); } } else { - $this->db->query("select config_value from config where config_name='encryptkey'",__LINE__,__FILE__); - $this->db->next_record(); - $phpgw_info["server"]["encryptkey"] = $this->db->f("config_value"); + $config_var = array("encryptkey","auth_type","account_repository"); + $c= ""; + for ($i=0;$idb->query("select * from config where $c",__LINE__,__FILE__); + while($this->db->next_record()) { + $phpgw_info["server"][$this->db->f("config_name")] = $this->db->f("config_value"); + } } /**************************************************************************\ @@ -157,39 +164,36 @@ \**************************************************************************/ $this->common = new common; + /* Load selected authentication class */ + if (empty($phpgw_info["server"]["auth_type"])){$phpgw_info["server"]["auth_type"] = "sql";} + include($phpgw_info["server"]["api_inc"] . "/phpgw_auth_".$phpgw_info["server"]["auth_type"].".inc.php"); + + $this->auth = new auth; + + /* Load selected accounts class */ + if (empty($phpgw_info["server"]["account_repository"])){$phpgw_info["server"]["account_repository"] = $phpgw_info["server"]["auth_type"];} + include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_".$phpgw_info["server"]["account_repository"].".inc.php"); + include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_shared.inc.php"); + + $this->accounts = new accounts; + $this->preferences = new preferences(0); + + $this->session = new sessions; + if ($phpgw_info["flags"]["currentapp"] == "login") { - /* Load selected authentication class */ - if (empty($phpgw_info["server"]["auth_type"])){$phpgw_info["server"]["auth_type"] = "sql";} - include($phpgw_info["server"]["api_inc"] . "/phpgw_auth_".$phpgw_info["server"]["auth_type"].".inc.php"); - /* Load selected accounts class */ - if (empty($phpgw_info["server"]["account_repository"])){$phpgw_info["server"]["account_repository"] = $phpgw_info["server"]["auth_type"];} - include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_".$phpgw_info["server"]["account_repository"].".inc.php"); - include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_shared.inc.php"); - $this->auth = new auth; - $this->session = new sessions; $log = explode("@",$login); $this->preferences = new preferences($log[0]); }else{ - /* Load selected authentication class */ - if (empty($phpgw_info["server"]["auth_type"])){$phpgw_info["server"]["auth_type"] = "sql";} - include($phpgw_info["server"]["api_inc"] . "/phpgw_auth_".$phpgw_info["server"]["auth_type"].".inc.php"); - $this->session = new sessions; if (! $this->session->verify()) { - Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"] . "/login.php", "cd=10")); + $this->db->query("select config_value from config where config_name='webserver_url'",__LINE__,__FILE__); + $this->db->next_record(); + Header("Location: " . $this->link($this->db->f("config_value")."/login.php","cd=10")); exit; } - - /* Load selected accounts class */ - if (empty($phpgw_info["server"]["account_repository"])){$phpgw_info["server"]["account_repository"] = $phpgw_info["server"]["auth_type"];} - include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_".$phpgw_info["server"]["account_repository"].".inc.php"); - include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_shared.inc.php"); - $this->auth = new auth; - $this->preferences = new preferences(0); $this->preferences->preferences = $phpgw_info["user"]["preferences"]; $this->preferences->account_id = $phpgw_info["user"]["account_id"]; } - $this->accounts = new accounts; $this->translation = new translation; $this->acl = new acl; $this->hooks = new hooks; diff --git a/phpgwapi/inc/phpgw_accounts_shared.inc.php b/phpgwapi/inc/phpgw_accounts_shared.inc.php index 3b1f54f0ec..044b4d3c8f 100644 --- a/phpgwapi/inc/phpgw_accounts_shared.inc.php +++ b/phpgwapi/inc/phpgw_accounts_shared.inc.php @@ -223,29 +223,39 @@ if ($load_pref) { $db2->query("SELECT preference_value FROM preferences WHERE preference_owner=".$this->account_id,__LINE__,__FILE__); $db2->next_record(); - $this->preferences = unserialize($db2->f("preference_value")); + $pref_info = $db2->f("preference_value"); +// if ($PHP_VERSION < "4.0.0") { +// $pref_info = stripslashes($pref_info) +// } + $this->preferences = unserialize($pref_info); } } // This should be called when you are done makeing changes to the preferences function commit($line = "",$file = "") { - global $phpgw, $phpgw_info; + global $phpgw, $phpgw_info; - //echo "
commit called
Line: $line
File: $file".$phpgw_info["user"]["account_id"]."
"; + //echo "
commit called
Line: $line
File: $file".$phpgw_info["user"]["account_id"]."
"; - if ($this->account_id) { - $db = $phpgw->db; + if ($this->account_id) { + $db = $phpgw->db; - $db->query("delete from preferences where preference_owner='" . $this->account_id . "'",__LINE__,__FILE__); + $db->query("delete from preferences where preference_owner='" . $this->account_id . "'",__LINE__,__FILE__); - $db->query("insert into preferences (preference_owner,preference_value) values (" - . $this->account_id . ",'" . serialize($this->preferences) . "')",__LINE__,__FILE__); + if ($PHP_VERSION < "4.0.0") { + $pref_info = addslashes(serialize($this->preferences)); + } else { + $pref_info = serialize($this->preferences); + } - if ($phpgw_info["user"]["account_id"] == $this->account_id) { - $phpgw->preferences->preferences = $this->get_preferences(); - $phpgw->accounts->sync(__LINE__,__FILE__); - } + $db->query("insert into preferences (preference_owner,preference_value) values (" + . $this->account_id . ",'" . $pref_info . "')",__LINE__,__FILE__); + + if ($phpgw_info["user"]["account_id"] == $this->account_id) { + $phpgw->preferences->preferences = $this->get_preferences(); + $phpgw->accounts->sync(__LINE__,__FILE__); + } } }