6 * Copyright 2012, Roland Mas
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require (dirname(__FILE__).'/../common/include/env.inc.php');
25 require_once $gfcommon.'include/pre.php';
27 if (count ($argv) < 3) {
28 echo "Usage: .../forge_check_perm_for_user <username> <section_name> [ref_id] [perm]
34 if (count ($argv) >= 4) {
39 if (count ($argv) >= 5) {
44 $user = user_get_object_by_name ($u) ;
45 if (!$user || $user->isError()) {
46 echo "Can't find this user...
51 $un = $user->getUnixName();
52 echo "forge_check_perm_for_user ($un, $s, $r, $a))\n";
54 $engine = RBACEngine::getInstance();
55 $rs = $engine->getAvailableRolesForUser($user);
56 foreach ($rs as $role) {
57 print $role->getID()." = ".$role->getDisplayableName()." = ".$role->getSetting($s, $r);
58 if ($role->hasPermission ($s, $r, $a)) {
65 if (forge_check_perm_for_user ($user, $s, $r, $a)) {
75 // c-file-style: "bsd"