mirror of
https://github.com/friendica/friendica
synced 2024-12-22 22:40:16 +00:00
Refactor Item model
This commit is contained in:
parent
65a3bff645
commit
c61ae5da42
1 changed files with 23 additions and 17 deletions
|
@ -193,6 +193,7 @@ class Item
|
||||||
$fields['vid'] = Verb::getID($fields['verb']);
|
$fields['vid'] = Verb::getID($fields['verb']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$previous = [];
|
||||||
if (!empty($fields['edited'])) {
|
if (!empty($fields['edited'])) {
|
||||||
$previous = Post::selectFirst(['edited'], $condition);
|
$previous = Post::selectFirst(['edited'], $condition);
|
||||||
}
|
}
|
||||||
|
@ -856,6 +857,8 @@ class Item
|
||||||
|
|
||||||
$priority = Worker::PRIORITY_HIGH;
|
$priority = Worker::PRIORITY_HIGH;
|
||||||
|
|
||||||
|
$copy_permissions = false;
|
||||||
|
|
||||||
// If it is a posting where users should get notifications, then define it as wall posting
|
// If it is a posting where users should get notifications, then define it as wall posting
|
||||||
if ($notify) {
|
if ($notify) {
|
||||||
$item = self::prepareOriginPost($item);
|
$item = self::prepareOriginPost($item);
|
||||||
|
@ -3199,7 +3202,7 @@ class Item
|
||||||
} elseif ($remote_user) {
|
} elseif ($remote_user) {
|
||||||
// Authenticated visitor - fetch the matching permissionsets
|
// Authenticated visitor - fetch the matching permissionsets
|
||||||
$permissionSets = DI::permissionSet()->selectByContactId($remote_user, $owner_id);
|
$permissionSets = DI::permissionSet()->selectByContactId($remote_user, $owner_id);
|
||||||
if (!empty($permissionSets)) {
|
if (count($permissionSets) > 0) {
|
||||||
$condition = [
|
$condition = [
|
||||||
"(`private` != ? OR (`private` = ? AND `wall`
|
"(`private` != ? OR (`private` = ? AND `wall`
|
||||||
AND `psid` IN (" . implode(', ', array_fill(0, count($permissionSets), '?')) . ")))",
|
AND `psid` IN (" . implode(', ', array_fill(0, count($permissionSets), '?')) . ")))",
|
||||||
|
@ -3228,17 +3231,12 @@ class Item
|
||||||
$table = DBA::quoteIdentifier($table) . '.';
|
$table = DBA::quoteIdentifier($table) . '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Construct permissions
|
|
||||||
*
|
|
||||||
* default permissions - anonymous user
|
|
||||||
*/
|
|
||||||
$sql = sprintf(" AND " . $table . "`private` != %d", self::PRIVATE);
|
|
||||||
|
|
||||||
// Profile owner - everything is visible
|
// Profile owner - everything is visible
|
||||||
if ($local_user && ($local_user == $owner_id)) {
|
if ($local_user && ($local_user == $owner_id)) {
|
||||||
$sql = '';
|
return '';
|
||||||
} elseif ($remote_user) {
|
}
|
||||||
|
|
||||||
|
if ($remote_user) {
|
||||||
/*
|
/*
|
||||||
* Authenticated visitor. Unless pre-verified,
|
* Authenticated visitor. Unless pre-verified,
|
||||||
* check that the contact belongs to this $owner_id
|
* check that the contact belongs to this $owner_id
|
||||||
|
@ -3248,16 +3246,21 @@ class Item
|
||||||
*/
|
*/
|
||||||
$permissionSets = DI::permissionSet()->selectByContactId($remote_user, $owner_id);
|
$permissionSets = DI::permissionSet()->selectByContactId($remote_user, $owner_id);
|
||||||
|
|
||||||
if (!empty($permissionSets)) {
|
|
||||||
$sql_set = sprintf(" OR (" . $table . "`private` = %d AND " . $table . "`wall` AND " . $table . "`psid` IN (", self::PRIVATE) . implode(',', $permissionSets->column('id')) . "))";
|
|
||||||
} else {
|
|
||||||
$sql_set = '';
|
$sql_set = '';
|
||||||
|
|
||||||
|
if (count($permissionSets) > 0) {
|
||||||
|
$sql_set = sprintf(" OR (" . $table . "`private` = %d AND " . $table . "`wall` AND " . $table . "`psid` IN (", self::PRIVATE) . implode(',', $permissionSets->column('id')) . "))";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = sprintf(" AND (" . $table . "`private` != %d", self::PRIVATE) . $sql_set . ")";
|
return sprintf(" AND (" . $table . "`private` != %d", self::PRIVATE) . $sql_set . ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sql;
|
/*
|
||||||
|
* Construct permissions
|
||||||
|
*
|
||||||
|
* default permissions - anonymous user
|
||||||
|
*/
|
||||||
|
return sprintf(" AND " . $table . "`private` != %d", self::PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3381,6 +3384,7 @@ class Item
|
||||||
$shared_uri_id = 0;
|
$shared_uri_id = 0;
|
||||||
$shared_links = [];
|
$shared_links = [];
|
||||||
$quote_shared_links = [];
|
$quote_shared_links = [];
|
||||||
|
$shared_item = [];
|
||||||
|
|
||||||
$shared = DI::contentItem()->getSharedPost($item, $fields);
|
$shared = DI::contentItem()->getSharedPost($item, $fields);
|
||||||
if (!empty($shared['post'])) {
|
if (!empty($shared['post'])) {
|
||||||
|
@ -3424,6 +3428,8 @@ class Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sharedSplitAttachments = [];
|
||||||
|
|
||||||
if (!empty($shared_item['uri-id'])) {
|
if (!empty($shared_item['uri-id'])) {
|
||||||
$shared_uri_id = $shared_item['uri-id'];
|
$shared_uri_id = $shared_item['uri-id'];
|
||||||
$shared_links[] = strtolower($shared_item['plink']);
|
$shared_links[] = strtolower($shared_item['plink']);
|
||||||
|
@ -3497,7 +3503,7 @@ class Item
|
||||||
$s = self::addGallery($s, $sharedSplitAttachments['visual']);
|
$s = self::addGallery($s, $sharedSplitAttachments['visual']);
|
||||||
$s = self::addVisualAttachments($sharedSplitAttachments['visual'], $shared_item, $s, true);
|
$s = self::addVisualAttachments($sharedSplitAttachments['visual'], $shared_item, $s, true);
|
||||||
$s = self::addLinkAttachment($shared_uri_id ?: $item['uri-id'], $sharedSplitAttachments, $body, $s, true, $quote_shared_links);
|
$s = self::addLinkAttachment($shared_uri_id ?: $item['uri-id'], $sharedSplitAttachments, $body, $s, true, $quote_shared_links);
|
||||||
$s = self::addNonVisualAttachments($sharedSplitAttachments['additional'], $item, $s, true);
|
$s = self::addNonVisualAttachments($sharedSplitAttachments['additional'], $item, $s);
|
||||||
$body = BBCode::removeSharedData($body);
|
$body = BBCode::removeSharedData($body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3510,7 +3516,7 @@ class Item
|
||||||
$s = self::addGallery($s, $itemSplitAttachments['visual']);
|
$s = self::addGallery($s, $itemSplitAttachments['visual']);
|
||||||
$s = self::addVisualAttachments($itemSplitAttachments['visual'], $item, $s, false);
|
$s = self::addVisualAttachments($itemSplitAttachments['visual'], $item, $s, false);
|
||||||
$s = self::addLinkAttachment($item['uri-id'], $itemSplitAttachments, $body, $s, false, $shared_links);
|
$s = self::addLinkAttachment($item['uri-id'], $itemSplitAttachments, $body, $s, false, $shared_links);
|
||||||
$s = self::addNonVisualAttachments($itemSplitAttachments['additional'], $item, $s, false);
|
$s = self::addNonVisualAttachments($itemSplitAttachments['additional'], $item, $s);
|
||||||
$s = self::addQuestions($item, $s);
|
$s = self::addQuestions($item, $s);
|
||||||
|
|
||||||
// Map.
|
// Map.
|
||||||
|
|
Loading…
Reference in a new issue