Subversion Repositories Applications.projet

Rev

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

Rev Author Line No. Line
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
// +------------------------------------------------------------------------------------------------------+
121 alexandre_ 22
// CVS : $Id: projet.class.php,v 1.7 2006-07-04 09:28:53 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
121 alexandre_ 34
*@version       $Revision: 1.7 $
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
	/**
148
     * Indique si l'inscription au projet est modérés
149
     * @access private
150
     */
151
    var $_isModere;
152
 
2 ddelon 153
    /**
59 ddelon 154
     *
155
     * PHP5
2 ddelon 156
     * @return projet
157
     * @access public
158
     */
15 ddelon 159
    function __construct( &$dbObject,  $id_projet = "")
2 ddelon 160
    {
15 ddelon 161
      $this->projet($dbObject,  $id_projet);
59 ddelon 162
 
2 ddelon 163
    } // end of member function __construct
164
 
165
    /**
166
     *
59 ddelon 167
     *
2 ddelon 168
     * @param DB dbObject Un objet PEAR:DB
169
     * @param int id_projet On passe un identifiant de projet au constructeur. Cela lui permet de faire une
170
     * première requête pour les infos de bases comme le titre, le description etc.
171
     * @return projet
172
     * @access public
173
     */
174
    function projet( &$dbObject,  $id_projet = "")
175
    {
176
        $this->_db = $dbObject ;
177
        if ($id_projet != "") {
178
            $requete = "select * from projet where p_id=$id_projet" ;
179
            $resultat = $this->_db->query ($requete) ;
180
            if (DB::isError($resultat)) {
181
                die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
182
            }
183
            $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
59 ddelon 184
 
2 ddelon 185
            // Affectations dans les propriétés
186
            $this->_id_projet = $ligne->p_id ;
187
            $this->_titre = $ligne->p_titre ;
188
            $this->_description = $ligne->p_description ;
189
            $this->_espace_internet = $ligne->p_espace_internet ;
190
            $this->_date_creation = $ligne->p_date_creation ;
191
            $this->_nom_wikini = $ligne->p_wikini ;
192
            $this->_resume = $ligne->p_resume;
11 alexandre_ 193
            $this->_type = $ligne->p_type ;
2 ddelon 194
            // On récupère le nom du répertoire
195
            $this->_nom_repertoire = $ligne->p_nom_repertoire ;
121 alexandre_ 196
            $this->_isModere = $ligne->p_modere;
59 ddelon 197
 
2 ddelon 198
            // on regarde si on a à faire au projet racine
35 alexandre_ 199
            if (PROJET_UTILISE_HIERARCHIE) {
200
	            $requete = 'select  ph_id_projet_pere, ph_id_projet_fils from projet_hierarchie where ph_id_projet_fils='.$this->_id_projet ;
201
	            $resultat = $this->_db->query ($requete) ;
202
	            if (DB::isError ($resultat)) {
203
	                die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
204
	            }
205
	            if (!$resultat->numRows()) {
206
	                $this->_est_racine = true ;
207
	            } else {
208
	                $this->_est_racine = false ;
209
	            }
2 ddelon 210
            }
211
        }
212
    } // end of member function projet
213
 
214
    /**
215
     *
59 ddelon 216
     *
2 ddelon 217
     * @param DB dbObject Un objet PEAR:DB
218
     * @param int id_projet On passe un identifiant de projet au constructeur.
59 ddelon 219
     * @return bool
2 ddelon 220
     * @access public
221
     */
222
    function projetExiste( &$dbObject,  $id_projet)
223
    {
224
        if ($id_projet != "") {
225
            $requete = "select * from projet where p_id=$id_projet" ;
226
            $resultat = $dbObject->query ($requete) ;
227
            if (DB::isError($resultat)) {
228
                die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
229
            }
230
            if ($resultat->numRows() != 0) {
231
                return true ;
232
            }
233
        }
234
    } // end of member function projet
59 ddelon 235
 
2 ddelon 236
    /**
237
     *
59 ddelon 238
     *
239
     * @param int id_projet
2 ddelon 240
     * @return string
241
     * @access public
242
     */
243
    function getTitre( $id_projet = "" )
244
    {
245
        return $this->_titre ;
246
    } // end of member function getTitre
59 ddelon 247
 
2 ddelon 248
    /**
249
     *
59 ddelon 250
     *
2 ddelon 251
     * @return string
252
     * @access public
253
     */
254
    function getResume( )
255
    {
256
        return $this->_resume ;
257
    } // end of member function getResume
