';
echo '';
exit;
}
// Save new user info to the database
if ($action=='createuser' || $action=='edituser2') {
if (($action=='createuser' || $action=='edituser2' && $username!=$oldusername) && get_user_id($username)) {
print_header(WT_I18N::translate('User administration'));
echo "", WT_I18N::translate('Duplicate user name. A user with that user name already exists. Please choose another user name.'), " ";
} elseif (($action=='createuser' || $action=='edituser2' && $emailaddress!=$oldemailaddress) && get_user_by_email($emailaddress)) {
print_header(WT_I18N::translate('User administration'));
echo "", WT_I18N::translate('Duplicate email address. A user with that email already exists.'), " ";
} else {
if ($pass1!=$pass2) {
print_header(WT_I18N::translate('User administration'));
echo "", WT_I18N::translate('Passwords do not match.'), " ";
} else {
// New user
if ($action=='createuser') {
if ($user_id=create_user($username, $realname, $emailaddress, crypt($pass1))) {
set_user_setting($user_id, 'reg_timestamp', date('U'));
set_user_setting($user_id, 'sessiontime', '0');
AddToLog("User ->{$username}<- created", 'auth');
} else {
AddToLog("User ->{$username}<- was not created", 'auth');
$user_id=get_user_id($username);
}
} else {
$user_id=get_user_id($oldusername);
}
// Change password
if ($action=='edituser2' && !empty($pass1)) {
set_user_password($user_id, crypt($pass1));
AddToLog("User ->{$oldusername}<- had password changed", 'auth');
}
// Change username
if ($action=='edituser2' && $username!=$oldusername) {
rename_user($oldusername, $username);
AddToLog("User ->{$oldusername}<- renamed to ->{$username}<-", 'auth');
}
// Create/change settings that can be updated in the user's gedcom record?
$email_changed=($emailaddress!=getUserEmail($user_id));
$newly_verified=($verified_by_admin && !get_user_setting($user_id, 'verified_by_admin'));
// Create/change other settings
setUserFullName ($user_id, $realname);
setUserEmail ($user_id, $emailaddress);
set_user_setting($user_id, 'theme', $user_theme);
set_user_setting($user_id, 'language', $user_language);
set_user_setting($user_id, 'contactmethod', $new_contact_method);
set_user_setting($user_id, 'defaulttab', $new_default_tab);
set_user_setting($user_id, 'comment', $new_comment);
set_user_setting($user_id, 'comment_exp', $new_comment_exp);
set_user_setting($user_id, 'auto_accept', $new_auto_accept);
set_user_setting($user_id, 'canadmin', $canadmin);
set_user_setting($user_id, 'visibleonline', $visibleonline);
set_user_setting($user_id, 'editaccount', $editaccount);
set_user_setting($user_id, 'verified', $verified);
set_user_setting($user_id, 'verified_by_admin', $verified_by_admin);
foreach ($all_gedcoms as $ged_id=>$ged_name) {
set_user_gedcom_setting($user_id, $ged_id, 'gedcomid', safe_POST_xref('gedcomid'.$ged_id));
set_user_gedcom_setting($user_id, $ged_id, 'rootid', safe_POST_xref('rootid'.$ged_id));
set_user_gedcom_setting($user_id, $ged_id, 'canedit', safe_POST('canedit'.$ged_id, array_keys($ALL_EDIT_OPTIONS)));
if (safe_POST_xref('gedcomid'.$ged_id)) {
set_user_gedcom_setting($user_id, $ged_id, 'RELATIONSHIP_PATH_LENGTH', safe_POST_integer('RELATIONSHIP_PATH_LENGTH'.$ged_id, 0, 10, 0));
} else {
// Do not allow a path length to be set if the individual ID is not
set_user_gedcom_setting($user_id, $ged_id, 'RELATIONSHIP_PATH_LENGTH', null);
}
}
// If we're verifying a new user, send them a message to let them know
if ($newly_verified && $action=='edituser2') {
WT_I18N::init($user_language);
$message=array();
$message["to"]=$username;
$headers="From: ".$WEBTREES_EMAIL;
$message["from"]=WT_USER_NAME;
$message["subject"]=WT_I18N::translate('Approval of account at %s', WT_SERVER_NAME.WT_SCRIPT_PATH);
$message["body"]=WT_I18N::translate('The administrator at the webtrees site %s has approved your application for an account. You may now login by accessing the following link: %s', WT_SERVER_NAME.WT_SCRIPT_PATH, WT_SERVER_NAME.WT_SCRIPT_PATH);
$message["created"]="";
$message["method"]="messaging2";
addMessage($message);
// and send a copy to the admin
/*
$message=array();
$message["to"]=WT_USER_NAME;
$headers="From: ".$WEBTREES_EMAIL;
$message["from"]=$username; // fake the from address - so the admin can "reply" to it.
$message["subject"]=WT_I18N::translate('Approval of account at %s', WT_SERVER_NAME.WT_SCRIPT_PATH));
$message["body"]=WT_I18N::translate('The administrator at the webtrees site %s has approved your application for an account. You may now login by accessing the following link: %s', WT_SERVER_NAME.WT_SCRIPT_PATH, WT_SERVER_NAME.WT_SCRIPT_PATH));
$message["created"]="";
$message["method"]="messaging2";
addMessage($message); */
}
// Reload the form cleanly, to allow the user to verify their changes
header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH."admin_users.php?action=edituser&username=".rawurlencode($username)."&ged=".rawurlencode($ged));
exit;
}
}
} else {
print_header(WT_I18N::translate('User administration'));
if (get_gedcom_count()==1) { //Removed becasue it doesn't work here for multiple GEDCOMs. Can be reinstated when fixed (https://bugs.launchpad.net/webtrees/+bug/613235)
if ($ENABLE_AUTOCOMPLETE) require WT_ROOT.'js/autocomplete.js.htm';
}
}
// Print the form to edit a user
if ($action=="edituser") {
$user_id=get_user_id($username);
init_calendar_popup();
?>