Subversion Repositories Applications.projet

Rev

Rev 201 | Rev 309 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 201 Rev 249
1
<?php
1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
3
// +------------------------------------------------------------------------------------------------------+
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU General Public                                                  |
9
// | modify it under the terms of the GNU General Public                                                  |
10
// | License as published by the Free Software Foundation; either                                         |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | General Public License for more details.                                                             |
16
// | General Public License for more details.                                                             |
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU General Public                                            |
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                                  |
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                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: document.class.php,v 1.7 2007-04-19 09:22:29 alexandre_tb Exp $
22
// CVS : $Id: document.class.php,v 1.8 2007-06-25 12:15:06 alexandre_tb Exp $
23
/**
23
/**
24
* Application projet
24
* Application projet
25
*
25
*
26
* La classe document
26
* La classe document
27
*
27
*
28
*@package projet
28
*@package projet
29
//Auteur original :
29
//Auteur original :
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
31
//Autres auteurs :
31
//Autres auteurs :
32
*@author        Aucun
32
*@author        Aucun
33
*@copyright     Tela-Botanica 2000-2004
33
*@copyright     Tela-Botanica 2000-2004
34
*@version       $Revision: 1.7 $
34
*@version       $Revision: 1.8 $
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
36
*/
36
*/
37
 
37
 
38
 
38
 
39
// +------------------------------------------------------------------------------------------------------+
39
// +------------------------------------------------------------------------------------------------------+
40
// |                                            ENTETE du PROGRAMME                                       |
40
// |                                            ENTETE du PROGRAMME                                       |
41
// +------------------------------------------------------------------------------------------------------+
41
// +------------------------------------------------------------------------------------------------------+
42
 
42
 
43
include_once PROJET_CHEMIN_CLASSES.'fichier.class.php' ;
43
include_once PROJET_CHEMIN_CLASSES.'fichier.class.php' ;
44
 
44
 
45
// +------------------------------------------------------------------------------------------------------+
45
// +------------------------------------------------------------------------------------------------------+
46
// |                                            ENTETE du PROGRAMME                                       |
46
// |                                            ENTETE du PROGRAMME                                       |
47
// +------------------------------------------------------------------------------------------------------+
47
// +------------------------------------------------------------------------------------------------------+
48
 
48
 
49
/**
49
/**
50
 * class document
50
 * class document
51
 * Représente un document associé à un projet. C'est à dire un fichier
51
 * Représente un document associé à un projet. C'est à dire un fichier
52
 * téléchargeable disposant en plus d'une visibilité, d'un nom long, d'une
52
 * téléchargeable disposant en plus d'une visibilité, d'un nom long, d'une
53
 * description et d'une url.
53
 * description et d'une url.
54
 */
54
 */
