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