From 176ab7130f4b85fff37fdfea1c35651177a34f60 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 4 Jul 2018 19:53:02 +0000 Subject: [PATCH] Fixes issue 5322 - events now again are having a plink --- src/Model/Event.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Model/Event.php b/src/Model/Event.php index 9b258960e6..49d759585a 100644 --- a/src/Model/Event.php +++ b/src/Model/Event.php @@ -268,9 +268,9 @@ class Event extends BaseObject if ($event['id']) { // has the event actually changed? $existing_event = dba::selectFirst('event', ['edited'], ['id' => $event['id'], 'uid' => $event['uid']]); - if ((! DBM::is_result($existing_event)) || ($existing_event['edited'] === $event['edited'])) { + if (!DBM::is_result($existing_event) || ($existing_event['edited'] === $event['edited'])) { - $item = dba::selectFirst('item', [], ['event-id' => $event['id'], 'uid' => $event['uid']]); + $item = Item::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]); return DBM::is_result($item) ? $item['id'] : 0; } @@ -289,7 +289,7 @@ class Event extends BaseObject dba::update('event', $updated_fields, ['id' => $event['id'], 'uid' => $event['uid']]); - $item = dba::selectFirst('item', ['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]); + $item = Item::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]); if (DBM::is_result($item)) { $object = '' . xmlify(ACTIVITY_OBJ_EVENT) . '' . xmlify($event['uri']) . ''; $object .= '' . xmlify(self::getBBCode($event)) . ''; @@ -464,8 +464,7 @@ class Event extends BaseObject } // Query for the event by event id - $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`, - `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` + $r = q("SELECT `event`.*, `item`.`id` AS `itemid` FROM `event` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid` WHERE `event`.`uid` = %d AND `event`.`id` = %d $sql_extra", intval($owner_uid), @@ -505,8 +504,7 @@ class Event extends BaseObject // 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` + $r = q("SELECT `event`.*, `item`.`id` AS `itemid` FROM `event` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid` WHERE `event`.`uid` = %d AND event.ignore = %d AND ((`adjust` = 0 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s') @@ -542,6 +540,11 @@ class Event extends BaseObject $last_date = ''; $fmt = L10n::t('l, F j'); foreach ($event_result as $event) { + $item = Item::selectFirst(['plink', 'author-name', 'author-avatar', 'author-link'], ['id' => $event['itemid']]); + if (DBM::is_result($item)) { + $event = array_merge($event, $item); + } + $start = $event['adjust'] ? DateTimeFormat::local($event['start'], 'c') : DateTimeFormat::utc($event['start'], 'c'); $j = $event['adjust'] ? DateTimeFormat::local($event['start'], 'j') : DateTimeFormat::utc($event['start'], 'j'); $day = $event['adjust'] ? DateTimeFormat::local($event['start'], $fmt) : DateTimeFormat::utc($event['start'], $fmt); -- 2.39.5