コード例 #1
0
 public function _createContent(&$toReturn)
 {
     $agendaService = new AgendaService();
     $serviceDate = new DateService();
     //on détermine le jour d'affichage
     if ($this->getParam('day') == null) {
         $day = date('Ymd');
     } else {
         $day = $this->getParam('day');
     }
     //on récupère les évènements de la journée
     foreach ($this->getParam('arAgendasAffiches') as $idAgenda) {
         $arEventsSemaine[$idAgenda] = $agendaService->checkEventOfAgendaInBdd($idAgenda, $day, $day);
     }
     //on ordonne les évènements par ordre croissant d'heure de début d'évènement dans la journée
     $arEventByDay = $agendaService->getEventsByDay($arEventsSemaine, $day, $day);
     $arEventByDay = $agendaService->getEventsInOrderByDay($arEventByDay);
     //on simplifie le tableau pour le passer à la zone
     $arDayEvent = $arEventByDay[$day]->events;
     //on récupère la couleur d'affichage de chaque évènement
     //$arColorByEvent = $agendaService->getColorByIdEvent($arDayEvent);
     $arAgendas = $agendaService->getTilteAgendaByIdAgenda($this->getParam('arAgendasAffiches'));
     //on récupère la couleur d'affichage pour chaque agenda
     $boolCroise = array();
     $daoAgenda =& CopixDAOFactory::getInstanceOf('agenda|agenda');
     foreach ($this->getParam('arAgendasAffiches') as $id) {
         $agenda = $daoAgenda->get($id);
         $boolCroise[$agenda->type_agenda] = $boolCroise[$agenda->type_agenda] == false;
         $colors = $agendaService->getColorAgendaByIdAgenda($id);
         $arColorAgenda[$id] = $boolCroise[$agenda->type_agenda] ? $colors[0] : $colors[1];
     }
     $arEventToDisplay = array();
     foreach ($arDayEvent as $event) {
         $event->color = $arColorAgenda[$event->id_agenda];
         $arEventToDisplay[] = $event;
     }
     $jour = substr($day, 6, 2);
     $mois = $serviceDate->moisNumericToMoisLitteral(substr($day, 4, 2));
     $annee = substr($day, 0, 4);
     $tpl = new CopixTpl();
     $tpl->assign('jour', $jour);
     $tpl->assign('mois', $mois);
     $tpl->assign('annee', $annee);
     //$tpl->assign('arEvent'       , $arDayEvent);
     $tpl->assign('arEvent', $arEventToDisplay);
     $tpl->assign('arAgendas', $arAgendas);
     $tpl->assign('arColorByEvent', $arColorByEvent);
     $tpl->assign('arColorAgenda', $arColorAgenda);
     $toReturn = $tpl->fetch('aujourdhui.agenda.tpl');
     return true;
 }
コード例 #2
0
 /**
  * Fonction appelée lorsque l'on clique sur le bouton 'import'
  * Appel la méthode privée _validFromFormImportParams
  * vérifie les infos saisies dans le formulaire
  * stock l'objet en session
  * @author Audrey Vassal <*****@*****.**>
  */
 public function doExport()
 {
     $serviceAuth = new AgendaAuth();
     $serviceExport = new ExportService();
     $agendaService = new AgendaService();
     $dateService = new DateService();
     //demande de mettre l'objet à jour en fonction des valeurs saisies dans le formulaire
     if (!($exportParams = $this->_getSessionExport())) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.error.cannotFindSession'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine')));
     }
     //on vérifie les droits des utilisateurs sur la liste des agendas sélectionnés
     foreach ((array) $this->getRequest('agenda') as $id_agenda) {
         //on vérifie si l'utilisateur a les droits d'écriture sur un des agendas affiché
         if ($serviceAuth->getCapability($id_agenda) < $serviceAuth->getRead()) {
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.error.enableToWrite'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine')));
         }
     }
     $this->_validFromFormExportParams($exportParams);
     $errors = $this->_checkExport($exportParams);
     if (count($errors) > 0) {
         $this->_setSessionExport($exportParams);
         return CopixActionGroup::process('agenda|ImportExport::getPrepareExport', array('e' => 1, 'errors' => $errors));
     } else {
         //var_dump($exportParams);
         //die();
         //on récupère tous les évènements des agendas cochés dans la période demandée
         foreach ((array) _request('agenda') as $idAgenda) {
             $arEventsPeriode[$idAgenda] = $agendaService->checkEventOfAgendaInBdd($idAgenda, CopixDateTime::dateToYYYYMMDD($exportParams->datedeb_export), CopixDateTime::dateToYYYYMMDD($exportParams->datefin_export));
         }
         //on classe ces évènements par jour
         $arEventByDay = $agendaService->getEventsByDay($arEventsPeriode, CopixDateTime::dateToYYYYMMDD($exportParams->datedeb_export), CopixDateTime::dateToYYYYMMDD($exportParams->datefin_export));
         //on ordonne les évènements par ordre croissant d'heure de début d'évènement dans la journée
         //var_dump($arEventByDay);
         $arEventByDay = $agendaService->getEventsInOrderByDay($arEventByDay);
         $content = $serviceExport->getFileICal($arEventByDay, CopixDateTime::dateToTimestamp($exportParams->datedeb_export), CopixDateTime::dateToTimestamp($exportParams->datefin_export));
     }
     //on vide la session
     $this->_setSessionExport(null);
     return _arContent($content, array('filename' => 'agenda.ics', 'content-disposition' => 'attachement', 'content-type' => CopixMIMETypes::getFromExtension('.ics')));
 }
