/** * Add an action from the module/controller to action DbTable * Forwards to the edit action method * * @view views/scripts/action/add.phtml * @access public * @todo Add Exception handling / error notifications to user */ public function addAction() { $ctrl = $this->dbController->find($this->checkControllerIdParam()); $action = $this->getRequest()->getParam('actionname', NULL); if ($action === NULL || $ctrl->count() !== 1) { throw new Admin_Model_Acl_Exception('Invalid or no ActionName/ControllerId Parameter given'); } $ctrl = new Admin_Model_DbRow_Controller($ctrl->current()); $form = new Admin_Form_Action_Add($ctrl, $action); $form->setAction('/noc/admin/action/add'); if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getParams())) { $actionRow = new Admin_Model_DbRow_Action(array('mcId' => $ctrl->get('id'), 'actionName' => $this->getRequest()->getParam('actionname'), 'enabled' => 0, 'description' => $this->getRequest()->getParam('description', ''))); $this->dbAction->insert($actionRow->toDbArray()); $this->_redirect('admin/action/scan/control/' . $ctrl->get('id')); } else { $form->addError('Exexpected error occured'); } } $this->view->form = $form; $this->view->controller = $ctrl; }
/** * Add a new scanned action to db * @return array */ public function saveAddActionAction() { $modContrModel = new Admin_Model_DbTable_Acl_ModuleController(); $actionModel = new Admin_Model_DbTable_Acl_Action(); $modContrRow = $modContrModel->findbyName($this->request->getParam('moduleName', ''), $this->request->getParam('controllerName', '')); $actionRow = new Admin_Model_DbRow_Action($this->request->getParams()); if ($modContrRow->count() === 1 && $actionRow->get('actionName')) { $modContrRow = new Admin_Model_DbRow_Controller($modContrRow->current()); $actionRow->fromArray(array('mcId' => $modContrRow->get('id'), 'actionName' => $this->request->getParam('actionName'), 'enabled' => $this->request->getParam('enabled', 'off') == 'on' ? 1 : 0, 'description' => $this->request->getParam('description', ''))); $actionModel->insert($actionRow->toDbArray()); return $this->responseSuccess($actionRow->toDbArray()); } else { return $this->responseFailure('Failed Saving informations', 'Controller is not valid, cannot add action'); } }