mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-30 18:39:43 +00:00
Compare commits
13 Commits
issue706_c
...
71-adapt-r
Author | SHA1 | Date | |
---|---|---|---|
2dcc65d172 | |||
2d6a0d14eb | |||
fcb057c55b | |||
96ddc73e45
|
|||
4eb7d10e45
|
|||
efa475df0f | |||
a8977729fe
|
|||
ecac409586
|
|||
df2480c47c
|
|||
c729a14304 | |||
06b7e84270 | |||
1cc80c8e6a
|
|||
c3558beee1
|
@@ -257,12 +257,10 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
||||
/**
|
||||
* Add a social issue.
|
||||
*
|
||||
* Note: the social issue consistency (the fact that only yougest social issues
|
||||
* Note: the social issue consistency (the fact that only youngest social issues
|
||||
* are kept) is processed by an entity listener:
|
||||
*
|
||||
* @see{\Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodSocialIssueConsistencyEntityListener}
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addSocialIssue(SocialIssue $socialIssue): self
|
||||
{
|
||||
@@ -270,6 +268,10 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
||||
$this->socialIssues[] = $socialIssue;
|
||||
}
|
||||
|
||||
if ($this->getAccompanyingPeriod() !== null) {
|
||||
$this->getAccompanyingPeriod()->addSocialIssue($socialIssue);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -550,6 +552,10 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
||||
{
|
||||
$this->accompanyingPeriod = $accompanyingPeriod;
|
||||
|
||||
foreach ($this->getSocialIssues() as $issue) {
|
||||
$this->accompanyingPeriod->addSocialIssue($issue);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,7 @@ use Chill\MainBundle\Entity\User;
|
||||
use DateTimeImmutable;
|
||||
use LogicException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use function array_key_exists;
|
||||
|
||||
@@ -74,9 +75,18 @@ class MapCalendarToUser
|
||||
|
||||
public function getDefaultUserCalendar(string $idOrUserPrincipalName): ?array
|
||||
{
|
||||
$value = $this->machineHttpClient->request('GET', "users/{$idOrUserPrincipalName}/calendars", [
|
||||
'query' => ['$filter' => 'isDefaultCalendar eq true'],
|
||||
])->toArray()['value'];
|
||||
try {
|
||||
$value = $this->machineHttpClient->request('GET', "users/{$idOrUserPrincipalName}/calendars", [
|
||||
'query' => ['$filter' => 'isDefaultCalendar eq true'],
|
||||
])->toArray()['value'];
|
||||
} catch (ClientExceptionInterface $e) {
|
||||
$this->logger->error('[MapCalendarToUser] Error while listing calendars for a user', [
|
||||
'http_status_code' => $e->getResponse()->getStatusCode(),
|
||||
'id_user' => $idOrUserPrincipalName,
|
||||
]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $value[0] ?? null;
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
@@ -64,6 +65,8 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
|
||||
private OnBehalfOfUserHttpClient $userHttpClient;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(
|
||||
CalendarRepository $calendarRepository,
|
||||
CalendarRangeRepository $calendarRangeRepository,
|
||||
@@ -74,7 +77,8 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
OnBehalfOfUserHttpClient $userHttpClient,
|
||||
RemoteEventConverter $remoteEventConverter,
|
||||
TranslatorInterface $translator,
|
||||
UrlGeneratorInterface $urlGenerator
|
||||
UrlGeneratorInterface $urlGenerator,
|
||||
Security $security
|
||||
) {
|
||||
$this->calendarRepository = $calendarRepository;
|
||||
$this->calendarRangeRepository = $calendarRangeRepository;
|
||||
@@ -86,6 +90,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
$this->translator = $translator;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->userHttpClient = $userHttpClient;
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function countEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate): int
|
||||
@@ -133,6 +138,24 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
|
||||
public function isReady(): bool
|
||||
{
|
||||
$user = $this->security->getUser();
|
||||
|
||||
if (!$user instanceof User) {
|
||||
// this is not a user from chill. This is not the role of this class to
|
||||
// restrict access, so we will just say that we do not have to do anything more
|
||||
// here...
|
||||
return true;
|
||||
}
|
||||
|
||||
if (null === $this->mapCalendarToUser->getUserId($user)) {
|
||||
// this user is not mapped with remote calendar. The user will have to wait for
|
||||
// the next calendar subscription iteration
|
||||
$this->logger->debug('mark user ready for msgraph calendar as he does not have any mapping', [
|
||||
'userId' => $user->getId(),
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->tokenStorage->hasToken();
|
||||
}
|
||||
|
||||
|
@@ -76,8 +76,17 @@ class SimilarPersonMatcher
|
||||
|
||||
$qb->select('p')
|
||||
->from(Person::class, 'p')
|
||||
->join('p.centerHistory', 'center_history')
|
||||
->where('SIMILARITY(p.fullnameCanonical, UNACCENT(LOWER(:fullName))) >= :precision')
|
||||
->andWhere($qb->expr()->in('p.center', ':centers'));
|
||||
->andWhere($qb->expr()->in('center_history.center', ':centers'))
|
||||
->andWhere($qb->expr()->andX(
|
||||
$qb->expr()->lte('center_history.startDate', 'CURRENT_DATE()'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull('center_history.endDate'),
|
||||
$qb->expr()->gt('center_history.endDate', 'CURRENT_DATE()')
|
||||
)
|
||||
))
|
||||
;
|
||||
|
||||
$qb
|
||||
->setParameter('fullName', $this->personRender->renderString($person, []))
|
||||
@@ -117,7 +126,6 @@ class SimilarPersonMatcher
|
||||
$qb->setParameter('fullName', $this->personRender->renderString($person, []));
|
||||
}
|
||||
|
||||
dump($qb->getQuery());
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator
|
||||
$activities = $this->activityRepository->findBy(['accompanyingPeriod' => $period]);
|
||||
|
||||
foreach ($activities as $activity) {
|
||||
$socialIssues = $activity->getSocialIssues()->toArray();
|
||||
$socialIssues = array_merge($socialIssues, $activity->getSocialIssues()->toArray());
|
||||
}
|
||||
|
||||
foreach ($period->getWorks() as $work) {
|
||||
@@ -64,7 +64,7 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator
|
||||
$socialIssuesByKey = [];
|
||||
|
||||
foreach ($socialIssues as $si) {
|
||||
$socialIssuesByKey[$si->getId()] = $si;
|
||||
$socialIssuesByKey[spl_object_hash($si)] = $si;
|
||||
}
|
||||
|
||||
$periodIssuesWithAncestors = [];
|
||||
@@ -75,7 +75,7 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator
|
||||
$periodIssuesWithAncestors,
|
||||
array_map(
|
||||
static function (SocialIssue $si) {
|
||||
return $si->getId();
|
||||
return spl_object_hash($si);
|
||||
},
|
||||
$si->getAncestors(true)
|
||||
)
|
||||
|
@@ -11,12 +11,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\ReportBundle\Controller;
|
||||
|
||||
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Privacy\PrivacyEvent;
|
||||
use Chill\ReportBundle\Entity\Report;
|
||||
use Chill\ReportBundle\Form\ReportType;
|
||||
use Chill\ReportBundle\Security\Authorization\ReportVoter;
|
||||
use DateTime;
|
||||
use RuntimeException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@@ -25,7 +28,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
@@ -48,17 +51,25 @@ class ReportController extends AbstractController
|
||||
*/
|
||||
protected $paginator;
|
||||
|
||||
private CenterResolverManagerInterface $centerResolverManager;
|
||||
|
||||
private Security $security;
|
||||
|
||||
/**
|
||||
* ReportController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
PaginatorFactory $paginator
|
||||
PaginatorFactory $paginator,
|
||||
CenterResolverManagerInterface $centerResolverManager,
|
||||
Security $security
|
||||
) {
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->paginator = $paginator;
|
||||
$this->centerResolverManager = $centerResolverManager;
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +131,7 @@ class ReportController extends AbstractController
|
||||
->trans('The form is not valid. The report has not been created !')
|
||||
);
|
||||
|
||||
return $this->render('ChillReportBundle:Report:new.html.twig', [
|
||||
return $this->render('@ChillReport/Report/new.html.twig', [
|
||||
'entity' => $entity,
|
||||
'form' => $form->createView(),
|
||||
'person' => $person,
|
||||
@@ -140,7 +151,7 @@ class ReportController extends AbstractController
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
/** @var Report $report */
|
||||
$report = $em->getRepository('ChillReportBundle:Report')->find($report_id);
|
||||
$report = $em->getRepository(Report::class)->find($report_id);
|
||||
|
||||
if (!$report) {
|
||||
throw $this->createNotFoundException(
|
||||
@@ -189,7 +200,7 @@ class ReportController extends AbstractController
|
||||
$cFGroup = $em->getRepository(\Chill\CustomFieldsBundle\Entity\CustomFieldsGroup::class)->find($cf_group_id);
|
||||
$reports = $em->getRepository('ChillReportBundle:Report')->findByCFGroup($cFGroup);
|
||||
|
||||
$response = $this->render('ChillReportBundle:Report:export.csv.twig', [
|
||||
$response = $this->render('@ChillReport/Report/export.csv.twig', [
|
||||
'reports' => $reports,
|
||||
'cf_group' => $cFGroup,
|
||||
]);
|
||||
@@ -218,9 +229,9 @@ class ReportController extends AbstractController
|
||||
|
||||
$reachableScopes = $this->authorizationHelper
|
||||
->getReachableScopes(
|
||||
$this->getUser(),
|
||||
new Role('CHILL_REPORT_SEE'),
|
||||
$person->getCenter()
|
||||
$this->security->getUser(),
|
||||
ReportVoter::SEE,
|
||||
$this->centerResolverManager->resolveCenters($person)
|
||||
);
|
||||
|
||||
$total = $em
|
||||
@@ -298,7 +309,7 @@ class ReportController extends AbstractController
|
||||
|
||||
$form = $this->createCreateForm($entity, $person, $cFGroup);
|
||||
|
||||
return $this->render('ChillReportBundle:Report:new.html.twig', [
|
||||
return $this->render('@ChillReport/Report/new.html.twig', [
|
||||
'entity' => $entity,
|
||||
'form' => $form->createView(),
|
||||
'person' => $person,
|
||||
@@ -515,7 +526,7 @@ class ReportController extends AbstractController
|
||||
|
||||
$person = $em->getRepository(\Chill\PersonBundle\Entity\Person::class)->find($person_id);
|
||||
|
||||
$entity = $em->getRepository('ChillReportBundle:Report')->find($report_id);
|
||||
$entity = $em->getRepository(Report::class)->find($report_id);
|
||||
|
||||
if (!$entity || !$person) {
|
||||
throw $this->createNotFoundException(
|
||||
@@ -532,7 +543,7 @@ class ReportController extends AbstractController
|
||||
]);
|
||||
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
||||
|
||||
return $this->render('ChillReportBundle:Report:view.html.twig', [
|
||||
return $this->render('@ChillReport/Report/view.html.twig', [
|
||||
'entity' => $entity,
|
||||
'person' => $person,
|
||||
]);
|
||||
@@ -578,8 +589,8 @@ class ReportController extends AbstractController
|
||||
),
|
||||
'method' => 'PUT',
|
||||
'cFGroup' => $entity->getCFGroup(),
|
||||
'role' => new Role('CHILL_REPORT_UPDATE'),
|
||||
'center' => $entity->getPerson()->getCenter(),
|
||||
//'role' => ReportVoter::UPDATE,
|
||||
//'center' => $this->centerResolverManager->resolveCenters($entity->getPerson()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@@ -74,15 +74,15 @@ class ReportType extends AbstractType
|
||||
'group' => $options['cFGroup'], ]
|
||||
);
|
||||
|
||||
$this->appendScopeChoices(
|
||||
$builder,
|
||||
$options['role'],
|
||||
$options['center'],
|
||||
$this->user,
|
||||
$this->authorizationHelper,
|
||||
$this->translatableStringHelper,
|
||||
$this->om
|
||||
);
|
||||
//$this->appendScopeChoices(
|
||||
// $builder,
|
||||
// $options['role'],
|
||||
// $options['center'],
|
||||
// $this->user,
|
||||
// $this->authorizationHelper,
|
||||
// $this->translatableStringHelper,
|
||||
// $this->om
|
||||
//);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
@@ -97,7 +97,7 @@ class ReportType extends AbstractType
|
||||
|
||||
$resolver->setAllowedTypes('cFGroup', 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup');
|
||||
|
||||
$this->appendScopeChoicesOptions($resolver);
|
||||
//$this->appendScopeChoicesOptions($resolver);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -25,7 +25,9 @@
|
||||
|
||||
{{ form_row(edit_form.user) }}
|
||||
{{ form_row(edit_form.date) }}
|
||||
{#
|
||||
{{ form_row(edit_form.scope) }}
|
||||
#}
|
||||
{{ form_row(edit_form.cFData) }}
|
||||
|
||||
{{ form_widget(edit_form) }}
|
||||
|
@@ -1,7 +1,5 @@
|
||||
services:
|
||||
Chill\ReportBundle\Controller\ReportController:
|
||||
arguments:
|
||||
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
|
||||
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
||||
$paginator: '@Chill\MainBundle\Pagination\PaginatorFactory'
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags: ['controller.service_arguments']
|
||||
|
@@ -805,12 +805,9 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setProfession(string $profession): self
|
||||
public function setProfession(?string $profession): self
|
||||
{
|
||||
$this->profession = $profession;
|
||||
$this->profession = (string) $profession;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -110,6 +110,7 @@ class ThirdPartyType extends AbstractType
|
||||
->add('profession', TextType::class, [
|
||||
'label' => 'thirdparty.Profession',
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
])
|
||||
->add('contactDataAnonymous', CheckboxType::class, [
|
||||
'required' => false,
|
||||
|
Reference in New Issue
Block a user