Example #1
0
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;
}
function update_esgroup_from_form()
{
    global $msg, $charset, $dbh, $id;
    global $es_group_name, $es_group_fullname, $es_group_pmbuserid, $es_group_emprgroups;
    if (!is_array($es_group_esusers)) {
        $es_group_esusers = array($es_group_esusers);
    }
    if (!is_array($es_group_emprgroups)) {
        $es_group_emprgroups = array($es_group_emprgroups);
    }
    if (!$id) {
        //Ajout d'un nouveau groupe
        if (!$es_group_name) {
            print $msg['es_group_error_emptyfield'];
            show_esgroup_form(0, stripslashes($es_group_name), stripslashes($es_group_fullname), stripslashes($es_group_pmbuserid), array(), $es_group_emprgroups);
            return false;
        }
        if (es_esgroup::name_exists($es_group_name)) {
            print $msg['es_group_error_namealreadyexists'];
            show_esgroup_form(0, stripslashes($es_group_name), stripslashes($es_group_fullname), stripslashes($es_group_pmbuserid), array(), $es_group_emprgroups);
            return false;
        }
        $new_esgroup = es_esgroup::add_new();
        $new_esgroup->esgroup_name = $es_group_name;
        $new_esgroup->esgroup_fullname = $es_group_fullname;
        $new_esgroup->esgroup_pmbuserid = $es_group_pmbuserid;
        //		$new_esgroup->esgroup_esusers = $es_group_esusers;
        $new_esgroup->esgroup_emprgroups = $es_group_emprgroups;
        $new_esgroup->commit_to_db();
    } else {
        $thegroup = new es_esgroup($id);
        if ($the_group->error) {
            return false;
        }
        $thegroup->esgroup_name = $es_group_name;
        $thegroup->esgroup_fullname = $es_group_fullname;
        $thegroup->esgroup_pmbuserid = $es_group_pmbuserid;
        $thegroup->esgroup_esusers = $es_group_esusers;
        $thegroup->esgroup_emprgroups = $es_group_emprgroups;
        $thegroup->commit_to_db();
    }
    return true;
}