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; } } }
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 build_entry_label($event, $popupid, $can_access, $timestr, $time_only = 'N') { global $eventinfo, $login, $SUMMARY_LENGTH, $UAC_ENABLED, $user; $ret = ''; // Get reminders display string. $reminder = getReminders($event->getId(), true); $can_access = $UAC_ENABLED == 'Y' ? $can_access : 0; $not_my_entry = $login != $user && strlen($user) || $login != $event->getLogin() && strlen($event->getLogin()); $sum_length = $SUMMARY_LENGTH; if ($event->isAllDay() || $event->isUntimed()) { $sum_length += 6; } $tmpAccess = $event->getAccess(); $tmpId = $event->getId(); $tmpLogin = $event->getLogin(); $tmpName = $event->getName(); $tmp_ret = htmlspecialchars(substr($tmpName, 0, $sum_length) . (strlen($tmpName) > $sum_length ? '...' : '')); if ($not_my_entry && $tmpAccess == 'R' && !($can_access & PRIVATE_WT)) { if ($time_only != 'Y') { $ret = '(' . translate('Private') . ')'; } // translate ( 'This event is private' ) $eventinfo .= build_entry_popup($popupid, $tmpLogin, str_replace('XXX', translate('private'), translate('This event is XXX.')), ''); } else { if ($not_my_entry && $tmpAccess == 'C' && !($can_access & CONF_WT)) { if ($time_only != 'Y') { $ret = '(' . translate('Conf.') . ')'; } $eventinfo .= build_entry_popup($popupid, $tmpLogin, str_replace('XXX', translate('confidential'), translate('This event is XXX.')), ''); } else { if ($can_access == 0 && $UAC_ENABLED == 'Y') { if ($time_only != 'Y') { $ret = $tmp_ret; } $eventinfo .= build_entry_popup($popupid, $tmpLogin, '', $timestr, '', '', $tmpName, ''); } else { if ($time_only != 'Y') { $ret = $tmp_ret; } $eventinfo .= build_entry_popup($popupid, $tmpLogin, $event->getDescription(), $timestr, site_extras_for_popup($tmpId), $event->getLocation(), $tmpName, $tmpId, $reminder); } } } return $ret; }
function list_unapproved($user) { global $eventinfo, $key, $login, $NONUSER_ENABLED, $noret, $temp_fullname; user_load_variables($user, 'temp_'); $rssLink = '<a href="rss_unapproved.php?user='******'"><img src="images/rss.png" width="14" height="14" alt="RSS 2.0 - ' . htmlspecialchars($temp_fullname) . '" border="0"/></a>'; $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]; $key++; $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; $linkid = "pop{$id}-{$key}"; $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 .= ($count == 0 ? ' <tr> <td colspan="5"><h3>' . $temp_fullname . ' ' . $rssLink . '</h3></td> </tr>' : '') . ' <tr ' . ($count % 2 == 0 ? '' : 'class="odd"') . '> <td width="5%" align="right"><input type="checkbox" name="' . $entryID . '" value="' . $user . '"/></td> <td><a title="' . $viewStr . '" class="entry" id="' . $linkid . '" href="' . $view_link . '.php?id=' . $id . '&user='******'">' . htmlspecialchars($name) . '</a> (' . $eventdate . '):</td>' . ' <td align="center"><input type="image" src="images/check.gif" title="' . $appConStr . '" onclick="return do_confirm( \'approve\', \'' . $cal_user . '\', \'' . $entryID . '\' );" /></td>' . ' <td align="center"><input type="image" src="images/rejected.gif" title="' . $rejectStr . '" onclick="return do_confirm( \'reject\', \'' . $cal_user . '\', \'' . $entryID . '\' );" /></td>' . (!access_is_enabled() || access_user_calendar('edit', $user) ? ' <td align="center"><input type="image" src="images/delete.png" title="' . $deleteStr . '" onclick="return do_confirm( \'delete\', \'' . $cal_user . '\', \'' . $entryID . '\' );\\" /></td>' : '') . ' </tr>'; $eventinfo .= build_entry_popup('eventinfo-' . $linkid, $cal_user, $description, $timestr, site_extras_for_popup($id)); $count++; } if ($count > 1) { $ret .= ' <tr> <td colspan="5" nowrap="nowrap"> <img src="images/select.gif" border="0" alt="" /> <label><a title="' . $checkAllStr . '" onclick="check_all( \'' . $user . '\' );">' . $checkAllStr . '</a> / <a title="' . $uncheckAllStr . '" onclick="uncheck_all( \'' . $user . '\' );">' . $uncheckAllStr . '</a></label> <input type="image" src="images/check.gif" title="' . $appSelStr . '" onclick="return do_confirm( \'approveSelected\', \'' . $cal_user . '\' );" /> <input type="image" src="images/rejected.gif" title="' . $rejectSelStr . '" onclick="return do_confirm( \'rejectSelected\', \'' . $cal_user . '\' );" /> ( ' . $emailStr . ' ) </td> </tr>'; } } if ($count == 0) { $noret .= ' <tr> <td colspan="5" class="nounapproved">' . str_replace('XXX', $temp_fullname, translate('No unapproved entries for XXX.')) . ' ' . $rssLink . '</td> </tr>'; } return $ret; }
function print_upcoming_event($e, $date) { global $display_link, $link_target, $SERVER_URL, $charset, $login, $display_tzid, $showTime, $showPopups, $eventinfo, $username, $hcalendar_output, $UPCOMING_DISPLAY_CAT_ICONS; $popupid = 'pop' . $e->getId() . '-' . $date; $private = $confidential = false; // Access: P=Public, R=Private, C=Confidential if ($e->getAccess() == 'R') { // not a public event, so we will just display "Private" $private = true; } else { if ($e->getAccess() == 'C') { // not a public event, so we will just display "Confidential" $confidential = true; } } if (!empty($SERVER_URL) && !$private && !$confidential) { echo "<div class=\"vevent\">\n"; if ($display_link) { if ($showPopups) { $timestr = ''; if ($e->isAllDay()) { $timestr = translate('All day event'); } else { if ($e->getTime() >= 0) { $timestr = display_time($e->getDatetime()); if ($e->getDuration() > 0) { $timestr .= ' - ' . display_time($e->getEndDateTime()); } } } $eventinfo .= build_entry_popup('eventinfo-' . $popupid, $username, $e->getDescription(), $timestr, site_extras_for_popup($e->getId()), $e->getLocation(), $e->getName(), $e->getId()); } $link = "<a class=\"entry\" id=\"{$popupid}\" title=\"" . htmlspecialchars($e->getName()) . '" href="' . $SERVER_URL . 'view_entry.php?id=' . $e->getID() . "&date={$date}&user="******"\" target=\"{$link_target}\""; } $link .= '>'; if (empty($UPCOMING_DISPLAY_CAT_ICONS) || $UPCOMING_DISPLAY_CAT_ICONS != 'N') { $catNum = abs($e->getCategory()); if ($catNum > 0) { $catIcon = 'icons/cat-' . $catNum . '.gif'; if (file_exists($catIcon)) { echo $link . '<img src="' . $catIcon . '" alt="category icon" border="0"/></a>'; } } } echo $link; } } if ($private) { echo '[' . translate('Private') . ']'; } else { if ($confidential) { echo '[' . translate('Confidential') . ']'; } else { echo '<span class="summary">' . htmlspecialchars($e->getName()) . '</span>'; } } if ($display_link && !empty($SERVER_URL) && !$private) { echo '</a>'; } //added for hCalendar if ($hcalendar_output) { echo '<abbr class="dtstart" title="' . export_ts_utc_date($e->getDateTimeTS()) . '">' . $e->getDateTime() . "</abbr>\n"; echo '<abbr class="dtend" title="' . export_ts_utc_date($e->getEndDateTimeTS()) . '">' . $e->getEndDateTimeTS() . "</abbr>\n"; echo '<span class="description">' . $e->getDescription() . "</span>\n"; if (strlen($e->getLocation()) > 0) { echo '<span class="location">' . $e->getLocation() . "</span>\n"; } $categories = get_categories_by_id($e->getId(), $username); $category = implode(', ', $categories); if (strlen($category) > 0) { echo '<span class="categories">' . htmlentities($category) . "</span>\n"; } if (strlen($e->getUrl()) > 0) { echo '<span class="url">' . $e->getUrl() . "</span>\n"; } $rrule = export_recurrence_ical($e->getId()); if (strlen($rrule) > 6) { echo '<span class="rrule">' . substr($rrule, 6) . "</span>\n"; } } if ($showTime) { //show event time if requested (default=don't show) if ($e->isAllDay()) { echo ' (' . translate('All day event') . ")\n"; } else { if ($e->getTime() != -1) { echo ' (' . display_time($e->getDateTime(), $display_tzid) . ")\n"; } } } echo "</div>\n"; }
function print_detailed_entry($event, $date) { global $eventinfo, $layers, $login, $user; static $key = 0; $descStr = $event->getDescription(); $evAccessStr = $event->getAccess(); $evPri = $event->getPriority() < 4; $getExtStr = $event->getExtForID(); $loginStr = $event->getLogin(); $name = $event->getName(); $class = ($login != $loginStr && strlen($loginStr) ? 'layer' : ($event->getStatus() == 'W' ? 'unapproved' : '')) . 'entry'; if ($getExtStr != '') { $id = $getExtStr; $name .= ' (' . translate('cont.') . ')'; } else { $id = $event->getID(); } $linkid = 'pop' . "{$id}-{$key}"; $key++; echo ($evPri ? ' <strong>' : '') . ' <a title="' . translate('View this entry') . '" class="' . $class . '" id="' . $linkid . '" href="view_entry.php?id=' . $id . '&date=' . $date; if (strlen($user) > 0) { echo '&user='******'layerentry') { echo '&user='******'<img src="images/circle.gif" class="bullet" alt="view icon" />'; if ($login != $loginStr && strlen($loginStr)) { if ($layers) { foreach ($layers as $layer) { if ($layer['cal_layeruser'] == $loginStr) { $in_span = true; echo ' <span style="color:#' . $layer['cal_color'] . ';">'; } } } } $timestr = ''; if ($event->isAllDay()) { $timestr = translate('All day event'); } else { if ($event->getDuration() > 0) { $timestr = display_time($event->getDateTime()) . ' - ' . display_time($event->getEndDateTime()); echo $timestr . '» '; } } if ($login != $user && $evAccessStr == 'R' && strlen($user)) { $PN = $PD = '(' . translate('Private') . ')'; } elseif ($login != $loginStr && $evAccessStr == 'R' && strlen($loginStr)) { $PN = $PD = '(' . translate('Private') . ')'; } elseif ($login != $loginStr && strlen($loginStr)) { $PN = htmlspecialchars($name); $PD = activate_urls(htmlspecialchars($descStr)); } else { $PN = htmlspecialchars($name); $PD = activate_urls(htmlspecialchars($descStr)); } if (!empty($in_span)) { $PN .= '</span>'; } echo $PN . '</a>' . ($evPri ? ' </strong>' : '') . ($PN != $PD ? ' - ' . $PD : '') . '<br />'; $eventinfo .= build_entry_popup('eventinfo-' . $linkid, $loginStr, $descStr, $timestr, site_extras_for_popup($id)); }