示例#1
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;
}
示例#2
0
function getEventDataArray($month, $year, $auth = 0)
{
    global $roster, $addon;
    //////////////////////////////////////////////////////////////////////
    // Get Group Calendar Events
    //////////////////////////////////////////////////////////////////////
    $starttime = '';
    //First we get the events that DONT have set start times becuase they will
    // not be adjusted for the current time zone
    $sql = "SELECT id, title, start AS start_time, DATE_ADD(`start`, INTERVAL `duration` MINUTE) AS `end_time`, type, description, duration, ";
    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, ";
    $sql .= "DAYOFMONTH(`start`) AS d, MONTH(`start`) AS m, YEAR(`start`) AS y ";
    $sql .= "FROM " . CALENDAR_TABLE . " WHERE ";
    $sql .= "MONTH(`start`) = {$month} AND YEAR(`start`) = {$year} ";
    $sql .= "AND TIME_FORMAT(`start`, '%H:%i:%s')='00:00:25' ";
    $sql .= "ORDER BY `start`";
    $result = $roster->db->query($sql);
    //$result = mysql_query($sql,$gc_database['connection']) or die("Error in SQL Statement: $sql.\n ". mysql_error());
    $eventdata = array();
    while ($row = mysql_fetch_array($result)) {
        $eventdata[$row["d"]]["id"][] = $row["id"];
        if ($row['title'] == "") {
            $row['title'] = getGCtext($row['type']);
        }
        if (strlen($row["title"]) > $addon['config']['TITLE_CHAR_LIMIT']) {
            $eventdata[$row["d"]]["title"][] = substr(stripslashes($row["title"]), 0, TITLE_CHAR_LIMIT) . "...";
        } else {
            $eventdata[$row["d"]]["title"][] = stripslashes($row["title"]);
        }
        if (!($row["s_time"] == "00:00:25" && $row["e_time"] == "00:00:25")) {
            if ($row["s_time"] == "00:00:25") {
                $starttime = "- -";
            } else {
                $starttime = $row["stime"];
            }
            if ($row["e_time"] == "00:00:25" || $row["e_time"] == $row["s_time"]) {
                $endtime = "";
            } else {
                $endtime = " - " . $row["etime"];
            }
            $timestr = "({$starttime}{$endtime})&nbsp;";
        } else {
            $timestr = "<br>";
        }
        $eventdata[$row["d"]]["stime"][] = $starttime;
        $eventdata[$row["d"]]["timestr"][] = $timestr;
        $eventdata[$row["d"]]["type"][] = $row["type"];
        $eventdata[$row["d"]]["description"][] = $row["description"];
    }
    //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'];
    }
    $t_offset = $gc_user['user_timezone'] * 3600;
    //Now we get the Events that HAVE set start times becuase they will
    // need to be adjusted for the current time zone
    $sql = "SELECT id, title, start AS start_time, DATE_ADD(`start`, INTERVAL `duration` MINUTE) AS `end_time`, type, description, duration, ";
    if ($addon['config']['TIME_DISPLAY_FORMAT'] == "12hr") {
        $sql .= "TIME_FORMAT(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND), '%l:%i%p') AS stime, ";
        $sql .= "TIME_FORMAT(DATE_ADD(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND), INTERVAL `duration` MINUTE), '%l:%i%p') AS etime, ";
    } elseif ($addon['config']['TIME_DISPLAY_FORMAT'] == "24hr") {
        $sql .= "TIME_FORMAT(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND), '%H:%i') AS stime, ";
        $sql .= "TIME_FORMAT(DATE_ADD(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND), 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, ";
    $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 ";
    $sql .= "MONTH(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND)) = {$month} AND YEAR(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND)) = {$year} ";
    $sql .= "AND TIME_FORMAT(`start`, '%H:%i:%s')!='00:00:25' ";
    $sql .= "ORDER BY `start`";
    $result = $roster->db->query($sql);
    //$result = mysql_query($sql,$gc_database['connection']) or die("Error in SQL Statement: $sql.\n ". mysql_error());
    while ($row = mysql_fetch_array($result)) {
        $eventdata[$row["d"]]["id"][] = $row["id"];
        if ($row['title'] == "") {
            $row['title'] = getGCtext($row['type']);
        }
        if (strlen($row["title"]) > $addon['config']['TITLE_CHAR_LIMIT']) {
            $eventdata[$row["d"]]["title"][] = substr(stripslashes($row["title"]), 0, $addon['config']['TITLE_CHAR_LIMIT']) . "...";
        } else {
            $eventdata[$row["d"]]["title"][] = stripslashes($row["title"]);
        }
        if (!($row["s_time"] == "00:00:25" && $row["e_time"] == "00:00:25")) {
            if ($row["s_time"] == "00:00:25") {
                $starttime = "- -";
            } else {
                $starttime = $row["stime"];
            }
            if ($row["e_time"] == "00:00:25" || $row["e_time"] == $row["s_time"]) {
                $endtime = "";
            } else {
                $endtime = " - " . $row["etime"];
            }
            $timestr = "({$starttime}{$endtime})&nbsp;";
        } else {
            $timestr = "<br>";
        }
        $eventdata[$row["d"]]["stime"][] = $starttime;
        $eventdata[$row["d"]]["timestr"][] = $timestr;
        $eventdata[$row["d"]]["type"][] = $row["type"];
        $eventdata[$row["d"]]["description"][] = $row["description"];
    }
    return $eventdata;
}
示例#3
0
文件: index.php 项目: Sajaki/addons
} elseif ($addon['config']['TIME_DISPLAY_FORMAT'] == "24hr") {
    $sql .= "TIME_FORMAT(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND), '%H:%i') AS stime, ";
    $sql .= "TIME_FORMAT(DATE_ADD(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND), 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, ";
$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 DAYOFMONTH(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND)) = {$day} AND MONTH(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND)) = {$month} AND YEAR(DATE_ADD(`start`, INTERVAL {$t_offset} SECOND)) = {$year} ";
$sql .= "AND TIME_FORMAT(`start`, '%H:%i:%s')!='00:00:25' AND id != '" . $event['id'] . "' ";
$sql .= "ORDER BY start ASC";
$result = $roster->db->query($sql);
//$result = mysql_query($sql,$gc_database['connection']) or die("Error in SQL Statement: $sql.\n ". mysql_error());
while ($row = mysql_fetch_array($result)) {
    if ($row['s_time'] == "00:00:25") {
        $timestr = "";
    } elseif ($row['s_time'] == $row['e_time']) {
        $timestr = $row['stime'];
    } else {
        $timestr = $row['stime'] . " - " . $row['etime'];
    }
    $row['timestr'] = $timestr;
    if ($row['title'] == "") {
        $row['title'] = getGCtext($row['type']);
    }
    if (!in_array($row['type'], $skipme)) {
        $dayEvents[] = $row;
    }
}
echo $event['creator'] . '---';
示例#4
0
	<p><?php 
    echo utf8_decode($event['title']);
    ?>
<br>
	<?php 
    echo $roster->locale->act['created_by'];
    ?>
 <?php 
    echo utf8_decode($event['creator']);
    ?>
</p>
	<table border="0" width="400" cellpadding="2" cellspacing="0">
	  <tr>
		<td valign="top" width="100%">
		  <p><?php 
    echo getGCtext($event['type']);
    ?>
<br><br>
		  <?php 
    echo $roster->locale->act['months_short'][$event['m'] - 1];
    ?>
 <?php 
    echo $event['d'];
    ?>
, <?php 
    echo $event['y'];
    ?>
 <?php 
    echo $event['timestr'];
    ?>
		  <?php