True, "nonavbar" => True);
$phpgw_flags["currentapp"] = "admin";
include("../header.inc.php");
if (! $con)
Header("Location: " . $phpgw->link("accounts.php"));
function change_owner($app,$table,$field,$new,$old)
{
global $phpgw, $phpgw_info;
if ($phpgw_info["apps"][$app]["enabled"] || ! $app) {
$phpgw->db->query("update $table set $field='$new' where $field='$old'");
}
}
if ($submit) {
$phpgw->db->query("select loginid from accounts where con='$con'");
$phpgw->db->next_record();
$lid = $phpgw->db->f("loginid");
if ($n_passwd || $n_passwd_2) {
if ($n_passwd != $n_passwd_2)
$error .= lang_admin("The two passwords are not the same");
if (! $n_passwd)
$error .= lang_admin("You must enter a password");
}
if ($lid != $n_loginid) {
$phpgw->db->query("select loginid from accounts where loginid='$n_loginid'");
if ($phpgw->db->num_rows() != 0) {
$error .= "
" . lang_admin("That loginid has already been taken");
}
}
if (count($new_permissions) == 0)
$error .= "
" . lang_admin("You must add at least 1 permission to this account");
if (! $error) {
$phpgw->db->lock(array('accounts','preferences','sessions'));
if ($n_passwd) {
$phpgw->db->query("update accounts set passwd='" . md5($n_passwd) . "', "
. "lastpasswd_change='" . time() . "' where loginid='"
. "$lid'");
$phpgw->db->query("update sessions set passwd='" . addslashes($n_passwd)
. "' where loginid='$lid'");
}
while ($permission = each($new_permissions)) {
if ($phpgw_info["apps"][$permission[0]]["enabled"]) {
$phpgw->accounts->add_app($permission[0]);
}
}
//$phpgw->permissions->add("hr");
if ($new_permissions["anonymous"] && ! $new_permissions["admin"])
$phpgw->accounts->add_app("anonymous");
if (! $n_account_status)
$n_account_status = "L";
$cd = 27;
// If they changed there loginid, we need to change the owner in ALL
// tables to reflect on the new one
if ($lid != $n_loginid) {
change_owner("","preferences","owner",$n_loginid,$lid);
change_owner("addressbook","addressbook","owner",$n_loginid,$lid);
change_owner("todo","todo","owner",$n_loginid,$lid);
change_owner("","accounts","loginid",$n_loginid,$lid);
change_owner("","sessions","loginid",$n_loginid,$lid);
change_owner("calendar","webcal_entry","cal_create_by",$n_loginid,$lid);
change_owner("calendar","webcal_entry_user","cal_login",$n_loginid,$lid);
$sep = $phpgw->common->filesystem_sepeartor();
$basedir = $phpgw_info["server"]["server_root"] . $sep . "filemanager" . $sep
. "users" . $sep;
if (! @rename($basedir . $lid, $basedir . $n_loginid)) {
$cd = 35;
}
}
$phpgw->db->query("update accounts set firstname='" . addslashes($n_firstname) . "',"
. " lastname='" . addslashes($n_lastname) . "', permissions='"
. $phpgw->accounts->add_app("",True) . "', status='"
. "$n_account_status', groups='"
. $phpgw->accounts->array_to_string("none",$n_groups)
. "' where loginid='$n_loginid'");
$phpgw->db->unlock();
Header("Location: " . $phpgw->link("accounts.php", "cd=$cd"));
exit;
} // if ! $error
} // if $submit
$phpgw->common->header();
$phpgw->common->navbar();
$account_status = $phpgw->db->f("status");
$db_perms = $phpgw->accounts->read_apps($phpgw->db->f("loginid"));
$phpgw->db->query("select * from accounts where con='$con'");
$phpgw->db->next_record();
?>