/** * Deletes a module. * * Deletes the module entries, the module itself, * the databasemanager entry and the table itself. * * REQUIRES request parameters: * <pre> * - integer <b>id</b> id of the item to delete. * </pre> * * The return is a string in JSON format with: * <pre> * - type => 'success'. * - message => Success message. * - id => id of the deleted item. * </pre> * * @throws Zend_Controller_Action_Exception On missing or wrong id, or on error in the action delete. * * @return void */ public function jsonDeleteAction() { $id = (int) $this->getRequest()->getParam('id'); if (empty($id)) { throw new Zend_Controller_Action_Exception(self::ID_REQUIRED_TEXT, 400); } $model = $this->getModelObject()->find($id); if ($model instanceof Phprojekt_ActiveRecord_Abstract) { if (is_dir(PHPR_CORE_PATH . $model->name)) { throw new Zend_Controller_Action_Exception(self::CAN_NOT_DELETE_SYSTEM_MODULE, 422); } $databaseModel = Phprojekt_Loader::getModel($model->name, $model->name); if ($databaseModel instanceof Phprojekt_Item_Abstract) { $databaseManager = new Phprojekt_DatabaseManager($databaseModel); if (Default_Helpers_Delete::delete($model)) { $return = $databaseManager->deleteModule(); } else { $return = false; } } else { $return = Default_Helpers_Delete::delete($model); } if ($return === false) { $message = Phprojekt::getInstance()->translate('The module can not be deleted'); $type = 'error'; } else { Phprojekt::removeControllersFolders(); $message = Phprojekt::getInstance()->translate('The module was deleted correctly'); $type = 'success'; } $return = array('type' => $type, 'message' => $message, 'id' => $id); Phprojekt_Converter_Json::echoConvert($return); } else { throw new Zend_Controller_Action_Exception(self::NOT_FOUND, 404); } }