mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 02:38:50 +02:00
Added permission system, to control who can edit Twig labels.
This commit is contained in:
parent
f1a6bc31a1
commit
1a35adab17
6 changed files with 41 additions and 8 deletions
|
@ -165,11 +165,22 @@ abstract class BaseAdminController extends AbstractController
|
|||
$table = null;
|
||||
}
|
||||
|
||||
$form = $this->createForm($this->form_class, $entity, [
|
||||
$form_options = [
|
||||
'attachment_class' => $this->attachment_class,
|
||||
'parameter_class' => $this->parameter_class,
|
||||
'disabled' => null !== $timeTravel_timestamp ? true : null,
|
||||
]);
|
||||
];
|
||||
|
||||
//Disable editing of options, if user is not allowed to use twig...
|
||||
if (
|
||||
$entity instanceof LabelProfile
|
||||
&& $entity->getOptions()->getLinesMode() === 'twig'
|
||||
&& !$this->isGranted('@labels.use_twig')
|
||||
) {
|
||||
$form_options['disable_options'] = true;
|
||||
}
|
||||
|
||||
$form = $this->createForm($this->form_class, $entity, $form_options);
|
||||
|
||||
$form->handleRequest($request);
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
|
|
|
@ -87,7 +87,12 @@ class LabelController extends AbstractController
|
|||
$label_options = new LabelOptions();
|
||||
}
|
||||
|
||||
$form = $this->createForm(LabelDialogType::class);
|
||||
//We have to disable the options, if twig mode is selected and user is not allowed to use it.
|
||||
$disable_options = $label_options->getLinesMode() === 'twig' && !$this->isGranted("@labels.use_twig");
|
||||
|
||||
$form = $this->createForm(LabelDialogType::class, null, [
|
||||
'disable_options' => $disable_options,
|
||||
]);
|
||||
|
||||
//Try to parse given target_type and target_id
|
||||
$target_type = $request->query->get('target_type', null);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue