diff --git a/locale/en_US/manager.xml b/locale/en_US/manager.xml index 82b6fba2a..4e8766e97 100644 --- a/locale/en_US/manager.xml +++ b/locale/en_US/manager.xml @@ -98,6 +98,8 @@ Installation failed Successfully installed version The uploaded plugin archive does not contain a folder that corresponds to the plugin name. + The uploaded plugin does not fit the category of the upgraded plugin. + The version.xml in the uploaded plugin contains a plugin name that does not fit the name of the upgraded plugin. Plugin does not exist. Please Install instead Plugin already exists, but is newer than installed version. Please upgrade instead The tar command is not available. Please correctly configure it in your "config.inc.php". diff --git a/pages/manager/PluginHandler.inc.php b/pages/manager/PluginHandler.inc.php index 616601b06..8002664ad 100644 --- a/pages/manager/PluginHandler.inc.php +++ b/pages/manager/PluginHandler.inc.php @@ -12,7 +12,6 @@ * @brief Handle requests for plugin management functions. */ -//$Id$ import('pages.manager.ManagerHandler'); @@ -38,7 +37,7 @@ function plugins($args) { // get the plugins in that category only. $mainPage = false; $plugins =& PluginRegistry::loadCategory($category); - + $this->setupTemplate(false); $templateMgr->assign('pageTitle', 'plugins.categories.' . $category); $templateMgr->assign('pageHierarchy', PluginHandler::setBreadcrumbs(true)); @@ -52,14 +51,14 @@ function plugins($args) { $plugins = array_merge($plugins, PluginRegistry::loadCategory($category)); } } - + $this->setupTemplate(true); $templateMgr->assign('pageTitle', 'manager.plugins.pluginManagement'); $templateMgr->assign('pageHierarchy', PluginHandler::setBreadcrumbs(false)); } - + $templateMgr->assign_by_ref('plugins', $plugins); $templateMgr->assign_by_ref('categories', $categories); $templateMgr->assign('mainPage', $mainPage); @@ -93,7 +92,7 @@ function plugin($args, &$request) { $request->redirect(null, null, null, 'plugins', array($category)); } } - + /** * Set the page's breadcrumbs * @param $subclass boolean @@ -112,7 +111,7 @@ function setBreadcrumbs($subclass = false) { false ) ); - + if ($subclass) { $pageCrumbs[] = array( Request::url(null, null, 'manager', 'plugins'), diff --git a/pages/manager/PluginManagementHandler.inc.php b/pages/manager/PluginManagementHandler.inc.php index 6bd1da642..dbdfcac72 100644 --- a/pages/manager/PluginManagementHandler.inc.php +++ b/pages/manager/PluginManagementHandler.inc.php @@ -37,7 +37,8 @@ function PluginManagementHandler() { function managePlugins($args) { $this->validate(); $path = isset($args[0])?$args[0]:null; - $plugin = isset($args[1])?$args[1]:null; + $category = isset($args[1])?$args[1]:null; + $plugin = isset($args[2])?$args[2]:null; switch($path) { case 'install': @@ -47,16 +48,16 @@ function managePlugins($args) { $this->uploadPlugin('install'); break; case 'upgrade': - $this->showUpgradeForm($plugin); + $this->showUpgradeForm($category, $plugin); break; case 'upgradePlugin': - $this->uploadPlugin('upgrade'); + $this->uploadPlugin('upgrade', $category, $plugin); break; case 'delete': - $this->showDeleteForm($plugin); + $this->showDeleteForm($category, $plugin); break; case 'deletePlugin': - $this->deletePlugin($plugin); + $this->deletePlugin($category, $plugin); break; default: Request::redirect(null, 'manager', 'plugins'); @@ -84,18 +85,18 @@ function showInstallForm() { /** * Show form to select plugin for upgrade. - * @param plugin string + * @param $category string + * @param $plugin string */ - function showUpgradeForm($plugin) { + function showUpgradeForm($category, $plugin) { $this->validate(); $templateMgr =& TemplateManager::getManager(); $this->setupTemplate(true); $templateMgr->assign('path', 'upgrade'); + $templateMgr->assign('category', $category); $templateMgr->assign('plugin', $plugin); $templateMgr->assign('uploaded', false); - - $category = $this->_getPluginCategory($plugin); $templateMgr->assign('pageHierarchy', $this->setBreadcrumbs(true, $category)); $templateMgr->display('manager/plugins/managePlugins.tpl'); @@ -103,19 +104,19 @@ function showUpgradeForm($plugin) { /** * Confirm deletion of plugin. - * @param plugin string + * @param $category string + * @param $plugin string */ - function showDeleteForm($plugin) { + function showDeleteForm($category, $plugin) { $this->validate(); $templateMgr =& TemplateManager::getManager(); $this->setupTemplate(true); $templateMgr->assign('path', 'delete'); + $templateMgr->assign('category', $category); $templateMgr->assign('plugin', $plugin); $templateMgr->assign('deleted', false); $templateMgr->assign('error', false); - - $category = $this->_getPluginCategory($plugin); $templateMgr->assign('pageHierarchy', $this->setBreadcrumbs(true, $category)); $templateMgr->display('manager/plugins/managePlugins.tpl'); @@ -124,9 +125,11 @@ function showDeleteForm($plugin) { /** * Decompress uploaded plugin and install in the correct plugin directory. - * $param function string type of operation to perform after upload ('upgrade' or 'install') + * @param $function string type of operation to perform after upload ('upgrade' or 'install') + * @param $category string the category of the uploaded plugin (upgrade only) + * @param $plugin string the name of the uploaded plugin (upgrade only) */ - function uploadPlugin($function) { + function uploadPlugin($function, $category = null, $plugin = null) { $this->validate(); $templateMgr =& TemplateManager::getManager(); $this->setupTemplate(true); @@ -134,7 +137,6 @@ function uploadPlugin($function) { $templateMgr->assign('error', false); $templateMgr->assign('uploaded', false); $templateMgr->assign('path', $function); - $templateMgr->assign('pageHierarchy', $this->setBreadcrumbs(true)); $errorMsg = ''; if (Request::getUserVar('uploadPlugin')) { @@ -178,7 +180,7 @@ function uploadPlugin($function) { if ($function == 'install') { $this->installPlugin($pluginDir, $templateMgr); } else if ($function == 'upgrade') { - $this->upgradePlugin($pluginDir, $templateMgr); + $this->upgradePlugin($pluginDir, $templateMgr, $category, $plugin); } } else { $errorMsg = 'manager.plugins.invalidPluginArchive'; @@ -203,14 +205,14 @@ function installPlugin($path, &$templateMgr) { $this->validate(); $versionFile = $path . VERSION_FILE; $templateMgr->assign('error', true); - $templateMgr->assign('path', 'install'); + $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'); - $installedPlugin = $versionDao->getCurrentVersion($pluginVersion->getProduct(), true); + $installedPlugin = $versionDao->getCurrentVersion($pluginVersion->getProductType(), $pluginVersion->getProduct(), true); if(!$installedPlugin) { $pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . strtr($pluginVersion->getProductType(), '.', DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $pluginVersion->getProduct(); @@ -243,7 +245,7 @@ function installPlugin($path, &$templateMgr) { $versionDao->insertVersion($pluginVersion, true); return true; } else { - if ($this->_checkIfNewer($pluginVersion->getProduct(), $pluginVersion)) { + if ($this->_checkIfNewer($pluginVersion->getProductType(), $pluginVersion->getProduct(), $pluginVersion)) { $templateMgr->assign('message', 'manager.plugins.pleaseUpgrade'); return false; } else { @@ -257,26 +259,38 @@ function installPlugin($path, &$templateMgr) { * 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) { + function upgradePlugin($path, &$templateMgr, $category, $plugin) { $this->validate(); $versionFile = $path . VERSION_FILE; $templateMgr->assign('error', true); - $templateMgr->assign('path', 'upgrade'); + $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->getProduct(), true); + $installedPlugin = $versionDao->getCurrentVersion($pluginVersion->getProductType(), $pluginVersion->getProduct(), true); if(!$installedPlugin) { $templateMgr->assign('message', 'manager.plugins.pleaseInstall'); return false; } - if ($this->_checkIfNewer($pluginVersion->getProduct(), $pluginVersion)) { + if ($this->_checkIfNewer($pluginVersion->getProductType(), $pluginVersion->getProduct(), $pluginVersion)) { $templateMgr->assign('message', 'manager.plugins.installedVersionNewer'); return false; } else { @@ -317,9 +331,10 @@ function upgradePlugin($path, &$templateMgr) { /** * Delete a plugin from the system - * @param plugin string + * @param $category string + * @param $plugin string */ - function deletePlugin($plugin) { + function deletePlugin($category, $plugin) { $this->validate(); $templateMgr =& TemplateManager::getManager(); $this->setupTemplate(true); @@ -329,8 +344,7 @@ function deletePlugin($plugin) { $templateMgr->assign('error', false); $versionDao =& DAORegistry::getDAO('VersionDAO'); - $installedPlugin = $versionDao->getCurrentVersion($plugin, true); - $category = $this->_getPluginCategory($plugin); + $installedPlugin = $versionDao->getCurrentVersion('plugins.'.$category, $plugin, true); if ($installedPlugin) { $pluginDest = Core::getBaseDir() . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . $category . DIRECTORY_SEPARATOR . $plugin; @@ -359,13 +373,14 @@ function deletePlugin($plugin) { /** * Checks to see if local version of plugin is newer than installed version - * @param $pluginName string Product name of plugin + * @param $productType string Product type of plugin + * @param $productName string Product name of plugin * @param $newVersion Version Version object of plugin to check against database * @return boolean */ - function _checkIfNewer($pluginName, $newVersion) { + function _checkIfNewer($productType, $productName, $newVersion) { $versionDao =& DAORegistry::getDAO('VersionDAO'); - $installedPlugin = $versionDao->getCurrentVersion($pluginName, true); + $installedPlugin = $versionDao->getCurrentVersion($productType, $productName, true); if (!$installedPlugin) return false; if ($installedPlugin->compare($newVersion) > 0) return true; @@ -411,20 +426,6 @@ function setBreadcrumbs($subclass = false, $category = null) { return $pageCrumbs; } - /** - * Get the plugin category from the version. - * @param string - * @return string - */ - function _getPluginCategory($plugin) { - $versionDao =& DAORegistry::getDAO('VersionDAO'); - $installedPlugin = $versionDao->getCurrentVersion($plugin, true); - if ($installedPlugin) { - $productType = explode(".", $installedPlugin->getProductType()); - return $productType[1]; - } else return false; - } - /** * Load database connection parameters into an array (needed for upgrade). * @return array diff --git a/templates/manager/plugins/managePlugins.tpl b/templates/manager/plugins/managePlugins.tpl index 1141ea714..d3c569026 100644 --- a/templates/manager/plugins/managePlugins.tpl +++ b/templates/manager/plugins/managePlugins.tpl @@ -5,8 +5,6 @@ * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. * * List available import/export plugins. - * - * $Id$ *} {strip} {assign var="pageTitle" value="manager.plugins.$path"} @@ -15,111 +13,71 @@ {if $path == 'install'} - {if !$uploaded} -

