![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: acls_view.php 141 2008-04-05 16:41:20Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/system/acls_view.php $ */ 2 if (!defined('W2P_BASE_DIR')) { 3 die('You should not access this file directly.'); 4 } 5 global $AppUI, $m, $a; 6 7 $perms = &$AppUI->acl(); 8 if (!$perms->checkModule('system', 'view')) { 9 $AppUI->redirect('m=public&a=access_denied'); 10 } 11 12 $user_permissions = array(); 13 $users = w2PgetUsers(); 14 /*echo("<pre>"); 15 print_r($permissions); 16 echo("</pre>");*/ 17 18 if ($_POST['user'] != '') { 19 $q = new DBQuery; 20 $q->addTable($perms->_db_acl_prefix . 'permissions', 'gp'); 21 $q->addQuery('gp.*'); 22 $q->addWhere('user_id IN (' . implode(',', array_keys($users)) . ')'); 23 if ($_POST['user']) { 24 $q->addWhere('user_id = ' . (int)$_POST['user']); 25 } 26 if ($_POST['module']) { 27 $q->addWhere('module = \'' . $_POST['module'] . '\''); 28 } 29 if ($_POST['action']) { 30 $q->addWhere('action = \'' . $_POST['action'] . '\''); 31 } 32 $q->addOrder('user_name'); 33 $q->addOrder('module'); 34 $q->addOrder('action'); 35 $q->addOrder('item_id'); 36 $q->addOrder('acl_id'); 37 $permissions = $q->loadList(); 38 } else { 39 $permissions = array(); 40 } 41 42 $avail_modules = $perms->getModuleList(); 43 $modules = array(); 44 foreach ($avail_modules as $avail_module) { 45 $modules[$avail_module['value']] = $avail_module['value']; 46 } 47 $modules = array(0 => 'All Modules') + $modules; 48 49 $actions = array(0 => 'All Actions', 'access' => 'access', 'add' => 'add', 'delete' => 'delete', 'edit' => 'edit', 'view' => 'view'); 50 51 $table = '<table class="tbl" width="100%" cellspacing="1" cellpadding="2" border="0">'; 52 $table .= '<tr><th colspan="9"><b>Permission Result Table</b></th></tr>'; 53 $table .= '<tr><th>UserID</th><th>User</th><th>User Name</th><th>Module</th><th>Item</th><th>Item Name</th><th>Action</th><th>Allow</th><th>ACL_ID</th></tr>'; 54 foreach ($permissions as $permission) { 55 $item = ''; 56 if ($permission['item_id']) { 57 $q = new DBQuery; 58 $q->addTable('modules'); 59 $q->addQuery('permissions_item_field,permissions_item_label'); 60 $q->addWhere('mod_directory = \'' . $permission['module'] . '\''); 61 $field = $q->loadHash(); 62 63 $q = new DBQuery; 64 $q->addTable($permission['module']); 65 $q->addQuery($field['permissions_item_label']); 66 $q->addWhere($field['permissions_item_field'] . ' = \'' . $permission['item_id'] . '\''); 67 $item = $q->loadResult(); 68 } 69 if (!($permission['item_id'] && !$permission['acl_id'])) { 70 $table .= '<tr>' . '<td style="text-align:right;">' . $permission['user_id'] . '</td>' . '<td>' . $permission['user_name'] . '</td>' . '<td>' . $users[$permission['user_id']] . '</td>' . '<td>' . $permission['module'] . '</td>' . '<td style="text-align:right;">' . ($permission['item_id'] ? $permission['item_id'] : '') . '</td>' . '<td>' . ($item ? $item : 'ALL') . '</td>' . '<td>' . $permission['action'] . '</td>' . '<td ' . (!$permission['access'] ? 'style="text-align:right;background-color:red"' : 'style="text-align:right;background-color:green"') . '>' . $permission['access'] . '</td>' . '<td ' . ($permission['acl_id'] ? '' : 'style="background-color:gray"') . '>' . ($permission['acl_id'] ? $permission['acl_id'] : 'soft-denial') . '</td>' . '</tr>'; 71 } 72 } 73 $table .= '</table>'; 74 $users = array('' => '(' . $AppUI->_('Select User') . ')') + $users; 75 $user_selector = arraySelect($users, 'user', 'class="text" onchange="javascript:document.pickUser.submit()"', ($_POST['user'] != '' ? $_POST['user'] : '')); 76 $module_selector = arraySelect($modules, 'module', 'class="text" onchange="javascript:document.pickUser.submit()"', ($_POST['module'] ? $_POST['module'] : 0)); 77 $action_selector = arraySelect($actions, 'action', 'class="text" onchange="javascript:document.pickUser.submit()"', ($_POST['action'] ? $_POST['action'] : 0)); 78 echo $AppUI->_('View Users Permissions') . ':<form action="?m=system&a=acls_view" method="post" name="pickUser">' . $user_selector . $AppUI->_('View by Module') . ':' . $module_selector . $AppUI->_('View by Action') . ':' . $action_selector . '</form><br />'; 79 echo $table; 80 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jan 8 03:00:03 2009 | Cross-referenced by PHPXref 0.7 |