ajout des event shared dans le widget calendar (ref #168)
This commit is contained in:
parent
88a4e9882b
commit
c1fed2d994
|
@ -1588,6 +1588,8 @@ class PagewidgetController extends Controller
|
||||||
$entity = $em->getRepository($this->labelentity)->find($id);
|
$entity = $em->getRepository($this->labelentity)->find($id);
|
||||||
if (!$entity) throw $this->createNotFoundException('Unable to find entity.');
|
if (!$entity) throw $this->createNotFoundException('Unable to find entity.');
|
||||||
|
|
||||||
|
$groupentity=$em->getRepository("CadolesCoreBundle:Group")->find($group);
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
if($access=="config") {
|
if($access=="config") {
|
||||||
$canupdate = true;
|
$canupdate = true;
|
||||||
|
@ -1630,6 +1632,8 @@ class PagewidgetController extends Controller
|
||||||
$end->modify('last day of this month');
|
$end->modify('last day of this month');
|
||||||
|
|
||||||
$events=[];
|
$events=[];
|
||||||
|
$eventids=[];
|
||||||
|
|
||||||
foreach($calendars as $calendar) {
|
foreach($calendars as $calendar) {
|
||||||
$calendarevents = $this->getDoctrine()->getRepository("CadolesPortalBundle:Calendarevent")->getCalendareventByDate($calendar,$start,$end);
|
$calendarevents = $this->getDoctrine()->getRepository("CadolesPortalBundle:Calendarevent")->getCalendareventByDate($calendar,$start,$end);
|
||||||
|
|
||||||
|
@ -1650,6 +1654,37 @@ class PagewidgetController extends Controller
|
||||||
$tmp['end']->sub(new \DateInterval('PT1S'));
|
$tmp['end']->sub(new \DateInterval('PT1S'));
|
||||||
|
|
||||||
array_push($events,$tmp);
|
array_push($events,$tmp);
|
||||||
|
array_push($eventids,$tmp["id"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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($usage=="group") {
|
||||||
|
if(!$calendarevent->getGroups()->contains($groupentity)) continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tmp=[];
|
||||||
|
$tmp['id'] = strval($calendarevent->getId());
|
||||||
|
$tmp['title'] = $calendarevent->getName();
|
||||||
|
$tmp['description'] = $calendarevent->getDescription();
|
||||||
|
$tmp['start'] = $calendarevent->getStart();
|
||||||
|
$tmp['end'] = $calendarevent->getEnd();
|
||||||
|
$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();
|
||||||
|
|
||||||
|
// Si évènement sur la journée on enlève une 1 seconde à la date de fin
|
||||||
|
if($tmp['allDay'])
|
||||||
|
$tmp['end']->sub(new \DateInterval('PT1S'));
|
||||||
|
|
||||||
|
if(!in_array($tmp['id'],$eventids)) {
|
||||||
|
array_push($events,$tmp);
|
||||||
|
array_push($eventids,$tmp["id"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,6 @@ class CalendareventRepository extends EntityRepository
|
||||||
|
|
||||||
public function getCalendareventShareByDate($user,$start,$end)
|
public function getCalendareventShareByDate($user,$start,$end)
|
||||||
{
|
{
|
||||||
// Profilage
|
|
||||||
$roles=($user?$user->getRoles():["ROLE_ANONYME"]);
|
|
||||||
$groups=($user?$user->getGroups():[]);
|
|
||||||
|
|
||||||
// Event partagées
|
// Event partagées
|
||||||
$calendareventshared=[];
|
$calendareventshared=[];
|
||||||
if($user) {
|
if($user) {
|
||||||
|
@ -65,4 +61,40 @@ class CalendareventRepository extends EntityRepository
|
||||||
|
|
||||||
return $calendareventshared;
|
return $calendareventshared;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCalendareventGroupsShareByDate($user,$start,$end)
|
||||||
|
{
|
||||||
|
// Event partagées
|
||||||
|
$calendareventshared=[];
|
||||||
|
if($user) {
|
||||||
|
$calendareventshared=$this->createQueryBuilder('calendarevent')
|
||||||
|
->andWhere('calendarevent.start>=:start')
|
||||||
|
->andWhere('calendarevent.end<=:end')
|
||||||
|
|
||||||
|
->from('CadolesPortalBundle:Calendar','calendar')
|
||||||
|
->andWhere('calendarevent.calendar=calendar')
|
||||||
|
|
||||||
|
->from('CadolesCoreBundle:Group','groupe')
|
||||||
|
->andWhere('groupe.fgcanshare=:fgcanshare')
|
||||||
|
->andWhere('groupe MEMBER OF calendarevent.groups')
|
||||||
|
|
||||||
|
->from('CadolesCoreBundle:UserGroup','usergroupe')
|
||||||
|
->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)
|
||||||
|
->setParameter('end',$end)
|
||||||
|
|
||||||
|
->orderBy('calendarevent.start', 'ASC')
|
||||||
|
->getQuery()->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $calendareventshared;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
<div id="tolocalize" style="display:none">
|
<div id="tolocalize" style="display:none">
|
||||||
{% for pagewidget in entity.pagewidgets %}
|
{% for pagewidget in entity.pagewidgets %}
|
||||||
|
<!-- {{ url(pagewidget.widget.routeview|replace({'_config_':'_'~access~'_'}),{id:pagewidget.id,by:mode,usage:usage,group:group}) }} -->
|
||||||
{{ render(url(pagewidget.widget.routeview|replace({'_config_':'_'~access~'_'}),{id:pagewidget.id,by:mode,usage:usage,group:group})) }}
|
{{ render(url(pagewidget.widget.routeview|replace({'_config_':'_'~access~'_'}),{id:pagewidget.id,by:mode,usage:usage,group:group})) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue