| 45 | aurelien | 1 | <?php
 | 
        
           |  |  | 2 | /**
 | 
        
           |  |  | 3 | * PHP Version 5
 | 
        
           |  |  | 4 | *
 | 
        
           |  |  | 5 | * @category  PHP
 | 
        
           |  |  | 6 | * @package   annuaire
 | 
        
           |  |  | 7 | * @author    aurelien <aurelien@tela-botanica.org>
 | 
        
           |  |  | 8 | * @copyright 2010 Tela-Botanica
 | 
        
           |  |  | 9 | * @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
 | 
        
           |  |  | 10 | * @version   SVN: <svn_id>
 | 
        
           |  |  | 11 | * @link      /doc/annuaire/
 | 
        
           |  |  | 12 | */
 | 
        
           |  |  | 13 |   | 
        
           | 120 | aurelien | 14 | Class IdentificationControleur extends AppControleur {
 | 
        
           | 45 | aurelien | 15 |   | 
        
           |  |  | 16 | 	private $nom_cookie_persistant = '';
 | 
        
           |  |  | 17 | 	private $duree_identification = '0';
 | 
        
           | 85 | aurelien | 18 | 	private $fonction_cryptage_mdp_cookie = 'md5';
 | 
        
           |  |  | 19 | 	private $objet_identification = null;
 | 
        
           |  |  | 20 |   | 
        
           |  |  | 21 | 	/*public function IdentificationControleur() {
 | 
        
           | 45 | aurelien | 22 |   | 
        
           | 85 | aurelien | 23 | 		Controleur::__construct();
 | 
        
           |  |  | 24 | 		$this->cookie_persistant_nom = session_name().'-memo';
 | 
        
           | 45 | aurelien | 25 | 		$this->cookie_persistant_nom = 'pap-admin_papyrus_-memo';
 | 
        
           |  |  | 26 | 		$this->duree_identification = time()+Config::get('duree_session_identification');
 | 
        
           |  |  | 27 | 		$this->fonction_cryptage_mdp_cookie = Config::get('fonction_cryptage_mdp_cookie');
 | 
        
           | 85 | aurelien | 28 |   | 
        
           |  |  | 29 | 	}*/
 | 
        
           | 45 | aurelien | 30 |   | 
        
           |  |  | 31 | 	public function afficherFormulaireIdentification($id_annuaire, $donnees = array()) {
 | 
        
           |  |  | 32 |   | 
        
           |  |  | 33 | 		$this->chargerModele('AnnuaireModele');
 | 
        
           |  |  | 34 | 		$annuaire = $this->AnnuaireModele->chargerAnnuaire($id_annuaire);
 | 
        
           |  |  | 35 |   | 
        
           | 85 | aurelien | 36 | 		if(!isset($donnees['informations'])) {
 | 
        
           |  |  | 37 | 			$donnees['informations'] = array();
 | 
        
           |  |  | 38 | 		}
 | 
        
           |  |  | 39 |   | 
        
           |  |  | 40 | 		$donnees['id_annuaire'] = $id_annuaire;
 | 
        
           |  |  | 41 |   | 
        
           |  |  | 42 | 		return $this->getVue(Config::get('dossier_squelettes_formulaires').'identification',$donnees);
 | 
        
           | 45 | aurelien | 43 | 	}
 | 
        
           | 294 | aurelien | 44 |   | 
        
           | 85 | aurelien | 45 | 	public function loggerUtilisateur($utilisateur, $pass) {
 | 
        
           |  |  | 46 |   | 
        
           |  |  | 47 | 		$this->objet_identification = Config::get('objet_identification');
 | 
        
           | 120 | aurelien | 48 |   | 
        
           | 143 | aurelien | 49 | 		// on cree le cookie
 | 
        
           |  |  | 50 | 		$this->creerCookie($utilisateur, $pass);
 | 
        
           |  |  | 51 |   | 
        
           | 85 | aurelien | 52 | 		// On loggue l'utilisateur
 | 
        
           |  |  | 53 | 		$this->objet_identification->username = $utilisateur;
 | 
        
           |  |  | 54 | 		$this->objet_identification->password = $pass;
 | 
        
           |  |  | 55 | 		$this->objet_identification->login();
 | 
        
           |  |  | 56 |   | 
        
           |  |  | 57 | 		return true;
 | 
        
           |  |  | 58 | 	}
 | 
        
           | 96 | aurelien | 59 |   | 
        
           | 106 | aurelien | 60 | 	public function deLoggerUtilisateur() {
 | 
        
           |  |  | 61 |   | 
        
           |  |  | 62 | 		$this->objet_identification = Config::get('objet_identification');
 | 
        
           |  |  | 63 | 		$this->objet_identification->logout();
 | 
        
           | 120 | aurelien | 64 |   | 
        
           | 106 | aurelien | 65 | 		return true;
 | 
        
           |  |  | 66 | 	}
 | 
        
           |  |  | 67 |   | 
        
           | 143 | aurelien | 68 | 	public function setUtilisateur($nom_utilisateur) {
 | 
        
           |  |  | 69 | 		$this->objet_identification = Config::get('objet_identification');
 | 
        
           |  |  | 70 | 		$this->objet_identification->setAuth($nom_utilisateur);
 | 
        
           |  |  | 71 | 		$pass = $this->objet_identification->password;
 | 
        
           |  |  | 72 | 		$this->creerCookie($nom_utilisateur, $pass, true);
 | 
        
           |  |  | 73 | 	}
 | 
        
           |  |  | 74 |   | 
        
           |  |  | 75 | 	public function creerCookie($utilisateur, $pass, $pass_deja_crypte = false) {
 | 
        
           | 96 | aurelien | 76 |   | 
        
           | 143 | aurelien | 77 | 		$this->objet_identification = Config::get('objet_identification');
 | 
        
           |  |  | 78 |   | 
        
           |  |  | 79 | 		// Expiration si l'utilisateur ne referme pas son navigateur
 | 
        
           |  |  | 80 | 		$this->objet_identification->setExpire(0);
 | 
        
           | 359 | aurelien | 81 | 		$this->objet_identification->setIdle(0);
 | 
        
           | 143 | aurelien | 82 | 		// Création d'un cookie pour rendre permanente l'identification de Papyrus
 | 
        
           |  |  | 83 | 		if(!$pass_deja_crypte) {
 | 
        
           |  |  | 84 | 			$pass_crypt = md5($pass);
 | 
        
           |  |  | 85 | 		} else {
 | 
        
           |  |  | 86 | 			$pass_crypt = $pass;
 | 
        
           |  |  | 87 | 		}
 | 
        
           |  |  | 88 | 		$cookie_val = $pass_crypt.$utilisateur;
 | 
        
           | 170 | aurelien | 89 | 		setcookie(session_name().'-memo', $cookie_val, 0, '/');
 | 
        
           | 96 | aurelien | 90 | 	}
 | 
        
           | 170 | aurelien | 91 |   | 
        
           |  |  | 92 | 	public function obtenirLoginUtilisateurParCookie() {
 | 
        
           |  |  | 93 |   | 
        
           |  |  | 94 | 		$nom_session = Config::get('nom_session');
 | 
        
           |  |  | 95 |   | 
        
           |  |  | 96 | 		if(isset($_COOKIE[$nom_session])) {
 | 
        
           |  |  | 97 | 			$cookie_val = $_COOKIE[$nom_session];
 | 
        
           |  |  | 98 | 			$login_utilisateur = substr($cookie_val, '32', strlen($cookie_val));
 | 
        
           |  |  | 99 | 			return $login_utilisateur;
 | 
        
           |  |  | 100 | 		} else {
 | 
        
           |  |  | 101 | 			return false;
 | 
        
           |  |  | 102 | 		}
 | 
        
           |  |  | 103 |   | 
        
           |  |  | 104 | 	}
 | 
        
           | 45 | aurelien | 105 | }
 | 
        
           | 294 | aurelien | 106 | ?>
 |