/**
  * Delete an Controller from the database, which does not exists
  * as an controller file anymore.
  * Delete also from all releveant tables like
  *  - actions
  *  - rules
  *
  * @view views/scripts/controller/delete.phtml
  * @access public
  */
 public function deleteAction()
 {
     $ctrlRow = new Admin_Model_DbRow_Controller($this->dbCtrl->find($this->checkControllerIdParam()));
     $form = new Admin_Form_Controller_Delete($ctrlRow);
     $form->setAction('/noc/admin/controller/delete');
     if ($ctrlRow->get('id')) {
         if ($this->getRequest()->isPost()) {
             if ($form->isValid($this->getRequest()->getParams()) === TRUE && $form->getElement('chkdelete')->isChecked() === TRUE) {
                 // delete the model controller
                 $this->dbCtrl->deleteById($ctrlRow->get('id'));
                 // delete all actions for this module / controller
                 $actionDbModel = new Admin_Model_DbTable_Acl_Action();
                 $actionDbModel->deleteByControllerId($ctrlRow->get('id'));
                 // delete all rules which are bound to this module / controller
                 $rulesDbModel = new Admin_Model_DbTable_Acl_Rule();
                 $rulesDbModel->deleteByControllerId($ctrlRow->get('id'));
                 $this->_redirect('admin/controller/scan');
             } else {
                 $form->addErrors(array('Delete not successfull. Did you checked the checkbox?'));
             }
         }
     } else {
         $form->addErrors(array('Invalid Controller Id, cannot proceed'));
     }
     $this->view->form = $form;
 }
Exemplo n.º 2
0
 /**
  * Delete a Controller from the Database
  *
  * @return array
  */
 public function saveDeleteControllerAction()
 {
     $modContrModel = new Admin_Model_DbTable_Acl_ModuleController();
     $modContrRow = $modContrModel->find($this->request->getParam('id', 0));
     if ($modContrRow->count() === 1) {
         // initiate action and role model, because they reference to module/controller
         $actionModel = new Admin_Model_DbTable_Acl_Action();
         $rulesModel = new Admin_Model_DbTable_Acl_Rule();
         $modContrRow = new Admin_Model_DbRow_Controller($modContrRow->current());
         // delete all attached actions and rules
         $modContrModel->deleteById($modContrRow->get('id'));
         $actionModel->deleteByControllerId($modContrRow->get('id'));
         $rulesModel->deleteByControllerId($modContrRow->get('id'));
         return $this->responseSuccess();
     } else {
         return $this->responseFailure('Failed deleting Controller', 'Controller Id is not valid');
     }
 }