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