@@ -36,81 +36,81 @@ |
||
36 | 36 | |
37 | 37 | class Enforce extends Command { |
38 | 38 | |
39 | - /** @var MandatoryTwoFactor */ |
|
40 | - private $mandatoryTwoFactor; |
|
39 | + /** @var MandatoryTwoFactor */ |
|
40 | + private $mandatoryTwoFactor; |
|
41 | 41 | |
42 | - public function __construct(MandatoryTwoFactor $mandatoryTwoFactor) { |
|
43 | - parent::__construct(); |
|
42 | + public function __construct(MandatoryTwoFactor $mandatoryTwoFactor) { |
|
43 | + parent::__construct(); |
|
44 | 44 | |
45 | - $this->mandatoryTwoFactor = $mandatoryTwoFactor; |
|
46 | - } |
|
45 | + $this->mandatoryTwoFactor = $mandatoryTwoFactor; |
|
46 | + } |
|
47 | 47 | |
48 | - protected function configure() { |
|
49 | - $this->setName('twofactorauth:enforce'); |
|
50 | - $this->setDescription('Enabled/disable enforced two-factor authentication'); |
|
51 | - $this->addOption( |
|
52 | - 'on', |
|
53 | - null, |
|
54 | - InputOption::VALUE_NONE, |
|
55 | - 'enforce two-factor authentication' |
|
56 | - ); |
|
57 | - $this->addOption( |
|
58 | - 'off', |
|
59 | - null, |
|
60 | - InputOption::VALUE_NONE, |
|
61 | - 'don\'t enforce two-factor authenticaton' |
|
62 | - ); |
|
63 | - $this->addOption( |
|
64 | - 'group', |
|
65 | - null, |
|
66 | - InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
|
67 | - 'enforce only for the given group(s)' |
|
68 | - ); |
|
69 | - $this->addOption( |
|
70 | - 'exclude', |
|
71 | - null, |
|
72 | - InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
|
73 | - 'exclude mandatory two-factor auth for the given group(s)' |
|
74 | - ); |
|
75 | - } |
|
48 | + protected function configure() { |
|
49 | + $this->setName('twofactorauth:enforce'); |
|
50 | + $this->setDescription('Enabled/disable enforced two-factor authentication'); |
|
51 | + $this->addOption( |
|
52 | + 'on', |
|
53 | + null, |
|
54 | + InputOption::VALUE_NONE, |
|
55 | + 'enforce two-factor authentication' |
|
56 | + ); |
|
57 | + $this->addOption( |
|
58 | + 'off', |
|
59 | + null, |
|
60 | + InputOption::VALUE_NONE, |
|
61 | + 'don\'t enforce two-factor authenticaton' |
|
62 | + ); |
|
63 | + $this->addOption( |
|
64 | + 'group', |
|
65 | + null, |
|
66 | + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
|
67 | + 'enforce only for the given group(s)' |
|
68 | + ); |
|
69 | + $this->addOption( |
|
70 | + 'exclude', |
|
71 | + null, |
|
72 | + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
|
73 | + 'exclude mandatory two-factor auth for the given group(s)' |
|
74 | + ); |
|
75 | + } |
|
76 | 76 | |
77 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
78 | - if ($input->getOption('on')) { |
|
79 | - $enforcedGroups = $input->getOption('group'); |
|
80 | - $excludedGroups = $input->getOption('exclude'); |
|
81 | - $this->mandatoryTwoFactor->setState(new EnforcementState(true, $enforcedGroups, $excludedGroups)); |
|
82 | - } elseif ($input->getOption('off')) { |
|
83 | - $this->mandatoryTwoFactor->setState(new EnforcementState(false)); |
|
84 | - } |
|
77 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
78 | + if ($input->getOption('on')) { |
|
79 | + $enforcedGroups = $input->getOption('group'); |
|
80 | + $excludedGroups = $input->getOption('exclude'); |
|
81 | + $this->mandatoryTwoFactor->setState(new EnforcementState(true, $enforcedGroups, $excludedGroups)); |
|
82 | + } elseif ($input->getOption('off')) { |
|
83 | + $this->mandatoryTwoFactor->setState(new EnforcementState(false)); |
|
84 | + } |
|
85 | 85 | |
86 | - $state = $this->mandatoryTwoFactor->getState(); |
|
87 | - if ($state->isEnforced()) { |
|
88 | - $this->writeEnforced($output, $state); |
|
89 | - } else { |
|
90 | - $this->writeNotEnforced($output); |
|
91 | - } |
|
92 | - return 0; |
|
93 | - } |
|
86 | + $state = $this->mandatoryTwoFactor->getState(); |
|
87 | + if ($state->isEnforced()) { |
|
88 | + $this->writeEnforced($output, $state); |
|
89 | + } else { |
|
90 | + $this->writeNotEnforced($output); |
|
91 | + } |
|
92 | + return 0; |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * @param OutputInterface $output |
|
97 | - */ |
|
98 | - protected function writeEnforced(OutputInterface $output, EnforcementState $state) { |
|
99 | - if (empty($state->getEnforcedGroups())) { |
|
100 | - $message = 'Two-factor authentication is enforced for all users'; |
|
101 | - } else { |
|
102 | - $message = 'Two-factor authentication is enforced for members of the group(s) ' . implode(', ', $state->getEnforcedGroups()); |
|
103 | - } |
|
104 | - if (!empty($state->getExcludedGroups())) { |
|
105 | - $message .= ', except members of ' . implode(', ', $state->getExcludedGroups()); |
|
106 | - } |
|
107 | - $output->writeln($message); |
|
108 | - } |
|
95 | + /** |
|
96 | + * @param OutputInterface $output |
|
97 | + */ |
|
98 | + protected function writeEnforced(OutputInterface $output, EnforcementState $state) { |
|
99 | + if (empty($state->getEnforcedGroups())) { |
|
100 | + $message = 'Two-factor authentication is enforced for all users'; |
|
101 | + } else { |
|
102 | + $message = 'Two-factor authentication is enforced for members of the group(s) ' . implode(', ', $state->getEnforcedGroups()); |
|
103 | + } |
|
104 | + if (!empty($state->getExcludedGroups())) { |
|
105 | + $message .= ', except members of ' . implode(', ', $state->getExcludedGroups()); |
|
106 | + } |
|
107 | + $output->writeln($message); |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * @param OutputInterface $output |
|
112 | - */ |
|
113 | - protected function writeNotEnforced(OutputInterface $output) { |
|
114 | - $output->writeln('Two-factor authentication is not enforced'); |
|
115 | - } |
|
110 | + /** |
|
111 | + * @param OutputInterface $output |
|
112 | + */ |
|
113 | + protected function writeNotEnforced(OutputInterface $output) { |
|
114 | + $output->writeln('Two-factor authentication is not enforced'); |
|
115 | + } |
|
116 | 116 | } |
@@ -29,24 +29,24 @@ |
||
29 | 29 | use Symfony\Component\Console\Output\OutputInterface; |
30 | 30 | |
31 | 31 | class Status extends Base { |
32 | - protected function configure() { |
|
33 | - parent::configure(); |
|
32 | + protected function configure() { |
|
33 | + parent::configure(); |
|
34 | 34 | |
35 | - $this |
|
36 | - ->setName('status') |
|
37 | - ->setDescription('show some status information') |
|
38 | - ; |
|
39 | - } |
|
35 | + $this |
|
36 | + ->setName('status') |
|
37 | + ->setDescription('show some status information') |
|
38 | + ; |
|
39 | + } |
|
40 | 40 | |
41 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
42 | - $values = [ |
|
43 | - 'installed' => (bool) \OC::$server->getConfig()->getSystemValue('installed', false), |
|
44 | - 'version' => implode('.', \OCP\Util::getVersion()), |
|
45 | - 'versionstring' => \OC_Util::getVersionString(), |
|
46 | - 'edition' => '', |
|
47 | - ]; |
|
41 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
42 | + $values = [ |
|
43 | + 'installed' => (bool) \OC::$server->getConfig()->getSystemValue('installed', false), |
|
44 | + 'version' => implode('.', \OCP\Util::getVersion()), |
|
45 | + 'versionstring' => \OC_Util::getVersionString(), |
|
46 | + 'edition' => '', |
|
47 | + ]; |
|
48 | 48 | |
49 | - $this->writeArrayInOutputFormat($input, $output, $values); |
|
50 | - return 0; |
|
51 | - } |
|
49 | + $this->writeArrayInOutputFormat($input, $output, $values); |
|
50 | + return 0; |
|
51 | + } |
|
52 | 52 | } |
@@ -46,250 +46,250 @@ |
||
46 | 46 | use Symfony\Component\EventDispatcher\GenericEvent; |
47 | 47 | |
48 | 48 | class Upgrade extends Command { |
49 | - public const ERROR_SUCCESS = 0; |
|
50 | - public const ERROR_NOT_INSTALLED = 1; |
|
51 | - public const ERROR_MAINTENANCE_MODE = 2; |
|
52 | - public const ERROR_UP_TO_DATE = 0; |
|
53 | - public const ERROR_INVALID_ARGUMENTS = 4; |
|
54 | - public const ERROR_FAILURE = 5; |
|
49 | + public const ERROR_SUCCESS = 0; |
|
50 | + public const ERROR_NOT_INSTALLED = 1; |
|
51 | + public const ERROR_MAINTENANCE_MODE = 2; |
|
52 | + public const ERROR_UP_TO_DATE = 0; |
|
53 | + public const ERROR_INVALID_ARGUMENTS = 4; |
|
54 | + public const ERROR_FAILURE = 5; |
|
55 | 55 | |
56 | - /** @var IConfig */ |
|
57 | - private $config; |
|
56 | + /** @var IConfig */ |
|
57 | + private $config; |
|
58 | 58 | |
59 | - /** @var ILogger */ |
|
60 | - private $logger; |
|
59 | + /** @var ILogger */ |
|
60 | + private $logger; |
|
61 | 61 | |
62 | - /** |
|
63 | - * @param IConfig $config |
|
64 | - * @param ILogger $logger |
|
65 | - * @param Installer $installer |
|
66 | - */ |
|
67 | - public function __construct(IConfig $config, ILogger $logger, Installer $installer) { |
|
68 | - parent::__construct(); |
|
69 | - $this->config = $config; |
|
70 | - $this->logger = $logger; |
|
71 | - $this->installer = $installer; |
|
72 | - } |
|
62 | + /** |
|
63 | + * @param IConfig $config |
|
64 | + * @param ILogger $logger |
|
65 | + * @param Installer $installer |
|
66 | + */ |
|
67 | + public function __construct(IConfig $config, ILogger $logger, Installer $installer) { |
|
68 | + parent::__construct(); |
|
69 | + $this->config = $config; |
|
70 | + $this->logger = $logger; |
|
71 | + $this->installer = $installer; |
|
72 | + } |
|
73 | 73 | |
74 | - protected function configure() { |
|
75 | - $this |
|
76 | - ->setName('upgrade') |
|
77 | - ->setDescription('run upgrade routines after installation of a new release. The release has to be installed before.'); |
|
78 | - } |
|
74 | + protected function configure() { |
|
75 | + $this |
|
76 | + ->setName('upgrade') |
|
77 | + ->setDescription('run upgrade routines after installation of a new release. The release has to be installed before.'); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Execute the upgrade command |
|
82 | - * |
|
83 | - * @param InputInterface $input input interface |
|
84 | - * @param OutputInterface $output output interface |
|
85 | - */ |
|
86 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
87 | - if (Util::needUpgrade()) { |
|
88 | - if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
89 | - // Prepend each line with a little timestamp |
|
90 | - $timestampFormatter = new TimestampFormatter($this->config, $output->getFormatter()); |
|
91 | - $output->setFormatter($timestampFormatter); |
|
92 | - } |
|
80 | + /** |
|
81 | + * Execute the upgrade command |
|
82 | + * |
|
83 | + * @param InputInterface $input input interface |
|
84 | + * @param OutputInterface $output output interface |
|
85 | + */ |
|
86 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
87 | + if (Util::needUpgrade()) { |
|
88 | + if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
89 | + // Prepend each line with a little timestamp |
|
90 | + $timestampFormatter = new TimestampFormatter($this->config, $output->getFormatter()); |
|
91 | + $output->setFormatter($timestampFormatter); |
|
92 | + } |
|
93 | 93 | |
94 | - $self = $this; |
|
95 | - $updater = new Updater( |
|
96 | - $this->config, |
|
97 | - \OC::$server->getIntegrityCodeChecker(), |
|
98 | - $this->logger, |
|
99 | - $this->installer |
|
100 | - ); |
|
94 | + $self = $this; |
|
95 | + $updater = new Updater( |
|
96 | + $this->config, |
|
97 | + \OC::$server->getIntegrityCodeChecker(), |
|
98 | + $this->logger, |
|
99 | + $this->installer |
|
100 | + ); |
|
101 | 101 | |
102 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
103 | - $progress = new ProgressBar($output); |
|
104 | - $progress->setFormat(" %message%\n %current%/%max% [%bar%] %percent:3s%%"); |
|
105 | - $listener = function ($event) use ($progress, $output) { |
|
106 | - if ($event instanceof GenericEvent) { |
|
107 | - $message = $event->getSubject(); |
|
108 | - if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
109 | - $output->writeln(' Checking table ' . $message); |
|
110 | - } else { |
|
111 | - if (strlen($message) > 60) { |
|
112 | - $message = substr($message, 0, 57) . '...'; |
|
113 | - } |
|
114 | - $progress->setMessage($message); |
|
115 | - if ($event[0] === 1) { |
|
116 | - $output->writeln(''); |
|
117 | - $progress->start($event[1]); |
|
118 | - } |
|
119 | - $progress->setProgress($event[0]); |
|
120 | - if ($event[0] === $event[1]) { |
|
121 | - $progress->setMessage('Done'); |
|
122 | - $progress->finish(); |
|
123 | - $output->writeln(''); |
|
124 | - } |
|
125 | - } |
|
126 | - } |
|
127 | - }; |
|
128 | - $repairListener = function ($event) use ($progress, $output) { |
|
129 | - if (!$event instanceof GenericEvent) { |
|
130 | - return; |
|
131 | - } |
|
132 | - switch ($event->getSubject()) { |
|
133 | - case '\OC\Repair::startProgress': |
|
134 | - $progress->setMessage('Starting ...'); |
|
135 | - $output->writeln($event->getArgument(1)); |
|
136 | - $output->writeln(''); |
|
137 | - $progress->start($event->getArgument(0)); |
|
138 | - break; |
|
139 | - case '\OC\Repair::advance': |
|
140 | - $desc = $event->getArgument(1); |
|
141 | - if (!empty($desc)) { |
|
142 | - $progress->setMessage($desc); |
|
143 | - } |
|
144 | - $progress->advance($event->getArgument(0)); |
|
102 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
103 | + $progress = new ProgressBar($output); |
|
104 | + $progress->setFormat(" %message%\n %current%/%max% [%bar%] %percent:3s%%"); |
|
105 | + $listener = function ($event) use ($progress, $output) { |
|
106 | + if ($event instanceof GenericEvent) { |
|
107 | + $message = $event->getSubject(); |
|
108 | + if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
109 | + $output->writeln(' Checking table ' . $message); |
|
110 | + } else { |
|
111 | + if (strlen($message) > 60) { |
|
112 | + $message = substr($message, 0, 57) . '...'; |
|
113 | + } |
|
114 | + $progress->setMessage($message); |
|
115 | + if ($event[0] === 1) { |
|
116 | + $output->writeln(''); |
|
117 | + $progress->start($event[1]); |
|
118 | + } |
|
119 | + $progress->setProgress($event[0]); |
|
120 | + if ($event[0] === $event[1]) { |
|
121 | + $progress->setMessage('Done'); |
|
122 | + $progress->finish(); |
|
123 | + $output->writeln(''); |
|
124 | + } |
|
125 | + } |
|
126 | + } |
|
127 | + }; |
|
128 | + $repairListener = function ($event) use ($progress, $output) { |
|
129 | + if (!$event instanceof GenericEvent) { |
|
130 | + return; |
|
131 | + } |
|
132 | + switch ($event->getSubject()) { |
|
133 | + case '\OC\Repair::startProgress': |
|
134 | + $progress->setMessage('Starting ...'); |
|
135 | + $output->writeln($event->getArgument(1)); |
|
136 | + $output->writeln(''); |
|
137 | + $progress->start($event->getArgument(0)); |
|
138 | + break; |
|
139 | + case '\OC\Repair::advance': |
|
140 | + $desc = $event->getArgument(1); |
|
141 | + if (!empty($desc)) { |
|
142 | + $progress->setMessage($desc); |
|
143 | + } |
|
144 | + $progress->advance($event->getArgument(0)); |
|
145 | 145 | |
146 | - break; |
|
147 | - case '\OC\Repair::finishProgress': |
|
148 | - $progress->setMessage('Done'); |
|
149 | - $progress->finish(); |
|
150 | - $output->writeln(''); |
|
151 | - break; |
|
152 | - case '\OC\Repair::step': |
|
153 | - if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
154 | - $output->writeln('<info>Repair step: ' . $event->getArgument(0) . '</info>'); |
|
155 | - } |
|
156 | - break; |
|
157 | - case '\OC\Repair::info': |
|
158 | - if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
159 | - $output->writeln('<info>Repair info: ' . $event->getArgument(0) . '</info>'); |
|
160 | - } |
|
161 | - break; |
|
162 | - case '\OC\Repair::warning': |
|
163 | - $output->writeln('<error>Repair warning: ' . $event->getArgument(0) . '</error>'); |
|
164 | - break; |
|
165 | - case '\OC\Repair::error': |
|
166 | - $output->writeln('<error>Repair error: ' . $event->getArgument(0) . '</error>'); |
|
167 | - break; |
|
168 | - } |
|
169 | - }; |
|
146 | + break; |
|
147 | + case '\OC\Repair::finishProgress': |
|
148 | + $progress->setMessage('Done'); |
|
149 | + $progress->finish(); |
|
150 | + $output->writeln(''); |
|
151 | + break; |
|
152 | + case '\OC\Repair::step': |
|
153 | + if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
154 | + $output->writeln('<info>Repair step: ' . $event->getArgument(0) . '</info>'); |
|
155 | + } |
|
156 | + break; |
|
157 | + case '\OC\Repair::info': |
|
158 | + if (OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) { |
|
159 | + $output->writeln('<info>Repair info: ' . $event->getArgument(0) . '</info>'); |
|
160 | + } |
|
161 | + break; |
|
162 | + case '\OC\Repair::warning': |
|
163 | + $output->writeln('<error>Repair warning: ' . $event->getArgument(0) . '</error>'); |
|
164 | + break; |
|
165 | + case '\OC\Repair::error': |
|
166 | + $output->writeln('<error>Repair error: ' . $event->getArgument(0) . '</error>'); |
|
167 | + break; |
|
168 | + } |
|
169 | + }; |
|
170 | 170 | |
171 | - $dispatcher->addListener('\OC\DB\Migrator::executeSql', $listener); |
|
172 | - $dispatcher->addListener('\OC\DB\Migrator::checkTable', $listener); |
|
173 | - $dispatcher->addListener('\OC\Repair::startProgress', $repairListener); |
|
174 | - $dispatcher->addListener('\OC\Repair::advance', $repairListener); |
|
175 | - $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener); |
|
176 | - $dispatcher->addListener('\OC\Repair::step', $repairListener); |
|
177 | - $dispatcher->addListener('\OC\Repair::info', $repairListener); |
|
178 | - $dispatcher->addListener('\OC\Repair::warning', $repairListener); |
|
179 | - $dispatcher->addListener('\OC\Repair::error', $repairListener); |
|
171 | + $dispatcher->addListener('\OC\DB\Migrator::executeSql', $listener); |
|
172 | + $dispatcher->addListener('\OC\DB\Migrator::checkTable', $listener); |
|
173 | + $dispatcher->addListener('\OC\Repair::startProgress', $repairListener); |
|
174 | + $dispatcher->addListener('\OC\Repair::advance', $repairListener); |
|
175 | + $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener); |
|
176 | + $dispatcher->addListener('\OC\Repair::step', $repairListener); |
|
177 | + $dispatcher->addListener('\OC\Repair::info', $repairListener); |
|
178 | + $dispatcher->addListener('\OC\Repair::warning', $repairListener); |
|
179 | + $dispatcher->addListener('\OC\Repair::error', $repairListener); |
|
180 | 180 | |
181 | 181 | |
182 | - $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($output) { |
|
183 | - $output->writeln('<info>Turned on maintenance mode</info>'); |
|
184 | - }); |
|
185 | - $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($output) { |
|
186 | - $output->writeln('<info>Turned off maintenance mode</info>'); |
|
187 | - }); |
|
188 | - $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($output) { |
|
189 | - $output->writeln('<info>Maintenance mode is kept active</info>'); |
|
190 | - }); |
|
191 | - $updater->listen('\OC\Updater', 'updateEnd', |
|
192 | - function ($success) use ($output, $self) { |
|
193 | - if ($success) { |
|
194 | - $message = "<info>Update successful</info>"; |
|
195 | - } else { |
|
196 | - $message = "<error>Update failed</error>"; |
|
197 | - } |
|
198 | - $output->writeln($message); |
|
199 | - }); |
|
200 | - $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($output) { |
|
201 | - $output->writeln('<info>Updating database schema</info>'); |
|
202 | - }); |
|
203 | - $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($output) { |
|
204 | - $output->writeln('<info>Updated database</info>'); |
|
205 | - }); |
|
206 | - $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use ($output) { |
|
207 | - $output->writeln('<info>Checking whether the database schema can be updated (this can take a long time depending on the database size)</info>'); |
|
208 | - }); |
|
209 | - $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($output) { |
|
210 | - $output->writeln('<info>Checked database schema update</info>'); |
|
211 | - }); |
|
212 | - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output) { |
|
213 | - $output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>'); |
|
214 | - }); |
|
215 | - $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($output) { |
|
216 | - $output->writeln('<info>Checking for update of app ' . $app . ' in appstore</info>'); |
|
217 | - }); |
|
218 | - $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($output) { |
|
219 | - $output->writeln('<info>Update app ' . $app . ' from appstore</info>'); |
|
220 | - }); |
|
221 | - $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($output) { |
|
222 | - $output->writeln('<info>Checked for update of app "' . $app . '" in appstore </info>'); |
|
223 | - }); |
|
224 | - $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) { |
|
225 | - $output->writeln('<info>Checking updates of apps</info>'); |
|
226 | - }); |
|
227 | - $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) { |
|
228 | - $output->writeln("<info>Checking whether the database schema for <$app> can be updated (this can take a long time depending on the database size)</info>"); |
|
229 | - }); |
|
230 | - $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) { |
|
231 | - $output->writeln('<info>Checked database schema update for apps</info>'); |
|
232 | - }); |
|
233 | - $updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) { |
|
234 | - $output->writeln("<info>Updating <$app> ...</info>"); |
|
235 | - }); |
|
236 | - $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) { |
|
237 | - $output->writeln("<info>Updated <$app> to $version</info>"); |
|
238 | - }); |
|
239 | - $updater->listen('\OC\Updater', 'failure', function ($message) use ($output, $self) { |
|
240 | - $output->writeln("<error>$message</error>"); |
|
241 | - }); |
|
242 | - $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($output) { |
|
243 | - $output->writeln("<info>Set log level to debug</info>"); |
|
244 | - }); |
|
245 | - $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($output) { |
|
246 | - $output->writeln("<info>Reset log level</info>"); |
|
247 | - }); |
|
248 | - $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($output) { |
|
249 | - $output->writeln("<info>Starting code integrity check...</info>"); |
|
250 | - }); |
|
251 | - $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($output) { |
|
252 | - $output->writeln("<info>Finished code integrity check</info>"); |
|
253 | - }); |
|
182 | + $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($output) { |
|
183 | + $output->writeln('<info>Turned on maintenance mode</info>'); |
|
184 | + }); |
|
185 | + $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($output) { |
|
186 | + $output->writeln('<info>Turned off maintenance mode</info>'); |
|
187 | + }); |
|
188 | + $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($output) { |
|
189 | + $output->writeln('<info>Maintenance mode is kept active</info>'); |
|
190 | + }); |
|
191 | + $updater->listen('\OC\Updater', 'updateEnd', |
|
192 | + function ($success) use ($output, $self) { |
|
193 | + if ($success) { |
|
194 | + $message = "<info>Update successful</info>"; |
|
195 | + } else { |
|
196 | + $message = "<error>Update failed</error>"; |
|
197 | + } |
|
198 | + $output->writeln($message); |
|
199 | + }); |
|
200 | + $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($output) { |
|
201 | + $output->writeln('<info>Updating database schema</info>'); |
|
202 | + }); |
|
203 | + $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($output) { |
|
204 | + $output->writeln('<info>Updated database</info>'); |
|
205 | + }); |
|
206 | + $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use ($output) { |
|
207 | + $output->writeln('<info>Checking whether the database schema can be updated (this can take a long time depending on the database size)</info>'); |
|
208 | + }); |
|
209 | + $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($output) { |
|
210 | + $output->writeln('<info>Checked database schema update</info>'); |
|
211 | + }); |
|
212 | + $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output) { |
|
213 | + $output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>'); |
|
214 | + }); |
|
215 | + $updater->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($output) { |
|
216 | + $output->writeln('<info>Checking for update of app ' . $app . ' in appstore</info>'); |
|
217 | + }); |
|
218 | + $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($output) { |
|
219 | + $output->writeln('<info>Update app ' . $app . ' from appstore</info>'); |
|
220 | + }); |
|
221 | + $updater->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($output) { |
|
222 | + $output->writeln('<info>Checked for update of app "' . $app . '" in appstore </info>'); |
|
223 | + }); |
|
224 | + $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) { |
|
225 | + $output->writeln('<info>Checking updates of apps</info>'); |
|
226 | + }); |
|
227 | + $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) { |
|
228 | + $output->writeln("<info>Checking whether the database schema for <$app> can be updated (this can take a long time depending on the database size)</info>"); |
|
229 | + }); |
|
230 | + $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) { |
|
231 | + $output->writeln('<info>Checked database schema update for apps</info>'); |
|
232 | + }); |
|
233 | + $updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) { |
|
234 | + $output->writeln("<info>Updating <$app> ...</info>"); |
|
235 | + }); |
|
236 | + $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) { |
|
237 | + $output->writeln("<info>Updated <$app> to $version</info>"); |
|
238 | + }); |
|
239 | + $updater->listen('\OC\Updater', 'failure', function ($message) use ($output, $self) { |
|
240 | + $output->writeln("<error>$message</error>"); |
|
241 | + }); |
|
242 | + $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($output) { |
|
243 | + $output->writeln("<info>Set log level to debug</info>"); |
|
244 | + }); |
|
245 | + $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($output) { |
|
246 | + $output->writeln("<info>Reset log level</info>"); |
|
247 | + }); |
|
248 | + $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($output) { |
|
249 | + $output->writeln("<info>Starting code integrity check...</info>"); |
|
250 | + }); |
|
251 | + $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($output) { |
|
252 | + $output->writeln("<info>Finished code integrity check</info>"); |
|
253 | + }); |
|
254 | 254 | |
255 | - $success = $updater->upgrade(); |
|
255 | + $success = $updater->upgrade(); |
|
256 | 256 | |
257 | - $this->postUpgradeCheck($input, $output); |
|
257 | + $this->postUpgradeCheck($input, $output); |
|
258 | 258 | |
259 | - if (!$success) { |
|
260 | - return self::ERROR_FAILURE; |
|
261 | - } |
|
259 | + if (!$success) { |
|
260 | + return self::ERROR_FAILURE; |
|
261 | + } |
|
262 | 262 | |
263 | - return self::ERROR_SUCCESS; |
|
264 | - } elseif ($this->config->getSystemValueBool('maintenance')) { |
|
265 | - //Possible scenario: Nextcloud core is updated but an app failed |
|
266 | - $output->writeln('<warning>Nextcloud is in maintenance mode</warning>'); |
|
267 | - $output->write('<comment>Maybe an upgrade is already in process. Please check the ' |
|
268 | - . 'logfile (data/nextcloud.log). If you want to re-run the ' |
|
269 | - . 'upgrade procedure, remove the "maintenance mode" from ' |
|
270 | - . 'config.php and call this script again.</comment>' |
|
271 | - , true); |
|
272 | - return self::ERROR_MAINTENANCE_MODE; |
|
273 | - } else { |
|
274 | - $output->writeln('<info>Nextcloud is already latest version</info>'); |
|
275 | - return self::ERROR_UP_TO_DATE; |
|
276 | - } |
|
277 | - } |
|
263 | + return self::ERROR_SUCCESS; |
|
264 | + } elseif ($this->config->getSystemValueBool('maintenance')) { |
|
265 | + //Possible scenario: Nextcloud core is updated but an app failed |
|
266 | + $output->writeln('<warning>Nextcloud is in maintenance mode</warning>'); |
|
267 | + $output->write('<comment>Maybe an upgrade is already in process. Please check the ' |
|
268 | + . 'logfile (data/nextcloud.log). If you want to re-run the ' |
|
269 | + . 'upgrade procedure, remove the "maintenance mode" from ' |
|
270 | + . 'config.php and call this script again.</comment>' |
|
271 | + , true); |
|
272 | + return self::ERROR_MAINTENANCE_MODE; |
|
273 | + } else { |
|
274 | + $output->writeln('<info>Nextcloud is already latest version</info>'); |
|
275 | + return self::ERROR_UP_TO_DATE; |
|
276 | + } |
|
277 | + } |
|
278 | 278 | |
279 | - /** |
|
280 | - * Perform a post upgrade check (specific to the command line tool) |
|
281 | - * |
|
282 | - * @param InputInterface $input input interface |
|
283 | - * @param OutputInterface $output output interface |
|
284 | - */ |
|
285 | - protected function postUpgradeCheck(InputInterface $input, OutputInterface $output) { |
|
286 | - $trustedDomains = $this->config->getSystemValue('trusted_domains', []); |
|
287 | - if (empty($trustedDomains)) { |
|
288 | - $output->write( |
|
289 | - '<warning>The setting "trusted_domains" could not be ' . |
|
290 | - 'set automatically by the upgrade script, ' . |
|
291 | - 'please set it manually</warning>' |
|
292 | - ); |
|
293 | - } |
|
294 | - } |
|
279 | + /** |
|
280 | + * Perform a post upgrade check (specific to the command line tool) |
|
281 | + * |
|
282 | + * @param InputInterface $input input interface |
|
283 | + * @param OutputInterface $output output interface |
|
284 | + */ |
|
285 | + protected function postUpgradeCheck(InputInterface $input, OutputInterface $output) { |
|
286 | + $trustedDomains = $this->config->getSystemValue('trusted_domains', []); |
|
287 | + if (empty($trustedDomains)) { |
|
288 | + $output->write( |
|
289 | + '<warning>The setting "trusted_domains" could not be ' . |
|
290 | + 'set automatically by the upgrade script, ' . |
|
291 | + 'please set it manually</warning>' |
|
292 | + ); |
|
293 | + } |
|
294 | + } |
|
295 | 295 | } |
@@ -31,48 +31,48 @@ |
||
31 | 31 | use Symfony\Component\Console\Output\OutputInterface; |
32 | 32 | |
33 | 33 | class AddUser extends Base { |
34 | - /** @var IUserManager */ |
|
35 | - protected $userManager; |
|
36 | - /** @var IGroupManager */ |
|
37 | - protected $groupManager; |
|
34 | + /** @var IUserManager */ |
|
35 | + protected $userManager; |
|
36 | + /** @var IGroupManager */ |
|
37 | + protected $groupManager; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param IUserManager $userManager |
|
41 | - * @param IGroupManager $groupManager |
|
42 | - */ |
|
43 | - public function __construct(IUserManager $userManager, IGroupManager $groupManager) { |
|
44 | - $this->userManager = $userManager; |
|
45 | - $this->groupManager = $groupManager; |
|
46 | - parent::__construct(); |
|
47 | - } |
|
39 | + /** |
|
40 | + * @param IUserManager $userManager |
|
41 | + * @param IGroupManager $groupManager |
|
42 | + */ |
|
43 | + public function __construct(IUserManager $userManager, IGroupManager $groupManager) { |
|
44 | + $this->userManager = $userManager; |
|
45 | + $this->groupManager = $groupManager; |
|
46 | + parent::__construct(); |
|
47 | + } |
|
48 | 48 | |
49 | - protected function configure() { |
|
50 | - $this |
|
51 | - ->setName('group:adduser') |
|
52 | - ->setDescription('add a user to a group') |
|
53 | - ->addArgument( |
|
54 | - 'group', |
|
55 | - InputArgument::REQUIRED, |
|
56 | - 'group to add the user to' |
|
57 | - )->addArgument( |
|
58 | - 'user', |
|
59 | - InputArgument::REQUIRED, |
|
60 | - 'user to add to the group' |
|
61 | - ); |
|
62 | - } |
|
49 | + protected function configure() { |
|
50 | + $this |
|
51 | + ->setName('group:adduser') |
|
52 | + ->setDescription('add a user to a group') |
|
53 | + ->addArgument( |
|
54 | + 'group', |
|
55 | + InputArgument::REQUIRED, |
|
56 | + 'group to add the user to' |
|
57 | + )->addArgument( |
|
58 | + 'user', |
|
59 | + InputArgument::REQUIRED, |
|
60 | + 'user to add to the group' |
|
61 | + ); |
|
62 | + } |
|
63 | 63 | |
64 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
65 | - $group = $this->groupManager->get($input->getArgument('group')); |
|
66 | - if (is_null($group)) { |
|
67 | - $output->writeln('<error>group not found</error>'); |
|
68 | - return 1; |
|
69 | - } |
|
70 | - $user = $this->userManager->get($input->getArgument('user')); |
|
71 | - if (is_null($user)) { |
|
72 | - $output->writeln('<error>user not found</error>'); |
|
73 | - return 1; |
|
74 | - } |
|
75 | - $group->addUser($user); |
|
76 | - return 0; |
|
77 | - } |
|
64 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
65 | + $group = $this->groupManager->get($input->getArgument('group')); |
|
66 | + if (is_null($group)) { |
|
67 | + $output->writeln('<error>group not found</error>'); |
|
68 | + return 1; |
|
69 | + } |
|
70 | + $user = $this->userManager->get($input->getArgument('user')); |
|
71 | + if (is_null($user)) { |
|
72 | + $output->writeln('<error>user not found</error>'); |
|
73 | + return 1; |
|
74 | + } |
|
75 | + $group->addUser($user); |
|
76 | + return 0; |
|
77 | + } |
|
78 | 78 | } |
@@ -33,45 +33,45 @@ |
||
33 | 33 | use Symfony\Component\Console\Output\OutputInterface; |
34 | 34 | |
35 | 35 | class Delete extends Base { |
36 | - /** @var IGroupManager */ |
|
37 | - protected $groupManager; |
|
36 | + /** @var IGroupManager */ |
|
37 | + protected $groupManager; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param IGroupManager $groupManager |
|
41 | - */ |
|
42 | - public function __construct(IGroupManager $groupManager) { |
|
43 | - $this->groupManager = $groupManager; |
|
44 | - parent::__construct(); |
|
45 | - } |
|
39 | + /** |
|
40 | + * @param IGroupManager $groupManager |
|
41 | + */ |
|
42 | + public function __construct(IGroupManager $groupManager) { |
|
43 | + $this->groupManager = $groupManager; |
|
44 | + parent::__construct(); |
|
45 | + } |
|
46 | 46 | |
47 | - protected function configure() { |
|
48 | - $this |
|
49 | - ->setName('group:delete') |
|
50 | - ->setDescription('Remove a group') |
|
51 | - ->addArgument( |
|
52 | - 'groupid', |
|
53 | - InputArgument::REQUIRED, |
|
54 | - 'Group name' |
|
55 | - ); |
|
56 | - } |
|
47 | + protected function configure() { |
|
48 | + $this |
|
49 | + ->setName('group:delete') |
|
50 | + ->setDescription('Remove a group') |
|
51 | + ->addArgument( |
|
52 | + 'groupid', |
|
53 | + InputArgument::REQUIRED, |
|
54 | + 'Group name' |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | |
58 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
59 | - $gid = $input->getArgument('groupid'); |
|
60 | - if ($gid === 'admin') { |
|
61 | - $output->writeln('<error>Group "' . $gid . '" could not be deleted.</error>'); |
|
62 | - return 1; |
|
63 | - } |
|
64 | - if (! $this->groupManager->groupExists($gid)) { |
|
65 | - $output->writeln('<error>Group "' . $gid . '" does not exist.</error>'); |
|
66 | - return 1; |
|
67 | - } |
|
68 | - $group = $this->groupManager->get($gid); |
|
69 | - if ($group->delete()) { |
|
70 | - $output->writeln('Group "' . $gid . '" was removed'); |
|
71 | - } else { |
|
72 | - $output->writeln('<error>Group "' . $gid . '" could not be deleted. Please check the logs.</error>'); |
|
73 | - return 1; |
|
74 | - } |
|
75 | - return 0; |
|
76 | - } |
|
58 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
59 | + $gid = $input->getArgument('groupid'); |
|
60 | + if ($gid === 'admin') { |
|
61 | + $output->writeln('<error>Group "' . $gid . '" could not be deleted.</error>'); |
|
62 | + return 1; |
|
63 | + } |
|
64 | + if (! $this->groupManager->groupExists($gid)) { |
|
65 | + $output->writeln('<error>Group "' . $gid . '" does not exist.</error>'); |
|
66 | + return 1; |
|
67 | + } |
|
68 | + $group = $this->groupManager->get($gid); |
|
69 | + if ($group->delete()) { |
|
70 | + $output->writeln('Group "' . $gid . '" was removed'); |
|
71 | + } else { |
|
72 | + $output->writeln('<error>Group "' . $gid . '" could not be deleted. Please check the logs.</error>'); |
|
73 | + return 1; |
|
74 | + } |
|
75 | + return 0; |
|
76 | + } |
|
77 | 77 | } |
@@ -58,18 +58,18 @@ |
||
58 | 58 | protected function execute(InputInterface $input, OutputInterface $output): int { |
59 | 59 | $gid = $input->getArgument('groupid'); |
60 | 60 | if ($gid === 'admin') { |
61 | - $output->writeln('<error>Group "' . $gid . '" could not be deleted.</error>'); |
|
61 | + $output->writeln('<error>Group "'.$gid.'" could not be deleted.</error>'); |
|
62 | 62 | return 1; |
63 | 63 | } |
64 | - if (! $this->groupManager->groupExists($gid)) { |
|
65 | - $output->writeln('<error>Group "' . $gid . '" does not exist.</error>'); |
|
64 | + if (!$this->groupManager->groupExists($gid)) { |
|
65 | + $output->writeln('<error>Group "'.$gid.'" does not exist.</error>'); |
|
66 | 66 | return 1; |
67 | 67 | } |
68 | 68 | $group = $this->groupManager->get($gid); |
69 | 69 | if ($group->delete()) { |
70 | - $output->writeln('Group "' . $gid . '" was removed'); |
|
70 | + $output->writeln('Group "'.$gid.'" was removed'); |
|
71 | 71 | } else { |
72 | - $output->writeln('<error>Group "' . $gid . '" could not be deleted. Please check the logs.</error>'); |
|
72 | + $output->writeln('<error>Group "'.$gid.'" could not be deleted. Please check the logs.</error>'); |
|
73 | 73 | return 1; |
74 | 74 | } |
75 | 75 | return 0; |
@@ -31,59 +31,59 @@ |
||
31 | 31 | use Symfony\Component\Console\Output\OutputInterface; |
32 | 32 | |
33 | 33 | class ListCommand extends Base { |
34 | - /** @var IGroupManager */ |
|
35 | - protected $groupManager; |
|
34 | + /** @var IGroupManager */ |
|
35 | + protected $groupManager; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @param IGroupManager $groupManager |
|
39 | - */ |
|
40 | - public function __construct(IGroupManager $groupManager) { |
|
41 | - $this->groupManager = $groupManager; |
|
42 | - parent::__construct(); |
|
43 | - } |
|
37 | + /** |
|
38 | + * @param IGroupManager $groupManager |
|
39 | + */ |
|
40 | + public function __construct(IGroupManager $groupManager) { |
|
41 | + $this->groupManager = $groupManager; |
|
42 | + parent::__construct(); |
|
43 | + } |
|
44 | 44 | |
45 | - protected function configure() { |
|
46 | - $this |
|
47 | - ->setName('group:list') |
|
48 | - ->setDescription('list configured groups') |
|
49 | - ->addOption( |
|
50 | - 'limit', |
|
51 | - 'l', |
|
52 | - InputOption::VALUE_OPTIONAL, |
|
53 | - 'Number of groups to retrieve', |
|
54 | - 500 |
|
55 | - )->addOption( |
|
56 | - 'offset', |
|
57 | - 'o', |
|
58 | - InputOption::VALUE_OPTIONAL, |
|
59 | - 'Offset for retrieving groups', |
|
60 | - 0 |
|
61 | - )->addOption( |
|
62 | - 'output', |
|
63 | - null, |
|
64 | - InputOption::VALUE_OPTIONAL, |
|
65 | - 'Output format (plain, json or json_pretty, default is plain)', |
|
66 | - $this->defaultOutputFormat |
|
67 | - ); |
|
68 | - } |
|
45 | + protected function configure() { |
|
46 | + $this |
|
47 | + ->setName('group:list') |
|
48 | + ->setDescription('list configured groups') |
|
49 | + ->addOption( |
|
50 | + 'limit', |
|
51 | + 'l', |
|
52 | + InputOption::VALUE_OPTIONAL, |
|
53 | + 'Number of groups to retrieve', |
|
54 | + 500 |
|
55 | + )->addOption( |
|
56 | + 'offset', |
|
57 | + 'o', |
|
58 | + InputOption::VALUE_OPTIONAL, |
|
59 | + 'Offset for retrieving groups', |
|
60 | + 0 |
|
61 | + )->addOption( |
|
62 | + 'output', |
|
63 | + null, |
|
64 | + InputOption::VALUE_OPTIONAL, |
|
65 | + 'Output format (plain, json or json_pretty, default is plain)', |
|
66 | + $this->defaultOutputFormat |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | |
70 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
71 | - $groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); |
|
72 | - $this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups)); |
|
73 | - return 0; |
|
74 | - } |
|
70 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
71 | + $groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); |
|
72 | + $this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups)); |
|
73 | + return 0; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param IGroup[] $groups |
|
78 | - * @return array |
|
79 | - */ |
|
80 | - private function formatGroups(array $groups) { |
|
81 | - $keys = array_map(function (IGroup $group) { |
|
82 | - return $group->getGID(); |
|
83 | - }, $groups); |
|
84 | - $values = array_map(function (IGroup $group) { |
|
85 | - return array_keys($group->getUsers()); |
|
86 | - }, $groups); |
|
87 | - return array_combine($keys, $values); |
|
88 | - } |
|
76 | + /** |
|
77 | + * @param IGroup[] $groups |
|
78 | + * @return array |
|
79 | + */ |
|
80 | + private function formatGroups(array $groups) { |
|
81 | + $keys = array_map(function (IGroup $group) { |
|
82 | + return $group->getGID(); |
|
83 | + }, $groups); |
|
84 | + $values = array_map(function (IGroup $group) { |
|
85 | + return array_keys($group->getUsers()); |
|
86 | + }, $groups); |
|
87 | + return array_combine($keys, $values); |
|
88 | + } |
|
89 | 89 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | protected function execute(InputInterface $input, OutputInterface $output): int { |
71 | - $groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); |
|
71 | + $groups = $this->groupManager->search('', (int) $input->getOption('limit'), (int) $input->getOption('offset')); |
|
72 | 72 | $this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups)); |
73 | 73 | return 0; |
74 | 74 | } |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | * @return array |
79 | 79 | */ |
80 | 80 | private function formatGroups(array $groups) { |
81 | - $keys = array_map(function (IGroup $group) { |
|
81 | + $keys = array_map(function(IGroup $group) { |
|
82 | 82 | return $group->getGID(); |
83 | 83 | }, $groups); |
84 | - $values = array_map(function (IGroup $group) { |
|
84 | + $values = array_map(function(IGroup $group) { |
|
85 | 85 | return array_keys($group->getUsers()); |
86 | 86 | }, $groups); |
87 | 87 | return array_combine($keys, $values); |
@@ -37,53 +37,53 @@ |
||
37 | 37 | use Symfony\Component\Console\Output\OutputInterface; |
38 | 38 | |
39 | 39 | class Add extends Base { |
40 | - /** @var IGroupManager */ |
|
41 | - protected $groupManager; |
|
40 | + /** @var IGroupManager */ |
|
41 | + protected $groupManager; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param IGroupManager $groupManager |
|
45 | - */ |
|
46 | - public function __construct(IGroupManager $groupManager) { |
|
47 | - $this->groupManager = $groupManager; |
|
48 | - parent::__construct(); |
|
49 | - } |
|
43 | + /** |
|
44 | + * @param IGroupManager $groupManager |
|
45 | + */ |
|
46 | + public function __construct(IGroupManager $groupManager) { |
|
47 | + $this->groupManager = $groupManager; |
|
48 | + parent::__construct(); |
|
49 | + } |
|
50 | 50 | |
51 | - protected function configure() { |
|
52 | - $this |
|
53 | - ->setName('group:add') |
|
54 | - ->setDescription('Add a group') |
|
55 | - ->addArgument( |
|
56 | - 'groupid', |
|
57 | - InputArgument::REQUIRED, |
|
58 | - 'Group id' |
|
59 | - ) |
|
60 | - ->addOption( |
|
61 | - 'display-name', |
|
62 | - null, |
|
63 | - InputOption::VALUE_REQUIRED, |
|
64 | - 'Group name used in the web UI (can contain any characters)' |
|
65 | - ); |
|
66 | - } |
|
51 | + protected function configure() { |
|
52 | + $this |
|
53 | + ->setName('group:add') |
|
54 | + ->setDescription('Add a group') |
|
55 | + ->addArgument( |
|
56 | + 'groupid', |
|
57 | + InputArgument::REQUIRED, |
|
58 | + 'Group id' |
|
59 | + ) |
|
60 | + ->addOption( |
|
61 | + 'display-name', |
|
62 | + null, |
|
63 | + InputOption::VALUE_REQUIRED, |
|
64 | + 'Group name used in the web UI (can contain any characters)' |
|
65 | + ); |
|
66 | + } |
|
67 | 67 | |
68 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
69 | - $gid = $input->getArgument('groupid'); |
|
70 | - $group = $this->groupManager->get($gid); |
|
71 | - if ($group) { |
|
72 | - $output->writeln('<error>Group "' . $gid . '" already exists.</error>'); |
|
73 | - return 1; |
|
74 | - } else { |
|
75 | - $group = $this->groupManager->createGroup($gid); |
|
76 | - if (!$group instanceof IGroup) { |
|
77 | - $output->writeln('<error>Could not create group</error>'); |
|
78 | - return 2; |
|
79 | - } |
|
80 | - $output->writeln('Created group "' . $group->getGID() . '"'); |
|
68 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
69 | + $gid = $input->getArgument('groupid'); |
|
70 | + $group = $this->groupManager->get($gid); |
|
71 | + if ($group) { |
|
72 | + $output->writeln('<error>Group "' . $gid . '" already exists.</error>'); |
|
73 | + return 1; |
|
74 | + } else { |
|
75 | + $group = $this->groupManager->createGroup($gid); |
|
76 | + if (!$group instanceof IGroup) { |
|
77 | + $output->writeln('<error>Could not create group</error>'); |
|
78 | + return 2; |
|
79 | + } |
|
80 | + $output->writeln('Created group "' . $group->getGID() . '"'); |
|
81 | 81 | |
82 | - $displayName = trim((string)$input->getOption('display-name')); |
|
83 | - if ($displayName !== '') { |
|
84 | - $group->setDisplayName($displayName); |
|
85 | - } |
|
86 | - } |
|
87 | - return 0; |
|
88 | - } |
|
82 | + $displayName = trim((string)$input->getOption('display-name')); |
|
83 | + if ($displayName !== '') { |
|
84 | + $group->setDisplayName($displayName); |
|
85 | + } |
|
86 | + } |
|
87 | + return 0; |
|
88 | + } |
|
89 | 89 | } |
@@ -31,48 +31,48 @@ |
||
31 | 31 | use Symfony\Component\Console\Output\OutputInterface; |
32 | 32 | |
33 | 33 | class RemoveUser extends Base { |
34 | - /** @var IUserManager */ |
|
35 | - protected $userManager; |
|
36 | - /** @var IGroupManager */ |
|
37 | - protected $groupManager; |
|
34 | + /** @var IUserManager */ |
|
35 | + protected $userManager; |
|
36 | + /** @var IGroupManager */ |
|
37 | + protected $groupManager; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param IUserManager $userManager |
|
41 | - * @param IGroupManager $groupManager |
|
42 | - */ |
|
43 | - public function __construct(IUserManager $userManager, IGroupManager $groupManager) { |
|
44 | - $this->userManager = $userManager; |
|
45 | - $this->groupManager = $groupManager; |
|
46 | - parent::__construct(); |
|
47 | - } |
|
39 | + /** |
|
40 | + * @param IUserManager $userManager |
|
41 | + * @param IGroupManager $groupManager |
|
42 | + */ |
|
43 | + public function __construct(IUserManager $userManager, IGroupManager $groupManager) { |
|
44 | + $this->userManager = $userManager; |
|
45 | + $this->groupManager = $groupManager; |
|
46 | + parent::__construct(); |
|
47 | + } |
|
48 | 48 | |
49 | - protected function configure() { |
|
50 | - $this |
|
51 | - ->setName('group:removeuser') |
|
52 | - ->setDescription('remove a user from a group') |
|
53 | - ->addArgument( |
|
54 | - 'group', |
|
55 | - InputArgument::REQUIRED, |
|
56 | - 'group to remove the user from' |
|
57 | - )->addArgument( |
|
58 | - 'user', |
|
59 | - InputArgument::REQUIRED, |
|
60 | - 'user to remove from the group' |
|
61 | - ); |
|
62 | - } |
|
49 | + protected function configure() { |
|
50 | + $this |
|
51 | + ->setName('group:removeuser') |
|
52 | + ->setDescription('remove a user from a group') |
|
53 | + ->addArgument( |
|
54 | + 'group', |
|
55 | + InputArgument::REQUIRED, |
|
56 | + 'group to remove the user from' |
|
57 | + )->addArgument( |
|
58 | + 'user', |
|
59 | + InputArgument::REQUIRED, |
|
60 | + 'user to remove from the group' |
|
61 | + ); |
|
62 | + } |
|
63 | 63 | |
64 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
65 | - $group = $this->groupManager->get($input->getArgument('group')); |
|
66 | - if (is_null($group)) { |
|
67 | - $output->writeln('<error>group not found</error>'); |
|
68 | - return 1; |
|
69 | - } |
|
70 | - $user = $this->userManager->get($input->getArgument('user')); |
|
71 | - if (is_null($user)) { |
|
72 | - $output->writeln('<error>user not found</error>'); |
|
73 | - return 1; |
|
74 | - } |
|
75 | - $group->removeUser($user); |
|
76 | - return 0; |
|
77 | - } |
|
64 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
65 | + $group = $this->groupManager->get($input->getArgument('group')); |
|
66 | + if (is_null($group)) { |
|
67 | + $output->writeln('<error>group not found</error>'); |
|
68 | + return 1; |
|
69 | + } |
|
70 | + $user = $this->userManager->get($input->getArgument('user')); |
|
71 | + if (is_null($user)) { |
|
72 | + $output->writeln('<error>user not found</error>'); |
|
73 | + return 1; |
|
74 | + } |
|
75 | + $group->removeUser($user); |
|
76 | + return 0; |
|
77 | + } |
|
78 | 78 | } |
@@ -39,124 +39,124 @@ |
||
39 | 39 | |
40 | 40 | class File extends Command implements Completion\CompletionAwareInterface { |
41 | 41 | |
42 | - /** @var IConfig */ |
|
43 | - protected $config; |
|
44 | - |
|
45 | - public function __construct(IConfig $config) { |
|
46 | - $this->config = $config; |
|
47 | - parent::__construct(); |
|
48 | - } |
|
49 | - |
|
50 | - protected function configure() { |
|
51 | - $this |
|
52 | - ->setName('log:file') |
|
53 | - ->setDescription('manipulate logging backend') |
|
54 | - ->addOption( |
|
55 | - 'enable', |
|
56 | - null, |
|
57 | - InputOption::VALUE_NONE, |
|
58 | - 'enable this logging backend' |
|
59 | - ) |
|
60 | - ->addOption( |
|
61 | - 'file', |
|
62 | - null, |
|
63 | - InputOption::VALUE_REQUIRED, |
|
64 | - 'set the log file path' |
|
65 | - ) |
|
66 | - ->addOption( |
|
67 | - 'rotate-size', |
|
68 | - null, |
|
69 | - InputOption::VALUE_REQUIRED, |
|
70 | - 'set the file size for log rotation, 0 = disabled' |
|
71 | - ) |
|
72 | - ; |
|
73 | - } |
|
74 | - |
|
75 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
76 | - $toBeSet = []; |
|
77 | - |
|
78 | - if ($input->getOption('enable')) { |
|
79 | - $toBeSet['log_type'] = 'file'; |
|
80 | - } |
|
81 | - |
|
82 | - if ($file = $input->getOption('file')) { |
|
83 | - $toBeSet['logfile'] = $file; |
|
84 | - } |
|
85 | - |
|
86 | - if (($rotateSize = $input->getOption('rotate-size')) !== null) { |
|
87 | - $rotateSize = \OCP\Util::computerFileSize($rotateSize); |
|
88 | - $this->validateRotateSize($rotateSize); |
|
89 | - $toBeSet['log_rotate_size'] = $rotateSize; |
|
90 | - } |
|
91 | - |
|
92 | - // set config |
|
93 | - foreach ($toBeSet as $option => $value) { |
|
94 | - $this->config->setSystemValue($option, $value); |
|
95 | - } |
|
96 | - |
|
97 | - // display config |
|
98 | - // TODO: Drop backwards compatibility for config in the future |
|
99 | - $logType = $this->config->getSystemValue('log_type', 'file'); |
|
100 | - if ($logType === 'file' || $logType === 'owncloud') { |
|
101 | - $enabledText = 'enabled'; |
|
102 | - } else { |
|
103 | - $enabledText = 'disabled'; |
|
104 | - } |
|
105 | - $output->writeln('Log backend file: '.$enabledText); |
|
106 | - |
|
107 | - $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data'); |
|
108 | - $defaultLogFile = rtrim($dataDir, '/').'/nextcloud.log'; |
|
109 | - $output->writeln('Log file: '.$this->config->getSystemValue('logfile', $defaultLogFile)); |
|
110 | - |
|
111 | - $rotateSize = $this->config->getSystemValue('log_rotate_size', 100*1024*1024); |
|
112 | - if ($rotateSize) { |
|
113 | - $rotateString = \OCP\Util::humanFileSize($rotateSize); |
|
114 | - } else { |
|
115 | - $rotateString = 'disabled'; |
|
116 | - } |
|
117 | - $output->writeln('Rotate at: '.$rotateString); |
|
118 | - return 0; |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * @param mixed $rotateSize |
|
123 | - * @throws \InvalidArgumentException |
|
124 | - */ |
|
125 | - protected function validateRotateSize(&$rotateSize) { |
|
126 | - if ($rotateSize === false) { |
|
127 | - throw new \InvalidArgumentException('Error parsing log rotation file size'); |
|
128 | - } |
|
129 | - $rotateSize = (int) $rotateSize; |
|
130 | - if ($rotateSize < 0) { |
|
131 | - throw new \InvalidArgumentException('Log rotation file size must be non-negative'); |
|
132 | - } |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * @param string $optionName |
|
137 | - * @param CompletionContext $context |
|
138 | - * @return string[] |
|
139 | - */ |
|
140 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
141 | - if ($optionName === 'file') { |
|
142 | - $helper = new ShellPathCompletion( |
|
143 | - $this->getName(), |
|
144 | - 'file', |
|
145 | - Completion::TYPE_OPTION |
|
146 | - ); |
|
147 | - return $helper->run(); |
|
148 | - } elseif ($optionName === 'rotate-size') { |
|
149 | - return [0]; |
|
150 | - } |
|
151 | - return []; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * @param string $argumentName |
|
156 | - * @param CompletionContext $context |
|
157 | - * @return string[] |
|
158 | - */ |
|
159 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
160 | - return []; |
|
161 | - } |
|
42 | + /** @var IConfig */ |
|
43 | + protected $config; |
|
44 | + |
|
45 | + public function __construct(IConfig $config) { |
|
46 | + $this->config = $config; |
|
47 | + parent::__construct(); |
|
48 | + } |
|
49 | + |
|
50 | + protected function configure() { |
|
51 | + $this |
|
52 | + ->setName('log:file') |
|
53 | + ->setDescription('manipulate logging backend') |
|
54 | + ->addOption( |
|
55 | + 'enable', |
|
56 | + null, |
|
57 | + InputOption::VALUE_NONE, |
|
58 | + 'enable this logging backend' |
|
59 | + ) |
|
60 | + ->addOption( |
|
61 | + 'file', |
|
62 | + null, |
|
63 | + InputOption::VALUE_REQUIRED, |
|
64 | + 'set the log file path' |
|
65 | + ) |
|
66 | + ->addOption( |
|
67 | + 'rotate-size', |
|
68 | + null, |
|
69 | + InputOption::VALUE_REQUIRED, |
|
70 | + 'set the file size for log rotation, 0 = disabled' |
|
71 | + ) |
|
72 | + ; |
|
73 | + } |
|
74 | + |
|
75 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
76 | + $toBeSet = []; |
|
77 | + |
|
78 | + if ($input->getOption('enable')) { |
|
79 | + $toBeSet['log_type'] = 'file'; |
|
80 | + } |
|
81 | + |
|
82 | + if ($file = $input->getOption('file')) { |
|
83 | + $toBeSet['logfile'] = $file; |
|
84 | + } |
|
85 | + |
|
86 | + if (($rotateSize = $input->getOption('rotate-size')) !== null) { |
|
87 | + $rotateSize = \OCP\Util::computerFileSize($rotateSize); |
|
88 | + $this->validateRotateSize($rotateSize); |
|
89 | + $toBeSet['log_rotate_size'] = $rotateSize; |
|
90 | + } |
|
91 | + |
|
92 | + // set config |
|
93 | + foreach ($toBeSet as $option => $value) { |
|
94 | + $this->config->setSystemValue($option, $value); |
|
95 | + } |
|
96 | + |
|
97 | + // display config |
|
98 | + // TODO: Drop backwards compatibility for config in the future |
|
99 | + $logType = $this->config->getSystemValue('log_type', 'file'); |
|
100 | + if ($logType === 'file' || $logType === 'owncloud') { |
|
101 | + $enabledText = 'enabled'; |
|
102 | + } else { |
|
103 | + $enabledText = 'disabled'; |
|
104 | + } |
|
105 | + $output->writeln('Log backend file: '.$enabledText); |
|
106 | + |
|
107 | + $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data'); |
|
108 | + $defaultLogFile = rtrim($dataDir, '/').'/nextcloud.log'; |
|
109 | + $output->writeln('Log file: '.$this->config->getSystemValue('logfile', $defaultLogFile)); |
|
110 | + |
|
111 | + $rotateSize = $this->config->getSystemValue('log_rotate_size', 100*1024*1024); |
|
112 | + if ($rotateSize) { |
|
113 | + $rotateString = \OCP\Util::humanFileSize($rotateSize); |
|
114 | + } else { |
|
115 | + $rotateString = 'disabled'; |
|
116 | + } |
|
117 | + $output->writeln('Rotate at: '.$rotateString); |
|
118 | + return 0; |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * @param mixed $rotateSize |
|
123 | + * @throws \InvalidArgumentException |
|
124 | + */ |
|
125 | + protected function validateRotateSize(&$rotateSize) { |
|
126 | + if ($rotateSize === false) { |
|
127 | + throw new \InvalidArgumentException('Error parsing log rotation file size'); |
|
128 | + } |
|
129 | + $rotateSize = (int) $rotateSize; |
|
130 | + if ($rotateSize < 0) { |
|
131 | + throw new \InvalidArgumentException('Log rotation file size must be non-negative'); |
|
132 | + } |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * @param string $optionName |
|
137 | + * @param CompletionContext $context |
|
138 | + * @return string[] |
|
139 | + */ |
|
140 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
141 | + if ($optionName === 'file') { |
|
142 | + $helper = new ShellPathCompletion( |
|
143 | + $this->getName(), |
|
144 | + 'file', |
|
145 | + Completion::TYPE_OPTION |
|
146 | + ); |
|
147 | + return $helper->run(); |
|
148 | + } elseif ($optionName === 'rotate-size') { |
|
149 | + return [0]; |
|
150 | + } |
|
151 | + return []; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * @param string $argumentName |
|
156 | + * @param CompletionContext $context |
|
157 | + * @return string[] |
|
158 | + */ |
|
159 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
160 | + return []; |
|
161 | + } |
|
162 | 162 | } |