Ejemplo n.º 1
0
 /**
  * Encapsule le comportement du module d'ajout d'utilisateurs
  *
  * @param string $onglet
  *
  * @return void
  * @access public
  * @static
  */
 public static function ajoutUtilisateurModule($onglet)
 {
     $saisie_user = getpost_variable('saisie_user');
     $return = '';
     // si on recupere les users dans ldap et qu'on vient d'en créer un depuis la liste déroulante
     if ($_SESSION['config']['export_users_from_ldap'] && isset($_POST['new_ldap_user'])) {
         $index = 0;
         // On lance une boucle pour selectionner tous les items
         // traitements : $login contient les valeurs successives
         foreach ($_POST['new_ldap_user'] as $login) {
             $tab_login[$index] = $login;
             $index++;
             // cnx à l'annuaire ldap :
             $ds = ldap_connect($_SESSION['config']['ldap_server']);
             ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
             // Support Active Directory
             ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
             if ($_SESSION['config']['ldap_user'] == "") {
                 $bound = ldap_bind($ds);
             } else {
                 $bound = ldap_bind($ds, $_SESSION['config']['ldap_user'], $_SESSION['config']['ldap_pass']);
             }
             // recherche des entrées :
             $filter = "(" . $_SESSION['config']['ldap_login'] . "=" . $login . ")";
             $sr = ldap_search($ds, $_SESSION['config']['searchdn'], $filter);
             $data = ldap_get_entries($ds, $sr);
             foreach ($data as $info) {
                 $tab_new_user[$login]['login'] = $login;
                 $ldap_libelle_prenom = $_SESSION['config']['ldap_prenom'];
                 $ldap_libelle_nom = $_SESSION['config']['ldap_nom'];
                 $tab_new_user[$login]['prenom'] = utf8_decode($info[$ldap_libelle_prenom][0]);
                 $tab_new_user[$login]['nom'] = utf8_decode($info[$ldap_libelle_nom][0]);
                 $ldap_libelle_mail = $_SESSION['config']['ldap_mail'];
                 $tab_new_user[$login]['email'] = $info[$ldap_libelle_mail][0];
             }
             $tab_new_user[$login]['quotite'] = getpost_variable('new_quotite');
             $tab_new_user[$login]['is_resp'] = getpost_variable('new_is_resp');
             $tab_new_user[$login]['resp_login'] = getpost_variable('new_resp_login');
             $tab_new_user[$login]['is_admin'] = getpost_variable('new_is_admin');
             $tab_new_user[$login]['is_hr'] = getpost_variable('new_is_hr');
             $tab_new_user[$login]['see_all'] = getpost_variable('new_see_all');
             if ($_SESSION['config']['how_to_connect_user'] == "dbconges") {
                 $tab_new_user[$login]['password1'] = getpost_variable('new_password1');
                 $tab_new_user[$login]['password2'] = getpost_variable('new_password2');
             }
             $tab_new_jours_an = getpost_variable('tab_new_jours_an');
             $tab_new_solde = getpost_variable('tab_new_solde');
             $tab_checkbox_sem_imp = getpost_variable('tab_checkbox_sem_imp');
             $tab_checkbox_sem_p = getpost_variable('tab_checkbox_sem_p');
             $tab_new_user[$login]['new_jour'] = getpost_variable('new_jour');
             $tab_new_user[$login]['new_mois'] = getpost_variable('new_mois');
             $tab_new_user[$login]['new_year'] = getpost_variable('new_year');
         }
     } else {
         $tab_new_user[0]['login'] = getpost_variable('new_login');
         $tab_new_user[0]['nom'] = getpost_variable('new_nom');
         $tab_new_user[0]['prenom'] = getpost_variable('new_prenom');
         $tab_new_user[0]['quotite'] = getpost_variable('new_quotite');
         $tab_new_user[0]['is_resp'] = getpost_variable('new_is_resp');
         $tab_new_user[0]['resp_login'] = getpost_variable('new_resp_login');
         $tab_new_user[0]['is_admin'] = getpost_variable('new_is_admin');
         $tab_new_user[0]['is_hr'] = getpost_variable('new_is_hr');
         $tab_new_user[0]['see_all'] = getpost_variable('new_see_all');
         if ($_SESSION['config']['how_to_connect_user'] == "dbconges") {
             $tab_new_user[0]['password1'] = getpost_variable('new_password1');
             $tab_new_user[0]['password2'] = getpost_variable('new_password2');
         }
         $tab_new_user[0]['email'] = getpost_variable('new_email');
         $tab_new_jours_an = getpost_variable('tab_new_jours_an');
         $tab_new_solde = getpost_variable('tab_new_solde');
         $tab_checkbox_sem_imp = getpost_variable('tab_checkbox_sem_imp');
         $tab_checkbox_sem_p = getpost_variable('tab_checkbox_sem_p');
         $tab_new_user[0]['new_jour'] = getpost_variable('new_jour');
         $tab_new_user[0]['new_mois'] = getpost_variable('new_mois');
         $tab_new_user[0]['new_year'] = getpost_variable('new_year');
     }
     $checkbox_user_groups = getpost_variable('checkbox_user_groups');
     /* FIN de la recup des parametres    */
     /*************************************/
     if ($saisie_user == "ok") {
         if ($_SESSION['config']['export_users_from_ldap']) {
             foreach ($tab_login as $login) {
                 $return .= \admin\Fonctions::ajout_user($tab_new_user[$login], $tab_checkbox_sem_imp, $tab_checkbox_sem_p, $tab_new_jours_an, $tab_new_solde, $checkbox_user_groups);
             }
         } else {
             $return .= \admin\Fonctions::ajout_user($tab_new_user[0], $tab_checkbox_sem_imp, $tab_checkbox_sem_p, $tab_new_jours_an, $tab_new_solde, $checkbox_user_groups);
         }
     } else {
         $return .= \admin\Fonctions::affiche_formulaire_ajout_user($tab_new_user[0], $tab_new_jours_an, $tab_new_solde, $onglet);
     }
     return $return;
 }