This commit is contained in:
Philip Häusler 2012-12-03 21:00:20 +01:00
parent 6dba2ad03d
commit f62bd8e56b
1 changed files with 32 additions and 31 deletions

View File

@ -20,7 +20,7 @@ function user_ical() {
require_once ('includes/pages/user_shifts.php'); require_once ('includes/pages/user_shifts.php');
view_user_shifts(); view_user_shifts();
} else { } else {
$ical_shifts = sql_select("SELECT * FROM `ShiftEntry` JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `UID`=" . sql_escape($user['UID']) . " ORDER BY `start`"); $ical_shifts = sql_select("SELECT `Shifts`.*, `Room`.`Name` as `room_name` FROM `ShiftEntry` INNER JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) INNER JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `UID`=" . sql_escape($user['UID']) . " ORDER BY `start`");
} }
header("Content-Type: text/calendar; charset=utf-8"); header("Content-Type: text/calendar; charset=utf-8");
@ -29,10 +29,11 @@ function user_ical() {
$html .= "BEGIN:VEVENT\r\n"; $html .= "BEGIN:VEVENT\r\n";
$html .= "UID:" . md5($shift['start'] . $shift['end'] . $shift['name']) . "\r\n"; $html .= "UID:" . md5($shift['start'] . $shift['end'] . $shift['name']) . "\r\n";
$html .= "SUMMARY:" . str_replace("\n", "\\n", $shift['name']) . "\r\n"; $html .= "SUMMARY:" . str_replace("\n", "\\n", $shift['name']) . "\r\n";
if(isset($shift['Comment']))
$html .= "DESCRIPTION:" . str_replace("\n", "\\n", $shift['Comment']) . "\r\n"; $html .= "DESCRIPTION:" . str_replace("\n", "\\n", $shift['Comment']) . "\r\n";
$html .= "DTSTART;TZID=Europe/Berlin:" . date("Ymd\THis", $shift['start']) . "\r\n"; $html .= "DTSTART;TZID=Europe/Berlin:" . date("Ymd\THis", $shift['start']) . "\r\n";
$html .= "DTEND;TZID=Europe/Berlin:" . date("Ymd\THis", $shift['end']) . "\r\n"; $html .= "DTEND;TZID=Europe/Berlin:" . date("Ymd\THis", $shift['end']) . "\r\n";
$html .= "LOCATION:" . $shift['Name'] . "\r\n"; $html .= "LOCATION:" . $shift['room_name'] . "\r\n";
$html .= "END:VEVENT\r\n"; $html .= "END:VEVENT\r\n";
} }
$html .= "END:VCALENDAR\r\n"; $html .= "END:VCALENDAR\r\n";