forked from web2project/web2project
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcalendar.php
43 lines (35 loc) · 1.43 KB
/
calendar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
require_once 'base.php';
require_once W2P_BASE_DIR . '/includes/config.php';
require_once W2P_BASE_DIR . '/includes/main_functions.php';
require_once W2P_BASE_DIR . '/includes/db_adodb.php';
$AppUI = new w2p_Core_CAppUI();
$token = w2PgetParam($_GET, 'token', '');
$token = preg_replace("/[^A-Za-z0-9]/", "", $token );
$format = w2PgetParam($_GET, 'format', 'ical');
$userId = CUser::getUserIdByToken($token);
$AppUI->loadPrefs($userId);
$AppUI->user_id = $userId;
$AppUI->setUserLocale();
@include_once (W2P_BASE_DIR . '/locales/' . $AppUI->user_locale . '/locales.php');
include_once W2P_BASE_DIR . '/locales/core.php';
$defaultTZ = w2PgetConfig('system_timezone', 'Europe/London');
$defaultTZ = ('' == $defaultTZ) ? 'Europe/London' : $defaultTZ;
date_default_timezone_set($defaultTZ);
switch ($format) {
//TODO: We only output in vCal, are there others we need to consider?
case 'vcal':
default:
$format = 'vcal';
header ( 'Content-Type: text/calendar' );
header ( 'Content-disposition: attachment; filename="calendar.ics"' );
break;
}
if ($userId > 0) {
$myTimezoneName = date('e');
$calendarHeader = "BEGIN:VCALENDAR\nPRODID:-//web2project//EN\nVERSION:2.0\nCALSCALE:GREGORIAN\nMETHOD:PUBLISH\nX-WR-TIMEZONE:Europe/London\n";
$calendarFooter = "END:VCALENDAR";
$hooks = new w2p_Core_HookHandler($AppUI);
$buffer = $hooks->calendar();
echo $calendarHeader.$buffer.$calendarFooter;
}