Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2003 Aurélien 1
<?php
2
class liste_admin_model extends Model {
3
4
	var $config = array() ;
5
6
	function __construct() {
7
8
		parent::Model() ;
9
	}
10
11
	function loadAdmin() {
12
13
		$this->load->database() ;
14
		$query = 'SELECT * FROM  gen_annuaire ORDER BY ga_id_administrateur' ;
15
		$res = $this->db->query($query) ;
16
		$admin = array() ;
17
		foreach ($res->result() as $ligne)
18
		{
19
			$admin[] = $ligne ;
20
		}
21
22
		return $admin ;
23
	}
24
25
	function loadDetailsAdmin($id) {
26
27
		$this->load->database() ;
28
		$query = 'SELECT * FROM  gen_annuaire where ga_id_administrateur="'.$id.'"' ;
29
		$res = $this->db->query($query) ;
30
		$admin = array() ;
31
		foreach ($res->result() as $ligne)
32
		{
33
			$admin[] = $ligne ;
34
		}
35
36
		return $admin ;
37
	}
38
39
	function modifDetailsAdmin($id,$nom,$prenom,$mail,$lang) {
40
41
		$this->load->database() ;
42
		$query = 'UPDATE gen_annuaire SET ga_ce_i18n="'.$lang.'", ga_nom="'.$nom.'",ga_prenom="'.$prenom.'",ga_mail="'.$mail.'"
43
		WHERE ga_id_administrateur="'.$id.'"' ;
44
45
		if($res = $this->db->query($query)) {
46
			return true ;
47
		} else {
48
			return false ;
49
		}
50
51
	}
52
53
	function suppAdmin($id) {
54
55
		$this->load->database() ;
56
		$query = 'DELETE FROM gen_annuaire WHERE ga_id_administrateur="'.$id.'"' ;
57
58
		if($res = $this->db->query($query)) {
59
			return true ;
60
		} else {
61
			return false ;
62
		}
63
	}
64
65
	function ajoutAdmin($nom,$prenom,$mail,$lang,$pass,$pass_conf) {
66
		$this->load->database() ;
67
		$nouvel_id = 0 ;
68
		$query = 'SELECT MAX(ga_id_administrateur) as nouvel_id FROM gen_annuaire' ;
69
70
		if($res = $this->db->query($query)) {
71
72
			$ligne = $res->result() ;
73
			$nouvel_id = $ligne[0]->nouvel_id + 1 ;
74
		} else {
75
			return false ;
76
		}
77
78
		$query = 'INSERT INTO gen_annuaire VALUES ("'.$nouvel_id.'","'.$lang.'","'.$nom.'","'.$prenom.'","'.md5($pass).'","'.$mail.'")' ;
79
		if($res = $this->db->query($query)) {
80
			return true ;
81
		} else {
82
			return false ;
83
		}
84
	}
85
86
}
87
88
?>