Merge remote-tracking branch 'upstream/2021.12-rc' into user-banner
This commit is contained in:
commit
7d21f6f8d3
8 changed files with 75 additions and 45 deletions
|
@ -11,7 +11,6 @@ config/addon-sample.config.php
|
||||||
config/local-sample.config.php
|
config/local-sample.config.php
|
||||||
doc/
|
doc/
|
||||||
images/
|
images/
|
||||||
include/
|
|
||||||
mod/
|
mod/
|
||||||
mods/
|
mods/
|
||||||
spec/
|
spec/
|
||||||
|
|
|
@ -1135,7 +1135,7 @@ class BBCode
|
||||||
case self::API:
|
case self::API:
|
||||||
$text = ($is_quote_share? '<br>' : '') .
|
$text = ($is_quote_share? '<br>' : '') .
|
||||||
'<b><a href="' . $attributes['link'] . '">' . html_entity_decode('♲', ENT_QUOTES, 'UTF-8') . ' ' . $author_contact['addr'] . "</a>:</b><br>\n" .
|
'<b><a href="' . $attributes['link'] . '">' . html_entity_decode('♲', ENT_QUOTES, 'UTF-8') . ' ' . $author_contact['addr'] . "</a>:</b><br>\n" .
|
||||||
'<blockquote class="shared_content">' . $content . '</blockquote>';
|
'<blockquote class="shared_content" dir="auto">' . $content . '</blockquote>';
|
||||||
break;
|
break;
|
||||||
case self::DIASPORA:
|
case self::DIASPORA:
|
||||||
if (stripos(Strings::normaliseLink($attributes['link']), 'http://twitter.com/') === 0) {
|
if (stripos(Strings::normaliseLink($attributes['link']), 'http://twitter.com/') === 0) {
|
||||||
|
@ -1160,7 +1160,7 @@ class BBCode
|
||||||
$headline .= DI::l10n()->t('<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a> %3$s', $attributes['link'], $mention, $attributes['posted']);
|
$headline .= DI::l10n()->t('<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a> %3$s', $attributes['link'], $mention, $attributes['posted']);
|
||||||
$headline .= ':</b></p>' . "\n";
|
$headline .= ':</b></p>' . "\n";
|
||||||
|
|
||||||
$text = ($is_quote_share? '<hr />' : '') . $headline . '<blockquote class="shared_content">' . trim($content) . '</blockquote>' . "\n";
|
$text = ($is_quote_share? '<hr />' : '') . $headline . '<blockquote class="shared_content" dir="auto">' . trim($content) . '</blockquote>' . "\n";
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case self::OSTATUS:
|
case self::OSTATUS:
|
||||||
|
|
|
@ -1367,6 +1367,45 @@ class Database
|
||||||
return $this->toArray($this->select($table, $fields, $condition, $params));
|
return $this->toArray($this->select($table, $fields, $condition, $params));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escape fields, adding special treatment for "group by" handling
|
||||||
|
*
|
||||||
|
* @param array $fields
|
||||||
|
* @param array $options
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function escapeFields(array $fields, array $options)
|
||||||
|
{
|
||||||
|
// In the case of a "GROUP BY" we have to add all the ORDER fields to the fieldlist.
|
||||||
|
// This needs to done to apply the "ANY_VALUE(...)" treatment from below to them.
|
||||||
|
// Otherwise MySQL would report errors.
|
||||||
|
if (!empty($options['group_by']) && !empty($options['order'])) {
|
||||||
|
foreach ($options['order'] as $key => $field) {
|
||||||
|
if (!is_int($key)) {
|
||||||
|
if (!in_array($key, $fields)) {
|
||||||
|
$fields[] = $key;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!in_array($field, $fields)) {
|
||||||
|
$fields[] = $field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
array_walk($fields, function(&$value, $key) use ($options)
|
||||||
|
{
|
||||||
|
$field = $value;
|
||||||
|
$value = '`' . str_replace('`', '``', $value) . '`';
|
||||||
|
|
||||||
|
if (!empty($options['group_by']) && !in_array($field, $options['group_by'])) {
|
||||||
|
$value = 'ANY_VALUE(' . $value . ') AS ' . $value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return $fields;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select rows from a table
|
* Select rows from a table
|
||||||
*
|
*
|
||||||
|
@ -1403,7 +1442,8 @@ class Database
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($fields) > 0) {
|
if (count($fields) > 0) {
|
||||||
$select_string = implode(', ', array_map([DBA::class, 'quoteIdentifier'], $fields));
|
$fields = $this->escapeFields($fields, $params);
|
||||||
|
$select_string = implode(', ', $fields);
|
||||||
} else {
|
} else {
|
||||||
$select_string = '*';
|
$select_string = '*';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1014,10 +1014,17 @@ class Photo
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param int $uid User ID
|
||||||
* @param int $uid User ID
|
* @param array $files uploaded file array
|
||||||
* @param array $files uploaded file array
|
* @param string $album
|
||||||
|
* @param string|null $allow_cid
|
||||||
|
* @param string|null $allow_gid
|
||||||
|
* @param string $deny_cid
|
||||||
|
* @param string $deny_gid
|
||||||
|
* @param string $desc
|
||||||
|
* @param string $resource_id
|
||||||
* @return array photo record
|
* @return array photo record
|
||||||
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function upload(int $uid, array $files, string $album = '', string $allow_cid = null, string $allow_gid = null, string $deny_cid = '', string $deny_gid = '', string $desc = '', string $resource_id = ''): array
|
public static function upload(int $uid, array $files, string $album = '', string $allow_cid = null, string $allow_gid = null, string $deny_cid = '', string $deny_gid = '', string $desc = '', string $resource_id = ''): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Create extends BaseApi
|
||||||
$type = $this->getRequestValue($this->parameters, 'extension', 'json');
|
$type = $this->getRequestValue($this->parameters, 'extension', 'json');
|
||||||
|
|
||||||
// input params
|
// input params
|
||||||
$desc = $this->getRequestValue($request, 'desc');
|
$desc = $this->getRequestValue($request, 'desc', '');
|
||||||
$album = $this->getRequestValue($request, 'album');
|
$album = $this->getRequestValue($request, 'album');
|
||||||
$allow_cid = $this->getRequestValue($request, 'allow_cid');
|
$allow_cid = $this->getRequestValue($request, 'allow_cid');
|
||||||
$deny_cid = $this->getRequestValue($request, 'deny_cid');
|
$deny_cid = $this->getRequestValue($request, 'deny_cid');
|
||||||
|
|
|
@ -70,32 +70,35 @@ class Profile extends BaseModule
|
||||||
|
|
||||||
$last_updated = $last_updated_array[$last_updated_key] ?? 0;
|
$last_updated = $last_updated_array[$last_updated_key] ?? 0;
|
||||||
|
|
||||||
|
$condition = ["`uid` = ? AND NOT `contact-blocked` AND NOT `contact-pending`
|
||||||
|
AND `visible` AND (NOT `deleted` OR `gravity` = ?)
|
||||||
|
AND `wall` " . $sql_extra, $a->getProfileOwner(), GRAVITY_ACTIVITY];
|
||||||
|
|
||||||
if ($_GET['force'] && !empty($_GET['item'])) {
|
if ($_GET['force'] && !empty($_GET['item'])) {
|
||||||
// When the parent is provided, we only fetch this
|
// When the parent is provided, we only fetch this
|
||||||
$sql_extra4 = " AND `parent` = " . intval($_GET['item']);
|
$condition = DBA::mergeConditions($condition, ['parent' => $_GET['item']]);
|
||||||
} elseif ($is_owner || !$last_updated) {
|
} elseif ($is_owner || !$last_updated) {
|
||||||
// If the page user is the owner of the page we should query for unseen
|
// If the page user is the owner of the page we should query for unseen
|
||||||
// items. Otherwise use a timestamp of the last succesful update request.
|
// items. Otherwise use a timestamp of the last succesful update request.
|
||||||
$sql_extra4 = " AND `unseen`";
|
$condition = DBA::mergeConditions($condition, ['unseen' => true]);
|
||||||
} else {
|
} else {
|
||||||
$gmupdate = gmdate(DateTimeFormat::MYSQL, $last_updated);
|
$gmupdate = gmdate(DateTimeFormat::MYSQL, $last_updated);
|
||||||
$sql_extra4 = " AND `received` > '" . $gmupdate . "'";
|
$condition = DBA::mergeConditions($condition, ["`received` > ?", $gmupdate]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$items_stmt = DBA::p(
|
$items = Post::selectToArray(['parent-uri-id', 'created', 'received'], $condition, ['group_by' => ['parent-uri-id'], 'order' => ['received' => true]]);
|
||||||
"SELECT `parent-uri-id` AS `uri-id`, MAX(`created`), MAX(`received`) FROM `post-user-view`
|
if (!DBA::isResult($items)) {
|
||||||
WHERE `uid` = ? AND NOT `contact-blocked` AND NOT `contact-pending`
|
|
||||||
AND `visible` AND (NOT `deleted` OR `gravity` = ?)
|
|
||||||
AND `wall` $sql_extra4 $sql_extra
|
|
||||||
GROUP BY `parent-uri-id` ORDER BY `received` DESC",
|
|
||||||
$a->getProfileOwner(),
|
|
||||||
GRAVITY_ACTIVITY
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!DBA::isResult($items_stmt)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @todo the DBA functions should handle "SELECT field AS alias" in the future,
|
||||||
|
// so that this workaround here could be removed.
|
||||||
|
$items = array_map(function ($item) {
|
||||||
|
$item['uri-id'] = $item['parent-uri-id'];
|
||||||
|
unset($item['parent-uri-id']);
|
||||||
|
return $item;
|
||||||
|
}, $items);
|
||||||
|
|
||||||
// Set a time stamp for this page. We will make use of it when we
|
// Set a time stamp for this page. We will make use of it when we
|
||||||
// search for new items (update routine)
|
// search for new items (update routine)
|
||||||
$last_updated_array[$last_updated_key] = time();
|
$last_updated_array[$last_updated_key] = time();
|
||||||
|
@ -113,8 +116,6 @@ class Profile extends BaseModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$items = DBA::toArray($items_stmt);
|
|
||||||
|
|
||||||
$o .= DI::conversation()->create($items, 'profile', $a->getProfileOwner(), false, 'received', $a->getProfileOwner());
|
$o .= DI::conversation()->create($items, 'profile', $a->getProfileOwner(), false, 'received', $a->getProfileOwner());
|
||||||
|
|
||||||
System::htmlUpdateExit($o);
|
System::htmlUpdateExit($o);
|
||||||
|
|
|
@ -446,26 +446,9 @@ class Notifier
|
||||||
if ($diaspora_delivery && !$unlisted) {
|
if ($diaspora_delivery && !$unlisted) {
|
||||||
$batch_delivery = true;
|
$batch_delivery = true;
|
||||||
|
|
||||||
$participants_stmt = DBA::p(
|
$participants = DBA::selectToArray('contact', ['batch', 'network', 'protocol', 'id', 'url', 'name'],
|
||||||
"SELECT
|
["`network` = ? AND `batch` != '' AND `uid` = ? AND `rel` != ? AND NOT `blocked` AND NOT `pending` AND NOT `archive`", Protocol::DIASPORA, $owner['uid'], Contact::SHARING],
|
||||||
`batch`, `network`, `protocol`,
|
['group_by' => ['batch', 'network', 'protocol']]);
|
||||||
ANY_VALUE(`id`) AS `id`,
|
|
||||||
ANY_VALUE(`url`) AS `url`,
|
|
||||||
ANY_VALUE(`name`) AS `name`
|
|
||||||
FROM `contact`
|
|
||||||
WHERE `network` = ?
|
|
||||||
AND `batch` != ''
|
|
||||||
AND `uid` = ?
|
|
||||||
AND `rel` != ?
|
|
||||||
AND NOT `blocked`
|
|
||||||
AND NOT `pending`
|
|
||||||
AND NOT `archive`
|
|
||||||
GROUP BY `batch`, `network`, `protocol`",
|
|
||||||
Protocol::DIASPORA,
|
|
||||||
$owner['uid'],
|
|
||||||
Contact::SHARING
|
|
||||||
);
|
|
||||||
$participants = DBA::toArray($participants_stmt);
|
|
||||||
|
|
||||||
// Fetch the participation list
|
// Fetch the participation list
|
||||||
// The function will ensure that there are no duplicates
|
// The function will ensure that there are no duplicates
|
||||||
|
|
|
@ -34,5 +34,5 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<blockquote class="shared_content">{{$content nofilter}}</blockquote>
|
<blockquote class="shared_content" dir="auto">{{$content nofilter}}</blockquote>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue