Subversion Repositories Applications.projet

Rev

Rev 263 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1                                                                                      |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or                                        |
// | modify it under the terms of the GNU General Public                                                  |
// | License as published by the Free Software Foundation; either                                         |
// | version 2.1 of the License, or (at your option) any later version.                                   |
// |                                                                                                      |
// | This library is distributed in the hope that it will be useful,                                      |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
// | General Public License for more details.                                                             |
// |                                                                                                      |
// | You should have received a copy of the GNU General Public                                            |
// | 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: documents.php,v 1.10 2007-10-02 09:24:53 alexandre_tb Exp $
/**
* Application projet
*
* Action documents
*
*@package projet
//Auteur original :
*@author        Alexandre Granier <alexandre@tela-botanica.org>
//Autres auteurs :
*@author        Aucun
*@copyright     Tela-Botanica 2000-2005
*@version       $Revision: 1.10 $
// +------------------------------------------------------------------------------------------------------+
*/

// +------------------------------------------------------------------------------------------------------+
// |                                            ENTETE du PROGRAMME                                       |
// +------------------------------------------------------------------------------------------------------+

// RAPPEL IMPORTANT
// On se situe dans la methode run() de la classe projetControleur
//
if (!isset($retour)) $retour = '';

// creation de l'objet projet courant
include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
$projet = new projet ($this->_db, $this->_id_projet) ;

// recuperation de la liste des documents associes
$liste_documents = $projet->getListesDocuments(PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES) ;

// creation de la vue liste de document, on nettoie l'url
//$this->_url->removeQueryString(PROJET_VARIABLE_ACTION) ;
include_once PROJET_CHEMIN_CLASSES.'AJAX_arbreDocuments.class.php' ;

$this->_url->addQueryString(PROJET_VARIABLE_ACTION, $this->_action) ;

$vue_liste_document = new AJAX_arbreDocuments($this->_url, false, $this->_id_repertoire, $this->_auth) ;

// reglage de parametres de la vue
$vue_liste_document->setAction (array ("couper" => PROJET_ACTION_COUPER, "modifier" => PROJET_ACTION_MODIFIER, "supprimer" => PROJET_SUPPRESSION_FICHIER)) ;
$vue_liste_document->setCheminIcones(PROJET_CHEMIN_ICONES) ;

$tableau_navigation = document::getCheminIdRepertoire($this->_id_repertoire, $this->_db) ;

$vue_liste_document->setCheminNavigation ($tableau_navigation) ;

// verification des droits de l'utilisateur
$entete_liste = array (PROJET_FICHIERS_NOM, PROJET_FICHIERS_TAILLE, PROJET_FICHIERS_PAR, PROJET_FICHIERS_CREE_LE) ;

if ($this->_auth->getAuth()) {
    include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
    $participant = new participe($this->_db) ;
    $id_u = $this->_auth->getAuthData(PROJET_CHAMPS_ID) ;
    $isParticipant = $participant->isContributeur($id_u, $this->_id_projet, $this->_db);
    if ($isParticipant) $droits = PROJET_DROIT_CONTRIBUTEUR;
    
    $isCoord = $participant->isCoordinateur($id_u, $this->_id_projet, $this->_db) ;
    if ($isCoord) $droits = PROJET_DROIT_COORDINATEUR ;
    $isAdm = participe::isAdministrateur($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_db) ;
    if ($isAdm) $droits = PROJET_DROIT_ADMINISTRATEUR ;

 
    $statut = participe::getStatutSurProjetCourant ($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_id_projet, $this->_db) ;
    // si participant, on ajoute le champs visibilite
    
    if ($statut !='' || $isAdm) {
        array_push ($entete_liste, PROJET_FICHIERS_VISIBILITE) ;
    }
    // si chef de projet ou si proprietaire d'au moins 1 document
    $proprietaire_un_document = false ;

    foreach ($liste_documents as $document) {
        if ($this->_auth->getAuthData(PROJET_CHAMPS_ID) == $document->_id_proprietaire) {
            $proprietaire_un_document = true ;
            $droits = PROJET_DROIT_PROPRIETAIRE ;
        }
    }
    if ($statut > 0 || $proprietaire_un_document) {
        array_push ($entete_liste, PROJET_ACTION) ;
    }
} else {
    $droits = PROJET_DROIT_AUCUN ;
}
if (!isset($droits)) $droits = PROJET_DROIT_AUCUN ;

$vue_liste_document->construitEntete($entete_liste) ;
$vue_liste_document->construitListe ($liste_documents, $droits, '', $this->_db) ;

$retour .= '<h1>'.PROJET_PROJET.' : '.$projet->getTitre()."</h1>" ;

$retour .= '<h2>'.PROJET_DOCUMENT_DU_PROJET.'</h2>'."\n" ;
// Les liens pour l affichage classique ou arborescent (avec dojo)
$this->_url->addQueryString('affichage', 'ajax');
$retour .= '<a href="'.$this->_url->getURL().'">'.PROJET_AFFICHAGE_ARBORESCENT.'</a>'."\n";
$this->_url->addQueryString('affichage', 'standart');
$retour .= '<a href="'.$this->_url->getURL().'">'.PROJET_AFFICHAGE_CLASSIQUE.'</a>'."\n";
$this->_url->removeQueryString('affichage');

$arbre = document::getArbreDocument($this->_id_projet) ;

$retour .= '<noscript>';
$vue_liste_document->setModeAffichage('standart');
$retour .= $vue_liste_document->toHTML('', '') ;
$retour .= '</noscript>';

if (!isset ($_SESSION['mode_affichage'])) {
        if (isset($_GET['affichage'])) $_SESSION['mode_affichage'] = $_GET['affichage']; else $_SESSION['mode_affichage'] = 'ajax';
} else {
        if (isset($_GET['affichage'])) $_SESSION['mode_affichage'] = $_GET['affichage'];
}
$vue_liste_document->setModeAffichage($_SESSION['mode_affichage']);

$retour .= $vue_liste_document->toHTML($projet->getId(), $droits);
$this->_url->removeQueryString(PROJET_VARIABLE_SERVICE);
?>