예제 #1
0
 /**
  * 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)
 {
     $this->validate();
     $versionFile = $path . VERSION_FILE;
     $templateMgr->assign('error', true);
     $templateMgr->assign('pageHierarchy', $this->setBreadcrumbs(true));
     $pluginVersion =& VersionCheck::getValidPluginVersionInfo($versionFile, $templateMgr);
     if (is_null($pluginVersion)) {
         return false;
     }
     assert(is_a($pluginVersion, 'Version'));
     $versionDao =& DAORegistry::getDAO('VersionDAO');
     /* @var $versionDao VersionDAO */
     $installedPlugin = $versionDao->getCurrentVersion($pluginVersion->getProductType(), $pluginVersion->getProduct(), true);
     if (!$installedPlugin) {
         $pluginLibDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR . strtr($pluginVersion->getProductType(), '.', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $pluginVersion->getProduct();
         $pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . strtr($pluginVersion->getProductType(), '.', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $pluginVersion->getProduct();
         // 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));
         // Upgrade the database with the new plug-in.
         $installFile = $pluginDest . INSTALL_FILE;
         if (!is_file($installFile)) {
             $installFile = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'defaultPluginInstall.xml';
         }
         assert(is_file($installFile));
         $params = $this->_setConnectionParams();
         $installer = new Install($params, $installFile, true);
         $installer->setCurrentVersion($pluginVersion);
         if (!$installer->execute()) {
             // Roll back the copy
             if (is_dir($pluginLibDest)) {
                 FileManager::rmtree($pluginLibDest);
             }
             if (is_dir($pluginDest)) {
                 FileManager::rmtree($pluginDest);
             }
             $templateMgr->assign('message', array('manager.plugins.installFailed', $installer->getErrorString()));
             return false;
         }
         $message = array('manager.plugins.installSuccessful', $pluginVersion->getVersionString());
         $templateMgr->assign('message', $message);
         $templateMgr->assign('uploaded', true);
         $templateMgr->assign('error', false);
         $versionDao->insertVersion($pluginVersion, true);
         return true;
     } else {
         if ($this->_checkIfNewer($pluginVersion->getProductType(), $pluginVersion->getProduct(), $pluginVersion)) {
             $templateMgr->assign('message', 'manager.plugins.pleaseUpgrade');
             return false;
         } else {
             $templateMgr->assign('message', 'manager.plugins.installedVersionOlder');
             return false;
         }
     }
 }
 /**
  * Installs the uploaded plugin
  * @param $path string path to plugin Directory
  * @param $templateMgr reference to template manager
  * @return boolean
  */
 function installPlugin($path, &$templateMgr)
 {
     $this->validate();
     $versionFile = $path . VERSION_FILE;
     $templateMgr->assign('error', true);
     $templateMgr->assign('path', 'install');
     $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) {
         $pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . strtr($pluginVersion->getProductType(), '.', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $pluginVersion->getProduct();
         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 . INSTALL_FILE;
         if (FileManager::fileExists($installFile)) {
             $params = $this->setConnectionParams();
             $installer = new Install($params, $installFile, true);
             $installer->setCurrentVersion($pluginVersion);
             if (!$installer->execute()) {
                 // Roll back the copy
                 FileManager::rmtree($pluginDest);
                 $templateMgr->assign('message', array('manager.plugins.installFailed', $installer->getErrorString()));
                 return false;
             }
         }
         $message = array('manager.plugins.installSuccessful', $pluginVersion->getVersionString());
         $templateMgr->assign('message', $message);
         $templateMgr->assign('uploaded', true);
         $templateMgr->assign('error', false);
         $versionDao->insertVersion($pluginVersion, true);
         return true;
     } else {
         if ($this->checkIfNewer($pluginVersion->getProduct(), $pluginVersion)) {
             $templateMgr->assign('message', 'manager.plugins.pleaseUpgrade');
             return false;
         } else {
             $templateMgr->assign('message', 'manager.plugins.installedVersionOlder');
             return false;
         }
     }
 }
예제 #4
0
 /**
  * Installs an extracted plugin
  * @param $path string path to plugin Directory
  * @param $errorMsg string Reference to string receiving error message
  * @return Version|null Version of installed plugin on success
  */
 function installPlugin($path, &$errorMsg)
 {
     $versionFile = $path . '/' . PLUGIN_VERSION_FILE;
     $pluginVersion = VersionCheck::getValidPluginVersionInfo($versionFile, $errorMsg);
     if (!$pluginVersion) {
         return null;
     }
     $versionDao = DAORegistry::getDAO('VersionDAO');
     /* @var $versionDao VersionDAO */
     $installedPlugin = $versionDao->getCurrentVersion($pluginVersion->getProductType(), $pluginVersion->getProduct(), true);
     if (!$installedPlugin) {
         $pluginLibDest = Core::getBaseDir() . '/' . PKP_LIB_PATH . '/' . strtr($pluginVersion->getProductType(), '.', '/') . '/' . $pluginVersion->getProduct();
         $pluginDest = Core::getBaseDir() . '/' . strtr($pluginVersion->getProductType(), '.', '/') . '/' . $pluginVersion->getProduct();
         // Copy the plug-in from the temporary folder to the
         // target folder.
         // Start with the library part (if any).
         $libPath = $path . '/lib';
         $fileManager = new FileManager();
         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));
         // Upgrade the database with the new plug-in.
         $installFile = $pluginDest . '/' . PLUGIN_INSTALL_FILE;
         if (!is_file($installFile)) {
             $installFile = Core::getBaseDir() . '/' . PKP_LIB_PATH . '/xml/defaultPluginInstall.xml';
         }
         assert(is_file($installFile));
         $params = $this->_getConnectionParams();
         $installer = new Install($params, $installFile, true);
         $installer->setCurrentVersion($pluginVersion);
         if (!$installer->execute()) {
             // Roll back the copy
             if (is_dir($pluginLibDest)) {
                 $fileManager->rmtree($pluginLibDest);
             }
             if (is_dir($pluginDest)) {
                 $fileManager->rmtree($pluginDest);
             }
             $errorMsg = __('manager.plugins.installFailed', array('errorString' => $installer->getErrorString()));
             return null;
         }
         $versionDao->insertVersion($pluginVersion, true);
         return $pluginVersion;
     } else {
         if ($this->_checkIfNewer($pluginVersion->getProductType(), $pluginVersion->getProduct(), $pluginVersion)) {
             $errorMsg = __('manager.plugins.pleaseUpgrade');
         } else {
             $errorMsg = __('manager.plugins.installedVersionOlder');
         }
     }
     return null;
 }
예제 #5
0
 /**
  * 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;
         }
     }
 }