/** * Prepare urls to run install plugin tasks * * @param string $baseInstalUrl Base install URL (prepared by * OX_Admin_UI_Controller_Request::getBaseUrl) * @return array Array of arrays of 'id', name' and 'url' strings */ static function getTasksUrls($baseInstallUrl) { $aUrls = array(); $aPluginZips = array(); // Collect all plugin files present in the etc/plugins folder... $PLUGINS_DIR = opendir(MAX_PATH . '/etc/plugins'); while ($file = readdir($PLUGINS_DIR)) { if (substr($file, 0, 1) == '.' || substr($file, strrpos($file, '.')) != '.zip') { continue; } $name = substr($file, 0, strrpos($file, '.')); $aPluginZips[$name] = array('id' => 'plugin:' . $name, 'name' => $GLOBALS['strPluginTaskChecking'] . ': <br/> ' . OX_Upgrade_InstallPlugin_Controller::openxToRevivePluginName($name), 'url' => $baseInstallUrl . 'install-plugin.php?status=0&plugin=' . $name . '&disabled=1'); } closedir($PLUGINS_DIR); // Get installed plugins if upgrade $oStorage = OX_Admin_UI_Install_InstallUtils::getSessionStorage(); $oStatus = $oStorage->get('installStatus'); if (isset($oStatus) && $oStatus->isUpgrade()) { foreach ($GLOBALS['_MAX']['CONF']['plugins'] as $name => $enabled) { if (in_array($name, self::$DEPRECATED_PLUGINS)) { $status = '2'; // Remove plugin; deprecated } else { $status = '1'; // Install or migrate } $displayName = $name; $oPluginManager = new OX_PluginManager(); $aPackageInfo = $oPluginManager->getPackageInfo($name); if ($aPackageInfo['displayname']) { $displayName = $aPackageInfo['displayname']; } $aUrls[] = array('id' => 'plugin:' . $name, 'name' => $GLOBALS['strPluginTaskChecking'] . ': <br/> ' . OX_Upgrade_InstallPlugin_Controller::openxToRevivePluginName($displayName), 'url' => $baseInstallUrl . 'install-plugin.php?status=' . $status . '&plugin=' . $name); unset($aPluginZips[$name]); } } // Get the list of bundled plugins, retain order include MAX_PATH . '/etc/default_plugins.php'; if ($aDefaultPlugins) { foreach ($aDefaultPlugins as $idx => $aPlugin) { if (!array_key_exists($aPlugin['name'], $GLOBALS['_MAX']['CONF']['plugins'])) { $url = $baseInstallUrl . 'install-plugin.php?status=0&plugin=' . $aPlugin['name']; if (!empty($aPlugin['disabled'])) { $url .= '&disabled=1'; } $aUrls[] = array('id' => 'plugin:' . $aPlugin['name'], 'name' => $GLOBALS['strPluginTaskInstalling'] . ': <br/> ' . OX_Upgrade_InstallPlugin_Controller::openxToRevivePluginName($aPlugin['name']), 'url' => $url); unset($aPluginZips[$aPlugin['name']]); } } } // Anything left in the $aPluginsZip array are unknown plugins, should be installed but disabled foreach ($aPluginZips as $pluginName => $pluginArray) { $aUrls[] = $pluginArray; } return $aUrls; }
if (array_key_exists('import', $_POST)) { if (array_key_exists('filename', $_FILES)) { $oPluginManager->installPackageCodeOnly($_FILES['filename']); } } else { if (array_key_exists('getupgrade', $_POST)) { $downloadurl = $_POST['downloadurl']; $aFile['error'] = 0; $aFile['type'] = 'application/zip'; $aFile['name'] = basename($downloadurl); $aFile['tmp_name'] = MAX_PATH . '/var/' . $aFile['name']; file_put_contents($aFile['tmp_name'], file_get_contents($downloadurl)); if (file_exists($aFile['tmp_name'])) { $oPluginManager->upgradePackage($aFile, $plugin); $oTpl = new OA_Admin_Template('plugin-view.html'); $aPackageInfo = $oPluginManager->getPackageInfo($plugin); $aComponents = $aPackageInfo['contents']; unset($aPackageInfo['contents']); if ($aPackageInfo['readme']) { $readme = file_get_contents($aPackageInfo['readme']); } $aPackageInfo['package'] = true; $oTpl->assign('aPackage', $aPackageInfo); $oTpl->assign('aPlugins', $aComponents); $oTpl->assign('readme', $readme); $oTpl->assign('backURL', MAX::constructURL(MAX_URL_ADMIN, "plugin-index.php?selection=packages")); $oTpl->assign('aWarnings', $oPluginManager->aWarnings); $oTpl->assign('aErrors', $oPluginManager->aErrors); $oTpl->assign('aMessages', $oPluginManager->aMessages); } } else {