Subversion Repositories Applications.projet

Compare Revisions

Ignore whitespace Rev 308 → Rev 309

/trunk/classes/document.class.php
19,7 → 19,7
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: document.class.php,v 1.8 2007-06-25 12:15:06 alexandre_tb Exp $
// CVS : $Id: document.class.php,v 1.9 2008-08-25 15:18:10 alexandre_tb Exp $
/**
* Application projet
*
31,7 → 31,7
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.8 $
*@version $Revision: 1.9 $
// +------------------------------------------------------------------------------------------------------+
*/
 
128,12 → 128,14
*/
function document( $id_document = "", &$objetDB, $chemin = '', $chemin_icones = '')
{
$this->_db = $objetDB ;
if (is_object($objetDB)) {
$GLOBALS['projet_db'] = $objetDB;
}
$this->_chemin_icone = $chemin_icones ;
if ($id_document != "") {
$requete = "select * from projet_documents where pd_id=".$id_document ;
$resultat = $this->_db->query ($requete) ;
$resultat = $GLOBALS['projet_db']->query ($requete) ;
if (DB::isError($resultat)) {
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
142,7 → 144,7
$this->nom_fichier = $ligne->pd_lien;
$this->_id_projet = $ligne->pd_ce_projet;
$this->_id = $ligne->pd_id ;
fichier::fichier($chemin.$this->getChemin(), $this->_db) ;
fichier::fichier($chemin.$this->getChemin(), $GLOBALS['projet_db']) ;
if (is_object ($this->_type_mime)) $this->_type_mime->setCheminIcone ($chemin_icones) ;
$this->_id_proprietaire = $ligne->pd_ce_utilisateur ;
281,7 → 283,7
{
if ($id_document) {
$requete = "select pd_pere from projet_documents where pd_id=".$id_document ;
$resultat = $this->_db->query ($requete) ;
$resultat = $GLOBALS['projet_db']->query ($requete) ;
if (DB::isError($resultat)) {
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
307,7 → 309,7
$chemin_repertoire_entre_racine_et_fichier = '';
 
include_once PROJET_CHEMIN_CLASSES.'projet.class.php';
$projet = new projet ($this->_db, $this->_id_projet);
$projet = new projet ($GLOBALS['projet_db'], $this->_id_projet);
// l arborescence des repertoires
$tableau_navigation = $this->getPath($this->_id) ;
364,7 → 366,7
$chemin_rep_id_nom = array() ;
if ($resultat->numRows()>0) {
if ($ligne->pd_pere == 0) {
return;
return array();
}
array_push ($chemin_rep_id_nom, $ligne->pd_pere) ;
$chemin_rep_id_nom = array_merge ($chemin_rep_id_nom, document::getPath($ligne->pd_pere) );
389,7 → 391,7
// des répertoires jusqu'à la racine, on enlève la racine ($i = 0) et on concatène
// toutes les entrées pour obtenir le chemin jusqu'au répertoire courant
$chemin_repertoire_entre_racine_et_repertoire_a_cree = '' ;
$doc_pere = new document ($this->_id_pere, $this->_db);
$doc_pere = new document ($this->_id_pere, $GLOBALS['projet_db']);
return $doc_pere->getChemin();
$tableau_navigation = $this->getPath($this->_id_pere) ;
421,7 → 423,7
// On prend le dernier élément du tableau, si c'est un tableau
if (is_array($tableau_nom)) {
$extension = array_pop($tableau_nom) ;
$type = type_fichier_mime::factory($extension, $this->_db) ;
$type = type_fichier_mime::factory($extension) ;
$id_extension = $type->getIdType() ;
} else {
$id_extension = 12 ;
436,14 → 438,14
// des répertoires jusqu'à la racine, on enlève la racine ($i = 0) et on concatène
// toutes les entrées pour obtenir le chemin jusqu'au répertoire courant
$chemin_repertoire_entre_racine_et_repertoire_a_cree = '' ;
$tableau_navigation = $this->getCheminIdRepertoire($this->_id_pere, $this->_db) ;
$tableau_navigation = $this->getCheminIdRepertoire($this->_id_pere, $GLOBALS['projet_db']) ;
for ($i = 0; $i < count ($tableau_navigation); $i+=2) $chemin_repertoire_entre_racine_et_repertoire_a_cree.= $tableau_navigation[$i]."/";
$pd_lien .= $chemin_repertoire_entre_racine_et_repertoire_a_cree ;
}
//$pd_lien .= SQL_obtenirNouveauId($this->_db, 'projet_documents', 'pd_id')."/" ;
$pd_lien = SQL_obtenirNouveauId($this->_db, 'projet_documents', 'pd_id')."/" ;
//$pd_lien .= SQL_obtenirNouveauId($GLOBALS['projet_db'], 'projet_documents', 'pd_id')."/" ;
$pd_lien = SQL_obtenirNouveauId($GLOBALS['projet_db'], 'projet_documents', 'pd_id')."/" ;
}
$id = SQL_obtenirNouveauId($this->_db, 'projet_documents', 'pd_id') ;
$id = SQL_obtenirNouveauId($GLOBALS['projet_db'], 'projet_documents', 'pd_id') ;
 
$requete = "insert into projet_documents set pd_id=".$id ;
$requete .= ", pd_nom=\"".$valeur['document_nom']."\", pd_description=\"".$valeur['document_description']."\"".
451,7 → 453,7
"pd_ce_projet=\"".$this->_id_projet."\", pd_ce_utilisateur=\"".$this->_id_proprietaire."\"".
", pd_pere=\"$this->_id_pere\", pd_ce_type=\"$id_extension\", pd_lien=\"$pd_lien\"" ;
 
$resultat = $this->_db->query ($requete) ;
$resultat = $GLOBALS['projet_db']->query ($requete) ;
if (DB::isError($resultat)) {
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
479,7 → 481,7
", pd_visibilite=\"".$valeur['document_visibilite']."\", pd_date_de_mise_a_jour=NOW()".
" where pd_id=".$this->_id;
 
$resultat = $this->_db->query ($requete) ;
$resultat = $GLOBALS['projet_db']->query ($requete) ;
if (DB::isError($resultat)) {
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
494,8 → 496,8
function suppressionSQL () {
$requete = 'delete from projet_documents where pd_id='.$this->_id ;
$resultat = $this->_db->query ($requete) ;
if ($this->_db->affectedRows()) return true ;
$resultat = $GLOBALS['projet_db']->query ($requete) ;
if ($GLOBALS['projet_db']->affectedRows()) return true ;
return false ;
}
511,19 → 513,19
 
// On récupère les informations du répertoire cible
if ($repertoire_destination != 0) {
$repertoire_cible = new document ($repertoire_destination, $this->_db) ;
$repertoire_cible = new document ($repertoire_destination, $GLOBALS['projet_db']) ;
$chemin_rep_cible = $repertoire_cible->getChemin();
} else {
// Si le repertoire destination est la racine cad id =0
// on cree un document qui aura pour chemin le repertoire du projet
include_once PROJET_CHEMIN_CLASSES.'projet.class.php';
$projet = new projet ($this->_db, $this->_id_projet);
$projet = new projet ($GLOBALS['projet_db'], $this->_id_projet);
$chemin_rep_cible = $projet->getNomRepertoire().'/';
}
$nom_fichier = $this->_pd_lien ;
$requete = 'update projet_documents set pd_pere='.$repertoire_destination.' where pd_id='.$this->_id ;
$resultat = $this->_db->query ($requete) ;
$resultat = $GLOBALS['projet_db']->query ($requete) ;
if (DB::isError($resultat)) {
echo ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
return false ;