| 2 | ddelon | 1 | <?php
 | 
        
           | 59 | ddelon | 2 | /*vim: set expandtab tabstop=4 shiftwidth=4: */
 | 
        
           | 2 | ddelon | 3 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 4 | // | PHP version 4.1                                                                                      |
 | 
        
           |  |  | 5 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 6 | // | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
 | 
        
           |  |  | 7 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 8 | // | This library is free software; you can redistribute it and/or                                        |
 | 
        
           |  |  | 9 | // | modify it under the terms of the GNU General Public                                                  |
 | 
        
           |  |  | 10 | // | License as published by the Free Software Foundation; either                                         |
 | 
        
           |  |  | 11 | // | version 2.1 of the License, or (at your option) any later version.                                   |
 | 
        
           |  |  | 12 | // |                                                                                                      |
 | 
        
           |  |  | 13 | // | This library is distributed in the hope that it will be useful,                                      |
 | 
        
           |  |  | 14 | // | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
 | 
        
           |  |  | 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
 | 
        
           |  |  | 16 | // | General Public License for more details.                                                             |
 | 
        
           |  |  | 17 | // |                                                                                                      |
 | 
        
           |  |  | 18 | // | You should have received a copy of the GNU General Public                                            |
 | 
        
           |  |  | 19 | // | License along with this library; if not, write to the Free Software                                  |
 | 
        
           |  |  | 20 | // | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
 | 
        
           |  |  | 21 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           | 298 | alexandre_ | 22 | // CVS : $Id: projet.class.php,v 1.13 2008-08-25 15:09:25 alexandre_tb Exp $
 | 
        
           | 2 | ddelon | 23 | /**
 | 
        
           |  |  | 24 | * Application projet
 | 
        
           |  |  | 25 | *
 | 
        
           |  |  | 26 | * La classe projet
 | 
        
           |  |  | 27 | *
 | 
        
           |  |  | 28 | *@package projet
 | 
        
           |  |  | 29 | //Auteur original :
 | 
        
           |  |  | 30 | *@author        Alexandre Granier <alexandre@tela-botanica.org>
 | 
        
           |  |  | 31 | //Autres auteurs :
 | 
        
           |  |  | 32 | *@author        Aucun
 | 
        
           |  |  | 33 | *@copyright     Tela-Botanica 2000-2004
 | 
        
           | 298 | alexandre_ | 34 | *@version       $Revision: 1.13 $
 | 
        
           | 2 | ddelon | 35 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 36 | */
 | 
        
           |  |  | 37 |   | 
        
           |  |  | 38 |   | 
        
           |  |  | 39 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 40 | // |                                            ENTETE du PROGRAMME                                       |
 | 
        
           |  |  | 41 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 42 |   | 
        
           |  |  | 43 | include_once PROJET_CHEMIN_CLASSES.'document.class.php' ;
 | 
        
           |  |  | 44 | include_once PROJET_CHEMIN_CLASSES.'liste_discussion.class.php' ;
 | 
        
           | 59 | ddelon | 45 | /* Permet la récupération d'un nouvel identifiant d'une table.*/
 | 
        
           |  |  | 46 | require_once PROJET_CHEMIN_BIBLIOTHEQUE_API.'sql/SQL_manipulation.fonct.php';
 | 
        
           | 2 | ddelon | 47 | include_once 'Mail.php' ;
 | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 50 | // |                                            ENTETE du PROGRAMME                                       |
 | 
        
           |  |  | 51 | // +------------------------------------------------------------------------------------------------------+
 | 
        
           |  |  | 52 |   | 
        
           |  |  | 53 |   | 
        
           |  |  | 54 |   | 
        
           |  |  | 55 |   | 
        
           |  |  | 56 | /**
 | 
        
           |  |  | 57 |  * class projet
 | 
        
           | 59 | ddelon | 58 |  *
 | 
        
           | 2 | ddelon | 59 |  */
 | 
        
           |  |  | 60 | class projet
 | 
        
           |  |  | 61 | {
 | 
        
           |  |  | 62 |   | 
        
           |  |  | 63 |     /** Aggregations: */
 | 
        
           |  |  | 64 |   | 
        
           |  |  | 65 |     /**
 | 
        
           |  |  | 66 |      * Le tableau d'objet document associés au projet
 | 
        
           |  |  | 67 |      *
 | 
        
           |  |  | 68 |      */
 | 
        
           |  |  | 69 |     var $_documents_associes = array();
 | 
        
           |  |  | 70 |   | 
        
           |  |  | 71 |     var $_listes_associes = array();
 | 
        
           |  |  | 72 |   | 
        
           |  |  | 73 |     /** Compositions: */
 | 
        
           |  |  | 74 |   | 
        
           |  |  | 75 |     /*** Attributes: ***/
 | 
        
           | 59 | ddelon | 76 |   | 
        
           | 2 | ddelon | 77 |     /**
 | 
        
           |  |  | 78 |      * L'identifiant du projet.
 | 
        
           |  |  | 79 |      * @access private
 | 
        
           |  |  | 80 |      */
 | 
        
           |  |  | 81 |     var $_id_projet;
 | 
        
           |  |  | 82 |   | 
        
           |  |  | 83 |     /**
 | 
        
           |  |  | 84 |      * Le titre du projet, tel que dans la base de donnée.
 | 
        
           |  |  | 85 |      * @access private
 | 
        
           |  |  | 86 |      */
 | 
        
           |  |  | 87 |     var $_titre;
 | 
        
           |  |  | 88 |     /**
 | 
        
           |  |  | 89 |      * La description du projet, tel que dans la base.
 | 
        
           |  |  | 90 |      * @access private
 | 
        
           |  |  | 91 |      */
 | 
        
           |  |  | 92 |     var $_description;
 | 
        
           |  |  | 93 |     /**
 | 
        
           |  |  | 94 |      * L'URL d'un site sur le projet. Facultatif.
 | 
        
           |  |  | 95 |      * @access private
 | 
        
           |  |  | 96 |      */
 | 
        
           |  |  | 97 |     var $_espace_internet;
 | 
        
           |  |  | 98 |     /**
 | 
        
           |  |  | 99 |      * Le nom du wikini associé au projet, avec la syntaxe wikini. Vide par défaut.
 | 
        
           |  |  | 100 |      * @access private
 | 
        
           |  |  | 101 |      */
 | 
        
           |  |  | 102 |     var $_nom_wikini;
 | 
        
           |  |  | 103 |     /**
 | 
        
           |  |  | 104 |      * Date de création du projet. A priori ne varie pas dans le temps.
 | 
        
           |  |  | 105 |      * @access private
 | 
        
           |  |  | 106 |      */
 | 
        
           |  |  | 107 |     var $_date_creation;
 | 
        
           |  |  | 108 |     /**
 | 
        
           |  |  | 109 |      * Le chemin relatif vers le répertoire contenant les wikinis.
 | 
        
           |  |  | 110 |      * @access private
 | 
        
           |  |  | 111 |      */
 | 
        
           |  |  | 112 |     var $_chemin_wikini;
 | 
        
           |  |  | 113 |     /**
 | 
        
           |  |  | 114 |      * Une connexion vers la base de donnée.
 | 
        
           |  |  | 115 |      * @access private
 | 
        
           |  |  | 116 |      */
 | 
        
           |  |  | 117 |     var $_db;
 | 
        
           |  |  | 118 |   | 
        
           |  |  | 119 |     /**
 | 
        
           |  |  | 120 |      * Contient le nom du répertoire du projet tel que sur le disque.
 | 
        
           |  |  | 121 |      * @access private
 | 
        
           |  |  | 122 |      */
 | 
        
           |  |  | 123 |     var $_nom_repertoire;
 | 
        
           |  |  | 124 |   | 
        
           |  |  | 125 |     /**
 | 
        
           |  |  | 126 |      * Le chemin jusqu'au répertoire où seront stockés les fichiers.
 | 
        
           |  |  | 127 |      * @access private
 | 
        
           |  |  | 128 |      */
 | 
        
           |  |  | 129 |     var $_chemin_repertoire;
 | 
        
           |  |  | 130 |   | 
        
           |  |  | 131 |     /**
 | 
        
           |  |  | 132 |      * Vaut vrai si le projet est un projet racine et s'il est le seul.
 | 
        
           |  |  | 133 |      * @access private
 | 
        
           |  |  | 134 |      */
 | 
        
           |  |  | 135 |     var $_est_racine;
 | 
        
           |  |  | 136 |     /**
 | 
        
           |  |  | 137 |      * Le résumé du projet
 | 
        
           |  |  | 138 |      * @access private
 | 
        
           |  |  | 139 |      */
 | 
        
           |  |  | 140 |     var $_resume;
 | 
        
           | 11 | alexandre_ | 141 |     /**
 | 
        
           |  |  | 142 |      * Contient le numéro du type du projet
 | 
        
           |  |  | 143 |      * @access private
 | 
        
           |  |  | 144 |      */
 | 
        
           |  |  | 145 |     var $_type;
 | 
        
           | 2 | ddelon | 146 |   | 
        
           | 121 | alexandre_ | 147 | 	/**
 | 
        
           | 208 | neiluj | 148 |      * Indique si l'inscription au projet est moderes
 | 
        
           | 121 | alexandre_ | 149 |      * @access private
 | 
        
           |  |  | 150 |      */
 | 
        
           |  |  | 151 |     var $_isModere;
 | 
        
           | 208 | neiluj | 152 |   | 
        
           |  |  | 153 | 	/**
 | 
        
           |  |  | 154 |      * Indique si le projet a des documents
 | 
        
           |  |  | 155 |      * @access private
 | 
        
           |  |  | 156 |      */
 | 
        
           |  |  | 157 |     var $_avoirDocument;
 | 
        
           | 288 | alexandre_ | 158 |   | 
        
           | 2 | ddelon | 159 |     /**
 | 
        
           | 288 | alexandre_ | 160 |      * tableau contenant les themes associes au projet
 | 
        
           |  |  | 161 |      */
 | 
        
           |  |  | 162 |     var $_themes = array();
 | 
        
           |  |  | 163 |     /**
 | 
        
           | 59 | ddelon | 164 |      *
 | 
        
           |  |  | 165 |      * PHP5
 | 
        
           | 2 | ddelon | 166 |      * @return projet
 | 
        
           |  |  | 167 |      * @access public
 | 
        
           |  |  | 168 |      */
 | 
        
           | 15 | ddelon | 169 |     function __construct( &$dbObject,  $id_projet = "")
 | 
        
           | 2 | ddelon | 170 |     {
 | 
        
           | 15 | ddelon | 171 |       $this->projet($dbObject,  $id_projet);
 | 
        
           | 59 | ddelon | 172 |   | 
        
           | 2 | ddelon | 173 |     } // end of member function __construct
 | 
        
           |  |  | 174 |   | 
        
           |  |  | 175 |     /**
 | 
        
           |  |  | 176 |      *
 | 
        
           | 59 | ddelon | 177 |      *
 | 
        
           | 2 | ddelon | 178 |      * @param DB dbObject Un objet PEAR:DB
 | 
        
           |  |  | 179 |      * @param int id_projet On passe un identifiant de projet au constructeur. Cela lui permet de faire une
 | 
        
           | 288 | alexandre_ | 180 |      * premiere requete pour les infos de bases comme le titre, le description etc.
 | 
        
           | 2 | ddelon | 181 |      * @return projet
 | 
        
           |  |  | 182 |      * @access public
 | 
        
           |  |  | 183 |      */
 | 
        
           |  |  | 184 |     function projet( &$dbObject,  $id_projet = "")
 | 
        
           |  |  | 185 |     {
 | 
        
           |  |  | 186 |         $this->_db = $dbObject ;
 | 
        
           |  |  | 187 |         if ($id_projet != "") {
 | 
        
           |  |  | 188 |             $requete = "select * from projet where p_id=$id_projet" ;
 | 
        
           |  |  | 189 |             $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 190 |             if (DB::isError($resultat)) {
 | 
        
           |  |  | 191 |                 die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
 | 
        
           |  |  | 192 |             }
 | 
        
           |  |  | 193 |             $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
 | 
        
           | 59 | ddelon | 194 |   | 
        
           | 288 | alexandre_ | 195 |             // Affectations dans les proprietes
 | 
        
           | 2 | ddelon | 196 |             $this->_id_projet = $ligne->p_id ;
 | 
        
           |  |  | 197 |             $this->_titre = $ligne->p_titre ;
 | 
        
           |  |  | 198 |             $this->_description = $ligne->p_description ;
 | 
        
           |  |  | 199 |             $this->_espace_internet = $ligne->p_espace_internet ;
 | 
        
           |  |  | 200 |             $this->_date_creation = $ligne->p_date_creation ;
 | 
        
           |  |  | 201 |             $this->_nom_wikini = $ligne->p_wikini ;
 | 
        
           |  |  | 202 |             $this->_resume = $ligne->p_resume;
 | 
        
           | 11 | alexandre_ | 203 |             $this->_type = $ligne->p_type ;
 | 
        
           | 288 | alexandre_ | 204 |             // On recupere le nom du repertoire
 | 
        
           | 2 | ddelon | 205 |             $this->_nom_repertoire = $ligne->p_nom_repertoire ;
 | 
        
           | 121 | alexandre_ | 206 |             $this->_isModere = $ligne->p_modere;
 | 
        
           | 208 | neiluj | 207 | 			$this->_avoirDocument = $ligne->p_avoir_document;
 | 
        
           | 288 | alexandre_ | 208 |             // on regarde si on a a faire au projet racine
 | 
        
           | 35 | alexandre_ | 209 |             if (PROJET_UTILISE_HIERARCHIE) {
 | 
        
           |  |  | 210 | 	            $requete = 'select  ph_id_projet_pere, ph_id_projet_fils from projet_hierarchie where ph_id_projet_fils='.$this->_id_projet ;
 | 
        
           |  |  | 211 | 	            $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 212 | 	            if (DB::isError ($resultat)) {
 | 
        
           | 288 | alexandre_ | 213 | 	                return ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
 | 
        
           | 35 | alexandre_ | 214 | 	            }
 | 
        
           |  |  | 215 | 	            if (!$resultat->numRows()) {
 | 
        
           |  |  | 216 | 	                $this->_est_racine = true ;
 | 
        
           |  |  | 217 | 	            } else {
 | 
        
           |  |  | 218 | 	                $this->_est_racine = false ;
 | 
        
           |  |  | 219 | 	            }
 | 
        
           | 2 | ddelon | 220 |             }
 | 
        
           | 288 | alexandre_ | 221 |   | 
        
           |  |  | 222 |             /** Recuperation des themes */
 | 
        
           |  |  | 223 |             $requete_theme = 'select pat_id_theme, pt_label_theme from projet_avoir_theme, projet_theme'.
 | 
        
           |  |  | 224 |             			 ' where pat_id_projet='.$this->_id_projet.' and pat_id_theme=pt_id_theme';
 | 
        
           |  |  | 225 |             $resultat_theme = $GLOBALS['projet_db']->query ($requete_theme);
 | 
        
           |  |  | 226 |             if (DB::isError($resultat_theme)) {
 | 
        
           |  |  | 227 |             	return ("Echec de la requete : $requete_theme<br />".$resultat_theme->getMessage()) ;
 | 
        
           |  |  | 228 |             }
 | 
        
           |  |  | 229 |             if ($resultat_theme->numRows() != 0) {
 | 
        
           |  |  | 230 |   | 
        
           |  |  | 231 |             	while ($ligne_theme = $resultat_theme->fetchRow(DB_FETCHMODE_OBJECT)) {
 | 
        
           |  |  | 232 |             		$this->_themes[$ligne_theme->pat_id_theme] = $ligne_theme->pt_label_theme;
 | 
        
           |  |  | 233 |             	}
 | 
        
           |  |  | 234 |   | 
        
           |  |  | 235 |             }
 | 
        
           | 2 | ddelon | 236 |         }
 | 
        
           |  |  | 237 |     } // end of member function projet
 | 
        
           |  |  | 238 |   | 
        
           |  |  | 239 |     /**
 | 
        
           |  |  | 240 |      *
 | 
        
           | 59 | ddelon | 241 |      *
 | 
        
           | 2 | ddelon | 242 |      * @param DB dbObject Un objet PEAR:DB
 | 
        
           |  |  | 243 |      * @param int id_projet On passe un identifiant de projet au constructeur.
 | 
        
           | 59 | ddelon | 244 |      * @return bool
 | 
        
           | 2 | ddelon | 245 |      * @access public
 | 
        
           |  |  | 246 |      */
 | 
        
           |  |  | 247 |     function projetExiste( &$dbObject,  $id_projet)
 | 
        
           |  |  | 248 |     {
 | 
        
           |  |  | 249 |         if ($id_projet != "") {
 | 
        
           |  |  | 250 |             $requete = "select * from projet where p_id=$id_projet" ;
 | 
        
           |  |  | 251 |             $resultat = $dbObject->query ($requete) ;
 | 
        
           |  |  | 252 |             if (DB::isError($resultat)) {
 | 
        
           |  |  | 253 |                 die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
 | 
        
           |  |  | 254 |             }
 | 
        
           |  |  | 255 |             if ($resultat->numRows() != 0) {
 | 
        
           |  |  | 256 |                 return true ;
 | 
        
           |  |  | 257 |             }
 | 
        
           |  |  | 258 |         }
 | 
        
           |  |  | 259 |     } // end of member function projet
 | 
        
           | 59 | ddelon | 260 |   | 
        
           | 2 | ddelon | 261 |     /**
 | 
        
           |  |  | 262 |      *
 | 
        
           | 59 | ddelon | 263 |      *
 | 
        
           |  |  | 264 |      * @param int id_projet
 | 
        
           | 2 | ddelon | 265 |      * @return string
 | 
        
           |  |  | 266 |      * @access public
 | 
        
           |  |  | 267 |      */
 | 
        
           |  |  | 268 |     function getTitre( $id_projet = "" )
 | 
        
           |  |  | 269 |     {
 | 
        
           |  |  | 270 |         return $this->_titre ;
 | 
        
           |  |  | 271 |     } // end of member function getTitre
 | 
        
           | 59 | ddelon | 272 |   | 
        
           | 2 | ddelon | 273 |     /**
 | 
        
           |  |  | 274 |      *
 | 
        
           | 59 | ddelon | 275 |      *
 | 
        
           | 2 | ddelon | 276 |      * @return string
 | 
        
           |  |  | 277 |      * @access public
 | 
        
           |  |  | 278 |      */
 | 
        
           |  |  | 279 |     function getResume( )
 | 
        
           |  |  | 280 |     {
 | 
        
           |  |  | 281 |         return $this->_resume ;
 | 
        
           |  |  | 282 |     } // end of member function getResume
 | 
        
           |  |  | 283 |   | 
        
           |  |  | 284 |     /**
 | 
        
           |  |  | 285 |      * Renvoie l'identifiant du projet courant.
 | 
        
           |  |  | 286 |      *
 | 
        
           |  |  | 287 |      * @return int
 | 
        
           |  |  | 288 |      * @access public
 | 
        
           |  |  | 289 |      */
 | 
        
           |  |  | 290 |     function getId( )
 | 
        
           |  |  | 291 |     {
 | 
        
           |  |  | 292 |         return $this->_id_projet ;
 | 
        
           |  |  | 293 |     } // end of member function getId
 | 
        
           |  |  | 294 |   | 
        
           |  |  | 295 |     /**
 | 
        
           |  |  | 296 |      *
 | 
        
           | 59 | ddelon | 297 |      *
 | 
        
           | 2 | ddelon | 298 |      * @return string
 | 
        
           |  |  | 299 |      * @access public
 | 
        
           |  |  | 300 |      */
 | 
        
           |  |  | 301 |     function getDescription( )
 | 
        
           |  |  | 302 |     {
 | 
        
           |  |  | 303 |         return $this->_description;
 | 
        
           |  |  | 304 |     } // end of member function getDescription
 | 
        
           |  |  | 305 |   | 
        
           |  |  | 306 |     /**
 | 
        
           |  |  | 307 |      *
 | 
        
           | 59 | ddelon | 308 |      *
 | 
        
           | 2 | ddelon | 309 |      * @return string
 | 
        
           |  |  | 310 |      * @access public
 | 
        
           |  |  | 311 |      */
 | 
        
           |  |  | 312 |     function getEspaceInternet( )
 | 
        
           |  |  | 313 |     {
 | 
        
           |  |  | 314 |         return $this->_espace_internet;
 | 
        
           |  |  | 315 |     } // end of member function getEspaceInternet
 | 
        
           |  |  | 316 |   | 
        
           |  |  | 317 |     /**
 | 
        
           |  |  | 318 |      * Charge dans l'objet projet, les listes de discussion
 | 
        
           |  |  | 319 |      * ['nom_liste']
 | 
        
           |  |  | 320 |      * ['domaine']
 | 
        
           |  |  | 321 |      * ['adresse']
 | 
        
           |  |  | 322 |      *
 | 
        
           |  |  | 323 |      * @return boolean  true en cas de succès
 | 
        
           |  |  | 324 |      * @access public
 | 
        
           |  |  | 325 |      */
 | 
        
           |  |  | 326 |     function getListesAssociees( )
 | 
        
           |  |  | 327 |     {
 | 
        
           | 288 | alexandre_ | 328 |         // On rajoute un test pour eviter l'appel SQL si il a deja ete fait une fois
 | 
        
           | 2 | ddelon | 329 |         if (count($this->_listes_associes) > 0) return ;
 | 
        
           |  |  | 330 |         $requete = "select pl_id_liste from projet_lien_liste where pl_id_projet=".$this->_id_projet ;
 | 
        
           |  |  | 331 |         $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 332 |         if (DB::isError ($resultat)) {
 | 
        
           | 288 | alexandre_ | 333 |             return ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
 | 
        
           | 2 | ddelon | 334 |         }
 | 
        
           |  |  | 335 |         $retour = array() ;
 | 
        
           |  |  | 336 |         if ($resultat->numRows()) {
 | 
        
           |  |  | 337 |             $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
 | 
        
           |  |  | 338 |             $this->_listes_associes[] = new liste_discussion($ligne->pl_id_liste, $this->_db) ;
 | 
        
           | 59 | ddelon | 339 |   | 
        
           | 2 | ddelon | 340 |         }
 | 
        
           |  |  | 341 |     } // end of member function getListesAssociees
 | 
        
           |  |  | 342 |   | 
        
           |  |  | 343 |     /**
 | 
        
           |  |  | 344 |      * Renvoie vrai si le projet a au moins une liste
 | 
        
           |  |  | 345 |      *
 | 
        
           |  |  | 346 |      * @return bool
 | 
        
           |  |  | 347 |      * @access public
 | 
        
           |  |  | 348 |      */
 | 
        
           |  |  | 349 |     function avoirListe( )
 | 
        
           |  |  | 350 |     {
 | 
        
           |  |  | 351 |         $this->getListesAssociees() ;
 | 
        
           |  |  | 352 |         if (count($this->_listes_associes)) {
 | 
        
           |  |  | 353 |             return true ;
 | 
        
           |  |  | 354 |         }
 | 
        
           |  |  | 355 |         return false ;
 | 
        
           | 208 | neiluj | 356 |     }
 | 
        
           | 2 | ddelon | 357 |   | 
        
           | 208 | neiluj | 358 |     /**
 | 
        
           |  |  | 359 |      * Renvoie vrai si le projet a au moins un document, fichier ou repertoire
 | 
        
           |  |  | 360 |      *
 | 
        
           |  |  | 361 |      * Mis en place pour des raisons de performances avant la methode getListesDocuments etait utilisee
 | 
        
           |  |  | 362 |      *
 | 
        
           |  |  | 363 |      * @return bool
 | 
        
           |  |  | 364 |      * @access public
 | 
        
           |  |  | 365 |      */
 | 
        
           |  |  | 366 |     function avoirDocument( )
 | 
        
           |  |  | 367 |     {
 | 
        
           |  |  | 368 |         return $this->_avoirDocument;
 | 
        
           |  |  | 369 |     }
 | 
        
           | 2 | ddelon | 370 |   | 
        
           |  |  | 371 |     /**
 | 
        
           | 288 | alexandre_ | 372 |      * Permet de fixer la colonne p_avoir_document a 1
 | 
        
           | 208 | neiluj | 373 |      *
 | 
        
           |  |  | 374 |      * Mis en place pour des raisons de performances avant la methode getListesDocuments etait utilisee
 | 
        
           |  |  | 375 |      *
 | 
        
           |  |  | 376 |      * @param bool
 | 
        
           |  |  | 377 |      * @return mixed true si la requete fonctionne
 | 
        
           |  |  | 378 |      * @access public
 | 
        
           |  |  | 379 |      */
 | 
        
           |  |  | 380 |     function setAvoirDocument($bool)
 | 
        
           |  |  | 381 |     {
 | 
        
           |  |  | 382 |         $val = 0 ;
 | 
        
           |  |  | 383 |         if ($bool) $val = 1;
 | 
        
           |  |  | 384 |         $requete = 'update projet set p_avoir_document='.$val.' where p_id='.$this->_id_projet;
 | 
        
           |  |  | 385 |         $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 386 |         if (DB::isError($resultat)) {
 | 
        
           |  |  | 387 |             echo ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
 | 
        
           |  |  | 388 |         }
 | 
        
           |  |  | 389 |         return true;
 | 
        
           |  |  | 390 |     }
 | 
        
           |  |  | 391 |   | 
        
           |  |  | 392 |     /**
 | 
        
           | 249 | alexandre_ | 393 |      * Renvoie la liste des documents associes sous forme d'un tableau, avec les
 | 
        
           | 288 | alexandre_ | 394 |      * informations afferentes. 0 => "nom (cliquable)"
 | 
        
           | 2 | ddelon | 395 |      "Taille"
 | 
        
           |  |  | 396 |      "Date
 | 
        
           | 249 | alexandre_ | 397 |      * de creation"          "Prorietaire"          "Visibilite"          "Action
 | 
        
           | 2 | ddelon | 398 |      * (cliquable)"
 | 
        
           |  |  | 399 |      *
 | 
        
           | 249 | alexandre_ | 400 |      * @param visibilite visibilite Si visibilite est prive, tous les fichiers sont renvoyes ainsi qu'une entree
 | 
        
           |  |  | 401 |      * pour indiquer la visibilite du document.
 | 
        
           | 2 | ddelon | 402 |      * @return Array
 | 
        
           |  |  | 403 |      * @access public
 | 
        
           |  |  | 404 |      */
 | 
        
           | 288 | alexandre_ | 405 |     function getListesDocuments( $chemin, $chemin_icones = "icones/", $id_repertoire = '', $date = '' )
 | 
        
           | 2 | ddelon | 406 |     {
 | 
        
           | 249 | alexandre_ | 407 |         // On realise une requete sur projet_documents avec une jointure sur l'annuaire
 | 
        
           |  |  | 408 |         // et sur gen_type_de_fichier pour envoyer un resultat complet.
 | 
        
           | 2 | ddelon | 409 |         // On exclue les fichiers racines cad pd_pere is null
 | 
        
           | 249 | alexandre_ | 410 |         $requete = "select pd_id from projet_documents where pd_ce_projet=".$this->_id_projet ;
 | 
        
           |  |  | 411 |         if ($id_repertoire != '') $requete .= ' and pd_pere='.$id_repertoire;
 | 
        
           | 298 | alexandre_ | 412 |         if ($id_repertoire != '' && $id_repertoire == 0) $requete .= ' and pd_pere=0';
 | 
        
           | 288 | alexandre_ | 413 |         if ($date != '') $requete .= ' and pd_date_de_mise_a_jour > date_sub (NOW(), interval 1 week)';
 | 
        
           | 249 | alexandre_ | 414 |         $requete .= ' order by pd_nom' ;
 | 
        
           | 2 | ddelon | 415 |         $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 416 |         if (DB::isError($resultat)) {
 | 
        
           | 249 | alexandre_ | 417 |             return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
 | 
        
           | 2 | ddelon | 418 |         }
 | 
        
           |  |  | 419 |         $tableau_document = array() ;
 | 
        
           |  |  | 420 |         // Un compteur
 | 
        
           |  |  | 421 |         $i = 0 ;
 | 
        
           |  |  | 422 |         while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) {
 | 
        
           | 298 | alexandre_ | 423 |             array_push ($tableau_document, new document ($ligne->pd_id, $i, $chemin, $chemin_icones)) ;
 | 
        
           | 2 | ddelon | 424 |         }
 | 
        
           |  |  | 425 |         return $tableau_document ;
 | 
        
           | 249 | alexandre_ | 426 |     }
 | 
        
           | 2 | ddelon | 427 |   | 
        
           |  |  | 428 |   | 
        
           |  |  | 429 |     /**
 | 
        
           | 249 | alexandre_ | 430 |      * Renvoie un tableau avec tous les repertoires d'un projet, imbrique. ['rep1'],
 | 
        
           | 2 | ddelon | 431 |      * ['rep2'] => array (['rep21'], 	['rep22']), etc .
 | 
        
           |  |  | 432 |      *
 | 
        
           |  |  | 433 |      * @return Array
 | 
        
           |  |  | 434 |      * @access public
 | 
        
           |  |  | 435 |      */
 | 
        
           |  |  | 436 |     function getListeRepertoireHierarchisee( )
 | 
        
           |  |  | 437 |     {
 | 
        
           | 249 | alexandre_ | 438 |         // On ne prend que les repertoires
 | 
        
           |  |  | 439 |         $requete = "select pd_id, pd_pere, pd_nom from projet_documents where pd_ce_projet=".$this->_id_projet.' and pd_ce_type=0 order by pd_nom' ;
 | 
        
           | 2 | ddelon | 440 |         $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 441 |         if (DB::isError($resultat)) {
 | 
        
           | 288 | alexandre_ | 442 |             return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
 | 
        
           | 2 | ddelon | 443 |         }
 | 
        
           |  |  | 444 |         $tableau_document = array() ;
 | 
        
           | 249 | alexandre_ | 445 | 		/*
 | 
        
           | 2 | ddelon | 446 |         while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) {
 | 
        
           |  |  | 447 |             array_push ($tableau_document, new document ($ligne->pd_id, $this->_db));
 | 
        
           |  |  | 448 |         }
 | 
        
           | 249 | alexandre_ | 449 |         */
 | 
        
           |  |  | 450 |         $tableau = array();
 | 
        
           |  |  | 451 |         $tab = array();
 | 
        
           | 59 | ddelon | 452 |   | 
        
           | 249 | alexandre_ | 453 |   | 
        
           |  |  | 454 |         while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) {
 | 
        
           |  |  | 455 |             array_push ($tableau, array ('id' => $ligne->pd_id,
 | 
        
           |  |  | 456 | 										'id_pere' => $ligne->pd_pere,
 | 
        
           |  |  | 457 | 										'fils' => array(),
 | 
        
           |  |  | 458 | 										'label' => $ligne->pd_nom));
 | 
        
           |  |  | 459 |   | 
        
           |  |  | 460 |         }
 | 
        
           |  |  | 461 |   | 
        
           |  |  | 462 |         // la $tableau reste un tableau de valeur a plat
 | 
        
           |  |  | 463 |   | 
        
           |  |  | 464 |   | 
        
           |  |  | 465 | 		$i = 0;
 | 
        
           |  |  | 466 |         foreach ($tableau as $noeud) {
 | 
        
           |  |  | 467 |         	// On teste si le noeud est racine si oui on l ajoute a l arbre sinon on ne l ajoute pas
 | 
        
           |  |  | 468 |         	if ($noeud['id_pere'] == 0) {
 | 
        
           |  |  | 469 |         		$tab[$i] = $noeud;
 | 
        
           |  |  | 470 |         		$this->construireArbre($tab[$i], $tableau) ;
 | 
        
           |  |  | 471 |         	}
 | 
        
           |  |  | 472 |         	$i++;
 | 
        
           |  |  | 473 |         }
 | 
        
           |  |  | 474 |         return $tab;
 | 
        
           | 2 | ddelon | 475 |     } // end of member function getListeRepertoireHierarchisee
 | 
        
           |  |  | 476 |   | 
        
           | 249 | alexandre_ | 477 | 	function construireArbre(&$noeud, $tableau) {
 | 
        
           |  |  | 478 |     	$j = 0;
 | 
        
           |  |  | 479 |     	foreach ($tableau as $element) {
 | 
        
           |  |  | 480 |         	// pour chaque element on teste
 | 
        
           |  |  | 481 |         	if ($element['id_pere'] == $noeud['id']) {
 | 
        
           |  |  | 482 |         		$noeud['fils'][$j]= $element ;
 | 
        
           |  |  | 483 |         		$this->construireArbre($noeud['fils'][$j],$tableau);
 | 
        
           |  |  | 484 |         	}
 | 
        
           |  |  | 485 |         	$j++;
 | 
        
           |  |  | 486 |         }
 | 
        
           |  |  | 487 |     }
 | 
        
           | 2 | ddelon | 488 |   | 
        
           |  |  | 489 |     /**
 | 
        
           |  |  | 490 |      * Renvoie un tableau comprenant tous les objets projet de la base.
 | 
        
           |  |  | 491 |      *
 | 
        
           |  |  | 492 |      * @return Array
 | 
        
           |  |  | 493 |      * @static
 | 
        
           |  |  | 494 |      * @access public
 | 
        
           |  |  | 495 |      */
 | 
        
           | 208 | neiluj | 496 |     function getTousLesProjets(&$objetDB, $exclu = '')
 | 
        
           | 2 | ddelon | 497 |     {
 | 
        
           | 208 | neiluj | 498 |     	$sql = '';
 | 
        
           | 280 | alexandre_ | 499 |         if (is_object($this) && isset ($this->_projet_exclu) && count($this->_projet_exclu)) {
 | 
        
           | 208 | neiluj | 500 |         	$sql = 'where p_id not in (';
 | 
        
           |  |  | 501 |             foreach ($this->_projet_exclu as $valeur) {
 | 
        
           |  |  | 502 |             	$sql .= $valeur.',' ;
 | 
        
           |  |  | 503 |             }
 | 
        
           |  |  | 504 |             $sql[count($sql)-1] = ')';
 | 
        
           |  |  | 505 |         }
 | 
        
           |  |  | 506 |         $requete = 'select p_id from projet '.$sql.' order by p_titre' ;
 | 
        
           | 2 | ddelon | 507 |         $resultat = $objetDB->query ($requete) ;
 | 
        
           |  |  | 508 |         if (DB::isError($resultat)) {
 | 
        
           | 208 | neiluj | 509 |             echo ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
 | 
        
           | 2 | ddelon | 510 |         }
 | 
        
           |  |  | 511 |         $tableau_resultat = array() ;
 | 
        
           |  |  | 512 |         while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) {
 | 
        
           |  |  | 513 |             array_push ($tableau_resultat, new projet ($objetDB, $ligne->p_id)) ;
 | 
        
           |  |  | 514 |         }
 | 
        
           |  |  | 515 |         return $tableau_resultat ;
 | 
        
           |  |  | 516 |     } // end of member function getTousLesProjets
 | 
        
           |  |  | 517 |   | 
        
           |  |  | 518 |     /**
 | 
        
           | 11 | alexandre_ | 519 |      * Renvoie un tableau comprenant les objets projet de la base du type $type.
 | 
        
           |  |  | 520 |      *
 | 
        
           |  |  | 521 |      * @return Array
 | 
        
           |  |  | 522 |      * @static
 | 
        
           |  |  | 523 |      * @access public
 | 
        
           |  |  | 524 |      */
 | 
        
           |  |  | 525 |     function getProjetDuType($type, &$objetDB)
 | 
        
           |  |  | 526 |     {
 | 
        
           |  |  | 527 |         $requete = "select p_id from projet where p_type=$type order by p_titre" ;
 | 
        
           |  |  | 528 |         $resultat = $objetDB->query ($requete) ;
 | 
        
           |  |  | 529 |         if (DB::isError($resultat)) {
 | 
        
           |  |  | 530 |             die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
 | 
        
           |  |  | 531 |         }
 | 
        
           |  |  | 532 |         $tableau_resultat = array() ;
 | 
        
           |  |  | 533 |         while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) {
 | 
        
           |  |  | 534 |             array_push ($tableau_resultat, new projet ($objetDB, $ligne->p_id)) ;
 | 
        
           |  |  | 535 |         }
 | 
        
           |  |  | 536 |         return $tableau_resultat ;
 | 
        
           |  |  | 537 |     } // end of member function getTousLesProjets
 | 
        
           |  |  | 538 |   | 
        
           |  |  | 539 |     /**
 | 
        
           |  |  | 540 |      * Renvoie un le projet racine.
 | 
        
           |  |  | 541 |      *
 | 
        
           |  |  | 542 |      * @return projet
 | 
        
           |  |  | 543 |      * @static
 | 
        
           |  |  | 544 |      * @access public
 | 
        
           |  |  | 545 |      */
 | 
        
           |  |  | 546 |     function getProjetRacine(&$objetDB)
 | 
        
           |  |  | 547 |     {
 | 
        
           |  |  | 548 |         $requete = "select p_id from projet where p_id not in (select ph_id_projet_fils from projet_hierarchie)" ;
 | 
        
           |  |  | 549 |         $resultat = $objetDB->query ($requete) ;
 | 
        
           |  |  | 550 |         if (DB::isError($resultat)) {
 | 
        
           |  |  | 551 |             die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
 | 
        
           |  |  | 552 |         }
 | 
        
           |  |  | 553 |         if ($resultat->numRows() == 1) {
 | 
        
           |  |  | 554 |             $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
 | 
        
           |  |  | 555 |             return new projet($objetDB, $ligne->p_id) ;
 | 
        
           |  |  | 556 |         }
 | 
        
           |  |  | 557 |         $tableau_resultat = array() ;
 | 
        
           |  |  | 558 |         while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) {
 | 
        
           |  |  | 559 |             array_push ($tableau_resultat, new projet ($objetDB, $ligne->p_id)) ;
 | 
        
           |  |  | 560 |         }
 | 
        
           |  |  | 561 |         return $tableau_resultat ;
 | 
        
           |  |  | 562 |     } // end of member function getTousLesProjets
 | 
        
           |  |  | 563 |   | 
        
           |  |  | 564 |     /**
 | 
        
           | 288 | alexandre_ | 565 |      * Desctructeur de la classe. Libere la memoire, ferme les connexions et fichiers.
 | 
        
           | 2 | ddelon | 566 |      *
 | 
        
           |  |  | 567 |      * @return void
 | 
        
           |  |  | 568 |      * @access public
 | 
        
           |  |  | 569 |      */
 | 
        
           |  |  | 570 |     function __destruct( )
 | 
        
           |  |  | 571 |     {
 | 
        
           | 59 | ddelon | 572 |   | 
        
           | 2 | ddelon | 573 |     } // end of member function __destruct
 | 
        
           |  |  | 574 |   | 
        
           |  |  | 575 |     /**
 | 
        
           |  |  | 576 |      * Supprime le projet courrant. Il s'ensuit une suppression en cascade de tous les
 | 
        
           | 288 | alexandre_ | 577 |      * elements lies.
 | 
        
           | 2 | ddelon | 578 |      *
 | 
        
           |  |  | 579 |      * @return void
 | 
        
           |  |  | 580 |      * @access public
 | 
        
           |  |  | 581 |      */
 | 
        
           |  |  | 582 |     function supprimer( )
 | 
        
           |  |  | 583 |     {
 | 
        
           | 59 | ddelon | 584 |   | 
        
           | 2 | ddelon | 585 |     } // end of member function supprimer
 | 
        
           |  |  | 586 |   | 
        
           |  |  | 587 |     /**
 | 
        
           | 288 | alexandre_ | 588 |      * Permet d'enregistrer une ligne dans la table concernee.
 | 
        
           | 2 | ddelon | 589 |      *
 | 
        
           | 288 | alexandre_ | 590 |      * @param Array tableau_de_valeur Le tableau de valeur a inserer dans la base avec pour cle les noms des elements
 | 
        
           | 2 | ddelon | 591 |      * du formulaire.
 | 
        
           |  |  | 592 |      * @return int
 | 
        
           |  |  | 593 |      * @access public
 | 
        
           |  |  | 594 |      */
 | 
        
           |  |  | 595 |     function enregistrerSQL( $tableau_de_valeur )
 | 
        
           |  |  | 596 |     {
 | 
        
           |  |  | 597 |         $nom_repertoire = projet::genereNomRepertoire($tableau_de_valeur['projet_titre'], $this->_db) ;
 | 
        
           |  |  | 598 |         if (!$this->_creationRepertoire ($nom_repertoire)) {
 | 
        
           | 288 | alexandre_ | 599 |             echo 'Impossible de crée un répertoire'.$nom_repertoire ;
 | 
        
           | 2 | ddelon | 600 |             return false ;
 | 
        
           |  |  | 601 |         }
 | 
        
           | 11 | alexandre_ | 602 |         // Traitement du type
 | 
        
           |  |  | 603 |         if (!PROJET_UTILISE_TYPE) {
 | 
        
           |  |  | 604 |             $tableau_de_valeur['projet_type'] = 0 ;
 | 
        
           |  |  | 605 |         }
 | 
        
           | 2 | ddelon | 606 |         $id = SQL_obtenirNouveauId($this->_db, 'projet', 'p_id') ;
 | 
        
           |  |  | 607 |         $requete = 'insert into projet set p_id='.$id ;
 | 
        
           | 15 | ddelon | 608 |         if (!isset($tableau_de_valeur['projet_wikini'])) {
 | 
        
           |  |  | 609 |         	$tableau_de_valeur['projet_wikini']='';
 | 
        
           |  |  | 610 |         }
 | 
        
           | 2 | ddelon | 611 |         $requete .= ', p_titre="'.$tableau_de_valeur['projet_titre'].'", p_description="'.$tableau_de_valeur['projet_description'].'"'.
 | 
        
           |  |  | 612 |                     ', p_espace_internet="'.$tableau_de_valeur['projet_espace_internet'].'", p_date_creation=NOW()'.
 | 
        
           | 11 | alexandre_ | 613 |                     ', p_wikini="'.$tableau_de_valeur['projet_wikini'].'", p_nom_repertoire="'.$nom_repertoire.'", p_resume="'.$tableau_de_valeur['projet_resume'].
 | 
        
           | 121 | alexandre_ | 614 |                     '", p_type='.$tableau_de_valeur['projet_type'].', p_modere="'.$tableau_de_valeur['projet_moderation'].'"' ;
 | 
        
           | 2 | ddelon | 615 |         $resultat = $this->_db->query ($requete) ;
 | 
        
           | 59 | ddelon | 616 |   | 
        
           | 2 | ddelon | 617 |         if (DB::isError($resultat)) {
 | 
        
           | 288 | alexandre_ | 618 |             return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
 | 
        
           | 2 | ddelon | 619 |         }
 | 
        
           | 59 | ddelon | 620 |   | 
        
           | 288 | alexandre_ | 621 |         // On affecte a l'objet projet son identifiant
 | 
        
           | 35 | alexandre_ | 622 |         $this->_id_projet = $id ;
 | 
        
           | 59 | ddelon | 623 |   | 
        
           | 288 | alexandre_ | 624 |         //insertion dans projet_herarchie
 | 
        
           | 35 | alexandre_ | 625 | 		if (PROJET_UTILISE_HIERARCHIE) {
 | 
        
           |  |  | 626 | 	        $requete = 'insert into projet_hierarchie set ph_id_projet_pere='.$tableau_de_valeur['projet_asso'].
 | 
        
           |  |  | 627 | 	                    ', ph_id_projet_fils='.$id ;
 | 
        
           |  |  | 628 | 	        $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 629 | 		}
 | 
        
           | 288 | alexandre_ | 630 |   | 
        
           |  |  | 631 | 		/** enregistrement dans projet_avoir_theme */
 | 
        
           |  |  | 632 | 		$requete_theme = '';
 | 
        
           |  |  | 633 | 		foreach ($tableau_de_valeur['projet_theme'] as $cle => $valeur) {
 | 
        
           |  |  | 634 | 			$requete_theme = 'insert into projet_avoir_theme set pat_id_projet='.$id.', pat_id_theme='.$cle;
 | 
        
           |  |  | 635 | 			$resultat_theme = $GLOBALS['projet_db']->query($requete_theme);
 | 
        
           |  |  | 636 | 			if (DB::isError($resultat_theme)) {
 | 
        
           |  |  | 637 | 				return $resultat_theme->getMessage();
 | 
        
           |  |  | 638 | 			}
 | 
        
           |  |  | 639 | 		}
 | 
        
           | 2 | ddelon | 640 |         return true ;
 | 
        
           | 288 | alexandre_ | 641 |     }
 | 
        
           | 2 | ddelon | 642 |   | 
        
           |  |  | 643 |     /**
 | 
        
           | 288 | alexandre_ | 644 |      * Permet de mettre a jour une ligne dans la table concernee.
 | 
        
           | 2 | ddelon | 645 |      *
 | 
        
           | 288 | alexandre_ | 646 |      * @param Array tableau_de_valeur Le tableau de valeur a inserer dans la base avec pour cle les noms des elements
 | 
        
           | 2 | ddelon | 647 |      * du formulaire.
 | 
        
           |  |  | 648 |      * @return int
 | 
        
           |  |  | 649 |      * @access public
 | 
        
           |  |  | 650 |      */
 | 
        
           |  |  | 651 |     function majSQL( $tableau_de_valeur )
 | 
        
           |  |  | 652 |     {
 | 
        
           | 11 | alexandre_ | 653 |         // Traitement du type
 | 
        
           |  |  | 654 |         if (!PROJET_UTILISE_TYPE) {
 | 
        
           |  |  | 655 |             $tableau_de_valeur['projet_type'] = 0 ;
 | 
        
           |  |  | 656 |         }
 | 
        
           | 2 | ddelon | 657 |         $requete = 'update projet set ';
 | 
        
           |  |  | 658 |         $requete .= 'p_titre="'.$tableau_de_valeur['projet_titre'].'", p_description="'.$tableau_de_valeur['projet_description'].'"'.
 | 
        
           |  |  | 659 |                     ', p_espace_internet="'.$tableau_de_valeur['projet_espace_internet'].'"'.
 | 
        
           | 11 | alexandre_ | 660 |                     ', p_resume="'.$tableau_de_valeur['projet_resume'].'", p_type='.$tableau_de_valeur['projet_type'].
 | 
        
           | 121 | alexandre_ | 661 |                     ', p_modere='.$tableau_de_valeur['projet_moderation'].
 | 
        
           | 2 | ddelon | 662 |                     ' where p_id="'.$this->_id_projet.'"' ;
 | 
        
           |  |  | 663 |         $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 664 |         if (DB::isError($resultat)) {
 | 
        
           | 288 | alexandre_ | 665 |             return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
 | 
        
           | 2 | ddelon | 666 |         }
 | 
        
           | 59 | ddelon | 667 |   | 
        
           | 35 | alexandre_ | 668 |         if (PROJET_UTILISE_HIERARCHIE) {
 | 
        
           |  |  | 669 | 	        // suppression dans projet_hierarchie
 | 
        
           | 59 | ddelon | 670 |   | 
        
           | 35 | alexandre_ | 671 | 	        $requete = 'delete from projet_hierarchie where ph_id_projet_fils='.$this->_id_projet ;
 | 
        
           |  |  | 672 | 	        $resultat = $this->_db->query ($requete) ;
 | 
        
           | 59 | ddelon | 673 |   | 
        
           | 208 | neiluj | 674 | 	        //insertion dans projet_hierarchie
 | 
        
           | 59 | ddelon | 675 |   | 
        
           | 35 | alexandre_ | 676 | 	        $requete = 'insert into projet_hierarchie set ph_id_projet_pere='.$tableau_de_valeur['projet_asso'].
 | 
        
           |  |  | 677 | 	                    ', ph_id_projet_fils='.$this->_id_projet ;
 | 
        
           |  |  | 678 | 	        $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 679 |         }
 | 
        
           | 288 | alexandre_ | 680 |   | 
        
           |  |  | 681 |         /** enregistrement dans projet_avoir_theme */
 | 
        
           |  |  | 682 |   | 
        
           |  |  | 683 |         $requete_suppression_theme = 'delete from projet_avoir_theme where pat_id_projet='.$this->_id_projet;
 | 
        
           |  |  | 684 |         $resultat_suppression_theme  = $GLOBALS['projet_db']->query($requete_suppression_theme);
 | 
        
           |  |  | 685 |   | 
        
           |  |  | 686 | 		$requete_theme = '';
 | 
        
           |  |  | 687 | 		foreach ($tableau_de_valeur['projet_theme'] as $cle => $valeur) {
 | 
        
           |  |  | 688 | 			$requete_theme = 'insert into projet_avoir_theme set pat_id_projet='.$this->_id_projet.', pat_id_theme='.$cle;
 | 
        
           |  |  | 689 | 			$resultat_theme = $GLOBALS['projet_db']->query($requete_theme);
 | 
        
           |  |  | 690 | 			if (DB::isError($resultat_theme)) {
 | 
        
           |  |  | 691 | 				return $resultat_theme->getMessage();
 | 
        
           |  |  | 692 | 			}
 | 
        
           |  |  | 693 | 		}
 | 
        
           | 2 | ddelon | 694 |         return true ;
 | 
        
           |  |  | 695 |     } // end of member function enregistrerSQL
 | 
        
           |  |  | 696 |   | 
        
           |  |  | 697 |     /**
 | 
        
           | 288 | alexandre_ | 698 |      * Met a jour dans la base de donnee le champs p_nom_wikini
 | 
        
           | 2 | ddelon | 699 |      *
 | 
        
           |  |  | 700 |      * @param int nom_wikini Le nouveau nom wikini
 | 
        
           |  |  | 701 |      * @return bool
 | 
        
           |  |  | 702 |      * @access public
 | 
        
           |  |  | 703 |      */
 | 
        
           |  |  | 704 |     function majNomWikini( $nom_wikini )
 | 
        
           |  |  | 705 |     {
 | 
        
           |  |  | 706 |         $requete = 'update projet set p_wikini="'.$nom_wikini.'" where p_id="'.$this->_id_projet.'"' ;
 | 
        
           |  |  | 707 |         $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 708 |         if (DB::isError ($resultat)) {
 | 
        
           | 288 | alexandre_ | 709 |             return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
 | 
        
           | 2 | ddelon | 710 |         }
 | 
        
           |  |  | 711 |         return true ;
 | 
        
           |  |  | 712 |     } // end of member function majNomWikini
 | 
        
           |  |  | 713 |   | 
        
           |  |  | 714 |   | 
        
           |  |  | 715 |     /**
 | 
        
           |  |  | 716 |      *
 | 
        
           | 59 | ddelon | 717 |      *
 | 
        
           |  |  | 718 |      * @param string code_sql
 | 
        
           | 2 | ddelon | 719 |      * @return bool
 | 
        
           |  |  | 720 |      * @access public
 | 
        
           |  |  | 721 |      */
 | 
        
           |  |  | 722 |     function suppressionSQL()
 | 
        
           |  |  | 723 |     {
 | 
        
           |  |  | 724 |         $msg = '' ;
 | 
        
           | 288 | alexandre_ | 725 |         // Supression du repertoire du projet
 | 
        
           | 2 | ddelon | 726 |         if (!$this->_suppression_repertoire()) {
 | 
        
           | 288 | alexandre_ | 727 |             $msg = 'La suppression du repertoire n\'a pas fonctionne' ;
 | 
        
           | 2 | ddelon | 728 |         }
 | 
        
           | 288 | alexandre_ | 729 |         // A ajouter la suppression des documents associes
 | 
        
           | 59 | ddelon | 730 |   | 
        
           | 288 | alexandre_ | 731 |         // La suppression des evenements associés
 | 
        
           | 59 | ddelon | 732 |   | 
        
           | 288 | alexandre_ | 733 |         // Le projet lui-meme
 | 
        
           | 2 | ddelon | 734 |         $requete = "delete from projet where p_id=".$this->_id_projet ;
 | 
        
           |  |  | 735 |         $resultat = $this->_db->query ($requete) ;
 | 
        
           | 59 | ddelon | 736 |   | 
        
           | 35 | alexandre_ | 737 |         if (PROJET_UTILISE_HIERARCHIE) {
 | 
        
           |  |  | 738 | 	        $requete = "delete from projet_hierarchie where ph_id_projet_fils=".$this->_id_projet ;
 | 
        
           |  |  | 739 | 	        $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 740 |         }
 | 
        
           | 2 | ddelon | 741 |         $requete = "delete from projet_statut_utilisateurs where psu_id_projet=".$this->_id_projet ;
 | 
        
           |  |  | 742 |         $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 743 |         return $msg ;
 | 
        
           |  |  | 744 |     } // end of member function suppressionSQL
 | 
        
           |  |  | 745 |   | 
        
           |  |  | 746 |     /**
 | 
        
           | 288 | alexandre_ | 747 |      * Supprime le repertoire associe au projet (le repertoire doit etre vide).
 | 
        
           | 2 | ddelon | 748 |      *
 | 
        
           |  |  | 749 |      * @return void
 | 
        
           |  |  | 750 |      * @access private
 | 
        
           |  |  | 751 |      */
 | 
        
           |  |  | 752 |     function _suppression_repertoire( )
 | 
        
           |  |  | 753 |     {
 | 
        
           |  |  | 754 |         return rmdir ($this->_chemin_repertoire.$this->_nom_repertoire) ;
 | 
        
           |  |  | 755 |     } // end of member function _suppression_repertoire
 | 
        
           |  |  | 756 |   | 
        
           |  |  | 757 |     /**
 | 
        
           | 288 | alexandre_ | 758 |      * Permet de creer le repertoire associe au projet.
 | 
        
           | 2 | ddelon | 759 |      *
 | 
        
           |  |  | 760 |      * @param string nom_repertoire Le nom du répertoire à créer.
 | 
        
           |  |  | 761 |      * @return boolean
 | 
        
           |  |  | 762 |      * @access private
 | 
        
           |  |  | 763 |      */
 | 
        
           |  |  | 764 |     function _creationRepertoire( $nom_repertoire )
 | 
        
           |  |  | 765 |     {
 | 
        
           |  |  | 766 |         return mkdir ($this->_chemin_repertoire.$nom_repertoire) ;
 | 
        
           |  |  | 767 |     } // end of member function _creationRepertoire
 | 
        
           |  |  | 768 |   | 
        
           |  |  | 769 |     /**
 | 
        
           | 288 | alexandre_ | 770 |      * Permet d'indiquer ou seront stockes les fichiers.
 | 
        
           | 2 | ddelon | 771 |      *
 | 
        
           | 288 | alexandre_ | 772 |      * @param string cheminRepertoire Le chemin jusqu'au repertoire ou seront stockes les fichiers.
 | 
        
           | 2 | ddelon | 773 |      * @return void
 | 
        
           |  |  | 774 |      * @access public
 | 
        
           |  |  | 775 |      */
 | 
        
           |  |  | 776 |     function setCheminRepertoire( $cheminRepertoire )
 | 
        
           |  |  | 777 |     {
 | 
        
           |  |  | 778 |         $this->_chemin_repertoire = $cheminRepertoire ;
 | 
        
           |  |  | 779 |     } // end of member function setCheminRepertoire
 | 
        
           |  |  | 780 |   | 
        
           |  |  | 781 |     /**
 | 
        
           | 288 | alexandre_ | 782 |      * Genere un nom de repertoire a partir de la premiere lettre de la chaine passe en
 | 
        
           |  |  | 783 |      * parametre et de l'identifiant du dernier projet.
 | 
        
           | 2 | ddelon | 784 |      *
 | 
        
           | 288 | alexandre_ | 785 |      * @param string chaine Une chaine a partir de laquelle sera generer le nom du repertoire.
 | 
        
           | 2 | ddelon | 786 |      * @param DB objetDB un objet PEAR::DB
 | 
        
           |  |  | 787 |      * @return string
 | 
        
           |  |  | 788 |      * @static
 | 
        
           |  |  | 789 |      * @access public
 | 
        
           |  |  | 790 |      */
 | 
        
           |  |  | 791 |     function genereNomRepertoire( $chaine, &$objetDB )
 | 
        
           |  |  | 792 |     {
 | 
        
           |  |  | 793 |         $requete = "select p_id from projet order by p_id desc limit 0,1" ;
 | 
        
           |  |  | 794 |         $resultat = $objetDB->query ($requete) ;
 | 
        
           |  |  | 795 |         if (DB::isError ($resultat)) {
 | 
        
           | 288 | alexandre_ | 796 |             return ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
 | 
        
           | 2 | ddelon | 797 |         }
 | 
        
           | 15 | ddelon | 798 |         if ($resultat->numRows() > 0) {
 | 
        
           |  |  | 799 | 	        $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
 | 
        
           |  |  | 800 | 	        $nom = strtoupper(substr($chaine, 0, 1)) ;
 | 
        
           |  |  | 801 | 	        $nom .= $ligne->p_id + 1 ;
 | 
        
           |  |  | 802 |         }
 | 
        
           |  |  | 803 | 	    else {
 | 
        
           |  |  | 804 | 	    	$nom = strtoupper(substr($chaine, 0, 1)) ;
 | 
        
           |  |  | 805 | 	        $nom .=  1 ;
 | 
        
           |  |  | 806 | 	    }
 | 
        
           | 2 | ddelon | 807 |         return $nom ;
 | 
        
           | 59 | ddelon | 808 |   | 
        
           | 2 | ddelon | 809 |     } // end of member function genereNomRepertoire
 | 
        
           |  |  | 810 |   | 
        
           |  |  | 811 |     /**
 | 
        
           | 288 | alexandre_ | 812 |      * Permet de recuperer le nom du repertoire d'un projet.
 | 
        
           | 2 | ddelon | 813 |      *
 | 
        
           |  |  | 814 |      * @return string
 | 
        
           |  |  | 815 |      * @access public
 | 
        
           |  |  | 816 |      */
 | 
        
           |  |  | 817 |     function getNomRepertoire( )
 | 
        
           |  |  | 818 |     {
 | 
        
           |  |  | 819 |         return $this->_nom_repertoire ;
 | 
        
           |  |  | 820 |     } // end of member function getNomRepertoire
 | 
        
           |  |  | 821 |   | 
        
           |  |  | 822 |     /**
 | 
        
           | 288 | alexandre_ | 823 |      *  Ajoute une liste a un projet
 | 
        
           | 2 | ddelon | 824 |      *  Effectue une insertion dans projet_lien_liste
 | 
        
           |  |  | 825 |      *
 | 
        
           |  |  | 826 |      * @param liste_discussion liste Une instance de la classe liste_discussion
 | 
        
           |  |  | 827 |      * @return void
 | 
        
           |  |  | 828 |      * @access public
 | 
        
           |  |  | 829 |      */
 | 
        
           |  |  | 830 |     function ajouterListe( &$liste )
 | 
        
           |  |  | 831 |     {
 | 
        
           |  |  | 832 |         $requete = "insert into projet_lien_liste set pl_id_liste=".$liste->getId().
 | 
        
           |  |  | 833 |                     ', pl_id_projet='.$this->_id_projet ;
 | 
        
           |  |  | 834 |         $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 835 |         if (DB::isError ($resultat)) {
 | 
        
           | 288 | alexandre_ | 836 |             return ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
 | 
        
           | 2 | ddelon | 837 |         }
 | 
        
           | 288 | alexandre_ | 838 |     }
 | 
        
           | 2 | ddelon | 839 |   | 
        
           |  |  | 840 |     /**
 | 
        
           | 288 | alexandre_ | 841 |      * Supprime la liste de discussion associee au projet
 | 
        
           | 2 | ddelon | 842 |      *
 | 
        
           |  |  | 843 |      * @return void
 | 
        
           |  |  | 844 |      * @access public
 | 
        
           |  |  | 845 |      */
 | 
        
           |  |  | 846 |     function supprimerListe(&$liste)
 | 
        
           |  |  | 847 |     {
 | 
        
           |  |  | 848 |         $requete = 'delete from projet_lien_liste where pl_id_liste='.$liste->getId() ;
 | 
        
           |  |  | 849 |         $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 850 |         if (DB::isError ($resultat)) {
 | 
        
           | 288 | alexandre_ | 851 |             return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
 | 
        
           | 2 | ddelon | 852 |         }
 | 
        
           |  |  | 853 |         $requete = 'delete from projet_liste where pl_id_liste='.$liste->getId() ;
 | 
        
           |  |  | 854 |         $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 855 |         if (DB::isError ($resultat)) {
 | 
        
           | 288 | alexandre_ | 856 |             return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
 | 
        
           | 2 | ddelon | 857 |         }
 | 
        
           | 288 | alexandre_ | 858 |     }
 | 
        
           | 2 | ddelon | 859 |   | 
        
           |  |  | 860 |   | 
        
           |  |  | 861 |     /**
 | 
        
           |  |  | 862 |      * Renvoie vrai si le projet est racine.
 | 
        
           |  |  | 863 |      *
 | 
        
           |  |  | 864 |      * @return bool
 | 
        
           |  |  | 865 |      * @access public
 | 
        
           |  |  | 866 |      */
 | 
        
           |  |  | 867 |     function isRacine( )
 | 
        
           |  |  | 868 |     {
 | 
        
           |  |  | 869 |         return $this->_est_racine ;
 | 
        
           |  |  | 870 |     } // end of member function isRacine
 | 
        
           |  |  | 871 |   | 
        
           |  |  | 872 |     /**
 | 
        
           |  |  | 873 |      * Renvoie le nombre d'inscrits au projet. Effectue une requete dans la table
 | 
        
           |  |  | 874 |      * projet_statut_utilisateurs
 | 
        
           |  |  | 875 |      *
 | 
        
           |  |  | 876 |      * @return int
 | 
        
           |  |  | 877 |      * @access public
 | 
        
           |  |  | 878 |      */
 | 
        
           |  |  | 879 |     function getNombreInscrits( )
 | 
        
           |  |  | 880 |     {
 | 
        
           |  |  | 881 |         $requete = 'select count(psu_id_utilisateur) as nbre from projet_statut_utilisateurs where psu_id_projet='.$this->_id_projet ;
 | 
        
           |  |  | 882 |         $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 883 |         if (DB::isError ($resultat)) {
 | 
        
           |  |  | 884 |             die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
 | 
        
           |  |  | 885 |         }
 | 
        
           |  |  | 886 |         $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
 | 
        
           |  |  | 887 |         return $ligne->nbre ;
 | 
        
           |  |  | 888 |     } // end of member function getNombreInscrits
 | 
        
           |  |  | 889 |   | 
        
           |  |  | 890 |   | 
        
           |  |  | 891 |     /**
 | 
        
           |  |  | 892 |      * Renvoie un tableau contenant les identifiants des fils du projet courant.
 | 
        
           |  |  | 893 |      *
 | 
        
           |  |  | 894 |      * @return Array
 | 
        
           |  |  | 895 |      * @access public
 | 
        
           |  |  | 896 |      */
 | 
        
           |  |  | 897 |     function getHierarchie( )
 | 
        
           |  |  | 898 |     {
 | 
        
           |  |  | 899 |         $requete = 'select ph_id_projet_fils from projet_hierarchie where ph_id_projet_pere='.$this->_id_projet ;
 | 
        
           |  |  | 900 |         $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 901 |         if (DB::isError ($resultat)) {
 | 
        
           |  |  | 902 |             die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
 | 
        
           |  |  | 903 |         }
 | 
        
           |  |  | 904 |         $tableau_resultat = array() ;
 | 
        
           |  |  | 905 |         while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
 | 
        
           |  |  | 906 |             array_push ($tableau_resultat, $ligne->ph_id_projet_fils) ;
 | 
        
           |  |  | 907 |         }
 | 
        
           |  |  | 908 |         return $tableau_resultat ;
 | 
        
           |  |  | 909 |     } // end of member function getHierarchie
 | 
        
           | 59 | ddelon | 910 |   | 
        
           | 2 | ddelon | 911 |     /**
 | 
        
           |  |  | 912 |      * Renvoie l'identifiant du pere du projet courrant.
 | 
        
           |  |  | 913 |      *
 | 
        
           |  |  | 914 |      * @return int
 | 
        
           |  |  | 915 |      * @access public
 | 
        
           |  |  | 916 |      */
 | 
        
           |  |  | 917 |     function getIdPere()
 | 
        
           |  |  | 918 |     {
 | 
        
           |  |  | 919 |         $requete = 'select ph_id_projet_pere from projet_hierarchie where ph_id_projet_fils='.$this->_id_projet ;
 | 
        
           |  |  | 920 |         $resultat = $this->_db->query ($requete) ;
 | 
        
           |  |  | 921 |         if (DB::isError ($resultat)) {
 | 
        
           |  |  | 922 |             die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
 | 
        
           |  |  | 923 |         }
 | 
        
           |  |  | 924 |         $tableau_resultat = array() ;
 | 
        
           |  |  | 925 |         $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
 | 
        
           |  |  | 926 |         return $ligne->ph_id_projet_pere ;
 | 
        
           |  |  | 927 |     } // end of member function getIdPere()
 | 
        
           |  |  | 928 |   | 
        
           |  |  | 929 |     /**
 | 
        
           | 288 | alexandre_ | 930 |      * Renvoie le nom Wiki du wikini associe au projet.
 | 
        
           | 2 | ddelon | 931 |      *
 | 
        
           |  |  | 932 |      * @return string
 | 
        
           |  |  | 933 |      * @access public
 | 
        
           |  |  | 934 |      */
 | 
        
           |  |  | 935 |     function getWikini( )
 | 
        
           |  |  | 936 |     {
 | 
        
           |  |  | 937 |         return $this->_nom_wikini ;
 | 
        
           |  |  | 938 |     } // end of member function getWikini
 | 
        
           |  |  | 939 |   | 
        
           | 11 | alexandre_ | 940 |     /**
 | 
        
           | 288 | alexandre_ | 941 |      * Renvoie le type du projet, ou zero si le projet n'a pas de type.
 | 
        
           | 11 | alexandre_ | 942 |      *
 | 
        
           |  |  | 943 |      * @return int
 | 
        
           |  |  | 944 |      * @access public
 | 
        
           |  |  | 945 |      */
 | 
        
           |  |  | 946 |     function getType( )
 | 
        
           |  |  | 947 |     {
 | 
        
           |  |  | 948 |         return $this->_type ;
 | 
        
           |  |  | 949 |     } // end of member function getType
 | 
        
           | 2 | ddelon | 950 |   | 
        
           | 288 | alexandre_ | 951 |     /**
 | 
        
           |  |  | 952 |      * Renvoie les themes du projet, ou zero si le projet n'a pas de type.
 | 
        
           |  |  | 953 |      *
 | 
        
           |  |  | 954 |      * @return int
 | 
        
           |  |  | 955 |      * @access public
 | 
        
           |  |  | 956 |      */
 | 
        
           |  |  | 957 |     function getThemes( )
 | 
        
           |  |  | 958 |     {
 | 
        
           |  |  | 959 |         return $this->_themes ;
 | 
        
           |  |  | 960 |     } // end of member function getType
 | 
        
           |  |  | 961 |   | 
        
           | 121 | alexandre_ | 962 | 	/**
 | 
        
           | 288 | alexandre_ | 963 |      * Renvoie 1 si les inscriptions au projet sont moderees.
 | 
        
           | 121 | alexandre_ | 964 |      *
 | 
        
           |  |  | 965 |      * @return int
 | 
        
           |  |  | 966 |      * @access public
 | 
        
           |  |  | 967 |      */
 | 
        
           |  |  | 968 |     function isModere( )
 | 
        
           |  |  | 969 |     {
 | 
        
           |  |  | 970 |         return $this->_isModere ;
 | 
        
           |  |  | 971 |     } // end of member function getType
 | 
        
           | 2 | ddelon | 972 |   | 
        
           |  |  | 973 |   | 
        
           |  |  | 974 |   | 
        
           |  |  | 975 |     /**
 | 
        
           | 288 | alexandre_ | 976 |      * initAttributes sets all projet attributes to its default value make
 | 
        
           | 2 | ddelon | 977 |      * sure to call this method within your class constructor
 | 
        
           |  |  | 978 |      */
 | 
        
           |  |  | 979 |     function initAttributes( )
 | 
        
           |  |  | 980 |     {
 | 
        
           |  |  | 981 |         $this->chemin_wikini = "projet/wikini/";
 | 
        
           |  |  | 982 |     }
 | 
        
           |  |  | 983 |   | 
        
           |  |  | 984 |   | 
        
           |  |  | 985 | } // end of projet
 | 
        
           |  |  | 986 | ?>
 |