Commit 3f3fda6c authored by Francesco Iannuzzelli's avatar Francesco Iannuzzelli

#26 Calendar API

parent 38888f3c
......@@ -569,20 +569,27 @@ class Events
$params['format'] = (isset($arguments['format']) && in_array($arguments['format'],$formats))? $arguments['format'] : 'json';
$params['id_prov'] = "0";
$params['id_reg'] = "0";
if(isset($arguments['prov']) && $arguments['prov']!='') {
$geo = new Geo();
$prov = $geo->ProvinceGetByProv($arguments['prov']);
if(isset($prov['id_prov']) && $prov['id_prov']>0) {
$params = array_merge($params,$prov);
}
} elseif(isset($arguments['reg']) && $arguments['reg']!='') {
$geo = new Geo();
$reg = $geo->RegionGetByReg($arguments['reg']);
if(isset($reg['id_reg']) && $reg['id_reg']>0) {
$params = array_merge($params,$reg);
if(isset($arguments['id']) && $arguments['id']>0) {
include_once(SERVER_ROOT."/../classes/event.php");
$e = new Event();
$event = $e->EventGet($arguments['id']);
$events = [$event];
} else {
if(isset($arguments['prov']) && $arguments['prov']!='') {
$geo = new Geo();
$prov = $geo->ProvinceGetByProv($arguments['prov']);
if(isset($prov['id_prov']) && $prov['id_prov']>0) {
$params = array_merge($params,$prov);
}
} elseif(isset($arguments['reg']) && $arguments['reg']!='') {
$geo = new Geo();
$reg = $geo->RegionGetByReg($arguments['reg']);
if(isset($reg['id_reg']) && $reg['id_reg']>0) {
$params = array_merge($params,$reg);
}
}
$events = $this->NextPub($params);
}
$events = $this->NextPub($params);
$info = array();
$info['params'] = $params;
$info['qs'] = $arguments;
......
......@@ -44,16 +44,25 @@ if(in_array($format, $allowed_formats)) {
$allowed_types = array('event','prov','reg','all');
$type = isset($get['type'])? $get['type'] : 'all';
if(in_array($type, $allowed_types)) {
if($type == 'event') {
if($type == 'event' && $format == 'ical') {
$id = (int)$get['id'];
if($id>0) {
$ee = new Events();
echo $ee->ExportIcsEvent($id);
} else {
http_response_code(404);
http_response_code(401);
}
} else {
switch($type) {
case 'event':
$id = (int)$get['id'];
if($id>0) {
$params['id'] = $id;
} else {
http_response_code(401);
exit;
}
break;
case 'prov':
$id = $get['id'];
if($id!='') {
......
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