Merge pull request #1152 from annando/app-user

Replaced direct calls to App->user
pull/1154/head
Hypolite Petovan 2021-08-09 17:00:24 -04:00 committed by GitHub
commit b74288fa96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 26 additions and 12 deletions

View File

@ -45,6 +45,7 @@ use Friendica\DI;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Post; use Friendica\Model\Post;
use Friendica\Model\Tag; use Friendica\Model\Tag;
use Friendica\Model\User;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
@ -200,7 +201,9 @@ function advancedcontentfilter_content(App $a)
} }
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'help') { if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'help') {
$lang = $a->user['language']; $user = User::getById(local_user());
$lang = $user['language'];
$default_dir = 'addon/advancedcontentfilter/doc/'; $default_dir = 'addon/advancedcontentfilter/doc/';
$help_file = 'advancedcontentfilter.md'; $help_file = 'advancedcontentfilter.md';

View File

@ -57,7 +57,7 @@ function ifttt_settings(App $a, &$s)
$s .= '<div id="ifttt-configuration-wrapper">'; $s .= '<div id="ifttt-configuration-wrapper">';
$s .= '<p>' . DI::l10n()->t('Create an account at <a href="http://www.ifttt.com">IFTTT</a>. Create three Facebook recipes that are connected with <a href="https://ifttt.com/maker">Maker</a> (In the form "if Facebook then Maker") with the following parameters:') . '</p>'; $s .= '<p>' . DI::l10n()->t('Create an account at <a href="http://www.ifttt.com">IFTTT</a>. Create three Facebook recipes that are connected with <a href="https://ifttt.com/maker">Maker</a> (In the form "if Facebook then Maker") with the following parameters:') . '</p>';
$s .= '<h4>URL</h4>'; $s .= '<h4>URL</h4>';
$s .= '<p>' . DI::baseUrl()->get() . '/ifttt/' . $a->user['nickname'] . '</p>'; $s .= '<p>' . DI::baseUrl()->get() . '/ifttt/' . $a->getLoggedInUserNickname() . '</p>';
$s .= '<h4>Method</h4>'; $s .= '<h4>Method</h4>';
$s .= '<p>POST</p>'; $s .= '<p>POST</p>';
$s .= '<h4>Content Type</h4>'; $s .= '<h4>Content Type</h4>';

View File

@ -283,7 +283,7 @@ function jappixmini_settings(App $a, &$s)
} }
if (($username == "") && DI::config()->get("jappixmini", "default_user")) { if (($username == "") && DI::config()->get("jappixmini", "default_user")) {
$username = $a->user["nickname"]; $username = $a->getLoggedInUserNickname();
} }
$info_text = DI::config()->get("jappixmini", "infotext"); $info_text = DI::config()->get("jappixmini", "infotext");

View File

@ -105,7 +105,7 @@ function langfilter_prepare_body_content_filter(App $a, &$hook_data)
// Never filter own messages // Never filter own messages
// TODO: find a better way to extract this // 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->getLoggedInUserNickname();
if ($logged_user_profile == $hook_data['item']['author-link']) { if ($logged_user_profile == $hook_data['item']['author-link']) {
return; return;
} }

View File

