Subversion Repositories Applications.bazar

Rev

Rev 99 | Rev 205 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 99 Rev 110
Line 17... Line 17...
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
*/
Line 33... Line 33...
33
 
33
 
34
// +------------------------------------------------------------------------------------------------------+
34
// +------------------------------------------------------------------------------------------------------+
Line 39... Line 39...
39
// +------------------------------------------------------------------------------------------------------+
39
// +------------------------------------------------------------------------------------------------------+
40
// |                                            ENTETE du PROGRAMME                                       |
40
// |                                            ENTETE du PROGRAMME                                       |
41
// +------------------------------------------------------------------------------------------------------+
41
// +------------------------------------------------------------------------------------------------------+
Line 42... Line 42...
42
 
42
 
Line 43... Line 43...
43
 
43
 
-
 
44
class Administrateur_bazar {
-
 
45
 
-
 
46
	var $_auth ;
-
 
47
	
-
 
48
	/**
-
 
49
	 * Identifiant de l'utilisateur
Line 44... Line 50...
44
class Utilisateur_bazar {
50
	 */
45
 
51
	
46
	var $_auth ;
52
	var $_id_utilisateur ;
47
 
53
 
Line 55... Line 61...
55
	 * @param	object Un objet authentification
61
	 * @param	object Un objet authentification
56
	 * @return void
62
	 * @return void
57
	 * 
63
	 * 
58
	 */
64
	 */
Line 59... Line 65...
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) ;
Line 62... Line 69...
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
Line 71... Line 78...
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 ;
Line 73... Line 80...
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.
Line 77... Line 84...
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) ;
Line 113... Line 120...
113
	 * 
120
	 * 
114
	 */
121
	 */
Line 115... Line 122...
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.
Line 119... Line 126...
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) ;
Line 127... Line 134...
127
		}
134
		}
128
		return false ;
135
		return false ;
129
	}
136
	}
130
}
137
}
Line -... Line 138...
-
 
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
*
-
 
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
134
* $Log: not supported by cvs2svn $
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 ----------------------------------------------------------------------------------------+