X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FEvent.php;h=cb7c39c37d094f0de46d6db4846cfbd11ae7f1d6;hb=ab83d0dd27e46e733ecb49f25789bfb318852ac7;hp=995941edd0b568740c7d4102e7f5297b39ac5870;hpb=c5c9fda93cc7dd49fea056df212683c1d85b0b1a;p=friendica.git
diff --git a/src/Model/Event.php b/src/Model/Event.php
index 995941edd0..cb7c39c37d 100644
--- a/src/Model/Event.php
+++ b/src/Model/Event.php
@@ -1,6 +1,6 @@
t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8 AM.
+ $uriid = $event['uri-id'] ?? $uriid;
- $event_start = DI::l10n()->getDay(
- !empty($event['adjust']) ?
- DateTimeFormat::local($event['start'], $bd_format) : DateTimeFormat::utc($event['start'], $bd_format)
- );
+ $bd_format = DI::l10n()->t('l F d, Y \@ g:i A \G\M\TP (e)'); // Friday October 29, 2021 @ 9:15 AM GMT-04:00 (America/New_York)
+
+ $event_start = DI::l10n()->getDay(DateTimeFormat::local($event['start'], $bd_format));
if (!empty($event['finish'])) {
- $event_end = DI::l10n()->getDay(
- !empty($event['adjust']) ?
- DateTimeFormat::local($event['finish'], $bd_format) : DateTimeFormat::utc($event['finish'], $bd_format)
- );
+ $event_end = DI::l10n()->getDay(DateTimeFormat::local($event['finish'], $bd_format));
} else {
$event_end = '';
}
@@ -67,11 +63,11 @@ class Event
$o = '';
if (!empty($event['summary'])) {
- $o .= "
" . BBCode::convert(Strings::escapeHtml($event['desc']), false, $simple) . "
";
+ $o .= "" . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['desc']), $simple) . "
";
}
$o .= "" . $event_start . "
";
@@ -81,7 +77,7 @@ class Event
}
if (!empty($event['location'])) {
- $o .= "" . BBCode::convert(Strings::escapeHtml($event['location']), false, $simple) . "
";
+ $o .= "" . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['location']), $simple) . "
";
}
return $o;
@@ -89,27 +85,27 @@ class Event
$o = '' . "\r\n";
- $o .= '
' . BBCode::convert(Strings::escapeHtml($event['summary']), false, $simple) . '
' . "\r\n";
+ $o .= '
' . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['summary']), $simple) . '
' . "\r\n";
$o .= '
' . DI::l10n()->t('Starts:') . ' ' . $event_start
. '
' . "\r\n";
if (!$event['nofinish']) {
$o .= '
' . DI::l10n()->t('Finishes:') . ' ' . $event_end
. '
' . "\r\n";
}
if (!empty($event['desc'])) {
- $o .= '
' . BBCode::convert(Strings::escapeHtml($event['desc']), false, $simple) . '
' . "\r\n";
+ $o .= '
' . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['desc']), $simple) . '
' . "\r\n";
}
if (!empty($event['location'])) {
$o .= '
' . DI::l10n()->t('Location:') . ' '
- . BBCode::convert(Strings::escapeHtml($event['location']), false, $simple)
+ . BBCode::convertForUriId($uriid, Strings::escapeHtml($event['location']), $simple)
. '
' . "\r\n";
// Include a map of the location if the [map] BBCode is used.
@@ -155,10 +151,6 @@ class Event
$o .= '[event-location]' . $event['location'] . '[/event-location]';
}
- if ($event['adjust']) {
- $o .= '[event-adjust]' . $event['adjust'] . '[/event-adjust]';
- }
-
return $o;
}
@@ -173,36 +165,31 @@ class Event
{
$ev = [];
- $match = '';
+ $match = [];
if (preg_match("/\[event\-summary\](.*?)\[\/event\-summary\]/is", $text, $match)) {
$ev['summary'] = $match[1];
}
- $match = '';
+ $match = [];
if (preg_match("/\[event\-description\](.*?)\[\/event\-description\]/is", $text, $match)) {
$ev['desc'] = $match[1];
}
- $match = '';
+ $match = [];
if (preg_match("/\[event\-start\](.*?)\[\/event\-start\]/is", $text, $match)) {
$ev['start'] = $match[1];
}
- $match = '';
+ $match = [];
if (preg_match("/\[event\-finish\](.*?)\[\/event\-finish\]/is", $text, $match)) {
$ev['finish'] = $match[1];
}
- $match = '';
+ $match = [];
if (preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is", $text, $match)) {
$ev['location'] = $match[1];
}
- $match = '';
- if (preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is", $text, $match)) {
- $ev['adjust'] = $match[1];
- }
-
$ev['nofinish'] = !empty($ev['start']) && empty($ev['finish']) ? 1 : 0;
return $ev;
@@ -216,8 +203,8 @@ class Event
private static function compareDatesCallback($event_a, $event_b)
{
- $date_a = (($event_a['adjust']) ? DateTimeFormat::local($event_a['start']) : $event_a['start']);
- $date_b = (($event_b['adjust']) ? DateTimeFormat::local($event_b['start']) : $event_b['start']);
+ $date_a = DateTimeFormat::local($event_a['start']);
+ $date_b = DateTimeFormat::local($event_b['start']);
if ($date_a === $date_b) {
return strcasecmp($event_a['desc'], $event_b['desc']);
@@ -242,8 +229,8 @@ class Event
return;
}
- DBA::delete('event', ['id' => $event_id], ['cascade' => false]);
- Logger::log("Deleted event ".$event_id, Logger::DEBUG);
+ DBA::delete('event', ['id' => $event_id]);
+ Logger::info("Deleted event", ['id' => $event_id]);
}
/**
@@ -263,6 +250,7 @@ class Event
$event['cid'] = intval($arr['cid'] ?? 0);
$event['guid'] = ($arr['guid'] ?? '') ?: System::createUUID();
$event['uri'] = ($arr['uri'] ?? '') ?: Item::newURI($event['uid'], $event['guid']);
+ $event['uri-id'] = ItemURI::insert(['uri' => $event['uri'], 'guid' => $event['guid']]);
$event['type'] = ($arr['type'] ?? '') ?: 'event';
$event['summary'] = $arr['summary'] ?? '';
$event['desc'] = $arr['desc'] ?? '';
@@ -271,7 +259,6 @@ class Event
$event['allow_gid'] = $arr['allow_gid'] ?? '';
$event['deny_cid'] = $arr['deny_cid'] ?? '';
$event['deny_gid'] = $arr['deny_gid'] ?? '';
- $event['adjust'] = intval($arr['adjust'] ?? 0);
$event['nofinish'] = intval($arr['nofinish'] ?? (!empty($event['start']) && empty($event['finish'])));
$event['created'] = DateTimeFormat::utc(($arr['created'] ?? '') ?: 'now');
@@ -281,29 +268,17 @@ class Event
if ($event['finish'] < DBA::NULL_DATETIME) {
$event['finish'] = DBA::NULL_DATETIME;
}
- $private = intval($arr['private'] ?? 0);
-
- $conditions = ['uid' => $event['uid']];
- if ($event['cid']) {
- $conditions['id'] = $event['cid'];
- } else {
- $conditions['self'] = true;
- }
-
- $contact = DBA::selectFirst('contact', [], $conditions);
- if (!DBA::isResult($contact)) {
- Logger::warning('Contact not found', ['condition' => $conditions, 'cakkstack' => System::callstack(20)]);
- }
// Existing event being modified.
if ($event['id']) {
// has the event actually changed?
$existing_event = DBA::selectFirst('event', ['edited'], ['id' => $event['id'], 'uid' => $event['uid']]);
- if (!DBA::isResult($existing_event) || ($existing_event['edited'] === $event['edited'])) {
-
- $item = Item::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
-
- return DBA::isResult($item) ? $item['id'] : 0;
+ if (!DBA::isResult($existing_event)) {
+ return 0;
+ }
+
+ if ($existing_event['edited'] === $event['edited']) {
+ return $event['id'];
}
$updated_fields = [
@@ -314,13 +289,12 @@ class Event
'desc' => $event['desc'],
'location' => $event['location'],
'type' => $event['type'],
- 'adjust' => $event['adjust'],
'nofinish' => $event['nofinish'],
];
DBA::update('event', $updated_fields, ['id' => $event['id'], 'uid' => $event['uid']]);
- $item = Item::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
+ $item = Post::selectFirst(['id', 'uri-id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
if (DBA::isResult($item)) {
$object = '