forked from extern/egroupware
I have things working to a point where the user can login. I still wil lhave to do MAJOR cleanup of session class and fix a few things in the acl that I commented out
This commit is contained in:
parent
a09fb881a4
commit
3f44799099
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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)) {
|
||||
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;
|
||||
} elseif(is_string($account_id)) {
|
||||
$this->account_id = $phpgw->accounts->name2id($account_id);
|
||||
}
|
||||
//echo "prefs loaded for: ".$this->account_id."<br>";
|
||||
}
|
||||
|
||||
/**************************************************************************\
|
||||
@ -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
|
||||
?>
|
||||
|
@ -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;
|
||||
}
|
||||
@ -117,7 +116,6 @@
|
||||
$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()
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)");
|
||||
|
Loading…
Reference in New Issue
Block a user