コード例 #3
0
 /**
  * Fonction qui insère en base de données les évènements du fichier iCal
  *
  * @param file $iCalFile   Fichier iCalendar contenant des événements à importer
  * @param int  $agendaId   Identifiant de l'agenda dans lequel doivent être insérés les évènements
  * @param bool $withPurge  Purge le calendrier de l'agenda sur la période concernée
  *
  * @return int Nombre d'insertions effectuées
  */
 public static function import($iCalFile, $agendaId, $withPurge = false)
 {
     $ical = new SG_iCal($iCalFile);
     $events = $ical->getEvents();
     $eventsCounter = 0;
     if (is_array($events) && !empty($events)) {
         // Récupération de la première et dernière date du calendrier importé
         foreach ($events as $event) {
             if (!isset($startDate) && !isset($endDate)) {
                 $startDate = $event->getStart();
                 $endDate = $event->getEnd();
             }
             $startDate = min($event->getStart(), $startDate);
             $endDate = max($event->getEnd(), $endDate);
         }
         // Si purge de l'agenda demandé...
         if ($withPurge) {
             try {
                 _classInclude('agenda|AgendaService');
                 AgendaService::purgeAgendaByDateInterval($agendaId, date('Ymd', $startDate), date('Ymd', $endDate), date('H:i', $startDate), date('H:i', $endDate));
             } catch (Exception $e) {
                 throw new Exception('Error during agenda purge.');
             }
         }
         $eventDAO = _ioDAO('event');
         foreach ($events as $event) {
             // Recherche si l'événement existe déjà en base
             $criteres = _daoSp();
             $criteres->addCondition('id_agenda', '=', $agendaId);
             $criteres->addCondition('title_event', '=', $event->getSummary());
             $criteres->addCondition('datedeb_event', '=', date('Ymd', $event->getStart()));
             $criteres->addCondition('datefin_event', '=', date('Ymd', $event->getEnd()));
             if ($event->isWholeDay()) {
                 $criteres->addCondition('alldaylong_event', '=', 1);
             } else {
                 $criteres->addCondition('heuredeb_event', '=', date('H:i', $event->getStart()));
             }
             $resultat = $eventDAO->findBy($criteres);
             // Si l'évenement n'est pas présent en base on le sauvegarde tel qu'elle
             if (count($resultat) < 1) {
                 $record = self::createEvent($agendaId, $event);
                 $eventDAO->insert($record);
                 $eventsCounter++;
             } else {
                 // Sinon, on applique un traitement spécifique aux événements récurrents
                 if ($event->getProperty('recurrence')) {
                     $findSame = false;
                     // On cherche la date de fin de récurrence
                     if ($event->getProperty('freq')) {
                         $endRepeatdateEvent = date('Ymd', $event->getProperty('freq')->lastOccurrence());
                     } else {
                         $endRepeatdateEvent = 99999999;
                     }
                     // Si dans les résultat, une date de fin de récurrence est trouvé, alors l'évenements est déjà en base
                     foreach ($resultat as $eventSame) {
                         if ($eventSame->endrepeatdate_event == $endRepeatdateEvent || $eventSame->endrepeatdate_event == date('Ymd', $endDate)) {
                             $findSame = true;
                         }
                     }
                     // Sinon, il a pus être purger, on vérifie donc si sa date de fin de récurrence est égale à la date de début de purge
                     if ($resultat[0]->endrepeatdate_event == date('Ymd', $startDate) && !$findSame) {
                         $record = self::createEvent($agendaId, $event);
                         // Dans se cas, la récurrence prendra fin à la date de fin de purge, car un nouvel événement est entré en base pour la suite
                         $record->endrepeatdate_event = date('Ymd', $endDate);
                         $eventDAO->insert($record);
                     }
                 }
             }
         }
     }
     return $eventsCounter;
 }
