示例#1
0
function writeMiniCalendar($month, $year)
{
    global $gc_user, $roster, $addon;
    //if using SID field for authentication, include it in the links
    if (isset($gc_user['session_id'])) {
        $sid = "&sid=" . $gc_user['session_id'];
    } else {
        $sid = "";
    }
    //Check to see if user specified timezone exists, if not use default
    if (!isset($gc_user['user_timezone'])) {
        $gc_user['user_timezone'] = $addon['config']['CURR_TIME_OFFSET'];
    }
    $str = getDayNameHeader();
    // get user permission level
    $auth = cal_auth();
    // get the events for the month
    $eventdata = getEventDataArray($month, $year, $auth);
    // get week position of first day of month.
    $weekpos = getFirstDayOfMonthPosition($month, $year);
    // get number of days in month
    $days = 31 - (($month - ($month < 8 ? 1 : 0)) % 2 + ($month == 2 ? !($year % (!($year % 100) ? 400 : 4)) ? 1 : 2 : 0));
    // initialize day variable to zero, unless $weekpos is zero
    if ($weekpos == 0) {
        $day = 1;
    } else {
        $day = 0;
    }
    // initialize today's date variables for color change
    $timestamp = gmmktime() + $gc_user['user_timezone'] * 3600;
    $d = date('j', $timestamp);
    $m = date('n', $timestamp);
    $y = date('Y', $timestamp);
    // loop writes empty cells until it reaches position of 1st day of month ($wPos)
    // it writes the days, then fills the last row with empty cells after last day
    while ($day <= $days) {
        $str .= "<tr>\n";
        for ($i = 0; $i < 7; $i++) {
            if ($day > 0 && $day <= $days) {
                $str .= "\t<td class=\"";
                if ($day == $d && $month == $m && $year == $y) {
                    $str .= "today";
                } else {
                    $str .= "day";
                }
                $str .= "_minicell\" valign=\"top\"><span class=\"day_number\">";
                $str .= "" . $day . "";
                $str .= "</span><br>";
                if (!empty($eventdata[$day]["title"])) {
                    $eventcount = count($eventdata[$day]["title"]);
                } else {
                    $eventcount = '0';
                }
                // write picture link if posting exists for day
                for ($j = 0; $j < $eventcount; $j++) {
                    // skip these
                    if (in_array($eventdata[$day]["type"][$j], reset_event_names())) {
                        continue;
                    }
                    switch ($eventdata[$day]["type"][$j]) {
                        case "birthday":
                            //is a birthday
                            $str .= '<a href=\\"' . makelink('&amp;m=' . $month . '&amp;d=' . $day . $sid) . '">';
                            $str .= '<img src="' . $addon['image_url'] . 'calendar/Icon-Birth.jpg" border="0" width="16" height="16"></a>';
                            break;
                            //Do anything else
                        //Do anything else
                        default:
                            // Blacknight
                            $str .= '<a href="' . makelink('&amp;id=' . utf8_decode($eventdata[$day]['id'][$j]) . $sid) . '">';
                            $tip = '' . $eventdata[$day]['title'][$j] . " \n" . getGCtext($eventdata[$day]['type'][$j]) . "\n" . $eventdata[$day]['timestr'][$j] . '';
                            $image = $addon['image_url'] . 'calendar/Icon-' . $eventdata[$day]['type'][$j] . '.png';
                            $str .= gctt($tip, $image, getGCtext($eventdata[$day]['type'][$j]), '16', '16');
                            break;
                    }
                }
                $str .= "</td>\n";
                $day++;
            } elseif ($day == 0) {
                $str .= "\t<td class=\"empty_day_minicell\" valign=\"top\">&nbsp;</td>\n";
                $weekpos--;
                if ($weekpos == 0) {
                    $day++;
                }
            } else {
                $str .= "\t<td class=\"empty_day_minicell\" valign=\"top\">&nbsp;</td>\n";
            }
        }
        $str .= "</tr>\n\n";
    }
    $str .= "</table>\n\n";
    return $str;
}
示例#2
0
function writeCalendar($month, $year)
{
    $str = getDayNameHeader();
    $eventdata = getEventDataArray($month, $year);
    # get first row position of first day of month.
    $weekpos = getFirstDayOfMonthPosition($month, $year);
    # get user permission level
    $auth = isset($_SESSION['authdata']) ? $_SESSION['authdata']['userlevel'] : false;
    # get number of days in month
    $days = date("t", mktime(0, 0, 0, $month, 1, $year));
    # initialize day variable to zero, unless $weekpos is zero
    if ($weekpos == 0) {
        $day = 1;
    } else {
        $day = 0;
    }
    # initialize today's date variables for color change
    $timestamp = mktime() + CURR_TIME_OFFSET * 3600;
    $d = date('j', $timestamp);
    $m = date('n', $timestamp);
    $y = date('Y', $timestamp);
    # lookup for testing whether day is today
    $today["{$y}-{$m}-{$d}"] = 1;
    # loop writes empty cells until it reaches position of 1st day of
    # month ($wPos).  It writes the days, then fills the last row with empty
    # cells after last day
    while ($day <= $days) {
        $str .= "<tr>\n";
        # write row
        for ($i = 0; $i < 7; $i++) {
            # if cell is a day of month
            if ($day > 0 && $day <= $days) {
                # set css class today if cell represents current date
                $class = isset($today["{$year}-{$month}-{$day}"]) ? 'today' : 'day';
                $str .= "\n\t\t\t\t<td class=\"{$class}_cell\" valign=\"top\">\n\t\t\t\t<span class=\"day_number\">\n";
                if ($auth) {
                    $str .= "\n\t\t\t\t\t<a href=\"javascript: postMessage({$day}, {$month}, {$year})\">\n\t\t\t\t\t{$day}</a>";
                } else {
                    $str .= "{$day}";
                }
                $str .= "</span><br />";
                if (isset($eventdata[$day]["title"])) {
                    // enforce title limit
                    $eventcount = count($eventdata[$day]["title"]);
                    if (MAX_TITLES_DISPLAYED < $eventcount) {
                        $eventcount = MAX_TITLES_DISPLAYED;
                    }
                    // write title link if day's postings
                    for ($j = 0; $j < $eventcount; $j++) {
                        $str .= "\n\t\t\t\t\t\t<span class=\"title_txt\">\n\t\t\t\t\t\t-<a href=\"javascript:openPosting(" . $eventdata[$day]["id"][$j] . ")\">" . $eventdata[$day]["title"][$j] . "</a></span>" . $eventdata[$day]["timestr"][$j];
                    }
                }
                $str .= "</td>\n";
                $day++;
            } elseif ($day == 0) {
                $str .= "\n\t\t\t\t<td class=\"empty_day_cell\" valign=\"top\">&nbsp;</td>\n";
                $weekpos--;
                if ($weekpos == 0) {
                    $day++;
                }
            } else {
                $str .= "\n\t\t\t\t<td class=\"empty_day_cell\" valign=\"top\">&nbsp;</td>\n";
            }
        }
        $str .= "</tr>\n\n";
    }
    $str .= "</table>\n\n";
    return $str;
}