Merge branch 'master' into dist/envole/6/master

This commit is contained in:
Arnaud Fornerot 2020-06-26 15:46:34 +02:00
commit d1637e4efa
2 changed files with 23 additions and 15 deletions

View File

@ -19,9 +19,10 @@ class CalendareventController extends Controller
public function loadAction(Request $request,$access="config")
{
// S'assurer que c'est un appel ajax
if (!$request->isXmlHttpRequest()) return new JsonResponse(array('message' => 'Interdit'), 400);
$output=array();
// if (!$request->isXmlHttpRequest()) return new JsonResponse(array('message' => 'Interdit'), 400);
$events=array();
$eventids=array();
$idcalendar = $request->query->get('idcalendar');
$start = $request->query->get('start');
$end = $request->query->get('end');
@ -62,15 +63,23 @@ class CalendareventController extends Controller
$tmp['color'] = "#".(is_null($calendar->getColor())?$this->get('session')->get('color')["main"]:$calendar->getColor());
$tmp['allDay'] = $calendarevent->getAllday();
$tmp['calendar'] = $calendar->getId();
$tmp['editable'] = $calendar->getCanupdate();
$tmp['editable'] = $calendarevent->getCalendar()->getCanupdate();
array_push($output,$tmp);
array_push($events,$tmp);
array_push($eventids,$tmp["id"]);
}
}
if($idcalendar==0) {
$calendareventsshared = $this->getDoctrine()->getRepository("CadolesPortalBundle:Calendarevent")->getCalendareventShareByDate($this->getUser(),$start,$end);
foreach($calendareventsshared as $calendarevent) {
// On récupére les évenement partagé de l'utilisateur
if($this->getUser()) {
$calendarevents = $this->getDoctrine()->getRepository("CadolesPortalBundle:Calendarevent")->getCalendareventGroupsShareByDate($this->getUser(),$start,$end);
foreach($calendarevents as $calendarevent) {
if($idcalendar>0) {
if(!$calendarevent->getGroups()->contains($calendar->getGroups()[0])) continue;
}
$tmp=[];
$tmp['id'] = strval($calendarevent->getId());
$tmp['title'] = $calendarevent->getName();
@ -80,13 +89,16 @@ class CalendareventController extends Controller
$tmp['color'] = "#".(is_null($calendar->getColor())?$this->get('session')->get('color')["main"]:$calendar->getColor());
$tmp['allDay'] = $calendarevent->getAllday();
$tmp['calendar'] = $calendar->getId();
$tmp['editable'] = $calendar->getCanupdate();
$tmp['editable'] = $calendarevent->getCalendar()->getCanupdate();
array_push($output,$tmp);
if(!in_array($tmp['id'],$eventids)) {
array_push($events,$tmp);
array_push($eventids,$tmp["id"]);
}
}
}
$response = new Response(json_encode($output));
$response = new Response(json_encode($events));
$response->headers->set('Content-Type', 'application/text');
return $response;
}

View File

@ -82,10 +82,6 @@ class CalendareventRepository extends EntityRepository
->andWhere('groupe=usergroupe.group')
->andWhere('usergroupe.user=:user')
->from('CadolesCoreBundle:UserGroup','proprio')
->andWhere('proprio.group=groupe')
->andWhere('proprio.user=calendar.user')
->setParameter('fgcanshare',true)
->setParameter('user',$user)
->setParameter('start',$start)