Esempio n. 1
0
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 ? '&nbsp;</td>' : '') . '
              <td class="entry" colspan="' . $ev_duration . '">' . ($pos > 1 ? '&nbsp;</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 . '&amp;date=' . ($tempClone ? $tempClone : $date) . (strlen($user) > 0 ? '&amp;user='******'') . '">' : '') . '[' . ($event->getLogin() == '__public__' ? $PUBLIC_ACCESS_FULLNAME : $event->getLogin()) . ']&nbsp;' . 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 . '">&nbsp;</td>' : '') . ($end_padding > 1 ? '
        <td class="alignleft" colspan="' . $end_padding . '">&nbsp;</td>' : '') : '') . '
      </tr>';
}
function print_entry($event, $date)
{
    global $categories, $DISPLAY_END_TIMES, $DISPLAY_LOCATION, $DISPLAY_TASKS_IN_GRID, $eventinfo, $is_assistant, $is_nonuser_admin, $layers, $login, $PHP_SELF, $TIME_SPACER, $user;
    static $key = 0;
    static $viewEventStr, $viewTaskStr;
    if (empty($viewEventStr)) {
        $viewEventStr = translate('View this event');
        $viewTaskStr = translate('View this task');
    }
    $catIcon = $in_span = $padding = $popup_timestr = $ret = $timestr = '';
    $cal_type = $event->getCalTypeName();
    $loginStr = $event->getLogin();
    if (access_is_enabled()) {
        $can_access = access_user_calendar('view', $loginStr, '', $event->getCalType(), $event->getAccess());
        $time_only = access_user_calendar('time', $loginStr);
        if ($cal_type == 'task' && $can_access == 0) {
            return false;
        }
    } else {
        $can_access = CAN_DOALL;
        $time_only = 'N';
    }
    // No need to display if show time only and not a timed event.
    if ($time_only == 'Y' && !$event->Istimed()) {
        return false;
    }
    $class = ($login != $loginStr && strlen($loginStr) ? 'layer' : ($event->getStatus() == 'W' ? 'unapproved' : '')) . 'entry';
    // If we are looking at a view, then always use "entry".
    if (strstr($PHP_SELF, 'view_m.php') || strstr($PHP_SELF, 'view_t.php') || strstr($PHP_SELF, 'view_v.php') || strstr($PHP_SELF, 'view_w.php')) {
        $class = 'entry';
    }
    if ($event->getPriority() < 4) {
        $ret .= '<strong>';
    }
    $cloneStr = $event->getClone();
    $id = $event->getID();
    $linkid = 'pop' . "{$id}-{$key}";
    $name = $event->getName();
    $view_text = $cal_type == 'task' ? $viewTaskStr : $viewEventStr;
    $key++;
    // Build entry link if UAC permits viewing.
    if ($can_access != 0 && $time_only != 'Y') {
        // Make sure clones have parents URL date.
        $href = 'href="view_entry.php?id=' . $id . '&amp;date=' . ($cloneStr ? $cloneStr : $date) . (strlen($user) > 0 ? '&amp;user='******'layerentry' ? '&amp;user='******'')) . '"';
        $title = ' title="' . $view_text . '" ';
    } else {
        $href = $title = '';
    }
    $ret .= '
      <a ' . $title . ' class="' . $class . '" id="' . "{$linkid}\" {$href}" . '><img src="';
    $catNum = abs($event->getCategory());
    $icon = $cal_type . '.gif';
    if ($catNum > 0) {
        $catIcon = 'icons/cat-' . $catNum . '.gif';
        if (!file_exists($catIcon)) {
            $catIcon = '';
        }
    }
    if (empty($catIcon)) {
        $ret .= 'images/' . $icon . '" class="bullet" alt="' . $view_text . '" width="5" height="7" />';
    } else {
        // Use category icon.
        $catAlt = empty($categories[$catNum]) ? '' : translate('Category') . ': ' . $categories[$catNum]['cat_name'];
        $ret .= $catIcon . '" alt="' . $catAlt . '" title="' . "{$catAlt}\" />";
    }
    if ($login != $loginStr && strlen($loginStr)) {
        if ($layers) {
            foreach ($layers as $layer) {
                if ($layer['cal_layeruser'] == $loginStr) {
                    $in_span = true;
                    $ret .= '<span style="color:' . $layer['cal_color'] . ';">';
                }
            }
        }
        // Check to see if Category Colors are set.
    } else {
        if (!empty($categories[$catNum]['cat_color'])) {
            $cat_color = $categories[$catNum]['cat_color'];
            if ($cat_color != '#000000') {
                $in_span = true;
                $ret .= '<span style="color:' . $cat_color . ';">';
            }
        }
    }
    if ($event->isAllDay()) {
        $timestr = $popup_timestr = translate('All day event');
    } else {
        if (!$event->isUntimed()) {
            $timestr = $popup_timestr = display_time($event->getDateTime());
            if ($event->getDuration() > 0) {
                $popup_timestr .= ' - ' . display_time($event->getEndDateTime());
            }
            if ($DISPLAY_END_TIMES == 'Y') {
                $timestr = $popup_timestr;
            }
            if ($cal_type == 'event') {
                $ret .= getShortTime($timestr) . ($time_only == 'Y' ? '' : $TIME_SPACER);
            }
        }
    }
    return $ret . build_entry_label($event, 'eventinfo-' . $linkid, $can_access, $popup_timestr, $time_only) . (!empty($location) && !empty($DISPLAY_LOCATION) && $DISPLAY_LOCATION == 'Y' ? '<br /><span class="location">(' . htmlspecialchars($location) . ')</span>' : '') . ($in_span == true ? '</span>' : '') . '</a>' . ($event->getPriority() < 4 ? '</strong>' : '') . '<br />';
}