mirror of https://github.com/friendica/friendica
API add events_show
This PR is pripared via proxy by Marco R. See [this thread in the Developers forum](https://forum.friendi.ca/display/3e98eba8-215e-45b9-c311-c93505586413).
This commit is contained in:
parent
756de11cda
commit
2801efd795
|
@ -426,6 +426,54 @@ function api_error($type, $e, App\Arguments $args)
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function api_events_show($type)
|
||||||
|
{
|
||||||
|
$a = \get_app();
|
||||||
|
|
||||||
|
$user_info = api_get_user($a);
|
||||||
|
|
||||||
|
if (api_user() === false || $user_info === false)
|
||||||
|
{
|
||||||
|
throw new ForbiddenException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$since_id = $_REQUEST['since_id'] ?? 0;
|
||||||
|
$count = $_REQUEST['count'] ?? 20;
|
||||||
|
$condition = ["`id` > ? AND (`uid` = 0 OR (`uid` = ?))", $since_id, api_user()];
|
||||||
|
$params = ['limit'=> $count];
|
||||||
|
$terms = DBA::select('event',[] , $condition, $params);
|
||||||
|
|
||||||
|
$events = [];
|
||||||
|
while ($term = DBA::fetch($terms))
|
||||||
|
{
|
||||||
|
$events[] = [
|
||||||
|
'id' => intval($term['id']),
|
||||||
|
'uid' => intval($term['uid']),
|
||||||
|
'cid' => $term['cid'],
|
||||||
|
'uri' => $term['uri'],
|
||||||
|
'summary' => $term['summary'],
|
||||||
|
'desc' => BBCode::convert($term['desc']),
|
||||||
|
'start' => $term['start'],
|
||||||
|
'finish' => $term['finish'],
|
||||||
|
'type' => $term['type'],
|
||||||
|
'nofinish' => $term['nofinish'],
|
||||||
|
'location' => $term['location'],
|
||||||
|
'adjust' => $term['adjust'],
|
||||||
|
'ignore' => $term['ignore'],
|
||||||
|
'allow_cid' => $term['allow_cid'],
|
||||||
|
'allow_gid' => $term['allow_gid'],
|
||||||
|
'deny_cid' => $term['deny_cid'],
|
||||||
|
'deny_gid' => $term['deny_gid']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
DBA::close($terms);
|
||||||
|
|
||||||
|
return api_format_data('events', $type, ['events' => $events]);
|
||||||
|
}
|
||||||
|
|
||||||
|
api_register_func('api/friendica/events/show', 'api_events_show', true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set values for RSS template
|
* Set values for RSS template
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue