/** * Récupération de tous les agendas en base de données * @author Audrey Vassal <*****@*****.**> * @since 2006/07/24 * @return array tableau d'objet agenda */ public function getAvailableAgenda() { //var_dump($_SESSION); if (!_sessionGet('modules|agenda|his')) { $serviceAuth = new AgendaAuth(); $res = array(); $ags = array(); // 1. Son agenda perso $userInfo = Kernel::getUserInfo(); // Création des modules inexistants. Kernel::createMissingModules($userInfo["type"], $userInfo["id"]); // Liste des modules activés. $modsList = Kernel::getModEnabled($userInfo["type"], $userInfo["id"]); foreach ($modsList as $modInfo) { if ($modInfo->module_type == "MOD_AGENDA" && $modInfo->module_id) { $ags[] = $modInfo->module_id; } } // 2. Ceux de sa classe, son école, ses groupes... $mynodes = Kernel::getNodes(); foreach ($mynodes as $nodes) { foreach ($nodes as $node) { //print_r($node); if (substr($node['type'], 0, 5) == 'USER_') { continue; } $modules = Kernel::getModEnabled($node['type'], $node['id']); $agenda = Kernel::filterModuleList($modules, 'MOD_AGENDA'); if ($agenda && $serviceAuth->getCapability($agenda[0]->module_id) >= $serviceAuth->getRead()) { $ags[] = $agenda[0]->module_id; } } } //print_r($ags); $daoAgenda =& CopixDAOFactory::getInstanceOf('agenda|agenda'); $agendas = $daoAgenda->findAgendasInIds($ags); foreach ($agendas as $agenda) { $tmp = new stdClass(); $tmp->id_agenda = $agenda->id_agenda; $tmp->title_agenda = $agenda->title_agenda; $tmp->desc_agenda = $agenda->desc_agenda; $tmp->type_agenda = $agenda->type_agenda; /* $tmp = array ( 'id_agenda' => $agenda->id_agenda, 'title_agenda' => $agenda->title_agenda, 'desc_agenda' => $agenda->desc_agenda, 'type_agenda' => $agenda->type_agenda, ); */ $res[] = $tmp; } //die(); //$sess = $daoAgenda->findAll (); _sessionSet('modules|agenda|his', serialize($res)); } return unserialize(_sessionGet('modules|agenda|his')); }
/** * Retourne le niveau de droit de la personne connectée * @param integer $idAgenda l'identifiant de l'agenda */ public function getCapability($idAgenda) { if (!$idAgenda) { return 0; } if (!($d = _sessionGet('modules|agenda|rights|' . $idAgenda))) { $d = Kernel::getModRight('MOD_AGENDA', $idAgenda); _sessionSet('modules|agenda|rights|' . $idAgenda, $d); } if ($d >= PROFILE_CCV_MEMBER) { $res = AgendaAuth::getModerate(); } elseif ($d >= PROFILE_CCV_READ) { $res = AgendaAuth::getRead(); } else { $res = AgendaAuth::getNone(); } //print_r ("idAgenda=$idAgenda / res=$res<br>"); return $res; }
public function _createContent(&$toReturn) { $serviceAuth = new AgendaAuth(); $tpl = new CopixTpl(); //gestion des erreurs if ($this->getParam('e') == 1) { $tpl->assign('showError', $this->getParam('e')); } $tpl->assign('arError', $this->getParam('errors')); $tpl->assign('exportParams', $this->getParam('exportParams')); //vérification des droits d'écriture sur les agendas $listeFiltre = $this->getParam('arTitleAgendasAffiches'); //on vérifie les droits de lecture des utilisateurs foreach ((array) $listeFiltre as $key => $title_agenda) { //on vérifie si l'utilisateur a les droits de lecture sur la liste des agendas if ($serviceAuth->getCapability($key) < $serviceAuth->getRead()) { unset($listeFiltre[$key]); } } $tpl->assign('arTitleAgendasAffiches', $listeFiltre); $toReturn = $tpl->fetch('export.agenda.tpl'); return true; }
/** * 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'))); }
/** * 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')); }
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; }