permission check for mark-as-exported buttons (#3313)
This commit is contained in:
@@ -120,7 +120,6 @@ class ExportController extends AbstractController
|
|||||||
$entries = $this->getEntries($query);
|
$entries = $this->getEntries($query);
|
||||||
$response = $renderer->render($entries, $query);
|
$response = $renderer->render($entries, $query);
|
||||||
|
|
||||||
// TODO check entries if user is allowed to update export state - see https://github.com/kevinpapst/kimai2/issues/1473
|
|
||||||
if ($query->isMarkAsExported()) {
|
if ($query->isMarkAsExported()) {
|
||||||
$this->export->setExported($entries);
|
$this->export->setExported($entries);
|
||||||
}
|
}
|
||||||
@@ -163,6 +162,7 @@ class ExportController extends AbstractController
|
|||||||
return $this->createForm(ExportToolbarForm::class, $query, [
|
return $this->createForm(ExportToolbarForm::class, $query, [
|
||||||
'action' => $this->generateUrl('export', []),
|
'action' => $this->generateUrl('export', []),
|
||||||
'include_user' => $this->isGranted('view_other_timesheet'),
|
'include_user' => $this->isGranted('view_other_timesheet'),
|
||||||
|
'include_export' => $this->isGranted('edit_export_other_timesheet'),
|
||||||
'method' => $method,
|
'method' => $method,
|
||||||
'timezone' => $this->getDateTimeFactory()->getTimezone()->getName(),
|
'timezone' => $this->getDateTimeFactory()->getTimezone()->getName(),
|
||||||
'attr' => [
|
'attr' => [
|
||||||
|
|||||||
@@ -669,6 +669,7 @@ final class InvoiceController extends AbstractController
|
|||||||
'action' => $this->generateUrl('invoice', []),
|
'action' => $this->generateUrl('invoice', []),
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'include_user' => $this->isGranted('view_other_timesheet'),
|
'include_user' => $this->isGranted('view_other_timesheet'),
|
||||||
|
'include_export' => $this->isGranted('edit_export_other_timesheet'),
|
||||||
'timezone' => $this->getDateTimeFactory()->getTimezone()->getName(),
|
'timezone' => $this->getDateTimeFactory()->getTimezone()->getName(),
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'id' => 'invoice-print-form'
|
'id' => 'invoice-print-form'
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
namespace App\Form\Toolbar;
|
namespace App\Form\Toolbar;
|
||||||
|
|
||||||
|
use App\Form\Type\MarkAsExportedType;
|
||||||
use App\Repository\Query\ExportQuery;
|
use App\Repository\Query\ExportQuery;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
@@ -38,10 +38,9 @@ class ExportToolbarForm extends AbstractToolbarForm
|
|||||||
$this->addActivityMultiChoice($builder, [], true);
|
$this->addActivityMultiChoice($builder, [], true);
|
||||||
$this->addExportRenderer($builder);
|
$this->addExportRenderer($builder);
|
||||||
$this->addTagInputField($builder);
|
$this->addTagInputField($builder);
|
||||||
$builder->add('markAsExported', CheckboxType::class, [
|
if ($options['include_export']) {
|
||||||
'label' => 'label.mark_as_exported',
|
$builder->add('markAsExported', MarkAsExportedType::class);
|
||||||
'required' => false,
|
}
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,6 +60,7 @@ class ExportToolbarForm extends AbstractToolbarForm
|
|||||||
'data_class' => ExportQuery::class,
|
'data_class' => ExportQuery::class,
|
||||||
'csrf_protection' => false,
|
'csrf_protection' => false,
|
||||||
'include_user' => true,
|
'include_user' => true,
|
||||||
|
'include_export' => true,
|
||||||
'timezone' => date_default_timezone_get(),
|
'timezone' => date_default_timezone_get(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
namespace App\Form\Toolbar;
|
namespace App\Form\Toolbar;
|
||||||
|
|
||||||
use App\Form\Type\InvoiceTemplateType;
|
use App\Form\Type\InvoiceTemplateType;
|
||||||
|
use App\Form\Type\MarkAsExportedType;
|
||||||
use App\Repository\Query\InvoiceQuery;
|
use App\Repository\Query\InvoiceQuery;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
@@ -29,10 +29,9 @@ class InvoiceToolbarSimpleForm extends AbstractToolbarForm
|
|||||||
$this->addDateRange($builder, ['timezone' => $options['timezone']]);
|
$this->addDateRange($builder, ['timezone' => $options['timezone']]);
|
||||||
$this->addCustomerMultiChoice($builder, ['required' => false, 'start_date_param' => null, 'end_date_param' => null, 'ignore_date' => true, 'placeholder' => ''], true);
|
$this->addCustomerMultiChoice($builder, ['required' => false, 'start_date_param' => null, 'end_date_param' => null, 'ignore_date' => true, 'placeholder' => ''], true);
|
||||||
$this->addProjectMultiChoice($builder, ['ignore_date' => true], true, true);
|
$this->addProjectMultiChoice($builder, ['ignore_date' => true], true, true);
|
||||||
$builder->add('markAsExported', CheckboxType::class, [
|
if ($options['include_export']) {
|
||||||
'label' => 'label.mark_as_exported',
|
$builder->add('markAsExported', MarkAsExportedType::class);
|
||||||
'required' => false,
|
}
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addTemplateChoice(FormBuilderInterface $builder)
|
protected function addTemplateChoice(FormBuilderInterface $builder)
|
||||||
@@ -52,6 +51,7 @@ class InvoiceToolbarSimpleForm extends AbstractToolbarForm
|
|||||||
'data_class' => InvoiceQuery::class,
|
'data_class' => InvoiceQuery::class,
|
||||||
'csrf_protection' => false,
|
'csrf_protection' => false,
|
||||||
'include_user' => true,
|
'include_user' => true,
|
||||||
|
'include_export' => true,
|
||||||
'timezone' => date_default_timezone_get(),
|
'timezone' => date_default_timezone_get(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
30
src/Form/Type/MarkAsExportedType.php
Normal file
30
src/Form/Type/MarkAsExportedType.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Form\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
class MarkAsExportedType extends AbstractType
|
||||||
|
{
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'label' => 'label.mark_as_exported',
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getParent(): string
|
||||||
|
{
|
||||||
|
return CheckboxType::class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,7 +50,9 @@
|
|||||||
{{ form_row(form.billable) }}
|
{{ form_row(form.billable) }}
|
||||||
{{ form_row(form.exported) }}
|
{{ form_row(form.exported) }}
|
||||||
{{ form_row(form.state) }}
|
{{ form_row(form.state) }}
|
||||||
|
{% if form.markAsExported is defined %}
|
||||||
{{ form_row(form.markAsExported) }}
|
{{ form_row(form.markAsExported) }}
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block box_footer%}
|
{% block box_footer%}
|
||||||
{{ search.searchButton(form) }}
|
{{ search.searchButton(form) }}
|
||||||
|
|||||||
@@ -53,7 +53,9 @@
|
|||||||
{{ form_row(form.exported) }}
|
{{ form_row(form.exported) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ form_row(form.template) }}
|
{{ form_row(form.template) }}
|
||||||
|
{% if form.markAsExported is defined %}
|
||||||
{{ form_row(form.markAsExported) }}
|
{{ form_row(form.markAsExported) }}
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block box_footer%}
|
{% block box_footer%}
|
||||||
{{ search.searchButton(form) }}
|
{{ search.searchButton(form) }}
|
||||||
|
|||||||
Reference in New Issue
Block a user