/** * Grabs the whole list of permissions plus whether or not the group has it. * * This method is slow. * * @rdbms-specific MySQL 4/5-specific due to IF(). * @param StaffGroup $group_id The group. * @param object $db PEAR::DB connector. * @return array array(array('permission' => StaffPermission, * 'group_has' => bool * ) * ) **/ public static function grabPermissionsForGroup(StaffGroup &$group, $db) { $permissions = new StaffPermission($db); $permissions = $permissions->findBy(array()); $RETURN = array(); foreach ($permissions as $permission) { $RETURN[] = array('permission' => $permission, 'group_has' => $group->hasPermission($permission->getApiName())); } // end permission loop return $RETURN; }
$renderer->assign('permissions', $CHECKBOXES); $renderer->assign('permission_defaults', $CHECKBOX_DEFAULTS); $renderer->assign('group', $GROUP); if ($group != null) { $renderer->display('admin/permissions/edit.tpl'); } else { $renderer->display('admin/permissions/new.tpl'); } break; // end default // end default case 'save': $GROUP = array('name' => trim(stripinput($_POST['group']['name'])), 'description' => trim(clean_xhtml($_POST['group']['descr'], false)), 'order_by' => trim(stripinput($_POST['group']['order_by'])), 'show' => trim(stripinput($_POST['group']['show']))); // If the group could not be loaded, start making a new one. if ($group == null) { $group = new StaffGroup($db); } if ($GROUP['name'] == null) { $ERRORS[] = 'No name specified.'; } elseif (strlen($GROUP['name']) > 50) { $ERRORS[] = 'There is a maxlength=50 on that field for a reason.'; } if ($GROUP['description'] == null) { $ERRORS[] = 'No description specified.'; } if (in_array($GROUP['show'], array_keys($Y_N)) == false) { $ERRORS[] = 'Invalid option for show on staff list specified.'; } if (sizeof($ERRORS) > 0) { draw_errors($ERRORS); } else {