public function getPermission($createIfNotExist = false) { if (!isset($this->permission)) { $this->permission = \Rebond\Core\Permission\Data::loadById($this->permissionId, $createIfNotExist); } return $this->permission; }
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'); }