Subversion Repositories Applications.projet

Rev

Rev 206 | Rev 354 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 206 Rev 249
Line 17... Line 17...
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.1 2007-04-19 09:37:50 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
*
Line 29... Line 29...
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.1 $
34
*@version       $Revision: 1.2 $
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
36
*/
36
*/
Line 37... Line 37...
37
 
37
 
38
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
Line 41... Line 41...
41
 
41
 
42
// ATTENTION - le programme suivant doit renvoyer un tableau, meme vide
42
// ATTENTION - le programme suivant doit renvoyer un tableau, meme vide
Line 43... Line -...
43
// sinon l arbre dojo ne fonctionnera pas (ligne 117 $returnArray = array)
-
 
44
 
-
 
45
 
-
 
46
set_include_path(get_include_path() . PATH_SEPARATOR . '/home/alex/www/api/pear');
43
// sinon l arbre dojo ne fonctionnera pas (ligne 117 $returnArray = array)
47
include_once ('../../../papyrus/configuration/pap_config.inc.php');
-
 
48
include_once ('../../../api/pear/DB.php');
-
 
49
include_once ('../../../api/json/JSON.php');
-
 
50
 
-
 
51
define ('PROJET_CHEMIN_APPLI','../');
-
 
52
define ('PROJET_CHEMIN_ICONES', "client/projet/icones/") ;
-
 
53
define ('PROJET_CHEMIN_CLASSES', PROJET_CHEMIN_APPLI.'classes/');//le chemin vers les fichiers propre à GSITE
-
 
54
define ('PROJET_CHEMIN_FONCTIONS', PROJET_CHEMIN_APPLI.'fonctions/') ;
-
 
55
define ('PROJET_CHEMIN_LIBRAIRIE','bibliotheque/');//le chemin de la librairie de fichier php
-
 
56
define ('PROJET_CHEMIN_FICHIER', PROJET_CHEMIN_APPLI.'fichiers/') ; // Chemin ou seront créer les dossiers
-
 
57
 
-
 
58
if (file_exists(PROJET_CHEMIN_CLASSES.'document.class.php')) {
-
 
59
	include_once (PROJET_CHEMIN_CLASSES.'document.class.php') ;
-
 
60
} else {
-
 
61
	echo 'impossible document_class';
-
 
62
}
-
 
63
if (file_exists(PROJET_CHEMIN_APPLI.'langues/pro_langue_fr.inc.php')) {
-
 
64
	include_once PROJET_CHEMIN_APPLI.'langues/pro_langue_fr.inc.php' ;
-
 
65
} else {
-
 
66
	echo 'impossible fichier de langue';
-
 
67
}
-
 
68
 
-
 
69
 
-
 
70
$GLOBALS['db'] = & DB::connect(PAP_DSN);
-
 
71
if (PEAR::isError($db)) {
-
 
72
    echo ($db->getMessage());
-
 
73
}
-
 
74
 
-
 
Line 75... Line 44...
75
 
44
 
76
 // we're returning json
45
 
77
//header('Content-type: text/json');
46
include_once (GEN_CHEMIN_API.'json/JSON.php');
Line 78... Line 47...
78
 
47
 
Line 79... Line 48...
79
$action = $_REQUEST["action"];
48
$action = $_REQUEST["action"];
Line 80... Line 49...
80
$data = $_REQUEST["data"];
49
$data = $_REQUEST["data"];
Line 81... Line 50...
81
$cache = $_REQUEST["dojo.preventCache"];
50
$cache = $_REQUEST["dojo.preventCache"];
82
 
51
 
83
$data = str_replace("\\\"","\"",$data);
52
$data = str_replace("\\\"","\"",$data);
84
 
53
 
85
// instanciate a json-php instance
54
// instanciation d un json-php
Line 86... Line 55...
86
 
55
 
-
 
56
$json = new services_JSON();
87
$json = new services_JSON();
57
 
88
 
-
 
