Subversion Repositories Applications.projet

Rev

Rev 354 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 354 Rev 431
1
<?php
1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
3
// +------------------------------------------------------------------------------------------------------+
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU General Public                                                  |
9
// | modify it under the terms of the GNU General Public                                                  |
10
// | License as published by the Free Software Foundation; either                                         |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | General Public License for more details.                                                             |
16
// | General Public License for more details.                                                             |
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU General Public                                            |
18
// | You should have received a copy of the GNU General Public                                            |
19
// | License along with this library; if not, write to the Free Software                                  |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: ecouteArbreFichier.php,v 1.3 2008-10-29 15:53:06 alexandre_tb Exp $
22
// CVS : $Id: ecouteArbreFichier.php,v 1.2 2007-06-25 12:15:06 alexandre_tb Exp $
23
/**
23
/**
24
* Application projet
24
* Application projet
25
*
25
*
26
* Service d ecoute de l arbre du porte document, renvoie les donnees du repertoire demande
26
* Service d ecoute de l arbre du porte document, renvoie les donnees du repertoire demande
27
*
27
*
28
*@package projet
28
*@package projet
29
//Auteur original :
29
//Auteur original :
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
31
//Autres auteurs :
31
//Autres auteurs :
32
*@author        Aucun
32
*@author        Aucun
33
*@copyright     Tela-Botanica 2000-2005
33
*@copyright     Tela-Botanica 2000-2005
34
*@version       $Revision: 1.3 $
34
*@version       $Revision: 1.2 $
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
36
*/
36
*/
37
 
37
 
38
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
40
// +------------------------------------------------------------------------------------------------------+
41
 
41
 
42
// ATTENTION - le programme suivant doit renvoyer un tableau, meme vide
42
// ATTENTION - le programme suivant doit renvoyer un tableau, meme vide
43
// sinon l arbre dojo ne fonctionnera pas (ligne 117 $returnArray = array)
43
// sinon l arbre dojo ne fonctionnera pas (ligne 117 $returnArray = array)
44
 
44
 
45
 
45
 
46
include_once (GEN_CHEMIN_API.'json/JSON.php');
46
include_once (GEN_CHEMIN_API.'json/JSON.php');
47
 
47
 
48
$action = $_REQUEST["action"];
48
$action = $_REQUEST["action"];
49
$data = $_REQUEST["data"];
49
$data = $_REQUEST["data"];
50
$cache = $_REQUEST["dojo.preventCache"];
50
$cache = $_REQUEST["dojo.preventCache"];
51
 
51
 
52
$data = str_replace("\\\"","\"",$data);
52
$data = str_replace("\\\"","\"",$data);
53
 
53
 
54
// instanciation d un json-php
54
// instanciation d un json-php
55
 
55
 
56
$json = new services_JSON();
56
$json = new services_JSON();
57
 
57
 
58
if ( $action == "getChildren") {
58
if ( $action == "getChildren") {
59
    $jsonData = $json->decode($data);
59
    $jsonData = $json->decode($data);
60
    // get the node object
60
    // get the node object
61
    $node = $jsonData->node;
61
    $node = $jsonData->node;
62
}
62
}
63
 
63
 
64
if ( $action == "getChildren") {
64
if ( $action == "getChildren") {
65
   $jsonData = $json->decode($data);
65
   $jsonData = $json->decode($data);
66
   // get the node object
66
   // get the node object
67
   $node = $jsonData->node;
67
   $node = $jsonData->node;
68
   // on recupere le noeud parent
68
   // on recupere le noeud parent
69
   $parent = $node->objectId;
69
   $parent = $node->objectId;
70
	if (isset($_REQUEST['id_projet'])) $id_projet = $_REQUEST['id_projet'];
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];
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
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)) {
73
   if ( $parent == "root" || preg_match ('/projet_([0-9]+)/', $node->objectId, $match)) {
74
    	$id_parent = 0 ;
74
    	$id_parent = 0 ;
75
   } else {
75
   } else {
76
   		$id_parent = $node->objectId;
76
   		$id_parent = $node->objectId;
77
   }
77
   }
78
	$sql = 'select * from projet_documents where pd_pere='.$id_parent ;
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"';
79
	if (isset($id_projet)) $sql .= ' and pd_ce_projet='.$id_projet.' and pd_visibilite="public"';
80
	$sql .= ' order by pd_nom';
80
	$sql .= ' order by pd_nom';
81
   $resultat = $GLOBALS['projet_db']->query($sql);