55
class document extends fichier
55
class document extends fichier
56
{
56
{
57
    /*** Attributes: ***/
57
    /*** Attributes: ***/
58
 
58
 
59
    /**
59
    /**
60
     * Description qui apparaitra à l'écran.
60
     * Description qui apparaitra à l'écran.
61
     * @access private
61
     * @access private
62
     */
62
     */
63
    var $_description;
63
    var $_description;
64
    /**
64
    /**
65
     * Date de dernière mise à jour des attributs du fichier.
65
     * Date de dernière mise à jour des attributs du fichier.
66
     * @access private
66
     * @access private
67
     */
67
     */
68
    var $_date_mise_a_jour;
68
    var $_date_mise_a_jour;
69
    /**
69
    /**
70
     * Soit public, soit privé.
70
     * Soit public, soit privé.
71
     * @access private
71
     * @access private
72
     */
72
     */
73
    var $_visibilite;
73
    var $_visibilite;
74
    /**
74
    /**
75
     * Le nom du fichier tel qu'il apparaitra à l'écran.
75
     * Le nom du fichier tel qu'il apparaitra à l'écran.
76
     * @access private
76
     * @access private
77
     */
77
     */
78
    var $_nom_long;
78
    var $_nom_long;
79
    /**
79
    /**
80
     * Un objet PEAR:DB
80
     * Un objet PEAR:DB
81
     * @access private
81
     * @access private
82
     */
82
     */
83
    var $_db;
83
    var $_db;
84
    
84
    
85
    /**
85
    /**
86
     * L'identifiant du document dans la table projet_document.
86
     * L'identifiant du document dans la table projet_document.
87
     * @access private
87
     * @access private
88
     */
88
     */
89
    var $_id;
89
    var $_id;
90
 
90
 
91
    /**
91
    /**
92
     * 
92
     * 
93
     * @access private
93
     * @access private
94
     */
94
     */
95
    var $_chemin_icone;
95
    var $_chemin_icone;
96
    
96
    
97
    /**
97
    /**
98
     * L'identifiant du père, peut être à NULL
98
     * L'identifiant du père, peut être à NULL
99
     * @access private
99
     * @access private
100
     */
100
     */
101
    var $_id_pere;
101
    var $_id_pere;
102
    
102
    
103
    /**
103
    /**
104
     * L'identifiant du propriétaire. Provient d'un annuaire. Peut être à NULL.
104
     * L'identifiant du propriétaire. Provient d'un annuaire. Peut être à NULL.
105
     * @access private
105
     * @access private
106
     */
106
     */
107
    var $_id_proprietaire;
107
    var $_id_proprietaire;
108
    /**
108
    /**
109
     * L'identifiant du projet auquel appartient le document. Peut être à NULL.
109
     * L'identifiant du projet auquel appartient le document. Peut être à NULL.
110
     * @access private
110
     * @access private
111
     */
111
     */
112
    var $_id_projet;
112
    var $_id_projet;
113
 
113
 
114
    /**
114
    /**
115
    *   Le chemin du fichier, depuis le répertoire du projet
115
    *   Le chemin du fichier, depuis le répertoire du projet
116
    *
116
    *
117
    */
117
    */
118
    var $_pd_lien ;
118
    var $_pd_lien ;
-
 
119
    
-
 
120
    var $nom_fichier ;
119
    /**
121
    /**
120
     * 
122
     * 
121
     *
123
     *
122
     * @param int id_document L'identifiant du document dans la base.
124
     * @param int id_document L'identifiant du document dans la base.
123
     * @param int objetDB un objet PEAR:DB
125
     * @param int objetDB un objet PEAR:DB
124
     * @return void
126
     * @return void
125
     * @access public
127
     * @access public
126
     */
128
     */
127
    function document( $id_document = "",  &$objetDB, $chemin = '', $chemin_icones = '')
129
    function document( $id_document = "",  &$objetDB, $chemin = '', $chemin_icones = '')
128
    {
130
    {
129
        $this->_db = $objetDB ;
131
        $this->_db = $objetDB ;
130
        $this->_chemin_icone = $chemin_icones ;
132
        $this->_chemin_icone = $chemin_icones ;
-
 
133
        
131
        if ($id_document != "") {
134
        if ($id_document != "") {
132
            $requete = "select * from projet_documents where pd_id=".$id_document ;
135
            $requete = "select * from projet_documents where pd_id=".$id_document ;
133
            $resultat = $this->_db->query ($requete) ;
136
            $resultat = $this->_db->query ($requete) ;
134
            if (DB::isError($resultat)) {
137
            if (DB::isError($resultat)) {
135
                die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
138
                die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
136
            }
139
            }
137
            $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
140
            $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
138
    		if ($resultat->numRows()>0) {
141
    		if ($resultat->numRows()>0) {
139
	            fichier::fichier($chemin.$ligne->pd_lien, $this->_db) ;
142
	            $this->nom_fichier = $ligne->pd_lien;
-
 
143
	            $this->_id_projet = $ligne->pd_ce_projet;
140
	            $this->_id = $ligne->pd_id ;
144
	            $this->_id = $ligne->pd_id ;
-
 
145
	            fichier::fichier($chemin.$this->getChemin(), $this->_db) ;
-
 
146
	            
141
	            if (is_object ($this->_type_mime)) $this->_type_mime->setCheminIcone ($chemin_icones) ;
147
	            if (is_object ($this->_type_mime)) $this->_type_mime->setCheminIcone ($chemin_icones) ;
142
	            $this->_id_proprietaire = $ligne->pd_ce_utilisateur ;
148
	            $this->_id_proprietaire = $ligne->pd_ce_utilisateur ;
143
	            $this->_nom_long = $ligne->pd_nom ;
149
	            $this->_nom_long = $ligne->pd_nom ;
144
	            $this->_visibilite = $ligne->pd_visibilite ;
150
	            $this->_visibilite = $ligne->pd_visibilite ;
145
	            $this->_date_mise_a_jour = $ligne->pd_date_de_mise_a_jour ;
151
	            $this->_date_mise_a_jour = $ligne->pd_date_de_mise_a_jour ;
146
	            $this->_description = $ligne->pd_description ;
152
	            $this->_description = $ligne->pd_description ;
147
	            $this->_pd_lien = $ligne->pd_lien;
153
	            $this->_pd_lien = $ligne->pd_lien;
-
 
154
	            
148
	            if ($this->_isRacine($ligne->pd_pere)) {
155
	            if ($this->_isRacine($ligne->pd_pere)) {
149
	                $this->_id_pere = 0 ;
156
	                $this->_id_pere = 0 ;
150
	            } else {
157
	            } else {
151
	                $this->_id_pere = $ligne->pd_pere ;
158
	                $this->_id_pere = $ligne->pd_pere ;
152
	            }
159
	            }
153
    		}
160
    		}
154
        }
161
        }
155
        
162
        
156
    } // end of member function document
163
    } // end of member function document
157
 
164
 
158
    /**
165
    /**
159
     * 
166
     * 
160
     *
167
     *
161
     * @param int id_document L'identifiant du document dans la base.
168
     * @param int id_document L'identifiant du document dans la base.
162
     * @param int objetDB Un objet PEAR:DB
169
     * @param int objetDB Un objet PEAR:DB
163
     * @return document
170
     * @return document
164
     * @access public
171
     * @access public
165
     */
172
     */
166
    function __construct( $id_document = "",  &$objetDB, $chemin = '', $chemin_icones = '' )
173
    function __construct( $id_document = "",  &$objetDB, $chemin = '', $chemin_icones = '' )
167
    {
174
    {
168
       
175
       
169
       $this->document($id_document, $objetDB, $chemin, $chemin_icones);
176
       $this->document($id_document, $objetDB, $chemin, $chemin_icones);
170
        
177
        
171
    } // end of member function __construct
178
    } // end of member function __construct
172
 
179
 
173
 
180
 
174
    /**
181
    /**
175
     * Renvoie le nom long du fichier.
182
     * Renvoie le nom long du fichier.
176
     *
183
     *
177
     * @return string
184
     * @return string
178
     * @access public
185
     * @access public
179
     */
186
     */
180
    function getNomLong( )
187
    function getNomLong( )
181
    {
188
    {
182
        return $this->_nom_long ;
189
        return $this->_nom_long ;
183
    } // end of member function getNomLong
190
    } // end of member function getNomLong
184
 
191
 
185
    /**
192
    /**
186
     * Renvoie la visibilité du document, soit "public" soit "prive"
193
     * Renvoie la visibilité du document, soit "public" soit "prive"
187
     *
194
     *
188
     * @return visibilite
195
     * @return visibilite
189
     * @access public
196
     * @access public
190
     */
197
     */
191
    function getVisibilite( )
198
    function getVisibilite( )
192
    {
199
    {
193
        return $this->_visibilite ;
200
        return $this->_visibilite ;
194
    } // end of member function getVisibilite
201
    } // end of member function getVisibilite
195
 
202
 
196
    /**
203
    /**
197
     * Renvoie la description du document, sous forme de chaine.
204
     * Renvoie la description du document, sous forme de chaine.
198
     *
205
     *
199
     * @return string
206
     * @return string
200
     * @access public
207
     * @access public
201
     */
208
     */
202
    function getDescription( )
209
    function getDescription( )
203
    {
210
    {
204
        return $this->_description ;
211
        return $this->_description ;
205
    } // end of member function getDescription
212
    } // end of member function getDescription
206
 
213
 
207
    /**
214
    /**
208
     * Renvoie la date de création ou de mise à jour du fichier.
215
     * Renvoie la date de création ou de mise à jour du fichier.
209
     *
216
     *
210
     * @return date
217
     * @return date
211
     * @access public
218
     * @access public
212
     */
219
     */
213
    function getDateMiseAJour( )
220
    function getDateMiseAJour( )
214
    {
221
    {
215
        return $this->_date_mise_a_jour ;
222
        return $this->_date_mise_a_jour ;
216
    } // end of member function getDateMiseAJour
223
    } // end of member function getDateMiseAJour
217
 
224
 
218
    /**
225
    /**
219
     * Renvoie l'identifiant d'un document.
226
     * Renvoie l'identifiant d'un document.
220
     *
227
     *
221
     * @return int
228
     * @return int
222
     * @access public
229
     * @access public
223
     */
230
     */
224
    function getIdDocument( )
231
    function getIdDocument( )
225
    {
232
    {
226
        return $this->_id ;
233
        return $this->_id ;
227
    } // end of member function getIdDocument
234
    } // end of member function getIdDocument
228
 
235
 
229
    /**
236
    /**
230
     * Renvoie le chemin de l'icone du fichier. Fait un appel à type_fichier_mime.
237
     * Renvoie le chemin de l'icone du fichier. Fait un appel à type_fichier_mime.
231
     *
238
     *
232
     * @return string
239
     * @return string
233
     * @access public
240
     * @access public
234
     */
241
     */
235
    function getCheminIcone()
242
    function getCheminIcone()
236
    {
243
    {
237
        if ($this->isRepertoire()) {
244
        if ($this->isRepertoire()) {
238
            return $this->_chemin_icone."repertoire.gif" ;
245
            return $this->_chemin_icone."repertoire.gif" ;
239
        } else {
246
        } else {
240
            return $this->_type_mime->getCheminIcone() ;
247
            if (is_object ($this->_type_mime)) return $this->_type_mime->getCheminIcone() ;
241
        }
248
        }
242
    } // end of member function getCheminIcone
249
    } // end of member function getCheminIcone
243
 
250
 
244
    /**
251
    /**
245
     * Permet de récupérer le nom du répertoire racine associé à un projet.
252
     * Permet de récupérer le nom du répertoire racine associé à un projet.
246
     *
253
     *
247
     * @param int id_projet L'identifiant du projet dont on veux récupérer le répertoire racine.
254
     * @param int id_projet L'identifiant du projet dont on veux récupérer le répertoire racine.
248
     * @param DB objetDB Un objet PEAR:DB
255
     * @param DB objetDB Un objet PEAR:DB
249
     * @return string
256
     * @return string
250
     * @static
257
     * @static
251
     * @access public
258
     * @access public
252
     */
259
     */
253
    function getNomRepertoireProjet( $id_projet , &$objetDB)
260
    function getNomRepertoireProjet( $id_projet , &$objetDB)
254
    {
261
    {
255
        // Dans la table projet_documents, pour les répertoires racines, pd_pere = null
262
        // Dans la table projet_documents, pour les répertoires racines, pd_pere = null
256
        $requete = "select pd_nom from projet_documents where pd_ce_projet=$id_projet and pd_pere is null" ;
263
        $requete = "select pd_nom from projet_documents where pd_ce_projet=$id_projet and pd_pere is null" ;
257
        $resultat = $objetDB->query ($requete) ;
264
        $resultat = $objetDB->query ($requete) ;
258
        if (DB::isError($resultat)) {
265
        if (DB::isError($resultat)) {
259
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
266
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
260
        }
267
        }
261
        $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
268
        $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
262
        return $ligne->pd_nom ;
269
        return $ligne->pd_nom ;
263
    } // end of member function getNomRepertoireProjet
270
    } // end of member function getNomRepertoireProjet
264
 
271
 
265
 
272
 
266
    /**
273
    /**
267
     * Renvoie true si le document passé en paramètre est le répertoire racine.
274
     * Renvoie true si le document passé en paramètre est le répertoire racine.
268
     *
275
     *
269
     * @param int id_document L'identifiant du document dont on veut savoir si c'est la racine.
276
     * @param int id_document L'identifiant du document dont on veut savoir si c'est la racine.
270
     * @return bool
277
     * @return bool
271
     * @access public
278
     * @access public
272
     */
279
     */
273
    function _isRacine( $id_document )
280
    function _isRacine( $id_document )
274
    {
281
    {
275
    	if ($id_document) {
282
    	if ($id_document) {
276
	        $requete = "select pd_pere from projet_documents where pd_id=".$id_document ;
283
	        $requete = "select pd_pere from projet_documents where pd_id=".$id_document ;
277
	        $resultat = $this->_db->query ($requete) ;
284
	        $resultat = $this->_db->query ($requete) ;
278
	        if (DB::isError($resultat)) {
285
	        if (DB::isError($resultat)) {
279
	            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
286
	            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
280
	        }
287
	        }
281
	        $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
288
	        $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
282
	        if ($resultat->numRows() >0) {
289
	        if ($resultat->numRows() >0) {
283
	        	if ($ligne->pd_pere == null){
290
	        	if ($ligne->pd_pere == null){
284
	            	return true ;
291
	            	return true ;
285
	        	}
292
	        	}
286
	        }
293
	        }
287
    	}
294
    	}
288
        return false ;
295
        return false ;
289
    } // end of member function _isRacine
296
    } // end of member function _isRacine
290
 
297
 
291
    /**
298
    /**
292
     * Renvoie le chemin d'un fichier ou d'un répertoire. Contrairement à la classe
299
     * Renvoie le chemin d'un fichier ou d'un répertoire. Contrairement à la classe
293
     * mère, cette méthode renvoie une URL projet et non pas un fichier.
300
     * mère, cette méthode renvoie une URL projet et non pas un fichier.
294
     *
301
     *
295
     * @return string
302
     * @return string
296
     * @access public
303
     * @access public
297
     */
304
     */
298
    function getChemin( )
305
    function getChemin($prefixe = '')
299
    {
306
    {
300
        if ($this->isRepertoire()) {
307
        $chemin_repertoire_entre_racine_et_fichier = '';
-
 
308
 
-
 
309
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php';
301
            return $this->_id ;
310
        $projet = new projet ($this->_db, $this->_id_projet);
302
        } else {
311
        // l arborescence des repertoires
-
 
312
        
303
            return $this->_chemin ;
313
        $tableau_navigation = $this->getPath($this->_id) ;
-
 
314
        if (is_array ($tableau_navigation))$tableau_navigation = array_reverse($tableau_navigation);
-
 
315
        for ($i = 0; $i < count ($tableau_navigation); $i++) {
-
 
316
        	$chemin_repertoire_entre_racine_et_fichier.= $tableau_navigation[$i]."/";	
304
        }
317
        }
305
    } // end of member function getChemin
318
        return $projet->getNomRepertoire().'/'.$chemin_repertoire_entre_racine_et_fichier.$this->nom_fichier ;
-
 
319
    } 
306
 
320
 
307
 
321
 
308
    /**
322
    /**
309
     * Renvoie pour le répertoire courant, les identifiants et les noms de tous les
323
     * Renvoie pour le repertoire ou le fichier courant, les identifiants et les noms de tous les
310
     * répertoires père jusqu'à la racine. 0 => ['id'], ['nom'] 1 => [id'], ['nom'] etc.
324
     * répertoires père jusqu'à la racine. 0 => ['id'], ['nom'] 1 => [id'], ['nom'] etc.
311
     * En commençant par la racine et en descendant.  Pour la racine id vaut "" et nom
325
     * En commençant par la racine et en descendant.  Pour la racine id vaut "" et nom
312
     * vaut "".
326
     * vaut "".
313
     *
327
     *
314
     * @param int id_repertoire L'identifiant d'un répertoire.
328
     * @param int id_repertoire L'identifiant d'un répertoire.
315
     * @return Array
329
     * @return Array
316
     * @access public
330
     * @access public
317
     */
331
     */
-
 
332
     
318
    function getCheminIdRepertoire( $id_repertoire, &$objetDB )
333
    function getCheminIdRepertoire( $id_doc, &$objetDB )
319
    {
334
    {
320
        if ($id_repertoire == "") $id_repertoire = 0;
335
        if ($id_doc == "") $id_doc = 0;
321
        // on commence par rechercher le répertoire père, dans la base de donnée
336
        // on commence par rechercher le répertoire père, dans la base de donnée
322
        $requete = "select pd_pere, pd_nom, pd_id from projet_documents where pd_id=$id_repertoire" ;
337
        $requete = 'select pd_pere, pd_nom, pd_id, pd_ce_type from projet_documents where pd_id='.$id_doc ;
323
        $resultat = $objetDB->query ($requete) ;
338
        $resultat = $objetDB->query ($requete) ;
324
        if (DB::isError($resultat)) {
339
        if (DB::isError($resultat)) {
325
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
340
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
326
        }
341
        }
327
        $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
342
        $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
328
        $chemin_rep_id_nom = array() ;
343
        $chemin_rep_id_nom = array() ;
329
        if ($resultat->numRows()>0) {
344
        if ($resultat->numRows()>0) {
330
    	    if ($ligne->pd_pere == 0) {
345
    	    if ($ligne->pd_pere == 0) {
331
        	    $tab = array ($ligne->pd_id, $ligne->pd_nom) ;
346
        	    return ; //array ($ligne->pd_pere);
332
            return $tab ;
-
 
333
        	} 
-
 
334
        	else {
-
 
335
	            $requete_pere = "select pd_id, pd_nom from projet_documents where pd_id=$ligne->pd_pere" ;
-
 
336
	            $resultat_pere = $objetDB->query ($requete_pere) ;
-
 
337
	            if (DB::isError($resultat_pere)) {
-
 
338
	                die ("Echec de la requete<br />".$resultat_pere->getMessage()."<br />".$resultat_pere->getDebugInfo()) ;
-
 
339
	            }
-
 
340
	            $ligne_pere = $resultat_pere->fetchRow (DB_FETCHMODE_OBJECT) ;
-
 
341
	            array_push ($chemin_rep_id_nom, $ligne->pd_id,$ligne->pd_nom) ;
-
 
342
	            $tab = document::getCheminIdRepertoire($ligne_pere->pd_id, $objetDB) ;
-
 
343
	            $chemin_rep_id_nom = array_merge ($chemin_rep_id_nom, $tab) ;
-
 
344
        	}
347
        	}
-
 
348
            array_push ($chemin_rep_id_nom, $ligne->pd_pere) ;
-
 
349
            $tab = document::getCheminIdRepertoire($ligne->pd_pere, $objetDB) ;
-
 
350
            $chemin_rep_id_nom = array_merge ($tab, $chemin_rep_id_nom) ;
345
        }
351
        }
346
        $tabl_resultat = array() ;
352
        return array_reverse($chemin_rep_id_nom);
-
 
353
    }
-
 
354
	function getPath( $id_doc)
-
 
355
    {
347
        for ($i = 0; $i < count ($chemin_rep_id_nom); $i++) {
356
        if ($id_doc == "") $id_doc = 0;
348
            $val1 = array_pop ($chemin_rep_id_nom) ;
357
        // on commence par rechercher le répertoire père, dans la base de donnée
-
 
358
        $requete = 'select pd_pere, pd_nom, pd_id, pd_ce_type from projet_documents where pd_id='.$id_doc ;
349
            $val2 = array_pop ($chemin_rep_id_nom) ;
359
        $resultat = $GLOBALS['projet_db']->query ($requete) ;
350
            array_push ($tabl_resultat, $val2, $val1) ;
360
        if (DB::isError($resultat)) {
-
 
361
            return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
351
        }
362
        }
-
 
363
        $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
-
 
364
        $chemin_rep_id_nom = array() ;
-
 
365
        if ($resultat->numRows()>0) {
-
 
366
    	    if ($ligne->pd_pere == 0) {
352
        return $tabl_resultat ;
367
        	    return;
-
 
368
        	}
-
 
369
            array_push ($chemin_rep_id_nom, $ligne->pd_pere) ;
-
 
370
            $chemin_rep_id_nom = array_merge ($chemin_rep_id_nom, document::getPath($ligne->pd_pere) );
-
 
371
        }
353
    } // end of member function getCheminIdRepertoire
372
        return $chemin_rep_id_nom;
354
 
373
    }
355
    /**
374
    /**
356
     *  Calcule le chemin vers le fichier ou le répertoire uploadé
375
     *  Calcule le chemin vers le fichier ou le répertoire uploadé
357
     *  renvoie un chaine de la forme dir1/dir2/fichier.ext
376
     *  renvoie un chaine de la forme dir1/dir2/fichier.ext
358
     *  En prenant comme racine le répertoire du projet, exclu.
377
     *  En prenant comme racine le répertoire du projet, exclu.
359
     * @return  string  Le chemin
378
     * @return  string  Le chemin
360
     */
379
     */
361
 
380
 
362
    function calculeCheminUploaded ($radical) {
381
    function calculeCheminUploaded ($radical) {
363
        // On recherche le chemin vers le fichier, en fonction du répertoire
-
 
364
        // ici on renomme le fichier à partir du dernier ID de la table gen_voiraussi
-
 
365
        $requete_document = "select pd_id from projet_documents order by pd_id desc limit 1,1" ;
-
 
366
        $resultat_document = $this->_db->query($requete_document) ;
-
 
367
        $ligne_document = $resultat_document->fetchRow(DB_FETCHMODE_OBJECT) ;
-
 
368
        $nouveau_nom = $ligne_document->pd_id + 1 ;
-
 
369
        
382
 
-
 
383
        if (isset($_FILES['fichier']['name'])) {
370
        $extension = preg_replace("/^([^\.]+)\.(\w+$)/", "\\2", $_FILES['fichier']['name']) ;
384
        	$extension = preg_replace("/^([^\.]+)\.(\w+$)/", "\\2", $_FILES['fichier']['name']) ;
-
 
385
        } 
371
        
386
 
372
        $nouveau_nom = $radical."_".$nouveau_nom.".".$extension ;
-
 
373
        if ($this->_id_pere != '') {
387
        if ($this->_id_pere != '') {
374
            // On appelle la méthode getCheminIdRepertoire qui renvoie un tableau avec la liste
388
            // On appelle la méthode getCheminIdRepertoire qui renvoie un tableau avec la liste
375
            // des répertoires jusqu'à la racine, on enlève la racine ($i = 0) et on concatène
389
            // des répertoires jusqu'à la racine, on enlève la racine ($i = 0) et on concatène
376
            // toutes les entrées pour obtenir le chemin jusqu'au répertoire courant
390
            // toutes les entrées pour obtenir le chemin jusqu'au répertoire courant
377
            $chemin_repertoire_entre_racine_et_repertoire_a_cree = '' ;
391
            $chemin_repertoire_entre_racine_et_repertoire_a_cree = '' ;
-
 
392
            $doc_pere = new document ($this->_id_pere, $this->_db);
-
 
393
            return $doc_pere->getChemin();
378
            $tableau_navigation = $this->getCheminIdRepertoire($this->_id_pere, $this->_db) ;
394
            $tableau_navigation = $this->getPath($this->_id_pere) ;
-
 
395
            
379
            for ($i = 0; $i < count ($tableau_navigation); $i+=2) $chemin_repertoire_entre_racine_et_repertoire_a_cree.= $tableau_navigation[$i]."/";
396
            for ($i = 0; $i < count ($tableau_navigation); $i++) $chemin_repertoire_entre_racine_et_repertoire_a_cree.= $tableau_navigation[$i]."/";
380
            $chemin = $chemin_repertoire_entre_racine_et_repertoire_a_cree.$nouveau_nom ;
397
            $chemin = $chemin_repertoire_entre_racine_et_repertoire_a_cree ;
381
        } else {
398
        } else {
382
            // Si l'on est à la racine du projet, le chemin est le nom du fichier
399
            // Si l'on est à la racine du projet, le chemin vide
383
            return $nouveau_nom ;
400
            return $radical ;
384
        }
401
        }
385
        return $chemin ;
402
        return $chemin ;
386
    }
403
    }
387
 
404
 
388
    /**
405
    /**
389
     * Enregistre une ligne dans la table projet_document
406
     * Enregistre une ligne dans la table projet_document
390
     * Le tableau de valeur doit contenir les éléments suivants 'document_nom','document_description','document_visibilite','fichier'
407
     * Le tableau de valeur doit contenir les éléments suivants 'document_nom','document_description','document_visibilite','fichier'
391
     *
408
     *
392
     * @param Array tableau_de_valeur Le tableau de valeur a insérer dans la base avec pour clé les noms des éléments
409
     * @param Array tableau_de_valeur Le tableau de valeur a insérer dans la base avec pour clé les noms des éléments
393
     * @access  public
410
     * @access  public
394
     * @return void
411
     * @return void
395
     */
412
     */
396
 
413
 
397
    function enregistrerSQL ($valeur, $chemin) {
414
    function enregistrerSQL ($valeur, $chemin) {
398
        
415
        
399
        // On teste si on a affaire à un répertoire ou un fichier
416
        // On teste si on a affaire à un répertoire ou un fichier
400
        if (isset ($_FILES['fichier']['name'])) {
417
        if (isset ($_FILES['fichier']['name'])) {
401
            // On tente de déterminer le type du fichier à partir de son nom dans $valeur['$fichier']
418
            // On tente de déterminer le type du fichier à partir de son nom dans $valeur['$fichier']
402
            $tableau_nom = explode (".", $_FILES['fichier']['name']) ;
419
            $tableau_nom = explode (".", $_FILES['fichier']['name']) ;
403
    
420
    
404
            // On prend le dernier élément du tableau, si c'est un tableau 
421
            // On prend le dernier élément du tableau, si c'est un tableau 
405
            if (is_array($tableau_nom)) {
422
            if (is_array($tableau_nom)) {
406
                $extension = array_pop($tableau_nom) ;
423
                $extension = array_pop($tableau_nom) ;
407
                $type = type_fichier_mime::factory($extension, $this->_db) ;
424
                $type = type_fichier_mime::factory($extension, $this->_db) ;
408
                $id_extension = $type->getIdType() ;
425
                $id_extension = $type->getIdType() ;
409
            } else {
426
            } else {
410
                $id_extension = 12 ;
427
                $id_extension = 12 ;
411
            }
428
            }
412
            $pd_lien = $chemin ;
429
            $pd_lien = $chemin ;
413
        } else {    // Le cas ou on a affaire à un répertoire
430
        } else {    // Le cas ou on a affaire à un répertoire
414
            $id_extension = 0 ;
431
            $id_extension = 0 ;
415
            // Le nom du répertoire est son identifiant avec un slash à la fin
432
            // Le nom du répertoire est son identifiant avec un slash à la fin
416
            $pd_lien = $chemin."/" ;
433
            $pd_lien = $chemin."/" ;
417
            if ($this->_id_pere != '') {
434
            if ($this->_id_pere != '') {
418
                // On appelle la méthode getCheminIdRepertoire qui renvoie un tableau avec la liste
435
                // On appelle la méthode getCheminIdRepertoire qui renvoie un tableau avec la liste
419
                // des répertoires jusqu'à la racine, on enlève la racine ($i = 0) et on concatène
436
                // des répertoires jusqu'à la racine, on enlève la racine ($i = 0) et on concatène
420
                // toutes les entrées pour obtenir le chemin jusqu'au répertoire courant
437
                // toutes les entrées pour obtenir le chemin jusqu'au répertoire courant
421
                $chemin_repertoire_entre_racine_et_repertoire_a_cree = '' ;
438
                $chemin_repertoire_entre_racine_et_repertoire_a_cree = '' ;
422
                $tableau_navigation = $this->getCheminIdRepertoire($this->_id_pere, $this->_db) ;
439
                $tableau_navigation = $this->getCheminIdRepertoire($this->_id_pere, $this->_db) ;
423
                for ($i = 0; $i < count ($tableau_navigation); $i+=2) $chemin_repertoire_entre_racine_et_repertoire_a_cree.= $tableau_navigation[$i]."/";
440
                for ($i = 0; $i < count ($tableau_navigation); $i+=2) $chemin_repertoire_entre_racine_et_repertoire_a_cree.= $tableau_navigation[$i]."/";
424
                $pd_lien .= $chemin_repertoire_entre_racine_et_repertoire_a_cree ;
441
                $pd_lien .= $chemin_repertoire_entre_racine_et_repertoire_a_cree ;
425
            }
442
            }
-
 
443
            //$pd_lien .= SQL_obtenirNouveauId($this->_db, 'projet_documents', 'pd_id')."/" ;
426
            $pd_lien .= SQL_obtenirNouveauId($this->_db, 'projet_documents', 'pd_id')."/" ;
444
            $pd_lien = SQL_obtenirNouveauId($this->_db, 'projet_documents', 'pd_id')."/" ;
427
        }
445
        }
428
        $id = SQL_obtenirNouveauId($this->_db, 'projet_documents', 'pd_id') ;
446
        $id = SQL_obtenirNouveauId($this->_db, 'projet_documents', 'pd_id') ;
429
 
447
 
430
        $requete = "insert into projet_documents set pd_id=".$id ;
448
        $requete = "insert into projet_documents set pd_id=".$id ;
431
        $requete .= ", pd_nom=\"".$valeur['document_nom']."\", pd_description=\"".$valeur['document_description']."\"".
449
        $requete .= ", pd_nom=\"".$valeur['document_nom']."\", pd_description=\"".$valeur['document_description']."\"".
432
                    ", pd_visibilite=\"".$valeur['document_visibilite']."\", pd_date_de_mise_a_jour=NOW(),".
450
                    ", pd_visibilite=\"".$valeur['document_visibilite']."\", pd_date_de_mise_a_jour=NOW(),".
433
                    "pd_ce_projet=\"".$this->_id_projet."\", pd_ce_utilisateur=\"".$this->_id_proprietaire."\"".
451
                    "pd_ce_projet=\"".$this->_id_projet."\", pd_ce_utilisateur=\"".$this->_id_proprietaire."\"".
434
                    ", pd_pere=\"$this->_id_pere\", pd_ce_type=\"$id_extension\", pd_lien=\"$pd_lien\"" ;
452
                    ", pd_pere=\"$this->_id_pere\", pd_ce_type=\"$id_extension\", pd_lien=\"$pd_lien\"" ;
435
 
453
 
436
        $resultat = $this->_db->query ($requete) ;
454
        $resultat = $this->_db->query ($requete) ;
437
        if (DB::isError($resultat)) {
455
        if (DB::isError($resultat)) {
438
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
456
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
439
        }
457
        }
440
        $this->_id = $id ;
458
        $this->_id = $id ;
441
        return $pd_lien;
459
        return $pd_lien;
442
    }
460
    }
-
 
461
 
-
 
462
	function genereNouveauNom ($radical, $ancien_nom, $id) {
-
 
463
		$extension = preg_replace("/^([^\.]+)\.(\w+$)/", "\\2", $ancien_nom) ;
-
 
464
        $nouveau_nom = $radical."_".$id.".".$extension ;
-
 
465
        return $nouveau_nom;
443
 
466
	}
444
 
467
 
445
    /**
468
    /**
446
     * Met à jour une ligne dans la table projet_document
469
     * Met à jour une ligne dans la table projet_document
447
     * Le tableau de valeur doit contenir les éléments suivants 'document_nom','document_description','document_visibilite','fichier'
470
     * Le tableau de valeur doit contenir les éléments suivants 'document_nom','document_description','document_visibilite','fichier'
448
     *
471
     *
449
     * @param Array tableau_de_valeur Le tableau de valeur a insérer dans la base avec pour clé les noms des éléments
472
     * @param Array tableau_de_valeur Le tableau de valeur a insérer dans la base avec pour clé les noms des éléments
450
     * @access  public
473
     * @access  public
451
     * @return void
474
     * @return void
452
     */
475
     */
453
 
476
 
454
    function majSQL ($valeur) {
477
    function majSQL ($valeur) {
455
        $requete = "update projet_documents set pd_nom=\"".$valeur['document_nom']."\", pd_description=\"".$valeur['document_description']."\"".
478
        $requete = "update projet_documents set pd_nom=\"".$valeur['document_nom']."\", pd_description=\"".$valeur['document_description']."\"".
456
                    ", pd_visibilite=\"".$valeur['document_visibilite']."\", pd_date_de_mise_a_jour=NOW()".
479
                    ", pd_visibilite=\"".$valeur['document_visibilite']."\", pd_date_de_mise_a_jour=NOW()".
457
                    " where pd_id=".$this->_id;
480
                    " where pd_id=".$this->_id;
458
 
481
 
459
        $resultat = $this->_db->query ($requete) ;
482
        $resultat = $this->_db->query ($requete) ;
460
        if (DB::isError($resultat)) {
483
        if (DB::isError($resultat)) {
461
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
484
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
462
        }
485
        }
463
        return ;
486
        return ;
464
    }
487
    }
465
 
488
 
466
    /** Supprime les donnéexs du document dans la table projet_documents
489
    /** Supprime les donnéexs du document dans la table projet_documents
467
     *
490
     *
468
     *
491
     *
469
     * @return true en cas de succès
492
     * @return true en cas de succès
470
     */
493
     */
471
    
494
    
472
    function suppressionSQL () {
495
    function suppressionSQL () {
473
        $requete = 'delete from projet_documents where pd_id='.$this->_id ;
496
        $requete = 'delete from projet_documents where pd_id='.$this->_id ;
474
        $resultat = $this->_db->query ($requete) ;
497
        $resultat = $this->_db->query ($requete) ;
475
        if ($this->_db->affectedRows()) return true ;
498
        if ($this->_db->affectedRows()) return true ;
476
        return false ;
499
        return false ;
477
    }
500
    }
478
    
501
    
479
    /**
502
    /**
480
     * Déplace un document au sein d'un même projet
503
     * Déplace un document au sein d'un même projet
481
     *
504
     *
482
     * @param int repertoire_destination L'identifiant du répertoire destination.
505
     * @param int repertoire_destination L'identifiant du répertoire destination.
483
     * @return bool
506
     * @return bool
484
     * @access public
507
     * @access public
485
     */
508
     */
486
    function deplace( $repertoire_destination, $repertoire_projet )
509
    function deplace( $repertoire_destination, $repertoire_projet )
487
    {
510
    {
-
 
511
 
488
        // On récupère les informations du répertoire cible
512
        // On récupère les informations du répertoire cible
489
        if ($repertoire_destination != 0) {
513
        if ($repertoire_destination != 0) {
490
            $repertoire_cible = new document ($repertoire_destination, $this->_db) ;
514
            $repertoire_cible = new document ($repertoire_destination, $this->_db) ;
491
            $rep = $repertoire_cible->_pd_lien ;
515
            $chemin_rep_cible = $repertoire_cible->getChemin();
492
        } else {
516
        } else {
-
 
517
        	// Si le repertoire destination est la racine cad id =0
-
 
518
        	// on cree un document qui aura pour chemin le repertoire du projet 
-
 
519
        	include_once PROJET_CHEMIN_CLASSES.'projet.class.php';
-
 
520
            $projet = new projet ($this->_db, $this->_id_projet);
493
            $rep = $repertoire_projet.'/' ;
521
        	$chemin_rep_cible = $projet->getNomRepertoire().'/';
494
        }
522
        }
495
        
523
   
496
        // On récupère le nom du fichier
-
 
497
        $decoupe = explode ('/', $this->_pd_lien) ;
524
        $nom_fichier = $this->_pd_lien ;
498
        $nom_fichier = $decoupe[count($decoupe)-1] ;
-
 
499
        $requete = 'update projet_documents set pd_lien="'.$rep.$nom_fichier.'", pd_pere='.$repertoire_destination.' where pd_id='.$this->_id ;
525
        $requete = 'update projet_documents set pd_pere='.$repertoire_destination.' where pd_id='.$this->_id ;
500
        $resultat = $this->_db->query ($requete) ;
526
        $resultat = $this->_db->query ($requete) ;
501
        if (DB::isError($resultat)) {
527
        if (DB::isError($resultat)) {
502
            echo ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
528
            echo ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
503
            return false ;
529
            return false ;
504
        }
530
        }
-
 
531
        //echo $this->_chemin.'<br>'.PROJET_CHEMIN_FICHIER.$chemin_rep_cible.$nom_fichier;
505
        return fichier::deplace ($this->_chemin, PROJET_CHEMIN_FICHIER.$rep.$nom_fichier) ;
532
        return fichier::deplace ($this->_chemin, PROJET_CHEMIN_FICHIER.$chemin_rep_cible.$nom_fichier) ;
506
        
533
        
507
    } // end of member function deplace
534
    } // end of member function deplace
508
 
535
 
509
 
536
 
510
    /**
537
    /**
511
     * Pour modifier l'identifiant du projet auquel appartient un document.
538
     * Pour modifier l'identifiant du projet auquel appartient un document.
512
     *
539
     *
513
     * @param int id_projet L'identifiant du projet.
540
     * @param int id_projet L'identifiant du projet.
514
     * @return void
541
     * @return void
515
     * @access public
542
     * @access public
516
     */
543
     */
517
    function setIdProjet( $id_projet )
544
    function setIdProjet( $id_projet )
518
    {
545
    {
519
        $this->_id_projet = $id_projet ;
546
        $this->_id_projet = $id_projet ;
520
    } // end of member function setIdProjet
547
    } // end of member function setIdProjet
521
 
548
 
522
    /**
549
    /**
523
     * Permet de modifier l'identifiant du propietaire d'un projet.
550
     * Permet de modifier l'identifiant du propietaire d'un projet.
524
     *
551
     *
525
     * @param int id_proprietaire L'identifiant du proprietaire d'un document.
552
     * @param int id_proprietaire L'identifiant du proprietaire d'un document.
526
     * @return void
553
     * @return void
527
     * @access public
554
     * @access public
528
     */
555
     */
529
    function setIdProprietaire( $id_proprietaire )
556
    function setIdProprietaire( $id_proprietaire )
530
    {
557
    {
531
        $this->_id_proprietaire = $id_proprietaire ;
558
        $this->_id_proprietaire = $id_proprietaire ;
532
    } // end of member function setIdProprietaire
559
    } // end of member function setIdProprietaire
533
 
560
 
534
    /**
561
    /**
535
     * Permet de modifier l'identifiant du répertoire d'un document.
562
     * Permet de modifier l'identifiant du répertoire d'un document.
536
     *
563
     *
537
     * @param int id_repertoire L'identifiant du repertoire d'un document.
564
     * @param int id_repertoire L'identifiant du repertoire d'un document.
538
     * @return void
565
     * @return void
539
     * @access public
566
     * @access public
540
     */
567
     */
541
    function setIdRepertoire( $id_repertoire )
568
    function setIdRepertoire( $id_repertoire )
542
    {
569
    {
543
        $this->_id_pere = $id_repertoire;
570
        $this->_id_pere = $id_repertoire;
544
    } // end of member function setIdRepertoire
571
    } // end of member function setIdRepertoire
545
 
572
 
546
    /**
573
    /**
547
     * initAttributes sets all document attributes to its default                    value make
574
     * initAttributes sets all document attributes to its default                    value make
548
     * sure to call this method within your class constructor
575
     * sure to call this method within your class constructor
549
     */
576
     */
550
    function initAttributes( )
577
    function initAttributes( )
551
    {
578
    {
552
        $this->_visibilite = "public";
579
        $this->_visibilite = "public";
553
    }
580
    }
554
 
581
 
555
    /**
582
    /**
556
     * Renvoie les derniers documents de l'ensemble des projets.
583
     * Renvoie les derniers documents de l'ensemble des projets.
557
     *
584
     *
558
     * @param int nombre Le nombre de document à renvoyer
585
     * @param int nombre Le nombre de document à renvoyer
559
     * @return Array
586
     * @return Array
560
     * @static
587
     * @static
561
     * @access public
588
     * @access public
562
     */
589
     */
563
    function getDocumentsRecents( $nombre = 10, &$objetDB, $chemin, $chemin_icones, $id_projet = '', $visible = true)
590
    function getDocumentsRecents( $nombre = 10, &$objetDB, $chemin, $chemin_icones, $id_projet = '', $visible = true)
564
    {
591
    {
565
        // on recherche les documents, hors repertoire
592
        // on recherche les documents, hors repertoire
566
        $requete = 'select pd_id from projet_documents where pd_ce_type<>0 ';
593
        $requete = 'select pd_id from projet_documents where pd_ce_type<>0 ';
567
        if ($id_projet != '') $requete .= ' and pd_ce_projet='.$id_projet.' ';
594
        if ($id_projet != '') $requete .= ' and pd_ce_projet='.$id_projet.' ';
568
        if (!$visible) $requete .= ' and pd_visibilite="public" ';
595
        if (!$visible) $requete .= ' and pd_visibilite="public" ';
569
        $requete .= 'order by pd_date_de_mise_a_jour desc limit 0,'.$nombre ;
596
        $requete .= 'order by pd_date_de_mise_a_jour desc limit 0,'.$nombre ;
570
        $resultat = $objetDB->query ($requete) ;
597
        $resultat = $objetDB->query ($requete) ;
571
        if (DB::isError ($resultat)) {
598
        if (DB::isError ($resultat)) {
572
            die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
599
            die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
573
        }
600
        }
574
        $tableau_document = array() ;
601
        $tableau_document = array() ;
575
        
602
        
576
        while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) {
603
        while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) {
577
            array_push ($tableau_document, new document ($ligne->pd_id, $objetDB, $chemin, $chemin_icones)) ;
604
            array_push ($tableau_document, new document ($ligne->pd_id, $objetDB, $chemin, $chemin_icones)) ;
578
        }
605
        }
579
        return $tableau_document ;
606
        return $tableau_document ;
580
    } // end of member function getDocumentsRecents
607
    } // end of member function getDocumentsRecents
