sessions should work correctly/restructure of code

This commit is contained in:
skeeter 2000-12-30 17:10:20 +00:00
parent 1433ec0b6f
commit b693138a0b
3 changed files with 56 additions and 38 deletions

View File

@ -48,14 +48,18 @@
. "' where group_id=$group_id");
for ($i=0; $i<count($n_users);$i++) {
$phpgw->db->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]));

View File

@ -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;$i<count($config_var);$i++) {
if($i) $c .= " OR ";
$c .= "config_name='".$config_var[$i]."'";
}
$this->db->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;

View File

@ -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 "<br>commit called<br>Line: $line<br>File: $file".$phpgw_info["user"]["account_id"]."<br>";
//echo "<br>commit called<br>Line: $line<br>File: $file".$phpgw_info["user"]["account_id"]."<br>";
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__);
}
}
}