diff --git a/admin/inc/accounts_ldap.inc.php b/admin/inc/accounts_ldap.inc.php index a828ed1e40..14dd764426 100644 --- a/admin/inc/accounts_ldap.inc.php +++ b/admin/inc/accounts_ldap.inc.php @@ -30,3 +30,8 @@ { } + + function account_exsists($loginid) + { + + } diff --git a/admin/inc/accounts_sql.inc.php b/admin/inc/accounts_sql.inc.php index b46d4f8dc3..da30d1e3a8 100755 --- a/admin/inc/accounts_sql.inc.php +++ b/admin/inc/accounts_sql.inc.php @@ -18,7 +18,52 @@ 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) @@ -74,3 +119,18 @@ } 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; + } + } + + \ No newline at end of file diff --git a/admin/newaccount.php b/admin/newaccount.php index 25fb9c3a87..701882f301 100755 --- a/admin/newaccount.php +++ b/admin/newaccount.php @@ -15,6 +15,10 @@ "disable_send_class" => True, "currentapp" => "admin"); include("../header.inc.php"); + include($phpgw_info["server"]["server_root"] . "/admin/inc/accounts_" + . $phpgw_info["server"]["auth_type"] . ".inc.php"); + + if ($submit) { $totalerrors = 0; @@ -36,56 +40,16 @@ if (count($n_groups) == 0) $error[$totalerrors++] = lang("Account must belong to at least 1 group"); - $phpgw->db->query("select count(*) from accounts where account_lid='$n_loginid'"); - $phpgw->db->next_record(); - if ($phpgw->db->f(0) != 0) + if (account_exsists($n_loginid)) { $error[$totalerrors++] = lang("That loginid has already been taken"); + } if (! $error) { - $phpgw->db->lock(array("accounts","preferences")); - - $phpgw->common->preferences_add($n_loginid,"maxmatchs","common","15"); - $phpgw->common->preferences_add($n_loginid,"theme","common","default"); - $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; - } - + $cd = account_add(array("loginid" => $n_loginid, "permissions" => $new_permissions, + "firstname" => $n_firstname, "lastname" => $n_lastname, + "passwd" => $n_passwd, + "groups" => $phpgw->accounts->groups_array_to_string($n_groups))); + Header("Location: " . $phpgw->link("accounts.php","cd=$cd")); exit; }