- rewrote to almost one block of array initialization
This commit is contained in:
Roland Häder 2022-07-25 16:48:04 +02:00
parent 389e59b857
commit 1ac1db6173
No known key found for this signature in database
GPG Key ID: C82EDE5DDFA0BA77

View File

@ -243,27 +243,29 @@ class Event
*/ */
public static function store(array $arr): int public static function store(array $arr): int
{ {
$event = []; $event = [
$event['id'] = intval($arr['id'] ?? 0); 'id' => intval($arr['id'] ?? 0),
$event['uid'] = intval($arr['uid'] ?? 0); 'uid' => intval($arr['uid'] ?? 0),
$event['cid'] = intval($arr['cid'] ?? 0); 'cid' => intval($arr['cid'] ?? 0),
$event['guid'] = ($arr['guid'] ?? '') ?: System::createUUID(); 'guid' => ($arr['guid'] ?? '') ?: System::createUUID(),
$event['uri'] = ($arr['uri'] ?? '') ?: Item::newURI($event['guid']); 'type' => ($arr['type'] ?? '') ?: 'event',
$event['uri-id'] = ItemURI::insert(['uri' => $event['uri'], 'guid' => $event['guid']]); 'summary' => $arr['summary'] ?? '',
$event['type'] = ($arr['type'] ?? '') ?: 'event'; 'desc' => $arr['desc'] ?? '',
$event['summary'] = $arr['summary'] ?? ''; 'location' => $arr['location'] ?? '',
$event['desc'] = $arr['desc'] ?? ''; 'allow_cid' => $arr['allow_cid'] ?? '',
$event['location'] = $arr['location'] ?? ''; 'allow_gid' => $arr['allow_gid'] ?? '',
$event['allow_cid'] = $arr['allow_cid'] ?? ''; 'deny_cid' => $arr['deny_cid'] ?? '',
$event['allow_gid'] = $arr['allow_gid'] ?? ''; 'deny_gid' => $arr['deny_gid'] ?? '',
$event['deny_cid'] = $arr['deny_cid'] ?? ''; 'nofinish' => intval($arr['nofinish'] ?? (!empty($arr['start']) && empty($arr['finish']))),
$event['deny_gid'] = $arr['deny_gid'] ?? ''; 'created' => DateTimeFormat::utc(($arr['created'] ?? '') ?: 'now'),
$event['nofinish'] = intval($arr['nofinish'] ?? (!empty($event['start']) && empty($event['finish']))); 'edited' => DateTimeFormat::utc(($arr['edited'] ?? '') ?: 'now'),
'start' => DateTimeFormat::utc(($arr['start'] ?? '') ?: DBA::NULL_DATETIME),
'finish' => DateTimeFormat::utc(($arr['finish'] ?? '') ?: DBA::NULL_DATETIME),
];
$event['uri'] = ($arr['uri'] ?? '') ?: Item::newURI($event['guid']);
$event['uri-id'] = ItemURI::insert(['uri' => $event['uri'], 'guid' => $event['guid']]);
$event['created'] = DateTimeFormat::utc(($arr['created'] ?? '') ?: 'now');
$event['edited'] = DateTimeFormat::utc(($arr['edited'] ?? '') ?: 'now');
$event['start'] = DateTimeFormat::utc(($arr['start'] ?? '') ?: DBA::NULL_DATETIME);
$event['finish'] = DateTimeFormat::utc(($arr['finish'] ?? '') ?: DBA::NULL_DATETIME);
if ($event['finish'] < DBA::NULL_DATETIME) { if ($event['finish'] < DBA::NULL_DATETIME) {
$event['finish'] = DBA::NULL_DATETIME; $event['finish'] = DBA::NULL_DATETIME;
} }