diff --git a/boot.php b/boot.php
index 1716956fa1..60c8bf5a30 100644
--- a/boot.php
+++ b/boot.php
@@ -29,18 +29,6 @@
use Friendica\Core\Session;
-/**
- * @name Gravity
- *
- * Item weight for query ordering
- * @{
- */
-define('GRAVITY_PARENT', 0);
-define('GRAVITY_ACTIVITY', 3);
-define('GRAVITY_COMMENT', 6);
-define('GRAVITY_UNKNOWN', 9);
-/* @}*/
-
/**
* Returns the user id of locally logged in user or false.
*
diff --git a/mod/display.php b/mod/display.php
index 5aba7eb81d..c1b7746e24 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -106,7 +106,7 @@ function display_init(App $a)
displayShowFeed($item['uri-id'], $item['uid'], false);
}
- if ($item['gravity'] != GRAVITY_PARENT) {
+ if ($item['gravity'] != Item::GRAVITY_PARENT) {
$parent = Post::selectFirstForUser($item_user, $fields, ['uid' => [0, $item_user], 'uri-id' => $item['parent-uri-id']], ['order' => ['uid' => true]]);
$item = $parent ?: $item;
}
diff --git a/mod/events.php b/mod/events.php
index f1d8a7ca60..a9a2e47fe2 100644
--- a/mod/events.php
+++ b/mod/events.php
@@ -173,22 +173,23 @@ function events_post(App $a)
$private_event = true;
}
- $datarray = [];
- $datarray['start'] = $start;
- $datarray['finish'] = $finish;
- $datarray['summary'] = $summary;
- $datarray['desc'] = $desc;
- $datarray['location'] = $location;
- $datarray['type'] = $type;
- $datarray['nofinish'] = $nofinish;
- $datarray['uid'] = $uid;
- $datarray['cid'] = $cid;
- $datarray['allow_cid'] = $str_contact_allow;
- $datarray['allow_gid'] = $str_group_allow;
- $datarray['deny_cid'] = $str_contact_deny;
- $datarray['deny_gid'] = $str_group_deny;
- $datarray['private'] = $private_event;
- $datarray['id'] = $event_id;
+ $datarray = [
+ 'start' => $start,
+ 'finish' => $finish,
+ 'summary' => $summary,
+ 'desc' => $desc,
+ 'location' => $location,
+ 'type' => $type,
+ 'nofinish' => $nofinish,
+ 'uid' => $uid,
+ 'cid' => $cid,
+ 'allow_cid' => $str_contact_allow,
+ 'allow_gid' => $str_group_allow,
+ 'deny_cid' => $str_contact_deny,
+ 'deny_gid' => $str_group_deny,
+ 'private' => $private_event,
+ 'id' => $event_id,
+ ];
if (intval($_REQUEST['preview'])) {
System::httpExit(Event::getHTML($datarray));
diff --git a/mod/item.php b/mod/item.php
index cc8e953858..799d1b8881 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -123,7 +123,7 @@ function item_post(App $a) {
$thr_parent_uri = $parent_item['uri'];
$toplevel_item = $parent_item;
- if ($parent_item['gravity'] != GRAVITY_PARENT) {
+ if ($parent_item['gravity'] != Item::GRAVITY_PARENT) {
$toplevel_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $toplevel_item['parent']]);
}
}
@@ -308,7 +308,7 @@ function item_post(App $a) {
// for non native networks use the network of the original post as network of the item
if (($toplevel_item['network'] != Protocol::DIASPORA)
&& ($toplevel_item['network'] != Protocol::OSTATUS)
- && ($network == "")) {
+ && ($network == '')) {
$network = $toplevel_item['network'];
}
@@ -386,7 +386,7 @@ function item_post(App $a) {
// Look for any tags and linkify them
$item = [
'uid' => local_user() ? local_user() : $profile_uid,
- 'gravity' => $toplevel_item_id ? GRAVITY_COMMENT : GRAVITY_PARENT,
+ 'gravity' => $toplevel_item_id ? Item::GRAVITY_COMMENT : Item::GRAVITY_PARENT,
'network' => $network,
'body' => $body,
'postopts' => $postopts,
@@ -463,7 +463,7 @@ function item_post(App $a) {
$data = BBCode::getAttachmentData($body);
$match = [];
- if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) || isset($data["type"]))
+ if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) || isset($data['type']))
&& ($posttype != Item::PT_PERSONAL_NOTE)) {
$posttype = Item::PT_PAGE;
$objecttype = Activity\ObjectType::BOOKMARK;
@@ -478,11 +478,11 @@ function item_post(App $a) {
$objecttype = Activity\ObjectType::NOTE; // Default value
$objectdata = BBCode::getAttachedData($body);
- if ($objectdata["type"] == "link") {
+ if ($objectdata['type'] == 'link') {
$objecttype = Activity\ObjectType::BOOKMARK;
- } elseif ($objectdata["type"] == "video") {
+ } elseif ($objectdata['type'] == 'video') {
$objecttype = Activity\ObjectType::VIDEO;
- } elseif ($objectdata["type"] == "photo") {
+ } elseif ($objectdata['type'] == 'photo') {
$objecttype = Activity\ObjectType::IMAGE;
}
@@ -510,11 +510,11 @@ function item_post(App $a) {
$verb = Activity::POST;
}
- if ($network == "") {
+ if ($network == '') {
$network = Protocol::DFRN;
}
- $gravity = ($toplevel_item_id ? GRAVITY_COMMENT : GRAVITY_PARENT);
+ $gravity = ($toplevel_item_id ? Item::GRAVITY_COMMENT : Item::GRAVITY_PARENT);
// even if the post arrived via API we are considering that it
// originated on this site by default for determining relayability.
@@ -533,68 +533,65 @@ function item_post(App $a) {
$thr_parent_uri = $uri;
}
- $datarray = [];
- $datarray['uid'] = $profile_uid;
- $datarray['wall'] = $wall;
- $datarray['gravity'] = $gravity;
- $datarray['network'] = $network;
- $datarray['contact-id'] = $contact_id;
- $datarray['owner-name'] = $contact_record['name'] ?? '';
- $datarray['owner-link'] = $contact_record['url'] ?? '';
- $datarray['owner-avatar'] = $contact_record['thumb'] ?? '';
- $datarray['owner-id'] = Contact::getIdForURL($datarray['owner-link']);
- $datarray['author-name'] = $author['name'];
- $datarray['author-link'] = $author['url'];
- $datarray['author-avatar'] = $author['thumb'];
- $datarray['author-id'] = Contact::getIdForURL($datarray['author-link']);
- $datarray['created'] = empty($_REQUEST['created_at']) ? DateTimeFormat::utcNow() : $_REQUEST['created_at'];
- $datarray['edited'] = $datarray['created'];
- $datarray['commented'] = $datarray['created'];
- $datarray['changed'] = $datarray['created'];
- $datarray['received'] = DateTimeFormat::utcNow();
- $datarray['extid'] = $extid;
- $datarray['guid'] = $guid;
- $datarray['uri'] = $uri;
- $datarray['title'] = $title;
- $datarray['body'] = $body;
- $datarray['app'] = $app;
- $datarray['location'] = $location;
- $datarray['coord'] = $coord;
- $datarray['file'] = $categories;
- $datarray['inform'] = $inform;
- $datarray['verb'] = $verb;
- $datarray['post-type'] = $posttype;
- $datarray['object-type'] = $objecttype;
- $datarray['allow_cid'] = $str_contact_allow;
- $datarray['allow_gid'] = $str_group_allow;
- $datarray['deny_cid'] = $str_contact_deny;
- $datarray['deny_gid'] = $str_group_deny;
- $datarray['private'] = $private;
- $datarray['pubmail'] = $pubmail_enabled;
- $datarray['attach'] = $attachments;
+ $datarray = [
+ 'uid' => $profile_uid,
+ 'wall' => $wall,
+ 'gravity' => $gravity,
+ 'network' => $network,
+ 'contact-id' => $contact_id,
+ 'owner-name' => $contact_record['name'] ?? '',
+ 'owner-link' => $contact_record['url'] ?? '',
+ 'owner-avatar' => $contact_record['thumb'] ?? '',
+ 'author-name' => $author['name'],
+ 'author-link' => $author['url'],
+ 'author-avatar' => $author['thumb'],
+ 'created' => empty($_REQUEST['created_at']) ? DateTimeFormat::utcNow() : $_REQUEST['created_at'],
+ 'received' => DateTimeFormat::utcNow(),
+ 'extid' => $extid,
+ 'guid' => $guid,
+ 'uri' => $uri,
+ 'title' => $title,
+ 'body' => $body,
+ 'app' => $app,
+ 'location' => $location,
+ 'coord' => $coord,
+ 'file' => $categories,
+ 'inform' => $inform,
+ 'verb' => $verb,
+ 'post-type' => $posttype,
+ 'object-type' => $objecttype,
+ 'allow_cid' => $str_contact_allow,
+ 'allow_gid' => $str_group_allow,
+ 'deny_cid' => $str_contact_deny,
+ 'deny_gid' => $str_group_deny,
+ 'private' => $private,
+ 'pubmail' => $pubmail_enabled,
+ 'attach' => $attachments,
+ 'thr-parent' => $thr_parent_uri,
+ 'postopts' => $postopts,
+ 'origin' => $origin,
+ 'object' => $object,
+ 'attachments' => $_REQUEST['attachments'] ?? [],
+ /*
+ * These fields are for the convenience of addons...
+ * 'self' if true indicates the owner is posting on their own wall
+ * If parent is 0 it is a top-level post.
+ */
+ 'parent' => $toplevel_item_id,
+ 'self' => $self,
+ // This triggers posts via API and the mirror functions
+ 'api_source' => $api_source,
+ // This field is for storing the raw conversation data
+ 'protocol' => Conversation::PARCEL_DIRECT,
+ 'direction' => Conversation::PUSH,
+ ];
- $datarray['thr-parent'] = $thr_parent_uri;
-
- $datarray['postopts'] = $postopts;
- $datarray['origin'] = $origin;
- $datarray['object'] = $object;
-
- $datarray['attachments'] = $_REQUEST['attachments'] ?? [];
-
- /*
- * These fields are for the convenience of addons...
- * 'self' if true indicates the owner is posting on their own wall
- * If parent is 0 it is a top-level post.
- */
- $datarray['parent'] = $toplevel_item_id;
- $datarray['self'] = $self;
-
- // This triggers posts via API and the mirror functions
- $datarray['api_source'] = $api_source;
-
- // This field is for storing the raw conversation data
- $datarray['protocol'] = Conversation::PARCEL_DIRECT;
- $datarray['direction'] = Conversation::PUSH;
+ // These cannot be part of above initialization ...
+ $datarray['edited'] = $datarray['created'];
+ $datarray['commented'] = $datarray['created'];
+ $datarray['changed'] = $datarray['created'];
+ $datarray['owner-id'] = Contact::getIdForURL($datarray['owner-link']);
+ $datarray['author-id'] = Contact::getIdForURL($datarray['author-link']);
$datarray['edit'] = $orig_post;
@@ -607,14 +604,14 @@ function item_post(App $a) {
if ($preview) {
// We set the datarray ID to -1 because in preview mode the dataray
// doesn't have an ID.
- $datarray["id"] = -1;
- $datarray["uri-id"] = -1;
- $datarray["author-network"] = Protocol::DFRN;
- $datarray["author-updated"] = '';
- $datarray["author-gsid"] = 0;
- $datarray["author-uri-id"] = ItemURI::getIdByURI($datarray["author-link"]);
- $datarray["owner-updated"] = '';
- $datarray["has-media"] = false;
+ $datarray['id'] = -1;
+ $datarray['uri-id'] = -1;
+ $datarray['author-network'] = Protocol::DFRN;
+ $datarray['author-updated'] = '';
+ $datarray['author-gsid'] = 0;
+ $datarray['author-uri-id'] = ItemURI::getIdByURI($datarray['author-link']);
+ $datarray['owner-updated'] = '';
+ $datarray['has-media'] = false;
$datarray['body'] = Item::improveSharedDataInBody($datarray);
$o = DI::conversation()->create([array_merge($contact_record, $datarray)], 'search', false, true);
@@ -658,13 +655,13 @@ function item_post(App $a) {
$datarray['uri-id'] = ItemURI::getIdByURI($datarray['uri']);
$datarray['body'] = Item::improveSharedDataInBody($datarray);
- if ($orig_post) {
+ if ($orig_post) {
$fields = [
- 'title' => $datarray['title'],
- 'body' => $datarray['body'],
- 'attach' => $datarray['attach'],
- 'file' => $datarray['file'],
- 'edited' => DateTimeFormat::utcNow(),
+ 'title' => $datarray['title'],
+ 'body' => $datarray['body'],
+ 'attach' => $datarray['attach'],
+ 'file' => $datarray['file'],
+ 'edited' => DateTimeFormat::utcNow(),
'changed' => DateTimeFormat::utcNow()
];
@@ -706,7 +703,7 @@ function item_post(App $a) {
Tag::storeFromBody($datarray['uri-id'], $datarray['body']);
- if (!\Friendica\Content\Feature::isEnabled($uid, 'explicit_mentions') && ($datarray['gravity'] == GRAVITY_COMMENT)) {
+ if (!\Friendica\Content\Feature::isEnabled($uid, 'explicit_mentions') && ($datarray['gravity'] == Item::GRAVITY_COMMENT)) {
Tag::createImplicitMentions($datarray['uri-id'], $datarray['thr-parent-id']);
}
@@ -808,6 +805,7 @@ function item_content(App $a)
}
}
break;
+
case 'block':
$item = Post::selectFirstForUser(local_user(), ['guid', 'author-id', 'parent', 'gravity'], ['id' => $args->get(2)]);
if (empty($item['author-id'])) {
@@ -834,15 +832,15 @@ function item_content(App $a)
* @return string
* @throws HTTPException\InternalServerErrorException
*/
-function drop_item(int $id, string $return = '')
+function drop_item(int $id, string $return = ''): string
{
- // locate item to be deleted
- $fields = ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', 'parent'];
- $item = Post::selectFirstForUser(local_user(), $fields, ['id' => $id]);
+ // Locate item to be deleted
+ $item = Post::selectFirstForUser(local_user(), ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', 'parent'], ['id' => $id]);
if (!DBA::isResult($item)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Item not found.'));
DI::baseUrl()->redirect('network');
+ //NOTREACHED
}
if ($item['deleted']) {
@@ -861,6 +859,7 @@ function drop_item(int $id, string $return = '')
Item::deleteForUser(['id' => $item['id']], local_user());
item_redirect_after_action($item, $return);
+ //NOTREACHED
} else {
Logger::warning('Permission denied.', ['local' => local_user(), 'uid' => $item['uid'], 'cid' => $contact_id]);
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
@@ -871,15 +870,15 @@ function drop_item(int $id, string $return = '')
return '';
}
-function item_redirect_after_action($item, $returnUrlHex)
+function item_redirect_after_action(array $item, string $returnUrlHex)
{
$return_url = hex2bin($returnUrlHex);
// removes update_* from return_url to ignore Ajax refresh
- $return_url = str_replace("update_", "", $return_url);
+ $return_url = str_replace('update_', '', $return_url);
// Check if delete a comment
- if ($item['gravity'] == GRAVITY_COMMENT) {
+ if ($item['gravity'] == Item::GRAVITY_COMMENT) {
if (!empty($item['parent'])) {
$parentitem = Post::selectFirstForUser(local_user(), ['guid'], ['id' => $item['parent']]);
}
diff --git a/mod/message.php b/mod/message.php
index d1231b7c5d..4b6f5b31b8 100644
--- a/mod/message.php
+++ b/mod/message.php
@@ -43,23 +43,23 @@ function message_init(App $a)
}
$new = [
- 'label' => DI::l10n()->t('New Message'),
- 'url' => 'message/new',
- 'sel' => DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new',
+ 'label' => DI::l10n()->t('New Message'),
+ 'url' => 'message/new',
+ 'sel' => DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new',
'accesskey' => 'm',
];
$tpl = Renderer::getMarkupTemplate('message_side.tpl');
DI::page()['aside'] = Renderer::replaceMacros($tpl, [
'$tabs' => $tabs,
- '$new' => $new,
+ '$new' => $new,
]);
$base = DI::baseUrl();
$head_tpl = Renderer::getMarkupTemplate('message-head.tpl');
DI::page()['htmlhead'] .= Renderer::replaceMacros($head_tpl, [
'$baseurl' => DI::baseUrl()->get(true),
- '$base' => $base
+ '$base' => $base
]);
}
@@ -83,12 +83,15 @@ function message_post(App $a)
DI::sysmsg()->addNotice(DI::l10n()->t('No recipient selected.'));
$norecip = true;
break;
+
case -2:
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to locate contact information.'));
break;
+
case -3:
DI::sysmsg()->addNotice(DI::l10n()->t('Message could not be sent.'));
break;
+
case -4:
DI::sysmsg()->addNotice(DI::l10n()->t('Message collection failure.'));
break;
@@ -118,20 +121,20 @@ function message_content(App $a)
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new') {
$button = [
'label' => DI::l10n()->t('Discard'),
- 'url' => '/message',
- 'sel' => 'close',
+ 'url' => '/message',
+ 'sel' => 'close',
];
} else {
$button = [
- 'label' => DI::l10n()->t('New Message'),
- 'url' => '/message/new',
- 'sel' => 'new',
+ 'label' => DI::l10n()->t('New Message'),
+ 'url' => '/message/new',
+ 'sel' => 'new',
'accesskey' => 'm',
];
}
$header = Renderer::replaceMacros($tpl, [
'$messages' => DI::l10n()->t('Messages'),
- '$button' => $button,
+ '$button' => $button,
]);
if ((DI::args()->getArgc() == 3) && (DI::args()->getArgv()[1] === 'drop' || DI::args()->getArgv()[1] === 'dropconv')) {
@@ -186,19 +189,19 @@ function message_content(App $a)
$tpl = Renderer::getMarkupTemplate('prv_message.tpl');
$o .= Renderer::replaceMacros($tpl, [
- '$header' => DI::l10n()->t('Send Private Message'),
- '$to' => DI::l10n()->t('To:'),
- '$subject' => DI::l10n()->t('Subject:'),
- '$subjtxt' => $_REQUEST['subject'] ?? '',
- '$text' => $_REQUEST['body'] ?? '',
- '$readonly' => '',
- '$yourmessage'=> DI::l10n()->t('Your message:'),
- '$select' => $select,
- '$parent' => '',
- '$upload' => DI::l10n()->t('Upload photo'),
- '$insert' => DI::l10n()->t('Insert web link'),
- '$wait' => DI::l10n()->t('Please wait'),
- '$submit' => DI::l10n()->t('Submit')
+ '$header' => DI::l10n()->t('Send Private Message'),
+ '$to' => DI::l10n()->t('To:'),
+ '$subject' => DI::l10n()->t('Subject:'),
+ '$subjtxt' => $_REQUEST['subject'] ?? '',
+ '$text' => $_REQUEST['body'] ?? '',
+ '$readonly' => '',
+ '$yourmessage' => DI::l10n()->t('Your message:'),
+ '$select' => $select,
+ '$parent' => '',
+ '$upload' => DI::l10n()->t('Upload photo'),
+ '$insert' => DI::l10n()->t('Insert web link'),
+ '$wait' => DI::l10n()->t('Please wait'),
+ '$submit' => DI::l10n()->t('Submit')
]);
return $o;
}
@@ -312,18 +315,18 @@ function message_content(App $a)
$from_photo = Contact::getThumb($contact);
$mails[] = [
- 'id' => $message['id'],
- 'from_name' => $from_name_e,
- 'from_url' => $from_url,
- 'from_addr' => $contact['addr'] ?? $from_url,
- 'sparkle' => $sparkle,
+ 'id' => $message['id'],
+ 'from_name' => $from_name_e,
+ 'from_url' => $from_url,
+ 'from_addr' => $contact['addr'] ?? $from_url,
+ 'sparkle' => $sparkle,
'from_photo' => $from_photo,
- 'subject' => $subject_e,
- 'body' => $body_e,
- 'delete' => DI::l10n()->t('Delete message'),
- 'to_name' => $to_name_e,
- 'date' => DateTimeFormat::local($message['created'], DI::l10n()->t('D, d M Y - g:i A')),
- 'ago' => Temporal::getRelativeDate($message['created']),
+ 'subject' => $subject_e,
+ 'body' => $body_e,
+ 'delete' => DI::l10n()->t('Delete message'),
+ 'to_name' => $to_name_e,
+ 'date' => DateTimeFormat::local($message['created'], DI::l10n()->t('D, d M Y - g:i A')),
+ 'ago' => Temporal::getRelativeDate($message['created']),
];
$seen = $message['seen'];
@@ -334,28 +337,27 @@ function message_content(App $a)
$tpl = Renderer::getMarkupTemplate('mail_display.tpl');
$o = Renderer::replaceMacros($tpl, [
- '$thread_id' => DI::args()->getArgv()[1],
+ '$thread_id' => DI::args()->getArgv()[1],
'$thread_subject' => $message['title'],
- '$thread_seen' => $seen,
- '$delete' => DI::l10n()->t('Delete conversation'),
- '$canreply' => (($unknown) ? false : '1'),
- '$unknown_text' => DI::l10n()->t("No secure communications available. You may be able to respond from the sender's profile page."),
- '$mails' => $mails,
-
+ '$thread_seen' => $seen,
+ '$delete' => DI::l10n()->t('Delete conversation'),
+ '$canreply' => (($unknown) ? false : '1'),
+ '$unknown_text' => DI::l10n()->t("No secure communications available. You may be able to respond from the sender's profile page."),
+ '$mails' => $mails,
// reply
- '$header' => DI::l10n()->t('Send Reply'),
- '$to' => DI::l10n()->t('To:'),
- '$subject' => DI::l10n()->t('Subject:'),
- '$subjtxt' => $message['title'],
- '$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ',
- '$yourmessage' => DI::l10n()->t('Your message:'),
- '$text' => '',
- '$select' => $select,
- '$parent' => $parent,
- '$upload' => DI::l10n()->t('Upload photo'),
- '$insert' => DI::l10n()->t('Insert web link'),
- '$submit' => DI::l10n()->t('Submit'),
- '$wait' => DI::l10n()->t('Please wait')
+ '$header' => DI::l10n()->t('Send Reply'),
+ '$to' => DI::l10n()->t('To:'),
+ '$subject' => DI::l10n()->t('Subject:'),
+ '$subjtxt' => $message['title'],
+ '$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ',
+ '$yourmessage' => DI::l10n()->t('Your message:'),
+ '$text' => '',
+ '$select' => $select,
+ '$parent' => $parent,
+ '$upload' => DI::l10n()->t('Upload photo'),
+ '$insert' => DI::l10n()->t('Insert web link'),
+ '$submit' => DI::l10n()->t('Submit'),
+ '$wait' => DI::l10n()->t('Please wait')
]);
return $o;
@@ -368,7 +370,7 @@ function message_content(App $a)
* @param int $limit
* @return array
*/
-function get_messages(int $uid, int $start, int $limit)
+function get_messages(int $uid, int $start, int $limit): array
{
return DBA::toArray(DBA::p('SELECT
m.`id`,
@@ -392,21 +394,21 @@ function get_messages(int $uid, int $start, int $limit)
c.`url`,
c.`thumb`,
c.`network`,
- m2.`count`,
- m2.`mailcreated`,
- m2.`mailseen`
- FROM `mail` m
- JOIN (
- SELECT
- `parent-uri`,
- MIN(`id`) AS `id`,
- COUNT(*) AS `count`,
- MAX(`created`) AS `mailcreated`,
- MIN(`seen`) AS `mailseen`
- FROM `mail`
- WHERE `uid` = ?
- GROUP BY `parent-uri`
- ) m2 ON m.`parent-uri` = m2.`parent-uri` AND m.`id` = m2.`id`
+ m2.`count`,
+ m2.`mailcreated`,
+ m2.`mailseen`
+ FROM `mail` m
+ JOIN (
+ SELECT
+ `parent-uri`,
+ MIN(`id`) AS `id`,
+ COUNT(*) AS `count`,
+ MAX(`created`) AS `mailcreated`,
+ MIN(`seen`) AS `mailseen`
+ FROM `mail`
+ WHERE `uid` = ?
+ GROUP BY `parent-uri`
+ ) m2 ON m.`parent-uri` = m2.`parent-uri` AND m.`id` = m2.`id`
LEFT JOIN `contact` c ON m.`contact-id` = c.`id`
WHERE m.`uid` = ?
ORDER BY m2.`mailcreated` DESC
@@ -414,7 +416,7 @@ function get_messages(int $uid, int $start, int $limit)
, $uid, $uid, $start, $limit));
}
-function render_messages(array $msg, $t)
+function render_messages(array $msg, string $t): string
{
$a = DI::app();
@@ -444,20 +446,20 @@ function render_messages(array $msg, $t)
$from_photo = Contact::getThumb($contact);
$rslt .= Renderer::replaceMacros($tpl, [
- '$id' => $rr['id'],
- '$from_name' => $participants,
- '$from_url' => Contact::magicLink($rr['url']),
- '$from_addr' => $contact['addr'] ?? '',
- '$sparkle' => ' sparkle',
+ '$id' => $rr['id'],
+ '$from_name' => $participants,
+ '$from_url' => Contact::magicLink($rr['url']),
+ '$from_addr' => $contact['addr'] ?? '',
+ '$sparkle' => ' sparkle',
'$from_photo' => $from_photo,
- '$subject' => $rr['title'],
- '$delete' => DI::l10n()->t('Delete conversation'),
- '$body' => $body_e,
- '$to_name' => $to_name_e,
- '$date' => DateTimeFormat::local($rr['mailcreated'], DI::l10n()->t('D, d M Y - g:i A')),
- '$ago' => Temporal::getRelativeDate($rr['mailcreated']),
- '$seen' => $rr['mailseen'],
- '$count' => DI::l10n()->tt('%d message', '%d messages', $rr['count']),
+ '$subject' => $rr['title'],
+ '$delete' => DI::l10n()->t('Delete conversation'),
+ '$body' => $body_e,
+ '$to_name' => $to_name_e,
+ '$date' => DateTimeFormat::local($rr['mailcreated'], DI::l10n()->t('D, d M Y - g:i A')),
+ '$ago' => Temporal::getRelativeDate($rr['mailcreated']),
+ '$seen' => $rr['mailseen'],
+ '$count' => DI::l10n()->tt('%d message', '%d messages', $rr['count']),
]);
}
diff --git a/mod/notes.php b/mod/notes.php
index a30d807693..2c23e7aaa6 100644
--- a/mod/notes.php
+++ b/mod/notes.php
@@ -38,7 +38,7 @@ function notes_init(App $a)
}
-function notes_content(App $a, $update = false)
+function notes_content(App $a, bool $update = false)
{
if (!local_user()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
@@ -60,7 +60,7 @@ function notes_content(App $a, $update = false)
$o .= DI::conversation()->statusEditor($x, $a->getContactId());
}
- $condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
+ $condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => Item::GRAVITY_PARENT,
'contact-id'=> $a->getContactId()];
if (DI::mode()->isMobile()) {
diff --git a/mod/oexchange.php b/mod/oexchange.php
index 173de0a6bc..f914e1e177 100644
--- a/mod/oexchange.php
+++ b/mod/oexchange.php
@@ -20,6 +20,8 @@
*/
use Friendica\App;
+use Friendica\Content\Text\BBCode;
+use Friendica\Content\Text\HTML;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Module\Response;
@@ -93,8 +95,8 @@ function oexchange_init(App $a)
System::httpExit($xml->saveXML(), Response::TYPE_XML, 'application/xrd+xml');
}
-function oexchange_content(App $a) {
-
+function oexchange_content(App $a)
+{
if (!local_user()) {
$o = Login::form();
return $o;
@@ -109,7 +111,7 @@ function oexchange_content(App $a) {
$description = !empty($_REQUEST['description']) ? trim($_REQUEST['description']) : '';
$tags = !empty($_REQUEST['tags']) ? trim($_REQUEST['tags']) : '';
- $s = \Friendica\Content\Text\BBCode::embedURL($url, true, $title, $description, $tags);
+ $s = BBCode::embedURL($url, true, $title, $description, $tags);
if (!strlen($s)) {
return;
@@ -119,9 +121,9 @@ function oexchange_content(App $a) {
$post['profile_uid'] = local_user();
$post['return'] = '/oexchange/done';
- $post['body'] = Friendica\Content\Text\HTML::toBBCode($s);
+ $post['body'] = HTML::toBBCode($s);
$_REQUEST = $post;
- require_once('mod/item.php');
+ require_once 'mod/item.php';
item_post($a);
}
diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php
index 2ecea60166..0dbce59f29 100644
--- a/mod/ostatus_subscribe.php
+++ b/mod/ostatus_subscribe.php
@@ -27,7 +27,7 @@ use Friendica\Model\Contact;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Protocol\ActivityPub;
-function ostatus_subscribe_content(App $a)
+function ostatus_subscribe_content(App $a): string
{
if (!local_user()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
@@ -42,7 +42,6 @@ function ostatus_subscribe_content(App $a)
$counter = intval($_REQUEST['counter'] ?? 0);
if (DI::pConfig()->get($uid, 'ostatus', 'legacy_friends') == '') {
-
if ($_REQUEST['url'] == '') {
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
return $o . DI::l10n()->t('No contact provided.');
diff --git a/mod/photos.php b/mod/photos.php
index 047328aa53..8111fffa30 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -55,8 +55,8 @@ use Friendica\Util\Temporal;
use Friendica\Util\XML;
use Friendica\Network\HTTPException;
-function photos_init(App $a) {
-
+function photos_init(App $a)
+{
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
return;
}
@@ -526,44 +526,40 @@ function photos_post(App $a)
foreach ($taginfo as $tagged) {
$uri = Item::newURI();
- $arr = [];
- $arr['guid'] = System::createUUID();
- $arr['uid'] = $page_owner_uid;
- $arr['uri'] = $uri;
- $arr['wall'] = 1;
- $arr['contact-id'] = $owner_record['id'];
- $arr['owner-name'] = $owner_record['name'];
- $arr['owner-link'] = $owner_record['url'];
- $arr['owner-avatar'] = $owner_record['thumb'];
- $arr['author-name'] = $owner_record['name'];
- $arr['author-link'] = $owner_record['url'];
- $arr['author-avatar'] = $owner_record['thumb'];
- $arr['title'] = '';
- $arr['allow_cid'] = $photo['allow_cid'];
- $arr['allow_gid'] = $photo['allow_gid'];
- $arr['deny_cid'] = $photo['deny_cid'];
- $arr['deny_gid'] = $photo['deny_gid'];
- $arr['visible'] = 0;
- $arr['verb'] = Activity::TAG;
- $arr['gravity'] = GRAVITY_PARENT;
- $arr['object-type'] = Activity\ObjectType::PERSON;
- $arr['target-type'] = Activity\ObjectType::IMAGE;
- $arr['inform'] = $tagged[2];
- $arr['origin'] = 1;
- $arr['body'] = DI::l10n()->t('%1$s was tagged in %2$s by %3$s', '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . DI::l10n()->t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ;
- $arr['body'] .= "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . '[img]' . DI::baseUrl() . "/photo/" . $photo['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ;
+ $arr = [
+ 'guid' => System::createUUID(),
+ 'uid' => $page_owner_uid,
+ 'uri' => $uri,
+ 'wall' => 1,
+ 'contact-id' => $owner_record['id'],
+ 'owner-name' => $owner_record['name'],
+ 'owner-link' => $owner_record['url'],
+ 'owner-avatar' => $owner_record['thumb'],
+ 'author-name' => $owner_record['name'],
+ 'author-link' => $owner_record['url'],
+ 'author-avatar' => $owner_record['thumb'],
+ 'title' => '',
+ 'allow_cid' => $photo['allow_cid'],
+ 'allow_gid' => $photo['allow_gid'],
+ 'deny_cid' => $photo['deny_cid'],
+ 'deny_gid' => $photo['deny_gid'],
+ 'visible' => 0,
+ 'verb' => Activity::TAG,
+ 'gravity' => Item::GRAVITY_PARENT,
+ 'object-type' => Activity\ObjectType::PERSON,
+ 'target-type' => Activity\ObjectType::IMAGE,
+ 'inform' => $tagged[2],
+ 'origin' => 1,
+ 'body' => DI::l10n()->t('%1$s was tagged in %2$s by %3$s', '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . DI::l10n()->t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') . "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo['resource-id'] . ']' . '[img]' . DI::baseUrl() . '/photo/' . $photo['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n",
+ 'object' => '