@@ -35,134 +35,134 @@ |
||
| 35 | 35 | |
| 36 | 36 | class CreateJs extends Command implements CompletionAwareInterface { |
| 37 | 37 | |
| 38 | - protected function configure() { |
|
| 39 | - $this |
|
| 40 | - ->setName('l10n:createjs') |
|
| 41 | - ->setDescription('Create javascript translation files for a given app') |
|
| 42 | - ->addArgument( |
|
| 43 | - 'app', |
|
| 44 | - InputOption::VALUE_REQUIRED, |
|
| 45 | - 'name of the app' |
|
| 46 | - ) |
|
| 47 | - ->addArgument( |
|
| 48 | - 'lang', |
|
| 49 | - InputOption::VALUE_OPTIONAL, |
|
| 50 | - 'name of the language' |
|
| 51 | - ); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 55 | - $app = $input->getArgument('app'); |
|
| 56 | - $lang = $input->getArgument('lang'); |
|
| 57 | - |
|
| 58 | - $path = \OC_App::getAppPath($app); |
|
| 59 | - if ($path === false) { |
|
| 60 | - $output->writeln("The app <$app> is unknown."); |
|
| 61 | - return; |
|
| 62 | - } |
|
| 63 | - $languages = $lang; |
|
| 64 | - if (empty($lang)) { |
|
| 65 | - $languages= $this->getAllLanguages($path); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - foreach($languages as $lang) { |
|
| 69 | - $this->writeFiles($app, $path, $lang, $output); |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - private function getAllLanguages($path) { |
|
| 74 | - $result = array(); |
|
| 75 | - foreach (new DirectoryIterator("$path/l10n") as $fileInfo) { |
|
| 76 | - if($fileInfo->isDot()) { |
|
| 77 | - continue; |
|
| 78 | - } |
|
| 79 | - if($fileInfo->isDir()) { |
|
| 80 | - continue; |
|
| 81 | - } |
|
| 82 | - if($fileInfo->getExtension() !== 'php') { |
|
| 83 | - continue; |
|
| 84 | - } |
|
| 85 | - $result[]= substr($fileInfo->getBasename(), 0, -4); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - return $result; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - private function writeFiles($app, $path, $lang, OutputInterface $output) { |
|
| 92 | - list($translations, $plurals) = $this->loadTranslations($path, $lang); |
|
| 93 | - $this->writeJsFile($app, $path, $lang, $output, $translations, $plurals); |
|
| 94 | - $this->writeJsonFile($path, $lang, $output, $translations, $plurals); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - private function writeJsFile($app, $path, $lang, OutputInterface $output, $translations, $plurals) { |
|
| 98 | - $jsFile = "$path/l10n/$lang.js"; |
|
| 99 | - if (file_exists($jsFile)) { |
|
| 100 | - $output->writeln("File already exists: $jsFile"); |
|
| 101 | - return; |
|
| 102 | - } |
|
| 103 | - $content = "OC.L10N.register(\n \"$app\",\n {\n "; |
|
| 104 | - $jsTrans = array(); |
|
| 105 | - foreach ($translations as $id => $val) { |
|
| 106 | - if (is_array($val)) { |
|
| 107 | - $val = '[ ' . join(',', $val) . ']'; |
|
| 108 | - } |
|
| 109 | - $jsTrans[] = "\"$id\" : \"$val\""; |
|
| 110 | - } |
|
| 111 | - $content .= join(",\n ", $jsTrans); |
|
| 112 | - $content .= "\n},\n\"$plurals\");\n"; |
|
| 113 | - |
|
| 114 | - file_put_contents($jsFile, $content); |
|
| 115 | - $output->writeln("Javascript translation file generated: $jsFile"); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - private function writeJsonFile($path, $lang, OutputInterface $output, $translations, $plurals) { |
|
| 119 | - $jsFile = "$path/l10n/$lang.json"; |
|
| 120 | - if (file_exists($jsFile)) { |
|
| 121 | - $output->writeln("File already exists: $jsFile"); |
|
| 122 | - return; |
|
| 123 | - } |
|
| 124 | - $content = array('translations' => $translations, 'pluralForm' => $plurals); |
|
| 125 | - file_put_contents($jsFile, json_encode($content)); |
|
| 126 | - $output->writeln("Json translation file generated: $jsFile"); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - private function loadTranslations($path, $lang) { |
|
| 130 | - $phpFile = "$path/l10n/$lang.php"; |
|
| 131 | - $TRANSLATIONS = array(); |
|
| 132 | - $PLURAL_FORMS = ''; |
|
| 133 | - if (!file_exists($phpFile)) { |
|
| 134 | - throw new UnexpectedValueException("PHP translation file <$phpFile> does not exist."); |
|
| 135 | - } |
|
| 136 | - require $phpFile; |
|
| 137 | - |
|
| 138 | - return array($TRANSLATIONS, $PLURAL_FORMS); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Return possible values for the named option |
|
| 143 | - * |
|
| 144 | - * @param string $optionName |
|
| 145 | - * @param CompletionContext $context |
|
| 146 | - * @return string[] |
|
| 147 | - */ |
|
| 148 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 149 | - return []; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * Return possible values for the named argument |
|
| 154 | - * |
|
| 155 | - * @param string $argumentName |
|
| 156 | - * @param CompletionContext $context |
|
| 157 | - * @return string[] |
|
| 158 | - */ |
|
| 159 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 160 | - if ($argumentName === 'app') { |
|
| 161 | - return \OC_App::getAllApps(); |
|
| 162 | - } else if ($argumentName === 'lang') { |
|
| 163 | - $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
| 164 | - return $this->getAllLanguages(\OC_App::getAppPath($appName)); |
|
| 165 | - } |
|
| 166 | - return []; |
|
| 167 | - } |
|
| 38 | + protected function configure() { |
|
| 39 | + $this |
|
| 40 | + ->setName('l10n:createjs') |
|
| 41 | + ->setDescription('Create javascript translation files for a given app') |
|
| 42 | + ->addArgument( |
|
| 43 | + 'app', |
|
| 44 | + InputOption::VALUE_REQUIRED, |
|
| 45 | + 'name of the app' |
|
| 46 | + ) |
|
| 47 | + ->addArgument( |
|
| 48 | + 'lang', |
|
| 49 | + InputOption::VALUE_OPTIONAL, |
|
| 50 | + 'name of the language' |
|
| 51 | + ); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 55 | + $app = $input->getArgument('app'); |
|
| 56 | + $lang = $input->getArgument('lang'); |
|
| 57 | + |
|
| 58 | + $path = \OC_App::getAppPath($app); |
|
| 59 | + if ($path === false) { |
|
| 60 | + $output->writeln("The app <$app> is unknown."); |
|
| 61 | + return; |
|
| 62 | + } |
|
| 63 | + $languages = $lang; |
|
| 64 | + if (empty($lang)) { |
|
| 65 | + $languages= $this->getAllLanguages($path); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + foreach($languages as $lang) { |
|
| 69 | + $this->writeFiles($app, $path, $lang, $output); |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + private function getAllLanguages($path) { |
|
| 74 | + $result = array(); |
|
| 75 | + foreach (new DirectoryIterator("$path/l10n") as $fileInfo) { |
|
| 76 | + if($fileInfo->isDot()) { |
|
| 77 | + continue; |
|
| 78 | + } |
|
| 79 | + if($fileInfo->isDir()) { |
|
| 80 | + continue; |
|
| 81 | + } |
|
| 82 | + if($fileInfo->getExtension() !== 'php') { |
|
| 83 | + continue; |
|
| 84 | + } |
|
| 85 | + $result[]= substr($fileInfo->getBasename(), 0, -4); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + return $result; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + private function writeFiles($app, $path, $lang, OutputInterface $output) { |
|
| 92 | + list($translations, $plurals) = $this->loadTranslations($path, $lang); |
|
| 93 | + $this->writeJsFile($app, $path, $lang, $output, $translations, $plurals); |
|
| 94 | + $this->writeJsonFile($path, $lang, $output, $translations, $plurals); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + private function writeJsFile($app, $path, $lang, OutputInterface $output, $translations, $plurals) { |
|
| 98 | + $jsFile = "$path/l10n/$lang.js"; |
|
| 99 | + if (file_exists($jsFile)) { |
|
| 100 | + $output->writeln("File already exists: $jsFile"); |
|
| 101 | + return; |
|
| 102 | + } |
|
| 103 | + $content = "OC.L10N.register(\n \"$app\",\n {\n "; |
|
| 104 | + $jsTrans = array(); |
|
| 105 | + foreach ($translations as $id => $val) { |
|
| 106 | + if (is_array($val)) { |
|
| 107 | + $val = '[ ' . join(',', $val) . ']'; |
|
| 108 | + } |
|
| 109 | + $jsTrans[] = "\"$id\" : \"$val\""; |
|
| 110 | + } |
|
| 111 | + $content .= join(",\n ", $jsTrans); |
|
| 112 | + $content .= "\n},\n\"$plurals\");\n"; |
|
| 113 | + |
|
| 114 | + file_put_contents($jsFile, $content); |
|
| 115 | + $output->writeln("Javascript translation file generated: $jsFile"); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + private function writeJsonFile($path, $lang, OutputInterface $output, $translations, $plurals) { |
|
| 119 | + $jsFile = "$path/l10n/$lang.json"; |
|
| 120 | + if (file_exists($jsFile)) { |
|
| 121 | + $output->writeln("File already exists: $jsFile"); |
|
| 122 | + return; |
|
| 123 | + } |
|
| 124 | + $content = array('translations' => $translations, 'pluralForm' => $plurals); |
|
| 125 | + file_put_contents($jsFile, json_encode($content)); |
|
| 126 | + $output->writeln("Json translation file generated: $jsFile"); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + private function loadTranslations($path, $lang) { |
|
| 130 | + $phpFile = "$path/l10n/$lang.php"; |
|
| 131 | + $TRANSLATIONS = array(); |
|
| 132 | + $PLURAL_FORMS = ''; |
|
| 133 | + if (!file_exists($phpFile)) { |
|
| 134 | + throw new UnexpectedValueException("PHP translation file <$phpFile> does not exist."); |
|
| 135 | + } |
|
| 136 | + require $phpFile; |
|
| 137 | + |
|
| 138 | + return array($TRANSLATIONS, $PLURAL_FORMS); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Return possible values for the named option |
|
| 143 | + * |
|
| 144 | + * @param string $optionName |
|
| 145 | + * @param CompletionContext $context |
|
| 146 | + * @return string[] |
|
| 147 | + */ |
|
| 148 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 149 | + return []; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * Return possible values for the named argument |
|
| 154 | + * |
|
| 155 | + * @param string $argumentName |
|
| 156 | + * @param CompletionContext $context |
|
| 157 | + * @return string[] |
|
| 158 | + */ |
|
| 159 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 160 | + if ($argumentName === 'app') { |
|
| 161 | + return \OC_App::getAllApps(); |
|
| 162 | + } else if ($argumentName === 'lang') { |
|
| 163 | + $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
| 164 | + return $this->getAllLanguages(\OC_App::getAppPath($appName)); |
|
| 165 | + } |
|
| 166 | + return []; |
|
| 167 | + } |
|
| 168 | 168 | } |
@@ -62,10 +62,10 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | $languages = $lang; |
| 64 | 64 | if (empty($lang)) { |
| 65 | - $languages= $this->getAllLanguages($path); |
|
| 65 | + $languages = $this->getAllLanguages($path); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - foreach($languages as $lang) { |
|
| 68 | + foreach ($languages as $lang) { |
|
| 69 | 69 | $this->writeFiles($app, $path, $lang, $output); |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -73,16 +73,16 @@ discard block |
||
| 73 | 73 | private function getAllLanguages($path) { |
| 74 | 74 | $result = array(); |
| 75 | 75 | foreach (new DirectoryIterator("$path/l10n") as $fileInfo) { |
| 76 | - if($fileInfo->isDot()) { |
|
| 76 | + if ($fileInfo->isDot()) { |
|
| 77 | 77 | continue; |
| 78 | 78 | } |
| 79 | - if($fileInfo->isDir()) { |
|
| 79 | + if ($fileInfo->isDir()) { |
|
| 80 | 80 | continue; |
| 81 | 81 | } |
| 82 | - if($fileInfo->getExtension() !== 'php') { |
|
| 82 | + if ($fileInfo->getExtension() !== 'php') { |
|
| 83 | 83 | continue; |
| 84 | 84 | } |
| 85 | - $result[]= substr($fileInfo->getBasename(), 0, -4); |
|
| 85 | + $result[] = substr($fileInfo->getBasename(), 0, -4); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | return $result; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $jsTrans = array(); |
| 105 | 105 | foreach ($translations as $id => $val) { |
| 106 | 106 | if (is_array($val)) { |
| 107 | - $val = '[ ' . join(',', $val) . ']'; |
|
| 107 | + $val = '[ '.join(',', $val).']'; |
|
| 108 | 108 | } |
| 109 | 109 | $jsTrans[] = "\"$id\" : \"$val\""; |
| 110 | 110 | } |
@@ -28,23 +28,23 @@ |
||
| 28 | 28 | use Symfony\Component\Console\Output\OutputInterface; |
| 29 | 29 | |
| 30 | 30 | class Status extends Base { |
| 31 | - protected function configure() { |
|
| 32 | - parent::configure(); |
|
| 31 | + protected function configure() { |
|
| 32 | + parent::configure(); |
|
| 33 | 33 | |
| 34 | - $this |
|
| 35 | - ->setName('status') |
|
| 36 | - ->setDescription('show some status information') |
|
| 37 | - ; |
|
| 38 | - } |
|
| 34 | + $this |
|
| 35 | + ->setName('status') |
|
| 36 | + ->setDescription('show some status information') |
|
| 37 | + ; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 41 | - $values = array( |
|
| 42 | - 'installed' => (bool) \OC::$server->getConfig()->getSystemValue('installed', false), |
|
| 43 | - 'version' => implode('.', \OCP\Util::getVersion()), |
|
| 44 | - 'versionstring' => \OC_Util::getVersionString(), |
|
| 45 | - 'edition' => '', |
|
| 46 | - ); |
|
| 40 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 41 | + $values = array( |
|
| 42 | + 'installed' => (bool) \OC::$server->getConfig()->getSystemValue('installed', false), |
|
| 43 | + 'version' => implode('.', \OCP\Util::getVersion()), |
|
| 44 | + 'versionstring' => \OC_Util::getVersionString(), |
|
| 45 | + 'edition' => '', |
|
| 46 | + ); |
|
| 47 | 47 | |
| 48 | - $this->writeArrayInOutputFormat($input, $output, $values); |
|
| 49 | - } |
|
| 48 | + $this->writeArrayInOutputFormat($input, $output, $values); |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -30,35 +30,35 @@ |
||
| 30 | 30 | |
| 31 | 31 | class Enable extends Base { |
| 32 | 32 | |
| 33 | - /** @var Manager */ |
|
| 34 | - private $manager; |
|
| 33 | + /** @var Manager */ |
|
| 34 | + private $manager; |
|
| 35 | 35 | |
| 36 | - /** @var IUserManager */ |
|
| 37 | - protected $userManager; |
|
| 36 | + /** @var IUserManager */ |
|
| 37 | + protected $userManager; |
|
| 38 | 38 | |
| 39 | - public function __construct(Manager $manager, IUserManager $userManager) { |
|
| 40 | - parent::__construct('twofactorauth:enable'); |
|
| 41 | - $this->manager = $manager; |
|
| 42 | - $this->userManager = $userManager; |
|
| 43 | - } |
|
| 39 | + public function __construct(Manager $manager, IUserManager $userManager) { |
|
| 40 | + parent::__construct('twofactorauth:enable'); |
|
| 41 | + $this->manager = $manager; |
|
| 42 | + $this->userManager = $userManager; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - protected function configure() { |
|
| 46 | - parent::configure(); |
|
| 45 | + protected function configure() { |
|
| 46 | + parent::configure(); |
|
| 47 | 47 | |
| 48 | - $this->setName('twofactorauth:enable'); |
|
| 49 | - $this->setDescription('Enable two-factor authentication for a user'); |
|
| 50 | - $this->addArgument('uid', InputArgument::REQUIRED); |
|
| 51 | - } |
|
| 48 | + $this->setName('twofactorauth:enable'); |
|
| 49 | + $this->setDescription('Enable two-factor authentication for a user'); |
|
| 50 | + $this->addArgument('uid', InputArgument::REQUIRED); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 54 | - $uid = $input->getArgument('uid'); |
|
| 55 | - $user = $this->userManager->get($uid); |
|
| 56 | - if (is_null($user)) { |
|
| 57 | - $output->writeln("<error>Invalid UID</error>"); |
|
| 58 | - return; |
|
| 59 | - } |
|
| 60 | - $this->manager->enableTwoFactorAuthentication($user); |
|
| 61 | - $output->writeln("Two-factor authentication enabled for user $uid"); |
|
| 62 | - } |
|
| 53 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 54 | + $uid = $input->getArgument('uid'); |
|
| 55 | + $user = $this->userManager->get($uid); |
|
| 56 | + if (is_null($user)) { |
|
| 57 | + $output->writeln("<error>Invalid UID</error>"); |
|
| 58 | + return; |
|
| 59 | + } |
|
| 60 | + $this->manager->enableTwoFactorAuthentication($user); |
|
| 61 | + $output->writeln("Two-factor authentication enabled for user $uid"); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | } |
@@ -28,33 +28,33 @@ |
||
| 28 | 28 | |
| 29 | 29 | class Base extends \OC\Core\Command\Base implements CompletionAwareInterface { |
| 30 | 30 | |
| 31 | - /** @var IUserManager */ |
|
| 32 | - protected $userManager; |
|
| 31 | + /** @var IUserManager */ |
|
| 32 | + protected $userManager; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Return possible values for the named option |
|
| 36 | - * |
|
| 37 | - * @param string $optionName |
|
| 38 | - * @param CompletionContext $context |
|
| 39 | - * @return string[] |
|
| 40 | - */ |
|
| 41 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 42 | - return []; |
|
| 43 | - } |
|
| 34 | + /** |
|
| 35 | + * Return possible values for the named option |
|
| 36 | + * |
|
| 37 | + * @param string $optionName |
|
| 38 | + * @param CompletionContext $context |
|
| 39 | + * @return string[] |
|
| 40 | + */ |
|
| 41 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
| 42 | + return []; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Return possible values for the named argument |
|
| 47 | - * |
|
| 48 | - * @param string $argumentName |
|
| 49 | - * @param CompletionContext $context |
|
| 50 | - * @return string[] |
|
| 51 | - */ |
|
| 52 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 53 | - if ($argumentName === 'uid') { |
|
| 54 | - return array_map(function(IUser $user) { |
|
| 55 | - return $user->getUID(); |
|
| 56 | - }, $this->userManager->search($context->getCurrentWord(), 100)); |
|
| 57 | - } |
|
| 58 | - return []; |
|
| 59 | - } |
|
| 45 | + /** |
|
| 46 | + * Return possible values for the named argument |
|
| 47 | + * |
|
| 48 | + * @param string $argumentName |
|
| 49 | + * @param CompletionContext $context |
|
| 50 | + * @return string[] |
|
| 51 | + */ |
|
| 52 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
| 53 | + if ($argumentName === 'uid') { |
|
| 54 | + return array_map(function(IUser $user) { |
|
| 55 | + return $user->getUID(); |
|
| 56 | + }, $this->userManager->search($context->getCurrentWord(), 100)); |
|
| 57 | + } |
|
| 58 | + return []; |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -30,35 +30,35 @@ |
||
| 30 | 30 | |
| 31 | 31 | class Disable extends Base { |
| 32 | 32 | |
| 33 | - /** @var Manager */ |
|
| 34 | - private $manager; |
|
| 33 | + /** @var Manager */ |
|
| 34 | + private $manager; |
|
| 35 | 35 | |
| 36 | - /** @var IUserManager */ |
|
| 37 | - protected $userManager; |
|
| 36 | + /** @var IUserManager */ |
|
| 37 | + protected $userManager; |
|
| 38 | 38 | |
| 39 | - public function __construct(Manager $manager, IUserManager $userManager) { |
|
| 40 | - parent::__construct('twofactorauth:disable'); |
|
| 41 | - $this->manager = $manager; |
|
| 42 | - $this->userManager = $userManager; |
|
| 43 | - } |
|
| 39 | + public function __construct(Manager $manager, IUserManager $userManager) { |
|
| 40 | + parent::__construct('twofactorauth:disable'); |
|
| 41 | + $this->manager = $manager; |
|
| 42 | + $this->userManager = $userManager; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - protected function configure() { |
|
| 46 | - parent::configure(); |
|
| 45 | + protected function configure() { |
|
| 46 | + parent::configure(); |
|
| 47 | 47 | |
| 48 | - $this->setName('twofactorauth:disable'); |
|
| 49 | - $this->setDescription('Disable two-factor authentication for a user'); |
|
| 50 | - $this->addArgument('uid', InputArgument::REQUIRED); |
|
| 51 | - } |
|
| 48 | + $this->setName('twofactorauth:disable'); |
|
| 49 | + $this->setDescription('Disable two-factor authentication for a user'); |
|
| 50 | + $this->addArgument('uid', InputArgument::REQUIRED); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 54 | - $uid = $input->getArgument('uid'); |
|
| 55 | - $user = $this->userManager->get($uid); |
|
| 56 | - if (is_null($user)) { |
|
| 57 | - $output->writeln("<error>Invalid UID</error>"); |
|
| 58 | - return; |
|
| 59 | - } |
|
| 60 | - $this->manager->disableTwoFactorAuthentication($user); |
|
| 61 | - $output->writeln("Two-factor authentication disabled for user $uid"); |
|
| 62 | - } |
|
| 53 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 54 | + $uid = $input->getArgument('uid'); |
|
| 55 | + $user = $this->userManager->get($uid); |
|
| 56 | + if (is_null($user)) { |
|
| 57 | + $output->writeln("<error>Invalid UID</error>"); |
|
| 58 | + return; |
|
| 59 | + } |
|
| 60 | + $this->manager->disableTwoFactorAuthentication($user); |
|
| 61 | + $output->writeln("Two-factor authentication disabled for user $uid"); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | } |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | $this->printErrors($output, $errors); |
| 79 | 79 | |
| 80 | 80 | // ignore the OS X setup warning |
| 81 | - if(count($errors) !== 1 || |
|
| 82 | - (string)($errors[0]['error']) !== 'Mac OS X is not supported and Nextcloud will not work properly on this platform. Use it at your own risk! ') { |
|
| 81 | + if (count($errors) !== 1 || |
|
| 82 | + (string) ($errors[0]['error']) !== 'Mac OS X is not supported and Nextcloud will not work properly on this platform. Use it at your own risk! ') { |
|
| 83 | 83 | return 1; |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -180,10 +180,10 @@ discard block |
||
| 180 | 180 | protected function printErrors(OutputInterface $output, $errors) { |
| 181 | 181 | foreach ($errors as $error) { |
| 182 | 182 | if (is_array($error)) { |
| 183 | - $output->writeln('<error>' . (string)$error['error'] . '</error>'); |
|
| 184 | - $output->writeln('<info> -> ' . (string)$error['hint'] . '</info>'); |
|
| 183 | + $output->writeln('<error>'.(string) $error['error'].'</error>'); |
|
| 184 | + $output->writeln('<info> -> '.(string) $error['hint'].'</info>'); |
|
| 185 | 185 | } else { |
| 186 | - $output->writeln('<error>' . (string)$error . '</error>'); |
|
| 186 | + $output->writeln('<error>'.(string) $error.'</error>'); |
|
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | } |
@@ -43,162 +43,162 @@ |
||
| 43 | 43 | |
| 44 | 44 | class Install extends Command { |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var SystemConfig |
|
| 48 | - */ |
|
| 49 | - private $config; |
|
| 50 | - |
|
| 51 | - public function __construct(SystemConfig $config) { |
|
| 52 | - parent::__construct(); |
|
| 53 | - $this->config = $config; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - protected function configure() { |
|
| 57 | - $this |
|
| 58 | - ->setName('maintenance:install') |
|
| 59 | - ->setDescription('install Nextcloud') |
|
| 60 | - ->addOption('database', null, InputOption::VALUE_REQUIRED, 'Supported database type', 'sqlite') |
|
| 61 | - ->addOption('database-name', null, InputOption::VALUE_REQUIRED, 'Name of the database') |
|
| 62 | - ->addOption('database-host', null, InputOption::VALUE_REQUIRED, 'Hostname of the database', 'localhost') |
|
| 63 | - ->addOption('database-port', null, InputOption::VALUE_REQUIRED, 'Port the database is listening on') |
|
| 64 | - ->addOption('database-user', null, InputOption::VALUE_REQUIRED, 'User name to connect to the database') |
|
| 65 | - ->addOption('database-pass', null, InputOption::VALUE_OPTIONAL, 'Password of the database user', null) |
|
| 66 | - ->addOption('database-table-prefix', null, InputOption::VALUE_OPTIONAL, 'Prefix for all tables (default: oc_)', null) |
|
| 67 | - ->addOption('database-table-space', null, InputOption::VALUE_OPTIONAL, 'Table space of the database (oci only)', null) |
|
| 68 | - ->addOption('admin-user', null, InputOption::VALUE_REQUIRED, 'User name of the admin account', 'admin') |
|
| 69 | - ->addOption('admin-pass', null, InputOption::VALUE_REQUIRED, 'Password of the admin account') |
|
| 70 | - ->addOption('data-dir', null, InputOption::VALUE_REQUIRED, 'Path to data directory', \OC::$SERVERROOT."/data"); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 74 | - |
|
| 75 | - // validate the environment |
|
| 76 | - $server = \OC::$server; |
|
| 77 | - $setupHelper = new Setup( |
|
| 78 | - $this->config, |
|
| 79 | - $server->getIniWrapper(), |
|
| 80 | - $server->getL10N('lib'), |
|
| 81 | - $server->query(Defaults::class), |
|
| 82 | - $server->getLogger(), |
|
| 83 | - $server->getSecureRandom(), |
|
| 84 | - \OC::$server->query(Installer::class) |
|
| 85 | - ); |
|
| 86 | - $sysInfo = $setupHelper->getSystemInfo(true); |
|
| 87 | - $errors = $sysInfo['errors']; |
|
| 88 | - if (count($errors) > 0) { |
|
| 89 | - $this->printErrors($output, $errors); |
|
| 90 | - |
|
| 91 | - // ignore the OS X setup warning |
|
| 92 | - if(count($errors) !== 1 || |
|
| 93 | - (string)($errors[0]['error']) !== 'Mac OS X is not supported and Nextcloud will not work properly on this platform. Use it at your own risk! ') { |
|
| 94 | - return 1; |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - // validate user input |
|
| 99 | - $options = $this->validateInput($input, $output, array_keys($sysInfo['databases'])); |
|
| 100 | - |
|
| 101 | - // perform installation |
|
| 102 | - $errors = $setupHelper->install($options); |
|
| 103 | - if (count($errors) > 0) { |
|
| 104 | - $this->printErrors($output, $errors); |
|
| 105 | - return 1; |
|
| 106 | - } |
|
| 107 | - $output->writeln("Nextcloud was successfully installed"); |
|
| 108 | - return 0; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * @param InputInterface $input |
|
| 113 | - * @param OutputInterface $output |
|
| 114 | - * @param string[] $supportedDatabases |
|
| 115 | - * @return array |
|
| 116 | - */ |
|
| 117 | - protected function validateInput(InputInterface $input, OutputInterface $output, $supportedDatabases) { |
|
| 118 | - $db = strtolower($input->getOption('database')); |
|
| 119 | - |
|
| 120 | - if (!in_array($db, $supportedDatabases)) { |
|
| 121 | - throw new InvalidArgumentException("Database <$db> is not supported."); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - $dbUser = $input->getOption('database-user'); |
|
| 125 | - $dbPass = $input->getOption('database-pass'); |
|
| 126 | - $dbName = $input->getOption('database-name'); |
|
| 127 | - $dbPort = $input->getOption('database-port'); |
|
| 128 | - if ($db === 'oci') { |
|
| 129 | - // an empty hostname needs to be read from the raw parameters |
|
| 130 | - $dbHost = $input->getParameterOption('--database-host', ''); |
|
| 131 | - } else { |
|
| 132 | - $dbHost = $input->getOption('database-host'); |
|
| 133 | - } |
|
| 134 | - $dbTablePrefix = 'oc_'; |
|
| 135 | - if ($input->hasParameterOption('--database-table-prefix')) { |
|
| 136 | - $dbTablePrefix = (string) $input->getOption('database-table-prefix'); |
|
| 137 | - $dbTablePrefix = trim($dbTablePrefix); |
|
| 138 | - } |
|
| 139 | - if ($input->hasParameterOption('--database-pass')) { |
|
| 140 | - $dbPass = (string) $input->getOption('database-pass'); |
|
| 141 | - } |
|
| 142 | - $adminLogin = $input->getOption('admin-user'); |
|
| 143 | - $adminPassword = $input->getOption('admin-pass'); |
|
| 144 | - $dataDir = $input->getOption('data-dir'); |
|
| 145 | - |
|
| 146 | - if ($db !== 'sqlite') { |
|
| 147 | - if (is_null($dbUser)) { |
|
| 148 | - throw new InvalidArgumentException("Database user not provided."); |
|
| 149 | - } |
|
| 150 | - if (is_null($dbName)) { |
|
| 151 | - throw new InvalidArgumentException("Database name not provided."); |
|
| 152 | - } |
|
| 153 | - if (is_null($dbPass)) { |
|
| 154 | - /** @var QuestionHelper $helper */ |
|
| 155 | - $helper = $this->getHelper('question'); |
|
| 156 | - $question = new Question('What is the password to access the database with user <'.$dbUser.'>?'); |
|
| 157 | - $question->setHidden(true); |
|
| 158 | - $question->setHiddenFallback(false); |
|
| 159 | - $dbPass = $helper->ask($input, $output, $question); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - if (is_null($adminPassword)) { |
|
| 164 | - /** @var QuestionHelper $helper */ |
|
| 165 | - $helper = $this->getHelper('question'); |
|
| 166 | - $question = new Question('What is the password you like to use for the admin account <'.$adminLogin.'>?'); |
|
| 167 | - $question->setHidden(true); |
|
| 168 | - $question->setHiddenFallback(false); |
|
| 169 | - $adminPassword = $helper->ask($input, $output, $question); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - $options = [ |
|
| 173 | - 'dbtype' => $db, |
|
| 174 | - 'dbuser' => $dbUser, |
|
| 175 | - 'dbpass' => $dbPass, |
|
| 176 | - 'dbname' => $dbName, |
|
| 177 | - 'dbhost' => $dbHost, |
|
| 178 | - 'dbport' => $dbPort, |
|
| 179 | - 'dbtableprefix' => $dbTablePrefix, |
|
| 180 | - 'adminlogin' => $adminLogin, |
|
| 181 | - 'adminpass' => $adminPassword, |
|
| 182 | - 'directory' => $dataDir |
|
| 183 | - ]; |
|
| 184 | - if ($db === 'oci') { |
|
| 185 | - $options['dbtablespace'] = $input->getParameterOption('--database-table-space', ''); |
|
| 186 | - } |
|
| 187 | - return $options; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * @param OutputInterface $output |
|
| 192 | - * @param $errors |
|
| 193 | - */ |
|
| 194 | - protected function printErrors(OutputInterface $output, $errors) { |
|
| 195 | - foreach ($errors as $error) { |
|
| 196 | - if (is_array($error)) { |
|
| 197 | - $output->writeln('<error>' . (string)$error['error'] . '</error>'); |
|
| 198 | - $output->writeln('<info> -> ' . (string)$error['hint'] . '</info>'); |
|
| 199 | - } else { |
|
| 200 | - $output->writeln('<error>' . (string)$error . '</error>'); |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - } |
|
| 46 | + /** |
|
| 47 | + * @var SystemConfig |
|
| 48 | + */ |
|
| 49 | + private $config; |
|
| 50 | + |
|
| 51 | + public function __construct(SystemConfig $config) { |
|
| 52 | + parent::__construct(); |
|
| 53 | + $this->config = $config; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + protected function configure() { |
|
| 57 | + $this |
|
| 58 | + ->setName('maintenance:install') |
|
| 59 | + ->setDescription('install Nextcloud') |
|
| 60 | + ->addOption('database', null, InputOption::VALUE_REQUIRED, 'Supported database type', 'sqlite') |
|
| 61 | + ->addOption('database-name', null, InputOption::VALUE_REQUIRED, 'Name of the database') |
|
| 62 | + ->addOption('database-host', null, InputOption::VALUE_REQUIRED, 'Hostname of the database', 'localhost') |
|
| 63 | + ->addOption('database-port', null, InputOption::VALUE_REQUIRED, 'Port the database is listening on') |
|
| 64 | + ->addOption('database-user', null, InputOption::VALUE_REQUIRED, 'User name to connect to the database') |
|
| 65 | + ->addOption('database-pass', null, InputOption::VALUE_OPTIONAL, 'Password of the database user', null) |
|
| 66 | + ->addOption('database-table-prefix', null, InputOption::VALUE_OPTIONAL, 'Prefix for all tables (default: oc_)', null) |
|
| 67 | + ->addOption('database-table-space', null, InputOption::VALUE_OPTIONAL, 'Table space of the database (oci only)', null) |
|
| 68 | + ->addOption('admin-user', null, InputOption::VALUE_REQUIRED, 'User name of the admin account', 'admin') |
|
| 69 | + ->addOption('admin-pass', null, InputOption::VALUE_REQUIRED, 'Password of the admin account') |
|
| 70 | + ->addOption('data-dir', null, InputOption::VALUE_REQUIRED, 'Path to data directory', \OC::$SERVERROOT."/data"); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 74 | + |
|
| 75 | + // validate the environment |
|
| 76 | + $server = \OC::$server; |
|
| 77 | + $setupHelper = new Setup( |
|
| 78 | + $this->config, |
|
| 79 | + $server->getIniWrapper(), |
|
| 80 | + $server->getL10N('lib'), |
|
| 81 | + $server->query(Defaults::class), |
|
| 82 | + $server->getLogger(), |
|
| 83 | + $server->getSecureRandom(), |
|
| 84 | + \OC::$server->query(Installer::class) |
|
| 85 | + ); |
|
| 86 | + $sysInfo = $setupHelper->getSystemInfo(true); |
|
| 87 | + $errors = $sysInfo['errors']; |
|
| 88 | + if (count($errors) > 0) { |
|
| 89 | + $this->printErrors($output, $errors); |
|
| 90 | + |
|
| 91 | + // ignore the OS X setup warning |
|
| 92 | + if(count($errors) !== 1 || |
|
| 93 | + (string)($errors[0]['error']) !== 'Mac OS X is not supported and Nextcloud will not work properly on this platform. Use it at your own risk! ') { |
|
| 94 | + return 1; |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + // validate user input |
|
| 99 | + $options = $this->validateInput($input, $output, array_keys($sysInfo['databases'])); |
|
| 100 | + |
|
| 101 | + // perform installation |
|
| 102 | + $errors = $setupHelper->install($options); |
|
| 103 | + if (count($errors) > 0) { |
|
| 104 | + $this->printErrors($output, $errors); |
|
| 105 | + return 1; |
|
| 106 | + } |
|
| 107 | + $output->writeln("Nextcloud was successfully installed"); |
|
| 108 | + return 0; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * @param InputInterface $input |
|
| 113 | + * @param OutputInterface $output |
|
| 114 | + * @param string[] $supportedDatabases |
|
| 115 | + * @return array |
|
| 116 | + */ |
|
| 117 | + protected function validateInput(InputInterface $input, OutputInterface $output, $supportedDatabases) { |
|
| 118 | + $db = strtolower($input->getOption('database')); |
|
| 119 | + |
|
| 120 | + if (!in_array($db, $supportedDatabases)) { |
|
| 121 | + throw new InvalidArgumentException("Database <$db> is not supported."); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + $dbUser = $input->getOption('database-user'); |
|
| 125 | + $dbPass = $input->getOption('database-pass'); |
|
| 126 | + $dbName = $input->getOption('database-name'); |
|
| 127 | + $dbPort = $input->getOption('database-port'); |
|
| 128 | + if ($db === 'oci') { |
|
| 129 | + // an empty hostname needs to be read from the raw parameters |
|
| 130 | + $dbHost = $input->getParameterOption('--database-host', ''); |
|
| 131 | + } else { |
|
| 132 | + $dbHost = $input->getOption('database-host'); |
|
| 133 | + } |
|
| 134 | + $dbTablePrefix = 'oc_'; |
|
| 135 | + if ($input->hasParameterOption('--database-table-prefix')) { |
|
| 136 | + $dbTablePrefix = (string) $input->getOption('database-table-prefix'); |
|
| 137 | + $dbTablePrefix = trim($dbTablePrefix); |
|
| 138 | + } |
|
| 139 | + if ($input->hasParameterOption('--database-pass')) { |
|
| 140 | + $dbPass = (string) $input->getOption('database-pass'); |
|
| 141 | + } |
|
| 142 | + $adminLogin = $input->getOption('admin-user'); |
|
| 143 | + $adminPassword = $input->getOption('admin-pass'); |
|
| 144 | + $dataDir = $input->getOption('data-dir'); |
|
| 145 | + |
|
| 146 | + if ($db !== 'sqlite') { |
|
| 147 | + if (is_null($dbUser)) { |
|
| 148 | + throw new InvalidArgumentException("Database user not provided."); |
|
| 149 | + } |
|
| 150 | + if (is_null($dbName)) { |
|
| 151 | + throw new InvalidArgumentException("Database name not provided."); |
|
| 152 | + } |
|
| 153 | + if (is_null($dbPass)) { |
|
| 154 | + /** @var QuestionHelper $helper */ |
|
| 155 | + $helper = $this->getHelper('question'); |
|
| 156 | + $question = new Question('What is the password to access the database with user <'.$dbUser.'>?'); |
|
| 157 | + $question->setHidden(true); |
|
| 158 | + $question->setHiddenFallback(false); |
|
| 159 | + $dbPass = $helper->ask($input, $output, $question); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + if (is_null($adminPassword)) { |
|
| 164 | + /** @var QuestionHelper $helper */ |
|
| 165 | + $helper = $this->getHelper('question'); |
|
| 166 | + $question = new Question('What is the password you like to use for the admin account <'.$adminLogin.'>?'); |
|
| 167 | + $question->setHidden(true); |
|
| 168 | + $question->setHiddenFallback(false); |
|
| 169 | + $adminPassword = $helper->ask($input, $output, $question); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + $options = [ |
|
| 173 | + 'dbtype' => $db, |
|
| 174 | + 'dbuser' => $dbUser, |
|
| 175 | + 'dbpass' => $dbPass, |
|
| 176 | + 'dbname' => $dbName, |
|
| 177 | + 'dbhost' => $dbHost, |
|
| 178 | + 'dbport' => $dbPort, |
|
| 179 | + 'dbtableprefix' => $dbTablePrefix, |
|
| 180 | + 'adminlogin' => $adminLogin, |
|
| 181 | + 'adminpass' => $adminPassword, |
|
| 182 | + 'directory' => $dataDir |
|
| 183 | + ]; |
|
| 184 | + if ($db === 'oci') { |
|
| 185 | + $options['dbtablespace'] = $input->getParameterOption('--database-table-space', ''); |
|
| 186 | + } |
|
| 187 | + return $options; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * @param OutputInterface $output |
|
| 192 | + * @param $errors |
|
| 193 | + */ |
|
| 194 | + protected function printErrors(OutputInterface $output, $errors) { |
|
| 195 | + foreach ($errors as $error) { |
|
| 196 | + if (is_array($error)) { |
|
| 197 | + $output->writeln('<error>' . (string)$error['error'] . '</error>'); |
|
| 198 | + $output->writeln('<info> -> ' . (string)$error['hint'] . '</info>'); |
|
| 199 | + } else { |
|
| 200 | + $output->writeln('<error>' . (string)$error . '</error>'); |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | 204 | } |
@@ -30,25 +30,25 @@ |
||
| 30 | 30 | |
| 31 | 31 | class DataFingerprint extends Command { |
| 32 | 32 | |
| 33 | - /** @var IConfig */ |
|
| 34 | - protected $config; |
|
| 35 | - /** @var ITimeFactory */ |
|
| 36 | - protected $timeFactory; |
|
| 33 | + /** @var IConfig */ |
|
| 34 | + protected $config; |
|
| 35 | + /** @var ITimeFactory */ |
|
| 36 | + protected $timeFactory; |
|
| 37 | 37 | |
| 38 | - public function __construct(IConfig $config, |
|
| 39 | - ITimeFactory $timeFactory) { |
|
| 40 | - $this->config = $config; |
|
| 41 | - $this->timeFactory = $timeFactory; |
|
| 42 | - parent::__construct(); |
|
| 43 | - } |
|
| 38 | + public function __construct(IConfig $config, |
|
| 39 | + ITimeFactory $timeFactory) { |
|
| 40 | + $this->config = $config; |
|
| 41 | + $this->timeFactory = $timeFactory; |
|
| 42 | + parent::__construct(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - protected function configure() { |
|
| 46 | - $this |
|
| 47 | - ->setName('maintenance:data-fingerprint') |
|
| 48 | - ->setDescription('update the systems data-fingerprint after a backup is restored'); |
|
| 49 | - } |
|
| 45 | + protected function configure() { |
|
| 46 | + $this |
|
| 47 | + ->setName('maintenance:data-fingerprint') |
|
| 48 | + ->setDescription('update the systems data-fingerprint after a backup is restored'); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 52 | - $this->config->setSystemValue('data-fingerprint', md5($this->timeFactory->getTime())); |
|
| 53 | - } |
|
| 51 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 52 | + $this->config->setSystemValue('data-fingerprint', md5($this->timeFactory->getTime())); |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -132,16 +132,16 @@ |
||
| 132 | 132 | $this->output->writeln(''); |
| 133 | 133 | break; |
| 134 | 134 | case '\OC\Repair::step': |
| 135 | - $this->output->writeln(' - ' . $event->getArgument(0)); |
|
| 135 | + $this->output->writeln(' - '.$event->getArgument(0)); |
|
| 136 | 136 | break; |
| 137 | 137 | case '\OC\Repair::info': |
| 138 | - $this->output->writeln(' - ' . $event->getArgument(0)); |
|
| 138 | + $this->output->writeln(' - '.$event->getArgument(0)); |
|
| 139 | 139 | break; |
| 140 | 140 | case '\OC\Repair::warning': |
| 141 | - $this->output->writeln(' - WARNING: ' . $event->getArgument(0)); |
|
| 141 | + $this->output->writeln(' - WARNING: '.$event->getArgument(0)); |
|
| 142 | 142 | break; |
| 143 | 143 | case '\OC\Repair::error': |
| 144 | - $this->output->writeln(' - ERROR: ' . $event->getArgument(0)); |
|
| 144 | + $this->output->writeln(' - ERROR: '.$event->getArgument(0)); |
|
| 145 | 145 | break; |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -38,116 +38,116 @@ |
||
| 38 | 38 | use Symfony\Component\EventDispatcher\GenericEvent; |
| 39 | 39 | |
| 40 | 40 | class Repair extends Command { |
| 41 | - /** @var \OC\Repair $repair */ |
|
| 42 | - protected $repair; |
|
| 43 | - /** @var IConfig */ |
|
| 44 | - protected $config; |
|
| 45 | - /** @var EventDispatcherInterface */ |
|
| 46 | - private $dispatcher; |
|
| 47 | - /** @var ProgressBar */ |
|
| 48 | - private $progress; |
|
| 49 | - /** @var OutputInterface */ |
|
| 50 | - private $output; |
|
| 51 | - /** @var IAppManager */ |
|
| 52 | - private $appManager; |
|
| 41 | + /** @var \OC\Repair $repair */ |
|
| 42 | + protected $repair; |
|
| 43 | + /** @var IConfig */ |
|
| 44 | + protected $config; |
|
| 45 | + /** @var EventDispatcherInterface */ |
|
| 46 | + private $dispatcher; |
|
| 47 | + /** @var ProgressBar */ |
|
| 48 | + private $progress; |
|
| 49 | + /** @var OutputInterface */ |
|
| 50 | + private $output; |
|
| 51 | + /** @var IAppManager */ |
|
| 52 | + private $appManager; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @param \OC\Repair $repair |
|
| 56 | - * @param IConfig $config |
|
| 57 | - * @param EventDispatcherInterface $dispatcher |
|
| 58 | - * @param IAppManager $appManager |
|
| 59 | - */ |
|
| 60 | - public function __construct(\OC\Repair $repair, IConfig $config, EventDispatcherInterface $dispatcher, IAppManager $appManager) { |
|
| 61 | - $this->repair = $repair; |
|
| 62 | - $this->config = $config; |
|
| 63 | - $this->dispatcher = $dispatcher; |
|
| 64 | - $this->appManager = $appManager; |
|
| 65 | - parent::__construct(); |
|
| 66 | - } |
|
| 54 | + /** |
|
| 55 | + * @param \OC\Repair $repair |
|
| 56 | + * @param IConfig $config |
|
| 57 | + * @param EventDispatcherInterface $dispatcher |
|
| 58 | + * @param IAppManager $appManager |
|
| 59 | + */ |
|
| 60 | + public function __construct(\OC\Repair $repair, IConfig $config, EventDispatcherInterface $dispatcher, IAppManager $appManager) { |
|
| 61 | + $this->repair = $repair; |
|
| 62 | + $this->config = $config; |
|
| 63 | + $this->dispatcher = $dispatcher; |
|
| 64 | + $this->appManager = $appManager; |
|
| 65 | + parent::__construct(); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - protected function configure() { |
|
| 69 | - $this |
|
| 70 | - ->setName('maintenance:repair') |
|
| 71 | - ->setDescription('repair this installation') |
|
| 72 | - ->addOption( |
|
| 73 | - 'include-expensive', |
|
| 74 | - null, |
|
| 75 | - InputOption::VALUE_NONE, |
|
| 76 | - 'Use this option when you want to include resource and load expensive tasks'); |
|
| 77 | - } |
|
| 68 | + protected function configure() { |
|
| 69 | + $this |
|
| 70 | + ->setName('maintenance:repair') |
|
| 71 | + ->setDescription('repair this installation') |
|
| 72 | + ->addOption( |
|
| 73 | + 'include-expensive', |
|
| 74 | + null, |
|
| 75 | + InputOption::VALUE_NONE, |
|
| 76 | + 'Use this option when you want to include resource and load expensive tasks'); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 80 | - $includeExpensive = $input->getOption('include-expensive'); |
|
| 81 | - if ($includeExpensive) { |
|
| 82 | - foreach ($this->repair->getExpensiveRepairSteps() as $step) { |
|
| 83 | - $this->repair->addStep($step); |
|
| 84 | - } |
|
| 85 | - } |
|
| 79 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 80 | + $includeExpensive = $input->getOption('include-expensive'); |
|
| 81 | + if ($includeExpensive) { |
|
| 82 | + foreach ($this->repair->getExpensiveRepairSteps() as $step) { |
|
| 83 | + $this->repair->addStep($step); |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - $apps = $this->appManager->getInstalledApps(); |
|
| 88 | - foreach ($apps as $app) { |
|
| 89 | - if (!$this->appManager->isEnabledForUser($app)) { |
|
| 90 | - continue; |
|
| 91 | - } |
|
| 92 | - $info = \OC_App::getAppInfo($app); |
|
| 93 | - if (!is_array($info)) { |
|
| 94 | - continue; |
|
| 95 | - } |
|
| 96 | - $steps = $info['repair-steps']['post-migration']; |
|
| 97 | - foreach ($steps as $step) { |
|
| 98 | - try { |
|
| 99 | - $this->repair->addStep($step); |
|
| 100 | - } catch (Exception $ex) { |
|
| 101 | - $output->writeln("<error>Failed to load repair step for $app: {$ex->getMessage()}</error>"); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - } |
|
| 87 | + $apps = $this->appManager->getInstalledApps(); |
|
| 88 | + foreach ($apps as $app) { |
|
| 89 | + if (!$this->appManager->isEnabledForUser($app)) { |
|
| 90 | + continue; |
|
| 91 | + } |
|
| 92 | + $info = \OC_App::getAppInfo($app); |
|
| 93 | + if (!is_array($info)) { |
|
| 94 | + continue; |
|
| 95 | + } |
|
| 96 | + $steps = $info['repair-steps']['post-migration']; |
|
| 97 | + foreach ($steps as $step) { |
|
| 98 | + try { |
|
| 99 | + $this->repair->addStep($step); |
|
| 100 | + } catch (Exception $ex) { |
|
| 101 | + $output->writeln("<error>Failed to load repair step for $app: {$ex->getMessage()}</error>"); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - $maintenanceMode = $this->config->getSystemValue('maintenance', false); |
|
| 107 | - $this->config->setSystemValue('maintenance', true); |
|
| 106 | + $maintenanceMode = $this->config->getSystemValue('maintenance', false); |
|
| 107 | + $this->config->setSystemValue('maintenance', true); |
|
| 108 | 108 | |
| 109 | - $this->progress = new ProgressBar($output); |
|
| 110 | - $this->output = $output; |
|
| 111 | - $this->dispatcher->addListener('\OC\Repair::startProgress', [$this, 'handleRepairFeedBack']); |
|
| 112 | - $this->dispatcher->addListener('\OC\Repair::advance', [$this, 'handleRepairFeedBack']); |
|
| 113 | - $this->dispatcher->addListener('\OC\Repair::finishProgress', [$this, 'handleRepairFeedBack']); |
|
| 114 | - $this->dispatcher->addListener('\OC\Repair::step', [$this, 'handleRepairFeedBack']); |
|
| 115 | - $this->dispatcher->addListener('\OC\Repair::info', [$this, 'handleRepairFeedBack']); |
|
| 116 | - $this->dispatcher->addListener('\OC\Repair::warning', [$this, 'handleRepairFeedBack']); |
|
| 117 | - $this->dispatcher->addListener('\OC\Repair::error', [$this, 'handleRepairFeedBack']); |
|
| 109 | + $this->progress = new ProgressBar($output); |
|
| 110 | + $this->output = $output; |
|
| 111 | + $this->dispatcher->addListener('\OC\Repair::startProgress', [$this, 'handleRepairFeedBack']); |
|
| 112 | + $this->dispatcher->addListener('\OC\Repair::advance', [$this, 'handleRepairFeedBack']); |
|
| 113 | + $this->dispatcher->addListener('\OC\Repair::finishProgress', [$this, 'handleRepairFeedBack']); |
|
| 114 | + $this->dispatcher->addListener('\OC\Repair::step', [$this, 'handleRepairFeedBack']); |
|
| 115 | + $this->dispatcher->addListener('\OC\Repair::info', [$this, 'handleRepairFeedBack']); |
|
| 116 | + $this->dispatcher->addListener('\OC\Repair::warning', [$this, 'handleRepairFeedBack']); |
|
| 117 | + $this->dispatcher->addListener('\OC\Repair::error', [$this, 'handleRepairFeedBack']); |
|
| 118 | 118 | |
| 119 | - $this->repair->run(); |
|
| 119 | + $this->repair->run(); |
|
| 120 | 120 | |
| 121 | - $this->config->setSystemValue('maintenance', $maintenanceMode); |
|
| 122 | - } |
|
| 121 | + $this->config->setSystemValue('maintenance', $maintenanceMode); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - public function handleRepairFeedBack($event) { |
|
| 125 | - if (!$event instanceof GenericEvent) { |
|
| 126 | - return; |
|
| 127 | - } |
|
| 128 | - switch ($event->getSubject()) { |
|
| 129 | - case '\OC\Repair::startProgress': |
|
| 130 | - $this->progress->start($event->getArgument(0)); |
|
| 131 | - break; |
|
| 132 | - case '\OC\Repair::advance': |
|
| 133 | - $this->progress->advance($event->getArgument(0)); |
|
| 134 | - break; |
|
| 135 | - case '\OC\Repair::finishProgress': |
|
| 136 | - $this->progress->finish(); |
|
| 137 | - $this->output->writeln(''); |
|
| 138 | - break; |
|
| 139 | - case '\OC\Repair::step': |
|
| 140 | - $this->output->writeln(' - ' . $event->getArgument(0)); |
|
| 141 | - break; |
|
| 142 | - case '\OC\Repair::info': |
|
| 143 | - $this->output->writeln(' - ' . $event->getArgument(0)); |
|
| 144 | - break; |
|
| 145 | - case '\OC\Repair::warning': |
|
| 146 | - $this->output->writeln(' - WARNING: ' . $event->getArgument(0)); |
|
| 147 | - break; |
|
| 148 | - case '\OC\Repair::error': |
|
| 149 | - $this->output->writeln(' - ERROR: ' . $event->getArgument(0)); |
|
| 150 | - break; |
|
| 151 | - } |
|
| 152 | - } |
|
| 124 | + public function handleRepairFeedBack($event) { |
|
| 125 | + if (!$event instanceof GenericEvent) { |
|
| 126 | + return; |
|
| 127 | + } |
|
| 128 | + switch ($event->getSubject()) { |
|
| 129 | + case '\OC\Repair::startProgress': |
|
| 130 | + $this->progress->start($event->getArgument(0)); |
|
| 131 | + break; |
|
| 132 | + case '\OC\Repair::advance': |
|
| 133 | + $this->progress->advance($event->getArgument(0)); |
|
| 134 | + break; |
|
| 135 | + case '\OC\Repair::finishProgress': |
|
| 136 | + $this->progress->finish(); |
|
| 137 | + $this->output->writeln(''); |
|
| 138 | + break; |
|
| 139 | + case '\OC\Repair::step': |
|
| 140 | + $this->output->writeln(' - ' . $event->getArgument(0)); |
|
| 141 | + break; |
|
| 142 | + case '\OC\Repair::info': |
|
| 143 | + $this->output->writeln(' - ' . $event->getArgument(0)); |
|
| 144 | + break; |
|
| 145 | + case '\OC\Repair::warning': |
|
| 146 | + $this->output->writeln(' - WARNING: ' . $event->getArgument(0)); |
|
| 147 | + break; |
|
| 148 | + case '\OC\Repair::error': |
|
| 149 | + $this->output->writeln(' - ERROR: ' . $event->getArgument(0)); |
|
| 150 | + break; |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | 153 | } |
@@ -31,19 +31,19 @@ |
||
| 31 | 31 | |
| 32 | 32 | class UpdateHtaccess extends Command { |
| 33 | 33 | |
| 34 | - protected function configure() { |
|
| 35 | - $this |
|
| 36 | - ->setName('maintenance:update:htaccess') |
|
| 37 | - ->setDescription('Updates the .htaccess file'); |
|
| 38 | - } |
|
| 34 | + protected function configure() { |
|
| 35 | + $this |
|
| 36 | + ->setName('maintenance:update:htaccess') |
|
| 37 | + ->setDescription('Updates the .htaccess file'); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 41 | - if (\OC\Setup::updateHtaccess()) { |
|
| 42 | - $output->writeln('.htaccess has been updated'); |
|
| 43 | - return 0; |
|
| 44 | - } else { |
|
| 45 | - $output->writeln('<error>Error updating .htaccess file, not enough permissions?</error>'); |
|
| 46 | - return 1; |
|
| 47 | - } |
|
| 48 | - } |
|
| 40 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 41 | + if (\OC\Setup::updateHtaccess()) { |
|
| 42 | + $output->writeln('.htaccess has been updated'); |
|
| 43 | + return 0; |
|
| 44 | + } else { |
|
| 45 | + $output->writeln('<error>Error updating .htaccess file, not enough permissions?</error>'); |
|
| 46 | + return 1; |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | } |