* * Plugin Schedule: manage events per wiki @groups // TODO : // passer des actions suivant langue en actions neutres // selection automatique de cantons suivant lieu si existe le canton existe // radius dans conf puis select */ if (!defined ('DOKU_INC')) define ('DOKU_INC', realpath (dirname (__FILE__).'/../../../').'/'); if (!defined ('DOKU_PLUGIN')) define ('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); require_once (realpath (dirname (__FILE__)).'/scheduleInseeCities.php'); // ============================================================ // management event class class schedules { // ============================================================ // Config attributs // ============================================================ var $scheduleRoot; // commun data for all schedules var $nameSpace; // namespace where definition could be found var $lastNotification; // time of last proposal notification var $lastNotificationReset; // time of last administrators acknowledgement var $md5ns; // the ns directory var $cacheDir; // cache directory var $dataDir; // schedule database var $migrate; // performe data migration var $showOldValues; // highlight non migrate data // ============================================================ // Transcient attributs // ============================================================ var $allGroups = array (); // dynamique set of groups name var $allSchedules = array (); // set of all events var $memberSchedules = array (); // set of events indexed by member var $repeatedSchedules = array (); // set of repeated events indexed by date var $fixedSchedules = array (); // set of non repeated events indexed by date var $datedSchedules = array (); // set of repeated or not events indexed by date var $membersToSave = array (); // set of modified members var $allProposals = array (); // set of all proposals var $proposalsToSave = false; // modified proposals var $printProp = false; // display proposal event form var $printForm = false; // display add event form var $printCtrl = false; // display action event form var $isShow = false; // date focus flag mode var $userGroups = array (); // set of user group wich are schedule groupe var $defaultSchedule; // empty schedule model var $before; // before filter date var $date; // exact filter date var $after; // after filter date var $max; // max events lines var $filters; // ============================================================ // Util // ============================================================ function getConf ($name) { return $this->scheduleRoot->plugin->getConf ($name); } function getLang ($name) { return $this->scheduleRoot->plugin->getLang ($name); } function isAdmin () { return $this->scheduleRoot->isAdmin; } function message ($type, $text) { return $this->scheduleRoot->message ($type, $text); } function startMessage ($type, $text) { return $this->scheduleRoot->startMessage ($type, $text); } function debug ($text) { return $this->scheduleRoot->debug ($text); } function isMessage ($type) { return isset ($this->scheduleRoot->message[$type]); } // ============================================================ function __construct ($scheduleRoot, $ns) { $this->scheduleRoot = $scheduleRoot; $this->defaultSchedule = new schedule (); $this->nameSpace = cleanId (trim ($ns)); $this->md5ns = md5 ($this->nameSpace); $this->cacheDir = $this->scheduleRoot->cacheRootDir.$this->md5ns.'/'; $this->dataDir = $this->scheduleRoot->dataRootDir.$this->md5ns.'/'; $this->migrate = $this->getConf ('migrate'); $this->showOldValues = $this->getConf ('showOldValues'); if ($this->migrate) { global $scheduleInseeCities, $scheduleCitiesInsee; $scheduleCitiesInsee = array (); foreach ($scheduleInseeCities as $insee => $cityDef) $scheduleCitiesInsee [strtolower ($cityDef[0])] = $insee; } $config = $this->scheduleRoot->readConfig ($this->dataDir); if (!$config) $this->scheduleRoot->writeConfig ($this); else foreach ($this->scheduleRoot->configAttributsName as $field) if (isset ($config [$field])) $this->$field = $config [$field]; } /** XXX utilisé par scheduleRoot ?! */ function load () { $exclude_array = explode ('|', '.|..'); global $conf; $pathDir = $conf['savedir'].'/pages/'.trim ($this->scheduleRoot->groupsDir, '/') . '/'; if (is_dir($pathDir)) { $pathDirObj = opendir ($pathDir); while (false !== ($file = readdir ($pathDirObj))) { if (in_array (strtolower ($file), $exclude_array)) continue; $pathFile = $pathDir . $file; // XXX precedent se trouve dans les membres ??? if (is_dir ($pathFile) && !in_array ($file, explode (',', trim ($this->getConf ('noSchedule'))))) $this->allGroups [] = $file; } } sort ($this->allGroups); global $INFO; if (isset ($INFO ['userinfo']) && isset ($INFO ['userinfo']['grps'])) { $userGroups = array (); $scheduleGroup = false; foreach ($INFO['userinfo']['grps'] as $tmpMember) { $tmpMember = trim ($tmpMember); if ($this->scheduleRoot->scheduleGroup == $tmpMember) $scheduleGroup = true; if (in_array ($tmpMember, $this->allGroups)) $userGroups [] = $tmpMember; } if ($scheduleGroup) $this->userGroups = $userGroups; } $this->readSchedules ($this->dataDir); $this->readProp (); } function isMember ($member) { return $this->isAdmin () || in_array ($member, $this->userGroups); } function isAMemberOf ($members) { if ($this->isAdmin ()) return true; foreach ($members as $member) if (in_array ($member, $this->userGroups)) return true; return false; } function isMemberOfAll ($members) { if ($this->isAdmin ()) return true; foreach ($members as $member) if (!in_array ($member, $this->userGroups)) return false; return true; } // ============================================================ function readCache ($key) { if (!is_dir ($this->cacheDir)) return false; $filename = $this->cacheDir.md5 ($key).'.cache'; if (!file_exists ($filename)) return false; // YYY date du fichier (le calendrier change tous les jours) if (filemtime ($filename) < strtotime ('today')) return false; // XXX ??? Warning: file_get_contents() [function.file-get-contents]: failed to open stream: No such file or directory in on line 153 return file_get_contents ($filename); } function writeCache ($key, $text) { scheduleRoot::createDirIsNeeded ($this->cacheDir); $filename = $this->cacheDir.md5 ($key).'.cache'; file_put_contents ($filename, $text); } function clearCache () { if (!$this->isAdmin ()) return; $exclude = '.|..|'.$this->scheduleRoot->configFile; $exclude_array = explode('|', $exclude); $pathDir = $this->cacheDir; if (!is_dir($pathDir)) return; $pathDirObj = opendir ($pathDir); while (false !== ($file = readdir ($pathDirObj))) { if (in_array (strtolower ($file), $exclude_array)) continue; $pathFile = $pathDir . $file; if (is_file ($pathFile) && preg_match ('#.*\.cache#i', $file, $b)) unlink ($pathFile); } @rmdir ($pathDir); } // ============================================================ function setDateFilters ($before, $date, $after) { $this->before = $this->scheduleRoot->df2ds ($before); $this->after = $this->scheduleRoot->df2ds ($after); $this->date = $this->scheduleRoot->df2ds ($date); if ($this->date) $this->before = $this->after = $this->date; } // ============================================================ function setFormLevel ($formLevel) { global $INFO; if ($formLevel > 2) $this->printProp = true; if (($formLevel > 0) && isset ($INFO ['userinfo']) && isset ($INFO ['userinfo']['grps'])) foreach ($INFO['userinfo']['grps'] as $tmpMember) { $tmpMember = trim ($tmpMember); if ($this->scheduleRoot->scheduleGroup == $tmpMember) { if ($formLevel > 1) $this->printForm = true; $this->printCtrl = true; $this->printProp = false; break; } } } // ============================================================ function setOtherFilters ($max, $filters, $grouped) { $this->max = $max; foreach ($filters as $name => $values) { $newValues = array (); foreach (explode (',', $values) as $value) { $value = trim ($value); if (! empty ($value)) $newValues [] = $value; } if (!empty ($newValues)) $this->filters[$name] = $newValues; } $this->repeatGrouped = trim ($this->getConf ('repeatPosition')) == 'grouped'; $grouped = trim ($grouped); if (in_array ($grouped, array ('grouped', 'isolated'))) $this->repeatGrouped = $grouped == 'grouped'; } // ============================================================ // Manage XML file // ============================================================ /* Save a member data base */ function writeSchedule ($member) { $xml = new DOMDocument ('1.0', 'utf8'); $root = $xml->createElement ('schedule'); $root->setAttribute ('member', $member); $xml->appendChild ($root); foreach ($this->memberSchedules [$member] as $id => $schedule) { $event = $xml->createElement ('event'); foreach ($this->scheduleRoot->scheduleSaveAttributsName as $field) $event->appendChild ($xml->createElement ($field, htmlspecialchars ($schedule->$field))); $root->appendChild ($event); } $xml->formatOutput = true; $fileName = $this->dataDir.$this->scheduleRoot->mbrPrefix.$member.'.xml'; $xml->save ($fileName); chmod ($fileName, 0664); } function readProp () { $this->readSchedule ($this->dataDir.$this->scheduleRoot->propFile, true); } function writeProp () { // if (! class_exists ('DOMDocument')) // return; $xml = new DOMDocument ('1.0', 'utf8'); $root = $xml->createElement ('schedule'); $root->setAttribute ('member', 'proposal'); $xml->appendChild ($root); foreach ($this->allProposals as $id => $schedule) { $event = $xml->createElement ('event'); foreach ($this->scheduleRoot->scheduleSaveAttributsName as $field) $event->appendChild ($xml->createElement ($field, htmlspecialchars ($schedule->$field))); $event->appendChild ($xml->createElement ('member', htmlspecialchars ($schedule->member))); $root->appendChild ($event); } $xml->formatOutput = true; $fileName = $this->dataDir.$this->scheduleRoot->propFile; $xml->save ($fileName); chmod ($fileName, 0664); } /* Migrate where format */ function whereMigrate ($schedule, $sep) { global $scheduleCitiesInsee; if (!$schedule) return false; if (preg_match ('/[0-9]/', $schedule->where)) { return false; } $newFields = array (); $updated = false; foreach (explode ($sep, $schedule->where) as $city) { $city = trim ($city); if (!$city) continue; $insee = $scheduleCitiesInsee [strtolower ($city)]; $newFields [] = $insee ? $insee : $city; if ($insee) $updated = true; } $newWhere = implode (',', $newFields); if (!$newWhere || !$updated) return false; $schedule->where = $newWhere; return true; } /* Read a member data base */ function readSchedule ($file, $prop = false) { if (!file_exists ($file)) return; // if (! class_exists ('DOMDocument')) // return; $xml = new DOMDocument ('1.0', 'utf8'); $xml->load ($file); $root = $xml->documentElement; $member = $root->getAttribute ('member'); $events = $root->getElementsByTagName ('event'); for ($i = $events->length; --$i >= 0; ) { $event = $events->item ($i); $schedule = new schedule (); foreach ($this->scheduleRoot->scheduleSaveAttributsName as $field) { $element = $event->getElementsByTagName ($field); if ($element) $schedule->$field = $element->item (0)->nodeValue; } if ($prop) { $element = $event->getElementsByTagName ('member'); if ($element) $schedule->member = $element->item (0)->nodeValue; } else $schedule->member = $member; if ($this->migrate && !$prop && ($this->whereMigrate ($schedule, ',') || $this->whereMigrate ($schedule, '/') || $this->whereMigrate ($schedule, ' - ') || $this->whereMigrate ($schedule, ' '))) $this->membersToSave [$member] = true; // XXX compatibilité $schedule->shared = ($schedule->shared == true); $schedule->repeatFlag = $schedule->to != '' && $schedule->from != $schedule->to; if ($prop) $this->allProposals [$schedule->id] = $schedule; else $this->allSchedules [$schedule->id] = $schedule; } } // ============================================================ // IO functions // ============================================================ /* Read all member data base */ function readSchedules ($pathDir) { $exclude = '.|..|'.$this->scheduleRoot->configFile; $exclude_array = explode('|', $exclude); $pathDir = rtrim ($pathDir, '/') . '/'; if (!is_dir($pathDir)) return; $pathDirObj = opendir ($pathDir); while (false !== ($file = readdir ($pathDirObj))) { if (in_array (strtolower ($file), $exclude_array)) continue; $pathFile = $pathDir . $file; if (is_file ($pathFile) && preg_match ('#'.$this->scheduleRoot->mbrPrefix.'.*\.xml$#i', $file, $b)) $this->readSchedule ($pathFile); } $this->updateSchedulesLists (); } // ============================================================ /* Save all member data base marked as modified */ function writeSchedules () { if (!count ($this->membersToSave)) return; foreach (array_keys ($this->membersToSave) as $member) if (count ($this->memberSchedules [$member]) <= 0) @unlink ($this->dataDir.$this->scheduleRoot->mbrPrefix.$member.'.xml'); else $this->writeSchedule ($member); $this->clearCache (); } // ============================================================ // YYY // ============================================================ /* get all siblings shared events but the pattern */ function getOtherSharedEvents ($event) { $result = array (); if (!$event->from) return $result; foreach ($this->datedSchedules [$event->from] as $other) if ($event->shared == $other->shared && $event->to == $other->to && $event->at == $other->at && $event->title == $other->title && $event->id != $other->id) $result [] = $other; return $result; } // ============================================================ /* XXX */ function getMembersSharedEvents ($event) { if (!$event->shared || !$event->from || !$event->title) return $event->requestMembers ? $event->requestMembers : array ($event->member); $result = array (); foreach ($this->datedSchedules [$event->from] as $other) if ($event->shared == $other->shared && $event->to == $other->to && $event->at == $other->at && $event->title == $other->title) $result [] = $other->member; return $result; } // ============================================================ /* Performe action */ function manageAction ($request) { if ($request['action'] == $this->getLang ('show')) { $this->isShow = true; if (isset ($request['date'])) { $this->before = $this->after = $this->date = $this->scheduleRoot->df2ds ($request['date']); } } elseif ($request['action'] == $this->getLang ('selected')) { if (isset ($request['id'])) { $id = $request['id']; if (isset ($this->allProposals [$id])) { $this->defaultSchedule = $this->allProposals [$id]; $this->defaultSchedule->prop = true; } else if (isset ($this->allSchedules [$id])) { $this->defaultSchedule = $this->allSchedules [$id]; } } } elseif (in_array ($request['action'], array ($this->getLang ('modifyAll'), $this->getLang ('modify'), $this->getLang ('add'), $this->getLang ('valid'), $this->getLang ('prop')))) { if (isset ($request['id'])) $id = $request['id']; $this->manageAddAction ($request); if ($request['action'] == $this->getLang ('valid')) $this->removeSchedule ($id); } elseif ($request['action'] == $this->getLang ('remove')) { if (isset ($request['idl'])) foreach ($request['idl'] as $id) $this->removeSchedule ($id); unset ($_REQUEST['schd']); } elseif ($request['action'] == $this->getLang ('created')) $this->manageCreateAction ($request); } // ============================================================ function manageAddAction ($request) { if (isset ($request['id'])) $id = $request['id']; $schedule = new schedule (); $others = array (); $oldMember = ''; if (isset ($this->allSchedules [$id]) && ($request['action'] == $this->getLang ('modifyAll') || $request['action'] == $this->getLang ('modify'))) { $schedule = &$this->allSchedules [$id]; $oldMember = $schedule->member; if ($request['action'] == $this->getLang ('modifyAll')) $others = $this->getOtherSharedEvents ($schedule); } foreach ($this->scheduleRoot->scheduleRequestAttributsName as $field) $schedule->$field = trim (str_replace (array ('"'), '', $request [$field])); if ($request ['member']) { $schedule->requestMembers = explode (',', trim (str_replace (',,', ',', $request ['member']), ',')); $schedule->member = trim ($schedule->requestMembers [0]); } $schedule->title = strtr ($schedule->title, '"', "''"); $schedule->lead = strtr ($schedule->lead, '"', "''"); $schedule->remark = strtr ($schedule->remark, '"', "''"); $schedule->weekDays = scheduleRoot::array2string ($request ['weekDays']); $schedule->from = $this->scheduleRoot->df2ds ($request ['from']); $schedule->to = $this->scheduleRoot->df2ds ($request ['to']); if ('' == $schedule->from) { $schedule->from = $schedule->to; $schedule->to = ''; } if ($schedule->from == $schedule->to) $schedule->to = ''; if ('' == $schedule->from && '' == $schedule->where && '' == $schedule->title) { $this->defaultSchedule = $schedule; unset ($_REQUEST['schd']); return; } if (!$this->printProp && $schedule->member && !$this->isMemberOfAll ($schedule->requestMembers)) { $this->message ('info', $this->getLang ('notMemberError')); $this->defaultSchedule = $schedule; unset ($_REQUEST['schd']); return; } if (!$request ['audience']) $this->message ('error', $this->getLang ('noAudienceError')); if (!$schedule->member) $this->message ('error', $this->getLang ('noMemberError')); if ('' == $schedule->what) $this->message ('error', $this->getLang ('noTypeError')); if ('' == $schedule->title) $this->message ('error', $this->getLang ('noTitleError')); if ('' == $schedule->where) $this->message ('error', $this->getLang ('noWhereError')); if (!$this->scheduleRoot->checkDS ($schedule->from)) $this->message ('error', $request ['from'].' : '.$this->getLang ('badDateError')); if ($schedule->to && !$this->scheduleRoot->checkDS ($schedule->to)) $this->message ('error', $request ['to'].' : '.$this->getLang ('badDateError')); else if ($this->after && ($schedule->to ? $schedule->to : $schedule->from) < $this->after) $this->message ('error', $request ['from'].' : '.$this->getLang ('pastError')); else if ($schedule->to != '' && $schedule->from > $schedule->to) $this->message ('error', $request ['to'].' : '.$this->getLang ('pastToError')); if ($this->isMessage ('error')) { $this->startMessage ('error', $this->getLang ('startError')); $this->defaultSchedule = $schedule; unset ($_REQUEST['schd']); return; } $schedule->repeatFlag = $schedule->to != '' && $schedule->from != $schedule->to; // force un nouvel id, member et file if (!$schedule->id || in_array ($request['action'], array ($this->getLang ('add'), $this->getLang ('valid'), $this->getLang ('prop')))) $schedule->id = date ('Ymdhis.0'); if ($this->printProp) { unset ($_REQUEST['schd']); if (!$captcha =& plugin_load ('helper', 'captcha') || !$captcha->check ()) { $this->defaultSchedule = $schedule; return; } $schedule->member = implode (',', $schedule->requestMembers); $this->allProposals [] = $schedule; $this->proposalsToSave = true; $this->adminNotification (); $this->message ('success', $this->getLang ('propSuccess')); return; } if ($oldMember) $this->membersToSave [$oldMember] = true; global $INFO; $schedule->user = $_SERVER['REMOTE_USER']; $this->addSchedule ($schedule); unset ($_REQUEST['schd']); foreach ($others as $other) { if (!$this->isMember ($others->member)) continue; foreach ($this->scheduleRoot->scheduleSaveAttributsName as $field) if ($field != 'id') $other->$field = $schedule->$field; $this->membersToSave [$other->member] = true; } $sharedMembers = $this->getMembersSharedEvents ($schedule); $i = 1; foreach ($schedule->requestMembers as $newMember) { $newMember = trim ($newMember); if (!$newMember || in_array ($newMember, $sharedMembers)) continue; if (!$this->isMember ($newMember)) continue; $newSchedule = new schedule (); foreach ($this->scheduleRoot->scheduleSaveAttributsName as $field) $newSchedule->$field = $schedule->$field; $newSchedule->id = date ('Ymdhis').$i; $i++; $newSchedule->member = $newMember; $this->addSchedule ($newSchedule); } $pageId = $this->scheduleRoot->getPageId ($schedule); resolve_pageid ($this->nameSpace, $pageId, $exists); if (!$exists) return; $content = io_readFile (wikiFN ($pageId)); $start = ""; $option = ""; $end = $content; $place = trim ($this->makeListPlaceForMap ($schedule)); if (preg_match ("#(?(.|\n)*)[^>]*)>(?([^<]|\n)*)(?(.|\n)*)#", $content, $dumy)) { $start = $dumy ['start']; $option = $dumy ['option']; $place2 = trim ($dumy ['place']); $end = $dumy ['end']; if ($place == $place2) return; } else if (preg_match ("#(?(.|\n)*=+ Lieu =+\n)(?([^=]|=[^=]|\n)*)(?\n=(.|\n)*)#", $content, $dumy)) { $start = $dumy ['start'].NL; $end = $dumy ['end']; } else { $start = '===== Lieu ====='.NL.NL; $end = $content; } $content = $start.''.NL.$place.NL.''.NL.$end; saveWikiText ($pageId, $content, 'update place'); } // ============================================================ function manageCreateAction ($request) { $id = $request['id']; $pageId = $request ['pageId']; resolve_pageid ($this->nameSpace, $pageId, $exists); if (!$exists && isset ($this->allSchedules [$id])) { $schedule = $this->allSchedules [$id]; $sharedMembers = $this->getMembersSharedEvents ($schedule); // XXX mettre date, lieu, sujet, tarif dans langue $content = ''; foreach ($sharedMembers as $member) $content .= '[[:'.$this->scheduleRoot->groupsDir.':'.$member.':|'. '{{ :'.$this->scheduleRoot->groupsDir.':'.$member.':'.$this->scheduleRoot->iconName.'?100}}]]'.NL; $content .= '~~NOTOC~~'.NL. '====== '.$schedule->title.' ======'.NL.NL; if ($schedule->lead) $content .= str_replace ("''", '"', $schedule->lead).NL.NL; $content .= '===== Date ====='.NL.NL. ($schedule->repeatFlag ? $this->makeRepeatString ($schedule, true) : ('Le '. $this->scheduleRoot->ds2ln ($schedule->from, true))). $this->makePrettyAt ($schedule->at).NL.NL. '===== Lieu ====='.NL.NL. ''.NL. $this->makeListPlaceForMap ($schedule). ''.NL.NL. '===== Sujet ====='.NL.NL; if (!$schedule->remark) $content .= 'Sujet à préciser'.NL.NL; if ($schedule->posterURL) $content .= '{{ '.$schedule->posterURL.'?direct&200|}}'.NL; if ($schedule->paperURL) $content .= '[['.$schedule->paperURL.' |]]'.NL; if ($schedule->remark) $content .= str_replace ("''", '"', $schedule->remark).NL.NL; if ($schedule->rate) $content .= '===== Tarif ====='.NL.NL. $schedule->rate.NL; saveWikiText ($pageId, $content, 'wizard creation'); $this->clearCache (); } unset ($_REQUEST['schd']); } // ============================================================ /* Add event */ function addSchedule (&$schedule) { if (isset ($this->allSchedules [$schedule->id])) unset ($this->allSchedules [$schedule->id]); $this->membersToSave [$schedule->member] = true; // élimine les doublons if (isset ($this->memberSchedules [$schedule->member])) foreach ($this->memberSchedules [$schedule->member] as $event) if ($event->from == $schedule->from && $event->to == $schedule->to && $event->at == $schedule->at && $event->shared == $schedule->shared && $event->title == $schedule->title && $event->id != $schedule->id) { unset ($this->allSchedules [$event->id]); } $this->allSchedules [$schedule->id] = $schedule; $this->updateSchedulesLists (); } // ============================================================ /* Remove event */ function removeSchedule ($id) { if (isset ($this->allProposals [$id])) { $this->proposalsToSave = true; unset ($this->allProposals [$id]); $this->resetAdminNotification (); } else if (isset ($this->allSchedules [$id])) { $this->membersToSave [$this->allSchedules [$id]->member] = true; unset ($this->allSchedules [$id]); $this->updateSchedulesLists (); } } // ============================================================ /* Update data base memory indexes after modification */ function updateSchedulesLists () { $this->memberSchedules = array (); $this->repeatedSchedules = array (); $this->fixedSchedules = array (); $this->datedSchedules = array (); foreach ($this->allSchedules as $id => $schedule) { $this->memberSchedules [$schedule->member][$id] = $schedule; $this->datedSchedules [$schedule->from][] = $schedule; if ($schedule->repeatFlag) $this->repeatedSchedules [$schedule->from][] = $schedule; else $this->fixedSchedules [$schedule->from][] = $schedule; } foreach (array_keys ($this->memberSchedules) as $member) uasort ($this->memberSchedules [$member], 'cmpSchedule'); uasort ($this->allSchedules, 'cmpSchedule'); } // ============================================================ /* Print schedule as a matrix of days */ function printScheduleCalendar ($mapId, $dn_showDay) { $nbDaysPerWeek = 7; $nbWeeks = 5; $nbDays = $nbDaysPerWeek * $nbWeeks; $dn_today = mktime (0, 0, 0, date ('n'), date ('j'), date ('Y')); $dn_start = mktime (0, 0, 0, date ('m', $dn_showDay), date ('d', $dn_showDay)-date ('w', $dn_showDay), date ('Y', $dn_showDay)); $dn_end = $dn_start + $nbDays * 86400; $ds_start = date ('Ymd', $dn_start); $ds_end = date ('Ymd', $dn_end); $dn_prev = mktime (0, 0, 0, date ('m', $dn_showDay)-1, date ('d', $dn_showDay), date ('Y', $dn_showDay)); $dn_next = mktime (0, 0, 0, date ('m', $dn_showDay)+1, date ('d', $dn_showDay), date ('Y', $dn_showDay)); $df_prev = date ($this->scheduleRoot->currentDateFormat['prettyPrint'], $dn_prev); $df_next = date ($this->scheduleRoot->currentDateFormat['prettyPrint'], $dn_next); $dayNames = $this->getLang ('days'); ptln (''.NL. ' '.NL. ' '); if ($dayNames) foreach ($dayNames as $dayName => $dayAbrv) echo ''; ptln (' '.NL. ' '); $focusSchedules = array (); $dn_day = $dn_start; // copie des évènements non répété (à part quotidient) for ($i = 0; $i < $nbDays; $i++) { $ds_index = date ('Ymd', $dn_day); if (isset ($this->fixedSchedules [$ds_index])) $focusSchedules [$ds_index] = array_values ($this->fixedSchedules [$ds_index]); $dn_day = mktime(0, 0, 0, date ('m', $dn_day) , date ('d', $dn_day)+1, date ('Y', $dn_day)); } // extends repeated events foreach ($this->repeatedSchedules as $ds_index => $events) { foreach ($events as $event) { if ($event->from >= $ds_end) continue; if ($event->to < $ds_start) continue; preg_match ("#(?[0-9]{4})(?[0-9]{2})(?[0-9]{2})#", $event->from, $dt_from); $dn_from = $this->scheduleRoot->dt2dn ($dt_from); if ($event->to > $ds_end) $dn_to = $dn_end; else { preg_match ("#(?[0-9]{4})(?[0-9]{2})(?[0-9]{2})#", $event->to, $dt_to); $dn_to = $this->scheduleRoot->dt2dn ($dt_to); } switch ($event->repeatType) { // chercher le premier dans la fenêtre // tant que dans la fenêtre répété la répétition // ajouter l'évènement dans les autres case 'day' : // répétition des évènements quotidients $dn_day = $dn_from; $step = 86400 * $event->repeat; if ($dn_from < $dn_start) $dn_day += ceil (($dn_start - $dn_from) / $step) * $step; for ( ; $dn_day <= $dn_to; $dn_day += $step) $focusSchedules [date ('Ymd', $dn_day)][] = $event; break; case 'week' : $dn_startWeek = mktime (0, 0, 0, date ('m', $dn_from), date ('d', $dn_from) - date ('w', $dn_from), date ('Y', $dn_from)); $step = 86400 * 7 * $event->repeat; if ($dn_startWeek < $dn_start) $dn_startWeek += floor (($dn_start - $dn_startWeek) / $step) * $step; for ( ; $dn_startWeek <= $dn_to; $dn_startWeek += $step) foreach (explode ('|', $event->weekDays) as $idd) { $dn_day = $dn_startWeek + $idd * 86400; if ($dn_day >= $dn_start && $dn_day >= $dn_from && $dn_day <= $dn_to) $focusSchedules [date ('Ymd', $dn_day)][] = $event; } break; case 'dayMonth' : case 'dateMonth' : $dn_startMonth = mktime (0, 0, 0, date ('m', $dn_from), 1, date ('Y', $dn_from)); if ($dn_startMonth < $dn_start) { $nbMonth = floor ((date ('m', $dn_start) + date ('Y', $dn_start)*12 - (date ('m', $dn_from) + date ('Y', $dn_from)*12))/$event->repeat)*$event->repeat; $dn_startMonth = mktime (0, 0, 0, date ('m', $dn_startMonth) + $nbMonth, 1, date ('Y', $dn_startMonth)); } for ( ; $dn_startMonth <= $dn_to; $dn_startMonth = mktime (0, 0, 0, date ('m', $dn_startMonth) + $event->repeat, 1, date ('Y', $dn_startMonth))) { $dn_day = $dn_startMonth; if ($event->repeatType == 'dateMonth') // XXX pb si moins de jour dans le mois $dn_day = mktime (0, 0, 0, date ('m', $dn_startMonth), $event->dayRank, date ('Y', $dn_startMonth)); else { $delta = $event->dayInWeek - date ('w', $dn_startMonth); if ($delta < 0) $delta += 7; $delta += 7 * $event->weekRank; // XXX pb si moins de jour dans le mois $dn_day = mktime (0, 0, 0, date ('m', $dn_startMonth), $delta+1, date ('Y', $dn_startMonth)); } if ($dn_day >= $dn_start && $dn_day >= $dn_from && $dn_day <= $dn_to) $focusSchedules [date ('Ymd', $dn_day)][] = $event; } break; case 'year' : $dayInmonth = date ('j', $dn_from); $monthInYear = date ('n', $dn_from); $startYear = date ('Y', $dn_start) - (date ('Y', $dn_start) - date ('Y', $dn_from)) % $event->repeat; $endYear = date ('Y', $dn_end); for ( ; $startYear <= $endYear; $startYear += $event->repeat) { $dn_day = mktime (0, 0, 0, $monthInYear, $dayInmonth, $startYear); if ($dn_day >= $dn_start && $dn_day >= $dn_from && $dn_day <= $dn_to) $focusSchedules [date ('Ymd', $dn_day)][] = $event; } break; } } } global $conf; $dn_day = $dn_start; $allLocations = ''; $LocationsEvents = array (); for ($s = 0; $s < 5; $s++) { $line = ''; for ($d = 0; $d < 7; $d++) { $locations = ''; $df_day = date ($this->scheduleRoot->currentDateFormat['prettyPrint'], $dn_day); $url = "javascript:scheduleSelectDate('".$df_day."');"; $bubble = ''; if ($d == 1) $w = date ('W', $dn_day); $class = 'day showBubbleOnFocus'; $dayRank = date ('d', $dn_day); $eventClass = ''; if (isset ($focusSchedules [date ('Ymd', $dn_day)])) { $eventClass = array (); $nbEvent = 0; $dayEvents = array (); foreach ($focusSchedules [date ('Ymd', $dn_day)] as $event) { $eventClass [preg_replace ("/\s/", '', htmlspecialchars (strtolower ($this->scheduleRoot->scheduleWhat [$event->what])))] = true; $nbEvent++; list ($LocationsEvents, $dayEvents, $locations) = $this->addLocationsDayEvent ($LocationsEvents, $dayEvents, $locations, $dn_day, $event); } $bubble = $this->getDayBubble ($dn_day, $dayEvents); ksort ($eventClass); $eventClass = 'cat_'.implode ('', array_keys ($eventClass)); $url = '?id='.$this->nameSpace.':'.$conf['start'].'&schd[ns]='.$this->nameSpace.'&schd[action]='.$this->getLang ('show').'&schd[date]='.$df_day; $class .= ' '.$eventClass; $class .= ' op_'.($nbEvent < 2 ? $nbEvent : 3); } if (!$bubble && $dn_day != $dn_today && $dn_day != $dn_showDay) $class .= ' empty'; $locations = trim (implode (',', array_unique (explode (',', $locations))), ','); $allLocations = trim (implode (',', array_unique (explode (',', $locations.','.$allLocations))), ','); $over = ''; if ($dn_day < $dn_today) $over .= '
'.$dayRank.'
'; if ($d == 0 || $d == 6) $class .= ' weekend'; if ($dn_day == $dn_today) $over .= '
'.$dayRank.'
'; elseif ($dn_day == $dn_showDay) $over .= '
'.$dayRank.'
'; $js = ' onMouseOver="javascript:scheduleHighlightPOI (\''.$locations.'\')"'; $line .= '
'; $dn_day = mktime(0, 0, 0, date ('m', $dn_day), date ('d', $dn_day)+1, date ('Y', $dn_day)); } echo ''.$line.''.NL; } ptln (' '.NL. ' '.NL. ' '.NL. ' '.NL. '
'.NL. '
'.NL. ' <'.NL. '
'.$this->getLang ('tipPrevM').'
'.NL. '
'.NL. ' '.date ($this->scheduleRoot->currentDateFormat['prettyPrint'], $dn_showDay).NL. '
'.NL. ' >'. '
'.$this->getLang ('tipNextM').'
'.NL. '
'. '
'.$dayAbrv.'
'.$over.$bubble.''.$dayRank.'
'.$w.'
'.NL. $this->getCityBubble ($LocationsEvents). '
'.NL. '
'.NL. ' '.NL. '
'.NL. '
'); } // ============================================================ function getLocationsFromEvent ($event) { $locations = ''; if ($event->lat && $event->lon) { foreach (array_combine (explode (',', $event->lat), explode (',', $event->lon)) as $lat => $lon) { $location = '('.$lat.'|'.$lon.')'; $locations .= ','.$location; } } elseif ($event->where) { $location = $event->where; $locations .= ','.$location; } return $locations; } function addLocationsDayEvent ($LocationsEvents, $dayEvents, $locations, $dn_day, $event) { $pageId = $this->scheduleRoot->getPageId ($event); resolve_pageid ($this->nameSpace, $pageId, $exists); $logoId = $this->scheduleRoot->groupsDir.':'.$event->member.':'.$this->scheduleRoot->iconName; $pageIdAt = $pageId.'-'.$event->at; if ($dayEvents [$pageIdAt]) $dayEvents [$pageIdAt]['logo'][] = $logoId; else $dayEvents [$pageIdAt] = array ('pageId'=> $pageId, 'logo' => array ($logoId), 'what'=> $event->what, 'where'=> $event->where, 'at' =>$event->at, 'title' => $event->title, 'exists' => $exists); if ($event->lat && $event->lon) { foreach (array_combine (explode (',', $event->lat), explode (',', $event->lon)) as $lat => $lon) { $location = '('.$lat.'|'.$lon.')'; $LocationsEvents [$location][$dn_day][$pageIdAt] = $dayEvents [$pageIdAt]; $locations .= ','.$location; } } elseif ($event->where) { $location = $event->where; $LocationsEvents [$location][$dn_day][$pageIdAt] = $dayEvents [$pageIdAt]; $locations .= ','.$location; } // YYY sauf répétition de jours return array ($LocationsEvents, $dayEvents, $locations); } function formatDayEventsBubble ($dn_day, $dayEvents) { $content = ''; $this->scheduleRoot->resetOddEven (); foreach ($dayEvents as $pageIdAt => $values) { $line = ''; sort ($values['logo']); foreach ($values['logo'] as $logoId) $line .= ' '; if ($values['at']) $line .= $values['at']. ' '; $line .= $values['what']; if ($values['where']) $line .= ' - '.$this->makeWhereString ($values['where']); $line .= ' : '.$values['title']; if ($values['exists']) $line = ''.$line.''; $content .= '
'.$line.'
'.NL; $this->scheduleRoot->switchOddEven (); } if (!$content) return ''; return '
'.date ($this->scheduleRoot->currentDateFormat['prettyPrint'], $dn_day).'
'.$content; } function getDayBubble ($dn_day, $dayEvents) { uasort ($dayEvents, 'cmpScheduleInDay'); $this->scheduleRoot->resetOddEven (); $content = $this->formatDayEventsBubble ($dn_day, $dayEvents); if (!$content) return ''; return '
'.$content.'
'; } // ============================================================ function getCityBubble ($LocationsEvents) { $content = ''; // XXX uasort ($dayEvents, 'cmpScheduleInCities'); foreach ($LocationsEvents as $location => $datedEvents) { $locationContent = ''; foreach ($datedEvents as $dn_day => $dayEvents) $locationContent .= $this->formatDayEventsBubble ($dn_day, $dayEvents); if ($locationContent) $content .= '
'.$locationContent.'
'; } return $content; } // ============================================================ /* Print schedule as a matrix or list */ function printScheduleList ($mapId) { if ($this->isAdmin ()) { echo '
'; foreach (array ('clear', 'clearAll') as $action) echo ''; echo '
'; } ptln ('
'); if ($this->printProp || $this->printForm) $this->printScheduleInputForm ($mapId); if ($this->printCtrl) ptln ('
'.NL. '
'.NL. '
'.NL. ' '.NL. ' '); ptln (' '); $this->printScheduleListHead (); if ($this->isAdmin ()) $this->printScheduleListContent ($this->allProposals, true); $this->printScheduleListContent ($this->allSchedules); $this->printScheduleDeleteForm (); ptln ('
'); if ($this->printCtrl) ptln ('
'); ptln ('
'); } // ============================================================ /* Print schedule head list */ function printScheduleListHead () { global $conf; ptln (' '.NL. ' '.NL. ' '. ($this->isShow ? (''. $this->getLang ('allDates').'') : $this->getLang ('when')).''.NL. ' '.$this->getLang ('what').''.NL. ' '.$this->getLang ('where').''.NL. ' '.$this->getLang ('title').''.NL. ' '.NL. ' '.NL. ' '.$this->getLang ('audience').''.NL. ' '.$this->getLang ('proposedBy').''.NL. ' '); if ($this->printCtrl) ptln (''); ptln (''.NL. ' '.NL. ' '); } // ============================================================ /* Print schedule line list */ function printScheduleLineEvent ($pageId, $lineVals, $even, $prop = false) { $ns = $this->nameSpace; $event = $lineVals['event']; $propClass = $prop ? ' proposal' : ''; $day = $this->scheduleRoot->ds2df ($event->syncStart ? $event->syncStart : $event->from); $overEvent=' onMouseOver="javascript:scheduleHighlightEvent (\''.$day.'\', \''.$this->getLocationsFromEvent ($event).'\')"'; ksort ($lineVals['member']); ptln (' '.NL. ' '); if ($prop) ptln ('proposition
'); ptln ($day.(($event->syncStart || ('' == $event->to)) ? '' : '
'.NL.$this->scheduleRoot->ds2df ($event->to)).('' == $event->at ? '' : '
'.NL.$event->at).''.NL. ' '.$event->what.''.NL. ' '.$this->makeWhereString ($event->where).''.NL. ' '.$event->title.''.NL. ' '.NL. ' '.NL. ' '.$event->audience.''.NL. ' '); if ($this->printCtrl) { ptln ($this->scheduleRoot->scheduleShared[$event->shared]); if (!$prop && !$lineVals['exists'] && $this->isAMemberOf (array_keys ($lineVals['member']))) { // petite baguette magique de création $id = reset (array_values($lineVals['member'])); ptln (''. ' '); } } foreach ($lineVals['member'] as $member => $id) { echo ''; if ($this->printCtrl && $this->isMember ($member)) { // suppression ou édition pour un membre ptln (' '. ''. ''); } $logoId = $this->scheduleRoot->groupsDir.':'.$member.':'.$this->scheduleRoot->iconName; // YYY ptln (' '); } ptln (''.NL. ' '); if ($event->repeatFlag) ptln (' '.$this->makeRepeatString ($event, false)); ptln (''.NL. ' '); } // ============================================================ function makePrettyAt ($at) { if (!$at) return ''; if (preg_match ("#(?[^-]*)-(?[^-]*)#", $at, $dumy)) return ' '.$this->getLang ('fromHour').' **'.$dumy ['from'].'** '.$this->getLang ('toHour').' **'.$dumy ['to'].'**'; return ' '.$this->getLang ('at').' **'.$at.'**'; } function makeListPlaceForMap ($schedule) { global $scheduleInseeCities; $result= ''; $cities = explode (',', $schedule->where); $lats = explode (',', $schedule->lat); $lons = explode (',', $schedule->lon); $addrs = explode ('|', $schedule->addr); $unknownAddr = false; for ($i = 0; $i < count ($cities); $i++) { if (!isset ($addrs [$i])) $unknownAddr = true; $result .= $cities[$i].' | '. (isset ($lats [$i]) ? $lats [$i] : '').' | '. (isset ($lons [$i]) ? $lons [$i] : '').' | '. (isset ($addrs [$i]) ? $addrs [$i] : ''). NL; } if ($unknownAddr) $result .= 'Les coordonnées par défaut correspondent aux centres-villes !'.NL; return $result; } // ============================================================ /* Create a natural langage string for cities zipcode */ function makeWhereString ($where) { global $scheduleInseeCities; $result = array (); foreach (explode (',', $where) as $zip) $result[] = (isset ($scheduleInseeCities[$zip]) ? $scheduleInseeCities[$zip][0] : ($this->showOldValues ? ''.$zip.'' : $zip)); return implode (',', array_unique ($result)); } // ============================================================ /* Create a natural langage string to formulate repeat event */ function makeRepeatString ($event, $bold = false) { $orderedFormat = $this->getLang ('orderedFormat'); $rt = $this->getLang ('repeatType'); $result = ''; switch ($event->repeatType) { case 'day' : return $this->getLang ('from').' '.$this->scheduleRoot->ds2ln ($event->from, $bold).' '.$this->getLang ('to').' '.$this->scheduleRoot->ds2ln ($event->to, $bold); break; // pour gagner du temps case 'week' : foreach (array_keys ($this->getLang ('days')) as $idd => $dayName) $result .= in_array ($idd, explode ('|', $event->weekDays)) ? $dayName.' ' : ''; break; case 'dayMonth' : $dayNames = array_keys ($this->getLang ('days')); // XXX pb OVH => utilisation de tableau au lieu de fonction // $result .= $f ($event->weekRank+1).' '.$d [$event->dayInWeek].' '; $result .= $orderedFormat [$event->weekRank+1].' '.$dayNames [$event->dayInWeek].' '; break; case 'dateMonth' : // XXX pb OVH => utilisation de tableau au lieu de fonction // $result .= $f ($event->dayRank).' '; $result .= $orderedFormat [$event->dayRank].' '; break; case 'year' : // XXX le Ie jour du Je mois preg_match ("#(?[0-9]{4})(?[0-9]{2})(?[0-9]{2})#", $event->from, $dt_from); $dn_from = $this->scheduleRoot->dt2dn ($dt_from); $result .= date ($this->scheduleRoot->currentDateFormat ['dayMonth'], $dn_from).' '; } $result .= $this->getLang ('all').' '; if ($event->repeat > 1) $result .= $event->repeat.' '; $result .= $rt[$event->repeatType]; return $result; } // ============================================================ /* Add a schedule line list in array for futur print */ function addEventTab (&$tab, $event, $when, $pageId, $eventClass, $exists, $cssLink) { if (!$tab [$when]) $tab [$when] = array (); if ($tab [$when][$pageId]) $tab [$when][$pageId]['member'][$event->member] = $event->id; else $tab [$when][$pageId] = array ('member' => array ($event->member => $event->id), 'event' => $event, 'class' => $eventClass, 'exists' => $exists, 'css' => $cssLink); } // ============================================================ /* Print all schedule line list */ function printScheduleListContent ($allSchedules, $prop = false) { $linesTab = array (); $repeatTab = array (); if ($this->after) { preg_match ("#(?[0-9]{4})(?[0-9]{2})(?[0-9]{2})#", $this->after, $dt_start); $dn_start = $this->scheduleRoot->dt2dn ($dt_start); } foreach ($allSchedules as $event) { // XXX même filtre pour printScheduleCalendar ? if ($this->before && strcmp ($event->from, $this->before) > 0) continue; // XXX repeat le même jour => calcul if ($this->date && (strcmp ($event->from, $this->date) > 0 || strcmp (('' != $event->to ? $event->to : $event->from), $this->date) < 0)) continue; if ($this->after && strcmp (('' != $event->to ? $event->to : $event->from), $this->after) < 0) continue; if ($this->max && $line > $this->max) break; $continue = false; if ($this->filters) foreach ($this->filters as $name => $values) { if (in_array ($name, $this->scheduleRoot->filterNames) && !in_array ($event->$name, $values)) { $continue = true; break; } elseif (in_array ($name, array_keys ($this->scheduleRoot->filterNames))) { $trueName = $this->scheduleRoot->filterNames[$name]; if (in_array ($event->$trueName, $values)) { $continue = true; break; } } } if ($continue) continue; $pageId = $this->scheduleRoot->getPageId ($event); resolve_pageid ($this->nameSpace, $pageId, $exists); $cssLink = $exists ? 'wikilink1' : 'wikilink2'; $eventClass = 'cat_'.preg_replace ("/\s/", '', htmlspecialchars (strtolower ($this->scheduleRoot->scheduleWhat [$event->what]))); $when = $event->from.'-'.$event->at.'-'.$event->to; if ($event->repeatFlag) { if (!$this->after || strcmp ($event->from, $this->after) > 0) $event->syncStart = $event->from; else { // cas ou il faut déplacer le début de la répétition (on ne déplace si la 1re occurance est après le début de la fenêtre) preg_match ("#(?[0-9]{4})(?[0-9]{2})(?[0-9]{2})#", $event->from, $dt_from); $dn_day = $dn_from = $this->scheduleRoot->dt2dn ($dt_from); // on déplace sur la 1re occurance switch ($event->repeatType) { // chercher le 1er évènement après 'after' case 'day' : $step = 86400 * $event->repeat; $dn_day += ceil (($dn_start - $dn_from) / $step) * $step; break; case 'week' : $dn_startWeek = mktime (0, 0, 0, date ('m', $dn_from), date ('d', $dn_from) - date ('w', $dn_from), date ('Y', $dn_from)); $step = 86400 * 7 * $event->repeat; $dn_startWeek += floor (($dn_start - $dn_startWeek) / $step) * $step; // au pire start commence après les jours répétés dans la semaine for ($i = 0; $i < 2; $i++, $dn_startWeek += $step) { foreach (explode ('|', $event->weekDays) as $idd) { $dn_day = $dn_startWeek + $idd * 86400; if ($dn_day >= $dn_start && $dn_day >= $dn_from) { break 2; } } } break; case 'dayMonth' : case 'dateMonth' : { $dn_startMonth = mktime (0, 0, 0, date ('m', $dn_from), 1, date ('Y', $dn_from)); $nbMonth = floor ((date ('m', $dn_start) + date ('Y', $dn_start)*12 - (date ('m', $dn_from) + date ('Y', $dn_from)*12))/$event->repeat)*$event->repeat; $dn_startMonth = mktime (0, 0, 0, date ('m', $dn_startMonth) + $nbMonth, 1, date ('Y', $dn_startMonth)); for ($i = 0; $i < 2; $i++, $dn_startMonth = mktime (0, 0, 0, date ('m', $dn_startMonth) + $event->repeat, 1, date ('Y', $dn_startMonth))) { $dn_day = $dn_startMonth; if ($event->repeatType == 'dateMonth') // XXX pb si moins de jour dans le mois $dn_day = mktime (0, 0, 0, date ('m', $dn_startMonth), $event->dayRank, date ('Y', $dn_startMonth)); else { $delta = $event->dayInWeek - date ('w', $dn_startMonth); if ($delta < 0) $delta += 7; $delta += 7 * $event->weekRank; // XXX pb si moins de jour dans le mois $dn_day = mktime (0, 0, 0, date ('m', $dn_startMonth), $delta+1, date ('Y', $dn_startMonth)); } if ($dn_day >= $dn_start && $dn_day >= $dn_from) break; } break; } case 'year' : $dayInmonth = date ('j', $dn_from); $monthInYear = date ('n', $dn_from); $startYear = date ('Y', $dn_start) - (date ('Y', $dn_start) - date ('Y', $dn_from)) % $event->repeat; for ($i = 0; $i < 2; $i++, $startYear += $event->repeat) { $dn_day = mktime (0, 0, 0, $monthInYear, $dayInmonth, $startYear); if ($dn_day >= $dn_start && $dn_day >= $dn_from) break; } break; } $ds_day = date ('Ymd', $dn_day); if ($this->before && strcmp ($ds_day, $this->before) > 0) continue; if ($this->date && strcmp ($ds_day, $this->date) != 0) continue; $event->syncStart = $ds_day; $when = $ds_day.'-'.$event->at.'-'.$event->to; } } if ($this->repeatGrouped && $event->repeatFlag) schedules::addEventTab ($repeatTab, $event, $when, $pageId, $eventClass, $exists, $cssLink); else schedules::addEventTab ($linesTab, $event, $when, $pageId, $eventClass, $exists, $cssLink); } ksort ($repeatTab); ksort ($linesTab); $line = 1; foreach ($repeatTab as $when) { foreach ($when as $pageId => $lineVals) { schedules::printScheduleLineEvent ($pageId, $lineVals, $even, $prop); $this->scheduleRoot->switchOddEven (); $line++; } } foreach ($linesTab as $when) { foreach ($when as $pageId => $lineVals) { schedules::printScheduleLineEvent ($pageId, $lineVals, $even, $prop); $this->scheduleRoot->switchOddEven (); $line++; } } if ($line < 1) echo ' '.$this->getLang ('noEvent').''; } // ============================================================ /* Print delete button in form */ function printScheduleDeleteForm () { if (!$this->printCtrl) return; echo ' '; } // ============================================================ /* Print add event form */ function printRepeatForm () { $repeat = ($this->defaultSchedule->repeat > 1) ? $this->defaultSchedule->repeat : 1; ptln(' '); $disabled = ($this->defaultSchedule->repeatType !== "week") ? ' disabled="true"' : ''; $eventWeekDays = explode ("|", $this->defaultSchedule->weekDays); $checkbox = ""; $dayNames = $this->getLang ('days'); foreach (array_values ($dayNames) as $idd => $dayAbrv) { ptln (' '); $selected = in_array ($idd, $eventWeekDays) ? ' checked="true"' : ''; $checkbox .= ' '.NL; } $disabled = ($this->defaultSchedule->repeatType !== "dayMonth") ? ' disabled="true"' : ''; ptln (' '.$checkbox.'
'.$this->getLang ('all').'
'.$this->getLang ('each').''.$dayAbrv.'
'); } // ============================================================ function printScheduleInputForm ($mapId) { if (!($this->printForm || $this->printProp)) return; $from = (!$this->defaultSchedule->from && isset ($_REQUEST["schd"]["date"])) ? $_REQUEST["schd"]["date"] : $this->scheduleRoot->ds2df ($this->defaultSchedule->from); ptln ('
'.NL. '

