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;
'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',
}
// 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;
*/
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];
*/
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) . '.';
$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)) {
// 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']);
}
$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);
$plink = $item['uri'];
}
- if (Session::getLocalUser()) {
+ if (DI::userSession()->getLocalUserId()) {
$ret = [
'href' => "display/" . $item['guid'],
'orig' => "display/" . $item['guid'],
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
*