Commit 38888f3c authored by Francesco Iannuzzelli's avatar Francesco Iannuzzelli

#26 Calendar API

parent dec5c45d
......@@ -259,7 +259,7 @@ class Events
$e['prov'] = $row['geo_name'];
$e['description'] = $row['is_html']? $row['description'] : $th->Htmlise($row['description'],false);
$e['place_details'] = $th->Htmlise($row['place_details'],false);
$e['export'] = $irl->pub_web . '/' . $ini->Get("events_path") . "/export.php?id={$row['id_event']}";
$e['export'] = $irl->pub_web . '/' . $ini->Get("events_path") . "/export.php?format=ical&type=event&id={$row['id_event']}";
$e['export_escaped'] = urlencode($e['export']);
$e['export_webcal'] = preg_replace('#^http(s)?://#','webcal://',$e['export']);
$e['gmaps'] = "https://www.google.com/maps/search/?api=1&hl={$tr->lang_code}&query=" . urlencode("{$row['place']}, {$row['place_details']}");
......
......@@ -33,22 +33,56 @@ include_once(SERVER_ROOT."/../classes/events.php");
include_once(SERVER_ROOT."/../classes/formhelper.php");
$fh = new FormHelper(false,0,false);
$get = $fh->HttpGet();
$id = (int)$get['id'];
if($id>0) {
$ee = new Events();
echo $ee->ExportIcsEvent($id);
} else {
$er = new EventsREST();
$allowed_formats = array('ical','json','xml');
$format = isset($get['format'])? $get['format'] : 'json';
if(in_array($format, $allowed_formats)) {
$params = array();
$params['format'] = 'ical';
if(isset($get['prov']) && $get['prov']!='') {
$params['prov'] = $get['prov'];
$params['format'] = $format;
$allowed_types = array('event','prov','reg','all');
$type = isset($get['type'])? $get['type'] : 'all';
if(in_array($type, $allowed_types)) {
if($type == 'event') {
$id = (int)$get['id'];
if($id>0) {
$ee = new Events();
echo $ee->ExportIcsEvent($id);
} else {
http_response_code(404);
}
} else {
switch($type) {
case 'prov':
$id = $get['id'];
if($id!='') {
$params['prov'] = $id;
} else {
http_response_code(404);
exit;
}
break;
case 'reg':
$id = $get['id'];
if($id!='') {
$params['reg'] = $id;
} else {
http_response_code(404);
exit;
}
break;
case 'all':
break;
}
$er = new EventsREST();
$er->arguments = $params;
echo $er->Next();
}
} else {
http_response_code(401);
}
if(isset($get['reg']) && $get['reg']!='') {
$params['reg'] = $get['reg'];
}
$er->arguments = $params;
echo $er->Next();
} else {
http_response_code(401);
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment