diff --git a/system/src/Commands/GiveAdminCommand.php b/system/src/Commands/GiveAdminCommand.php new file mode 100644 index 00000000..d2565783 --- /dev/null +++ b/system/src/Commands/GiveAdminCommand.php @@ -0,0 +1,50 @@ +setName('give:admin') + ->setDescription('This command adds super admin privileges to selected user') + ->addArgument('account', InputArgument::REQUIRED, 'Account E-Mail, name or id'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + require SYSTEM . 'init.php'; + + $io = new SymfonyStyle($input, $output); + + $account = new \OTS_Account(); + + $accountParam = $input->getArgument('account'); + if (str_contains($accountParam, '@')) { + $account->findByEMail($accountParam); + } + else { + if (USE_ACCOUNT_NAME || USE_ACCOUNT_NUMBER) { + $account->find($accountParam); + } + else { + $account->load($accountParam); + } + } + + if (!$account->isLoaded()) { + $io->error('Cannot find account mit supplied parameter: ' . $accountParam); + return self::FAILURE; + } + + $account->setCustomField('web_flags', 3); + $io->success('Successfully added admin privileges to ' . $accountParam . ' (E-Mail: ' . $account->getEMail() . ')'); + return self::SUCCESS; + } +}