mirror of
https://github.com/slawkens/myaac.git
synced 2026-02-06 21:26:22 +01:00
Merge branch 'develop' into feature/2fa
This commit is contained in:
50
system/src/Commands/GiveAdminCommand.php
Normal file
50
system/src/Commands/GiveAdminCommand.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace MyAAC\Commands;
|
||||
|
||||
use MyAAC\Plugins;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
class GiveAdminCommand extends Command
|
||||
{
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace MyAAC\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Gallery extends Model {
|
||||
|
||||
protected $table = TABLE_PREFIX . 'gallery';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'comment', 'image', 'thumb',
|
||||
'author', 'ordering', 'hide',
|
||||
];
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user