81
   $resultat = $GLOBALS['projet_db']->query($sql);
82
 
82
 
83
   if (DB::isError($resultat)) {
83
   if (DB::isError($resultat)) {
84
        die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
84
        die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
85
   }
85
   }
86
   $nodeArray = array();
86
   $nodeArray = array();
87
   $i = 0;
87
   $i = 0;
88
   
88
   
89
   include_once PROJET_CHEMIN_CLASSES.'document.class.php';
89
   include_once PROJET_CHEMIN_CLASSES.'document.class.php';
90
   
90
   
91
   if ($GLOBALS['projet_auth']->getAuth() && is_object($this)) {
91
   if ($GLOBALS['projet_auth']->getAuth() && is_object($this)) {
92
	    include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
92
	    include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
93
	    $participant = new participe($GLOBALS['projet_db']) ;
93
	    $participant = new participe($GLOBALS['projet_db']) ;
94
	    $id_u = $GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID) ;
94
	    $id_u = $GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID) ;
95
	    $isCoord = $participant->isCoordinateur($id_u, $this->_id_projet, $GLOBALS['projet_db']) ;
95
	    $isCoord = $participant->isCoordinateur($id_u, $this->_id_projet, $GLOBALS['projet_db']) ;
96
	    if ($isCoord) $droits = PROJET_DROIT_COORDINATEUR ;
96
	    if ($isCoord) $droits = PROJET_DROIT_COORDINATEUR ;
97
	    $isAdm = participe::isAdministrateur($GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID), $GLOBALS['projet_db']) ;
97
	    $isAdm = participe::isAdministrateur($GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID), $GLOBALS['projet_db']) ;
98
	    if ($isAdm) $droits = PROJET_DROIT_ADMINISTRATEUR ;
98
	    if ($isAdm) $droits = PROJET_DROIT_ADMINISTRATEUR ;
99
	    if ($isAdm) $isCoord = true ;
99
	    if ($isAdm) $isCoord = true ;
100
	    $isParticipant = $participant->isContributeur($id_u, $this->_id_projet, $GLOBALS['projet_db']);
100
	    $isParticipant = $participant->isContributeur($id_u, $this->_id_projet, $GLOBALS['projet_db']);
101
	    if ($isParticipant) $droits = PROJET_DROIT_CONTRIBUTEUR;
101
	    if ($isParticipant) $droits = PROJET_DROIT_CONTRIBUTEUR;
102
	    
102
	    
103
	    $statut = participe::getStatutSurProjetCourant ($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_id_projet, $this->_db) ;
103
	    $statut = participe::getStatutSurProjetCourant ($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_id_projet, $this->_db) ;
104
	    // si participant, on ajoute le champs visibilite
104
	    // si participant, on ajoute le champs visibilite
105
   } else {
105
   } else {
106
   	$droits = PROJET_DROIT_AUCUN;
106
   	$droits = PROJET_DROIT_AUCUN;
107
   }
107
   }
108
	// Recuperation de l'auteur
108
	// Recuperation de l'auteur
109
        include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
109
        include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
110
        
110
        
