shiftplan ical export
This commit is contained in:
parent
1633d62772
commit
cf3960aeba
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
// Öffentlich zugängliche Funktion zum Abrufen von iCal-Exports der eigenen Schichten
|
// Öffentlich zugängliche Funktion zum Abrufen von iCal-Exports der eigenen Schichten
|
||||||
function user_ical() {
|
function user_ical() {
|
||||||
global $ical_shifts;
|
global $ical_shifts, $user;
|
||||||
|
|
||||||
if (isset ($_REQUEST['key']) && preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key']))
|
if (isset ($_REQUEST['key']) && preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key']))
|
||||||
$key = $_REQUEST['key'];
|
$key = $_REQUEST['key'];
|
||||||
|
@ -24,18 +24,20 @@ function user_ical() {
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Content-Type: text/calendar; charset=utf-8");
|
header("Content-Type: text/calendar; charset=utf-8");
|
||||||
echo "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//-//Engelsystem//DE\r\nCALSCALE:GREGORIAN\r\n";
|
$html = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//-//Engelsystem//DE\r\nCALSCALE:GREGORIAN\r\n";
|
||||||
foreach ($ical_shifts as $shift) {
|
foreach ($ical_shifts as $shift) {
|
||||||
echo "BEGIN:VEVENT\r\n";
|
$html .= "BEGIN:VEVENT\r\n";
|
||||||
echo "UID:" . md5($shift['start'] . $shift['end'] . $shift['name']) . "\r\n";
|
$html .= "UID:" . md5($shift['start'] . $shift['end'] . $shift['name']) . "\r\n";
|
||||||
echo "SUMMARY:" . str_replace("\n", "\\n", preg_replace("/[^a-z]*/i", '', $shift['name'])) . "\r\n";
|
$html .= "SUMMARY:" . str_replace("\n", "\\n", $shift['name']) . "\r\n";
|
||||||
echo "DESCRIPTION:" . str_replace("\n", "\\n", $shift['Comment']) . "\r\n";
|
$html .= "DESCRIPTION:" . str_replace("\n", "\\n", $shift['Comment']) . "\r\n";
|
||||||
echo "DTSTART;TZID=Europe/Berlin:" . date("Ymd\THis", $shift['start']) . "\r\n";
|
$html .= "DTSTART;TZID=Europe/Berlin:" . date("Ymd\THis", $shift['start']) . "\r\n";
|
||||||
echo "DTEND;TZID=Europe/Berlin:" . date("Ymd\THis", $shift['end']) . "\r\n";
|
$html .= "DTEND;TZID=Europe/Berlin:" . date("Ymd\THis", $shift['end']) . "\r\n";
|
||||||
echo "LOCATION:" . $shift['Name'] . "\r\n";
|
$html .= "LOCATION:" . $shift['Name'] . "\r\n";
|
||||||
echo "END:VEVENT\r\n";
|
$html .= "END:VEVENT\r\n";
|
||||||
}
|
}
|
||||||
echo "END:VCALENDAR\r\n";
|
$html .= "END:VCALENDAR\r\n";
|
||||||
|
header("Content-Length: " . strlen($html));
|
||||||
|
echo $html;
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -27,7 +27,7 @@ function user_myshifts() {
|
||||||
}
|
}
|
||||||
elseif (isset ($_REQUEST['edit']) && preg_match("/^[0-9]*$/", $_REQUEST['edit'])) {
|
elseif (isset ($_REQUEST['edit']) && preg_match("/^[0-9]*$/", $_REQUEST['edit'])) {
|
||||||
$id = $_REQUEST['edit'];
|
$id = $_REQUEST['edit'];
|
||||||
$shift = sql_select("SELECT `ShiftEntry`.`Comment`, `Shifts`.*, `Room`.`Name`, `AngelTypes`.`name` as `angel_type` FROM `ShiftEntry` JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`) JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `id`=" . sql_escape($id) . " AND `UID`=" . sql_escape($shifts_user['UID']) . " LIMIT 1");
|
$shift = sql_select("SELECT `ShiftEntry`.`Comment`, `Shifts`.*, `Room`.`Name`, `AngelTypes`.`name` as `angel_type` FROM `ShiftEntry` JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`) JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `ShiftEntry`.`id`=" . sql_escape($id) . " AND `UID`=" . sql_escape($shifts_user['UID']) . " LIMIT 1");
|
||||||
if (count($shift) > 0) {
|
if (count($shift) > 0) {
|
||||||
$shift = $shift[0];
|
$shift = $shift[0];
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,7 @@ function view_user_shifts() {
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
global $ical_shifts;
|
global $ical_shifts;
|
||||||
|
|
||||||
|
$ical_shifts = array ();
|
||||||
$days = sql_select("SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name` FROM `Shifts`");
|
$days = sql_select("SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name` FROM `Shifts`");
|
||||||
$rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
|
$rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
|
||||||
$types = sql_select("SELECT `id`, `name` FROM `AngelTypes`");
|
$types = sql_select("SELECT `id`, `name` FROM `AngelTypes`");
|
||||||
|
@ -271,8 +272,7 @@ function view_user_shifts() {
|
||||||
$shifts = sql_select("SELECT * FROM `Shifts`
|
$shifts = sql_select("SELECT * FROM `Shifts`
|
||||||
WHERE `RID` IN (" . implode(',', $_SESSION['user_shifts']['rooms']) . ")
|
WHERE `RID` IN (" . implode(',', $_SESSION['user_shifts']['rooms']) . ")
|
||||||
AND DATE(FROM_UNIXTIME(`start`)) IN ('" . implode("','", $_SESSION['user_shifts']['days']) . "')
|
AND DATE(FROM_UNIXTIME(`start`)) IN ('" . implode("','", $_SESSION['user_shifts']['days']) . "')
|
||||||
ORDER BY `start`
|
ORDER BY `start`");
|
||||||
");
|
|
||||||
|
|
||||||
$shifts_table = "";
|
$shifts_table = "";
|
||||||
$row_count = 0;
|
$row_count = 0;
|
||||||
|
|
Loading…
Reference in New Issue