diff --git a/include/class/user.class.php b/include/class/user.class.php index 130501a3d..45faa8091 100644 --- a/include/class/user.class.php +++ b/include/class/user.class.php @@ -384,7 +384,7 @@ class User $cn=new Database(); $this->id=$cn->get_value($Sql, - array($this->first_name, $this->last_name, $this->login, 1, 0, $this->pass, $this->email)); + array($this->first_name, $this->last_name, $this->login, 1, $this->admin, $this->pass, $this->email)); } /** diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index 64cbb55b5..f706bda19 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -1468,7 +1468,7 @@ function remove_divide_zero($p_formula) function generate_random_string($car) { $string=""; - $chaine="abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789*/+-=<>"; + $chaine="abcdefghijklmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY0123456789*/+-="; srand((double) microtime()*1020030); for ($i=0; $i<$car; $i++) { diff --git a/include/user.inc.php b/include/user.inc.php index df3152ff5..2ab409454 100644 --- a/include/user.inc.php +++ b/include/user.inc.php @@ -62,9 +62,88 @@ if ( isset ($_POST["ADD"]) ) } } //SET login +/******************************************************/ +// Update user +/******************************************************/ +$sbaction=$http->post('sbaction',"string", ""); +if ($sbaction == "save") +{ + $uid = $http->post("UID"); + // Update User + $cn = new Database(); + $UserChange = new User($cn, $uid); + + if ($UserChange->load() == -1) + { + alert(_("Cet utilisateur n'existe pas")); + } + else + { + $UserChange->first_name =$http->post('fname'); + $UserChange->last_name = $http->post('lname'); + $UserChange->active = $http->post('Actif'); + $UserChange->admin = $http->post('Admin'); + $UserChange->email = $http->post('email'); + if ($UserChange->active ==-1 || $UserChange->admin ==-1) + { + die ('Missing data'); + } + else if ( trim($_POST['password'])<>'') + { + $UserChange->pass = md5($_POST['password']); + $UserChange->save(); + } + else + { + $UserChange->pass=$UserChange->password; + $UserChange->save(); + } + + } +} +else if ($sbaction == "delete") +{ +/******************************************************/ +// Delete the user +/******************************************************/ + // check that the control is correct + try { + $code=$http->post("userdel"); + $ctl_code=$http->post('ctlcode'); + $uid = $http->request('use_id'); + } catch (Exception $ex) { + echo_error($ex->getMessage()); + throw $ex; + } + if ( DEBUGNOALYSS > 1) { + echo "code [$code] code control [$ctl_code]"; + } + if ( $code != $ctl_code) { + echo _("Code invalide, effacement refusé"); + return; + } + $cn = new Database(); + $auser=$cn->get_row('select use_login from ac_users where use_id = $1',[$uid]); + if ( $auser == null) return; + $Res = $cn->exec_sql("delete from jnt_use_dos where use_id=$1", array($uid)); + $Res = $cn->exec_sql("delete from ac_users where use_id=$1", array($uid)); + //------------------------------------ + // Remove user from all the dossiers + //------------------------------------ + $a_dossier=$cn->get_array('select dos_id from ac_dossier'); + if ( is_array($a_dossier) ) { + $nb=count($a_dossier); + for ( $i=0;$i<$nb;$i++) + User::remove_inexistant_user($a_dossier[$i]['dos_id']); + } + User::audit_admin(sprintf('DELETE USER %s %s',$uid,$auser['use_login'])); + echo "