'.$this->getLang ($this->printProp ? 'proposedEvent' : 'addEvent').'

'.NL. // XXX getLang ' '.NL. '
'.NL. '
'.NL. '
'.NL. '
'.NL. ' '.NL. '
'.NL. '
'.NL. '
'.NL. '
'.NL. '
'.NL. ' '.NL. '

'.NL. ' '.$this->getLang ('lead').':
'.NL. ' '.NL. '

'.NL. ' '.$this->getLang ('posterURL').':
'.NL. ' '.NL. '

'.NL. ' '.$this->getLang ('paperURL').':
'.NL. ' '.NL. '

'.NL. ' '.$this->getLang ('remark').':
'.NL. ' '.NL. '

'.NL. ' '.$this->getLang ('rate').':
'.NL. ' '.NL. '

'.NL. '
'.NL. '
'.NL. '
'.NL. '
'.NL. '
'.NL. '
'.NL. '
'.NL. '
    '.NL); if ($this->defaultSchedule->where) { global $scheduleInseeCities; $cities = explode (',', $this->defaultSchedule->where); $lats = explode (',', $this->defaultSchedule->lat); $lons = explode (',', $this->defaultSchedule->lon); $addrs = explode ('|', $this->defaultSchedule->addr); for ($i = 0; $i < count ($cities); $i++) { $insee = $cities[$i]; $cityName = isset ($scheduleInseeCities [$insee]) ? $scheduleInseeCities [$insee][0] : $insee; ptln ('
  • '. ''.(isset ($addrs [$i]) ? str_replace ('\\\\', '
    ', str_replace ('~br~', '
    ', $addrs [$i])) : "").'
    '. ''.$cityName.'
  • '); } } ptln ('
