91 |
alexandre_ |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This library is free software; you can redistribute it and/or |
|
|
|
9 |
// | modify it under the terms of the GNU Lesser General Public |
|
|
|
10 |
// | License as published by the Free Software Foundation; either |
|
|
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
|
|
12 |
// | |
|
|
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
|
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
16 |
// | Lesser General Public License for more details. |
|
|
|
17 |
// | |
|
|
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
|
|
19 |
// | License along with this library; if not, write to the Free Software |
|
|
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
22 |
// CVS : $Id: bazar.class.php,v 1.1 2006-02-07 11:08:06 alexandre_tb Exp $
|
|
|
23 |
/**
|
|
|
24 |
*
|
|
|
25 |
*@package bazar
|
|
|
26 |
//Auteur original :
|
|
|
27 |
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
|
|
|
28 |
*@author Florian Schmitt <florian@ecole-et-nature.org>
|
|
|
29 |
*@copyright Tela-Botanica 2000-2004
|
|
|
30 |
*@version $Revision: 1.1 $
|
|
|
31 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
32 |
*/
|
|
|
33 |
|
|
|
34 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
35 |
// | LES CONSTANTES DES NIVEAUX DE DROIT |
|
|
|
36 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
40 |
// | ENTETE du PROGRAMME |
|
|
|
41 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
class Utilisateur_bazar {
|
|
|
45 |
|
|
|
46 |
var $_auth ;
|
|
|
47 |
|
|
|
48 |
/**
|
|
|
49 |
* Vaut true si l'utilisateur est un administrateur
|
|
|
50 |
*/
|
|
|
51 |
var $_isSuperAdmin ;
|
|
|
52 |
|
|
|
53 |
/** Constructeur
|
|
|
54 |
*
|
|
|
55 |
* @param object Un objet authentification
|
|
|
56 |
* @return void
|
|
|
57 |
*
|
|
|
58 |
*/
|
|
|
59 |
|
|
|
60 |
function Utilisateur_bazar (&$AUTH) {
|
|
|
61 |
$this->_auth = $AUTH ;
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
/** isSuperAdmin () - Renvoie true si l'utilisateur est un super administrateur
|
|
|
65 |
*
|
|
|
66 |
*/
|
|
|
67 |
function isSuperAdmin() {
|
|
|
68 |
// On court-circuite si la question a déjà été posé pour ne pas refaire la requete
|
|
|
69 |
if (isset ($this->_isSuperAdmin)) return $this->_isSuperAdmin ;
|
|
|
70 |
|
|
|
71 |
// On court-circuite si l'utilisateur n'est pas loggué
|
|
|
72 |
if (!$this->_auth->getAuth()) return false ;
|
|
|
73 |
|
|
|
74 |
// Sinon on interroge la base
|
|
|
75 |
$requete = 'select bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='.
|
|
|
76 |
$this->_auth->getAuthData(BAZ_CHAMPS_ID).
|
|
|
77 |
' AND bd_niveau_droit=0';
|
|
|
78 |
|
|
|
79 |
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
|
|
|
80 |
if (DB::isError($resultat)) {
|
|
|
81 |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
|
|
|
82 |
}
|
|
|
83 |
if ($resultat->numRows() != 0) {
|
|
|
84 |
$this->_isSuperAdmin = true ;
|
|
|
85 |
} else {
|
|
|
86 |
$this->_isSuperAdmin = false ;
|
|
|
87 |
}
|
|
|
88 |
return $this->_isSuperAdmin;
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
/** isAdmin () - Renvoie true si l'utilisateur est administrateur du type de fiche spécifié
|
|
|
92 |
*
|
|
|
93 |
* @param interger type_annonce Le type de l'annonce
|
|
|
94 |
*
|
|
|
95 |
*/
|
|
|
96 |
|
|
|
97 |
function isAdmin($id_nature) {
|
|
|
98 |
// on court-circuite si l'utilisateur n'est pas loggué
|
|
|
99 |
if (!$this->_auth->getAuth()) return false ;
|
|
|
100 |
|
|
|
101 |
return $this->_requeteDroit ($id_nature, 1) ;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
/** isRedacteur() - Renvoie true si l'utilisateur est rédacteur du type de fiche spécifié
|
|
|
105 |
*
|
|
|
106 |
*/
|
|
|
107 |
|
|
|
108 |
function isRedacteur($id_nature) {
|
|
|
109 |
return $this->_requeteDroit ($id_nature, 2) ;
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
/** _requeteDroit() - fait une requete sur la table bazar_droit
|
|
|
113 |
*
|
|
|
114 |
*/
|
|
|
115 |
|
|
|
116 |
function _requeteDroit ($id_nature, $niveau) {
|
|
|
117 |
$requete = 'select bd_niveau_droit FROM bazar_droits WHERE bd_id_utilisateur='
|
|
|
118 |
.$this->_auth->getAuthData(BAZ_CHAMPS_ID).
|
|
|
119 |
' AND bd_id_nature_offre="'.$id_nature.'" and bd_niveau_droit='.$niveau;
|
|
|
120 |
|
|
|
121 |
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete) ;
|
|
|
122 |
if (DB::isError($resultat)) {
|
|
|
123 |
die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
|
|
|
124 |
}
|
|
|
125 |
if ($resultat->numRows() != 0) {
|
|
|
126 |
return true ;
|
|
|
127 |
}
|
|
|
128 |
return false ;
|
|
|
129 |
}
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
|
|
133 |
*
|
|
|
134 |
* $Log: not supported by cvs2svn $
|
|
|
135 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
|
|
136 |
*/
|
|
|
137 |
?>
|