mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-26 09:53:20 +01:00
More work on the SQL version of the admin section, add and delete account now works
This commit is contained in:
parent
e5f5796d49
commit
f9fe837aa5
@ -30,3 +30,8 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function account_exsists($loginid)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -18,7 +18,52 @@
|
|||||||
|
|
||||||
function account_add($account_info)
|
function account_add($account_info)
|
||||||
{
|
{
|
||||||
|
global $phpgw, $phpgw_info;
|
||||||
|
|
||||||
|
$phpgw->db->lock(array("accounts","preferences"));
|
||||||
|
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"maxmatchs","common","15");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"theme","common","default");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"tz_offset","common","0");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"dateformat","common","m/d/Y");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"timeformat","common","12");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"lang","common","en");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"company","addressbook","True");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"lastname","addressbook","True");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"firstname","addressbook","True");
|
||||||
|
|
||||||
|
// Even if they don't have access to the calendar, we will add these.
|
||||||
|
// Its better then the calendar being all messed up, they will be deleted
|
||||||
|
// the next time the update there preferences.
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"weekstarts","calendar","Monday");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"workdaystarts","calendar","9");
|
||||||
|
$phpgw->common->preferences_add($account_info["loginid"],"workdayends","calendar","17");
|
||||||
|
|
||||||
|
while ($permission = each($account_info["permissions"])) {
|
||||||
|
if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
|
||||||
|
$phpgw->accounts->add_app($permission[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "insert into accounts (account_lid,account_pwd,account_firstname,account_lastname,"
|
||||||
|
. "account_permissions,account_groups,account_status,account_lastpwd_change) values ('"
|
||||||
|
. $account_info["loginid"] . "','" . md5($account_info["passwd"]) . "','"
|
||||||
|
. addslashes($account_info["firstname"]) . "','". addslashes($account_info["lastname"])
|
||||||
|
. "','" . $phpgw->accounts->add_app("",True) . "','" . $account_info["groups"] . "','A',0)";
|
||||||
|
|
||||||
|
$phpgw->db->query($sql);
|
||||||
|
$phpgw->db->unlock();
|
||||||
|
|
||||||
|
$sep = $phpgw->common->filesystem_separator();
|
||||||
|
|
||||||
|
$basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep;
|
||||||
|
|
||||||
|
if (! @mkdir($basedir . $n_loginid, 0707)) {
|
||||||
|
$cd = 36;
|
||||||
|
} else {
|
||||||
|
$cd = 28;
|
||||||
|
}
|
||||||
|
return $cd;
|
||||||
}
|
}
|
||||||
|
|
||||||
function account_edit($account_id,$account_info)
|
function account_edit($account_id,$account_info)
|
||||||
@ -74,3 +119,18 @@
|
|||||||
}
|
}
|
||||||
return $cd;
|
return $cd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function account_exsists($loginid)
|
||||||
|
{
|
||||||
|
global $phpgw;
|
||||||
|
|
||||||
|
$phpgw->db->query("select count(*) from accounts where account_lid='$loginid'");
|
||||||
|
$phpgw->db->next_record();
|
||||||
|
if ($phpgw->db->f(0) != 0) {
|
||||||
|
return True;
|
||||||
|
} else {
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -15,6 +15,10 @@
|
|||||||
"disable_send_class" => True, "currentapp" => "admin");
|
"disable_send_class" => True, "currentapp" => "admin");
|
||||||
|
|
||||||
include("../header.inc.php");
|
include("../header.inc.php");
|
||||||
|
include($phpgw_info["server"]["server_root"] . "/admin/inc/accounts_"
|
||||||
|
. $phpgw_info["server"]["auth_type"] . ".inc.php");
|
||||||
|
|
||||||
|
|
||||||
if ($submit) {
|
if ($submit) {
|
||||||
$totalerrors = 0;
|
$totalerrors = 0;
|
||||||
|
|
||||||
@ -36,56 +40,16 @@
|
|||||||
if (count($n_groups) == 0)
|
if (count($n_groups) == 0)
|
||||||
$error[$totalerrors++] = lang("Account must belong to at least 1 group");
|
$error[$totalerrors++] = lang("Account must belong to at least 1 group");
|
||||||
|
|
||||||
$phpgw->db->query("select count(*) from accounts where account_lid='$n_loginid'");
|
if (account_exsists($n_loginid)) {
|
||||||
$phpgw->db->next_record();
|
|
||||||
if ($phpgw->db->f(0) != 0)
|
|
||||||
$error[$totalerrors++] = lang("That loginid has already been taken");
|
$error[$totalerrors++] = lang("That loginid has already been taken");
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error) {
|
if (! $error) {
|
||||||
$phpgw->db->lock(array("accounts","preferences"));
|
$cd = account_add(array("loginid" => $n_loginid, "permissions" => $new_permissions,
|
||||||
|
"firstname" => $n_firstname, "lastname" => $n_lastname,
|
||||||
$phpgw->common->preferences_add($n_loginid,"maxmatchs","common","15");
|
"passwd" => $n_passwd,
|
||||||
$phpgw->common->preferences_add($n_loginid,"theme","common","default");
|
"groups" => $phpgw->accounts->groups_array_to_string($n_groups)));
|
||||||
$phpgw->common->preferences_add($n_loginid,"tz_offset","common","0");
|
|
||||||
$phpgw->common->preferences_add($n_loginid,"dateformat","common","m/d/Y");
|
|
||||||
$phpgw->common->preferences_add($n_loginid,"timeformat","common","12");
|
|
||||||
$phpgw->common->preferences_add($n_loginid,"lang","common","en");
|
|
||||||
$phpgw->common->preferences_add($n_loginid,"company","addressbook","True");
|
|
||||||
$phpgw->common->preferences_add($n_loginid,"lastname","addressbook","True");
|
|
||||||
$phpgw->common->preferences_add($n_loginid,"firstname","addressbook","True");
|
|
||||||
|
|
||||||
// Even if they don't have access to the calendar, we will add these.
|
|
||||||
// Its better then the calendar being all messed up, they will be deleted
|
|
||||||
// the next time the update there preferences.
|
|
||||||
$phpgw->common->preferences_add($n_loginid,"weekstarts","calendar","Monday");
|
|
||||||
$phpgw->common->preferences_add($n_loginid,"workdaystarts","calendar","9");
|
|
||||||
$phpgw->common->preferences_add($n_loginid,"workdayends","calendar","17");
|
|
||||||
|
|
||||||
while ($permission = each($new_permissions)) {
|
|
||||||
if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
|
|
||||||
$phpgw->accounts->add_app($permission[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = "insert into accounts (account_lid,account_pwd,account_firstname,account_lastname,"
|
|
||||||
. "account_permissions,account_groups,account_status,account_lastpwd_change) values ('$n_loginid'"
|
|
||||||
. ",'" . md5($n_passwd) . "','" . addslashes($n_firstname) . "','"
|
|
||||||
. addslashes($n_lastname) . "','" . $phpgw->accounts->add_app("",True)
|
|
||||||
. "','" . $phpgw->accounts->groups_array_to_string($n_groups) . "','A',0)";
|
|
||||||
|
|
||||||
$phpgw->db->query($sql);
|
|
||||||
$phpgw->db->unlock();
|
|
||||||
|
|
||||||
$sep = $phpgw->common->filesystem_separator();
|
|
||||||
|
|
||||||
$basedir = $phpgw_info["server"]["files_dir"] . $sep . "users" . $sep;
|
|
||||||
|
|
||||||
if (! @mkdir($basedir . $n_loginid, 0707)) {
|
|
||||||
// $cd = 36;
|
|
||||||
} else {
|
|
||||||
$cd = 28;
|
|
||||||
}
|
|
||||||
|
|
||||||
Header("Location: " . $phpgw->link("accounts.php","cd=$cd"));
|
Header("Location: " . $phpgw->link("accounts.php","cd=$cd"));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user