{translate key="manager.plugins.installDescription"}

- {/if} - -
- {if $error} - {translate key="form.errorsOccurred"}: - - {/if} - {if $uploaded} - - {/if} - -
- - - - - -
- {translate key="manager.plugins.uploadPluginDir"} - - - -
-

-

- -{elseif $path == 'upgrade'} - {if !$uploaded} -

{translate key="manager.plugins.upgradeDescription"}

- {/if} - -
- {if $error} - {translate key="form.errorsOccurred"}: - - {/if} - {if $uploaded} - +
+ {if !$uploaded} +

{translate key="manager.plugins.installDescription"}

{/if} -
- - - - - -
- {translate key="manager.plugins.uploadPluginDir"} - - - -
-

-

- -{elseif $path == 'delete'} - {if !$deleted} -

{translate key="manager.plugins.deleteDescription"}

- {/if} +
+ {if $error} + {translate key="form.errorsOccurred"}: +
    +
  • + {if is_array($message)} + {translate key=$message[0]} {$message[1]} + {else} + {translate key=$message} + {/if} +
  • +
+ {/if} + {if $uploaded} +
    +
  • »  + {if is_array($message)} + {translate key=$message[0]} {$message[1]} + {else} + {translate key=$message} + {/if} +
  • +
+ {/if} - {if !$deleted} - {if !$error} -
    -
  • {translate key="manager.plugins.deleteConfirm"}
  • -
