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); } }