-
 
58
if ( $action == "getChildren") {
89
if ( $action == "getChildren") {
59
    $jsonData = $json->decode($data);
90
    $jsonData = $json->decode($data);
60
    // get the node object
91
    // get the node object
61
    $node = $jsonData->node;
92
    $node = $jsonData->node;
62
}
93
}
63
 
94
 
64
if ( $action == "getChildren") {
Line 105... Line 75...
105
   } else {
75
   } else {
106
   		$id_parent = $node->objectId;
76
   		$id_parent = $node->objectId;
107
   }
77
   }
108
	$sql = 'select * from projet_documents where pd_pere='.$id_parent ;
78
	$sql = 'select * from projet_documents where pd_pere='.$id_parent ;
109
	if (isset($id_projet)) $sql .= ' and pd_ce_projet='.$id_projet;
79
	if (isset($id_projet)) $sql .= ' and pd_ce_projet='.$id_projet;
110
   // assemble the resulting rows into an array of node objects.
-
 
111
   // Each node object is represented in php by an associative array
-
 
112
   // the array of associative arrays will then be encoded in json and
-
 
113
   // returned back to the browser
80
	$sql .= ' order by pd_nom';
114
   $resultat = $GLOBALS['db']->query($sql);
81
   $resultat = $GLOBALS['projet_db']->query($sql);
Line 115... Line 82...
115
 
82
 
116
   if (DB::isError($resultat)) {
83
   if (DB::isError($resultat)) {
117
        die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
84
        die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
118
   }
85
   }
119
   $returnArray = array();
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' ;
120
   $i = 0;
110
        
121
   while ( $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
111
   while ( $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
122
       $document = new document($ligne['pd_id'], $GLOBALS['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);
-
 
114
		$GLOBALS['url']->addQueryString('id_document', $document->getIdDocument());
123
 
115
		$GLOBALS['url']->addQueryString(PROJET_VARIABLE_SERVICE, 'telechargement');
124
		// 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
-
 
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 = '';
125
		// ca passe
132
		
126
       $node = array(
133
       $node = array(
127
          'title'=> htmlentities($document->getNomLong()),
134
          'title'=> iconv('ISO-8859-1', 'UTF-8', $document->getNomLong()),
128
          'widgetId' => 'document_'.$document->getIdDocument(),
135
          'widgetId' => 'document_'.$document->getIdDocument(),
129
          'objectId'=> $document->getIdDocument(),
136
          'objectId'=> $document->getIdDocument(),
130
          'isFolder'=> $document->isRepertoire(),
137
          'isFolder'=> $document->isRepertoire(),
131
          'link' => $document->getChemin(),
138
          'link' => str_replace ('&amp;', '&', $GLOBALS['url']->getURL()),
132
          'childIconSrc' => $document->getCheminIcone(),
139
          'childIconSrc' => $document->getCheminIcone(),
133
          'expandIcon' => PROJET_CHEMIN_ICONES.'folder-expanded.gif',
140
          'expandIcon' => PROJET_CHEMIN_ICONES.'folder-expanded.gif',
134
          'afterLabel' => ' '.$document->getTailleFormatee()
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
						
135
       );
154
				}*/
136
       $returnArray[$i] = $node;
155
       $nodeArray[$i] = $node;
137
       $i++;
156
       $i++;
138
       unset ($document);
157
       unset ($document);
139
   }
158
   }
140
   return $returnArray;
-
 
141
}
-
 
142
 
-
 
143
 
159
   if (!is_null($nodeArray)) {
144
if ( $action == "getChildren") {
160
   	header ('Content-type: json');
145
   $jsonData = $json->decode($data);
161
   	print $json->encode($nodeArray);
146
   // get the node object
162
   	exit();
147
   $node = $jsonData->node;
-
 
148
   $nodeArray = getChildren($node);
-
 
149
   if (!is_null($nodeArray)) print $json->encode($nodeArray);
163
   }