/** * @secured * @param string $aclRoleID */ public function handleDeleteRole($aclRoleID) { if ($this->user->isAllowed("permission", "delete")) { if (is_string($aclRoleID)) { try { $aclRoleID = (array) Json::decode($aclRoleID); $aclRoleID = array_values($aclRoleID); } catch (JsonException $e) { $this['notification']->addError($e->getMessage()); if ($this->isAjax()) { $this['notification']->redrawControl('error'); } } } $result = $this->permissionManager->remove($aclRoleID); if ($result === TRUE) { $this['notification']->addSuccess("Úspěšně uloženo..."); } else { if (strpos("Integrity constraint violation", $result) != -1) { $this['notification']->addError("Skupinu stále využívá někdo z uživatelů, proto ji nebylo možné vymazat."); } else { $this['notification']->addError($result); } } } if ($this->isAjax()) { $this['notification']->redrawControl('error'); $this['notification']->redrawControl('success'); $this['grid']->redrawControl(); } }
/** Submit * * @param \Nette\Application\UI\Form $form */ public function Submit(Form $form) { $json = new \stdClass(); $json->result = "success"; $values = $form->getValues(); if (!empty($values['aclRoleID'])) { if ($this->user->isAllowed("permission", "edit")) { $result = $this->permissionManager->update($values); } else { $result = RoleForm::PERMISSION; } } else { if ($this->user->isAllowed("permission", "add")) { $result = $this->permissionManager->insert($values); } else { $result = RoleForm::PERMISSION; } } /*Debugger::dump($values); exit();*/ if ($result === TRUE) { $json->result = "success"; } else { $json->result = "error"; $json->message = $result; } $response = new JsonResponse($json); $this->getPresenter()->sendResponse($response); }