| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace Opentalent\OtAdmin\Command;
- use Opentalent\OtAdmin\Controller\SiteController;
- use Symfony\Component\Console\Command\Command;
- use Symfony\Component\Console\Input\InputArgument;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Input\InputOption;
- use Symfony\Component\Console\Output\OutputInterface;
- use Symfony\Component\Console\Style\SymfonyStyle;
- use TYPO3\CMS\Core\Utility\GeneralUtility;
- use TYPO3\CMS\Extbase\Object\ObjectManager;
- /**
- * This CLI command resets the permissions granted to
- * this website be users
- *
- * @package Opentalent\OtAdmin\Command
- */
- class ResetBeUserPermsCommand extends Command
- {
- /**
- * -- This method is expected by Typo3, do not rename ou remove --
- *
- * Allows to configure the command.
- * Allows to add a description, a help text, and / or define arguments.
- *
- */
- protected function configure()
- {
- $this
- ->setName("ot:site:reset-perms")
- ->setDescription("Reset the permissions granted to the be users")
- ->setHelp("This CLI command resets the permissions granted to
- either one website be users, or every websites be users")
- ->addArgument(
- 'organization-id',
- InputArgument::OPTIONAL,
- "The organization's id in the opentalent DB"
- )
- ->addOption(
- "all",
- null,
- InputOption::VALUE_NONE,
- "Reset all of the websites be_users permissions."
- );
- }
- /**
- * -- This method is expected by Typo3, do not rename ou remove --
- *
- * @param InputInterface $input
- * @param OutputInterface $output
- * @throws \Exception
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- $org_id = $input->getArgument('organization-id');
- $all = $input->getOption('all');
- if ($all && $org_id) {
- throw new \InvalidArgumentException("You can not pass both an organization id and the --all option");
- }
- if (!$all && !$org_id) {
- throw new \InvalidArgumentException("You shall either pass an organization id or use the --all option");
- }
- $io = new SymfonyStyle($input, $output);
- $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
- if ($all) {
- $siteController->resetAllBeUserPermsAction();
- $io->success(sprintf("Be users permissions were reset for every website"));
- } else {
- $rootUid = $siteController->resetBeUserPermsAction($org_id);
- $io->success(sprintf("The website with root uid " . $rootUid . " had its be users permissions reset"));
- }
- }
- }
|