Subversion Repositories Applications.projet

Compare Revisions

Ignore whitespace Rev 248 → Rev 249

/trunk/services/telechargement.php
19,7 → 19,7
// | 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.1 2007-04-19 09:37:50 alexandre_tb Exp $
// CVS : $Id: telechargement.php,v 1.2 2007-06-25 12:15:06 alexandre_tb Exp $
/**
* Application projet
*
31,7 → 31,7
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.1 $
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
40,6 → 40,61
// +------------------------------------------------------------------------------------------------------+
 
 
if (is_object ($this) && $this->_id_document == '') {
return 'aucun fichier demandé';
} 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)
|| $participant->isContributeur($id_utilisateur)) {
$ok = true ;
} else {
$ok = false ;
return 'Vous devez participer à ce projet pour acc&eacuteder à ce document';
}
}
} 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();
 
 
?>
/trunk/services/ecouteArbreFichier.php
19,7 → 19,7
// | 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.1 2007-04-19 09:37:50 alexandre_tb Exp $
// CVS : $Id: ecouteArbreFichier.php,v 1.2 2007-06-25 12:15:06 alexandre_tb Exp $
/**
* Application projet
*
31,7 → 31,7
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2005
*@version $Revision: 1.1 $
*@version $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/
 
43,39 → 43,8
// sinon l arbre dojo ne fonctionnera pas (ligne 117 $returnArray = array)
 
 
set_include_path(get_include_path() . PATH_SEPARATOR . '/home/alex/www/api/pear');
include_once ('../../../papyrus/configuration/pap_config.inc.php');
include_once ('../../../api/pear/DB.php');
include_once ('../../../api/json/JSON.php');
include_once (GEN_CHEMIN_API.'json/JSON.php');
 
define ('PROJET_CHEMIN_APPLI','../');
define ('PROJET_CHEMIN_ICONES', "client/projet/icones/") ;
define ('PROJET_CHEMIN_CLASSES', PROJET_CHEMIN_APPLI.'classes/');//le chemin vers les fichiers propre à GSITE
define ('PROJET_CHEMIN_FONCTIONS', PROJET_CHEMIN_APPLI.'fonctions/') ;
define ('PROJET_CHEMIN_LIBRAIRIE','bibliotheque/');//le chemin de la librairie de fichier php
define ('PROJET_CHEMIN_FICHIER', PROJET_CHEMIN_APPLI.'fichiers/') ; // Chemin ou seront créer les dossiers
 
if (file_exists(PROJET_CHEMIN_CLASSES.'document.class.php')) {
include_once (PROJET_CHEMIN_CLASSES.'document.class.php') ;
} else {
echo 'impossible document_class';
}
if (file_exists(PROJET_CHEMIN_APPLI.'langues/pro_langue_fr.inc.php')) {
include_once PROJET_CHEMIN_APPLI.'langues/pro_langue_fr.inc.php' ;
} else {
echo 'impossible fichier de langue';
}
 
 
$GLOBALS['db'] = & DB::connect(PAP_DSN);
if (PEAR::isError($db)) {
echo ($db->getMessage());
}
 
 
// we're returning json
//header('Content-type: text/json');
 
$action = $_REQUEST["action"];
$data = $_REQUEST["data"];
$cache = $_REQUEST["dojo.preventCache"];
82,7 → 51,7
 
$data = str_replace("\\\"","\"",$data);
 
// instanciate a json-php instance
// instanciation d un json-php
 
$json = new services_JSON();
 
92,10 → 61,11
$node = $jsonData->node;
}
 
function getChildren($node) {
// setup the database connction
 
// get the parent 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];
107,50 → 77,94
}
$sql = 'select * from projet_documents where pd_pere='.$id_parent ;
if (isset($id_projet)) $sql .= ' and pd_ce_projet='.$id_projet;
// assemble the resulting rows into an array of node objects.
// Each node object is represented in php by an associative array
// the array of associative arrays will then be encoded in json and
// returned back to the browser
$resultat = $GLOBALS['db']->query($sql);
$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()) ;
}
$returnArray = array();
$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['db'], PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES);
 
$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'=> htmlentities($document->getNomLong()),
'title'=> iconv('ISO-8859-1', 'UTF-8', $document->getNomLong()),
'widgetId' => 'document_'.$document->getIdDocument(),
'objectId'=> $document->getIdDocument(),
'isFolder'=> $document->isRepertoire(),
'link' => $document->getChemin(),
'link' => str_replace ('&amp;', '&', $GLOBALS['url']->getURL()),
'childIconSrc' => $document->getCheminIcone(),
'expandIcon' => PROJET_CHEMIN_ICONES.'folder-expanded.gif',
'afterLabel' => ' '.$document->getTailleFormatee()
'afterLabel' => ' '.$document->getTailleFormatee().' '.iconv('ISO-8859-1', 'UTF-8',$nom_prenom),
);
$returnArray[$i] = $node;
// 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);
}
return $returnArray;
if (!is_null($nodeArray)) {
header ('Content-type: json');
print $json->encode($nodeArray);
exit();
}
}
 
 
if ( $action == "getChildren") {
$jsonData = $json->decode($data);
// get the node object
$node = $jsonData->node;
$nodeArray = getChildren($node);
if (!is_null($nodeArray)) print $json->encode($nodeArray);
}
 
 
 
 
 
?>