コード例 #1
0
 /**
  * Run upgrade script.
  */
 function upgrade()
 {
     $installer = new Upgrade(array());
     $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);
             }
         }
         $newVersion =& $installer->getNewVersion();
         printf("Successfully upgraded to version %s\n", $newVersion->getVersionString());
     } else {
         printf("ERROR: Upgrade failed: %s\n", $installer->getErrorString());
     }
 }
コード例 #2
0
 /**
  * Upgrade a plugin to a newer version from the user's filesystem
  * @param $path string path to plugin Directory
  * @param $templateMgr reference to template manager
  * @param $category string
  * @param $plugin string
  * @return boolean
  */
 function upgradePlugin($path, &$templateMgr, $category, $plugin)
 {
     $this->validate();
     $versionFile = $path . VERSION_FILE;
     $templateMgr->assign('error', true);
     $templateMgr->assign('pageHierarchy', $this->setBreadcrumbs(true, $category));
     $pluginVersion =& VersionCheck::getValidPluginVersionInfo($versionFile, $templateMgr);
     if (is_null($pluginVersion)) {
         return false;
     }
     assert(is_a($pluginVersion, 'Version'));
     // Check whether the uploaded plug-in fits the original plug-in.
     if ('plugins.' . $category != $pluginVersion->getProductType()) {
         $templateMgr->assign('message', 'manager.plugins.wrongCategory');
         return false;
     }
     if ($plugin != $pluginVersion->getProduct()) {
         $templateMgr->assign('message', 'manager.plugins.wrongName');
         return false;
     }
     $versionDao =& DAORegistry::getDAO('VersionDAO');
     $installedPlugin = $versionDao->getCurrentVersion($pluginVersion->getProductType(), $pluginVersion->getProduct(), true);
     if (!$installedPlugin) {
         $templateMgr->assign('message', 'manager.plugins.pleaseInstall');
         return false;
     }
     if ($this->_checkIfNewer($pluginVersion->getProductType(), $pluginVersion->getProduct(), $pluginVersion)) {
         $templateMgr->assign('message', 'manager.plugins.installedVersionNewer');
         return false;
     } else {
         $pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $category . DIRECTORY_SEPARATOR . $plugin;
         $pluginLibDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $category . DIRECTORY_SEPARATOR . $plugin;
         // Delete existing files.
         if (is_dir($pluginDest)) {
             FileManager::rmtree($pluginDest);
         }
         if (is_dir($pluginLibDest)) {
             FileManager::rmtree($pluginLibDest);
         }
         // Check whether deleting has worked.
         if (is_dir($pluginDest) || is_dir($pluginLibDest)) {
             $templateMgr->assign('message', 'manager.plugins.deleteError');
             return false;
         }
         // Copy the plug-in from the temporary folder to the
         // target folder.
         // Start with the library part (if any).
         $libPath = $path . DIRECTORY_SEPARATOR . 'lib';
         if (is_dir($libPath)) {
             if (!FileManager::copyDir($libPath, $pluginLibDest)) {
                 $templateMgr->assign('message', 'manager.plugins.copyError');
                 return false;
             }
             // Remove the library part of the temporary folder.
             FileManager::rmtree($libPath);
         }
         // Continue with the application-specific part (mandatory).
         if (!FileManager::copyDir($path, $pluginDest)) {
             $templateMgr->assign('message', 'manager.plugins.copyError');
             return false;
         }
         // Remove the temporary folder.
         FileManager::rmtree(dirname($path));
         $upgradeFile = $pluginDest . UPGRADE_FILE;
         if (FileManager::fileExists($upgradeFile)) {
             $params = $this->_setConnectionParams();
             $installer = new Upgrade($params, $upgradeFile, true);
             if (!$installer->execute()) {
                 $templateMgr->assign('message', array('manager.plugins.upgradeFailed', $installer->getErrorString()));
                 return false;
             }
         }
         $installedPlugin->setCurrent(0);
         $pluginVersion->setCurrent(1);
         $versionDao->insertVersion($pluginVersion, true);
         $templateMgr->assign('category', $category);
         $templateMgr->assign('plugin', $plugin);
         $templateMgr->assign('message', array('manager.plugins.upgradeSuccessful', $pluginVersion->getVersionString()));
         $templateMgr->assign('uploaded', true);
         $templateMgr->assign('error', false);
         return true;
     }
 }
 /**
  * Upgrade a plugin to a newer version from the user's filesystem
  * @param $path string path to plugin Directory
  * @param $templateMgr reference to template manager
  * @return boolean
  */
 function upgradePlugin($path, &$templateMgr)
 {
     $this->validate();
     $versionFile = $path . VERSION_FILE;
     $templateMgr->assign('error', true);
     $templateMgr->assign('path', 'upgrade');
     $pluginVersion =& VersionCheck::getValidPluginVersionInfo($versionFile, $templateMgr);
     if (is_null($pluginVersion)) {
         return false;
     }
     assert(is_a($pluginVersion, 'Version'));
     $versionDao =& DAORegistry::getDAO('VersionDAO');
     $installedPlugin = $versionDao->getCurrentVersion($pluginVersion->getProduct(), true);
     if (!$installedPlugin) {
         $templateMgr->assign('message', 'manager.plugins.pleaseInstall');
         return false;
     }
     if ($this->checkIfNewer($pluginVersion->getProduct(), $pluginVersion)) {
         $templateMgr->assign('message', 'manager.plugins.installedVersionNewer');
         return false;
     } else {
         $pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . strtr($pluginVersion->getProductType(), '.', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $pluginVersion->getProduct();
         FileManager::rmtree($pluginDest);
         if (FileManager::fileExists($pluginDest, 'dir')) {
             $templateMgr->assign('message', 'manager.plugins.deleteError');
             return false;
         }
         if (!FileManager::copyDir($path, $pluginDest)) {
             $templateMgr->assign('message', 'manager.plugins.copyError');
             return false;
         }
         $upgradeFile = $pluginDest . UPGRADE_FILE;
         if (FileManager::fileExists($upgradeFile)) {
             $params = $this->setConnectionParams();
             $installer = new Upgrade($params, $upgradeFile, true);
             if (!$installer->execute()) {
                 $templateMgr->assign('message', array('manager.plugins.upgradeFailed', $installer->getErrorString()));
                 return false;
             }
         }
         $installedPlugin->setCurrent(0);
         $pluginVersion->setCurrent(1);
         $versionDao->insertVersion($pluginVersion, true);
         $templateMgr->assign('message', array('manager.plugins.upgradeSuccessful', $pluginVersion->getVersionString()));
         $templateMgr->assign('uploaded', true);
         $templateMgr->assign('error', false);
         return true;
     }
 }
コード例 #4
0
ファイル: PluginHelper.inc.php プロジェクト: doana/pkp-lib
 /**
  * Upgrade a plugin to a newer version from the user's filesystem
  * @param $category string
  * @param $plugin string
  * @param $path string path to plugin Directory
  * @param $category string
  * @param $plugin string
  * @return Version|null The upgraded version, on success; null on fail
  */
 function upgradePlugin($category, $plugin, $path, &$errorMsg)
 {
     $versionFile = $path . '/' . PLUGIN_VERSION_FILE;
     $pluginVersion = VersionCheck::getValidPluginVersionInfo($versionFile, $errorMsg);
     if (!$pluginVersion) {
         return null;
     }
     // Check whether the uploaded plug-in fits the original plug-in.
     if ('plugins.' . $category != $pluginVersion->getProductType()) {
         $errorMsg = __('manager.plugins.wrongCategory');
         return null;
     }
     if ($plugin != $pluginVersion->getProduct()) {
         $errorMsg = __('manager.plugins.wrongName');
         return null;
     }
     $versionDao = DAORegistry::getDAO('VersionDAO');
     $installedPlugin = $versionDao->getCurrentVersion($pluginVersion->getProductType(), $pluginVersion->getProduct(), true);
     if (!$installedPlugin) {
         $errorMsg = __('manager.plugins.pleaseInstall');
         return null;
     }
     if ($this->_checkIfNewer($pluginVersion->getProductType(), $pluginVersion->getProduct(), $pluginVersion)) {
         $errorMsg = __('manager.plugins.installedVersionNewer');
         return null;
     } else {
         $pluginDest = Core::getBaseDir() . '/plugins/' . $category . '/' . $plugin;
         $pluginLibDest = Core::getBaseDir() . '/' . PKP_LIB_PATH . '/plugins/' . $category . '/' . $plugin;
         // Delete existing files.
         $fileManager = new FileManager();
         if (is_dir($pluginDest)) {
             $fileManager->rmtree($pluginDest);
         }
         if (is_dir($pluginLibDest)) {
             $fileManager->rmtree($pluginLibDest);
         }
         // Check whether deleting has worked.
         if (is_dir($pluginDest) || is_dir($pluginLibDest)) {
             $errorMsg = __('message', 'manager.plugins.deleteError');
             return null;
         }
         // Copy the plug-in from the temporary folder to the
         // target folder.
         // Start with the library part (if any).
         $libPath = $path . '/lib';
         if (is_dir($libPath)) {
             if (!$fileManager->copyDir($libPath, $pluginLibDest)) {
                 $errorMsg = __('manager.plugins.copyError');
                 return null;
             }
             // Remove the library part of the temporary folder.
             $fileManager->rmtree($libPath);
         }
         // Continue with the application-specific part (mandatory).
         if (!$fileManager->copyDir($path, $pluginDest)) {
             $errorMsg = __('manager.plugins.copyError');
             return null;
         }
         // Remove the temporary folder.
         $fileManager->rmtree(dirname($path));
         $upgradeFile = $pluginDest . '/' . PLUGIN_UPGRADE_FILE;
         if ($fileManager->fileExists($upgradeFile)) {
             $params = $this->_getConnectionParams();
             $installer = new Upgrade($params, $upgradeFile, true);
             if (!$installer->execute()) {
                 $errorMsg = __('manager.plugins.upgradeFailed', array('errorString' => $installer->getErrorString()));
                 return null;
             }
         }
         $installedPlugin->setCurrent(0);
         $pluginVersion->setCurrent(1);
         $versionDao->insertVersion($pluginVersion, true);
         return $pluginVersion;
     }
 }
コード例 #5
0
 /**
  * Upgrade a plugin to a newer version from the user's filesystem
  * @param $path string path to plugin Directory
  * @param $templateMgr reference to template manager
  * @return boolean
  */
 function upgradePlugin($path, &$templateMgr)
 {
     $versionFile = $path . VERSION_FILE;
     $templateMgr->assign('error', true);
     $templateMgr->assign('path', 'upgrade');
     if (FileManager::fileExists($versionFile)) {
         $versionInfo =& VersionCheck::parseVersionXML($versionFile);
     } else {
         $templateMgr->assign('message', 'manager.plugins.versionFileNotFound');
         return false;
     }
     $pluginVersion = $versionInfo['version'];
     $pluginName = $versionInfo['application'];
     $category = explode(".", $pluginVersion->getProductType());
     $versionDao =& DAORegistry::getDAO('VersionDAO');
     $installedPlugin = $versionDao->getCurrentVersion($pluginName);
     if (!$installedPlugin) {
         $templateMgr->assign('message', 'manager.plugins.pleaseInstall');
         return false;
     }
     if (PluginManagementHandler::checkIfNewer($pluginName, $pluginVersion)) {
         $templateMgr->assign('message', 'manager.plugins.installedVersionNewer');
         return false;
     } else {
         $pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $category . DIRECTORY_SEPARATOR . $pluginName;
         FileManager::rmtree($pluginDest);
         if (FileManager::fileExists($pluginDest, 'dir')) {
             $templateMgr->assign('message', 'manager.plugins.deleteError');
             return false;
         }
         if (!FileManager::copyDir($path, $pluginDest)) {
             $templateMgr->assign('message', 'manager.plugins.copyError');
             return false;
         }
         $upgradeFile = $pluginDest . DIRECTORY_SEPARATOR . UPGRADE_FILE;
         if (FileManager::fileExists($upgradeFile)) {
             $params = PluginManagementHandler::setConnectionParams();
             $installer = new Upgrade($params, $upgradeFile, true);
             if (!$installer->execute()) {
                 $templateMgr->assign('message', array('manager.plugins.upgradeFailed', $installer->getErrorString()));
                 return false;
             }
         }
         $installedPlugin->setCurrent(0);
         $pluginVersion->setCurrent(1);
         $versionDao->insertVersion($pluginVersion);
         $templateMgr->assign('message', array('manager.plugins.upgradeSuccessful', $pluginVersion->getVersionString()));
         $templateMgr->assign('uploaded', true);
         $templateMgr->assign('error', false);
         return true;
     }
 }
コード例 #6
0
ファイル: UpgradeTool.inc.php プロジェクト: anorton/pkp-lib
 /**
  * Run upgrade script.
  */
 function upgrade()
 {
     $pretend = false;
     // isset($this->argv[1]) && $this->argv[1] == 'pretend';
     $installer = new Upgrade(array('manualInstall' => $pretend));
     $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 ($pretend) {
             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 upgraded to version %s\n", $newVersion->getVersionString());
         }
     } else {
         printf("ERROR: Upgrade failed: %s\n", $installer->getErrorString());
     }
 }