/** * Edit an acion of a controller * * Change status and description * * @return array */ public function saveEditActionAction() { $actionModel = new Admin_Model_DbTable_Acl_Action(); $actionRow = $actionModel->find($this->request->getParam('id', 0)); if ($actionRow->count() === 1) { $actionRow = new Admin_Model_DbRow_Action($actionRow->current()); $actionRow->fromArray(array('enabled' => $this->request->getParam('enabled', 'off') == 'on' ? 1 : 0, 'description' => $this->request->getParam('description', ''))); $actionModel->updateById($actionRow->toDbArray(array('enabled', 'description')), $actionRow->get('id')); return $this->responseSuccess(); } else { return $this->responseFailure('Failed saving informations', 'Could not find Action Id'); } }
/** * Change the Status of a controller (enabled/disabled) * * @view views/scripts/controller/status.phtml * @access public */ public function statusAction() { $ctrlRow = new Admin_Model_DbRow_Controller($this->dbCtrl->find($this->checkControllerIdParam())); $ctrlRow->set('enabled', $ctrlRow->get('enabled') == 1 ? 0 : 1); $this->dbCtrl->update($ctrlRow->toDbArray(array('enabled')), $ctrlRow->get('id')); // disabled all actions too, they are relevant in the ACL if ($ctrlRow->get('enabled') === 0) { $actionRow = new Admin_Model_DbRow_Action(array('enabled' => 0)); $actionDbModel = new Admin_Model_DbTable_Acl_Action(); $actionDbModel->updateWithControllerId($actionRow->toDbArray(array('enabled')), $ctrlRow->get('id')); } $this->_redirect('admin/controller/index'); }
/** * Edit an Action * * @view views/scripts/action/delete.phtml * @access public */ public function editAction() { $actionRow = new Admin_Model_DbRow_Action(); $ctrlRow = new Admin_Model_DbRow_Controller(); $action = $this->dbAction->find($this->checkActionIdParam()); if ($action->count() !== 1) { $form = new Admin_Form_Action_Edit($ctrlRow, $actionRow); $form->setErrors(array('Invalid ActionId, cannot proceed!')); $form->setAction('/noc/admin/action/edit'); } else { $actionRow->fromArray($action); $ctrlRow->fromArray($this->dbController->find($actionRow->get('mcId'))); $form = new Admin_Form_Action_Edit($ctrlRow, $actionRow); $form->setAction('/noc/admin/action/edit'); if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getParams())) { $actionRow->set('description', $this->getRequest()->getParam('description')); $this->dbAction->updateById($actionRow->toDbArray(array('description')), $actionRow->get('id')); $this->_redirect('admin/action/index/control/' . $ctrlRow->get('id')); } } } $this->view->form = $form; $this->view->controller = $ctrlRow; }