Subversion Repositories Applications.papyrus

Rev

Rev 465 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 465 Rev 474
Line 17... Line 17...
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.2 2005-09-26 20:18:27 ddelon Exp $
22
// CVS : $Id: document.class.php,v 1.3 2005-09-27 16:38:11 alexandre_tb Exp $
23
/**
23
/**
24
* Application projet
24
* Application projet
25
*
25
*
26
* La classe document
26
* La classe document
27
*
27
*
Line 29... Line 29...
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.2 $
34
*@version       $Revision: 1.3 $
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
36
*/
36
*/
Line 37... Line 37...
37
 
37
 
Line 133... Line 133...
133
            $resultat = $this->_db->query ($requete) ;
133
            $resultat = $this->_db->query ($requete) ;
134
            if (DB::isError($resultat)) {
134
            if (DB::isError($resultat)) {
135
                die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
135
                die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
136
            }
136
            }
137
            $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
137
            $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
138
    		if ($resultat->numRows()>0) {
-
 
-
 
138
    
139
	            fichier::fichier($chemin.$ligne->pd_lien, $this->_db) ;
139
            fichier::fichier($chemin.$ligne->pd_lien, $this->_db) ;
140
	            $this->_id = $ligne->pd_id ;
140
            $this->_id = $ligne->pd_id ;
141
	            if (is_object ($this->_type_mime)) $this->_type_mime->setCheminIcone ($chemin_icones) ;
141
            if (is_object ($this->_type_mime)) $this->_type_mime->setCheminIcone ($chemin_icones) ;
142
	            $this->_id_proprietaire = $ligne->pd_ce_utilisateur ;
142
            $this->_id_proprietaire = $ligne->pd_ce_utilisateur ;
143
	            $this->_nom_long = $ligne->pd_nom ;
143
            $this->_nom_long = $ligne->pd_nom ;
144
	            $this->_visibilite = $ligne->pd_visibilite ;
144
            $this->_visibilite = $ligne->pd_visibilite ;
145
	            $this->_date_mise_a_jour = $ligne->pd_date_de_mise_a_jour ;
145
            $this->_date_mise_a_jour = $ligne->pd_date_de_mise_a_jour ;
146
	            $this->_description = $ligne->pd_description ;
146
            $this->_description = $ligne->pd_description ;
147
	            $this->_pd_lien = $ligne->pd_lien;
147
            $this->_pd_lien = $ligne->pd_lien;
148
	            if ($this->_isRacine($ligne->pd_pere)) {
148
            if ($this->_isRacine($ligne->pd_pere)) {
149
	                $this->_id_pere = 0 ;
149
                $this->_id_pere = 0 ;
150
	            } else {
150
            } else {
151
	                $this->_id_pere = $ligne->pd_pere ;
151
                $this->_id_pere = $ligne->pd_pere ;
152
	            }
152
            }
153
    		}
-
 
154
        }
153
        }
Line 155... Line 154...
155
        
154
        
Line 156... Line 155...
156
    } // end of member function document
155
    } // end of member function document
Line 161... Line 160...
161
     * @param int id_document L'identifiant du document dans la base.
160
     * @param int id_document L'identifiant du document dans la base.
162
     * @param int objetDB Un objet PEAR:DB
161
     * @param int objetDB Un objet PEAR:DB
163
     * @return document
162
     * @return document
164
     * @access public
163
     * @access public
165
     */
164
     */
166
    function __construct( $id_document = "",  &$objetDB, $chemin = '', $chemin_icones = '' )
165
    function __construct( $id_document,  &$objetDB )
167
    {
166
    {
168
       
-
 
169
       $this->document($id_document, $objetDB, $chemin, $chemin_icones);
-
 
Line 170... Line 167...
170
        
167
        
Line 171... Line 168...
171
    } // end of member function __construct
168
    } // end of member function __construct
Line 270... Line 267...
270
     * @return bool
267
     * @return bool
271
     * @access public
268
     * @access public
272
     */
269
     */
273
    function _isRacine( $id_document )
270
    function _isRacine( $id_document )
