Get group action permissions
public static getActionPermissions ( integer $id ) : array | ||
$id | integer | The id of the group. |
return | array |
/** * Load the form */ private function loadForm() { $this->frm = new BackendForm('edit'); // get selected permissions $modulePermissions = BackendGroupsModel::getModulePermissions($this->id); $actionPermissions = BackendGroupsModel::getActionPermissions($this->id); // add selected modules to array foreach ($modulePermissions as $permission) { $selectedModules[] = $permission['module']; } // loop through modules foreach ($this->modules as $key => $module) { // widgets available? if (isset($this->widgets)) { // loop through widgets foreach ($this->widgets as $j => $widget) { // widget is present? if (isset($this->dashboardSequence[$module['value']][$widget['value']]['present']) && $this->dashboardSequence[$module['value']][$widget['value']]['present'] === true && $widget['checkbox_name'] == $module['value'] . $widget['value']) { $selectedWidgets[$j] = $widget['checkbox_name']; } // add widget checkboxes $widgetBoxes[$j]['checkbox'] = '<span>' . $this->frm->addCheckbox('widgets_' . $widget['checkbox_name'], isset($selectedWidgets[$j]) ? $selectedWidgets[$j] : null)->parse() . '</span>'; $widgetBoxes[$j]['module'] = \SpoonFilter::ucfirst(BL::lbl($widget['module_name'])); $widgetBoxes[$j]['widget'] = '<label for="widgets' . \SpoonFilter::toCamelCase($widget['label']) . '">' . $widget['label'] . '</label>'; $widgetBoxes[$j]['description'] = $widget['description']; } } $selectedActions = array(); // loop through action permissions foreach ($actionPermissions as $permission) { // add to selected actions if ($permission['module'] == $module['value']) { $selectedActions[] = $permission['action']; } } // add module labels $permissionBoxes[$key]['label'] = $module['label']; // init var $addedBundles = array(); // loop through actions foreach ($this->actions[$module['value']] as $i => $action) { // action is bundled? if (array_key_exists('group', $action)) { // bundle not yet in array? if (!in_array($action['group'], $addedBundles)) { // assign bundled action boxes $actionBoxes[$key]['actions'][$i]['checkbox'] = $this->frm->addCheckbox('actions_' . $module['label'] . '_' . 'Group_' . \SpoonFilter::ucfirst($action['group']), in_array($action['value'], $selectedActions))->parse(); $actionBoxes[$key]['actions'][$i]['action'] = \SpoonFilter::ucfirst($action['group']); $actionBoxes[$key]['actions'][$i]['description'] = $this->actionGroups[$action['group']]; // add the group to the added bundles $addedBundles[] = $action['group']; } } else { // assign action boxes $actionBoxes[$key]['actions'][$i]['checkbox'] = $this->frm->addCheckbox('actions_' . $module['label'] . '_' . $action['label'], in_array($action['value'], $selectedActions))->parse(); $actionBoxes[$key]['actions'][$i]['action'] = '<label for="actions' . \SpoonFilter::toCamelCase($module['label'] . '_' . $action['label']) . '">' . $action['label'] . '</label>'; $actionBoxes[$key]['actions'][$i]['description'] = $action['description']; } } // widgetboxes available? if (isset($widgetBoxes)) { // create datagrid $widgetGrid = new BackendDataGridArray($widgetBoxes); $widgetGrid->setHeaderLabels(array('checkbox' => '<span class="checkboxHolder"><input id="toggleChecksWidgets" type="checkbox" name="toggleChecks" value="toggleChecks" /></span>')); // get content $widgets = $widgetGrid->getContent(); } // create datagrid $actionGrid = new BackendDataGridArray($actionBoxes[$key]['actions']); // disable paging $actionGrid->setPaging(false); // get content of datagrids $permissionBoxes[$key]['actions']['dataGrid'] = $actionGrid->getContent(); $permissionBoxes[$key]['chk'] = $this->frm->addCheckbox($module['label'], null, 'inputCheckbox checkBeforeUnload selectAll')->parse(); $permissionBoxes[$key]['id'] = \SpoonFilter::toCamelCase($module['label']); } // create elements $this->frm->addText('name', $this->record['name']); $this->frm->addDropdown('manage_users', array('Deny', 'Allow')); $this->frm->addDropdown('manage_groups', array('Deny', 'Allow')); $this->tpl->assign('permissions', $permissionBoxes); $this->tpl->assign('widgets', isset($widgets) ? $widgets : false); }