Subversion Repositories Applications.bazar

Compare Revisions

Ignore whitespace Rev 90 → Rev 91

/trunk/bibliotheque/bazar.class.php
New file
0,0 → 1,137
<?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 Lesser 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 |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser 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: bazar.class.php,v 1.1 2006-02-07 11:08:06 alexandre_tb Exp $
/**
*
*@package bazar
//Auteur original :
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
*@author Florian Schmitt <florian@ecole-et-nature.org>
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.1 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | LES CONSTANTES DES NIVEAUX DE DROIT |
// +------------------------------------------------------------------------------------------------------+
 
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
 
class Utilisateur_bazar {
 
var $_auth ;
 
/**
* Vaut true si l'utilisateur est un administrateur
*/
var $_isSuperAdmin ;
/** Constructeur
*
* @param object Un objet authentification
* @return void
*
*/
function Utilisateur_bazar (&$AUTH) {
$this->_auth = $AUTH ;
}
/** isSuperAdmin () - Renvoie true si l'utilisateur est un super administrateur
*
*/
function isSuperAdmin() {
// On court-circuite si la question a déjà été posé pour ne pas refaire la requete
if (isset ($this->_isSuperAdmin)) return $this->_isSuperAdmin ;
// On court-circuite si l'utilisateur n'est pas loggué
if (!$this->_auth->getAuth()) return false ;
// Sinon on interroge la base
$requete = 'select bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='.
$this->_auth->getAuthData(BAZ_CHAMPS_ID).
' AND bd_niveau_droit=0';
 
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
if (DB::isError($resultat)) {
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
$this->_isSuperAdmin = true ;
} else {
$this->_isSuperAdmin = false ;
}
return $this->_isSuperAdmin;
}
/** isAdmin () - Renvoie true si l'utilisateur est administrateur du type de fiche spécifié
*
* @param interger type_annonce Le type de l'annonce
*
*/
function isAdmin($id_nature) {
// on court-circuite si l'utilisateur n'est pas loggué
if (!$this->_auth->getAuth()) return false ;
return $this->_requeteDroit ($id_nature, 1) ;
}
/** isRedacteur() - Renvoie true si l'utilisateur est rédacteur du type de fiche spécifié
*
*/
function isRedacteur($id_nature) {
return $this->_requeteDroit ($id_nature, 2) ;
}
/** _requeteDroit() - fait une requete sur la table bazar_droit
*
*/
function _requeteDroit ($id_nature, $niveau) {
$requete = 'select bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='
.$this->_auth->getAuthData(BAZ_CHAMPS_ID).
' AND bd_id_nature_offre="'.$id_nature.'" and bd_niveau_droit='.$niveau;
 
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
if (DB::isError($resultat)) {
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
}
if ($resultat->numRows() != 0) {
return true ;
}
return false ;
}
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>