| 431 | 
           mathias | 
           1 | 
           <?php
  | 
        
        
            | 
            | 
           2 | 
           // +------------------------------------------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           3 | 
           // | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
  | 
        
        
            | 
            | 
           4 | 
           // +------------------------------------------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           5 | 
           // | This library is free software; you can redistribute it and/or                                        |
  | 
        
        
            | 
            | 
           6 | 
           // | modify it under the terms of the GNU General Public                                                  |
  | 
        
        
            | 
            | 
           7 | 
           // | License as published by the Free Software Foundation; either                                         |
  | 
        
        
            | 
            | 
           8 | 
           // | version 2.1 of the License, or (at your option) any later version.                                   |
  | 
        
        
            | 
            | 
           9 | 
           // |                                                                                                      |
  | 
        
        
            | 
            | 
           10 | 
           // | This library is distributed in the hope that it will be useful,                                      |
  | 
        
        
            | 
            | 
           11 | 
           // | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
  | 
        
        
            | 
            | 
           12 | 
           // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
  | 
        
        
            | 
            | 
           13 | 
           // | General Public License for more details.                                                             |
  | 
        
        
            | 
            | 
           14 | 
           // |                                                                                                      |
  | 
        
        
            | 
            | 
           15 | 
           // | You should have received a copy of the GNU General Public                                            |
  | 
        
        
            | 
            | 
           16 | 
           // | License along with this library; if not, write to the Free Software                                  |
  | 
        
        
            | 
            | 
           17 | 
           // | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
  | 
        
        
            | 
            | 
           18 | 
           // +------------------------------------------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           19 | 
           // CVS : $Id: participe.class.php,v 1.6 2008-08-25 15:11:56 alexandre_tb Exp $
  | 
        
        
            | 
            | 
           20 | 
           /**
  | 
        
        
            | 
            | 
           21 | 
           * Application projet
  | 
        
        
            | 
            | 
           22 | 
           *
  | 
        
        
            | 
            | 
           23 | 
           * La classe partiicpe assure la jointure entre projet et Auth
  | 
        
        
            | 
            | 
           24 | 
           * Elle se base sur la table projet_statut_utilisateur
  | 
        
        
            | 
            | 
           25 | 
           *
  | 
        
        
            | 
            | 
           26 | 
           *@package projet
  | 
        
        
            | 
            | 
           27 | 
           //Auteur original :
  | 
        
        
            | 
            | 
           28 | 
           *@author        Alexandre Granier <alexandre@tela-botanica.org>
  | 
        
        
            | 
            | 
           29 | 
           //Autres auteurs :
  | 
        
        
            | 
            | 
           30 | 
           *@author        Aucun
  | 
        
        
            | 
            | 
           31 | 
           *@copyright     Tela-Botanica 2000-2004
  | 
        
        
            | 
            | 
           32 | 
           *@version       $Revision: 1.6 $
  | 
        
        
            | 
            | 
           33 | 
           // +------------------------------------------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           34 | 
           */
  | 
        
        
            | 
            | 
           35 | 
              | 
        
        
            | 
            | 
           36 | 
              | 
        
        
            | 
            | 
           37 | 
           // +------------------------------------------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           38 | 
           // |                                            ENTETE du PROGRAMME                                       |
  | 
        
        
            | 
            | 
           39 | 
           // +------------------------------------------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           40 | 
              | 
        
        
            | 
            | 
           41 | 
              | 
        
        
            | 
            | 
           42 | 
           /**
  | 
        
        
            | 
            | 
           43 | 
            * class participe
  | 
        
        
            | 
            | 
           44 | 
            *
  | 
        
        
            | 
            | 
           45 | 
            */
  | 
        
        
            | 
            | 
           46 | 
           class participe
  | 
        
        
            | 
            | 
           47 | 
           {
  | 
        
        
            | 
            | 
           48 | 
               /*** Attributes: ***/
  | 
        
        
            | 
            | 
           49 | 
              | 
        
        
            | 
            | 
           50 | 
               /**
  | 
        
        
            | 
            | 
           51 | 
                * Date d'inscription au projet de l'utilisateur.
  | 
        
        
            | 
            | 
           52 | 
                * @access private
  | 
        
        
            | 
            | 
           53 | 
                */
  | 
        
        
            | 
            | 
           54 | 
               var $_date_inscription;
  | 
        
        
            | 
            | 
           55 | 
               /**
  | 
        
        
            | 
            | 
           56 | 
                * Statut de l'utilisateur, un entier.
  | 
        
        
            | 
            | 
           57 | 
                * @access private
  | 
        
        
            | 
            | 
           58 | 
                */
  | 
        
        
            | 
            | 
           59 | 
               var $_statut;
  | 
        
        
            | 
            | 
           60 | 
               /**
  | 
        
        
            | 
            | 
           61 | 
                * Connexion à la base de donnée.
  | 
        
        
            | 
            | 
           62 | 
                * @access private
  | 
        
        
            | 
            | 
           63 | 
                */
  | 
        
        
            | 
            | 
           64 | 
               var $_db;
  | 
        
        
            | 
            | 
           65 | 
              | 
        
        
            | 
            | 
           66 | 
               /**
  | 
        
        
            | 
            | 
           67 | 
                * Constructeur. Nécessite un objet DB valide connecté à la base contenant les
  | 
        
        
            | 
            | 
           68 | 
                * tables projets.
  | 
        
        
            | 
            | 
           69 | 
                *
  | 
        
        
            | 
            | 
           70 | 
                * @param DB objetDB Un objet PEAR:DB valide.
  | 
        
        
            | 
            | 
           71 | 
                * @return void
  | 
        
        
            | 
            | 
           72 | 
                * @access public
  | 
        
        
            | 
            | 
           73 | 
                */
  | 
        
        
            | 
            | 
           74 | 
               function participe( &$objetDB )
  | 
        
        
            | 
            | 
           75 | 
               {
  | 
        
        
            | 
            | 
           76 | 
                   $this->_db = $objetDB ;
  | 
        
        
            | 
            | 
           77 | 
               } // end of member function participe
  | 
        
        
            | 
            | 
           78 | 
              | 
        
        
            | 
            | 
           79 | 
               /**
  | 
        
        
            | 
            | 
           80 | 
                * Renvoie la liste des inscrit à un projet avec leur statut.
  | 
        
        
            | 
            | 
           81 | 
                *
  | 
        
        
            | 
            | 
           82 | 
                * @return Array
  | 
        
        
            | 
            | 
           83 | 
                * @access public
  | 
        
        
            | 
            | 
           84 | 
                */
  | 
        
        
            | 
            | 
           85 | 
               function getInscrits($id_projet, $droits )
  | 
        
        
            | 
            | 
           86 | 
               {
  | 
        
        
            | 
            | 
           87 | 
                   $tableau_resultat = array() ;
  | 
        
        
            | 
            | 
           88 | 
              | 
        
        
            | 
            | 
           89 | 
                   $requete = 'select psu_id_utilisateur,'.PROJET_CHAMPS_NOM.','.PROJET_CHAMPS_PRENOM.',' ;
  | 
        
        
            | 
            | 
           90 | 
                   $requete .= PROJET_CHAMPS_MAIL.', ' ;
  | 
        
        
            | 
            | 
           91 | 
                   $requete .= 'psu_date_inscription,  ps_id_statut '.
  | 
        
        
            | 
            | 
           92 | 
                               ' from projet_statut_utilisateurs, projet_statut,'.PROJET_ANNUAIRE.
  | 
        
        
            | 
            | 
           93 | 
                               ' where psu_id_projet='.$this->_db->escapeSimple($id_projet).' and psu_id_utilisateur='.PROJET_CHAMPS_ID.
  | 
        
        
            | 
            | 
           94 | 
                               ' and psu_id_statut=ps_id_statut order by ps_id_statut,'.PROJET_CHAMPS_NOM;
  | 
        
        
            | 
            | 
           95 | 
                   $resultat = $this->_db->query ($requete) ;
  | 
        
        
            | 
            | 
           96 | 
                   if (DB::isError($resultat)) {
  | 
        
        
            | 
            | 
           97 | 
                       die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
  | 
        
        
            | 
            | 
           98 | 
                   }
  | 
        
        
            | 
            | 
           99 | 
                   while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ORDERED)) {
  | 
        
        
            | 
            | 
           100 | 
                       array_push ($tableau_resultat, $ligne) ;
  | 
        
        
            | 
            | 
           101 | 
                       $id = $ligne[0];
  | 
        
        
            | 
            | 
           102 | 
                       $inscrits[$id]['nom'] = $ligne[1];
  | 
        
        
            | 
            | 
           103 | 
                       $inscrits[$id]['prenom'] = $ligne[2];
  | 
        
        
            | 
            | 
           104 | 
                       $inscrits[$id]['mail'] = $ligne[3];
  | 
        
        
            | 
            | 
           105 | 
                       $inscrits[$id]['date'] = $ligne[4];
  | 
        
        
            | 
            | 
           106 | 
                       $inscrits[$id]['id_statut'] = $ligne[5];
  | 
        
        
            | 
            | 
           107 | 
                   }
  | 
        
        
            | 
            | 
           108 | 
                   $resultat->free() ;
  | 
        
        
            | 
            | 
           109 | 
                   return $tableau_resultat ;
  | 
        
        
            | 
            | 
           110 | 
               } // end of member function getInscrits
  | 
        
        
            | 
            | 
           111 | 
              | 
        
        
            | 
            | 
           112 | 
               /**
  | 
        
        
            | 
            | 
           113 | 
                * Renvoie un tableau contenant la liste des identifiants des projets et des statuts
  | 
        
        
            | 
            | 
           114 | 
                * d'un inscrit. 0 => ['psu_id_utilisateur']          ['psu_id_statut'] 1 => ...
  | 
        
        
            | 
            | 
           115 | 
                *
  | 
        
        
            | 
            | 
           116 | 
                * @param int id_utilisateur Un identifiant d'utilisateur pour le champs
  | 
        
        
            | 
            | 
           117 | 
                * projet_statut_utilisateurs:psu_id_utilisateur
  | 
        
        
            | 
            | 
           118 | 
                * @return Array
  | 
        
        
            | 
            | 
           119 | 
                * @access public
  | 
        
        
            | 
            | 
           120 | 
                */
  | 
        
        
            | 
            | 
           121 | 
               function getIdProjetsStatuts( $id_utilisateur )
  | 
        
        
            | 
            | 
           122 | 
               {
  | 
        
        
            | 
            | 
           123 | 
                   $tableau_resultat = array() ;
  | 
        
        
            | 
            | 
           124 | 
                   $requete = "select psu_id_utilisateur, psu_id_statut from projet_statut_utilisateurs".
  | 
        
        
            | 
            | 
           125 | 
                               " where psu_id_utilisateur=".$this->_db->escapeSimple($id_utilisateur) ;
  | 
        
        
            | 
            | 
           126 | 
                   $resultat = $this->_db->query ($requete) ;
  | 
        
        
            | 
            | 
           127 | 
                   if (DB::isError($resultat)) {
  | 
        
        
            | 
            | 
           128 | 
                       die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
  | 
        
        
            | 
            | 
           129 | 
                   }
  | 
        
        
            | 
            | 
           130 | 
                   while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
  | 
        
        
            | 
            | 
           131 | 
                       array_push ($tableau_resultat, $ligne) ;
  | 
        
        
            | 
            | 
           132 | 
                   }
  | 
        
        
            | 
            | 
           133 | 
                   $resultat->free() ;
  | 
        
        
            | 
            | 
           134 | 
                   return $tableau_resultat ;
  | 
        
        
            | 
            | 
           135 | 
               } // end of member function getIdProjetsStatuts
  | 
        
        
            | 
            | 
           136 | 
              | 
        
        
            | 
            | 
           137 | 
              | 
        
        
            | 
            | 
           138 | 
               /**
  | 
        
        
            | 
            | 
           139 | 
                * Renvoie un tableau à 2 dimensions avec les informations sur l'inscription aux
  | 
        
        
            | 
            | 
           140 | 
                * différents projets d'un utilisateur. 0 => ['p_titre']         Le titre du projet
  | 
        
        
            | 
            | 
           141 | 
                *         ['ps_label']    Le statut de l'utilisateur 1 => .... (autant que de
  | 
        
        
            | 
            | 
           142 | 
                * projets)
  | 
        
        
            | 
            | 
           143 | 
                *
  | 
        
        
            | 
            | 
           144 | 
                * @param int id_utilisateur L'identifiant d'un utilisateur.
  | 
        
        
            | 
            | 
           145 | 
                * @return Array
  | 
        
        
            | 
            | 
           146 | 
                * @access public
  | 
        
        
            | 
            | 
           147 | 
                */
  | 
        
        
            | 
            | 
           148 | 
               function getInformationsUtilisateurs( $id_utilisateur )
  | 
        
        
            | 
            | 
           149 | 
               {
  | 
        
        
            | 
            | 
           150 | 
                   $tableau_resultat = array() ;
  | 
        
        
            | 
            | 
           151 | 
                   $requete = "select p_titre, ps_statut_nom, psu_id_statut, psu_id_projet from projet_statut_utilisateurs, projet, projet_statut".
  | 
        
        
            | 
            | 
           152 | 
                               " where psu_id_utilisateur=".$this->_db->escapeSimple($id_utilisateur).
  | 
        
        
            | 
            | 
           153 | 
                               " and psu_id_projet = p_id and psu_id_statut = ps_id_statut" ;
  | 
        
        
            | 
            | 
           154 | 
                   $resultat = $this->_db->query ($requete) ;
  | 
        
        
            | 
            | 
           155 | 
                   if (DB::isError($resultat)) {
  | 
        
        
            | 
            | 
           156 | 
                       die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
  | 
        
        
            | 
            | 
           157 | 
                   }
  | 
        
        
            | 
            | 
           158 | 
                   while ($ligne = $resultat->fetchRow()) {
  | 
        
        
            | 
            | 
           159 | 
                       array_push ($tableau_resultat, $ligne) ;
  | 
        
        
            | 
            | 
           160 | 
                   }
  | 
        
        
            | 
            | 
           161 | 
                   $resultat->free() ;
  | 
        
        
            | 
            | 
           162 | 
                   return $tableau_resultat ;
  | 
        
        
            | 
            | 
           163 | 
               } // end of member function getInformationsUtilisateurs
  | 
        
        
            | 
            | 
           164 | 
              | 
        
        
            | 
            | 
           165 | 
              | 
        
        
            | 
            | 
           166 | 
               /**
  | 
        
        
            | 
            | 
           167 | 
                * Renvoie le statut du projet passé en paramètre.
  | 
        
        
            | 
            | 
           168 | 
                *
  | 
        
        
            | 
            | 
           169 | 
                * @param int id_utilisateur
  | 
        
        
            | 
            | 
           170 | 
                * @param int id_projet
  | 
        
        
            | 
            | 
           171 | 
                * @param int dbObject
  | 
        
        
            | 
            | 
           172 | 
                * @return int
  | 
        
        
            | 
            | 
           173 | 
                * @static
  | 
        
        
            | 
            | 
           174 | 
                * @access public
  | 
        
        
            | 
            | 
           175 | 
                */
  | 
        
        
            | 
            | 
           176 | 
               function getStatutSurProjetCourant( $id_utilisateur,  $id_projet,  &$dbObject )
  | 
        
        
            | 
            | 
           177 | 
               {
  | 
        
        
            | 
            | 
           178 | 
              | 
        
        
            | 
            | 
           179 | 
                   if (participe::isAdministrateur($id_utilisateur, $dbObject)) return PROJET_DROIT_ADMINISTRATEUR;
  | 
        
        
            | 
            | 
           180 | 
                   $requete = 'select psu_id_statut from projet_statut_utilisateurs'.
  | 
        
        
            | 
            | 
           181 | 
                               ' where psu_id_utilisateur='.$this->_db->escapeSimple($id_utilisateur).' and psu_id_projet ='.$this->_db->escapeSimple($id_projet) ;
  | 
        
        
            | 
            | 
           182 | 
                   $resultat = $dbObject->query ($requete) ;
  | 
        
        
            | 
            | 
           183 | 
                   if (DB::isError ($resultat)) {
  | 
        
        
            | 
            | 
           184 | 
                       return DB::raiseError('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
  | 
        
        
            | 
            | 
           185 | 
                   }
  | 
        
        
            | 
            | 
           186 | 
                   $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
  | 
        
        
            | 
            | 
           187 | 
                   if (!$resultat->numRows()) {
  | 
        
        
            | 
            | 
           188 | 
                       return 4 ;      // Le statut ne participe pas
  | 
        
        
            | 
            | 
           189 | 
                   }
  | 
        
        
            | 
            | 
           190 | 
                   return $ligne->psu_id_statut ;
  | 
        
        
            | 
            | 
           191 | 
               } // end of member function getStatutSurProjetCourant
  | 
        
        
            | 
            | 
           192 | 
              | 
        
        
            | 
            | 
           193 | 
               /**
  | 
        
        
            | 
            | 
           194 | 
                * Réalise une requête dans projet_statut_utilisateurs et renvoie true si l'utilisateur
  | 
        
        
            | 
            | 
           195 | 
                * est administrateur de l'application projet.
  | 
        
        
            | 
            | 
           196 | 
                *
  | 
        
        
            | 
            | 
           197 | 
                * @param int id_utilisateur L'identifiant d'un utilisateur.
  | 
        
        
            | 
            | 
           198 | 
                * @param DB objetDB Un objet PEAR::DB
  | 
        
        
            | 
            | 
           199 | 
                * @return bool
  | 
        
        
            | 
            | 
           200 | 
                * @access public
  | 
        
        
            | 
            | 
           201 | 
                */
  | 
        
        
            | 
            | 
           202 | 
               function isAdministrateur( $id_utilisateur, $objetDB = "" )
  | 
        
        
            | 
            | 
           203 | 
               {
  | 
        
        
            | 
            | 
           204 | 
                   // La table projet_statut_utilisateurs possède une entré avec psu_id_projet = 0
  | 
        
        
            | 
            | 
           205 | 
                   // pour indiquer un administrateur
  | 
        
        
            | 
            | 
           206 | 
                   $requete = "select psu_id_statut from projet_statut_utilisateurs where psu_id_utilisateur=".$this->_db->escapeSimple($id_utilisateur)." ".
  | 
        
        
            | 
            | 
           207 | 
                               " and psu_id_projet=0" ;
  | 
        
        
            | 
            | 
           208 | 
              | 
        
        
            | 
            | 
           209 | 
                   if (is_object ($objetDB)) {
  | 
        
        
            | 
            | 
           210 | 
                       $resultat = $objetDB->query ($requete) ;
  | 
        
        
            | 
            | 
           211 | 
                   } else {
  | 
        
        
            | 
            | 
           212 | 
                       $resultat = $this->_db->query ($requete) ;
  | 
        
        
            | 
            | 
           213 | 
                   }
  | 
        
        
            | 
            | 
           214 | 
                   if ($resultat->numRows () != 0) {
  | 
        
        
            | 
            | 
           215 | 
                       return true;
  | 
        
        
            | 
            | 
           216 | 
                   }
  | 
        
        
            | 
            | 
           217 | 
                   return false ;
  | 
        
        
            | 
            | 
           218 | 
               } // end of member function isAdministrateur
  | 
        
        
            | 
            | 
           219 | 
              | 
        
        
            | 
            | 
           220 | 
               /**
  | 
        
        
            | 
            | 
           221 | 
                * Met à jour le statut d'un utilisateur sur un projet
  | 
        
        
            | 
            | 
           222 | 
                *
  | 
        
        
            | 
            | 
           223 | 
                * @param int id_statut L'identifiant du statut à ajouter ou mettre à jour
  | 
        
        
            | 
            | 
           224 | 
                * @param int id_utilisateur Identifiant de l'utilisateur
  | 
        
        
            | 
            | 
           225 | 
                * @param int id_projet Identifiant du projet
  | 
        
        
            | 
            | 
           226 | 
                * @return bool
  | 
        
        
            | 
            | 
           227 | 
                * @access public
  | 
        
        
            | 
            | 
           228 | 
                */
  | 
        
        
            | 
            | 
           229 | 
               function setStatut( $id_statut,  $id_utilisateur,  $id_projet )
  | 
        
        
            | 
            | 
           230 | 
               {
  | 
        
        
            | 
            | 
           231 | 
                   $requete = 'update projet_statut_utilisateurs set psu_id_statut='.$this->_db->escapeSimple($id_statut).
  | 
        
        
            | 
            | 
           232 | 
                               ' where psu_id_utilisateur='.$id_utilisateur.' and psu_id_projet='.$this->_db->escapeSimple($id_projet);
  | 
        
        
            | 
            | 
           233 | 
              | 
        
        
            | 
            | 
           234 | 
                   if (participe::getStatutSurProjetCourant($id_utilisateur, $id_projet, $this->_db) == 4) {
  | 
        
        
            | 
            | 
           235 | 
                       $requete = 'insert into projet_statut_utilisateurs set psu_id_statut='.$this->_db->escapeSimple($id_statut).
  | 
        
        
            | 
            | 
           236 | 
                               ', psu_id_utilisateur='.$this->_db->escapeSimple($id_utilisateur).',psu_id_projet='.$this->_db->escapeSimple($id_projet).
  | 
        
        
            | 
            | 
           237 | 
                               ', psu_date_inscription=NOW()';
  | 
        
        
            | 
            | 
           238 | 
                   }
  | 
        
        
            | 
            | 
           239 | 
                   if ($id_statut == 4) {  // Si le statut est ne participe pas, on supprime l'inscrit
  | 
        
        
            | 
            | 
           240 | 
                       $requete = 'delete from projet_statut_utilisateurs where psu_id_utilisateur='.$this->_db->escapeSimple($id_utilisateur).' and psu_id_projet='.$this->_db->escapeSimple($id_projet) ;
  | 
        
        
            | 
            | 
           241 | 
                   }
  | 
        
        
            | 
            | 
           242 | 
                   $resultat = $this->_db->query ($requete) ;
  | 
        
        
            | 
            | 
           243 | 
                   if (DB::isError ($resultat)) {
  | 
        
        
            | 
            | 
           244 | 
                       die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
  | 
        
        
            | 
            | 
           245 | 
                   }
  | 
        
        
            | 
            | 
           246 | 
                   return true ;
  | 
        
        
            | 
            | 
           247 | 
               } // end of member function setStatut
  | 
        
        
            | 
            | 
           248 | 
              | 
        
        
            | 
            | 
           249 | 
               /**
  | 
        
        
            | 
            | 
           250 | 
                * Renvoie vrai si l'utilisateur est coordinateur, faux dans les autres cas
  | 
        
        
            | 
            | 
           251 | 
                *
  | 
        
        
            | 
            | 
           252 | 
                * @param int id_utilisateur L'identifiant d'un utilisateur
  | 
        
        
            | 
            | 
           253 | 
                * @param DB objetDB Optionnel, nécessaire si on appelle cette méthode statiquement
  | 
        
        
            | 
            | 
           254 | 
                * @return bool
  | 
        
        
            | 
            | 
           255 | 
                * @static
  | 
        
        
            | 
            | 
           256 | 
                * @access public
  | 
        
        
            | 
            | 
           257 | 
                */
  | 
        
        
            | 
            | 
           258 | 
               function isCoordinateur( $id_utilisateur, $id_projet, &$objetDB )
  | 
        
        
            | 
            | 
           259 | 
               {
  | 
        
        
            | 
            | 
           260 | 
                   if (!is_object($objetDB)) $objetDB = $this->_db;
  | 
        
        
            | 
            | 
           261 | 
                   $statut = $this->getStatutSurProjetCourant($id_utilisateur,  $id_projet, $objetDB) ;
  | 
        
        
            | 
            | 
           262 | 
                   if ($statut == 1) {
  | 
        
        
            | 
            | 
           263 | 
                       return true;
  | 
        
        
            | 
            | 
           264 | 
                   }
  | 
        
        
            | 
            | 
           265 | 
                   return false ;
  | 
        
        
            | 
            | 
           266 | 
               } // end of member function isCoordinateur
  | 
        
        
            | 
            | 
           267 | 
              | 
        
        
            | 
            | 
           268 | 
               /**
  | 
        
        
            | 
            | 
           269 | 
                * Renvoie la liste des projets auquels l'utilisateur passé en paramètre ne
  | 
        
        
            | 
            | 
           270 | 
                * participe pas.
  | 
        
        
            | 
            | 
           271 | 
                *
  | 
        
        
            | 
            | 
           272 | 
                * @param int id_utilisateur L'identifiant de l'utilisateur.
  | 
        
        
            | 
            | 
           273 | 
                * @return Array
  | 
        
        
            | 
            | 
           274 | 
                * @access public
  | 
        
        
            | 
            | 
           275 | 
                */
  | 
        
        
            | 
            | 
           276 | 
               function getProjetsNonParticipant( $id_utilisateur )
  | 
        
        
            | 
            | 
           277 | 
               {
  | 
        
        
            | 
            | 
           278 | 
                   $tableau_resultat = array() ;
  | 
        
        
            | 
            | 
           279 | 
                   $requete = 'select p_id from projet'.
  | 
        
        
            | 
            | 
           280 | 
                               ' where p_id not in (select psu_id_projet from projet_statut_utilisateurs where psu_id_utilisateur='.$this->_db->escapeSimple($id_utilisateur).')' ;
  | 
        
        
            | 
            | 
           281 | 
                   $resultat = $this->_db->query ($requete) ;
  | 
        
        
            | 
            | 
           282 | 
                   if (DB::isError($resultat)) {
  | 
        
        
            | 
            | 
           283 | 
                       die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
  | 
        
        
            | 
            | 
           284 | 
                   }
  | 
        
        
            | 
            | 
           285 | 
                   while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
  | 
        
        
            | 
            | 
           286 | 
                       array_push ($tableau_resultat, new projet ($this->_db, $ligne->p_id)) ;
  | 
        
        
            | 
            | 
           287 | 
                   }
  | 
        
        
            | 
            | 
           288 | 
                   $resultat->free() ;
  | 
        
        
            | 
            | 
           289 | 
                   return $tableau_resultat ;
  | 
        
        
            | 
            | 
           290 | 
               } // end of member function getProjetsNonParticipant
  | 
        
        
            | 
            | 
           291 | 
              | 
        
        
            | 
            | 
           292 | 
               /**
  | 
        
        
            | 
            | 
           293 | 
                * Renvoie true si l'utilisateur passé en paramètre est observateur du projet passé
  | 
        
        
            | 
            | 
           294 | 
                * en paramètre.
  | 
        
        
            | 
            | 
           295 | 
                *
  | 
        
        
            | 
            | 
           296 | 
                * @param int id_utilisateur L'identifiant de l'utilisateur
  | 
        
        
            | 
            | 
           297 | 
                * @param int id_projet L'identifiant du projet
  | 
        
        
            | 
            | 
           298 | 
                * @return bool
  | 
        
        
            | 
            | 
           299 | 
                * @access public
  | 
        
        
            | 
            | 
           300 | 
                */
  | 
        
        
            | 
            | 
           301 | 
               function isObservateur( $id_utilisateur,  $id_projet, &$objetDB )
  | 
        
        
            | 
            | 
           302 | 
               {
  | 
        
        
            | 
            | 
           303 | 
                   if (!is_object($objetDB)) $objetDB = $this->_db;
  | 
        
        
            | 
            | 
           304 | 
                   if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 3) {
  | 
        
        
            | 
            | 
           305 | 
                       return true;
  | 
        
        
            | 
            | 
           306 | 
                   }
  | 
        
        
            | 
            | 
           307 | 
                   return false ;
  | 
        
        
            | 
            | 
           308 | 
               } // end of member function isObservateur
  | 
        
        
            | 
            | 
           309 | 
              | 
        
        
            | 
            | 
           310 | 
               /**
  | 
        
        
            | 
            | 
           311 | 
                * Renvoie true si l'utilisateur passé en paramètre est contributeur du projet passé
  | 
        
        
            | 
            | 
           312 | 
                * en paramètre.
  | 
        
        
            | 
            | 
           313 | 
                *
  | 
        
        
            | 
            | 
           314 | 
                * @param int id_utilisateur L'identifiant de l'utilisateur
  | 
        
        
            | 
            | 
           315 | 
                * @param int id_projet L'identifiant du projet
  | 
        
        
            | 
            | 
           316 | 
                * @return bool
  | 
        
        
            | 
            | 
           317 | 
                * @access public
  | 
        
        
            | 
            | 
           318 | 
                */
  | 
        
        
            | 
            | 
           319 | 
               function isContributeur( $id_utilisateur,  $id_projet, &$objetDB )
  | 
        
        
            | 
            | 
           320 | 
               {
  | 
        
        
            | 
            | 
           321 | 
                   if (!is_object($objetDB)) $objetDB = $this->_db;
  | 
        
        
            | 
            | 
           322 | 
                   if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 4) return false;
  | 
        
        
            | 
            | 
           323 | 
                   if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 2) {
  | 
        
        
            | 
            | 
           324 | 
                       return true;
  | 
        
        
            | 
            | 
           325 | 
                   }
  | 
        
        
            | 
            | 
           326 | 
                   return false ;
  | 
        
        
            | 
            | 
           327 | 
               } // end of member function isObservateur
  | 
        
        
            | 
            | 
           328 | 
              | 
        
        
            | 
            | 
           329 | 
               /**
  | 
        
        
            | 
            | 
           330 | 
                * Renvoie true si l'utilisateur passé en paramètre est contributeur du projet passé
  | 
        
        
            | 
            | 
           331 | 
                * en paramètre.
  | 
        
        
            | 
            | 
           332 | 
                *
  | 
        
        
            | 
            | 
           333 | 
                * @param int id_utilisateur L'identifiant de l'utilisateur
  | 
        
        
            | 
            | 
           334 | 
                * @param int id_projet L'identifiant du projet
  | 
        
        
            | 
            | 
           335 | 
                * @return bool
  | 
        
        
            | 
            | 
           336 | 
                * @access public
  | 
        
        
            | 
            | 
           337 | 
                */
  | 
        
        
            | 
            | 
           338 | 
               function isEnAttente( $id_utilisateur,  $id_projet, &$objetDB )
  | 
        
        
            | 
            | 
           339 | 
               {
  | 
        
        
            | 
            | 
           340 | 
                   if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 3) {
  | 
        
        
            | 
            | 
           341 | 
                       return true;
  | 
        
        
            | 
            | 
           342 | 
                   }
  | 
        
        
            | 
            | 
           343 | 
                   return false ;
  | 
        
        
            | 
            | 
           344 | 
               } // end of member function isObservateur
  | 
        
        
            | 
            | 
           345 | 
              | 
        
        
            | 
            | 
           346 | 
           	/**
  | 
        
        
            | 
            | 
           347 | 
                * Renvoie les infos sur les coordinateurs d'un projet
  | 
        
        
            | 
            | 
           348 | 
                *
  | 
        
        
            | 
            | 
           349 | 
                * @param int id_projet L'identifiant du projet
  | 
        
        
            | 
            | 
           350 | 
                * @return array	Un tableau contenant les infos concernants les coordinateurs du projet
  | 
        
        
            | 
            | 
           351 | 
                * @access public
  | 
        
        
            | 
            | 
           352 | 
                */
  | 
        
        
            | 
            | 
           353 | 
               function getCoordinateurs($id_projet)
  | 
        
        
            | 
            | 
           354 | 
               {
  | 
        
        
            | 
            | 
           355 | 
                   $tableau_resultat = array() ;
  | 
        
        
            | 
            | 
           356 | 
              | 
        
        
            | 
            | 
           357 | 
                   $requete = 'select psu_id_utilisateur,'.PROJET_CHAMPS_NOM.','.PROJET_CHAMPS_PRENOM.',' ;
  | 
        
        
            | 
            | 
           358 | 
                   $requete .= PROJET_CHAMPS_MAIL.', ' ;
  | 
        
        
            | 
            | 
           359 | 
                   $requete .= 'psu_date_inscription,  ps_id_statut '.
  | 
        
        
            | 
            | 
           360 | 
                               ' from projet_statut_utilisateurs, projet_statut,'.PROJET_ANNUAIRE.
  | 
        
        
            | 
            | 
           361 | 
                               ' where psu_id_projet='.$this->_db->escapeSimple($id_projet).' and psu_id_utilisateur='.PROJET_CHAMPS_ID.
  | 
        
        
            | 
            | 
           362 | 
                               ' and psu_id_statut=ps_id_statut and psu_id_statut=1 order by ps_id_statut,'.PROJET_CHAMPS_NOM;
  | 
        
        
            | 
            | 
           363 | 
                   $resultat = $this->_db->query ($requete) ;
  | 
        
        
            | 
            | 
           364 | 
                   if (DB::isError($resultat)) {
  | 
        
        
            | 
            | 
           365 | 
                       return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
  | 
        
        
            | 
            | 
           366 | 
                   }
  | 
        
        
            | 
            | 
           367 | 
                   while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ORDERED)) {
  | 
        
        
            | 
            | 
           368 | 
                       array_push ($tableau_resultat, $ligne) ;
  | 
        
        
            | 
            | 
           369 | 
                   }
  | 
        
        
            | 
            | 
           370 | 
                   $resultat->free() ;
  | 
        
        
            | 
            | 
           371 | 
                   return $tableau_resultat ;
  | 
        
        
            | 
            | 
           372 | 
               } // end of member function getCoordinateurs
  | 
        
        
            | 
            | 
           373 | 
              | 
        
        
            | 
            | 
           374 | 
               function getAdministrateurs () {
  | 
        
        
            | 
            | 
           375 | 
              | 
        
        
            | 
            | 
           376 | 
               	$tableau_resultat = array() ;
  | 
        
        
            | 
            | 
           377 | 
              | 
        
        
            | 
            | 
           378 | 
               	$requete = 'select psu_id_utilisateur,'.PROJET_CHAMPS_NOM.','.PROJET_CHAMPS_PRENOM.',' ;
  | 
        
        
            | 
            | 
           379 | 
                   $requete .= PROJET_CHAMPS_MAIL.', ' ;
  | 
        
        
            | 
            | 
           380 | 
                   $requete .= 'psu_date_inscription,  ps_id_statut '.
  | 
        
        
            | 
            | 
           381 | 
                               ' from projet_statut_utilisateurs, projet_statut,'.PROJET_ANNUAIRE.
  | 
        
        
            | 
            | 
           382 | 
                               ' where psu_id_utilisateur='.PROJET_CHAMPS_ID.
  | 
        
        
            | 
            | 
           383 | 
                               ' and psu_id_statut=ps_id_statut and psu_id_statut=0 order by ps_id_statut,'.PROJET_CHAMPS_NOM;
  | 
        
        
            | 
            | 
           384 | 
                   $resultat = $this->_db->query ($requete) ;
  | 
        
        
            | 
            | 
           385 | 
                   if (DB::isError($resultat)) {
  | 
        
        
            | 
            | 
           386 | 
                       die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
  | 
        
        
            | 
            | 
           387 | 
                   }
  | 
        
        
            | 
            | 
           388 | 
                   while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ORDERED)) {
  | 
        
        
            | 
            | 
           389 | 
                       array_push ($tableau_resultat, $ligne) ;
  | 
        
        
            | 
            | 
           390 | 
                   }
  | 
        
        
            | 
            | 
           391 | 
                   $resultat->free() ;
  | 
        
        
            | 
            | 
           392 | 
                   return $tableau_resultat ;
  | 
        
        
            | 
            | 
           393 | 
               }
  | 
        
        
            | 
            | 
           394 | 
               /**
  | 
        
        
            | 
            | 
           395 | 
                * Renvoie la constante de statut d un utilisateur
  | 
        
        
            | 
            | 
           396 | 
                *
  | 
        
        
            | 
            | 
           397 | 
                * define ('PROJET_DROIT_ADMINISTRATEUR', 1) ;
  | 
        
        
            | 
            | 
           398 | 
           	 * define ('PROJET_DROIT_COORDINATEUR', 2) ;
  | 
        
        
            | 
            | 
           399 | 
           	 * define ('PROJET_DROIT_PROPRIETAIRE', 4) ;
  | 
        
        
            | 
            | 
           400 | 
           	 * define ('PROJET_DROIT_CONTRIBUTEUR', 8) ;
  | 
        
        
            | 
            | 
           401 | 
           	 * define ('PROJET_DROIT_AUCUN', 16) ;
  | 
        
        
            | 
            | 
           402 | 
           	 * define ('PROJET_DROIT_EN_ATTENTE', 32);
  | 
        
        
            | 
            | 
           403 | 
           	 *
  | 
        
        
            | 
            | 
           404 | 
           	 * @access	public
  | 
        
        
            | 
            | 
           405 | 
           	 * @return int	La constante de statut
  | 
        
        
            | 
            | 
           406 | 
                */
  | 
        
        
            | 
            | 
           407 | 
              | 
        
        
            | 
            | 
           408 | 
                function getStatut($id_utilisateur, $id_projet)
  | 
        
        
            | 
            | 
           409 | 
                {
  | 
        
        
            | 
            | 
           410 | 
                	$statut = $this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $this->_db);
  | 
        
        
            | 
            | 
           411 | 
                	switch ($statut)
  | 
        
        
            | 
            | 
           412 | 
                	{
  | 
        
        
            | 
            | 
           413 | 
                		case 0 : return PROJET_DROIT_ADMINISTRATEUR;
  | 
        
        
            | 
            | 
           414 | 
                		break;
  | 
        
        
            | 
            | 
           415 | 
                		case 1 : return PROJET_DROIT_COORDINATEUR;
  | 
        
        
            | 
            | 
           416 | 
                		break;
  | 
        
        
            | 
            | 
           417 | 
                		case 2 : return PROJET_DROIT_CONTRIBUTEUR;
  | 
        
        
            | 
            | 
           418 | 
                		break;
  | 
        
        
            | 
            | 
           419 | 
                		case 3 : return PROJET_DROIT_EN_ATTENTE;
  | 
        
        
            | 
            | 
           420 | 
                		break;
  | 
        
        
            | 
            | 
           421 | 
                		default : return PROJET_DROIT_AUCUN;
  | 
        
        
            | 
            | 
           422 | 
                	}
  | 
        
        
            | 
            | 
           423 | 
                }
  | 
        
        
            | 
            | 
           424 | 
           } // end of participe
  | 
        
        
            | 
            | 
           425 | 
           ?>
  |