From e823a1bd0555eca499a65bb44b999e04dae1881a Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 8 Aug 2021 11:17:08 +0000 Subject: [PATCH 1/5] Replaced direct calls to App->user --- advancedcontentfilter/advancedcontentfilter.php | 2 +- ifttt/ifttt.php | 2 +- jappixmini/jappixmini.php | 2 +- langfilter/langfilter.php | 2 +- opmlexport/opmlexport.php | 4 ++-- securemail/SecureTestEmail.php | 2 +- statusnet/statusnet.php | 2 +- twitter/twitter.php | 4 ++-- windowsphonepush/windowsphonepush.php | 2 +- xmpp/xmpp.php | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/advancedcontentfilter/advancedcontentfilter.php b/advancedcontentfilter/advancedcontentfilter.php index d7af3eee2..aedd6e8c9 100644 --- a/advancedcontentfilter/advancedcontentfilter.php +++ b/advancedcontentfilter/advancedcontentfilter.php @@ -200,7 +200,7 @@ function advancedcontentfilter_content(App $a) } if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'help') { - $lang = $a->user['language']; + $lang = $a->getUserValue('language'); $default_dir = 'addon/advancedcontentfilter/doc/'; $help_file = 'advancedcontentfilter.md'; diff --git a/ifttt/ifttt.php b/ifttt/ifttt.php index 67ffdd858..2cf452120 100644 --- a/ifttt/ifttt.php +++ b/ifttt/ifttt.php @@ -57,7 +57,7 @@ function ifttt_settings(App $a, &$s) $s .= '
'; $s .= '

' . DI::l10n()->t('Create an account at IFTTT. Create three Facebook recipes that are connected with Maker (In the form "if Facebook then Maker") with the following parameters:') . '

'; $s .= '

URL

'; - $s .= '

' . DI::baseUrl()->get() . '/ifttt/' . $a->user['nickname'] . '

'; + $s .= '

' . DI::baseUrl()->get() . '/ifttt/' . $a->getNickname() . '

'; $s .= '

Method

'; $s .= '

POST

'; $s .= '

Content Type

'; diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php index 0333d8ecf..3d1a19727 100644 --- a/jappixmini/jappixmini.php +++ b/jappixmini/jappixmini.php @@ -283,7 +283,7 @@ function jappixmini_settings(App $a, &$s) } if (($username == "") && DI::config()->get("jappixmini", "default_user")) { - $username = $a->user["nickname"]; + $username = $a->getNickname(); } $info_text = DI::config()->get("jappixmini", "infotext"); diff --git a/langfilter/langfilter.php b/langfilter/langfilter.php index 0cf3e552c..aaf6d16f6 100644 --- a/langfilter/langfilter.php +++ b/langfilter/langfilter.php @@ -105,7 +105,7 @@ function langfilter_prepare_body_content_filter(App $a, &$hook_data) // Never filter own messages // TODO: find a better way to extract this - $logged_user_profile = DI::baseUrl()->get() . '/profile/' . $a->user['nickname']; + $logged_user_profile = DI::baseUrl()->get() . '/profile/' . $a->getNickname(); if ($logged_user_profile == $hook_data['item']['author-link']) { return; } diff --git a/opmlexport/opmlexport.php b/opmlexport/opmlexport.php index ca65cbaab..28689f5d7 100644 --- a/opmlexport/opmlexport.php +++ b/opmlexport/opmlexport.php @@ -43,8 +43,8 @@ function opmlexport(App $a) $head = $xml->createElement('head'); $body = $xml->createElement('body'); $outline = $xml->createElement('outline'); - $outline->setAttribute('title', $a->user['username'] . '\'s RSS/Atom contacts'); - $outline->setAttribute('text', $a->user['username'] . '\'s RSS/Atom contacts'); + $outline->setAttribute('title', $a->getUserValue('username') . '\'s RSS/Atom contacts'); + $outline->setAttribute('text', $a->getUserValue('username') . '\'s RSS/Atom contacts'); foreach($data as $c) { $entry = $xml->createElement('outline'); diff --git a/securemail/SecureTestEmail.php b/securemail/SecureTestEmail.php index 8341f5451..b40f3a6f1 100644 --- a/securemail/SecureTestEmail.php +++ b/securemail/SecureTestEmail.php @@ -52,7 +52,7 @@ class SecureTestEmail extends Email // enable addon for test $pConfig->set(local_user(), 'securemail', 'enable', 1); - parent::__construct($sitename, $sender_email, $sender_email, $a->user['email'], + parent::__construct($sitename, $sender_email, $sender_email, $a->getUserValue('email'), $subject, "

{$message}

", $message, [], local_user()); } diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 6f4c3e20d..d0e96a01d 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -334,7 +334,7 @@ function statusnet_settings(App $a, &$s) $s .= '

' . DI::l10n()->t('Currently connected to: ') . '' . $details->screen_name . '
' . $details->description . '

'; } $s .= '

' . DI::l10n()->t('If enabled all your public postings can be posted to the associated GNU Social account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.') . '

'; - if ($a->user['hidewall']) { + if ($a->getUserValue('hidewall')) { $s .= '

' . DI::l10n()->t('Note: Due your privacy settings (Hide your profile details from unknown viewers?) the link potentially included in public postings relayed to GNU Social will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') . '

'; } $s .= '
'; diff --git a/twitter/twitter.php b/twitter/twitter.php index 8bc5940cf..90e676100 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -146,7 +146,7 @@ function twitter_follow(App $a, array &$contact) $nickname = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $contact["url"]); $nickname = str_replace("@twitter.com", "", $nickname); - $uid = $a->user["uid"]; + $uid = $a->getUserId(); $ckey = DI::config()->get('twitter', 'consumerkey'); $csecret = DI::config()->get('twitter', 'consumersecret'); @@ -356,7 +356,7 @@ function twitter_settings(App $a, &$s) $s .= Renderer::replaceMacros($field_checkbox, [ '$field' => ['twitter-enable', DI::l10n()->t('Allow posting to Twitter'), $enabled, DI::l10n()->t('If enabled all your public postings can be posted to the associated Twitter account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.')] ]); - if ($a->user['hidewall']) { + if ($a->getUserValue('hidewall')) { $s .= '

' . DI::l10n()->t('Note: Due to your privacy settings (Hide your profile details from unknown viewers?) the link potentially included in public postings relayed to Twitter will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') . '

'; } $s .= Renderer::replaceMacros($field_checkbox, [ diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index c5ff6965e..ca2dd3588 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -460,5 +460,5 @@ function windowsphonepush_login(App $a) DI::auth()->setForUser($a, $record); DI::session()->set('allow_api', true); - Hook::callAll('logged_in', $a->user); + Hook::callAll('logged_in', $record); } diff --git a/xmpp/xmpp.php b/xmpp/xmpp.php index 392dbe0e9..c64a517a9 100644 --- a/xmpp/xmpp.php +++ b/xmpp/xmpp.php @@ -153,7 +153,7 @@ function xmpp_converse(App $a) DI::pConfig()->set(local_user(), "xmpp", "password", $password); } - $jid = $a->user["nickname"] . "@" . DI::baseUrl()->getHostname() . "/converse-" . Strings::getRandomHex(5); + $jid = $a->getNickname() . "@" . DI::baseUrl()->getHostname() . "/converse-" . Strings::getRandomHex(5); $auto_login = "auto_login: true, authentication: 'login', From 9ad7500146cfdf775fc9744090a5fd50376f8709 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 8 Aug 2021 17:10:04 +0000 Subject: [PATCH 2/5] Remove the use of app function --- advancedcontentfilter/advancedcontentfilter.php | 5 ++++- opmlexport/opmlexport.php | 6 ++++-- securemail/SecureTestEmail.php | 5 ++++- statusnet/statusnet.php | 5 ++++- twitter/twitter.php | 5 ++++- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/advancedcontentfilter/advancedcontentfilter.php b/advancedcontentfilter/advancedcontentfilter.php index aedd6e8c9..bd97b309c 100644 --- a/advancedcontentfilter/advancedcontentfilter.php +++ b/advancedcontentfilter/advancedcontentfilter.php @@ -45,6 +45,7 @@ use Friendica\DI; use Friendica\Model\Item; use Friendica\Model\Post; use Friendica\Model\Tag; +use Friendica\Model\User; use Friendica\Module\Security\Login; use Friendica\Network\HTTPException; use Friendica\Util\DateTimeFormat; @@ -200,7 +201,9 @@ function advancedcontentfilter_content(App $a) } if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'help') { - $lang = $a->getUserValue('language'); + $user = User::getById(local_user()); + + $lang = $user['language']; $default_dir = 'addon/advancedcontentfilter/doc/'; $help_file = 'advancedcontentfilter.md'; diff --git a/opmlexport/opmlexport.php b/opmlexport/opmlexport.php index 28689f5d7..5d6139416 100644 --- a/opmlexport/opmlexport.php +++ b/opmlexport/opmlexport.php @@ -16,6 +16,7 @@ use Friendica\Database\DBA; use Friendica\Core\Renderer; use Friendica\Core\Protocol; use Friendica\Model\Contact; +use Friendica\Model\User; function opmlexport_install() { @@ -37,14 +38,15 @@ function opmlexport(App $a) 'network' => Protocol::FEED ]; $data = Contact::selectToArray([], $condition, ['order' => ['name']]); + $user = User::getById(local_user()); $xml = new \DOMDocument( '1.0', 'utf-8' ); $opml = $xml->createElement('opml'); $head = $xml->createElement('head'); $body = $xml->createElement('body'); $outline = $xml->createElement('outline'); - $outline->setAttribute('title', $a->getUserValue('username') . '\'s RSS/Atom contacts'); - $outline->setAttribute('text', $a->getUserValue('username') . '\'s RSS/Atom contacts'); + $outline->setAttribute('title', $user['username'] . '\'s RSS/Atom contacts'); + $outline->setAttribute('text', $user['username'] . '\'s RSS/Atom contacts'); foreach($data as $c) { $entry = $xml->createElement('outline'); diff --git a/securemail/SecureTestEmail.php b/securemail/SecureTestEmail.php index b40f3a6f1..b3abcd509 100644 --- a/securemail/SecureTestEmail.php +++ b/securemail/SecureTestEmail.php @@ -25,6 +25,7 @@ use Friendica\App; use Friendica\App\BaseURL; use Friendica\Core\Config\IConfig; use Friendica\Core\PConfig\IPConfig; +use Friendica\Model\User; use Friendica\Object\Email; /** @@ -46,13 +47,15 @@ class SecureTestEmail extends Email $sender_email = 'noreply@' . $hostname; } + $user = User::getById(local_user()); + $subject = 'Friendica - Secure Mail - Test'; $message = 'This is a test message from your Friendica Secure Mail addon.'; // enable addon for test $pConfig->set(local_user(), 'securemail', 'enable', 1); - parent::__construct($sitename, $sender_email, $sender_email, $a->getUserValue('email'), + parent::__construct($sitename, $sender_email, $sender_email, $user['email'], $subject, "

{$message}

", $message, [], local_user()); } diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index d0e96a01d..1a3ba1f97 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -216,6 +216,9 @@ function statusnet_settings(App $a, &$s) if (!local_user()) { return; } + + $user = User::getById(local_user()); + DI::page()['htmlhead'] .= '' . "\r\n"; /* * * * 1) Check that we have a base api url and a consumer key & secret @@ -334,7 +337,7 @@ function statusnet_settings(App $a, &$s) $s .= '

' . DI::l10n()->t('Currently connected to: ') . '' . $details->screen_name . '
' . $details->description . '

'; } $s .= '

' . DI::l10n()->t('If enabled all your public postings can be posted to the associated GNU Social account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.') . '

'; - if ($a->getUserValue('hidewall')) { + if ($user['hidewall']) { $s .= '

' . DI::l10n()->t('Note: Due your privacy settings (Hide your profile details from unknown viewers?) the link potentially included in public postings relayed to GNU Social will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') . '

'; } $s .= '
'; diff --git a/twitter/twitter.php b/twitter/twitter.php index 90e676100..56b5ead84 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -266,6 +266,9 @@ function twitter_settings(App $a, &$s) if (!local_user()) { return; } + + $user = User::getById(local_user()); + DI::page()['htmlhead'] .= '' . "\r\n"; /* * * * 1) Check that we have global consumer key & secret @@ -356,7 +359,7 @@ function twitter_settings(App $a, &$s) $s .= Renderer::replaceMacros($field_checkbox, [ '$field' => ['twitter-enable', DI::l10n()->t('Allow posting to Twitter'), $enabled, DI::l10n()->t('If enabled all your public postings can be posted to the associated Twitter account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.')] ]); - if ($a->getUserValue('hidewall')) { + if ($user['hidewall']) { $s .= '

' . DI::l10n()->t('Note: Due to your privacy settings (Hide your profile details from unknown viewers?) the link potentially included in public postings relayed to Twitter will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') . '

'; } $s .= Renderer::replaceMacros($field_checkbox, [ From 9cf43bb85bb2060e54b1b38fbcfe2864071e4deb Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 9 Aug 2021 15:29:26 +0000 Subject: [PATCH 3/5] Changed function name --- ifttt/ifttt.php | 2 +- jappixmini/jappixmini.php | 2 +- langfilter/langfilter.php | 2 +- xmpp/xmpp.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ifttt/ifttt.php b/ifttt/ifttt.php index 2cf452120..7ce21e614 100644 --- a/ifttt/ifttt.php +++ b/ifttt/ifttt.php @@ -57,7 +57,7 @@ function ifttt_settings(App $a, &$s) $s .= '
'; $s .= '

' . DI::l10n()->t('Create an account at IFTTT. Create three Facebook recipes that are connected with Maker (In the form "if Facebook then Maker") with the following parameters:') . '

'; $s .= '

URL

'; - $s .= '

' . DI::baseUrl()->get() . '/ifttt/' . $a->getNickname() . '

'; + $s .= '

' . DI::baseUrl()->get() . '/ifttt/' . $a->getUserNickname() . '

'; $s .= '

Method

'; $s .= '

POST

'; $s .= '

Content Type

'; diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php index 3d1a19727..1740923b3 100644 --- a/jappixmini/jappixmini.php +++ b/jappixmini/jappixmini.php @@ -283,7 +283,7 @@ function jappixmini_settings(App $a, &$s) } if (($username == "") && DI::config()->get("jappixmini", "default_user")) { - $username = $a->getNickname(); + $username = $a->getUserNickname(); } $info_text = DI::config()->get("jappixmini", "infotext"); diff --git a/langfilter/langfilter.php b/langfilter/langfilter.php index aaf6d16f6..9bde281ec 100644 --- a/langfilter/langfilter.php +++ b/langfilter/langfilter.php @@ -105,7 +105,7 @@ function langfilter_prepare_body_content_filter(App $a, &$hook_data) // Never filter own messages // TODO: find a better way to extract this - $logged_user_profile = DI::baseUrl()->get() . '/profile/' . $a->getNickname(); + $logged_user_profile = DI::baseUrl()->get() . '/profile/' . $a->getUserNickname(); if ($logged_user_profile == $hook_data['item']['author-link']) { return; } diff --git a/xmpp/xmpp.php b/xmpp/xmpp.php index c64a517a9..510b2150c 100644 --- a/xmpp/xmpp.php +++ b/xmpp/xmpp.php @@ -153,7 +153,7 @@ function xmpp_converse(App $a) DI::pConfig()->set(local_user(), "xmpp", "password", $password); } - $jid = $a->getNickname() . "@" . DI::baseUrl()->getHostname() . "/converse-" . Strings::getRandomHex(5); + $jid = $a->getUserNickname() . "@" . DI::baseUrl()->getHostname() . "/converse-" . Strings::getRandomHex(5); $auto_login = "auto_login: true, authentication: 'login', From 08c64387d702ce52471482c530a0069aa1412476 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 9 Aug 2021 19:49:06 +0000 Subject: [PATCH 4/5] "getUserNickname" is now "getLoggedInUserNickname" --- ifttt/ifttt.php | 2 +- jappixmini/jappixmini.php | 2 +- langfilter/langfilter.php | 2 +- xmpp/xmpp.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ifttt/ifttt.php b/ifttt/ifttt.php index 7ce21e614..593c0e086 100644 --- a/ifttt/ifttt.php +++ b/ifttt/ifttt.php @@ -57,7 +57,7 @@ function ifttt_settings(App $a, &$s) $s .= '
'; $s .= '

' . DI::l10n()->t('Create an account at IFTTT. Create three Facebook recipes that are connected with Maker (In the form "if Facebook then Maker") with the following parameters:') . '

'; $s .= '

URL

'; - $s .= '

' . DI::baseUrl()->get() . '/ifttt/' . $a->getUserNickname() . '

'; + $s .= '

' . DI::baseUrl()->get() . '/ifttt/' . $a->getLoggedInUserNickname() . '

'; $s .= '

Method

'; $s .= '

POST

'; $s .= '

Content Type

'; diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php index 1740923b3..0e0abfc89 100644 --- a/jappixmini/jappixmini.php +++ b/jappixmini/jappixmini.php @@ -283,7 +283,7 @@ function jappixmini_settings(App $a, &$s) } if (($username == "") && DI::config()->get("jappixmini", "default_user")) { - $username = $a->getUserNickname(); + $username = $a->getLoggedInUserNickname(); } $info_text = DI::config()->get("jappixmini", "infotext"); diff --git a/langfilter/langfilter.php b/langfilter/langfilter.php index 9bde281ec..aeb53eebd 100644 --- a/langfilter/langfilter.php +++ b/langfilter/langfilter.php @@ -105,7 +105,7 @@ function langfilter_prepare_body_content_filter(App $a, &$hook_data) // Never filter own messages // TODO: find a better way to extract this - $logged_user_profile = DI::baseUrl()->get() . '/profile/' . $a->getUserNickname(); + $logged_user_profile = DI::baseUrl()->get() . '/profile/' . $a->getLoggedInUserNickname(); if ($logged_user_profile == $hook_data['item']['author-link']) { return; } diff --git a/xmpp/xmpp.php b/xmpp/xmpp.php index 510b2150c..2f359a7e8 100644 --- a/xmpp/xmpp.php +++ b/xmpp/xmpp.php @@ -153,7 +153,7 @@ function xmpp_converse(App $a) DI::pConfig()->set(local_user(), "xmpp", "password", $password); } - $jid = $a->getUserNickname() . "@" . DI::baseUrl()->getHostname() . "/converse-" . Strings::getRandomHex(5); + $jid = $a->getLoggedInUserNickname() . "@" . DI::baseUrl()->getHostname() . "/converse-" . Strings::getRandomHex(5); $auto_login = "auto_login: true, authentication: 'login', From 752602f5f57c0619655c9a00a77c105756fb1dce Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 9 Aug 2021 20:38:36 +0000 Subject: [PATCH 5/5] "getUserId" is now "getLoggedInUserId" --- twitter/twitter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/twitter/twitter.php b/twitter/twitter.php index 56b5ead84..b5c9ffbc1 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -146,7 +146,7 @@ function twitter_follow(App $a, array &$contact) $nickname = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $contact["url"]); $nickname = str_replace("@twitter.com", "", $nickname); - $uid = $a->getUserId(); + $uid = $a->getLoggedInUserId(); $ckey = DI::config()->get('twitter', 'consumerkey'); $csecret = DI::config()->get('twitter', 'consumersecret');