old boot.php functions replaced in /src

This commit is contained in:
Michael 2022-10-19 04:26:41 +00:00 committed by Hypolite Petovan
parent 7fc37832f7
commit ee1acba9eb
22 changed files with 130 additions and 116 deletions

View file

@ -171,7 +171,7 @@ class Conversation
continue;
}
if (public_contact() == $activity['author-id']) {
if (Session::getPublicContact() == $activity['author-id']) {
$conv_responses[$mode][$activity['thr-parent-id']]['self'] = 1;
}
@ -296,7 +296,7 @@ class Conversation
$x['bang'] = $x['bang'] ?? '';
$x['visitor'] = $x['visitor'] ?? 'block';
$x['is_owner'] = $x['is_owner'] ?? true;
$x['profile_uid'] = $x['profile_uid'] ?? local_user();
$x['profile_uid'] = $x['profile_uid'] ?? Session::getLocalUser();
$geotag = !empty($x['allow_location']) ? Renderer::replaceMacros(Renderer::getMarkupTemplate('jot_geotag.tpl'), []) : '';
@ -359,7 +359,7 @@ class Conversation
'$title' => $x['title'] ?? '',
'$placeholdertitle' => $this->l10n->t('Set title'),
'$category' => $x['category'] ?? '',
'$placeholdercategory' => Feature::isEnabled(local_user(), 'categories') ? $this->l10n->t("Categories \x28comma-separated list\x29") : '',
'$placeholdercategory' => Feature::isEnabled(Session::getLocalUser(), 'categories') ? $this->l10n->t("Categories \x28comma-separated list\x29") : '',
'$scheduled_at' => Temporal::getDateTimeField(
new \DateTime(),
new \DateTime('now + 6 months'),
@ -397,7 +397,7 @@ class Conversation
'$browser' => $this->l10n->t('Browser'),
'$compose_link_title' => $this->l10n->t('Open Compose page'),
'$always_open_compose' => $this->pConfig->get(local_user(), 'frio', 'always_open_compose', false),
'$always_open_compose' => $this->pConfig->get(Session::getLocalUser(), 'frio', 'always_open_compose', false),
]);
@ -436,7 +436,7 @@ class Conversation
$this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
$this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
$ssl_state = (local_user() ? true : false);
$ssl_state = (Session::getLocalUser() ? true : false);
$live_update_div = '';
@ -488,11 +488,11 @@ class Conversation
}
}
} elseif ($mode === 'notes') {
$items = $this->addChildren($items, false, $order, local_user(), $mode);
$items = $this->addChildren($items, false, $order, Session::getLocalUser(), $mode);
if (!$update) {
$live_update_div = '<div id="live-notes"></div>' . "\r\n"
. "<script> var profile_uid = " . local_user()
. "<script> var profile_uid = " . Session::getLocalUser()
. "; var netargs = '/?f='; </script>\r\n";
}
} elseif ($mode === 'display') {
@ -526,7 +526,7 @@ class Conversation
$live_update_div = '<div id="live-search"></div>' . "\r\n";
}
$page_dropping = ((local_user() && local_user() == $uid) ? true : false);
$page_dropping = ((Session::getLocalUser() && Session::getLocalUser() == $uid) ? true : false);
if (!$update) {
$_SESSION['return_path'] = $this->args->getQueryString();
@ -546,7 +546,7 @@ class Conversation
'announce' => [],
];
if ($this->pConfig->get(local_user(), 'system', 'hide_dislike')) {
if ($this->pConfig->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
unset($conv_responses['dislike']);
}
@ -564,7 +564,7 @@ class Conversation
$writable = $items[0]['writable'] || ($items[0]['uid'] == 0) && in_array($items[0]['network'], Protocol::FEDERATED);
}
if (!local_user()) {
if (!Session::getLocalUser()) {
$writable = false;
}
@ -597,7 +597,7 @@ class Conversation
$threadsid++;
// prevent private email from leaking.
if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
if ($item['network'] === Protocol::MAIL && Session::getLocalUser() != $item['uid']) {
continue;
}
@ -641,17 +641,17 @@ class Conversation
'announce' => null,
];
if ($this->pConfig->get(local_user(), 'system', 'hide_dislike')) {
if ($this->pConfig->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
unset($likebuttons['dislike']);
}
$body_html = ItemModel::prepareBody($item, true, $preview);
[$categories, $folders] = $this->item->determineCategoriesTerms($item, local_user());
[$categories, $folders] = $this->item->determineCategoriesTerms($item, Session::getLocalUser());
if (!empty($item['title'])) {
$title = $item['title'];
} elseif (!empty($item['content-warning']) && $this->pConfig->get(local_user(), 'system', 'disable_cw', false)) {
} elseif (!empty($item['content-warning']) && $this->pConfig->get(Session::getLocalUser(), 'system', 'disable_cw', false)) {
$title = ucfirst($item['content-warning']);
} else {
$title = '';
@ -745,7 +745,7 @@ class Conversation
$this->builtinActivityPuller($item, $conv_responses);
// Only add what is visible
if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
if ($item['network'] === Protocol::MAIL && Session::getLocalUser() != $item['uid']) {
continue;
}
@ -790,11 +790,11 @@ class Conversation
private function getBlocklist(): array
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return [];
}
$str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get(local_user(), 'system', 'blocked'));
$str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get(Session::getLocalUser(), 'system', 'blocked'));
if (empty($str_blocked)) {
return [];
}
@ -864,7 +864,7 @@ class Conversation
$row['direction'] = ['direction' => 4, 'title' => $this->l10n->t('You subscribed to one or more tags in this post.')];
break;
case ItemModel::PR_ANNOUNCEMENT:
if (!empty($row['causer-id']) && $this->pConfig->get(local_user(), 'system', 'display_resharer')) {
if (!empty($row['causer-id']) && $this->pConfig->get(Session::getLocalUser(), 'system', 'display_resharer')) {
$row['owner-id'] = $row['causer-id'];
$row['owner-link'] = $row['causer-link'];
$row['owner-avatar'] = $row['causer-avatar'];
@ -1216,7 +1216,7 @@ class Conversation
$parents[$i]['children'] = $this->sortItemChildren($parents[$i]['children']);
}
if (!$this->pConfig->get(local_user(), 'system', 'no_smart_threading', 0)) {
if (!$this->pConfig->get(Session::getLocalUser(), 'system', 'no_smart_threading', 0)) {
foreach ($parents as $i => $parent) {
$parents[$i] = $this->smartFlattenConversation($parent);
}

View file

@ -24,6 +24,7 @@ namespace Friendica\Content;
use Friendica\Content\Text\HTML;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
@ -223,7 +224,7 @@ class ForumManager
AND NOT `contact`.`pending` AND NOT `contact`.`archive`
AND `contact`.`uid` = ?
GROUP BY `contact`.`id`",
local_user(), Protocol::DFRN, Protocol::ACTIVITYPUB, Contact::TYPE_COMMUNITY, local_user()
Session::getLocalUser(), Protocol::DFRN, Protocol::ACTIVITYPUB, Contact::TYPE_COMMUNITY, Session::getLocalUser()
);
return DBA::toArray($stmtContacts);

View file

@ -27,6 +27,7 @@ use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
@ -109,7 +110,7 @@ class Item
$categories[] = [
'name' => $savedFolderName,
'url' => $url,
'removeurl' => local_user() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
'removeurl' => Session::getLocalUser() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
'first' => $first,
'last' => false
];
@ -120,12 +121,12 @@ class Item
$categories[count($categories) - 1]['last'] = true;
}
if (local_user() == $uid) {
if (Session::getLocalUser() == $uid) {
foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::FILE) as $savedFolderName) {
$folders[] = [
'name' => $savedFolderName,
'url' => "#",
'removeurl' => local_user() == $uid ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : '',
'removeurl' => Session::getLocalUser() == $uid ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : '',
'first' => $first,
'last' => false
];
@ -331,7 +332,7 @@ class Item
$sub_link = $contact_url = $pm_url = $status_link = '';
$photos_link = $posts_link = $block_link = $ignore_link = '';
if (local_user() && local_user() == $item['uid'] && $item['gravity'] == ItemModel::GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
if (Session::getLocalUser() && Session::getLocalUser() == $item['uid'] && $item['gravity'] == ItemModel::GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
$sub_link = 'javascript:doFollowThread(' . $item['id'] . '); return false;';
}
@ -348,7 +349,7 @@ class Item
$pcid = $item['author-id'];
$network = '';
$rel = 0;
$condition = ['uid' => local_user(), 'uri-id' => $item['author-uri-id']];
$condition = ['uid' => Session::getLocalUser(), 'uri-id' => $item['author-uri-id']];
$contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
if (DBA::isResult($contact)) {
$cid = $contact['id'];
@ -378,7 +379,7 @@ class Item
}
}
if (local_user()) {
if (Session::getLocalUser()) {
$menu = [
$this->l10n->t('Follow Thread') => $sub_link,
$this->l10n->t('View Status') => $status_link,
@ -439,7 +440,7 @@ class Item
return (!($this->activity->match($item['verb'], Activity::FOLLOW) &&
$item['object-type'] === Activity\ObjectType::NOTE &&
empty($item['self']) &&
$item['uid'] == local_user())
$item['uid'] == Session::getLocalUser())
);
}

View file

@ -127,7 +127,7 @@ class Nav
//Don't populate apps_menu if apps are private
$privateapps = DI::config()->get('config', 'private_addons', false);
if (local_user() || !$privateapps) {
if (Session::getLocalUser() || !$privateapps) {
$arr = ['app_menu' => self::$app_menu];
Hook::callAll('app_menu', $arr);
@ -149,7 +149,7 @@ class Nav
*/
private static function getInfo(App $a): array
{
$ssl_state = (bool) local_user();
$ssl_state = (bool) Session::getLocalUser();
/*
* Our network is distributed, and as you visit friends some of the
@ -211,7 +211,7 @@ class Nav
$homelink = DI::session()->get('visitor_home', '');
}
if ((DI::args()->getModuleName() != 'home') && (! (local_user()))) {
if ((DI::args()->getModuleName() != 'home') && (! (Session::getLocalUser()))) {
$nav['home'] = [$homelink, DI::l10n()->t('Home'), '', DI::l10n()->t('Home Page')];
}
@ -229,7 +229,7 @@ class Nav
$nav['apps'] = ['apps', DI::l10n()->t('Apps'), '', DI::l10n()->t('Addon applications, utilities, games')];
}
if (local_user() || !DI::config()->get('system', 'local_search')) {
if (Session::getLocalUser() || !DI::config()->get('system', 'local_search')) {
$nav['search'] = ['search', DI::l10n()->t('Search'), '', DI::l10n()->t('Search site content')];
$nav['searchoption'] = [
@ -252,12 +252,12 @@ class Nav
}
}
if ((local_user() || DI::config()->get('system', 'community_page_style') != Community::DISABLED_VISITOR) &&
if ((Session::getLocalUser() || DI::config()->get('system', 'community_page_style') != Community::DISABLED_VISITOR) &&
!(DI::config()->get('system', 'community_page_style') == Community::DISABLED)) {
$nav['community'] = ['community', DI::l10n()->t('Community'), '', DI::l10n()->t('Conversations on this and other servers')];
}
if (local_user()) {
if (Session::getLocalUser()) {
$nav['events'] = ['events', DI::l10n()->t('Events'), '', DI::l10n()->t('Events and Calendar')];
}
@ -270,7 +270,7 @@ class Nav
}
// The following nav links are only show to logged in users
if (local_user() && !empty($a->getLoggedInUserNickname())) {
if (Session::getLocalUser() && !empty($a->getLoggedInUserNickname())) {
$nav['network'] = ['network', DI::l10n()->t('Network'), '', DI::l10n()->t('Conversations from your friends')];
$nav['home'] = ['profile/' . $a->getLoggedInUserNickname(), DI::l10n()->t('Home'), '', DI::l10n()->t('Your posts and conversations')];
@ -288,7 +288,7 @@ class Nav
$nav['messages']['outbox'] = ['message/sent', DI::l10n()->t('Outbox'), '', DI::l10n()->t('Outbox')];
$nav['messages']['new'] = ['message/new', DI::l10n()->t('New Message'), '', DI::l10n()->t('New Message')];
if (User::hasIdentities(DI::session()->get('submanage') ?: local_user())) {
if (User::hasIdentities(DI::session()->get('submanage') ?: Session::getLocalUser())) {
$nav['delegation'] = ['delegation', DI::l10n()->t('Accounts'), '', DI::l10n()->t('Manage other pages')];
}

View file

@ -22,6 +22,7 @@
namespace Friendica\Content;
use Friendica\Core\Hook;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Util\Strings;
@ -213,7 +214,7 @@ class Smilies
public static function replaceFromArray(string $text, array $smilies, bool $no_images = false): string
{
if (intval(DI::config()->get('system', 'no_smilies'))
|| (local_user() && intval(DI::pConfig()->get(local_user(), 'system', 'no_smilies')))
|| (Session::getLocalUser() && intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_smilies')))
) {
return $text;
}

View file

@ -26,6 +26,7 @@ use Friendica\Core\Cache\Enum\Duration;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
@ -66,7 +67,7 @@ class Widget
$global_dir = Search::getGlobalDirectory();
if (DI::config()->get('system', 'invitation_only')) {
$x = intval(DI::pConfig()->get(local_user(), 'system', 'invites_remaining'));
$x = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'invites_remaining'));
if ($x || DI::app()->isSiteAdmin()) {
DI::page()['aside'] .= '<div class="side-link widget" id="side-invite-remain">'
. DI::l10n()->tt('%d invitation available', '%d invitations available', $x)
@ -195,7 +196,7 @@ class Widget
*/
public static function groups(string $baseurl, string $selected = ''): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return '';
}
@ -204,7 +205,7 @@ class Widget
'ref' => $group['id'],
'name' => $group['name']
];
}, Group::getByUserId(local_user()));
}, Group::getByUserId(Session::getLocalUser()));
return self::filter(
'group',
@ -227,7 +228,7 @@ class Widget
*/
public static function contactRels(string $baseurl, string $selected = ''): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return '';
}
@ -258,13 +259,13 @@ class Widget
*/
public static function networks(string $baseurl, string $selected = ''): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return '';
}
$networks = self::unavailableNetworks();
$query = "`uid` = ? AND NOT `deleted` AND `network` != '' AND NOT `network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")";
$condition = array_merge([$query], array_merge([local_user()], $networks));
$condition = array_merge([$query], array_merge([Session::getLocalUser()], $networks));
$r = DBA::select('contact', ['network'], $condition, ['group_by' => ['network'], 'order' => ['network']]);
@ -299,12 +300,12 @@ class Widget
*/
public static function fileAs(string $baseurl, string $selected = ''): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return '';
}
$terms = [];
foreach (Post\Category::getArray(local_user(), Post\Category::FILE) as $savedFolderName) {
foreach (Post\Category::getArray(Session::getLocalUser(), Post\Category::FILE) as $savedFolderName) {
$terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName];
}
@ -361,11 +362,11 @@ class Widget
*/
public static function commonFriendsVisitor(int $uid, string $nickname): string
{
if (local_user() == $uid) {
if (Session::getLocalUser() == $uid) {
return '';
}
$visitorPCid = local_user() ? Contact::getPublicIdByUserId(local_user()) : remote_user();
$visitorPCid = Session::getLocalUser() ? Contact::getPublicIdByUserId(Session::getLocalUser()) : Session::getRemoteUser();
if (!$visitorPCid) {
return '';
}

View file

@ -23,6 +23,7 @@ namespace Friendica\Content\Widget;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
@ -37,7 +38,7 @@ class SavedSearches
public static function getHTML($return_url, $search = '')
{
$saved = [];
$saved_searches = DBA::select('search', ['id', 'term'], ['uid' => local_user()]);
$saved_searches = DBA::select('search', ['id', 'term'], ['uid' => Session::getLocalUser()]);
while ($saved_search = DBA::fetch($saved_searches)) {
$saved[] = [
'id' => $saved_search['id'],

View file

@ -26,6 +26,7 @@ use Friendica\Content\Text\BBCode;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
@ -64,13 +65,13 @@ class VCard
$photo = Contact::getPhoto($contact);
if (local_user()) {
if (Session::getLocalUser()) {
if ($contact['uid']) {
$id = $contact['id'];
$rel = $contact['rel'];
$pending = $contact['pending'];
} else {
$pcontact = Contact::selectFirst([], ['uid' => local_user(), 'uri-id' => $contact['uri-id']]);
$pcontact = Contact::selectFirst([], ['uid' => Session::getLocalUser(), 'uri-id' => $contact['uri-id']]);
$id = $pcontact['id'] ?? 0;
$rel = $pcontact['rel'] ?? Contact::NOTHING;