public static function getHTML(array $event, $simple = false)
{
- if (!is_array($event) || !!count($event)) {
+ if (empty($event)) {
return '';
}
}
$private = intval(defaults($arr, 'private', 0));
- $condition = ['uid' => $event['uid']];
+ $conditions = ['uid' => $event['uid']];
if ($event['cid']) {
- $condition['id'] = $event['cid'];
+ $conditions['id'] = $event['cid'];
+ } else {
+ $conditions['self'] = true;
}
- $contact = dba::selectFirst('contact', [], ['id' => $event['cid'], 'uid' => $event['uid']]);
+ $contact = dba::selectFirst('contact', [], $conditions);
// Existing event being modified.
if ($event['id']) {
'nofinish' => $event['nofinish'],
];
- dba::update('event', $updated_fields, ['id' => $event['cid'], 'uid' => $event['uid']]);
+ dba::update('event', $updated_fields, ['id' => $event['id'], 'uid' => $event['uid']]);
$item = dba::selectFirst('item', ['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
if (DBM::is_result($item)) {
}
// Query for the event by date.
+ // @todo Slow query (518 seconds to run), to be optimzed
$r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,
`item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event`
LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
$events = dba::select('event', $fields, $conditions);
if (DBM::is_result($events)) {
- $return = $events;
+ $return = dba::inArray($events);
}
return $return;
/**
* @brief Format an item array with event data to HTML.
*
- * @param arr $item Array with item and event data.
+ * @param array $item Array with item and event data.
* @return string HTML output.
*/
- public static function getItemHTML($item) {
+ public static function getItemHTML(array $item) {
$same_date = false;
$finish = false;