Disallow disabling of files app

This commit is contained in:
Morris Jobke 2015-02-03 00:39:01 +01:00
parent 1bb8d5978c
commit a7eedf0149
3 changed files with 13 additions and 2 deletions

View File

@ -28,8 +28,12 @@ class Disable extends Command {
protected function execute(InputInterface $input, OutputInterface $output) { protected function execute(InputInterface $input, OutputInterface $output) {
$appId = $input->getArgument('app-id'); $appId = $input->getArgument('app-id');
if (\OC_App::isEnabled($appId)) { if (\OC_App::isEnabled($appId)) {
\OC_App::disable($appId); try {
$output->writeln($appId . ' disabled'); \OC_App::disable($appId);
$output->writeln($appId . ' disabled');
} catch(\Exception $e) {
$output->writeln($e->getMessage());
}
} else { } else {
$output->writeln('No such app enabled: ' . $appId); $output->writeln('No such app enabled: ' . $appId);
} }

View File

@ -321,6 +321,9 @@ class OC_App {
* @param string $app app * @param string $app app
*/ */
public static function disable($app) { public static function disable($app) {
if($app === 'files') {
throw new \Exception("App 'files' can't be disabled.");
}
self::$enabledAppsCache = array(); // flush self::$enabledAppsCache = array(); // flush
// check if app is a shipped app or not. if not delete // check if app is a shipped app or not. if not delete
\OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app)); \OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app));

View File

@ -131,8 +131,12 @@ class AppManager implements IAppManager {
* Disable an app for every user * Disable an app for every user
* *
* @param string $appId * @param string $appId
* @throws \Exception if app can't be disabled
*/ */
public function disableApp($appId) { public function disableApp($appId) {
if($appId === 'files') {
throw new \Exception("App 'files' can't be disabled.");
}
$this->appConfig->setValue($appId, 'enabled', 'no'); $this->appConfig->setValue($appId, 'enabled', 'no');
} }
} }