public function setpermissionstoadminAction() { if ($data = $this->getRequest()->getPost()) { try { if (empty($data["admin_id"]) or empty($data["app_id"])) { throw new Exception($this->_("1An error occurred while saving. Please try again later.")); } $admin = new Admin_Model_Admin(); $admin->find($data["admin_id"]); if (($admin->getId() or $admin->getParentId()) and ($admin->getId() != $this->getAdmin()->getId() and $admin->getParentId() != $this->getAdmin()->getId())) { $this->getSession()->addError("This administrator does not exist"); } $application = new Application_Model_Application(); $application->find($data["app_id"]); if (!$application->getId()) { throw new Exception($this->_("2An error occurred while saving. Please try again later.")); } if (!$application->hasAsAdmin($this->getAdmin()->getId())) { throw new Exception($this->_("3An error occurred while saving. Please try again later.")); } $admin->setIsAllowedToAddPages(!empty($data["is_selected"])); $application->addAdmin($admin); $data = array("success" => 1); } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } $this->_sendHtml($data); } }
public function deleteAction() { if ($admin_id = $this->getRequest()->getParam('admin_id') and !$this->getSession()->getAdmin()->getParentId()) { try { $admin = new Admin_Model_Admin(); $admin->find($admin_id); if (!$admin->getId()) { throw new Exception($this->_("This administrator does not exist")); } else { if (!$admin->getParentId()) { throw new Exception($this->_("You can't delete the main account")); } } $admin->delete(); $html = array('success' => 1, 'admin_id' => $admin_id); } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage()); } $this->_sendHtml($html); } }