示例#1
0
         $id = $_GET['id'];
     } elseif (isset($_POST['id'])) {
         $id = $_POST['id'];
     } else {
         // TODO ERROR
     }
     if (isset($_GET['userId'])) {
         $userId = $_GET['userId'];
     } elseif (isset($_POST['userId'])) {
         $userId = $_POST['userId'];
     } else {
         // TODO ERROR
     }
     $groupM = new groupManager();
     if ($groupM->getGroupUserMap($id, $userId) == 0) {
         $groupM->addGroupUserMap($id, $userId);
         // TODO
         echo 'Le membre vient d\'être ajouté!';
         echo '<script type="text/javascript">$( \'#popupContent\' ).load(\'index.php?m=a&g=core&p=admin_groups&a=group_user_map&id=' . $id . '\');</script>';
     } else {
         // TODO
         echo 'Ce membre existe déjà.';
     }
     break;
     // Display the table content
 // Display the table content
 case 'jsonList':
     $dataArray['data'] = array();
     $q0 = get_link()->prepare("SELECT id AS ID,name AS NAME FROM " . get_ini('BDD_PREFIX') . "core_groups WHERE deleted_date=0 ORDER BY name ASC");
     $q0->execute();
     while ($r0 = $q0->fetch(PDO::FETCH_OBJ)) {
示例#2
0
 if ($userM->getIdByName('admin') == 0) {
     $userM->create('admin', 'lib/avatars/brain.jpg', '');
 }
 if ($userM->getIdByName('#core#_#0#') == 0) {
     $userM->create('#core#_#0#', 'lib/avatars/brain.jpg', '');
 }
 // Guest user
 if ($userM->getIdByName('process') == 0) {
     $userM->create('process', 'lib/avatars/brain.jpg', '');
 }
 // Add default user group mapping
 echo ' - Fill user group maps table<BR>';
 $groupM = new groupManager();
 $userM = new userManager();
 if ($groupM->getGroupUserMap($groupM->getId('admins'), $userM->getIdByName('admin')) == 0) {
     $groupM->addGroupUserMap($groupM->getId('admins'), $userM->getIdByName('admin'));
 }
 if ($groupM->getGroupUserMap($groupM->getId('admins'), $userM->getIdByName('process')) == 0) {
     $groupM->addGroupUserMap($groupM->getId('admins'), $userM->getIdByName('process'));
 }
 if ($groupM->getGroupUserMap($groupM->getId('guests'), $userM->getIdByName('#core#_#0#')) == 0) {
     $groupM->addGroupUserMap($groupM->getId('guests'), $userM->getIdByName('#core#_#0#'));
 }
 // Add default auth
 echo ' - Fill auths table<BR>';
 $authM = new authManager();
 $authMethodM = new authMethodManager();
 $userM = new userManager();
 if ($authM->getId($userM->getIdByName('admin'), $authMethodM->getId('LOCAL')) == 0) {
     $authM->create($userM->getIdByName('admin'), $authMethodM->getId('LOCAL'), 'admin', 'gob', 'lib/avatars/brain.jpg', '', '', 'admin');
 }
示例#3
0
 function register($method, $name, $password, $avatar, $lastName, $firstName, $mail, $isSendMail = 'TRUE')
 {
     $authM = new authManager();
     $authMethodM = new authMethodManager();
     $groupM = new groupManager();
     // Check if the user already exist
     if ($mail != '' && mailCheck($mail) && $this->getId($mail) == 0) {
         // $authM->getId($userId,$methodId) && ($method,$mail,$password) == 0
         // Generate a password
         $generatedPassword = stringGenerate();
         if ($isSendMail == 'TRUE') {
             // On envoie le mail de confirmation avec le mot de passe
             $sujet = 'Création d\'un compte ' . get_ini('APPLICATION_NAME');
             $message = '
         	            Bonjour,<br />
         	            <br />
         	            Voici vos identifiants pour l\'application ' . get_ini('APPLICATION_NAME') . '<br />
         	            Login: <strong>' . $mail . '</strong><br />
         	            Password: <strong>' . $generatedPassword . '</strong><br />
         	            <br />
         	            Merci!<br />
         	            <br />
         	            ' . get_ini('ADMIN_MAIL') . '
         	            ';
             $destinataire = strtolower($mail);
             $headers = "From: " . get_ini('ADMIN_MAIL') . "\n";
             $headers .= "Reply-To: " . get_ini('ADMIN_MAIL') . "\n";
             $headers .= "Content-Type: text/html; charset=\"UTF-8\"";
             if (!mail($destinataire, $sujet, $message, $headers)) {
                 echo "Une erreur c'est produite lors de l'envois de l'email.";
             }
         }
         // On créé l'utilisateur
         $q0_last_insert = $this->create($name, $avatar, $mail);
         // On ajoute la méthode de connexion locale
         $authM->create($q0_last_insert, $authMethodM->getId('LOCAL'), $name, $generatedPassword, $avatar, $lastName, $firstName, $mail);
         // On ajoute le groupe par défaut si il y en a un
         if (get_ini('default_group') != '') {
             $groupM->addGroupUserMap($groupM->getId(get_ini('default_group')), $q0_last_insert);
         }
         // On ajoute d'éventuelle autre méthode d'authentification (Facebook, google, ...)
         switch ($method) {
             case 'LDAP':
                 $authM->create($q0_last_insert, $authMethodM->getId('LDAP'), strtolower($name), '', get_ini('DEFAULT_AVATAR'), '', '', $mail, 'FALSE');
                 break;
             case 'FACEBOOK':
                 $authM->create($q0_last_insert, $authMethodM->getId('FACEBOOK'), $name, $password, $avatar, $lastName, $firstName, $mail);
                 break;
             case 'GOOGLE':
                 $authM->create($q0_last_insert, $authMethodM->getId('GOOGLE'), $name, $password, $avatar, $lastName, $firstName, $mail);
                 break;
         }
     } else {
         // Todo error
     }
 }