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