function renewJsonAction() { $extensions = RM_Environment::getInstance()->getOutOfDateExtensions(); $pluginModel = new RM_Plugins(); $pluginManager = new RM_Plugin_Manager($this->_translate); $failedPlugins = array(); foreach ($extensions['plugins'] as $pluginName) { $plugin = $pluginModel->fetchByName($pluginName); try { $pluginManager->autoUpgrade($plugin); } catch (Exception $e) { $failedPlugins[] = $pluginName; continue; } } $moduleModel = new RM_Modules(); $moduleManager = new RM_Module_Manager($this->_translate); $failedModules = array(); foreach ($extensions['modules'] as $moduleName) { $module = $moduleModel->fetchByName($moduleName); try { $moduleManager->autoUpgrade($module); } catch (Exception $e) { $failedModules[] = $moduleName; continue; } } return array('data' => array('success' => true)); }
public function getRouter() { $plugins = $this->getAllPlugins(true); if (count($plugins) == 0) { return null; } foreach ($plugins as $plugin) { $pluginObject = RM_Plugin_Manager::getPlugin($plugin->name); $router = $pluginObject->getRouter(); if ($router !== null) { return $router; } } return null; }
/** * Private constructor that invokes only from 'getInstance' method */ private function __construct() { $this->_initializeLocale(); $model = new RM_Modules(); $allModules = $model->fetchAll(); $modules = $model->fetchAllEnabled(); foreach ($modules as $module) { $moduleObject = RM_Module_Manager::getModule($module->name); //We will get the last enabled module in the system //that implements one of our internal interfaces if ($moduleObject instanceof RM_Payments_Interface) { $this->_paymentSystem = $moduleObject; } if ($moduleObject instanceof RM_Extras_Interface) { $this->_extrasSystems[] = $moduleObject; } if ($moduleObject instanceof RM_Others_Interface) { $this->_othersSystems[] = $moduleObject; } if ($moduleObject instanceof RM_SEF_Manager_Interface) { $this->_sefManager = $moduleObject; } } $pluginModel = new RM_Plugins(); $allPlugins = $pluginModel->fetchAll(); $plugins = $pluginModel->fetchAllEnabled(); $this->_taxSystem = new RM_Taxes_Default(); foreach ($plugins as $plugin) { $pluginObject = RM_Plugin_Manager::getPlugin($plugin->name); if ($pluginObject instanceof RM_Taxes_Interface) { $this->_taxSystem = $pluginObject; } if ($pluginObject instanceof RM_Discounts_Plugin_Interface) { $this->_discounts[] = $pluginObject; } //We will assign only one deposit system (the last one enabled) if ($pluginObject instanceof RM_Deposit_Plugin_Interface) { $this->_depositSystem = $pluginObject; } } $this->_initializeTranslate($allModules, $allPlugins); }
/** * Uninstall module * * @param RM_Module_Row $module * @throws RM_Exception is some error occures */ function uninstall($module) { //1. get module path $moduleFolderPath = self::getModuleFolderpath($module->name); //3. invoke uninstall from module main class $className = self::_getClassname($module->name); $moduleObject = new $className(); $moduleObject->uninstall(); //5. invoke SQL uninstall file self::uninstallDatabase($moduleFolderPath); //6. remove userdata module directories $result = RM_Filesystem::deleteFolder($moduleFolderPath); $result = RM_Filesystem::deleteFolder(self::getModuleUserFolderpath($module->name)); //7. disable all modules that are connected to this module if this is possible $pluginsManager = new RM_Plugin_Manager(RM_Environment::getInstance()->getTranslation()); $pluginsModel = new RM_Plugins(); $plugins = $pluginsModel->fetchByModuleName($module->name, true); foreach ($plugins as $plugin) { try { $pluginsManager->disable($plugin); } catch (Exception $e) { //TODO: add some log message that we could not disable this plugin continue; } } //8. remove module row from database $module->delete(); return true; }
/** * Initialize autoloading for modules and plugins */ public function initAuloadMP() { $isSafeMode = $this->isSafeMode(); $paths = array(); $modulesDAO = new RM_Modules(); $modules = $modulesDAO->fetchAll(); foreach ($modules as $module) { if ($isSafeMode && $module->core == 0) { continue; } $bothPath = RM_Module_Manager::getModuleFolderpath($module->name, $this->_rootPath) . DIRECTORY_SEPARATOR; $paths[] = $bothPath . RM_Module_Config::CLASSES; $paths[] = $bothPath . RM_Module_Config::CONTROLLERS; } $pluginsDAO = new RM_Plugins(); $plugins = $pluginsDAO->fetchAll(); foreach ($plugins as $plugin) { if ($isSafeMode && $plugin->core == 0) { continue; } $bothPath = RM_Plugin_Manager::getPluginFolderpath($plugin->name, $this->_rootPath) . DIRECTORY_SEPARATOR; $paths[] = $bothPath . RM_Plugin_Config::CLASSES; $paths[] = $bothPath . RM_Plugin_Config::CONTROLLERS; } $MPPathString = implode(PATH_SEPARATOR, $paths); set_include_path(get_include_path() . PATH_SEPARATOR . $MPPathString); }
/** * Add language to the system, laguage files need to be in there places on language folder * * @param string $iso */ public function installLanguage($iso, $name) { $model = new RM_Languages(); $language = array('iso' => $iso, 'name' => $name, 'icon' => $this->getIconPath($iso)); $model->insert($language); //Here is a list of multilingual code models $model = new RM_UnitTypes(); $model->addLanguage($iso); $unitModel = new RM_UnitLanguageDetails(); $unitModel->addLanguage($iso); $templatesModel = new RM_Templates(); $templatesModel->addLanguage($iso); $manager = new RM_Module_Manager(); $manager->addLanguage($iso); $pluginManager = new RM_Plugin_Manager(); $pluginManager->addLanguage($iso); }
public function disableJsonAction() { $json = new stdClass(); $json->success = 1; $json->msg = array(); $ids = $this->_getParam('ids', array()); $manager = new RM_Plugin_Manager($this->_translate); $model = new RM_Plugins(); foreach ($ids as $id) { $row = $model->find($id)->current(); try { $manager->disable($row); } catch (Exception $e) { $json->success = 0; $json->msg[] = $e->getMessage(); } } return array('data' => $json); }