/trunk/classes/HTML_listeParticipants.class.php |
---|
1,216 → 1,216 |
<?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: HTML_listeParticipants.class.php,v 1.5 2008-08-25 15:13:17 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe HTML_listeParticipants |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.5 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
include_once PROJET_CHEMIN_CLASSES.'HTML_Liste.class.php' ; |
/** |
* class HTML_listeParticipants |
* |
*/ |
class HTML_listeParticipants extends HTML_Liste |
{ |
/*** Attributes: ***/ |
/** |
* Le mode, par défaut 0 => normal 1 => modification En mode modification, une |
* colonne de plus pour désinscrire un utilisateur |
* @access private |
*/ |
var $_mode; |
/** |
* L'url vers la page affichant la liste |
* @access private |
*/ |
var $_url; |
/** |
* |
* |
* @return void |
* @access public |
*/ |
function HTML_listeParticipants( $utilise_pager) |
{ |
HTML_Liste::HTML_Liste($utilise_pager, array('class' => 'table_cadre')) ; |
} // end of member function HTML_listeParticipants |
/** |
* |
* |
* @param Array elements Tableau des éléments de l'entête. Des labels. |
* @return void |
* @access public |
*/ |
function construitEntete( $elements ) |
{ |
if ($this->_mode == 1) { |
array_push ($elements, PROJET_SUPPRIMER) ; |
} |
$this->addRow ($elements, '', 'TH') ; |
} // end of member function construitEntete |
/** |
* |
* |
* @param Array elements Tableau à deux dimension contenant les éléments à afficher. |
* @return void |
* @access public |
*/ |
function construitListe( $elements, $tableau_statut = '', &$projet ) |
{ |
for ($i = 0; $i < count ($elements) ; $i++) { |
// L'identifiant de l'utilisateur est le premier élément du tableau |
$id_utilisateur = array_shift ($elements[$i]) ; |
// L'identifiant du statut est le dernier |
if (count ($elements)>5) $inscrit_liste = (int) array_pop ($elements[$i]); |
$id_statut = (int) array_pop ($elements[$i]) ; |
// En mode modif on ajoute la colonne supprimer |
if ($this->_mode == 1) { |
$this->_url->addQueryString ('id_utilisateur', $id_utilisateur) ; |
$this->_url->addQueryString('statut', 4) ; |
$supprimer = '<a href="'.$this->_url->getURL().'" onclick="javascript:return confirm(\''.PROJET_SUPPRIMER.' ?\')">'.PROJET_SUPPRIMER.'</a>'; |
if (count ($elements) > 5) array_push ($elements[$i], ''); |
array_push ($elements[$i], '', $supprimer); |
$this->_url->removeQueryString('statut') ; |
} |
// La colonne avec l inscription a la liste de discussion |
$this->addRow ($elements[$i]) ; |
// mise à jour du champs mail en l'entourant par la balise mailto |
/// $i+1 pour sauter la ligne de titre, |
if (strlen ($elements[$i][2]) > 10) { |
$mail_racourci = substr($elements[$i][2], 0, 10).'...' ; |
} |
$this->setCellContents ($i+1, 2, '<a href="mailto:'.$elements[$i][2].'">'.$mail_racourci.'</a>') ; |
// Mise à jour de la cellule contenant le statut |
if ($this->_mode == 1) { |
$this->_url->addQueryString ('id_utilisateur', $id_utilisateur) ; |
$select = '<form action="'.$this->_url->getURL().'" method="post">'."\n" ; |
$select .= '<select name="statut" onchange="javascript:this.form.submit();">' ; |
foreach ($tableau_statut as $cle =>$element_statut) { |
$select .= '<option value="'.$cle.'"' ; |
if ($cle == $id_statut) { |
$select .= ' selected="selected"' ; |
} |
$select .= '>'.$element_statut.'</option>'."\n" ; |
} |
$select .= '</select>'."\n".'</form>'."\n" ; |
$this->setCellContents($i+1, 4, $select) ; |
// Colonne avec l inscription a la liste de discussion |
if (count ($elements)>5) { |
$this->_url->addQueryString ('id_utilisateur', $id_utilisateur) ; |
$select = '<form action="'.$this->_url->getURL().'" method="post">'."\n" ; |
$select .= '<select name="inscription_liste" onchange="javascript:this.form.submit();">' ; |
$select .= '<option value="0">Non inscrit</option>'; |
$select .= '<option value="1"'.($inscrit_liste ? ' selected="selected"': '').'>Inscrit</option>'; |
$select .= '</select>'."\n".'</form>'."\n" ; |
$this->setCellContents($i+1, 5, $select) ; |
} |
} |
if ($id_statut == 1 && $this->_mode != 1) { |
$this->setCellContents($i + 1, 4, PROJET_CHEF) ; |
$this->updateRowAttributes ($i + 1, array('style' => 'font-weight:bold'), true) ; |
} |
if ($this->_mode != 1 && $id_statut != 1) { |
$this->setCellContents($i + 1, 4, $tableau_statut[$id_statut]) ; |
} |
$this->updateCellAttributes ($i + 1, 0, array ('class' => 'nom')) ; |
$this->updateCellAttributes ($i + 1, 1, array ('class' => 'prenom')) ; |
} |
} // end of member function construitListe |
/** |
* |
* |
* @return void |
* @access public |
*/ |
function setModeModification( ) |
{ |
$this->_mode = 1 ; |
} // end of member function setModeModification |
/** |
* Renvoie le code HTML de la table. |
* |
* @return string |
* @access public |
*/ |
function toHTML( ) |
{ |
// Application de style |
$this->altRowAttributes(1, array('class' =>'ligne_paire'), array('class' =>'ligne_impaire'), true) ; |
// s'il n'y a qu'une seule ligne, on renvoie un message indiquant qu'il n'y a pas de participants |
if ($this->getRowCount() == 1) { |
return '<div>'.PROJET_PAS_D_INSCRIT.'</div>'."\n"; |
} |
$res = HTML_Table::toHTML() ; |
return $res ; |
} // end of member function toHTML |
/** |
* Fixe la valeur de l'URL |
* |
* @param Net_URL url Un pointeur vers un objet Net_URL |
* @return void |
* @access public |
*/ |
function setURL( &$url ) |
{ |
$this->_url = $url ; |
} // end of member function setURL |
} // end of HTML_listeParticipants |
?> |
<?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: HTML_listeParticipants.class.php,v 1.4 2007-06-25 12:15:06 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe HTML_listeParticipants |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.4 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
include_once PROJET_CHEMIN_CLASSES.'HTML_Liste.class.php' ; |
/** |
* class HTML_listeParticipants |
* |
*/ |
class HTML_listeParticipants extends HTML_Liste |
{ |
/*** Attributes: ***/ |
/** |
* Le mode, par défaut 0 => normal 1 => modification En mode modification, une |
* colonne de plus pour désinscrire un utilisateur |
* @access private |
*/ |
var $_mode; |
/** |
* L'url vers la page affichant la liste |
* @access private |
*/ |
var $_url; |
/** |
* |
* |
* @return void |
* @access public |
*/ |
function HTML_listeParticipants( $utilise_pager) |
{ |
HTML_Liste::HTML_Liste($utilise_pager, array('class' => 'table_cadre')) ; |
} // end of member function HTML_listeParticipants |
/** |
* |
* |
* @param Array elements Tableau des éléments de l'entête. Des labels. |
* @return void |
* @access public |
*/ |
function construitEntete( $elements ) |
{ |
if ($this->_mode == 1) { |
array_push ($elements, PROJET_SUPPRIMER) ; |
} |
$this->addRow ($elements, '', 'TH') ; |
} // end of member function construitEntete |
/** |
* |
* |
* @param Array elements Tableau à deux dimension contenant les éléments à afficher. |
* @return void |
* @access public |
*/ |
function construitListe( $elements, $tableau_statut = '', &$projet ) |
{ |
for ($i = 0; $i < count ($elements) ; $i++) { |
// L'identifiant de l'utilisateur est le premier élément du tableau |
$id_utilisateur = array_shift ($elements[$i]) ; |
// L'identifiant du statut est le dernier |
if (count ($elements)>5) $inscrit_liste = (int) array_pop ($elements[$i]); |
$id_statut = (int) array_pop ($elements[$i]) ; |
// En mode modif on ajoute la colonne supprimer |
if ($this->_mode == 1) { |
$this->_url->addQueryString ('id_utilisateur', $id_utilisateur) ; |
$this->_url->addQueryString('statut', 4) ; |
$supprimer = '<a href="'.$this->_url->getURL().'" onclick="javascript:return confirm(\''.PROJET_SUPPRIMER.' ?\')">'.PROJET_SUPPRIMER.'</a>'; |
if (count ($elements) > 5) array_push ($elements[$i], ''); |
array_push ($elements[$i], '', $supprimer); |
$this->_url->removeQueryString('statut') ; |
} |
// La colonne avec l inscription a la liste de discussion |
$this->addRow ($elements[$i]) ; |
// mise à jour du champs mail en l'entourant par la balise mailto |
/// $i+1 pour sauter la ligne de titre, |
if (strlen ($elements[$i][2]) > 10) { |
$mail_racourci = substr($elements[$i][2], 0, 10).'...' ; |
} |
$this->setCellContents ($i+1, 2, '<a href="mailto:'.$elements[$i][2].'">'.$mail_racourci.'</a>') ; |
// Mise à jour de la cellule contenant le statut |
if ($this->_mode == 1) { |
$this->_url->addQueryString ('id_utilisateur', $id_utilisateur) ; |
$select = '<form action="'.$this->_url->getURL().'" method="post">'."\n" ; |
$select .= '<select name="statut" onchange="javascript:this.form.submit();">' ; |
foreach ($tableau_statut as $cle =>$element_statut) { |
$select .= '<option value="'.$cle.'"' ; |
if ($cle == $id_statut) { |
$select .= ' selected="selected"' ; |
} |
$select .= '>'.$element_statut.'</option>'."\n" ; |
} |
$select .= '</select>'."\n".'</form>'."\n" ; |
$this->setCellContents($i+1, 4, $select) ; |
// Colonne avec l inscription a la liste de discussion |
if (count ($elements)>5) { |
$this->_url->addQueryString ('id_utilisateur', $id_utilisateur) ; |
$select = '<form action="'.$this->_url->getURL().'" method="post">'."\n" ; |
$select .= '<select name="inscription_liste" onchange="javascript:this.form.submit();">' ; |
$select .= '<option value="0">Non inscrit</option>'; |
$select .= '<option value="1"'.($inscrit_liste ? ' selected="selected"': '').'>Inscrit</option>'; |
$select .= '</select>'."\n".'</form>'."\n" ; |
$this->setCellContents($i+1, 5, $select) ; |
} |
} |
if ($id_statut == 1 && $this->_mode != 1) { |
$this->setCellContents($i + 1, 4, PROJET_CHEF) ; |
$this->updateRowAttributes ($i + 1, array('style' => 'font-weight:bold'), true) ; |
} |
if ($this->_mode != 1 && $id_statut != 1) { |
$this->setCellContents($i + 1, 4, $tableau_statut[$id_statut]) ; |
} |
$this->updateCellAttributes ($i + 1, 0, array ('class' => 'nom')) ; |
$this->updateCellAttributes ($i + 1, 1, array ('class' => 'prenom')) ; |
} |
} // end of member function construitListe |
/** |
* |
* |
* @return void |
* @access public |
*/ |
function setModeModification( ) |
{ |
$this->_mode = 1 ; |
} // end of member function setModeModification |
/** |
* Renvoie le code HTML de la table. |
* |
* @return string |
* @access public |
*/ |
function toHTML( ) |
{ |
// Application de style |
$this->altRowAttributes(1, array('class' =>'ligne_paire'), array('class' =>'ligne_impaire'), true) ; |
// s'il n'y a qu'une seule ligne, on renvoie un message indiquant qu'il n'y a pas de participants |
if ($this->getRowCount() == 1) { |
return '<div>'.PROJET_PAS_D_INSCRIT.'</div>'."\n"; |
} |
$res = HTML_Table::toHTML() ; |
return $res ; |
} // end of member function toHTML |
/** |
* Fixe la valeur de l'URL |
* |
* @param Net_URL url Un pointeur vers un objet Net_URL |
* @return void |
* @access public |
*/ |
function setURL( &$url ) |
{ |
$this->_url = $url ; |
} // end of member function setURL |
} // end of HTML_listeParticipants |
?> |
/trunk/classes/HTML_listeDocuments.class.php |
---|
1,390 → 1,402 |
<?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: HTML_listeDocuments.class.php,v 1.10 2008-08-25 15:14:17 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe HTML_listeDocuments |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.10 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
// +------------------------------------------------------------------------------------------------------+ |
// | LISTE des constantes | |
// +------------------------------------------------------------------------------------------------------+ |
define ("FICHIER_ICONE_COUPER", "cut.gif") ; |
define ("FICHIER_ICONE_COLLER", "paste.gif") ; |
define ("FICHIER_ICONE_SUPPRIMER", "trash.gif") ; |
define ("FICHIER_ICONE_MODIFIER", "modif.png") ; |
include_once PROJET_CHEMIN_CLASSES.'HTML_Liste.class.php'; |
/** |
* class HTML_listeDocuments |
* |
*/ |
class HTML_listeDocuments extends HTML_Liste |
{ |
/*** Attributes: ***/ |
/** |
* Une url. |
* @access private |
*/ |
var $_url; |
/** |
* Tableau contenant les actions possibles. "couper" => 1, "modifier" => 2, |
* "supprimer" => 3 Elles seront passées en paramètre aux url des icones des |
* documents. |
* @access private |
*/ |
var $_actions = array ("couper" => 1, "modifier" => 2, "supprimer" => 3) ; |
/** |
* Indique le chemin des icones couper, coller, modifier, supprimer. |
* @access private |
*/ |
var $_chemin_icone = "icones/"; |
/** |
* L'identifiant du repertoire que l'on est en train d'observer. |
* @access private |
*/ |
var $_id_repertoire; |
/** |
* Un tableau contenant les id et les noms du chemin des répertoires. 0 => ["id"], |
* ["nom"] etc. |
* @access private |
*/ |
var $_chemin_navigation = array (); |
/** |
* un pointeur vers une authentificatin PEAR |
* @access private |
*/ |
var $_auth ; |
/** |
* le style d affichage |
* @access private |
*/ |
var $_mode_affichage ; |
/** |
* |
* |
* @param bool utilise_pager Indique l'utilisation ou non du Pager. |
* @return void |
* @access public |
*/ |
function HTML_listeDocuments(&$url, $utilise_pager = false, $id_repertoire = 0, $auth = '' ) |
{ |
HTML_Liste::HTML_Liste($utilise_pager, array('class' => 'table_cadre')) ; |
$this->_url = $url ; |
$this->_id_repertoire = $id_repertoire ; |
if (is_object($auth)) { |
$this->_auth = $auth ; |
} |
$this->_mode_affichage = 'standart'; |
} // end of member function HTML_listeDocuments |
/** |
* |
* |
* @param bool utilise_pager Voir HTML_listeDocuments |
* @return void |
* @access public |
*/ |
function __construct( &$url, $utilise_pager = false, $id_repertoire = 0, $auth = '', $id_projet = '' ) |
{ |
$this->HTML_listeDocuments($url, $utilise_pager, $id_repertoire, $auth); |
} // end of member function __construct |
/** |
* |
* |
* @param Array tableau_label Un tableau contenant les labels à afficher dans l'entête. |
* @return void |
* @access public |
*/ |
function construitEntete( $tableau_label ) |
{ |
$this->addRow ($tableau_label, NULL, 'TH') ; |
} |
/** |
* |
* |
* @param Array tableau_label Un tableau a deux dimensions avec les labels a afficher dans le corps du |
* tableau. |
* @return void |
* @access public |
*/ |
function construitListe( &$tableau_document, $droits, $mode = '', $objetDB = '', $id_projet = '') |
{ |
if ($this->_mode_affichage == 'standart') { |
$compteur = 0 ;$class[0] = 'ligne_impaire'; $class[1] = 'ligne_paire' ; |
//var_dump ($tableau_document); |
for ($i = 0; $i < count ($tableau_document) ; $i++) { |
// Premiere condition : est-ce que le fichier a pour pere le repertoire courant, si oui on l'affiche |
if ($tableau_document[$i]->_id_pere == $this->_id_repertoire || $mode == 'ignore_repertoire') { |
// d'abord l'image |
$icone = '<img src="'.$tableau_document[$i]->getCheminIcone().'" />' ; |
// Si le document est un repertoire, on ajoute id_repertoire au lien. |
if ($tableau_document[$i]->isRepertoire()) { |
$this->_url->addQueryString ('id_repertoire', $tableau_document[$i]->getIdDocument()) ; |
$lien = $this->_url->getURL() ; |
} else { // Si c'est un fichier, on fait un lien direct |
$this->_url->addQueryString('id_document', $tableau_document[$i]->getIdDocument()); |
$this->_url->addQueryString('service', 'telechargement'); |
$lien = $this->_url->getURL() ; |
$this->_url->removeQueryString('service'); |
$this->_url->removeQueryString('id_document'); |
$lien = 'http://'.$this->_url->host.'/projets/'.$this->_url->querystring[PROJET_VARIABLE_ID_PROJET].'/telechargement/'.$tableau_document[$i]->getIdDocument(); |
} |
// pour eviter des effets de bords, on enleve id_repertoire de l'url |
// dans le cas d'un repertoire, pour les fichiers on le laisse pour |
// qu'apres une operation, on reste dans le repertoire ou a eu lieu l'operation |
if ($tableau_document[$i]->isRepertoire()) $this->_url->removeQueryString('id_repertoire') ; |
// on insere le lien |
$lien_nom = '<a href="'.$lien.'">'.$icone.' '.$tableau_document[$i]->getNomLong()."</a>\n" ; |
$taille = $tableau_document[$i]->getTailleFormatee(); |
// Recuperation de l'auteur |
include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ; |
$annuaire = new annuaire($objetDB, array('table' => PROJET_ANNUAIRE, 'identifiant' => PROJET_CHAMPS_ID, |
'nom' => PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ; |
$annuaire->setId($tableau_document[$i]->_id_proprietaire) ; |
$nom_prenom = $annuaire->getInfo('nom').' '.$annuaire->getInfo('prenom') ; |
// On rempli le tableau a donner en parametre a HTML_Table avec toutes ces infos, une par colonne |
$ligne_tableau = array($lien_nom, $taille, $nom_prenom, $tableau_document[$i]->getDateMiseAJour()) ; |
if ($droits <= PROJET_DROIT_CONTRIBUTEUR) array_push ($ligne_tableau, $tableau_document[$i]->getVisibilite()) ; |
// On ajoute au tableau, les action couper / modifier / supprimer |
if ($droits <= PROJET_DROIT_COORDINATEUR || $this->_auth->getAuthData(PROJET_CHAMPS_ID) == $tableau_document[$i]->_id_proprietaire) |
array_push ($ligne_tableau, $this->_actions ($tableau_document[$i])) ; |
if ($tableau_document[$i]->getVisibilite() != 'prive' || $droits < PROJET_DROIT_AUCUN) { |
$this->addRow ($ligne_tableau, array('class' => $class[$compteur]), 'TD', true) ; |
// enfin , s'il y a une description, on l'ajoute, mais sur une ligne entière (colspan) |
if ($tableau_document[$i]->getDescription() != "") { |
$this->addRow (array ($tableau_document[$i]->getDescription()), |
array ('colspan' => $this->getColCount(), 'class' => $class[$compteur])) ; |
$this->updateRowAttributes ($this->getRowCount()-1, array ('class' => $class[$compteur]), true) ; |
} |
} |
$compteur++; |
} |
if ($compteur == 2) $compteur = 0 ; |
} |
$this->_url->removeQueryString('id_document'); |
$this->updateColAttributes(0, array ('class' => 'col1')) ; |
} else { |
} |
} // end of member function construitListe |
/** |
* |
* |
* @param Array actions Un tableau avec les valeurs d'actions comme cle. "couper", modifier", |
* "supprimer". |
* @return void |
* @access public |
*/ |
function setAction( $actions ) |
{ |
$this->_actions = $actions ; |
} |
/** |
* |
* |
* @param string le mode, valeur possible standart ou ajax |
* @return void |
* @access public |
*/ |
function setModeAffichage( $mode ) |
{ |
$this->_mode_affichage = $mode ; |
} |
/** |
* |
* |
* @param string chemin Le chemin vers les icones couper, coller ... |
* @return void |
* @access public |
*/ |
function setCheminIcones( $chemin ) |
{ |
$this->_chemin_icone = $chemin ; |
} |
/** |
* Surcharge de l'operation de la classe mere. Ajoute la navigation dans les |
* repertoires. |
* |
* @return string |
* @access public |
*/ |
function toHTML($id_projet = '', $droits) |
{ |
if ($this->_mode_affichage == 'standart') { |
$chemin_navig = "" ; |
if ($this->_id_repertoire != "") { |
$this->_url->removeQueryString(PROJET_VARIABLE_ID_REPERTOIRE) ; |
$chemin_navig = "<p>" ; |
$chemin_navig .= "<a href=\"".$this->_url->getURL()."\">".PROJET_RACINE."</a>\n" ; |
$this->_url->addQueryString(PROJET_VARIABLE_ID_REPERTOIRE, $this->_id_repertoire) ; |
for ($i = 0; $i < count ($this->_chemin_navigation); $i++) { |
$chemin_navig .= "> " ; |
$doc = new document ($this->_chemin_navigation[$i], $GLOBALS['projet_db']); |
$nom = $doc->getNomLong() ; |
$this->_url->addQueryString ('id_repertoire', $this->_chemin_navigation[$i]) ; |
$chemin_navig .= "<a href=\"".$this->_url->getURL()."\">".$nom."</a>\n" ; |
} |
$chemin_navig .= "</p>\n" ; |
} |
$res = $chemin_navig.HTML_Liste::toHTML() ; |
if ($this->getRowCount() == 1 && $this->_id_repertoire == '') { |
return '<div>'.PROJET_PAS_DE_DOCUMENTS.'</div>'."\n"; |
} |
} else { |
GEN_stockerFichierScript('dojo', 'api/js/dojo/dojo.js', 'text/javascript'); |
GEN_stockerFichierScript('dojoScriptProjet', 'client/projet/js/arbreDocument.js'); |
$res = '' ; |
$RCPUrl = PROJET_CHEMIN_APPLI.'services/ecouteArbreFichier.php?id_projet='.$id_projet; |
$this->_url->addQueryString(PROJET_VARIABLE_SERVICE, 'ecouteArbreFichier'); |
$RCPUrl = $this->_url->getURL(); |
// Le noeud racine |
if ($droits <= PROJET_DROIT_CONTRIBUTEUR) { |
$tree = '<div dojoType="Tree" DNDMode="between" selector="treeSelector" DNDAcceptTypes="bandTree" widgetId="bandTree" controller="treeController" eventNames="moveTo:nodeRemoved">'; |
} else { |
$tree = '<div dojoType="Tree" selector="treeSelector" DNDAcceptTypes="bandTree" widgetId="bandTree" controller="treeController">'; |
} |
$res .= '<div dojoType="TreeLoadingController" RPCUrl="'.$RCPUrl.'" widgetId="treeController" DNDController="create"></div> |
<div dojoType="TreeSelector" widgetId="treeSelector"></div>'.$tree. |
'<div dojoType="TreeNode" title="Racine" widgetId="rootNode" objectId="root" isFolder="true"></div></div>'; |
} |
return $res ; |
} // end of member function toHTML |
/** |
* |
* |
* @param Array tableau_navigation Un tableau contenant les identifiants et les noms des repertoires. 0 => ["id"], |
* ["nom"] etc. |
* @return void |
* @access public |
*/ |
function setCheminNavigation( $tableau_navigation ) |
{ |
$this->_chemin_navigation = $tableau_navigation ; |
} // end of member function setCheminNavigation |
/** |
* Affiche la legende des actions du module "documents" |
* |
* @return string |
* @access public |
*/ |
function affLegende( ) |
{ |
$res = "<h2 class=\"titre2_projet\">".PROJET_LEGENDE."</h2>\n" ; |
$res .= "<p><img src=\"".$this->_chemin_icone."/cut.gif\" title=\"couper\" alt=\"couper\">".PROJET_LEGENDE_DEPLACE."</p>\n" ; |
$res .= "<p><img src=\"".$this->_chemin_icone."/modif.png\" title=\"modifier\" alt=\"modifier\"> ".PROJET_LEGENDE_MODIFIE."</p>\n" ; |
$res .= "<p><img src=\"".$this->_chemin_icone."/trash.gif\" title=\"supprimer\" alt=\"supprimer\"> ".PROJET_LEGENDE_SUPPR."</p>\n" ; |
return $res ; |
} |
/** |
* Renvoie le chemin HTML, depuis le repertoire courant jusqu'a la racine. |
* |
* @return string |
* @access private |
*/ |
function _getCheminHTML( ) |
{ |
$path = "" ; |
return $path ; |
} |
/** |
* Renvoie une chaine contenant le code html des icones des actions possibles sur un |
* fichier, c'est a dire couper, modifier, supprimer. |
* |
* @return string |
* @access private |
*/ |
function _actions($document) |
{ |
$this->_url->addQueryString ('id_document', $document->getIdDocument()) ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["couper"]) ; |
$couper = ' '.PROJET_FICHIER_COUPER ; |
$couper = '<a href="'.$this->_url->getURL().'">'.$couper.'</a>' ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["modifier"]) ; |
$modifier = '<a href="'.$this->_url->getURL().'">'.PROJET_FICHIER_MODIFIER.'</a> ' ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["supprimer"]) ; |
$supprimer= '<a href="'.$this->_url->getURL().'" onclick="javascript:return confirm (\''.PROJET_FICHIER_SUPPRIMER.' ?\');">'.PROJET_FICHIER_SUPPRIMER.'</a>' ; |
$this->_url->removeQueryString ('id_document') ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_VOIR_DOCUMENT) ; |
return $modifier.$supprimer.$couper ; |
} // end of member function _action |
} // end of HTML_listeDocuments |
?> |
<?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: HTML_listeDocuments.class.php,v 1.9 2007-06-25 12:15:06 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe HTML_listeDocuments |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.9 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
// +------------------------------------------------------------------------------------------------------+ |
// | LISTE des constantes | |
// +------------------------------------------------------------------------------------------------------+ |
define ("FICHIER_ICONE_COUPER", "cut.gif") ; |
define ("FICHIER_ICONE_COLLER", "paste.gif") ; |
define ("FICHIER_ICONE_SUPPRIMER", "trash.gif") ; |
define ("FICHIER_ICONE_MODIFIER", "modif.png") ; |
include_once PROJET_CHEMIN_CLASSES.'HTML_Liste.class.php'; |
/** |
* class HTML_listeDocuments |
* |
*/ |
class HTML_listeDocuments extends HTML_Liste |
{ |
/*** Attributes: ***/ |
/** |
* Une url. |
* @access private |
*/ |
var $_url; |
/** |
* Tableau contenant les actions possibles. "couper" => 1, "modifier" => 2, |
* "supprimer" => 3 Elles seront pass�es en param�tre aux url des icones des |
* documents. |
* @access private |
*/ |
var $_actions = array ("couper" => 1, "modifier" => 2, "supprimer" => 3) ; |
/** |
* Indique le chemin des icones couper, coller, modifier, supprimer. |
* @access private |
*/ |
var $_chemin_icone = "icones/"; |
/** |
* L'identifiant du repertoire que l'on est en train d'observer. |
* @access private |
*/ |
var $_id_repertoire; |
/** |
* Un tableau contenant les id et les noms du chemin des r�pertoires. 0 => ["id"], |
* ["nom"] etc. |
* @access private |
*/ |
var $_chemin_navigation = array (); |
/** |
* un pointeur vers une authentificatin PEAR |
* @access private |
*/ |
var $_auth ; |
/** |
* le style d affichage |
* @access private |
*/ |
var $_mode_affichage ; |
/** |
* |
* |
* @param bool utilise_pager Indique l'utilisation ou non du Pager. |
* @return void |
* @access public |
*/ |
function HTML_listeDocuments(&$url, $utilise_pager = false, $id_repertoire = 0, $auth = '' ) |
{ |
HTML_Liste::HTML_Liste($utilise_pager, array('class' => 'table_cadre')) ; |
$this->_url = $url ; |
$this->_id_repertoire = $id_repertoire ; |
if (is_object($auth)) { |
$this->_auth = $auth ; |
} |
$this->_mode_affichage = 'standart'; |
} // end of member function HTML_listeDocuments |
/** |
* |
* |
* @param bool utilise_pager Voir HTML_listeDocuments |
* @return void |
* @access public |
*/ |
function __construct( &$url, $utilise_pager = false, $id_repertoire = 0, $auth = '', $id_projet = '' ) |
{ |
$this->HTML_listeDocuments($url, $utilise_pager, $id_repertoire, $auth); |
} // end of member function __construct |
/** |
* |
* |
* @param Array tableau_label Un tableau contenant les labels � afficher dans l'ent�te. |
* @return void |
* @access public |
*/ |
function construitEntete( $tableau_label ) |
{ |
$this->addRow ($tableau_label, NULL, 'TH') ; |
} |
/** |
* |
* |
* @param Array tableau_label Un tableau a deux dimensions avec les labels a afficher dans le corps du |
* tableau. |
* @return void |
* @access public |
*/ |
function construitListe( &$tableau_document, $droits, $mode = '', $objetDB = '', $id_projet = '') |
{ |
// mail('aurelien@tela-botanica.org','contenu de tableau documents', print_r($tableau_document,true)); |
if ($this->_mode_affichage == 'standart') { |
$compteur = 0 ;$class[0] = 'ligne_impaire'; $class[1] = 'ligne_paire' ; |
//var_dump ($tableau_document); |
for ($i = 0; $i < count ($tableau_document) ; $i++) { |
// Premiere condition : est-ce que le fichier a pour pere le repertoire courant, si oui on l'affiche |
if ($tableau_document[$i]->_id_pere == $this->_id_repertoire || $mode == 'ignore_repertoire') { |
// d'abord l'image |
$icone = '<img src="'.$tableau_document[$i]->getCheminIcone().'" />' ; |
// Si le document est un repertoire, on ajoute id_repertoire au lien. |
if ($tableau_document[$i]->isRepertoire()) { |
$this->_url->addQueryString ('id_repertoire', $tableau_document[$i]->getIdDocument()) ; |
$lien = $this->_url->getURL() ; |
} else { // Si c'est un fichier, on fait un lien direct |
$this->_url->addQueryString('id_document', $tableau_document[$i]->getIdDocument()); |
$this->_url->addQueryString('service', 'telechargement'); |
$lien = $this->_url->getURL() ; |
$this->_url->removeQueryString('service'); |
$this->_url->removeQueryString('id_document'); |
if($this->_url->querystring[PROJET_VARIABLE_ID_PROJET] == null) { |
$identifiant_projet =$tableau_document[$i]->_id_projet ; |
} |
else |
{ |
$identifiant_projet =$this->_url->querystring[PROJET_VARIABLE_ID_PROJET] ; |
} |
//$lien = 'http://'.$this->_url->host.'/projets/'.$this->_url->querystring[PROJET_VARIABLE_ID_PROJET].'/telechargement/'.$tableau_document[$i]->getIdDocument(); |
$lien = 'http://'.$this->_url->host.'/projets/'.$identifiant_projet.'/telechargement/'.$tableau_document[$i]->getIdDocument(); |
} |
// pour eviter des effets de bords, on enleve id_repertoire de l'url |
// dans le cas d'un repertoire, pour les fichiers on le laisse pour |
// qu'apres une operation, on reste dans le repertoire ou a eu lieu l'operation |
if ($tableau_document[$i]->isRepertoire()) $this->_url->removeQueryString('id_repertoire') ; |
// on insere le lien |
$lien_nom = '<a href="'.$lien.'">'.$icone.' '.$tableau_document[$i]->getNomLong()."</a>\n" ; |
$taille = $tableau_document[$i]->getTailleFormatee(); |
// Recuperation de l'auteur |
include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ; |
$annuaire = new annuaire($objetDB, array('table' => PROJET_ANNUAIRE, 'identifiant' => PROJET_CHAMPS_ID, |
'nom' => PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ; |
$annuaire->setId($tableau_document[$i]->_id_proprietaire) ; |
$nom_prenom = $annuaire->getInfo('nom').' '.$annuaire->getInfo('prenom') ; |
// On rempli le tableau a donner en parametre a HTML_Table avec toutes ces infos, une par colonne |
$ligne_tableau = array($lien_nom, $taille, $nom_prenom, $tableau_document[$i]->getDateMiseAJour()) ; |
if ($droits <= PROJET_DROIT_CONTRIBUTEUR) array_push ($ligne_tableau, $tableau_document[$i]->getVisibilite()) ; |
// On ajoute au tableau, les action couper / modifier / supprimer |
if ($droits <= PROJET_DROIT_COORDINATEUR || $this->_auth->getAuthData(PROJET_CHAMPS_ID) == $tableau_document[$i]->_id_proprietaire) |
array_push ($ligne_tableau, $this->_actions ($tableau_document[$i])) ; |
if ($tableau_document[$i]->getVisibilite() != 'prive' || $droits < PROJET_DROIT_AUCUN) { |
$this->addRow ($ligne_tableau, array('class' => $class[$compteur]), 'TD', true) ; |
// enfin , s'il y a une description, on l'ajoute, mais sur une ligne enti�re (colspan) |
if ($tableau_document[$i]->getDescription() != "") { |
$this->addRow (array ($tableau_document[$i]->getDescription()), |
array ('colspan' => $this->getColCount(), 'class' => $class[$compteur])) ; |
$this->updateRowAttributes ($this->getRowCount()-1, array ('class' => $class[$compteur]), true) ; |
} |
} |
$compteur++; |
} |
if ($compteur == 2) $compteur = 0 ; |
} |
$this->_url->removeQueryString('id_document'); |
$this->updateColAttributes(0, array ('class' => 'col1')) ; |
} else { |
} |
} // end of member function construitListe |
/** |
* |
* |
* @param Array actions Un tableau avec les valeurs d'actions comme cle. "couper", modifier", |
* "supprimer". |
* @return void |
* @access public |
*/ |
function setAction( $actions ) |
{ |
$this->_actions = $actions ; |
} |
/** |
* |
* |
* @param string le mode, valeur possible standart ou ajax |
* @return void |
* @access public |
*/ |
function setModeAffichage( $mode ) |
{ |
$this->_mode_affichage = $mode ; |
} |
/** |
* |
* |
* @param string chemin Le chemin vers les icones couper, coller ... |
* @return void |
* @access public |
*/ |
function setCheminIcones( $chemin ) |
{ |
$this->_chemin_icone = $chemin ; |
} |
/** |
* Surcharge de l'operation de la classe mere. Ajoute la navigation dans les |
* repertoires. |
* |
* @return string |
* @access public |
*/ |
function toHTML($id_projet = '', $droits) |
{ |
if ($this->_mode_affichage == 'standart') { |
$chemin_navig = "" ; |
if ($this->_id_repertoire != "") { |
$this->_url->removeQueryString(PROJET_VARIABLE_ID_REPERTOIRE) ; |
$chemin_navig = "<p>" ; |
$chemin_navig .= "<a href=\"".$this->_url->getURL()."\">".PROJET_RACINE."</a>\n" ; |
$this->_url->addQueryString(PROJET_VARIABLE_ID_REPERTOIRE, $this->_id_repertoire) ; |
for ($i = 0; $i < count ($this->_chemin_navigation); $i++) { |
$chemin_navig .= "> " ; |
$doc = new document ($this->_chemin_navigation[$i], $GLOBALS['projet_db']); |
$nom = $doc->getNomLong() ; |
$this->_url->addQueryString ('id_repertoire', $this->_chemin_navigation[$i]) ; |
$chemin_navig .= "<a href=\"".$this->_url->getURL()."\">".$nom."</a>\n" ; |
} |
$chemin_navig .= "</p>\n" ; |
} |
$res = $chemin_navig.HTML_Liste::toHTML() ; |
if ($this->getRowCount() == 1 && $this->_id_repertoire == '') { |
return '<div>'.PROJET_PAS_DE_DOCUMENTS.'</div>'."\n"; |
} |
} else { |
GEN_stockerFichierScript('dojo', 'api/js/dojo/dojo.js', 'text/javascript'); |
GEN_stockerFichierScript('dojoScriptProjet', 'client/projet/js/arbreDocument.js'); |
$res = '' ; |
$RCPUrl = PROJET_CHEMIN_APPLI.'services/ecouteArbreFichier.php?id_projet='.$id_projet; |
$this->_url->addQueryString(PROJET_VARIABLE_SERVICE, 'ecouteArbreFichier'); |
$RCPUrl = $this->_url->getURL(); |
// Le noeud racine |
if ($droits <= PROJET_DROIT_CONTRIBUTEUR) { |
$tree = '<div dojoType="Tree" DNDMode="between" selector="treeSelector" DNDAcceptTypes="bandTree" widgetId="bandTree" controller="treeController" eventNames="moveTo:nodeRemoved">'; |
} else { |
$tree = '<div dojoType="Tree" selector="treeSelector" DNDAcceptTypes="bandTree" widgetId="bandTree" controller="treeController">'; |
} |
$res .= '<div dojoType="TreeLoadingController" RPCUrl="'.$RCPUrl.'" widgetId="treeController" DNDController="create"></div> |
<div dojoType="TreeSelector" widgetId="treeSelector"></div>'.$tree. |
'<div dojoType="TreeNode" title="Racine" widgetId="rootNode" objectId="root" isFolder="true"></div></div>'; |
} |
return $res ; |
} // end of member function toHTML |
/** |
* |
* |
* @param Array tableau_navigation Un tableau contenant les identifiants et les noms des repertoires. 0 => ["id"], |
* ["nom"] etc. |
* @return void |
* @access public |
*/ |
function setCheminNavigation( $tableau_navigation ) |
{ |
$this->_chemin_navigation = $tableau_navigation ; |
} // end of member function setCheminNavigation |
/** |
* Affiche la legende des actions du module "documents" |
* |
* @return string |
* @access public |
*/ |
function affLegende( ) |
{ |
$res = "<h2 class=\"titre2_projet\">".PROJET_LEGENDE."</h2>\n" ; |
$res .= "<p><img src=\"".$this->_chemin_icone."/cut.gif\" title=\"couper\" alt=\"couper\">".PROJET_LEGENDE_DEPLACE."</p>\n" ; |
$res .= "<p><img src=\"".$this->_chemin_icone."/modif.png\" title=\"modifier\" alt=\"modifier\"> ".PROJET_LEGENDE_MODIFIE."</p>\n" ; |
$res .= "<p><img src=\"".$this->_chemin_icone."/trash.gif\" title=\"supprimer\" alt=\"supprimer\"> ".PROJET_LEGENDE_SUPPR."</p>\n" ; |
return $res ; |
} |
/** |
* Renvoie le chemin HTML, depuis le repertoire courant jusqu'a la racine. |
* |
* @return string |
* @access private |
*/ |
function _getCheminHTML( ) |
{ |
$path = "" ; |
return $path ; |
} |
/** |
* Renvoie une chaine contenant le code html des icones des actions possibles sur un |
* fichier, c'est a dire couper, modifier, supprimer. |
* |
* @return string |
* @access private |
*/ |
function _actions($document) |
{ |
$this->_url->addQueryString ('id_document', $document->getIdDocument()) ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["couper"]) ; |
$couper = ' '.PROJET_FICHIER_COUPER ; |
$couper = '<a href="'.$this->_url->getURL().'">'.$couper.'</a>' ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["modifier"]) ; |
$modifier = '<a href="'.$this->_url->getURL().'">'.PROJET_FICHIER_MODIFIER.'</a> ' ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["supprimer"]) ; |
$supprimer= '<a href="'.$this->_url->getURL().'" onclick="javascript:return confirm (\''.PROJET_FICHIER_SUPPRIMER.' ?\');">'.PROJET_FICHIER_SUPPRIMER.'</a>' ; |
$this->_url->removeQueryString ('id_document') ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_VOIR_DOCUMENT) ; |
return $modifier.$supprimer.$couper ; |
} // end of member function _action |
} // end of HTML_listeDocuments |
?> |
/trunk/classes/HTML_formulaireDocument.class.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: HTML_formulaireDocument.class.php,v 1.4 2007-02-13 15:11:39 jp_milcent Exp $ |
// CVS : $Id: HTML_formulaireDocument.class.php,v 1.4 2007/02/13 15:11:39 jp_milcent Exp $ |
/** |
* Application projet |
* |
/trunk/classes/HTML_formulaireCreationWikini.class.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: HTML_formulaireCreationWikini.class.php,v 1.2 2005-09-27 16:39:47 alexandre_tb Exp $ |
// CVS : $Id: HTML_formulaireCreationWikini.class.php,v 1.2 2005/09/27 16:39:47 alexandre_tb Exp $ |
/** |
* Application projet |
* |
/trunk/classes/HTML_formulaireListe.class.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: HTML_formulaireListe.class.php,v 1.2 2005-09-27 16:40:39 alexandre_tb Exp $ |
// CVS : $Id: HTML_formulaireListe.class.php,v 1.2 2005/09/27 16:40:39 alexandre_tb Exp $ |
/** |
* Application projet |
* |
/trunk/classes/HTML_formulaireMail.class.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: HTML_formulaireMail.class.php,v 1.3 2006-07-05 09:44:11 alexandre_tb Exp $ |
// CVS : $Id: HTML_formulaireMail.class.php,v 1.3 2006/07/05 09:44:11 alexandre_tb Exp $ |
/** |
* Application projet |
* |
/trunk/classes/commande_serveur.class.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: commande_serveur.class.php,v 1.2 2005-09-27 16:37:40 alexandre_tb Exp $ |
// CVS : $Id: commande_serveur.class.php,v 1.2 2005/09/27 16:37:40 alexandre_tb Exp $ |
/** |
* Application projet |
* |
/trunk/classes/projetTemplate.class.php |
---|
1,89 → 1,89 |
<?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: projetTemplate.class.php,v 1.4 2008-09-16 14:10:41 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe controleur projet |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.4 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
include_once 'PEAR.php' ; |
/** Constante des templates */ |
// Pour le coordinateur dans la cas de projets moderes |
define ('PROJET_TEMPLATE_DEMANDE_INSCRIPTION_SUJET', 1); |
define ('PROJET_TEMPLATE_DEMANDE_INSCRIPTION_CORPS', 2); |
// Pour le coordinateur lors d une nouvelle inscription (projets non moderes) |
define ('PROJET_TEMPLATE_INSCRIPTION_NOUVELLE_SUJET', 3); |
define ('PROJET_TEMPLATE_INSCRIPTION_NOUVELLE_CORPS', 4); |
// pour le coodinateur lors des desinscription |
define ('PROJET_TEMPLATE_DESINSCRIPTION_SUJET', 5); |
define ('PROJET_TEMPLATE_DESINSCRIPTION_CORPS', 6); |
// Pour le coordinateur lors du depot d un nouveau document |
define ('PROJET_TEMPLATE_NOUVEAU_DOC_SUJET', 7); |
define ('PROJET_TEMPLATE_NOUVEAU_DOC_CORPS', 8); |
// Pour les administrateur lorsque le dernier coordinateur |
// d un projet se desinscrit |
define ('PROJET_TEMPLATE_DESINSCRIPTION_DERNIER_COORD_SUJET', 9); |
define ('PROJET_TEMPLATE_DESINSCRIPTION_DERNIER_COORD_CORPS', 10); |
class projetTemplate extends PEAR { |
var $_db ; |
function projetTemplate(&$objetDB) { |
$this->_db = $objetDB ; |
} |
function getTemplate ($id_template, $lang='fr-FR', $argument = 0) { |
$requete = 'select pt_template from projet_template where pt_id_template='.$this->_db->escapeSimple($id_template). |
' and pt_i18n like "'.$lang.'%"' ; |
if ($argument != 0) $requete .= ' and pt_argument='.$this->_db->escapeSimple($argument) ; |
$resultat = $GLOBALS['projet_db']->query($requete) ; |
if (DB::isError($resultat)) return $this->raiseError ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ; |
if ($resultat->numRows() == 0) return $this->raiseError ('Aucun template avec l\'identifiant: '.$id_template. |
', la langue: '.$lang. ' et l argument '.$argument) ; |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
return $ligne->pt_template ; |
} |
} |
<?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: projetTemplate.class.php,v 1.3 2008-08-25 15:04:38 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe controleur projet |
* |
*@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 | |
// +------------------------------------------------------------------------------------------------------+ |
include_once 'PEAR.php' ; |
/** Constante des templates */ |
// Pour le coordinateur dans la cas de projets moderes |
define ('PROJET_TEMPLATE_DEMANDE_INSCRIPTION_SUJET', 1); |
define ('PROJET_TEMPLATE_DEMANDE_INSCRIPTION_CORPS', 2); |
// Pour le coordinateur lors d une nouvelle inscription (projets non moderes) |
define ('PROJET_TEMPLATE_INSCRIPTION_NOUVELLE_SUJET', 3); |
define ('PROJET_TEMPLATE_INSCRIPTION_NOUVELLE_CORPS', 4); |
// pour le coodinateur lors des desinscription |
define ('PROJET_TEMPLATE_DESINSCRIPTION_SUJET', 5); |
define ('PROJET_TEMPLATE_DESINSCRIPTION_CORPS', 6); |
// Pour le coordinateur lors du depot d un nouveau document |
define ('PROJET_TEMPLATE_NOUVEAU_DOC_SUJET', 7); |
define ('PROJET_TEMPLATE_NOUVEAU_DOC_CORPS', 8); |
// Pour les administrateur lorsque le dernier coordinateur |
// d un projet se desinscrit |
define ('PROJET_TEMPLATE_DESINSCRIPTION_DERNIER_COORD_SUJET', 9); |
define ('PROJET_TEMPLATE_DESINSCRIPTION_DERNIER_COORD_CORPS', 10); |
class projetTemplate extends PEAR { |
var $_db ; |
function projetTemplate(&$objetDB) { |
$this->_db = $objetDB ; |
} |
function getTemplate ($id_template, $lang='fr-FR', $argument = 0) { |
$requete = 'select pt_template from projet_template where pt_id_template='.$this->_db->escapeSimple($id_template). |
' and pt_i18n like "'.$lang.'%"' ; |
if ($argument != 0) $requete .= ' and pt_argument='.$this->_db->escapeSimple($argument) ; |
$resultat = $GLOBALS['projet_db']->query($requete) ; |
if (DB::isError($resultat)) return $this->raiseError ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ; |
if ($resultat->numRows() == 0) return $this->raiseError ('Aucun template avec l\'identifiant: '.$id_template. |
', la langue: '.$lang. ' et l argument '.$argument) ; |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
return $ligne->pt_template ; |
} |
} |
?> |
/trunk/classes/HTML_formulaireInscriptionProjet.class.php |
---|
1,115 → 1,115 |
<?php |
// +------------------------------------------------------------------------------------------------------+ |
// | 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: HTML_formulaireInscriptionProjet.class.php,v 1.3 2007-11-21 09:42:50 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe HTML_formulaireInscriptionProjet |
* Elle se base sur la table projet_statut_utilisateur |
* |
*@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 | |
// +------------------------------------------------------------------------------------------------------+ |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/radio.php'; |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm.php'; |
/** |
* class HTML_formulaireInscriptionProjet |
* |
*/ |
class HTML_formulaireInscriptionProjet extends HTML_QuickForm |
{ |
/*** Attributes: ***/ |
/** |
* |
* |
* @return void |
* @access public |
*/ |
function HTML_formulaireInscriptionProjet( $formName = '', $method = 'post', $action = '', $target = '_self', $attributes = '', $trackSubmit = false ) |
{ |
HTML_QuickForm::HTML_QuickForm($formName, $method, $action, $target, $attributes, $trackSubmit) ; |
} // end of member function HTML_formulaireInscriptionProjet |
/** |
* |
* |
* @return void |
* @access public |
*/ |
function construitFormulaire(& $projet ) |
{ |
$squelette =& $this->defaultRenderer(); |
$squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'{content}'."\n".'</form>'."\n"); |
$modele_element_debut = '<li class="groupe_formulaire">'."\n".'<span class="inscription_label1">{label}<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required --></span>'. |
"\n".'{element}'."\n".''."\n". |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n". |
''."\n" ; |
$modele_element_fin = "\n".'<span class="inscription_label2">{label}<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required --></span>'. |
"\n".'{element}'."\n".''."\n". |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n". |
'</li>'."\n" ; |
$squelette->setElementTemplate( '<li class="liste_inscription">'."\n".'<span class="inscription_label">{label}<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required --></span>'. |
"\n".'{element}'."\n".''."\n". |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n". |
'</li>'."\n"); |
$squelette->setElementTemplate( '<ul><li class="groupe_bouton">{element}', 'annuler'); |
$squelette->setElementTemplate( '{element}</li></ul>', 'valider'); |
$squelette->setRequiredNoteTemplate("\n".'<p>'."\n".'<span class="symbole_obligatoire">*</span> {requiredNote}'."\n".'</p>'."\n"); |
if ($projet->avoirListe()) { |
$this->addElement ('radio', 'radio_inscription_liste', ' ', PROJET_INSCRIPTION_LISTE_NORMAL, 2) ; |
$this->addElement ('radio', 'radio_inscription_liste', ' ', PROJET_INSCRIPTION_PAS_DE_MAIL, 1) ; |
// Indisponible pour le moment |
//$this->addElement ('radio', 'radio_inscription_liste', ' ', PROJET_INSCRIPTION_LISTE_RESUME, 2) ; |
} |
$this->addElement ('hidden', 'id_projet', $projet->getId()) ; |
$url_annuler = new Net_URL($this->getAttribute('action')) ; |
$url_annuler->removeQueryString(PROJET_VARIABLE_ACTION) ; |
$url_annuler->removeQueryString(PROJET_VARIABLE_ID_PROJET) ; |
// on fait un groupe avec les boutons pour les mettres sur la même ligne |
$buttons[] = &HTML_QuickForm::createElement('link', 'annuler', PROJET_FICHIER_ANNULER, |
preg_replace ("/&/", "&", $url_annuler->getURL()), PROJET_FICHIER_ANNULER); // Le preg_replace contourne un pb de QuickForm et Net_URL |
// qui remplacent deux fois les & par des & |
// ce qui fait échouer le lien |
$buttons[] = &HTML_QuickForm::createElement('submit', 'valider_inscription_projet', PROJET_S_INSCRIRE_AU_PROJET); |
$this->addGroup($buttons, null, null, ' '); |
} // end of member function construitFormulaire |
} // end of HTML_formulaireInscriptionProjet |
?> |
<?php |
// +------------------------------------------------------------------------------------------------------+ |
// | 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: HTML_formulaireInscriptionProjet.class.php,v 1.3 2007-11-21 09:42:50 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe HTML_formulaireInscriptionProjet |
* Elle se base sur la table projet_statut_utilisateur |
* |
*@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 | |
// +------------------------------------------------------------------------------------------------------+ |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/radio.php'; |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm.php'; |
/** |
* class HTML_formulaireInscriptionProjet |
* |
*/ |
class HTML_formulaireInscriptionProjet extends HTML_QuickForm |
{ |
/*** Attributes: ***/ |
/** |
* |
* |
* @return void |
* @access public |
*/ |
function HTML_formulaireInscriptionProjet( $formName = '', $method = 'post', $action = '', $target = '_self', $attributes = '', $trackSubmit = false ) |
{ |
HTML_QuickForm::HTML_QuickForm($formName, $method, $action, $target, $attributes, $trackSubmit) ; |
} // end of member function HTML_formulaireInscriptionProjet |
/** |
* |
* |
* @return void |
* @access public |
*/ |
function construitFormulaire(& $projet ) |
{ |
$squelette =& $this->defaultRenderer(); |
$squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'{content}'."\n".'</form>'."\n"); |
$modele_element_debut = '<li class="groupe_formulaire">'."\n".'<span class="inscription_label1">{label}<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required --></span>'. |
"\n".'{element}'."\n".''."\n". |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n". |
''."\n" ; |
$modele_element_fin = "\n".'<span class="inscription_label2">{label}<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required --></span>'. |
"\n".'{element}'."\n".''."\n". |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n". |
'</li>'."\n" ; |
$squelette->setElementTemplate( '<li class="liste_inscription">'."\n".'<span class="inscription_label">{label}<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required --></span>'. |
"\n".'{element}'."\n".''."\n". |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n". |
'</li>'."\n"); |
$squelette->setElementTemplate( '<ul><li class="groupe_bouton">{element}', 'annuler'); |
$squelette->setElementTemplate( '{element}</li></ul>', 'valider'); |
$squelette->setRequiredNoteTemplate("\n".'<p>'."\n".'<span class="symbole_obligatoire">*</span> {requiredNote}'."\n".'</p>'."\n"); |
if ($projet->avoirListe()) { |
$this->addElement ('radio', 'radio_inscription_liste', ' ', PROJET_INSCRIPTION_LISTE_NORMAL, 2) ; |
$this->addElement ('radio', 'radio_inscription_liste', ' ', PROJET_INSCRIPTION_PAS_DE_MAIL, 1) ; |
// Indisponible pour le moment |
//$this->addElement ('radio', 'radio_inscription_liste', ' ', PROJET_INSCRIPTION_LISTE_RESUME, 2) ; |
} |
$this->addElement ('hidden', 'id_projet', $projet->getId()) ; |
$url_annuler = new Net_URL($this->getAttribute('action')) ; |
$url_annuler->removeQueryString(PROJET_VARIABLE_ACTION) ; |
$url_annuler->removeQueryString(PROJET_VARIABLE_ID_PROJET) ; |
// on fait un groupe avec les boutons pour les mettres sur la même ligne |
$buttons[] = &HTML_QuickForm::createElement('link', 'annuler', PROJET_FICHIER_ANNULER, |
preg_replace ("/&/", "&", $url_annuler->getURL()), PROJET_FICHIER_ANNULER); // Le preg_replace contourne un pb de QuickForm et Net_URL |
// qui remplacent deux fois les & par des & |
// ce qui fait échouer le lien |
$buttons[] = &HTML_QuickForm::createElement('submit', 'valider_inscription_projet', PROJET_S_INSCRIRE_AU_PROJET); |
$this->addGroup($buttons, null, null, ' '); |
} // end of member function construitFormulaire |
} // end of HTML_formulaireInscriptionProjet |
?> |
/trunk/classes/inscription_liste.class.php |
---|
1,238 → 1,236 |
<?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: inscription_liste.class.php,v 1.5 2006-04-19 13:50:49 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe inscription_liste |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.5 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class isncription_liste |
* |
*/ |
class inscription_liste |
{ |
/*** Attributes: ***/ |
/** |
* Identifiant de la liste |
* @access private |
*/ |
var $_id_liste; |
/** |
* Identifiant de l'utilisateur |
* @access private |
*/ |
var $_id_utilisateur; |
/** |
* Une ressource PEAR::DB |
* @access private |
*/ |
var $_db; |
/** |
* Le type d'inscription indique : - 0 : pas d'email - 1 : normale - 2 : résumé |
* @access private |
*/ |
var $_type_inscription; |
/** |
* Constructeur |
* |
* @param DB objetDB Une ressource PEAR::DB |
* @return void |
* @access public |
*/ |
function inscription_liste( &$objetDB ) |
{ |
$this->_db = $objetDB ; |
} // end of member function inscription_liste |
/** |
* Renvoie un tableau avec la liste des inscrit à une liste. |
* |
* @param int id_liste L'identifiant de la liste |
* @return Array |
* @access public |
*/ |
function getInscritsListe( $id_liste ) |
{ |
} // end of member function getInscritsListe |
/** |
* |
* |
* @param annire utilisateur |
* @param liste_discussion id_liste |
* @param int type_inscription |
* @return void |
* @access public |
*/ |
function inscrireUtilisateur( &$utilisateur, &$liste, $type_inscription ) |
{ |
$requete = 'update projet_inscription_liste set '. |
'pil_id_liste='.$this->_db->escapeSimple($liste->getId()).', pil_id_statut='.$this->_db->escapeSimple($type_inscription). |
' where pil_id_utilisateur='.$this->_db->escapeSimple($utilisateur->getInfo('identifiant')) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
echo ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
if ($this->_db->affectedRows() == 0) { |
$requete = 'insert into projet_inscription_liste set pil_id_utilisateur='.$this->_db->escapeSimple($utilisateur->getInfo('identifiant')). |
', pil_id_liste='.$this->_db->escapeSimple($liste->getId()).', pil_id_statut='.$this->_db->escapeSimple($type_inscription) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
echo ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
} |
// Ajout dans la liste des commandes au serveur |
// On inscrit le créateur de la liste |
$resultat_ajout_utilisateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/ajout_abonne.php?domaine='. |
$liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$utilisateur->getInfo('mail')) ; |
} // end of member function inscrireUtilisateur |
/** |
* |
* |
* @param int id_utilisateur |
* @param int id_liste |
* @return void |
* @access public |
*/ |
function desinscrireUtilisateur( &$utilisateur, &$liste ) |
{ |
$requete = 'delete from projet_inscription_liste where pil_id_utilisateur='.$this->_db->escapeSimple($utilisateur->getInfo('identifiant')). |
' and pil_id_liste='.$this->_db->escapeSimple($liste->getId()) ; |
$resultat = $this->_db->query ($requete) ; |
$resultat_suppression_utilisateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/suppression_abonne.php?domaine='. |
$liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$utilisateur->getInfo('mail')) ; |
} // end of member function desinscrireUtilisateur |
/** |
* |
* |
* @param int id_liste |
* @param int id_utilisateur |
* @param int type_inscription |
* @return void |
* @access public |
*/ |
function modifierTypeInscription( $liste, $utilisateur, $type_inscription ) |
{ |
// envoie d'une demande d'inscription par email à la liste |
//include_once 'Mail.php' ; |
switch ($type_inscription) { |
case 0 : |
// Ajout du modérateur en tant qu'utilisateur |
$resultat_suppression_utilisateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/suppression_abonne.php?domaine='. |
$liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$utilisateur->getInfo('mail')) ; |
break ; |
case 1 : |
break ; |
case 2 : |
// Ajout d'un utilisateur |
$resultat_ajout_utilisateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/ajout_abonne.php?domaine='. |
$liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$utilisateur->getInfo('mail')) ; |
break ; |
} |
} // end of member function modifierTypeInscription |
/** |
* Renvoie la liste des statuts d'un utilisateur |
* |
* @param int id_utilisateur |
* @return Array |
* @access public |
*/ |
function getStatutsInscrit( $id_utilisateur ) |
{ |
$requete = 'select pil_id_liste, pil_id_statut from projet_inscription_liste where pil_id_utilisateur='.$this->_db->escapeSimple($id_utilisateur) ; |
$resultat = $this->_db->query ($requete) ;echo $requete; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$tableau_resultat = array() ; |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$tableau_resultat[$ligne->pil_id_liste] = $ligne->pil_id_statut ; |
} |
return $tableau_resultat ; |
} // end of member function getStatutsInscrit |
/** |
* Renvoie le statut d'un inscrit à une liste |
* |
* @param int id_liste |
* @param int id_utilisateur |
* @return int |
* @access public |
*/ |
function getStatutInscrit( $id_liste, &$auth ) |
{ |
// Récupération de la liste des listes !! |
$requete = 'select pl_nom_liste, pl_domaine from projet_liste where pl_id_liste='.$this->_db->escapeSimple($id_liste) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; |
$xml = file_get_contents(PROJET_SERVEUR_VPOPMAIL.'/liste_abonnes.php?domaine='. |
$ligne->pl_domaine.'&liste='.$ligne->pl_nom_liste) ; |
$tableau_mail = array() ; |
$tableau_ligne = explode ('<email>', $xml) ; |
foreach ($tableau_ligne as $ligne) array_push ($tableau_mail, strip_tags($ligne)) ; |
array_shift($tableau_mail) ; |
if (in_array($auth->getUsername(), $tableau_mail)) { |
return 2; // Inscrit est le statut 2 |
} |
return 0 ; |
} // end of member function getStatutInscrit |
} // end of isncription_liste |
?> |
<?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: inscription_liste.class.php,v 1.5 2006/04/19 13:50:49 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe inscription_liste |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.5 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class isncription_liste |
* |
*/ |
class inscription_liste |
{ |
/*** Attributes: ***/ |
/** |
* Identifiant de la liste |
* @access private |
*/ |
var $_id_liste; |
/** |
* Identifiant de l'utilisateur |
* @access private |
*/ |
var $_id_utilisateur; |
/** |
* Une ressource PEAR::DB |
* @access private |
*/ |
var $_db; |
/** |
* Le type d'inscription indique : - 0 : pas d'email - 1 : normale - 2 : résumé |
* @access private |
*/ |
var $_type_inscription; |
/** |
* Constructeur |
* |
* @param DB objetDB Une ressource PEAR::DB |
* @return void |
* @access public |
*/ |
function inscription_liste( &$objetDB ) |
{ |
$this->_db = $objetDB ; |
} // end of member function inscription_liste |
/** |
* Renvoie un tableau avec la liste des inscrit à une liste. |
* |
* @param int id_liste L'identifiant de la liste |
* @return Array |
* @access public |
*/ |
function getInscritsListe( $id_liste ) |
{ |
} // end of member function getInscritsListe |
/** |
* |
* |
* @param annire utilisateur |
* @param liste_discussion id_liste |
* @param int type_inscription |
* @return void |
* @access public |
*/ |
function inscrireUtilisateur( &$utilisateur, &$liste, $type_inscription ) |
{ |
$requete = 'update projet_inscription_liste set '. |
'pil_id_liste='.$liste->getId().', pil_id_statut='.$this->_db->escapeSimple($type_inscription).' where pil_id_utilisateur='.$this->_db->escapeSimple($utilisateur->getInfo('identifiant')) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
echo ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
if ($this->_db->affectedRows() == 0) { |
$requete = 'insert into projet_inscription_liste set pil_id_utilisateur='.$this->_db->escapeSimple($utilisateur->getInfo('identifiant')). |
', pil_id_liste='.$this->_db->escapeSimple($liste->getId()).', pil_id_statut='.$this->_db->escapeSimple($type_inscription) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
echo ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
} |
// Ajout dans la liste des commandes au serveur |
// On inscrit le créateur de la liste |
$resultat_ajout_utilisateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/ajout_abonne.php?domaine='. |
$liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$utilisateur->getInfo('mail')) ; |
} // end of member function inscrireUtilisateur |
/** |
* |
* |
* @param int id_utilisateur |
* @param int id_liste |
* @return void |
* @access public |
*/ |
function desinscrireUtilisateur( &$utilisateur, &$liste ) |
{ |
$requete = 'delete from projet_inscription_liste where pil_id_utilisateur='.$this->_db->escapeSimple($utilisateur->getInfo('identifiant')).' and pil_id_liste='.$this->_db->escapeSimple($liste->getId()) ; |
$resultat = $this->_db->query ($requete) ; |
$resultat_suppression_utilisateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/suppression_abonne.php?domaine='. |
$liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$utilisateur->getInfo('mail')) ; |
} // end of member function desinscrireUtilisateur |
/** |
* |
* |
* @param int id_liste |
* @param int id_utilisateur |
* @param int type_inscription |
* @return void |
* @access public |
*/ |
function modifierTypeInscription( $liste, $utilisateur, $type_inscription ) |
{ |
// envoie d'une demande d'inscription par email à la liste |
//include_once 'Mail.php' ; |
switch ($type_inscription) { |
case 0 : |
// Ajout du modérateur en tant qu'utilisateur |
$resultat_suppression_utilisateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/suppression_abonne.php?domaine='. |
$liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$utilisateur->getInfo('mail')) ; |
break ; |
case 1 : |
break ; |
case 2 : |
// Ajout d'un utilisateur |
$resultat_ajout_utilisateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/ajout_abonne.php?domaine='. |
$liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$utilisateur->getInfo('mail')) ; |
break ; |
} |
} // end of member function modifierTypeInscription |
/** |
* Renvoie la liste des statuts d'un utilisateur |
* |
* @param int id_utilisateur |
* @return Array |
* @access public |
*/ |
function getStatutsInscrit( $id_utilisateur ) |
{ |
$requete = 'select pil_id_liste, pil_id_statut from projet_inscription_liste where pil_id_utilisateur='.$this->_db->escapeSimple($id_utilisateur) ; |
$resultat = $this->_db->query ($requete) ;echo $requete; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$tableau_resultat = array() ; |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$tableau_resultat[$ligne->pil_id_liste] = $ligne->pil_id_statut ; |
} |
return $tableau_resultat ; |
} // end of member function getStatutsInscrit |
/** |
* Renvoie le statut d'un inscrit à une liste |
* |
* @param int id_liste |
* @param int id_utilisateur |
* @return int |
* @access public |
*/ |
function getStatutInscrit( $id_liste, &$auth ) |
{ |
// Récupération de la liste des listes !! |
$requete = 'select pl_nom_liste, pl_domaine from projet_liste where pl_id_liste='.$this->_db->escapeSimple($id_liste) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; |
$xml = file_get_contents(PROJET_SERVEUR_VPOPMAIL.'/liste_abonnes.php?domaine='. |
$ligne->pl_domaine.'&liste='.$ligne->pl_nom_liste) ; |
$tableau_mail = array() ; |
$tableau_ligne = explode ('<email>', $xml) ; |
foreach ($tableau_ligne as $ligne) array_push ($tableau_mail, strip_tags($ligne)) ; |
array_shift($tableau_mail) ; |
if (in_array($auth->getUsername(), $tableau_mail)) { |
return 2; // Inscrit est le statut 2 |
} |
return 0 ; |
} // end of member function getStatutInscrit |
} // end of isncription_liste |
?> |
/trunk/classes/HTML_Liste.class.php |
---|
16,7 → 16,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: HTML_Liste.class.php,v 1.2 2005-09-27 16:42:00 alexandre_tb Exp $ |
// CVS : $Id: HTML_Liste.class.php,v 1.2 2005/09/27 16:42:00 alexandre_tb Exp $ |
/** |
* Application projet |
* |
/trunk/classes/fichier.class.php |
---|
1,293 → 1,293 |
<?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: fichier.class.php,v 1.8 2008-08-25 15:16:25 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe fichier |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.8 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
include_once PROJET_CHEMIN_CLASSES.'type_fichier_mime.class.php' ; |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class fichier |
* Cette classe représente un fichier au sens physique du terme. Elle fonctionne |
* pour les système UNIX. A faire : adaptation selon les système. L'objectif est de |
* gérer correctement l'upload de fichier. |
*/ |
class fichier |
{ |
/*** Attributes: ***/ |
/** |
* Le nom du fichier, avec son extension. |
* @access private |
*/ |
var $_nom; |
/** |
* Le chemin UNIX ou Windows pour accéder au fichier sur le serveur (par ex; |
* /var/www/fichier.txt |
* @access private |
*/ |
var $_chemin; |
/** |
* Cet attribut contient une valeur du type 755, indiquant les droits afférent à un |
* fichier selon le système UNIX (propriétaire, groupe, autres) |
* @access private |
*/ |
var $_droits_unix; |
/** |
* Le type indique si le fichier est un répertoire, un lien ou un fichier. |
* @access private |
*/ |
var $_type = 'fichier'; |
/** |
* l'identifiant du type mime. |
* @access private |
*/ |
var $_type_mime; |
/** |
* Le chemin vers le fichier, en partant du répertoire de travail. |
* @access private |
*/ |
var $_prefixe_chemin; |
/** |
* |
* |
* @return void |
* @access public |
*/ |
function fichier( $chemin, &$objetDB) |
{ |
$this->_chemin = $chemin ; |
// On analyse l'extension pour découvrir le type mime |
$partie_chemin = pathinfo ($this->_chemin) ; |
if (is_object($objetDB) && isset($partie_chemin['extension'])) { |
$this->_type_mime = type_fichier_mime::factory ($partie_chemin['extension']) ; |
} |
// calcul du type |
if (is_dir ($this->_chemin)) $this->_type = 'repertoire' ; |
} // end of member function fichier |
/** |
* Le constructeur de la classe. |
* |
* @param string chemin Le chemin du fichier sur le serveur. |
* @return fichier |
* @access public |
*/ |
function __construct( $chemin, &$objetDB) |
{ |
$this->fichier($chemin, $objetDB); |
} // end of member function __construct |
/** |
* |
* |
* @return void |
* @access public |
*/ |
function suppression() |
{ |
if ($this->_type == 'repertoire') rmdir ($this->_chemin) ; |
if ($this->_type == 'fichier') unlink ($this->_chemin) ; |
} // end of member function suppression |
/** |
* Réalise l'upload d'un fichier vers chemin_destination. |
* |
* @param string chemin_destination Il s'agit du chemin UNIX de destination du fichier. Le script doit avoir les |
* droits en écriture sur le répertoire. |
* @global mixed une référence vers un objet HTML_QuickForm_File |
* @return void |
* @access public |
*/ |
function upload( $chemin_destination ) |
{ |
if (move_uploaded_file($_FILES['fichier']['tmp_name'], $chemin_destination)) { |
return true ; |
} else { |
return false ; |
} |
} // end of member function upload |
/** |
* Déplace un fichier, renvoie vrai en cas de succès. |
* |
* @param string origine L'emplacement de départ du fichier. |
* @param string destination Le répertoire d'arrivé. |
* @return bool |
* @access public |
*/ |
function deplace( $origine, $destination ) |
{ |
if (rename ($origine, $destination )) return true ; |
return false ; |
} // end of member function deplace |
/** |
* |
* |
* @param int id_type_mime L'identifiant du type mime du document. |
* @return type_fichier_mime |
* @access public |
*/ |
function getTypeMime( ) |
{ |
return $this->_type_mime; |
} // end of member function getTypeMime |
/** |
* Renvoie vrai si le document est un répertoire. |
* |
* @return bool |
* @access public |
*/ |
function isRepertoire( ) |
{ $isRep = is_dir ($this->_chemin) ; |
return $isRep ; |
} // end of member function isRepertoire |
/** |
* |
* |
* @param int id_type_mime L'identifiant du type mime. |
* @return void |
* @access public |
*/ |
function setTypeMime( $id_type_mime ) |
{ |
$this->_type_mime = $id_type_mime ; |
} // end of member function set TypeMime |
/** |
* Renvoie la taille du fichier en octet. Nécessite un accès au disque. |
* |
* @return int |
* @access public |
*/ |
function getTaille( ) |
{ |
if ($this->isRepertoire()) { |
return $this->_tailleRepertoire($this->_chemin) ; |
} |
return @filesize ($this->_chemin) ; |
} // end of member function getTaille |
/** |
* Renovie le nom du fichier, sur le disque. |
* |
* @return string |
* @access public |
*/ |
function getNom( ) |
{ |
} // end of member function getNom |
/** |
* Renvoie le chemin du fichier. |
* |
* @return string |
* @access public |
*/ |
function getChemin( ) |
{ |
return $this->_chemin ; |
} // end of member function getChemin |
/** |
* Permet de calculer la taille en octet du repertoire courrant |
* |
* @return int |
* @access protected |
*/ |
function _tailleRepertoire($rep) |
{ |
$taille = 0 ; |
$liste_fichier = scandir ($rep) ; |
foreach ($liste_fichier as $key => $value) { |
if (is_dir ($rep."/".$value) && $value != ".." && $value != ".") { |
$taille += $this->_tailleRepertoire ($rep.$value."/") ; |
} else { |
if ($value != '..' && $value != '.') $taille += @filesize ($rep.$value) ; |
} |
} |
return $taille ; |
} // end of member function _tailleRepertoire |
/** |
* initAttributes sets all fichier attributes to its default value make |
* sure to call this method within your class constructor |
*/ |
function initAttributes( ) |
{ |
$this->_type = 'fichier'; |
} |
} // end of fichier |
if(!function_exists("scandir")) |
{ |
function scandir($dirstr) |
{ |
// php.net/scandir (PHP5) |
$files = array(); |
$fh = opendir($dirstr); |
while (false !== ($filename = readdir($fh))) |
{ |
array_push($files, $filename); |
} |
closedir($fh); |
return $files; |
} |
} |
?> |
<?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: fichier.class.php,v 1.7 2007-06-25 12:15:06 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe fichier |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.7 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
include_once PROJET_CHEMIN_CLASSES.'type_fichier_mime.class.php' ; |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class fichier |
* Cette classe représente un fichier au sens physique du terme. Elle fonctionne |
* pour les système UNIX. A faire : adaptation selon les système. L'objectif est de |
* gérer correctement l'upload de fichier. |
*/ |
class fichier |
{ |
/*** Attributes: ***/ |
/** |
* Le nom du fichier, avec son extension. |
* @access private |
*/ |
var $_nom; |
/** |
* Le chemin UNIX ou Windows pour accéder au fichier sur le serveur (par ex; |
* /var/www/fichier.txt |
* @access private |
*/ |
var $_chemin; |
/** |
* Cet attribut contient une valeur du type 755, indiquant les droits afférent à un |
* fichier selon le système UNIX (propriétaire, groupe, autres) |
* @access private |
*/ |
var $_droits_unix; |
/** |
* Le type indique si le fichier est un répertoire, un lien ou un fichier. |
* @access private |
*/ |
var $_type = 'fichier'; |
/** |
* l'identifiant du type mime. |
* @access private |
*/ |
var $_type_mime; |
/** |
* Le chemin vers le fichier, en partant du répertoire de travail. |
* @access private |
*/ |
var $_prefixe_chemin; |
/** |
* |
* |
* @return void |
* @access public |
*/ |
function fichier( $chemin, &$objetDB) |
{ |
$this->_chemin = $chemin ; |
// On analyse l'extension pour découvrir le type mime |
$partie_chemin = pathinfo ($this->_chemin) ; |
if (is_object($objetDB) && isset($partie_chemin['extension'])) { |
$this->_type_mime = type_fichier_mime::factory ($partie_chemin['extension']) ; |
} |
// calcul du type |
if (is_dir ($this->_chemin)) $this->_type = 'repertoire' ; |
} // end of member function fichier |
/** |
* Le constructeur de la classe. |
* |
* @param string chemin Le chemin du fichier sur le serveur. |
* @return fichier |
* @access public |
*/ |
function __construct( $chemin, &$objetDB) |
{ |
$this->fichier($chemin, $objetDB); |
} // end of member function __construct |
/** |
* |
* |
* @return void |
* @access public |
*/ |
function suppression() |
{ |
if ($this->_type == 'repertoire') rmdir ($this->_chemin) ; |
if ($this->_type == 'fichier') unlink ($this->_chemin) ; |
} // end of member function suppression |
/** |
* Réalise l'upload d'un fichier vers chemin_destination. |
* |
* @param string chemin_destination Il s'agit du chemin UNIX de destination du fichier. Le script doit avoir les |
* droits en écriture sur le répertoire. |
* @global mixed une référence vers un objet HTML_QuickForm_File |
* @return void |
* @access public |
*/ |
function upload( $chemin_destination ) |
{ |
if (move_uploaded_file($_FILES['fichier']['tmp_name'], $chemin_destination)) { |
return true ; |
} else { |
return false ; |
} |
} // end of member function upload |
/** |
* Déplace un fichier, renvoie vrai en cas de succès. |
* |
* @param string origine L'emplacement de départ du fichier. |
* @param string destination Le répertoire d'arrivé. |
* @return bool |
* @access public |
*/ |
function deplace( $origine, $destination ) |
{ |
if (rename ($origine, $destination )) return true ; |
return false ; |
} // end of member function deplace |
/** |
* |
* |
* @param int id_type_mime L'identifiant du type mime du document. |
* @return type_fichier_mime |
* @access public |
*/ |
function getTypeMime( ) |
{ |
return $this->_type_mime; |
} // end of member function getTypeMime |
/** |
* Renvoie vrai si le document est un répertoire. |
* |
* @return bool |
* @access public |
*/ |
function isRepertoire( ) |
{ $isRep = is_dir ($this->_chemin) ; |
return $isRep ; |
} // end of member function isRepertoire |
/** |
* |
* |
* @param int id_type_mime L'identifiant du type mime. |
* @return void |
* @access public |
*/ |
function setTypeMime( $id_type_mime ) |
{ |
$this->_type_mime = $id_type_mime ; |
} // end of member function set TypeMime |
/** |
* Renvoie la taille du fichier en octet. Nécessite un accès au disque. |
* |
* @return int |
* @access public |
*/ |
function getTaille( ) |
{ |
if ($this->isRepertoire()) { |
return $this->_tailleRepertoire($this->_chemin) ; |
} |
return @filesize ($this->_chemin) ; |
} // end of member function getTaille |
/** |
* Renovie le nom du fichier, sur le disque. |
* |
* @return string |
* @access public |
*/ |
function getNom( ) |
{ |
} // end of member function getNom |
/** |
* Renvoie le chemin du fichier. |
* |
* @return string |
* @access public |
*/ |
function getChemin( ) |
{ |
return $this->_chemin ; |
} // end of member function getChemin |
/** |
* Permet de calculer la taille en octet du repertoire courrant |
* |
* @return int |
* @access protected |
*/ |
function _tailleRepertoire($rep) |
{ |
$taille = 0 ; |
$liste_fichier = scandir ($rep) ; |
foreach ($liste_fichier as $key => $value) { |
if (is_dir ($rep."/".$value) && $value != ".." && $value != ".") { |
$taille += $this->_tailleRepertoire ($rep.$value."/") ; |
} else { |
if ($value != '..' && $value != '.') $taille += @filesize ($rep.$value) ; |
} |
} |
return $taille ; |
} // end of member function _tailleRepertoire |
/** |
* initAttributes sets all fichier attributes to its default value make |
* sure to call this method within your class constructor |
*/ |
function initAttributes( ) |
{ |
$this->_type = 'fichier'; |
} |
} // end of fichier |
if(!function_exists("scandir")) |
{ |
function scandir($dirstr) |
{ |
// php.net/scandir (PHP5) |
$files = array(); |
$fh = opendir($dirstr); |
while (false !== ($filename = readdir($fh))) |
{ |
array_push($files, $filename); |
} |
closedir($fh); |
return $files; |
} |
} |
?> |
/trunk/classes/liste_externe.class.php |
---|
1,166 → 1,162 |
<?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: liste_externe.class.php,v 1.3 2008-09-16 14:12:04 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe liste_externe |
* |
*@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 | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class liste_externe |
* |
*/ |
class liste_externe |
{ |
/*** Attributes: ***/ |
/** |
* Identifiant de la liste, dans la table agora et dans la table |
* projet_lien_liste_externe |
* @access private |
*/ |
var $_id_liste; |
/** |
* |
* @access private |
*/ |
var $_db; |
/** |
* Constructeur |
* |
* @param DB objetDB Un objet PEAR::DB |
* @return void |
* @access public |
*/ |
function liste_externe(&$objetDB ) |
{ |
$this->_db = $objetDB ; |
} // end of member function liste_externe |
/** |
* Renvoie un tableau avec en clé l'identifiant d'une liste et en valeur le nom de |
* la liste. |
* |
* @return Array |
* @access public |
*/ |
function getListeNom( ) |
{ |
$requete = 'select AGO_A_ID, AGO_A_NOMGRPLG from agora' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$tableau_resultat = array() ; |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
$tableau_resultat[$ligne['AGO_A_ID']] = $ligne['AGO_A_NOMGRPLG'] ; |
} |
return $tableau_resultat ; |
} // end of member function getListeNom |
/** |
* Renvoie un tableau avec les identifiants des listes associées au projet passé en |
* paramètre. |
* |
* @param int id_projet L'identifiant du projet |
* @return Array |
* @access public |
*/ |
function getListesAssociees( $id_projet ) |
{ |
if(!intval($id_projet)) return NULL; |
$requete = sprintf('SELECT plle_id_liste FROM projet_lien_liste_externe WHERE plle_id_projet=%d -- %s', |
intval($id_projet), |
__FILE__ . ':' . __LINE__); |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$tableau_resultat = array() ; |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_resultat, $ligne->plle_id_liste) ; |
} |
return $tableau_resultat ; |
} // end of member function getListesAssociees |
/** |
* enregistrerSQL |
* |
* @return |
*/ |
function enregistrerSQL ($valeur, $id_projet) { |
// on commence par supprimer |
$requete = 'delete from projet_lien_liste_externe where plle_id_projet='.intval($id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
// puis on réinsère |
foreach ($valeur as $cle => $val) { |
if (!preg_match ('/liste_/', $cle)) continue ; |
$id_liste = preg_replace ('/liste_/', '', $cle) ; |
$requete = 'insert into projet_lien_liste_externe set plle_id_liste='.$this->_db->escapeSimple($id_liste). |
', plle_id_projet='.inval($id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
} |
} |
/** |
* Renvoie un tableau avec les infos sur la liste, voir les noms des champs de la |
* table agora pour une description plus détaillé. |
* |
* @param int id_liste L'identifiant de la liste |
* @return void |
* @access public |
*/ |
function getInfoListe( $id_liste ) |
{ |
$requete = 'select * from agora where AGO_A_ID='.$this->_db->escapeSimple($id_liste) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
return $ligne ; |
} // end of member function getInfoListe |
} // end of liste_externe |
?> |
<?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: liste_externe.class.php,v 1.2 2005-09-27 16:42:00 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe liste_externe |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.2 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class liste_externe |
* |
*/ |
class liste_externe |
{ |
/*** Attributes: ***/ |
/** |
* Identifiant de la liste, dans la table agora et dans la table |
* projet_lien_liste_externe |
* @access private |
*/ |
var $_id_liste; |
/** |
* |
* @access private |
*/ |
var $_db; |
/** |
* Constructeur |
* |
* @param DB objetDB Un objet PEAR::DB |
* @return void |
* @access public |
*/ |
function liste_externe(&$objetDB ) |
{ |
$this->_db = $objetDB ; |
} // end of member function liste_externe |
/** |
* Renvoie un tableau avec en clé l'identifiant d'une liste et en valeur le nom de |
* la liste. |
* |
* @return Array |
* @access public |
*/ |
function getListeNom( ) |
{ |
$requete = 'select AGO_A_ID, AGO_A_NOMGRPLG from agora' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$tableau_resultat = array() ; |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
$tableau_resultat[$ligne['AGO_A_ID']] = $ligne['AGO_A_NOMGRPLG'] ; |
} |
return $tableau_resultat ; |
} // end of member function getListeNom |
/** |
* Renvoie un tableau avec les identifiants des listes associées au projet passé en |
* paramètre. |
* |
* @param int id_projet L'identifiant du projet |
* @return Array |
* @access public |
*/ |
function getListesAssociees( $id_projet ) |
{ |
$requete = 'select plle_id_liste from projet_lien_liste_externe where plle_id_projet='.$this->_db->escapeSimple($id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$tableau_resultat = array() ; |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_resultat, $ligne->plle_id_liste) ; |
} |
return $tableau_resultat ; |
} // end of member function getListesAssociees |
/** |
* enregistrerSQL |
* |
* @return |
*/ |
function enregistrerSQL ($valeur, $id_projet) { |
// on commence par supprimer |
$requete = 'delete from projet_lien_liste_externe where plle_id_projet='.$this->_db->escapeSimple($id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
// puis on réinsère |
foreach ($valeur as $cle => $val) { |
if (!preg_match ('/liste_/', $cle)) continue ; |
$id_liste = preg_replace ('/liste_/', '', $cle) ; |
$requete = 'insert into projet_lien_liste_externe set plle_id_liste='.$this->_db->escapeSimple($id_liste).', plle_id_projet='.$this->_db->escapeSimple($id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
} |
} |
/** |
* Renvoie un tableau avec les infos sur la liste, voir les noms des champs de la |
* table agora pour une description plus détaillé. |
* |
* @param int id_liste L'identifiant de la liste |
* @return void |
* @access public |
*/ |
function getInfoListe( $id_liste ) |
{ |
$requete = 'select * from agora where AGO_A_ID='.$this->_db->escapeSimple($id_liste) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
return $ligne ; |
} // end of member function getInfoListe |
} // end of liste_externe |
?> |
/trunk/classes/AJAX_arbreDocuments.class.php |
---|
1,353 → 1,353 |
<?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: AJAX_arbreDocuments.class.php,v 1.2 2007-10-10 13:52:52 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe AJAX_arbreDocuments |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.2 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
// +------------------------------------------------------------------------------------------------------+ |
// | LISTE des constantes | |
// +------------------------------------------------------------------------------------------------------+ |
define ("FICHIER_ICONE_COUPER", "cut.gif") ; |
define ("FICHIER_ICONE_COLLER", "paste.gif") ; |
define ("FICHIER_ICONE_SUPPRIMER", "trash.gif") ; |
define ("FICHIER_ICONE_MODIFIER", "modif.png") ; |
// Appel de la bibliotheque dojo |
include_once PROJET_CHEMIN_CLASSES.'HTML_Liste.class.php'; |
GEN_stockerFichierScript('dojo', 'api/js/dojo/dojo.js', 'text/javascript'); |
/** |
* class HTML_listeDocuments |
* |
*/ |
class AJAX_arbreDocuments extends HTML_Liste |
{ |
/*** Attributes: ***/ |
/** |
* Une url. |
* @access private |
*/ |
var $_url; |
/** |
* Tableau contenant les actions possibles. "couper" => 1, "modifier" => 2, |
* "supprimer" => 3 Elles seront passées en paramètre aux url des icones des |
* documents. |
* @access private |
*/ |
var $_actions = array ("couper" => 1, "modifier" => 2, "supprimer" => 3) ; |
/** |
* Indique le chemin des icones couper, coller, modifier, supprimer. |
* @access private |
*/ |
var $_chemin_icone = "icones/"; |
/** |
* L'identifiant du répertoire que l'on est en train d'observer. |
* @access private |
*/ |
var $_id_repertoire; |
/** |
* Un tableau contenant les id et les noms du chemin des répertoires. 0 => ["id"], |
* ["nom"] etc. |
* @access private |
*/ |
var $_chemin_navigation = array (); |
/** |
* un pointeur vers une authentificatin PEAR |
* @access private |
*/ |
var $_auth ; |
/** |
* |
* |
* @param bool utilise_pager Indique l'utilisation ou non du Pager. |
* @return void |
* @access public |
*/ |
function AJAX_arbreDocuments(&$url, $utilise_pager = false, $id_repertoire = 0, $auth = '' ) |
{ |
//HTML_Liste::HTML_Liste($utilise_pager, array('class' => 'table_cadre')) ; |
$this->_url = $url ; |
$this->_id_repertoire = $id_repertoire ; |
if (is_object($auth)) { |
$this->_auth = $auth ; |
} |
} // end of member function HTML_listeDocuments |
function AJAX_construitListe($id_projet, $droits, $mode = '', $objetDB = '') { |
GEN_stockerFichierScript('dojoScriptProjet', 'client/projet/js/arbreDocument.js'); |
$res = '' ; |
$RCPUrl = PROJET_CHEMIN_APPLI.'services/ecouteArbreFichier.php?id_projet='.$id_projet; |
// Le noeud racine |
$res .= '<div dojoType="TreeLoadingController" RPCUrl="'.$RCPUrl.'" widgetId="treeController" DNDController="create"></div> |
<div dojoType="TreeSelector" widgetId="treeSelector"></div> |
<div dojoType="Tree" DNDMode="between" selector="treeSelector" DNDAcceptTypes="bandTree" widgetId="bandTree" controller="treeController" eventNames="moveTo:nodeRemoved"> |
<div dojoType="TreeNode" title="Racine" widgetId="eisleyRoot" objectId="root" isFolder="true"></div>'; |
return $res ; |
} |
/** |
* |
* |
* @param bool utilise_pager Voir HTML_listeDocuments |
* @return void |
* @access public |
*/ |
function __construct( &$url, $utilise_pager = false, $id_repertoire = 0, $auth = '' ) |
{ |
$this->AJAX_arbreDocuments($url, $utilise_pager, $id_repertoire, $auth); |
} // end of member function __construct |
/** |
* |
* |
* @param Array tableau_label Un tableau contenant les labels à afficher dans l'entête. |
* @return void |
* @access public |
*/ |
function construitEntete( $tableau_label ) |
{ |
$this->addRow ($tableau_label, NULL, 'TH') ; |
} // end of member function construitEntete |
/** |
* |
* |
* @param Array tableau_label Un tableau à deux dimensions avec les labels à afficher dans le corps du |
* tableau. |
* @return void |
* @access public |
*/ |
function construitListe( &$tableau_document, $droits, $mode = '', $objetDB = '') |
{ |
$compteur = 0 ;$class[0] = 'ligne_impaire'; $class[1] = 'ligne_paire' ; |
for ($i = 0; $i < count ($tableau_document) ; $i++) { |
// Première condition : est-ce que le fichier a pour père le répertoire courant, si oui on l'affiche |
if ($tableau_document[$i]->_id_pere == $this->_id_repertoire || $mode == 'ignore_repertoire') { |
// d'abord l'image |
$icone = '<img src="'.$tableau_document[$i]->getCheminIcone().'" />' ; |
// Si le document est un répertoire, on ajoute id_repertoire au lien. |
if ($tableau_document[$i]->isRepertoire()) { |
$this->_url->addQueryString ('id_repertoire', $tableau_document[$i]->getChemin()) ; |
$lien = $this->_url->getURL() ; |
} else { // Si c'est un fichier, on fait un lien direct |
$lien = $tableau_document[$i]->getChemin() ; |
} |
// pour éviter des effets de bords, on enlève id_repertoire de l'url |
// dans le cas d'un répertoire, pour les fichiers on le laisse pour |
// qu'après une opération, on reste dans le répertoire où a eu lieu l'opération |
if ($tableau_document[$i]->isRepertoire()) $this->_url->removeQueryString('id_repertoire') ; |
// on insère le lien |
$lien_nom = '<a href="'.$lien.'">'.$icone.' '.$tableau_document[$i]->getNomLong()."</a>\n" ; |
// Pour la taille on divise par 1000 et on écrit Ko |
$taille = round($tableau_document[$i]->getTaille() / 1000).' Ko' ; |
// Récupération de l'auteur |
include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ; |
$annuaire = new annuaire($objetDB, array('table' => PROJET_ANNUAIRE, 'identifiant' => PROJET_CHAMPS_ID, |
'nom' => PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ; |
$annuaire->setId($tableau_document[$i]->_id_proprietaire) ; |
$nom_prenom = $annuaire->getInfo('nom').' '.$annuaire->getInfo('prenom') ; |
// On rempli le tableau à donner en paramètre à HTML_Table avec toutes ces infos, une par colonne |
$ligne_tableau = array($lien_nom, $taille, $nom_prenom, $tableau_document[$i]->getDateMiseAJour()) ; |
if ($droits <= PROJET_DROIT_CONTRIBUTEUR) array_push ($ligne_tableau, $tableau_document[$i]->getVisibilite()) ; |
// On ajoute au tableau, les action couper / modifier / supprimer |
if ($droits <= PROJET_DROIT_COORDINATEUR || $this->_auth->getAuthData(PROJET_CHAMPS_ID) == $tableau_document[$i]->_id_proprietaire) |
array_push ($ligne_tableau, $this->_actions ($tableau_document[$i])) ; |
if ($tableau_document[$i]->getVisibilite() != 'prive' || $droits < PROJET_DROIT_AUCUN) { |
$this->addRow ($ligne_tableau, array('class' => $class[$compteur]), 'TD', true) ; |
// enfin , s'il y a une description, on l'ajoute, mais sur une ligne entière (colspan) |
if ($tableau_document[$i]->getDescription() != "") { |
$this->addRow (array ($tableau_document[$i]->getDescription()), |
array ('colspan' => $this->getColCount(), 'class' => $class[$compteur])) ; |
$this->updateRowAttributes ($this->getRowCount()-1, array ('class' => $class[$compteur]), true) ; |
} |
} |
$compteur++; |
} |
if ($compteur == 2) $compteur = 0 ; |
} |
$this->updateColAttributes(0, array ('class' => 'col1')) ; |
} // end of member function construitListe |
/** |
* |
* |
* @param Array actions Un tableau avec les valeurs d'actions comme clé. "couper", modifier", |
* "supprimer". |
* @return void |
* @access public |
*/ |
function setAction( $actions ) |
{ |
$this->_actions = $actions ; |
} // end of member function setAction |
/** |
* |
* |
* @param string chemin Le chemin vers les icones couper, coller ... |
* @return void |
* @access public |
*/ |
function setCheminIcones( $chemin ) |
{ |
$this->_chemin_icone = $chemin ; |
} // end of member function setCheminIcones |
/** |
* Surcharge de l'opération de la classe mère. Ajoute la navigation dans les |
* répertoires. |
* |
* @return string |
* @access public |
*/ |
function toHTML( ) |
{ |
$chemin_navig = "" ; |
if ($this->_id_repertoire != "") { |
$this->_url->removeQueryString(PROJET_VARIABLE_ID_REPERTOIRE) ; |
$chemin_navig = "<p>" ; |
$chemin_navig .= "<a href=\"".$this->_url->getURL()."\">".PROJET_RACINE."</a>\n" ; |
$this->_url->addQueryString(PROJET_VARIABLE_ID_REPERTOIRE, $this->_id_repertoire) ; |
for ($i = 0; $i < count ($this->_chemin_navigation); $i+=2) { |
$chemin_navig .= "> " ; |
$nom = $this->_chemin_navigation[$i+1] ; |
$this->_url->addQueryString ('id_repertoire', $this->_chemin_navigation[$i]) ; |
$chemin_navig .= "<a href=\"".$this->_url->getURL()."\">".$nom."</a>\n" ; |
} |
$chemin_navig .= "</p>\n" ; |
} |
$res = $chemin_navig.HTML_Liste::toHTML() ; |
if ($this->getRowCount() == 1 && $this->_id_repertoire == '') { |
return '<div>'.PROJET_PAS_DE_DOCUMENTS.'</div>'."\n"; |
} |
return $res ; |
} // end of member function toHTML |
/** |
* |
* |
* @param Array tableau_navigation Un tableau contenant les identifiants et les noms des répertoires. 0 => ["id"], |
* ["nom"] etc. |
* @return void |
* @access public |
*/ |
function setCheminNavigation( $tableau_navigation ) |
{ |
$this->_chemin_navigation = $tableau_navigation ; |
} // end of member function setCheminNavigation |
/** |
* Affiche la légende des actions du module "documents" |
* |
* @return string |
* @access public |
*/ |
function affLegende( ) |
{ |
$res = "<h2 class=\"titre2_projet\">".PROJET_LEGENDE."</h2>\n" ; |
$res .= "<p><img src=\"".$this->_chemin_icone."/cut.gif\" title=\"couper\" alt=\"couper\">".PROJET_LEGENDE_DEPLACE."</p>\n" ; |
$res .= "<p><img src=\"".$this->_chemin_icone."/modif.png\" title=\"modifier\" alt=\"modifier\"> ".PROJET_LEGENDE_MODIFIE."</p>\n" ; |
$res .= "<p><img src=\"".$this->_chemin_icone."/trash.gif\" title=\"supprimer\" alt=\"supprimer\"> ".PROJET_LEGENDE_SUPPR."</p>\n" ; |
return $res ; |
} // end of member function affLegende |
/** |
* Renvoie le chemin HTML, depuis le répertoire courant jusqu'à la racine. |
* |
* @return string |
* @access private |
*/ |
function _getCheminHTML( ) |
{ |
$path = "" ; |
return $path ; |
} // end of member function _getCheminHTML |
/** |
* Renvoie une chaine contenant le code html des icones des actions possibles sur un |
* fichier, c'est à dire couper, modifier, supprimer. |
* |
* @return string |
* @access private |
*/ |
function _actions($document) |
{ |
$this->_url->addQueryString ('id_document', $document->getIdDocument()) ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["couper"]) ; |
$couper = ' '.PROJET_FICHIER_COUPER ; |
if (!$document->isRepertoire()) $couper = '<a href="'.$this->_url->getURL().'">'.$couper.'</a>' ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["modifier"]) ; |
$modifier = '<a href="'.$this->_url->getURL().'">'.PROJET_FICHIER_MODIFIER.'</a> ' ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["supprimer"]) ; |
$supprimer= '<a href="'.$this->_url->getURL().'" onclick="javascript:return confirm (\''.PROJET_FICHIER_SUPPRIMER.' ?\');">'.PROJET_FICHIER_SUPPRIMER.'</a>' ; |
$this->_url->removeQueryString ('id_document') ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_VOIR_DOCUMENT) ; |
return $modifier.$supprimer.$couper ; |
} // end of member function _action |
} // end of HTML_listeDocuments |
?> |
<?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: AJAX_arbreDocuments.class.php,v 1.1 2007/04/19 09:20:26 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe AJAX_arbreDocuments |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.1 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
// +------------------------------------------------------------------------------------------------------+ |
// | LISTE des constantes | |
// +------------------------------------------------------------------------------------------------------+ |
define ("FICHIER_ICONE_COUPER", "cut.gif") ; |
define ("FICHIER_ICONE_COLLER", "paste.gif") ; |
define ("FICHIER_ICONE_SUPPRIMER", "trash.gif") ; |
define ("FICHIER_ICONE_MODIFIER", "modif.png") ; |
// Appel de la bibliotheque dojo |
include_once PROJET_CHEMIN_CLASSES.'HTML_Liste.class.php'; |
GEN_stockerFichierScript('dojo', 'api/js/dojo/dojo.js', 'text/javascript'); |
/** |
* class HTML_listeDocuments |
* |
*/ |
class AJAX_arbreDocuments extends HTML_Liste |
{ |
/*** Attributes: ***/ |
/** |
* Une url. |
* @access private |
*/ |
var $_url; |
/** |
* Tableau contenant les actions possibles. "couper" => 1, "modifier" => 2, |
* "supprimer" => 3 Elles seront passées en paramètre aux url des icones des |
* documents. |
* @access private |
*/ |
var $_actions = array ("couper" => 1, "modifier" => 2, "supprimer" => 3) ; |
/** |
* Indique le chemin des icones couper, coller, modifier, supprimer. |
* @access private |
*/ |
var $_chemin_icone = "icones/"; |
/** |
* L'identifiant du répertoire que l'on est en train d'observer. |
* @access private |
*/ |
var $_id_repertoire; |
/** |
* Un tableau contenant les id et les noms du chemin des répertoires. 0 => ["id"], |
* ["nom"] etc. |
* @access private |
*/ |
var $_chemin_navigation = array (); |
/** |
* un pointeur vers une authentificatin PEAR |
* @access private |
*/ |
var $_auth ; |
/** |
* |
* |
* @param bool utilise_pager Indique l'utilisation ou non du Pager. |
* @return void |
* @access public |
*/ |
function AJAX_arbreDocuments(&$url, $utilise_pager = false, $id_repertoire = 0, $auth = '' ) |
{ |
//HTML_Liste::HTML_Liste($utilise_pager, array('class' => 'table_cadre')) ; |
$this->_url = $url ; |
$this->_id_repertoire = $id_repertoire ; |
if (is_object($auth)) { |
$this->_auth = $auth ; |
} |
} // end of member function HTML_listeDocuments |
function AJAX_construitListe($id_projet, $droits, $mode = '', $objetDB = '') { |
GEN_stockerFichierScript('dojoScriptProjet', 'client/projet/js/arbreDocument.js'); |
$res = '' ; |
$RCPUrl = PROJET_CHEMIN_APPLI.'services/ecouteArbreFichier.php?id_projet='.$id_projet; |
// Le noeud racine |
$res .= '<div dojoType="TreeLoadingController" RPCUrl="'.$RCPUrl.'" widgetId="treeController" DNDController="create"></div> |
<div dojoType="TreeSelector" widgetId="treeSelector"></div> |
<div dojoType="Tree" DNDMode="between" selector="treeSelector" DNDAcceptTypes="bandTree" widgetId="bandTree" controller="treeController" eventNames="moveTo:nodeRemoved"> |
<div dojoType="TreeNode" title="Racine" widgetId="eisleyRoot" objectId="root" isFolder="true"></div>'; |
return $res ; |
} |
/** |
* |
* |
* @param bool utilise_pager Voir HTML_listeDocuments |
* @return void |
* @access public |
*/ |
function __construct( &$url, $utilise_pager = false, $id_repertoire = 0, $auth = '' ) |
{ |
$this->AJAX_arbreDocuments($url, $utilise_pager, $id_repertoire, $auth); |
} // end of member function __construct |
/** |
* |
* |
* @param Array tableau_label Un tableau contenant les labels à afficher dans l'entête. |
* @return void |
* @access public |
*/ |
function construitEntete( $tableau_label ) |
{ |
$this->addRow ($tableau_label, NULL, 'TH') ; |
} // end of member function construitEntete |
/** |
* |
* |
* @param Array tableau_label Un tableau à deux dimensions avec les labels à afficher dans le corps du |
* tableau. |
* @return void |
* @access public |
*/ |
function construitListe( &$tableau_document, $droits, $mode = '', $objetDB = '') |
{ |
$compteur = 0 ;$class[0] = 'ligne_impaire'; $class[1] = 'ligne_paire' ; |
for ($i = 0; $i < count ($tableau_document) ; $i++) { |
// Première condition : est-ce que le fichier a pour père le répertoire courant, si oui on l'affiche |
if ($tableau_document[$i]->_id_pere == $this->_id_repertoire || $mode == 'ignore_repertoire') { |
// d'abord l'image |
$icone = '<img src="'.$tableau_document[$i]->getCheminIcone().'" />' ; |
// Si le document est un répertoire, on ajoute id_repertoire au lien. |
if ($tableau_document[$i]->isRepertoire()) { |
$this->_url->addQueryString ('id_repertoire', $tableau_document[$i]->getChemin()) ; |
$lien = $this->_url->getURL() ; |
} else { // Si c'est un fichier, on fait un lien direct |
$lien = $tableau_document[$i]->getChemin() ; |
} |
// pour éviter des effets de bords, on enlève id_repertoire de l'url |
// dans le cas d'un répertoire, pour les fichiers on le laisse pour |
// qu'après une opération, on reste dans le répertoire où a eu lieu l'opération |
if ($tableau_document[$i]->isRepertoire()) $this->_url->removeQueryString('id_repertoire') ; |
// on insère le lien |
$lien_nom = '<a href="'.$lien.'">'.$icone.' '.$tableau_document[$i]->getNomLong()."</a>\n" ; |
// Pour la taille on divise par 1000 et on écrit Ko |
$taille = round($tableau_document[$i]->getTaille() / 1000).' Ko' ; |
// Récupération de l'auteur |
include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ; |
$annuaire = new annuaire($objetDB, array('table' => PROJET_ANNUAIRE, 'identifiant' => PROJET_CHAMPS_ID, |
'nom' => PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ; |
$annuaire->setId($tableau_document[$i]->_id_proprietaire) ; |
$nom_prenom = $annuaire->getInfo('nom').' '.$annuaire->getInfo('prenom') ; |
// On rempli le tableau à donner en paramètre à HTML_Table avec toutes ces infos, une par colonne |
$ligne_tableau = array($lien_nom, $taille, $nom_prenom, $tableau_document[$i]->getDateMiseAJour()) ; |
if ($droits <= PROJET_DROIT_CONTRIBUTEUR) array_push ($ligne_tableau, $tableau_document[$i]->getVisibilite()) ; |
// On ajoute au tableau, les action couper / modifier / supprimer |
if ($droits <= PROJET_DROIT_COORDINATEUR || $this->_auth->getAuthData(PROJET_CHAMPS_ID) == $tableau_document[$i]->_id_proprietaire) |
array_push ($ligne_tableau, $this->_actions ($tableau_document[$i])) ; |
if ($tableau_document[$i]->getVisibilite() != 'prive' || $droits < PROJET_DROIT_AUCUN) { |
$this->addRow ($ligne_tableau, array('class' => $class[$compteur]), 'TD', true) ; |
// enfin , s'il y a une description, on l'ajoute, mais sur une ligne entière (colspan) |
if ($tableau_document[$i]->getDescription() != "") { |
$this->addRow (array ($tableau_document[$i]->getDescription()), |
array ('colspan' => $this->getColCount(), 'class' => $class[$compteur])) ; |
$this->updateRowAttributes ($this->getRowCount()-1, array ('class' => $class[$compteur]), true) ; |
} |
} |
$compteur++; |
} |
if ($compteur == 2) $compteur = 0 ; |
} |
$this->updateColAttributes(0, array ('class' => 'col1')) ; |
} // end of member function construitListe |
/** |
* |
* |
* @param Array actions Un tableau avec les valeurs d'actions comme clé. "couper", modifier", |
* "supprimer". |
* @return void |
* @access public |
*/ |
function setAction( $actions ) |
{ |
$this->_actions = $actions ; |
} // end of member function setAction |
/** |
* |
* |
* @param string chemin Le chemin vers les icones couper, coller ... |
* @return void |
* @access public |
*/ |
function setCheminIcones( $chemin ) |
{ |
$this->_chemin_icone = $chemin ; |
} // end of member function setCheminIcones |
/** |
* Surcharge de l'opération de la classe mère. Ajoute la navigation dans les |
* répertoires. |
* |
* @return string |
* @access public |
*/ |
function toHTML( ) |
{ |
$chemin_navig = "" ; |
if ($this->_id_repertoire != "") { |
$this->_url->removeQueryString(PROJET_VARIABLE_ID_REPERTOIRE) ; |
$chemin_navig = "<p>" ; |
$chemin_navig .= "<a href=\"".$this->_url->getURL()."\">".PROJET_RACINE."</a>\n" ; |
$this->_url->addQueryString(PROJET_VARIABLE_ID_REPERTOIRE, $this->_id_repertoire) ; |
for ($i = 0; $i < count ($this->_chemin_navigation); $i+=2) { |
$chemin_navig .= "> " ; |
$nom = $this->_chemin_navigation[$i+1] ; |
$this->_url->addQueryString ('id_repertoire', $this->_chemin_navigation[$i]) ; |
$chemin_navig .= "<a href=\"".$this->_url->getURL()."\">".$nom."</a>\n" ; |
} |
$chemin_navig .= "</p>\n" ; |
} |
$res = $chemin_navig.HTML_Liste::toHTML() ; |
if ($this->getRowCount() == 1 && $this->_id_repertoire == '') { |
return '<div>'.PROJET_PAS_DE_DOCUMENTS.'</div>'."\n"; |
} |
return $res ; |
} // end of member function toHTML |
/** |
* |
* |
* @param Array tableau_navigation Un tableau contenant les identifiants et les noms des répertoires. 0 => ["id"], |
* ["nom"] etc. |
* @return void |
* @access public |
*/ |
function setCheminNavigation( $tableau_navigation ) |
{ |
$this->_chemin_navigation = $tableau_navigation ; |
} // end of member function setCheminNavigation |
/** |
* Affiche la légende des actions du module "documents" |
* |
* @return string |
* @access public |
*/ |
function affLegende( ) |
{ |
$res = "<h2 class=\"titre2_projet\">".PROJET_LEGENDE."</h2>\n" ; |
$res .= "<p><img src=\"".$this->_chemin_icone."/cut.gif\" title=\"couper\" alt=\"couper\">".PROJET_LEGENDE_DEPLACE."</p>\n" ; |
$res .= "<p><img src=\"".$this->_chemin_icone."/modif.png\" title=\"modifier\" alt=\"modifier\"> ".PROJET_LEGENDE_MODIFIE."</p>\n" ; |
$res .= "<p><img src=\"".$this->_chemin_icone."/trash.gif\" title=\"supprimer\" alt=\"supprimer\"> ".PROJET_LEGENDE_SUPPR."</p>\n" ; |
return $res ; |
} // end of member function affLegende |
/** |
* Renvoie le chemin HTML, depuis le répertoire courant jusqu'à la racine. |
* |
* @return string |
* @access private |
*/ |
function _getCheminHTML( ) |
{ |
$path = "" ; |
return $path ; |
} // end of member function _getCheminHTML |
/** |
* Renvoie une chaine contenant le code html des icones des actions possibles sur un |
* fichier, c'est à dire couper, modifier, supprimer. |
* |
* @return string |
* @access private |
*/ |
function _actions($document) |
{ |
$this->_url->addQueryString ('id_document', $document->getIdDocument()) ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["couper"]) ; |
$couper = ' '.PROJET_FICHIER_COUPER ; |
if (!$document->isRepertoire()) $couper = '<a href="'.$this->_url->getURL().'">'.$couper.'</a>' ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["modifier"]) ; |
$modifier = '<a href="'.$this->_url->getURL().'">'.PROJET_FICHIER_MODIFIER.'</a> ' ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["supprimer"]) ; |
$supprimer= '<a href="'.$this->_url->getURL().'" onclick="javascript:return confirm (\''.PROJET_FICHIER_SUPPRIMER.' ?\');">'.PROJET_FICHIER_SUPPRIMER.'</a>' ; |
$this->_url->removeQueryString ('id_document') ; |
$this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_VOIR_DOCUMENT) ; |
return $modifier.$supprimer.$couper ; |
} // end of member function _action |
} // end of HTML_listeDocuments |
?> |
/trunk/classes/gestion_wikini.class.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: gestion_wikini.class.php,v 1.2 2005-09-27 16:38:54 alexandre_tb Exp $ |
// CVS : $Id: gestion_wikini.class.php,v 1.2 2005/09/27 16:38:54 alexandre_tb Exp $ |
/** |
* Application projet |
* |
/trunk/classes/liste_discussion.class.php |
---|
1,294 → 1,288 |
<?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: liste_discussion.class.php,v 1.4 2008-08-25 15:12:24 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe liste_discussion |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.4 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
require_once GEN_CHEMIN_API.'sql/SQL_manipulation.fonct.php' ; |
/** |
* class liste_discussion |
* |
*/ |
class liste_discussion |
{ |
/*** Attributes: ***/ |
/** |
* Le nom de la liste, sans le domaine. |
* @access private |
*/ |
var $_nom; |
/** |
* |
* @access private |
*/ |
var $_adresse; |
/** |
* Le domaine de la liste |
* @access private |
*/ |
var $_domaine; |
/** |
* |
* @access private |
*/ |
var $_adresse_inscription; |
/** |
* |
* @access private |
*/ |
var $_adresse_desinscription; |
/** |
* |
* @access private |
*/ |
var $_adresse_aide; |
/** |
* Une connexion PEAR::DB |
* @access private |
*/ |
var $_db; |
/** |
* L'identifiant de la liste. |
* @access private |
*/ |
var $_id; |
/** |
* |
* @access private |
*/ |
var $_adresse_inscription_resume; |
/** |
* Indique la portee, publique ou privee de la liste |
* @access private |
*/ |
var $_portee; |
/** |
* Le constructeur |
* |
* @param int id_liste L'identifiant de la liste souhaité |
* @param DB objetDB Un objet PEAR:DB |
* @return void |
* @access public |
*/ |
function liste_discussion( $id_liste, & $objetDB ) |
{ |
$this->_db = $objetDB ; |
if ($id_liste != '') { |
$this->_id = $id_liste ; |
$requete_liste = 'select * from projet_liste where pl_id_liste='.$this->_db->escapeSimple($this->_id) ; |
$resultat_liste = $this->_db->query ($requete_liste) ; |
if (DB::isError ($resultat_liste)) { |
die ("Echec de la requete : $requete_liste<br />".$resultat_liste->getMessage()) ; |
} |
$ligne_liste = $resultat_liste->fetchRow(DB_FETCHMODE_OBJECT) ; |
$this->_adresse = $ligne_liste->pl_adresse_liste ; |
$this->_domaine = $ligne_liste->pl_domaine ; |
$this->_nom = $ligne_liste->pl_nom_liste ; |
$this->_adresse_inscription = $ligne_liste->pl_adresse_inscription ; |
$this->_adresse_inscription_resume = $ligne_liste->pl_nom_liste.'-digest-subscribe@'.$this->_domaine ; |
$this->_portee = $ligne_liste->pl_visibilite ; |
} |
} // end of member function liste_discussion |
/** |
* Renvoie le domaine de la liste |
* |
* @return string |
* @access public |
*/ |
function getDomaine( ) |
{ |
return $this->_domaine ; |
} // end of member function getDomaine |
/** |
* Renvoie le nom de la liste |
* |
* @return string |
* @access public |
*/ |
function getNom( ) |
{ |
return $this->_nom ; |
} // end of member function getNom |
/** |
* Renvoie l'identifiant de la liste |
* |
* @return integer |
* @access public |
*/ |
function getId( ) |
{ |
return $this->_id ; |
} // end of member function getNom |
function getVisibilite( ) |
{ |
return $this->_portee ; |
} // end of member function getNom |
/** |
* Enregistre une ligne dans la table projet_liste |
* Le tableau de valeur doit contenir les éléments suivants 'nom_liste','','domaine_liste' |
* |
* @param Array tableau_de_valeur Le tableau de valeur a insérer dans la base avec pour clé les noms des éléments |
* @access public |
* @return void |
*/ |
function enregistrerSQL ($valeur) { |
$id = SQL_obtenirNouveauId($this->_db, 'projet_liste', 'pl_id_liste') ; |
$requete = "insert into projet_liste set pl_id_liste=".$this->_db->escapeSimple($id) ; |
$requete .= ", pl_nom_liste=\"".$valeur['nom_liste']."\", pl_domaine=\"".$valeur['domaine_liste']."\"". |
", pl_adresse_liste=\"".$valeur['nom_liste'].'@'.$valeur['domaine_liste'].'", pl_adresse_inscription="'. |
$valeur['nom_liste']."-subscribe@".$valeur['domaine_liste'].'",pl_adresse_desinscription="'. |
$valeur['nom_liste']."-unsubscribe@".$valeur['domaine_liste'].'", pl_adresse_aide="'. |
$valeur['nom_liste']."-help@".$valeur['domaine_liste'].'", pl_visibilite="'.$valeur['liste_visibilite'].'"' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$this->_id = $id ; |
$this->_domaine = $valeur['domaine_liste'] ; |
$this->_nom = $valeur['nom_liste'] ; |
return $id; |
} |
/** |
* |
* |
* @param string code_sql |
* @return bool |
* @access public |
*/ |
function suppressionSQL() |
{ |
$requete = "delete from projet_liste where pl_id_liste=".$this->_db->escapeSimple($this->_id) ; |
$resultat = $this->_db->query ($requete) ; |
return true ; |
} // end of member function suppressionSQL |
/** |
* Vérifie si une liste existe déjà dans la table projet_liste. |
* |
* @param string adresse_liste L'adresse de la liste à tester |
* @param DB objetDB Un objet PEAR::DB |
* @return bool |
* @static |
* @access public |
*/ |
function verifieDoubleListe( $adresse_liste, &$objetDB ) |
{ |
$requete = 'select pl_id_liste from projet_liste where pl_adresse_liste="'.$adresse_liste.'"' ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ; |
} |
if ($resultat->numRows()) { |
return false; |
} |
return true ; |
} // end of member function verifieDoubleListe |
/** |
* Renvoie l'adresse de la liste |
* |
* @return string |
* @access public |
*/ |
function getAdresseEnvoi( ) |
{ |
return $this->_adresse ; |
} // end of member function getAdresseEnvoi |
/** |
* Renvoie l'adresse de la liste |
* |
* @return string |
* @access public |
*/ |
function getAdresseInscription( ) |
{ |
return $this->_adresse_inscription ; |
} // end of member function getAdresseEnvoi |
/** |
* |
* |
* @return string |
* @access public |
*/ |
function getAdresseResume( ) |
{ |
return $this->_adresse_inscription_resume ; |
} // end of member function getAdresseResume |
/** |
* |
* |
* @return string |
* @access public |
*/ |
function isPublic( ) |
{ |
return $this->_portee ; |
} // end of member function getAdresseResume |
} // end of liste_discussion |
?> |
<?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: liste_discussion.class.php,v 1.3 2007-04-19 15:34:35 neiluj Exp $ |
/** |
* Application projet |
* |
* La classe liste_discussion |
* |
*@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 | |
// +------------------------------------------------------------------------------------------------------+ |
require_once GEN_CHEMIN_API.'sql/SQL_manipulation.fonct.php' ; |
/** |
* class liste_discussion |
* |
*/ |
class liste_discussion |
{ |
/*** Attributes: ***/ |
/** |
* Le nom de la liste, sans le domaine. |
* @access private |
*/ |
var $_nom; |
/** |
* |
* @access private |
*/ |
var $_adresse; |
/** |
* Le domaine de la liste |
* @access private |
*/ |
var $_domaine; |
/** |
* |
* @access private |
*/ |
var $_adresse_inscription; |
/** |
* |
* @access private |
*/ |
var $_adresse_desinscription; |
/** |
* |
* @access private |
*/ |
var $_adresse_aide; |
/** |
* Une connexion PEAR::DB |
* @access private |
*/ |
var $_db; |
/** |
* L'identifiant de la liste. |
* @access private |
*/ |
var $_id; |
/** |
* |
* @access private |
*/ |
var $_adresse_inscription_resume; |
/** |
* Indique la portee, publique ou privee de la liste |
* @access private |
*/ |
var $_portee; |
/** |
* Le constructeur |
* |
* @param int id_liste L'identifiant de la liste souhait� |
* @param DB objetDB Un objet PEAR:DB |
* @return void |
* @access public |
*/ |
function liste_discussion( $id_liste, & $objetDB ) |
{ |
$this->_db = $objetDB ; |
if ($id_liste != '') { |
$this->_id = $id_liste ; |
$requete_liste = 'select * from projet_liste where pl_id_liste='.$this->_db->escapeSimple($this->_id) ; |
$resultat_liste = $this->_db->query ($requete_liste) ; |
if (DB::isError ($resultat_liste)) { |
die ("Echec de la requete : $requete_liste<br />".$resultat_liste->getMessage()) ; |
} |
$ligne_liste = $resultat_liste->fetchRow(DB_FETCHMODE_OBJECT) ; |
$this->_adresse = $ligne_liste->pl_adresse_liste ; |
$this->_domaine = $ligne_liste->pl_domaine ; |
$this->_nom = $ligne_liste->pl_nom_liste ; |
$this->_adresse_inscription = $ligne_liste->pl_adresse_inscription ; |
$this->_adresse_inscription_resume = $ligne_liste->pl_nom_liste.'-digest-subscribe@'.$this->_domaine ; |
$this->_portee = $ligne_liste->pl_visibilite ; |
} |
} // end of member function liste_discussion |
/** |
* Renvoie le domaine de la liste |
* |
* @return string |
* @access public |
*/ |
function getDomaine( ) |
{ |
return $this->_domaine ; |
} // end of member function getDomaine |
/** |
* Renvoie le nom de la liste |
* |
* @return string |
* @access public |
*/ |
function getNom( ) |
{ |
return $this->_nom ; |
} // end of member function getNom |
/** |
* Renvoie l'identifiant de la liste |
* |
* @return integer |
* @access public |
*/ |
function getId( ) |
{ |
return $this->_id ; |
} // end of member function getNom |
function getVisibilite( ) |
{ |
return $this->_portee ; |
} // end of member function getNom |
/** |
* Enregistre une ligne dans la table projet_liste |
* Le tableau de valeur doit contenir les �l�ments suivants 'nom_liste','','domaine_liste' |
* |
* @param Array tableau_de_valeur Le tableau de valeur a ins�rer dans la base avec pour cl� les noms des �l�ments |
* @access public |
* @return void |
*/ |
function enregistrerSQL ($valeur) { |
$id = SQL_obtenirNouveauId($this->_db, 'projet_liste', 'pl_id_liste') ; |
$requete = "insert into projet_liste set pl_id_liste=".$this->_db->escapeSimple($id) ; |
$requete .= ", pl_nom_liste=\"".$valeur['nom_liste']."\", pl_domaine=\"".$valeur['domaine_liste']."\"". |
", pl_adresse_liste=\"".$valeur['nom_liste'].'@'.$valeur['domaine_liste'].'", pl_adresse_inscription="'. |
$valeur['nom_liste']."-subscribe@".$valeur['domaine_liste'].'",pl_adresse_desinscription="'. |
$valeur['nom_liste']."-unsubscribe@".$valeur['domaine_liste'].'", pl_adresse_aide="'. |
$valeur['nom_liste']."-help@".$valeur['domaine_liste'].'", pl_visibilite="'.$valeur['liste_visibilite'].'"' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$this->_id = $id ; |
$this->_domaine = $valeur['domaine_liste'] ; |
$this->_nom = $valeur['nom_liste'] ; |
return $id; |
} |
/** |
* |
* |
* @param string code_sql |
* @return bool |
* @access public |
*/ |
function suppressionSQL() |
{ |
$requete = "delete from projet_liste where pl_id_liste=".$this->_db->escapeSimple($this->_id); |
$resultat = $this->_db->query ($requete) ; |
return true ; |
} // end of member function suppressionSQL |
/** |
* V�rifie si une liste existe d�j� dans la table projet_liste. |
* |
* @param string adresse_liste L'adresse de la liste � tester |
* @param DB objetDB Un objet PEAR::DB |
* @return bool |
* @static |
* @access public |
*/ |
function verifieDoubleListe( $adresse_liste, &$objetDB ) |
{ |
$requete = 'select pl_id_liste from projet_liste where pl_adresse_liste="'.$adresse_liste.'"' ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ; |
} |
if ($resultat->numRows()) { |
return false; |
} |
return true ; |
} // end of member function verifieDoubleListe |
/** |
* Renvoie l'adresse de la liste |
* |
* @return string |
* @access public |
*/ |
function getAdresseEnvoi( ) |
{ |
return $this->_adresse ; |
} // end of member function getAdresseEnvoi |
/** |
* Renvoie l'adresse de la liste |
* |
* @return string |
* @access public |
*/ |
function getAdresseInscription( ) |
{ |
return $this->_adresse_inscription ; |
} // end of member function getAdresseEnvoi |
/** |
* |
* |
* @return string |
* @access public |
*/ |
function getAdresseResume( ) |
{ |
return $this->_adresse_inscription_resume ; |
} // end of member function getAdresseResume |
/** |
* |
* |
* @return string |
* @access public |
*/ |
function isPublic( ) |
{ |
return $this->_portee ; |
} // end of member function getAdresseResume |
} // end of liste_discussion |
?> |
/trunk/classes/statut.class.php |
---|
1,138 → 1,138 |
<?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: statut.class.php,v 1.2 2005-09-27 16:42:00 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe statut |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.2 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
define ('PROJET_STATUT_TOUS', 1) ; |
define ('PROJET_STATUT_SAUF_ADM', 2) ; |
define ('PROJET_STATUT_SAUF_ADM_COORD', 3) ; |
/** |
* class statut |
* |
*/ |
class statut |
{ |
/** Aggregations: */ |
/** Compositions: */ |
/*** Attributes: ***/ |
/** |
* L'identifiant du statut |
* @access private |
*/ |
var $_id_statut; |
/** |
* Le label du statut, dans la table. |
* @access private |
*/ |
var $_label; |
/** |
* Un objet PEAR::DB |
* @access private |
*/ |
var $_db; |
/** |
* Constructeur. |
* |
* @param int id_statut L'identifiant du statut créé. |
* @param DB objetDB Un objet PEAR::DB |
* @return void |
* @access public |
*/ |
function statut( $id_statut, &$objetDB ) |
{ |
$requete = "select * from projet_statut where ps_id_statut=".$this->_db->escapeSimple($id_statut)." " ; |
$resultat = $objetDB->query ($requete) ; |
if (PEAR::isError ($resultat)) { |
die ($resultat->getMessage()."<br />".$requete."<br />") ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
$this->_db = $objetDB ; |
$this->_id_statut = $ligne->pd_id_statut ; |
$this->_label = $ligne->ps_statut_nom; |
} // end of member function statut |
/** |
* Renvoie le label du statut. |
* |
* @return string |
* @access public |
*/ |
function getLabel( ) |
{ |
return $this->_label ; |
} // end of member function getLabel |
/** |
* |
* |
* @param int type_statut Indique quels statuts l'on désire voir retourner PROJET_STATUT_TOUS |
* PROJET_STATUT_SAUF_ADM PROJET_STATUT_SAUF_ADM_COORD |
* @return Array |
* @static |
* @access public |
*/ |
function getTousLesStatuts( $type_statut = PROJET_STATUT_TOUS, &$objetDB) |
{ |
$requete = 'select * from projet_statut' ; |
if ($type_statut == PROJET_STATUT_SAUF_ADM) { |
$requete .= ' where ps_id_statut <> 0' ; |
} |
if ($type_statut == PROJET_STATUT_SAUF_ADM_COORD) { |
$requete .= ' where ps_id_statut > 1' ; |
} |
$resultat = $objetDB->query ($requete) ; |
$tableau_resultat = array(); |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$tableau_resultat[$ligne->ps_id_statut] = $ligne->ps_statut_nom ; |
} |
return $tableau_resultat; |
} // end of member function getTousLesStatuts |
} // end of statut |
?> |
<?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: statut.class.php,v 1.2 2005/09/27 16:42:00 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe statut |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.2 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
define ('PROJET_STATUT_TOUS', 1) ; |
define ('PROJET_STATUT_SAUF_ADM', 2) ; |
define ('PROJET_STATUT_SAUF_ADM_COORD', 3) ; |
/** |
* class statut |
* |
*/ |
class statut |
{ |
/** Aggregations: */ |
/** Compositions: */ |
/*** Attributes: ***/ |
/** |
* L'identifiant du statut |
* @access private |
*/ |
var $_id_statut; |
/** |
* Le label du statut, dans la table. |
* @access private |
*/ |
var $_label; |
/** |
* Un objet PEAR::DB |
* @access private |
*/ |
var $_db; |
/** |
* Constructeur. |
* |
* @param int id_statut L'identifiant du statut créé. |
* @param DB objetDB Un objet PEAR::DB |
* @return void |
* @access public |
*/ |
function statut( $id_statut, &$objetDB ) |
{ |
$requete = "select * from projet_statut where ps_id_statut=".$objetDB->escapeSimple($id_statut)." " ; |
$resultat = $objetDB->query ($requete) ; |
if (PEAR::isError ($resultat)) { |
die ($resultat->getMessage()."<br />".$requete."<br />") ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
$this->_db = $objetDB ; |
$this->_id_statut = $ligne->pd_id_statut ; |
$this->_label = $ligne->ps_statut_nom; |
} // end of member function statut |
/** |
* Renvoie le label du statut. |
* |
* @return string |
* @access public |
*/ |
function getLabel( ) |
{ |
return $this->_label ; |
} // end of member function getLabel |
/** |
* |
* |
* @param int type_statut Indique quels statuts l'on désire voir retourner PROJET_STATUT_TOUS |
* PROJET_STATUT_SAUF_ADM PROJET_STATUT_SAUF_ADM_COORD |
* @return Array |
* @static |
* @access public |
*/ |
function getTousLesStatuts( $type_statut = PROJET_STATUT_TOUS, &$objetDB) |
{ |
$requete = 'select * from projet_statut' ; |
if ($type_statut == PROJET_STATUT_SAUF_ADM) { |
$requete .= ' where ps_id_statut <> 0' ; |
} |
if ($type_statut == PROJET_STATUT_SAUF_ADM_COORD) { |
$requete .= ' where ps_id_statut > 1' ; |
} |
$resultat = $objetDB->query ($requete) ; |
$tableau_resultat = array(); |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
$tableau_resultat[$ligne->ps_id_statut] = $ligne->ps_statut_nom ; |
} |
return $tableau_resultat; |
} // end of member function getTousLesStatuts |
} // end of statut |
?> |
/trunk/classes/statut_liste.class.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: statut_liste.class.php,v 1.2 2005-09-27 16:42:00 alexandre_tb Exp $ |
// CVS : $Id: statut_liste.class.php,v 1.2 2005/09/27 16:42:00 alexandre_tb Exp $ |
/** |
* Application projet |
* |
/trunk/classes/projet_theme.class.php |
---|
1,103 → 1,103 |
<?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: projet_theme.class.php,v 1.1 2008-08-25 15:09:39 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe projet_theme |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2008 |
*@version $Revision: 1.1 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class projet_type |
* |
*/ |
class projet_theme |
{ |
/*** Attributes: ***/ |
/** |
* Une connection vers une base de donnée |
* @access private |
*/ |
var $_db; |
/** |
* Renvoie tous types de projets (de la table projet_type) ans un tableau avec pour |
* clé l'identifiant et pour valeur le label. |
* |
* @return Array |
* @static |
* @access public |
*/ |
function getTousLesThemes(& $objetDB ) |
{ |
$requete = 'select * from projet_theme' ; |
return $objetDB->getAssoc ($requete) ; |
} |
/** |
* |
* |
* @param DB objetDB Une instance de la classe PEAR::DB |
* @return void |
* @access public |
*/ |
function projet_theme( & $objetDB ) |
{ |
$this->_db = $objetDB ; |
} |
/** |
* |
* |
* @param DB objetDB Une instance de la classe PEAR::DB |
* @return void |
* @access public |
*/ |
function getLabelType( $id_type) |
{ |
$requete = 'select pt_label_theme from projet_theme where pt_id_theme='.$this->_db->escapeSimple($id_type) ; |
$resultat = $this->_db->getOne($requete) ; |
if (DB::isError($resultat)) { |
echo $resultat->getMessage() ; |
} |
return $resultat ; |
} |
} |
?> |
<?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$ |
/** |
* Application projet |
* |
* La classe projet_theme |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2008 |
*@version $Revision:$ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class projet_type |
* |
*/ |
class projet_theme |
{ |
/*** Attributes: ***/ |
/** |
* Une connection vers une base de donnée |
* @access private |
*/ |
var $_db; |
/** |
* Renvoie tous types de projets (de la table projet_type) ans un tableau avec pour |
* clé l'identifiant et pour valeur le label. |
* |
* @return Array |
* @static |
* @access public |
*/ |
function getTousLesThemes(& $objetDB ) |
{ |
$requete = 'select * from projet_theme' ; |
return $objetDB->getAssoc ($requete) ; |
} |
/** |
* |
* |
* @param DB objetDB Une instance de la classe PEAR::DB |
* @return void |
* @access public |
*/ |
function projet_theme( & $objetDB ) |
{ |
$this->_db = $objetDB ; |
} |
/** |
* |
* |
* @param DB objetDB Une instance de la classe PEAR::DB |
* @return void |
* @access public |
*/ |
function getLabelType( $id_type) |
{ |
$requete = 'select pt_label_theme from projet_theme where pt_id_theme='.$this->_db->escapeSimple($id_type) ; |
$resultat = $this->_db->getOne($requete) ; |
if (DB::isError($resultat)) { |
echo $resultat->getMessage() ; |
} |
return $resultat ; |
} |
} |
?> |
/trunk/classes/HTML_listeProjet.class.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: HTML_listeProjet.class.php,v 1.7 2006-09-15 12:35:54 alexandre_tb Exp $ |
// CVS : $Id: HTML_listeProjet.class.php,v 1.7 2006/09/15 12:35:54 alexandre_tb Exp $ |
/** |
* Application projet |
* |
/trunk/classes/ezmlmAccessObject.class.php |
---|
1,354 → 1,355 |
<?php |
//vim: set expandtab tabstop=4 shiftwidth=4: |
// Copyright (C) 1999-2006 Tela Botanica (accueil@tela-botanica.org) |
// |
// Ce logiciel est un programme informatique servant � g�rer du contenu et des |
// applications web. |
// Ce logiciel est regi par la licence CeCILL soumise au droit francais et |
// respectant les principes de diffusion des logiciels libres. Vous pouvez |
// utiliser, modifier et/ou redistribuer ce programme sous les conditions |
// de la licence CeCILL telle que diffusee par le CEA, le CNRS et l'INRIA |
// sur le site "http://www.cecill.info". |
// En contrepartie de l'accessibilite au code source et des droits de copie, |
// de modification et de redistribution accordes par cette licence, il n'est |
// offert aux utilisateurs qu'une garantie limitee. Pour les memes raisons, |
// seule une responsabilite restreinte pese sur l'auteur du programme, le |
// titulaire des droits patrimoniaux et les concedants successifs. |
// A cet egard l'attention de l'utilisateur est attiree sur les risques |
// associes au chargement, a l'utilisation, a la modification et/ou au |
// developpement et a la reproduction du logiciel par l'utilisateur etant |
// donne sa specificite de logiciel libre, qui peut le rendre complexe a |
// manipuler et qui le reserve donc a des developpeurs et des professionnels |
// avertis possedant des connaissances informatiques approfondies. Les |
// utilisateurs sont donc invites a charger et tester l'adequation du |
// logiciel a leurs besoins dans des conditions permettant d'assurer la |
// securite de leurs systemes et ou de leurs donnees et, plus generalement, |
// a l'utiliser et l'exploiter dans les memes conditions de securite. |
// Le fait que vous puissiez acceder a cet en-tete signifie que vous avez |
// pris connaissance de la licence CeCILL, et que vous en avez accepte les |
// termes. |
// ---- |
// CVS : $Id: ezmlmAccessObject.class.php,v 1.6 2008-08-25 15:16:59 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe ezmlmAccessObject |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2006 |
*@version $Revision: 1.6 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
/** Etend XML_Parser_Simple */ |
require_once 'XML/Parser/Simple.php' ; |
/** |
* Les codes erreurs |
*/ |
define ('EZMLM_ACCESS_OBJECT_ACTION_NON_SUPPORTEE', 206) ; |
/** |
* classe ezmlmAccessObject parse les fichiers XML |
* issue de ezmlm |
* |
* @category XML |
* @package projet |
* @author alex |
*/ |
class ezmlmAccessObject extends XML_Parser_Simple { |
/** |
* Le domaine de la liste |
*/ |
var $domaine ; |
/** |
* Le nom de la liste |
*/ |
var $liste ; |
/** |
* Les actions valides |
*/ |
var $actions_supportees = array ('calendrier_messages', |
'message', |
'derniers_messages', |
'messages_auteur', |
'messages_mois', |
'messages_thread', |
'supprimer', |
'liste_abonnes', |
'nombre_messages'); |
/** |
* l'action selectionnee |
*/ |
var $action ; |
/** |
* La langue 'fr-FR' |
*/ |
var $langue ; |
/** |
* L'url de base |
*/ |
var $url ; |
/** |
* L'identifiant du repertoire |
*/ |
var $identifiant_repertoire ; |
/** |
* Identifiant message |
*/ |
var $identifiant_message; |
/** |
* L'identifiant du repertoire |
*/ |
var $_numeroRepertoireSuivant ; |
/** |
* L'identifiant du repertoire |
*/ |
var $hash_auteur ; |
/** |
* Le mois a afficher |
*/ |
var $mois ; |
var $_numeraRepertoirePrecedent; |
/** |
* Identifiant message |
*/ |
var $_numeroFichierSuivant; |
var $_numeroFichierPrecedent; |
var $chemin_fichier_xml; |
/** |
* Creation de l'objet d'acces |
* |
*/ |
function ezmlmAccessObject ($action, $domaine, $liste, $langue = 'fr', $url = '') { |
$this->XML_Parser_Simple(null, 'func') ; |
$this->action = $action ; |
$this->domaine = $domaine ; |
$this->liste = $liste ; |
$this->langue = $langue ; |
$this->url = $url ; |
} |
/** |
* Gestion des balises |
* |
* Cette methode specifie les balises reconnus par ezmlmAccessObject |
* Elle remplace la methode handleElement de XML_Parser_Simple |
* |
* @access public |
* @param string nom de l'element (Voir la doc de PHP) |
* @param array attributes |
* @param |
* @link http://fr.php.net/manual/fr/ref.xml.php manuel |
*/ |
function handleElement_ezmlm_message ($name, $attribs, $data) { |
echo $data ; |
} |
function handleElement_message_suivant ($name, $attribs, $data) { |
$this->_numeroRepertoireSuivant = $attribs['NUMERO_REPERTOIRE'] ; |
$this->_numeroFichierSuivant = $attribs['NUMERO'] ; |
} |
function handleElement_message_precedent ($name, $attribs, $data) { |
$this->_numeroRepertoirePrecedent = $attribs['NUMERO_REPERTOIRE'] ; |
$this->_numeroFichierPrecedent = $attribs['NUMERO'] ; |
} |
function handleElement_ezmlm_calendrier_messages ($name, $attribs, $data) { echo $data ; } |
function handleElement_ezmlm_derniers_messages ($name, $attribs, $data) { echo $data ; } |
function handleElement_ezmlm_messages_auteur ($name, $attribs, $data) { echo $data ; } |
function handleElement_ezmlm_messages_mois ($name, $attribs, $data) { echo $data ; } |
function handleElement_ezmlm_messages_thread ($name, $attribs, $data) { echo $data ; } |
function handleElement_ezmlm_liste_abonnes ($name, $attribs, $data) { echo $data ; } |
function handleElement_ezmlm_nombre_messages ($name, $attribs, $data) { echo $data ; } |
/** |
* Choix de l'action |
* |
* Liste des actions : |
* 'calendrier_messages' |
* |
* @access public |
* @param string une action qui doit etre support� |
*/ |
function setAction($action) { |
// verification de l'action |
if (!in_array($action, $this->actions_supportees)) { |
return raiseError(EZMLM_ACCESS_OBJECT_ACTION_NON_SUPPORTEE) ; |
} |
$this->action = $action ; |
// Libere les ressources (XML_Parser::free) |
$this->free(); |
// On vide l url |
//$this->url = ''; |
$this->chemin_fichier_xml = ''; |
// Charge la nouvelle action |
$this->load() ; |
} |
/** |
* Charge une action |
* |
* cad affecte un fichier xml au parser |
* |
* @access public |
*/ |
function load() { |
$this->chemin_fichier_xml = PROJET_SERVEUR_VPOPMAIL.'/'.$this->action.'.php?domaine='. |
$this->domaine.'&liste='.$this->liste.'&langue='. |
$this->langue ; |
if ($this->url != '') $this->chemin_fichier_xml.= '&url='.urlencode($this->url) ; |
if (isset ($this->identifiant_repertoire)) |
$this->chemin_fichier_xml .= '&actionargs[]='.$this->identifiant_repertoire ; |
if (isset ($this->identifiant_message)) |
$this->chemin_fichier_xml .= '&actionargs[]='.$this->identifiant_message ; |
if (isset ($this->hash_auteur)) |
$this->chemin_fichier_xml .= '&actionargs[]='.$this->hash_auteur ; |
if (isset ($this->mois)) |
$this->chemin_fichier_xml .= '&actionargs[]='.$this->mois ; |
$this->setInputFile($this->chemin_fichier_xml) ; |
} |
/** |
* Precise un message a extraire |
* |
* On indique le numero de repertoire ezmlm et le numero du message |
* @param integer le numero du repertoire |
* @param integer le numero du message |
* |
*/ |
function setIdMessage ($identifiant_repertoire, $identifiant_message) { |
$this->identifiant_repertoire = $identifiant_repertoire ; |
$this->identifiant_message = $identifiant_message ; |
} |
/** |
* Precise un auteur |
* |
* On indique le numero de repertoire ezmlm et le numero du message |
* @param string le hash d'un auteur |
* |
*/ |
function setHashAuteur ($hash_auteur) { |
$this->hash_auteur = $hash_auteur; |
} |
/** |
* Precise un mois |
* |
* On indique le numero de repertoire ezmlm et le num�ro du message |
* @param string le hash d'un auteur |
* |
*/ |
function setMois ($mois) { |
$this->mois = $mois; |
} |
/** |
* Renvoi le numero du repertoire suivant |
* |
* |
*/ |
function getNumeroRepertoireSuivant() { return $this->_numeroRepertoireSuivant; } |
function getNumeroFichierSuivant () { return $this->_numeroFichierSuivant ; } |
function getNumeroRepertoirePrecedent() { return $this->_numeroRepertoirePrecedent; } |
function getNumeroFichierPrecedent () { return $this->_numeroFichierPrecedent ; } |
function getNumeroMessage () { return $this->_numeroMessage ; } |
function getNombreTotalMessage () { return $this->_nombreTotalMessage ; } |
function parse() |
{ |
if (substr(phpversion(), 0, 1) == '5') { |
try { |
$xml = new SimpleXMLElement($this->chemin_fichier_xml, null, true); |
switch ($this->action) { |
case 'calendrier_messages' :echo $xml; |
echo $xml->ezmlm_calendrier_messages; |
break; |
case 'message': |
echo $xml; |
$this->_numeroRepertoirePrecedent = $xml->message_precedent['numero_repertoire']; |
$this->_numeroRepertoireSuivant = $xml->message_suivant['numero_repertoire']; |
$this->_numeroFichierSuivant = $xml->message_suivant['numero']; |
$this->_numeroFichierPrecedent = $xml->message_precedent['numero']; |
$this->_numeroMessage = $xml->numero; |
$this->_nombreTotalMessage = $xml->numero['total_message']; |
break; |
case 'nombre_messages': |
echo $xml[0]; |
break; |
case 'liste_abonnes': |
return $xml; |
break; |
default : |
echo $xml; |
} |
$error = 'Erreur dans l\'accès au fichier:<br />'.$this->chemin_fichier_xml.'<br />'; |
$error = ''; |
throw new Exception($error); |
} |
catch (Exception $e) { |
echo $e->getMessage().'<br />'; |
//echo $this->chemin_fichier_xml; |
} |
} else { |
return parent::parse(); |
} |
} |
} |
?> |
<?php |
//vim: set expandtab tabstop=4 shiftwidth=4: |
// Copyright (C) 1999-2006 Tela Botanica (accueil@tela-botanica.org) |
// |
// Ce logiciel est un programme informatique servant � g�rer du contenu et des |
// applications web. |
// Ce logiciel est regi par la licence CeCILL soumise au droit francais et |
// respectant les principes de diffusion des logiciels libres. Vous pouvez |
// utiliser, modifier et/ou redistribuer ce programme sous les conditions |
// de la licence CeCILL telle que diffusee par le CEA, le CNRS et l'INRIA |
// sur le site "http://www.cecill.info". |
// En contrepartie de l'accessibilite au code source et des droits de copie, |
// de modification et de redistribution accordes par cette licence, il n'est |
// offert aux utilisateurs qu'une garantie limitee. Pour les memes raisons, |
// seule une responsabilite restreinte pese sur l'auteur du programme, le |
// titulaire des droits patrimoniaux et les concedants successifs. |
// A cet egard l'attention de l'utilisateur est attiree sur les risques |
// associes au chargement, a l'utilisation, a la modification et/ou au |
// developpement et a la reproduction du logiciel par l'utilisateur etant |
// donne sa specificite de logiciel libre, qui peut le rendre complexe a |
// manipuler et qui le reserve donc a des developpeurs et des professionnels |
// avertis possedant des connaissances informatiques approfondies. Les |
// utilisateurs sont donc invites a charger et tester l'adequation du |
// logiciel a leurs besoins dans des conditions permettant d'assurer la |
// securite de leurs systemes et ou de leurs donnees et, plus generalement, |
// a l'utiliser et l'exploiter dans les memes conditions de securite. |
// Le fait que vous puissiez acceder a cet en-tete signifie que vous avez |
// pris connaissance de la licence CeCILL, et que vous en avez accepte les |
// termes. |
// ---- |
// CVS : $Id: ezmlmAccessObject.class.php,v 1.5 2007-06-25 12:15:06 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe ezmlmAccessObject |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2006 |
*@version $Revision: 1.5 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
/** Etend XML_Parser_Simple */ |
require_once 'XML/Parser/Simple.php' ; |
/** |
* Les codes erreurs |
*/ |
define ('EZMLM_ACCESS_OBJECT_ACTION_NON_SUPPORTEE', 206) ; |
/** |
* classe ezmlmAccessObject parse les fichiers XML |
* issue de ezmlm |
* |
* @category XML |
* @package projet |
* @author alex |
*/ |
class ezmlmAccessObject extends XML_Parser_Simple { |
/** |
* Le domaine de la liste |
*/ |
var $domaine ; |
/** |
* Le nom de la liste |
*/ |
var $liste ; |
/** |
* Les actions valides |
*/ |
var $actions_supportees = array ('calendrier_messages', |
'message', |
'derniers_messages', |
'messages_auteur', |
'messages_mois', |
'messages_thread', |
'supprimer', |
'liste_abonnes', |
'nombre_messages'); |
/** |
* l'action selectionnee |
*/ |
var $action ; |
/** |
* La langue 'fr-FR' |
*/ |
var $langue ; |
/** |
* L'url de base |
*/ |
var $url ; |
/** |
* L'identifiant du repertoire |
*/ |
var $identifiant_repertoire ; |
/** |
* Identifiant message |
*/ |
var $identifiant_message; |
/** |
* L'identifiant du repertoire |
*/ |
var $_numeroRepertoireSuivant ; |
/** |
* L'identifiant du repertoire |
*/ |
var $hash_auteur ; |
/** |
* Le mois a afficher |
*/ |
var $mois ; |
var $_numeraRepertoirePrecedent; |
/** |
* Identifiant message |
*/ |
var $_numeroFichierSuivant; |
var $_numeroFichierPrecedent; |
var $chemin_fichier_xml; |
/** |
* Creation de l'objet d'acces |
* |
*/ |
function ezmlmAccessObject ($action, $domaine, $liste, $langue = 'fr', $url = '') { |
$this->XML_Parser_Simple(null, 'func') ; |
$this->action = $action ; |
$this->domaine = $domaine ; |
$this->liste = $liste ; |
$this->langue = $langue ; |
$this->url = $url ; |
} |
/** |
* Gestion des balises |
* |
* Cette methode specifie les balises reconnus par ezmlmAccessObject |
* Elle remplace la methode handleElement de XML_Parser_Simple |
* |
* @access public |
* @param string nom de l'element (Voir la doc de PHP) |
* @param array attributes |
* @param |
* @link http://fr.php.net/manual/fr/ref.xml.php manuel |
*/ |
function handleElement_ezmlm_message ($name, $attribs, $data) { |
echo $data ; |
} |
function handleElement_message_suivant ($name, $attribs, $data) { |
$this->_numeroRepertoireSuivant = $attribs['NUMERO_REPERTOIRE'] ; |
$this->_numeroFichierSuivant = $attribs['NUMERO'] ; |
} |
function handleElement_message_precedent ($name, $attribs, $data) { |
$this->_numeroRepertoirePrecedent = $attribs['NUMERO_REPERTOIRE'] ; |
$this->_numeroFichierPrecedent = $attribs['NUMERO'] ; |
} |
function handleElement_ezmlm_calendrier_messages ($name, $attribs, $data) { echo $data ; } |
function handleElement_ezmlm_derniers_messages ($name, $attribs, $data) { echo $data ; } |
function handleElement_ezmlm_messages_auteur ($name, $attribs, $data) { echo $data ; } |
function handleElement_ezmlm_messages_mois ($name, $attribs, $data) { echo $data ; } |
function handleElement_ezmlm_messages_thread ($name, $attribs, $data) { echo $data ; } |
function handleElement_ezmlm_liste_abonnes ($name, $attribs, $data) { echo $data ; } |
function handleElement_ezmlm_nombre_messages ($name, $attribs, $data) { echo $data ; } |
/** |
* Choix de l'action |
* |
* Liste des actions : |
* 'calendrier_messages' |
* |
* @access public |
* @param string une action qui doit etre support� |
*/ |
function setAction($action) { |
// verification de l'action |
if (!in_array($action, $this->actions_supportees)) { |
return raiseError(EZMLM_ACCESS_OBJECT_ACTION_NON_SUPPORTEE) ; |
} |
$this->action = $action ; |
// Libere les ressources (XML_Parser::free) |
$this->free(); |
// On vide l url |
//$this->url = ''; |
$this->chemin_fichier_xml = ''; |
// Charge la nouvelle action |
$this->load() ; |
} |
/** |
* Charge une action |
* |
* cad affecte un fichier xml au parser |
* |
* @access public |
*/ |
function load() { |
$this->chemin_fichier_xml = PROJET_SERVEUR_VPOPMAIL.'/'.$this->action.'.php?domaine='. |
$this->domaine.'&liste='.$this->liste.'&langue='. |
$this->langue ; |
if ($this->url != '') $this->chemin_fichier_xml.= '&url='.urlencode($this->url) ; |
if (isset ($this->identifiant_repertoire)) |
$this->chemin_fichier_xml .= '&actionargs[]='.$this->identifiant_repertoire ; |
if (isset ($this->identifiant_message)) |
$this->chemin_fichier_xml .= '&actionargs[]='.$this->identifiant_message ; |
if (isset ($this->hash_auteur)) |
$this->chemin_fichier_xml .= '&actionargs[]='.$this->hash_auteur ; |
if (isset ($this->mois)) |
$this->chemin_fichier_xml .= '&actionargs[]='.$this->mois ; |
$this->setInputFile($this->chemin_fichier_xml) ; |
} |
/** |
* Precise un message a extraire |
* |
* On indique le numero de repertoire ezmlm et le numero du message |
* @param integer le numero du repertoire |
* @param integer le numero du message |
* |
*/ |
function setIdMessage ($identifiant_repertoire, $identifiant_message) { |
$this->identifiant_repertoire = $identifiant_repertoire ; |
$this->identifiant_message = $identifiant_message ; |
} |
/** |
* Precise un auteur |
* |
* On indique le numero de repertoire ezmlm et le numero du message |
* @param string le hash d'un auteur |
* |
*/ |
function setHashAuteur ($hash_auteur) { |
$this->hash_auteur = $hash_auteur; |
} |
/** |
* Precise un mois |
* |
* On indique le numero de repertoire ezmlm et le num�ro du message |
* @param string le hash d'un auteur |
* |
*/ |
function setMois ($mois) { |
$this->mois = $mois; |
} |
/** |
* Renvoi le numero du repertoire suivant |
* |
* |
*/ |
function getNumeroRepertoireSuivant() { return $this->_numeroRepertoireSuivant; } |
function getNumeroFichierSuivant () { return $this->_numeroFichierSuivant ; } |
function getNumeroRepertoirePrecedent() { return $this->_numeroRepertoirePrecedent; } |
function getNumeroFichierPrecedent () { return $this->_numeroFichierPrecedent ; } |
function getNumeroMessage () { return $this->_numeroMessage ; } |
function getNombreTotalMessage () { return $this->_nombreTotalMessage ; } |
function parse() |
{ |
if (substr(phpversion(), 0, 1) == '5') { |
try { |
$xml = new SimpleXMLElement($this->chemin_fichier_xml, null, true); |
switch ($this->action) { |
case 'calendrier_messages' :echo utf8_decode($xml); |
trigger_error ($this->chemin_fichier_xml); |
echo utf8_decode($xml->ezmlm_calendrier_messages); |
break; |
case 'message': |
echo utf8_decode ($xml); |
$this->_numeroRepertoirePrecedent = $xml->message_precedent['numero_repertoire']; |
$this->_numeroRepertoireSuivant = $xml->message_suivant['numero_repertoire']; |
$this->_numeroFichierSuivant = $xml->message_suivant['numero']; |
$this->_numeroFichierPrecedent = $xml->message_precedent['numero']; |
$this->_numeroMessage = $xml->numero; |
$this->_nombreTotalMessage = $xml->numero['total_message']; |
break; |
case 'nombre_messages': |
echo $xml[0]; |
break; |
case 'liste_abonnes': |
return $xml; |
break; |
default : |
echo utf8_decode($xml); |
} |
$error = 'Erreur dans l\'accès au fichier:<br />'.$this->chemin_fichier_xml.'<br />'; |
$error = ''; |
throw new Exception($error); |
} |
catch (Exception $e) { |
echo $e->getMessage().'<br />'; |
//echo $this->chemin_fichier_xml; |
} |
} else { |
return parent::parse(); |
} |
} |
} |
?> |
/trunk/classes/annuaire.class.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: annuaire.class.php,v 1.5 2006-07-04 09:25:38 alexandre_tb Exp $ |
// CVS : $Id: annuaire.class.php,v 1.5 2006/07/04 09:25:38 alexandre_tb Exp $ |
/** |
* Application annuaire |
* |
/trunk/classes/projet.class.php |
---|
1,1000 → 1,986 |
<?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: projet.class.php,v 1.14 2008-09-16 14:11:05 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe projet |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.14 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
include_once PROJET_CHEMIN_CLASSES.'document.class.php' ; |
include_once PROJET_CHEMIN_CLASSES.'liste_discussion.class.php' ; |
/* Permet la recuperation d'un nouvel identifiant d'une table.*/ |
require_once PROJET_CHEMIN_BIBLIOTHEQUE_API.'sql/SQL_manipulation.fonct.php'; |
include_once 'Mail.php' ; |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class projet |
* |
*/ |
class projet |
{ |
/** Aggregations: */ |
/** |
* Le tableau d'objet document associés au projet |
* |
*/ |
var $_documents_associes = array(); |
var $_listes_associes = array(); |
/** Compositions: */ |
/*** Attributes: ***/ |
/** |
* L'identifiant du projet. |
* @access private |
*/ |
var $_id_projet; |
/** |
* Le titre du projet, tel que dans la base de donnée. |
* @access private |
*/ |
var $_titre; |
/** |
* La description du projet, tel que dans la base. |
* @access private |
*/ |
var $_description; |
/** |
* L'URL d'un site sur le projet. Facultatif. |
* @access private |
*/ |
var $_espace_internet; |
/** |
* Le nom du wikini associe au projet, avec la syntaxe wikini. Vide par defaut. |
* @access private |
*/ |
var $_nom_wikini; |
/** |
* Date de creation du projet. A priori ne varie pas dans le temps. |
* @access private |
*/ |
var $_date_creation; |
/** |
* Le chemin relatif vers le repertoire contenant les wikinis. |
* @access private |
*/ |
var $_chemin_wikini; |
/** |
* Une connexion vers la base de donnee. |
* @access private |
*/ |
var $_db; |
/** |
* Contient le nom du repertoire du projet tel que sur le disque. |
* @access private |
*/ |
var $_nom_repertoire; |
/** |
* Le chemin jusqu'au repertoire ou seront stockes les fichiers. |
* @access private |
*/ |
var $_chemin_repertoire; |
/** |
* Vaut vrai si le projet est un projet racine et s'il est le seul. |
* @access private |
*/ |
var $_est_racine; |
/** |
* Le resume du projet |
* @access private |
*/ |
var $_resume; |
/** |
* Contient le numero du type du projet |
* @access private |
*/ |
var $_type; |
/** |
* Indique si l'inscription au projet est moderes |
* @access private |
*/ |
var $_isModere; |
/** |
* Indique si le projet a des documents |
* @access private |
*/ |
var $_avoirDocument; |
/** |
* tableau contenant les themes associes au projet |
*/ |
var $_themes = array(); |
/** |
* |
* PHP5 |
* @return projet |
* @access public |
*/ |
function __construct( &$dbObject, $id_projet = "") |
{ |
$this->projet($dbObject, $id_projet); |
} // end of member function __construct |
/** |
* |
* |
* @param DB dbObject Un objet PEAR:DB |
* @param int id_projet On passe un identifiant de projet au constructeur. Cela lui permet de faire une |
* premiere requete pour les infos de bases comme le titre, le description etc. |
* @return projet |
* @access public |
*/ |
function projet( &$dbObject, $id_projet = "") |
{ |
$this->_db = $dbObject ; |
if (intval($id_projet)) { |
$resultat = $this->_db->query(sprintf("SELECT * FROM projet WHERE p_id=%d -- %s", |
intval($id_projet), |
__FILE__ . ':' . __LINE__)); |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
// Affectations dans les proprietes |
$this->_id_projet = $ligne->p_id ; |
$this->_titre = $ligne->p_titre ; |
$this->_description = $ligne->p_description ; |
$this->_espace_internet = $ligne->p_espace_internet ; |
$this->_date_creation = $ligne->p_date_creation ; |
$this->_nom_wikini = $ligne->p_wikini ; |
$this->_resume = $ligne->p_resume; |
$this->_type = $ligne->p_type ; |
// On recupere le nom du repertoire |
$this->_nom_repertoire = $ligne->p_nom_repertoire ; |
$this->_isModere = $ligne->p_modere; |
$this->_avoirDocument = $ligne->p_avoir_document; |
// on regarde si on a a faire au projet racine |
if (PROJET_UTILISE_HIERARCHIE) { |
$requete = 'select ph_id_projet_pere, ph_id_projet_fils from projet_hierarchie where ph_id_projet_fils='.$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ("Echec de la requete : $requete<br />".$resultat->getMessage()) ; |
} |
if (!$resultat->numRows()) { |
$this->_est_racine = true ; |
} else { |
$this->_est_racine = false ; |
} |
} |
/** Recuperation des themes */ |
$requete_theme = 'select pat_id_theme, pt_label_theme from projet_avoir_theme, projet_theme'. |
' where pat_id_projet='.$this->_db->escapeSimple($this->_id_projet).' and pat_id_theme=pt_id_theme'; |
$resultat_theme = $GLOBALS['projet_db']->query ($requete_theme); |
if (DB::isError($resultat_theme)) { |
return ("Echec de la requete : $requete_theme<br />".$resultat_theme->getMessage()) ; |
} |
if ($resultat_theme->numRows() != 0) { |
while ($ligne_theme = $resultat_theme->fetchRow(DB_FETCHMODE_OBJECT)) { |
$this->_themes[$ligne_theme->pat_id_theme] = $ligne_theme->pt_label_theme; |
} |
} |
} |
} // end of member function projet |
/** |
* |
* |
* @param DB dbObject Un objet PEAR:DB |
* @param int id_projet On passe un identifiant de projet au constructeur. |
* @return bool |
* @access public |
*/ |
function projetExiste( &$dbObject, $id_projet) |
{ |
if (intval($id_projet)) { |
$resultat = $dbObject->query(sprintf("SELECT * FROM projet WHERE p_id=%d -- %s", |
intval($id_projet), |
__FILE__ . ':' . __LINE__)); |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows() != 0) { |
return true ; |
} |
} |
} // end of member function projet |
/** |
* |
* |
* @param int id_projet |
* @return string |
* @access public |
*/ |
function getTitre( $id_projet = "" ) |
{ |
return $this->_titre ; |
} // end of member function getTitre |
/** |
* |
* |
* @return string |
* @access public |
*/ |
function getResume( ) |
{ |
return $this->_resume ; |
} // end of member function getResume |
/** |
* Renvoie l'identifiant du projet courant. |
* |
* @return int |
* @access public |
*/ |
function getId( ) |
{ |
return $this->_id_projet ; |
} // end of member function getId |
/** |
* |
* |
* @return string |
* @access public |
*/ |
function getDescription( ) |
{ |
return $this->_description; |
} // end of member function getDescription |
/** |
* |
* |
* @return string |
* @access public |
*/ |
function getEspaceInternet( ) |
{ |
return $this->_espace_internet; |
} // end of member function getEspaceInternet |
/** |
* Charge dans l'objet projet, les listes de discussion |
* ['nom_liste'] |
* ['domaine'] |
* ['adresse'] |
* |
* @return boolean true en cas de succès |
* @access public |
*/ |
function getListesAssociees( ) |
{ |
// On rajoute un test pour eviter l'appel SQL si il a deja ete fait une fois |
if (count($this->_listes_associes) > 0) return ; |
$requete = "select pl_id_liste from projet_lien_liste where pl_id_projet=".$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ("Echec de la requete : $requete<br />".$resultat->getMessage()) ; |
} |
$retour = array() ; |
if ($resultat->numRows()) { |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
$this->_listes_associes[] = new liste_discussion($ligne->pl_id_liste, $this->_db) ; |
} |
} // end of member function getListesAssociees |
/** |
* Renvoie vrai si le projet a au moins une liste |
* |
* @return bool |
* @access public |
*/ |
function avoirListe( ) |
{ |
$this->getListesAssociees() ; |
if (count($this->_listes_associes)) { |
return true ; |
} |
return false ; |
} |
/** |
* Renvoie vrai si le projet a au moins un document, fichier ou repertoire |
* |
* Mis en place pour des raisons de performances avant la methode getListesDocuments etait utilisee |
* |
* @return bool |
* @access public |
*/ |
function avoirDocument( ) |
{ |
return $this->_avoirDocument; |
} |
/** |
* Permet de fixer la colonne p_avoir_document a 1 |
* |
* Mis en place pour des raisons de performances avant la methode getListesDocuments etait utilisee |
* |
* @param bool |
* @return mixed true si la requete fonctionne |
* @access public |
*/ |
function setAvoirDocument($bool) |
{ |
$val = 0 ; |
if ($bool) $val = 1; |
$requete = 'update projet set p_avoir_document='.$this->_db->escapeSimple($val).' where p_id='.$this->_db->escapeSimple($this->_id_projet); |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
echo ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
return true; |
} |
/** |
* Renvoie la liste des documents associes sous forme d'un tableau, avec les |
* informations afferentes. 0 => "nom (cliquable)" |
"Taille" |
"Date |
* de creation" "Prorietaire" "Visibilite" "Action |
* (cliquable)" |
* |
* @param visibilite visibilite Si visibilite est prive, tous les fichiers sont renvoyes ainsi qu'une entree |
* pour indiquer la visibilite du document. |
* @return Array |
* @access public |
*/ |
function getListesDocuments( $chemin, $chemin_icones = "icones/", $id_repertoire = '', $date = '' ) |
{ |
// On realise une requete sur projet_documents avec une jointure sur l'annuaire |
// et sur gen_type_de_fichier pour envoyer un resultat complet. |
// On exclue les fichiers racines cad pd_pere is null |
$requete = "select pd_id from projet_documents where pd_ce_projet=".$this->_db->escapeSimple($this->_id_projet) ; |
if ($id_repertoire != '') $requete .= ' and pd_pere='.$this->_db->escapeSimple($id_repertoire); |
if ($id_repertoire != '' && $id_repertoire == 0) $requete .= ' and pd_pere=0'; |
if ($date != '') $requete .= ' and pd_date_de_mise_a_jour > date_sub (NOW(), interval 1 week)'; |
$requete .= ' order by pd_nom' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$tableau_document = array() ; |
// Un compteur |
$i = 0 ; |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_document, new document ($ligne->pd_id, $i, $chemin, $chemin_icones)) ; |
} |
return $tableau_document ; |
} |
/** |
* Renvoie un tableau avec tous les repertoires d'un projet, imbrique. ['rep1'], |
* ['rep2'] => array (['rep21'], ['rep22']), etc . |
* |
* @return Array |
* @access public |
*/ |
function getListeRepertoireHierarchisee( ) |
{ |
// On ne prend que les repertoires |
$requete = "select pd_id, pd_pere, pd_nom from projet_documents where pd_ce_projet=".$this->_db->escapeSimple($this->_id_projet).' and pd_ce_type=0 order by pd_nom' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$tableau_document = array() ; |
/* |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_document, new document ($ligne->pd_id, $this->_db)); |
} |
*/ |
$tableau = array(); |
$tab = array(); |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) { |
array_push ($tableau, array ('id' => $ligne->pd_id, |
'id_pere' => $ligne->pd_pere, |
'fils' => array(), |
'label' => $ligne->pd_nom)); |
} |
// la $tableau reste un tableau de valeur a plat |
$i = 0; |
foreach ($tableau as $noeud) { |
// On teste si le noeud est racine si oui on l ajoute a l arbre sinon on ne l ajoute pas |
if ($noeud['id_pere'] == 0) { |
$tab[$i] = $noeud; |
$this->construireArbre($tab[$i], $tableau) ; |
} |
$i++; |
} |
return $tab; |
} // end of member function getListeRepertoireHierarchisee |
function construireArbre(&$noeud, $tableau) { |
$j = 0; |
foreach ($tableau as $element) { |
// pour chaque element on teste |
if ($element['id_pere'] == $noeud['id']) { |
$noeud['fils'][$j]= $element ; |
$this->construireArbre($noeud['fils'][$j],$tableau); |
} |
$j++; |
} |
} |
/** |
* Renvoie un tableau comprenant tous les objets projet de la base. |
* |
* @return Array |
* @static |
* @access public |
*/ |
function getTousLesProjets(&$objetDB, $exclu = '') |
{ |
$sql = ''; |
if (is_object($this) && isset ($this->_projet_exclu) && count($this->_projet_exclu)) { |
$sql = 'where p_id not in ('; |
foreach ($this->_projet_exclu as $valeur) { |
$sql .= $objetDB->escapeSimple($valeur).',' ; |
} |
$sql[count($sql)-1] = ')'; |
} |
$requete = 'select p_id from projet '.$sql.' order by p_titre' ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError($resultat)) { |
echo ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$tableau_resultat = array() ; |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_resultat, new projet ($objetDB, $ligne->p_id)) ; |
} |
return $tableau_resultat ; |
} // end of member function getTousLesProjets |
/** |
* Renvoie un tableau comprenant les objets projet de la base du type $type. |
* |
* @return Array |
* @static |
* @access public |
*/ |
function getProjetDuType($type, &$objetDB) |
{ |
$requete = "select p_id from projet where p_type=".$objetDB->escapeSimple($type)." order by p_titre" ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$tableau_resultat = array() ; |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_resultat, new projet ($objetDB, $ligne->p_id)) ; |
} |
return $tableau_resultat ; |
} // end of member function getTousLesProjets |
/** |
* Renvoie un le projet racine. |
* |
* @return projet |
* @static |
* @access public |
*/ |
function getProjetRacine(&$objetDB) |
{ |
$requete = "select p_id from projet where p_id not in (select ph_id_projet_fils from projet_hierarchie)" ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows() == 1) { |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; |
return new projet($objetDB, $ligne->p_id) ; |
} |
$tableau_resultat = array() ; |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_resultat, new projet ($objetDB, $ligne->p_id)) ; |
} |
return $tableau_resultat ; |
} // end of member function getTousLesProjets |
/** |
* Desctructeur de la classe. Libere la memoire, ferme les connexions et fichiers. |
* |
* @return void |
* @access public |
*/ |
function __destruct( ) |
{ |
} // end of member function __destruct |
/** |
* Supprime le projet courrant. Il s'ensuit une suppression en cascade de tous les |
* elements lies. |
* |
* @return void |
* @access public |
*/ |
function supprimer( ) |
{ |
} // end of member function supprimer |
/** |
* Permet d'enregistrer une ligne dans la table concernee. |
* |
* @param Array tableau_de_valeur Le tableau de valeur a inserer dans la base avec pour cle les noms des elements |
* du formulaire. |
* @return int |
* @access public |
*/ |
function enregistrerSQL( $tableau_de_valeur ) |
{ |
$nom_repertoire = projet::genereNomRepertoire($tableau_de_valeur['projet_titre'], $this->_db) ; |
if (!$this->_creationRepertoire ($nom_repertoire)) { |
echo 'Impossible de crée un répertoire'.$nom_repertoire ; |
return false ; |
} |
// Traitement du type |
if (!PROJET_UTILISE_TYPE) { |
$tableau_de_valeur['projet_type'] = 0 ; |
} |
$id = SQL_obtenirNouveauId($this->_db, 'projet', 'p_id') ; |
$requete = 'insert into projet set p_id='.$this->_db->escapeSimple($id) ; |
if (!isset($tableau_de_valeur['projet_wikini'])) { |
$tableau_de_valeur['projet_wikini']=''; |
} |
$requete .= ', p_titre="'.$tableau_de_valeur['projet_titre'].'", p_description="'.$tableau_de_valeur['projet_description'].'"'. |
', p_espace_internet="'.$tableau_de_valeur['projet_espace_internet'].'", p_date_creation=NOW()'. |
', p_wikini="'.$tableau_de_valeur['projet_wikini'].'", p_nom_repertoire="'.$nom_repertoire.'", p_resume="'.$tableau_de_valeur['projet_resume']. |
'", p_type="'.$tableau_de_valeur['projet_type'].'", p_modere="'.$tableau_de_valeur['projet_moderation'].'"' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
// On affecte a l'objet projet son identifiant |
$this->_id_projet = $id ; |
//insertion dans projet_herarchie |
if (PROJET_UTILISE_HIERARCHIE) { |
$requete = 'insert into projet_hierarchie set ph_id_projet_pere='.$this->_db->escapeSimple($tableau_de_valeur['projet_asso']). |
', ph_id_projet_fils='.$this->_db->escapeSimple($id) ; |
$resultat = $this->_db->query ($requete) ; |
} |
/** enregistrement dans projet_avoir_theme */ |
$requete_theme = ''; |
foreach ($tableau_de_valeur['projet_theme'] as $cle => $valeur) { |
$requete_theme = 'insert into projet_avoir_theme set pat_id_projet='.$this->_db->escapeSimple($id).', pat_id_theme='.$this->_db->escapeSimple($cle); |
$resultat_theme = $GLOBALS['projet_db']->query($requete_theme); |
if (DB::isError($resultat_theme)) { |
return $resultat_theme->getMessage(); |
} |
} |
return true ; |
} |
/** |
* Permet de mettre a jour une ligne dans la table concernee. |
* |
* @param Array tableau_de_valeur Le tableau de valeur a inserer dans la base avec pour cle les noms des elements |
* du formulaire. |
* @return int |
* @access public |
*/ |
function majSQL( $tableau_de_valeur ) |
{ |
// Traitement du type |
if (!PROJET_UTILISE_TYPE) { |
$tableau_de_valeur['projet_type'] = 0 ; |
} |
$requete = 'update projet set '; |
$requete .= 'p_titre="'.$tableau_de_valeur['projet_titre'].'", p_description="'.$tableau_de_valeur['projet_description'].'"'. |
', p_espace_internet="'.$tableau_de_valeur['projet_espace_internet'].'"'. |
', p_resume="'.$tableau_de_valeur['projet_resume'].'", p_type="'.$tableau_de_valeur['projet_type'].'"'. |
', p_modere='.$tableau_de_valeur['projet_moderation']. |
' where p_id="'.$this->_id_projet.'"' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
if (PROJET_UTILISE_HIERARCHIE) { |
// suppression dans projet_hierarchie |
$requete = 'delete from projet_hierarchie where ph_id_projet_fils='.$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
//insertion dans projet_hierarchie |
$requete = 'insert into projet_hierarchie set ph_id_projet_pere='.$this->_db->escapeSimple($tableau_de_valeur['projet_asso']). |
', ph_id_projet_fils='.$this->_id_projet ; |
$resultat = $this->_db->query ($requete) ; |
} |
/** enregistrement dans projet_avoir_theme */ |
$requete_suppression_theme = 'delete from projet_avoir_theme where pat_id_projet='.$this->_db->escapeSimple($this->_id_projet); |
$resultat_suppression_theme = $GLOBALS['projet_db']->query($requete_suppression_theme); |
$requete_theme = ''; |
foreach ($tableau_de_valeur['projet_theme'] as $cle => $valeur) { |
$requete_theme = 'insert into projet_avoir_theme set pat_id_projet='.$this->_db->escapeSimple($this->_id_projet). |
', pat_id_theme='.$this->_db->escapeSimple($cle); |
$resultat_theme = $GLOBALS['projet_db']->query($requete_theme); |
if (DB::isError($resultat_theme)) { |
return $resultat_theme->getMessage(); |
} |
} |
return true ; |
} // end of member function enregistrerSQL |
/** |
* Met a jour dans la base de donnee le champs p_nom_wikini |
* |
* @param int nom_wikini Le nouveau nom wikini |
* @return bool |
* @access public |
*/ |
function majNomWikini( $nom_wikini ) |
{ |
$requete = 'update projet set p_wikini="'.$nom_wikini.'" where p_id="'.$this->_id_projet.'"' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
return true ; |
} // end of member function majNomWikini |
function majSQLVisibilite($id_liste, $visible) { |
$requete = 'UPDATE projet_liste set pl_visibilite='.$this->_db->escapeSimple($visible).' '. |
'WHERE pl_id_liste ='.$id_liste; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
return true; |
} |
/** |
* |
* |
* @param string code_sql |
* @return bool |
* @access public |
*/ |
function suppressionSQL() |
{ |
$msg = '' ; |
// Supression du repertoire du projet |
if (!$this->_suppression_repertoire()) { |
$msg = 'La suppression du repertoire n\'a pas fonctionne' ; |
} |
// A ajouter la suppression des documents associes |
// La suppression des evenements associés |
// Le projet lui-meme |
$requete = "delete from projet where p_id=".$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (PROJET_UTILISE_HIERARCHIE) { |
$requete = "delete from projet_hierarchie where ph_id_projet_fils=".$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
} |
$requete = "delete from projet_statut_utilisateurs where psu_id_projet=".$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
return $msg ; |
} // end of member function suppressionSQL |
/** |
* Supprime le repertoire associe au projet (le repertoire doit etre vide). |
* |
* @return void |
* @access private |
*/ |
function _suppression_repertoire( ) |
{ |
return rmdir ($this->_chemin_repertoire.$this->_nom_repertoire) ; |
} // end of member function _suppression_repertoire |
/** |
* Permet de creer le repertoire associe au projet. |
* |
* @param string nom_repertoire Le nom du répertoire à créer. |
* @return boolean |
* @access private |
*/ |
function _creationRepertoire( $nom_repertoire ) |
{ |
return mkdir ($this->_chemin_repertoire.$nom_repertoire) ; |
} // end of member function _creationRepertoire |
/** |
* Permet d'indiquer ou seront stockes les fichiers. |
* |
* @param string cheminRepertoire Le chemin jusqu'au repertoire ou seront stockes les fichiers. |
* @return void |
* @access public |
*/ |
function setCheminRepertoire( $cheminRepertoire ) |
{ |
$this->_chemin_repertoire = $cheminRepertoire ; |
} // end of member function setCheminRepertoire |
/** |
* Genere un nom de repertoire a partir de la premiere lettre de la chaine passe en |
* parametre et de l'identifiant du dernier projet. |
* |
* @param string chaine Une chaine a partir de laquelle sera generer le nom du repertoire. |
* @param DB objetDB un objet PEAR::DB |
* @return string |
* @static |
* @access public |
*/ |
function genereNomRepertoire( $chaine, &$objetDB ) |
{ |
$requete = "select p_id from projet order by p_id desc limit 0,1" ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ("Echec de la requete : $requete<br />".$resultat->getMessage()) ; |
} |
if ($resultat->numRows() > 0) { |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
$nom = strtoupper(substr($chaine, 0, 1)) ; |
$nom .= $ligne->p_id + 1 ; |
} |
else { |
$nom = strtoupper(substr($chaine, 0, 1)) ; |
$nom .= 1 ; |
} |
return $nom ; |
} // end of member function genereNomRepertoire |
/** |
* Permet de recuperer le nom du repertoire d'un projet. |
* |
* @return string |
* @access public |
*/ |
function getNomRepertoire( ) |
{ |
return $this->_nom_repertoire ; |
} // end of member function getNomRepertoire |
/** |
* Ajoute une liste a un projet |
* Effectue une insertion dans projet_lien_liste |
* |
* @param liste_discussion liste Une instance de la classe liste_discussion |
* @return void |
* @access public |
*/ |
function ajouterListe( &$liste ) |
{ |
$requete = "insert into projet_lien_liste set pl_id_liste=".$this->_db->escapeSimple($liste->getId()). |
', pl_id_projet='.$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ("Echec de la requete : $requete<br />".$resultat->getMessage()) ; |
} |
} |
/** |
* Supprime la liste de discussion associee au projet |
* |
* @return void |
* @access public |
*/ |
function supprimerListe(&$liste) |
{ |
$requete = 'delete from projet_lien_liste where pl_id_liste='.$this->_db->escapeSimple($liste->getId()) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$requete = 'delete from projet_liste where pl_id_liste='.$this->_db->escapeSimple($liste->getId()) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
} |
/** |
* Renvoie vrai si le projet est racine. |
* |
* @return bool |
* @access public |
*/ |
function isRacine( ) |
{ |
return $this->_est_racine ; |
} // end of member function isRacine |
/** |
* Renvoie le nombre d'inscrits au projet. Effectue une requete dans la table |
* projet_statut_utilisateurs |
* |
* @return int |
* @access public |
*/ |
function getNombreInscrits( ) |
{ |
$requete = 'select count(psu_id_utilisateur) as nbre from projet_statut_utilisateurs where psu_id_projet='.$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
return $ligne->nbre ; |
} // end of member function getNombreInscrits |
/** |
* Renvoie un tableau contenant les identifiants des fils du projet courant. |
* |
* @return Array |
* @access public |
*/ |
function getHierarchie( ) |
{ |
$requete = 'select ph_id_projet_fils from projet_hierarchie where ph_id_projet_pere='.$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$tableau_resultat = array() ; |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_resultat, $ligne->ph_id_projet_fils) ; |
} |
return $tableau_resultat ; |
} // end of member function getHierarchie |
/** |
* Renvoie l'identifiant du pere du projet courrant. |
* |
* @return int |
* @access public |
*/ |
function getIdPere() |
{ |
$requete = 'select ph_id_projet_pere from projet_hierarchie where ph_id_projet_fils='.$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$tableau_resultat = array() ; |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; |
return $ligne->ph_id_projet_pere ; |
} // end of member function getIdPere() |
/** |
* Renvoie le nom Wiki du wikini associe au projet. |
* |
* @return string |
* @access public |
*/ |
function getWikini( ) |
{ |
return $this->_nom_wikini ; |
} // end of member function getWikini |
/** |
* Renvoie le type du projet, ou zero si le projet n'a pas de type. |
* |
* @return int |
* @access public |
*/ |
function getType( ) |
{ |
return $this->_type ; |
} // end of member function getType |
/** |
* Renvoie les themes du projet, ou zero si le projet n'a pas de type. |
* |
* @return int |
* @access public |
*/ |
function getThemes( ) |
{ |
return $this->_themes ; |
} // end of member function getType |
/** |
* Renvoie 1 si les inscriptions au projet sont moderees. |
* |
* @return int |
* @access public |
*/ |
function isModere( ) |
{ |
return $this->_isModere ; |
} // end of member function getType |
/** |
* initAttributes sets all projet attributes to its default value make |
* sure to call this method within your class constructor |
*/ |
function initAttributes( ) |
{ |
$this->chemin_wikini = "projet/wikini/"; |
} |
} // end of projet |
?> |
<?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: projet.class.php,v 1.12 2008-05-21 14:35:26 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe projet |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.12 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
include_once PROJET_CHEMIN_CLASSES.'document.class.php' ; |
include_once PROJET_CHEMIN_CLASSES.'liste_discussion.class.php' ; |
/* Permet la r�cup�ration d'un nouvel identifiant d'une table.*/ |
require_once PROJET_CHEMIN_BIBLIOTHEQUE_API.'sql/SQL_manipulation.fonct.php'; |
include_once 'Mail.php' ; |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class projet |
* |
*/ |
class projet |
{ |
/** Aggregations: */ |
/** |
* Le tableau d'objet document associ�s au projet |
* |
*/ |
var $_documents_associes = array(); |
var $_listes_associes = array(); |
/** Compositions: */ |
/*** Attributes: ***/ |
/** |
* L'identifiant du projet. |
* @access private |
*/ |
var $_id_projet; |
/** |
* Le titre du projet, tel que dans la base de donn�e. |
* @access private |
*/ |
var $_titre; |
/** |
* La description du projet, tel que dans la base. |
* @access private |
*/ |
var $_description; |
/** |
* L'URL d'un site sur le projet. Facultatif. |
* @access private |
*/ |
var $_espace_internet; |
/** |
* Le nom du wikini associ� au projet, avec la syntaxe wikini. Vide par d�faut. |
* @access private |
*/ |
var $_nom_wikini; |
/** |
* Date de cr�ation du projet. A priori ne varie pas dans le temps. |
* @access private |
*/ |
var $_date_creation; |
/** |
* Le chemin relatif vers le r�pertoire contenant les wikinis. |
* @access private |
*/ |
var $_chemin_wikini; |
/** |
* Une connexion vers la base de donn�e. |
* @access private |
*/ |
var $_db; |
/** |
* Contient le nom du r�pertoire du projet tel que sur le disque. |
* @access private |
*/ |
var $_nom_repertoire; |
/** |
* Le chemin jusqu'au r�pertoire o� seront stock�s les fichiers. |
* @access private |
*/ |
var $_chemin_repertoire; |
/** |
* Vaut vrai si le projet est un projet racine et s'il est le seul. |
* @access private |
*/ |
var $_est_racine; |
/** |
* Le r�sum� du projet |
* @access private |
*/ |
var $_resume; |
/** |
* Contient le num�ro du type du projet |
* @access private |
*/ |
var $_type; |
/** |
* Indique si l'inscription au projet est moderes |
* @access private |
*/ |
var $_isModere; |
/** |
* Indique si le projet a des documents |
* @access private |
*/ |
var $_avoirDocument; |
/** |
* tableau contenant les themes associes au projet |
*/ |
var $_themes = array(); |
/** |
* |
* PHP5 |
* @return projet |
* @access public |
*/ |
function __construct( &$dbObject, $id_projet = "") |
{ |
$this->projet($dbObject, $id_projet); |
} // end of member function __construct |
/** |
* |
* |
* @param DB dbObject Un objet PEAR:DB |
* @param int id_projet On passe un identifiant de projet au constructeur. Cela lui permet de faire une |
* premiere requete pour les infos de bases comme le titre, le description etc. |
* @return projet |
* @access public |
*/ |
function projet( &$dbObject, $id_projet = "") |
{ |
$this->_db = $dbObject ; |
if ($id_projet != "") { |
$requete = "select * from projet where p_id=".$this->_db->escapeSimple($id_projet)." " ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
// Affectations dans les proprietes |
$this->_id_projet = $ligne->p_id ; |
$this->_titre = $ligne->p_titre ; |
$this->_description = $ligne->p_description ; |
$this->_espace_internet = $ligne->p_espace_internet ; |
$this->_date_creation = $ligne->p_date_creation ; |
$this->_nom_wikini = $ligne->p_wikini ; |
$this->_resume = $ligne->p_resume; |
$this->_type = $ligne->p_type ; |
// On recupere le nom du repertoire |
$this->_nom_repertoire = $ligne->p_nom_repertoire ; |
$this->_isModere = $ligne->p_modere; |
$this->_avoirDocument = $ligne->p_avoir_document; |
// on regarde si on a a faire au projet racine |
if (PROJET_UTILISE_HIERARCHIE) { |
$requete = 'select ph_id_projet_pere, ph_id_projet_fils from projet_hierarchie where ph_id_projet_fils='.$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ("Echec de la requete : $requete<br />".$resultat->getMessage()) ; |
} |
if (!$resultat->numRows()) { |
$this->_est_racine = true ; |
} else { |
$this->_est_racine = false ; |
} |
} |
/** Recuperation des themes */ |
$requete_theme = 'select pat_id_theme, pt_label_theme from projet_avoir_theme, projet_theme'. |
' where pat_id_projet='.$this->_db->escapeSimple($this->_id_projet).' and pat_id_theme=pt_id_theme'; |
$resultat_theme = $GLOBALS['projet_db']->query ($requete_theme); |
if (DB::isError($resultat_theme)) { |
return ("Echec de la requete : $requete_theme<br />".$resultat_theme->getMessage()) ; |
} |
if ($resultat_theme->numRows() != 0) { |
while ($ligne_theme = $resultat_theme->fetchRow(DB_FETCHMODE_OBJECT)) { |
$this->_themes[$ligne_theme->pat_id_theme] = $ligne_theme->pt_label_theme; |
} |
} |
} |
} // end of member function projet |
/** |
* |
* |
* @param DB dbObject Un objet PEAR:DB |
* @param int id_projet On passe un identifiant de projet au constructeur. |
* @return bool |
* @access public |
*/ |
function projetExiste( &$dbObject, $id_projet) |
{ |
if ($id_projet != "") { |
$requete = "select * from projet where p_id=".$dbObject->escapeSimple($id_projet)." " ; |
$resultat = $dbObject->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows() != 0) { |
return true ; |
} |
} |
} // end of member function projet |
/** |
* |
* |
* @param int id_projet |
* @return string |
* @access public |
*/ |
function getTitre( $id_projet = "" ) |
{ |
return $this->_titre ; |
} // end of member function getTitre |
/** |
* |
* |
* @return string |
* @access public |
*/ |
function getResume( ) |
{ |
return $this->_resume ; |
} // end of member function getResume |
/** |
* Renvoie l'identifiant du projet courant. |
* |
* @return int |
* @access public |
*/ |
function getId( ) |
{ |
return $this->_id_projet ; |
} // end of member function getId |
/** |
* |
* |
* @return string |
* @access public |
*/ |
function getDescription( ) |
{ |
return $this->_description; |
} // end of member function getDescription |
/** |
* |
* |
* @return string |
* @access public |
*/ |
function getEspaceInternet( ) |
{ |
return $this->_espace_internet; |
} // end of member function getEspaceInternet |
/** |
* Charge dans l'objet projet, les listes de discussion |
* ['nom_liste'] |
* ['domaine'] |
* ['adresse'] |
* |
* @return boolean true en cas de succ�s |
* @access public |
*/ |
function getListesAssociees( ) |
{ |
// On rajoute un test pour eviter l'appel SQL si il a deja ete fait une fois |
if (count($this->_listes_associes) > 0) return ; |
$requete = "select pl_id_liste from projet_lien_liste where pl_id_projet=".$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ("Echec de la requete : $requete<br />".$resultat->getMessage()) ; |
} |
$retour = array() ; |
if ($resultat->numRows()) { |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
$this->_listes_associes[] = new liste_discussion($ligne->pl_id_liste, $this->_db) ; |
} |
} // end of member function getListesAssociees |
/** |
* Renvoie vrai si le projet a au moins une liste |
* |
* @return bool |
* @access public |
*/ |
function avoirListe( ) |
{ |
$this->getListesAssociees() ; |
if (count($this->_listes_associes)) { |
return true ; |
} |
return false ; |
} |
/** |
* Renvoie vrai si le projet a au moins un document, fichier ou repertoire |
* |
* Mis en place pour des raisons de performances avant la methode getListesDocuments etait utilisee |
* |
* @return bool |
* @access public |
*/ |
function avoirDocument( ) |
{ |
return $this->_avoirDocument; |
} |
/** |
* Permet de fixer la colonne p_avoir_document a 1 |
* |
* Mis en place pour des raisons de performances avant la methode getListesDocuments etait utilisee |
* |
* @param bool |
* @return mixed true si la requete fonctionne |
* @access public |
*/ |
function setAvoirDocument($bool) |
{ |
$val = 0 ; |
if ($bool) $val = 1; |
$requete = 'update projet set p_avoir_document='.$this->_db->escapeSimple($val).' where p_id='.$this->_db->escapeSimple($this->_id_projet); |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
echo ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
return true; |
} |
/** |
* Renvoie la liste des documents associes sous forme d'un tableau, avec les |
* informations afferentes. 0 => "nom (cliquable)" |
"Taille" |
"Date |
* de creation" "Prorietaire" "Visibilite" "Action |
* (cliquable)" |
* |
* @param visibilite visibilite Si visibilite est prive, tous les fichiers sont renvoyes ainsi qu'une entree |
* pour indiquer la visibilite du document. |
* @return Array |
* @access public |
*/ |
function getListesDocuments( $chemin, $chemin_icones = "icones/", $id_repertoire = '', $date = '' ) |
{ |
// On realise une requete sur projet_documents avec une jointure sur l'annuaire |
// et sur gen_type_de_fichier pour envoyer un resultat complet. |
// On exclue les fichiers racines cad pd_pere is null |
$requete = "select pd_id from projet_documents where pd_ce_projet=".$this->_db->escapeSimple($this->_id_projet) ; |
if ($id_repertoire != '') $requete .= ' and pd_pere='.$this->_db->escapeSimple($id_repertoire); |
if ($id_repertoire != '' && $id_repertoire == 0) $requete .= ' and pd_pere=0'; |
if ($date != '') $requete .= ' and pd_date_de_mise_a_jour > date_sub (NOW(), interval 1 week)'; |
$requete .= ' order by pd_nom' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$tableau_document = array() ; |
// Un compteur |
$i = 0 ; |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_document, new document ($ligne->pd_id, $i, $chemin, $chemin_icones)) ; |
} |
return $tableau_document ; |
} |
/** |
* Renvoie un tableau avec tous les repertoires d'un projet, imbrique. ['rep1'], |
* ['rep2'] => array (['rep21'], ['rep22']), etc . |
* |
* @return Array |
* @access public |
*/ |
function getListeRepertoireHierarchisee( ) |
{ |
// On ne prend que les repertoires |
$requete = "select pd_id, pd_pere, pd_nom from projet_documents where pd_ce_projet=".$this->_db->escapeSimple($this->_id_projet).' and pd_ce_type=0 order by pd_nom' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$tableau_document = array() ; |
/* |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_document, new document ($ligne->pd_id, $this->_db)); |
} |
*/ |
$tableau = array(); |
$tab = array(); |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) { |
array_push ($tableau, array ('id' => $ligne->pd_id, |
'id_pere' => $ligne->pd_pere, |
'fils' => array(), |
'label' => $ligne->pd_nom)); |
} |
// la $tableau reste un tableau de valeur a plat |
$i = 0; |
foreach ($tableau as $noeud) { |
// On teste si le noeud est racine si oui on l ajoute a l arbre sinon on ne l ajoute pas |
if ($noeud['id_pere'] == 0) { |
$tab[$i] = $noeud; |
$this->construireArbre($tab[$i], $tableau) ; |
} |
$i++; |
} |
return $tab; |
} // end of member function getListeRepertoireHierarchisee |
function construireArbre(&$noeud, $tableau) { |
$j = 0; |
foreach ($tableau as $element) { |
// pour chaque element on teste |
if ($element['id_pere'] == $noeud['id']) { |
$noeud['fils'][$j]= $element ; |
$this->construireArbre($noeud['fils'][$j],$tableau); |
} |
$j++; |
} |
} |
/** |
* Renvoie un tableau comprenant tous les objets projet de la base. |
* |
* @return Array |
* @static |
* @access public |
*/ |
function getTousLesProjets(&$objetDB, $exclu = '') |
{ |
$sql = ''; |
if (is_object($this) && isset ($this->_projet_exclu) && count($this->_projet_exclu)) { |
$sql = 'where p_id not in ('; |
foreach ($this->_projet_exclu as $valeur) { |
$sql .= $objetDB->escapeSimple($valeur).',' ; |
} |
$sql[count($sql)-1] = ')'; |
} |
$requete = 'select p_id from projet '.$sql.' order by p_titre' ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError($resultat)) { |
echo ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$tableau_resultat = array() ; |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_resultat, new projet ($objetDB, $ligne->p_id)) ; |
} |
return $tableau_resultat ; |
} // end of member function getTousLesProjets |
/** |
* Renvoie un tableau comprenant les objets projet de la base du type $type. |
* |
* @return Array |
* @static |
* @access public |
*/ |
function getProjetDuType($type, &$objetDB) |
{ |
$requete = "select p_id from projet where p_type= ".$objetDB->escapeSimple($type)." order by p_titre" ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$tableau_resultat = array() ; |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_resultat, new projet ($objetDB, $ligne->p_id)) ; |
} |
return $tableau_resultat ; |
} // end of member function getTousLesProjets |
/** |
* Renvoie un le projet racine. |
* |
* @return projet |
* @static |
* @access public |
*/ |
function getProjetRacine(&$objetDB) |
{ |
$requete = "select p_id from projet where p_id not in (select ph_id_projet_fils from projet_hierarchie)" ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows() == 1) { |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; |
return new projet($objetDB, $ligne->p_id) ; |
} |
$tableau_resultat = array() ; |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_resultat, new projet ($objetDB, $ligne->p_id)) ; |
} |
return $tableau_resultat ; |
} // end of member function getTousLesProjets |
/** |
* Desctructeur de la classe. Libere la memoire, ferme les connexions et fichiers. |
* |
* @return void |
* @access public |
*/ |
function __destruct( ) |
{ |
} // end of member function __destruct |
/** |
* Supprime le projet courrant. Il s'ensuit une suppression en cascade de tous les |
* elements lies. |
* |
* @return void |
* @access public |
*/ |
function supprimer( ) |
{ |
} // end of member function supprimer |
/** |
* Permet d'enregistrer une ligne dans la table concernee. |
* |
* @param Array tableau_de_valeur Le tableau de valeur a inserer dans la base avec pour cle les noms des elements |
* du formulaire. |
* @return int |
* @access public |
*/ |
function enregistrerSQL( $tableau_de_valeur ) |
{ |
$nom_repertoire = projet::genereNomRepertoire($tableau_de_valeur['projet_titre'], $this->_db) ; |
if (!$this->_creationRepertoire ($nom_repertoire)) { |
echo 'Impossible de crée un répertoire'.$nom_repertoire ; |
return false ; |
} |
// Traitement du type |
if (!PROJET_UTILISE_TYPE) { |
$tableau_de_valeur['projet_type'] = 0 ; |
} |
$id = SQL_obtenirNouveauId($this->_db, 'projet', 'p_id') ; |
$requete = 'insert into projet set p_id='.$this->_db->escapeSimple($id) ; |
if (!isset($tableau_de_valeur['projet_wikini'])) { |
$tableau_de_valeur['projet_wikini']=''; |
} |
$requete .= ', p_titre="'.$tableau_de_valeur['projet_titre'].'", p_description="'.$tableau_de_valeur['projet_description'].'"'. |
', p_espace_internet="'.$tableau_de_valeur['projet_espace_internet'].'", p_date_creation=NOW()'. |
', p_wikini="'.$tableau_de_valeur['projet_wikini'].'", p_nom_repertoire="'.$nom_repertoire.'", p_resume="'.$tableau_de_valeur['projet_resume']. |
'", p_type="'.$tableau_de_valeur['projet_type'].'", p_modere="'.$tableau_de_valeur['projet_moderation'].'"' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
// On affecte a l'objet projet son identifiant |
$this->_id_projet = $id ; |
//insertion dans projet_herarchie |
if (PROJET_UTILISE_HIERARCHIE) { |
$requete = 'insert into projet_hierarchie set ph_id_projet_pere='.$this->_db->escapeSimple($tableau_de_valeur['projet_asso']). |
', ph_id_projet_fils='.$id ; |
$resultat = $this->_db->query ($requete) ; |
} |
/** enregistrement dans projet_avoir_theme */ |
$requete_theme = ''; |
foreach ($tableau_de_valeur['projet_theme'] as $cle => $valeur) { |
$requete_theme = 'insert into projet_avoir_theme set pat_id_projet='.$this->_db->escapeSimple($id).', pat_id_theme='.$this->_db->escapeSimple($cle); |
$resultat_theme = $GLOBALS['projet_db']->query($requete_theme); |
if (DB::isError($resultat_theme)) { |
return $resultat_theme->getMessage(); |
} |
} |
return true ; |
} |
/** |
* Permet de mettre a jour une ligne dans la table concernee. |
* |
* @param Array tableau_de_valeur Le tableau de valeur a inserer dans la base avec pour cle les noms des elements |
* du formulaire. |
* @return int |
* @access public |
*/ |
function majSQL( $tableau_de_valeur ) |
{ |
// Traitement du type |
if (!PROJET_UTILISE_TYPE) { |
$tableau_de_valeur['projet_type'] = 0 ; |
} |
$requete = 'update projet set '; |
$requete .= 'p_titre="'.$tableau_de_valeur['projet_titre'].'", p_description="'.$tableau_de_valeur['projet_description'].'"'. |
', p_espace_internet="'.$tableau_de_valeur['projet_espace_internet'].'"'. |
', p_resume="'.$tableau_de_valeur['projet_resume'].'", p_type="'.$tableau_de_valeur['projet_type'].'"'. |
', p_modere='.$tableau_de_valeur['projet_moderation']. |
' where p_id="'.$this->_id_projet.'"' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
if (PROJET_UTILISE_HIERARCHIE) { |
// suppression dans projet_hierarchie |
$requete = 'delete from projet_hierarchie where ph_id_projet_fils='.$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
//insertion dans projet_hierarchie |
$requete = 'insert into projet_hierarchie set ph_id_projet_pere='.$this->_db->escapeSimple($tableau_de_valeur['projet_asso']). |
', ph_id_projet_fils='.$this->_id_projet ; |
$resultat = $this->_db->query ($requete) ; |
} |
/** enregistrement dans projet_avoir_theme */ |
$requete_suppression_theme = 'delete from projet_avoir_theme where pat_id_projet='.$this->_db->escapeSimple($this->_id_projet); |
$resultat_suppression_theme = $GLOBALS['projet_db']->query($requete_suppression_theme); |
$requete_theme = ''; |
foreach ($tableau_de_valeur['projet_theme'] as $cle => $valeur) { |
$requete_theme = 'insert into projet_avoir_theme set pat_id_projet='.$this->_db->escapeSimple($this->_id_projet).', pat_id_theme='.$this->_db->escapeSimple($cle); |
$resultat_theme = $GLOBALS['projet_db']->query($requete_theme); |
if (DB::isError($resultat_theme)) { |
return $resultat_theme->getMessage(); |
} |
} |
return true ; |
} // end of member function enregistrerSQL |
/** |
* Met a jour dans la base de donnee le champs p_nom_wikini |
* |
* @param int nom_wikini Le nouveau nom wikini |
* @return bool |
* @access public |
*/ |
function majNomWikini( $nom_wikini ) |
{ |
$requete = 'update projet set p_wikini="'.$nom_wikini.'" where p_id="'.$this->_id_projet.'"' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
return true ; |
} // end of member function majNomWikini |
/** |
* |
* |
* @param string code_sql |
* @return bool |
* @access public |
*/ |
function suppressionSQL() |
{ |
$msg = '' ; |
// Supression du repertoire du projet |
if (!$this->_suppression_repertoire()) { |
$msg = 'La suppression du repertoire n\'a pas fonctionne' ; |
} |
// A ajouter la suppression des documents associes |
// La suppression des evenements associ�s |
// Le projet lui-meme |
$requete = "delete from projet where p_id=".$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (PROJET_UTILISE_HIERARCHIE) { |
$requete = "delete from projet_hierarchie where ph_id_projet_fils=".$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
} |
$requete = "delete from projet_statut_utilisateurs where psu_id_projet=".$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
return $msg ; |
} // end of member function suppressionSQL |
/** |
* Supprime le repertoire associe au projet (le repertoire doit etre vide). |
* |
* @return void |
* @access private |
*/ |
function _suppression_repertoire( ) |
{ |
return rmdir ($this->_chemin_repertoire.$this->_nom_repertoire) ; |
} // end of member function _suppression_repertoire |
/** |
* Permet de creer le repertoire associe au projet. |
* |
* @param string nom_repertoire Le nom du r�pertoire � cr�er. |
* @return boolean |
* @access private |
*/ |
function _creationRepertoire( $nom_repertoire ) |
{ |
return mkdir ($this->_chemin_repertoire.$nom_repertoire) ; |
} // end of member function _creationRepertoire |
/** |
* Permet d'indiquer ou seront stockes les fichiers. |
* |
* @param string cheminRepertoire Le chemin jusqu'au repertoire ou seront stockes les fichiers. |
* @return void |
* @access public |
*/ |
function setCheminRepertoire( $cheminRepertoire ) |
{ |
$this->_chemin_repertoire = $cheminRepertoire ; |
} // end of member function setCheminRepertoire |
/** |
* Genere un nom de repertoire a partir de la premiere lettre de la chaine passe en |
* parametre et de l'identifiant du dernier projet. |
* |
* @param string chaine Une chaine a partir de laquelle sera generer le nom du repertoire. |
* @param DB objetDB un objet PEAR::DB |
* @return string |
* @static |
* @access public |
*/ |
function genereNomRepertoire( $chaine, &$objetDB ) |
{ |
$requete = "select p_id from projet order by p_id desc limit 0,1" ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ("Echec de la requete : $requete<br />".$resultat->getMessage()) ; |
} |
if ($resultat->numRows() > 0) { |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
$nom = strtoupper(substr($chaine, 0, 1)) ; |
$nom .= $ligne->p_id + 1 ; |
} |
else { |
$nom = strtoupper(substr($chaine, 0, 1)) ; |
$nom .= 1 ; |
} |
return $nom ; |
} // end of member function genereNomRepertoire |
/** |
* Permet de recuperer le nom du repertoire d'un projet. |
* |
* @return string |
* @access public |
*/ |
function getNomRepertoire( ) |
{ |
return $this->_nom_repertoire ; |
} // end of member function getNomRepertoire |
/** |
* Ajoute une liste a un projet |
* Effectue une insertion dans projet_lien_liste |
* |
* @param liste_discussion liste Une instance de la classe liste_discussion |
* @return void |
* @access public |
*/ |
function ajouterListe( &$liste ) |
{ |
$requete = "insert into projet_lien_liste set pl_id_liste=".$this->_db->escapeSimple($liste->getId()). |
', pl_id_projet='.$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ("Echec de la requete : $requete<br />".$resultat->getMessage()) ; |
} |
} |
/** |
* Supprime la liste de discussion associee au projet |
* |
* @return void |
* @access public |
*/ |
function supprimerListe(&$liste) |
{ |
$requete = 'delete from projet_lien_liste where pl_id_liste='.$this->_db->escapeSimple($liste->getId()) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$requete = 'delete from projet_liste where pl_id_liste='.$this->_db->escapeSimple($liste->getId()) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
} |
/** |
* Renvoie vrai si le projet est racine. |
* |
* @return bool |
* @access public |
*/ |
function isRacine( ) |
{ |
return $this->_est_racine ; |
} // end of member function isRacine |
/** |
* Renvoie le nombre d'inscrits au projet. Effectue une requete dans la table |
* projet_statut_utilisateurs |
* |
* @return int |
* @access public |
*/ |
function getNombreInscrits( ) |
{ |
$requete = 'select count(psu_id_utilisateur) as nbre from projet_statut_utilisateurs where psu_id_projet='.$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
return $ligne->nbre ; |
} // end of member function getNombreInscrits |
/** |
* Renvoie un tableau contenant les identifiants des fils du projet courant. |
* |
* @return Array |
* @access public |
*/ |
function getHierarchie( ) |
{ |
$requete = 'select ph_id_projet_fils from projet_hierarchie where ph_id_projet_pere='.$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$tableau_resultat = array() ; |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_resultat, $ligne->ph_id_projet_fils) ; |
} |
return $tableau_resultat ; |
} // end of member function getHierarchie |
/** |
* Renvoie l'identifiant du pere du projet courrant. |
* |
* @return int |
* @access public |
*/ |
function getIdPere() |
{ |
$requete = 'select ph_id_projet_pere from projet_hierarchie where ph_id_projet_fils='.$this->_db->escapeSimple($this->_id_projet) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$tableau_resultat = array() ; |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; |
return $ligne->ph_id_projet_pere ; |
} // end of member function getIdPere() |
/** |
* Renvoie le nom Wiki du wikini associe au projet. |
* |
* @return string |
* @access public |
*/ |
function getWikini( ) |
{ |
return $this->_nom_wikini ; |
} // end of member function getWikini |
/** |
* Renvoie le type du projet, ou zero si le projet n'a pas de type. |
* |
* @return int |
* @access public |
*/ |
function getType( ) |
{ |
return $this->_type ; |
} // end of member function getType |
/** |
* Renvoie les themes du projet, ou zero si le projet n'a pas de type. |
* |
* @return int |
* @access public |
*/ |
function getThemes( ) |
{ |
return $this->_themes ; |
} // end of member function getType |
/** |
* Renvoie 1 si les inscriptions au projet sont moderees. |
* |
* @return int |
* @access public |
*/ |
function isModere( ) |
{ |
return $this->_isModere ; |
} // end of member function getType |
/** |
* initAttributes sets all projet attributes to its default value make |
* sure to call this method within your class constructor |
*/ |
function initAttributes( ) |
{ |
$this->chemin_wikini = "projet/wikini/"; |
} |
} // end of projet |
?> |
/trunk/classes/projet_type.class.php |
---|
1,107 → 1,107 |
<?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: projet_type.class.php,v 1.2 2005-10-14 08:55:50 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe projet_type |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.2 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class projet_type |
* |
*/ |
class projet_type |
{ |
/*** Attributes: ***/ |
/** |
* Une connection vers une base de donnée |
* @access private |
*/ |
var $_db; |
/** |
* Renvoie tous types de projets (de la table projet_type) ans un tableau avec pour |
* clé l'identifiant et pour valeur le label. |
* |
* @return Array |
* @static |
* @access public |
*/ |
function getTousLesTypes(& $objetDB ) |
{ |
$requete = 'select * from projet_type' ; |
return $objetDB->getAssoc ($requete) ; |
} // end of member function getTousLesTypes |
/** |
* |
* |
* @param DB objetDB Une instance de la classe PEAR::DB |
* @return void |
* @access public |
*/ |
function projet_type( & $objetDB ) |
{ |
$this->_db = $objetDB ; |
} // end of member function projet_type |
/** |
* |
* |
* @param DB objetDB Une instance de la classe PEAR::DB |
* @return void |
* @access public |
*/ |
function getLabelType( $id_type) |
{ |
$requete = 'select pt_label_type from projet_type where pt_id_type='.$this->_db->escapeSimple($id_type) ; |
$resultat = $this->_db->getOne($requete) ; |
if (DB::isError($resultat)) { |
echo $resultat->getMessage() ; |
} |
return $resultat ; |
} // end of member function projet_type |
} // end of projet_type |
?> |
<?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: projet_type.class.php,v 1.2 2005/10/14 08:55:50 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe projet_type |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.2 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class projet_type |
* |
*/ |
class projet_type |
{ |
/*** Attributes: ***/ |
/** |
* Une connection vers une base de donnée |
* @access private |
*/ |
var $_db; |
/** |
* Renvoie tous types de projets (de la table projet_type) ans un tableau avec pour |
* clé l'identifiant et pour valeur le label. |
* |
* @return Array |
* @static |
* @access public |
*/ |
function getTousLesTypes(& $objetDB ) |
{ |
$requete = 'select * from projet_type' ; |
return $objetDB->getAssoc ($requete) ; |
} // end of member function getTousLesTypes |
/** |
* |
* |
* @param DB objetDB Une instance de la classe PEAR::DB |
* @return void |
* @access public |
*/ |
function projet_type( & $objetDB ) |
{ |
$this->_db = $objetDB ; |
} // end of member function projet_type |
/** |
* |
* |
* @param DB objetDB Une instance de la classe PEAR::DB |
* @return void |
* @access public |
*/ |
function getLabelType( $id_type) |
{ |
$requete = 'select pt_label_type from projet_type where pt_id_type='.$this->_db->escapeSimple($id_type) ; |
$resultat = $this->_db->getOne($requete) ; |
if (DB::isError($resultat)) { |
echo $resultat->getMessage() ; |
} |
return $resultat ; |
} // end of member function projet_type |
} // end of projet_type |
?> |
/trunk/classes/enteteColonneTriable.class.php |
---|
1,259 → 1,259 |
<?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: enteteColonneTriable.class.php,v 1.1 2008-08-25 15:17:13 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* Fichier de presentation de la liste des projets pour Tela Botanica nouvelle version |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2008 |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
/** |
* class enteteColonneTriable |
*/ |
class enteteColonneTriable |
{ |
/*** Attributes: ***/ |
/** |
* Nom de la colonne dont on veut afficher le lien |
* @access private |
*/ |
private $colonne; |
/** |
* Nom de la colonne dont on veut afficher le lien |
* @access private |
*/ |
private $var_colonneDeTri; |
/** |
* Nom de la colonne clique par l utilisateur |
* @access private |
*/ |
private $colonneCliquee; |
/** |
* @access private |
*/ |
private $ordre = 'asc'; |
/** |
* @access private |
*/ |
private $var_ordre ; |
/** |
* @access private |
*/ |
private $icone_asc; |
/** |
* @access private |
*/ |
private $icone_desc; |
/** |
* icone par defaut lorsqu aucun tri n est demande |
* @access private |
*/ |
private $icone_base; |
/** |
* |
* @param string nom_colonne Le nom de la colonne sur laquelle va s'effectuer les tris |
* @return |
* @access public |
*/ |
public function enteteColonneTriable( $nom_colonne ) { |
$this->colonne = $nom_colonne; |
} // end of member function enteteColonneTriable |
/** |
* |
* @param string colonneDeTri |
* @return bool |
* @access public |
*/ |
public function setColonneCliquee( $colonneDeTri, $var_colonneDeTri ) { |
$this->colonneCliquee = $colonneDeTri; |
$this->var_colonneDeTri = $var_colonneDeTri; |
} // end of member function setColonneCliquee |
/** |
* Precise l ordre ascendant ou descendant |
* Ne peut prendre que 2 valeurs asc ou desc |
* |
* @param string ordre |
* @return |
* @access public |
*/ |
public function setOrdre( $ordre, $var_ordre ) { |
if ($ordre != 'asc' && $ordre != 'desc') return false; |
//if ($this->colonne == $this->colonneCliquee) $this->ordre = $ordre; |
// C subtil, il faut inverser l ordre de tri pour la colonne dont le tri est |
// actif, afin de pouvoir inverser le tri |
$this->ordre = $ordre; |
if ($this->colonne == $this->colonneCliquee) { |
if ($ordre == 'asc') $this->ordre = 'desc'; else $this->ordre = 'asc'; |
} |
$this->var_ordre = $var_ordre; |
} // end of member function setOrdre |
/** |
* Pour indiquer le chemin vers l icone de fleche vers le bas |
* Renvoie false si le chemin vers l icone n existe pas |
* |
* @param string chemin_icone Le chemin vers l icone |
* @return |
* @access public |
*/ |
public function setIconeAsc( $chemin_icone ) { |
$this->icone_asc = $chemin_icone; |
} // end of member function setIconeAsc |
/** |
* Pour indiquer le chemin vers l icone de fleche vers le bas |
* Renvoie false si le chemin vers l icone n existe pas |
* |
* @param string chemin_icone Chemin vers l icone indiquant un classement descendant, en general une fleche |
vers le haut |
* @return bool |
* @access public |
*/ |
public function setIconeDesc( $chemin_icone ) { |
$this->icone_desc = $chemin_icone; |
} // end of member function setIconeDesc |
/** |
* |
* @param string chemin_icone chemin vers un fichier |
* @return bool |
* @access public |
*/ |
public function setIconeSansTri( $chemin_icone ) { |
$this->icone_base = $chemin_icone; |
} // end of member function setIconeSansTri |
/** |
* Permet d attribuer un template d affichage |
* |
* @param string template Permet d attribuer un template d affichage |
* @return |
* @access public |
*/ |
public function setTemplate( $template ) { |
} // end of member function setTemplate |
/** |
* Renvoie l icone approprie pour l entete de la colonne |
* |
* @return string |
* @access public |
*/ |
public function getIcone( ) { |
if ($this->colonne == $this->colonneCliquee) { |
if ($this->ordre == 'asc') { |
return $this->icone_asc; |
} else { |
return $this->icone_desc; |
} |
} else { |
return $this->icone_base; |
} |
} // end of member function getIcone |
/** |
* Renvoie la classe approprie pour l entete de la colonne |
* |
* @return string |
* @access public |
*/ |
public function getClasse( ) { |
if ($this->colonne == $this->colonneCliquee) { |
if ($this->ordre == 'asc') { |
return 'tri_bas'; |
} else { |
return 'tri_haut'; |
} |
} else { |
return 'tri_sans'; |
} |
} // end of member function getIcone |
/** |
* Renvoie le lien de la colonne |
* |
* @return string |
* @access public |
*/ |
public function getLien($url) { |
$url->addQueryString('projet_tri', $this->colonne); |
$url->addQueryString('projet_ordre_tri', $this->ordre); |
return $url->getURL(); |
} // end of member function getLien |
/** |
* Renvoie l entete |
* |
* @return string |
* @access public |
*/ |
public function getEntete( ) { |
} // end of member function getEntete |
/** |
* similaire a getEntete() |
* |
* @return string |
* @access public |
*/ |
public function toHTML( ) { |
return getEntete(); |
} // end of member function toHTML |
} // end of enteteColonneTriable |
<?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$ |
/** |
* Application projet |
* |
* Fichier de presentation de la liste des projets pour Tela Botanica nouvelle version |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2008 |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
/** |
* class enteteColonneTriable |
*/ |
class enteteColonneTriable |
{ |
/*** Attributes: ***/ |
/** |
* Nom de la colonne dont on veut afficher le lien |
* @access private |
*/ |
private $colonne; |
/** |
* Nom de la colonne dont on veut afficher le lien |
* @access private |
*/ |
private $var_colonneDeTri; |
/** |
* Nom de la colonne clique par l utilisateur |
* @access private |
*/ |
private $colonneCliquee; |
/** |
* @access private |
*/ |
private $ordre = 'asc'; |
/** |
* @access private |
*/ |
private $var_ordre ; |
/** |
* @access private |
*/ |
private $icone_asc; |
/** |
* @access private |
*/ |
private $icone_desc; |
/** |
* icone par defaut lorsqu aucun tri n est demande |
* @access private |
*/ |
private $icone_base; |
/** |
* |
* @param string nom_colonne Le nom de la colonne sur laquelle va s'effectuer les tris |
* @return |
* @access public |
*/ |
public function enteteColonneTriable( $nom_colonne ) { |
$this->colonne = $nom_colonne; |
} // end of member function enteteColonneTriable |
/** |
* |
* @param string colonneDeTri |
* @return bool |
* @access public |
*/ |
public function setColonneCliquee( $colonneDeTri, $var_colonneDeTri ) { |
$this->colonneCliquee = $colonneDeTri; |
$this->var_colonneDeTri = $var_colonneDeTri; |
} // end of member function setColonneCliquee |
/** |
* Precise l ordre ascendant ou descendant |
* Ne peut prendre que 2 valeurs asc ou desc |
* |
* @param string ordre |
* @return |
* @access public |
*/ |
public function setOrdre( $ordre, $var_ordre ) { |
if ($ordre != 'asc' && $ordre != 'desc') return false; |
//if ($this->colonne == $this->colonneCliquee) $this->ordre = $ordre; |
// C subtil, il faut inverser l ordre de tri pour la colonne dont le tri est |
// actif, afin de pouvoir inverser le tri |
$this->ordre = $ordre; |
if ($this->colonne == $this->colonneCliquee) { |
if ($ordre == 'asc') $this->ordre = 'desc'; else $this->ordre = 'asc'; |
} |
$this->var_ordre = $var_ordre; |
} // end of member function setOrdre |
/** |
* Pour indiquer le chemin vers l icone de fleche vers le bas |
* Renvoie false si le chemin vers l icone n existe pas |
* |
* @param string chemin_icone Le chemin vers l icone |
* @return |
* @access public |
*/ |
public function setIconeAsc( $chemin_icone ) { |
$this->icone_asc = $chemin_icone; |
} // end of member function setIconeAsc |
/** |
* Pour indiquer le chemin vers l icone de fleche vers le bas |
* Renvoie false si le chemin vers l icone n existe pas |
* |
* @param string chemin_icone Chemin vers l icone indiquant un classement descendant, en general une fleche |
vers le haut |
* @return bool |
* @access public |
*/ |
public function setIconeDesc( $chemin_icone ) { |
$this->icone_desc = $chemin_icone; |
} // end of member function setIconeDesc |
/** |
* |
* @param string chemin_icone chemin vers un fichier |
* @return bool |
* @access public |
*/ |
public function setIconeSansTri( $chemin_icone ) { |
$this->icone_base = $chemin_icone; |
} // end of member function setIconeSansTri |
/** |
* Permet d attribuer un template d affichage |
* |
* @param string template Permet d attribuer un template d affichage |
* @return |
* @access public |
*/ |
public function setTemplate( $template ) { |
} // end of member function setTemplate |
/** |
* Renvoie l icone approprie pour l entete de la colonne |
* |
* @return string |
* @access public |
*/ |
public function getIcone( ) { |
if ($this->colonne == $this->colonneCliquee) { |
if ($this->ordre == 'asc') { |
return $this->icone_asc; |
} else { |
return $this->icone_desc; |
} |
} else { |
return $this->icone_base; |
} |
} // end of member function getIcone |
/** |
* Renvoie la classe approprie pour l entete de la colonne |
* |
* @return string |
* @access public |
*/ |
public function getClasse( ) { |
if ($this->colonne == $this->colonneCliquee) { |
if ($this->ordre == 'asc') { |
return 'tri_bas'; |
} else { |
return 'tri_haut'; |
} |
} else { |
return 'tri_sans'; |
} |
} // end of member function getIcone |
/** |
* Renvoie le lien de la colonne |
* |
* @return string |
* @access public |
*/ |
public function getLien($url) { |
$url->addQueryString('projet_tri', $this->colonne); |
$url->addQueryString('projet_ordre_tri', $this->ordre); |
return $url->getURL(); |
} // end of member function getLien |
/** |
* Renvoie l entete |
* |
* @return string |
* @access public |
*/ |
public function getEntete( ) { |
} // end of member function getEntete |
/** |
* similaire a getEntete() |
* |
* @return string |
* @access public |
*/ |
public function toHTML( ) { |
return getEntete(); |
} // end of member function toHTML |
} // end of enteteColonneTriable |
?> |
/trunk/classes/HTML_formulaireCouperColler.class.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: HTML_formulaireCouperColler.class.php,v 1.3 2007-06-25 12:15:06 alexandre_tb Exp $ |
// CVS : $Id: HTML_formulaireCouperColler.class.php,v 1.2 2005/09/27 16:39:25 alexandre_tb Exp $ |
/** |
* Application projet |
* |
31,7 → 31,7 |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.3 $ |
*@version $Revision: 1.2 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
/trunk/classes/ezmlm-php-2.0/ezmlm-repondre.php |
---|
1,187 → 1,187 |
<?php |
// $Id: ezmlm-repondre.php,v 1.2 2005/09/27 16:43:08 alexandre_tb Exp $ |
// |
// ezmlm-msgdisplay.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
// Will parse a template (if specified) and display a message. |
// Includes a default template. |
// -------------------------------------------------------------- |
require_once("ezmlm.php"); |
require_once("Mail/mimeDecode.php") ; |
class ezmlm_repondre extends ezmlm_php { |
// our template |
var $msgtmpl; |
var $message_rendu ; |
// display: parses a message (using ezmlm_parser) and displays it |
// using a template |
function repondre($msgfile) { |
if (!is_file($msgfile)) { |
if (is_file($this->listdir . "/" . $msgfile)) { $msgfile = $this->listdir . "/" . $msgfile; } |
else if (is_file($this->listdir . "/archive/" . $msgfile)) { $msgfile = $this->listdir . "/archive/" . $msgfile; } |
else { return FALSE; } |
} |
$message = file_get_contents($msgfile) ; |
$mimeDecode = new Mail_mimeDecode($message) ; |
$mailDecode = $mimeDecode->decode(array('decode_bodies' => 'true', 'include_bodies' => 'true')) ; |
// $msg->msgfile contient le chemin du fichier du mail en partant de la racine |
// Le point d'exclamation est le délimiteur de l'expression régulière |
$relfile = preg_replace('!' . $this->listdir . '!', '', $msgfile); |
$a1 = preg_replace('!/archive/(.*)/.*$!', '\1', $relfile); // $a1 contient le nom du répertoire |
$a2 = preg_replace('!/archive/.*/(.*)$!', '\1', $relfile); // $a2 contient le nom du fichier |
if (isset($mailDecode->headers['date'])) $msgtime = strtotime(preg_replace ('/CEST/', '', $mailDecode->headers['date'])); |
$threadidx = date("Ym", $msgtime); |
if ($a2 <= 10) $numero_precedent = '0'.($a2 - 1) ; else $numero_precedent = ($a2 - 1) ; |
if ($a2 < 9) $numero_suivant = '0'.($a2 + 1) ; else $numero_suivant = ($a2 + 1); |
// On teste si le message suivant existe |
$decoupe = explode ('/', $msgfile) ; |
// Les nom de fichiers sont du format : |
// archive/0/01 |
// archive/0/02 ... 0/99 archive/1/01 ... |
$nom_fichier = $decoupe[count($decoupe)-1] ; |
$nom_repertoire = $decoupe[count($decoupe)-2] ; |
$repertoire_suivant = $nom_repertoire ; $repertoire_precedent = $nom_repertoire ; |
if ($nom_fichier > 8) { |
$fichier_suivant = $nom_fichier + 1 ; |
if ($nom_fichier == 99) { |
$fichier_suivant = '01' ; |
$repertoire_suivant = $nom_repertoire + 1 ; |
} |
} else { |
$fichier_suivant = '0'.($nom_fichier + 1) ; |
} |
if ($nom_fichier > 10) { |
$fichier_precedent = $nom_fichier - 1 ; |
} else { |
if ($nom_fichier == '01') { |
$fichier_precedent = '99' ; |
$repertoire_precedent = $nom_repertoire - 1 ; |
} else { |
$fichier_precedent = '0'.($nom_fichier - 1) ; |
} |
} |
print '<br />'."\n"; |
$this->parse_template($mailDecode, $a2, $a1); |
$formulaireReponse = new HTML_formulaireMail('formulaire_reponse', 'post', str_replace('&', '&', $this->forcehref).'&action=repondre&'. |
'actionargs[]='.$a1.'&actionargs[]='.$a2.'&'.PROJET_VARIABLE_ACTION.'='.PROJET_ENVOYER_UN_MAIL_V) ; |
$formulaireReponse->construitFormulaire() ; |
$formulaireReponse->addElement ('hidden', 'messageid', $mailDecode->headers['message-id']) ; |
// Ajout de > au début de chaque ligne du message |
$tableau = explode ("\n", $this->message_rendu) ; |
$this->message_rendu = "> ".implode ("\n> ", $tableau) ; |
$formulaireReponse->setDefaults(array('mail_corps' => $this->message_rendu, |
'mail_titre' => 'Re : '.$this->decode_iso ($mailDecode->headers['subject']))) ; |
print $formulaireReponse->toHTML() ; |
} |
function parse_template(&$mailDecode, $numero_mail, $numero_mois, $num_part = '') { |
static $profondeur = array(); |
array_push ($profondeur, $num_part) ; |
$corps = '' ; |
if ($mailDecode->ctype_primary == 'multipart') { |
include_once PROJET_CHEMIN_CLASSES.'type_fichier_mime.class.php' ; |
for ($i = 0; $i < count($mailDecode->parts); $i++) { |
switch ($mailDecode->parts[$i]->ctype_secondary) { |
case 'plain' : |
case 'html' : $corps .= $mailDecode->parts[$i]->body ; |
break ; |
case 'mixed' : |
case 'rfc822' : |
case 'alternative' : |
case 'appledouble' : |
$this->parse_template($mailDecode->parts[$i], $numero_mail, $numero_mois, $i) ; |
break ; |
case 'applefile' : continue ; |
break ; |
default : |
if ($mailDecode->parts[$i]->ctype_secondary == 'octet-stream') { |
$nom_piece_jointe = $mailDecode->parts[$i]->ctype_parameters['name'] ; |
$tab = explode ('.', $nom_piece_jointe) ; |
$extension = $tab[count ($tab) - 1] ; |
$mimeType = type_fichier_mime::factory($extension, $GLOBALS['projet_db']); |
$mimeType->setCheminIcone(PROJET_CHEMIN_ICONES) ; |
} else { |
$nom_piece_jointe = isset ($mailDecode->parts[$i]->d_parameters['filename']) ? |
$mailDecode->parts[$i]->d_parameters['filename'] : $mailDecode->parts[$i]->ctype_parameters['name'] ; |
$mimeType = new type_fichier_mime($GLOBALS['projet_db'], $mailDecode->parts[$i]->ctype_primary.'/'. |
$mailDecode->parts[$i]->ctype_secondary, PROJET_CHEMIN_ICONES) ; |
} |
$corps .= ''; |
if (count ($profondeur) > 0) { |
array_shift($profondeur) ; |
//for ($j= 0; $j < count ($profondeur); $j++) $corps .= '&actionargs[]='.$profondeur[$j]; |
} |
/*$corps .= '&actionargs[]='.$i ; |
$corps .= '">'.'<img src="'.$mimeType->getCheminIcone().'" alt="'.$nom_piece_jointe.'" /> ' ; |
$corps .= $nom_piece_jointe; |
$corps .= '</a><br />' ;*/ |
break ; |
} |
} |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,TRUE), $this->msgtmpl); |
} else if ($mailDecode->ctype_primary == 'message') { |
$this->message_rendu .= "\n".'<div class="message">'.$this->parse_entete_mail($mailDecode->parts[0]); |
$corps .= $this->parse_template($mailDecode->parts[0], $numero_mail, $numero_mois, 0) ; |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl).'</div>'; |
} else if ($mailDecode->ctype_primary == 'application' || $mailDecode->ctype_primary == 'image'){ |
if ($mailDecode->ctype_secondary == 'applefile') return ; |
$mimeType = new type_fichier_mime($GLOBALS['projet_db'], $mailDecode->ctype_primary.'/'.$mailDecode->ctype_secondary,PROJET_CHEMIN_ICONES) ; |
if ($mimeType->getIdType() != 12) { |
$corps .= '' ; |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl); |
} |
} else { |
if (preg_match('/html/i', $mailDecode->ctype_secondary)) { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($mailDecode->body), $this->msgtmpl); |
} else { |
if (isset ($mailDecode->ctype_parameters['charset']) && $mailDecode->ctype_parameters['charset'] == 'UTF-8') { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', utf8_decode($this->cleanup_body($mailDecode->body)) , $this->msgtmpl); |
} else { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($mailDecode->body), $this->msgtmpl); |
} |
} |
} |
} |
function ezmlm_repondre() { |
$this->ezmlm_php(); |
if (($this->msgtemplate != "") and (is_file($this->msgtemplate))) { |
$fd = fopen($this->msgtemplate, "r"); |
while (!feof($fd)) { $this->msgtmpl .= fgets($fd,4096); } |
fclose($fd); |
} else { |
$this->msgtmpl = '<ezmlm-body>'; |
} |
$this->msgtmpl_entete = '<dl><ezmlm-headers> |
<dt><ezmlm-header-name> :</dt> |
<dd><ezmlm-header-value></dd> |
</ezmlm-headers> |
</dl>' ; |
} |
} |
<?php |
// $Id: ezmlm-repondre.php,v 1.2 2005-09-27 16:43:08 alexandre_tb Exp $ |
// |
// ezmlm-msgdisplay.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
// Will parse a template (if specified) and display a message. |
// Includes a default template. |
// -------------------------------------------------------------- |
require_once("ezmlm.php"); |
require_once("Mail/mimeDecode.php") ; |
class ezmlm_repondre extends ezmlm_php { |
// our template |
var $msgtmpl; |
var $message_rendu ; |
// display: parses a message (using ezmlm_parser) and displays it |
// using a template |
function repondre($msgfile) { |
if (!is_file($msgfile)) { |
if (is_file($this->listdir . "/" . $msgfile)) { $msgfile = $this->listdir . "/" . $msgfile; } |
else if (is_file($this->listdir . "/archive/" . $msgfile)) { $msgfile = $this->listdir . "/archive/" . $msgfile; } |
else { return FALSE; } |
} |
$message = file_get_contents($msgfile) ; |
$mimeDecode = new Mail_mimeDecode($message) ; |
$mailDecode = $mimeDecode->decode(array('decode_bodies' => 'true', 'include_bodies' => 'true')) ; |
// $msg->msgfile contient le chemin du fichier du mail en partant de la racine |
// Le point d'exclamation est le délimiteur de l'expression régulière |
$relfile = preg_replace('!' . $this->listdir . '!', '', $msgfile); |
$a1 = preg_replace('!/archive/(.*)/.*$!', '\1', $relfile); // $a1 contient le nom du répertoire |
$a2 = preg_replace('!/archive/.*/(.*)$!', '\1', $relfile); // $a2 contient le nom du fichier |
if (isset($mailDecode->headers['date'])) $msgtime = strtotime(preg_replace ('/CEST/', '', $mailDecode->headers['date'])); |
$threadidx = date("Ym", $msgtime); |
if ($a2 <= 10) $numero_precedent = '0'.($a2 - 1) ; else $numero_precedent = ($a2 - 1) ; |
if ($a2 < 9) $numero_suivant = '0'.($a2 + 1) ; else $numero_suivant = ($a2 + 1); |
// On teste si le message suivant existe |
$decoupe = explode ('/', $msgfile) ; |
// Les nom de fichiers sont du format : |
// archive/0/01 |
// archive/0/02 ... 0/99 archive/1/01 ... |
$nom_fichier = $decoupe[count($decoupe)-1] ; |
$nom_repertoire = $decoupe[count($decoupe)-2] ; |
$repertoire_suivant = $nom_repertoire ; $repertoire_precedent = $nom_repertoire ; |
if ($nom_fichier > 8) { |
$fichier_suivant = $nom_fichier + 1 ; |
if ($nom_fichier == 99) { |
$fichier_suivant = '01' ; |
$repertoire_suivant = $nom_repertoire + 1 ; |
} |
} else { |
$fichier_suivant = '0'.($nom_fichier + 1) ; |
} |
if ($nom_fichier > 10) { |
$fichier_precedent = $nom_fichier - 1 ; |
} else { |
if ($nom_fichier == '01') { |
$fichier_precedent = '99' ; |
$repertoire_precedent = $nom_repertoire - 1 ; |
} else { |
$fichier_precedent = '0'.($nom_fichier - 1) ; |
} |
} |
print '<br />'."\n"; |
$this->parse_template($mailDecode, $a2, $a1); |
$formulaireReponse = new HTML_formulaireMail('formulaire_reponse', 'post', str_replace('&', '&', $this->forcehref).'&action=repondre&'. |
'actionargs[]='.$a1.'&actionargs[]='.$a2.'&'.PROJET_VARIABLE_ACTION.'='.PROJET_ENVOYER_UN_MAIL_V) ; |
$formulaireReponse->construitFormulaire() ; |
$formulaireReponse->addElement ('hidden', 'messageid', $mailDecode->headers['message-id']) ; |
// Ajout de > au début de chaque ligne du message |
$tableau = explode ("\n", $this->message_rendu) ; |
$this->message_rendu = "> ".implode ("\n> ", $tableau) ; |
$formulaireReponse->setDefaults(array('mail_corps' => $this->message_rendu, |
'mail_titre' => 'Re : '.$this->decode_iso ($mailDecode->headers['subject']))) ; |
print $formulaireReponse->toHTML() ; |
} |
function parse_template(&$mailDecode, $numero_mail, $numero_mois, $num_part = '') { |
static $profondeur = array(); |
array_push ($profondeur, $num_part) ; |
$corps = '' ; |
if ($mailDecode->ctype_primary == 'multipart') { |
include_once PROJET_CHEMIN_CLASSES.'type_fichier_mime.class.php' ; |
for ($i = 0; $i < count($mailDecode->parts); $i++) { |
switch ($mailDecode->parts[$i]->ctype_secondary) { |
case 'plain' : |
case 'html' : $corps .= $mailDecode->parts[$i]->body ; |
break ; |
case 'mixed' : |
case 'rfc822' : |
case 'alternative' : |
case 'appledouble' : |
$this->parse_template($mailDecode->parts[$i], $numero_mail, $numero_mois, $i) ; |
break ; |
case 'applefile' : continue ; |
break ; |
default : |
if ($mailDecode->parts[$i]->ctype_secondary == 'octet-stream') { |
$nom_piece_jointe = $mailDecode->parts[$i]->ctype_parameters['name'] ; |
$tab = explode ('.', $nom_piece_jointe) ; |
$extension = $tab[count ($tab) - 1] ; |
$mimeType = type_fichier_mime::factory($extension); |
$mimeType->setCheminIcone(PROJET_CHEMIN_ICONES) ; |
} else { |
$nom_piece_jointe = isset ($mailDecode->parts[$i]->d_parameters['filename']) ? |
$mailDecode->parts[$i]->d_parameters['filename'] : $mailDecode->parts[$i]->ctype_parameters['name'] ; |
$mimeType = new type_fichier_mime( $mailDecode->parts[$i]->ctype_primary.'/'. |
$mailDecode->parts[$i]->ctype_secondary, PROJET_CHEMIN_ICONES) ; |
} |
$corps .= ''; |
if (count ($profondeur) > 0) { |
array_shift($profondeur) ; |
//for ($j= 0; $j < count ($profondeur); $j++) $corps .= '&actionargs[]='.$profondeur[$j]; |
} |
/*$corps .= '&actionargs[]='.$i ; |
$corps .= '">'.'<img src="'.$mimeType->getCheminIcone().'" alt="'.$nom_piece_jointe.'" /> ' ; |
$corps .= $nom_piece_jointe; |
$corps .= '</a><br />' ;*/ |
break ; |
} |
} |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,TRUE), $this->msgtmpl); |
} else if ($mailDecode->ctype_primary == 'message') { |
$this->message_rendu .= "\n".'<div class="message">'.$this->parse_entete_mail($mailDecode->parts[0]); |
$corps .= $this->parse_template($mailDecode->parts[0], $numero_mail, $numero_mois, 0) ; |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl).'</div>'; |
} else if ($mailDecode->ctype_primary == 'application' || $mailDecode->ctype_primary == 'image'){ |
if ($mailDecode->ctype_secondary == 'applefile') return ; |
$mimeType = new type_fichier_mime( $mailDecode->ctype_primary.'/'.$mailDecode->ctype_secondary,PROJET_CHEMIN_ICONES) ; |
if ($mimeType->getIdType() != 12) { |
$corps .= '' ; |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl); |
} |
} else { |
if (preg_match('/html/i', $mailDecode->ctype_secondary)) { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($mailDecode->body), $this->msgtmpl); |
} else { |
if (isset ($mailDecode->ctype_parameters['charset']) && $mailDecode->ctype_parameters['charset'] == 'UTF-8') { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', utf8_decode($this->cleanup_body($mailDecode->body)) , $this->msgtmpl); |
} else { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($mailDecode->body), $this->msgtmpl); |
} |
} |
} |
} |
function ezmlm_repondre() { |
$this->ezmlm_php(); |
if (($this->msgtemplate != "") and (is_file($this->msgtemplate))) { |
$fd = fopen($this->msgtemplate, "r"); |
while (!feof($fd)) { $this->msgtmpl .= fgets($fd,4096); } |
fclose($fd); |
} else { |
$this->msgtmpl = '<ezmlm-body>'; |
} |
$this->msgtmpl_entete = '<dl><ezmlm-headers> |
<dt><ezmlm-header-name> :</dt> |
<dd><ezmlm-header-value></dd> |
</ezmlm-headers> |
</dl>' ; |
} |
} |
/trunk/classes/ezmlm-php-2.0/ezmlm-author.php |
---|
1,5 → 1,5 |
<?php |
// $Id: ezmlm-author.php,v 1.4 2008-11-19 09:28:46 aperonnet Exp $ |
// $Id: ezmlm-author.php,v 1.3 2007/04/19 15:34:35 neiluj Exp $ |
// |
// ezmlm-author.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
14,8 → 14,8 |
//echo $file ; |
if (!is_file($this->listdir . $file)) { $this->error(EZMLM_INVALID_AUTHOR); return; } |
// Le fichier author comprend |
// première ligne hash_auteur nom_auteur |
// num_mess:annéemois:hash_sujet sujet |
// Premi�re ligne hash_auteur nom_auteur |
// num_mess:ann�emois:hash_sujet sujet |
$fd = @fopen($this->listdir . $file, "r"); |
$i = 0 ; |
$class = array ('ligne_impaire', 'ligne_paire') ; |
30,7 → 30,7 |
$tableopened = TRUE; |
} else if (preg_match('/^[0-9]*:[0-9]/',$buf)) { |
// si la ligne est valide |
// on récupère le numéro du message pour en extraire le nom du fichier |
// on r�cup�re le num�ro du message pour en extraire le nom du fichier |
$msgfile = preg_replace('/^([0-9]*):.*/', '\1', $buf); |
$msgdir = (int)((int)$msgfile / 100); |
$msgfile = (int)$msgfile % 100; |
/trunk/classes/ezmlm-php-2.0/ezmlm.php |
---|
1,5 → 1,5 |
<?php |
// $Id: ezmlm.php,v 1.3.2.2 2007/03/13 11:04:46 alexandre_tb Exp $ |
// $Id: ezmlm.php,v 1.5 2007/04/19 15:34:35 neiluj Exp $ |
// |
// ezmlm.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
30,7 → 30,7 |
require_once("ezmlm-repondre.php"); |
require_once("ezmlm-author.php"); |
$GLOBALS['mois'] = array ('Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre') ; |
$GLOBALS['mois'] = array ('Jan', 'F�v', 'Mars', 'Avril', 'Mai', 'Juin', 'Juil', 'Ao�t', 'Sept', 'Oct', 'Nov', 'D�c') ; |
// CLASS: ezmlm_php |
// the base class, contains common functions and the config |
67,15 → 67,15 |
var $actionargs; |
function ezmlm_php() { |
// USER-CONFIG section |
// these variables act the same way ezmlm-php-config.php did in the first release |
// simply edit these variables to match your setup |
$this->listdir = ""; |
$this->listname = ""; |
$this->listdomain = ""; |
$this->tempdir = ""; |
$this->sendheaders = TRUE; |
93,7 → 93,7 |
"subject", |
"date" |
); |
$this->header_en_francais = array ('to' => 'A', |
$this->header_en_francais = array ('to' => 'A', |
'from' => 'De', |
'subject' => 'Sujet', |
'date' => 'Date') ; |
118,16 → 118,6 |
/*$this->error(EZMLM_INVALID_DIR,TRUE);*/ |
} |
} |
/* |
* Renvoi le nombre de message dans une archive |
* Le nombre contenu dans liste/num |
*/ |
function getNumArchive() { |
if ($this->listdir != '') { |
$num = split(':', file_get_contents($this->listdir.'/num')); |
return $num[0]; |
} |
} |
function set_action($action) { |
if (is_array($action)) { $this->error(EZMLM_INVALID_SYNTAX,TRUE); } |
189,8 → 179,8 |
print "</body>\n"; |
print "</html>\n"; |
} |
// begin common functions |
// makehash - generates an author hash using the included makehash program |
243,15 → 233,6 |
$outstr = preg_replace("/<.*>/", '', $outstr); |
$outstr = preg_replace("/[\"']/", '', $outstr); |
} |
$at_split = explode('@',$outstr); |
$outstr = $at_split[0]; |
$points_sep = explode('.',$outstr); |
if(count($points_sep) > 2) { |
$outstr = implode('.', array_slice($points_sep,0,count($points_sep) - 2)); |
$outstr = rtrim($outstr, '.').'...'; |
} |
return trim($outstr); |
} |
273,13 → 254,13 |
if ($critical) { die; } |
} |
/** |
* Parse une chaine et supprime les probleme d'encodage de type ISO-4 ... |
* Parse une chaime et supprime les probl�me d'encodage de type ISO-4 ... |
* |
* @return string |
*/ |
function decode_iso ($chaine) { |
if (preg_match ('/windows-[0-9][0-9][0-9][0-9]/i', $chaine, $nombre)) { |
$reg_exp = $nombre[0] ; |
$chaine = str_replace(' ', '', $chaine); |
289,7 → 270,7 |
if (preg_match ('/UTF/i', $chaine)) $reg_exp = 'UTF-8' ; |
preg_match_all ("/=\?$reg_exp\?(Q|B)\?(.*?)\?=/i", $chaine, $match, PREG_PATTERN_ORDER) ; |
for ($i = 0; $i < count ($match[0]); $i++ ) { |
if (strtoupper($match[1][$i]) == 'Q') { |
$decode = quoted_printable_decode ($match[2][$i]) ; |
} elseif ($match[1][$i] == 'B') { |
298,23 → 279,23 |
$decode = preg_replace ("/_/", " ", $decode) ; |
if ($reg_exp == 'UTF-8') { |
$decode = utf8_decode ($decode) ; |
} |
} |
$chaine = str_replace ($match[0][$i], $decode, $chaine) ; |
} |
return $chaine ; |
} |
/** |
* |
* |
* @return |
*/ |
function date_francaise ($date_mail) { |
$date_mail = preg_replace ('/CEST/', '', $date_mail) ; |
$date_mail = preg_replace ('/\(?CEST\)?/', '', $date_mail) ; |
$numero_mois = date('m ', strtotime($date_mail)) - 1 ; |
$date = date ('d ', strtotime($date_mail)).$GLOBALS['mois'][$numero_mois] ; // Le jour et le mois |
$date .= date(' Y ', strtotime($date_mail)) ; // l'annee |
$date .= date(' Y ', strtotime($date_mail)) ; // l'ann�e |
if (date('a', strtotime($date_mail)) == 'pm') { |
$date .= (int) date('g', strtotime($date_mail)) + 12 ; // Les heures |
} else { |
323,8 → 304,8 |
$date .= date(':i', strtotime($date_mail)) ; // Les minutes |
return $date ; |
} |
/** |
/** |
* Cette fonction renvoie le prefixe, cad 0 ou rien |
* d un nom de message, ex : pour 09, on renvoie 0 |
* pour 12 on renvoie rien |
/trunk/classes/ezmlm-php-2.0/services_vpopmail/messages_mois.php |
---|
1,101 → 1,101 |
<?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: messages_mois.php,v 1.4 2008-11-04 17:11:10 aperonnet Exp $ |
/** |
* Application projet |
* |
* Action forums |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2008 |
*@version $Revision: 1.4 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
include_once 'ezmlm-php-2.0/ezmlm.php' ; |
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT); |
date_default_timezone_set("Europe/Paris"); |
// extract($_GET); // PHP-5.4, sans register_globals |
// Parametrage de la liste |
$info = new ezmlm_listinfo(); |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
$info->forcehref = $url; |
$info->listdir = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
$info->listname = $liste; |
$info->listdomain = $domaine ; |
/** Calcul du cache */ |
require_once('Cache/Lite.php'); |
// Set a id for this cache |
$id = 'cachemonth_'.$domaine.'_'.$liste.'_'.$actionargs[0]; |
// Set a few options |
$options = array( |
'cacheDir' => 'tmp/', |
'lifeTime' => 360000 |
); |
// Create a Cache_Lite object |
$Cache_Lite = new Cache_Lite($options); |
if ($xml = $Cache_Lite->get($id)) { |
} else { |
include_once 'XML/Util.php' ; |
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-15', 'no') ; |
$html = $info->show_month($actionargs[0]); |
if (!$html) { |
$xml .= XML_Util::createStartElement ('ezmlm_erreur', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[ \'Les fichiers de la liste ne sont pas visibles sur le serveur\']]>'; |
$xml .= XML_Util::createEndElement('ezmlm_erreur') ; |
} else { |
$xml .= XML_Util::createStartElement ('ezmlm_messages_mois', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[ '.$html.']]>'; |
$xml .= XML_Util::createEndElement('ezmlm_messages_mois') ; |
$Cache_Lite->save($xml); |
} |
} |
header ('Content-type: text/xml'); |
echo $xml ; |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.3 2008-08-25 15:24:09 alexandre_tb |
* ajout de la gestion du cache |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
<?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: messages_mois.php,v 1.4 2008-11-04 17:11:10 aperonnet Exp $ |
/** |
* Application projet |
* |
* Action forums |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2008 |
*@version $Revision: 1.4 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
include_once 'ezmlm-php-2.0/ezmlm.php' ; |
// Parametrage de la liste |
$info = new ezmlm_listinfo(); |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
$info->forcehref = $url; |
$info->listdir = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
$info->listname = $liste; |
$info->listdomain = $domaine ; |
/** Calcul du cache */ |
require_once('Cache/Lite.php'); |
// Set a id for this cache |
$id = 'cachemonth_'.$domaine.'_'.$liste.'_'.$actionargs[0]; |
// Set a few options |
$options = array( |
'cacheDir' => 'tmp/', |
'lifeTime' => 360000 |
); |
// Create a Cache_Lite object |
$Cache_Lite = new Cache_Lite($options); |
if ($xml = $Cache_Lite->get($id)) { |
} else { |
include_once 'XML/Util.php' ; |
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-15', 'no') ; |
$html = $info->show_month($actionargs[0]); |
if (!$html) { |
$xml .= XML_Util::createStartElement ('ezmlm_erreur', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[ \'Les fichiers de la liste ne sont pas visibles sur le serveur\']]>'; |
$xml .= XML_Util::createEndElement('ezmlm_erreur') ; |
} else { |
$xml .= XML_Util::createStartElement ('ezmlm_messages_mois', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[ '.$html.']]>'; |
$xml .= XML_Util::createEndElement('ezmlm_messages_mois') ; |
$Cache_Lite->save($xml); |
} |
} |
header ('Content-type: text/xml'); |
echo $xml ; |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: messages_mois.php,v $ |
* Revision 1.4 2008-11-04 17:11:10 aperonnet |
* correction de bugs dans la liste des derniers messages |
* |
* Revision 1.3 2008-08-25 15:24:09 alexandre_tb |
* ajout de la gestion du cache |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/trunk/classes/ezmlm-php-2.0/services_vpopmail/messages_thread.php |
---|
1,76 → 1,74 |
<?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: messages_thread.php,v 1.5 2008-11-19 09:28:45 aperonnet Exp $ |
/** |
* Application projet |
* |
* Renvoie les messages d un thread |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
*@copyright Tela-Botanica 2000-2008 |
*@version $Revision: 1.5 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
include_once 'ezmlm-php-2.0/ezmlm.php' ; |
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT); |
// extract($_GET); // PHP-5.4, sans register_globals |
// Parametrage de la liste |
$info = new ezmlm_threads(); |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
$info->forcehref = $url; |
$info->listdir = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
$info->listname = $liste; |
$info->listdomain = $domaine ; |
$info->tempdir = '/home/vpopmail/www/tmp' ; |
$html = $info->load($actionargs[0]) ; |
if (!$html) { |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
} |
include_once 'XML/Util.php' ; |
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-15', 'no') ; |
$xml .= XML_Util::createStartElement ('ezmlm_messages_thread', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[ '.$html.']]>'; |
$xml .= XML_Util::createEndElement('ezmlm_messages_thread') ; |
header ('Content-type: text/xml'); |
echo $xml ; |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.4 2008-11-04 17:11:10 aperonnet |
* correction de bugs dans la liste des derniers messages |
* |
* Revision 1.3 2008-08-26 09:26:41 alexandre_tb |
* ajout commentaire |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
<?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: messages_thread.php,v 1.4 2008-11-04 17:11:10 aperonnet Exp $ |
/** |
* Application projet |
* |
* Renvoie les messages d un thread |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
*@copyright Tela-Botanica 2000-2008 |
*@version $Revision: 1.4 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
include_once 'ezmlm-php-2.0/ezmlm.php' ; |
// Parametrage de la liste |
$info = new ezmlm_threads(); |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
$info->forcehref = $url; |
$info->listdir = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
$info->listname = $liste; |
$info->listdomain = $domaine ; |
$info->tempdir = '/home/vpopmail/www/tmp' ; |
$html = $info->load($actionargs[0]) ; |
if (!$html) { |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
} |
include_once 'XML/Util.php' ; |
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-15', 'no') ; |
$xml .= XML_Util::createStartElement ('ezmlm_messages_thread', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[ '.$html.']]>'; |
$xml .= XML_Util::createEndElement('ezmlm_messages_thread') ; |
header ('Content-type: text/xml'); |
echo $xml ; |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: messages_thread.php,v $ |
* Revision 1.4 2008-11-04 17:11:10 aperonnet |
* correction de bugs dans la liste des derniers messages |
* |
* Revision 1.3 2008-08-26 09:26:41 alexandre_tb |
* ajout commentaire |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/trunk/classes/ezmlm-php-2.0/services_vpopmail/calendrier_messages.php |
---|
1,44 → 1,7 |
<?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: calendrier_messages.php,v 1.4 2008-08-25 15:25:47 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* Action forums |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2008 |
*@version $Revision: 1.4 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
include_once 'ezmlm-php-2.0/ezmlm.php' ; |
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT); |
date_default_timezone_set("Europe/Paris"); |
// extract($_GET); // PHP-5.4, sans register_globals |
// Parametrage de la liste |
$info = new ezmlm_threads(); |
48,85 → 11,22 |
$info->listname = $liste; |
$info->listdomain = $domaine ; |
/** Calcul du cache */ |
/* |
require_once('Cache/Lite.php'); |
ob_start() ; |
if (!$info->listmessages()) { |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
} |
$html = ob_get_contents() ; |
ob_end_clean() ; |
// Set a id for this cache |
$id = 'cache_'.$domaine.'_'.$liste; |
include_once 'XML/Util.php' ; |
// Set a few options |
$options = array( |
'cacheDir' => 'tmp/', |
'lifeTime' => null |
); |
*/ |
include_once 'XML/Util.php' ; |
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-15', 'no') ; |
if (!file_exists($info->listdir.'/num')) { |
$xml .= XML_Util::createStartElement ('ezmlm_calendrier_messages', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[il n\'y a pas de messages dans cette liste pour le moment.]]>'; |
$xml .= XML_Util::createEndElement('ezmlm_calendrier_messages') ; |
header ('Content-type: text/xml'); |
echo $xml; |
exit(); |
} |
/* |
// Create a Cache_Lite object |
$Cache_Lite = new Cache_Lite($options); |
$recalcule = false ; |
$Cache_Lite->get($id); |
$xml .= XML_Util::createStartElement ('ezmlm_calendrier_messages', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[ '.$html.']]>'; |
if (@fileatime($info->listdir.'/num') > (int)$Cache_Lite->lastModified()) { |
$recalcule = true; |
} |
// Test if thereis a valide cache for this id |
if (!$recalcule) { |
$xml = $Cache_Lite->get($id); |
} else { // pas de cache, on construit le calendrier |
*/ |
$html = $info->listmessages(); |
if (!$html) { |
$xml .= XML_Util::createStartElement ('ezmlm_erreur', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[Les fichiers de la liste ne sont pas visibles sur le serveur]]>'; |
$xml .= XML_Util::createEndElement('ezmlm_erreur') ; |
} else { |
$xml .= XML_Util::createStartElement ('ezmlm_calendrier_messages', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[ '.$html.']]>'; |
$xml .= XML_Util::createEndElement('ezmlm_calendrier_messages') ; |
/* |
$xml .= XML_Util::createStartElement('cache_time') ; |
$xml .= (int)$Cache_Lite->lastmodified().'#'.fileatime($info->listdir.'/num'); |
$xml .= XML_Util::createEndElement('cache_time') ;*/ |
//$Cache_Lite->save($xml, $id); |
} |
//} |
$xml .= XML_Util::createEndElement('ezmlm_calendrier_messages') ; |
header ('Content-type: text/xml'); |
echo $xml ; |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: calendrier_messages.php,v $ |
* Revision 1.4 2008-08-25 15:25:47 alexandre_tb |
* optimisation et gestion du cache |
* |
* Revision 1.3 2008-06-09 10:05:28 alexandre_tb |
* Ajout de la gestion du cache |
* dependance avec Cache_Lite |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
?> |
/trunk/classes/ezmlm-php-2.0/services_vpopmail/derniers_messages.php |
---|
1,93 → 1,90 |
<?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 $ |
/** |
* Application projet |
* |
* Action forums |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2008 |
*@version $Revision: 1.6 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
include_once 'ezmlm-php-2.0/ezmlm.php' ; |
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT); |
date_default_timezone_set("Europe/Paris"); |
// extract($_GET); // PHP-5.4, sans register_globals |
// Parametrage de la liste |
$info = new ezmlm_listinfo(); |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
$info->forcehref = $url; |
$info->listdir = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
$info->listname = $liste; |
$info->listdomain = $domaine ; |
include_once 'XML/Util.php' ; |
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-15', 'no') ; |
if (!file_exists($info->listdir.'/num')) { |
$xml .= XML_Util::createStartElement ('ezmlm_derniers_messages', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[il n\'y a pas de messages dans cette liste pour le moment.]]>'; |
$xml .= XML_Util::createEndElement('ezmlm_derniers_messages') ; |
header ('Content-type: text/xml'); |
echo $xml; |
exit(); |
} |
$html = $info->show_recentmsgs() ; |
if (!$html) { |
if (!$info) { |
echo 'Les fichiers de la liste ne sont pas visibles sur le serveur' ; |
exit(); |
} |
} |
$xml .= XML_Util::createStartElement ('ezmlm_derniers_messages', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[ '.$html.']]>'; |
$xml .= XML_Util::createEndElement('ezmlm_derniers_messages') ; |
header ('Content-type: text/xml'); |
echo $xml ; |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.5 2008-11-04 17:11:10 aperonnet |
* correction de bugs dans la liste des derniers messages |
* |
* Revision 1.4 2008-08-25 15:25:09 alexandre_tb |
* optimisation et gestion des erreurs |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
<?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 $ |
/** |
* Application projet |
* |
* Action forums |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2008 |
*@version $Revision: 1.5 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
include_once 'ezmlm-php-2.0/ezmlm.php' ; |
// Parametrage de la liste |
$info = new ezmlm_listinfo(); |
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ; |
$info->forcehref = $url; |
$info->listdir = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
$info->listname = $liste; |
$info->listdomain = $domaine ; |
include_once 'XML/Util.php' ; |
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-15', 'no') ; |
if (!file_exists($info->listdir.'/num')) { |
$xml .= XML_Util::createStartElement ('ezmlm_derniers_messages', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[il n\'y a pas de messages dans cette liste pour le moment.]]>'; |
$xml .= XML_Util::createEndElement('ezmlm_derniers_messages') ; |
header ('Content-type: text/xml'); |
echo $xml; |
exit(); |
} |
$html = $info->show_recentmsgs() ; |
if (!$html) { |
if (!$info) { |
echo 'Les fichiers de la liste ne sont pas visibles sur le serveur' ; |
exit(); |
} |
} |
$xml .= XML_Util::createStartElement ('ezmlm_derniers_messages', array('domaine' => $domaine, 'liste' => $liste, 'langue' => $langue)) ; |
$xml .= '<![CDATA[ '.$html.']]>'; |
$xml .= XML_Util::createEndElement('ezmlm_derniers_messages') ; |
header ('Content-type: text/xml'); |
echo $xml ; |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: derniers_messages.php,v $ |
* Revision 1.5 2008-11-04 17:11:10 aperonnet |
* correction de bugs dans la liste des derniers messages |
* |
* Revision 1.4 2008-08-25 15:25:09 alexandre_tb |
* optimisation et gestion des erreurs |
* |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/trunk/classes/ezmlm-php-2.0/services_vpopmail/ajout_abonne.php |
---|
2,5 → 2,5 |
$repertoire = '/home/vpopmail/domains/'.$domaine.'/'.$liste ; |
echo exec ('/usr/local/bin/ezmlm-sub '.$repertoire.' '.$mail, $output, $ret) ; |
echo exec ('ezmlm-sub '.$repertoire.' '.$mail, $output, $ret) ; |
?> |
/trunk/classes/ezmlm-php-2.0/ezmlm-listinfo.php |
---|
1,235 → 1,197 |
<?php |
// $Id: ezmlm-listinfo.php,v 1.3 2007/04/19 15:34:35 neiluj Exp $ |
// |
// ezmlm-listinfo.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
// Displays general list info in the format of a welcome page. |
// -------------------------------------------------------------- |
require_once("ezmlm.php"); |
class ezmlm_listinfo extends ezmlm_php { |
function ezmlm_listinfo () { |
//return is_dir($this->listdir.'/archive/0') ; |
} |
function display() { |
if (!is_dir($this->listdir.'/archive/0')) { // On teste si il y a au moins un message, cad le répertoire 0 |
echo $this->listdir.'/archive/0' ; |
return false ; |
} |
$parser = new ezmlm_parser(); |
$parser->listdir = $this->listdir ; |
//$this->show_info_file(); |
$threads = new ezmlm_threads(); |
$threads->listdir = $this->listdir ; |
$threads->listname = $this->listname ; |
$threads->forcehref = $this->forcehref ; /// ajout alex |
$threads->listmessages() ; |
$this->show_recentmsgs(); |
return true ; |
} |
function show_info_file() { |
if (@is_file($this->listdir . "/text/info")) { |
$infofile = @file($this->listdir . "/text/info"); |
while (list($line_num, $line) = each($infofile)) { |
print nl2br($line); |
} |
} |
} |
function show_recentmsgs($title = "Messages récents") { |
if (!is_dir($this->listdir.'/archive/0')) return false; |
$html = '' ; |
$parser = new ezmlm_parser(); |
$parser->listdir = $this->listdir ; |
$html .= '<table class="table_cadre">'."\n"; |
$html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n"; |
$ctc = 0; |
$recent = $parser->recent_msgs(); |
// le tableau recent est de la forme |
// $recent[numero_message][1] sujet |
// $recent[numero_message][2] date en anglais => (22 May 2006) |
// $recent[numero_message][3] le hash de l auteur |
// $recent[numero_message][4] auteur |
$class = array ('ligne_paire', 'ligne_impaire') ; |
while (list($key,$val) = each($recent)) { |
$html .= '<tr class="'.$class[$ctc].'">'."\n"; |
//print '<td>'.$val->nummessage.'</td>' ; |
// $key contient le numero du message tel que dans les fichiers d index par ex 216 |
// on retrouve le nom du repertoire et le nom du fichier |
$decimal = (string) $key; |
if ($key >= 100) { |
$fichier_message = substr($decimal, -2) ; |
$repertoire_message = substr ($decimal, 0, -2) ; |
} else { |
if ($key < 10) { |
$fichier_message = '0'.$key; |
} else { |
$fichier_message = $decimal; |
} |
$repertoire_message = '0'; |
} |
$html .= '<td>'.$key.'</td>' ; |
$html .= '<td>'; |
$from = $val[4]; |
$html .= $this->makelink("action=show_author_msgs&actionargs[]=".$val[3],$this->decode_iso($this->protect_email($from,false))); |
$html .= "</td>\n"; |
$html .= '<td><b>'; |
$actionargs = preg_split("/\//", $val->msgfile); |
$html .= $this->makelink("action=show_msg&actionargs[]=".$repertoire_message. |
"&actionargs[]=".$fichier_message ,$this->decode_iso($val[1])); |
$html .= "</b></td>\n"; |
//print '<td>'.$this->date_francaise($val[2]).'</td>'."\n"; |
$html .= '<td>'.$val[2].'</td>'."\n"; |
$html .= "</tr>\n"; |
$ctc++; |
if ($ctc == 2) { $ctc = 0; } |
} |
$html .= '</table>'."\n"; |
return $html; |
} |
// month = yyyymm |
function show_month ($month) { |
$html = '' ; |
// on ouvre chaque fichier en lecture |
if(!file_exists($this->listdir . '/archive/threads/' . $month)) { |
return false ; |
} |
$numeros_mails_mois = $this->calculerNumMessagesDansMois($month); |
$html .= '<table class="table_cadre">'."\n"; |
$html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n"; |
$ctc = 0; |
$class = array ('ligne_paire', 'ligne_impaire') ; |
if(count($numeros_mails_mois) > 0) { |
$repertoire_premier_mail = (int) (reset($numeros_mails_mois) / 100) ; |
} |
foreach ($numeros_mails_mois as $num_message) { |
$i = $num_message; |
if ($i > 99) { |
$multiplicateur = (int) ($i / 100) ; |
// pour les mails > 99, on retranche n fois 100, ex 256 => 56 cad 256 - 2 * 100 |
$i = $i - $multiplicateur * 100 ; |
} |
if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ; |
if (file_exists($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) { |
$mimeDecode = new Mail_mimeDecode(file_get_contents ($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) ; |
$mailDecode = $mimeDecode->decode() ; |
if ($i == 99) { |
$repertoire_premier_mail++; |
$i = -1; |
} |
$html .= '<tr class="'.$class[$ctc].'">'."\n"; |
$html .= '<td>'.($repertoire_premier_mail != 0 ? $repertoire_premier_mail : '').$num_message.'</td><td>'; |
$hash = $this->makehash($mailDecode->headers['from']); |
$html .= $this->makelink("action=show_author_msgs&actionargs[]=". |
$hash,$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE))); |
$html .= "</td>\n"; |
$html .= '<td><b>'; |
$actionargs[0] = $repertoire_premier_mail ; |
$actionargs[1] = $num_message ; |
if (count ($actionargs) > 1) { |
$html .= $this->makelink("action=show_msg&actionargs[]=". |
$actionargs[(count($actionargs) - 2)] . |
"&actionargs[]=". |
$actionargs[(count($actionargs) - 1)] ,$this->decode_iso($mailDecode->headers['subject'])); |
} |
$html .= "</b></td>\n"; |
$html .= '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n"; |
$html .= "</tr>\n"; |
$ctc++; |
if ($ctc == 2) { $ctc = 0; } |
} |
} |
$html .= '</table>'."\n"; |
return $html; |
} |
private function calculerNumMessagesDansMois($mois) { |
$fd = file_get_contents($this->listdir . '/archive/threads/'.$mois, 'r'); |
$fichier = explode ("\n", $fd) ; |
$premiere_ligne = $fichier[0] ; |
$nb_lignes_fichier = count($fichier); |
$lignes_messages = array(); |
preg_match ('/[0-9]+/', $premiere_ligne, $match) ; |
$numero_premier_mail = $match[0] ; |
$lignes_messages[$numero_premier_mail] = $numero_premier_mail; |
foreach($fichier as $ligne) { |
if(trim($ligne == '')) { continue ;} |
$ligne_tableau = explode(' ', $ligne); |
$num_mail_sujet = explode(':',$ligne_tableau[0]); |
$num_sujet = $num_mail_sujet[1]; |
$fd_sujet = file_get_contents($this->listdir.'/archive/subjects/'.substr($num_sujet,0,2).'/'.substr($num_sujet,2,strlen($num_sujet) - 1), 'r'); |
$premiere_ligne = true; |
$fichier_sujet = explode ("\n", $fd_sujet) ; |
foreach($fichier_sujet as $ligne_sujet) { |
if($premiere_ligne || trim($ligne_sujet) == '') {$premiere_ligne = false; continue; } |
$ligne_tableau_sujet = explode(':', $ligne_sujet); |
$num_mail = $ligne_tableau_sujet[0]; |
$mois_ligne = $ligne_tableau_sujet[1]; |
if($mois_ligne == $mois) { |
if(is_numeric($num_mail)) { |
$lignes_messages[$num_mail] = $num_mail; |
} else { |
$num_mail = preg_replace('/[^0-9]+/','', $num_mail) ; |
$lignes_messages[$num_mail] = $num_mail; |
} |
} |
} |
} |
asort($lignes_messages); |
return $lignes_messages; |
} |
} |
<?php |
// $Id: ezmlm-listinfo.php,v 1.5 2008-11-04 17:11:10 aperonnet Exp $ |
// |
// ezmlm-listinfo.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
// Displays general list info in the format of a welcome page. |
// -------------------------------------------------------------- |
require_once("ezmlm.php"); |
class ezmlm_listinfo extends ezmlm_php { |
function ezmlm_listinfo () { |
return is_dir($this->listdir.'/archive/0') ; |
} |
function display() { |
if (!is_dir($this->listdir.'/archive/0')) { // On teste si il y a au moins un message, cad le r�pertoire 0 |
echo $this->listdir.'/archive/0' ; |
return false ; |
} |
$parser = new ezmlm_parser(); |
$parser->listdir = $this->listdir ; |
//$this->show_info_file(); |
$threads = new ezmlm_threads(); |
$threads->listdir = $this->listdir ; |
$threads->listname = $this->listname ; |
$threads->forcehref = $this->forcehref ; /// ajout alex |
$threads->listmessages() ; |
$this->show_recentmsgs(); |
return true ; |
} |
function show_info_file() { |
if (@is_file($this->listdir . "/text/info")) { |
$infofile = @file($this->listdir . "/text/info"); |
while (list($line_num, $line) = each($infofile)) { |
print nl2br($line); |
} |
} |
} |
function show_recentmsgs($title = "Messages r�cents") { |
if (!is_dir($this->listdir.'/archive/0')) return false; |
$html = '' ; |
$parser = new ezmlm_parser(); |
$parser->listdir = $this->listdir ; |
$html .= '<table class="table_cadre">'."\n"; |
$html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n"; |
$ctc = 0; |
$recent = $parser->recent_msgs(); |
// le tableau recent est de la forme |
// $recent[numero_message][1] sujet |
// $recent[numero_message][2] date en anglais => (22 May 2006) |
// $recent[numero_message][3] le hash de l auteur |
// $recent[numero_message][4] auteur |
$class = array ('ligne_paire', 'ligne_impaire') ; |
while (list($key,$val) = each($recent)) { |
$html .= '<tr class="'.$class[$ctc].'">'."\n"; |
//print '<td>'.$val->nummessage.'</td>' ; |
// $key contient le numero du message tel que dans les fichiers d index par ex 216 |
// on retrouve le nom du repertoire et le nom du fichier |
$decimal = (string) $key; |
if ($key >= 100) { |
$fichier_message = substr($decimal, -2) ; |
$repertoire_message = substr ($decimal, 0, -2) ; |
} else { |
if ($key < 10) { |
$fichier_message = '0'.$key; |
} else { |
$fichier_message = $decimal; |
} |
$repertoire_message = '0'; |
} |
$html .= '<td>'.$key.'</td>' ; |
$html .= '<td>'; |
$from = $val[4]; |
$html .= $this->makelink("action=show_author_msgs&actionargs[]=".$val[3],$this->decode_iso($this->protect_email($from,false))); |
$html .= "</td>\n"; |
$html .= '<td><b>'; |
$actionargs = preg_split("/\//", $val->msgfile); |
$html .= $this->makelink("action=show_msg&actionargs[]=".$repertoire_message. |
"&actionargs[]=".$fichier_message ,$this->decode_iso($val[1])); |
$html .= "</b></td>\n"; |
//print '<td>'.$this->date_francaise($val[2]).'</td>'."\n"; |
$html .= '<td>'.$val[2].'</td>'."\n"; |
$html .= "</tr>\n"; |
$ctc++; |
if ($ctc == 2) { $ctc = 0; } |
} |
$html .= '</table>'."\n"; |
return $html; |
} |
function show_month ($month) { |
// Le nom du fichier est ann�emoi ex 200501 pour janvier 2005 |
// le html est vide au début |
$html = '' ; |
// on ouvre chaque fichier en lecture |
if(!file_exists($this->listdir . '/archive/threads/' . $month)) { |
return false ; |
} |
$fd = file_get_contents($this->listdir . '/archive/threads/' . $month, 'r'); |
$fichier = explode ("\n", $fd) ; |
// on r�cup�re la premi�re ligne |
$premiere_ligne = $fichier[0] ; |
$derniere_ligne = $fichier[count($fichier)-2]; |
preg_match ('/[0-9]+/', $premiere_ligne, $match) ; |
$numero_premier_mail = $match[0] ; |
preg_match ('/[0-9]+/', $derniere_ligne, $match1) ; |
$numero_dernier_mail = $match1[0] ; |
// On cherche le r�pertoire du premier mail |
$repertoire_premier_mail = (int) ($numero_premier_mail / 100) ; |
// petite verification de coherence |
if ($numero_premier_mail > $numero_dernier_mail) { |
$temp = $numero_premier_mail; |
$numero_premier_mail = $numero_dernier_mail ; |
$numero_dernier_mail = $temp; |
} |
$html .= '<table class="table_cadre">'."\n"; |
$html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n"; |
$ctc = 0; |
$class = array ('ligne_paire', 'ligne_impaire') ; |
for ($i = $numero_premier_mail, $compteur = $numero_premier_mail ; $compteur <= $numero_dernier_mail; $i++, $compteur++) { |
if ($i > 99) { |
$multiplicateur = (int) ($i / 100) ; |
// pour les nails > 99, on retranche n fois 100, ex 256 => 56 cad 256 - 2 * 100 |
$i = $i - $multiplicateur * 100 ; |
} |
if ($i < 10) $num_message = '0'.$i ; else $num_message = $i ; |
if (file_exists($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) { |
$mimeDecode = new Mail_mimeDecode(file_get_contents ($this->listdir.'/archive/'.$repertoire_premier_mail.'/'.$num_message)) ; |
$mailDecode = $mimeDecode->decode() ; |
if ($i == 99) { |
$repertoire_premier_mail++; |
$i = -1; |
} |
$html .= '<tr class="'.$class[$ctc].'">'."\n"; |
$html .= '<td>'.($repertoire_premier_mail != 0 ? $repertoire_premier_mail : '').$num_message.'</td><td>'; |
$hash = $this->makehash($mailDecode->headers['from']); |
$html .= $this->makelink("action=show_author_msgs&actionargs[]=". |
$hash,$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE))); |
$html .= "</td>\n"; |
$html .= '<td><b>'; |
$actionargs[0] = $repertoire_premier_mail ; |
$actionargs[1] = $num_message ; |
if (count ($actionargs) > 1) { |
$html .= $this->makelink("action=show_msg&actionargs[]=". |
$actionargs[(count($actionargs) - 2)] . |
"&actionargs[]=". |
$actionargs[(count($actionargs) - 1)] ,$this->decode_iso($mailDecode->headers['subject'])); |
} |
$html .= "</b></td>\n"; |
$html .= '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n"; |
$html .= "</tr>\n"; |
$ctc++; |
if ($ctc == 2) { $ctc = 0; } |
} |
} |
$html .= '</table>'."\n"; |
return $html; |
} |
} |
?> |
/trunk/classes/ezmlm-php-2.0/makehash |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/classes/ezmlm-php-2.0/ezmlm-threads.php |
---|
1,492 → 1,464 |
<?php |
// $Id: ezmlm-threads.php,v 1.7 2008-11-19 09:28:46 aperonnet Exp $ |
// |
// ezmlm-threads.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
// Builds, maintains & displays thread caches |
// These cache files live in $ezmlm->tmpdir and are serialized |
// php objects that can be unserialized and displayed easily |
// -------------------------------------------------------------- |
require_once("ezmlm.php"); |
require_once("ezmlm-parser.php"); |
require_once ('ezmlm-langue-fr.php'); |
// CLASS: ezmlm_threads will build, maintain & display thread files (even if a thread is only 1 msg) |
class ezmlm_threads extends ezmlm_php { |
// load: this is the main function that should be called. |
// it first checks to see if the cache files are stale, if they are it calls build |
// other wise it loads them and calls display |
function load($month) { |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
$checksum = $this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month . "-" . "checksum"; |
} else { |
$checksum = $this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month . "-" . "checksum"; |
} |
$md5 = '' ; |
if (!is_file($checksum)) { |
$this->build($month); |
} else { |
$fd = fopen($checksum,"r"); |
while (!preg_match('/^md5:/', $md5)) { $md5 = fgets($fd,4096); } |
fclose($fd); |
$md5 = rtrim(preg_replace('/^md5:/', '', $md5), "\n"); |
if ($md5 != $this->md5_of_file($this->listdir . "/archive/threads/" . $month)) { |
print "<!-- $md5 ne " . $this->md5_of_file($this->listdir . "/archive/threads/" . $month) . " -->\n"; |
$this->build($month); |
} |
} |
$html = $this->display($month); |
return $html ; |
} |
// display: this loads each cache file sequentially and displays the messages in them |
// there is no checking of checksum's done here so load() is the preferred method to |
// view the threads |
function display($month) { |
$html = '' ; |
$seq = 0; |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
$cache = $this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month; |
} else { |
$cache = $this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month; |
} |
// Le lien par date et par thread |
$html .= '[ '.$this->makelink('action=show_month&actionargs[]='.$month, 'par date').' ]' ; |
$months = array(1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', |
9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December'); |
// remplacé par le tableau globals $mois dans ezmlm.php |
$html .= '<h2>'.FIL_DE_DISCUSSION.' pour '.$GLOBALS['mois'][((int)substr($month,4,2) / 1) -1] .', ' . substr($month,0,4) . '</h2>'."\n"; |
$html .= '<table class="table_cadre">'."\n"; |
$html .= '<tr><th>Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n"; |
$html .= '<tr><td colspan="3"><hr /></td></tr>'."\n"; |
$ctc .= 0; |
if (is_file($cache)) { |
$html .= file_get_contents($cache); |
} |
$html .= '<tr><td colspan="3"></td></tr>'."\n"; |
$html .= '</table>'."\n"; |
return $html ; |
} |
function thread_to_html($thread) { |
$html = ''; |
$lastdepth = -1; |
$ctc = 0 ; |
$thread_curr = $thread; |
$class = array ('ligne_paire', 'ligne_impaire') ; |
while ($thread_curr != NULL) { |
preg_match ('!/archive/([0-9]*)/([0-9]*)!', $thread_curr->file, $match) ; |
if (!isset($GLOBALS['fichiers_analyses'][$match[1]][$match[2]])) { |
$message = file_get_contents($this->listdir . "/archive/" . $msgdir . "/" . $msgfile) ; |
$mimeDecode = new Mail_mimeDecode($message) ; |
$mailDecode = $mimeDecode->decode() ; |
//$msg = new ezmlm_parser(); |
//$msg->parse_file($this->listdir . $thread_curr->file, TRUE); |
} else { |
$mailDecode = $GLOBALS['fichiers_analyses'][$match[1]][$match[2]] ; |
} |
$actionargs = preg_split("/\//", $thread_curr->file); |
$html .= '<tr class="'.$class[$ctc].'">'."\n"; |
$html .= '<td>'.$actionargs[2].$actionargs[3].'</td><td>'; |
$html .= $this->makelink('action=show_author_msgs&actionargs[]='. |
$this->makehash($this->decode_iso($mailDecode->headers['from'])),$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE))); |
$html .= '</td>'."\n"; |
$html .= '<td><b>'; |
//$html .= " <a name=\"" . urlencode($thread_curr->file) . "\">"; A quoi ça sert ? |
for ($i = 0; $i < $thread_curr->depth; $i++) { |
$html .= " "; |
} |
if (($this->thread_subjlen > 0) and (strlen($this->decode_iso($mailDecode->headers['subject'])) > $this->thread_subjlen)) { |
$subject = substr($this->decode_iso($mailDecode->headers['subject']), 0, ($this->thread_subjlen - 3 - ($thread_curr->depth * 2))); |
$subject = $subject . "..."; |
} else { |
$subject = $this->decode_iso($mailDecode->headers['subject']); |
} |
$subject = preg_replace("/\[" . $this->listname . "\]/", "", $subject); |
$html .= $this->makelink("action=show_msg&actionargs[]=" . $actionargs[2] . "&actionargs[]=" . $actionargs[3], $subject); |
$html .= "</b></td>\n"; |
$html .= '<td>' .$this->date_francaise($mailDecode->headers['date']).'</td>'."\n"; |
$html .= "</tr>\n"; |
$ctc++; |
if ($ctc == count($this->tablecolours)) { $ctc = 0; } |
$lastdepth = $thread_curr->depth; |
$thread_curr = $thread_curr->next; |
} |
$html .= '<tr><td colspan="3"><hr noshade size="1" /></td></tr>'."\n"; |
return $html; |
} |
// TODO: Fonction à tester et compléter |
// Construit un index de tous les messages envoyés dans une liste donnée pour un mois |
// au format YYYYMM |
/* // commenté sur le serveur |
function build_month_list($date) |
{ |
$months = array(1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 5 => 'May', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug', |
9 => 'Sep', 10 => 'Oct', 11 => 'Nov', 12 => 'Dec'); |
$month = $months[((int)substr($month,4,2) / 1) -1] ; |
$year = substr($month,0,4) ; |
$numArchive = $this->getNumArchive(); |
$dernierRepertoire = floor($numArchive / 100); |
$threads = array(); |
for ($rep_courant = $dernierRepertoire; $rep_courant >= 0; $rep_courant--) { |
$fichier_index = file ($this->listdir.'/archive/'.$rep_courant.'/index', FILE_IGNORE_NEW_LINES); |
// On parcourt le fichier a l envers |
for ($j = count($fichier_index)-1; $j >= 0; $j-=2) { |
$match = strpos($fichier_index[$j],$month.' '.$year) ; |
if ($match) { |
$threads[] = $fichier_index[$j-1] ; |
} |
} |
} |
} |
*/ |
// build: takes one argument in the format YYYYMM and builds the thread cache file |
// for that month if the ezmlm thread file exists. The resulting cache file is then |
// stored in $this->tmpdir; |
function build($month) { |
if (!is_file($this->listdir . "/archive/threads/" . $month)) { return FALSE; } |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month,"w+"); |
} else { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month,"w+"); |
} |
fclose($fd2); |
$i=0; |
// ouverture du fichier thread de ezmlm |
// Ils sont classés mois par mois |
$fd1 = fopen($this->listdir . "/archive/threads/" . $month, "r"); |
while (!feof($fd1)) { |
$line = fgets($fd1,4096); |
if (preg_match('/^[0-9]*\:[a-z]* \[.*/', $line)) { |
// valid ezmlm thread file entry |
// On place dans $subjectfile le chemin vers le fichier sujet |
$subjectfile = preg_replace("/^[0-9]*\:([a-z]*) \[.*/", "\\1", $line); |
$subjectfile = substr($subjectfile,0,2) . '/' . substr($subjectfile,2,18); |
$thread_head = NULL; |
$thread_curr = NULL; |
$thread_temp = NULL; |
$thread_depth = 1; |
if (!is_file($this->listdir . "/archive/subjects/" . $subjectfile)) { continue; } |
// on ouvre le fichier sujet |
// Celui-ci contient sur la première ligne le hash du sujet puis le sujet |
// sur les autres lignes : |
// num_message:annéemois:hash_auteur nom_auteur |
$fd2 = fopen($this->listdir . "/archive/subjects/" . $subjectfile, "r"); |
while (!feof($fd2)) { |
$line2 = fgets($fd2,4096); |
if (preg_match('/^[0-9]/',$line2)) { |
$msgnum = preg_replace('/^([0-9]*):.*/', '\\1', $line2); |
$msgfile = $msgnum % 100; |
$msgdir = (int)($msgnum / 100); |
if ($msgfile < 10) { $msgfile = "0" . $msgfile; } |
//$msg = new ezmlm_parser(); |
//$msg->parse_file_headers($this->listdir . "/archive/" . $msgdir . "/" . $msgfile, TRUE); |
$message = file_get_contents($this->listdir . "/archive/" . $msgdir . "/" . $msgfile) ; |
$mimeDecode = new Mail_mimeDecode($message) ; |
$mailDecode = $mimeDecode->decode() ; |
// On stocke le fichier analysée pour réutilisation ultàrieure |
$GLOBALS['fichiers_analyses'][$msgdir][$msgfile] = $mailDecode ; |
$msgid = (isset ($mailDecode->headers['message-id']) ? $mailDecode->headers['message-id'] : ''); |
$inreply = (isset($mailDecode->headers['in-reply-to']) ? $mailDecode->headers['in-reply-to'] : ''); |
$references = (isset ($mailDecode->headers['references']) ? $mailDecode->headers['references'] : '') ; |
$thread_depth = 1; |
if ($thread_head == NULL) { |
$thread_head = new ezmlm_thread(0,'/archive/' . $msgdir . '/' . $msgfile,$msgid); |
} else { |
$thread_curr = new ezmlm_thread($depth,'/archive/' . $msgdir . '/' . $msgfile,$msgid); |
if ($inreply != '') { $thread_curr->inreply = $inreply; } |
if ($references != '') { $thread_curr->references = $references; } |
$thread_head->append($thread_curr); |
} |
} |
} |
fclose($fd2); |
// so now after all that mess $thread_head contains a full thread tree |
// first build the depth of each message based on 'in-reply-to' and 'references' |
unset($thread_temp); |
$thread_temp = NULL; |
$thread_curr =& $thread_head->next; |
while (get_class($thread_curr) == 'ezmlm_thread') { |
unset($thread_temp); |
$thread_temp = NULL; |
if ($thread_curr->inreply != '') { $thread_temp =& $thread_head->find_msgid($thread_curr->inreply); } |
if ($thread_temp == NULL) { |
if ($thread_curr->references != '') { |
$refs = preg_split('/ /', $thread_curr->references); |
$refs = array_pop($refs); |
$thread_temp =& $thread_head->find_msgid($refs); |
} |
} |
if ($thread_temp == NULL) { |
// we couldn't find anything... set depth to 1, the default |
$thread_curr->depth = 1; |
} else { |
// we found a reference, set it to it's depth + 1 |
$thread_curr->depth = $thread_temp->depth + 1; |
} |
$thread_curr =& $thread_curr->next; |
} |
// now write it to a temp file named MONTH-SEQ where seq is cronologic sequence order of the thread. |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
@mkdir($this->tempdir . "/ezmlm-php-" . $this->listname, 0755); |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month, "a"); |
} else { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month, "a"); |
} |
} else { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month, "a"); |
} |
fputs($fd2,$this->thread_to_html($thread_head)); |
fclose($fd2); |
} |
} |
// finally store our checksum |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month . "-" . "checksum","w+"); |
} else { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month . "-" . "checksum","w+"); |
} |
fputs($fd2,"md5:" . $this->md5_of_file($this->listdir . "/archive/threads/" . $month) . "\n"); |
fclose($fd2); |
fclose($fd1); |
return TRUE; |
} |
// listmessages: prints out a nice little calendar and displays the message |
// totals for each month. The link jumps to the thread listing. |
// On lit le repertoire archive/threads/ qui contient un fichier par mois avec tous les thread, par sujet |
// Presentes comme suit |
// num_thread:hash [taille_du_thread] Sujet du thread (le dernier) |
// les messages sont ranges par leur numero |
function listmessages() { |
if (!is_dir($this->listdir . "/archive/threads/")) { |
return false ; |
} |
$res = '<table id="petit_calendrier">'."\n"; |
$res .= " <tr>\n"; |
$res .= " <td></td>" ; |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<th>'.$valeur.'</th>' ; |
$res .=" </tr>\n"; |
$res .= $this->calendrierMessage(); |
$res .= "</table>\n"; |
return $res; |
/* |
$threadcount = array(); |
$repertoire_archive = opendir($this->listdir . "/archive/"); |
$tableau_annee = array(); |
while (false !== ($item = readdir($repertoire_archive))) { |
// $item contient les noms des repertoires |
// on ne garde que ceux qui sont des chiffres |
if (preg_match('/[0-9]+/', $item)) { |
// on ouvre le fichier d index de chaque repertoire |
$fichier_index = fopen($this->listdir.'/archive/'.$item.'/index', 'r'); |
$compteur = 0 ; |
while (!feof($fichier_index)) { |
// On ignore la premiere ligne |
$temp = fgets($fichier_index, 4096); |
// dans la seconde on recupere la date |
$temp = fgets($fichier_index, 4096); |
preg_match('/\t([0-9]+) ([a-zA-Z][a-zA-Z][a-zA-Z]) ([0-9][0-9][0-9][0-9])/', $temp, $match) ; |
if ($match[0] != '') { |
$threadmonth = date('n', strtotime($match[0])) ; |
$threadyear = date('Y', strtotime($match[0])) ; |
$threadcount[$threadyear][$threadmonth]++; |
if (!in_array($threadyear, $tableau_annee)) array_push ($tableau_annee, $threadyear); |
} |
} |
fclose ($fichier_index); |
} |
} |
if (count($threadcount) == 0) return 'Il n\y a pas de messages dans les archives'; |
// La partie qui suit, simple, cree la table avec le nombre de message echange chaque mois |
$res = '<table id="petit_calendrier">'."\n"; |
$res .= " <tr>\n"; |
$res .= " <td></td>" ; |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<th>'.$valeur.'</th>' ; |
$res .=" </tr>\n"; |
arsort($tableau_annee); |
foreach ($tableau_annee as $annee) { |
$res .= " <tr>\n"; |
$res .= ' <td class="col_annee">'.$annee.'</td>'; |
for ($i = 1; $i <= 12; $i++) { |
$res .= '<td class="mois">'; |
if (isset($threadcount[$annee][$i]) && $threadcount[$annee][$i] > 0) { |
$res .= $this->makelink('action=show_month&actionargs[]='.$annee.($i < 10 ? '0'.$i:$i),$threadcount[$annee][$i]); |
} |
$res .= '</td>'; |
} |
$res .= '</tr>'."\n"; |
} |
$res .= "</table>\n"; |
return $res ; |
*/ |
} |
/* |
* Cree un fichier liste.calendrierPermanent qui contient |
* le nombre de message par mois pour toutes les annees |
* depuis le debut de la liste sauf la derniere |
* |
*/ |
function calculeCalendrierPermanent($Annnee = '') { |
$numArchive = $this->getNumArchive(); |
$dernierRepertoire = floor($numArchive / 100); |
$threadcount = array(); |
$tableau_annee = array(); |
for ($rep_courant = $dernierRepertoire; $rep_courant >= 0; $rep_courant--) { |
$fichier_index = file ($this->listdir.'/archive/'.$rep_courant.'/index', FILE_IGNORE_NEW_LINES); |
// On parcours le fichier a l envers |
for ($j = count($fichier_index)-1; $j >= 0; $j-=2) { |
preg_match('/\t([0-9]+) ([a-zA-Z]{3}) ([0-9]{4})/', $fichier_index[$j], $match) ; |
if ($match[0] != '') { |
$threadmonth = date('n', strtotime($match[0])); |
$threadyear = date('Y', strtotime($match[0])); |
if ($Annnee != '') { |
if ($threadyear < date('Y')) { |
$sortir = true; |
break; |
} |
} else { |
if ($threadyear == date('Y')) continue; |
} |
$threadcount[$threadyear][$threadmonth]++; |
if (!in_array($threadyear, $tableau_annee)) array_push ($tableau_annee, $threadyear); |
} |
} |
if ($sortir) break; |
} |
$res = ''; |
arsort($tableau_annee); |
foreach ($tableau_annee as $annee) { |
$res .= " <tr>\n"; |
$res .= ' <td class="col_annee">'.$annee.'</td>'; |
for ($i = 1; $i <= 12; $i++) { |
$res .= '<td class="mois">'; |
if (isset($threadcount[$annee][$i]) && $threadcount[$annee][$i] > 0) { |
$res .= $this->makelink('action=show_month&actionargs[]='.$annee.($i < 10 ? '0'.$i:$i),$threadcount[$annee][$i]); |
} |
$res .= '</td>'; |
} |
$res .= '</tr>'."\n"; |
} |
return $res; |
} |
function ecrireFichierCalendrier() { |
$html = $this->calculeCalendrierPermanent(); |
$f = fopen ('tmp/'.$this->listname.'.calendrier', 'w') ; |
fwrite ($f, $html); |
fclose($f); |
return $html; |
} |
function calendrierMessage() { |
$html = ''; |
// On ajoute la derniere annee |
$html .= $this->calculeCalendrierPermanent(date ('Y')); |
if (! $this->isFichierCalendrierExiste()) return $html . $this->ecrireFichierCalendrier(); |
// S'il existe mais qu il est trop vieux, il faut le recalculer et le réécrire |
if ($this->isDoitRecalculerCalendrier()) return $html . $this->ecrireFichierCalendrier(); |
// précédemment, dans ce cas ci-dessus |
// était effectuée un recalcul partiel, mais sans réécriture du fichier: |
/* $annees = $this->getAnneesARecalculer(); |
$html .= $this->calculeCalendrierPermanent($annees); */ |
return $html . file_get_contents('tmp/'.$this->listname.'.calendrier'); |
} |
function isFichierCalendrierExiste() { |
if (file_exists('tmp/'.$this->listname.'.calendrier')) { |
return true; |
} |
return false; |
} |
function isDoitRecalculerCalendrier() { |
return (date ('Y', filemtime('tmp/'.$this->listname.'.calendrier')) <= date('Y') - 1); |
} |
function getAnneesARecalculer() { |
// On suppose que l index de ezmlm est correct |
$anneeFichierCalendrier = date ('Y', filemtime('tmp/'.$this->listname.'.calendrier')); |
return $anneeFichierCalendrier + 1; |
} |
} |
// CLASS: ezmlm-thread is a quick little class to allow us to define |
// a structure of the current thread in a single-linked list. |
// it's a little messy since php doesn't support pointers like C does |
// so we have to use references and a head object to append to the list. |
class ezmlm_thread { |
var $next; |
var $depth; |
var $file; |
var $msgid; |
var $inreply; |
var $references; |
function append($thread) { |
$thread_curr =& $this; |
while ($thread_curr->next != NULL) { |
$thread_curr =& $thread_curr->next; |
} |
$thread_curr->next = $thread; |
} |
function &find_msgid($msgid) { |
$thread_curr =& $this; |
while ($thread_curr->next != NULL) { |
if (trim($thread_curr->msgid) == trim($msgid)) { return $thread_curr; } |
$thread_curr =& $thread_curr->next; |
} |
return NULL; |
} |
function ezmlm_thread($depth,$file,$msgid) { |
$this->depth = $depth; |
$this->file = $file; |
$this->msgid = $msgid; |
$this->next = NULL; |
} |
} |
?> |
<?php |
// $Id: ezmlm-threads.php,v 1.6 2008-08-25 15:19:15 alexandre_tb Exp $ |
// |
// ezmlm-threads.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
// Builds, maintains & displays thread caches |
// These cache files live in $ezmlm->tmpdir and are serialized |
// php objects that can be unserialized and displayed easily |
// -------------------------------------------------------------- |
require_once("ezmlm.php"); |
require_once("ezmlm-parser.php"); |
require_once ('ezmlm-langue-fr.php'); |
// CLASS: ezmlm_threads will build, maintain & display thread files (even if a thread is only 1 msg) |
class ezmlm_threads extends ezmlm_php { |
// load: this is the main function that should be called. |
// it first checks to see if the cache files are stale, if they are it calls build |
// other wise it loads them and calls display |
function load($month) { |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
$checksum = $this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month . "-" . "checksum"; |
} else { |
$checksum = $this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month . "-" . "checksum"; |
} |
$md5 = '' ; |
if (!is_file($checksum)) { |
$this->build($month); |
} else { |
$fd = fopen($checksum,"r"); |
while (!preg_match('/^md5:/', $md5)) { $md5 = fgets($fd,4096); } |
fclose($fd); |
$md5 = rtrim(preg_replace('/^md5:/', '', $md5), "\n"); |
if ($md5 != $this->md5_of_file($this->listdir . "/archive/threads/" . $month)) { |
print "<!-- $md5 ne " . $this->md5_of_file($this->listdir . "/archive/threads/" . $month) . " -->\n"; |
$this->build($month); |
} |
} |
$html = $this->display($month); |
return $html ; |
} |
// display: this loads each cache file sequentially and displays the messages in them |
// there is no checking of checksum's done here so load() is the preferred method to |
// view the threads |
function display($month) { |
$html = '' ; |
$seq = 0; |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
$cache = $this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month; |
} else { |
$cache = $this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month; |
} |
// Le lien par date et par thread |
$html .= '[ '.$this->makelink('action=show_month&actionargs[]='.$month, 'par date').' ]' ; |
$months = array(1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', |
9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December'); |
// remplac� par le tableau globals $mois dans ezmlm.php |
$html .= '<h2>'.FIL_DE_DISCUSSION.' pour '.$GLOBALS['mois'][((int)substr($month,4,2) / 1) -1] .', ' . substr($month,0,4) . '</h2>'."\n"; |
$html .= '<table class="table_cadre">'."\n"; |
$html .= '<tr><th>Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n"; |
$html .= '<tr><td colspan="3"><hr /></td></tr>'."\n"; |
$ctc .= 0; |
if (is_file($cache)) { |
include($cache); |
} |
$html .= '<tr><td colspan="3"></td></tr>'."\n"; |
$html .= '</table>'."\n"; |
return $html ; |
} |
function thread_to_html($thread) { |
$html = ''; |
$lastdepth = -1; |
$ctc = 0 ; |
$thread_curr = $thread; |
$class = array ('ligne_paire', 'ligne_impaire') ; |
while ($thread_curr != NULL) { |
preg_match ('!/archive/([0-9]*)/([0-9]*)!', $thread_curr->file, $match) ; |
if (!isset($GLOBALS['fichiers_analyses'][$match[1]][$match[2]])) { |
$message = file_get_contents($this->listdir . "/archive/" . $msgdir . "/" . $msgfile) ; |
$mimeDecode = new Mail_mimeDecode($message) ; |
$mailDecode = $mimeDecode->decode() ; |
//$msg = new ezmlm_parser(); |
//$msg->parse_file($this->listdir . $thread_curr->file, TRUE); |
} else { |
$mailDecode = $GLOBALS['fichiers_analyses'][$match[1]][$match[2]] ; |
} |
$actionargs = preg_split("/\//", $thread_curr->file); |
$html .= '<tr class="'.$class[$ctc].'">'."\n"; |
$html .= '<td>'.$actionargs[2].$actionargs[3].'</td><td>'; |
$html .= $this->makelink('action=show_author_msgs&actionargs[]='. |
$this->makehash($this->decode_iso($mailDecode->headers['from'])),$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE))); |
$html .= '</td>'."\n"; |
$html .= '<td><b>'; |
//$html .= " <a name=\"" . urlencode($thread_curr->file) . "\">"; A quoi �a sert ? |
for ($i = 0; $i < $thread_curr->depth; $i++) { |
$html .= " "; |
} |
if (($this->thread_subjlen > 0) and (strlen($this->decode_iso($mailDecode->headers['subject'])) > $this->thread_subjlen)) { |
$subject = substr($this->decode_iso($mailDecode->headers['subject']), 0, ($this->thread_subjlen - 3 - ($thread_curr->depth * 2))); |
$subject = $subject . "..."; |
} else { |
$subject = $this->decode_iso($mailDecode->headers['subject']); |
} |
$subject = preg_replace("/\[" . $this->listname . "\]/", "", $subject); |
$html .= $this->makelink("action=show_msg&actionargs[]=" . $actionargs[2] . "&actionargs[]=" . $actionargs[3], $subject); |
$html .= "</b></td>\n"; |
$html .= '<td>' .$this->date_francaise($mailDecode->headers['date']).'</td>'."\n"; |
$html .= "</tr>\n"; |
$ctc++; |
if ($ctc == count($this->tablecolours)) { $ctc = 0; } |
$lastdepth = $thread_curr->depth; |
$thread_curr = $thread_curr->next; |
} |
$html .= '<tr><td colspan="3"><hr noshade size="1" /></td></tr>'."\n"; |
return $html; |
} |
// build: takes one argument in the format YYYYMM and builds the thread cache file |
// for that month if the ezmlm thread file exists. The resulting cache file is then |
// stored in $this->tmpdir; |
function build($month) { |
if (!is_file($this->listdir . "/archive/threads/" . $month)) { return FALSE; } |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month,"w+"); |
} else { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month,"w+"); |
} |
fclose($fd2); |
$i=0; |
// ouverture du fichier thread de ezmlm |
// Ils sont class�s mois par mois |
$fd1 = fopen($this->listdir . "/archive/threads/" . $month, "r"); |
while (!feof($fd1)) { |
$line = fgets($fd1,4096); |
if (preg_match('/^[0-9]*\:[a-z]* \[.*/', $line)) { |
// valid ezmlm thread file entry |
// On place dans $subjectfile le chemin vers le fichier sujet |
$subjectfile = preg_replace("/^[0-9]*\:([a-z]*) \[.*/", "\\1", $line); |
$subjectfile = substr($subjectfile,0,2) . '/' . substr($subjectfile,2,18); |
$thread_head = NULL; |
$thread_curr = NULL; |
$thread_temp = NULL; |
$thread_depth = 1; |
if (!is_file($this->listdir . "/archive/subjects/" . $subjectfile)) { continue; } |
// on ouvre le fichier sujet |
// Celui-ci contient sur la premi�re ligne le hash du sujet puis le sujet |
// sur les autres lignes : |
// num_message:ann�emois:hash_auteur nom_auteur |
$fd2 = fopen($this->listdir . "/archive/subjects/" . $subjectfile, "r"); |
while (!feof($fd2)) { |
$line2 = fgets($fd2,4096); |
if (preg_match('/^[0-9]/',$line2)) { |
$msgnum = preg_replace('/^([0-9]*):.*/', '\\1', $line2); |
$msgfile = $msgnum % 100; |
$msgdir = (int)($msgnum / 100); |
if ($msgfile < 10) { $msgfile = "0" . $msgfile; } |
//$msg = new ezmlm_parser(); |
//$msg->parse_file_headers($this->listdir . "/archive/" . $msgdir . "/" . $msgfile, TRUE); |
$message = file_get_contents($this->listdir . "/archive/" . $msgdir . "/" . $msgfile) ; |
$mimeDecode = new Mail_mimeDecode($message) ; |
$mailDecode = $mimeDecode->decode() ; |
// On stocke le fichier analys�e pour r�utilisation ult�rieure |
$GLOBALS['fichiers_analyses'][$msgdir][$msgfile] = $mailDecode ; |
$msgid = (isset ($mailDecode->headers['message-id']) ? $mailDecode->headers['message-id'] : ''); |
$inreply = (isset($mailDecode->headers['in-reply-to']) ? $mailDecode->headers['in-reply-to'] : ''); |
$references = (isset ($mailDecode->headers['references']) ? $mailDecode->headers['references'] : '') ; |
$thread_depth = 1; |
if ($thread_head == NULL) { |
$thread_head = new ezmlm_thread(0,'/archive/' . $msgdir . '/' . $msgfile,$msgid); |
} else { |
$thread_curr = new ezmlm_thread($depth,'/archive/' . $msgdir . '/' . $msgfile,$msgid); |
if ($inreply != '') { $thread_curr->inreply = $inreply; } |
if ($references != '') { $thread_curr->references = $references; } |
$thread_head->append($thread_curr); |
} |
} |
} |
fclose($fd2); |
// so now after all that mess $thread_head contains a full thread tree |
// first build the depth of each message based on 'in-reply-to' and 'references' |
unset($thread_temp); |
$thread_temp = NULL; |
$thread_curr =& $thread_head->next; |
while (get_class($thread_curr) == 'ezmlm_thread') { |
unset($thread_temp); |
$thread_temp = NULL; |
if ($thread_curr->inreply != '') { $thread_temp =& $thread_head->find_msgid($thread_curr->inreply); } |
if ($thread_temp == NULL) { |
if ($thread_curr->references != '') { |
$refs = preg_split('/ /', $thread_curr->references); |
$refs = array_pop($refs); |
$thread_temp =& $thread_head->find_msgid($refs); |
} |
} |
if ($thread_temp == NULL) { |
// we couldn't find anything... set depth to 1, the default |
$thread_curr->depth = 1; |
} else { |
// we found a reference, set it to it's depth + 1 |
$thread_curr->depth = $thread_temp->depth + 1; |
} |
$thread_curr =& $thread_curr->next; |
} |
// now write it to a temp file named MONTH-SEQ where seq is cronologic sequence order of the thread. |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
@mkdir($this->tempdir . "/ezmlm-php-" . $this->listname, 0755); |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month, "a"); |
} else { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month, "a"); |
} |
} else { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month, "a"); |
} |
fputs($fd2,$this->thread_to_html($thread_head)); |
fclose($fd2); |
} |
} |
// finally store our checksum |
if (!is_dir($this->tempdir . "/ezmlm-php-" . $this->listname)) { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "-" . $month . "-" . "checksum","w+"); |
} else { |
$fd2 = fopen($this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month . "-" . "checksum","w+"); |
} |
fputs($fd2,"md5:" . $this->md5_of_file($this->listdir . "/archive/threads/" . $month) . "\n"); |
fclose($fd2); |
fclose($fd1); |
return TRUE; |
} |
// listmessages: prints out a nice little calendar and displays the message |
// totals for each month. The link jumps to the thread listing. |
// On lit le repetoire archive/threads/ qui contient un fichier par moi avec tous les thread, par sujet |
// Presentes comme suit |
// num_thread:hash [taille_du_thread] Sujet du thread (le dernier) |
// les messages sont ranges par leur numero |
function listmessages() { |
if (!is_dir($this->listdir . "/archive/threads/")) { |
return false ; |
} |
$res = '<table id="petit_calendrier">'."\n"; |
$res .= " <tr>\n"; |
$res .= " <td></td>" ; |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<th>'.$valeur.'</th>' ; |
$res .=" </tr>\n"; |
$res .= $this->calendrierMessage(); |
$res .= "</table>\n"; |
return $res; |
/* |
$threadcount = array(); |
$repertoire_archive = opendir($this->listdir . "/archive/"); |
$tableau_annee = array(); |
while (false !== ($item = readdir($repertoire_archive))) { |
// $item contient les noms des repertoires |
// on ne garde que ceux qui sont des chiffres |
if (preg_match('/[0-9]+/', $item)) { |
// on ouvre le fichier d index de chaque repertoire |
$fichier_index = fopen($this->listdir.'/archive/'.$item.'/index', 'r'); |
$compteur = 0 ; |
while (!feof($fichier_index)) { |
// On ignore la premiere ligne |
$temp = fgets($fichier_index, 4096); |
// dans la seconde on recupere la date |
$temp = fgets($fichier_index, 4096); |
preg_match('/\t([0-9]+) ([a-zA-Z][a-zA-Z][a-zA-Z]) ([0-9][0-9][0-9][0-9])/', $temp, $match) ; |
if ($match[0] != '') { |
$threadmonth = date('n', strtotime($match[0])) ; |
$threadyear = date('Y', strtotime($match[0])) ; |
$threadcount[$threadyear][$threadmonth]++; |
if (!in_array($threadyear, $tableau_annee)) array_push ($tableau_annee, $threadyear); |
} |
} |
fclose ($fichier_index); |
} |
} |
if (count($threadcount) == 0) return 'Il n\y a pas de messages dans les archives'; |
// La partie qui suit, simple, cree la table avec le nombre de message echange chaque mois |
$res = '<table id="petit_calendrier">'."\n"; |
$res .= " <tr>\n"; |
$res .= " <td></td>" ; |
foreach ($GLOBALS['mois'] as $valeur) $res .= '<th>'.$valeur.'</th>' ; |
$res .=" </tr>\n"; |
arsort($tableau_annee); |
foreach ($tableau_annee as $annee) { |
$res .= " <tr>\n"; |
$res .= ' <td class="col_annee">'.$annee.'</td>'; |
for ($i = 1; $i <= 12; $i++) { |
$res .= '<td class="mois">'; |
if (isset($threadcount[$annee][$i]) && $threadcount[$annee][$i] > 0) { |
$res .= $this->makelink('action=show_month&actionargs[]='.$annee.($i < 10 ? '0'.$i:$i),$threadcount[$annee][$i]); |
} |
$res .= '</td>'; |
} |
$res .= '</tr>'."\n"; |
} |
$res .= "</table>\n"; |
return $res ; |
*/ |
} |
/* |
* Cree un fichier liste.calendrierPermanent qui contient |
* le nombre de message par mois pour toutes les annees |
* depuis le debut de la liste sauf la derniere |
* |
*/ |
function calculeCalendrierPermanent($Annnee = '') { |
$numArchive = $this->getNumArchive(); |
$dernierRepertoire = floor($numArchive / 100); |
$threadcount = array(); |
$tableau_annee = array(); |
for ($rep_courant = $dernierRepertoire; $rep_courant >= 0; $rep_courant--) { |
$fichier_index = file ($this->listdir.'/archive/'.$rep_courant.'/index', FILE_IGNORE_NEW_LINES); |
// On parcours le fichier a l envers |
for ($j = count($fichier_index)-1; $j >= 0; $j-=2) { |
preg_match('/\t([0-9]+) ([a-zA-Z][a-zA-Z][a-zA-Z]) ([0-9][0-9][0-9][0-9])/', $fichier_index[$j], $match) ; |
if ($match[0] != '') { |
$threadmonth = date('n', strtotime($match[0])) ; |
$threadyear = date('Y', strtotime($match[0])) ; |
if ($Annnee != '') { |
if ($threadyear < date('Y')) { |
$sortir = true; |
break; |
} |
} else { |
if ($threadyear == date('Y')) continue; |
} |
$threadcount[$threadyear][$threadmonth]++; |
if (!in_array($threadyear, $tableau_annee)) array_push ($tableau_annee, $threadyear); |
} |
} |
if ($sortir) break; |
} |
$res = ''; |
arsort($tableau_annee); |
foreach ($tableau_annee as $annee) { |
$res .= " <tr>\n"; |
$res .= ' <td class="col_annee">'.$annee.'</td>'; |
for ($i = 1; $i <= 12; $i++) { |
$res .= '<td class="mois">'; |
if (isset($threadcount[$annee][$i]) && $threadcount[$annee][$i] > 0) { |
$res .= $this->makelink('action=show_month&actionargs[]='.$annee.($i < 10 ? '0'.$i:$i),$threadcount[$annee][$i]); |
} |
$res .= '</td>'; |
} |
$res .= '</tr>'."\n"; |
} |
return $res; |
} |
function ecrireFichierCalendrier() { |
$html = $this->calculeCalendrierPermanent(); |
$f = fopen ('tmp/'.$this->listname.'.calendrier', 'w') ; |
fwrite ($f, $html); |
fclose($f); |
return $html; |
} |
function calendrierMessage() { |
$html = ''; |
// On ajoute la derniere annee |
$html .= $this->calculeCalendrierPermanent(date ('Y')); |
if ($this->isFichierCalendrierExiste()) { |
// S il existe mais qu il est trop vieux, il faut le recalculer |
if ($this->isDoitRecalculerCalendrier()) { |
$annees = $this->getAnneesARecalculer(); |
$html .= $this->calculeCalendrierPermanent($annees); |
} |
$html .= file_get_contents('tmp/'.$this->listname.'.calendrier'); |
} else { |
$html .= $this->ecrireFichierCalendrier(); |
} |
return $html; |
} |
function isFichierCalendrierExiste() { |
if (file_exists('tmp/'.$this->listname.'.calendrier')) { |
return true; |
} |
return false; |
} |
function isDoitRecalculerCalendrier() { |
if (date ('Y', fileatime('tmp/'.$this->listname.'.calendrier')) != date('Y')) return true; |
return false; |
} |
function getAnneesARecalculer() { |
// On suppose que l index de ezmlm est correct |
$anneeFichierCalendrier = date ('Y', fileatime('tmp/'.$this->listname.'.calendrier')); |
return $anneeFichierCalendrier + 1; |
} |
} |
// CLASS: ezmlm-thread is a quick little class to allow us to define |
// a structure of the current thread in a single-linked list. |
// it's a little messy since php doesn't support pointers like C does |
// so we have to use references and a head object to append to the list. |
class ezmlm_thread { |
var $next; |
var $depth; |
var $file; |
var $msgid; |
var $inreply; |
var $references; |
function append($thread) { |
$thread_curr =& $this; |
while ($thread_curr->next != NULL) { |
$thread_curr =& $thread_curr->next; |
} |
$thread_curr->next = $thread; |
} |
function &find_msgid($msgid) { |
$thread_curr =& $this; |
while ($thread_curr->next != NULL) { |
if (trim($thread_curr->msgid) == trim($msgid)) { return $thread_curr; } |
$thread_curr =& $thread_curr->next; |
} |
return NULL; |
} |
function ezmlm_thread($depth,$file,$msgid) { |
$this->depth = $depth; |
$this->file = $file; |
$this->msgid = $msgid; |
$this->next = NULL; |
} |
} |
?> |
/trunk/classes/ezmlm-php-2.0/ezmlm-msgdisplay.php |
---|
1,396 → 1,400 |
<?php |
// $Id: ezmlm-msgdisplay.php,v 1.11 2008-11-19 09:28:46 aperonnet Exp $ |
// |
// ezmlm-msgdisplay.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
// Will parse a template (if specified) and display a message. |
// Includes a default template. |
// -------------------------------------------------------------- |
require_once("ezmlm.php"); |
require_once("Mail/mimeDecode.php") ; |
class ezmlm_msgdisplay extends ezmlm_php { |
// our template |
var $msgtmpl; |
var $message_rendu ; |
var $_auth ; |
// display: parses a message (using ezmlm_parser) and displays it |
// using a template |
var $msgfile; |
function display($msgfile) { |
if (!is_file($msgfile)) { |
if (is_file($this->listdir . "/" . $msgfile)) { $msgfile = $this->listdir . "/" . $msgfile; } |
else if (is_file($this->listdir . "/archive/" . $msgfile)) { $msgfile = $this->listdir . "/archive/" . $msgfile; } |
else { return FALSE; } |
} |
$this->msgfile = $msgfile ; |
$message = file_get_contents($msgfile) ; |
// En cours de codage |
// La fonction display retourne tout simplement le source du mail |
// Il n'y a plus d'analyse a ce niveau |
return $message; |
$mimeDecode = new Mail_mimeDecode($message) ; |
$mailDecode = $mimeDecode->decode(array('decode_bodies' => 'true', 'include_bodies' => 'true')) ; |
// $msg->msgfile contient le chemin du fichier du mail en partant de la racine |
// Le point d'exclamation est le delimiteur de l'expression reguliere |
$relfile = preg_replace('!' . $this->listdir . '!', '', $msgfile); |
$a1 = preg_replace('!/archive/(.*)/.*$!', '\1', $relfile); // $a1 contient le nom du repertoire |
$a2 = preg_replace('!/archive/.*/(.*)$!', '\1', $relfile); // $a2 contient le nom du fichier |
if (isset($mailDecode->headers['date'])) $msgtime = strtotime(preg_replace ('/CEST/', '', $mailDecode->headers['date'])); |
$threadidx = date("Ym", $msgtime); |
if ($a2 <= 10) $numero_precedent = '0'.($a2 - 1) ; else $numero_precedent = ($a2 - 1) ; |
if ($a2 < 9) $numero_suivant = '0'.($a2 + 1) ; else $numero_suivant = ($a2 + 1); |
// On teste si le message suivant existe |
$decoupe = explode ('/', $msgfile) ; |
// Les nom de fichiers sont du format : |
// archive/0/01 |
// archive/0/02 ... 0/99 archive/1/01 ... |
$nom_fichier = $decoupe[count($decoupe)-1] ; |
$nom_repertoire = $decoupe[count($decoupe)-2] ; |
$repertoire_suivant = $nom_repertoire ; $repertoire_precedent = $nom_repertoire ; |
if ($nom_fichier > 8) { |
$fichier_suivant = $nom_fichier + 1 ; |
if ($nom_fichier == 99) { |
$fichier_suivant = '01' ; |
$repertoire_suivant = $nom_repertoire + 1 ; |
} |
} else { |
$fichier_suivant = '0'.($nom_fichier + 1) ; |
} |
if ($nom_fichier > 10) { |
$fichier_precedent = $nom_fichier - 1 ; |
} else { |
if ($nom_fichier == '01') { |
$fichier_precedent = '99' ; |
$repertoire_precedent = $nom_repertoire - 1 ; |
} else { |
$fichier_precedent = '0'.($nom_fichier - 1) ; |
} |
} |
print $this->parse_entete_mail($mailDecode) ; |
$this->parse_template($mailDecode, $a2, $a1); |
print $this->message_rendu; |
//print '</div>' ; |
} |
/** |
* Renvoie les infos des messages suivants |
* |
* |
*/ |
function getInfoSuivant() { |
$relfile = preg_replace('!' . $this->listdir . '!', '', $this->msgfile); |
$nom_repertoire = preg_replace('!/archive/(.*)/.*$!', '\1', $relfile); |
$nom_fichier = preg_replace('!/archive/.*/(.*)$!', '\1', $relfile); |
$repertoire_suivant = $nom_repertoire; |
// On recupere le numero du dernier message |
if (file_exists($this->listdir.'/archnum')) { |
$numero_dernier_message = file_get_contents($this->listdir.'/archnum'); |
} |
// a partir du nom du fichier |
// et du nom du repertoire, on reconstitue |
// le numero du message stocke dans le fichier d index |
// le message 12 du repertoire 2 a le numero 212 |
if ($nom_repertoire == '0') { |
$numero_message = $nom_fichier; |
} else { |
$numero_message = $nom_repertoire.$nom_fichier ; |
} |
// On ouvre le fichier d index |
$fichier_index = fopen ($this->listdir.'/archive/'.$nom_repertoire.'/index', 'r'); |
$compteur_ligne = 1; |
if (preg_match ('/0([1-9][0-9]*)/', $nom_fichier, $match)) { |
$nom_fichier = $match[1]; |
$prefixe = '0' ; |
} else { |
$prefixe = '' ; |
} |
$prefixe = $this->prefixe_nom_message($nom_fichier); |
//echo $numero_message; |
// on cherche la ligne avec le numero du message |
while (!feof($fichier_index)) { |
$temp = fgets($fichier_index,4096); |
$x = preg_match('/(\d+): (\w+) (.*)/', $temp, $matches); |
array_shift($matches); |
list($num, $hash, $sujet) = $matches; |
if ($num == $numero_message) { |
$ligne_message_precedent = $compteur_ligne -2; |
$temp = fgets($fichier_index, 4096); |
$temp = fgets($fichier_index, 4096); |
list ($fichier_suivant,$hash, $sujet) = split(':', $temp); |
// Au cas ou est au dernier message du fichier d index |
// il faut ouvrir le suivant |
if (feof($fichier_index)) { |
$repertoire_suivant++; |
if (file_exists($this->listdir.'/archive/'.$repertoire_suivant.'/index')) { |
$fichier_index_suivant = fopen($this->listdir.'/archive/'.$repertoire_suivant.'/index', 'r'); |
// on recupere le numero du premier message |
list($fichier_suivant, $hash, $sujet) = split (':', fgets($fichier_index_suivant), 4096); |
fclose ($fichier_index_suivant); |
} |
} |
// Si le numero est > 100, il faut decouper et ne retenir |
// que les dizaines et unites |
if ($fichier_suivant >= 100) { |
$decimal = (string) $fichier_suivant; |
$numero = substr($decimal, -2) ; |
$fichier_suivant = $numero ; |
} else { |
if ($fichier_suivant <= 9)$fichier_suivant = '0'.$fichier_suivant; |
} |
break; |
} |
// On avance d une ligne, la 2e ligne contient date hash auteur |
$temp2 = fgets($fichier_index, 4096); |
$compteur_ligne += 2; |
} |
// On utilise $ligne_message_precedent pour recupere le num du message precedent |
// Si $ligne_precedent est negatif soit c le premier message de la liste |
// soit il faut ouvrir le repertoire precedent |
if ($ligne_message_precedent > 0) { |
$compteur = 1; |
rewind($fichier_index); |
while (!feof($fichier_index)) { |
$temp = fgets($fichier_index, 4096); |
if ($ligne_message_precedent == $compteur) { |
list ($fichier_precedent, $hash, $sujet) = split (':', $temp) ; |
} |
$compteur++; |
} |
// Le nom du repertoire precedent est le meme que le repertoire courant |
$repertoire_precedent = $nom_repertoire ; |
// Si $ligne_message_precedent est negatif, alors il faut ouvrir |
// le fichier index du repertoire precedent |
// si le nom du repertoire est 0, alors il n y a pas de repertoire precedent |
// et donc pas de message precedent |
} else { |
if ($nom_repertoire != '0') { |
$repertoire_precedent = $nom_repertoire -1 ; |
// on ouvre le fichier d index et on extraie le numero |
// du dernier message |
$fichier_index_precedent = fopen ($this->listdir.'/archive/'.$repertoire_precedent.'/index', 'r') ; |
while (!feof($fichier_index_precedent)) { |
$temp = fgets($fichier_index_precedent,4096); |
$ligne = split (':', $temp) ; |
if ($ligne[0] != '') $fichier_precedent = $ligne[0]; |
$temp = fgets($fichier_index_precedent,4096); |
} |
fclose ($fichier_index_precedent); |
// on se situe dans le repertoire 0 donc pas de message precedent |
} else { |
$fichier_precedent = null; |
$repertoire_precedent = null; |
} |
} |
if ($fichier_precedent > 100) { |
$decimal = (string) $fichier_precedent; |
$numero = substr($decimal, -2) ; |
$fichier_precedent = $numero ; |
} else { |
if ($fichier_precedent < 10 )$fichier_precedent = '0'.$fichier_precedent; |
} |
fclose ($fichier_index); |
//if ($fichier_precedent != null && $fichier_precedent < 10) $fichier_precedent = '0'.$fichier_precedent; |
return array ('fichier_suivant' => $fichier_suivant, |
'repertoire_suivant' => $repertoire_suivant, |
'fichier_precedent' => $fichier_precedent, |
'repertoire_precedent' => $repertoire_precedent); |
} |
/** |
* analyse l'entete d'un mail pour en extraire les entête |
* to, from, subject, date |
* met à jour la variable $this->msgtmpl |
* |
*/ |
function parse_entete_mail (&$mailDecode) { |
$startpos = strpos(strtolower($this->msgtmpl_entete), '<ezmlm-headers>'); |
$endpos = strpos(strtolower($this->msgtmpl_entete), '</ezmlm-headers>'); |
$headers = substr($this->msgtmpl_entete,$startpos + 15,($endpos - $startpos - 15)); |
$headers_replace = '' ; |
for ($i = 0; $i < count($this->showheaders); $i++) { |
$val = $this->showheaders[$i]; |
$headers_replace .= $headers; |
$hnpos = strpos(strtolower($headers_replace), '<ezmlm-header-name>'); |
$headers_replace = substr_replace($headers_replace, $this->header_en_francais[$val], $hnpos, 19); |
$hvpos = strpos(strtolower($headers_replace), '<ezmlm-header-value'); |
$headers_replace = $this->decode_iso ($headers_replace) ; |
switch ($val) { |
case 'date': |
$headers_replace = substr_replace($headers_replace, $this->date_francaise($mailDecode->headers[strtolower($val)]), $hvpos, 20); |
break; |
case 'from': |
if ($mailDecode->headers[strtolower($val)] == '') $from = $mailDecode->headers['return-path'] ; |
else $from = $mailDecode->headers['from']; |
$headers_replace = substr_replace($headers_replace, $this->protect_email($this->decode_iso($from)), $hvpos, 20); |
//$headers_replace = htmlspecialchars($headers_replace); |
break; |
default: |
$headers_replace = substr_replace($headers_replace, $this->protect_email($this->decode_iso($mailDecode->headers[strtolower($val)])), $hvpos, 20); |
} |
} |
return substr_replace($this->msgtmpl_entete, $headers_replace, $startpos, (($endpos + 16) - $startpos)); |
} |
function parse_template(&$mailDecode, $numero_mail, $numero_mois, $num_part = '') { |
static $profondeur = array(); |
if ($num_part != '') array_push ($profondeur, $num_part) ; |
$corps = '' ; |
if ($mailDecode->ctype_primary == 'multipart') { |
include_once PROJET_CHEMIN_CLASSES.'type_fichier_mime.class.php' ; |
for ($i = 0; $i < count($mailDecode->parts); $i++) { |
switch ($mailDecode->parts[$i]->ctype_secondary) { |
case 'plain' : |
if ($mailDecode->parts[$i]->headers['content-transfer-encoding'] == '8bit') { |
$corps .= $this->_cte_8bit($mailDecode->parts[$i]->body); |
} else if ($mailDecode->parts[$i]->headers['content-transfer-encoding'] == 'quoted-printable') { |
if ($mailDecode->parts[$i]->ctype_parameters['charset'] == 'UTF-8') { |
$corps .= utf8_decode($mailDecode->parts[$i]->body); |
} |
} |
break; |
case 'html' : $corps .= trim(strip_tags ($mailDecode->parts[$i]->body, '<br><p><a><style>')); |
break ; |
case 'mixed' : |
case 'rfc822' : |
case 'alternative' : |
case 'appledouble' : |
$this->parse_template($mailDecode->parts[$i], $numero_mail, $numero_mois, $i) ; |
break ; |
case 'applefile' : continue ; |
break ; |
default : |
if ($mailDecode->parts[$i]->ctype_secondary == 'octet-stream') { |
$nom_piece_jointe = $mailDecode->parts[$i]->ctype_parameters['name'] ; |
$tab = explode ('.', $nom_piece_jointe) ; |
$extension = $tab[count ($tab) - 1] ; |
$mimeType = type_fichier_mime::factory($extension); |
$mimeType->setCheminIcone(PROJET_CHEMIN_ICONES) ; |
} else { |
$nom_piece_jointe = isset ($mailDecode->parts[$i]->d_parameters['filename']) ? |
$mailDecode->parts[$i]->d_parameters['filename'] : $mailDecode->parts[$i]->ctype_parameters['name'] ; |
$mimeType = new type_fichier_mime( $mailDecode->parts[$i]->ctype_primary.'/'. |
$mailDecode->parts[$i]->ctype_secondary, PROJET_CHEMIN_ICONES) ; |
} |
$lien = PROJET_CHEMIN_APPLI.'fichier_attache.php?nom_liste='.$this->listname. |
'&actionargs[]='.$numero_mois. |
'&actionargs[]='.$numero_mail; |
if (count ($profondeur) > 0) { |
array_shift($profondeur) ; |
for ($j= 0; $j < count ($profondeur); $j++) $lien .= '&actionargs[]='.$profondeur[$j]; |
} |
$lien .= '&actionargs[]='.$i ; |
$corps .= '<a href="'.$lien.'">'; |
$corps .= '<img src="'.$mimeType->getCheminIcone().'" alt="'.$nom_piece_jointe.'" /> ' ; |
if ($mailDecode->parts[$i]->ctype_secondary == 'jpg' || $mailDecode->parts[$i]->ctype_secondary == 'jpeg') |
$corps .= '<img src="'.$lien.'" alt="'.$nom_piece_jointe.'" /> ' ; |
$corps .= $nom_piece_jointe; |
$corps .= '</a><br />' ; |
break ; |
} |
} |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,TRUE), $this->msgtmpl); |
} else if ($mailDecode->ctype_primary == 'message') { |
$this->message_rendu .= "\n".'<div class="message">'.$this->parse_entete_mail($mailDecode->parts[0]); |
$corps .= $this->parse_template($mailDecode->parts[0], $numero_mail, $numero_mois, 0) ; |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl).'</div>'; |
} else if ($mailDecode->ctype_primary == 'application' || $mailDecode->ctype_primary == 'image'){ |
if ($mailDecode->ctype_secondary == 'applefile') return ; |
$mimeType = new type_fichier_mime( $mailDecode->ctype_primary.'/'.$mailDecode->ctype_secondary,PROJET_CHEMIN_ICONES) ; |
if ($mimeType->getIdType() != 12) { |
$corps .= '<a href="'.PROJET_CHEMIN_APPLI.'fichier_attache.php?nom_liste='.$this->listname.'&actionargs[]='. |
$numero_mois.'&actionargs[]='. |
$numero_mail.'&actionargs[]='.$i.'">'. |
'<img src="'.$mimeType->getCheminIcone().'" alt="'.$mailDecode->ctype_parameters['name'].'" /> ' ; |
$corps .= $mailDecode->ctype_parameters['name'].'</a><br />' ; |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl); |
} |
} else { |
if (preg_match('/html/i', $mailDecode->ctype_secondary)) { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($mailDecode->body,TRUE), $this->msgtmpl); |
} else { |
if (isset ($mailDecode->ctype_parameters['charset']) && $mailDecode->ctype_parameters['charset'] == 'UTF-8') { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', '<pre>' . utf8_decode($this->cleanup_body($mailDecode->body,TRUE)) . '</pre>', $this->msgtmpl); |
} else { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', '<pre>' . $this->cleanup_body($mailDecode->body,TRUE) . '</pre>', $this->msgtmpl); |
} |
} |
} |
array_pop ($profondeur); |
} |
function ezmlm_msgdisplay() { |
$this->ezmlm_php(); |
if (($this->msgtemplate != "") and (is_file($this->msgtemplate))) { |
$fd = fopen($this->msgtemplate, "r"); |
while (!feof($fd)) { $this->msgtmpl .= fgets($fd,4096); } |
fclose($fd); |
} else { |
$this->msgtmpl = '<pre> |
<ezmlm-body> |
</pre> |
'; |
} |
$this->msgtmpl_entete = '<dl><ezmlm-headers> |
<dt><ezmlm-header-name> :</dt> |
<dd><ezmlm-header-value></dd> |
</ezmlm-headers> |
</dl>' ; |
} |
// _cte_8bit: decode a content transfer encoding of 8bit |
// NOTE: this function is a little bit special. Since the end result will be displayed in |
// a web browser _cte_8bit decodes ASCII characters > 127 (the US-ASCII table) into the |
// html ordinal equivilant, it also ensures that the messages content-type is changed |
// to include text/html if it changes anything... |
function _cte_8bit($data,$simple = FALSE) { |
if ($simple) { return $data; } |
$changed = FALSE; |
$out = ''; |
$chars = preg_split('//',$data); |
while (list($key,$val) = each($chars)) { |
if (ord($val) > 127) { $out .= '&#' . ord($val) . ';'; $changed = TRUE; } |
else { $out .= $val; } |
} |
if ($changed) { $this->headers['content-type'][1] = 'text/html'; } |
return $out; |
} |
} |
<?php |
// $Id: ezmlm-msgdisplay.php,v 1.9 2008-05-23 10:18:37 alexandre_tb Exp $ |
// |
// ezmlm-msgdisplay.php - ezmlm-php v2.0 |
// -------------------------------------------------------------- |
// Will parse a template (if specified) and display a message. |
// Includes a default template. |
// -------------------------------------------------------------- |
require_once("ezmlm.php"); |
require_once("Mail/mimeDecode.php") ; |
class ezmlm_msgdisplay extends ezmlm_php { |
// our template |
var $msgtmpl; |
var $message_rendu ; |
var $_auth ; |
// display: parses a message (using ezmlm_parser) and displays it |
// using a template |
var $msgfile; |
function display($msgfile) { |
if (!is_file($msgfile)) { |
if (is_file($this->listdir . "/" . $msgfile)) { $msgfile = $this->listdir . "/" . $msgfile; } |
else if (is_file($this->listdir . "/archive/" . $msgfile)) { $msgfile = $this->listdir . "/archive/" . $msgfile; } |
else { return FALSE; } |
} |
$this->msgfile = $msgfile ; |
$message = file_get_contents($msgfile) ; |
// En cours de codage |
// La fonction display retourne tout simplement le source du mail |
// Il n'y a plus d'analyse a ce niveau |
return $message; |
$mimeDecode = new Mail_mimeDecode($message) ; |
$mailDecode = $mimeDecode->decode(array('decode_bodies' => 'true', 'include_bodies' => 'true')) ; |
// $msg->msgfile contient le chemin du fichier du mail en partant de la racine |
// Le point d'exclamation est le delimiteur de l'expression reguliere |
$relfile = preg_replace('!' . $this->listdir . '!', '', $msgfile); |
$a1 = preg_replace('!/archive/(.*)/.*$!', '\1', $relfile); // $a1 contient le nom du repertoire |
$a2 = preg_replace('!/archive/.*/(.*)$!', '\1', $relfile); // $a2 contient le nom du fichier |
if (isset($mailDecode->headers['date'])) $msgtime = strtotime(preg_replace ('/CEST/', '', $mailDecode->headers['date'])); |
$threadidx = date("Ym", $msgtime); |
if ($a2 <= 10) $numero_precedent = '0'.($a2 - 1) ; else $numero_precedent = ($a2 - 1) ; |
if ($a2 < 9) $numero_suivant = '0'.($a2 + 1) ; else $numero_suivant = ($a2 + 1); |
// On teste si le message suivant existe |
$decoupe = explode ('/', $msgfile) ; |
// Les nom de fichiers sont du format : |
// archive/0/01 |
// archive/0/02 ... 0/99 archive/1/01 ... |
$nom_fichier = $decoupe[count($decoupe)-1] ; |
$nom_repertoire = $decoupe[count($decoupe)-2] ; |
$repertoire_suivant = $nom_repertoire ; $repertoire_precedent = $nom_repertoire ; |
if ($nom_fichier > 8) { |
$fichier_suivant = $nom_fichier + 1 ; |
if ($nom_fichier == 99) { |
$fichier_suivant = '01' ; |
$repertoire_suivant = $nom_repertoire + 1 ; |
} |
} else { |
$fichier_suivant = '0'.($nom_fichier + 1) ; |
} |
if ($nom_fichier > 10) { |
$fichier_precedent = $nom_fichier - 1 ; |
} else { |
if ($nom_fichier == '01') { |
$fichier_precedent = '99' ; |
$repertoire_precedent = $nom_repertoire - 1 ; |
} else { |
$fichier_precedent = '0'.($nom_fichier - 1) ; |
} |
} |
print $this->parse_entete_mail($mailDecode) ; |
$this->parse_template($mailDecode, $a2, $a1); |
print $this->message_rendu; |
//print '</div>' ; |
} |
/** |
* Renvoie les infos des messages suivants |
* |
* |
*/ |
function getInfoSuivant() { |
$relfile = preg_replace('!' . $this->listdir . '!', '', $this->msgfile); |
$nom_repertoire = preg_replace('!/archive/(.*)/.*$!', '\1', $relfile); |
$nom_fichier = preg_replace('!/archive/.*/(.*)$!', '\1', $relfile); |
$repertoire_suivant = $nom_repertoire; |
// On recupere le numero du dernier message |
if (file_exists($this->listdir.'/archnum')) { |
$numero_dernier_message = file_get_contents($this->listdir.'/archnum'); |
} |
// a partir du nom du fichier |
// et du nom du repertoire, on reconstitue |
// le numero du message stocke dans le fichier d index |
// le message 12 du repertoire 2 a le numero 212 |
if ($nom_repertoire == '0') { |
$numero_message = $nom_fichier; |
} else { |
$numero_message = $nom_repertoire.$nom_fichier ; |
} |
// On ouvre le fichier d index |
$fichier_index = fopen ($this->listdir.'/archive/'.$nom_repertoire.'/index', 'r'); |
$compteur_ligne = 1; |
if (preg_match ('/0([1-9][0-9]*)/', $nom_fichier, $match)) { |
$nom_fichier = $match[1]; |
$prefixe = '0' ; |
} else { |
$prefixe = '' ; |
} |
$prefixe = $this->prefixe_nom_message($nom_fichier); |
//echo $numero_message; |
// on cherche la ligne avec le numero du message |
while (!feof($fichier_index)) { |
$temp = fgets($fichier_index,4096); |
list($num, $hash, $sujet) = split (':', $temp) ; |
if ($num == $numero_message) { |
$ligne_message_precedent = $compteur_ligne -2; |
$temp = fgets($fichier_index, 4096); |
$temp = fgets($fichier_index, 4096); |
list ($fichier_suivant,$hash, $sujet) = split(':', $temp); |
// Au cas ou est au dernier message du fichier d index |
// il faut ouvrir le suivant |
if (feof($fichier_index)) { |
$repertoire_suivant++; |
if (file_exists($this->listdir.'/archive/'.$repertoire_suivant.'/index')) { |
$fichier_index_suivant = fopen($this->listdir.'/archive/'.$repertoire_suivant.'/index', 'r'); |
// on recupere le numero du premier message |
list($fichier_suivant, $hash, $sujet) = split (':', fgets($fichier_index_suivant), 4096); |
fclose ($fichier_index_suivant); |
} |
} |
// Si le numero est > 100, il faut decouper et ne retenir |
// que les dizaines et unites |
if ($fichier_suivant >= 100) { |
$decimal = (string) $fichier_suivant; |
$numero = substr($decimal, -2) ; |
$fichier_suivant = $numero ; |
} else { |
if ($fichier_suivant <= 9)$fichier_suivant = '0'.$fichier_suivant; |
} |
break; |
} |
// On avance d une ligne, la 2e ligne contient date hash auteur |
$temp2 = fgets($fichier_index, 4096); |
$compteur_ligne += 2; |
} |
// On utilise $ligne_message_precedent pour recupere le num du message precedent |
// Si $ligne_precedent est negatif soit c le premier message de la liste |
// soit il faut ouvrir le repertoire precedent |
if ($ligne_message_precedent > 0) { |
$compteur = 1; |
rewind($fichier_index); |
while (!feof($fichier_index)) { |
$temp = fgets($fichier_index, 4096); |
if ($ligne_message_precedent == $compteur) { |
list ($fichier_precedent, $hash, $sujet) = split (':', $temp) ; |
} |
$compteur++; |
} |
// Le nom du repertoire precedent est le meme que le repertoire courant |
$repertoire_precedent = $nom_repertoire ; |
// Si $ligne_message_precedent est negatif, alors il faut ouvrir |
// le fichier index du repertoire precedent |
// si le nom du repertoire est 0, alors il n y a pas de repertoire precedent |
// et donc pas de message precedent |
} else { |
if ($nom_repertoire != '0') { |
$repertoire_precedent = $nom_repertoire -1 ; |
// on ouvre le fichier d index et on extraie le numero |
// du dernier message |
$fichier_index_precedent = fopen ($this->listdir.'/archive/'.$repertoire_precedent.'/index', 'r') ; |
while (!feof($fichier_index_precedent)) { |
$temp = fgets($fichier_index_precedent,4096); |
$ligne = split (':', $temp) ; |
if ($ligne[0] != '') $fichier_precedent = $ligne[0]; |
$temp = fgets($fichier_index_precedent,4096); |
} |
fclose ($fichier_index_precedent); |
// on se situe dans le repertoire 0 donc pas de message precedent |
} else { |
$fichier_precedent = null; |
$repertoire_precedent = null; |
} |
} |
if ($fichier_precedent > 100) { |
$decimal = (string) $fichier_precedent; |
$numero = substr($decimal, -2) ; |
$fichier_precedent = $numero ; |
} else { |
if ($fichier_precedent < 10 )$fichier_precedent = '0'.$fichier_precedent; |
} |
fclose ($fichier_index); |
//if ($fichier_precedent != null && $fichier_precedent < 10) $fichier_precedent = '0'.$fichier_precedent; |
return array ('fichier_suivant' => $fichier_suivant, |
'repertoire_suivant' => $repertoire_suivant, |
'fichier_precedent' => $fichier_precedent, |
'repertoire_precedent' => $repertoire_precedent); |
} |
/** |
* analyse l'entete d'un mail pour en extraire les ent�tes |
* to, from, subject, date |
* met � jour la variable $this->msgtmpl |
* |
*/ |
function parse_entete_mail (&$mailDecode) { |
$startpos = strpos(strtolower($this->msgtmpl_entete), '<ezmlm-headers>'); |
$endpos = strpos(strtolower($this->msgtmpl_entete), '</ezmlm-headers>'); |
$headers = substr($this->msgtmpl_entete,$startpos + 15,($endpos - $startpos - 15)); |
$headers_replace = '' ; |
for ($i = 0; $i < count($this->showheaders); $i++) { |
$val = $this->showheaders[$i]; |
$headers_replace .= $headers; |
$hnpos = strpos(strtolower($headers_replace), '<ezmlm-header-name>'); |
$headers_replace = substr_replace($headers_replace, $this->header_en_francais[$val], $hnpos, 19); |
$hvpos = strpos(strtolower($headers_replace), '<ezmlm-header-value'); |
$headers_replace = $this->decode_iso ($headers_replace) ; |
switch ($val) { |
case 'date': |
$headers_replace = substr_replace($headers_replace, $this->date_francaise($mailDecode->headers[strtolower($val)]), $hvpos, 20); |
break; |
case 'from': |
if ($mailDecode->headers[strtolower($val)] == '') $from = $mailDecode->headers['return-path'] ; |
else $from = $mailDecode->headers['from']; |
$headers_replace = substr_replace($headers_replace, $this->protect_email($this->decode_iso($from)), $hvpos, 20); |
//$headers_replace = htmlspecialchars($headers_replace); |
break; |
default: |
$headers_replace = substr_replace($headers_replace, $this->protect_email($this->decode_iso($mailDecode->headers[strtolower($val)])), $hvpos, 20); |
} |
} |
return substr_replace($this->msgtmpl_entete, $headers_replace, $startpos, (($endpos + 16) - $startpos)); |
} |
function parse_template(&$mailDecode, $numero_mail, $numero_mois, $num_part = '') { |
static $profondeur = array(); |
if ($num_part != '') array_push ($profondeur, $num_part) ; |
$corps = '' ; |
if ($mailDecode->ctype_primary == 'multipart') { |
include_once PROJET_CHEMIN_CLASSES.'type_fichier_mime.class.php' ; |
for ($i = 0; $i < count($mailDecode->parts); $i++) { |
switch ($mailDecode->parts[$i]->ctype_secondary) { |
case 'plain' : |
if ($mailDecode->parts[$i]->headers['content-transfer-encoding'] == '8bit') { |
$corps .= $this->_cte_8bit($mailDecode->parts[$i]->body); |
} else if ($mailDecode->parts[$i]->headers['content-transfer-encoding'] == 'quoted-printable') { |
if ($mailDecode->parts[$i]->ctype_parameters['charset'] == 'UTF-8') { |
$corps .= utf8_decode($mailDecode->parts[$i]->body); |
} |
} |
break; |
case 'html' : $corps .= trim(strip_tags ($mailDecode->parts[$i]->body, '<br><p><a><style>')); |
break ; |
case 'mixed' : |
case 'rfc822' : |
case 'alternative' : |
case 'appledouble' : |
$this->parse_template($mailDecode->parts[$i], $numero_mail, $numero_mois, $i) ; |
break ; |
case 'applefile' : continue ; |
break ; |
default : |
if ($mailDecode->parts[$i]->ctype_secondary == 'octet-stream') { |
$nom_piece_jointe = $mailDecode->parts[$i]->ctype_parameters['name'] ; |
$tab = explode ('.', $nom_piece_jointe) ; |
$extension = $tab[count ($tab) - 1] ; |
$mimeType = type_fichier_mime::factory($extension); |
$mimeType->setCheminIcone(PROJET_CHEMIN_ICONES) ; |
} else { |
$nom_piece_jointe = isset ($mailDecode->parts[$i]->d_parameters['filename']) ? |
$mailDecode->parts[$i]->d_parameters['filename'] : $mailDecode->parts[$i]->ctype_parameters['name'] ; |
$mimeType = new type_fichier_mime( $mailDecode->parts[$i]->ctype_primary.'/'. |
$mailDecode->parts[$i]->ctype_secondary, PROJET_CHEMIN_ICONES) ; |
} |
$lien = PROJET_CHEMIN_APPLI.'fichier_attache.php?nom_liste='.$this->listname. |
'&actionargs[]='.$numero_mois. |
'&actionargs[]='.$numero_mail; |
if (count ($profondeur) > 0) { |
array_shift($profondeur) ; |
for ($j= 0; $j < count ($profondeur); $j++) $lien .= '&actionargs[]='.$profondeur[$j]; |
} |
$lien .= '&actionargs[]='.$i ; |
$corps .= '<a href="'.$lien.'">'; |
$tableau_type_image = array ('jpg', 'jpeg', 'pjpeg'); |
if (in_array ($mailDecode->parts[$i]->ctype_secondary, $tableau_type_image)) { |
$corps .= '<img src="'.$lien.'&min=1" alt="'.$nom_piece_jointe.'" /> ' ; |
$texte_lien = ''; |
} else { |
$corps .= '<img src="'.$mimeType->getCheminIcone().'" alt="'.$nom_piece_jointe.'" /> ' ; |
$texte_lien = $nom_piece_jointe; |
} |
$corps .= $texte_lien; |
$corps .= '</a><br />' ; |
break ; |
} |
} |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,TRUE), $this->msgtmpl); |
} else if ($mailDecode->ctype_primary == 'message') { |
$this->message_rendu .= "\n".'<div class="message">'.$this->parse_entete_mail($mailDecode->parts[0]); |
$corps .= $this->parse_template($mailDecode->parts[0], $numero_mail, $numero_mois, 0) ; |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl).'</div>'; |
} else if ($mailDecode->ctype_primary == 'application' || $mailDecode->ctype_primary == 'image'){ |
if ($mailDecode->ctype_secondary == 'applefile') return ; |
$mimeType = new type_fichier_mime( $mailDecode->ctype_primary.'/'.$mailDecode->ctype_secondary,PROJET_CHEMIN_ICONES) ; |
if ($mimeType->getIdType() != 12) { |
$corps .= '<a href="'.PROJET_CHEMIN_APPLI.'fichier_attache.php?nom_liste='.$this->listname.'&actionargs[]='. |
$numero_mois.'&actionargs[]='. |
$numero_mail.'&actionargs[]='.$i.'">'. |
'<img src="'.$mimeType->getCheminIcone().'" alt="'.$mailDecode->ctype_parameters['name'].'" /> ' ; |
$corps .= $mailDecode->ctype_parameters['name'].'</a><br />' ; |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($corps,true), $this->msgtmpl); |
} |
} else { |
if (preg_match('/html/i', $mailDecode->ctype_secondary)) { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', $this->cleanup_body($mailDecode->body,TRUE), $this->msgtmpl); |
} else { |
if (isset ($mailDecode->ctype_parameters['charset']) && $mailDecode->ctype_parameters['charset'] == 'UTF-8') { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', '<pre>' . utf8_decode($this->cleanup_body($mailDecode->body,TRUE)) . '</pre>', $this->msgtmpl); |
} else { |
$this->message_rendu .= preg_replace('/<ezmlm-body>/i', '<pre>' . $this->cleanup_body($mailDecode->body,TRUE) . '</pre>', $this->msgtmpl); |
} |
} |
} |
array_pop ($profondeur); |
} |
function ezmlm_msgdisplay() { |
$this->ezmlm_php(); |
if (($this->msgtemplate != "") and (is_file($this->msgtemplate))) { |
$fd = fopen($this->msgtemplate, "r"); |
while (!feof($fd)) { $this->msgtmpl .= fgets($fd,4096); } |
fclose($fd); |
} else { |
$this->msgtmpl = '<pre> |
<ezmlm-body> |
</pre> |
'; |
} |
$this->msgtmpl_entete = '<dl><ezmlm-headers> |
<dt><ezmlm-header-name> :</dt> |
<dd><ezmlm-header-value></dd> |
</ezmlm-headers> |
</dl>' ; |
} |
// _cte_8bit: decode a content transfer encoding of 8bit |
// NOTE: this function is a little bit special. Since the end result will be displayed in |
// a web browser _cte_8bit decodes ASCII characters > 127 (the US-ASCII table) into the |
// html ordinal equivilant, it also ensures that the messages content-type is changed |
// to include text/html if it changes anything... |
function _cte_8bit($data,$simple = FALSE) { |
if ($simple) { return $data; } |
$changed = FALSE; |
$out = ''; |
$chars = preg_split('//',$data); |
while (list($key,$val) = each($chars)) { |
if (ord($val) > 127) { $out .= '&#' . ord($val) . ';'; $changed = TRUE; } |
else { $out .= $val; } |
} |
if ($changed) { $this->headers['content-type'][1] = 'text/html'; } |
return $out; |
} |
} |
/trunk/classes/ezmlm-php-2.0/ezmlm-parser.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: ezmlm-parser.php,v 1.5 2008-11-19 09:28:46 aperonnet Exp $ |
// CVS : $Id: ezmlm-parser.php,v 1.3 2007/04/19 15:34:35 neiluj Exp $ |
/** |
* Application projet |
* |
29,7 → 29,7 |
//Auteur original : ?? recupere dans ezmlm-php |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.5 $ |
*@version $Revision: 1.3 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
38,7 → 38,7 |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
// $Id: ezmlm-parser.php,v 1.5 2008-11-19 09:28:46 aperonnet Exp $ |
// $Id: ezmlm-parser.php,v 1.3 2007/04/19 15:34:35 neiluj Exp $ |
// |
require_once("ezmlm.php"); |
87,10 → 87,17 |
$repertoire_archive = opendir($this->listdir . "/archive/"); |
$repertoire_message = array() ; |
$dernier_repertoire = 0 ; |
while (false !== ($item = readdir($repertoire_archive))) { |
// $item contient les noms des repertoires |
// on ne garde que ceux qui sont des chiffres |
$numArchive = $this->getNumArchive(); |
$dernier_repertoire = floor($numArchive / 100); |
if (preg_match('/[0-9]+/', $item)) { |
// on ouvre le fichier d index de chaque repertoire |
if ((int) $item > $dernier_repertoire) $dernier_repertoire = (int) $item; |
} |
} |
$tableau_message = array() ; |
$compteur_message = 0 ; |
$fichier_index = fopen ($this->listdir.'/archive/'.$dernier_repertoire.'/index', 'r') ; |
169,7 → 176,7 |
return $this->parse($data,$simple); |
} |
// parse_file_headers - ouvre un fichier et analyse les entête |
// parse_file_headers - ouvre un fichier et analyse les ent�tes |
function parse_file_headers($file,$simple = FALSE) { |
if (!is_file($file)) { |
if (is_file($this->listdir . "/" . $file)) { $file = $this->listdir . "/" . $file; } |
243,8 → 250,8 |
} |
} |
// ajout alex |
// pour supprimer le problème des ISO... |
// a déplacer ailleur, et appelé avant affichage |
// pour supprimer le probl�me des ISO... |
// a d�placer ailleur, et appel� avant affichage |
if (preg_match ('/windows-[0-9][0-9][0-9][0-9]/', $this->headers['subject'], $nombre)) { |
$reg_exp = $nombre[0] ; |
353,8 → 360,8 |
function _get_parts($data,$boundary) { |
$inpart = -1; |
$lines = preg_split('/\n/', $data); |
// La première partie contient l'avertissement pour les client mail ne supportant pas |
// multipart, elle est stocké dans parts[-1] |
// La premi�re partie contient l'avertissement pour les client mail ne supportant pas |
// multipart, elle est stock� dans parts[-1] |
while(list($key,$val) = each($lines)) { |
if ($val == "--" . $boundary) { $inpart++; continue; } // start of a part |
else if ($val == "--" . $boundary . "--") { break; } // the end of the last part |
361,7 → 368,7 |
else { $parts[$inpart] .= $val . "\n"; } |
} |
for ($i = 0; $i < count($parts) - 1; $i++) { // On saute la première partie |
for ($i = 0; $i < count($parts) - 1; $i++) { // On saute la premi�re partie |
$part[$i] = new ezmlm_parser(); |
$part[$i]->parse($parts[$i]); |
$this->parts[$i] = $part[$i]; |
/trunk/classes/HTML_formulaireProjet.class.php |
---|
1,175 → 1,175 |
<?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: HTML_formulaireProjet.class.php,v 1.8 2008-08-25 15:15:09 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe HTML_formulaireProjet |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.8 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** Inclure le fichier de langue pour utiliser cette classe de façon autonome. */ |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm.php' ; |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/checkbox.php' ; |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/select.php' ; |
/** |
* class HTML_formulaireProjet |
* Cette classe représente un formulaire pour saisir un projet ou le modifier. |
*/ |
class HTML_formulaireProjet extends HTML_QuickForm |
{ |
/** |
* Constructeur |
* |
* @param string formName Le nom du formulaire. |
* @param string method Soit get soit post, voir le protocole HTTP |
* @param string action L'action du formulaire. |
* @param string target La cible du formulaire. |
* @param Array attributes Des attributs supplémentaires pour la balise <form> |
* @param bool trackSubmit Pour repérer si la formulaire a été soumis. |
* @return void |
* @access public |
*/ |
function HTML_formulaireProjet( $formName = "", $method = "post", $action = "", $target = "_self", $attributes = "", $trackSubmit = false ) |
{ |
HTML_QuickForm::HTML_QuickForm($formName, $method, $action, $target, $attributes, $trackSubmit) ; |
} // end of member function HTML_formulaireProjet |
/** |
* Renvoie le code HTML du formulaire. |
* |
* @return string |
* @access public |
*/ |
function toHTML( ) |
{ |
$res = HTML_QuickForm::toHTML() ; |
return $res ; |
} // end of member function toHTML |
/** |
* Ajoute les champs nécessaire au formulaire. |
* |
* @return void |
* @access public |
*/ |
function construitFormulaire(&$tableau_projet, $tableau_type = '', $tableau_theme = '') |
{ |
$this->addElement ('text', 'projet_titre', PROJET_TITRE, array ('class' => 'projet_titre', 'maxlength' => 255, 'size' => '80')) ; |
$this->addRule ('projet_titre', PROJET_ALERTE_TITRE, 'required', '', 'client') ; |
if ($tableau_type != '') { |
$select = new HTML_QuickForm_select ('projet_type', PROJET_TYPE, $tableau_type, array ('class' => 'projet_type')) ; |
$this->addElement($select) ; |
unset ($select) ; |
} |
/* impossible de faire fonctionner dojo Editor !!! |
* |
GEN_stockerStyleExterne('tundra', 'api/js/dojo1.0/dijit/themes/tundra/tundra.css'); |
GEN_stockerStyleExterne('dojo', 'api/js/dojo1.0/dojo/resources/dojo.css'); |
GEN_AttributsBody('class', 'tundra'); |
GEN_stockerFichierScript('dojo', 'api/js/dojo1.0/dojo/dojo.js', |
'text/javascript', |
array ('djConfig' => 'parseOnLoad: true, isDebug: true')); |
GEN_stockerFichierScript('dojo.editor', 'api/js/dojo1.0/dijit/Editor.js', 'text/javascript'); |
GEN_stockerCodeScript('dojo.config.allowXdRichTextSave = true;'); |
*/ |
$this->addElement ('textarea', 'projet_resume', PROJET_RESUME, array('class'=>'projet_resume', 'rows'=>"5", 'cols'=>'80', |
'width'=>"200", /*'dojoType' => 'dijit.Editor',*/ 'id' => 'resume_editeur')) ; |
$this->addElement ('textarea', 'projet_description', PROJET_DESCRIPTION, |
array('class'=>"projet_resume", 'rows'=>"20", 'cols'=>'80'/*, 'dojoType' => 'dijit.Editor'*/)) ; |
$this->addElement ('text', 'projet_espace_internet', PROJET_ESPACE_INTERNET, array ('class' => 'projet_espace_internet', 'size' => '80')) ; |
// on fait un groupe avec les boutons radio pour les mettres sur la même ligne |
$radio[] = & HTML_QuickForm::createElement('radio', 'projet_moderation', '0', PROJET_NON_MODERE, '0') ; |
$radio[] = & HTML_QuickForm::createElement('radio', 'projet_moderation', '1', PROJET_MODERE, '1'); |
$this->addGroup($radio, null, PROJET_INSCRIPTION, ' '); |
/** Theme du projet ajout 05/2008 */ |
//var_dump ($tableau_theme); |
if ($tableau_theme != '') { |
foreach ($tableau_theme as $cle => $theme) { |
$checkbox[$cle] = new HTML_QuickForm_checkbox('projet_theme['.$cle.']', '', $theme); |
$this->addElement($checkbox[$cle]); |
} |
} |
$label_projet = array() ; |
$id_projet = array() ; |
foreach ($tableau_projet as $projet) { |
$label_projet[] = $projet->getTitre() ; |
$id_projet[] = $projet->getId() ; |
} |
if (PROJET_UTILISE_HIERARCHIE) { |
$select = new HTML_QuickForm_select ('projet_asso', PROJET_PERE, $label_projet, array ('class' => 'projet_asso')) ; |
$this->addElement($select) ; |
unset ($select) ; |
} |
$this->applyFilter(array('projet_resume', 'projet_description'), 'addslashes') ; |
$this->setRequiredNote('<span style="color: #ff0000">*</span>'.PROJET_CHAMPS_REQUIS) ; |
$url_annuler = new Net_URL($this->getAttribute('action')) ; |
$url_annuler->removeQueryString(PROJET_VARIABLE_ACTION) ; |
// on fait un groupe avec les boutons pour les mettres sur la même ligne |
$buttons[] = &HTML_QuickForm::createElement('link', 'annuler', PROJET_FICHIER_ANNULER, |
preg_replace ("/&/", "&", $url_annuler->getURL()), PROJET_FICHIER_ANNULER); |
$buttons[] = &HTML_QuickForm::createElement('submit', 'valider', PROJET_FICHIER_VALIDER); |
$this->addGroup($buttons, null, null, ' '); |
} // end of member function _construitFormulaire |
} |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
<?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: HTML_formulaireProjet.class.php,v 1.7 2007-11-21 09:42:50 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe HTML_formulaireProjet |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.7 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** Inclure le fichier de langue pour utiliser cette classe de façon autonome. */ |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm.php' ; |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/checkbox.php' ; |
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/select.php' ; |
/** |
* class HTML_formulaireProjet |
* Cette classe représente un formulaire pour saisir un projet ou le modifier. |
*/ |
class HTML_formulaireProjet extends HTML_QuickForm |
{ |
/** |
* Constructeur |
* |
* @param string formName Le nom du formulaire. |
* @param string method Soit get soit post, voir le protocole HTTP |
* @param string action L'action du formulaire. |
* @param string target La cible du formulaire. |
* @param Array attributes Des attributs supplémentaires pour la balise <form> |
* @param bool trackSubmit Pour repérer si la formulaire a été soumis. |
* @return void |
* @access public |
*/ |
function HTML_formulaireProjet( $formName = "", $method = "post", $action = "", $target = "_self", $attributes = "", $trackSubmit = false ) |
{ |
HTML_QuickForm::HTML_QuickForm($formName, $method, $action, $target, $attributes, $trackSubmit) ; |
} // end of member function HTML_formulaireProjet |
/** |
* Renvoie le code HTML du formulaire. |
* |
* @return string |
* @access public |
*/ |
function toHTML( ) |
{ |
$res = HTML_QuickForm::toHTML() ; |
return $res ; |
} // end of member function toHTML |
/** |
* Ajoute les champs nécessaire au formulaire. |
* |
* @return void |
* @access public |
*/ |
function construitFormulaire(&$tableau_projet, $tableau_type = '', $tableau_theme = '') |
{ |
$this->addElement ('text', 'projet_titre', PROJET_TITRE, array ('class' => 'projet_titre', 'maxlength' => 255, 'size' => '80')) ; |
$this->addRule ('projet_titre', PROJET_ALERTE_TITRE, 'required', '', 'client') ; |
if ($tableau_type != '') { |
$select = new HTML_QuickForm_select ('projet_type', PROJET_TYPE, $tableau_type, array ('class' => 'projet_type')) ; |
$this->addElement($select) ; |
unset ($select) ; |
} |
/* impossible de faire fonctionner dojo Editor !!! |
* |
GEN_stockerStyleExterne('tundra', 'api/js/dojo1.0/dijit/themes/tundra/tundra.css'); |
GEN_stockerStyleExterne('dojo', 'api/js/dojo1.0/dojo/resources/dojo.css'); |
GEN_AttributsBody('class', 'tundra'); |
GEN_stockerFichierScript('dojo', 'api/js/dojo1.0/dojo/dojo.js', |
'text/javascript', |
array ('djConfig' => 'parseOnLoad: true, isDebug: true')); |
GEN_stockerFichierScript('dojo.editor', 'api/js/dojo1.0/dijit/Editor.js', 'text/javascript'); |
GEN_stockerCodeScript('dojo.config.allowXdRichTextSave = true;'); |
*/ |
$this->addElement ('textarea', 'projet_resume', PROJET_RESUME, array('class'=>'projet_resume', 'rows'=>"5", 'cols'=>'80', |
'width'=>"200", /*'dojoType' => 'dijit.Editor',*/ 'id' => 'resume_editeur')) ; |
$this->addElement ('textarea', 'projet_description', PROJET_DESCRIPTION, |
array('class'=>"projet_resume", 'rows'=>"20", 'cols'=>'80'/*, 'dojoType' => 'dijit.Editor'*/)) ; |
$this->addElement ('text', 'projet_espace_internet', PROJET_ESPACE_INTERNET, array ('class' => 'projet_espace_internet', 'size' => '80')) ; |
// on fait un groupe avec les boutons radio pour les mettres sur la même ligne |
$radio[] = & HTML_QuickForm::createElement('radio', 'projet_moderation', '0', PROJET_NON_MODERE, '0') ; |
$radio[] = & HTML_QuickForm::createElement('radio', 'projet_moderation', '1', PROJET_MODERE, '1'); |
$this->addGroup($radio, null, PROJET_INSCRIPTION, ' '); |
/** Theme du projet ajout 05/2008 */ |
//var_dump ($tableau_theme); |
if ($tableau_theme != '') { |
foreach ($tableau_theme as $cle => $theme) { |
$checkbox[$cle] = new HTML_QuickForm_checkbox('projet_theme['.$cle.']', '', $theme); |
$this->addElement($checkbox[$cle]); |
} |
} |
$label_projet = array() ; |
$id_projet = array() ; |
foreach ($tableau_projet as $projet) { |
$label_projet[] = $projet->getTitre() ; |
$id_projet[] = $projet->getId() ; |
} |
if (PROJET_UTILISE_HIERARCHIE) { |
$select = new HTML_QuickForm_select ('projet_asso', PROJET_PERE, $label_projet, array ('class' => 'projet_asso')) ; |
$this->addElement($select) ; |
unset ($select) ; |
} |
$this->applyFilter(array('projet_resume', 'projet_description'), 'addslashes') ; |
$this->setRequiredNote('<span style="color: #ff0000">*</span>'.PROJET_CHAMPS_REQUIS) ; |
$url_annuler = new Net_URL($this->getAttribute('action')) ; |
$url_annuler->removeQueryString(PROJET_VARIABLE_ACTION) ; |
// on fait un groupe avec les boutons pour les mettres sur la même ligne |
$buttons[] = &HTML_QuickForm::createElement('link', 'annuler', PROJET_FICHIER_ANNULER, |
preg_replace ("/&/", "&", $url_annuler->getURL()), PROJET_FICHIER_ANNULER); |
$buttons[] = &HTML_QuickForm::createElement('submit', 'valider', PROJET_FICHIER_VALIDER); |
$this->addGroup($buttons, null, null, ' '); |
} // end of member function _construitFormulaire |
} |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log$ |
* |
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |
/trunk/classes/document.class.php |
---|
1,665 → 1,675 |
<?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: document.class.php,v 1.10 2008-08-26 12:41:10 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe document |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.10 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
include_once PROJET_CHEMIN_CLASSES.'fichier.class.php' ; |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class document |
* Représente un document associé à un projet. C'est à dire un fichier |
* téléchargeable disposant en plus d'une visibilité, d'un nom long, d'une |
* description et d'une url. |
*/ |
class document extends fichier |
{ |
/*** Attributes: ***/ |
/** |
* Description qui apparaitra à l'écran. |
* @access private |
*/ |
var $_description; |
/** |
* Date de dernière mise à jour des attributs du fichier. |
* @access private |
*/ |
var $_date_mise_a_jour; |
/** |
* Soit public, soit privé. |
* @access private |
*/ |
var $_visibilite; |
/** |
* Le nom du fichier tel qu'il apparaitra à l'écran. |
* @access private |
*/ |
var $_nom_long; |
/** |
* Un objet PEAR:DB |
* @access private |
*/ |
var $_db; |
/** |
* L'identifiant du document dans la table projet_document. |
* @access private |
*/ |
var $_id; |
/** |
* |
* @access private |
*/ |
var $_chemin_icone; |
/** |
* L'identifiant du père, peut être à NULL |
* @access private |
*/ |
var $_id_pere; |
/** |
* L'identifiant du propriétaire. Provient d'un annuaire. Peut être à NULL. |
* @access private |
*/ |
var $_id_proprietaire; |
/** |
* L'identifiant du projet auquel appartient le document. Peut être à NULL. |
* @access private |
*/ |
var $_id_projet; |
/** |
* Le chemin du fichier, depuis le répertoire du projet |
* |
*/ |
var $_pd_lien ; |
var $nom_fichier ; |
/** |
* |
* |
* @param int id_document L'identifiant du document dans la base. |
* @param int objetDB un objet PEAR:DB |
* @return void |
* @access public |
*/ |
function document( $id_document = "", &$objetDB, $chemin = '', $chemin_icones = '') |
{ |
if (is_object($objetDB)) { |
$GLOBALS['projet_db'] = $objetDB; |
} |
$this->_chemin_icone = $chemin_icones ; |
if ($id_document != "") { |
$requete = "select * from projet_documents where pd_id=".$GLOBALS['projet_db']->escapeSimple($id_document) ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
if ($resultat->numRows()>0) { |
$this->nom_fichier = $ligne->pd_lien; |
$this->_id_projet = $ligne->pd_ce_projet; |
$this->_id = $ligne->pd_id ; |
fichier::fichier($chemin.$this->getChemin(), $GLOBALS['projet_db']) ; |
if (is_object ($this->_type_mime)) $this->_type_mime->setCheminIcone ($chemin_icones) ; |
$this->_id_proprietaire = $ligne->pd_ce_utilisateur ; |
$this->_nom_long = $ligne->pd_nom ; |
$this->_visibilite = $ligne->pd_visibilite ; |
$this->_date_mise_a_jour = $ligne->pd_date_de_mise_a_jour ; |
$this->_description = $ligne->pd_description ; |
$this->_pd_lien = $ligne->pd_lien; |
if ($this->_isRacine($ligne->pd_pere)) { |
$this->_id_pere = 0 ; |
} else { |
$this->_id_pere = $ligne->pd_pere ; |
} |
} |
} |
} // end of member function document |
/** |
* |
* |
* @param int id_document L'identifiant du document dans la base. |
* @param int objetDB Un objet PEAR:DB |
* @return document |
* @access public |
*/ |
function __construct( $id_document = "", &$objetDB, $chemin = '', $chemin_icones = '' ) |
{ |
$this->document($id_document, $objetDB, $chemin, $chemin_icones); |
} // end of member function __construct |
/** |
* Renvoie le nom long du fichier. |
* |
* @return string |
* @access public |
*/ |
function getNomLong( ) |
{ |
return $this->_nom_long ; |
} // end of member function getNomLong |
/** |
* Renvoie la visibilité du document, soit "public" soit "prive" |
* |
* @return visibilite |
* @access public |
*/ |
function getVisibilite( ) |
{ |
return $this->_visibilite ; |
} // end of member function getVisibilite |
/** |
* Renvoie la description du document, sous forme de chaine. |
* |
* @return string |
* @access public |
*/ |
function getDescription( ) |
{ |
return $this->_description ; |
} // end of member function getDescription |
/** |
* Renvoie la date de création ou de mise à jour du fichier. |
* |
* @return date |
* @access public |
*/ |
function getDateMiseAJour( ) |
{ |
return $this->_date_mise_a_jour ; |
} // end of member function getDateMiseAJour |
/** |
* Renvoie l'identifiant d'un document. |
* |
* @return int |
* @access public |
*/ |
function getIdDocument( ) |
{ |
return $this->_id ; |
} // end of member function getIdDocument |
/** |
* Renvoie le chemin de l'icone du fichier. Fait un appel à type_fichier_mime. |
* |
* @return string |
* @access public |
*/ |
function getCheminIcone() |
{ |
if ($this->isRepertoire()) { |
return $this->_chemin_icone."repertoire.gif" ; |
} else { |
if (is_object ($this->_type_mime)) return $this->_type_mime->getCheminIcone() ; |
} |
} // end of member function getCheminIcone |
/** |
* Permet de récupérer le nom du répertoire racine associé à un projet. |
* |
* @param int id_projet L'identifiant du projet dont on veux récupérer le répertoire racine. |
* @param DB objetDB Un objet PEAR:DB |
* @return string |
* @static |
* @access public |
*/ |
function getNomRepertoireProjet( $id_projet , &$objetDB) |
{ |
// Dans la table projet_documents, pour les répertoires racines, pd_pere = null |
$requete = "select pd_nom from projet_documents where pd_ce_projet=".$GLOBALS['projet_db']->escapeSimple($id_projet)." and pd_pere is null" ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
return $ligne->pd_nom ; |
} // end of member function getNomRepertoireProjet |
/** |
* Renvoie true si le document passé en paramètre est le répertoire racine. |
* |
* @param int id_document L'identifiant du document dont on veut savoir si c'est la racine. |
* @return bool |
* @access public |
*/ |
function _isRacine( $id_document ) |
{ |
if ($id_document) { |
$requete = "select pd_pere from projet_documents where pd_id=".$GLOBALS['projet_db']->escapeSimple($id_document) ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; |
if ($resultat->numRows() >0) { |
if ($ligne->pd_pere == null){ |
return true ; |
} |
} |
} |
return false ; |
} // end of member function _isRacine |
/** |
* Renvoie le chemin d'un fichier ou d'un répertoire. Contrairement à la classe |
* mère, cette méthode renvoie une URL projet et non pas un fichier. |
* |
* @return string |
* @access public |
*/ |
function getChemin($prefixe = '') |
{ |
$chemin_repertoire_entre_racine_et_fichier = ''; |
include_once PROJET_CHEMIN_CLASSES.'projet.class.php'; |
$projet = new projet ($GLOBALS['projet_db'], $this->_id_projet); |
// l arborescence des repertoires |
$tableau_navigation = $this->getPath($this->_id) ; |
if (is_array ($tableau_navigation))$tableau_navigation = array_reverse($tableau_navigation); |
for ($i = 0; $i < count ($tableau_navigation); $i++) { |
$chemin_repertoire_entre_racine_et_fichier.= $tableau_navigation[$i]."/"; |
} |
return $projet->getNomRepertoire().'/'.$chemin_repertoire_entre_racine_et_fichier.$this->nom_fichier ; |
} |
/** |
* Renvoie pour le repertoire ou le fichier courant, les identifiants et les noms de tous les |
* répertoires père jusqu'à la racine. 0 => ['id'], ['nom'] 1 => [id'], ['nom'] etc. |
* En commençant par la racine et en descendant. Pour la racine id vaut "" et nom |
* vaut "". |
* |
* @param int id_repertoire L'identifiant d'un répertoire. |
* @return Array |
* @access public |
*/ |
function getCheminIdRepertoire( $id_doc, &$objetDB ) |
{ |
if ($id_doc == "") $id_doc = 0; |
// on commence par rechercher le répertoire père, dans la base de donnée |
$requete = 'select pd_pere, pd_nom, pd_id, pd_ce_type from projet_documents where pd_id='.$GLOBALS['projet_db']->escapeSimple($id_doc) ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
$chemin_rep_id_nom = array() ; |
if ($resultat->numRows()>0) { |
if ($ligne->pd_pere == 0) { |
return array ($ligne->pd_id); |
} |
array_push ($chemin_rep_id_nom, $ligne->pd_id) ; |
$tab = document::getCheminIdRepertoire($ligne->pd_pere, $objetDB) ; |
$chemin_rep_id_nom = array_merge ($tab, $chemin_rep_id_nom) ; |
} |
return ($chemin_rep_id_nom); |
} |
function getPath( $id_doc) |
{ |
if ($id_doc == "") $id_doc = 0; |
// on commence par rechercher le répertoire père, dans la base de donnée |
$requete = 'select pd_pere, pd_nom, pd_id, pd_ce_type from projet_documents where pd_id='.$GLOBALS['projet_db']->escapeSimple($id_doc) ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
$chemin_rep_id_nom = array() ; |
if ($resultat->numRows()>0 && $ligne->pd_pere != 0 && $ligne->pd_pere != $ligne->pd_id) { |
array_push ($chemin_rep_id_nom, $ligne->pd_pere) ; |
// Récursion sur le répertoires ou fichiers fils |
$chemin_rep_id_nom = array_merge ($chemin_rep_id_nom, document::getPath($ligne->pd_pere) ); |
} |
return $chemin_rep_id_nom; |
} |
/** |
* Calcule le chemin vers le fichier ou le répertoire uploadé |
* renvoie un chaine de la forme dir1/dir2/fichier.ext |
* En prenant comme racine le répertoire du projet, exclu. |
* @return string Le chemin |
*/ |
function calculeCheminUploaded ($radical) { |
if (isset($_FILES['fichier']['name'])) { |
$extension = preg_replace("/^([^\.]+)\.(\w+$)/", "\\2", $_FILES['fichier']['name']) ; |
} |
if ($this->_id_pere != '') { |
// On appelle la méthode getCheminIdRepertoire qui renvoie un tableau avec la liste |
// des répertoires jusqu'à la racine, on enlève la racine ($i = 0) et on concatène |
// toutes les entrées pour obtenir le chemin jusqu'au répertoire courant |
$chemin_repertoire_entre_racine_et_repertoire_a_cree = '' ; |
$doc_pere = new document ($this->_id_pere, $GLOBALS['projet_db']); |
return $doc_pere->getChemin(); |
$tableau_navigation = $this->getPath($this->_id_pere) ; |
for ($i = 0; $i < count ($tableau_navigation); $i++) $chemin_repertoire_entre_racine_et_repertoire_a_cree.= $tableau_navigation[$i]."/"; |
$chemin = $chemin_repertoire_entre_racine_et_repertoire_a_cree ; |
} else { |
// Si l'on est à la racine du projet, le chemin vide |
return $radical ; |
} |
return $chemin ; |
} |
/** |
* Enregistre une ligne dans la table projet_document |
* Le tableau de valeur doit contenir les éléments suivants 'document_nom','document_description','document_visibilite','fichier' |
* |
* @param Array tableau_de_valeur Le tableau de valeur a insérer dans la base avec pour clé les noms des éléments |
* @access public |
* @return void |
*/ |
function enregistrerSQL ($valeur, $chemin) { |
// On teste si on a affaire à un répertoire ou un fichier |
if (isset ($_FILES['fichier']['name'])) { |
// On tente de déterminer le type du fichier à partir de son nom dans $valeur['$fichier'] |
$tableau_nom = explode (".", $_FILES['fichier']['name']) ; |
// On prend le dernier élément du tableau, si c'est un tableau |
if (is_array($tableau_nom)) { |
$extension = array_pop($tableau_nom) ; |
$type = type_fichier_mime::factory($extension) ; |
$id_extension = $type->getIdType() ; |
} else { |
$id_extension = 12 ; |
} |
$pd_lien = $chemin ; |
} else { // Le cas ou on a affaire à un répertoire |
$id_extension = 0 ; |
// Le nom du répertoire est son identifiant avec un slash à la fin |
$pd_lien = $chemin."/" ; |
if ($this->_id_pere != '') { |
// On appelle la méthode getCheminIdRepertoire qui renvoie un tableau avec la liste |
// des répertoires jusqu'à la racine, on enlève la racine ($i = 0) et on concatène |
// toutes les entrées pour obtenir le chemin jusqu'au répertoire courant |
$chemin_repertoire_entre_racine_et_repertoire_a_cree = '' ; |
$tableau_navigation = $this->getCheminIdRepertoire($this->_id_pere, $GLOBALS['projet_db']) ; |
for ($i = 0; $i < count ($tableau_navigation); $i+=2) $chemin_repertoire_entre_racine_et_repertoire_a_cree.= $tableau_navigation[$i]."/"; |
$pd_lien .= $chemin_repertoire_entre_racine_et_repertoire_a_cree ; |
} |
//$pd_lien .= SQL_obtenirNouveauId($GLOBALS['projet_db'], 'projet_documents', 'pd_id')."/" ; |
$pd_lien = SQL_obtenirNouveauId($GLOBALS['projet_db'], 'projet_documents', 'pd_id')."/" ; |
} |
$id = SQL_obtenirNouveauId($GLOBALS['projet_db'], 'projet_documents', 'pd_id') ; |
$requete = "insert into projet_documents set pd_id=".$id ; |
$requete .= ", pd_nom=\"".$valeur['document_nom']."\", pd_description=\"".$valeur['document_description']."\"". |
", pd_visibilite=\"".$valeur['document_visibilite']."\", pd_date_de_mise_a_jour=NOW(),". |
"pd_ce_projet=\"".$this->_id_projet."\", pd_ce_utilisateur=\"".$this->_id_proprietaire."\"". |
", pd_pere=\"$this->_id_pere\", pd_ce_type=\"$id_extension\", pd_lien=\"$pd_lien\"" ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$this->_id = $id ; |
return $pd_lien; |
} |
function genereNouveauNom ($radical, $ancien_nom, $id) { |
$extension = preg_replace("/^([^\.]+)\.(\w+$)/", "\\2", $ancien_nom) ; |
$nouveau_nom = $radical."_".$id.".".$extension ; |
return $nouveau_nom; |
} |
/** |
* Met à jour une ligne dans la table projet_document |
* Le tableau de valeur doit contenir les éléments suivants 'document_nom','document_description','document_visibilite','fichier' |
* |
* @param Array tableau_de_valeur Le tableau de valeur a insérer dans la base avec pour clé les noms des éléments |
* @access public |
* @return void |
*/ |
function majSQL ($valeur) { |
$requete = "update projet_documents set pd_nom=\"".$valeur['document_nom']."\", pd_description=\"".$valeur['document_description']."\"". |
", pd_visibilite=\"".$valeur['document_visibilite']."\", pd_date_de_mise_a_jour=NOW()". |
" where pd_id=".$GLOBALS['projet_db']->escapeSimple($this->_id); |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
return ; |
} |
/** Supprime les donnéexs du document dans la table projet_documents |
* |
* |
* @return true en cas de succès |
*/ |
function suppressionSQL () { |
$requete = 'delete from projet_documents where pd_id='.$GLOBALS['projet_db']->escapeSimple($this->_id) ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if ($GLOBALS['projet_db']->affectedRows()) return true ; |
return false ; |
} |
/** |
* Déplace un document au sein d'un même projet |
* |
* @param int repertoire_destination L'identifiant du répertoire destination. |
* @return bool |
* @access public |
*/ |
function deplace( $repertoire_destination, $repertoire_projet ) |
{ |
// On récupère les informations du répertoire cible |
if ($repertoire_destination != 0) { |
$repertoire_cible = new document ($repertoire_destination, $GLOBALS['projet_db']) ; |
$chemin_rep_cible = $repertoire_cible->getChemin(); |
} else { |
// Si le repertoire destination est la racine cad id =0 |
// on cree un document qui aura pour chemin le repertoire du projet |
include_once PROJET_CHEMIN_CLASSES.'projet.class.php'; |
$projet = new projet ($GLOBALS['projet_db'], $this->_id_projet); |
$chemin_rep_cible = $projet->getNomRepertoire().'/'; |
} |
$nom_fichier = $this->_pd_lien ; |
$requete = 'update projet_documents set pd_pere='.$GLOBALS['projet_db']->escapeSimple($repertoire_destination).' where pd_id='.$GLOBALS['projet_db']->escapeSimple($this->_id) ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
echo ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
return false ; |
} |
//echo $this->_chemin.'<br>'.PROJET_CHEMIN_FICHIER.$chemin_rep_cible.$nom_fichier; |
return fichier::deplace ($this->_chemin, PROJET_CHEMIN_FICHIER.$chemin_rep_cible.$nom_fichier) ; |
} // end of member function deplace |
/** |
* Pour modifier l'identifiant du projet auquel appartient un document. |
* |
* @param int id_projet L'identifiant du projet. |
* @return void |
* @access public |
*/ |
function setIdProjet( $id_projet ) |
{ |
$this->_id_projet = $id_projet ; |
} // end of member function setIdProjet |
/** |
* Permet de modifier l'identifiant du propietaire d'un projet. |
* |
* @param int id_proprietaire L'identifiant du proprietaire d'un document. |
* @return void |
* @access public |
*/ |
function setIdProprietaire( $id_proprietaire ) |
{ |
$this->_id_proprietaire = $id_proprietaire ; |
} // end of member function setIdProprietaire |
/** |
* Permet de modifier l'identifiant du répertoire d'un document. |
* |
* @param int id_repertoire L'identifiant du repertoire d'un document. |
* @return void |
* @access public |
*/ |
function setIdRepertoire( $id_repertoire ) |
{ |
$this->_id_pere = $id_repertoire; |
} // end of member function setIdRepertoire |
/** |
* initAttributes sets all document attributes to its default value make |
* sure to call this method within your class constructor |
*/ |
function initAttributes( ) |
{ |
$this->_visibilite = "public"; |
} |
/** |
* Renvoie les derniers documents de l'ensemble des projets. |
* |
* @param int nombre Le nombre de document à renvoyer |
* @return Array |
* @static |
* @access public |
*/ |
function getDocumentsRecents( $nombre = 10, &$objetDB, $chemin, $chemin_icones, $id_projet = '', $visible = true) |
{ |
// on recherche les documents, hors repertoire |
$requete = 'select pd_id from projet_documents where pd_ce_type<>0 '; |
if ($id_projet != '') $requete .= ' and pd_ce_projet='.$GLOBALS['projet_db']->escapeSimple($id_projet).' '; |
if (!$visible) $requete .= ' and pd_visibilite="public" '; |
$requete .= 'order by pd_date_de_mise_a_jour desc limit 0,'.$nombre ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$tableau_document = array() ; |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_document, new document ($ligne->pd_id, $objetDB, $chemin, $chemin_icones)) ; |
} |
return $tableau_document ; |
} // end of member function getDocumentsRecents |
/** |
* Renvoie les documents du projet passe en parametre sous forme d arbre d objet document |
* |
* @param int l identifiant du projet |
* @return Array |
* @static |
* @access public |
*/ |
function getArbreDocument($id_projet, $objetDB = '') { |
$requete = 'select pd_id, pd_nom, pd_ce_type, pd_pere from projet_documents where pd_ce_projet='.$GLOBALS['projet_db']->escapeSimple($id_projet); |
$resultat = $GLOBALS['projet_db']->getAll($requete, null, DB_FETCHMODE_OBJECT); |
if (DB::isError ($resultat)) { |
return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
return $resultat; |
} |
/** |
* Renvoie la taille du document formatee avec une unite adapte |
* |
* @return string La taille formate |
* @access public |
*/ |
function getTailleFormatee($precision = 1) { |
$taille = $this->getTaille(); |
if ($taille > 1000000) { |
$diviseur = 1000000; |
$unite = 'Mo'; |
} else { |
$diviseur = 1000 ; |
$unite = 'Ko'; |
} |
return round ($taille / $diviseur, $precision).' '.$unite; |
} |
/** |
* Renvoie une liste de document, enfant du document courant |
* qui doit etre un repertoire bien sur |
* |
* @return mixed un tableau de document |
* @access public |
*/ |
function getDocumentsEnfant() { |
} |
} // end of document |
?> |
<?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: document.class.php,v 1.9 2008-08-25 15:18:10 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe document |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.9 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
include_once PROJET_CHEMIN_CLASSES.'fichier.class.php' ; |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class document |
* Représente un document associé à un projet. C'est à dire un fichier |
* téléchargeable disposant en plus d'une visibilité, d'un nom long, d'une |
* description et d'une url. |
*/ |
class document extends fichier |
{ |
/*** Attributes: ***/ |
/** |
* Description qui apparaitra à l'écran. |
* @access private |
*/ |
var $_description; |
/** |
* Date de dernière mise à jour des attributs du fichier. |
* @access private |
*/ |
var $_date_mise_a_jour; |
/** |
* Soit public, soit privé. |
* @access private |
*/ |
var $_visibilite; |
/** |
* Le nom du fichier tel qu'il apparaitra à l'écran. |
* @access private |
*/ |
var $_nom_long; |
/** |
* Un objet PEAR:DB |
* @access private |
*/ |
var $_db; |
/** |
* L'identifiant du document dans la table projet_document. |
* @access private |
*/ |
var $_id; |
/** |
* |
* @access private |
*/ |
var $_chemin_icone; |
/** |
* L'identifiant du père, peut être à NULL |
* @access private |
*/ |
var $_id_pere; |
/** |
* L'identifiant du propriétaire. Provient d'un annuaire. Peut être à NULL. |
* @access private |
*/ |
var $_id_proprietaire; |
/** |
* L'identifiant du projet auquel appartient le document. Peut être à NULL. |
* @access private |
*/ |
var $_id_projet; |
/** |
* Le chemin du fichier, depuis le répertoire du projet |
* |
*/ |
var $_pd_lien ; |
var $nom_fichier ; |
/** |
* |
* |
* @param int id_document L'identifiant du document dans la base. |
* @param int objetDB un objet PEAR:DB |
* @return void |
* @access public |
*/ |
function document( $id_document = "", &$objetDB, $chemin = '', $chemin_icones = '') |
{ |
if (is_object($objetDB)) { |
$GLOBALS['projet_db'] = $objetDB; |
} |
$this->_chemin_icone = $chemin_icones ; |
if ($id_document != "") { |
$requete = "select * from projet_documents where pd_id=".$GLOBALS['projet_db']->escapeSimple($id_document) ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
if ($resultat->numRows()>0) { |
$this->nom_fichier = $ligne->pd_lien; |
$this->_id_projet = $ligne->pd_ce_projet; |
$this->_id = $ligne->pd_id ; |
fichier::fichier($chemin.$this->getChemin(), $GLOBALS['projet_db']) ; |
if (is_object ($this->_type_mime)) $this->_type_mime->setCheminIcone ($chemin_icones) ; |
$this->_id_proprietaire = $ligne->pd_ce_utilisateur ; |
$this->_nom_long = $ligne->pd_nom ; |
$this->_visibilite = $ligne->pd_visibilite ; |
$this->_date_mise_a_jour = $ligne->pd_date_de_mise_a_jour ; |
$this->_description = $ligne->pd_description ; |
$this->_pd_lien = $ligne->pd_lien; |
if ($this->_isRacine($ligne->pd_pere)) { |
$this->_id_pere = 0 ; |
} else { |
$this->_id_pere = $ligne->pd_pere ; |
} |
} |
} |
} // end of member function document |
/** |
* |
* |
* @param int id_document L'identifiant du document dans la base. |
* @param int objetDB Un objet PEAR:DB |
* @return document |
* @access public |
*/ |
function __construct( $id_document = "", &$objetDB, $chemin = '', $chemin_icones = '' ) |
{ |
$this->document($id_document, $objetDB, $chemin, $chemin_icones); |
} // end of member function __construct |
/** |
* Renvoie le nom long du fichier. |
* |
* @return string |
* @access public |
*/ |
function getNomLong( ) |
{ |
return $this->_nom_long ; |
} // end of member function getNomLong |
/** |
* Renvoie la visibilité du document, soit "public" soit "prive" |
* |
* @return visibilite |
* @access public |
*/ |
function getVisibilite( ) |
{ |
return $this->_visibilite ; |
} // end of member function getVisibilite |
/** |
* Renvoie la description du document, sous forme de chaine. |
* |
* @return string |
* @access public |
*/ |
function getDescription( ) |
{ |
return $this->_description ; |
} // end of member function getDescription |
/** |
* Renvoie la date de création ou de mise à jour du fichier. |
* |
* @return date |
* @access public |
*/ |
function getDateMiseAJour( ) |
{ |
return $this->_date_mise_a_jour ; |
} // end of member function getDateMiseAJour |
/** |
* Renvoie l'identifiant d'un document. |
* |
* @return int |
* @access public |
*/ |
function getIdDocument( ) |
{ |
return $this->_id ; |
} // end of member function getIdDocument |
/** |
* Renvoie le chemin de l'icone du fichier. Fait un appel à type_fichier_mime. |
* |
* @return string |
* @access public |
*/ |
function getCheminIcone() |
{ |
if ($this->isRepertoire()) { |
return $this->_chemin_icone."repertoire.gif" ; |
} else { |
if (is_object ($this->_type_mime)) return $this->_type_mime->getCheminIcone() ; |
} |
} // end of member function getCheminIcone |
/** |
* Permet de récupérer le nom du répertoire racine associé à un projet. |
* |
* @param int id_projet L'identifiant du projet dont on veux récupérer le répertoire racine. |
* @param DB objetDB Un objet PEAR:DB |
* @return string |
* @static |
* @access public |
*/ |
function getNomRepertoireProjet( $id_projet , &$objetDB) |
{ |
// Dans la table projet_documents, pour les répertoires racines, pd_pere = null |
$requete = "select pd_nom from projet_documents where pd_ce_projet=".$GLOBALS['projet_db']->escapeSimple($id_projet)." and pd_pere is null" ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
return $ligne->pd_nom ; |
} // end of member function getNomRepertoireProjet |
/** |
* Renvoie true si le document passé en paramètre est le répertoire racine. |
* |
* @param int id_document L'identifiant du document dont on veut savoir si c'est la racine. |
* @return bool |
* @access public |
*/ |
function _isRacine( $id_document ) |
{ |
if ($id_document) { |
$requete = "select pd_pere from projet_documents where pd_id=".$GLOBALS['projet_db']->escapeSimple($id_document) ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; |
if ($resultat->numRows() >0) { |
if ($ligne->pd_pere == null){ |
return true ; |
} |
} |
} |
return false ; |
} // end of member function _isRacine |
/** |
* Renvoie le chemin d'un fichier ou d'un répertoire. Contrairement à la classe |
* mère, cette méthode renvoie une URL projet et non pas un fichier. |
* |
* @return string |
* @access public |
*/ |
function getChemin($prefixe = '') |
{ |
$chemin_repertoire_entre_racine_et_fichier = ''; |
include_once PROJET_CHEMIN_CLASSES.'projet.class.php'; |
$projet = new projet ($GLOBALS['projet_db'], $this->_id_projet); |
// l arborescence des repertoires |
$tableau_navigation = $this->getPath($this->_id) ; |
if (is_array ($tableau_navigation))$tableau_navigation = array_reverse($tableau_navigation); |
for ($i = 0; $i < count ($tableau_navigation); $i++) { |
$chemin_repertoire_entre_racine_et_fichier.= $tableau_navigation[$i]."/"; |
} |
return $projet->getNomRepertoire().'/'.$chemin_repertoire_entre_racine_et_fichier.$this->nom_fichier ; |
} |
/** |
* Renvoie pour le repertoire ou le fichier courant, les identifiants et les noms de tous les |
* répertoires père jusqu'à la racine. 0 => ['id'], ['nom'] 1 => [id'], ['nom'] etc. |
* En commençant par la racine et en descendant. Pour la racine id vaut "" et nom |
* vaut "". |
* |
* @param int id_repertoire L'identifiant d'un répertoire. |
* @return Array |
* @access public |
*/ |
function getCheminIdRepertoire( $id_doc, &$objetDB ) |
{ |
if ($id_doc == "") $id_doc = 0; |
// on commence par rechercher le répertoire père, dans la base de donnée |
$requete = 'select pd_pere, pd_nom, pd_id, pd_ce_type from projet_documents where pd_id='.$GLOBALS['projet_db']->escapeSimple($id_doc) ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
$chemin_rep_id_nom = array() ; |
if ($resultat->numRows()>0) { |
if ($ligne->pd_pere == 0) { |
return array ($ligne->pd_id); |
} |
array_push ($chemin_rep_id_nom, $ligne->pd_id) ; |
$tab = document::getCheminIdRepertoire($ligne->pd_pere, $objetDB) ; |
$chemin_rep_id_nom = array_merge ($tab, $chemin_rep_id_nom) ; |
} |
return ($chemin_rep_id_nom); |
} |
function getPath( $id_doc) |
{ |
if ($id_doc == "") $id_doc = 0; |
// on commence par rechercher le répertoire père, dans la base de donnée |
$requete = 'select pd_pere, pd_nom, pd_id, pd_ce_type from projet_documents where pd_id='.$GLOBALS['projet_db']->escapeSimple($id_doc) ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
$chemin_rep_id_nom = array() ; |
if ($resultat->numRows()>0 && $ligne->pd_pere != 0 && $ligne->pd_pere != $ligne->pd_id) { |
array_push ($chemin_rep_id_nom, $ligne->pd_pere) ; |
// Récursion sur le répertoires ou fichiers fils |
$chemin_rep_id_nom = array_merge ($chemin_rep_id_nom, document::getPath($ligne->pd_pere) ); |
} |
return $chemin_rep_id_nom; |
} |
/** |
* Calcule le chemin vers le fichier ou le répertoire uploadé |
* renvoie un chaine de la forme dir1/dir2/fichier.ext |
* En prenant comme racine le répertoire du projet, exclu. |
* @return string Le chemin |
*/ |
function calculeCheminUploaded ($radical) { |
if (isset($_FILES['fichier']['name'])) { |
$extension = preg_replace("/^([^\.]+)\.(\w+$)/", "\\2", $_FILES['fichier']['name']) ; |
} |
if ($this->_id_pere != '') { |
// On appelle la méthode getCheminIdRepertoire qui renvoie un tableau avec la liste |
// des répertoires jusqu'à la racine, on enlève la racine ($i = 0) et on concatène |
// toutes les entrées pour obtenir le chemin jusqu'au répertoire courant |
$chemin_repertoire_entre_racine_et_repertoire_a_cree = '' ; |
$doc_pere = new document ($this->_id_pere, $GLOBALS['projet_db']); |
return $doc_pere->getChemin(); |
$tableau_navigation = $this->getPath($this->_id_pere) ; |
for ($i = 0; $i < count ($tableau_navigation); $i++) $chemin_repertoire_entre_racine_et_repertoire_a_cree.= $tableau_navigation[$i]."/"; |
$chemin = $chemin_repertoire_entre_racine_et_repertoire_a_cree ; |
} else { |
// Si l'on est à la racine du projet, le chemin vide |
return $radical ; |
} |
return $chemin ; |
} |
/** |
* Enregistre une ligne dans la table projet_document |
* Le tableau de valeur doit contenir les éléments suivants 'document_nom','document_description','document_visibilite','fichier' |
* |
* @param Array tableau_de_valeur Le tableau de valeur a insérer dans la base avec pour clé les noms des éléments |
* @access public |
* @return void |
*/ |
function enregistrerSQL ($valeur, $chemin) { |
// On teste si on a affaire à un répertoire ou un fichier |
if (isset ($_FILES['fichier']['name'])) { |
// On tente de déterminer le type du fichier à partir de son nom dans $valeur['$fichier'] |
$tableau_nom = explode (".", $_FILES['fichier']['name']) ; |
// On prend le dernier élément du tableau, si c'est un tableau |
if (is_array($tableau_nom)) { |
$extension = array_pop($tableau_nom) ; |
$type = type_fichier_mime::factory($extension) ; |
$id_extension = $type->getIdType() ; |
} else { |
$id_extension = 12 ; |
} |
$pd_lien = $chemin ; |
} else { // Le cas ou on a affaire à un répertoire |
$id_extension = 0 ; |
// Le nom du répertoire est son identifiant avec un slash à la fin |
$pd_lien = $chemin."/" ; |
if ($this->_id_pere != '') { |
// On appelle la méthode getCheminIdRepertoire qui renvoie un tableau avec la liste |
// des répertoires jusqu'à la racine, on enlève la racine ($i = 0) et on concatène |
// toutes les entrées pour obtenir le chemin jusqu'au répertoire courant |
$chemin_repertoire_entre_racine_et_repertoire_a_cree = '' ; |
$tableau_navigation = $this->getCheminIdRepertoire($this->_id_pere, $GLOBALS['projet_db']) ; |
for ($i = 0; $i < count ($tableau_navigation); $i+=2) $chemin_repertoire_entre_racine_et_repertoire_a_cree.= $tableau_navigation[$i]."/"; |
$pd_lien .= $chemin_repertoire_entre_racine_et_repertoire_a_cree ; |
} |
//$pd_lien .= SQL_obtenirNouveauId($GLOBALS['projet_db'], 'projet_documents', 'pd_id')."/" ; |
$pd_lien = SQL_obtenirNouveauId($GLOBALS['projet_db'], 'projet_documents', 'pd_id')."/" ; |
} |
$id = SQL_obtenirNouveauId($GLOBALS['projet_db'], 'projet_documents', 'pd_id') ; |
$requete = "insert into projet_documents set pd_id=".$GLOBALS['projet_db']->escapeSimple($id) ; |
$requete .= ", pd_nom=\"".$valeur['document_nom']."\", pd_description=\"".$valeur['document_description']."\"". |
", pd_visibilite=\"".$valeur['document_visibilite']."\", pd_date_de_mise_a_jour=NOW(),". |
"pd_ce_projet=\"".$this->_id_projet."\", pd_ce_utilisateur=\"".$this->_id_proprietaire."\"". |
", pd_pere=\"$this->_id_pere\", pd_ce_type=\"$id_extension\", pd_lien=\"$pd_lien\"" ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$this->_id = $id ; |
return $pd_lien; |
} |
function genereNouveauNom ($radical, $ancien_nom, $id) { |
$extension = preg_replace("/^([^\.]+)\.(\w+$)/", "\\2", $ancien_nom) ; |
$nouveau_nom = $radical."_".$id.".".$extension ; |
return $nouveau_nom; |
} |
/** |
* Met à jour une ligne dans la table projet_document |
* Le tableau de valeur doit contenir les éléments suivants 'document_nom','document_description','document_visibilite','fichier' |
* |
* @param Array tableau_de_valeur Le tableau de valeur a insérer dans la base avec pour clé les noms des éléments |
* @access public |
* @return void |
*/ |
function majSQL ($valeur) { |
$requete = "update projet_documents set pd_nom=\"".$valeur['document_nom']."\", pd_description=\"".$valeur['document_description']."\"". |
", pd_visibilite=\"".$valeur['document_visibilite']."\", pd_date_de_mise_a_jour=NOW()". |
" where pd_id=".$GLOBALS['projet_db']->escapeSimple($this->_id); |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
return ; |
} |
/** Supprime les donnéexs du document dans la table projet_documents |
* |
* |
* @return true en cas de succès |
*/ |
function suppressionSQL () { |
$requete = 'delete from projet_documents where pd_id='.$GLOBALS['projet_db']->escapeSimple($this->_id) ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if ($GLOBALS['projet_db']->affectedRows()) return true ; |
return false ; |
} |
/** |
* Déplace un document au sein d'un même projet |
* |
* @param int repertoire_destination L'identifiant du répertoire destination. |
* @return bool |
* @access public |
*/ |
function deplace( $repertoire_destination, $repertoire_projet ) |
{ |
// On récupère les informations du répertoire cible |
if ($repertoire_destination != 0) { |
$repertoire_cible = new document ($repertoire_destination, $GLOBALS['projet_db']) ; |
$chemin_rep_cible = $repertoire_cible->getChemin(); |
} else { |
// Si le repertoire destination est la racine cad id =0 |
// on cree un document qui aura pour chemin le repertoire du projet |
include_once PROJET_CHEMIN_CLASSES.'projet.class.php'; |
$projet = new projet ($GLOBALS['projet_db'], $this->_id_projet); |
$chemin_rep_cible = $projet->getNomRepertoire().'/'; |
} |
$nom_fichier = $this->_pd_lien ; |
$requete = 'update projet_documents set pd_pere='.$GLOBALS['projet_db']->escapeSimple($repertoire_destination).' where pd_id='.$GLOBALS['projet_db']->escapeSimple($this->_id) ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
echo ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
return false ; |
} |
//echo $this->_chemin.'<br>'.PROJET_CHEMIN_FICHIER.$chemin_rep_cible.$nom_fichier; |
return fichier::deplace ($this->_chemin, PROJET_CHEMIN_FICHIER.$chemin_rep_cible.$nom_fichier) ; |
} // end of member function deplace |
/** |
* Pour modifier l'identifiant du projet auquel appartient un document. |
* |
* @param int id_projet L'identifiant du projet. |
* @return void |
* @access public |
*/ |
function setIdProjet( $id_projet ) |
{ |
$this->_id_projet = $id_projet ; |
} // end of member function setIdProjet |
/** |
* Permet de modifier l'identifiant du propietaire d'un projet. |
* |
* @param int id_proprietaire L'identifiant du proprietaire d'un document. |
* @return void |
* @access public |
*/ |
function setIdProprietaire( $id_proprietaire ) |
{ |
$this->_id_proprietaire = $id_proprietaire ; |
} // end of member function setIdProprietaire |
/** |
* Permet de modifier l'identifiant du répertoire d'un document. |
* |
* @param int id_repertoire L'identifiant du repertoire d'un document. |
* @return void |
* @access public |
*/ |
function setIdRepertoire( $id_repertoire ) |
{ |
$this->_id_pere = $id_repertoire; |
} // end of member function setIdRepertoire |
/** |
* initAttributes sets all document attributes to its default value make |
* sure to call this method within your class constructor |
*/ |
function initAttributes( ) |
{ |
$this->_visibilite = "public"; |
} |
/** |
* Renvoie les derniers documents de l'ensemble des projets. |
* |
* @param int nombre Le nombre de document à renvoyer |
* @return Array |
* @static |
* @access public |
*/ |
static function getDocumentsRecents( $nombre = 10, &$objetDB, $chemin, $chemin_icones, $id_projet = '', $visible = true) |
{ |
// on recherche les documents, hors repertoire |
$requete = 'select pd_id from projet_documents where pd_ce_type<>0 '; |
if ($id_projet != '') $requete .= ' and pd_ce_projet='.$GLOBALS['projet_db']->escapeSimple($id_projet).' '; |
if (!$visible) $requete .= ' and pd_visibilite="public" '; |
$requete .= 'order by pd_date_de_mise_a_jour desc limit 0,'.$nombre ; |
$resultat = $objetDB->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$tableau_document = array() ; |
while ($ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_document, new document ($ligne->pd_id, $objetDB, $chemin, $chemin_icones)) ; |
} |
return $tableau_document ; |
} // end of member function getDocumentsRecents |
/** |
* Renvoie les documents du projet passe en parametre sous forme d arbre d objet document |
* |
* @param int l identifiant du projet |
* @return Array |
* @static |
* @access public |
*/ |
function getArbreDocument($id_projet, $objetDB = '') { |
$requete = 'select pd_id, pd_nom, pd_ce_type, pd_pere from projet_documents where pd_ce_projet='.$GLOBALS['projet_db']->escapeSimple($id_projet); |
$resultat = $GLOBALS['projet_db']->getAll($requete, null, DB_FETCHMODE_OBJECT); |
if (DB::isError ($resultat)) { |
return ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
return $resultat; |
} |
/** |
* Renvoie la taille du document formatee avec une unite adapte |
* |
* @return string La taille formate |
* @access public |
*/ |
function getTailleFormatee($precision = 1) { |
$taille = $this->getTaille(); |
if ($taille > 1000000) { |
$diviseur = 1000000; |
$unite = 'Mo'; |
} else { |
$diviseur = 1000 ; |
$unite = 'Ko'; |
} |
return round ($taille / $diviseur, $precision).' '.$unite; |
} |
/** |
* Renvoie une liste de document, enfant du document courant |
* qui doit etre un repertoire bien sur |
* |
* @return mixed un tableau de document |
* @access public |
*/ |
function getDocumentsEnfant() { |
} |
} // end of document |
?> |
/trunk/classes/participe.class.php |
---|
1,426 → 1,425 |
<?php |
// +------------------------------------------------------------------------------------------------------+ |
// | 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: participe.class.php,v 1.7 2008-09-16 14:11:31 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe partiicpe assure la jointure entre projet et Auth |
* Elle se base sur la table projet_statut_utilisateur |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.7 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class participe |
* |
*/ |
class participe |
{ |
/*** Attributes: ***/ |
/** |
* Date d'inscription au projet de l'utilisateur. |
* @access private |
*/ |
var $_date_inscription; |
/** |
* Statut de l'utilisateur, un entier. |
* @access private |
*/ |
var $_statut; |
/** |
* Connexion à la base de donnée. |
* @access private |
*/ |
var $_db; |
/** |
* Constructeur. Nécessite un objet DB valide connecté à la base contenant les |
* tables projets. |
* |
* @param DB objetDB Un objet PEAR:DB valide. |
* @return void |
* @access public |
*/ |
function participe( &$objetDB ) |
{ |
$this->_db = $objetDB ; |
} // end of member function participe |
/** |
* Renvoie la liste des inscrit à un projet avec leur statut. |
* |
* @return Array |
* @access public |
*/ |
function getInscrits($id_projet, $droits ) |
{ |
$tableau_resultat = array() ; |
$requete = 'select psu_id_utilisateur,'.PROJET_CHAMPS_NOM.','.PROJET_CHAMPS_PRENOM.',' ; |
$requete .= PROJET_CHAMPS_MAIL.', ' ; |
$requete .= 'psu_date_inscription, ps_id_statut '. |
' from projet_statut_utilisateurs, projet_statut,'.PROJET_ANNUAIRE. |
' where psu_id_projet='.$this->_db->escapeSimple($id_projet).' and psu_id_utilisateur='.PROJET_CHAMPS_ID. |
' and psu_id_statut=ps_id_statut order by ps_id_statut,'.PROJET_CHAMPS_NOM; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ORDERED)) { |
array_push ($tableau_resultat, $ligne) ; |
$id = $ligne[0]; |
$inscrits[$id]['nom'] = $ligne[1]; |
$inscrits[$id]['prenom'] = $ligne[2]; |
$inscrits[$id]['mail'] = $ligne[3]; |
$inscrits[$id]['date'] = $ligne[4]; |
$inscrits[$id]['id_statut'] = $ligne[5]; |
} |
$resultat->free() ; |
return $tableau_resultat ; |
} // end of member function getInscrits |
/** |
* Renvoie un tableau contenant la liste des identifiants des projets et des statuts |
* d'un inscrit. 0 => ['psu_id_utilisateur'] ['psu_id_statut'] 1 => ... |
* |
* @param int id_utilisateur Un identifiant d'utilisateur pour le champs |
* projet_statut_utilisateurs:psu_id_utilisateur |
* @return Array |
* @access public |
*/ |
function getIdProjetsStatuts( $id_utilisateur ) |
{ |
$tableau_resultat = array() ; |
$requete = "select psu_id_utilisateur, psu_id_statut from projet_statut_utilisateurs". |
" where psu_id_utilisateur=".$this->_db->escapeSimple($id_utilisateur) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
array_push ($tableau_resultat, $ligne) ; |
} |
$resultat->free() ; |
return $tableau_resultat ; |
} // end of member function getIdProjetsStatuts |
/** |
* Renvoie un tableau à 2 dimensions avec les informations sur l'inscription aux |
* différents projets d'un utilisateur. 0 => ['p_titre'] Le titre du projet |
* ['ps_label'] Le statut de l'utilisateur 1 => .... (autant que de |
* projets) |
* |
* @param int id_utilisateur L'identifiant d'un utilisateur. |
* @return Array |
* @access public |
*/ |
function getInformationsUtilisateurs( $id_utilisateur ) |
{ |
$tableau_resultat = array() ; |
$requete = "select p_titre, ps_statut_nom, psu_id_statut, psu_id_projet from projet_statut_utilisateurs, projet, projet_statut". |
" where psu_id_utilisateur=".$this->_db->escapeSimple($id_utilisateur). |
" and psu_id_projet = p_id and psu_id_statut = ps_id_statut" ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
while ($ligne = $resultat->fetchRow()) { |
array_push ($tableau_resultat, $ligne) ; |
} |
$resultat->free() ; |
return $tableau_resultat ; |
} // end of member function getInformationsUtilisateurs |
/** |
* Renvoie le statut du projet passé en paramètre. |
* |
* @param int id_utilisateur |
* @param int id_projet |
* @param int dbObject |
* @return int |
* @static |
* @access public |
*/ |
function getStatutSurProjetCourant( $id_utilisateur, $id_projet, &$dbObject ) |
{ |
if (participe::isAdministrateur($id_utilisateur, $dbObject)) return PROJET_DROIT_ADMINISTRATEUR; |
$requete = 'select psu_id_statut from projet_statut_utilisateurs'. |
' where psu_id_utilisateur='.$this->_db->escapeSimple($id_utilisateur).' and psu_id_projet ='.$this->_db->escapeSimple($id_projet) ; |
$resultat = $dbObject->query ($requete) ; |
if (DB::isError ($resultat)) { |
return DB::raiseError('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; |
if (!$resultat->numRows()) { |
return 4 ; // Le statut ne participe pas |
} |
return $ligne->psu_id_statut ; |
} // end of member function getStatutSurProjetCourant |
/** |
* Réalise une requête dans projet_statut_utilisateurs et renvoie true si l'utilisateur |
* est administrateur de l'application projet. |
* |
* @param int id_utilisateur L'identifiant d'un utilisateur. |
* @param DB objetDB Un objet PEAR::DB |
* @return bool |
* @access public |
*/ |
function isAdministrateur( $id_utilisateur, $objetDB = "" ) |
{ |
// La table projet_statut_utilisateurs possède une entré avec psu_id_projet = 0 |
// pour indiquer un administrateur |
$requete = "select psu_id_statut from projet_statut_utilisateurs where psu_id_utilisateur=".$this->_db->escapeSimple($id_utilisateur)." ". |
" and psu_id_projet=0" ; |
if (is_object ($objetDB)) { |
$resultat = $objetDB->query ($requete) ; |
} else { |
$resultat = $this->_db->query ($requete) ; |
} |
if ($resultat->numRows () != 0) { |
return true; |
} |
return false ; |
} // end of member function isAdministrateur |
/** |
* Met à jour le statut d'un utilisateur sur un projet |
* |
* @param int id_statut L'identifiant du statut à ajouter ou mettre à jour |
* @param int id_utilisateur Identifiant de l'utilisateur |
* @param int id_projet Identifiant du projet |
* @return bool |
* @access public |
*/ |
function setStatut( $id_statut, $id_utilisateur, $id_projet ) |
{ |
$requete = 'update projet_statut_utilisateurs set psu_id_statut='.$this->_db->escapeSimple($id_statut). |
' where psu_id_utilisateur='.$this->_db->escapeSimple($id_utilisateur).' and psu_id_projet='.$this->_db->escapeSimple($id_projet); |
if (participe::getStatutSurProjetCourant($id_utilisateur, $id_projet, $this->_db) == 4) { |
$requete = 'insert into projet_statut_utilisateurs set psu_id_statut='.$this->_db->escapeSimple($id_statut). |
', psu_id_utilisateur='.$this->_db->escapeSimple($id_utilisateur).',psu_id_projet='.$this->_db->escapeSimple($id_projet). |
', psu_date_inscription=NOW()'; |
} |
if ($id_statut == 4) { // Si le statut est ne participe pas, on supprime l'inscrit |
$requete = 'delete from projet_statut_utilisateurs where psu_id_utilisateur='.$this->_db->escapeSimple($id_utilisateur). |
' and psu_id_projet='.$this->_db->escapeSimple($id_projet) ; |
} |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
return true ; |
} // end of member function setStatut |
/** |
* Renvoie vrai si l'utilisateur est coordinateur, faux dans les autres cas |
* |
* @param int id_utilisateur L'identifiant d'un utilisateur |
* @param DB objetDB Optionnel, nécessaire si on appelle cette méthode statiquement |
* @return bool |
* @static |
* @access public |
*/ |
function isCoordinateur( $id_utilisateur, $id_projet, &$objetDB ) |
{ |
if (!is_object($objetDB)) $objetDB = $this->_db; |
$statut = $this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) ; |
if ($statut == 1) { |
return true; |
} |
return false ; |
} // end of member function isCoordinateur |
/** |
* Renvoie la liste des projets auquels l'utilisateur passé en paramètre ne |
* participe pas. |
* |
* @param int id_utilisateur L'identifiant de l'utilisateur. |
* @return Array |
* @access public |
*/ |
function getProjetsNonParticipant( $id_utilisateur ) |
{ |
$tableau_resultat = array() ; |
$requete = 'select p_id from projet'. |
' where p_id not in (select psu_id_projet from projet_statut_utilisateurs where psu_id_utilisateur='.$this->_db->escapeSimple($id_utilisateur).')' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_resultat, new projet ($this->_db, $ligne->p_id)) ; |
} |
$resultat->free() ; |
return $tableau_resultat ; |
} // end of member function getProjetsNonParticipant |
/** |
* Renvoie true si l'utilisateur passé en paramètre est observateur du projet passé |
* en paramètre. |
* |
* @param int id_utilisateur L'identifiant de l'utilisateur |
* @param int id_projet L'identifiant du projet |
* @return bool |
* @access public |
*/ |
function isObservateur( $id_utilisateur, $id_projet, &$objetDB ) |
{ |
if (!is_object($objetDB)) $objetDB = $this->_db; |
if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 3) { |
return true; |
} |
return false ; |
} // end of member function isObservateur |
/** |
* Renvoie true si l'utilisateur passé en paramètre est contributeur du projet passé |
* en paramètre. |
* |
* @param int id_utilisateur L'identifiant de l'utilisateur |
* @param int id_projet L'identifiant du projet |
* @return bool |
* @access public |
*/ |
function isContributeur( $id_utilisateur, $id_projet, &$objetDB ) |
{ |
if (!is_object($objetDB)) $objetDB = $this->_db; |
if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 4) return false; |
if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 2) { |
return true; |
} |
return false ; |
} // end of member function isObservateur |
/** |
* Renvoie true si l'utilisateur passé en paramètre est contributeur du projet passé |
* en paramètre. |
* |
* @param int id_utilisateur L'identifiant de l'utilisateur |
* @param int id_projet L'identifiant du projet |
* @return bool |
* @access public |
*/ |
function isEnAttente( $id_utilisateur, $id_projet, &$objetDB ) |
{ |
if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 3) { |
return true; |
} |
return false ; |
} // end of member function isObservateur |
/** |
* Renvoie les infos sur les coordinateurs d'un projet |
* |
* @param int id_projet L'identifiant du projet |
* @return array Un tableau contenant les infos concernants les coordinateurs du projet |
* @access public |
*/ |
function getCoordinateurs($id_projet) |
{ |
$tableau_resultat = array() ; |
$requete = 'select psu_id_utilisateur,'.PROJET_CHAMPS_NOM.','.PROJET_CHAMPS_PRENOM.',' ; |
$requete .= PROJET_CHAMPS_MAIL.', ' ; |
$requete .= 'psu_date_inscription, ps_id_statut '. |
' from projet_statut_utilisateurs, projet_statut,'.PROJET_ANNUAIRE. |
' where psu_id_projet='.$this->_db->escapeSimple($id_projet).' and psu_id_utilisateur='.PROJET_CHAMPS_ID. |
' and psu_id_statut=ps_id_statut and psu_id_statut=1 order by ps_id_statut,'.PROJET_CHAMPS_NOM; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ORDERED)) { |
array_push ($tableau_resultat, $ligne) ; |
} |
$resultat->free() ; |
return $tableau_resultat ; |
} // end of member function getCoordinateurs |
function getAdministrateurs () { |
$tableau_resultat = array() ; |
$requete = 'select psu_id_utilisateur,'.PROJET_CHAMPS_NOM.','.PROJET_CHAMPS_PRENOM.',' ; |
$requete .= PROJET_CHAMPS_MAIL.', ' ; |
$requete .= 'psu_date_inscription, ps_id_statut '. |
' from projet_statut_utilisateurs, projet_statut,'.PROJET_ANNUAIRE. |
' where psu_id_utilisateur='.PROJET_CHAMPS_ID. |
' and psu_id_statut=ps_id_statut and psu_id_statut=0 order by ps_id_statut,'.PROJET_CHAMPS_NOM; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ORDERED)) { |
array_push ($tableau_resultat, $ligne) ; |
} |
$resultat->free() ; |
return $tableau_resultat ; |
} |
/** |
* Renvoie la constante de statut d un utilisateur |
* |
* define ('PROJET_DROIT_ADMINISTRATEUR', 1) ; |
* define ('PROJET_DROIT_COORDINATEUR', 2) ; |
* define ('PROJET_DROIT_PROPRIETAIRE', 4) ; |
* define ('PROJET_DROIT_CONTRIBUTEUR', 8) ; |
* define ('PROJET_DROIT_AUCUN', 16) ; |
* define ('PROJET_DROIT_EN_ATTENTE', 32); |
* |
* @access public |
* @return int La constante de statut |
*/ |
function getStatut($id_utilisateur, $id_projet) |
{ |
$statut = $this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $this->_db); |
switch ($statut) |
{ |
case 0 : return PROJET_DROIT_ADMINISTRATEUR; |
break; |
case 1 : return PROJET_DROIT_COORDINATEUR; |
break; |
case 2 : return PROJET_DROIT_CONTRIBUTEUR; |
break; |
case 3 : return PROJET_DROIT_EN_ATTENTE; |
break; |
default : return PROJET_DROIT_AUCUN; |
} |
} |
} // end of participe |
?> |
<?php |
// +------------------------------------------------------------------------------------------------------+ |
// | 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: participe.class.php,v 1.6 2008-08-25 15:11:56 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe partiicpe assure la jointure entre projet et Auth |
* Elle se base sur la table projet_statut_utilisateur |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.6 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class participe |
* |
*/ |
class participe |
{ |
/*** Attributes: ***/ |
/** |
* Date d'inscription au projet de l'utilisateur. |
* @access private |
*/ |
var $_date_inscription; |
/** |
* Statut de l'utilisateur, un entier. |
* @access private |
*/ |
var $_statut; |
/** |
* Connexion à la base de donnée. |
* @access private |
*/ |
var $_db; |
/** |
* Constructeur. Nécessite un objet DB valide connecté à la base contenant les |
* tables projets. |
* |
* @param DB objetDB Un objet PEAR:DB valide. |
* @return void |
* @access public |
*/ |
function participe( &$objetDB ) |
{ |
$this->_db = $objetDB ; |
} // end of member function participe |
/** |
* Renvoie la liste des inscrit à un projet avec leur statut. |
* |
* @return Array |
* @access public |
*/ |
function getInscrits($id_projet, $droits ) |
{ |
$tableau_resultat = array() ; |
$requete = 'select psu_id_utilisateur,'.PROJET_CHAMPS_NOM.','.PROJET_CHAMPS_PRENOM.',' ; |
$requete .= PROJET_CHAMPS_MAIL.', ' ; |
$requete .= 'psu_date_inscription, ps_id_statut '. |
' from projet_statut_utilisateurs, projet_statut,'.PROJET_ANNUAIRE. |
' where psu_id_projet='.$this->_db->escapeSimple($id_projet).' and psu_id_utilisateur='.PROJET_CHAMPS_ID. |
' and psu_id_statut=ps_id_statut order by ps_id_statut,'.PROJET_CHAMPS_NOM; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ORDERED)) { |
array_push ($tableau_resultat, $ligne) ; |
$id = $ligne[0]; |
$inscrits[$id]['nom'] = $ligne[1]; |
$inscrits[$id]['prenom'] = $ligne[2]; |
$inscrits[$id]['mail'] = $ligne[3]; |
$inscrits[$id]['date'] = $ligne[4]; |
$inscrits[$id]['id_statut'] = $ligne[5]; |
} |
$resultat->free() ; |
return $tableau_resultat ; |
} // end of member function getInscrits |
/** |
* Renvoie un tableau contenant la liste des identifiants des projets et des statuts |
* d'un inscrit. 0 => ['psu_id_utilisateur'] ['psu_id_statut'] 1 => ... |
* |
* @param int id_utilisateur Un identifiant d'utilisateur pour le champs |
* projet_statut_utilisateurs:psu_id_utilisateur |
* @return Array |
* @access public |
*/ |
function getIdProjetsStatuts( $id_utilisateur ) |
{ |
$tableau_resultat = array() ; |
$requete = "select psu_id_utilisateur, psu_id_statut from projet_statut_utilisateurs". |
" where psu_id_utilisateur=".$this->_db->escapeSimple($id_utilisateur) ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
array_push ($tableau_resultat, $ligne) ; |
} |
$resultat->free() ; |
return $tableau_resultat ; |
} // end of member function getIdProjetsStatuts |
/** |
* Renvoie un tableau à 2 dimensions avec les informations sur l'inscription aux |
* différents projets d'un utilisateur. 0 => ['p_titre'] Le titre du projet |
* ['ps_label'] Le statut de l'utilisateur 1 => .... (autant que de |
* projets) |
* |
* @param int id_utilisateur L'identifiant d'un utilisateur. |
* @return Array |
* @access public |
*/ |
function getInformationsUtilisateurs( $id_utilisateur ) |
{ |
$tableau_resultat = array() ; |
$requete = "select p_titre, ps_statut_nom, psu_id_statut, psu_id_projet from projet_statut_utilisateurs, projet, projet_statut". |
" where psu_id_utilisateur=".$this->_db->escapeSimple($id_utilisateur). |
" and psu_id_projet = p_id and psu_id_statut = ps_id_statut" ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
while ($ligne = $resultat->fetchRow()) { |
array_push ($tableau_resultat, $ligne) ; |
} |
$resultat->free() ; |
return $tableau_resultat ; |
} // end of member function getInformationsUtilisateurs |
/** |
* Renvoie le statut du projet passé en paramètre. |
* |
* @param int id_utilisateur |
* @param int id_projet |
* @param int dbObject |
* @return int |
* @static |
* @access public |
*/ |
function getStatutSurProjetCourant( $id_utilisateur, $id_projet, &$dbObject ) |
{ |
if (participe::isAdministrateur($id_utilisateur, $dbObject)) return PROJET_DROIT_ADMINISTRATEUR; |
$requete = 'select psu_id_statut from projet_statut_utilisateurs'. |
' where psu_id_utilisateur='.$this->_db->escapeSimple($id_utilisateur).' and psu_id_projet ='.$this->_db->escapeSimple($id_projet) ; |
$resultat = $dbObject->query ($requete) ; |
if (DB::isError ($resultat)) { |
return DB::raiseError('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ; |
if (!$resultat->numRows()) { |
return 4 ; // Le statut ne participe pas |
} |
return $ligne->psu_id_statut ; |
} // end of member function getStatutSurProjetCourant |
/** |
* Réalise une requête dans projet_statut_utilisateurs et renvoie true si l'utilisateur |
* est administrateur de l'application projet. |
* |
* @param int id_utilisateur L'identifiant d'un utilisateur. |
* @param DB objetDB Un objet PEAR::DB |
* @return bool |
* @access public |
*/ |
function isAdministrateur( $id_utilisateur, $objetDB = "" ) |
{ |
// La table projet_statut_utilisateurs possède une entré avec psu_id_projet = 0 |
// pour indiquer un administrateur |
$requete = "select psu_id_statut from projet_statut_utilisateurs where psu_id_utilisateur=".$this->_db->escapeSimple($id_utilisateur)." ". |
" and psu_id_projet=0" ; |
if (is_object ($objetDB)) { |
$resultat = $objetDB->query ($requete) ; |
} else { |
$resultat = $this->_db->query ($requete) ; |
} |
if ($resultat->numRows () != 0) { |
return true; |
} |
return false ; |
} // end of member function isAdministrateur |
/** |
* Met à jour le statut d'un utilisateur sur un projet |
* |
* @param int id_statut L'identifiant du statut à ajouter ou mettre à jour |
* @param int id_utilisateur Identifiant de l'utilisateur |
* @param int id_projet Identifiant du projet |
* @return bool |
* @access public |
*/ |
function setStatut( $id_statut, $id_utilisateur, $id_projet ) |
{ |
$requete = 'update projet_statut_utilisateurs set psu_id_statut='.$this->_db->escapeSimple($id_statut). |
' where psu_id_utilisateur='.$id_utilisateur.' and psu_id_projet='.$this->_db->escapeSimple($id_projet); |
if (participe::getStatutSurProjetCourant($id_utilisateur, $id_projet, $this->_db) == 4) { |
$requete = 'insert into projet_statut_utilisateurs set psu_id_statut='.$this->_db->escapeSimple($id_statut). |
', psu_id_utilisateur='.$this->_db->escapeSimple($id_utilisateur).',psu_id_projet='.$this->_db->escapeSimple($id_projet). |
', psu_date_inscription=NOW()'; |
} |
if ($id_statut == 4) { // Si le statut est ne participe pas, on supprime l'inscrit |
$requete = 'delete from projet_statut_utilisateurs where psu_id_utilisateur='.$this->_db->escapeSimple($id_utilisateur).' and psu_id_projet='.$this->_db->escapeSimple($id_projet) ; |
} |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError ($resultat)) { |
die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ; |
} |
return true ; |
} // end of member function setStatut |
/** |
* Renvoie vrai si l'utilisateur est coordinateur, faux dans les autres cas |
* |
* @param int id_utilisateur L'identifiant d'un utilisateur |
* @param DB objetDB Optionnel, nécessaire si on appelle cette méthode statiquement |
* @return bool |
* @static |
* @access public |
*/ |
function isCoordinateur( $id_utilisateur, $id_projet, &$objetDB ) |
{ |
if (!is_object($objetDB)) $objetDB = $this->_db; |
$statut = $this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) ; |
if ($statut == 1) { |
return true; |
} |
return false ; |
} // end of member function isCoordinateur |
/** |
* Renvoie la liste des projets auquels l'utilisateur passé en paramètre ne |
* participe pas. |
* |
* @param int id_utilisateur L'identifiant de l'utilisateur. |
* @return Array |
* @access public |
*/ |
function getProjetsNonParticipant( $id_utilisateur ) |
{ |
$tableau_resultat = array() ; |
$requete = 'select p_id from projet'. |
' where p_id not in (select psu_id_projet from projet_statut_utilisateurs where psu_id_utilisateur='.$this->_db->escapeSimple($id_utilisateur).')' ; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) { |
array_push ($tableau_resultat, new projet ($this->_db, $ligne->p_id)) ; |
} |
$resultat->free() ; |
return $tableau_resultat ; |
} // end of member function getProjetsNonParticipant |
/** |
* Renvoie true si l'utilisateur passé en paramètre est observateur du projet passé |
* en paramètre. |
* |
* @param int id_utilisateur L'identifiant de l'utilisateur |
* @param int id_projet L'identifiant du projet |
* @return bool |
* @access public |
*/ |
function isObservateur( $id_utilisateur, $id_projet, &$objetDB ) |
{ |
if (!is_object($objetDB)) $objetDB = $this->_db; |
if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 3) { |
return true; |
} |
return false ; |
} // end of member function isObservateur |
/** |
* Renvoie true si l'utilisateur passé en paramètre est contributeur du projet passé |
* en paramètre. |
* |
* @param int id_utilisateur L'identifiant de l'utilisateur |
* @param int id_projet L'identifiant du projet |
* @return bool |
* @access public |
*/ |
function isContributeur( $id_utilisateur, $id_projet, &$objetDB ) |
{ |
if (!is_object($objetDB)) $objetDB = $this->_db; |
if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 4) return false; |
if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 2) { |
return true; |
} |
return false ; |
} // end of member function isObservateur |
/** |
* Renvoie true si l'utilisateur passé en paramètre est contributeur du projet passé |
* en paramètre. |
* |
* @param int id_utilisateur L'identifiant de l'utilisateur |
* @param int id_projet L'identifiant du projet |
* @return bool |
* @access public |
*/ |
function isEnAttente( $id_utilisateur, $id_projet, &$objetDB ) |
{ |
if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 3) { |
return true; |
} |
return false ; |
} // end of member function isObservateur |
/** |
* Renvoie les infos sur les coordinateurs d'un projet |
* |
* @param int id_projet L'identifiant du projet |
* @return array Un tableau contenant les infos concernants les coordinateurs du projet |
* @access public |
*/ |
function getCoordinateurs($id_projet) |
{ |
$tableau_resultat = array() ; |
$requete = 'select psu_id_utilisateur,'.PROJET_CHAMPS_NOM.','.PROJET_CHAMPS_PRENOM.',' ; |
$requete .= PROJET_CHAMPS_MAIL.', ' ; |
$requete .= 'psu_date_inscription, ps_id_statut '. |
' from projet_statut_utilisateurs, projet_statut,'.PROJET_ANNUAIRE. |
' where psu_id_projet='.$this->_db->escapeSimple($id_projet).' and psu_id_utilisateur='.PROJET_CHAMPS_ID. |
' and psu_id_statut=ps_id_statut and psu_id_statut=1 order by ps_id_statut,'.PROJET_CHAMPS_NOM; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
return ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ORDERED)) { |
array_push ($tableau_resultat, $ligne) ; |
} |
$resultat->free() ; |
return $tableau_resultat ; |
} // end of member function getCoordinateurs |
function getAdministrateurs () { |
$tableau_resultat = array() ; |
$requete = 'select psu_id_utilisateur,'.PROJET_CHAMPS_NOM.','.PROJET_CHAMPS_PRENOM.',' ; |
$requete .= PROJET_CHAMPS_MAIL.', ' ; |
$requete .= 'psu_date_inscription, ps_id_statut '. |
' from projet_statut_utilisateurs, projet_statut,'.PROJET_ANNUAIRE. |
' where psu_id_utilisateur='.PROJET_CHAMPS_ID. |
' and psu_id_statut=ps_id_statut and psu_id_statut=0 order by ps_id_statut,'.PROJET_CHAMPS_NOM; |
$resultat = $this->_db->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ORDERED)) { |
array_push ($tableau_resultat, $ligne) ; |
} |
$resultat->free() ; |
return $tableau_resultat ; |
} |
/** |
* Renvoie la constante de statut d un utilisateur |
* |
* define ('PROJET_DROIT_ADMINISTRATEUR', 1) ; |
* define ('PROJET_DROIT_COORDINATEUR', 2) ; |
* define ('PROJET_DROIT_PROPRIETAIRE', 4) ; |
* define ('PROJET_DROIT_CONTRIBUTEUR', 8) ; |
* define ('PROJET_DROIT_AUCUN', 16) ; |
* define ('PROJET_DROIT_EN_ATTENTE', 32); |
* |
* @access public |
* @return int La constante de statut |
*/ |
function getStatut($id_utilisateur, $id_projet) |
{ |
$statut = $this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $this->_db); |
switch ($statut) |
{ |
case 0 : return PROJET_DROIT_ADMINISTRATEUR; |
break; |
case 1 : return PROJET_DROIT_COORDINATEUR; |
break; |
case 2 : return PROJET_DROIT_CONTRIBUTEUR; |
break; |
case 3 : return PROJET_DROIT_EN_ATTENTE; |
break; |
default : return PROJET_DROIT_AUCUN; |
} |
} |
} // end of participe |
?> |
/trunk/classes/type_fichier_mime.class.php |
---|
1,190 → 1,190 |
<?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: type_fichier_mime.class.php,v 1.3 2008-08-25 15:03:52 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe type_fichier_mime |
* |
*@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 | |
// +------------------------------------------------------------------------------------------------------+ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class type_fichier_mime |
* |
*/ |
class type_fichier_mime |
{ |
/*** Attributes: ***/ |
/** |
* Le nom du type en français (ex Image jpg) |
* @access private |
*/ |
var $_nom; |
/** |
* L'extension du fichier (ex: png) |
* @access private |
*/ |
var $_extension; |
/** |
* Le nom du fichier de l'icône représentant ce fichier. |
* @access private |
*/ |
var $_icone; |
/** |
* Le type mime. |
* @access private |
*/ |
var $_type_mime; |
/** |
* |
* @access private |
*/ |
var $_description; |
/** |
* Le chemin UNIX ou Windows vers le dossier des icônes. Il ne commence pas par un |
* slash et termine par slash. |
* @access private |
*/ |
var $_chemin_icone = "icones/"; |
/** |
* Un objet PEAR:DB |
* @access private |
*/ |
var $_db; |
/** |
* L'identifiant du type dans la table gen_type_de_fichier |
* @access private |
*/ |
var $_id_type; |
/** |
* Renvoie le chemin vers les icônes. |
* |
* @return string |
* @access public |
*/ |
function getCheminIcone( ) |
{ |
return $this->_chemin_icone.$this->_icone ; ; |
} // end of member function getCheminIcone |
/** |
* |
* |
* @param string chemin Le chemin vers l'icône. |
* @return void |
* @access public |
*/ |
function setCheminIcone( $chemin ) |
{ |
$this->_chemin_icone = $chemin ; |
} // end of member function setCheminIcone |
/** |
* |
* |
* @param DB objetDB un objet PEAR:DB |
* @param int id_type |
* @return void |
* @access public |
*/ |
function type_fichier_mime( $id_type = '', $chemin_icones = "icones/" ) |
{ |
$requete = 'select * from gen_type_de_fichier where ' ; |
if (is_numeric ($id_type)) { |
$requete .= 'gtf_id_type='.$GLOBALS['projet_db']->escapeSimple($id_type) ; |
} else { |
$requete .= 'gtf_type_mime="'.$id_type.'"' ; |
} |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
$this->_chemin_icone = $chemin_icones ; |
$this->_icone = $ligne->gtf_type_icone ; |
$this->_id_type = $ligne->gtf_id_type ; |
} // end of member function type_fichier_mime |
/** |
* Tente de renvoyer un objet type_fichier_mime à partir de l'extension passé en |
* paramètre. S'il elle n'y arrive pas, elle renvoie 'inconnue'. |
* |
* @param string extension On passe un extension en paramètre, pour déterminer le type mime. |
* @param DB objetDB un objet PEAR:DB |
* @return type_fichier_mime |
* @static |
* @access public |
*/ |
function factory( $extension, $objetDB = '') |
{ |
if (is_object($objetDB)) { |
$GLOBALS['projet_db'] = $objetDB; |
} |
$requete = "select * from gen_type_de_fichier where gtf_extension=\"$extension\" or gtf_type_mime=\"$extension\"" ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows() != 0) { |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
return new type_fichier_mime ( $ligne->gtf_id_type) ; |
} else { |
// si il n'y a pas de résultat, on renvoie inconnue |
return new type_fichier_mime (12) ; |
} |
} // end of member function factory |
/** |
* Renvoie l'identifiant du type Mime de la table gen_type_de_fichier |
* |
* @return int |
* @access public |
*/ |
function getIdType( ) |
{ |
return $this->_id_type; |
} // end of member function getIdType |
} // end of type_fichier_mime |
?> |
<?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: type_fichier_mime.class.php,v 1.2 2005-09-27 16:42:00 alexandre_tb Exp $ |
/** |
* Application projet |
* |
* La classe type_fichier_mime |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.2 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
/** |
* class type_fichier_mime |
* |
*/ |
class type_fichier_mime |
{ |
/*** Attributes: ***/ |
/** |
* Le nom du type en français (ex Image jpg) |
* @access private |
*/ |
var $_nom; |
/** |
* L'extension du fichier (ex: png) |
* @access private |
*/ |
var $_extension; |
/** |
* Le nom du fichier de l'icône représentant ce fichier. |
* @access private |
*/ |
var $_icone; |
/** |
* Le type mime. |
* @access private |
*/ |
var $_type_mime; |
/** |
* |
* @access private |
*/ |
var $_description; |
/** |
* Le chemin UNIX ou Windows vers le dossier des icônes. Il ne commence pas par un |
* slash et termine par slash. |
* @access private |
*/ |
var $_chemin_icone = "icones/"; |
/** |
* Un objet PEAR:DB |
* @access private |
*/ |
var $_db; |
/** |
* L'identifiant du type dans la table gen_type_de_fichier |
* @access private |
*/ |
var $_id_type; |
/** |
* Renvoie le chemin vers les icônes. |
* |
* @return string |
* @access public |
*/ |
function getCheminIcone( ) |
{ |
return $this->_chemin_icone.$this->_icone ; ; |
} // end of member function getCheminIcone |
/** |
* |
* |
* @param string chemin Le chemin vers l'icône. |
* @return void |
* @access public |
*/ |
function setCheminIcone( $chemin ) |
{ |
$this->_chemin_icone = $chemin ; |
} // end of member function setCheminIcone |
/** |
* |
* |
* @param DB objetDB un objet PEAR:DB |
* @param int id_type |
* @return void |
* @access public |
*/ |
function type_fichier_mime( $id_type = '', $chemin_icones = "icones/" ) |
{ |
$requete = 'select * from gen_type_de_fichier where ' ; |
if (is_numeric ($id_type)) { |
$requete .= 'gtf_id_type='.$GLOBALS['projet_db']->escapeSimple($id_type) ; |
} else { |
$requete .= 'gtf_type_mime="'.$id_type.'"' ; |
} |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
$this->_chemin_icone = $chemin_icones ; |
$this->_icone = $ligne->gtf_type_icone ; |
$this->_id_type = $ligne->gtf_id_type ; |
} // end of member function type_fichier_mime |
/** |
* Tente de renvoyer un objet type_fichier_mime à partir de l'extension passé en |
* paramètre. S'il elle n'y arrive pas, elle renvoie 'inconnue'. |
* |
* @param string extension On passe un extension en paramètre, pour déterminer le type mime. |
* @param DB objetDB un objet PEAR:DB |
* @return type_fichier_mime |
* @static |
* @access public |
*/ |
function factory( $extension, $objetDB = '') |
{ |
if (is_object($objetDB)) { |
$GLOBALS['projet_db'] = $objetDB; |
} |
$requete = "select * from gen_type_de_fichier where gtf_extension=\"$extension\" or gtf_type_mime=\"$extension\"" ; |
$resultat = $GLOBALS['projet_db']->query ($requete) ; |
if (DB::isError($resultat)) { |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ; |
} |
if ($resultat->numRows() != 0) { |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ; |
return new type_fichier_mime ( $ligne->gtf_id_type) ; |
} else { |
// si il n'y a pas de résultat, on renvoie inconnue |
return new type_fichier_mime (12) ; |
} |
} // end of member function factory |
/** |
* Renvoie l'identifiant du type Mime de la table gen_type_de_fichier |
* |
* @return int |
* @access public |
*/ |
function getIdType( ) |
{ |
return $this->_id_type; |
} // end of member function getIdType |
} // end of type_fichier_mime |
?> |
/trunk/classes/HTML_formulaireListeExterne.class.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: HTML_formulaireListeExterne.class.php,v 1.2 2005-09-27 16:42:00 alexandre_tb Exp $ |
// CVS : $Id: HTML_formulaireListeExterne.class.php,v 1.2 2005/09/27 16:42:00 alexandre_tb Exp $ |
/** |
* Application projet |
* |