mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-06 16:34:35 +02:00
Check permissions for time travel and element undo.
This commit is contained in:
parent
254d4e6c69
commit
8a61b465d0
23 changed files with 370 additions and 90 deletions
|
@ -27,15 +27,18 @@ use App\Entity\LogSystem\ElementCreatedLogEntry;
|
|||
use App\Entity\LogSystem\ElementDeletedLogEntry;
|
||||
use App\Entity\LogSystem\ElementEditedLogEntry;
|
||||
use Omines\DataTablesBundle\Column\AbstractColumn;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class RevertLogColumn extends AbstractColumn
|
||||
{
|
||||
protected $translator;
|
||||
protected $security;
|
||||
|
||||
public function __construct(TranslatorInterface $translator)
|
||||
public function __construct(TranslatorInterface $translator, Security $security)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,17 +68,21 @@ class RevertLogColumn extends AbstractColumn
|
|||
return '';
|
||||
}
|
||||
|
||||
$disabled = !$this->security->isGranted('revert_element', $context->getTargetClass());
|
||||
|
||||
$tmp = '<div class="btn-group btn-group-sm">';
|
||||
$tmp .= sprintf(
|
||||
'<button type="submit" class="btn btn-outline-secondary" name="undo" value="%d"><i class="fas fa-fw %s" title="%s"></i></button>',
|
||||
'<button type="submit" class="btn btn-outline-secondary" name="undo" value="%d" %s><i class="fas fa-fw %s" title="%s"></i></button>',
|
||||
$context->getID(),
|
||||
$disabled ? 'disabled' : '',
|
||||
$icon,
|
||||
$title
|
||||
);
|
||||
|
||||
$tmp .= sprintf(
|
||||
'<button type="submit" class="btn btn-outline-secondary" name="revert" value="%d"><i class="fas fa-fw fa-backward" title="%s"></i></button>',
|
||||
'<button type="submit" class="btn btn-outline-secondary" name="revert" value="%d" %s><i class="fas fa-fw fa-backward" title="%s"></i></button>',
|
||||
$context->getID(),
|
||||
$disabled ? 'disabled' : '',
|
||||
$this->translator->trans('log.undo.revert')
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue