function modifier_user() { global $page; global $administration; global $message; $page['gabarit'] = "administration"; if (isset($_SESSION['role_user']) && droit_acces($administration['modifier_user'], $_SESSION['role_user'])) { $page['vue'] = "utilisateurs/user.vue.php"; $page['role'] = liste_role(); $page['lieux'] = liste_lieux(); $page['armee'] = liste_armee(); if (isset($_GET['id'])) { $id = $_GET['id']; } if (isset($_POST['id_user'])) { $id = $_POST['id_user']; } $page['user'] = detail_user($id); $page['user'] = $page['user'][0]; $page['user']['roles'] = detail_affectation($id); if (isset($_POST['modif_user'])) { if (isset($_POST['mdp_user']) && $_POST['mdp_user'] != $_POST['mdp_2_user']) { $page['message'] = $message['erreur_password']; } else { if (!isset($_POST['mdp_user'])) { $_POST['mdp_user'] = ""; } /*modifier en base*/ $admin = 0; foreach ($_POST['id_role'] as $r) { if ($r == 1) { $admin = 1; } } if ($admin == 0) { if (count_admin() > 1 || count_admin() == 1 && !is_admin($_POST['id_user'])) { modification_user($_POST['id_user'], $_POST['nom_user'], $_POST['prenom_user'], $_POST['mail_user'], $_POST['armee_user'], $_POST['mdp_user'], $_POST['lieu_user'], $_POST['actif']); delete_affectation_by_user($_POST['id_user']); if (isset($_POST['id_role'])) { foreach ($_POST['id_role'] as $r) { /*changer affectation*/ affectation($_POST['id_user'], $r); } } if ($_POST['id_user'] == $_SESSION['id_user']) { $_SESSION['nom_prenom'] = $_POST['prenom_user'] . ' ' . $_POST['nom_user']; $_SESSION['id_lieu'] = $_POST['lieu_user']; } header("Location: index.php?controleur=administration&tache=lister_user"); } else { $page['message'] = $message['1_seul_admin']; } } else { modification_user($_POST['id_user'], $_POST['nom_user'], $_POST['prenom_user'], $_POST['mail_user'], $_POST['armee_user'], $_POST['mdp_user'], $_POST['lieu_user'], $_POST['actif']); delete_affectation_by_user($_POST['id_user']); if (isset($_POST['id_role'])) { foreach ($_POST['id_role'] as $r) { /*changer affectation*/ affectation($_POST['id_user'], $r); } } if ($_POST['id_user'] == $_SESSION['id_user']) { $_SESSION['nom_prenom'] = $_POST['prenom_user'] . ' ' . $_POST['nom_user']; $_SESSION['id_lieu'] = $_POST['lieu_user']; } header("Location: index.php?controleur=administration&tache=lister_user"); } } } else { $page['user'] = detail_user($_GET['id']); $page['user'] = $page['user'][0]; $page['user']['roles'] = detail_affectation($_GET['id']); } } else { $page['vue'] = "erreur_droit.vue.php"; } }
function modifier_user() { global $page; global $administration; global $message; $page['message'] = ""; $page['gabarit'] = "administration"; if (isset($_SESSION['role_user']) && droit_acces($administration['modifier_user'], $_SESSION['role_user'])) { $page['vue'] = "utilisateurs/user.vue.php"; $page['role'] = liste_role(); $page['lieux'] = liste_lieux(); $page['armee'] = liste_armee(); if (isset($_GET['id'])) { $id = $_GET['id']; } if (isset($_POST['id_user'])) { $id = $_POST['id_user']; } $page['user'] = detail_user($id); $page['user'] = $page['user'][0]; $page['user']['roles'] = detail_affectation($id); if (isset($_POST['modif_user'])) { if (is_current_version_user($id, $_POST['revision'])) { if (isset($_POST['mdp_user']) && $_POST['mdp_user'] != $_POST['mdp_2_user']) { $page['message'] = $message['erreur_password']; } else { if (!isset($_POST['mdp_user'])) { $_POST['mdp_user'] = ""; } elseif (isset($_POST['mdp_user']) && strlen($_POST['mdp_user']) > 0 && $_POST['mdp_user'] == $_POST['mdp_2_user']) { if (verify_password($_POST['mdp_user'])) { //verification des regles de gestion modification_mdp($_POST['id_user'], $_POST['mdp_user']); } else { $page['message'] = $message['erreur_password_2']; } } /*modifier en base*/ $admin = 0; if (isset($_POST['id_role'])) { foreach ($_POST['id_role'] as $r) { if ($r == 1) { $admin = 1; } } } if ($admin == 0) { if (count_admin() > 1 || count_admin() == 1 && !is_admin($_POST['id_user'])) { if ($_POST['nom_user'] != '' && $_POST['prenom_user'] != "" && $page['message'] == '') { modification_user($_POST['id_user'], $_POST['nom_user'], $_POST['prenom_user'], $_POST['mail_user'], $_POST['id_armee'], $_POST['id_organisme'], $_POST['actif']); delete_affectation_by_user($_POST['id_user']); if (isset($_POST['id_role'])) { foreach ($_POST['id_role'] as $r) { /*changer affectation*/ affectation($_POST['id_user'], $r); } } if ($_POST['id_user'] == $_SESSION['id_user']) { $_SESSION['nom_prenom'] = $_POST['prenom_user'] . ' ' . $_POST['nom_user']; $_SESSION['id_lieu'] = $_POST['lieu_user']; } if ($page['message'] == "") { header("Location: index.php?controleur=utilisateur&tache=lister_user"); } } else { $page['message'] .= $message['champs_obligatoire_2']; } } else { $page['message'] .= $message['1_seul_admin']; } } else { if (!isset($_POST['mdp_user'])) { $_POST['mdp_user'] = ""; } elseif (isset($_POST['mdp_user']) && strlen($_POST['mdp_user']) > 0 && $_POST['mdp_user'] == $_POST['mdp_2_user']) { if (verify_password($_POST['mdp_user'])) { //verification des regles de gestion modification_mdp($_POST['id_user'], $_POST['mdp_user']); } else { $page['message'] = $message['erreur_password_2']; } } if ($_POST['nom_user'] != '' && $_POST['prenom_user'] != "" && $page['message'] == '') { modification_user($_POST['id_user'], $_POST['nom_user'], $_POST['prenom_user'], $_POST['mail_user'], $_POST['id_armee'], $_POST['id_organisme'], $_POST['actif']); delete_affectation_by_user($_POST['id_user']); if (isset($_POST['id_role'])) { foreach ($_POST['id_role'] as $r) { /*changer affectation*/ affectation($_POST['id_user'], $r); } } if ($_POST['id_user'] == $_SESSION['id_user']) { $_SESSION['nom_prenom'] = $_POST['prenom_user'] . ' ' . $_POST['nom_user']; $_SESSION['id_lieu'] = $_POST['id_organisme']; } if ($page['message'] == "") { header("Location: index.php?controleur=utilisateur&tache=lister_user"); } } else { $page['message'] = $message['champs_obligatoire_2']; } } } } else { $page['message'] = $message['outdated_user']; } } else { $page['user'] = detail_user($_GET['id']); $page['user'] = $page['user'][0]; $page['user']['roles'] = detail_affectation($_GET['id']); } } else { $page['vue'] = "erreur_droit.vue.php"; } }