X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FEvent.php;h=6f8ed123c17396bc4fd6e45f8405e13e33018967;hb=71415094cb92de900926639bec1b3a8e2982c57e;hp=3ce86017ba99028203aeb946a09c1a70bbe530cb;hpb=08da1ed038c9b193ded0ca70b3b1c1085bb7e90a;p=friendica.git
diff --git a/src/Model/Event.php b/src/Model/Event.php
index 3ce86017ba..6f8ed123c1 100644
--- a/src/Model/Event.php
+++ b/src/Model/Event.php
@@ -1,28 +1,44 @@
.
+ *
*/
namespace Friendica\Model;
-use Friendica\BaseObject;
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;
+use Friendica\DI;
+use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map;
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 extends BaseObject
+class Event
{
public static function getHTML(array $event, $simple = false)
@@ -31,15 +47,15 @@ class Event extends BaseObject
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)
);
@@ -58,14 +74,14 @@ class Event extends BaseObject
$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;
@@ -75,13 +91,13 @@ class Event extends BaseObject
$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";
@@ -92,7 +108,7 @@ class Event extends BaseObject
}
if (!empty($event['location'])) {
- $o .= '' . L10n::t('Location:') . ' '
+ $o .= '' . DI::l10n()->t('Location:') . ' '
. BBCode::convert(Strings::escapeHtml($event['location']), false, $simple)
. '
' . "\r\n";
@@ -110,7 +126,7 @@ class Event extends BaseObject
}
/**
- * @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.
@@ -147,7 +163,7 @@ class Event extends BaseObject
}
/**
- * @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
@@ -211,7 +227,7 @@ class Event extends BaseObject
}
/**
- * @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.
@@ -226,12 +242,12 @@ class Event extends BaseObject
return;
}
- DBA::delete('event', ['id' => $event_id]);
+ DBA::delete('event', ['id' => $event_id], ['cascade' => false]);
Logger::log("Deleted event ".$event_id, Logger::DEBUG);
}
/**
- * @brief Store the event.
+ * Store the event.
*
* Store the event in the event table and create an event item in the item table.
*
@@ -242,29 +258,30 @@ class Event extends BaseObject
public static function store($arr)
{
$event = [];
- $event['id'] = intval(defaults($arr, 'id' , 0));
- $event['uid'] = intval(defaults($arr, 'uid' , 0));
- $event['cid'] = intval(defaults($arr, 'cid' , 0));
- $event['uri'] = defaults($arr, 'uri' , Item::newURI($event['uid']));
- $event['type'] = defaults($arr, 'type' , 'event');
- $event['summary'] = defaults($arr, 'summary' , '');
- $event['desc'] = defaults($arr, 'desc' , '');
- $event['location'] = defaults($arr, 'location' , '');
- $event['allow_cid'] = defaults($arr, 'allow_cid', '');
- $event['allow_gid'] = defaults($arr, 'allow_gid', '');
- $event['deny_cid'] = defaults($arr, 'deny_cid' , '');
- $event['deny_gid'] = defaults($arr, 'deny_gid' , '');
- $event['adjust'] = intval(defaults($arr, 'adjust' , 0));
- $event['nofinish'] = intval(defaults($arr, 'nofinish' , !empty($event['start']) && empty($event['finish'])));
-
- $event['created'] = DateTimeFormat::utc(defaults($arr, 'created' , 'now'));
- $event['edited'] = DateTimeFormat::utc(defaults($arr, 'edited' , 'now'));
- $event['start'] = DateTimeFormat::utc(defaults($arr, 'start' , DBA::NULL_DATETIME));
- $event['finish'] = DateTimeFormat::utc(defaults($arr, 'finish' , DBA::NULL_DATETIME));
+ $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['type'] = ($arr['type'] ?? '') ?: 'event';
+ $event['summary'] = $arr['summary'] ?? '';
+ $event['desc'] = $arr['desc'] ?? '';
+ $event['location'] = $arr['location'] ?? '';
+ $event['allow_cid'] = $arr['allow_cid'] ?? '';
+ $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');
+ $event['edited'] = DateTimeFormat::utc(($arr['edited'] ?? '') ?: 'now');
+ $event['start'] = DateTimeFormat::utc(($arr['start'] ?? '') ?: DBA::NULL_DATETIME);
+ $event['finish'] = DateTimeFormat::utc(($arr['finish'] ?? '') ?: DBA::NULL_DATETIME);
if ($event['finish'] < DBA::NULL_DATETIME) {
$event['finish'] = DBA::NULL_DATETIME;
}
- $private = intval(defaults($arr, 'private', 0));
+ $private = intval($arr['private'] ?? 0);
$conditions = ['uid' => $event['uid']];
if ($event['cid']) {
@@ -302,7 +319,7 @@ class Event extends BaseObject
$item = Item::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
if (DBA::isResult($item)) {
- $object = '