コード例 #4
0
 /**
  * Fonction qui est appelée lorsque l'on valide la saisie d'un évènement
  * Met à jour l'objet avec les données du formulaire
  * Vérifie les informations saisies dans le formulaire
  * @author Audrey Vassal <*****@*****.**>
  * @return redirige vers l'action "getVueSemaine" de l'actiongroup agenda
  */
 public function doValid()
 {
     $serviceAuth = new AgendaAuth();
     $serviceAgenda = new AgendaService();
     $serviceType = new AgendaType();
     if (!($toValid = $this->_getSessionLecon())) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.error.cannotFindSession'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine')));
     }
     if ($serviceAuth->getCapability($toValid->id_agenda) < $serviceAuth->getWriteLecon() || $serviceAgenda->getTypeAgendaByIdAgenda($toValid->id_agenda) != $serviceType->getClassRoom()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.error.enableToWrite'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine')));
     }
     //demande de mettre l'objet à jour en fonction des valeurs saisies dans le formulaire
     $this->_validFromForm($toValid);
     $errors = $this->_check();
     if (count($errors) > 0) {
         $this->_setSessionLecon($toValid);
         return CopixActionGroup::process('agenda|Lecon::getEdit', array('e' => 1, 'errors' => $errors));
     } else {
         $daoLecon =& CopixDAOFactory::getInstanceOf('lecon');
         $record =& CopixDAOFactory::createRecord('lecon');
         $criteres = _daoSp();
         $criteres->addCondition('id_lecon', '=', $toValid->id_lecon);
         $resultat = $daoLecon->findBy($criteres);
         $modif = false;
         if (count($resultat) > 0) {
             //modification
             $record = $resultat[0];
             $modif = true;
         }
         $record->id_agenda = $toValid->id_agenda;
         $record->desc_lecon = $toValid->desc_lecon;
         $record->date_lecon = $toValid->date_lecon;
         if ($modif) {
             $daoLecon->update($record);
         } else {
             $daoLecon->insert($record);
         }
         //on vide la session
         $this->_setSessionLecon(null);
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('agenda|agenda|vueSemaine'));
     }
 }
