Subversion Repositories Applications.gtt

Rev

Rev 67 | Rev 92 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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