forked from extern/egroupware
fix for preferences on login
This commit is contained in:
parent
7ec19342e2
commit
ce195b4f2c
@ -132,7 +132,7 @@
|
|||||||
|
|
||||||
function phpgw_()
|
function phpgw_()
|
||||||
{
|
{
|
||||||
global $phpgw_info, $sessionid;
|
global $phpgw_info, $sessionid, $login;
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* Required classes *
|
* Required classes *
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
@ -167,6 +167,9 @@
|
|||||||
include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_shared.inc.php");
|
include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_shared.inc.php");
|
||||||
$this->auth = new auth;
|
$this->auth = new auth;
|
||||||
$this->session = new sessions;
|
$this->session = new sessions;
|
||||||
|
$log = explode("@",$login);
|
||||||
|
$this->preferences = new preferences($log[0]);
|
||||||
|
// $this->preferences->preferences_($log[0]);
|
||||||
}else{
|
}else{
|
||||||
/* Load selected authentication class */
|
/* Load selected authentication class */
|
||||||
if (empty($phpgw_info["server"]["auth_type"])){$phpgw_info["server"]["auth_type"] = "sql";}
|
if (empty($phpgw_info["server"]["auth_type"])){$phpgw_info["server"]["auth_type"] = "sql";}
|
||||||
@ -182,11 +185,11 @@
|
|||||||
include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_".$phpgw_info["server"]["account_repository"].".inc.php");
|
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");
|
include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_shared.inc.php");
|
||||||
$this->auth = new auth;
|
$this->auth = new auth;
|
||||||
|
$this->preferences = new preferences;
|
||||||
}
|
}
|
||||||
$this->accounts = new accounts;
|
$this->accounts = new accounts;
|
||||||
$this->translation = new translation;
|
$this->translation = new translation;
|
||||||
$this->common = new common;
|
$this->common = new common;
|
||||||
$this->preferences = new preferences($phpgw_info["user"]["account_id"]);
|
|
||||||
$this->acl = new acl;
|
$this->acl = new acl;
|
||||||
$this->hooks = new hooks;
|
$this->hooks = new hooks;
|
||||||
|
|
||||||
|
@ -21,7 +21,10 @@
|
|||||||
//echo "accounts_const called<br>line: $line<br>$file";
|
//echo "accounts_const called<br>line: $line<br>$file";
|
||||||
|
|
||||||
$phpgw->accounts->phpgw_fillarray();
|
$phpgw->accounts->phpgw_fillarray();
|
||||||
$preferences = new preferences($phpgw_info["user"]["account_id"]);
|
if(! $phpgw->preferences->account_id) {
|
||||||
|
$phpgw->preferences->preferences($phpgw_info["user"]["account_id"]);
|
||||||
|
}
|
||||||
|
$phpgw_info["user"]["preferences"] = $phpgw->preferences->get_preferences();
|
||||||
$this->groups = $this->read_groups($phpgw_info["user"]["userid"]);
|
$this->groups = $this->read_groups($phpgw_info["user"]["userid"]);
|
||||||
$this->apps = $this->read_apps($phpgw_info["user"]["userid"]);
|
$this->apps = $this->read_apps($phpgw_info["user"]["userid"]);
|
||||||
|
|
||||||
@ -47,8 +50,7 @@
|
|||||||
$phpgw_info_temp["apps"] = $phpgw_info["apps"];
|
$phpgw_info_temp["apps"] = $phpgw_info["apps"];
|
||||||
$phpgw_info_temp["server"] = $phpgw_info["server"];
|
$phpgw_info_temp["server"] = $phpgw_info["server"];
|
||||||
$phpgw_info_temp["hooks"] = $phpgw->hooks->read();
|
$phpgw_info_temp["hooks"] = $phpgw->hooks->read();
|
||||||
$p = new preferences($phpgw_info["user"]["account_id"]);
|
$phpgw_info_temp["user"]["preferences"] = $phpgw_info["user"]["preferences"];
|
||||||
$phpgw_info_temp["user"]["preferences"] = $p->preferences;
|
|
||||||
$phpgw_info_temp["user"]["kp3"] = ""; // We don't want it anywhere in the
|
$phpgw_info_temp["user"]["kp3"] = ""; // We don't want it anywhere in the
|
||||||
// database for security.
|
// database for security.
|
||||||
|
|
||||||
@ -197,13 +199,26 @@
|
|||||||
function preferences($account_id)
|
function preferences($account_id)
|
||||||
{
|
{
|
||||||
global $phpgw;
|
global $phpgw;
|
||||||
$db2 = $phpgw->db;
|
$db2 = $phpgw->db;
|
||||||
$this->account_id = $account_id;
|
$load_pref = True;
|
||||||
|
if (is_long($account_id)) {
|
||||||
|
$this->account_id = $account_id;
|
||||||
|
} elseif(is_string($account_id)) {
|
||||||
|
$db2->query("SELECT account_id FROM accounts WHERE account_lid='".$account_id."'");
|
||||||
|
if($db2->num_rows()) {
|
||||||
|
$db2->next_record();
|
||||||
|
$this->account_id = $db2->f("account_id");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$load_pref = False;
|
||||||
|
}
|
||||||
|
|
||||||
$db2->query("select preference_value from preferences where preference_owner='"
|
if ($load_pref) {
|
||||||
. $this->account_id . "'",__LINE__,__FILE__);
|
$db2->query("select preference_value from preferences where preference_owner='"
|
||||||
$db2->next_record();
|
. $this->account_id . "'",__LINE__,__FILE__);
|
||||||
$this->preferences = unserialize($db2->f("preference_value"));
|
$db2->next_record();
|
||||||
|
$this->preferences = unserialize($db2->f("preference_value"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This should be called when you are done makeing changes to the preferences
|
// This should be called when you are done makeing changes to the preferences
|
||||||
@ -212,16 +227,19 @@
|
|||||||
//echo "<br>commit called<br>Line: $line<br>File: $file";
|
//echo "<br>commit called<br>Line: $line<br>File: $file";
|
||||||
|
|
||||||
global $phpgw, $phpgw_info;
|
global $phpgw, $phpgw_info;
|
||||||
$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 ('"
|
$db->query("insert into preferences (preference_owner,preference_value) values ('"
|
||||||
. $this->account_id . "','" . serialize($this->preferences) . "')",__LINE__,__FILE__);
|
. $this->account_id . "','" . serialize($this->preferences) . "')",__LINE__,__FILE__);
|
||||||
|
|
||||||
if ($phpgw_info["user"]["account_id"] == $this->account_id) {
|
if ($phpgw_info["user"]["account_id"] == $this->account_id) {
|
||||||
$phpgw->accounts->sync(__LINE__,__FILE__);
|
$phpgw_info["user"]["preferences"] = $this->preferences;
|
||||||
}
|
$phpgw->accounts->sync(__LINE__,__FILE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a new preference.
|
// Add a new preference.
|
||||||
@ -239,7 +257,11 @@
|
|||||||
|
|
||||||
function delete($app_name,$var)
|
function delete($app_name,$var)
|
||||||
{
|
{
|
||||||
$this->change($app_name,$var,"");
|
if (! $var) {
|
||||||
|
$this->reset($app_name);
|
||||||
|
} else {
|
||||||
|
unset($this->preferences[$app_name][$var]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will kill all preferences within a certain app
|
// This will kill all preferences within a certain app
|
||||||
@ -248,6 +270,10 @@
|
|||||||
$this->preferences[$app_name] = array();
|
$this->preferences[$app_name] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_preferences()
|
||||||
|
{
|
||||||
|
return $this->preferences;
|
||||||
|
}
|
||||||
} //end of preferences class
|
} //end of preferences class
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user