258
 
259
    /**
260
     * Renvoie l'identifiant du projet courant.
261
     *
262
     * @return int
263
     * @access public
264
     */
265
    function getId( )
266
    {
267
        return $this->_id_projet ;
268
    } // end of member function getId
269
 
270
    /**
271
     *
59 ddelon 272
     *
2 ddelon 273
     * @return string
274
     * @access public
275
     */
276
    function getDescription( )
277
    {
278
        return $this->_description;
279
    } // end of member function getDescription
280
 
281
    /**
282
     *
59 ddelon 283
     *
2 ddelon 284
     * @return string
285
     * @access public
286
     */
287
    function getEspaceInternet( )
288
    {
289
        return $this->_espace_internet;
290
    } // end of member function getEspaceInternet
291
 
292
    /**
293
     * Charge dans l'objet projet, les listes de discussion
294
     * ['nom_liste']
295
     * ['domaine']
296
     * ['adresse']
297
     *
298
     * @return boolean  true en cas de succès
299
     * @access public
300
     */
301
    function getListesAssociees( )
302
    {
303
        // On rajoute un test pour éviter l'appel SQL si il a déjà été fait une fois
304
        if (count($this->_listes_associes) > 0) return ;
305
        $requete = "select pl_id_liste from projet_lien_liste where pl_id_projet=".$this->_id_projet ;
306
        $resultat = $this->_db->query ($requete) ;
307
        if (DB::isError ($resultat)) {
308
            die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
309
        }
310
        $retour = array() ;
311
        if ($resultat->numRows()) {
312
            $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
313
            $this->_listes_associes[] = new liste_discussion($ligne->pl_id_liste, $this->_db) ;
59 ddelon 314
 
2 ddelon 315
        }
316
    } // end of member function getListesAssociees
317
 
318
    /**
319
     * Renvoie vrai si le projet a au moins une liste
320
     *
321
     * @return bool
322
     * @access public
323
     */
324
    function avoirListe( )
325
    {
326
        $this->getListesAssociees() ;
327
        if (count($this->_listes_associes)) {
328
            return true ;
329
        }
330
        return false ;
331
    } // end of member function isListeExiste
332
 
333
 
334
    /**
335
     * Renvoie la liste des documents associés sous forme d'un tableau, avec les
336
     * informations afférentes. 0 => "nom (cliquable)"
337
     "Taille"
338
     "Date
339
     * de création"          "Proriétaire"          "Visibilité"          "Action
340
     * (cliquable)"
341
     *
342
     * @param visibilite visibilite Si visibilite est à prive, tous les fichiers sont renvoyés ainsi qu'une entrée
59 ddelon 343
     * pour indiquer la visibilité du document.
2 ddelon 344
     * @return Array
345
     * @access public
346
     */
347
    function getListesDocuments( $chemin, $chemin_icones = "icones/" )
348
    {
349
        // On réalise une requete sur projet_documents avec une jointure sur l'annuaire
350
        // et sur gen_type_de_fichier pour envoyer un résultat complet.
351
        // On exclue les fichiers racines cad pd_pere is null
352
        $requete = "select pd_id from projet_documents where pd_ce_projet=".$this->_id_projet.' order by pd_nom' ;
353
        $resultat = $this->_db->query ($requete) ;
354
        if (DB::isError($resultat)) {
355
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
356
        }
357
        $tableau_document = array() ;
59 ddelon 358
 
2 ddelon 359
        // Un compteur
360
        $i = 0 ;
59 ddelon 361
 
2 ddelon 362
        while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) {
363
            array_push ($tableau_document, new document ($ligne->pd_id, &$this->_db, $chemin, $chemin_icones)) ;
364
        }
365
        return $tableau_document ;
366
    } // end of member function getListesDocuments
367
 
368
 
369
    /**
370
     * Renvoie un tableau avec tous les répertoires d'un projet, imbriqué. ['rep1'],
371
     * ['rep2'] => array (['rep21'], 	['rep22']), etc .
372
     *
373
     * @return Array
374
     * @access public
375
     */
376
    function getListeRepertoireHierarchisee( )
377
    {
378
        // On ne prend que les répertoires
379
        $requete = "select pd_id from projet_documents where pd_ce_projet=".$this->_id_projet.' and pd_ce_type=0 order by pd_nom' ;
380
        $resultat = $this->_db->query ($requete) ;
381
        if (DB::isError($resultat)) {
382
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
383
        }
384
        $tableau_document = array() ;
59 ddelon 385
 
2 ddelon 386
        while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) {
387
            array_push ($tableau_document, new document ($ligne->pd_id, $this->_db));
388
        }
