True,
"nonavbar" => True,
"currentapp" => "admin",
"parent_page" => "accounts.php");
include("../header.inc.php");
include($phpgw_info["server"]["app_inc"]."/accounts_".$phpgw_info["server"]["account_repository"].".inc.php");
function is_odd($n)
{
$ln = substr($n,-1);
if ($ln == 1 || $ln == 3 || $ln == 5 || $ln == 7 || $ln == 9) {
return True;
} else {
return False;
}
}
if (! $account_id) {
Header("Location: " . $phpgw->link("accounts.php"));
}
if ($submit) {
$totalerrors = 0;
if ($phpgw_info["server"]["account_repository"] == "ldap" && ! $allow_long_loginids) {
if (strlen($n_loginid) > 8) {
$error[$totalerrors++] = lang("The loginid can not be more then 8 characters");
}
}
if ($old_loginid != $n_loginid) {
if (account_exsists($n_loginid)) {
$error[$totalerrors++] = lang("That loginid has already been taken");
}
// $c_loginid = $n_loginid;
// $n_loginid = $old_loginid;
}
if ($n_passwd || $n_passwd_2) {
if ($n_passwd != $n_passwd_2) {
$error[$totalerrors++] = lang("The two passwords are not the same");
}
if (! $n_passwd){
$error[$totalerrors++] = lang("You must enter a password");
}
}
if (count($new_permissions) == 0){
$error[$totalerrors++] = "
" . lang("You must add at least 1 permission to this account");
}
if (! $totalerrors) {
$phpgw->db->query("SELECT account_id FROM accounts WHERE account_lid='" . $old_loginid . "'",__LINE__,__FILE__);
$phpgw->db->next_record();
$account_id = $phpgw->db->f("account_id");
while ($permission = each($new_permissions)) {
if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
$phpgw->accounts->add_app($permission[0]);
}
}
$apps_after = $phpgw->accounts->add_app("",True);
$cd = account_edit(array("loginid" => $n_loginid, "permissions" => $new_permissions,
"firstname" => $n_firstname, "lastname" => $n_lastname,
"passwd" => $n_passwd, "account_status" => $n_account_status,
"old_loginid" => $old_loginid, "account_id" => rawurldecode($account_id),
"groups" => $phpgw->accounts->groups_array_to_string($n_groups)));
// If the user is logged in, it will force a refresh of the session_info
$phpgw->db->query("update phpgw_sessions set session_info='' where session_lid='$new_loginid@" . $phpgw_info["user"]["domain"] . "'",__LINE__,__FILE__);
// The following sets any default preferences needed for new applications..
// This is smart enough to know if previous preferences were selected, use them.
$pref = new preferences($account_id);
$t = $pref->get_preferences();
$docommit = False;
while(list($key,$value) = each($phpgw_info["user"]["app_perms"])) {
if($value=="admin") {
$check = "common";
} else {
$check = $value;
}
if (!count($t["$check"])) {
$phpgw->common->hook_single("add_def_pref", $value);
$docommit = True;
}
}
if ($docommit) {
$pref->commit();
}
// start including other admin tools
while(list($key,$value) = each($phpgw_info["user"]["app_perms"]))
{
$phpgw->common->hook_single("update_user_data", $value);
}
Header("Location: " . $phpgw->link("accounts.php", "cd=$cd"));
$phpgw->common->phpgw_exit();
}
} // if $submit
$phpgw->template->set_file(array("form" => "account_form.tpl"));
$phpgw->common->phpgw_header();
echo parse_navbar();
if ($totalerrors) {
$phpgw->template->set_var("error_messages","