diff --git a/boot.php b/boot.php
index 8e7958de36..0f2b25027f 100644
--- a/boot.php
+++ b/boot.php
@@ -59,18 +59,6 @@ define('CP_USERS_AND_GLOBAL', 2);
* @}
*/
-/**
- * @name Gravity
- *
- * Item weight for query ordering
- * @{
- */
-define('GRAVITY_PARENT', 0);
-define('GRAVITY_ACTIVITY', 3);
-define('GRAVITY_COMMENT', 6);
-define('GRAVITY_UNKNOWN', 9);
-/* @}*/
-
/**
* @name Priority
*
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/item.php b/mod/item.php
index f3f0fd40d6..9bb082884d 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -122,7 +122,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']]);
}
}
@@ -385,7 +385,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,
@@ -513,7 +513,7 @@ function item_post(App $a) {
$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.
@@ -705,7 +705,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']);
}
@@ -833,15 +833,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)) {
notice(DI::l10n()->t('Item not found.'));
DI::baseUrl()->redirect('network');
+ //NOTREACHED
}
if ($item['deleted']) {
@@ -860,6 +860,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]);
notice(DI::l10n()->t('Permission denied.'));
@@ -870,15 +871,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 a07c8b4493..e8fe60fd33 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)
notice(DI::l10n()->t('No recipient selected.'));
$norecip = true;
break;
+
case -2:
notice(DI::l10n()->t('Unable to locate contact information.'));
break;
+
case -3:
notice(DI::l10n()->t('Message could not be sent.'));
break;
+
case -4:
notice(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 b5bdbf870f..e81cedf0b7 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()) {
notice(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..4eb25a2ab7 100644
--- a/mod/oexchange.php
+++ b/mod/oexchange.php
@@ -93,8 +93,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 +109,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 +119,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 781de3493a..345e64924f 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()) {
notice(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 6a4596bf24..d953569edc 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' => '