mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 14:25:00 +00:00
Merge remote-tracking branch 'origin/master' into rector/rules-up-to-php80
Conflicts: src/Bundle/ChillActivityBundle/Controller/ActivityController.php src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php src/Bundle/ChillActivityBundle/Menu/PersonMenuBuilder.php src/Bundle/ChillActivityBundle/Repository/ActivityACLAwareRepository.php src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php src/Bundle/ChillCalendarBundle/Command/MapAndSubscribeUserCalendarCommand.php src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MSGraphUserRepository.php src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php src/Bundle/ChillDocStoreBundle/Controller/DocumentPersonController.php src/Bundle/ChillDocStoreBundle/Repository/PersonDocumentACLAwareRepository.php src/Bundle/ChillEventBundle/Search/EventSearch.php src/Bundle/ChillMainBundle/Controller/ExportController.php src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php src/Bundle/ChillMainBundle/Cron/CronManager.php src/Bundle/ChillMainBundle/Entity/CronJobExecution.php src/Bundle/ChillMainBundle/Export/ExportManager.php src/Bundle/ChillMainBundle/Form/Type/Export/PickCenterType.php src/Bundle/ChillMainBundle/Form/Type/Listing/FilterOrderType.php src/Bundle/ChillMainBundle/Repository/NotificationRepository.php src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelper.php src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperBuilder.php src/Bundle/ChillMainBundle/Templating/Listing/FilterOrderHelperFactory.php src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseWorkController.php src/Bundle/ChillPersonBundle/Controller/SocialWorkSocialActionApiController.php src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php src/Bundle/ChillPersonBundle/Export/Export/ListHouseholdInPeriod.php src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodContext.php src/Bundle/ChillPersonBundle/Service/DocGenerator/AccompanyingPeriodWorkEvaluationContext.php src/Bundle/ChillPersonBundle/Service/DocGenerator/PersonContext.php src/Bundle/ChillReportBundle/DataFixtures/ORM/LoadReports.php src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php
This commit is contained in:
@@ -18,11 +18,17 @@ use Chill\ActivityBundle\Repository\ActivityACLAwareRepositoryInterface;
|
||||
use Chill\ActivityBundle\Repository\ActivityRepository;
|
||||
use Chill\ActivityBundle\Repository\ActivityTypeCategoryRepository;
|
||||
use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface;
|
||||
use Chill\ActivityBundle\Repository\ActivityUserJobRepository;
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
use Chill\MainBundle\Entity\UserJob;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Repository\LocationRepository;
|
||||
use Chill\MainBundle\Repository\UserRepositoryInterface;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
|
||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Privacy\PrivacyEvent;
|
||||
@@ -48,29 +54,33 @@ use function array_key_exists;
|
||||
final class ActivityController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private ActivityACLAwareRepositoryInterface $activityACLAwareRepository,
|
||||
private ActivityTypeRepositoryInterface $activityTypeRepository,
|
||||
private ActivityTypeCategoryRepository $activityTypeCategoryRepository,
|
||||
private PersonRepository $personRepository,
|
||||
private ThirdPartyRepository $thirdPartyRepository,
|
||||
private LocationRepository $locationRepository,
|
||||
private ActivityRepository $activityRepository,
|
||||
private AccompanyingPeriodRepository $accompanyingPeriodRepository,
|
||||
private EntityManagerInterface $entityManager,
|
||||
private EventDispatcherInterface $eventDispatcher,
|
||||
private LoggerInterface $logger,
|
||||
private SerializerInterface $serializer,
|
||||
private UserRepositoryInterface $userRepository,
|
||||
private CenterResolverManagerInterface $centerResolver,
|
||||
private TranslatorInterface $translator,
|
||||
)
|
||||
{
|
||||
private readonly ActivityACLAwareRepositoryInterface $activityACLAwareRepository,
|
||||
private readonly ActivityTypeRepositoryInterface $activityTypeRepository,
|
||||
private readonly ActivityTypeCategoryRepository $activityTypeCategoryRepository,
|
||||
private readonly PersonRepository $personRepository,
|
||||
private readonly ThirdPartyRepository $thirdPartyRepository,
|
||||
private readonly LocationRepository $locationRepository,
|
||||
private readonly ActivityRepository $activityRepository,
|
||||
private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository,
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly EventDispatcherInterface $eventDispatcher,
|
||||
private readonly LoggerInterface $logger,
|
||||
private readonly SerializerInterface $serializer,
|
||||
private readonly UserRepositoryInterface $userRepository,
|
||||
private readonly CenterResolverManagerInterface $centerResolver,
|
||||
private readonly TranslatorInterface $translator,
|
||||
private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory,
|
||||
private readonly TranslatableStringHelperInterface $translatableStringHelper,
|
||||
private readonly PaginatorFactory $paginatorFactory,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a Activity entity.
|
||||
*
|
||||
* @param mixed $id
|
||||
*/
|
||||
public function deleteAction(Request $request, mixed $id)
|
||||
public function deleteAction(Request $request, $id)
|
||||
{
|
||||
$view = null;
|
||||
|
||||
@@ -243,14 +253,31 @@ final class ActivityController extends AbstractController
|
||||
{
|
||||
$view = null;
|
||||
$activities = [];
|
||||
// TODO: add pagination
|
||||
|
||||
[$person, $accompanyingPeriod] = $this->getEntity($request);
|
||||
$filter = $this->buildFilterOrder($person ?? $accompanyingPeriod);
|
||||
|
||||
$filterArgs = [
|
||||
'my_activities' => $filter->getSingleCheckboxData('my_activities'),
|
||||
'types' => $filter->hasEntityChoice('activity_types') ? $filter->getEntityChoiceData('activity_types') : [],
|
||||
'jobs' => $filter->hasEntityChoice('jobs') ? $filter->getEntityChoiceData('jobs') : [],
|
||||
'before' => $filter->getDateRangeData('activity_date')['to'],
|
||||
'after' => $filter->getDateRangeData('activity_date')['from'],
|
||||
];
|
||||
|
||||
if ($person instanceof Person) {
|
||||
$this->denyAccessUnlessGranted(ActivityVoter::SEE, $person);
|
||||
$count = $this->activityACLAwareRepository->countByPerson($person, ActivityVoter::SEE, $filterArgs);
|
||||
$paginator = $this->paginatorFactory->create($count);
|
||||
$activities = $this->activityACLAwareRepository
|
||||
->findByPerson($person, ActivityVoter::SEE, 0, null, ['date' => 'DESC', 'id' => 'DESC']);
|
||||
->findByPerson(
|
||||
$person,
|
||||
ActivityVoter::SEE,
|
||||
$paginator->getCurrentPageFirstItemNumber(),
|
||||
$paginator->getItemsPerPage(),
|
||||
['date' => 'DESC', 'id' => 'DESC'],
|
||||
$filterArgs
|
||||
);
|
||||
|
||||
$event = new PrivacyEvent($person, [
|
||||
'element_class' => Activity::class,
|
||||
@@ -262,10 +289,21 @@ final class ActivityController extends AbstractController
|
||||
} elseif ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
||||
$this->denyAccessUnlessGranted(ActivityVoter::SEE, $accompanyingPeriod);
|
||||
|
||||
$count = $this->activityACLAwareRepository->countByAccompanyingPeriod($accompanyingPeriod, ActivityVoter::SEE, $filterArgs);
|
||||
$paginator = $this->paginatorFactory->create($count);
|
||||
$activities = $this->activityACLAwareRepository
|
||||
->findByAccompanyingPeriod($accompanyingPeriod, ActivityVoter::SEE, 0, null, ['date' => 'DESC', 'id' => 'DESC']);
|
||||
->findByAccompanyingPeriod(
|
||||
$accompanyingPeriod,
|
||||
ActivityVoter::SEE,
|
||||
$paginator->getCurrentPageFirstItemNumber(),
|
||||
$paginator->getItemsPerPage(),
|
||||
['date' => 'DESC', 'id' => 'DESC'],
|
||||
$filterArgs
|
||||
);
|
||||
|
||||
$view = 'ChillActivityBundle:Activity:listAccompanyingCourse.html.twig';
|
||||
} else {
|
||||
throw new \LogicException("Unsupported");
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
@@ -274,10 +312,47 @@ final class ActivityController extends AbstractController
|
||||
'activities' => $activities,
|
||||
'person' => $person,
|
||||
'accompanyingCourse' => $accompanyingPeriod,
|
||||
'filter' => $filter,
|
||||
'paginator' => $paginator,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
private function buildFilterOrder(AccompanyingPeriod|Person $associated): FilterOrderHelper
|
||||
{
|
||||
|
||||
$filterBuilder = $this->filterOrderHelperFactory->create(self::class);
|
||||
$types = $this->activityACLAwareRepository->findActivityTypeByAssociated($associated);
|
||||
$jobs = $this->activityACLAwareRepository->findUserJobByAssociated($associated);
|
||||
|
||||
$filterBuilder
|
||||
->addDateRange('activity_date', 'activity.date')
|
||||
->addSingleCheckbox('my_activities', 'activity_filter.My activities');
|
||||
|
||||
if (1 < count($types)) {
|
||||
$filterBuilder
|
||||
->addEntityChoice('activity_types', 'activity_filter.Types', \Chill\ActivityBundle\Entity\ActivityType::class, $types, [
|
||||
'choice_label' => function (\Chill\ActivityBundle\Entity\ActivityType $activityType) {
|
||||
$text = match ($activityType->hasCategory()) {
|
||||
true => $this->translatableStringHelper->localize($activityType->getCategory()->getName()) . ' > ',
|
||||
false => '',
|
||||
};
|
||||
|
||||
return $text . $this->translatableStringHelper->localize($activityType->getName());
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
if (1 < count($jobs)) {
|
||||
$filterBuilder
|
||||
->addEntityChoice('jobs', 'activity_filter.Jobs', UserJob::class, $jobs, [
|
||||
'choice_label' => fn (UserJob $u) => $this->translatableStringHelper->localize($u->getLabel())
|
||||
]);
|
||||
}
|
||||
|
||||
return $filterBuilder->build();
|
||||
}
|
||||
|
||||
public function newAction(Request $request): Response
|
||||
{
|
||||
$view = null;
|
||||
@@ -604,8 +679,8 @@ final class ActivityController extends AbstractController
|
||||
throw $this->createNotFoundException('Accompanying Period not found');
|
||||
}
|
||||
|
||||
// TODO Add permission
|
||||
// $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
|
||||
// TODO Add permission
|
||||
// $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
|
||||
} else {
|
||||
throw $this->createNotFoundException('Person or Accompanying Period not found');
|
||||
}
|
||||
|
Reference in New Issue
Block a user