'.NL. ' '.NL. ' '.$this->getLang ('enterTip').''.NL. ' '.NL. ' '.$this->getLang ('enterTip').''.NL. '
'.NL. '
'.NL. '
'.NL); if ($this->isAdmin ()) ptln ('
'.NL. ''.NL. ''.NL. ''.NL. '
'.NL); ptln ('
'.NL. '
'.NL. '
'.NL. '

'.NL. $this->getLang ('from').' '. $this->getLang ('to').'

'. $this->getLang ('at').'

'); $this->printRepeatForm (); ptln ('
'.NL. '
'.NL. '

'.NL. ' '.NL. ' '.NL); if ($this->printForm) { if ($this->defaultSchedule->id) { ptln (''); if (!$this->defaultSchedule->prop) { if (count ($this->getMembersSharedEvents ($this->defaultSchedule)) > 1) ptln (''); ptln (' '); } } ptln (''); } if ($this->printProp) { ptln (' '); if ($captcha =& plugin_load ('helper', 'captcha')) ptln ($captcha->getHTML ()); } ptln ('

'.NL. '
'.NL. '
'.NL. '
'.NL. ' Aide'.NL. '
'.NL. '
'.NL. ' '.NL. ' '.NL. ' '.NL. ' '.NL. ' '.NL. '
'.NL. '
'.NL. '
'.NL. '
'.NL); } // ============================================================ function resetAdminNotification () { $this->lastNotificationReset = date ('YmdHis'); $this->scheduleRoot->writeConfig ($this); } function adminNotification () { if ($this->lastNotification > $this->lastNotificationReset) return; global $auth; $users = $auth->retrieveUsers (); foreach ($users as $user => $userinfo) { $mailSubject = $this->getLang ('notifySubject'); $mailContent = $this->getLang ('notifyContent'); if (in_array (trim ($this->getConf ('adminGroup')), $userinfo ['grps'])) { mail_send ($userinfo['mail'], $mailSubject, $mailContent); } } $this->lastNotification = date ('YmdHis'); $this->scheduleRoot->writeConfig ($this); } // ============================================================ }