added first version of auto create accounts

This commit is contained in:
seek3r 2001-02-02 01:08:03 +00:00
parent 053e5aaea8
commit 208adb1792
2 changed files with 35 additions and 0 deletions

View File

@ -214,5 +214,34 @@
return False;
}
}
function exists($accountname){
$this->db->query("SELECT account_id FROM accounts WHERE account_lid='".$accountname."'",__LINE__,__FILE__);
if($this->db->num_rows()) {
return True;
}else{
return False;
}
}
function auto_generate($accountname, $passwd, $defaultprefs =""){
global $phpgw, $phpgw_info;
$accountid = mt_rand (100, 600000);
if ($defaultprefs ==""){ $defaultprefs = 'a:5:{s:6:"common";a:1:{s:0:"";s:2:"en";}s:11:"addressbook";a:1:{s:0:"";s:4:"True";}i:8;a:1:{s:0:"";s:13:"workdaystarts";}i:15;a:1:{s:0:"";s:11:"workdayends";}s:6:"Monday";a:1:{s:0:"";s:13:"weekdaystarts";}}'; }
$sql = "insert into accounts";
$sql .= "(account_id, account_lid, account_pwd, account_firstname, account_lastname, account_lastpwd_change, account_status)";
$sql .= "values (".$accountid.", '".$accountname."', '".md5($passwd)."', '".$accountname."', 'AutoCreated', ".time().", 'A')";
$this->db->query($sql);
$this->db->query("insert into preferences (preference_owner, preference_value) values ('".$accountid."', '$defaultprefs')");
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)values('preferences', 'changepassword', ".$accountid.", 'u', 0)");
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('phpgw_group', '1', ".$accountid.", 'u', 1)");
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('addressbook', 'run', ".$accountid.", 'u', 1)");
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('filemanager', 'run', ".$accountid.", 'u', 1)");
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('calendar', 'run', ".$accountid.", 'u', 1)");
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('email', 'run', ".$accountid.", 'u', 1)");
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('notes', 'run', ".$accountid.", 'u', 1)");
$this->db->query("insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights) values('todo', 'run', ".$accountid.", 'u', 1)");
return $accountid;
}
}//end of class
?>

View File

@ -127,7 +127,13 @@
return False;
exit;
}
$accts = CreateObject("phpgwapi.accounts");
if (!$accts->exists($phpgw_info["user"]["userid"])) {
$accts->auto_generate($phpgw_info["user"]["userid"], $passwd);
}
$phpgw_info["user"]["sessionid"] = md5($phpgw->common->randomstring(10));
$phpgw_info["user"]["kp3"] = md5($phpgw->common->randomstring(15));