/** * Perform installation. */ function install() { $installer = new Install($this->params); $installer->setLogger($this); if ($installer->execute()) { if (count($installer->getNotes()) > 0) { printf("\nRelease Notes\n"); printf("----------------------------------------\n"); foreach ($installer->getNotes() as $note) { printf("%s\n\n", $note); } } if (!$installer->wroteConfig()) { printf("\nNew config.inc.php:\n"); printf("----------------------------------------\n"); echo $installer->getConfigContents(); printf("----------------------------------------\n"); } if ($this->params['manualInstall']) { if (count($installer->getSQL()) > 0) { printf("\nSQL\n"); printf("----------------------------------------\n"); foreach ($installer->getSQL() as $sql) { printf("%s\n\n", $sql); } } } else { $newVersion =& $installer->getNewVersion(); printf("Successfully installed version %s\n", $newVersion->getVersionString()); } } else { printf("ERROR: Installation failed: %s\n", $installer->getErrorString()); } }
/** * Installs the uploaded plugin * @param $path string path to plugin Directory * @param $templateMgr reference to template manager * @return boolean */ function installPlugin($path, &$templateMgr) { $versionFile = $path . VERSION_FILE; $templateMgr->assign('error', true); $templateMgr->assign('path', 'install'); if (FileManager::fileExists($versionFile)) { $versionInfo =& VersionCheck::parseVersionXML($versionFile); } else { $templateMgr->assign('message', 'manager.plugins.versionFileNotFound'); return false; } $pluginVersion = $versionInfo['version']; $pluginName = $pluginVersion->getProduct(); $category = $this->getPluginCategory($plugin); $versionDao =& DAORegistry::getDAO('VersionDAO'); $installedPlugin = $versionDao->getCurrentVersion($pluginName); if (!$installedPlugin) { $pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $category . DIRECTORY_SEPARATOR . $pluginName; if (!FileManager::copyDir($path, $pluginDest)) { $templateMgr->assign('message', 'manager.plugins.copyError'); return false; } // If plugin has an install.xml file, update database with it $installFile = $pluginDest . DIRECTORY_SEPARATOR . INSTALL_FILE; if (FileManager::fileExists($installFile)) { $params = PluginManagementHandler::setConnectionParams(); $installer = new Install($params, $installFile, true); if ($installer->execute()) { $newVersion =& $installer->getNewVersion(); } else { // Roll back the copy FileManager::rmtree($pluginDest); $templateMgr->assign('message', array('manager.plugins.installFailed', $installer->getErrorString())); return false; } } else { $newVersion = $pluginVersion; } $message = array('manager.plugins.installSuccessful', $newVersion->getVersionString()); $templateMgr->assign('message', $message); $templateMgr->assign('uploaded', true); $templateMgr->assign('error', false); $newVersion->setCurrent(1); $versionDao->insertVersion($newVersion); return true; } else { if (PluginManagementHandler::checkIfNewer($pluginName, $pluginVersion)) { $templateMgr->assign('message', 'manager.plugins.pleaseUpgrade'); return false; } if (!PluginManagementHandler::checkIfNewer($pluginName, $pluginVersion)) { $templateMgr->assign('message', 'manager.plugins.installedVersionOlder'); return false; } } }