function list_regs($reg_array) { $list = ''; foreach ($reg_array as $reg) { $ticket = ''; switch ($reg['ticket']) { case 'dag': $ticket = 'dag (€ 10)'; break; case 'dag_overnacht': $ticket = 'dag met overnachting (€ 12,50)'; break; case 'overnacht': $ticket = 'overnachting (€ 7,50)'; break; default: $ticket = 'onbekend'; break; } $extra = !empty($reg['sharing']) || !empty($reg['comments']) ? 'ja' : '-'; $list .= '<tr>'; $list .= '<td>' . $reg['fullname'] . '</td>'; $list .= '<td>' . $ticket . '</td>'; $list .= '<td>' . $extra . '</td>'; $list .= '<td>' . display_time($reg['time']) . '</td>'; $list .= '</tr>' . "\r\n"; } return $list; }
</td> </tr>'; } if (Doc::commentsEnabled()) { echo ' <tr> <td class="aligntop bold">' . translate('Comments') . ':</td> <td>'; $comList = new CommentList($id); $num_comment = $comList->getSize(); $comment_text = ''; for ($i = 0; $i < $num_comment; $i++) { $cmt = $comList->getDoc($i); user_load_variables($cmt->getLogin(), 'cmt_'); $comment_text .= ' <strong>' . htmlspecialchars($cmt->getDescription()) . '</strong> - ' . $cmt_fullname . ' ' . translate('at') . ' ' . date_to_str($cmt->getModDate(), '', false, true) . ' ' . display_time($cmt->getModTime(), 2) . ($is_admin || $login == $cmt->getLogin() || user_is_assistant($login, $cmt->getLogin()) || $login == $create_by || user_is_assistant($login, $create_by) ? ' [<a href="docdel.php?blid=' . $cmt->getId() . '" onclick="return confirm( \'' . $areYouSureStr . '\' );">' . translate('Delete') . '</a>]' : '') . '<br /> <blockquote id="eventcomment">' . nl2br(activate_urls(htmlspecialchars($cmt->getData()))) . ' </blockquote><div style="clear:both"></div>'; } if ($num_comment == 0) { echo translate('None') . '<br />'; } else { echo ' ' . $num_comment . ' ' . translate('comments') . ' <input id="showbutton" type="button" value="' . translate('Show') . '" onclick="showComments();" /> <input id="hidebutton" type="button" value="' . translate('Hide') . '" onclick="hideComments();" /><br /> <div id="comtext">' . $comment_text . '</div>'; // We could put the following JS in includes/js/view_entry.php, // but we won't need it in many cases and we don't know whether // we need it until after would need to include it. // So, we will include it here instead.
function list_unapproved($user) { global $temp_fullname, $key, $login; //echo "Listing events for $user <BR>"; echo "<UL>\n"; $sql = "SELECT webcal_entry.cal_id, webcal_entry.cal_name, " . "webcal_entry.cal_description, " . "webcal_entry.cal_priority, webcal_entry.cal_date, " . "webcal_entry.cal_time, webcal_entry.cal_duration, " . "webcal_entry_user.cal_status " . "FROM webcal_entry, webcal_entry_user " . "WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " . "AND ( webcal_entry.cal_ext_for_id IS NULL " . "OR webcal_entry.cal_ext_for_id = 0 ) AND " . "webcal_entry_user.cal_login = '******' AND " . "webcal_entry_user.cal_status = 'W' " . "ORDER BY webcal_entry.cal_date"; $res = dbi_query($sql); $count = 0; $eventinfo = ""; if ($res) { while ($row = dbi_fetch_row($res)) { $key++; $id = $row[0]; $name = $row[1]; $description = $row[2]; $pri = $row[3]; $date = $row[4]; $time = $row[5]; $duration = $row[6]; $status = $row[7]; $divname = "eventinfo-{$id}-{$key}"; echo "<LI><A CLASS=\"entry\" HREF=\"view_entry.php?id={$id}"; echo "\" onMouseOver=\"window.status='" . translate("View this entry") . "'; show(event, '{$divname}'); return true;\" onMouseOut=\"hide('{$divname}'); return true;\">"; $timestr = ""; if ($time > 0) { $timestr = display_time($time); if ($duration > 0) { // calc end time $h = (int) ($time / 10000); $m = $time / 100 % 100; $m += $duration; $d = $duration; while ($m >= 60) { $h++; $m -= 60; } $end_time = sprintf("%02d%02d00", $h, $m); $timestr .= " - " . display_time($end_time); } } echo htmlspecialchars($name); echo "</A>"; echo " (" . date_to_str($date) . ")\n"; echo ": <A HREF=\"approve_entry.php?id={$id}&ret=list"; if ($user == "__public__") { echo "&public=1"; } echo "\" CLASS=\"navlinks\" onClick=\"return confirm('" . translate("Approve this entry?") . "');\">" . translate("Approve/Confirm") . "</A>, "; echo "<A HREF=\"reject_entry.php?id={$id}&ret=list"; if ($user == "__public__") { echo "&public=1"; } echo "\" CLASS=\"navlinks\" onClick=\"return confirm('" . translate("Reject this entry?") . "');\">" . translate("Reject") . "</A>"; $eventinfo .= build_event_popup($divname, $user, $description, $timestr, $time); $count++; } dbi_free_result($res); } echo "</UL><P>\n"; if ($count == 0) { user_load_variables($user, "temp_"); echo translate("No unapproved events for") . " " . $temp_fullname . "."; } else { echo $eventinfo; } }
</label> <select name="admin_WORK_DAY_START_HOUR" id="workstart"> <?php for ($i = 0; $i < 24; $i++) { echo "<option value=\"{$i}\"" . ($i == $s["WORK_DAY_START_HOUR"] ? " selected=\"selected\"" : "") . ">" . display_time($i * 10000, 1) . "</option>\n"; } ?> </select> <label for="workend"><?php etranslate("to"); ?> </label> <select name="admin_WORK_DAY_END_HOUR" id="workend"> <?php for ($i = 0; $i < 24; $i++) { echo "<option value=\"{$i}\"" . ($i == $s["WORK_DAY_END_HOUR"] ? " selected=\"selected\"" : "") . ">" . display_time($i * 10000, 1) . "</option>\n"; } ?> </select> </td></tr> <tr><td class="tooltip" title="<?php etooltip("disable-priority-field-help"); ?> "> <?php etranslate("Disable Priority field"); ?> :</td><td> <label><input type="radio" name="admin_disable_priority_field" value="Y"<?php if ($s["disable_priority_field"] != "N") { echo " checked=\"checked\"";
</label> <select name="pref_WORK_DAY_START_HOUR" id="pref_starthr"> <?php for ($i = 0; $i < 24; $i++) { echo "<option value=\"{$i}\"" . ($i == $prefarray['WORK_DAY_START_HOUR'] ? $selected : '') . ">" . display_time($i * 10000, 1) . "</option>\n"; } ?> </select> <label for="pref_endhr"><?php etranslate('to'); ?> </label> <select name="pref_WORK_DAY_END_HOUR" id="pref_endhr"> <?php for ($i = 0; $i < 24; $i++) { echo "<option value=\"{$i}\"" . ($i == $prefarray['WORK_DAY_END_HOUR'] ? $selected : '') . ">" . display_time($i * 10000, 1) . "</option>\n"; } ?> </select> </td></tr> </table> </fieldset> <fieldset> <legend><?php etranslate('Appearance'); ?> </legend> <table cellspacing="1" cellpadding="2" border="0"> <tr><td class="tooltip" title="<?php etooltip('preferred-view-help');
$tmp = $prad ? $s['DATE_FORMAT_TASK'] : $prefarray['DATE_FORMAT_TASK']; for ($i = 0, $cnt = count($datestyles_task); $i < $cnt; $i++) { $datestyle_tk .= $option . $datestyles_task[$i] . '"' . ($tmp == $datestyles_task[$i] ? $selected : '') . '>' . $datestyles_task[++$i] . '</option>'; } $tmp_wk = $prad ? $s['WEEK_START'] : $prefarray['WEEK_START']; $tmp_en = $prad ? $s['WEEKEND_START'] : $prefarray['WEEKEND_START']; for ($i = 0; $i < 7; $i++) { $start_wk_on .= $option . "{$i}\"" . ($i == $tmp_wk ? $selected : '') . '>' . weekday_name($i) . '</option>'; $j = $i == 0 ? 6 : $i - 1; // Make sure to start with Saturday. $start_wkend_on .= $option . "{$j}\"" . ($j == $tmp_en ? $selected : '') . '>' . weekday_name($j) . '</option>'; } $tmp_st = $prad ? $s['WORK_DAY_START_HOUR'] : $prefarray['WORK_DAY_START_HOUR']; $tmp_en = $prad ? $s['WORK_DAY_END_HOUR'] : $prefarray['WORK_DAY_END_HOUR']; for ($i = 0; $i < 24; $i++) { $tmp = display_time($i * 10000, 1); $work_hr_start .= $option . "{$i}\"" . ($i == $tmp_st ? $selected : '') . '>' . $tmp . '</option>'; $work_hr_end .= $option . "{$i}\"" . ($i == $tmp_en ? $selected : '') . '>' . $tmp . '</option>'; } $tmp = $prad ? $s['STARTVIEW'] : $prefarray['STARTVIEW']; for ($i = 0, $cnt = count($choices); $i < $cnt; $i++) { $prefer_vu .= $option . $choices[$i] . '"' . ($tmp == $choices[$i] ? $selected : '') . '>' . htmlspecialchars($choices_text[$i]) . '</option>'; } // Allow user to select a view also. $tmp = $prad ? $s['STARTVIEW'] : $prefarray['STARTVIEW']; for ($i = 0, $cnt = count($views); $i < $cnt; $i++) { if ($views[$i]['cal_is_global'] != 'Y' && ($prad || $views[$i]['cal_owner'] != $user)) { continue; } $xurl = $views[$i]['url']; $xurl_strip = str_replace('&', '&', $xurl);
$sql .= "ORDER BY webcal_entry_log.cal_log_id DESC"; $res = dbi_query($sql); $nextpage = ""; if ($res) { $num = 0; while ($row = dbi_fetch_row($res)) { $num++; if ($num > $PAGE_SIZE) { $nextpage = $row[7]; break; } else { echo "<tr"; if ($num % 2) { echo " class=\"odd\""; } echo "><td>\n" . $row[0] . "</td><td>\n" . $row[1] . "</td><td>\n" . date_to_str($row[3]) . " " . display_time($row[4]) . "</td><td>\n" . "<a title=\"" . htmlspecialchars($row[6]) . "\" href=\"view_entry.php?id={$row['5']}\">" . htmlspecialchars($row[6]) . "</a></td><td>\n"; if ($row[2] == $LOG_CREATE) { etranslate("Event created"); } else { if ($row[2] == $LOG_APPROVE) { etranslate("Event approved"); } else { if ($row[2] == $LOG_REJECT) { etranslate("Event rejected"); } else { if ($row[2] == $LOG_UPDATE) { etranslate("Event updated"); } else { if ($row[2] == $LOG_DELETE) { etranslate("Event deleted"); } else {
dbi_free_result($res); } if ($time != '-1') { $hour = substr($time, 0, 2); $minute = substr($time, 2, 2); } for ($i = 0; $i < count($partlogin); $i++) { // does this user want email for this? $send_user_mail = get_pref_setting($partlogin[$i], "EMAIL_EVENT_REJECTED"); user_load_variables($partlogin[$i], "temp"); $user_language = get_pref_setting($partlogin[$i], "LANGUAGE"); if ($send_user_mail == "Y" && strlen($tempemail) && $send_email != "N") { if ($GLOBALS['LANGUAGE'] != $user_language && !empty($user_language) && $user_language != 'none') { reset_language($user_language); } $msg = translate("Hello") . ", " . $tempfullname . ".\n\n" . translate("An appointment has been rejected by") . " " . $login_fullname . ". " . translate("The subject was") . " \"" . $name . " \"\n" . translate("The description is") . " \"" . $description . "\"\n" . translate("Date") . ": " . date_to_str($fmtdate) . "\n" . (empty($hour) && empty($minute) ? "" : translate("Time") . ": " . display_time($hour * 10000 + $minute * 100)) . "\n\n\n"; if (!empty($server_url)) { $url = $server_url . "view_entry.php?id=" . $id; $msg .= "\n\n" . $url; } $from = $email_fallback_from; if (strlen($login_email)) { $from = $login_email; } $extra_hdrs = "From: {$from}\r\nX-Mailer: " . translate("Title"); mail($tempemail, translate($application_name) . " " . translate("Notification") . ": " . $name, html_to_8bits($msg), $extra_hdrs); activity_log($id, $login, $partlogin[$i], $LOG_NOTIFICATION, "Event rejected by {$app_user}"); } } } if (empty($error)) {
etranslate("Scheduling Conflict"); ?> </h2> <?php etranslate("Your suggested time of"); ?> <span style="font-weight:bold;"> <?php if (!empty($allday) && $allday == "Y") { etranslate("All day event"); } else { $time = sprintf("%d%02d00", $hour, $minute); echo display_time($time); if ($duration > 0) { echo "-" . display_time(add_duration($time, $duration)); } } ?> </span> <?php etranslate("conflicts with the following existing calendar entries"); ?> : <ul> <?php echo $conflicts; ?> </ul> <?php // user can confirm conflicts
function print_entry_timebar($id, $date, $time, $duration, $name, $description, $status, $pri, $access, $event_owner) { global $eventinfo, $login, $user, $PHP_SELF, $prefarray; static $key = 0; global $layers; // compute time offsets in % of total table width $day_start = $prefarray["WORK_DAY_START_HOUR"] * 60; if ($day_start == 0) { $day_start = 9 * 60; } $day_end = $prefarray["WORK_DAY_END_HOUR"] * 60; if ($day_end == 0) { $day_end = 19 * 60; } if ($day_end <= $day_start) { $day_end = $day_start + 60; } //avoid exceptions if ($time >= 0) { $ev_start = $time / 10000 * 60 + $time / 100 % 100; $ev_start = round(100 * ($ev_start - $day_start) / ($day_end - $day_start)); } else { $ev_start = 0; } if ($duration > 0) { $ev_duration = round(100 * $duration / ($day_end - $day_start)); if ($ev_start + $ev_duration > 100) { $ev_duration = 100 - $ev_start; } } else { if ($time >= 0) { $ev_duration = 1; } else { $ev_duration = 100 - $ev_start; } } $ev_padding = 100 - $ev_start - $ev_duration; // choose where to position the text (pos=0->before,pos=1->on,pos=2->after) if ($ev_duration > 20) { $pos = 1; } elseif ($ev_padding > 20) { $pos = 2; } else { $pos = 0; } echo "\n<!-- ENTRY BAR -->\n<table class=\"entrycont\">\n"; echo "<tr>\n"; echo "<td style=\"text-align:right; width:{$ev_start}%;\">"; if ($pos > 0) { echo " </td>\n"; echo "<td style=\"width:{$ev_duration}%;\">\n<table class=\"entrybar\">\n<tr>\n<td class=\"entry\">"; if ($pos > 1) { echo " </td>\n</tr>\n</table></td>\n"; echo "<td style=\"text-align:left; width:{$ev_padding}%;\">"; } } //TODO: The following section has several nested spans. if ($login != $event_owner && strlen($event_owner)) { $class = "layerentry"; } else { $class = "entry"; if ($status == "W") { $class = "unapprovedentry"; } } // if we are looking at a view, then always use "entry" if (strstr($PHP_SELF, "view_m.php") || strstr($PHP_SELF, "view_w.php") || strstr($PHP_SELF, "view_v.php") || strstr($PHP_SELF, "view_t.php")) { $class = "entry"; } if ($pri == 3) { echo "<span style=\"font-weight:bold;\">"; } $popupid = "eventinfo-{$id}-{$key}"; $key++; echo "<a class=\"{$class}\" href=\"view_entry.php?id={$id}&date={$date}"; if (strlen($user) > 0) { echo "&user="******"\" onmouseover=\"window.status='" . translate("View this entry") . "'; show(event, '{$popupid}'); return true;\" onmouseout=\"hide('{$popupid}'); return true;\">"; if ($login != $event_owner && strlen($event_owner)) { if ($layers) { foreach ($layers as $layer) { if ($layer['cal_layeruser'] == $event_owner) { echo "<span style=\"color:" . $layer['cal_color'] . ";\">"; } } } } echo "[{$event_owner}] "; $timestr = ""; if ($duration == 24 * 60) { $timestr = translate("All day event"); } else { if ($time >= 0) { $timestr = display_time($time); if ($duration > 0) { // calc end time $h = (int) ($time / 10000); $m = $time / 100 % 100; $m += $duration; $d = $duration; while ($m >= 60) { $h++; $m -= 60; } $end_time = sprintf("%02d%02d00", $h, $m); $timestr .= " - " . display_time($end_time); } } } if ($login != $user && $access == 'R' && strlen($user)) { echo "(" . translate("Private") . ")"; } else { if ($login != $event_owner && $access == 'R' && strlen($event_owner)) { echo "(" . translate("Private") . ")"; } else { if ($login != $event_owner && strlen($event_owner)) { echo htmlspecialchars($name); echo "</span>"; //end color span } else { echo htmlspecialchars($name); } } } echo "</a>"; if ($pri == 3) { echo "</span>"; } //end font-weight span echo "</td>\n"; if ($pos < 2) { if ($pos < 1) { echo "<td style=\"width:{$ev_duration}%;\"><table style=\"width:100%; border-width:0px; background-color:#000000;\" cellpadding=\"0\" cellspacing=\"1\">\n<tr>\n<td style=\"text-align:center; background-color:#F5DEB3;\"> </td>\n"; } echo "</tr>\n</table></td>\n"; echo "<td style=\"text-align:left; width:{$ev_padding}%;\"> </td>\n"; } echo "</tr>\n</table>\n"; if ($login != $user && $access == 'R' && strlen($user)) { $eventinfo .= build_event_popup($popupid, $event_owner, translate("This event is confidential"), ""); } else { if ($login != $event_owner && $access == 'R' && strlen($event_owner)) { $eventinfo .= build_event_popup($popupid, $event_owner, translate("This event is confidential"), ""); } else { $eventinfo .= build_event_popup($popupid, $event_owner, $description, $timestr, site_extras_for_popup($id)); } } }
function sort_events_insensitive($a, $b) { $retval = strnatcmp(display_time('', 0, $a->getDateTimeTS(), 24), display_time('', 0, $b->getDateTimeTS(), 24)); return $retval ? $retval : strnatcmp(strtolower($a->getName()), strtolower($b->getName())); }
$sql .= "ORDER BY webcal_entry_log.cal_log_id DESC"; $res = dbi_query($sql); $nextpage = ""; if ($res) { $font = "<FONT SIZE=\"-1\">"; $num = 0; while ($row = dbi_fetch_row($res)) { $num++; if ($num > $PAGE_SIZE) { $nextpage = $row[7]; break; } else { echo "<TR>"; echo "<TD VALIGN=\"top\" BGCOLOR=\"{$CELLBG}\">" . $font . $row[0] . "</FONT></TD>"; echo "<TD VALIGN=\"top\" BGCOLOR=\"{$CELLBG}\">" . $font . $row[1] . "</FONT></TD>"; echo "<TD VALIGN=\"top\" BGCOLOR=\"{$CELLBG}\">" . $font . date_to_str($row[3]) . " " . display_time($row[4]) . "</FONT></TD>"; echo "<TD VALIGN=\"top\" BGCOLOR=\"{$CELLBG}\">" . $font . "<A HREF=\"view_entry.php?id={$row['5']}\" CLASS=\"navlinks\">" . htmlspecialchars($row[6]) . "</A></FONT></TD>"; echo "<TD VALIGN=\"top\" BGCOLOR=\"{$CELLBG}\">" . $font; if ($row[2] == $LOG_CREATE) { etranslate("Event created"); } else { if ($row[2] == $LOG_APPROVE) { etranslate("Event approved"); } else { if ($row[2] == $LOG_REJECT) { etranslate("Event rejected"); } else { if ($row[2] == $LOG_UPDATE) { etranslate("Event updated"); } else { if ($row[2] == $LOG_DELETE) {
} if (!empty($conflicts)) { print_header(); ob_start(); echo ' <h2>' . translate('Scheduling Conflict') . '</h2> ' . translate('Your suggested time of') . ' <span class="bold">'; if ($timetype == 'A') { etranslate('All day event'); } else { $time = sprintf("%d%02d00", $entry_hour, $entry_minute); // Pass the adjusted timestamp in case the date changed due to GMT offset. echo display_time('', 0, $eventstart); if ($duration > 0) { echo '-' . display_time('', 0, $eventstart + $duration * 60); } } echo '</span> ' . translate('conflicts with the following existing calendar entries') . ': <ul>' . $conflicts . ' </ul> ' . '<form name="confirm" method="post">'; foreach ($_POST as $xkey => $xval) { if (is_array($xval)) { $xkey .= "[]"; foreach ($xval as $ykey => $yval) { if (get_magic_quotes_gpc()) { $yval = stripslashes($yval); } // $yval = htmlentities ( $yval );
<td' . (!empty($untimed[$i]) && strlen($untimed[$i]) ? ' class="hasevents"' : $class) . '>' . (!empty($untimed[$i]) && strlen($untimed[$i]) ? $untimed[$i] : ' ') . '</td>'; $save_hour_arr[$i] = $hour_arr; $save_rowspan_arr[$i] = $rowspan_arr; $rowspan_day[$i] = 0; } $untimedStr = $untimed_found ? ' <tr> <th class="empty"> </th>' . $untimedStr . ' </tr>' : ''; for ($i = $first_slot; $i <= $last_slot; $i++) { $time_h = intval($i * $interval / 60); $time_m = $i * $interval % 60; // Do not apply TZ offset. $eventsStr .= ' <tr> <th class="row">' . display_time(($time_h * 100 + $time_m) * 100, 1) . '</th>'; for ($d = $start_ind; $d <= $end_ind; $d++) { $dateYmd = date('Ymd', $days[$d]); // Class "hasevents" overrides both "today" and "weekend". // And class "today" overrides "weekend". // So, no need to list them all. $class = !empty($save_hour_arr[$d][$i]) && strlen($save_hour_arr[$d][$i]) ? ' class="hasevents"' : ($dateYmd == date('Ymd', $today) ? ' class="today"' : (is_weekend($days[$d]) ? ' class="weekend"' : '')); if ($rowspan_day[$d] > 1) { // This might mean there's an overlap, // or it could mean one event ends at 11:15 and another starts at 11:30. if (!empty($save_hour_arr[$d][$i])) { $eventsStr .= ' <td' . $class . '>' . $save_hour_arr[$d][$i] . '</td>'; } $rowspan_day[$d]--; } else {
function print_upcoming_event($e) { global $display_link, $link_target, $server_url, $charset; if ($e['cal_access'] == 'P') { if ($display_link && !empty($server_url)) { print "<a title=\"" . $e['cal_name'] . "\" href=\"" . $server_url . "view_entry.php?id=" . $e['cal_id'] . "&date=" . $e['cal_date'] . "\""; if (!empty($link_target)) { print " target=\"{$link_target}\""; } print ">"; } print $e['cal_name']; } else { print "[" . translate("Confidential") . "]"; } if ($display_link && !empty($server_url)) { print "</a>"; } if ($e['cal_duration'] == 24 * 60) { print " (" . translate("All day event") . ")\n"; } else { if ($e['cal_time'] != -1) { print " (" . display_time($e['cal_time']) . ")\n"; } } print "<br />\n"; }
function print_entry_timebar($event, $date) { global $ENTRY_SLOTS, $entrySlots, $eventinfo, $login, $PHP_SELF, $PUBLIC_ACCESS_FULLNAME, $slotValue, $totalHours, $totalSlots, $user, $width, $WORK_DAY_END_HOUR, $WORK_DAY_START_HOUR, $yardSlots, $yardWidth; static $key = 0; $insidespan = false; $ret = ''; if (access_is_enabled()) { $temp = $event->getLogin(); $can_access = access_user_calendar('view', $temp, '', $event->getCalType(), $event->getAccess()); $time_only = access_user_calendar('time', $temp); } else { $can_access = CAN_DOALL; $time_only = 'N'; } $id = $event->getID(); $name = $event->getName(); $linkid = "pop{$id}-{$key}"; $key++; $day_start = $WORK_DAY_START_HOUR * 60; $day_end = $WORK_DAY_END_HOUR * 60; if ($day_end <= $day_start) { $day_end = $day_start + 60; } //Avoid exceptions. $time = date('His', $event->getDateTimeTS()); $startminutes = time_to_minutes($time); $endminutes = time_to_minutes(date('His', $event->getEndDateTimeTS())); $duration = $event->getDuration(); if ($event->isAllDay()) { // All day event. $ev_duration = $totalSlots; $start_padding = 0; } else { if ($event->isUntimed()) { $ev_duration = $start_padding = 0; } else { // Must be timed. $start_padding = round(($startminutes - $day_start) / $slotValue); if ($start_padding < 0) { $start_padding = 0; } if ($startminutes > $day_end || $endminutes < $day_start) { $ev_duration = 1; } else { if ($duration > 0) { $ev_duration = intval($duration / $slotValue); // Event starts before workday. if ($startminutes < $day_start) { $ev_duration = $ev_duration - (int) ($day_start - $startminutes) / $slotValue; } // Event ends after workday. if ($endminutes > $day_end) { $ev_duration = $ev_duration - (int) ($endminutes - $day_end) / $slotValue; } } } } } $end_padding = $totalSlots - $start_padding - $ev_duration + 1; // If event is past viewing area. if ($start_padding >= $totalSlots) { $ev_duration = 1; $start_padding = $totalSlots - 1; } // Choose where to position the text (pos=0->before,pos=1->on,pos=2->after). if ($ev_duration / $totalSlots >= 0.3) { $pos = 1; } elseif ($end_padding / $totalSlots >= 0.3) { $pos = 2; } else { $pos = 0; } $ret .= ' <!-- ENTRY BAR --> <tr class="entrycont">' . ($start_padding > 0 ? ' <td class="alignright" colspan="' . $start_padding . '">' : ''); if ($pos > 0) { if (!$event->isUntimed()) { $ret .= ($start_padding > 0 ? ' </td>' : '') . ' <td class="entry" colspan="' . $ev_duration . '">' . ($pos > 1 ? ' </td> <td class="alignleft" colspan="' . $end_padding . '">' : ''); } else { // Untimed, just display text. $ret .= ' <td colspan="' . $totalSlots . '">'; } } $tempClone = $event->getClone(); $tempPri = $event->getPriority() < 4; return $ret . ($tempPri ? '<strong>' : '') . ($can_access != 0 && $time_only != 'Y' ? ' <a class="entry" id="' . $linkid . '" href="view_entry.php?id=' . $id . '&date=' . ($tempClone ? $tempClone : $date) . (strlen($user) > 0 ? '&user='******'') . '">' : '') . '[' . ($event->getLogin() == '__public__' ? $PUBLIC_ACCESS_FULLNAME : $event->getLogin()) . '] ' . build_entry_label($event, 'eventinfo-' . $linkid, $can_access, $event->isAllDay() ? translate('All day event') : (!$event->isUntimed() ? display_time($event->getDatetime()) . ($event->getDuration() > 0 ? ' - ' . display_time($event->getEndDateTime(), 2) : '') : ''), $time_only) . ($insidespan ? '</span>' : '') . '</a>' . ($tempPri ? '</strong>' : '') . '</td>' . ($pos < 2 ? ($pos < 1 ? ' <td class="entry" colspan="' . $ev_duration . '"> </td>' : '') . ($end_padding > 1 ? ' <td class="alignleft" colspan="' . $end_padding . '"> </td>' : '') : '') . ' </tr>'; }
$name = $row[0]; $eventdate = $row[1]; $eventtime = $row[2]; dbi_free_result($res); } // TODO: switch transation language based on user so each user // gets message in their selected language. for ($i = 0; $i < count($partlogin); $i++) { // Log the deletion activity_log($id, $login, $partlogin[$i], $LOG_DELETE, ""); $do_send = get_pref_setting($partlogin[$i], "EMAIL_EVENT_DELETED"); user_load_variables($partlogin[$i], "temp"); if ($partlogin[$i] != $login && $do_send == "Y" && boss_must_be_notified($login, $partlogin[$i]) && strlen($tempemail) && $send_email != "N") { $msg = translate("Hello") . ", " . $tempfullname . ".\n\n" . translate("An appointment has been canceled for you by") . " " . $login_fullname . ". " . translate("The subject was") . " \"" . $name . "\"\n" . translate("Date") . ": " . date_to_str($thisdate) . "\n"; if ($eventtime != '-1') { $msg .= translate("Time") . ": " . display_time($eventtime); } $msg .= "\n\n"; if (strlen($login_email)) { $extra_hdrs = "From: {$login_email}\r\nX-Mailer: " . translate($application_name); } else { $extra_hdrs = "From: {$email_fallback_from}\r\nX-Mailer: " . translate($application_name); } mail($tempemail, translate($application_name) . " " . translate("Notification") . ": " . $name, html_to_8bits($msg), $extra_hdrs); } } // Instead of deleting from the database... mark it as deleted // by setting the status for each participant to "D" (instead // of "A"/Accepted, "W"/Waiting-on-approval or "R"/Rejected) if ($override_repeat) { dbi_query("INSERT INTO webcal_entry_repeats_not ( cal_id, cal_date ) " . "VALUES ( {$id}, {$date} )");
$color = $is_weekend ? $WEEKENDBG : $CELLBG; if (!empty($untimed[$d]) && strlen($untimed[$d])) { echo $untimed[$d]; } else { echo "<TD WIDTH=\"12%\" BGCOLOR=\"{$color}\"> </TD>"; } } echo "</TR>\n"; } for ($d = $start_ind; $d < $end_ind; $d++) { $rowspan_day[$d] = 0; } for ($i = $first_slot; $i <= $last_slot; $i++) { $time_h = (int) ($i * $interval / 60); $time_m = $i * $interval % 60; $time = display_time(($time_h * 100 + $time_m) * 100); echo "<TR><TH CLASS=\"tableheader\" VALIGN=\"top\" WIDTH=\"13%\" BGCOLOR=\"{$THBG}\" HEIGHT=\"40\">" . "<FONT COLOR=\"{$THFG}\">" . $time . "</FONT></TH>\n"; for ($d = $start_ind; $d < $end_ind; $d++) { $thiswday = date("w", $days[$d]); $is_weekend = $thiswday == 0 || $thiswday == 6; if (empty($WEEKENDBG)) { $is_weekend = false; } $color = $is_weekend ? $WEEKENDBG : $CELLBG; if ($all_day[$d] > 0) { $color = $TODAYCELLBG; } if ($rowspan_day[$d] > 1) { // this might mean there's an overlap, or it could mean one event // ends at 11:15 and another starts at 11:30. if (!empty($save_hour_arr[$d][$i])) {
function list_unapproved($user) { global $login, $SERVER_URL; $count = 0; $ret = ''; $sql = 'SELECT we.cal_id, we.cal_name, we.cal_description, weu.cal_login, we.cal_priority, we.cal_date, we.cal_time, we.cal_duration, weu.cal_status, we.cal_type FROM webcal_entry we, webcal_entry_user weu WHERE we.cal_id = weu.cal_id AND weu.cal_login = ? AND weu.cal_status = \'W\' ORDER BY weu.cal_login, we.cal_date'; $rows = dbi_get_cached_rows($sql, array($user)); if ($rows) { $allDayStr = translate('All day event'); $appConStr = translate('Approve/Confirm'); $appSelStr = translate('Approve Selected'); $checkAllStr = translate('Check All'); $deleteStr = translate('Delete'); $emailStr = translate('Emails Will Not Be Sent'); $rejectSelStr = translate('Reject Selected'); $rejectStr = translate('Reject'); $uncheckAllStr = translate('Uncheck All'); $viewStr = translate('View this entry'); for ($i = 0, $cnt = count($rows); $i < $cnt; $i++) { $row = $rows[$i]; $id = $row[0]; $name = $row[1]; $description = $row[2]; $cal_user = $row[3]; $pri = $row[4]; $date = $row[5]; $time = sprintf("%06d", $row[6]); $duration = $row[7]; $status = $row[8]; $type = $row[9]; $view_link = 'view_entry'; $entryID = 'entry' . $type . $id; $unixtime = date_to_epoch($date . $time); $timestr = ''; if ($time > 0 || $time == 0 && $duration != 1440) { $eventstart = date_to_epoch($date . $time); $eventstop = $eventstart + $duration; $eventdate = date_to_str(date('Ymd', $eventstart)); $timestr = display_time('', 0, $eventstart) . ($duration > 0 ? ' - ' . display_time('', 0, $eventstop) : ''); } else { // Don't shift date if All Day or Untimed. $eventdate = date_to_str($date); // If All Day display in popup. if ($time == 0 && $duration == 1440) { $timestr = $allDayStr; } } $ret .= "<item>\n" . ' <title><![CDATA[' . htmlspecialchars($name) . ']]></title>' . "\n <link>" . $SERVER_URL . $view_link . '.php?id=' . $id . '&user='******' <description><![CDATA[' . $description . ']]></description>' . "\n"; $ret .= ' <category><![CDATA[' . $category . ']]></category>' . "\n"; /* RSS 2.0 date format Wed, 02 Oct 2002 13:00:00 GMT */ $ret .= '<pubDate>' . gmdate('D, d M Y H:i:s', $unixtime) . ' GMT</pubDate>' . "\n" . ' <guid>' . $SERVER_URL . 'view_entry.php?id=' . $id . '&friendly=1&rssuser='******'&date=' . $d . "</guid>\n"; $ret .= "</item>\n\n"; } } return $ret; }
function event_to_text($id, $date, $time, $duration, $name, $description, $status, $pri, $access, $event_owner) { global $login, $user, $event_template, $report_id, $allow_html_description; $time_str = $start_time_str = $end_time_str = ''; if ($duration == 24 * 60) { $time_str = translate("All day event"); } else { if ($time == -1) { $time_str = translate("Untimed event"); } else { $time_str = display_time($time); $start_time_str = $time_str; $time_short = preg_replace("/(:00)/", '', $time_str); if ($duration > 0) { if ($duration == 24 * 60) { $time_str = translate("All day event"); } else { // calc end time $h = (int) ($time / 10000); $m = $time / 100 % 100; $m += $duration; $d = $duration; while ($m >= 60) { $h++; $m -= 60; } $end_time = sprintf("%02d%02d00", $h, $m); $time_str .= " - " . display_time($end_time); $end_time_str = display_time($end_time); } } } } if ($login != $user && $access == 'R' && strlen($user)) { $name_str = "(" . translate("Private") . ")"; $description_str = translate("This event is confidential"); } else { if ($login != $event_owner && $access == 'R' && strlen($event_owner)) { $name_str = "(" . translate("Private") . ")"; $description_str = translate("This event is confidential"); } else { $name_str = htmlspecialchars($name); if (!empty($allow_html_description) && $allow_html_description == 'Y') { $str = str_replace('&', '&', $description); $description_str = str_replace('&amp;', '&', $str); if (strstr($description_str, "<") && strstr($description_str, ">")) { // found some HTML } else { // No HTML found. Add line breaks. $description_str = nl2br($description_str); } } else { $description_str = nl2br(activate_urls(htmlspecialchars($description))); } } } $date_str = date_to_str($date, "", false); $date_full_str = date_to_str($date, "", true, false); if ($duration > 0) { $duration_str = $duration . ' ' . translate("minutes"); } else { $duration_str = ''; } if ($pri == 1) { $pri_str = translate("Low"); } else { if ($pri == 2) { $pri_str = translate("Medium"); } else { if ($pri == 3) { $pri_str = translate("High"); } } } if ($status == 'W') { $status_str = translate("Waiting for approval"); } else { if ($status == 'D') { $status_str = translate("Deleted"); } else { if ($status == 'R') { $status_str = translate("Rejected"); } else { if ($status == 'A') { $status_str = translate("Approved"); } else { $status_str = translate("Unknown"); } } } } $href_str = "view_entry.php?id={$id}"; // Replace all variables in the event template. $text = $event_template; $text = str_replace('${name}', $name_str, $text); $text = str_replace('${description}', $description_str, $text); $text = str_replace('${date}', $date_str, $text); $text = str_replace('${dateYmd}', $date, $text); $text = str_replace('${fulldate}', $date_full_str, $text); $text = str_replace('${time}', $time_str, $text); $text = str_replace('${starttime}', $start_time_str, $text); $text = str_replace('${endtime}', $end_time_str, $text); $text = str_replace('${duration}', $duration_str, $text); $text = str_replace('${priority}', $pri_str, $text); $text = str_replace('${href}', $href_str, $text); $text = str_replace('${id}', $id, $text); $text = str_replace('${user}', $event_owner, $text); $text = str_replace('${report_id}', $report_id, $text); return $text; }
function print_detailed_entry($id, $date, $time, $duration, $name, $description, $status, $pri, $access, $event_owner) { global $eventinfo, $login, $user, $TZ_OFFSET; static $key = 0; global $layers; if ($login != $event_owner && strlen($event_owner)) { $class = "layerentry"; } else { $class = "entry"; if ($status == "W") { $class = "unapprovedentry"; } } if ($pri == 3) { echo "<strong>"; } $divname = "eventinfo-{$id}-{$key}"; $key++; echo "<a title=\"" . translate("View this entry") . "\" class=\"{$class}\" href=\"view_entry.php?id={$id}&date={$date}"; if (strlen($user) > 0) { echo "&user="******"\" onmouseover=\"window.status='" . translate("View this entry") . "'; return true;\" onmouseout=\"window.status=''; return true;\">"; echo "<img src=\"circle.gif\" class=\"bullet\" alt=\"view icon\" />"; if ($login != $event_owner && strlen($event_owner)) { if ($layers) { foreach ($layers as $layer) { if ($layer['cal_layeruser'] == $event_owner) { echo "<span style=\"color:#" . $layer['cal_color'] . ";\">"; } } } } $timestr = ""; $my_time = $time + $TZ_OFFSET * 10000; if ($time >= 0) { if ($GLOBALS["TIME_FORMAT"] == "24") { printf("%02d:%02d", $my_time / 10000, $my_time / 100 % 100); } else { $h = (int) ($my_time / 10000) % 12; if ($h == 0) { $h = 12; } echo $h; $m = $my_time / 100 % 100; if ($m > 0) { printf(":%02d", $m); } else { print ":00"; } echo (int) ($my_time / 10000) < 12 ? translate("am") : translate("pm"); } $timestr = display_time($time); if ($duration > 0) { // calc end time $h = (int) ($time / 10000); $m = $time / 100 % 100; $m += $duration; $d = $duration; while ($m >= 60) { $h++; $m -= 60; } $end_time = sprintf("%02d%02d00", $h, $m); $timestr .= " - " . display_time($end_time); echo " - " . display_time($end_time) . ""; echo "» "; } else { echo "» "; } } if ($login != $user && $access == 'R' && strlen($user)) { $PN = "(" . translate("Private") . ")"; $PD = "(" . translate("Private") . ")"; } elseif ($login != $event_owner && $access == 'R' && strlen($event_owner)) { $PN = "(" . translate("Private") . ")"; $PD = "(" . translate("Private") . ")"; } elseif ($login != $event_owner && strlen($event_owner)) { $PN = htmlspecialchars($name) . "</span>"; $PD = activate_urls(htmlspecialchars($description)); } else { $PN = htmlspecialchars($name); $PD = activate_urls(htmlspecialchars($description)); } echo $PN; echo "</a>"; if ($pri == 3) { echo "</strong>"; } # Only display description if it is different than the event name. if ($PN != $PD) { echo " - " . $PD; } echo "<br />\n"; }
function print_upcoming_event($e) { global $display_link, $link_target, $server_url; if ($display_link && !empty($server_url)) { print "<a title\"" . htmlentities($e['cal_name']) . "\" href=\"" . $server_url . "view_entry.php?id=" . $e['cal_id'] . "&date=" . $e['cal_date'] . "\""; if (!empty($link_target)) { print " target=\"{$link_target}\""; } print ">"; } print htmlentities($e['cal_name']); if ($display_link && !empty($server_url)) { print "</a>"; } if ($e['cal_duration'] == 24 * 60) { print " (" . translate("All day event") . ")\n"; } else { if ($e['cal_time'] != -1) { print " (" . display_time($e['cal_time']) . ")\n"; } } print "<br />\n"; }
function send_reminder($id, $event_date) { global $names, $emails, $site_extras, $debug, $only_testing, $server_url, $languages, $tzoffset, $application_name; global $EXTRA_TEXT, $EXTRA_MULTILINETEXT, $EXTRA_URL, $EXTRA_DATE, $EXTRA_EMAIL, $EXTRA_USER, $EXTRA_REMINDER, $LANGUAGE, $LOG_REMINDER; global $allow_external_users, $external_reminders; $pri[1] = translate("Low"); $pri[2] = translate("Medium"); $pri[3] = translate("High"); // get participants first... $sql = "SELECT cal_login FROM webcal_entry_user " . "WHERE cal_id = {$id} AND cal_status IN ('A','W') " . "ORDER BY cal_login"; $res = dbi_query($sql); $participants = array(); $num_participants = 0; if ($res) { while ($row = dbi_fetch_row($res)) { $participants[$num_participants++] = $row[0]; } } // get external participants $ext_participants = array(); $num_ext_participants = 0; if (!empty($allow_external_users) && $allow_external_users == "Y" && !empty($external_reminders) && $external_reminders == "Y") { $sql = "SELECT cal_fullname, cal_email FROM webcal_entry_ext_user " . "WHERE cal_id = {$id} AND cal_email IS NOT NULL " . "ORDER BY cal_fullname"; $res = dbi_query($sql); if ($res) { while ($row = dbi_fetch_row($res)) { $ext_participants[$num_ext_participants] = $row[0]; $ext_participants_email[$num_ext_participants++] = $row[1]; } } } if (!$num_participants && !$num_ext_participants) { if ($debug) { echo "No participants found for event id: {$id} <br />\n"; } return; } // get event details $res = dbi_query("SELECT cal_create_by, cal_date, cal_time, cal_mod_date, " . "cal_mod_time, cal_duration, cal_priority, cal_type, cal_access, " . "cal_name, cal_description FROM webcal_entry WHERE cal_id = {$id}"); if (!$res) { echo "Db error: could not find event id {$id}.\n"; return; } if (!($row = dbi_fetch_row($res))) { echo "Error: could not find event id {$id} in database.\n"; return; } // send mail. we send one user at a time so that we can switch // languages between users if needed. $mailusers = array(); $recipients = array(); if (isset($single_user) && $single_user == "Y") { $mailusers[] = $emails[$single_user_login]; $recipients[] = $single_user_login; } else { for ($i = 0; $i < count($participants); $i++) { if (strlen($emails[$participants[$i]])) { $mailusers[] = $emails[$participants[$i]]; $recipients[] = $participants[$i]; } else { if ($debug) { echo "No email for user {$participants[$i]} <br />\n"; } } } for ($i = 0; $i < count($ext_participants); $i++) { $mailusers[] = $ext_participants_email[$i]; $recipients[] = $ext_participants[$i]; } } if ($debug) { echo "Found " . count($mailusers) . " with email addresses <br />\n"; } for ($j = 0; $j < count($mailusers); $j++) { $recip = $mailusers[$j]; $user = $participants[$j]; if (!empty($languages[$user])) { $userlang = $languages[$user]; } else { $userlang = $LANGUAGE; } // system default if ($userlang == "none") { $userlang = "English-US"; } // gotta pick something if ($debug) { echo "Setting language to \"{$userlang}\" <br />\n"; } reset_language($userlang); // reset timezone setting for current user if (empty($tzoffset[$user])) { $GLOBALS["TZ_OFFSET"] = 0; } else { $GLOBALS["TZ_OFFSET"] = $tzoffset[$user]; } $body = translate("This is a reminder for the event detailed below.") . "\n\n"; $create_by = $row[0]; $name = $row[9]; $description = $row[10]; // add trailing '/' if not found in server_url if (!empty($server_url)) { if (substr($server_url, -1, 1) == "/") { $body .= $server_url . "view_entry.php?id=" . $id . "\n\n"; } else { $body .= $server_url . "/view_entry.php?id=" . $id . "\n\n"; } } $body .= strtoupper($name) . "\n\n"; $body .= translate("Description") . ":\n"; $body .= indent($description) . "\n"; $body .= translate("Date") . ": " . date_to_str($event_date) . "\n"; if ($row[2] >= 0) { $body .= translate("Time") . ": " . display_time($row[2]) . "\n"; } if ($row[5] > 0) { $body .= translate("Duration") . ": " . $row[5] . " " . translate("minutes") . "\n"; } if (!empty($disable_priority_field) && !$disable_priority_field) { $body .= translate("Priority") . ": " . $pri[$row[6]] . "\n"; } if (!empty($disable_access_field) && !$disable_access_field) { $body .= translate("Access") . ": " . ($row[8] == "P" ? translate("Public") : translate("Confidential")) . "\n"; } if (!empty($single_user_login) && $single_user_login == false) { $body .= translate("Created by") . ": " . $row[0] . "\n"; } $body .= translate("Updated") . ": " . date_to_str($row[3]) . " " . display_time($row[4]) . "\n"; // site extra fields $extras = get_site_extra_fields($id); for ($i = 0; $i < count($site_extras); $i++) { $extra_name = $site_extras[$i][0]; $extra_descr = $site_extras[$i][1]; $extra_type = $site_extras[$i][2]; if ($extras[$extra_name]['cal_name'] != "") { $body .= translate($extra_descr) . ": "; if ($extra_type == $EXTRA_DATE) { $body .= date_to_str($extras[$extra_name]['cal_date']) . "\n"; } else { if ($extra_type == $EXTRA_MULTILINETEXT) { $body .= "\n" . indent($extras[$extra_name]['cal_data']) . "\n"; } else { if ($extra_type == $EXTRA_REMINDER) { $body .= ($extras[$extra_name]['cal_remind'] > 0 ? translate("Yes") : translate("No")) . "\n"; } else { // default method for $EXTRA_URL, $EXTRA_TEXT, etc... $body .= $extras[$extra_name]['cal_data'] . "\n"; } } } } } if (!empty($single_user) && $single_user != "Y" && !empty($disable_participants_field) && !$disable_participants_field) { $body .= translate("Participants") . ":\n"; for ($i = 0; $i < count($participants); $i++) { $body .= " " . $names[$participants[$i]] . "\n"; } for ($i = 0; $i < count($ext_participants); $i++) { $body .= " " . $ext_participants[$i] . " (" . translate("External User") . ")\n"; } } $subject = translate("Reminder") . ": " . $name; if (strlen($GLOBALS["email_fallback_from"])) { $extra_hdrs = "From: " . $GLOBALS["email_fallback_from"] . "\r\n" . "X-Mailer: " . translate($application_name); } else { $extra_hdrs = "X-Mailer: " . translate($application_name); } if ($debug) { echo "Sending mail to {$recip} (in {$userlang})\n"; } if ($only_testing) { if ($debug) { echo "<hr /><pre>To: {$recip}\nSubject: {$subject}\n{$extra_hdrs}\n\n{$body}\n\n</pre>\n"; } } else { mail($recip, $subject, $body, $extra_hdrs); activity_log($id, "system", $user, $LOG_REMINDER, ""); } } }
$show_log = true; } } if ($show_log) { echo "<h3>" . translate("Activity Log") . "</h3>\n"; echo "<table class=\"embactlog\">\n"; echo "<tr><th class=\"usr\">\n" . translate("User") . "</th><th class=\"cal\">\n"; echo translate("Calendar") . "</th><th class=\"date\">\n"; echo translate("Date") . "/" . translate("Time") . "</th><th class=\"action\">\n"; echo translate("Action") . "\n</th></tr>\n"; $res = dbi_query("SELECT cal_login, cal_user_cal, cal_type, " . "cal_date, cal_time " . "FROM webcal_entry_log WHERE cal_entry_id = {$id} " . "ORDER BY cal_log_id DESC"); if ($res) { while ($row = dbi_fetch_row($res)) { echo "<tr><td>\n"; echo $row[0] . "</td><td>\n"; echo $row[1] . "</td><td>\n" . date_to_str($row[3]) . " " . display_time($row[4]) . "</td><td>\n"; if ($row[2] == $LOG_CREATE) { etranslate("Event created"); } else { if ($row[2] == $LOG_APPROVE) { etranslate("Event approved"); } else { if ($row[2] == $LOG_REJECT) { etranslate("Event rejected"); } else { if ($row[2] == $LOG_UPDATE) { etranslate("Event updated"); } else { if ($row[2] == $LOG_DELETE) { etranslate("Event deleted"); } else {
function print_entry_timebar($id, $date, $time, $duration, $name, $description, $status, $pri, $access, $event_owner, $hide_icons) { global $eventinfo, $login, $user, $PHP_SELF; static $key = 0; global $layers; // compute time offsets in % of total table width $day_start = $prefarray["WORK_DAY_START_HOUR"] * 60; if ($day_start == 0) { $day_start = 9 * 60; } $day_end = $prefarray["WORK_DAY_END_HOUR"] * 60; if ($day_end == 0) { $day_end = 19 * 60; } if ($day_end <= $day_start) { $day_end = $day_start + 60; } //avoid exceptions if ($time >= 0) { $ev_start = $time / 10000 * 60 + $time / 100 % 100; $ev_start = round(100 * ($ev_start - $day_start) / ($day_end - $day_start)); } else { $ev_start = 0; } if ($duration > 0) { $ev_duration = round(100 * $duration / ($day_end - $day_start)); if ($ev_start + $ev_duration > 100) { $ev_duration = 100 - $ev_start; } } else { if ($time >= 0) { $ev_duration = 1; } else { $ev_duration = 100 - $ev_start; } } $ev_padding = 100 - $ev_start - $ev_duration; // choose where to position the text (pos=0->before,pos=1->on,pos=2->after) if ($ev_duration > 20) { $pos = 1; } elseif ($ev_padding > 20) { $pos = 2; } else { $pos = 0; } echo "<TABLE WIDTH=\"100%\" BGCOLOR=\"black\" BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">\n"; echo "<TR>"; echo "<TD ALIGN=\"right\" WIDTH=\"{$ev_start}%\" BGCOLOR=\"white\">"; if ($pos > 0) { echo " </TD>"; echo "<TD WIDTH=\"{$ev_duration}%\">\n <TABLE WIDTH=\"100%\" BORDER=\"0\" BGCOLOR=\"black\" CELLSPACING=\"1\">\n <TR><TD ALIGN=\"middle\" BGCOLOR=\"#F5DEB3\">"; if ($pos > 1) { echo " </TD></TR></TABLE></TD>"; echo "<TD ALIGN=\"left\" WIDTH=\"{$ev_padding}%\" BGCOLOR=\"white\">"; } } echo "<FONT SIZE=\"-1\">"; if ($login != $event_owner && strlen($event_owner)) { $class = "layerentry"; } else { $class = "entry"; if ($status == "W") { $class = "unapprovedentry"; } } // if we are looking at a view, then always use "entry" if (strstr($PHP_SELF, "view_m.php") || strstr($PHP_SELF, "view_w.php") || strstr($PHP_SELF, "view_v.php") || strstr($PHP_SELF, "view_t.php")) { $class = "entry"; } if ($pri == 3) { echo "<B>"; } if (!$hide_icons) { $divname = "eventinfo-{$id}-{$key}"; $key++; echo "<A CLASS=\"{$class}\" HREF=\"view_entry.php?id={$id}&date={$date}"; if (strlen($user) > 0) { echo "&user="******"\" onMouseOver=\"window.status='" . translate("View this entry") . "'; show(event, '{$divname}'); return true;\" onMouseOut=\"hide('{$divname}'); return true;\">"; } if ($login != $event_owner && strlen($event_owner)) { for ($index = 0; $index < sizeof($layers); $index++) { if ($layers[$index]['cal_layeruser'] == $event_owner) { echo "<FONT COLOR=\"" . $layers[$index]['cal_color'] . "\">"; } } } echo "[{$event_owner}]"; $timestr = ""; if ($duration == 24 * 60) { $timestr = translate("All day event"); } else { if ($time >= 0) { $timestr = display_time($time); if ($duration > 0) { // calc end time $h = (int) ($time / 10000); $m = $time / 100 % 100; $m += $duration; $d = $duration; while ($m >= 60) { $h++; $m -= 60; } $end_time = sprintf("%02d%02d00", $h, $m); $timestr .= " - " . display_time($end_time); } } } if ($login != $user && $access == 'R' && strlen($user)) { echo "(" . translate("Private") . ")"; } else { if ($login != $event_owner && $access == 'R' && strlen($event_owner)) { echo "(" . translate("Private") . ")"; } else { if ($login != $event_owner && strlen($event_owner)) { echo htmlspecialchars($name); echo "</FONT>"; } else { echo htmlspecialchars($name); } } } echo "</A>"; if ($pri == 3) { echo "</B>"; } echo "</FONT>"; echo "</TD>"; if ($pos < 2) { if ($pos < 1) { echo "<TD WIDTH=\"{$ev_duration}%\"> <TABLE WIDTH=\"100%\"\n BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"1\"\n BGCOLOR=\"black\"><TR><TD ALIGN=\"middle\"\n BGCOLOR=\"#F5DEB3\"> </TD>"; } echo "</TR></TABLE></TD>"; echo "<TD ALIGN=\"left\" WIDTH=\"{$ev_padding}%\" BGCOLOR=\"white\"> </TD>"; } echo "</TR></TABLE>"; if (!$hide_icons) { if ($login != $user && $access == 'R' && strlen($user)) { $eventinfo .= build_event_popup($divname, $event_owner, translate("This event is confidential"), ""); } else { if ($login != $event_owner && $access == 'R' && strlen($event_owner)) { $eventinfo .= build_event_popup($divname, $event_owner, translate("This event is confidential"), ""); } else { $eventinfo .= build_event_popup($divname, $event_owner, $description, $timestr); } } } }
function list_unapproved($user) { global $temp_fullname, $key, $login; //echo "Listing events for $user <br>"; $sql = "SELECT webcal_entry.cal_id, webcal_entry.cal_name, " . "webcal_entry.cal_description, " . "webcal_entry.cal_priority, webcal_entry.cal_date, " . "webcal_entry.cal_time, webcal_entry.cal_duration, " . "webcal_entry_user.cal_status " . "FROM webcal_entry, webcal_entry_user " . "WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " . "AND ( webcal_entry.cal_ext_for_id IS NULL " . "OR webcal_entry.cal_ext_for_id = 0 ) AND " . "webcal_entry_user.cal_login = '******' AND " . "webcal_entry_user.cal_status = 'W' " . "ORDER BY webcal_entry.cal_date"; $res = dbi_query($sql); $count = 0; $eventinfo = ""; if ($res) { while ($row = dbi_fetch_row($res)) { if ($count == 0) { echo "<ul>\n"; } $key++; $id = $row[0]; $name = $row[1]; $description = $row[2]; $pri = $row[3]; $date = $row[4]; $time = $row[5]; $duration = $row[6]; $status = $row[7]; $divname = "eventinfo-{$id}-{$key}"; echo "<li><a title=\"" . translate("View this entry") . "\" class=\"entry\" href=\"view_entry.php?id={$id}&user={$user}"; echo "\" onmouseover=\"window.status='" . translate("View this entry") . "'; show(event, '{$divname}'); return true;\" onmouseout=\"hide('{$divname}'); return true;\">"; $timestr = ""; if ($time > 0) { $timestr = display_time($time); if ($duration > 0) { // calc end time $h = (int) ($time / 10000); $m = $time / 100 % 100; $m += $duration; $d = $duration; while ($m >= 60) { $h++; $m -= 60; } $end_time = sprintf("%02d%02d00", $h, $m); $timestr .= " - " . display_time($end_time); } } echo htmlspecialchars($name); echo "</a>"; echo " (" . date_to_str($date) . ")\n"; //approve echo ": <a title=\"" . translate("Approve/Confirm") . "\" href=\"approve_entry.php?id={$id}&ret=list&user={$user}"; if ($user == "__public__") { echo "&public=1"; } echo "\" class=\"nav\" onclick=\"return confirm('" . translate("Approve this entry?") . "');\">" . translate("Approve/Confirm") . "</a>, "; //reject echo "<a title=\"" . translate("Reject") . "\" href=\"reject_entry.php?id={$id}&ret=list&user={$user}"; if ($user == "__public__") { echo "&public=1"; } echo "\" class=\"nav\" onclick=\"return confirm('" . translate("Reject this entry?") . "');\">" . translate("Reject") . "</a>"; //delete echo ", <a title=\"" . translate("Delete") . "\" href=\"del_entry.php?id={$id}&ret=list"; if ($user != $login) { echo "&user={$user}"; } echo "\" class=\"nav\" onclick=\"return confirm('" . translate("Are you sure you want to delete this entry?") . "');\">" . translate("Delete") . "</a>"; echo "\n</li>\n"; $eventinfo .= build_event_popup($divname, $user, $description, $timestr, site_extras_for_popup($id)); $count++; } dbi_free_result($res); if ($count > 0) { echo "</ul>\n"; } } if ($count == 0) { user_load_variables($user, "temp_"); echo "<span class=\"nounapproved\">" . translate("No unapproved events for") . " " . $temp_fullname . ".</span>\n"; } else { if (!empty($eventinfo)) { echo $eventinfo; } } }
$time .= " {$min}/min"; } } else { $time = "{$time}/min"; } echo "<tr><th colspan=4 align='right'>Project Totals</th>"; echo "<th>\$" . number_format($cost, 2) . "</th><th colspan=2 align='left'>{$time}</th></tr>\n"; $time = 0; $cost = 0; } $project_name = $log['Project_Name']; echo "<tr><td colspan=6><h2>{$project_name}</h2></td></tr>"; echo "<tr><th>Logged</th><th>Completed</th><th>Task</th><th>File</th><th>User</th><th>Cost</th><th>Time</th><th>Notes</th></tr>\n"; } echo "<tr>"; echo "<td>" . display_date($log['Creation_Date']) . "<br />@" . display_time($log['Creation_Date']) . "</td>\n"; echo "<td>" . display_date($log['Log_Date']) . "</td>\n"; echo "<td><a href=\"tasks.php?task_id=" . $log['Task_ID'] . "\">" . $log['Task_Name'] . "</a></td>\n"; echo "<td align=\"center\">"; $files = $slave->select("SELECT * FROM Files as F, File_Types as T WHERE F.File_Type_ID=T.File_Type_ID AND Log_ID=" . $log['Log_ID'] . " ORDER BY Image"); if ($files) { $img = $multi = ""; foreach ($files as $f) { if ($img != $f['Image'] or $img == 0) { $img = $f['Image']; if ($f['Image'] == 1) { $icon = "111.png"; echo "<a href=\"" . CDN . "img.php?id=" . $log['Task_ID'] . "&log=" . $log['Log_ID'] . "\" alt=\"\" target=\"_blank\"><img src=\"" . CDN . "img/icons/{$icon}\" border=0 /></a>"; } else { $icon = "3.png"; echo "<a href=\"{$target_path}" . $f['File_ID'] . "." . $f['Extention'] . "\" alt=\"\" target=\"_blank\"><img src=\"" . CDN . "img/icons/{$icon}\" border=0 /></a>";
echo T_("Add this respondent"); ?> "/></p> </form> <?php } else { if ($respondent_id) { $sql = "SELECT TIME(CONVERT_TZ(NOW(),'System',r.Time_zone_name)) as tme, r.Time_zone_name as tzn FROM `respondent` as r WHERE r.respondent_id = {$respondent_id}"; $ct = $db->GetRow($sql); print "<p>" . T_("Timezone") . ": " . $ct['tzn'] . " " . T_("Current Time") . ": <b class=\"fa text-primary\">" . $ct['tme'] . "</b></p>"; if (isset($_GET['d']) && isset($_GET['m']) && isset($_GET['y'])) { $day = bigintval($_GET['d']); $month = bigintval($_GET['m']); $year = bigintval($_GET['y']); display_calendar($respondent_id, $questionnaire_id, $year, $month, $day); display_time($questionnaire_id, $respondent_id, $day, $month, $year, isset($_GET['start']) ? $_GET['start'] : false, isset($_GET['end']) ? $_GET['end'] : false); print "</div>"; if (isset($_GET['end']) && isset($_GET['start'])) { $list = return_contact_phone_list($case_id); print "<div class=\"clearfix form-group\"><label class=\"pull-left\" style=\"padding-top: 5px;\">" . T_("Select phone number:") . " </label>"; if (isset($_GET['contact_phone_id'])) { $contact_phone_id = bigintval($_GET['contact_phone_id']); } else { $contact_phone_id = -1; } print "<div class=\"pull-left\"><select class=\"form-control\" id='phonenum' name='phonenum' onchange=\"LinkUp('phonenum')\"><option></option>"; foreach ($list as $l) { $id = $l['contact_phone_id']; $selected = ""; if ($id == $contact_phone_id) { $selected = "selected='selected'";
function minimum_entropy_match_sequence($password, $matches) { # e.g. 26 for lowercase $bruteforce_cardinality = calc_bruteforce_cardinality($password); # minimum entropy up to k. $up_to_k = array(); # for the optimal sequence of matches up to k, holds the # final match (match.j == k). null means the sequence ends # w/ a brute-force character. $backpointers = array(); $password_len = strlen($password); for ($k = 0; $k < $password_len; $k++) { # starting scenario to try and beat: # adding a brute-force character to the minimum entropy sequence at k-1. $up_to_k[$k] = _get_index($up_to_k, $k - 1) + logarithm($bruteforce_cardinality); $backpointers[$k] = NULL; foreach ($matches as $match) { if ($match['j'] !== $k) { continue; } $i = $match['i']; $j = $match['j']; # see if best entropy up to i-1 + entropy of this match # is less than the current minimum at j. $candidate_entropy = _get_index($up_to_k, $i - 1) + calc_entropy($match); if ($candidate_entropy < $up_to_k[$j]) { $up_to_k[$j] = $candidate_entropy; $backpointers[$j] = $match; } } } # walk backwards and decode the best sequence $match_sequence = array(); $k = strlen($password) - 1; while ($k >= 0) { $match = $backpointers[$k]; if ($match) { $match_sequence[] = $match; $k = $match['i'] - 1; } else { $k -= 1; } } $match_sequence = array_reverse($match_sequence); # fill in the blanks between pattern matches with bruteforce "matches" # that way the match sequence fully covers the password: # match1.j == match2.i - 1 for every adjacent match1, match2. $make_bruteforce_match = function ($i, $j) use($password, $bruteforce_cardinality) { return array('pattern' => 'bruteforce', 'i' => $i, 'j' => $j, 'token' => _slice($password, $i, $j + 1), 'entropy' => logarithm(pow($bruteforce_cardinality, $j - $i + 1)), 'cardinality' => $bruteforce_cardinality); }; $k = 0; $match_sequence_copy = array(); foreach ($match_sequence as $match) { $i = $match['i']; $j = $match['j']; if ($i - $k > 0) { $match_sequence_copy[] = $make_bruteforce_match($k, $i - 1); } $k = $j + 1; $match_sequence_copy[] = $match; } if ($k < strlen($password)) { $match_sequence_copy[] = $make_bruteforce_match($k, strlen($password) - 1); } $match_sequence = $match_sequence_copy; # or 0 corner case is for an empty password '' if (isset($up_to_k[strlen($password) - 1])) { $min_entropy = $up_to_k[strlen($password) - 1]; } else { $min_entropy = 0; } $crack_time = entropy_to_crack_time($min_entropy); # final result object $result = array('password' => $password, 'entropy' => round_to_x_digits($min_entropy, 3), 'match_sequence' => $match_sequence, 'crack_time_seconds' => round_to_x_digits($crack_time, 3), 'crack_time_display' => display_time($crack_time), 'score' => crack_time_to_score($crack_time)); return $result; }
function import_data($data, $overwrite, $type) { global $login, $count_con, $count_suc, $error_num, $ImportType, $LOG_CREATE; global $single_user, $single_user_login, $allow_conflicts; global $numDeleted, $errormsg; global $calUser, $H2COLOR, $sqlLog; $oldUIDs = array(); $oldIds = array(); $firstEventId = 0; $importId = 1; // Generate a unique import id $res = dbi_query("SELECT MAX(cal_import_id) FROM webcal_import"); if ($res) { if ($row = dbi_fetch_row($res)) { $importId = $row[0] + 1; } dbi_free_result($res); } $sql = "INSERT INTO webcal_import ( cal_import_id, cal_name, " . "cal_date, cal_type, cal_login ) VALUES ( {$importId}, NULL, " . date("Ymd") . ", '{$type}', '{$login}' )"; if (!dbi_query($sql)) { $errormsg = translate("Database error") . ": " . dbi_error(); return; } foreach ($data as $Entry) { $priority = 2; $participants[0] = $calUser; // Some additional date/time info $START = $Entry['StartTime'] > 0 ? localtime($Entry['StartTime']) : 0; $END = $Entry['EndTime'] > 0 ? localtime($Entry['EndTime']) : 0; $Entry['StartMinute'] = sprintf("%02d", $START[1]); $Entry['StartHour'] = sprintf("%02d", $START[2]); $Entry['StartDay'] = sprintf("%02d", $START[3]); $Entry['StartMonth'] = sprintf("%02d", $START[4] + 1); $Entry['StartYear'] = sprintf("%04d", $START[5] + 1900); $Entry['EndMinute'] = sprintf("%02d", $END[1]); $Entry['EndHour'] = sprintf("%02d", $END[2]); $Entry['EndDay'] = sprintf("%02d", $END[3]); $Entry['EndMonth'] = sprintf("%02d", $END[4] + 1); $Entry['EndYear'] = sprintf("%04d", $END[5] + 1900); if ($overwrite && !empty($Entry['UID'])) { $oldUIDs[$Entry['UID']]++; } // Check for untimed if ($Entry['Untimed'] == 1) { $Entry['StartMinute'] = ''; $Entry['StartHour'] = ''; $Entry['EndMinute'] = ''; $Entry['EndHour'] = ''; } // first check for any schedule conflicts if (empty($allow_conflicts) && $Entry['Duration'] != 0) { $date = mktime(0, 0, 0, $Entry['StartMonth'], $Entry['StartDay'], $Entry['StartYear']); $endt = !empty($Entry['Repeat']['EndTime']) ? $Entry['Repeat']['EndTime'] : 'NULL'; $dayst = !empty($Entry['Repeat']['RepeatDays']) ? $Entry['Repeat']['RepeatDays'] : "nnnnnnn"; $ex_days = array(); if (!empty($Entry['Repeat']['Exceptions'])) { foreach ($Entry['Repeat']['Exceptions'] as $ex_date) { $ex_days[] = date("Ymd", $ex_date); } } $dates = get_all_dates($date, RepeatType($Entry['Repeat']['Interval']), $endt, $dayst, $ex_days, $Entry['Repeat']['Frequency']); $overlap = overlap($dates, $Entry['Duration'], $Entry['StartHour'], $Entry['StartMinute'], $participants, $login, 0); } if (empty($error) && !empty($overlap)) { $error = translate("The following conflicts with the suggested time") . ":<ul>{$overlap}</ul>\n"; } if (empty($error)) { $updateMode = false; // See if event already is there from prior import. // The same UID is used for all events imported at once with iCal. // So, we still don't have enough info to find the exact // event we want to replace. We could just delete all // existing events that correspond to the UID. /************************************************************************ Not sure what to do with this code since I don't know how Palm and vCal use the UID stuff yet... if ( ! empty ( $Entry['UID'] ) ) { $res = dbi_query ( "SELECT webcal_import_data.cal_id " . "FROM webcal_import_data, webcal_entry_user " . "WHERE cal_import_type = 'ical' AND " . "webcal_import_data.cal_id = webcal_entry_user.cal_id AND " . "webcal_entry_user.cal_login = '******' AND " . "cal_external_id = '$Entry[UID]'" ); if ( $res ) { if ( $row = dbi_fetch_row ( $res ) ) { if ( ! empty ( $row[0] ) ) { $id = $row[0]; $updateMode = true; // update rather than add a new event } } } } ************************************************************************/ // Add the Event $res = dbi_query("SELECT MAX(cal_id) FROM webcal_entry"); if ($res) { $row = dbi_fetch_row($res); $id = $row[0] + 1; dbi_free_result($res); } else { $id = 1; //$error = "Unable to select MAX cal_id: " . dbi_error () . "<br /><br />\n<b>SQL:</b> $sql"; //break; } if ($firstEventId == 0) { $firstEventId = $id; } $names = array(); $values = array(); $names[] = 'cal_id'; $values[] = "{$id}"; if (!$updateMode) { $names[] = 'cal_create_by'; $values[] = "'{$login}'"; } $names[] = 'cal_date'; $values[] = sprintf("%04d%02d%02d", $Entry['StartYear'], $Entry['StartMonth'], $Entry['StartDay']); $names[] = 'cal_time'; $values[] = $Entry['Untimed'] == 1 ? "-1" : sprintf("%02d%02d00", $Entry['StartHour'], $Entry['StartMinute']); $names[] = 'cal_mod_date'; $values[] = date("Ymd"); $names[] = 'cal_mod_time'; $values[] = date("Gis"); $names[] = 'cal_duration'; $values[] = sprintf("%d", $Entry['Duration']); $names[] = 'cal_priority'; $values[] = $priority; $names[] = 'cal_access'; $values[] = $Entry['Private'] == 1 ? "'R'" : "'P'"; $names[] = 'cal_type'; $values[] = $Entry['Repeat'] ? "'M'" : "'E'"; if (strlen($Entry['Summary']) == 0) { $Entry['Summary'] = translate("Unnamed Event"); } if (strlen($Entry['Description']) == 0) { $Entry['Description'] = $Entry['Summary']; } $Entry['Summary'] = str_replace("\\n", "\n", $Entry['Summary']); $Entry['Summary'] = str_replace("\\'", "'", $Entry['Summary']); $Entry['Summary'] = str_replace("\\\"", "\"", $Entry['Summary']); $Entry['Summary'] = str_replace("'", "\\'", $Entry['Summary']); $names[] = 'cal_name'; $values[] = "'" . $Entry['Summary'] . "'"; $Entry['Description'] = str_replace("\\n", "\n", $Entry['Description']); $Entry['Description'] = str_replace("\\'", "'", $Entry['Description']); $Entry['Description'] = str_replace("\\\"", "\"", $Entry['Description']); $Entry['Description'] = str_replace("'", "\\'", $Entry['Description']); // limit length to 1024 chars since we setup tables that way if (strlen($Entry['Description']) >= 1024) { $Entry['Description'] = substr($Entry['Description'], 0, 1019) . "..."; } $names[] = 'cal_description'; $values[] = "'" . $Entry['Description'] . "'"; //echo "Summary:<p>" . nl2br ( htmlspecialchars ( $Entry['Summary'] ) ) . "</p>"; //echo "Description:<p>" . nl2br ( htmlspecialchars ( $Entry['Description'] ) ) . "</p>"; exit; if ($updateMode) { $sql = "UPDATE webcal_entry SET "; for ($f = 0; $f < count($names); $f++) { if ($f > 0) { $sql .= ", "; } $sql .= $names[$f] . " = " . $values[$f]; } $sql .= " WHERE cal_id = {$id}"; } else { $sql = "INSERT INTO webcal_entry ( " . implode(", ", $names) . " ) VALUES ( " . implode(", ", $values) . " )"; } if (empty($error)) { $sqlLog .= $sql . "<br />\n"; //echo "SQL: $sql <br />\n"; if (!dbi_query($sql)) { $error .= "<p>" . translate("Database error") . ": " . dbi_error() . "</p>\n"; break; } } // log add/update activity_log($id, $login, $login, $updateMode ? $LOG_UPDATE : $LOG_CREATE, "Import from {$ImportType}"); if ($single_user == "Y") { $participants[0] = $single_user_login; } // Now add to webcal_import_data if (!$updateMode) { if ($ImportType == "PALMDESKTOP") { $sql = "INSERT INTO webcal_import_data ( cal_import_id, cal_id, " . "cal_login, cal_import_type, cal_external_id ) VALUES ( " . "{$importId}, {$id}, '{$calUser}', 'palm', '{$Entry['RecordID']}' )"; $sqlLog .= $sql . "<br />\n"; if (!dbi_query($sql)) { $error = translate("Database error") . ": " . dbi_error(); break; } } else { if ($ImportType == "VCAL") { $uid = empty($Entry['UID']) ? "null" : "'{$Entry['UID']}'"; if (strlen($uid) > 200) { $uid = "NULL"; } $sql = "INSERT INTO webcal_import_data ( cal_import_id, cal_id, " . "cal_login, cal_import_type, cal_external_id ) VALUES ( " . "{$importId}, {$id}, '{$calUser}', 'vcal', {$uid} )"; $sqlLog .= $sql . "<br />\n"; if (!dbi_query($sql)) { $error = translate("Database error") . ": " . dbi_error(); break; } } else { if ($ImportType == "ICAL") { $uid = empty($Entry['UID']) ? "null" : "'{$Entry['UID']}'"; if (strlen($uid) > 200) { $uid = "NULL"; } $sql = "INSERT INTO webcal_import_data ( cal_import_id, cal_id, " . "cal_login, cal_import_type, cal_external_id ) VALUES ( " . "{$importId}, {$id}, '{$calUser}', 'ical', {$uid} )"; $sqlLog .= $sql . "<br />\n"; if (!dbi_query($sql)) { $error = translate("Database error") . ": " . dbi_error(); break; } } } } } // Now add participants if (!$updateMode) { $status = $login == "__public__" ? 'W' : 'A'; if (empty($cat_id)) { $cat_id = 'NULL'; } $sql = "INSERT INTO webcal_entry_user " . "( cal_id, cal_login, cal_status, cal_category ) VALUES ( {$id}, '" . $participants[0] . "', '{$status}', {$cat_id} )"; $sqlLog .= $sql . "<br />\n"; if (!dbi_query($sql)) { $error = translate("Database error") . ": " . dbi_error(); break; } } // Add repeating info if ($updateMode) { // remove old repeating info dbi_query("DELETE FROM webcal_entry_repeats WHERE cal_id = {$id}"); dbi_query("DELETE FROM webcal_entry_repeats_not WHERE cal_id = {$id}"); } if (!empty($Entry['Repeat']['Interval'])) { //while ( list($k,$v) = each ( $Entry['Repeat'] ) ) { // echo "$k: $v <br />\n"; //} $rpt_type = RepeatType($Entry['Repeat']['Interval']); $freq = $Entry['Repeat']['Frequency'] ? $Entry['Repeat']['Frequency'] : 1; if (strlen($Entry['Repeat']['EndTime'])) { $REND = localtime($Entry['Repeat']['EndTime']); $end = sprintf("%04d%02d%02d", $REND[5] + 1900, $REND[4] + 1, $REND[3]); } else { $end = 'NULL'; } $days = !empty($Entry['Repeat']['RepeatDays']) ? "'" . $Entry['Repeat']['RepeatDays'] . "'" : 'NULL'; $sql = "INSERT INTO webcal_entry_repeats ( cal_id, " . "cal_type, cal_end, cal_days, cal_frequency ) VALUES " . "( {$id}, '{$rpt_type}', {$end}, {$days}, {$freq} )"; $sqlLog .= $sql . "<br />\n"; if (!dbi_query($sql)) { $error = "Unable to add to webcal_entry_repeats: " . dbi_error() . "<br /><br />\n<b>SQL:</b> {$sql}"; break; } // Repeating Exceptions... if (!empty($Entry['Repeat']['Exceptions'])) { foreach ($Entry['Repeat']['Exceptions'] as $ex_date) { $ex_date = date("Ymd", $ex_date); $sql = "INSERT INTO webcal_entry_repeats_not ( cal_id, cal_date ) VALUES ( {$id}, {$ex_date} )"; $sqlLog .= $sql . "<br />\n"; if (!dbi_query($sql)) { $error = "Unable to add to webcal_entry_repeats_not: " . dbi_error() . "<br /><br />\n<b>SQL:</b> {$sql}"; break; } } } } // End Repeat // Add Alarm info -> site_extras if ($updateMode) { dbi_query("DELETE FROM webcal_site_extras WHERE cal_id = {$id}"); } if ($Entry['AlarmSet'] == 1) { $RM = $Entry['AlarmAdvanceAmount']; if ($Entry['AlarmAdvanceType'] == 1) { $RM = $RM * 60; } if ($Entry['AlarmAdvanceType'] == 2) { $RM = $RM * 60 * 24; } $sql = "INSERT INTO webcal_site_extras ( cal_id, " . "cal_name, cal_type, cal_remind, cal_data ) VALUES " . "( {$id}, 'Reminder', 7, 1, {$RM} )"; $sqlLog .= $sql . "<br />\n"; if (!dbi_query($sql)) { $error = translate("Database error") . ": " . dbi_error(); } } } if (!empty($error) && empty($overlap)) { $error_num++; echo "<h2>" . translate("Error") . "</h2>\n<blockquote>\n"; echo $error . "</blockquote>\n<br />\n"; } // Conflicting if (!empty($overlap)) { echo "<b><h2>" . translate("Scheduling Conflict") . ": "; $count_con++; echo "</h2></b>"; if ($Entry['Duration'] > 0) { $time = display_time($Entry['StartHour'] . $Entry['StartMinute'] . "00") . " - " . display_time($Entry['EndHour'] . $Entry['EndMinute'] . "00"); } $dd = $Entry['StartMonth'] . "-" . $Entry['StartDay'] . "-" . $Entry['StartYear']; echo "<a class=\"entry\" href=\"view_entry.php?id={$id}"; echo "\" onmouseover=\"window.status='" . translate("View this entry") . "'; return true;\" onmouseout=\"window.status=''; return true;\">"; $Entry['Summary'] = str_replace("''", "'", $Entry['Summary']); $Entry['Summary'] = str_replace("'", "\\'", $Entry['Summary']); echo htmlspecialchars($Entry['Summary']); echo "</a> (" . $dd; $time = trim($time); if (!empty($time)) { echo " " . $time; } echo ")<br />\n"; etranslate("conflicts with the following existing calendar entries"); echo ":<ul>\n" . $overlap . "</ul>\n"; } else { // No Conflict echo "<b><h2>" . translate("Event Imported") . ":</h2></b>\n"; $count_suc++; if ($Entry['Duration'] > 0) { $time = display_time($Entry['StartHour'] . $Entry['StartMinute'] . "00") . " - " . display_time($Entry['EndHour'] . $Entry['EndMinute'] . "00"); } $dateYmd = sprintf("%04d%02d%02d", $Entry['StartYear'], $Entry['StartMonth'], $Entry['StartDay']); $dd = date_to_str($dateYmd); echo "<a class=\"entry\" href=\"view_entry.php?id={$id}"; echo "\" onmouseover=\"window.status='" . translate("View this entry") . "'; return true;\" onmouseout=\"window.status=''; return true;\">"; $Entry['Summary'] = str_replace("''", "'", $Entry['Summary']); $Entry['Summary'] = str_replace("\\", "", $Entry['Summary']); echo htmlspecialchars($Entry['Summary']); echo "</a> (" . $dd; if (!empty($time)) { echo " " . $time; } echo ")<br />\n"; } // Reset Variables $overlap = $error = $dd = $time = ''; } // Mark old events from prior import as deleted. if ($overwrite && count($oldUIDs) > 0) { // We could do this with a single SQL using sub-select, but // I'm pretty sure MySQL does not support it. $old = array_keys($oldUIDs); for ($i = 0; $i < count($old); $i++) { $sql = "SELECT cal_id FROM webcal_import_data WHERE " . "cal_import_type = '{$type}' AND " . "cal_external_id = '{$old[$i]}' AND " . "cal_login = '******' AND " . "cal_id < {$firstEventId}"; $res = dbi_query($sql); if ($res) { while ($row = dbi_fetch_row($res)) { $oldIds[] = $row[0]; } dbi_free_result($res); } else { echo translate("Database error") . ": " . dbi_error() . "<br />\n"; } } for ($i = 0; $i < count($oldIds); $i++) { $sql = "UPDATE webcal_entry_user SET cal_status = 'D' " . "WHERE cal_id = {$oldIds[$i]}"; $sqlLog .= $sql . "<br />\n"; dbi_query($sql); $numDeleted++; } } //echo "<b>SQL:</b><br />\n$sqlLog\n"; }