@ -16,6 +16,7 @@ use Friendica\Database\DBA;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\User;
function opmlexport_install() function opmlexport_install()
{ {
@ -37,14 +38,15 @@ function opmlexport(App $a)
'network' => Protocol::FEED 'network' => Protocol::FEED
]; ];
$data = Contact::selectToArray([], $condition, ['order' => ['name']]); $data = Contact::selectToArray([], $condition, ['order' => ['name']]);
$user = User::getById(local_user());
$xml = new \DOMDocument( '1.0', 'utf-8' ); $xml = new \DOMDocument( '1.0', 'utf-8' );
$opml = $xml->createElement('opml'); $opml = $xml->createElement('opml');
$head = $xml->createElement('head'); $head = $xml->createElement('head');
$body = $xml->createElement('body'); $body = $xml->createElement('body');
$outline = $xml->createElement('outline'); $outline = $xml->createElement('outline');
$outline->setAttribute('title', $a->user['username'] . '\'s RSS/Atom contacts'); $outline->setAttribute('title', $user['username'] . '\'s RSS/Atom contacts');
$outline->setAttribute('text', $a->user['username'] . '\'s RSS/Atom contacts'); $outline->setAttribute('text', $user['username'] . '\'s RSS/Atom contacts');
foreach($data as $c) { foreach($data as $c) {
$entry = $xml->createElement('outline'); $entry = $xml->createElement('outline');

View File

@ -25,6 +25,7 @@ use Friendica\App;
use Friendica\App\BaseURL; use Friendica\App\BaseURL;
use Friendica\Core\Config\IConfig; use Friendica\Core\Config\IConfig;
use Friendica\Core\PConfig\IPConfig; use Friendica\Core\PConfig\IPConfig;
use Friendica\Model\User;
use Friendica\Object\Email; use Friendica\Object\Email;
/** /**
@ -46,13 +47,15 @@ class SecureTestEmail extends Email
$sender_email = 'noreply@' . $hostname; $sender_email = 'noreply@' . $hostname;
} }
$user = User::getById(local_user());
$subject = 'Friendica - Secure Mail - Test'; $subject = 'Friendica - Secure Mail - Test';
$message = 'This is a test message from your Friendica Secure Mail addon.'; $message = 'This is a test message from your Friendica Secure Mail addon.';
// enable addon for test // enable addon for test
$pConfig->set(local_user(), 'securemail', 'enable', 1); $pConfig->set(local_user(), 'securemail', 'enable', 1);
parent::__construct($sitename, $sender_email, $sender_email, $a->user['email'], parent::__construct($sitename, $sender_email, $sender_email, $user['email'],
$subject, "<p>{$message}</p>", $message, $subject, "<p>{$message}</p>", $message,
[], local_user()); [], local_user());
} }

View File

@ -216,6 +216,9 @@ function statusnet_settings(App $a, &$s)
if (!local_user()) { if (!local_user()) {
return; return;
} }
$user = User::getById(local_user());
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/statusnet/statusnet.css' . '" media="all" />' . "\r\n"; DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/statusnet/statusnet.css' . '" media="all" />' . "\r\n";
/* * * /* * *
* 1) Check that we have a base api url and a consumer key & secret * 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 .= '<div id="statusnet-info" ><img id="statusnet-avatar" src="' . $details->profile_image_url . '" /><p id="statusnet-info-block">' . DI::l10n()->t('Currently connected to: ') . '<a href="' . $details->statusnet_profile_url . '" target="_statusnet">' . $details->screen_name . '</a><br /><em>' . $details->description . '</em></p></div>'; $s .= '<div id="statusnet-info" ><img id="statusnet-avatar" src="' . $details->profile_image_url . '" /><p id="statusnet-info-block">' . DI::l10n()->t('Currently connected to: ') . '<a href="' . $details->statusnet_profile_url . '" target="_statusnet">' . $details->screen_name . '</a><br /><em>' . $details->description . '</em></p></div>';
} }
$s .= '<p>' . DI::l10n()->t('If enabled all your <strong>public</strong> 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.') . '</p>'; $s .= '<p>' . DI::l10n()->t('If enabled all your <strong>public</strong> 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.') . '</p>';
if ($a->user['hidewall']) { if ($user['hidewall']) {
$s .= '<p>' . DI::l10n()->t('<strong>Note</strong>: Due your privacy settings (<em>Hide your profile details from unknown viewers?</em>) 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.') . '</p>'; $s .= '<p>' . DI::l10n()->t('<strong>Note</strong>: Due your privacy settings (<em>Hide your profile details from unknown viewers?</em>) 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.') . '</p>';
} }
$s .= '<div id="statusnet-enable-wrapper">'; $s .= '<div id="statusnet-enable-wrapper">';

View File

@ -146,7 +146,7 @@ function twitter_follow(App $a, array &$contact)
$nickname = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $contact["url"]); $nickname = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $contact["url"]);
$nickname = str_replace("@twitter.com", "", $nickname); $nickname = str_replace("@twitter.com", "", $nickname);
$uid = $a->user["uid"]; $uid = $a->getLoggedInUserId();
$ckey = DI::config()->get('twitter', 'consumerkey'); $ckey = DI::config()->get('twitter', 'consumerkey');
$csecret = DI::config()->get('twitter', 'consumersecret'); $csecret = DI::config()->get('twitter', 'consumersecret');
@ -266,6 +266,9 @@ function twitter_settings(App $a, &$s)
if (!local_user()) { if (!local_user()) {
return; return;
} }
$user = User::getById(local_user());
DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/twitter/twitter.css' . '" media="all" />' . "\r\n"; DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/twitter/twitter.css' . '" media="all" />' . "\r\n";
/* * * /* * *
* 1) Check that we have global consumer key & secret * 1) Check that we have global consumer key & secret
@ -356,7 +359,7 @@ function twitter_settings(App $a, &$s)
$s .= Renderer::replaceMacros($field_checkbox, [ $s .= Renderer::replaceMacros($field_checkbox, [
'$field' => ['twitter-enable', DI::l10n()->t('Allow posting to Twitter'), $enabled, DI::l10n()->t('If enabled all your <strong>public</strong> 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.')] '$field' => ['twitter-enable', DI::l10n()->t('Allow posting to Twitter'), $enabled, DI::l10n()->t('If enabled all your <strong>public</strong> 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 ($user['hidewall']) {
$s .= '<p>' . DI::l10n()->t('<strong>Note</strong>: Due to your privacy settings (<em>Hide your profile details from unknown viewers?</em>) 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.') . '</p>'; $s .= '<p>' . DI::l10n()->t('<strong>Note</strong>: Due to your privacy settings (<em>Hide your profile details from unknown viewers?</em>) 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.') . '</p>';
} }
$s .= Renderer::replaceMacros($field_checkbox, [ $s .= Renderer::replaceMacros($field_checkbox, [

View File

@ -460,5 +460,5 @@ function windowsphonepush_login(App $a)
DI::auth()->setForUser($a, $record); DI::auth()->setForUser($a, $record);
DI::session()->set('allow_api', true); DI::session()->set('allow_api', true);
Hook::callAll('logged_in', $a->user); Hook::callAll('logged_in', $record);
} }

View File

@ -153,7 +153,7 @@ function xmpp_converse(App $a)
DI::pConfig()->set(local_user(), "xmpp", "password", $password); DI::pConfig()->set(local_user(), "xmpp", "password", $password);
} }
$jid = $a->user["nickname"] . "@" . DI::baseUrl()->getHostname() . "/converse-" . Strings::getRandomHex(5); $jid = $a->getLoggedInUserNickname() . "@" . DI::baseUrl()->getHostname() . "/converse-" . Strings::getRandomHex(5);
$auto_login = "auto_login: true, $auto_login = "auto_login: true,
authentication: 'login', authentication: 'login',