X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FItem.php;h=ced18fc8a68f74aed8557da4522580aa8eb2c73d;hb=c65fff6f93e4e33901510343faef69654fd1a97b;hp=e53d64d5e1985ccf81eeb22d875dbc1852d3367d;hpb=ba9f145ef78236ffbf304d07adbe2aa51f5326d4;p=friendica.git diff --git a/src/Model/Item.php b/src/Model/Item.php index e53d64d5e1..ced18fc8a6 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -27,7 +27,6 @@ use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; -use Friendica\Core\Session; use Friendica\Core\System; use Friendica\Model\Tag; use Friendica\Core\Worker; @@ -113,7 +112,7 @@ class Item 'private', 'title', 'body', 'raw-body', 'location', 'coord', 'app', 'inform', 'deleted', 'extid', 'post-type', 'post-reason', 'gravity', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', - 'author-id', 'author-link', 'author-name', 'author-avatar', 'owner-id', 'owner-link', 'contact-uid', + 'author-id', 'author-addr', 'author-link', 'author-name', 'author-avatar', 'owner-id', 'owner-link', 'contact-uid', 'signed_text', 'network', 'wall', 'contact-id', 'plink', 'origin', 'thr-parent-id', 'parent-uri-id', 'quote-uri', 'quote-uri-id', 'postopts', 'pubmail', 'event-created', 'event-edited', 'event-start', 'event-finish', @@ -1066,7 +1065,7 @@ class Item } // We have to tell the hooks who we are - this really should be improved - if (!Session::getLocalUser()) { + if (!DI::userSession()->getLocalUserId()) { $_SESSION['authenticated'] = true; $_SESSION['uid'] = $uid; $dummy_session = true; @@ -2775,8 +2774,8 @@ class Item */ public static function getPermissionsConditionArrayByUserId(int $owner_id): array { - $local_user = Session::getLocalUser(); - $remote_user = Session::getRemoteContactID($owner_id); + $local_user = DI::userSession()->getLocalUserId(); + $remote_user = DI::userSession()->getRemoteContactID($owner_id); // default permissions - anonymous user $condition = ["`private` != ?", self::PRIVATE]; @@ -2807,8 +2806,8 @@ class Item */ public static function getPermissionsSQLByUserId(int $owner_id, string $table = ''): string { - $local_user = Session::getLocalUser(); - $remote_user = Session::getRemoteContactID($owner_id); + $local_user = DI::userSession()->getLocalUserId(); + $remote_user = DI::userSession()->getRemoteContactID($owner_id); if (!empty($table)) { $table = DBA::quoteIdentifier($table) . '.'; @@ -2950,20 +2949,18 @@ class Item $item['mentions'] = $tags['mentions']; $body = $item['body'] ?? ''; - $shared = BBCode::fetchShareAttributes($body); - if (!empty($shared['guid'])) { - $shared_item = Post::selectFirst(['uri-id', 'guid', 'plink', 'has-media'], ['guid' => $shared['guid'], 'uid' => [$item['uid'], 0]]); - } $fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network', 'has-media']; $shared_uri_id = 0; $shared_links = []; - if (empty($shared_item['uri-id']) && !empty($item['quote-uri-id'])) { - $shared_item = Post::selectFirst($fields, ['uri-id' => $item['quote-uri-id']]); - $quote_uri_id = $item['quote-uri-id'] ?? 0; - $shared_links[] = strtolower($item['quote-uri']); + $shared = DI::contentItem()->getSharedPost($item, $fields); + if (!empty($shared['post'])) { + $shared_item = $shared['post']; + $quote_uri_id = $shared['post']['uri-id']; + $shared_links[] = strtolower($shared['post']['uri']); + $item['body'] = BBCode::removeSharedData($item['body']); } elseif (empty($shared_item['uri-id']) && empty($item['quote-uri-id'])) { $media = Post\Media::getByURIId($item['uri-id'], [Post\Media::ACTIVITY]); if (!empty($media)) { @@ -3006,8 +3003,8 @@ class Item // Compile eventual content filter reasons $filter_reasons = []; - if (!$is_preview && Session::getPublicContact() != $item['author-id']) { - if (!empty($item['content-warning']) && (!Session::getLocalUser() || !DI::pConfig()->get(Session::getLocalUser(), 'system', 'disable_cw', false))) { + if (!$is_preview && DI::userSession()->getPublicContactId() != $item['author-id']) { + if (!empty($item['content-warning']) && (!DI::userSession()->getLocalUserId() || !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'disable_cw', false))) { $filter_reasons[] = DI::l10n()->t('Content warning: %s', $item['content-warning']); } @@ -3043,7 +3040,7 @@ class Item $s = self::addVisualAttachments($shared_attachments, $item, $s, true); $s = self::addLinkAttachment($shared_uri_id ?: $item['uri-id'], $shared_attachments, $body, $s, true, []); $s = self::addNonVisualAttachments($shared_attachments, $item, $s, true); - $body = preg_replace("/\s*\[share .*?\].*?\[\/share\]\s*/ism", '', $body); + $body = BBCode::removeSharedData($body); } $s = self::addVisualAttachments($attachments, $item, $s, false); @@ -3443,7 +3440,7 @@ class Item $plink = $item['uri']; } - if (Session::getLocalUser()) { + if (DI::userSession()->getLocalUserId()) { $ret = [ 'href' => "display/" . $item['guid'], 'orig' => "display/" . $item['guid'], @@ -3589,21 +3586,6 @@ class Item return 0; } - /** - * Return share data from an item array (if the item is shared item) - * We are providing the complete Item array, because at some time in the future - * we hopefully will define these values not in the body anymore but in some item fields. - * This function is meant to replace all similar functions in the system. - * - * @param array $item - * - * @return array with share information - */ - public static function getShareArray(array $item): array - { - return BBCode::fetchShareAttributes($item['body']); - } - /** * Check a prospective item array against user-level permissions *