581
 
608
 
582
    /**
609
    /**
583
     * Renvoie les documents du projet passe en parametre sous forme d arbre d objet document
610
     * Renvoie les documents du projet passe en parametre sous forme d arbre d objet document
584
     *
611
     *
585
     * @param int l identifiant du projet
612
     * @param int l identifiant du projet
586
     * @return Array
613
     * @return Array
587
     * @static
614
     * @static
588
     * @access public
615
     * @access public
589
     */
616
     */
590
	function getArbreDocument($id_projet, $objetDB = '') {
617
	function getArbreDocument($id_projet, $objetDB = '') {
591
		$requete = 'select pd_id, pd_nom, pd_ce_type, pd_pere from projet_documents where pd_ce_projet='.$id_projet;
618
		$requete = 'select pd_id, pd_nom, pd_ce_type, pd_pere from projet_documents where pd_ce_projet='.$id_projet;
592
		$resultat = $GLOBALS['projet_db']->getAll($requete, null, DB_FETCHMODE_OBJECT);
619
		$resultat = $GLOBALS['projet_db']->getAll($requete, null, DB_FETCHMODE_OBJECT);
593
		if (DB::isError ($resultat)) {
620
		if (DB::isError ($resultat)) {
594
            return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
621
            return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
595
        }
622
        }
596
	
623
	
597
      	return $resultat;
624
      	return $resultat;
598
	}
625
	}