コード例 #5
0
 /**
  * Liste des agendas disponibles
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/08/24
  * @param integer $id Id de l'agenda (si aucun, l'envoie dans l'agenda perso)
  */
 public function processAgendaList()
 {
     $serviceAuth = new AgendaAuth();
     $serviceType = new AgendaType();
     $serviceAgenda = new AgendaService();
     $tpl = new CopixTpl();
     $agendaDispos = AgendaService::getAvailableAgenda();
     $agendaAffiches = AgendaService::getAgendaAffiches();
     $ableToWrite = $ableToModerate = false;
     //on vérifie les droits des utilisateurs sur la liste des agendas affichés
     foreach ((array) $agendaAffiches as $id_agenda) {
         //on vérifie si l'utilisateur a les droits d'écriture sur un des agendas affiché
         //print_r($serviceAuth->getWriteAgenda());
         if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getWriteAgenda()) {
             $ableToWrite = true;
             break;
         }
     }
     //on vérifie les droits des utilisateurs sur la liste des agendas affichés
     foreach ((array) $agendaAffiches as $id_agenda) {
         //on vérifie si l'utilisateur a les droits d'import
         if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getModerate()) {
             $ableToModerate = true;
             break;
         }
     }
     $listeFiltre = $agendaDispos;
     //on vérifie les droits de lecture des utilisateurs
     foreach ((array) $listeFiltre as $key => $agenda) {
         //on vérifie si l'utilisateur a les droits de lecture sur la liste des agendas
         if ($serviceAuth->getCapability($agenda->id_agenda) < $serviceAuth->getRead()) {
             unset($listeFiltre[$key]);
         }
     }
     //on construit le tableau de couleurs associées au type d'agenda
     $arColorByIdAgenda = array();
     foreach ((array) $listeFiltre as $agenda) {
         $arColor = $serviceType->getColors($serviceAgenda->getTypeAgendaByIdAgenda($agenda->id_agenda));
         $i = 0;
         foreach ($arColorByIdAgenda as $idAgenda => $couleurAgenda) {
             if ($arColorByIdAgenda[$idAgenda] == $arColor[$i]) {
                 $i = $i + 1;
             }
         }
         if ($i < count($arColor)) {
             $arColorByIdAgenda[$agenda->id_agenda] = $arColor[$i];
         } else {
             $arColorByIdAgenda[$agenda->id_agenda] = $arColor[0];
         }
     }
     $ppo = new CopixPPO();
     $ppo->arColorByIdAgenda = $arColorByIdAgenda;
     $ppo->listAgendas = $listeFiltre;
     $ppo->agendasSelectionnes = $agendaAffiches;
     CopixHTMLHeader::addCSSLink(_resource("styles/module_agenda.css"));
     return _arPPO($ppo, array('template' => 'popup_agendalist.agenda.tpl', 'mainTemplate' => 'main|main_fancy.php'));
 }
コード例 #6
0
 /**
  * Fonction qui est appel�e lorsque l'on valide la saisie d'un �v�nement
  * Met � jour l'objet avec les donn�es du formulaire
  * V�rifie les informations saisies dans le formulaire
  * @author Audrey Vassal <*****@*****.**>
  * @return redirige vers l'action "getVueSemaine" de l'actiongroup agenda
  */
 public function doValid()
 {
     $serviceAuth = new AgendaAuth();
     //initialisation des cases � cocher
     if (!($toValid = $this->_getSessionEvent())) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.error.cannotFindSession'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine')));
     }
     //demande de mettre l'objet � jour en fonction des valeurs saisies dans le formulaire
     $this->_validFromForm($toValid);
     //var_dump($toValid);
     //on v�rifie les droits
     if ($serviceAuth->getCapability($toValid->id_agenda) < $serviceAuth->getWriteAgenda()) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.error.enableToWrite'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine')));
     }
     $errors = $this->_check($toValid);
     //var_dump($toValid);
     if (count($errors) > 0) {
         //s'il y a des erreurs
         $this->_setSessionEvent($toValid);
         return CopixActionGroup::process('agenda|Event::getEdit', array('e' => 1, 'errors' => $errors));
     } else {
         $daoEvent =& CopixDAOFactory::getInstanceOf('event');
         $record = _record('event');
         $criteres = _daoSp();
         $criteres->addCondition('id_event', '=', $toValid->id_event);
         $resultat = $daoEvent->findBy($criteres);
         $modif = false;
         if (count($resultat) > 0) {
             //modification
             $record = $resultat[0];
             $modif = true;
         }
         //on fait l'enregistrement en base
         if (isset($toValid->endrepeat_event) && $toValid->endrepeat_event == 'nbfois' && $toValid->nb_fois != null) {
             //on determine la date de fin dans le cas o� il s'agit d'une r�p�tion n fois
             $obj = new AgendaService();
             $dateFin = $obj->getDateEndRepeatByNbFois($toValid->nb_fois, $toValid->repeat_event, $toValid->datefin_event);
         }
         //die ("dateFin=$dateFin");
         $record->id_agenda = $toValid->id_agenda;
         $record->title_event = $toValid->title_event;
         $record->desc_event = $toValid->desc_event;
         $record->place_event = $toValid->place_event;
         //$record->datedeb_event    = CopixDateTime::dateToTimestamp ($toValid->datedeb_event);//convertion des dates au format bdd
         $record->datedeb_event = CopixDateTime::dateToYYYYMMDD($toValid->datedeb_event, '/');
         //$record->datefin_event    = CopixDateTime::dateToTimestamp ($toValid->datefin_event);//convertion des dates au format bdd
         $record->datefin_event = CopixDateTime::dateToYYYYMMDD($toValid->datefin_event, '/');
         $record->heuredeb_event = $toValid->heuredeb_event;
         $record->heurefin_event = $toValid->heurefin_event;
         $record->alldaylong_event = isset($toValid->alldaylong_event) ? $toValid->alldaylong_event : 0;
         //si il y a r�p�tition de l'�v�nement
         if (isset($toValid->repeat) && $toValid->repeat == 1) {
             $record->everyday_event = $toValid->repeat_event == 'everyday_event' && $toValid->repeat == 1 ? 1 : 0;
             $record->everyweek_event = $toValid->repeat_event == 'everyweek_event' && $toValid->repeat == 1 ? 1 : 0;
             $record->everymonth_event = $toValid->repeat_event == 'everymonth_event' && $toValid->repeat == 1 ? 1 : 0;
             $record->everyyear_event = $toValid->repeat_event == 'everyyear_event' && $toValid->repeat == 1 ? 1 : 0;
             //date de fin de r�p�tition (� voir selon ce qui est coch�)
             if (isset($dateFin)) {
                 $record->endrepeatdate_event = CopixDateTime::dateToYYYYMMDD($dateFin, '/');
             } elseif (isset($toValid->dateendrepeat_event) && $toValid->endrepeat_event == 'date') {
                 $record->endrepeatdate_event = CopixDateTime::dateToTimestamp($toValid->dateendrepeat_event);
             } else {
                 $record->endrepeatdate_event = $toValid->endrepeat_event == '99999999' ? $toValid->endrepeat_event : null;
             }
         } else {
             $record->everyday_event = 0;
             $record->everyweek_event = 0;
             $record->everymonth_event = 0;
             $record->everyyear_event = 0;
             $record->endrepeatdate_event = null;
         }
         if ($modif == true) {
             //on fait une modification
             $daoEvent->update($record);
         } else {
             //on fait un ajout
             $daoEvent->insert($record);
             //if (!$record-id_event)
             //	return CopixActionGroup::process('agenda|Event::getEdit', array('e'=>1, 'errors'=>$errors));
         }
         //var_dump($record);
         //die("a");
         //on vide la session
         $this->_setSessionEvent(null);
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('agenda|agenda|vueSemaine'));
     }
 }
