function showEvents(&$events, $date) { global $privs, $wkDays, $set, $xx, $months; foreach ($events as $evt) { switch ($evt['r_t']) { //make repeat text case 0: $repeat = ''; break; case 1: $repeat = $xx['evt_repeat_on'] . ' ' . $evt['r_i'] . ' ' . $xx['evt_period1_' . $evt['r_p']]; break; case 2: $repeat = $xx['evt_repeat_on'] . ' ' . $xx['evt_interval2_' . $evt['r_i']] . ' ' . $wkDays[$evt['r_p']] . ' ' . $xx['of'] . ' ' . ($evt['r_m'] ? $months[$evt['r_m'] - 1] : $xx['evt_each_month']); } if ($evt['r_t'] > 0 and $evt['r_u']) { $repeat .= " {$xx['evt_until']} " . IDtoDD($evt['r_u']); } if ($evt['app'] and !$evt['apd']) { $eBoxStyle = 'border-left:2px solid #ff0000;'; } $eBoxStyle = !empty($eBoxStyle) ? " style='{$eBoxStyle}'" : ''; $evtDateTime = IDtoDD($evt['sda']); if ($evt['sti']) { $evtDateTime .= " {$xx['at_time']} " . ITtoDT($evt['sti']); } if ($evt['eda'] or $evt['eti']) { $evtDateTime .= ' -'; } if ($evt['eda']) { $evtDateTime .= ' ' . IDtoDD($evt['eda']) . ($evt['eti'] ? " {$xx['at_time']}" : ''); } if ($evt['eti']) { $evtDateTime .= ' ' . ITtoDT($evt['eti']); } if ($evt['ald']) { $evtDateTime .= ' ' . $xx['vws_all_day']; } if ($repeat) { $evtDateTime .= '. ' . $repeat; } if ($set['eventColor']) { $eStyle = ($evt['cco'] ? "color:{$evt['cco']};" : '') . ($evt['cbg'] ? "background-color:{$evt['cbg']};" : ''); } else { $eStyle = $evt['uco'] ? "background-color:{$evt['uco']};" : ''; } $eStyle = $eStyle ? " style='{$eStyle}'" : ''; echo "<table>\n<tr>\n\t\t\t<td class='widthCol1'>" . ($evt['sts'] < 0 ? $xx['chg_deleted'] : ($evt['mdt'] > $evt['adt'] ? $xx['chg_edited'] : $xx['chg_added'])) . "</td>\n"; echo "<td class='eBox'{$eBoxStyle}>{$evtDateTime}"; if ($evt['sts'] >= 0 and $evt['mayE']) { echo "<h6><span class='point'{$eStyle} onclick=\"editE({$evt['eid']},'{$date}');\">{$evt['tix']}</span></h6>\n"; } else { echo "<h6><span{$eStyle}>{$evt['tix']}</span></h6>\n"; } if ($set['details4All'] == 1 or $set['details4All'] == 2 and $_SESSION['uid'] > 1 or $evt['mayE']) { echo makeE($evt, $set['evtTemplGen'], 'br', "<br>\n", '1234567') . "\n"; } echo "</td>\n</tr>\n</table>\n<br>\n"; } }
function notify(&$evt, $date, $daysDue) { global $emlStyle, $set, $xx, $ax; $todayD = date("Y-m-d", time() + 43200); //today 12:00 //compose email message $dateTime = IDtoDD($date) . ' ' . $xx['at_time'] . ' ' . (($evt['sti'] or $evt['eti']) ? ITtoDT($evt['sti']) : $ax['cro_all_day']); if ($evt['eti']) { $dateTime .= " - " . ITtoDT($evt['eti']); } $status = ''; if ($evt['cbx']) { $status .= $evt['clb'] . ': ' . (strpos($evt['chd'], $date) ? $evt['cmk'] : '- -'); } $subject = "{$set['calendarTitle']} - " . ($daysDue ? "{$ax['cro_due_in']} {$daysDue} {$ax['cro_days']}" : $ax['cro_due_today']) . ": " . $evt['tit']; if ($set['eventColor']) { $eStyle = ($evt['cco'] ? "color:{$evt['cco']};" : '') . ($evt['cbg'] ? "background-color:{$evt['cbg']};" : ''); } else { $eStyle = $evt['uco'] ? "background-color:{$evt['uco']};" : ''; } $eStyle = $eStyle ? " style=\"{$eStyle}\"" : ''; $calUrl = $set['calendarUrl'] . (strpos($set['calendarUrl'], '?', 6) ? '&' : '?') . 'cD=' . $date; $evtText = makeE($evt, $set['evtTemplGen'], 'td', '', '12345'); $msgText = "\n<html>\n<head>\n<title>{$set['calendarTitle']} {$ax['cro_mailer']}</title>\n<style type='text/css'>\nbody, p, table {{$emlStyle}}\ntd {vertical-align:top;}\n</style>\n</head>\n<body>\n<p>{$set['calendarTitle']} {$ax['cro_mailer']} " . IDtoDD($todayD) . "</p>\n<p>" . ($daysDue ? "{$ax['cro_event_due_in']} {$daysDue} {$ax['cro_days']}" : $ax['cro_event_due_today']) . ":</p>\n<table>\n\t<tr><td>{$ax['cro_title']}:</td><td><b><span{$eStyle}>{$evt['tit']}</span></b></td></tr>\n\t" . ($evt['cbx'] ? "<tr><td>{$ax['cro_status']}:</td><td>{$status}</td></tr>" : '') . "\n\t<tr><td>{$ax['cro_date_time']}:</td><td>{$dateTime}</td></tr>\n\t{$evtText}\n</table>\n<p><a href='{$calUrl}'>{$ax['cro_open_calendar']}</a></p>\n</body>\n</html>\n"; //send notification $sender = $set['notifSender'] ? $evt['uid'] : 0; $sent = sendMail($subject, $msgText, $evt['rml'], $sender); $sentTo = $sent ? "{$sent} - {$ax['cro_subject']}: {$subject}" : "Sending mail failed. See logs/luxcal.log for details"; return $sentTo; }
function showGrid(&$events, $date) { global $privs, $hoverBox, $evtDone, $set, $xx, $upcoTxt; $lastDate = ''; $showDetails = ($set['details4All'] == 1 or $set['details4All'] == 2 and $_SESSION['uid'] > 1); foreach ($events as $evt) { if (!$evt['mde'] or !in_array($evt['eid'], $evtDone)) { //!mde or mde not processed $evtDate = $evt['mde'] ? makeD($evt['sda'], 5) . " - " . makeD($evt['eda'], 5) : makeD($date, 5); $evtTime = $evt['ald'] ? $xx['vws_all_day'] : ITtoDT($evt['sti']) . ($evt['eti'] ? ' - ' . ITtoDT($evt['eti']) : ''); if ($set['eventColor']) { $eStyle = ($evt['cco'] ? 'color:' . $evt['cco'] . ';' : '') . ($evt['cbg'] ? 'background-color:' . $evt['cbg'] . ';' : ''); } else { $eStyle = $evt['uco'] ? 'background-color:' . $evt['uco'] . ';' : ''; } $eStyle = $eStyle ? ' style="' . $eStyle . '"' : ''; $chBox = ''; if ($evt['cbx']) { $chBox .= !$evt['mde'] ? strpos($evt['chd'], $date) ? $evt['cmk'] : '☐' : '?'; } if ($chBox) { $mayCheck = ($privs > 3 or $privs > 1 and $evt['uid'] == $_SESSION['uid']) ? true : false; $attrib = ($mayCheck and !$evt['mde']) ? "class='chkBox point' onclick=\"checkE(" . $evt['eid'] . ",'" . $date . "');\" title=\"{$xx['vws_check_mark']}\"" : 'class="chkBox"'; $chBox = '<span ' . $attrib . ">" . trim($chBox) . '</span>'; } if ($hoverBox) { $popText = "<b>{$evtTime}:" . ((!$evt['mde'] and $evt['eti']) ? ' - ' . ITtoDT($evt['eti']) : '') . " {$evt['tit']}</b><br>"; if ($showDetails or $evt['mayE']) { $popText .= makeE($evt, $set['popBoxFields'], 'br', '<br>'); } $popText = htmlspecialchars(addslashes($popText)); $popClass = ($evt['pri'] ? 'private' : 'normal') . (($evt['mde'] or $evt['r_t']) ? ' repeat' : ''); $popAttr = " onmouseover=\"pop(this,'{$popText}','{$popClass}')\""; } else { $popAttr = ''; } $eBoxStyle = ($evt['app'] and !$evt['apd']) ? " style='border-left:2px solid #ff0000;'" : ''; echo $lastDate != $evtDate ? "<br>\n<h6>{$evtDate}</h6>\n" : "<br>\n"; echo "<table>\n<tr>\n\t\t\t\t<td class='widthCol1'>{$evtTime}</td>\n\t\t\t\t<td class='eBox'{$eBoxStyle}>"; if ($showDetails or $evt['mayE']) { echo "<h6>{$chBox}<span class='point'{$eStyle} onclick=\"editE({$evt['eid']},'{$date}');\"{$popAttr}>{$evt['tit']}</span></h6>\n"; echo makeE($evt, $set['evtTemplUpc'], 'br', '<br>') . "\n"; } else { echo "<h6>{$chBox}<span{$eStyle}{$popAttr}>{$evt['tit']}</span></h6>\n"; } echo "</td></tr></table>\n"; $evtDone[] = $evt['eid']; //add text version to $upcoTxt if ($lastDate != $evtDate) { $upcoTxt .= "\n{$evtDate}\n" . str_repeat('-', strlen($evtDate)); } //new or same date $upcoTxt .= "\n{$evtTime}\n" . html_entity_decode($evt['tit'], ENT_QUOTES) . "\n"; if ($showDetails or $evt['mayE']) { $upcoTxt .= html_entity_decode(makeE($evt, $set['evtTemplUpc'], 'br', "\n"), ENT_QUOTES) . "\n"; } $lastDate = $evtDate; } } }
function showGrid($date) { global $evtList, $privs, $set, $xx; if (!array_key_exists($date, $evtList)) { return; } $showDetails = ($set['details4All'] == 1 or $set['details4All'] == 2 and $_SESSION['uid'] > 1); foreach ($evtList[$date] as $evt) { switch ($evt['mde']) { //multi-day event? case 0: $time = ITtoDT($evt['sti']) . ($evt['eti'] ? ' - ' . ITtoDT($evt['eti']) : ''); break; //no //no case 1: $time = (($evt['sti'] != '00:00' and $evt['sti'] != '') ? ITtoDT($evt['sti']) : '•') . '···'; break; //first //first case 2: $time = '···'; break; //in between //in between case 3: $time = '···' . (($evt['eti'] < '23:59' and $evt['eti'] != '') ? ITtoDT($evt['eti']) : '•'); //last } $chBox = ''; if ($evt['cbx']) { $chBox .= strpos($evt['chd'], $date) ? $evt['cmk'] : '☐'; $chBox = "<span class='chkBox'>{$chBox}</span>"; } if ($set['popBoxYear'] and $set['popBoxFields']) { $popText = "<b>{$chBox} {$time} {$evt['tit']}</b><br>"; if ($showDetails or $evt['mayE']) { $popText .= makeE($evt, $set['popBoxFields'], 'br', '<br>'); } $popText = htmlspecialchars(addslashes($popText)); $popClass = ($evt['pri'] ? 'private' : 'normal') . (($evt['mde'] or $evt['r_t']) ? ' repeat' : ''); $popAttr = " onmouseover=\"pop(this,'{$popText}','{$popClass}')\""; } else { $popAttr = ''; } if ($set['eventColor']) { $eStyle = $evt['cbg'] ? "background-color:{$evt['cbg']};" : ''; } else { $eStyle = $evt['uco'] ? "background-color:{$evt['uco']};" : ''; } if ($evt['app'] and !$evt['apd']) { $eStyle .= 'border:1px solid #ff0000;'; } $eStyle = $eStyle ? " style='{$eStyle}'" : ''; echo '<div ' . (($showDetails or $evt['mayE']) ? "class='square point'{$eStyle} onclick=\"editE({$evt['eid']},'{$date}');\"" : "class='square arrow'{$eStyle}") . "{$popAttr}></div>\n"; } }
function displayUE(&$evtList) { global $evtList, $set, $xx, $sbMaxNbr, $sbCalUrl, $rxULink; $evtDone = array(); $lastDate = ''; foreach ($evtList as $date => &$events) { foreach ($events as $evt) { if (!$evt['mde'] or !in_array($evt['eid'], $evtDone)) { //!mde or mde not processed $evtDone[] = $evt['eid']; $evtDate = $evt['mde'] ? makeD($evt['sda'], 5) . " - " . makeD($evt['eda'], 5) : makeD($date, 5); $evtTime = $evt['ald'] ? $xx['vws_all_day'] : ITtoDT($evt['sti']) . ($evt['eti'] ? ' - ' . ITtoDT($evt['eti']) : ''); if ($set['popFieldsSbar']) { $popText = "<div class='ssb_gen ssb_popUp'><b>{$evtTime} {$evt['tit']}</b>"; $popText = makeE($evt, $set['popFieldsSbar'], 'br', "<br>"); $popText = htmlspecialchars(addslashes($popText . '</div>')); $popClass = ($evt['mde'] or $evt['r_t']) ? 'ssb_repeat' : 'ssb_normal'; $popAttr = " onmouseover=\"pop(this,'{$popText}','{$popClass}',50)\""; } else { $popAttr = ''; } if ($set['eventColor']) { $eStyle = ($evt['cco'] ? "color:{$evt['cco']};" : '') . ($evt['cbg'] ? "background-color:{$evt['cbg']};" : ''); } else { $eStyle = $evt['uco'] ? "background-color:{$evt['uco']};" : ''; } $eStyle = $eStyle ? " style='{$eStyle}'" : ''; if (empty($sbCalUrl)) { $eTitle = $evt['tit']; } else { $jumpD = (strpos($sbCalUrl, '?') ? '&' : '?') . "cD={$evt['sda']}"; $eTitle = "<a href='{$sbCalUrl}{$jumpD}' target='luxcal'>{$evt['tit']}</a>"; } if ($lastDate != $evtDate) { echo "<div class='ssb_gen ssb_date'>{$evtDate}</div>\n"; $lastDate = $evtDate; } echo "<div class='ssb_gen ssb_event ssb_arrow'{$popAttr}>\n\t\t\t\t\t<div class='ssb_gen ssb_evtTime'>{$evtTime}</div>\n<div class='ssb_gen ssb_evtTitle'{$eStyle}>{$eTitle}</div>\n\t\t\t\t\t</div>\n"; if ($set['showLinkInSB'] and preg_match_all($rxULink, $evt['des'], $urls, PREG_SET_ORDER)) { //display URL links echo "<div class='ssb_gen ssb_evtUrl'{$eStyle}>"; foreach ($urls as $url) { echo "{$url[0]}<br>"; } echo "</div>\n"; } if (--$sbMaxNbr < 1) { break 2; } } } } }
function makeGrid(&$events) { global $set, $xx, $wkDays, $months; $changeList = ''; foreach ($events as $evt) { switch ($evt['r_t']) { //make repeat text case 0: $repeat = ''; break; case 1: $repeat = $xx['evt_repeat_on'] . ' ' . $evt['r_i'] . ' ' . $xx['evt_period1_' . $evt['r_p']]; break; case 2: $repeat = $xx['evt_repeat_on'] . ' ' . $xx['evt_interval2_' . $evt['r_i']] . ' ' . $wkDays[$evt['r_p']] . ' ' . $xx['of'] . ' ' . ($evt['r_m'] ? $months[$evt['r_m'] - 1] : $xx['evt_each_month']); } if ($evt['r_t'] > 0 and $evt['r_u']) { $repeat .= " {$xx['evt_until']} " . IDtoDD($evt['r_u']); } if ($set['eventColor']) { $eStyle = ($evt['cco'] ? "color:{$evt['cco']};" : '') . ($evt['cbg'] ? "background-color:{$evt['cbg']};" : ''); } else { $eStyle = $evt['uco'] ? "background-color:{$evt['uco']};" : ''; } $eStyle = $eStyle ? " style=\"{$eStyle}\"" : ''; $eBoxStyle = ' style="padding-left:5px;' . (($evt['app'] and !$evt['apd']) ? ' border-left:2px solid #ff0000;' : '') . '"'; $changeList .= "<table><tr><td width='100px'>"; $changeList .= $evt['sts'] < 0 ? $xx['chg_deleted'] : ($evt['mdt'] > $evt['adt'] ? $xx['chg_edited'] : $xx['chg_added']); $changeList .= " </td>\n"; $changeList .= "<td{$eBoxStyle}>"; $changeList .= "<span{$eStyle}><b>{$evt['tit']}</b></span><br>\n"; $changeList .= IDtoDD($evt['sda']); if ($evt['sti']) { $changeList .= " {$xx['at_time']} " . ITtoDT($evt['sti']); } if ($evt['eda'] or $evt['eti']) { $changeList .= ' -'; } if ($evt['eda']) { $changeList .= ' ' . IDtoDD($evt['eda']) . ($evt['eti'] ? " {$xx['at_time']}" : ''); } if ($evt['eti']) { $changeList .= ' ' . ITtoDT($evt['eti']); } if ($evt['ald']) { $changeList .= " {$xx['vws_all_day']}"; } $changeList .= " {$repeat}<br>"; $changeList .= makeE($evt, $set['evtTemplGen'], 'br', "<br>\n", '1234567'); $changeList .= "</td></tr></table><br>\n"; } return $changeList; }
function notifyReg($uName, $eMail) { //notify a new user registration global $ax, $set, $emlStyle, $emlHeader, $emlTrailer; //compose email message $dDate = IDtoDD(date('Y-m-d')); //current date in display format $noteText = $ax['log_new_reg']; $subject = translit("{$set['calendarTitle']} - {$noteText}: {$uName}"); $msgText = $emlHeader . "\n<p>{$set['calendarTitle']} {$ax['cro_mailer']} {$dDate}</p>\n<p>{$noteText}:</p>\n<table>\n\t<tr><td>{$ax['log_un']}:</td><td>{$uName}</td></tr>\n\t<tr><td>{$ax['log_em']}:</td><td>{$eMail}</td></tr>\n\t<tr><td>{$ax['log_date_time']}:</td><td>{$dDate} {$ax['at_time']} " . ITtoDT(date("H:i")) . "</td></tr>\n</table>\n<p><a href='{$set['calendarUrl']}'>{$ax['cro_open_calendar']}</a></p>\n{$emlTrailer}"; //send email sendMail($subject, $msgText, $set['calendarEmail']); }
function IDTtoDDT($dateTime) { //convert ISO date+time (yyyy mm dd hh:mm:ss) to display date global $xx; $date = substr($dateTime, 0, 10); if (!$date) { return ''; } $time = substr($dateTime, 11, 5); $dD = IDtoDD($date); $dT = ITtoDT($time); return $dD . ($dT ? " {$xx['at_time']} {$dT}" : ''); }
function showGrid($date) { global $set, $evtList, $privs, $xx; if (!array_key_exists($date, $evtList)) { return; } foreach ($evtList[$date] as &$evt) { switch ($evt['mde']) { //multi-day event? case 0: $time = ITtoDT($evt['sti']); break; //no //no case 1: $time = (($evt['sti'] != '00:00' and $evt['sti'] != '') ? ITtoDT($evt['sti']) : '•') . '···'; break; //first //first case 2: $time = '···'; break; //in between //in between case 3: $time = '···' . (($evt['eti'] < '23:59' and $evt['eti'] != '') ? ITtoDT($evt['eti']) : '•'); //last } $chBox = ''; if ($evt['cbx']) { $chBox .= strpos($evt['chd'], $date) ? $evt['cmk'] : '☐'; } if ($chBox) { $chBox = '<span class="chkBox">' . trim($chBox) . '</span>'; } if ($set['popFieldsMcal']) { $popText = "<div class=\"fontS\"><b>" . $chBox . $time . ((!$evt['mde'] and $evt['eti']) ? ' - ' . ITtoDT($evt['eti']) . ' ' : ' ') . $evt['tit'] . '</b>'; $popText .= '<br>' . makeE($evt, $set['popFieldsMcal'], 'br', "<br>"); $popText = htmlspecialchars(addslashes($popText . '</div>')); $popClass = ($evt['mde'] or $evt['r_t']) ? 'normal repeat' : 'normal'; $popAttr = " onmouseover=\"pop(this,'{$popText}','{$popClass}',30)\""; $cursor = ' point'; } else { $popAttr = ''; $cursor = ' arrow'; } $bgColor = $evt['cbg'] ? " style=\"background-color:{$evt['cbg']};\"" : ''; $mayEdit = $set['miniCalPost'] ? " onclick=\"x=editE({$evt['eid']},'{$date}');\"" : ''; echo "<div class='miniSquare{$cursor}'{$bgColor}{$mayEdit}{$popAttr}></div>\n"; } }
function processEvtFields(&$sDate, &$eDate, &$sTime, &$eTime, &$title, &$catID) { global $dFormat, $tFormat; //Get calendar category ids $rSet = dbQuery("SELECT category_id FROM [db]categories WHERE status >= 0"); $catIDs = array(); if ($rSet) { while ($row = mysql_fetch_assoc($rSet)) { $catIDs[] = $row['category_id']; } } //Processing $errors = 0; $nofDates = count($sDate); for ($i = 0; $i < $nofDates; $i++) { $error = 0; if (($IsDate = DDtoID($sDate[$i], $dFormat)) === false) { $error++; } if ($eDate[$i]) { if (($IeDate = DDtoID($eDate[$i], $dFormat)) === false) { $error++; } } if ($sTime[$i]) { if (($IsTime = DTtoIT($sTime[$i], $tFormat)) === false) { $error++; } } if ($eTime[$i]) { if (($IeTime = DTtoIT($eTime[$i], $tFormat)) === false) { $error++; } } if (!$error) { if ($eDate[$i]) { if ($IsDate == $IeDate) { $eDate[$i] = ''; } elseif ($IeDate < $IsDate) { $temp = $eDate[$i]; $eDate[$i] = $sDate[$i]; $sDate[$i] = $temp; } elseif ($IeDate > $IsDate and $IsTime == "00:00" and $IeTime == "00:00") { $eDate[$i] = IDtoDD(date("Y-m-d", mktime(12, 0, 0, substr($IeDate, 5, 2), substr($IeDate, 8, 2), substr($IeDate, 0, 4)) - 86400), $dFormat); $eTime[$i] = ITtoDT("23:59", $tFormat); } } if (!$sTime[$i] and !$eTime[$i]) { $sTime[$i] = ITtoDT("00:00", $tFormat); $eTime[$i] = ITtoDT("23:59", $tFormat); } //no times: all day if (!$sTime[$i] and $eTime[$i]) { $sTime[$i] = $eTime[$i]; } if ($sTime[$i] == $eTime[$i]) { $eTime[$i] = ''; } if ($eTime[$i]) { if ($IeTime < $IsTime) { $temp = $eTime[$i]; $eTime[$i] = $sTime[$i]; $sTime[$i] = $temp; } } } $errors += $error; if (!$title[$i]) { $errors++; } //title empty if (!in_array($catID[$i], $catIDs)) { $catID[$i] = 0; } //reset non-existing category IDs } return $errors; }
function upcoList() { //make list with upcoming events global $xx, $set, $evtList; if ($set['navUpcoList']) { echo "<div id='upcoBar'>\n<div class='barHead move' onmousedown=\"dragMe('upcoBar',event)\">{$xx['hdr_upco_list']}<span class='floatR select' onclick=\"show('upcoBar')\"> ❌ </span></div>\n"; $startD = $_SESSION['cD']; $eTime = mktime(12, 0, 0, substr($startD, 5, 2), substr($startD, 8, 2), substr($startD, 0, 4)) + ($set['lookaheadDays'] - 1) * 86400; //Unix time of end date $endD = date("Y-m-d", $eTime); retrieve($startD, $endD, 'guc'); echo '<h6 class="floatC">' . IDtoDD($startD) . ' - ' . IDtoDD($endD) . "</h6>\n"; //display events echo "<div class='barBody'>\n"; if ($evtList) { $evtDone = array(); $lastDate = ''; foreach ($evtList as $date => &$events) { foreach ($events as $evt) { if (!$evt['mde'] or !in_array($evt['eid'], $evtDone)) { //!mde or mde not processed $evtDone[] = $evt['eid']; $evtDate = $evt['mde'] ? makeD($evt['sda'], 5) . " - " . makeD($evt['eda'], 5) : makeD($date, 5); $evtTime = $evt['ald'] ? $xx['vws_all_day'] : ITtoDT($evt['sti']) . ($evt['eti'] ? ' - ' . ITtoDT($evt['eti']) : ''); $details = ($set['details4All'] == 1 or $set['details4All'] == 2 and $_SESSION['uid'] > 1 or $evt['mayE']); $onClick = $details ? " class='point' onclick=\"editE({$evt['eid']},'{$date}');\"" : " class='arrow'"; if ($set['eventColor']) { $eStyle = ($evt['cco'] ? "color:{$evt['cco']};" : '') . ($evt['cbg'] ? "background-color:{$evt['cbg']};" : ''); } else { $eStyle = $evt['uco'] ? "background-color:{$evt['uco']};" : ''; } $eStyle = $eStyle ? " style='{$eStyle}'" : ''; echo $lastDate != $evtDate ? "<h6>{$evtDate}</h6>\n" : ''; echo "<p>{$evtTime}</p><p{$onClick}{$eStyle}> {$evt['tit']}</p><br>\n"; $lastDate = $evtDate; } } } } else { echo $xx['none'] . "\n"; } echo "</div>\n</div>\n"; } }
function makeHovT(&$evt) { //make hover box time switch ($evt['mde']) { //multi-day event? case 0: return ITtoDT($evt['sti']) . ($evt['eti'] ? ' - ' . ITtoDT($evt['eti']) : ''); //no //no case 1: return (($evt['sti'] != '00:00' and $evt['sti'] != '') ? ITtoDT($evt['sti']) : '•') . '···'; //first //first case 2: return '···'; //in between //in between case 3: return '···' . (($evt['eti'] < '23:59' and $evt['eti'] != '') ? ITtoDT($evt['eti']) : '•'); //last } }
} else { $edate = '9999-00-00'; } if ($ald == 'all') { $stime = '00:00'; $etime = '23:59'; } else { if ($sti) { $stime = DTtoIT($sti); if (!$stime) { $eMsg .= $xx['evt_bad_time'] . ": " . $sti . "<br>"; break; } } elseif ($edate[0] != '9') { $stime = '00:00'; $sti = ITtoDT('00:00'); } else { $eMsg .= $xx['evt_no_start_time'] . "<br>"; break; } if ($eti) { $etime = DTtoIT($eti); if (!$etime) { $eMsg .= $xx['evt_bad_time'] . ": " . $eti . "<br>"; break; } elseif (($edate[0] == '9' or $edate == $sdate) and $etime < $stime) { $eMsg .= $xx['evt_end_before_start_time'] . "<br>"; break; } if ($stime == $etime and $edate[0] == '9') { $etime = '99:00';
function processUpload() { global $ax, $curLine, $calProps, $fromD, $defcatID; $fName = $_FILES['fName']['tmp_name']; if (!$fName) { return $ax['iex_no_file_name']; } //ical file missing $fContent = file_get_contents($fName); //read file unlink($fName); $begin = strpos($fContent, 'BEGIN:VCALENDAR'); if ($begin === false) { return $ax['iex_no_begin_tag']; } //sanity check $fContent = preg_replace("#\r?\n[\\s\t]#m", "", trim(substr($fContent, $begin + 15))); //skip BEGIN and unfold lines $icsLines = preg_split("#\r?\n#", $fContent); //split into lines unset($fContent); //Get calendar categories $rset = dbQuery("SELECT category_id AS cid, name AS cnm FROM [db]categories WHERE status >= 0 ORDER BY category_id"); if ($rset) { $cats = array(); while ($row = mysql_fetch_assoc($rset)) { $cats[$row['cnm']] = $row['cid']; } } //Iterate icsLines $curLine = 1; while (isset($icsLines[$curLine])) { list($key, $value) = explode(':', $icsLines[$curLine++], 2); $key = strtoupper(trim($key)); $value = trim($value); if ($key == "BEGIN" and strtoupper($value) == "VEVENT") { //event start $event = parseEvent($icsLines); if ($event === false) { return $ax['iex_ics_file_error_on_line'] . ": " . $curLine; } //ics file error //save event data if ($event['r_t'] == 0 and (!$event['eda'] or $event['eda'] >= DDtoID($fromD)) or $event['r_t'] != 0 and (!$event['r_u'] or $event['r_u'] >= DDtoID($fromD))) { $curCat = ''; foreach ($cats as $catName => $catID) { if (strpos(strtolower($event['cat']), trim(strtolower($catName))) !== false) { $curCat = $catID; break; } } $_POST['title'][] = $event['tit']; $_POST['venue'][] = $event['ven']; $_POST['descr'][] = $event['des']; $_POST['catID'][] = $curCat ? $curCat : $defcatID; $_POST['sDate'][] = IDtoDD($event['sda']); $_POST['eDate'][] = IDtoDD($event['eda']); $_POST['sTime'][] = ITtoDT($event['sti']); $_POST['eTime'][] = ITtoDT($event['eti']); $_POST['r_t'][] = $event['r_t']; $_POST['r_i'][] = $event['r_i']; $_POST['r_p'][] = $event['r_p']; $_POST['r_m'][] = $event['r_m']; $_POST['r_u'][] = IDtoDD($event['r_u']); $_POST['delete'][] = 0; } } else { //meta data if (in_array($key, $calProps)) { $_POST[$key] = $value; //save meta data } } } return ''; //no error }
function showEvents($date) { global $evtList, $privs, $set, $xx, $rxULink, $rxIMGTags; $showDetails = ($set['details4All'] == 1 or $set['details4All'] == 2 and $_SESSION['uid'] > 1); foreach ($evtList[$date] as $evt) { $time = makeHovT($evt); $dTime = $evt['mde'] ? $time : ITtoDT($evt['sti']); $chBox = ''; if ($evt['cbx']) { $mayCheck = ($privs > 3 or $privs > 1 and $evt['uid'] == $_SESSION['uid']); //boolean $chBox .= strpos($evt['chd'], $date) ? $evt['cmk'] : '☐'; $cBoxAtt = $mayCheck ? "class='chkBox floatL point' onclick=\"checkE({$evt['eid']},'{$date}');\" title=\"{$xx['vws_check_mark']}\"" : 'class="chkBox floatL arrow"'; $chBox = "<span {$cBoxAtt}>{$chBox}</span>"; } if ($set['popBoxMonth'] and $set['popBoxFields']) { $popText = "<b>{$time} {$evt['tix']}</b><br>"; if ($showDetails or $evt['mayE']) { $popText .= makeE($evt, $set['popBoxFields'], 'br', '<br>'); } $popText = htmlspecialchars(addslashes($popText)); $popClass = ($evt['pri'] ? 'private' : 'normal') . (($evt['mde'] or $evt['r_t']) ? ' repeat' : ''); $popAttr = " onmouseover=\"pop(this,'{$popText}','{$popClass}')\""; } else { $popAttr = ''; } if ($set['eventColor']) { //use event color $eStyle = ($evt['cco'] ? "color:{$evt['cco']};" : '') . ($evt['cbg'] ? "background-color:{$evt['cbg']};" : ''); } else { //use user color $eStyle = $evt['uco'] ? "background-color:{$evt['uco']};" : ''; } if ($evt['app'] and !$evt['apd']) { $eStyle .= 'border-left:2px solid #ff0000;'; } $eStyle = $eStyle ? ' style="' . $eStyle . '"' : ''; echo "<div class='event'{$eStyle}>\n"; echo "<div>{$chBox}<span " . (($showDetails or $evt['mayE']) ? "class='evtTitle point' onclick=\"editE(" . $evt['eid'] . ",'" . $date . "');\"" : "class='evtTitle arrow'") . $popAttr . ">{$dTime} {$evt['tix']}</span></div>\n"; if ($evt['ven']) { //venue set $_SESSION['venList'][$evt['ven']] = true; //save it as an array key } if ($set['showImageInMV'] and preg_match_all($rxIMGTags, $evt['des'] . $evt['xf1'] . $evt['xf2'], $imgs, PREG_SET_ORDER)) { echo "<div>"; foreach ($imgs as $img) { echo $img[0] . "<br>"; } echo "</div>\n"; } if ($set['showLinkInMV'] and preg_match_all($rxULink, $evt['des'] . $evt['xf1'] . $evt['xf2'], $urls, PREG_SET_ORDER)) { //display URL links echo "<div>"; foreach ($urls as $url) { echo $url[0] . "<br>"; } echo "</div>\n"; } echo "</div>\n"; } }
function showHours() { global $set, $xx; //build day $tsHeight = $set['dwTsHeight'] - 1; echo "<div class='timeFrame'>\n"; echo "<div class='times' style='height:{$tsHeight}px;'>{$xx['vws_all_day']}</div>\n"; $i = $set['dwStartHour']; $j = 0; if ($set['dwStartHour']) { echo "<div class='times' style='height:{$tsHeight}px;'>{$xx['vws_earlier']}</div>\n"; } while ($i < $set['dwEndHour']) { echo "<div class='times' style='height:{$tsHeight}px;'>" . ITtoDT(str_pad($i, 2, "0", STR_PAD_LEFT) . ":" . str_pad($j, 2, "0", STR_PAD_LEFT)) . "</div>\n"; $j = ($j + $set['dwTimeSlot']) % 60; if ($j == 0) { $i++; } } if ($set['dwEndHour'] < 24) { echo "<div class='times' style='height:{$tsHeight}px;'>{$xx['vws_later']}</div>\n"; } echo "</div>\n"; }
$curD = $_SESSION['cD']; $curT = mktime(12, 0, 0, substr($curD, 5, 2), substr($curD, 8, 2), substr($curD, 0, 4)); //current Unix time $startD = date("Y-m-d", $curT - 30 * 86400); //current date - 1 month $endD = date("Y-m-d", $curT + ($set['lookaheadDays'] - 1) * 86400); //current date + look ahead nr of days $filter = '(c.chbox = 1)'; //events in cat with a check mark retrieve($startD, $endD, 'u', $filter); //display todo list if ($evtList) { foreach ($evtList as $date => &$events) { echo "<h6>" . makeD($date, 5) . "</h6>\n"; foreach ($events as $evt) { $evtTime = $evt['ald'] ? $xx['vws_all_day'] : ITtoDT($evt['sti']) . ($evt['eti'] ? ' - ' . ITtoDT($evt['eti']) : ''); $onClick = ($set['details4All'] == 1 or $set['details4All'] == 2 and $_SESSION['uid'] > 1 or $evt['mayE']) ? " class='point' onclick=\"editE({$evt['eid']},'{$date}');\"" : " class='arrow'"; if ($set['eventColor']) { $eStyle = ($evt['cco'] ? "color:{$evt['cco']};" : '') . ($evt['cbg'] ? "background-color:{$evt['cbg']};" : ''); } else { $eStyle = $evt['uco'] ? "background-color:{$evt['uco']};" : ''; } $eStyle = $eStyle ? " style='{$eStyle}'" : ''; $chBox = ''; if ($evt['cbx']) { $chBox .= strpos($evt['chd'], $date) ? $evt['cmk'] : '☐'; } if ($chBox) { $mayCheck = ($privs > 3 or $privs > 1 and $evt['uid'] == $_SESSION['uid']) ? true : false; $attrib = $mayCheck ? "class='chkBox floatL point' onclick=\"checkE({$evt['eid']},'{$date}');\" title=\"{$xx['vws_check_mark']}\"" : "class='chkBox floatL arrow'"; $chBox = "<div {$attrib}>" . trim($chBox) . "</div>";
function showMatches() { global $privs, $set, $xx, $evtList, $schText; //display matching events echo '<div class="eventBg">' . "\n"; if ($evtList) { $match = '%(' . str_replace(array('_', '&'), array('.', '[^<>]+?'), $schText) . ')(?![^<]*>)%i'; //convert to regex (?!: neg.look-ahead condition) $evtDone = array(); $lastDate = ''; foreach ($evtList as $date => &$events) { foreach ($events as $evt) { if (!$evt['mde'] or !in_array($evt['eid'], $evtDone)) { //!mde or mde not processed $evtDone[] = $evt['eid']; $evtDate = $evt['mde'] ? makeD($evt['sda'], 5) . " - " . makeD($evt['eda'], 5) : makeD($date, 5); $evtTime = $evt['ald'] ? $xx['vws_all_day'] : ITtoDT($evt['sti']) . ($evt['eti'] ? ' - ' . ITtoDT($evt['eti']) : ''); if ($set['eventColor']) { $eStyle = ($evt['cco'] ? "color:{$evt['cco']};" : '') . ($evt['cbg'] ? "background-color:{$evt['cbg']};" : ''); } else { $eStyle = $evt['uco'] ? "background-color:{$evt['uco']};" : ''; } $eStyle = $eStyle ? ' style="' . $eStyle . '"' : ''; $chBox = ''; if ($evt['cbx']) { $chBox .= !$evt['mde'] ? strpos($evt['chd'], $date) ? $evt['cmk'] : '☐' : '?'; } if ($chBox) { $mayCheck = ($privs > 3 or $privs > 1 and $evt['uid'] == $_SESSION['uid']) ? true : false; $attrib = ($mayCheck and !$evt['mde']) ? " class='chkBox point' onclick=\"checkE({$evt['eid']},'{$date}');\" title=\"{$xx['vws_check_mark']}\"" : 'class="chkBox arrow"'; $chBox = "<span{$attrib}>" . trim($chBox) . "</span> "; } if ($evt['app'] and !$evt['apd']) { $eBoxStyle = 'border-left:2px solid #ff0000;'; } $eBoxStyle = $eBoxStyle ? " style='{$eBoxStyle}'" : ''; echo $lastDate != $evtDate ? "<br><h6><a href='index.php?lc&cP=2&cD={$date}' title=\"{$xx['sch_calendar']}\">{$evtDate}</a></h6>\n" : "<br>\n"; echo "<table>\n<tr>\n\t\t\t\t\t\t<td class='widthCol1'>{$evtTime}</td>\n\t\t\t\t\t\t<td class='eBox'{$eBoxStyle}>"; if ($set['details4All'] == 1 or $set['details4All'] == 2 and $_SESSION['uid'] > 1 or $evt['mayE']) { echo "<h6>{$chBox}<span class='point'{$eStyle} onclick=\"editE({$evt['eid']},'{$date}');\">" . preg_replace($match, '<mark>$1</mark>', $evt['tit']) . "</span></h6>\n"; echo makeE($evt, $set['evtTemplGen'], 'br', "<br>\n") . "\n"; } else { echo "<h6>{$chBox}<span{$eStyle}>" . preg_replace($match, '<mark>$1</mark>', $evt['tit']) . "</span></h6>\n"; } echo "</td></tr></table>\n"; $lastDate = $evtDate; } } } } else { echo $xx['sch_no_results'] . "\n"; } echo "</div>\n"; }
function showGrid($date) { global $evtList, $privs, $set, $xx, $rxULink; if (!array_key_exists($date, $evtList)) { return; } $showDetails = ($set['details4All'] == 1 or $set['details4All'] == 2 and $_SESSION['uid'] > 1); foreach ($evtList[$date] as $evt) { $mayCheck = ($privs > 3 or $privs > 1 and $evt['uid'] == $_SESSION['uid']) ? true : false; switch ($evt['mde']) { //multi-day event? case 0: $time = ITtoDT($evt['sti']); break; //no //no case 1: $time = (($evt['sti'] != '00:00' and $evt['sti'] != '') ? ITtoDT($evt['sti']) : '•') . '···'; break; //first //first case 2: $time = '···'; break; //in between //in between case 3: $time = '···' . (($evt['eti'] < '23:59' and $evt['eti'] != '') ? ITtoDT($evt['eti']) : '•'); //last } $chBox = ''; if ($evt['cbx']) { $chBox .= strpos($evt['chd'], $date) ? $evt['cmk'] : '☐'; $cBoxAtt = $mayCheck ? "class='chkBox floatL point' onclick=\"checkE({$evt['eid']},'{$date}');\" title=\"{$xx['vws_check_mark']}\"" : 'class="chkBox floatL arrow"'; $chBox = "<span {$cBoxAtt}>{$chBox}</span>"; } if ($set['popBoxMonth'] and $set['popBoxFields']) { $popText = "<b>{$time}" . ((!$evt['mde'] and $evt['eti']) ? ' - ' . ITtoDT($evt['eti']) : '') . " {$evt['tit']}</b><br>"; if ($showDetails or $evt['mayE']) { $popText .= makeE($evt, $set['popBoxFields'], 'br', '<br>'); } $popText = htmlspecialchars(addslashes($popText)); $popClass = ($evt['pri'] ? 'private' : 'normal') . (($evt['mde'] or $evt['r_t']) ? ' repeat' : ''); $popAttr = " onmouseover=\"pop(this,'{$popText}','{$popClass}')\""; } else { $popAttr = ''; } if ($set['eventColor']) { $eStyle = ($evt['cco'] ? "color:{$evt['cco']};" : '') . ($evt['cbg'] ? "background-color:{$evt['cbg']};" : ''); } else { $eStyle = $evt['uco'] ? "background-color:{$evt['uco']};" : ''; } if ($evt['app'] and !$evt['apd']) { $eStyle .= 'border-left:2px solid #ff0000;'; } $eStyle = $eStyle ? ' style="' . $eStyle . '"' : ''; echo "<div class='event'{$eStyle}>\n"; echo "<div>{$chBox}<span " . (($showDetails or $evt['mayE']) ? "class='evtTitle point' onclick=\"editE(" . $evt['eid'] . ",'" . $date . "');\"" : "class='evtTitle arrow'") . $popAttr . ">{$time} {$evt['tit']}</span></div>\n"; if ($set['showLinkInMV'] and preg_match_all($rxULink, $evt['des'] . $evt['xf1'] . $evt['xf2'], $urls, PREG_SET_ORDER)) { //display URL links echo "<div>"; foreach ($urls as $url) { echo $url[0] . "<br>"; } echo "</div>\n"; } echo "</div>\n"; } }