Subversion Repositories Applications.projet

Compare Revisions

Ignore whitespace Rev 263 → Rev 367

/tags/v3.0-aha/services/serviceDeplacementFichier.php
New file
0,0 → 1,71
<?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: serviceDeplacementFichier.php,v 1.1 2007-04-19 09:37:50 alexandre_tb Exp $
/**
* Application projet
*
* Service pour deplacer un fichier, recoie l id du fichier a deplacer et l id du repertoire cible
*
*@package projet
//Auteur original :
*@author Alexandre Granier <alexandre@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2007
*@version $Revision: 1.1 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
// effectue le deplacement d un fichier, repond a un appel d arbreDocument.js
 
// On se situe dans la methode run() de projetControleur
 
// L url contient
// id_projet=id_projet&service=serviceDeplacement&enfant=id_du_doc_a_deplacer&parent=id_du_repertoire_cible
 
// $_GET['parent'] peut valoir 'root' auquel cas on remplace par 0, cela signifie
// qu on deplace un fichier vers le repertoire racine du projet
 
include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
$projet = new projet ($this->_db, $this->_id_projet) ;
 
 
header ('Content-type:text/json');
if (isset($_GET['enfant'])) {
$document = new document($_GET['enfant'], $this->_db, PROJET_CHEMIN_FICHIER) ;
// On traite le cas où l'on vient de déplacer un fichier
if (isset ($_GET['parent'])) {
if ($_GET['parent'] == 'root') $id_cible = 0 ; else $id_cible = $_GET['parent'];
if (!$document -> deplace ($id_cible, $projet->getNomRepertoire())) {
echo 'echec du déplacement' ;
}
exit() ;
}
}
exit();
?>
/tags/v3.0-aha/services/telechargement.php
New file
0,0 → 1,104
<?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: telechargement.php,v 1.3 2007-10-10 13:58:04 alexandre_tb Exp $
/**
* Application projet
*
* Service de telechargement recoie un id de document et renvoie le document
*
*@package projet
//Auteur original :
*@author Alexandre Granier <alexandre@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.3 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
 
if (is_object ($this) && $this->_id_document == '') {
return 'aucun fichier demand&eacute;';
} else {
if (!is_object($this) && isset ($_GET['id_document'])) {
$id_document = $_GET['id_document'];
}
}
 
if (is_object ($this)) {
$id_document = $this->_id_document;
}
 
include_once PROJET_CHEMIN_CLASSES.'projet.class.php';
include_once PROJET_CHEMIN_CLASSES.'document.class.php';
 
 
$document = new document ($id_document, $GLOBALS['projet_db'], PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES) ;
$projet = new projet ($document->_id_projet);
// Soit le document est public et on le renvoie, soit il est prive
// et on teste les droits
 
if ($document->getVisibilite() == 'prive') {
// On teste le login
if ($GLOBALS['projet_auth']->getAuth()) {
include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
$id_utilisateur = $GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID);
$participant = new participe($GLOBALS['projet_db']) ;
if ($participant->isAdministrateur($id_utilisateur) || $participant->isCoordinateur($id_utilisateur, $document->_id_projet)
|| $participant->isContributeur($id_utilisateur, $document->_id_projet)) {
$ok = true ;
} else {
$ok = false ;
return '<h1>'.$projet->getTitre($document->_id_projet).'</h1>'.
'<p class="information">Vous devez participer &agrave; ce projet pour acc&eacute;der &agrave; ce document</p>';
}
} else {
return '<h1>'.$projet->getTitre($document->_id_projet).'</h1>'.
'<p class="information">Vous devez participer &agrave; ce projet pour acc&eacute;der &agrave; ce document</p>';
}
} else {
$ok = true ;
}
 
// Recherche de l extension
$nom_de_fichier = pathinfo ($projet->getNomRepertoire().'/'.$document->getChemin()) ;
$extension = $nom_de_fichier['extension'];
 
header('Expires: Wen, 01 Dec 1999 01:00:00 GMT');// Date du passé
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');// toujours modifié
header('Cache-Control: Public, must-revalidate');// HTTP/1.1
header('Pragma: hack');
header ('Content-Type: '.$document->getTypeMime()) ;
header('Content-Length: '.(string) $document->getTaille());
header ('Content-Disposition: attachment; filename="'.$document->getNomLong().'.'.$extension.'"');
header("Content-Transfer-Encoding: binary\n");
 
readfile (PROJET_CHEMIN_FICHIER.$document->getChemin());
 
exit();
 
 
?>
/tags/v3.0-aha/services/ecouteArbreFichier.php
New file
0,0 → 1,170
<?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: ecouteArbreFichier.php,v 1.2 2007-06-25 12:15:06 alexandre_tb Exp $
/**
* Application projet
*
* Service d ecoute de l arbre du porte document, renvoie les donnees du repertoire demande
*
*@package projet
//Auteur original :
*@author Alexandre Granier <alexandre@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2005
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
// ATTENTION - le programme suivant doit renvoyer un tableau, meme vide
// sinon l arbre dojo ne fonctionnera pas (ligne 117 $returnArray = array)
 
 
include_once (GEN_CHEMIN_API.'json/JSON.php');
 
$action = $_REQUEST["action"];
$data = $_REQUEST["data"];
$cache = $_REQUEST["dojo.preventCache"];
 
$data = str_replace("\\\"","\"",$data);
 
// instanciation d un json-php
 
$json = new services_JSON();
 
if ( $action == "getChildren") {
$jsonData = $json->decode($data);
// get the node object
$node = $jsonData->node;
}
 
if ( $action == "getChildren") {
$jsonData = $json->decode($data);
// get the node object
$node = $jsonData->node;
// on recupere le noeud parent
$parent = $node->objectId;
if (isset($_REQUEST['id_projet'])) $id_projet = $_REQUEST['id_projet'];
if (preg_match ('/projet_([0-9]+)/', $node->objectId, $match)) $id_projet = $match[1];
// correspondance entre l objectid de dojo et id_parent de projet_document
if ( $parent == "root" || preg_match ('/projet_([0-9]+)/', $node->objectId, $match)) {
$id_parent = 0 ;
} else {
$id_parent = $node->objectId;
}
$sql = 'select * from projet_documents where pd_pere='.$id_parent ;
if (isset($id_projet)) $sql .= ' and pd_ce_projet='.$id_projet;
$sql .= ' order by pd_nom';
$resultat = $GLOBALS['projet_db']->query($sql);
 
if (DB::isError($resultat)) {
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
$nodeArray = array();
$i = 0;
include_once PROJET_CHEMIN_CLASSES.'document.class.php';
if ($GLOBALS['projet_auth']->getAuth() && is_object($this)) {
include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
$participant = new participe($GLOBALS['projet_db']) ;
$id_u = $GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID) ;
$isCoord = $participant->isCoordinateur($id_u, $this->_id_projet, $GLOBALS['projet_db']) ;
if ($isCoord) $droits = PROJET_DROIT_COORDINATEUR ;
$isAdm = participe::isAdministrateur($GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID), $GLOBALS['projet_db']) ;
if ($isAdm) $droits = PROJET_DROIT_ADMINISTRATEUR ;
if ($isAdm) $isCoord = true ;
$isParticipant = $participant->isContributeur($id_u, $this->_id_projet, $GLOBALS['projet_db']);
if ($isParticipant) $droits = PROJET_DROIT_CONTRIBUTEUR;
$statut = participe::getStatutSurProjetCourant ($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_id_projet, $this->_db) ;
// si participant, on ajoute le champs visibilite
} else {
$droits = PROJET_DROIT_AUCUN;
}
// Recuperation de l'auteur
include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
while ( $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$document = new document($ligne['pd_id'], $GLOBALS['projet_db'], PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES);
$GLOBALS['url']->addQueryString('id_projet', $id_projet);
$GLOBALS['url']->addQueryString('id_document', $document->getIdDocument());
$GLOBALS['url']->addQueryString(PROJET_VARIABLE_SERVICE, 'telechargement');
// json attend de l utf8, en lui fournissant des donnees au format htmlentities,
// ca passe
$annuaire = new annuaire($objetDB, array('table' => PROJET_ANNUAIRE, 'identifiant' => PROJET_CHAMPS_ID,
'nom' => PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ;
$annuaire->setId($document->_id_proprietaire) ;
$nom_prenom = $annuaire->getInfo('nom').' '.$annuaire->getInfo('prenom') ;
// On regarde si l utilisateur a les droits pour deplacer
if ($droits <= PROJET_DROIT_COORDINATEUR ||
$GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID) == $document->_id_proprietaire) {
$actions = 'MOVE,REMOVE,EDIT' ;
if ($document->isRepertoire()) $actions .= ',ADDCHILD';
}
else $actions = '';
$node = array(
'title'=> iconv('ISO-8859-1', 'UTF-8', $document->getNomLong()),
'widgetId' => 'document_'.$document->getIdDocument(),
'objectId'=> $document->getIdDocument(),
'isFolder'=> $document->isRepertoire(),
'link' => str_replace ('&amp;', '&', $GLOBALS['url']->getURL()),
'childIconSrc' => $document->getCheminIcone(),
'expandIcon' => PROJET_CHEMIN_ICONES.'folder-expanded.gif',
'afterLabel' => ' '.$document->getTailleFormatee().' '.iconv('ISO-8859-1', 'UTF-8',$nom_prenom),
);
// On regarde si l utilisateur a les droits pour deplacer
/*
if ($droits <= PROJET_DROIT_COORDINATEUR ||
$GLOBALS['projet_auth']->getAuthData(PROJET_CHAMPS_ID) == $document->_id_proprietaire) {
$actions = 'MOVE,REMOVE,EDIT' ;
if ($document->isRepertoire()) $actions .= ',ADDCHILD';
$node['actions'] = $actions;
}
else {
$node['actions'] = '';
}*/
$nodeArray[$i] = $node;
$i++;
unset ($document);
}
if (!is_null($nodeArray)) {
header ('Content-type: json');
print $json->encode($nodeArray);
exit();
}
}
 
 
 
 
 
?>