Subversion Repositories Applications.gtt

Rev

Rev 10 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10 Rev 48
1
<?php
1
<?php
2
// +------------------------------------------------------------------------------------------------------+
2
// +------------------------------------------------------------------------------------------------------+
3
// | PHP version 5.1.1                                                                                    |
3
// | PHP version 5.1.1                                                                                    |
4
// +------------------------------------------------------------------------------------------------------+
4
// +------------------------------------------------------------------------------------------------------+
5
// | Copyright (C) 2006 Tela Botanica (accueil@tela-botanica.org)                                         |
5
// | Copyright (C) 2006 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// +------------------------------------------------------------------------------------------------------+
6
// +------------------------------------------------------------------------------------------------------+
7
// | This file is part of eFlore.                                                                         |
7
// | This file is part of eFlore.                                                                         |
8
// |                                                                                                      |
8
// |                                                                                                      |
9
// | Foobar is free software; you can redistribute it and/or modify                                       |
9
// | Foobar is free software; you can redistribute it and/or modify                                       |
10
// | it under the terms of the GNU General Public License as published by                                 |
10
// | it under the terms of the GNU General Public License as published by                                 |
11
// | the Free Software Foundation; either version 2 of the License, or                                    |
11
// | the Free Software Foundation; either version 2 of the License, or                                    |
12
// | (at your option) any later version.                                                                  |
12
// | (at your option) any later version.                                                                  |
13
// |                                                                                                      |
13
// |                                                                                                      |
14
// | Foobar is distributed in the hope that it will be useful,                                            |
14
// | Foobar is distributed in the hope that it will be useful,                                            |
15
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
16
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
16
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
17
// | GNU General Public License for more details.                                                         |
17
// | GNU General Public License for more details.                                                         |
18
// |                                                                                                      |
18
// |                                                                                                      |
19
// | You should have received a copy of the GNU General Public License                                    |
19
// | You should have received a copy of the GNU General Public License                                    |
20
// | along with Foobar; if not, write to the Free Software                                                |
20
// | along with Foobar; if not, write to the Free Software                                                |
21
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// +------------------------------------------------------------------------------------------------------+
22
// +------------------------------------------------------------------------------------------------------+
23
// CVS : $Id$
23
// CVS : $Id$
24
/**
24
/**
25
* Classe UtilisateurStatut
25
* Classe UtilisateurStatut
26
*
26
*
27
* Description
27
* Description
28
*
28
*
29
*@package eFlore
29
*@package eFlore
30
*@subpackage modele
30
*@subpackage modele
31
//Auteur original :
31
//Auteur original :
32
*@version 3
32
*@version 3
33
*@author        Shaheen ABDOOL RAHEEM <shaheenar50@hotmail.com>
33
*@author        Shaheen ABDOOL RAHEEM <shaheenar50@hotmail.com>
34
//Autres auteurs :
34
//Autres auteurs :
35
*@version 4
35
*@version 4
36
*@author        Jean-Pascal MILCENT <jpm@clapas.org>
36
*@author        Jean-Pascal MILCENT <jpm@clapas.org>
37
*@author        aucun
37
*@author        aucun
38
*@copyright     Tela-Botanica 2000-2006
38
*@copyright     Tela-Botanica 2000-2006
39
*@version       $Revision$ $Date$
39
*@version       $Revision$ $Date$
40
// +------------------------------------------------------------------------------------------------------+
40
// +------------------------------------------------------------------------------------------------------+
41
*/
41
*/
42
 
42
 
