X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FEvent.php;h=c5a8ef7880d5f1a3c3b9e401b446d686850b7317;hb=ee5207410c71492b2e771479ff1890d8ef4552da;hp=ec39cc7133d6efcdf1a555d87f71e7ba27f4a682;hpb=3f3422975266835fc125d1d61aae85ccc10d96d9;p=friendica.git
diff --git a/src/Model/Event.php b/src/Model/Event.php
index ec39cc7133..c5a8ef7880 100644
--- a/src/Model/Event.php
+++ b/src/Model/Event.php
@@ -1,15 +1,30 @@
.
+ *
*/
namespace Friendica\Model;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
-use Friendica\Core\L10n;
use Friendica\Core\Logger;
-use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
@@ -21,7 +36,7 @@ use Friendica\Util\Strings;
use Friendica\Util\XML;
/**
- * @brief functions for interacting with the event database table
+ * functions for interacting with the event database table
*/
class Event
{
@@ -32,15 +47,15 @@ class Event
return '';
}
- $bd_format = L10n::t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8 AM.
+ $bd_format = DI::l10n()->t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8 AM.
- $event_start = L10n::getDay(
+ $event_start = DI::l10n()->getDay(
!empty($event['adjust']) ?
DateTimeFormat::local($event['start'], $bd_format) : DateTimeFormat::utc($event['start'], $bd_format)
);
if (!empty($event['finish'])) {
- $event_end = L10n::getDay(
+ $event_end = DI::l10n()->getDay(
!empty($event['adjust']) ?
DateTimeFormat::local($event['finish'], $bd_format) : DateTimeFormat::utc($event['finish'], $bd_format)
);
@@ -59,14 +74,14 @@ class Event
$o .= "
" . BBCode::convert(Strings::escapeHtml($event['desc']), false, $simple) . "
";
}
- $o .= "" . L10n::t('Starts:') . "
" . $event_start . "
";
+ $o .= "" . DI::l10n()->t('Starts:') . "
" . $event_start . "
";
if (!$event['nofinish']) {
- $o .= "" . L10n::t('Finishes:') . "
" . $event_end . "
";
+ $o .= "" . DI::l10n()->t('Finishes:') . "
" . $event_end . "
";
}
if (!empty($event['location'])) {
- $o .= "" . L10n::t('Location:') . "
" . BBCode::convert(Strings::escapeHtml($event['location']), false, $simple) . "
";
+ $o .= "" . DI::l10n()->t('Location:') . "
" . BBCode::convert(Strings::escapeHtml($event['location']), false, $simple) . "
";
}
return $o;
@@ -76,13 +91,13 @@ class Event
$o .= '' . BBCode::convert(Strings::escapeHtml($event['summary']), false, $simple) . '
' . "\r\n";
- $o .= '' . L10n::t('Starts:') . ' ' . DI::l10n()->t('Starts:') . ' ' . $event_start
. '
' . "\r\n";
if (!$event['nofinish']) {
- $o .= '' . L10n::t('Finishes:') . ' ' . DI::l10n()->t('Finishes:') . ' ' . $event_end
. '
' . "\r\n";
@@ -93,7 +108,7 @@ class Event
}
if (!empty($event['location'])) {
- $o .= '' . L10n::t('Location:') . ' '
+ $o .= '' . DI::l10n()->t('Location:') . ' '
. BBCode::convert(Strings::escapeHtml($event['location']), false, $simple)
. '
' . "\r\n";
@@ -111,7 +126,7 @@ class Event
}
/**
- * @brief Convert an array with event data to bbcode.
+ * Convert an array with event data to bbcode.
*
* @param array $event Array which contains the event data.
* @return string The event as a bbcode formatted string.
@@ -148,7 +163,7 @@ class Event
}
/**
- * @brief Extract bbcode formatted event data from a string.
+ * Extract bbcode formatted event data from a string.
*
* @params: string $s The string which should be parsed for event data.
* @param $text
@@ -212,7 +227,7 @@ class Event
}
/**
- * @brief Delete an event from the event table.
+ * Delete an event from the event table.
*
* Note: This function does only delete the event from the event table not its
* related entry in the item table.
@@ -232,7 +247,7 @@ class Event
}
/**
- * @brief Store the event.
+ * Store the event.
*
* Store the event in the event table and create an event item in the item table.
*
@@ -242,6 +257,16 @@ 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);
@@ -276,6 +301,9 @@ class Event
}
$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']) {
@@ -283,7 +311,7 @@ class Event
$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']]);
+ $item = Post::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
return DBA::isResult($item) ? $item['id'] : 0;
}
@@ -302,7 +330,7 @@ class Event
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'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
if (DBA::isResult($item)) {
$object = '