Пример #1
0
    $eid = "";
    $month = (int) $_GET['m'];
    $day = (int) $_GET['d'];
    $year = (int) $_GET['y'];
} else {
    // set month and year to present if month
    // and year not received from query string
    $eid = "";
    $month = date("n", gmmktime() + $t_offset);
    $day = date("j", gmmktime() + $t_offset);
    $year = date("Y", gmmktime() + $t_offset);
}
$prevDay = dateadd($month, $day, $year, "-1", "day");
$nextDay = dateadd($month, $day, $year, "1", "day");
////// Get other events happening this day
$skipme = reset_event_names();
$dayEvents = array();
//First get the ones without a start time
$sql = "SELECT id, title, start AS start_time, DATE_ADD(`start`, INTERVAL `duration` MINUTE) AS `end_time`, ";
$sql .= "creator, type, duration, `description`, minlevel, maxlevel, limits, maxattend, ";
if ($addon['config']['TIME_DISPLAY_FORMAT'] == "12hr") {
    $sql .= "TIME_FORMAT(`start`, '%l:%i%p') AS stime, ";
    $sql .= "TIME_FORMAT(DATE_ADD(`start`, INTERVAL `duration` MINUTE), '%l:%i%p') AS etime, ";
} elseif ($addon['config']['TIME_DISPLAY_FORMAT'] == "24hr") {
    $sql .= "TIME_FORMAT(`start`, '%H:%i') AS stime, ";
    $sql .= "TIME_FORMAT(DATE_ADD(`start`, INTERVAL `duration` MINUTE), '%H:%i') AS etime, ";
} else {
    echo "Bad time display format, check your configuration.";
}
$sql .= "TIME_FORMAT(`start`, '%H:%i:%s') AS s_time, ";
$sql .= "TIME_FORMAT(DATE_ADD(`start`, INTERVAL `duration` MINUTE), '%H:%i:%s') AS e_time, ";
Пример #2
0
function getUpcomingEvents()
{
    $right_now = gmdate("Y-m-d H:i:s");
    global $gc_database, $roster;
    global $gc_user;
    global $debuging_flag;
    $skipme = reset_event_names();
    //Check to see if user specified timezone exists, if not use default
    if (!isset($gc_user['user_timezone'])) {
        $gc_user['user_timezone'] = CURR_TIME_OFFSET;
    }
    $t_offset = $gc_user['user_timezone'] * 3600;
    //////////////////////////////////////////////////////////////////////
    // Get Group Calendar Events
    //////////////////////////////////////////////////////////////////////
    $sql = "SELECT `id`, `title`, `start` AS `start_time`, DATE_ADD(`start`, INTERVAL `duration` MINUTE) AS `end_time`, `type`, `duration`, `description`, `guildonly`, ";
    $sql .= "TIME_FORMAT(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND), '%l:%i%p') AS stime12, ";
    $sql .= "TIME_FORMAT(DATE_ADD(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND), INTERVAL `duration` MINUTE), '%l:%i%p') AS etime12, ";
    $sql .= "TIME_FORMAT(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND), '%H:%i') AS stime24, ";
    $sql .= "TIME_FORMAT(DATE_ADD(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND), INTERVAL `duration` MINUTE), '%H:%i') AS etime24, ";
    $sql .= "TIME_FORMAT(start, '%H:%i:%s') AS s_time, ";
    $sql .= "TIME_FORMAT(DATE_ADD(`start`, INTERVAL `duration` MINUTE), '%H:%i:%s') AS e_time, ";
    $sql .= "DAYOFMONTH(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND)) AS d, MONTH(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND)) AS m, YEAR(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND)) AS y ";
    $sql .= "FROM " . CALENDAR_TABLE . "  WHERE (`start` > '{$right_now}' OR DATE_ADD(`start`, INTERVAL `duration` MINUTE) > '{$right_now}') AND `type` != 'Birth' ORDER BY `start` ASC";
    $result = $roster->db->query($sql);
    // $result = mysql_query($sql,$gc_database['connection']);
    if ($result == false && $debuging_flag) {
        print "Error in SQL statement in getUpcomingEvents() function.<br />\nmySQL error: " . mysql_error() . "<br />\nFull SQL string: {$sql}<br />\n";
    }
    $newEvents = array();
    while ($row = mysql_fetch_array($result)) {
        if (in_array($row["type"], $skipme)) {
            continue;
        }
        $event = array();
        $event['title'] = stripslashes($row["title"]);
        if ($event['title'] == "") {
            $event['title'] = getGCtext($row['type']);
        }
        if (defined("TIME_DISPLAY_FORMAT") && TIME_DISPLAY_FORMAT == "12hr") {
            $stime = $row["stime12"];
            $etime = $row["etime12"];
        } else {
            $stime = $row["stime24"];
            $etime = $row["etime24"];
        }
        if (!($row["s_time"] == "00:00:25" && $row["e_time"] == "00:00:25")) {
            if ($row["s_time"] == "00:00:25") {
                $starttime = "- -";
            } else {
                $starttime = $stime;
            }
            if ($row["e_time"] == "00:00:25" || $row["e_time"] == $row["s_time"]) {
                $endtime = "";
            } else {
                $endtime = " - " . $etime;
            }
            $timestr = "({$starttime}{$endtime})&nbsp;";
        } else {
            $timestr = "<br>";
        }
        $event["id"] = $row["id"];
        $event["timestr"] = $timestr;
        $event["type"] = $row["type"];
        $event["start12"] = $row["stime12"];
        $event["end12"] = $row["etime12"];
        $event["start24"] = $row["stime24"];
        $event["end24"] = $row["etime24"];
        $event["duration"] = $row["duration"];
        $event["description"] = $row["description"];
        $event["guildonly"] = $row["guildonly"];
        $event["mday"] = $row["d"];
        $event["mon"] = $row["m"];
        $event["year"] = $row["y"];
        $event["datestr"] = date("l M j", mktime(12, 1, 1, $row["m"], $row["d"], $row["y"]));
        $newEvents[] = $event;
    }
    return $newEvents;
}
Пример #3
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;
}