How about this:
function checkPerm(){
require_once(WB_PATH.'/framework/class.wb.php');
global $page_id, $database;
$wb = new wb;
//Borrowed code from Frontend Edit snippet.
if (is_numeric($wb->get_session('USER_ID'))) {
/**
* Get permissons
*/
if ($page_id)
$this_page = $page_id;
else
$this_page = $wb->default_page_id;
$results = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$this_page'");
$results_array = $results->fetchRow();
$old_admin_groups = explode(',', $results_array['admin_groups']);
$old_admin_users = explode(',', $results_array['admin_users']);
$this_user = $wb->get_session('GROUP_ID');
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '".$page_id."'";
$get_pages = $database->query($query);
$page = $get_pages->fetchRow();
$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
$in_group = FALSE;
foreach($wb->get_groups_id() as $cur_gid)
if (in_array($cur_gid, $admin_groups)) $in_group = TRUE;
if (($in_group) OR is_numeric(array_search($this_user, $old_admin_groups)) ) {
return TRUE;
}
}
}
You can then call it with:
if(checkPerm() == TRUE) {
//code to execute if user is in admin group for this module
} else {
//code to run otherwise
}
As the comment in the code states, most of this is from the frontend edit snippet. I've used it in a few projects on an intranet and haven't had any issues. However, I do think it would be nice to have a built in function for this type of thing. I'm working on a couple modules that allow frontend editing and have been making due with this.
Nick