Subversion Repositories Applications.gtt

Compare Revisions

Ignore whitespace Rev 9 → Rev 10

/trunk/classes/metiers/UtilisateurAProjet.class.php
New file
0,0 → 1,161
<?php
// +------------------------------------------------------------------------------------------------------+
// | PHP version 5.1.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2006 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of eFlore. |
// | |
// | Foobar is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation; either version 2 of the License, or |
// | (at your option) any later version. |
// | |
// | Foobar is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with Foobar; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id$
/**
* Classe UtilisateurAProjet
*
* Description
*
*@package eFlore
*@subpackage modele
//Auteur original :
*@version 3
*@author Shaheen ABDOOL RAHEEM <shaheenar50@hotmail.com>
//Autres auteurs :
*@version 4
*@author Jean-Pascal MILCENT <jpm@clapas.org>
*@author aucun
*@copyright Tela-Botanica 2000-2006
*@version $Revision$ $Date$
// +------------------------------------------------------------------------------------------------------+
*/
 
/**
* class UtilisateurAProjet : est à la fois le DAO et le conteneur de la table gestion_utilisateur.
* classe métier
*/
class UtilisateurAProjet extends aGttSql {
/*** Constantes : */
const GUAP_ID = 'UTILISATEURAPROJET_ID';
const GUAP_ID_MAX_UTILISATEUR = 'UTILISATEURAPROJET_ID_MAX_UTILISATEUR';
const GUAP_ID_MAX_PROJET = 'UTILISATEURAPROJET_ID_MAX_PROJET';
const GUAP_UTILISATEUR = 'UTILISATEURAPROJET_ID_UTILISATEUR';
/*** Attributs : */
private $id_utilisateur;
private $id_projet;
/*** Aggregations : */
 
/*** Constructeur : */
public function __construct($cmd = null, $parametres = null)
{
$this->dao_table_nom = 'gestion_utilisateur_a_projet';
$this->dao_correspondance = array(
'guap_id_utilisateur' => 'id_utilisateur',
'guap_id_projet' => 'id_projet');
// Si l'on veut remplir l'objet à la création on lance la requete correspondante
if (!is_null($cmd)) {
$this->consulter($cmd, $parametres, true);
}
}
/*** Accesseurs : */
// Id Utilisateur
public function getIdUtilisateur()
{
return $this->id_utilisateur;
}
public function setIdUtilisateur( $iu )
{
$this->id_utilisateur = $iu;
}
// Id Projet
public function getIdProjet()
{
return $this->id_projet;
}
public function setIdProjet( $ip )
{
$this->id_projet = $ip;
}
/*** Méthodes : */
 
/**
* Consulter la table gestion_utilisateur_a_projet.
* @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.
*/
public function consulter($cmd = '', $parametres = array(), $instancier = false)
{
if (!is_array($parametres)) {
$parametres[0] = $parametres;
}
switch ($cmd) {
case UtilisateurAProjet::GUAP_ID:
$requete = 'SELECT * '.
'FROM gestion_utilisateur_a_projet '.
'WHERE guap_id_utilisateur = '.$parametres[0].' AND guap_id_projet = '.$parametres[1].' ';
break;
case UtilisateurAProjet::GUAP_ID_MAX_UTILISATEUR:
$requete = 'SELECT MAX(guap_id_utilisateur) '.
'FROM gestion_utilisateur_a_projet ';
break;
case UtilisateurAProjet::GUAP_ID_MAX_PROJET:
$requete = 'SELECT MAX(guap_id_projet) '.
'FROM gestion_utilisateur_a_projet ';
break;
case UtilisateurAProjet::GUAP_UTILISATEUR:
$requete = 'SELECT * '.
'FROM gestion_utilisateur_a_projet '.
'WHERE guap_id_utilisateur = '.$parametres[0].' ';
break;
default :
$message = 'Commande '.$cmd.'inconnue!';
$e = GestionnaireErreur::formaterMessageErreur(__FILE__, __LINE__, $message);
trigger_error($e, E_USER_ERROR);
}
$resultat = $GLOBALS['db']->query($requete);
(DB::isError($resultat)) ? die (GestionnaireErreur::retournerErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
$tab_resultat = array();
while ($donnees =& $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$tab_resultat[] = $this->basculerEnregistrementObjet($donnees, $instancier);
}
$resultat_nbre = count($tab_resultat);
if ($resultat_nbre > 1) {
return $tab_resultat;
} else if ($resultat_nbre == 1) {
return $tab_resultat[0];
} else if ($resultat_nbre == 0) {
return false;
}
}
/** Afficher l'objet UtilisateurAProjet */
function afficherUtilisateurAProjet()
{
echo '<pre>'.print_r($this, true).'</pre>';
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log$
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>