コード例 #7
0
 public function _createContent(&$toReturn)
 {
     $service = new DateService();
     $serviceAgenda = new AgendaService();
     $serviceType = new AgendaType();
     $serviceAuth = new AgendaAuth();
     //on determine la date du jour en timestamp
     $dimanche = $service->numweekToDate($this->getParam('elementsSemaineAffichee')->numSemaine, $this->getParam('elementsSemaineAffichee')->annee, 0);
     $lundi = $service->numweekToDate($this->getParam('elementsSemaineAffichee')->numSemaine, $this->getParam('elementsSemaineAffichee')->annee, 1);
     $mardi = $service->numweekToDate($this->getParam('elementsSemaineAffichee')->numSemaine, $this->getParam('elementsSemaineAffichee')->annee, 2);
     $mercredi = $service->numweekToDate($this->getParam('elementsSemaineAffichee')->numSemaine, $this->getParam('elementsSemaineAffichee')->annee, 3);
     $jeudi = $service->numweekToDate($this->getParam('elementsSemaineAffichee')->numSemaine, $this->getParam('elementsSemaineAffichee')->annee, 4);
     $vendredi = $service->numweekToDate($this->getParam('elementsSemaineAffichee')->numSemaine, $this->getParam('elementsSemaineAffichee')->annee, 5);
     $samedi = $service->numweekToDate($this->getParam('elementsSemaineAffichee')->numSemaine, $this->getParam('elementsSemaineAffichee')->annee, 6);
     $tpl = new CopixTpl();
     //date du jour
     $tpl->assign('dimanche', date('d', $dimanche));
     $tpl->assign('lundi', date('d', $lundi));
     $tpl->assign('mardi', date('d', $mardi));
     $tpl->assign('mercredi', date('d', $mercredi));
     $tpl->assign('jeudi', date('d', $jeudi));
     $tpl->assign('vendredi', date('d', $vendredi));
     $tpl->assign('samedi', date('d', $samedi));
     $tpl->assign('date_deb', date('Ymd', $lundi));
     $tpl->assign('date_fin', date('Ymd', $dimanche));
     $tpl->assign('moisDebutSemaine', $service->moisNumericToMoisLitteral(date('m', $lundi)));
     $tpl->assign('moisFinSemaine', $service->moisNumericToMoisLitteral(date('m', $dimanche)));
     $tpl->assign('semaine', $this->getParam('elementsSemaineAffichee')->numSemaine);
     $tpl->assign('annee', $this->getParam('elementsSemaineAffichee')->annee);
     //on vérifie si un agenda de classe est affiché
     //$lecon = false;
     $readLecon = false;
     $writeLecon = false;
     $idAgendaScolaire = null;
     $agendasAffiches = $this->getParam('agendasAffiches', null);
     foreach ($this->getParam('elementsSemaineAffichee')->agendas as $id_agenda) {
         if ($serviceAgenda->getTypeAgendaByIdAgenda($id_agenda) == $serviceType->getClassRoom()) {
             //on vérifie si l'utilisateur peut écrire des leçons
             if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getWriteLecon()) {
                 $writeLecon = true;
                 //$lecon = true;
                 $idAgendaScolaire = $id_agenda;
                 break;
             }
             //on vérifie si l'utilisateur peut lire les leçons
             if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getRead()) {
                 $readLecon = true;
                 //$lecon = true;
                 //$idAgendaScolaire = $id_agenda;
                 //break;
             }
         }
     }
     //on vérifie si l'utilisateur a les droits d'écriture sur un des agendas affichés
     $writeAgenda = false;
     $agendasAffiches = $this->getParam('agendasAffiches', null);
     foreach ($this->getParam('elementsSemaineAffichee')->agendas as $id_agenda) {
         if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getWriteAgenda()) {
             $writeAgenda = true;
             break;
         }
     }
     //on construit un tableau de droits pour chaque agenda affiché
     $arDroits = array();
     foreach ($this->getParam('elementsSemaineAffichee')->agendas as $id_agenda) {
         if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getRead()) {
             $arDroits[$id_agenda]->canRead = true;
         } else {
             $arDroits[$id_agenda]->canRead = false;
         }
         if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getWriteAgenda()) {
             $arDroits[$id_agenda]->canWrite = true;
         } else {
             $arDroits[$id_agenda]->canWrite = false;
         }
         if ($serviceAuth->getCapability($id_agenda) >= $serviceAuth->getModerate()) {
             $arDroits[$id_agenda]->canModerate = true;
         } else {
             $arDroits[$id_agenda]->canModerate = false;
         }
     }
     //on construit le tableau de couleurs associées au type d'agenda
     $arColorByIdAgenda = array();
     foreach ($this->getParam('elementsSemaineAffichee')->agendas as $id_agenda) {
         $arColor = $serviceType->getColors($serviceAgenda->getTypeAgendaByIdAgenda($id_agenda));
         $i = 0;
         foreach ($arColorByIdAgenda as $idAgenda => $couleurAgenda) {
             if ($arColorByIdAgenda[$idAgenda] == $arColor[$i]) {
                 $i = $i + 1;
             }
         }
         if ($i < count($arColor)) {
             $arColorByIdAgenda[$id_agenda] = $arColor[$i];
         } else {
             $arColorByIdAgenda[$id_agenda] = $arColor[0];
         }
     }
     $tpl->assign('arColorByIdAgenda', $arColorByIdAgenda);
     //on détermine l'heure de début et de fin pour l'affichage du calendrier
     $tpl->assign('heure_deb', $this->getParam('heureDeb'));
     $tpl->assign('heure_fin', $this->getParam('heureFin'));
     $tpl->assign('arEventByDay', $this->getParam('arEventByDay'));
     $tpl->assign('readLecon', $readLecon);
     $tpl->assign('writeLecon', $writeLecon);
     $tpl->assign('agendaScolaire', $idAgendaScolaire);
     $tpl->assign('arLecons', $this->getParam('arLecons'));
     $tpl->assign('arTravauxEnClasse', $this->getParam('arTravauxEnClasse'));
     $tpl->assign('arTravauxAFaire', $this->getParam('arTravauxAFaire'));
     $tpl->assign('agenda2cahier', $this->getParam('agenda2cahier'));
     $tpl->assign('writeAgenda', $writeAgenda);
     $tpl->assign('arDroits', $arDroits);
     $tpl->assign('todayJour', date('d'));
     $tpl->assign('todaySemaine', date('W'));
     $tpl->assign('todayAnnee', date('Y'));
     //paramètres pour passer d'une semaine à l'autre
     $tpl->assign('semaine_precedente', $service->dateToWeeknum(mktime(0, 0, 0, date('m', $lundi), date('d', $lundi) - 7, date('Y', $lundi))));
     $tpl->assign('semaine_suivante', $service->dateToWeeknum(mktime(0, 0, 0, date('m', $lundi), date('d', $lundi) + 7, date('Y', $lundi))));
     $tpl->assign('annee_precedente', date('Y', mktime(0, 0, 0, date('m', $lundi), date('d', $lundi) - 4, date('Y', $lundi))));
     $tpl->assign('annee_suivante', date('Y', mktime(0, 0, 0, date('m', $lundi), date('d', $lundi) + 10, date('Y', $lundi))));
     $listAgendas = $this->getParam('listAgendas', null);
     $tpl->assign('listAgendas', $listAgendas);
     $toReturn = $tpl->fetch('vuesemaine.agenda.ptpl');
     return true;
 }