599
	 /**
626
	 /**
600
     * Renvoie la taille du document formatee avec une unite adapte
627
     * Renvoie la taille du document formatee avec une unite adapte
601
     *
628
     *
602
     * @return string La taille formate
629
     * @return string La taille formate
603
     * @access public
630
     * @access public
604
     */
631
     */
605
	function getTailleFormatee($precision = 1) {
632
	function getTailleFormatee($precision = 1) {
606
		$taille = $this->getTaille();
633
		$taille = $this->getTaille();
607
		if ($taille > 1000000) {
634
		if ($taille > 1000000) {
608
			$diviseur = 1000000;
635
			$diviseur = 1000000;
609
			$unite = 'Mo';
636
			$unite = 'Mo';
610
		} else {
637
		} else {
611
			$diviseur = 1000 ;
638
			$diviseur = 1000 ;
612
			$unite = 'Ko';
639
			$unite = 'Ko';
613
		}
640
		}
614
		return round ($taille / $diviseur, $precision).'&nbsp;'.$unite;
641
		return round ($taille / $diviseur, $precision).'&nbsp;'.$unite;
615
	}
642
	}
-
 
643
	
-
 
644
	/**
-
 
645
     * Renvoie une liste de document, enfant du document courant
-
 
646
     * qui doit etre un repertoire bien sur
-
 
647
     *
-
 
648
     * @return mixed un tableau de document
-
 
649
     * @access public
-
 
650
     */
-
 
651
	function getDocumentsEnfant() {
-
 
652
		
-
 
653
	}
616
 
654
 
617
} // end of document
655
} // end of document
618
 
656
 
619
 
657
 
620
?>
658
?>