| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?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\Output\OutputInterface;
- use Symfony\Component\Console\Style\SymfonyStyle;
- use TYPO3\CMS\Core\Database\ConnectionPool;
- use TYPO3\CMS\Core\Utility\GeneralUtility;
- /**
- * This CLI command enable front-end editing for all be-users
- *
- * @package Opentalent\OtAdmin\Command
- */
- class EnableFeEditingCommand 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:users:enfeedit")
- ->setDescription("Enable front-end editing for all be-users");
- }
- /**
- * -- This method is expected by Typo3, do not rename ou remove --
- *
- * Executes the command for creating the new organization
- *
- * @param InputInterface $input
- * @param OutputInterface $output
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- $io = new SymfonyStyle($input, $output);
- $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
- ->getQueryBuilderForTable('be_users');
- $queryBuilder->getRestrictions()->removeAll();
- $statement = $queryBuilder
- ->select('be_users.*')
- ->from('be_users')
- ->where(
- $queryBuilder->expr()->eq('be_users.usergroup', $queryBuilder->createNamedParameter(3, \PDO::PARAM_INT))
- )
- ->execute()
- ;
- while ($row = $statement->fetch()) {
- $id = (int)$row['uid'];
- $BE_USER = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication');
- $user = $BE_USER->getRawUserByUid($id);
- $BE_USER->user = $user;
- $BE_USER->backendSetUC();
- $BE_USER->uc['frontend_editing'] = 1;
- $BE_USER->uc['frontend_editing_overlay'] = 1;
- $BE_USER->writeUC($BE_USER->uc);
- }
- $io->success(sprintf("-- done --"));
- }
- }
|