コード例 #8
0
 /**
  * Renvoie le menu des agendas
  * @author Christophe Beyer <*****@*****.**>
  * @since 2010/10/20
  * @param string $iCurrent Onglet a allumer
  * @return array Tableau du menu a afficher
  */
 public function getAgendaMenu($iCurrent)
 {
     $menu = array();
     // Affichage hebdomadaire
     $menu_txt = CopixI18N::get('agenda.menu.back');
     $menu_type = 'week';
     $menu_url = CopixUrl::get('agenda|agenda|vueSemaine');
     $menu[] = array('txt' => $menu_txt, 'type' => $menu_type, 'current' => $iCurrent == $menu_type, 'url' => $menu_url);
     // Liste des agendas (popup)
     $menu_txt = CopixI18N::get('agenda|agenda.menu.agendalist');
     $menu_type = 'agendalist';
     $menu_behavior = 'fancybox';
     $menu_url = CopixUrl::get('agenda|agenda|agendaList');
     $menu[] = array('txt' => $menu_txt, 'type' => $menu_type, 'current' => $iCurrent == $menu_type, 'behavior' => $menu_behavior, 'url' => $menu_url);
     // Nouvel evenement
     $listAgendasAffiches = AgendaService::getAgendaAffiches();
     $ableToWrite = false;
     $ableToModerate = false;
     //on vérifie les droits des utilisateurs sur la liste des agendas affichés
     foreach ((array) $listAgendasAffiches as $id_agenda) {
         //on vérifie si l'utilisateur a les droits d'écriture sur un des agendas affiché
         if (AgendaAuth::getCapability($id_agenda) >= AgendaAuth::getWriteAgenda()) {
             $ableToWrite = true;
         }
         if (AgendaAuth::getCapability($id_agenda) >= AgendaAuth::getModerate()) {
             $ableToModerate = true;
         }
     }
     if ($ableToWrite) {
         $menu_txt = CopixI18N::get('agenda.menu.ajoutEvent');
         $menu_type = 'create';
         $menu_url = CopixUrl::get('agenda|event|create');
         $menu[] = array('txt' => $menu_txt, 'type' => $menu_type, 'current' => $iCurrent == $menu_type, 'url' => $menu_url);
     }
     if ($ableToModerate) {
         $menu_txt = CopixI18N::get('agenda.menu.import');
         $menu_type = 'import';
         $menu_url = CopixUrl::get('agenda|importexport|prepareImport');
         $menu[] = array('txt' => $menu_txt, 'type' => $menu_type, 'current' => $iCurrent == $menu_type, 'url' => $menu_url);
     }
     // Export
     $menu_txt = CopixI18N::get('agenda.menu.export');
     $menu_type = 'export';
     $menu_url = CopixUrl::get('agenda|importexport|prepareExport');
     $menu[] = array('txt' => $menu_txt, 'type' => $menu_type, 'current' => $iCurrent == $menu_type, 'url' => $menu_url);
     return $menu;
 }