Merge pull request #4867 from nextcloud/kill-install-app
Remove OC_App:installApp
This commit is contained in:
commit
79af585ecd
3 changed files with 29 additions and 80 deletions
|
@ -98,7 +98,7 @@ class Installer {
|
|||
*
|
||||
* @param string $appId App to install
|
||||
* @throws \Exception
|
||||
* @return integer
|
||||
* @return string app ID
|
||||
*/
|
||||
public function installApp($appId) {
|
||||
$app = \OC_App::findAppInDirectories($appId);
|
||||
|
@ -109,6 +109,29 @@ class Installer {
|
|||
$basedir = $app['path'].'/'.$appId;
|
||||
$info = OC_App::getAppInfo($basedir.'/appinfo/info.xml', true);
|
||||
|
||||
$l = \OC::$server->getL10N('core');
|
||||
|
||||
if(!is_array($info)) {
|
||||
throw new \Exception(
|
||||
$l->t('App "%s" cannot be installed because appinfo file cannot be read.',
|
||||
[$info['name']]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$version = \OCP\Util::getVersion();
|
||||
if (!\OC_App::isAppCompatible($version, $info)) {
|
||||
throw new \Exception(
|
||||
// TODO $l
|
||||
$l->t('App "%s" cannot be installed because it is not compatible with this version of the server.',
|
||||
[$info['name']]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// check for required dependencies
|
||||
\OC_App::checkAppDependencies($this->config, $l, $info);
|
||||
|
||||
//install the database
|
||||
if(is_file($basedir.'/appinfo/database.xml')) {
|
||||
if (\OC::$server->getAppConfig()->getValue($info['id'], 'installed_version') === null) {
|
||||
|
@ -120,6 +143,9 @@ class Installer {
|
|||
|
||||
\OC_App::registerAutoloading($appId, $basedir);
|
||||
\OC_App::setupBackgroundJobs($info['background-jobs']);
|
||||
if(isset($info['settings']) && is_array($info['settings'])) {
|
||||
\OC::$server->getSettingsManager()->setupSettings($info['settings']);
|
||||
}
|
||||
|
||||
//run appinfo/install.php
|
||||
if((!isset($data['noinstall']) or $data['noinstall']==false)) {
|
||||
|
|
|
@ -357,8 +357,6 @@ class OC_App {
|
|||
public function enable($appId,
|
||||
$groups = null) {
|
||||
self::$enabledAppsCache = []; // flush
|
||||
$l = \OC::$server->getL10N('core');
|
||||
$config = \OC::$server->getConfig();
|
||||
|
||||
// Check if app is already downloaded
|
||||
$installer = new Installer(
|
||||
|
@ -374,23 +372,7 @@ class OC_App {
|
|||
$installer->downloadApp($appId);
|
||||
}
|
||||
|
||||
if (!Installer::isInstalled($appId)) {
|
||||
$appId = self::installApp(
|
||||
$appId,
|
||||
$config,
|
||||
$l
|
||||
);
|
||||
$appPath = self::getAppPath($appId);
|
||||
self::registerAutoloading($appId, $appPath);
|
||||
$installer->installApp($appId);
|
||||
} else {
|
||||
// check for required dependencies
|
||||
$info = self::getAppInfo($appId);
|
||||
self::checkAppDependencies($config, $l, $info);
|
||||
$appPath = self::getAppPath($appId);
|
||||
self::registerAutoloading($appId, $appPath);
|
||||
$installer->installApp($appId);
|
||||
}
|
||||
$installer->installApp($appId);
|
||||
|
||||
$appManager = \OC::$server->getAppManager();
|
||||
if (!is_null($groups)) {
|
||||
|
@ -406,13 +388,6 @@ class OC_App {
|
|||
} else {
|
||||
$appManager->enableApp($appId);
|
||||
}
|
||||
|
||||
$info = self::getAppInfo($appId);
|
||||
if(isset($info['settings']) && is_array($info['settings'])) {
|
||||
$appPath = self::getAppPath($appId);
|
||||
self::registerAutoloading($appId, $appPath);
|
||||
\OC::$server->getSettingsManager()->setupSettings($info['settings']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1258,7 +1233,7 @@ class OC_App {
|
|||
* @param array $info
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected static function checkAppDependencies($config, $l, $info) {
|
||||
public static function checkAppDependencies($config, $l, $info) {
|
||||
$dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l);
|
||||
$missing = $dependencyAnalyzer->analyze($info);
|
||||
if (!empty($missing)) {
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
||||
*
|
||||
* @author Georg Ehrke <georg@owncloud.com>
|
||||
* @author Lukas Reschke <lukas@statuscode.ch>
|
||||
* @author Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license AGPL-3.0
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License, version 3,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
OCP\JSON::checkAdminUser();
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
$lastConfirm = (int) \OC::$server->getSession()->get('last-password-confirm');
|
||||
if ($lastConfirm < (time() - 30 * 60 + 15)) { // allow 15 seconds delay
|
||||
$l = \OC::$server->getL10N('core');
|
||||
OC_JSON::error(array( 'data' => array( 'message' => $l->t('Password confirmation is required'))));
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!array_key_exists('appid', $_POST)) {
|
||||
OC_JSON::error();
|
||||
exit;
|
||||
}
|
||||
|
||||
$app = new OC_App();
|
||||
$appId = (string)$_POST['appid'];
|
||||
$appId = OC_App::cleanAppId($appId);
|
||||
$result = $app->installApp(
|
||||
$appId,
|
||||
\OC::$server->getConfig(),
|
||||
\OC::$server->getL10N('core')
|
||||
);
|
||||
if($result !== false) {
|
||||
OC_JSON::success(array('data' => array('appid' => $appId)));
|
||||
} else {
|
||||
$l = \OC::$server->getL10N('settings');
|
||||
OC_JSON::error(array("data" => array( "message" => $l->t("Couldn't remove app.") )));
|
||||
}
|
Loading…
Reference in a new issue