diff --git a/phpgwapi/inc/class.accounts_shared.inc.php b/phpgwapi/inc/class.accounts_shared.inc.php index 9385d3fe88..2516961f50 100644 --- a/phpgwapi/inc/class.accounts_shared.inc.php +++ b/phpgwapi/inc/class.accounts_shared.inc.php @@ -46,6 +46,14 @@ return $this->data; } + function update_data($data) { + reset($data); + $this->data = Array(); + $this->data = $data; + reset($this->data); + return $this->data; + } + function memberships($account_id = False) { global $phpgw_info, $phpgw; diff --git a/phpgwapi/inc/class.accounts_sql.inc.php b/phpgwapi/inc/class.accounts_sql.inc.php index 5341704e19..8a944766e2 100644 --- a/phpgwapi/inc/class.accounts_sql.inc.php +++ b/phpgwapi/inc/class.accounts_sql.inc.php @@ -38,7 +38,7 @@ $this->db->query("select * from phpgw_accounts where account_id='" . $this->account_id . "'",__LINE__,__FILE__); $this->db->next_record(); - $this->data["userid"] = $this->db->f("account_id"); + $this->data["userid"] = $this->db->f("account_lid"); $this->data["account_id"] = $this->db->f("account_id"); $this->data["account_lid"] = $this->db->f("account_lid"); $this->data["firstname"] = $this->db->f("account_firstname"); @@ -114,10 +114,8 @@ global $phpgw, $phpgw_info; if (gettype($account_id) == "string") { $account_id = $this->name2id($account_id); - $sql = "SELECT account_id FROM phpgw_accounts WHERE account_lid='".$account_id."'"; - }else{ - $sql = "SELECT account_id FROM phpgw_accounts WHERE account_id='".$account_id."'"; } + $sql = "SELECT account_id FROM phpgw_accounts WHERE account_id='".$account_id."'"; $this->db->query($sql,__LINE__,__FILE__); if ($this->db->num_rows()) { return True; diff --git a/phpgwapi/inc/class.acl.inc.php b/phpgwapi/inc/class.acl.inc.php index 574c30543f..8da875481f 100644 --- a/phpgwapi/inc/class.acl.inc.php +++ b/phpgwapi/inc/class.acl.inc.php @@ -56,12 +56,12 @@ { global $phpgw, $phpgw_info; $sql = "select * from phpgw_acl where (acl_account in (".$this->account_id.", 0"; - $equalto = $phpgw->accounts->security_equals($this->account_id); - if (is_array($equalto) && count($equalto) > 0){ - for ($idx = 0; $idx < count($equalto); ++$idx){ - $sql .= ",".$equalto[$idx][0]; - } - } +// $equalto = $phpgw->accounts->security_equals($this->account_id); +// if (is_array($equalto) && count($equalto) > 0){ +// for ($idx = 0; $idx < count($equalto); ++$idx){ +// $sql .= ",".$equalto[$idx][0]; +// } +// } $sql .= "))"; $this->db->query($sql ,__LINE__,__FILE__); $count = $this->db->num_rows(); diff --git a/phpgwapi/inc/class.preferences.inc.php b/phpgwapi/inc/class.preferences.inc.php index e561cfa473..61e5030a5a 100644 --- a/phpgwapi/inc/class.preferences.inc.php +++ b/phpgwapi/inc/class.preferences.inc.php @@ -39,13 +39,10 @@ { global $phpgw, $phpgw_info; $this->db = $phpgw->db; - if ($account_id == False){ - $this->account_id = $phpgw_info["user"]["account_id"]; - } elseif (is_long($account_id)) { - $this->account_id = $account_id; - } elseif(is_string($account_id)) { - $this->account_id = $phpgw->accounts->name2id($account_id); - } + if ($account_id == ""){ $account_id = $phpgw_info["user"]["account_id"]; } + elseif (gettype($account_id) == "string") { $account_id = $phpgw->accounts->name2id($account_id); } + $this->account_id = $account_id; +//echo "prefs loaded for: ".$this->account_id."
"; } /**************************************************************************\ @@ -122,5 +119,15 @@ return $this->data; } +// legacy support + function change($app_name,$var,$value = "") + { + return $this->add($app_name,$var,$value); + } + function commit() + { + return $this->save_repository(); + } + } //end of preferences class ?> diff --git a/phpgwapi/inc/class.sessions.inc.php b/phpgwapi/inc/class.sessions.inc.php index c7841494a8..f0826fad00 100644 --- a/phpgwapi/inc/class.sessions.inc.php +++ b/phpgwapi/inc/class.sessions.inc.php @@ -63,7 +63,8 @@ $t = explode("@",$db->f("session_lid")); $phpgw_info["user"]["userid"] = $t[0]; - //$phpgw->accounts->sync(__LINE__,__FILE__); +// $phpgw->accounts->account_id = $phpgw->accounts->name2id($phpgw_info["user"]["account_lid"]); +// $phpgw_info["user"] = $phpgw->accounts->read_repository(); // Now we need to re-read eveything $db->query("select * from phpgw_sessions where session_id='$sessionid'",__LINE__,__FILE__); @@ -75,14 +76,12 @@ $phpgw_info_flags = $phpgw_info["flags"]; $phpgw_info = $phpgw->crypto->decrypt($db->f("session_info")); $phpgw_info["flags"] = $phpgw_info_flags; - $userid_array = explode("@",$db->f("session_lid")); $phpgw_info["user"]["userid"] = $userid_array[0]; if ($userid_array[1] != $phpgw_info["user"]["domain"]) { - return False; +// return False; } - if (PHP_OS != "Windows" && (! $phpgw_info["user"]["session_ip"] || $phpgw_info["user"]["session_ip"] != $this->getuser_ip())){ return False; } @@ -113,11 +112,10 @@ function create($login,$passwd) { global $phpgw_info, $phpgw; - + $this->clean_sessions(); $login_array = explode("@", $login); $phpgw_info["user"]["userid"] = $login_array[0]; - if ($phpgw_info["server"]["global_denied_users"][$phpgw_info["user"]["userid"]]) { return False; } @@ -126,19 +124,17 @@ return False; exit; } - $accts = CreateObject("phpgwapi.accounts"); + //$accts = CreateObject("phpgwapi.accounts"); - if (!$accts->exists($phpgw_info["user"]["userid"])) { - $accts->auto_generate($phpgw_info["user"]["userid"], $passwd); - } + //if (!$accts->exists($phpgw_info["user"]["userid"])) { + // $accts->auto_generate($phpgw_info["user"]["userid"], $passwd); + //} $phpgw->accounts->account_id = $phpgw->accounts->name2id($phpgw_info["user"]["userid"]); - $phpgw->accounts->read(); $t_domain = $phpgw_info["user"]["domain"]; // We loose this info on the next line $phpgw_info["user"] = $phpgw->accounts->read_repository(); $phpgw_info["user"]["domain"] = $t_domain; - $phpgw_info["user"]["sessionid"] = md5($phpgw->common->randomstring(10)); $phpgw_info["user"]["kp3"] = md5($phpgw->common->randomstring(15)); @@ -166,12 +162,23 @@ } $phpgw_info["user"]["session_ip"] = $this->getuser_ip(); - + $phpgw_info["user"]["session_lid"] = $phpgw_info["user"]["account_lid"]."@".$phpgw_info["user"]["domain"]; + $phpgw_info_temp["user"] = $phpgw_info["user"]; + $phpgw_info_temp["apps"] = $phpgw_info["apps"]; + $phpgw_info_temp["server"] = $phpgw_info["server"]; + $phpgw_info_temp["hooks"] = $phpgw->hooks->read(); + $phpgw_info_temp["user"]["preferences"] = $phpgw_info["user"]["preferences"]; + $phpgw_info_temp["user"]["kp3"] = ""; + if ($PHP_VERSION < "4.0.0") { + $info_string = addslashes($phpgw->crypto->encrypt($phpgw_info_temp)); + } else { + $info_string = $phpgw->crypto->encrypt($phpgw_info_temp); + } $phpgw->db->query("insert into phpgw_sessions values ('" . $phpgw_info["user"]["sessionid"] . "','".$login."','" . $this->getuser_ip() . "','" - . time() . "','" . time() . "','')",__LINE__,__FILE__); + . time() . "','" . time() . "','".$info_string."')",__LINE__,__FILE__); - $phpgw->accounts->save_repository(); + //$phpgw->accounts->save_repository(); $phpgw->db->query("insert into phpgw_access_log values ('" . $phpgw_info["user"]["sessionid"] . "','" . "$login','" . $this->getuser_ip() . "','" . time() @@ -215,4 +222,4 @@ } } -?> +?> \ No newline at end of file diff --git a/phpgwapi/inc/functions.inc.php b/phpgwapi/inc/functions.inc.php index 4da5d92d0e..639e38b9c0 100644 --- a/phpgwapi/inc/functions.inc.php +++ b/phpgwapi/inc/functions.inc.php @@ -245,31 +245,32 @@ !$phpgw_info["flags"]["nocommon_preferences"]) { if (!isset($phpgw_info["user"]["preferences"]["common"]["maxmatchs"]) || !$phpgw_info["user"]["preferences"]["common"]["maxmatchs"]) { - $phpgw->preferences->change("common","maxmatchs",15); +// $phpgw->preferences->change("common","maxmatchs",15); + $phpgw->preferences->add("common","maxmatchs",15); $preferences_update = True; } if (!isset($phpgw_info["user"]["preferences"]["common"]["theme"]) || !$phpgw_info["user"]["preferences"]["common"]["theme"]) { - $phpgw->preferences->change("common","theme","default"); + $phpgw->preferences->add("common","theme","default"); $preferences_update = True; } if (!isset($phpgw_info["user"]["preferences"]["common"]["dateformat"]) || !$phpgw_info["user"]["preferences"]["common"]["dateformat"]) { - $phpgw->preferences->change("common","dateformat","m/d/Y"); + $phpgw->preferences->add("common","dateformat","m/d/Y"); $preferences_update = True; } if (!isset($phpgw_info["user"]["preferences"]["common"]["timeformat"]) || !$phpgw_info["user"]["preferences"]["common"]["timeformat"]) { - $phpgw->preferences->change("common","timeformat",12); + $phpgw->preferences->add("common","timeformat",12); $preferences_update = True; } if (!isset($phpgw_info["user"]["preferences"]["common"]["lang"]) || !$phpgw_info["user"]["preferences"]["common"]["lang"]) { - $phpgw->preferences->change("common","lang",$phpgw->common->getPreferredLanguage()); + $phpgw->preferences->add("common","lang",$phpgw->common->getPreferredLanguage()); $preferences_update = True; } if ($preferences_update) { - $phpgw->preferences->commit(__LINE__,__FILE__); + $phpgw->preferences->save_repository(); } unset($preferences_update); } diff --git a/setup/setup_demo.php b/setup/setup_demo.php index 3ba1e46af5..6cba4913bb 100644 --- a/setup/setup_demo.php +++ b/setup/setup_demo.php @@ -76,6 +76,7 @@ $sql = "insert into phpgw_accounts"; $sql .= "(account_id, account_lid, account_type, account_pwd, account_firstname, account_lastname, account_lastpwd_change, account_status)"; $sql .= "values (2, 'demo2', 'u', '084e0343a0486ff05530df6c705c8bb4', 'Demo2', 'Account', ".time().", 'A')"; + $phpgw_setup->db->query("insert into preferences (preference_owner, preference_value) values ('2', '$defaultprefs')"); $phpgw_setup->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)values('preferences', 'changepassword', 2, 'u', 0)") ; $phpgw_setup->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('phpgw_group', '1', 2, 'u', 1)"); $phpgw_setup->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('addressbook', 'run', 2, 'u', 1)"); @@ -89,7 +90,7 @@ $sql .= "(account_id, account_lid, account_type, account_pwd, account_firstname, account_lastname, account_lastpwd_change, account_status)"; $sql .= "values (3, 'demo3', 'u', '084e0343a0486ff05530df6c705c8bb4', 'Demo3', 'Account', ".time().", 'A')"; $phpgw_setup->db->query($sql); - $phpgw_setup->db->query("insert into preferences (preference_owner, preference_value) values ('1', '$defaultprefs')"); + $phpgw_setup->db->query("insert into preferences (preference_owner, preference_value) values ('3', '$defaultprefs')"); $phpgw_setup->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)values('preferences', 'changepassword', 3, 'u', 0)"); $phpgw_setup->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('phpgw_group', '1', 3, 'u', 1)"); $phpgw_setup->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('addressbook', 'run', 3, 'u', 1)"); @@ -104,7 +105,7 @@ $sql .= "(account_id, account_lid, account_type, account_pwd, account_firstname, account_lastname, account_lastpwd_change, account_status)"; $sql .= "values (4, '$username', 'u', '".md5($passwd)."', '$fname', '$lname', ".time().", 'A')"; $phpgw_setup->db->query($sql); - $phpgw_setup->db->query("insert into preferences (preference_owner, preference_value) values ('1', '$defaultprefs')"); + $phpgw_setup->db->query("insert into preferences (preference_owner, preference_value) values ('4', '$defaultprefs')"); $phpgw_setup->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('phpgw_group', '1', 4, 'u', 1)"); $phpgw_setup->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('phpgw_group', '2', 4, 'u', 1)"); $phpgw_setup->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('admin', 'run', 4, 'u', 1)");