/** * Install * * @param string $jsonFile */ public static function install($jsonFile, $moduleName) { $config = self::readConfigFile($jsonFile); $db = Di::getDefault()->get('db_centreon'); $isactivated = 1; $isinstalled = 1; $module = Informations::getModuleIdByName($moduleName); $stmt = $db->prepare("INSERT INTO cfg_widgets_models (name, shortname, description, version,\n author, email, website, keywords, screenshot, thumbnail, isactivated, isinstalled, module_id)\n \tVALUES (:name, :shortname, :description, :version, \n :author, :email, :website, :keywords, :screenshot, :thumbnail,\n :isactivated, :isinstalled, :module)"); $stmt->bindParam(':name', $config['name']); $stmt->bindParam(':shortname', $config['shortname']); $stmt->bindParam(':description', $config['description']); $stmt->bindParam(':version', $config['version']); $stmt->bindParam(':author', $config['author']); $stmt->bindParam(':email', $config['email']); $stmt->bindParam(':website', $config['website']); $stmt->bindParam(':keywords', $config['keywords']); $stmt->bindParam(':screenshot', $config['screenshot']); $stmt->bindParam(':thumbnail', $config['thumbnail']); $stmt->bindParam(':isactivated', $isactivated); $stmt->bindParam(':isinstalled', $isinstalled); $stmt->bindParam(':module', $module); $stmt->execute(); $lastId = self::getLastInsertedWidgetModelId($config['name']); self::insertWidgetPreferences($lastId, $config); self::insertWidgetWizard($config['name'], $lastId, $module); }
/** * Perform uninstall operation for module * * @throws NotInstalledException * @throws CoreModuleRemovalConstraintException */ public function uninstall() { if (!Informations::isModuleInstalled($this->moduleSlug)) { $exceptionMessage = _("The given module is not installed"); throw new NotInstalledException($this->colorizeMessage($exceptionMessage, 'danger'), 1109); } $coreModule = Informations::getCoreModuleList(); if (in_array($this->moduleSlug, $coreModule)) { $exceptionMessage = _("This module is a core module and therefore can't be uninstalled"); throw new CoreModuleRemovalConstraintException($this->colorizeMessage($exceptionMessage, 'danger'), 1103); } // Starting Message $message = _("Starting removal of %s module"); $this->displayOperationMessage($this->colorizeMessage(sprintf($message, $this->moduleFullName), 'info')); // Performing pre operation check $this->checkOperationValidity('uninstall'); // Set TemporaryVersion $this->versionManager->setTemporaryVersion('uninstall', true); $this->moduleId = Informations::getModuleIdByName($this->moduleSlug); // $this->preRemove(); $this->removeHook(); // Remove old static files $this->removeStaticFiles(); //Remove validators $this->removeValidators(); // Custom removal of the module $this->customRemove(); $this->postRemove(); // Ending Message $message = _("Removal of %s module complete"); $this->displayOperationMessage($this->colorizeMessage(sprintf($message, $this->moduleFullName), 'success')); }
/** * * @param string $object * @cmdObject string module the host */ public function deployFormsAction($object) { echo Colorize::colorizeMessage("Deployment of Forms...", "info"); try { $modulePath = Informations::getModulePath($object['module']); $moduleId = Informations::getModuleIdByName($object['module']); $formsFiles = $modulePath . '/install/forms/*.xml'; foreach (glob($formsFiles) as $xmlFile) { Form::installFromXml($moduleId, $xmlFile); } echo Colorize::colorizeMessage(" Done", "success"); } catch (\Exception $ex) { throw new \Exception(" " . $ex->getMessage(), 1); } }