43
/**
43
/**
44
* class UtilisateurStatut : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
44
* class UtilisateurStatut : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
45
* classe métier
45
* classe métier
46
*/
46
*/
47
class UtilisateurStatut extends aGttSql {
47
class UtilisateurStatut extends aGttSql {
48
	/*** Constantes : */
48
	/*** Constantes : */
-
 
49
	const GUS_TOUS = 'UTILISATEURSTATUT_TOUS';
49
	const GUS_ID = 'UTILISATEURSTATUT_ID';
50
	const GUS_ID = 'UTILISATEURSTATUT_ID';
50
	const GUS_ID_MAX = 'UTILISATEURSTATUT_ID_MAX';
51
	const GUS_ID_MAX = 'UTILISATEURSTATUT_ID_MAX';
-
 
52
	const GUS_LIBELLE = 'UTILISATEURSTATUT_LIBELLE';
51
	
53
 
52
	/*** Attributs : */
54
	/*** Attributs : */
53
	private $id_utilisateur_statut;
55
	private $id_utilisateur_statut;
54
	private $libelle;
56
	private $libelle;
55
	
57
 
56
	/*** Aggregations : */
58
	/*** Aggregations : */
57
 
59
 
58
	/*** Constructeur : */
60
	/*** Constructeur : */
59
	public function __construct($cmd = null, $parametres = null)
61
	public function __construct($cmd = null, $parametres = null)
60
	{
62
	{
61
		$this->dao_table_nom = 'gestion_utilisateur_statut';
63
		$this->dao_table_nom = 'gestion_utilisateur_statut';
62
		$this->dao_correspondance = array(
64
		$this->dao_correspondance = array(
63
			'gus_id_utilisateur_statut'	=> 'id_utilisateur_statut',
65
			'gus_id_utilisateur_statut'	=> 'id_utilisateur_statut',
64
			'gus_libelle'	=> 'libelle');
66
			'gus_libelle'	=> 'libelle');
65
		
67
 
66
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
68
		// Si l'on veut remplir l'objet à la création on lance la requete correspondante
67
		if (!is_null($cmd)) {
69
		if (!is_null($cmd)) {
68
			$this->consulter($cmd, $parametres, true);
70
			$this->consulter($cmd, $parametres, true);
69
		}
71
		}
70
	}
72
	}
71
	
73
 
72
	/*** Accesseurs : */
74
	/*** Accesseurs : */
73
	// Id Utilisateur Statut
75
	// Id Utilisateur Statut
74
	public function getIdUtilisateurStatut()
76
	public function getIdUtilisateurStatut()
75
	{
77
	{
76
		return $this->id_utilisateur_statut;
78
		return $this->id_utilisateur_statut;
77
	}
79
	}
78
	public function setIdUtilisateurStatut( $ius )
80
	public function setIdUtilisateurStatut( $ius )
79
	{
81
	{
80
		$this->id_utilisateur_statut = $ius;
82
		$this->id_utilisateur_statut = $ius;
81
	}
83
	}
82
	
84
 
83
	// Libelle
85
	// Libelle
84
	public function getLibelle()
86
	public function getLibelle()
85
	{
87
	{
86
		return $this->libelle;
88
		return $this->libelle;
87
	}
89
	}
88
	public function setLibelle( $l )
90
	public function setLibelle( $l )
89
	{
91
	{
90
		$this->libelle = $l;
92
		$this->libelle = $l;
91
	}
93
	}
92
	
94
 
93
	/*** Méthodes : */
95
	/*** Méthodes : */
94
 
96
 
95
	/**
97
	/**
96
	* Consulter la table gestion_utilisateur_statut.
98
	* Consulter la table gestion_utilisateur_statut.
97
	* @return mixed un tableau d'objets UtilisateurStatut s'il y en a plusieurs, l'objet UtilisateurStatut s'il y en a 1 seul sinon false.
99
	* @return mixed un tableau d'objets UtilisateurStatut s'il y en a plusieurs, l'objet UtilisateurStatut s'il y en a 1 seul sinon false.
98
	*/
100
	*/
99
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
101
	public function consulter($cmd = '', $parametres = array(), $instancier = false)
100
	{
102
	{
-
 
103
		if (!is_array($parametres)) {
-
 
104
			$parametres[0] = $parametres;
-
 
105
		}
101
		switch ($cmd) {
106
		switch ($cmd) {
-
 
107
			case UtilisateurStatut::GUS_TOUS:
-
 
108
				$requete = 	'SELECT * '.
-
 
109
							'FROM gestion_utilisateur_statut ';
-
 
110
				break;
102
			case UtilisateurStatut::GUS_ID:
111
			case UtilisateurStatut::GUS_ID:
103
				$requete = 	'SELECT * '.
112
				$requete = 	'SELECT * '.
104
							'FROM gestion_utilisateur_statut '.
113
							'FROM gestion_utilisateur_statut '.
105
							'WHERE gus_id_utilisateur_statut = '.$parametres[0].' ';
114
							'WHERE gus_id_utilisateur_statut = '.$parametres[0].' ';
106
				break;
115
				break;
107
			case UtilisateurStatut::GUS_ID_MAX:
116
			case UtilisateurStatut::GUS_ID_MAX:
108
				$requete =	'SELECT MAX(gus_id_utilisateur_statut) '.
117
				$requete =	'SELECT MAX(gus_id_utilisateur_statut) AS gus_id_utilisateur_statut '.
109
							'FROM gestion_utilisateur_statut ';
118
							'FROM gestion_utilisateur_statut ';
-
 
119
				break;
-
 
120
			case UtilisateurStatut::GUS_LIBELLE:
-
 
121
				$requete =	'SELECT * '.
-
 
122
							'FROM gestion_utilisateur_statut '.
-
 
123
							'WHERE gus_libelle = "'.$parametres[0].'" ';
110
				break;
124
				break;
111
			default :
125
			default :
112
				$message = 'Commande '.$cmd.'inconnue!';
126
				$message = 'Commande '.$cmd.'inconnue!';
113
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
127
				$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
114
    			trigger_error($e, E_USER_ERROR);
128
    			trigger_error($e, E_USER_ERROR);
115
		}
129
		}
116
		
130
 
117
		$resultat = $GLOBALS['db']->query($requete);
131
		$resultat = $GLOBALS['db']->query($requete);
118
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
132
		(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
119
		$tab_resultat = array();
133
		$tab_resultat = array();
120
		while ($donnees =& $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
134
		while ($donnees =& $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
121
			$tab_resultat[] = $this->basculerEnregistrementObjet($donnees, $instancier);
135
			$tab_resultat[] = $this->basculerEnregistrementObjet($donnees, $instancier);
122
		}
136
		}
123
				
137
 
124
		$resultat_nbre = count($tab_resultat); 
138
		$resultat_nbre = count($tab_resultat);
125
		if ($resultat_nbre > 1) {
139
		if ($resultat_nbre > 1) {
126
			return $tab_resultat;
140
			return $tab_resultat;
127
		} else if ($resultat_nbre == 1) {
141
		} else if ($resultat_nbre == 1) {
128
			return $tab_resultat[0];
142
			return $tab_resultat[0];
129
		} else if ($resultat_nbre == 0) {
143
		} else if ($resultat_nbre == 0) {
130
			return false;
144
			return false;
131
		}
145
		}
132
	}
146
	}
133
      
147
 
134
	/** Afficher l'objet UtilisateurStatut */
148
	/** Afficher l'objet UtilisateurStatut */
135
	function afficherUtilisateurStatut()
149
	function afficherUtilisateurStatut()
136
	{
150
	{
137
		echo '<pre>'.print_r($this, true).'</pre>';
151
		echo '<pre>'.print_r($this, true).'</pre>';
138
	}
152
	}
139
}
153
}
140
 
154
 
141
/* +--Fin du code ----------------------------------------------------------------------------------------+
155
/* +--Fin du code ----------------------------------------------------------------------------------------+
142
*
156
*
143
* $Log$
157
* $Log$
144
*
158
*
145
* +-- Fin du code ----------------------------------------------------------------------------------------+
159
* +-- Fin du code ----------------------------------------------------------------------------------------+
146
*/
160
*/
147
?>
161
?>