1
Hello!
Sometimes we have to verify (without making changes) what permissions has been set. When it is more complex site (intranet) we have many groups and many categories which produce matrix of thousands checkboxes. It's hard to see anything in that big forms.
So I have made script to prints html table of groups and only those items to which permission was assigned.
I'm not a good programmer. It's only a concept.
function showPermTab($permarr) {
global $xoopsDB, $xoopsModule;
$module_id = $xoopsModule->getVar('mid');
$sysperm_handler =& xoops_gethandler('groupperm');
//get groups
$result = $xoopsDB->query("SELECT groupid, name FROM ".$xoopsDB->prefix('groups'));
$print='';
while ($row=$xoopsDB->fetchArray($result)){
$print.=''.$row['name'].' | '; //start new tables' row with group name
//for each permission (add, edit, del, etc.) generate |
for($i=1;$i<=count($permarr);$i++) {
$items=$sysperm_handler->getItemIds($permarr[$i]['perm_name'], $row['groupid'], $module_id);
if(!empty($items)) {
$tbl=getItemsName($items);// custom function - returns names from items id
$print.=' ->'.$permarr[$i]['perm_name'].': '.$tbl.' | ';
}
}
$print.='
';
}
$print.='
';
echo $print;
}
//sample permissions
$permarr=array();
$permarr[1]['title_of_form'] = 'Delete permissions';
$permarr[1]['perm_name'] = 'del';
$permarr[1]['perm_desc'] = '';
$permarr[2]['title_of_form'] = 'Add permissions';
$permarr[2]['perm_name'] = 'add';
$permarr[2]['perm_desc'] = '';
$permarr[3]['title_of_form'] = 'Edit permissions';
$permarr[3]['perm_name'] = 'edit';
$permarr[3]['perm_desc'] = '';
showPermTab($permarr);
It will be nice to see that kind of functionality in Xoops.