/** * Load the form * * @return void */ private function loadForm() { // create form $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) { // add to array $selectedWidgets[$j] = $widget['value']; } // add widget checkboxes $widgetBoxes[$j]['checkbox'] = '<span>' . $this->frm->addCheckbox('widgets_' . $widget['label'], isset($selectedWidgets[$j]) ? $selectedWidgets[$j] : null)->parse() . '</span>'; $widgetBoxes[$j]['widget'] = $widget['label']; $widgetBoxes[$j]['description'] = $widget['description']; } } // init var $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'] = '<span>' . $this->frm->addCheckbox('actions_' . $module['label'] . '_' . 'Group_' . ucfirst($action['group']), in_array($action['value'], $selectedActions))->parse() . '</span>'; $actionBoxes[$key]['actions'][$i]['action'] = 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'] = '<span>' . $this->frm->addCheckbox('actions_' . $module['label'] . '_' . $action['label'], in_array($action['value'], $selectedActions))->parse() . '</span>'; $actionBoxes[$key]['actions'][$i]['action'] = $action['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 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(); } // 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); }