';
//id
print '
';
//username
print '
';
print '
';
//fullname
print '
';
print '
';
//password
print '
';
print '
';
//group
$esgroups = new es_esgroups();
$groupselect = '
';
print '
';
print $groupselect;
print '
';
//buttons
print "
";
print '';
}
function update_esuser_from_form() {
global $msg, $charset,$dbh,$id;
global $esuser_username, $esuser_fullname, $esuser_password, $esuser_esgroup;
if ($esuser_esgroup) {
//Vérifions que le groupe existe
if (!es_esgroup::id_exists($esuser_esgroup)) {
print $msg['es_user_error_unknowngroup'];
show_esuser_form(0, stripslashes($esuser_username), stripslashes($esuser_fullname), stripslashes($esuser_password), stripslashes($esuser_esgroup));
return false;
}
}
if (!$id) {
//Ajout d'un nouvel utilisateur
if (!$esuser_username) {
print $msg['es_user_error_emptyfield'];
show_esuser_form(0, stripslashes($esuser_username), stripslashes($esuser_fullname), stripslashes($esuser_password), stripslashes($esuser_esgroup));
return false;
}
if (es_esuser::username_exists($esuser_username)) {
print $msg['es_user_error_usernamealreadyexists'];
show_esuser_form(0, stripslashes($esuser_username), stripslashes($esuser_fullname), stripslashes($esuser_password), stripslashes($esuser_esgroup));
return false;
}
$new_esuser = es_esuser::add_new();
$new_esuser->esuser_username = $esuser_username;
$new_esuser->esuser_fullname = $esuser_fullname;
$new_esuser->esuser_password = $esuser_password;
$new_esuser->esuser_group = $esuser_esgroup;
$new_esuser->commit_to_db();
}
else {
$theuser = new es_esuser($id);
if ($the_user->error) {
return false;
}
$theuser->esuser_username = $esuser_username;
$theuser->esuser_fullname = $esuser_fullname;
$theuser->esuser_password = $esuser_password;
$theuser->esuser_group = $esuser_esgroup;
$theuser->commit_to_db();
}
return true;
}
switch ($action) {
case "add":
show_esuser_form(0, '', '', '');
break;
case "edit":
$esu_username='';
$esu_fullname='';
$esu_password='';
$esu_group=0;
if ($id) {
$the_user = new es_esuser($id);
if ($the_user->error) {
$id = 0;
}
else {
$esu_username=$the_user->esuser_username;
$esu_fullname=$the_user->esuser_fullname;
$esu_password=$the_user->esuser_password;
$esu_group=$the_user->esuser_group;
}
}
show_esuser_form($id, $esu_username, $esu_fullname, $esu_password, $esu_group);
break;
case "update":
if (update_esuser_from_form())
list_users();
break;
case "del":
if ($id) {
$the_user = new es_esuser($id);
$the_user->delete();
}
list_users();
break;
default:
list_users();
break;
}
?>