@@ -71,7 +71,7 @@ |
||
| 71 | 71 | if (!$item['default']) { |
| 72 | 72 | $item = $item['displayName']; |
| 73 | 73 | } else { |
| 74 | - $item = $item['displayName'] . ' [default*]'; |
|
| 74 | + $item = $item['displayName'].' [default*]'; |
|
| 75 | 75 | } |
| 76 | 76 | }); |
| 77 | 77 | } |
@@ -29,69 +29,69 @@ |
||
| 29 | 29 | use Symfony\Component\Console\Output\OutputInterface; |
| 30 | 30 | |
| 31 | 31 | class ListModules extends Base { |
| 32 | - /** @var IManager */ |
|
| 33 | - protected $encryptionManager; |
|
| 32 | + /** @var IManager */ |
|
| 33 | + protected $encryptionManager; |
|
| 34 | 34 | |
| 35 | - /** @var IConfig */ |
|
| 36 | - protected $config; |
|
| 35 | + /** @var IConfig */ |
|
| 36 | + protected $config; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @param IManager $encryptionManager |
|
| 40 | - * @param IConfig $config |
|
| 41 | - */ |
|
| 42 | - public function __construct( |
|
| 43 | - IManager $encryptionManager, |
|
| 44 | - IConfig $config |
|
| 45 | - ) { |
|
| 46 | - parent::__construct(); |
|
| 47 | - $this->encryptionManager = $encryptionManager; |
|
| 48 | - $this->config = $config; |
|
| 49 | - } |
|
| 38 | + /** |
|
| 39 | + * @param IManager $encryptionManager |
|
| 40 | + * @param IConfig $config |
|
| 41 | + */ |
|
| 42 | + public function __construct( |
|
| 43 | + IManager $encryptionManager, |
|
| 44 | + IConfig $config |
|
| 45 | + ) { |
|
| 46 | + parent::__construct(); |
|
| 47 | + $this->encryptionManager = $encryptionManager; |
|
| 48 | + $this->config = $config; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - protected function configure() { |
|
| 52 | - parent::configure(); |
|
| 51 | + protected function configure() { |
|
| 52 | + parent::configure(); |
|
| 53 | 53 | |
| 54 | - $this |
|
| 55 | - ->setName('encryption:list-modules') |
|
| 56 | - ->setDescription('List all available encryption modules') |
|
| 57 | - ; |
|
| 58 | - } |
|
| 54 | + $this |
|
| 55 | + ->setName('encryption:list-modules') |
|
| 56 | + ->setDescription('List all available encryption modules') |
|
| 57 | + ; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 61 | - $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
| 62 | - if ($isMaintenanceModeEnabled) { |
|
| 63 | - $output->writeln("Maintenance mode must be disabled when listing modules"); |
|
| 64 | - $output->writeln("in order to list the relevant encryption modules correctly."); |
|
| 65 | - return; |
|
| 66 | - } |
|
| 60 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 61 | + $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
| 62 | + if ($isMaintenanceModeEnabled) { |
|
| 63 | + $output->writeln("Maintenance mode must be disabled when listing modules"); |
|
| 64 | + $output->writeln("in order to list the relevant encryption modules correctly."); |
|
| 65 | + return; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $encryptionModules = $this->encryptionManager->getEncryptionModules(); |
|
| 69 | - $defaultEncryptionModuleId = $this->encryptionManager->getDefaultEncryptionModuleId(); |
|
| 68 | + $encryptionModules = $this->encryptionManager->getEncryptionModules(); |
|
| 69 | + $defaultEncryptionModuleId = $this->encryptionManager->getDefaultEncryptionModuleId(); |
|
| 70 | 70 | |
| 71 | - $encModules = array(); |
|
| 72 | - foreach ($encryptionModules as $module) { |
|
| 73 | - $encModules[$module['id']]['displayName'] = $module['displayName']; |
|
| 74 | - $encModules[$module['id']]['default'] = $module['id'] === $defaultEncryptionModuleId; |
|
| 75 | - } |
|
| 76 | - $this->writeModuleList($input, $output, $encModules); |
|
| 77 | - } |
|
| 71 | + $encModules = array(); |
|
| 72 | + foreach ($encryptionModules as $module) { |
|
| 73 | + $encModules[$module['id']]['displayName'] = $module['displayName']; |
|
| 74 | + $encModules[$module['id']]['default'] = $module['id'] === $defaultEncryptionModuleId; |
|
| 75 | + } |
|
| 76 | + $this->writeModuleList($input, $output, $encModules); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * @param InputInterface $input |
|
| 81 | - * @param OutputInterface $output |
|
| 82 | - * @param array $items |
|
| 83 | - */ |
|
| 84 | - protected function writeModuleList(InputInterface $input, OutputInterface $output, $items) { |
|
| 85 | - if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) { |
|
| 86 | - array_walk($items, function(&$item) { |
|
| 87 | - if (!$item['default']) { |
|
| 88 | - $item = $item['displayName']; |
|
| 89 | - } else { |
|
| 90 | - $item = $item['displayName'] . ' [default*]'; |
|
| 91 | - } |
|
| 92 | - }); |
|
| 93 | - } |
|
| 79 | + /** |
|
| 80 | + * @param InputInterface $input |
|
| 81 | + * @param OutputInterface $output |
|
| 82 | + * @param array $items |
|
| 83 | + */ |
|
| 84 | + protected function writeModuleList(InputInterface $input, OutputInterface $output, $items) { |
|
| 85 | + if ($input->getOption('output') === self::OUTPUT_FORMAT_PLAIN) { |
|
| 86 | + array_walk($items, function(&$item) { |
|
| 87 | + if (!$item['default']) { |
|
| 88 | + $item = $item['displayName']; |
|
| 89 | + } else { |
|
| 90 | + $item = $item['displayName'] . ' [default*]'; |
|
| 91 | + } |
|
| 92 | + }); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - $this->writeArrayInOutputFormat($input, $output, $items); |
|
| 96 | - } |
|
| 95 | + $this->writeArrayInOutputFormat($input, $output, $items); |
|
| 96 | + } |
|
| 97 | 97 | } |
@@ -28,30 +28,30 @@ |
||
| 28 | 28 | use Symfony\Component\Console\Output\OutputInterface; |
| 29 | 29 | |
| 30 | 30 | class Status extends Base { |
| 31 | - /** @var IManager */ |
|
| 32 | - protected $encryptionManager; |
|
| 31 | + /** @var IManager */ |
|
| 32 | + protected $encryptionManager; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @param IManager $encryptionManager |
|
| 36 | - */ |
|
| 37 | - public function __construct(IManager $encryptionManager) { |
|
| 38 | - parent::__construct(); |
|
| 39 | - $this->encryptionManager = $encryptionManager; |
|
| 40 | - } |
|
| 34 | + /** |
|
| 35 | + * @param IManager $encryptionManager |
|
| 36 | + */ |
|
| 37 | + public function __construct(IManager $encryptionManager) { |
|
| 38 | + parent::__construct(); |
|
| 39 | + $this->encryptionManager = $encryptionManager; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - protected function configure() { |
|
| 43 | - parent::configure(); |
|
| 42 | + protected function configure() { |
|
| 43 | + parent::configure(); |
|
| 44 | 44 | |
| 45 | - $this |
|
| 46 | - ->setName('encryption:status') |
|
| 47 | - ->setDescription('Lists the current status of encryption') |
|
| 48 | - ; |
|
| 49 | - } |
|
| 45 | + $this |
|
| 46 | + ->setName('encryption:status') |
|
| 47 | + ->setDescription('Lists the current status of encryption') |
|
| 48 | + ; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 52 | - $this->writeArrayInOutputFormat($input, $output, [ |
|
| 53 | - 'enabled' => $this->encryptionManager->isEnabled(), |
|
| 54 | - 'defaultModule' => $this->encryptionManager->getDefaultEncryptionModuleId(), |
|
| 55 | - ]); |
|
| 56 | - } |
|
| 51 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 52 | + $this->writeArrayInOutputFormat($input, $output, [ |
|
| 53 | + 'enabled' => $this->encryptionManager->isEnabled(), |
|
| 54 | + 'defaultModule' => $this->encryptionManager->getDefaultEncryptionModuleId(), |
|
| 55 | + ]); |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -59,11 +59,11 @@ |
||
| 59 | 59 | $moduleId = $input->getArgument('module'); |
| 60 | 60 | |
| 61 | 61 | if ($moduleId === $this->encryptionManager->getDefaultEncryptionModuleId()) { |
| 62 | - $output->writeln('"' . $moduleId . '"" is already the default module'); |
|
| 62 | + $output->writeln('"'.$moduleId.'"" is already the default module'); |
|
| 63 | 63 | } else if ($this->encryptionManager->setDefaultEncryptionModule($moduleId)) { |
| 64 | - $output->writeln('<info>Set default module to "' . $moduleId . '"</info>'); |
|
| 64 | + $output->writeln('<info>Set default module to "'.$moduleId.'"</info>'); |
|
| 65 | 65 | } else { |
| 66 | - $output->writeln('<error>The specified module "' . $moduleId . '" does not exist</error>'); |
|
| 66 | + $output->writeln('<error>The specified module "'.$moduleId.'" does not exist</error>'); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -31,55 +31,55 @@ |
||
| 31 | 31 | use Symfony\Component\Console\Output\OutputInterface; |
| 32 | 32 | |
| 33 | 33 | class SetDefaultModule extends Command { |
| 34 | - /** @var IManager */ |
|
| 35 | - protected $encryptionManager; |
|
| 34 | + /** @var IManager */ |
|
| 35 | + protected $encryptionManager; |
|
| 36 | 36 | |
| 37 | - /** @var IConfig */ |
|
| 38 | - protected $config; |
|
| 37 | + /** @var IConfig */ |
|
| 38 | + protected $config; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @param IManager $encryptionManager |
|
| 42 | - * @param IConfig $config |
|
| 43 | - */ |
|
| 44 | - public function __construct( |
|
| 45 | - IManager $encryptionManager, |
|
| 46 | - IConfig $config |
|
| 47 | - ) { |
|
| 48 | - parent::__construct(); |
|
| 49 | - $this->encryptionManager = $encryptionManager; |
|
| 50 | - $this->config = $config; |
|
| 51 | - } |
|
| 40 | + /** |
|
| 41 | + * @param IManager $encryptionManager |
|
| 42 | + * @param IConfig $config |
|
| 43 | + */ |
|
| 44 | + public function __construct( |
|
| 45 | + IManager $encryptionManager, |
|
| 46 | + IConfig $config |
|
| 47 | + ) { |
|
| 48 | + parent::__construct(); |
|
| 49 | + $this->encryptionManager = $encryptionManager; |
|
| 50 | + $this->config = $config; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - protected function configure() { |
|
| 54 | - parent::configure(); |
|
| 53 | + protected function configure() { |
|
| 54 | + parent::configure(); |
|
| 55 | 55 | |
| 56 | - $this |
|
| 57 | - ->setName('encryption:set-default-module') |
|
| 58 | - ->setDescription('Set the encryption default module') |
|
| 59 | - ->addArgument( |
|
| 60 | - 'module', |
|
| 61 | - InputArgument::REQUIRED, |
|
| 62 | - 'ID of the encryption module that should be used' |
|
| 63 | - ) |
|
| 64 | - ; |
|
| 65 | - } |
|
| 56 | + $this |
|
| 57 | + ->setName('encryption:set-default-module') |
|
| 58 | + ->setDescription('Set the encryption default module') |
|
| 59 | + ->addArgument( |
|
| 60 | + 'module', |
|
| 61 | + InputArgument::REQUIRED, |
|
| 62 | + 'ID of the encryption module that should be used' |
|
| 63 | + ) |
|
| 64 | + ; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 68 | - $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
| 69 | - if ($isMaintenanceModeEnabled) { |
|
| 70 | - $output->writeln("Maintenance mode must be disabled when setting default module,"); |
|
| 71 | - $output->writeln("in order to load the relevant encryption modules correctly."); |
|
| 72 | - return; |
|
| 73 | - } |
|
| 67 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 68 | + $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
|
| 69 | + if ($isMaintenanceModeEnabled) { |
|
| 70 | + $output->writeln("Maintenance mode must be disabled when setting default module,"); |
|
| 71 | + $output->writeln("in order to load the relevant encryption modules correctly."); |
|
| 72 | + return; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - $moduleId = $input->getArgument('module'); |
|
| 75 | + $moduleId = $input->getArgument('module'); |
|
| 76 | 76 | |
| 77 | - if ($moduleId === $this->encryptionManager->getDefaultEncryptionModuleId()) { |
|
| 78 | - $output->writeln('"' . $moduleId . '"" is already the default module'); |
|
| 79 | - } else if ($this->encryptionManager->setDefaultEncryptionModule($moduleId)) { |
|
| 80 | - $output->writeln('<info>Set default module to "' . $moduleId . '"</info>'); |
|
| 81 | - } else { |
|
| 82 | - $output->writeln('<error>The specified module "' . $moduleId . '" does not exist</error>'); |
|
| 83 | - } |
|
| 84 | - } |
|
| 77 | + if ($moduleId === $this->encryptionManager->getDefaultEncryptionModuleId()) { |
|
| 78 | + $output->writeln('"' . $moduleId . '"" is already the default module'); |
|
| 79 | + } else if ($this->encryptionManager->setDefaultEncryptionModule($moduleId)) { |
|
| 80 | + $output->writeln('<info>Set default module to "' . $moduleId . '"</info>'); |
|
| 81 | + } else { |
|
| 82 | + $output->writeln('<error>The specified module "' . $moduleId . '" does not exist</error>'); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | 85 | } |
@@ -34,58 +34,58 @@ |
||
| 34 | 34 | use Symfony\Component\Console\Output\OutputInterface; |
| 35 | 35 | |
| 36 | 36 | class ListCommand extends Base { |
| 37 | - /** @var IGroupManager */ |
|
| 38 | - protected $groupManager; |
|
| 37 | + /** @var IGroupManager */ |
|
| 38 | + protected $groupManager; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @param IGroupManager $groupManager |
|
| 42 | - */ |
|
| 43 | - public function __construct(IGroupManager $groupManager) { |
|
| 44 | - $this->groupManager = $groupManager; |
|
| 45 | - parent::__construct(); |
|
| 46 | - } |
|
| 40 | + /** |
|
| 41 | + * @param IGroupManager $groupManager |
|
| 42 | + */ |
|
| 43 | + public function __construct(IGroupManager $groupManager) { |
|
| 44 | + $this->groupManager = $groupManager; |
|
| 45 | + parent::__construct(); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - protected function configure() { |
|
| 49 | - $this |
|
| 50 | - ->setName('group:list') |
|
| 51 | - ->setDescription('list configured groups') |
|
| 52 | - ->addOption( |
|
| 53 | - 'limit', |
|
| 54 | - 'l', |
|
| 55 | - InputOption::VALUE_OPTIONAL, |
|
| 56 | - 'Number of groups to retrieve', |
|
| 57 | - 500 |
|
| 58 | - )->addOption( |
|
| 59 | - 'offset', |
|
| 60 | - 'o', |
|
| 61 | - InputOption::VALUE_OPTIONAL, |
|
| 62 | - 'Offset for retrieving groups', |
|
| 63 | - 0 |
|
| 64 | - )->addOption( |
|
| 65 | - 'output', |
|
| 66 | - null, |
|
| 67 | - InputOption::VALUE_OPTIONAL, |
|
| 68 | - 'Output format (plain, json or json_pretty, default is plain)', |
|
| 69 | - $this->defaultOutputFormat |
|
| 70 | - ); |
|
| 71 | - } |
|
| 48 | + protected function configure() { |
|
| 49 | + $this |
|
| 50 | + ->setName('group:list') |
|
| 51 | + ->setDescription('list configured groups') |
|
| 52 | + ->addOption( |
|
| 53 | + 'limit', |
|
| 54 | + 'l', |
|
| 55 | + InputOption::VALUE_OPTIONAL, |
|
| 56 | + 'Number of groups to retrieve', |
|
| 57 | + 500 |
|
| 58 | + )->addOption( |
|
| 59 | + 'offset', |
|
| 60 | + 'o', |
|
| 61 | + InputOption::VALUE_OPTIONAL, |
|
| 62 | + 'Offset for retrieving groups', |
|
| 63 | + 0 |
|
| 64 | + )->addOption( |
|
| 65 | + 'output', |
|
| 66 | + null, |
|
| 67 | + InputOption::VALUE_OPTIONAL, |
|
| 68 | + 'Output format (plain, json or json_pretty, default is plain)', |
|
| 69 | + $this->defaultOutputFormat |
|
| 70 | + ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 74 | - $groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); |
|
| 75 | - $this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups)); |
|
| 76 | - } |
|
| 73 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 74 | + $groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); |
|
| 75 | + $this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups)); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @param IGroup[] $groups |
|
| 80 | - * @return array |
|
| 81 | - */ |
|
| 82 | - private function formatGroups(array $groups) { |
|
| 83 | - $keys = array_map(function (IGroup $group) { |
|
| 84 | - return $group->getGID(); |
|
| 85 | - }, $groups); |
|
| 86 | - $values = array_map(function (IGroup $group) { |
|
| 87 | - return array_keys($group->getUsers()); |
|
| 88 | - }, $groups); |
|
| 89 | - return array_combine($keys, $values); |
|
| 90 | - } |
|
| 78 | + /** |
|
| 79 | + * @param IGroup[] $groups |
|
| 80 | + * @return array |
|
| 81 | + */ |
|
| 82 | + private function formatGroups(array $groups) { |
|
| 83 | + $keys = array_map(function (IGroup $group) { |
|
| 84 | + return $group->getGID(); |
|
| 85 | + }, $groups); |
|
| 86 | + $values = array_map(function (IGroup $group) { |
|
| 87 | + return array_keys($group->getUsers()); |
|
| 88 | + }, $groups); |
|
| 89 | + return array_combine($keys, $values); |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | protected function execute(InputInterface $input, OutputInterface $output) { |
| 74 | - $groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset')); |
|
| 74 | + $groups = $this->groupManager->search('', (int) $input->getOption('limit'), (int) $input->getOption('offset')); |
|
| 75 | 75 | $this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups)); |
| 76 | 76 | } |
| 77 | 77 | |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | * @return array |
| 81 | 81 | */ |
| 82 | 82 | private function formatGroups(array $groups) { |
| 83 | - $keys = array_map(function (IGroup $group) { |
|
| 83 | + $keys = array_map(function(IGroup $group) { |
|
| 84 | 84 | return $group->getGID(); |
| 85 | 85 | }, $groups); |
| 86 | - $values = array_map(function (IGroup $group) { |
|
| 86 | + $values = array_map(function(IGroup $group) { |
|
| 87 | 87 | return array_keys($group->getUsers()); |
| 88 | 88 | }, $groups); |
| 89 | 89 | return array_combine($keys, $values); |
@@ -33,47 +33,47 @@ |
||
| 33 | 33 | use Symfony\Component\Console\Output\OutputInterface; |
| 34 | 34 | |
| 35 | 35 | class RemoveUser extends Base { |
| 36 | - /** @var IUserManager */ |
|
| 37 | - protected $userManager; |
|
| 38 | - /** @var IGroupManager */ |
|
| 39 | - protected $groupManager; |
|
| 36 | + /** @var IUserManager */ |
|
| 37 | + protected $userManager; |
|
| 38 | + /** @var IGroupManager */ |
|
| 39 | + protected $groupManager; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @param IUserManager $userManager |
|
| 43 | - * @param IGroupManager $groupManager |
|
| 44 | - */ |
|
| 45 | - public function __construct(IUserManager $userManager, IGroupManager $groupManager) { |
|
| 46 | - $this->userManager = $userManager; |
|
| 47 | - $this->groupManager = $groupManager; |
|
| 48 | - parent::__construct(); |
|
| 49 | - } |
|
| 41 | + /** |
|
| 42 | + * @param IUserManager $userManager |
|
| 43 | + * @param IGroupManager $groupManager |
|
| 44 | + */ |
|
| 45 | + public function __construct(IUserManager $userManager, IGroupManager $groupManager) { |
|
| 46 | + $this->userManager = $userManager; |
|
| 47 | + $this->groupManager = $groupManager; |
|
| 48 | + parent::__construct(); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - protected function configure() { |
|
| 52 | - $this |
|
| 53 | - ->setName('group:removeuser') |
|
| 54 | - ->setDescription('remove a user from a group') |
|
| 55 | - ->addArgument( |
|
| 56 | - 'group', |
|
| 57 | - InputArgument::REQUIRED, |
|
| 58 | - 'group to remove the user from' |
|
| 59 | - )->addArgument( |
|
| 60 | - 'user', |
|
| 61 | - InputArgument::REQUIRED, |
|
| 62 | - 'user to remove from the group' |
|
| 63 | - ); |
|
| 64 | - } |
|
| 51 | + protected function configure() { |
|
| 52 | + $this |
|
| 53 | + ->setName('group:removeuser') |
|
| 54 | + ->setDescription('remove a user from a group') |
|
| 55 | + ->addArgument( |
|
| 56 | + 'group', |
|
| 57 | + InputArgument::REQUIRED, |
|
| 58 | + 'group to remove the user from' |
|
| 59 | + )->addArgument( |
|
| 60 | + 'user', |
|
| 61 | + InputArgument::REQUIRED, |
|
| 62 | + 'user to remove from the group' |
|
| 63 | + ); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 67 | - $group = $this->groupManager->get($input->getArgument('group')); |
|
| 68 | - if (is_null($group)) { |
|
| 69 | - $output->writeln('<error>group not found</error>'); |
|
| 70 | - return 1; |
|
| 71 | - } |
|
| 72 | - $user = $this->userManager->get($input->getArgument('user')); |
|
| 73 | - if (is_null($user)) { |
|
| 74 | - $output->writeln('<error>user not found</error>'); |
|
| 75 | - return 1; |
|
| 76 | - } |
|
| 77 | - $group->removeUser($user); |
|
| 78 | - } |
|
| 66 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 67 | + $group = $this->groupManager->get($input->getArgument('group')); |
|
| 68 | + if (is_null($group)) { |
|
| 69 | + $output->writeln('<error>group not found</error>'); |
|
| 70 | + return 1; |
|
| 71 | + } |
|
| 72 | + $user = $this->userManager->get($input->getArgument('user')); |
|
| 73 | + if (is_null($user)) { |
|
| 74 | + $output->writeln('<error>user not found</error>'); |
|
| 75 | + return 1; |
|
| 76 | + } |
|
| 77 | + $group->removeUser($user); |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -33,47 +33,47 @@ |
||
| 33 | 33 | use Symfony\Component\Console\Output\OutputInterface; |
| 34 | 34 | |
| 35 | 35 | class AddUser extends Base { |
| 36 | - /** @var IUserManager */ |
|
| 37 | - protected $userManager; |
|
| 38 | - /** @var IGroupManager */ |
|
| 39 | - protected $groupManager; |
|
| 36 | + /** @var IUserManager */ |
|
| 37 | + protected $userManager; |
|
| 38 | + /** @var IGroupManager */ |
|
| 39 | + protected $groupManager; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @param IUserManager $userManager |
|
| 43 | - * @param IGroupManager $groupManager |
|
| 44 | - */ |
|
| 45 | - public function __construct(IUserManager $userManager, IGroupManager $groupManager) { |
|
| 46 | - $this->userManager = $userManager; |
|
| 47 | - $this->groupManager = $groupManager; |
|
| 48 | - parent::__construct(); |
|
| 49 | - } |
|
| 41 | + /** |
|
| 42 | + * @param IUserManager $userManager |
|
| 43 | + * @param IGroupManager $groupManager |
|
| 44 | + */ |
|
| 45 | + public function __construct(IUserManager $userManager, IGroupManager $groupManager) { |
|
| 46 | + $this->userManager = $userManager; |
|
| 47 | + $this->groupManager = $groupManager; |
|
| 48 | + parent::__construct(); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - protected function configure() { |
|
| 52 | - $this |
|
| 53 | - ->setName('group:adduser') |
|
| 54 | - ->setDescription('add a user to a group') |
|
| 55 | - ->addArgument( |
|
| 56 | - 'group', |
|
| 57 | - InputArgument::REQUIRED, |
|
| 58 | - 'group to add the user to' |
|
| 59 | - )->addArgument( |
|
| 60 | - 'user', |
|
| 61 | - InputArgument::REQUIRED, |
|
| 62 | - 'user to add to the group' |
|
| 63 | - ); |
|
| 64 | - } |
|
| 51 | + protected function configure() { |
|
| 52 | + $this |
|
| 53 | + ->setName('group:adduser') |
|
| 54 | + ->setDescription('add a user to a group') |
|
| 55 | + ->addArgument( |
|
| 56 | + 'group', |
|
| 57 | + InputArgument::REQUIRED, |
|
| 58 | + 'group to add the user to' |
|
| 59 | + )->addArgument( |
|
| 60 | + 'user', |
|
| 61 | + InputArgument::REQUIRED, |
|
| 62 | + 'user to add to the group' |
|
| 63 | + ); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 67 | - $group = $this->groupManager->get($input->getArgument('group')); |
|
| 68 | - if (is_null($group)) { |
|
| 69 | - $output->writeln('<error>group not found</error>'); |
|
| 70 | - return 1; |
|
| 71 | - } |
|
| 72 | - $user = $this->userManager->get($input->getArgument('user')); |
|
| 73 | - if (is_null($user)) { |
|
| 74 | - $output->writeln('<error>user not found</error>'); |
|
| 75 | - return 1; |
|
| 76 | - } |
|
| 77 | - $group->addUser($user); |
|
| 78 | - } |
|
| 66 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 67 | + $group = $this->groupManager->get($input->getArgument('group')); |
|
| 68 | + if (is_null($group)) { |
|
| 69 | + $output->writeln('<error>group not found</error>'); |
|
| 70 | + return 1; |
|
| 71 | + } |
|
| 72 | + $user = $this->userManager->get($input->getArgument('user')); |
|
| 73 | + if (is_null($user)) { |
|
| 74 | + $output->writeln('<error>user not found</error>'); |
|
| 75 | + return 1; |
|
| 76 | + } |
|
| 77 | + $group->addUser($user); |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | * @param string $msg the error message |
| 38 | 38 | * @since 7.0.0 |
| 39 | 39 | */ |
| 40 | - public function __construct($msg){ |
|
| 40 | + public function __construct($msg) { |
|
| 41 | 41 | parent::__construct($msg); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -33,13 +33,13 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class DoesNotExistException extends \Exception implements IMapperException { |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Constructor |
|
| 38 | - * @param string $msg the error message |
|
| 39 | - * @since 7.0.0 |
|
| 40 | - */ |
|
| 41 | - public function __construct($msg){ |
|
| 42 | - parent::__construct($msg); |
|
| 43 | - } |
|
| 36 | + /** |
|
| 37 | + * Constructor |
|
| 38 | + * @param string $msg the error message |
|
| 39 | + * @since 7.0.0 |
|
| 40 | + */ |
|
| 41 | + public function __construct($msg){ |
|
| 42 | + parent::__construct($msg); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | } |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | try { |
| 69 | 69 | $mount = $this->globalService->getStorage($mountId); |
| 70 | 70 | } catch (NotFoundException $e) { |
| 71 | - $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
| 71 | + $output->writeln('<error>Mount with id "'.$mountId.' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
| 72 | 72 | return 404; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -37,76 +37,76 @@ |
||
| 37 | 37 | use Symfony\Component\Console\Question\ConfirmationQuestion; |
| 38 | 38 | |
| 39 | 39 | class Delete extends Base { |
| 40 | - /** |
|
| 41 | - * @var GlobalStoragesService |
|
| 42 | - */ |
|
| 43 | - protected $globalService; |
|
| 40 | + /** |
|
| 41 | + * @var GlobalStoragesService |
|
| 42 | + */ |
|
| 43 | + protected $globalService; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var UserStoragesService |
|
| 47 | - */ |
|
| 48 | - protected $userService; |
|
| 45 | + /** |
|
| 46 | + * @var UserStoragesService |
|
| 47 | + */ |
|
| 48 | + protected $userService; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @var IUserSession |
|
| 52 | - */ |
|
| 53 | - protected $userSession; |
|
| 50 | + /** |
|
| 51 | + * @var IUserSession |
|
| 52 | + */ |
|
| 53 | + protected $userSession; |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @var IUserManager |
|
| 57 | - */ |
|
| 58 | - protected $userManager; |
|
| 55 | + /** |
|
| 56 | + * @var IUserManager |
|
| 57 | + */ |
|
| 58 | + protected $userManager; |
|
| 59 | 59 | |
| 60 | - function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) { |
|
| 61 | - parent::__construct(); |
|
| 62 | - $this->globalService = $globalService; |
|
| 63 | - $this->userService = $userService; |
|
| 64 | - $this->userSession = $userSession; |
|
| 65 | - $this->userManager = $userManager; |
|
| 66 | - } |
|
| 60 | + function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) { |
|
| 61 | + parent::__construct(); |
|
| 62 | + $this->globalService = $globalService; |
|
| 63 | + $this->userService = $userService; |
|
| 64 | + $this->userSession = $userSession; |
|
| 65 | + $this->userManager = $userManager; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - protected function configure() { |
|
| 69 | - $this |
|
| 70 | - ->setName('files_external:delete') |
|
| 71 | - ->setDescription('Delete an external mount') |
|
| 72 | - ->addArgument( |
|
| 73 | - 'mount_id', |
|
| 74 | - InputArgument::REQUIRED, |
|
| 75 | - 'The id of the mount to edit' |
|
| 76 | - )->addOption( |
|
| 77 | - 'yes', |
|
| 78 | - 'y', |
|
| 79 | - InputOption::VALUE_NONE, |
|
| 80 | - 'Skip confirmation' |
|
| 81 | - ); |
|
| 82 | - parent::configure(); |
|
| 83 | - } |
|
| 68 | + protected function configure() { |
|
| 69 | + $this |
|
| 70 | + ->setName('files_external:delete') |
|
| 71 | + ->setDescription('Delete an external mount') |
|
| 72 | + ->addArgument( |
|
| 73 | + 'mount_id', |
|
| 74 | + InputArgument::REQUIRED, |
|
| 75 | + 'The id of the mount to edit' |
|
| 76 | + )->addOption( |
|
| 77 | + 'yes', |
|
| 78 | + 'y', |
|
| 79 | + InputOption::VALUE_NONE, |
|
| 80 | + 'Skip confirmation' |
|
| 81 | + ); |
|
| 82 | + parent::configure(); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 86 | - $mountId = $input->getArgument('mount_id'); |
|
| 87 | - try { |
|
| 88 | - $mount = $this->globalService->getStorage($mountId); |
|
| 89 | - } catch (NotFoundException $e) { |
|
| 90 | - $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
| 91 | - return 404; |
|
| 92 | - } |
|
| 85 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 86 | + $mountId = $input->getArgument('mount_id'); |
|
| 87 | + try { |
|
| 88 | + $mount = $this->globalService->getStorage($mountId); |
|
| 89 | + } catch (NotFoundException $e) { |
|
| 90 | + $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
| 91 | + return 404; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - $noConfirm = $input->getOption('yes'); |
|
| 94 | + $noConfirm = $input->getOption('yes'); |
|
| 95 | 95 | |
| 96 | - if (!$noConfirm) { |
|
| 97 | - $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
| 98 | - $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
| 99 | - $listInput->setOption('output', $input->getOption('output')); |
|
| 100 | - $listCommand->listMounts(null, [$mount], $listInput, $output); |
|
| 96 | + if (!$noConfirm) { |
|
| 97 | + $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
| 98 | + $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
| 99 | + $listInput->setOption('output', $input->getOption('output')); |
|
| 100 | + $listCommand->listMounts(null, [$mount], $listInput, $output); |
|
| 101 | 101 | |
| 102 | - $questionHelper = $this->getHelper('question'); |
|
| 103 | - $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false); |
|
| 102 | + $questionHelper = $this->getHelper('question'); |
|
| 103 | + $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false); |
|
| 104 | 104 | |
| 105 | - if (!$questionHelper->ask($input, $output, $question)) { |
|
| 106 | - return null; |
|
| 107 | - } |
|
| 108 | - } |
|
| 105 | + if (!$questionHelper->ask($input, $output, $question)) { |
|
| 106 | + return null; |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - $this->globalService->removeStorage($mountId); |
|
| 111 | - } |
|
| 110 | + $this->globalService->removeStorage($mountId); |
|
| 111 | + } |
|
| 112 | 112 | } |
@@ -117,7 +117,7 @@ |
||
| 117 | 117 | \OC_Util::setupFS($user); |
| 118 | 118 | |
| 119 | 119 | // Check if this user has a trashbin directory |
| 120 | - $view = new \OC\Files\View('/' . $user); |
|
| 120 | + $view = new \OC\Files\View('/'.$user); |
|
| 121 | 121 | if (!$view->is_dir('/files_trashbin/files')) { |
| 122 | 122 | return false; |
| 123 | 123 | } |
@@ -34,77 +34,77 @@ |
||
| 34 | 34 | |
| 35 | 35 | class ExpireTrash extends \OC\BackgroundJob\TimedJob { |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var Expiration |
|
| 39 | - */ |
|
| 40 | - private $expiration; |
|
| 37 | + /** |
|
| 38 | + * @var Expiration |
|
| 39 | + */ |
|
| 40 | + private $expiration; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var IUserManager |
|
| 44 | - */ |
|
| 45 | - private $userManager; |
|
| 42 | + /** |
|
| 43 | + * @var IUserManager |
|
| 44 | + */ |
|
| 45 | + private $userManager; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @param IUserManager|null $userManager |
|
| 49 | - * @param Expiration|null $expiration |
|
| 50 | - */ |
|
| 51 | - public function __construct(IUserManager $userManager = null, |
|
| 52 | - Expiration $expiration = null) { |
|
| 53 | - // Run once per 30 minutes |
|
| 54 | - $this->setInterval(60 * 30); |
|
| 47 | + /** |
|
| 48 | + * @param IUserManager|null $userManager |
|
| 49 | + * @param Expiration|null $expiration |
|
| 50 | + */ |
|
| 51 | + public function __construct(IUserManager $userManager = null, |
|
| 52 | + Expiration $expiration = null) { |
|
| 53 | + // Run once per 30 minutes |
|
| 54 | + $this->setInterval(60 * 30); |
|
| 55 | 55 | |
| 56 | - if (is_null($expiration) || is_null($userManager)) { |
|
| 57 | - $this->fixDIForJobs(); |
|
| 58 | - } else { |
|
| 59 | - $this->userManager = $userManager; |
|
| 60 | - $this->expiration = $expiration; |
|
| 61 | - } |
|
| 62 | - } |
|
| 56 | + if (is_null($expiration) || is_null($userManager)) { |
|
| 57 | + $this->fixDIForJobs(); |
|
| 58 | + } else { |
|
| 59 | + $this->userManager = $userManager; |
|
| 60 | + $this->expiration = $expiration; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - protected function fixDIForJobs() { |
|
| 65 | - /** @var Application $application */ |
|
| 66 | - $application = \OC::$server->query(Application::class); |
|
| 67 | - $this->userManager = \OC::$server->getUserManager(); |
|
| 68 | - $this->expiration = $application->getContainer()->query('Expiration'); |
|
| 69 | - } |
|
| 64 | + protected function fixDIForJobs() { |
|
| 65 | + /** @var Application $application */ |
|
| 66 | + $application = \OC::$server->query(Application::class); |
|
| 67 | + $this->userManager = \OC::$server->getUserManager(); |
|
| 68 | + $this->expiration = $application->getContainer()->query('Expiration'); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * @param $argument |
|
| 73 | - * @throws \Exception |
|
| 74 | - */ |
|
| 75 | - protected function run($argument) { |
|
| 76 | - $maxAge = $this->expiration->getMaxAgeAsTimestamp(); |
|
| 77 | - if (!$maxAge) { |
|
| 78 | - return; |
|
| 79 | - } |
|
| 71 | + /** |
|
| 72 | + * @param $argument |
|
| 73 | + * @throws \Exception |
|
| 74 | + */ |
|
| 75 | + protected function run($argument) { |
|
| 76 | + $maxAge = $this->expiration->getMaxAgeAsTimestamp(); |
|
| 77 | + if (!$maxAge) { |
|
| 78 | + return; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - $this->userManager->callForSeenUsers(function(IUser $user) { |
|
| 82 | - $uid = $user->getUID(); |
|
| 83 | - if (!$this->setupFS($uid)) { |
|
| 84 | - return; |
|
| 85 | - } |
|
| 86 | - $dirContent = Helper::getTrashFiles('/', $uid, 'mtime'); |
|
| 87 | - Trashbin::deleteExpiredFiles($dirContent, $uid); |
|
| 88 | - }); |
|
| 81 | + $this->userManager->callForSeenUsers(function(IUser $user) { |
|
| 82 | + $uid = $user->getUID(); |
|
| 83 | + if (!$this->setupFS($uid)) { |
|
| 84 | + return; |
|
| 85 | + } |
|
| 86 | + $dirContent = Helper::getTrashFiles('/', $uid, 'mtime'); |
|
| 87 | + Trashbin::deleteExpiredFiles($dirContent, $uid); |
|
| 88 | + }); |
|
| 89 | 89 | |
| 90 | - \OC_Util::tearDownFS(); |
|
| 91 | - } |
|
| 90 | + \OC_Util::tearDownFS(); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * Act on behalf on trash item owner |
|
| 95 | - * @param string $user |
|
| 96 | - * @return boolean |
|
| 97 | - */ |
|
| 98 | - protected function setupFS($user) { |
|
| 99 | - \OC_Util::tearDownFS(); |
|
| 100 | - \OC_Util::setupFS($user); |
|
| 93 | + /** |
|
| 94 | + * Act on behalf on trash item owner |
|
| 95 | + * @param string $user |
|
| 96 | + * @return boolean |
|
| 97 | + */ |
|
| 98 | + protected function setupFS($user) { |
|
| 99 | + \OC_Util::tearDownFS(); |
|
| 100 | + \OC_Util::setupFS($user); |
|
| 101 | 101 | |
| 102 | - // Check if this user has a trashbin directory |
|
| 103 | - $view = new \OC\Files\View('/' . $user); |
|
| 104 | - if (!$view->is_dir('/files_trashbin/files')) { |
|
| 105 | - return false; |
|
| 106 | - } |
|
| 102 | + // Check if this user has a trashbin directory |
|
| 103 | + $view = new \OC\Files\View('/' . $user); |
|
| 104 | + if (!$view->is_dir('/files_trashbin/files')) { |
|
| 105 | + return false; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - return true; |
|
| 109 | - } |
|
| 108 | + return true; |
|
| 109 | + } |
|
| 110 | 110 | } |