3 * @file class_erConfig.inc
4 * Class that handles the configuration
5 * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
8 * Copyright © 2007 Roland Hieber
10 * Permission is hereby granted, free of charge, to any person obtaining
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 require_once("sec/secure.inc");
30 require_once("mod_error-reporter/functions.inc");
31 require_once("db.inc");
37 * Determine if a privilege has been assigned
38 * @param $sPriv (string) Privilege to test
41 public static function privilegeAssigned($sPriv) {
42 $h = db_query("SELECT act FROM privileges_assign WHERE privilege = $1;",
44 return pg_num_rows($h) > 0;
48 * Retrieve all groups that have a privilege assigned
49 * @param $strPriv (string) Privilege to test
52 public static function privilegedGroups($strPriv) {
54 $h = db_query("SELECT act FROM privileges_assign WHERE privilege = $1 ".
55 "ORDER BY act;", $strPriv);
56 if(pg_num_rows($h) > 0) {
57 while($a = pg_fetch_array($h)) {
58 $aReturn[] = $a["act"];
65 * Determine if the current user is allowed to see and report errors. This
66 * function tests if the user is member of a group which has the
67 * <tt>mod-errorreporter_access</tt> privilege.
70 public static function userHasAccess() {
71 if(erConfig::userIsAdmin() ||
72 !erConfig::privilegeAssigned("mod_errorreporter_access")) {
73 // user is admin or privilege is not assigned
76 return secure_privilege("mod_errorreporter_access");
81 * Determine if the current user has admin rights. This function tests if
82 * the user is member of a group which has the
83 * <tt>mod-errorreporter_access</tt> privilege
86 public static function userIsAdmin() {
87 return secure_privilege("mod_errorreporter_admin");