Subversion Repositories Applications.framework

Rev

Rev 128 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 128 Rev 233
Line 10... Line 10...
10
 * @category  Class
10
 * @category  Class
11
 * @author	aurelien <aurelien@tela-botanica.org>
11
 * @author	aurelien <aurelien@tela-botanica.org>
12
 * @copyright 2009 Tela-Botanica
12
 * @copyright 2009 Tela-Botanica
13
 * @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
13
 * @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
14
 * @license   http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
14
 * @license   http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
15
 * @version   SVN: $$Id: ListeAdmin.php 128 2009-09-02 12:20:55Z aurelien $$
15
 * @version   SVN: $$Id: ListeAdmin.php 233 2010-11-19 17:14:01Z jpm $$
16
 * @link	  /doc/framework/
16
 * @link	  /doc/framework/
17
 *
17
 *
18
 */
18
 */
19
class listeAdmin extends Modele {
19
class listeAdmin extends Modele {
Line 27... Line 27...
27
	 */
27
	 */
28
   public function chargerAdmin() {
28
   public function chargerAdmin() {
29
		$requete = 	'SELECT * '.
29
		$requete = 	'SELECT * '.
30
					'FROM  gen_annuaire '.
30
					'FROM  gen_annuaire '.
31
					'ORDER BY ga_id_administrateur';
31
					'ORDER BY ga_id_administrateur';
32
		$resultat = $this->requete($requete);
32
		$resultat = $this->requeteTous($requete);
33
		$admin = array();
33
		$admin = array();
-
 
34
		if ($resultat !== false) {
34
		foreach ($resultat->fetchAll() as $ligne) {
35
			foreach ($resultat as $ligne) {
35
			if ($ligne['ga_id_administrateur'] != 0) {
36
				if ($ligne['ga_id_administrateur'] != 0) {
36
				$admin[] = $ligne;
37
					$admin[] = $ligne;
-
 
38
				}
37
			}
39
			}
38
		}
40
		}
39
		return $admin;
41
		return $admin;
40
	}
42
	}
Line 167... Line 169...
167
	 * @param  string   le code de langue
169
	 * @param  string   le code de langue
168
	 * @param  string   le mot de passe
170
	 * @param  string   le mot de passe
169
	 * @param  string   la confirmation du mot de passe
171
	 * @param  string   la confirmation du mot de passe
170
	 * @return array	un tableau contenant les erreurs s'il y en a, vide sinon
172
	 * @return array	un tableau contenant les erreurs s'il y en a, vide sinon
171
	 */
173
	 */
172
	function ajoutAdmin($nom,$prenom,$mail,$lang,$pass,$pass_conf) {
174
	function ajoutAdmin($nom, $prenom, $mail, $lang, $pass, $pass_conf) {
173
 
-
 
174
		$nouvel_id = 0;
175
		$nouvel_id = 0;
175
		$nb_admin = 0;
176
		$nb_admin = 0;
176
		$res = array();
177
		$res = array();
177
 
-
 
-
 
178
Debug::printr('pppppppppp');
178
		if(!$this->validerMail($mail)) {
179
		if (!$this->validerMail($mail)) {
179
			$res['mail'] = 'adresse mail invalide';
180
			$res['mail'] = 'Adresse mail invalide.';
180
		}
181
		}
Line 181... Line 182...
181
 
182
 
-
 
183
		$query_verif_mail =	'SELECT COUNT(*) AS nb_admin '.
-
 
184
								'FROM gen_annuaire '.
182
		$query_verif_mail = 'SELECT COUNT(*) AS nb_admin FROM gen_annuaire WHERE ga_mail = '.$this->proteger($mail);
185
								'WHERE ga_mail = '.$this->proteger($mail);
183
		if($res_nb = $this->requete($query_verif_mail)) {
186
		if ($res_nb = $this->requete($query_verif_mail)) {
184
			$ligne = $res_nb->fetch();
187
			$ligne = $res_nb->fetch();
185
			$nb_admin = $ligne['nb_admin'];
188
			$nb_admin = $ligne['nb_admin'];
186
		} else {
189
		} else {
187
			$res['bdd'] = 'Erreur dans la base de données';
190
			$res['bdd'] = 'Erreur dans la base de données.';
188
			return $res;
191
			return $res;
189
		}
-
 
190
 
192
		}
191
		if($nb_admin != 0) {
193
		if ($nb_admin != 0) {
192
			$res['mail'] = 'Cet email est déjà utilisé par un autre utilisateur';
194
			$res['mail'] = 'Cet email est déjà utilisé par un autre utilisateur.';
Line 193... Line 195...
193
		}
195
		}
194
 
196
 
195
		if($pass != '' || $pass_conf != '') {
197
		if ($pass != '' || $pass_conf != '') {
196
			// on vérifie si les deux concordent
-
 
197
			if($pass == $pass_conf) {
-
 
198
 
198
			// on vérifie si les deux concordent
199
			} else {
199
			if ($pass != $pass_conf) {
200
				// si non, on notifiera l'utilisateur
200
				// si non, on notifiera l'utilisateur
201
				$res['pass'] = 'mot de passe invalide';
201
				$res['pass'] = 'mot de passe invalide';
Line 202... Line 202...
202
			}
202
			}
203
		}
-
 
-
 
203
		}
204
 
204
 
205
		$query = 'SELECT MAX(ga_id_administrateur) as nouvel_id FROM gen_annuaire';
-
 
206
 
205
		$query =	'SELECT MAX(ga_id_administrateur) as nouvel_id '.
207
		if($res_requete_id = $this->requete($query)) {
206
					'FROM gen_annuaire';
208
 
207
		if ($res_requete_id = $this->requete($query)) {
209
			$ligne = $res_requete_id->fetch() ;
208
			$ligne = $res_requete_id->fetch() ;
210
			$nouvel_id = $ligne['nouvel_id'] + 1;
209
			$nouvel_id = $ligne['nouvel_id'] + 1;
Line -... Line 210...
-
 
210
		} else {
211
		} else {
211
			return $res ;
212
			return $res ;
212
		}
213
		}
213
 
214
 
214
		$query = 	'INSERT INTO gen_annuaire '.
215
		$query = 'INSERT INTO gen_annuaire VALUES ('.$nouvel_id.','.$this->proteger($lang).','.
215
					'VALUES ('.$nouvel_id.','.$this->proteger($lang).','.
216
		$this->proteger($nom).','.$this->proteger($prenom).','.$this->proteger(md5($pass)).','.
216
					$this->proteger($nom).','.$this->proteger($prenom).','.$this->proteger(md5($pass)).','.
217
		$this->proteger($mail).')';
217
					$this->proteger($mail).')';
Line 218... Line 218...
218
 
218
		
219
		if(count($res) != 0) {
-
 
220
			return $res;
-
 
221
		}
219
		if (count($res) != 0) {
222
 
220
			return $res;
Line 223... Line 221...
223
		if($res_ajout = $this->requete($query)) {
221
		}
224
 
222