+
+ + + + + +
+ {translate key="manager.plugins.uploadPluginDir"} + + + +
+

+

+
+{elseif $path == 'upgrade'} +
+ {if !$uploaded} +

{translate key="manager.plugins.upgradeDescription"}

{/if} - -
-
+ + {if $error} {translate key="form.errorsOccurred"}: + {/if} + {if $uploaded} + {/if} - + +
+ + + + + +
+ {translate key="manager.plugins.uploadPluginDir"} + + + +
+

- {else} -

{translate key="manager.plugins.deleteSuccess"}

- {/if} - +
+{elseif $path == 'delete'} +
+ {if !$deleted} +

{translate key="manager.plugins.deleteDescription"}

+ {/if} + + {if !$deleted} + {if !$error} + + {/if} + +
+
+ {if $error} + {translate key="form.errorsOccurred"}: + + {/if} + +
+ {else} +

{translate key="manager.plugins.deleteSuccess"}

+ {/if} +
{/if} {include file="common/footer.tpl"} diff --git a/templates/manager/plugins/plugins.tpl b/templates/manager/plugins/plugins.tpl index 5ab5778b9..95d417a37 100644 --- a/templates/manager/plugins/plugins.tpl +++ b/templates/manager/plugins/plugins.tpl @@ -5,8 +5,6 @@ * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. * * List available import/export plugins. - * - * $Id$ *} {strip} {include file="common/header.tpl"} @@ -16,12 +14,12 @@

{translate key="manager.plugins.description"}

@@ -36,34 +34,34 @@ {/foreach} {/if}