public function getPermission($createIfNotExist = false) { if (!isset($this->permission)) { $this->permission = \Rebond\Core\Permission\Data::loadById($this->permissionId, $createIfNotExist); } return $this->permission; }
public function buildPermissions() { $options = []; $options['clearSelect'] = true; $options['select'][] = \Rebond\Core\Permission\Data::getList(['id', 'title']); $options['where'][] = 'permission.status IN (0,1)'; $options['order'][] = 'permission.title'; $items = \Rebond\Core\Permission\Data::loadAll($options); $options['clearSelect'] = true; $options['select'][] = \Rebond\Core\RolePermission\Data::getList(['permission_id']); $permissions = \Rebond\Core\RolePermission\Data::loadAllByRoleId($this->getModel()->getId()); $selectedValues = []; if (isset($permissions)) { foreach ($permissions as $permission) { $selectedValues[] = $permission->getPermissionId(); } } return Util\Form::buildCheckboxList('permission' . $this->unique, $items, 'id', 'title', $selectedValues); }
public function buildPermission() { $options = []; $options['clearSelect'] = true; $options['select'][] = \Rebond\Core\Permission\Data::getList(['id', 'title']); $models = \Rebond\Core\Permission\Data::loadAll($options); return Util\Form::buildDropdownList('permissionId' . $this->unique, $models, 'id', 'title', $this->getModel()->getPermissionId(), $this->permissionValidator['foreignKey']); }
protected static function mapper(array $row, $alias = 'role_permission') { $model = new \Rebond\Core\RolePermission\Model(false); if (isset($row[$alias . 'RoleId'])) { $model->setRoleId($row[$alias . 'RoleId']); $model->setRole(\Rebond\Core\Role\Data::join($row, $alias . '_role')); } if (isset($row[$alias . 'PermissionId'])) { $model->setPermissionId($row[$alias . 'PermissionId']); $model->setPermission(\Rebond\Core\Permission\Data::join($row, $alias . '_permission')); } return $model; }
public function permission_edit() { // auth Auth::isAdminAuthorized($this->signedUser, 'admin.user.permission', true, '/user'); // check $id = Converter::int('id'); $save = Converter::int('save', 'post'); $permission = \Rebond\Core\Permission\Data::loadById($id, true); $form = new \Rebond\Core\Permission\Form($permission); // action if (isset($save)) { Auth::isAdminAuthorized($this->signedUser, 'admin.user.permission.edit', true, '/user/permission-edit?id=' . $id); if ($form->setFromPost()->validate()->isValid()) { $permission->save(); Session::adminSuccess('saved', '/user/permission'); } else { Session::set('adminError', $form->getValidation()->getMessage()); } } // view $this->setTpl(); // main $tplMain = new Template(Template::MODULE, ['core', 'permission']); $tplMain->set('item', $form); // layout if (Auth::isAdminAuthorized($this->signedUser, 'admin.user.permission.edit', false)) { $this->tplLayout->set('column1', $tplMain->render('editor')); } else { $this->tplLayout->set('column1', $tplMain->render('view')); } // master $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col')); return $this->tplMaster->render('tpl-default'); }