1
bumciach
Permissions preview
  • 2009/1/8 10:58

  • bumciach

  • Not too shy to talk

  • Posts: 153

  • Since: 2007/6/25


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='<table border="1">';
  while (
$row=$xoopsDB->fetchArray($result)){
    
$print.='<tr><td>'.$row['name'].'</td>'//start new tables' row with group name
    //for each permission (add, edit, del, etc.) generate <td></td>
    
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.='<td> ->'.$permarr[$i]['perm_name'].': '.$tbl.'</td>';
      }
    }
    
$print.='</tr>';
  }
  
$print.='</table>';
  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.

2
webmystar
Re: Permissions preview
  • 2009/1/8 17:20

  • webmystar

  • Friend of XOOPS

  • Posts: 415

  • Since: 2008/6/23


i think It's a Good Idea!

Login

Who's Online

236 user(s) are online (150 user(s) are browsing Support Forums)


Members: 0


Guests: 236


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits