/** * Add a new controller to the database (from scanning section) * * @view views/scripts/controller/add.phtml * @access public * @todo add validation on parameters */ public function addAction() { $row = new Admin_Model_DbRow_Controller(array('moduleName' => $this->getRequest()->getParam('modul', ''), 'controllerName' => $this->getRequest()->getParam('control', ''), 'enabled' => 0, 'virtual' => $this->getRequest()->getParam('virtual', 0), 'description' => $this->getRequest()->getParam('description', ''))); $form = new Admin_Form_Controller_Add($row); $form->setAction('/noc/admin/controller/add'); if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getParams())) { $this->dbCtrl->insert($row->toDbArray(array('moduleName', 'controllerName', 'enabled', 'virtual', 'description'))); $this->_redirect('admin/controller/scan'); } } $this->view->form = $form; }
/** * Save a new Controller to the database * * @return array */ public function saveAddControllerAction() { $row = new Admin_Model_DbRow_Controller(array('moduleName' => $this->request->getParam('moduleName', ''), 'controllerName' => $this->request->getParam('controllerName', ''), 'enabled' => $this->request->getParam('enabled', 'off') == 'on' ? 1 : 0, 'virtual' => $this->request->getParam('virtual', '0') == 1 ? 1 : 0, 'description' => $this->request->getParam('description', ''))); $modContrModel = new Admin_Model_DbTable_Acl_ModuleController(); $modContrRow = $modContrModel->findbyName($row->get('moduleName', ''), $row->get('controllerName', '')); if ($modContrRow->count() === 0) { $modContrModel->insert($row->toDbArray(array('moduleName', 'controllerName', 'enabled', 'virtual', 'description'))); return $this->responseSuccess(array('data' => $row->toDbArray())); } else { return $this->responseFailure('Failed adding Controller', 'Module/Controller already in the database'); } }