Subversion Repositories Applications.projet

Rev

Rev 354 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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: ecouteArbreFichier.php,v 1.2 2007-06-25 12:15:06 alexandre_tb Exp $
23
/**
24
* Application projet
25
*
26
* Service d ecoute de l arbre du porte document, renvoie les donnees du repertoire demande
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-2005
34
*@version       $Revision: 1.2 $
35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
41
 
42
// ATTENTION - le programme suivant doit renvoyer un tableau, meme vide
43
// sinon l arbre dojo ne fonctionnera pas (ligne 117 $returnArray = array)
44
 
45
 
46
include_once (GEN_CHEMIN_API.'json/JSON.php');
47
 
48
$action = $_REQUEST["action"];
49
$data = $_REQUEST["data"];
50
$cache = $_REQUEST["dojo.preventCache"];
51
 
52
$data = str_replace("\\\"","\"",$data);
53
 
54
// instanciation d un json-php
55
 
56
$json = new services_JSON();
57
 
58
if ( $action == "getChildren") {
59
    $jsonData = $json->decode($data);
60
    // get the node object
61
    $node = $jsonData->node;
62
}
63
 
64
if ( $action == "getChildren") {
65
   $jsonData = $json->decode($data);
66
   // get the node object
67
   $node = $jsonData->node;
68
   // on recupere le noeud parent
69
   $parent = $node->objectId;
70
	if (isset($_REQUEST['id_projet'])) $id_projet = $_REQUEST['id_projet'];
71
	if (preg_match ('/projet_([0-9]+)/', $node->objectId, $match)) $id_projet = $match[1];
72
   // correspondance entre l objectid de dojo et id_parent de projet_document
73
   if ( $parent == "root" || preg_match ('/projet_([0-9]+)/', $node->objectId, $match)) {
74
    	$id_parent = 0 ;
75
   } else {
76
   		$id_parent = $node->objectId;
77
   }
78
	$sql = 'select * from projet_documents where pd_pere='.$id_parent ;
79
	if (isset($id_projet)) $sql .= ' and pd_ce_projet='.$id_projet.' and pd_visibilite="public"';
80
	$sql .= ' order by pd_nom';
81
   $resultat = $GLOBALS['projet_db']->query($sql);
82
 
83
   if (DB::isError($resultat)) {
84
        die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
85
   }
86
   $nodeArray = array();
87
   $i = 0;
88
 
89
   include_once PROJET_CHEMIN_CLASSES.'document.class.php';
90
 
91
   if ($GLOBALS['projet_auth']->getAuth() && is_object($this)) {
92
	    include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
93
	    $participant = new participe($GLOBALS['projet_db']) ;
94
	    $id_u = $GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID) ;
95
	    $isCoord = $participant->isCoordinateur($id_u, $this->_id_projet, $GLOBALS['projet_db']) ;
96
	    if ($isCoord) $droits = PROJET_DROIT_COORDINATEUR ;
97
	    $isAdm = participe::isAdministrateur($GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID), $GLOBALS['projet_db']) ;
98
	    if ($isAdm) $droits = PROJET_DROIT_ADMINISTRATEUR ;
99
	    if ($isAdm) $isCoord = true ;
100
	    $isParticipant = $participant->isContributeur($id_u, $this->_id_projet, $GLOBALS['projet_db']);
101
	    if ($isParticipant) $droits = PROJET_DROIT_CONTRIBUTEUR;
102
 
103
	    $statut = participe::getStatutSurProjetCourant ($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_id_projet, $this->_db) ;
104
	    // si participant, on ajoute le champs visibilite
105
   } else {
106
   	$droits = PROJET_DROIT_AUCUN;
107
   }
108
	// Recuperation de l'auteur
109
        include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
110
 
111
   while ( $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
112
       $document = new document($ligne['pd_id'], $GLOBALS['projet_db'], PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES);
113
		$GLOBALS['url']->addQueryString('id_projet', $id_projet);
114
		$GLOBALS['url']->addQueryString('id_document', $document->getIdDocument());
115
		$GLOBALS['url']->addQueryString(PROJET_VARIABLE_SERVICE, 'telechargement');
116
		// json attend de l utf8, en lui fournissant des donnees au format htmlentities,
117
		// ca passe
118
 
119
		$annuaire = new annuaire($objetDB, array('table' => PROJET_ANNUAIRE, 'identifiant' => PROJET_CHAMPS_ID,
120
                                    'nom' => PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ;
121
        $annuaire->setId($document->_id_proprietaire) ;
122
        $nom_prenom = $annuaire->getInfo('nom').' '.$annuaire->getInfo('prenom') ;
123
 
124
 
125
		// On regarde si l utilisateur a les droits pour deplacer
126
		if ($droits <= PROJET_DROIT_COORDINATEUR ||
127
			$GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID) == $document->_id_proprietaire) {
128
				$actions = 'MOVE,REMOVE,EDIT' ;
129
				if ($document->isRepertoire()) $actions .= ',ADDCHILD';
130
			}
131
				else $actions = '';
132
 
133
       $node = array(
134
          'title'=> iconv('ISO-8859-1', 'UTF-8', $document->getNomLong()),
135
          'widgetId' => 'document_'.$document->getIdDocument(),
136
          'objectId'=> $document->getIdDocument(),
137
          'isFolder'=> $document->isRepertoire(),
138
          'link' => str_replace ('&amp;', '&', $GLOBALS['url']->getURL()),
139
          'childIconSrc' => $document->getCheminIcone(),
140
          'expandIcon' => PROJET_CHEMIN_ICONES.'folder-expanded.gif',
141
          'afterLabel' => ' '.$document->getTailleFormatee().' '.iconv('ISO-8859-1', 'UTF-8',$nom_prenom),
142
       );
143
       // On regarde si l utilisateur a les droits pour deplacer
144
       /*
145
		if ($droits <= PROJET_DROIT_COORDINATEUR ||
146
			$GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID) == $document->_id_proprietaire) {
147
				$actions = 'MOVE,REMOVE,EDIT' ;
148
				if ($document->isRepertoire()) $actions .= ',ADDCHILD';
149
				$node['actions'] = $actions;
150
			}
151
				else {
152
					$node['actions'] = '';
153
 
154
				}*/
155
       $nodeArray[$i] = $node;
156
       $i++;
157
       unset ($document);
158
   }
159
   if (!is_null($nodeArray)) {
160
   	header ('Content-type: json');
161
   	print $json->encode($nodeArray);
162
   	exit();
163
   }
164
}
165
 
166
 
167
 
168
 
169
 
206 alexandre_ 170
?>