old boot.php functions replaced in src/module

This commit is contained in:
Michael 2022-10-19 04:31:58 +00:00 committed by Hypolite Petovan
parent ba9f145ef7
commit d2da2492b7
21 changed files with 103 additions and 86 deletions

View File

@ -28,6 +28,7 @@ use Friendica\Content\Nav;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
@ -42,7 +43,7 @@ class Apps extends BaseModule
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$privateaddons = $config->get('config', 'private_addons');
if ($privateaddons === "1" && !local_user()) {
if ($privateaddons === "1" && !Session::getLocalUser()) {
$baseUrl->redirect();
}
}

View File

@ -52,7 +52,7 @@ abstract class BaseAdmin extends BaseModule
*/
public static function checkAdminAccess(bool $interactive = false)
{
if (!local_user()) {
if (!Session::getLocalUser()) {
if ($interactive) {
DI::sysmsg()->addNotice(DI::l10n()->t('Please login to continue.'));
Session::set('return_path', DI::args()->getQueryString());

View File

@ -28,6 +28,7 @@ use Friendica\BaseModule;
use Friendica\Content\Pager;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Navigation\Notifications\ValueObject\FormattedNotify;
use Friendica\Network\HTTPException\ForbiddenException;
@ -93,7 +94,7 @@ abstract class BaseNotifications extends BaseModule
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new ForbiddenException($this->t('Permission denied.'));
}

View File

@ -25,6 +25,7 @@ use Friendica\BaseModule;
use Friendica\Content\Pager;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model;
use Friendica\Network\HTTPException;
@ -82,10 +83,10 @@ class BaseSearch extends BaseModule
$search = Network::convertToIdn($search);
if (DI::mode()->isMobile()) {
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
@ -125,7 +126,7 @@ class BaseSearch extends BaseModule
// in case the result is a contact result, add a contact-specific entry
if ($result instanceof ContactResult) {
$contact = Model\Contact::getByURLForUser($result->getUrl(), local_user());
$contact = Model\Contact::getByURLForUser($result->getUrl(), Session::getLocalUser());
if (!empty($contact)) {
$entries[] = Contact::getContactTemplateVars($contact);
}

View File

@ -23,6 +23,7 @@ namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Content\PageInfo;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\Security\Login;
use Friendica\Network\HTTPException;
@ -40,7 +41,7 @@ class Bookmarklet extends BaseModule
$config = DI::config();
if (!local_user()) {
if (!Session::getLocalUser()) {
$output = '<h2>' . DI::l10n()->t('Login') . '</h2>';
$output .= Login::form(DI::args()->getQueryString(), intval($config->get('config', 'register_policy')) === Register::CLOSED ? false : true);
return $output;

View File

@ -28,6 +28,7 @@ use Friendica\Content\Pager;
use Friendica\Content\Widget;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
@ -59,12 +60,12 @@ class Contact extends BaseModule
self::checkFormSecurityTokenRedirectOnError($redirectUrl, 'contact_batch_actions');
$orig_records = Model\Contact::selectToArray(['id', 'uid'], ['id' => $_POST['contact_batch'], 'uid' => [0, local_user()], 'self' => false, 'deleted' => false]);
$orig_records = Model\Contact::selectToArray(['id', 'uid'], ['id' => $_POST['contact_batch'], 'uid' => [0, Session::getLocalUser()], 'self' => false, 'deleted' => false]);
$count_actions = 0;
foreach ($orig_records as $orig_record) {
$cdata = Model\Contact::getPublicAndUserContactID($orig_record['id'], local_user());
if (empty($cdata) || public_contact() === $cdata['public']) {
$cdata = Model\Contact::getPublicAndUserContactID($orig_record['id'], Session::getLocalUser());
if (empty($cdata) || Session::getPublicContact() === $cdata['public']) {
// No action available on your own contact
continue;
}
@ -75,7 +76,7 @@ class Contact extends BaseModule
}
if (!empty($_POST['contacts_batch_block'])) {
self::toggleBlockContact($cdata['public'], local_user());
self::toggleBlockContact($cdata['public'], Session::getLocalUser());
$count_actions++;
}
@ -93,7 +94,7 @@ class Contact extends BaseModule
protected function post(array $request = [])
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return;
}
@ -113,7 +114,7 @@ class Contact extends BaseModule
*/
public static function updateContactFromPoll(int $contact_id)
{
$contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false]);
$contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => Session::getLocalUser(), 'deleted' => false]);
if (!DBA::isResult($contact)) {
return;
}
@ -153,13 +154,13 @@ class Contact extends BaseModule
*/
private static function toggleIgnoreContact(int $contact_id)
{
$ignored = !Model\Contact\User::isIgnored($contact_id, local_user());
Model\Contact\User::setIgnored($contact_id, local_user(), $ignored);
$ignored = !Model\Contact\User::isIgnored($contact_id, Session::getLocalUser());
Model\Contact\User::setIgnored($contact_id, Session::getLocalUser(), $ignored);
}
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return Login::form($_SERVER['REQUEST_URI']);
}
@ -203,7 +204,7 @@ class Contact extends BaseModule
$_SESSION['return_path'] = DI::args()->getQueryString();
$sql_values = [local_user()];
$sql_values = [Session::getLocalUser()];
// @TODO: Replace with parameter from router
$type = DI::args()->getArgv()[1] ?? '';
@ -229,7 +230,7 @@ class Contact extends BaseModule
$sql_extra = " AND `pending` AND NOT `archive` AND NOT `failed` AND ((`rel` = ?)
OR `id` IN (SELECT `contact-id` FROM `intro` WHERE `intro`.`uid` = ? AND NOT `ignore`))";
$sql_values[] = Model\Contact::SHARING;
$sql_values[] = local_user();
$sql_values[] = Session::getLocalUser();
break;
default:
$sql_extra = " AND NOT `archive` AND NOT `blocked` AND NOT `pending`";
@ -298,8 +299,8 @@ class Contact extends BaseModule
$stmt = DBA::select('contact', [], $condition, ['order' => ['name'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]]);
while ($contact = DBA::fetch($stmt)) {
$contact['blocked'] = Model\Contact\User::isBlocked($contact['id'], local_user());
$contact['readonly'] = Model\Contact\User::isIgnored($contact['id'], local_user());
$contact['blocked'] = Model\Contact\User::isBlocked($contact['id'], Session::getLocalUser());
$contact['readonly'] = Model\Contact\User::isIgnored($contact['id'], Session::getLocalUser());
$contacts[] = self::getContactTemplateVars($contact);
}
DBA::close($stmt);
@ -423,7 +424,7 @@ class Contact extends BaseModule
public static function getTabsHTML(array $contact, int $active_tab)
{
$cid = $pcid = $contact['id'];
$data = Model\Contact::getPublicAndUserContactID($contact['id'], local_user());
$data = Model\Contact::getPublicAndUserContactID($contact['id'], Session::getLocalUser());
if (!empty($data['user']) && ($contact['id'] == $data['public'])) {
$cid = $data['user'];
} elseif (!empty($data['public'])) {
@ -499,8 +500,8 @@ class Contact extends BaseModule
{
$alt_text = '';
if (!empty($contact['url']) && isset($contact['uid']) && ($contact['uid'] == 0) && local_user()) {
$personal = Model\Contact::getByURL($contact['url'], false, ['uid', 'rel', 'self'], local_user());
if (!empty($contact['url']) && isset($contact['uid']) && ($contact['uid'] == 0) && Session::getLocalUser()) {
$personal = Model\Contact::getByURL($contact['url'], false, ['uid', 'rel', 'self'], Session::getLocalUser());
if (!empty($personal)) {
$contact['uid'] = $personal['uid'];
$contact['rel'] = $personal['rel'];
@ -508,7 +509,7 @@ class Contact extends BaseModule
}
}
if (!empty($contact['uid']) && !empty($contact['rel']) && local_user() == $contact['uid']) {
if (!empty($contact['uid']) && !empty($contact['rel']) && Session::getLocalUser() == $contact['uid']) {
switch ($contact['rel']) {
case Model\Contact::FRIEND:
$alt_text = DI::l10n()->t('Mutual Friendship');

View File

@ -38,11 +38,11 @@ class Delegation extends BaseModule
{
protected function post(array $request = [])
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return;
}
$uid = local_user();
$uid = Session::getLocalUser();
$orig_record = User::getById(DI::app()->getLoggedInUserId());
if (DI::session()->get('submanage')) {
@ -114,11 +114,11 @@ class Delegation extends BaseModule
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$identities = User::identities(DI::session()->get('submanage', local_user()));
$identities = User::identities(DI::session()->get('submanage', Session::getLocalUser()));
//getting additinal information for each identity
foreach ($identities as $key => $identity) {

View File

@ -49,7 +49,7 @@ class Directory extends BaseModule
throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.'));
}
if (local_user()) {
if (Session::getLocalUser()) {
DI::page()['aside'] .= Widget::findPeople();
DI::page()['aside'] .= Widget::follow();
}
@ -75,7 +75,7 @@ class Directory extends BaseModule
DI::sysmsg()->addNotice(DI::l10n()->t('No entries (some entries may be hidden).'));
} else {
foreach ($profiles['entries'] as $entry) {
$contact = Model\Contact::getByURLForUser($entry['url'], local_user());
$contact = Model\Contact::getByURLForUser($entry['url'], Session::getLocalUser());
if (!empty($contact)) {
$entries[] = Contact::getContactTemplateVars($contact);
}

View File

@ -22,6 +22,7 @@
namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Protocol\Feed as ProtocolFeed;
@ -46,7 +47,7 @@ class Feed extends BaseModule
protected function rawContent(array $request = [])
{
$last_update = $this->getRequestValue($request, 'last_update', '');
$nocache = !empty($request['nocache']) && local_user();
$nocache = !empty($request['nocache']) && Session::getLocalUser();
$type = null;
// @TODO: Replace with parameter from router

View File

@ -22,6 +22,7 @@
namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model\Contact;
@ -33,7 +34,7 @@ class FollowConfirm extends BaseModule
protected function post(array $request = [])
{
parent::post($request);
$uid = local_user();
$uid = Session::getLocalUser();
if (!$uid) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return;
@ -43,7 +44,7 @@ class FollowConfirm extends BaseModule
$duplex = intval($_POST['duplex'] ?? 0);
$hidden = intval($_POST['hidden'] ?? 0);
$intro = DI::intro()->selectOneById($intro_id, local_user());
$intro = DI::intro()->selectOneById($intro_id, Session::getLocalUser());
Contact\Introduction::confirm($intro, $duplex, $hidden);
DI::intro()->delete($intro);

View File

@ -26,6 +26,7 @@ use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\Worker;
use Friendica\Database\Database;
use Friendica\DI;
@ -53,7 +54,7 @@ class FriendSuggest extends BaseModule
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new ForbiddenException($this->t('Permission denied.'));
}
@ -67,7 +68,7 @@ class FriendSuggest extends BaseModule
$cid = intval($this->parameters['contact']);
// We do query the "uid" as well to ensure that it is our contact
if (!$this->dba->exists('contact', ['id' => $cid, 'uid' => local_user()])) {
if (!$this->dba->exists('contact', ['id' => $cid, 'uid' => Session::getLocalUser()])) {
throw new NotFoundException($this->t('Contact not found.'));
}
@ -77,7 +78,7 @@ class FriendSuggest extends BaseModule
}
// We do query the "uid" as well to ensure that it is our contact
$contact = $this->dba->selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => local_user()]);
$contact = $this->dba->selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => Session::getLocalUser()]);
if (empty($contact)) {
DI::sysmsg()->addNotice($this->t('Suggested contact not found.'));
return;
@ -86,7 +87,7 @@ class FriendSuggest extends BaseModule
$note = Strings::escapeHtml(trim($_POST['note'] ?? ''));
$suggest = $this->friendSuggestRepo->save($this->friendSuggestFac->createNew(
local_user(),
Session::getLocalUser(),
$cid,
$contact['name'],
$contact['url'],
@ -104,7 +105,7 @@ class FriendSuggest extends BaseModule
{
$cid = intval($this->parameters['contact']);
$contact = $this->dba->selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
$contact = $this->dba->selectFirst('contact', [], ['id' => $cid, 'uid' => Session::getLocalUser()]);
if (empty($contact)) {
DI::sysmsg()->addNotice($this->t('Contact not found.'));
$this->baseUrl->redirect();
@ -120,7 +121,7 @@ class FriendSuggest extends BaseModule
AND NOT `archive`
AND NOT `deleted`
AND `notify` != ""',
local_user(),
Session::getLocalUser(),
$cid,
Protocol::DFRN,
]);

View File

@ -23,6 +23,7 @@ namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
@ -38,7 +39,7 @@ class Group extends BaseModule
$this->ajaxPost();
}
if (!local_user()) {
if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect();
}
@ -48,9 +49,9 @@ class Group extends BaseModule
BaseModule::checkFormSecurityTokenRedirectOnError('/group/new', 'group_edit');
$name = trim($request['groupname']);
$r = Model\Group::create(local_user(), $name);
$r = Model\Group::create(Session::getLocalUser(), $name);
if ($r) {
$r = Model\Group::getIdByName(local_user(), $name);
$r = Model\Group::getIdByName(Session::getLocalUser(), $name);
if ($r) {
DI::baseUrl()->redirect('group/' . $r);
}
@ -64,7 +65,7 @@ class Group extends BaseModule
if ((DI::args()->getArgc() == 2) && intval(DI::args()->getArgv()[1])) {
BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_edit');
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => local_user()]);
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => Session::getLocalUser()]);
if (!DBA::isResult($group)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
DI::baseUrl()->redirect('contact');
@ -81,7 +82,7 @@ class Group extends BaseModule
public function ajaxPost()
{
try {
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new \Exception(DI::l10n()->t('Permission denied.'), 403);
}
@ -89,12 +90,12 @@ class Group extends BaseModule
$group_id = $this->parameters['group'];
$contact_id = $this->parameters['contact'];
if (!Model\Group::exists($group_id, local_user())) {
if (!Model\Group::exists($group_id, Session::getLocalUser())) {
throw new \Exception(DI::l10n()->t('Unknown group.'), 404);
}
// @TODO Backward compatibility with user contacts, remove by version 2022.03
$cdata = Model\Contact::getPublicAndUserContactID($contact_id, local_user());
$cdata = Model\Contact::getPublicAndUserContactID($contact_id, Session::getLocalUser());
if (empty($cdata['public'])) {
throw new \Exception(DI::l10n()->t('Contact not found.'), 404);
}
@ -144,7 +145,7 @@ class Group extends BaseModule
{
$change = false;
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new \Friendica\Network\HTTPException\ForbiddenException();
}
@ -159,7 +160,7 @@ class Group extends BaseModule
}
// Switch to text mode interface if we have more than 'n' contacts or group members
$switchtotext = DI::pConfig()->get(local_user(), 'system', 'groupedit_image_limit');
$switchtotext = DI::pConfig()->get(Session::getLocalUser(), 'system', 'groupedit_image_limit');
if (is_null($switchtotext)) {
$switchtotext = DI::config()->get('system', 'groupedit_image_limit', 200);
}
@ -211,7 +212,7 @@ class Group extends BaseModule
// @TODO: Replace with parameter from router
if (intval(DI::args()->getArgv()[2])) {
if (!Model\Group::exists(DI::args()->getArgv()[2], local_user())) {
if (!Model\Group::exists(DI::args()->getArgv()[2], Session::getLocalUser())) {
DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
DI::baseUrl()->redirect('contact');
}
@ -227,14 +228,14 @@ class Group extends BaseModule
if ((DI::args()->getArgc() > 2) && intval(DI::args()->getArgv()[1]) && intval(DI::args()->getArgv()[2])) {
BaseModule::checkFormSecurityTokenForbiddenOnError('group_member_change', 't');
if (DBA::exists('contact', ['id' => DI::args()->getArgv()[2], 'uid' => local_user(), 'self' => false, 'pending' => false, 'blocked' => false])) {
if (DBA::exists('contact', ['id' => DI::args()->getArgv()[2], 'uid' => Session::getLocalUser(), 'self' => false, 'pending' => false, 'blocked' => false])) {
$change = intval(DI::args()->getArgv()[2]);
}
}
// @TODO: Replace with parameter from router
if ((DI::args()->getArgc() > 1) && intval(DI::args()->getArgv()[1])) {
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => local_user(), 'deleted' => false]);
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => Session::getLocalUser(), 'deleted' => false]);
if (!DBA::isResult($group)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
DI::baseUrl()->redirect('contact');
@ -317,11 +318,11 @@ class Group extends BaseModule
}
if ($nogroup) {
$contacts = Model\Contact\Group::listUngrouped(local_user());
$contacts = Model\Contact\Group::listUngrouped(Session::getLocalUser());
} else {
$contacts_stmt = DBA::select('contact', [],
['rel' => [Model\Contact::FOLLOWER, Model\Contact::FRIEND, Model\Contact::SHARING],
'uid' => local_user(), 'pending' => false, 'blocked' => false, 'failed' => false, 'self' => false],
'uid' => Session::getLocalUser(), 'pending' => false, 'blocked' => false, 'failed' => false, 'self' => false],
['order' => ['name']]
);
$contacts = DBA::toArray($contacts_stmt);

View File

@ -36,7 +36,7 @@ class HCard extends BaseModule
{
protected function content(array $request = []): string
{
if ((local_user()) && ($this->parameters['action'] ?? '') === 'view') {
if ((Session::getLocalUser()) && ($this->parameters['action'] ?? '') === 'view') {
// A logged in user views a profile of a user
$nickname = DI::app()->getLoggedInUserNickname();
} elseif (empty($this->parameters['action'])) {

View File

@ -24,6 +24,7 @@ namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\Security\Login;
@ -42,7 +43,7 @@ class Home extends BaseModule
Hook::callAll('home_init', $ret);
if (local_user() && ($app->getLoggedInUserNickname())) {
if (Session::getLocalUser() && ($app->getLoggedInUserNickname())) {
DI::baseUrl()->redirect('network');
}

View File

@ -24,6 +24,7 @@ namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model;
use Friendica\Model\User;
@ -38,7 +39,7 @@ class Invite extends BaseModule
{
protected function post(array $request = [])
{
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
@ -52,7 +53,7 @@ class Invite extends BaseModule
$max_invites = 50;
}
$current_invites = intval(DI::pConfig()->get(local_user(), 'system', 'sent_invites'));
$current_invites = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'sent_invites'));
if ($current_invites > $max_invites) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Total invitation limit exceeded.'));
}
@ -67,13 +68,13 @@ class Invite extends BaseModule
if ($config->get('system', 'invitation_only')) {
$invitation_only = true;
$invites_remaining = DI::pConfig()->get(local_user(), 'system', 'invites_remaining');
$invites_remaining = DI::pConfig()->get(Session::getLocalUser(), 'system', 'invites_remaining');
if ((!$invites_remaining) && (!$app->isSiteAdmin())) {
throw new HTTPException\ForbiddenException();
}
}
$user = User::getById(local_user());
$user = User::getById(Session::getLocalUser());
foreach ($recipients as $recipient) {
$recipient = trim($recipient);
@ -90,7 +91,7 @@ class Invite extends BaseModule
if (!$app->isSiteAdmin()) {
$invites_remaining--;
if ($invites_remaining >= 0) {
DI::pConfig()->set(local_user(), 'system', 'invites_remaining', $invites_remaining);
DI::pConfig()->set(Session::getLocalUser(), 'system', 'invites_remaining', $invites_remaining);
} else {
return;
}
@ -112,7 +113,7 @@ class Invite extends BaseModule
if ($res) {
$total++;
$current_invites++;
DI::pConfig()->set(local_user(), 'system', 'sent_invites', $current_invites);
DI::pConfig()->set(Session::getLocalUser(), 'system', 'sent_invites', $current_invites);
if ($current_invites > $max_invites) {
DI::sysmsg()->addNotice(DI::l10n()->t('Invitation limit exceeded. Please contact your site administrator.'));
return;
@ -127,7 +128,7 @@ class Invite extends BaseModule
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
@ -138,7 +139,7 @@ class Invite extends BaseModule
if ($config->get('system', 'invitation_only')) {
$inviteOnly = true;
$x = DI::pConfig()->get(local_user(), 'system', 'invites_remaining');
$x = DI::pConfig()->get(Session::getLocalUser(), 'system', 'invites_remaining');
if ((!$x) && (!$app->isSiteAdmin())) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('You have no more invitations available'));
}

View File

@ -24,6 +24,7 @@ namespace Friendica\Module;
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\Database;
use Friendica\Model\Contact;
@ -90,8 +91,8 @@ class Magic extends BaseModule
}
// OpenWebAuth
if (local_user() && $owa) {
$user = User::getById(local_user());
if (Session::getLocalUser() && $owa) {
$user = User::getById(Session::getLocalUser());
// Extract the basepath
// NOTE: we need another solution because this does only work

View File

@ -22,6 +22,7 @@
namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
@ -42,7 +43,7 @@ class NoScrape extends BaseModule
if (isset($this->parameters['nick'])) {
// Get infos about a specific nick (public)
$which = $this->parameters['nick'];
} elseif (local_user() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') {
} elseif (Session::getLocalUser() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') {
// view infos about a known profile (needs a login)
$which = $a->getLoggedInUserNickname();
} else {

View File

@ -22,6 +22,7 @@
namespace Friendica\Module;
use Friendica\Core\Hook;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
@ -49,7 +50,7 @@ class PermissionTooltip extends \Friendica\BaseModule
throw new HTTPException\BadRequestException(DI::l10n()->t('Wrong type "%s", expected one of: %s', $type, implode(', ', $expectedTypes)));
}
$condition = ['id' => $referenceId, 'uid' => [0, local_user()]];
$condition = ['id' => $referenceId, 'uid' => [0, Session::getLocalUser()]];
if ($type == 'item') {
$fields = ['uid', 'psid', 'private', 'uri-id'];
$model = Post::selectFirst($fields, $condition);
@ -177,7 +178,7 @@ class PermissionTooltip extends \Friendica\BaseModule
private function fetchReceivers(int $uriId): string
{
$own_url = '';
$uid = local_user();
$uid = Session::getLocalUser();
if ($uid) {
$owner = User::getOwnerDataById($uid);
if (!empty($owner['url'])) {

View File

@ -24,6 +24,7 @@ namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
@ -258,7 +259,7 @@ class Photo extends BaseModule
return MPhoto::getPhoto($matches[1], $matches[2]);
}
return MPhoto::createPhotoForExternalResource($url, (int)local_user(), $media['mimetype'] ?? '');
return MPhoto::createPhotoForExternalResource($url, (int)Session::getLocalUser(), $media['mimetype'] ?? '');
case 'media':
$media = DBA::selectFirst('post-media', ['url', 'mimetype', 'uri-id'], ['id' => $id, 'type' => Post\Media::IMAGE]);
if (empty($media)) {
@ -269,14 +270,14 @@ class Photo extends BaseModule
return MPhoto::getPhoto($matches[1], $matches[2]);
}
return MPhoto::createPhotoForExternalResource($media['url'], (int)local_user(), $media['mimetype']);
return MPhoto::createPhotoForExternalResource($media['url'], (int)Session::getLocalUser(), $media['mimetype']);
case 'link':
$link = DBA::selectFirst('post-link', ['url', 'mimetype'], ['id' => $id]);
if (empty($link)) {
return false;
}
return MPhoto::createPhotoForExternalResource($link['url'], (int)local_user(), $link['mimetype'] ?? '');
return MPhoto::createPhotoForExternalResource($link['url'], (int)Session::getLocalUser(), $link['mimetype'] ?? '');
case 'contact':
$fields = ['uid', 'uri-id', 'url', 'nurl', 'avatar', 'photo', 'xmpp', 'addr', 'network', 'failed', 'updated'];
$contact = Contact::getById($id, $fields);

View File

@ -23,6 +23,7 @@ namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Core\Logger;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
@ -74,7 +75,7 @@ class Proxy extends BaseModule
throw new \Friendica\Network\HTTPException\BadRequestException();
}
if (!local_user()) {
if (!Session::getLocalUser()) {
Logger::debug('Redirecting not logged in user to original address', ['url' => $request['url']]);
System::externalRedirect($request['url']);
}
@ -83,7 +84,7 @@ class Proxy extends BaseModule
$request['url'] = str_replace(' ', '+', $request['url']);
// Fetch the content with the local user
$fetchResult = HTTPSignature::fetchRaw($request['url'], local_user(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE], 'timeout' => 10]);
$fetchResult = HTTPSignature::fetchRaw($request['url'], Session::getLocalUser(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE], 'timeout' => 10]);
$img_str = $fetchResult->getBody();
if (!$fetchResult->isSuccess() || empty($img_str)) {
@ -92,7 +93,7 @@ class Proxy extends BaseModule
// stop.
}
Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => local_user(), 'image' => $request['url']]);
Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => Session::getLocalUser(), 'image' => $request['url']]);
$mime = Images::getMimeTypeByData($img_str);

View File

@ -29,6 +29,7 @@ use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
@ -73,20 +74,20 @@ class Register extends BaseModule
// 'block_extended_register' blocks all registrations, period.
$block = DI::config()->get('system', 'block_extended_register');
if (local_user() && $block) {
if (Session::getLocalUser() && $block) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return '';
}
if (local_user()) {
$user = DBA::selectFirst('user', ['parent-uid'], ['uid' => local_user()]);
if (Session::getLocalUser()) {
$user = DBA::selectFirst('user', ['parent-uid'], ['uid' => Session::getLocalUser()]);
if (!empty($user['parent-uid'])) {
DI::sysmsg()->addNotice(DI::l10n()->t('Only parent users can create additional accounts.'));
return '';
}
}
if (!local_user() && (intval(DI::config()->get('config', 'register_policy')) === self::CLOSED)) {
if (!Session::getLocalUser() && (intval(DI::config()->get('config', 'register_policy')) === self::CLOSED)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return '';
}
@ -108,7 +109,7 @@ class Register extends BaseModule
$photo = $_REQUEST['photo'] ?? '';
$invite_id = $_REQUEST['invite_id'] ?? '';
if (local_user() || DI::config()->get('system', 'no_openid')) {
if (Session::getLocalUser() || DI::config()->get('system', 'no_openid')) {
$fillwith = '';
$fillext = '';
$oidlabel = '';
@ -179,7 +180,7 @@ class Register extends BaseModule
'$form_security_token' => BaseModule::getFormSecurityToken('register'),
'$explicit_content' => DI::config()->get('system', 'explicit_content', false),
'$explicit_content_note' => DI::l10n()->t('Note: This node explicitly contains adult content'),
'$additional' => !empty(local_user()),
'$additional' => !empty(Session::getLocalUser()),
'$parent_password' => ['parent_password', DI::l10n()->t('Parent Password:'), '', DI::l10n()->t('Please enter the password of the parent account to legitimize your request.')]
]);
@ -202,19 +203,19 @@ class Register extends BaseModule
$additional_account = false;
if (!local_user() && !empty($arr['post']['parent_password'])) {
if (!Session::getLocalUser() && !empty($arr['post']['parent_password'])) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return;
} elseif (local_user() && !empty($arr['post']['parent_password'])) {
} elseif (Session::getLocalUser() && !empty($arr['post']['parent_password'])) {
try {
Model\User::getIdFromPasswordAuthentication(local_user(), $arr['post']['parent_password']);
Model\User::getIdFromPasswordAuthentication(Session::getLocalUser(), $arr['post']['parent_password']);
} catch (\Exception $ex) {
DI::sysmsg()->addNotice(DI::l10n()->t("Password doesn't match."));
$regdata = ['nickname' => $arr['post']['nickname'], 'username' => $arr['post']['username']];
DI::baseUrl()->redirect('register?' . http_build_query($regdata));
}
$additional_account = true;
} elseif (local_user()) {
} elseif (Session::getLocalUser()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Please enter your password.'));
$regdata = ['nickname' => $arr['post']['nickname'], 'username' => $arr['post']['username']];
DI::baseUrl()->redirect('register?' . http_build_query($regdata));
@ -262,7 +263,7 @@ class Register extends BaseModule
}
if ($additional_account) {
$user = DBA::selectFirst('user', ['email'], ['uid' => local_user()]);
$user = DBA::selectFirst('user', ['email'], ['uid' => Session::getLocalUser()]);
if (!DBA::isResult($user)) {
DI::sysmsg()->addNotice(DI::l10n()->t('User not found.'));
DI::baseUrl()->redirect('register');
@ -306,7 +307,7 @@ class Register extends BaseModule
}
if ($additional_account) {
DBA::update('user', ['parent-uid' => local_user()], ['uid' => $user['uid']]);
DBA::update('user', ['parent-uid' => Session::getLocalUser()], ['uid' => $user['uid']]);
DI::sysmsg()->addInfo(DI::l10n()->t('The additional account was created.'));
DI::baseUrl()->redirect('delegation');
}