274
    {
271
    {
275
    	if ($id_document) {
-
 
276
	        $requete = "select pd_pere from projet_documents where pd_id=".$id_document ;
272
        $requete = "select pd_pere from projet_documents where pd_id=$id_document" ;
277
	        $resultat = $this->_db->query ($requete) ;
273
        $resultat = $this->_db->query ($requete) ;
278
	        if (DB::isError($resultat)) {
274
        if (DB::isError($resultat)) {
279
	            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
275
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
280
	        }
276
        }
281
	        $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
277
        $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
282
	        if ($resultat->numRows() >0) {
-
 
283
	        	if ($ligne->pd_pere == null){
278
        if ($ligne->pd_pere == null){
284
	            	return true ;
279
            return true ;
285
	        	}
-
 
286
	        }
280
        }
287
    	}
-
 
288
        return false ;
281
        return false ;
289
    } // end of member function _isRacine
282
    } // end of member function _isRacine
Line 290... Line 283...
290
 
283
 
291
    /**
284
    /**
Line 324... Line 317...
324
        if (DB::isError($resultat)) {
317
        if (DB::isError($resultat)) {
325
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
318
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
326
        }
319
        }
327
        $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
320
        $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
328
        $chemin_rep_id_nom = array() ;
321
        $chemin_rep_id_nom = array() ;
329
        if ($resultat->numRows()>0) {
-
 
330
    	    if ($ligne->pd_pere == 0) {
322
        if ($ligne->pd_pere == 0) {
331
        	    $tab = array ($ligne->pd_id, $ligne->pd_nom) ;
323
            $tab = array ($ligne->pd_id, $ligne->pd_nom) ;
332
            return $tab ;
324
            return $tab ;
333
        	} 
-
 
334
        	else {
325
        } else {
335
	            $requete_pere = "select pd_id, pd_nom from projet_documents where pd_id=$ligne->pd_pere" ;
326
            $requete_pere = "select pd_id, pd_nom from projet_documents where pd_id=$ligne->pd_pere" ;
336
	            $resultat_pere = $objetDB->query ($requete_pere) ;
327
            $resultat_pere = $objetDB->query ($requete_pere) ;
337
	            if (DB::isError($resultat_pere)) {
328
            if (DB::isError($resultat_pere)) {
338
	                die ("Echec de la requete<br />".$resultat_pere->getMessage()."<br />".$resultat_pere->getDebugInfo()) ;
329
                die ("Echec de la requete<br />".$resultat_pere->getMessage()."<br />".$resultat_pere->getDebugInfo()) ;
339
	            }
330
            }
340
	            $ligne_pere = $resultat_pere->fetchRow (DB_FETCHMODE_OBJECT) ;
331
            $ligne_pere = $resultat_pere->fetchRow (DB_FETCHMODE_OBJECT) ;
341
	            array_push ($chemin_rep_id_nom, $ligne->pd_id,$ligne->pd_nom) ;
332
            array_push ($chemin_rep_id_nom, $ligne->pd_id,$ligne->pd_nom) ;
342
	            $tab = document::getCheminIdRepertoire($ligne_pere->pd_id, $objetDB) ;
333
            $tab = document::getCheminIdRepertoire($ligne_pere->pd_id, $objetDB) ;
343
	            $chemin_rep_id_nom = array_merge ($chemin_rep_id_nom, $tab) ;
334
            $chemin_rep_id_nom = array_merge ($chemin_rep_id_nom, $tab) ;
344
        	}
-
 
345
        }
335
        }
346
        $tabl_resultat = array() ;
336
        $tabl_resultat = array() ;
347
        for ($i = 0; $i < count ($chemin_rep_id_nom); $i++) {
337
        for ($i = 0; $i < count ($chemin_rep_id_nom); $i++) {
348
            $val1 = array_pop ($chemin_rep_id_nom) ;
338
            $val1 = array_pop ($chemin_rep_id_nom) ;
349
            $val2 = array_pop ($chemin_rep_id_nom) ;
339
            $val2 = array_pop ($chemin_rep_id_nom) ;