59 ddelon 389
 
2 ddelon 390
        return $tableau_document ;
391
    } // end of member function getListeRepertoireHierarchisee
392
 
393
 
394
    /**
395
     * Renvoie un tableau comprenant tous les objets projet de la base.
396
     *
397
     * @return Array
398
     * @static
399
     * @access public
400
     */
401
    function getTousLesProjets(&$objetDB)
402
    {
403
        $requete = "select p_id from projet order by p_titre" ;
404
        $resultat = $objetDB->query ($requete) ;
405
        if (DB::isError($resultat)) {
406
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
407
        }
408
        $tableau_resultat = array() ;
409
        while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) {
410
            array_push ($tableau_resultat, new projet ($objetDB, $ligne->p_id)) ;
411
        }
412
        return $tableau_resultat ;
413
    } // end of member function getTousLesProjets
414
 
415
    /**
11 alexandre_ 416
     * Renvoie un tableau comprenant les objets projet de la base du type $type.
417
     *
418
     * @return Array
419
     * @static
420
     * @access public
421
     */
422
    function getProjetDuType($type, &$objetDB)
423
    {
424
        $requete = "select p_id from projet where p_type=$type order by p_titre" ;
425
        $resultat = $objetDB->query ($requete) ;
426
        if (DB::isError($resultat)) {
427
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
428
        }
429
        $tableau_resultat = array() ;
430
        while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) {
431
            array_push ($tableau_resultat, new projet ($objetDB, $ligne->p_id)) ;
432
        }
433
        return $tableau_resultat ;
434
    } // end of member function getTousLesProjets
435
 
436
    /**
437
     * Renvoie un le projet racine.
438
     *
439
     * @return projet
440
     * @static
441
     * @access public
442
     */
443
    function getProjetRacine(&$objetDB)
444
    {
445
        $requete = "select p_id from projet where p_id not in (select ph_id_projet_fils from projet_hierarchie)" ;
446
        $resultat = $objetDB->query ($requete) ;
447
        if (DB::isError($resultat)) {
448
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
449
        }
450
        if ($resultat->numRows() == 1) {
451
            $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
452
            return new projet($objetDB, $ligne->p_id) ;
453
        }
454
        $tableau_resultat = array() ;
455
        while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) {
456
            array_push ($tableau_resultat, new projet ($objetDB, $ligne->p_id)) ;
457
        }
458
        return $tableau_resultat ;
459
    } // end of member function getTousLesProjets
460
 
461
    /**
2 ddelon 462
     * Desctructeur de la classe. Libère la mémoire, ferme les connexions et fichiers.
463
     *
464
     * @return void
465
     * @access public
466
     */
467
    function __destruct( )
468
    {
59 ddelon 469
 
2 ddelon 470
    } // end of member function __destruct
471
 
472
    /**
473
     * Supprime le projet courrant. Il s'ensuit une suppression en cascade de tous les
474
     * éléments liés.
475
     *
476
     * @return void
477
     * @access public
478
     */
479
    function supprimer( )
480
    {
59 ddelon 481
 
2 ddelon 482
    } // end of member function supprimer
483
 
484
    /**
485
     * Permet d'enregistrer une ligne dans la table concernée.
486
     *
487
     * @param Array tableau_de_valeur Le tableau de valeur a insérer dans la base avec pour clé les noms des éléments
488
     * du formulaire.
489
     * @return int
490
     * @access public
491
     */
492
    function enregistrerSQL( $tableau_de_valeur )
