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

This commit is contained in:
Arnaud Fornerot 2020-06-25 13:40:55 +02:00
commit 0777934192
4 changed files with 79 additions and 5 deletions

View File

@ -26,6 +26,7 @@
<variables>
<family name='Ninegate'>
<variable name="ninegate_test_ninegate" type="oui/non" hidden='True' exists='False'><value>non</value></variable>
<variable name="activer_adminer" type="oui/non" description="Activer Adminer" hidden='True' exists='False'><value>non</value></variable>
<variable name="activer_balado" type="oui/non" description="Activer Balado" hidden='True' exists='False'><value>non</value></variable>
<variable name="activer_dokuwiki" type="oui/non" description="Activer Dokuwiki" hidden='True' exists='False'><value>non</value></variable>
@ -508,7 +509,12 @@
<target type='variable'>ninegate_niveau02icon</target>
</condition>
<auto name='calc_multi_condition' target='ninegate_test_ninegate'>
<param>oui</param>
<param type='eole' name='condition_1' hidden='False'>activer_ninegate</param>
<param name='match'>oui</param>
<param name='mismatch'>non</param>
</auto>
<!-- AFFICHAGE EN FONCTION DU MODULE PORTAL -->

View File

@ -1588,6 +1588,8 @@ class PagewidgetController extends Controller
$entity = $em->getRepository($this->labelentity)->find($id);
if (!$entity) throw $this->createNotFoundException('Unable to find entity.');
$groupentity=$em->getRepository("CadolesCoreBundle:Group")->find($group);
// Permissions
if($access=="config") {
$canupdate = true;
@ -1630,6 +1632,8 @@ class PagewidgetController extends Controller
$end->modify('last day of this month');
$events=[];
$eventids=[];
foreach($calendars as $calendar) {
$calendarevents = $this->getDoctrine()->getRepository("CadolesPortalBundle:Calendarevent")->getCalendareventByDate($calendar,$start,$end);
@ -1650,9 +1654,40 @@ class PagewidgetController extends Controller
$tmp['end']->sub(new \DateInterval('PT1S'));
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"]);
}
}
}
// Render
return $this->render($this->labelentity.':viewcalendar.html.twig', [
'entity' => $entity,

View File

@ -26,10 +26,6 @@ class CalendareventRepository extends EntityRepository
public function getCalendareventShareByDate($user,$start,$end)
{
// Profilage
$roles=($user?$user->getRoles():["ROLE_ANONYME"]);
$groups=($user?$user->getGroups():[]);
// Event partagées
$calendareventshared=[];
if($user) {
@ -65,4 +61,40 @@ class CalendareventRepository extends EntityRepository
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;
}
}

View File

@ -25,6 +25,7 @@
<div id="tolocalize" style="display:none">
{% 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})) }}
{% endfor %}
</div>