} $p_plugins = Input::Get('p_plugins', 'array'); $p_enabled = Input::Get('p_enabled', 'array'); // delete from DB those which were uninstalled foreach (CampPlugin::getAll() as $CampPlugin) { if (!array_key_exists($CampPlugin->getName(), $p_plugins)) { if (strpos($CampPlugin->getName(), '/') !== false) { continue; } $CampPlugin->delete(); } } foreach ($p_plugins as $plugin => $oldversion) { $CampPlugin = new CampPlugin($plugin); // installed version, if exists $currentVersion = $CampPlugin->getFsVersion(); if ($p_enabled && array_key_exists($plugin, $p_enabled) && $p_enabled[$plugin]) { if ($CampPlugin->exists()) { if ($CampPlugin->getDbVersion() != $currentVersion) { // update plugin $CampPlugin->delete(); $CampPlugin->create($plugin, $currentVersion); $CampPlugin->update(); $CampPlugin->enable(); // update autoload exec('php ' . $GLOBALS['g_campsiteDir'] . '/scripts/newscoop.php autoload:update'); } else { // just enable plugin $CampPlugin->enable(); } } else {
/** * Updates plugins if needed * @return void */ public static function OnUpgrade() { $plugins = self::GetNeedsUpdate(); if (!is_array($plugins) || empty($plugins)) { return; // no plugin to update } // update foreach ($plugins as $name => $info) { $CampPlugin = new CampPlugin($name); if (empty($info['current'])) { continue; } $currentVersion = $CampPlugin->getFsVersion(); if ($CampPlugin->getDbVersion() != $currentVersion) { $CampPlugin->delete(); $CampPlugin->create($name, $currentVersion); $CampPlugin->update(); } } }