493
    {
494
        $nom_repertoire = projet::genereNomRepertoire($tableau_de_valeur['projet_titre'], $this->_db) ;
495
        if (!$this->_creationRepertoire ($nom_repertoire)) {
11 alexandre_ 496
            echo 'Impossible de crée un répertoire'.$nom_repertoire ;
2 ddelon 497
            return false ;
498
        }
11 alexandre_ 499
        // Traitement du type
500
        if (!PROJET_UTILISE_TYPE) {
501
            $tableau_de_valeur['projet_type'] = 0 ;
502
        }
2 ddelon 503
        $id = SQL_obtenirNouveauId($this->_db, 'projet', 'p_id') ;
504
        $requete = 'insert into projet set p_id='.$id ;
15 ddelon 505
        if (!isset($tableau_de_valeur['projet_wikini'])) {
506
        	$tableau_de_valeur['projet_wikini']='';
507
        }
2 ddelon 508
        $requete .= ', p_titre="'.$tableau_de_valeur['projet_titre'].'", p_description="'.$tableau_de_valeur['projet_description'].'"'.
509
                    ', p_espace_internet="'.$tableau_de_valeur['projet_espace_internet'].'", p_date_creation=NOW()'.
11 alexandre_ 510
                    ', p_wikini="'.$tableau_de_valeur['projet_wikini'].'", p_nom_repertoire="'.$nom_repertoire.'", p_resume="'.$tableau_de_valeur['projet_resume'].
121 alexandre_ 511
                    '", p_type='.$tableau_de_valeur['projet_type'].', p_modere="'.$tableau_de_valeur['projet_moderation'].'"' ;
2 ddelon 512
        $resultat = $this->_db->query ($requete) ;
59 ddelon 513
 
2 ddelon 514
        if (DB::isError($resultat)) {
515
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
516
        }
59 ddelon 517
 
35 alexandre_ 518
        // On affecte à l'objet projet son identifiant
519
        $this->_id_projet = $id ;
59 ddelon 520
 
2 ddelon 521
        //insertion dans projet_hiérarchie
35 alexandre_ 522
		if (PROJET_UTILISE_HIERARCHIE) {
523
	        $requete = 'insert into projet_hierarchie set ph_id_projet_pere='.$tableau_de_valeur['projet_asso'].
524
	                    ', ph_id_projet_fils='.$id ;
525
	        $resultat = $this->_db->query ($requete) ;
526
		}
2 ddelon 527
        return true ;
528
    } // end of member function enregistrerSQL
529
 
530
    /**
531
     * Permet de mettre à jour une ligne dans la table concernée.
532
     *
533
     * @param Array tableau_de_valeur Le tableau de valeur a insérer dans la base avec pour clé les noms des éléments
534
     * du formulaire.
535
     * @return int
536
     * @access public
537
     */
538
    function majSQL( $tableau_de_valeur )
539
    {
11 alexandre_ 540
        // Traitement du type
541
        if (!PROJET_UTILISE_TYPE) {
542
            $tableau_de_valeur['projet_type'] = 0 ;
543
        }
2 ddelon 544
        $requete = 'update projet set ';
545
        $requete .= 'p_titre="'.$tableau_de_valeur['projet_titre'].'", p_description="'.$tableau_de_valeur['projet_description'].'"'.
546
                    ', p_espace_internet="'.$tableau_de_valeur['projet_espace_internet'].'"'.
11 alexandre_ 547
                    ', p_resume="'.$tableau_de_valeur['projet_resume'].'", p_type='.$tableau_de_valeur['projet_type'].
121 alexandre_ 548
                    ', p_modere='.$tableau_de_valeur['projet_moderation'].
2 ddelon 549
                    ' where p_id="'.$this->_id_projet.'"' ;
550
        $resultat = $this->_db->query ($requete) ;
551
        if (DB::isError($resultat)) {
552
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
553
        }
59 ddelon 554
 
35 alexandre_ 555
        if (PROJET_UTILISE_HIERARCHIE) {
556
	        // suppression dans projet_hierarchie
59 ddelon 557
 
35 alexandre_ 558
	        $requete = 'delete from projet_hierarchie where ph_id_projet_fils='.$this->_id_projet ;
559
	        $resultat = $this->_db->query ($requete) ;
59 ddelon 560
 
35 alexandre_ 561
	        //insertion dans projet_hiérarchie
59 ddelon 562
 
35 alexandre_ 563
	        $requete = 'insert into projet_hierarchie set ph_id_projet_pere='.$tableau_de_valeur['projet_asso'].
564
	                    ', ph_id_projet_fils='.$this->_id_projet ;
565
	        $resultat = $this->_db->query ($requete) ;
566
        }
2 ddelon 567
        return true ;
568
    } // end of member function enregistrerSQL
569
 
570
    /**
571
     * Met à jour dans la base de donnée le champs p_nom_wikini
572
     *
573
     * @param int nom_wikini Le nouveau nom wikini
574
     * @return bool
575
     * @access public
576
     */
577
    function majNomWikini( $nom_wikini )
578
    {
579
        $requete = 'update projet set p_wikini="'.$nom_wikini.'" where p_id="'.$this->_id_projet.'"' ;
580
        $resultat = $this->_db->query ($requete) ;
581
        if (DB::isError ($resultat)) {
582
            die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
583
        }
584
        return true ;
585
    } // end of member function majNomWikini
