X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FEvent.php;h=dac00ceceb4a3e5e008db1bdaa839e5f17d6ed50;hb=4d274cc3ea17725a0eb1cfe81bc4c3a60b10f6c9;hp=f66d7656246ce781b71b5a3060e5d7acc0259413;hpb=2987070d93a43114104aa01e19ff901cfb145816;p=friendica.git
diff --git a/src/Model/Event.php b/src/Model/Event.php
index f66d765624..dac00ceceb 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]);
}
/**
@@ -257,22 +244,13 @@ class Event
*/
public static function store($arr)
{
- $network = $arr['network'] ?? Protocol::DFRN;
- $protocol = $arr['protocol'] ?? Conversation::PARCEL_UNKNOWN;
- $direction = $arr['direction'] ?? Conversation::UNKNOWN;
- $source = $arr['source'] ?? '';
-
- unset($arr['network']);
- unset($arr['protocol']);
- unset($arr['direction']);
- unset($arr['source']);
-
$event = [];
$event['id'] = intval($arr['id'] ?? 0);
$event['uid'] = intval($arr['uid'] ?? 0);
$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'] ?? '';
@@ -281,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');
@@ -291,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, 'callstack' => 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 = [
@@ -324,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 = '