111
   while ( $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
111
   while ( $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
112
       $document = new document($ligne['pd_id'], $GLOBALS['projet_db'], PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES);
112
       $document = new document($ligne['pd_id'], $GLOBALS['projet_db'], PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES);
113
		$GLOBALS['url']->addQueryString('id_projet', $id_projet);
113
		$GLOBALS['url']->addQueryString('id_projet', $id_projet);
114
		$GLOBALS['url']->addQueryString('id_document', $document->getIdDocument());
114
		$GLOBALS['url']->addQueryString('id_document', $document->getIdDocument());
115
		$GLOBALS['url']->addQueryString(PROJET_VARIABLE_SERVICE, 'telechargement');
115
		$GLOBALS['url']->addQueryString(PROJET_VARIABLE_SERVICE, 'telechargement');
116
		// json attend de l utf8, en lui fournissant des donnees au format htmlentities,
116
		// json attend de l utf8, en lui fournissant des donnees au format htmlentities,
117
		// ca passe
117
		// ca passe
118
		
118
		
119
		$annuaire = new annuaire($objetDB, array('table' => PROJET_ANNUAIRE, 'identifiant' => PROJET_CHAMPS_ID, 
119
		$annuaire = new annuaire($objetDB, array('table' => PROJET_ANNUAIRE, 'identifiant' => PROJET_CHAMPS_ID, 
120
                                    'nom' => PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ;
120
                                    'nom' => PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ;
121
        $annuaire->setId($document->_id_proprietaire) ;
121
        $annuaire->setId($document->_id_proprietaire) ;
122
        $nom_prenom = $annuaire->getInfo('nom').' '.$annuaire->getInfo('prenom') ;
122
        $nom_prenom = $annuaire->getInfo('nom').' '.$annuaire->getInfo('prenom') ;
123
        
123
        
124
        
124
        
125
		// On regarde si l utilisateur a les droits pour deplacer
125
		// On regarde si l utilisateur a les droits pour deplacer
126
		if ($droits <= PROJET_DROIT_COORDINATEUR || 
126
		if ($droits <= PROJET_DROIT_COORDINATEUR || 
127
			$GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID) == $document->_id_proprietaire) {
127
			$GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID) == $document->_id_proprietaire) {
128
				$actions = 'MOVE,REMOVE,EDIT' ;
128
				$actions = 'MOVE,REMOVE,EDIT' ;
129
				if ($document->isRepertoire()) $actions .= ',ADDCHILD';	
129
				if ($document->isRepertoire()) $actions .= ',ADDCHILD';	
130
			} 
130
			} 
131
				else $actions = '';
131
				else $actions = '';
132
		
132
		
133
       $node = array(
133
       $node = array(
134
          'title'=> iconv('ISO-8859-1', 'UTF-8', $document->getNomLong()),
134
          'title'=> iconv('ISO-8859-1', 'UTF-8', $document->getNomLong()),
135
          'widgetId' => 'document_'.$document->getIdDocument(),
135
          'widgetId' => 'document_'.$document->getIdDocument(),
136
          'objectId'=> $document->getIdDocument(),
136
          'objectId'=> $document->getIdDocument(),
137
          'isFolder'=> $document->isRepertoire(),
137
          'isFolder'=> $document->isRepertoire(),
138
          'link' => str_replace ('&amp;', '&', $GLOBALS['url']->getURL()),
138
          'link' => str_replace ('&amp;', '&', $GLOBALS['url']->getURL()),
139
          'childIconSrc' => $document->getCheminIcone(),
139
          'childIconSrc' => $document->getCheminIcone(),
140
          'expandIcon' => PROJET_CHEMIN_ICONES.'folder-expanded.gif',
140
          'expandIcon' => PROJET_CHEMIN_ICONES.'folder-expanded.gif',
141
          'afterLabel' => ' '.$document->getTailleFormatee().' '.iconv('ISO-8859-1', 'UTF-8',$nom_prenom),
141
          'afterLabel' => ' '.$document->getTailleFormatee().' '.iconv('ISO-8859-1', 'UTF-8',$nom_prenom),
142
       );
142
       );
143
       // On regarde si l utilisateur a les droits pour deplacer
143
       // On regarde si l utilisateur a les droits pour deplacer
144
       /*
144
       /*
145
		if ($droits <= PROJET_DROIT_COORDINATEUR || 
145
		if ($droits <= PROJET_DROIT_COORDINATEUR || 
146
			$GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID) == $document->_id_proprietaire) {
146
			$GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID) == $document->_id_proprietaire) {
147
				$actions = 'MOVE,REMOVE,EDIT' ;
147
				$actions = 'MOVE,REMOVE,EDIT' ;
148
				if ($document->isRepertoire()) $actions .= ',ADDCHILD';	
148
				if ($document->isRepertoire()) $actions .= ',ADDCHILD';	
149
				$node['actions'] = $actions;
149
				$node['actions'] = $actions;
150
			} 
150
			} 
151
				else {
151
				else {
152
					$node['actions'] = '';
152
					$node['actions'] = '';
153
						
153
						
154
				}*/
154
				}*/
155
       $nodeArray[$i] = $node;
155
       $nodeArray[$i] = $node;
156
       $i++;
156
       $i++;
157
       unset ($document);
157
       unset ($document);
158
   }
158
   }
159
   if (!is_null($nodeArray)) {
159
   if (!is_null($nodeArray)) {
160
   	header ('Content-type: json');
160
   	header ('Content-type: json');
161
   	print $json->encode($nodeArray);
161
   	print $json->encode($nodeArray);
162
   	exit();
162
   	exit();
163
   }
163
   }
164
}
164
}
165
 
165
 
166
 
166
 
167
 
167
 
168
 
168
 
169
 
169
 
170
?>
170
?>