2020-02-16 16:20:17 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2021-03-29 06:40:20 +00:00
|
|
|
* @copyright Copyright (C) 2010-2021, the Friendica project
|
2020-02-16 16:20:17 +00:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Friendica\Module\Api\Friendica\Events;
|
|
|
|
|
|
|
|
use Friendica\Content\Text\BBCode;
|
|
|
|
use Friendica\Database\DBA;
|
|
|
|
use Friendica\Module\BaseApi;
|
|
|
|
use Friendica\Network\HTTPException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* api/friendica/events
|
|
|
|
*
|
|
|
|
* @package Friendica\Module\Api\Friendica\Events
|
|
|
|
*/
|
|
|
|
class Index extends BaseApi
|
|
|
|
{
|
|
|
|
public static function rawContent(array $parameters = [])
|
|
|
|
{
|
2021-06-08 12:00:22 +00:00
|
|
|
self::checkAllowedScope(self::SCOPE_READ);
|
2021-06-08 06:32:24 +00:00
|
|
|
$uid = self::getCurrentUserID();
|
2020-02-16 16:20:17 +00:00
|
|
|
|
2021-05-19 06:18:42 +00:00
|
|
|
$request = self::getRequest([
|
|
|
|
'since_id' => 0,
|
|
|
|
'count' => 0,
|
|
|
|
]);
|
2020-02-16 16:20:17 +00:00
|
|
|
|
2021-06-08 06:32:24 +00:00
|
|
|
$condition = ["`id` > ? AND `uid` = ?", $request['since_id'], $uid];
|
2021-05-19 06:18:42 +00:00
|
|
|
$params = ['limit' => $request['count']];
|
2020-02-16 16:20:17 +00:00
|
|
|
$events = DBA::selectToArray('event', [], $condition, $params);
|
|
|
|
|
|
|
|
$items = [];
|
|
|
|
foreach ($events as $event) {
|
|
|
|
$items[] = [
|
|
|
|
'id' => intval($event['id']),
|
|
|
|
'uid' => intval($event['uid']),
|
|
|
|
'cid' => $event['cid'],
|
|
|
|
'uri' => $event['uri'],
|
|
|
|
'name' => $event['summary'],
|
2021-07-10 12:58:48 +00:00
|
|
|
'desc' => BBCode::convertForUriId($event['uri-id'], $event['desc']),
|
2020-02-16 16:20:17 +00:00
|
|
|
'startTime' => $event['start'],
|
|
|
|
'endTime' => $event['finish'],
|
|
|
|
'type' => $event['type'],
|
|
|
|
'nofinish' => $event['nofinish'],
|
|
|
|
'place' => $event['location'],
|
2021-10-03 17:21:17 +00:00
|
|
|
'adjust' => 1,
|
2020-02-16 16:20:17 +00:00
|
|
|
'ignore' => $event['ignore'],
|
|
|
|
'allow_cid' => $event['allow_cid'],
|
|
|
|
'allow_gid' => $event['allow_gid'],
|
|
|
|
'deny_cid' => $event['deny_cid'],
|
|
|
|
'deny_gid' => $event['deny_gid']
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2021-11-09 19:40:39 +00:00
|
|
|
self::exit('events', ['events' => $items], $parameters['extension'] ?? null);
|
2020-02-16 16:20:17 +00:00
|
|
|
}
|
|
|
|
}
|