586
 
587
 
588
    /**
589
     *
59 ddelon 590
     *
591
     * @param string code_sql
2 ddelon 592
     * @return bool
593
     * @access public
594
     */
595
    function suppressionSQL()
596
    {
597
        $msg = '' ;
598
        // Supression du répertoire du projet
599
        if (!$this->_suppression_repertoire()) {
600
            $msg = 'La suppression du répertoire n\'a pas fonctionné' ;
601
        }
602
        // A ajouter la suppression des documents associés
59 ddelon 603
 
2 ddelon 604
        // La suppression des évènements associés
59 ddelon 605
 
2 ddelon 606
        // Le projet lui-même
607
        $requete = "delete from projet where p_id=".$this->_id_projet ;
608
        $resultat = $this->_db->query ($requete) ;
59 ddelon 609
 
35 alexandre_ 610
        if (PROJET_UTILISE_HIERARCHIE) {
611
	        $requete = "delete from projet_hierarchie where ph_id_projet_fils=".$this->_id_projet ;
612
	        $resultat = $this->_db->query ($requete) ;
613
        }
2 ddelon 614
        $requete = "delete from projet_statut_utilisateurs where psu_id_projet=".$this->_id_projet ;
615
        $resultat = $this->_db->query ($requete) ;
616
        return $msg ;
617
    } // end of member function suppressionSQL
618
 
619
    /**
620
     * Supprime le répertoire associé au projet (le répertoire doit être vide).
621
     *
622
     * @return void
623
     * @access private
624
     */
625
    function _suppression_repertoire( )
626
    {
627
        return rmdir ($this->_chemin_repertoire.$this->_nom_repertoire) ;
628
    } // end of member function _suppression_repertoire
629
 
630
    /**
631
     * Permet de créer le répertoire associé au projet.
632
     *
633
     * @param string nom_repertoire Le nom du répertoire à créer.
634
     * @return boolean
635
     * @access private
636
     */
637
    function _creationRepertoire( $nom_repertoire )
638
    {
639
        return mkdir ($this->_chemin_repertoire.$nom_repertoire) ;
640
    } // end of member function _creationRepertoire
641
 
642
    /**
643
     * Permet d'indiquer où seront stockés les fichiers.
644
     *
645
     * @param string cheminRepertoire Le chemin jusqu'au répertoire où seront stockés les fichiers.
646
     * @return void
647
     * @access public
648
     */
649
    function setCheminRepertoire( $cheminRepertoire )
650
    {
651
        $this->_chemin_repertoire = $cheminRepertoire ;
652
    } // end of member function setCheminRepertoire
653
 
654
    /**
655
     * Génère un nom de répertoire à partir de la première lettre de la chaine passé en
656
     * paramètre et de l'identifiant du dernier projet.
657
     *
658
     * @param string chaine Une chaine à partir de laquelle sera générer le nom du répertoire.
659
     * @param DB objetDB un objet PEAR::DB
660
     * @return string
661
     * @static
662
     * @access public
663
     */
664
    function genereNomRepertoire( $chaine, &$objetDB )
665
    {
666
        $requete = "select p_id from projet order by p_id desc limit 0,1" ;
667
        $resultat = $objetDB->query ($requete) ;
668
        if (DB::isError ($resultat)) {
669
            die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
670
        }
15 ddelon 671
        if ($resultat->numRows() > 0) {
672
	        $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
673
	        $nom = strtoupper(substr($chaine, 0, 1)) ;
674
	        $nom .= $ligne->p_id + 1 ;
675
        }
676
	    else {
677
	    	$nom = strtoupper(substr($chaine, 0, 1)) ;
678
	        $nom .=  1 ;
679
	    }
2 ddelon 680
        return $nom ;
59 ddelon 681
 
2 ddelon 682
    } // end of member function genereNomRepertoire
683
 
684
    /**
685
     * Permet de récupérer le nom du répertoire d'un projet.
686
     *
687
     * @return string
688
     * @access public
689
     */
690
    function getNomRepertoire( )
691
    {
692
        return $this->_nom_repertoire ;
693
    } // end of member function getNomRepertoire
694
 
695
    /**
696
     *  Ajoute une liste à un projet
697
     *  Effectue une insertion dans projet_lien_liste
698
     *
699
     * @param liste_discussion liste Une instance de la classe liste_discussion
700
     * @return void
701
     * @access public
702
     */
703
    function ajouterListe( &$liste )
704
    {
705
        $requete = "insert into projet_lien_liste set pl_id_liste=".$liste->getId().
706
                    ', pl_id_projet='.$this->_id_projet ;
707
        $resultat = $this->_db->query ($requete) ;
708
        if (DB::isError ($resultat)) {
709
            die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
710
        }
711
    } // end of member function ajouterListe
712
 
713
    /**
714
     * Supprime la liste de discussion associée au projet
715
     *
716
     * @return void
717
     * @access public
718
     */
719
    function supprimerListe(&$liste)
720
    {
721
        $requete = 'delete from projet_lien_liste where pl_id_liste='.$liste->getId() ;
722
        $resultat = $this->_db->query ($requete) ;
723
        if (DB::isError ($resultat)) {
724
            die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
725
        }
726
        $requete = 'delete from projet_liste where pl_id_liste='.$liste->getId() ;
727
        $resultat = $this->_db->query ($requete) ;
728
        if (DB::isError ($resultat)) {
729
            die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
730
        }
731
    } // end of member function supprimerListe
732
 
733
 
734
    /**
735
     * Renvoie vrai si le projet est racine.
736
     *
737
     * @return bool
738
     * @access public
739
     */
740
    function isRacine( )
741
    {
742
        return $this->_est_racine ;
743
    } // end of member function isRacine
744
 
745
    /**
746
     * Renvoie le nombre d'inscrits au projet. Effectue une requete dans la table
747
     * projet_statut_utilisateurs
748
     *
749
     * @return int
750
     * @access public
751
     */
752
    function getNombreInscrits( )
753
    {
754
        $requete = 'select count(psu_id_utilisateur) as nbre from projet_statut_utilisateurs where psu_id_projet='.$this->_id_projet ;
755
        $resultat = $this->_db->query ($requete) ;
756
        if (DB::isError ($resultat)) {
757
            die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
758
        }
759
        $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
760
        return $ligne->nbre ;
761
    } // end of member function getNombreInscrits
762
 
763
 
764
    /**
765
     * Renvoie un tableau contenant les identifiants des fils du projet courant.
766
     *
767
     * @return Array
768
     * @access public
769
     */
770
    function getHierarchie( )
771
    {
772
        $requete = 'select ph_id_projet_fils from projet_hierarchie where ph_id_projet_pere='.$this->_id_projet ;
773
        $resultat = $this->_db->query ($requete) ;
774
        if (DB::isError ($resultat)) {
775
            die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
776
        }
777
        $tableau_resultat = array() ;
778
        while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
779
            array_push ($tableau_resultat, $ligne->ph_id_projet_fils) ;
780
        }
781
        return $tableau_resultat ;
782
    } // end of member function getHierarchie
59 ddelon 783
 
2 ddelon 784
    /**
785
     * Renvoie l'identifiant du pere du projet courrant.
786
     *
787
     * @return int
788
     * @access public
789
     */
790
    function getIdPere()
791
    {
792
        $requete = 'select ph_id_projet_pere from projet_hierarchie where ph_id_projet_fils='.$this->_id_projet ;
793
        $resultat = $this->_db->query ($requete) ;
794
        if (DB::isError ($resultat)) {
795
            die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
796
        }
797
        $tableau_resultat = array() ;
798
        $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
799
        return $ligne->ph_id_projet_pere ;
800
    } // end of member function getIdPere()
801
 
802
    /**
803
     * Renvoie le nom Wiki du wikini associé au projet.
804
     *
805
     * @return string
806
     * @access public
807
     */
808
    function getWikini( )
809
    {
810
        return $this->_nom_wikini ;
811
    } // end of member function getWikini
812
 
11 alexandre_ 813
    /**
814
     * Renvoie le type du projet, ou zéro si le projet n'a pas de type.
815
     *
816
     * @return int
817
     * @access public
818
     */
819
    function getType( )
820
    {
821
        return $this->_type ;
822
    } // end of member function getType
2 ddelon 823
 
121 alexandre_ 824
	/**
825
     * Renvoie 1 si les inscriptions au projet sont modérées.
826
     *
827
     * @return int
828
     * @access public
829
     */
830
    function isModere( )
831
    {
832
        return $this->_isModere ;
833
    } // end of member function getType
2 ddelon 834
 
835
 
836
 
837
    /**
838
     * initAttributes sets all projet attributes to its default                    value make
839
     * sure to call this method within your class constructor
840
     */
841
    function initAttributes( )
842
    {
843
        $this->chemin_wikini = "projet/wikini/";
844
    }
845
 
846
 
847
} // end of projet
848
?>