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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -38,11 +38,11 @@ class Delegation extends BaseModule
{ {
protected function post(array $request = []) protected function post(array $request = [])
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
return; return;
} }
$uid = local_user(); $uid = Session::getLocalUser();
$orig_record = User::getById(DI::app()->getLoggedInUserId()); $orig_record = User::getById(DI::app()->getLoggedInUserId());
if (DI::session()->get('submanage')) { if (DI::session()->get('submanage')) {
@ -114,11 +114,11 @@ class Delegation extends BaseModule
protected function content(array $request = []): string protected function content(array $request = []): string
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
throw new ForbiddenException(DI::l10n()->t('Permission denied.')); 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 //getting additinal information for each identity
foreach ($identities as $key => $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.')); 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::findPeople();
DI::page()['aside'] .= Widget::follow(); 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).')); DI::sysmsg()->addNotice(DI::l10n()->t('No entries (some entries may be hidden).'));
} else { } else {
foreach ($profiles['entries'] as $entry) { foreach ($profiles['entries'] as $entry) {
$contact = Model\Contact::getByURLForUser($entry['url'], local_user()); $contact = Model\Contact::getByURLForUser($entry['url'], Session::getLocalUser());
if (!empty($contact)) { if (!empty($contact)) {
$entries[] = Contact::getContactTemplateVars($contact); $entries[] = Contact::getContactTemplateVars($contact);
} }

View file

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

View file

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

View file

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

View file

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

View file

@ -36,7 +36,7 @@ class HCard extends BaseModule
{ {
protected function content(array $request = []): string 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 // A logged in user views a profile of a user
$nickname = DI::app()->getLoggedInUserNickname(); $nickname = DI::app()->getLoggedInUserNickname();
} elseif (empty($this->parameters['action'])) { } elseif (empty($this->parameters['action'])) {

View file

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

View file

@ -24,6 +24,7 @@ namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Search; use Friendica\Core\Search;
use Friendica\Core\Session;
use Friendica\DI; use Friendica\DI;
use Friendica\Model; use Friendica\Model;
use Friendica\Model\User; use Friendica\Model\User;
@ -38,7 +39,7 @@ class Invite extends BaseModule
{ {
protected function post(array $request = []) protected function post(array $request = [])
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
} }
@ -52,7 +53,7 @@ class Invite extends BaseModule
$max_invites = 50; $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) { if ($current_invites > $max_invites) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Total invitation limit exceeded.')); 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')) { if ($config->get('system', 'invitation_only')) {
$invitation_only = true; $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())) { if ((!$invites_remaining) && (!$app->isSiteAdmin())) {
throw new HTTPException\ForbiddenException(); throw new HTTPException\ForbiddenException();
} }
} }
$user = User::getById(local_user()); $user = User::getById(Session::getLocalUser());
foreach ($recipients as $recipient) { foreach ($recipients as $recipient) {
$recipient = trim($recipient); $recipient = trim($recipient);
@ -90,7 +91,7 @@ class Invite extends BaseModule
if (!$app->isSiteAdmin()) { if (!$app->isSiteAdmin()) {
$invites_remaining--; $invites_remaining--;
if ($invites_remaining >= 0) { 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 { } else {
return; return;
} }
@ -112,7 +113,7 @@ class Invite extends BaseModule
if ($res) { if ($res) {
$total++; $total++;
$current_invites++; $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) { if ($current_invites > $max_invites) {
DI::sysmsg()->addNotice(DI::l10n()->t('Invitation limit exceeded. Please contact your site administrator.')); DI::sysmsg()->addNotice(DI::l10n()->t('Invitation limit exceeded. Please contact your site administrator.'));
return; return;
@ -127,7 +128,7 @@ class Invite extends BaseModule
protected function content(array $request = []): string protected function content(array $request = []): string
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
} }
@ -138,7 +139,7 @@ class Invite extends BaseModule
if ($config->get('system', 'invitation_only')) { if ($config->get('system', 'invitation_only')) {
$inviteOnly = true; $inviteOnly = true;
$x = DI::pConfig()->get(local_user(), 'system', 'invites_remaining'); $x = DI::pConfig()->get(Session::getLocalUser(), 'system', 'invites_remaining');
if ((!$x) && (!$app->isSiteAdmin())) { if ((!$x) && (!$app->isSiteAdmin())) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('You have no more invitations available')); 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\App;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Model\Contact; use Friendica\Model\Contact;
@ -90,8 +91,8 @@ class Magic extends BaseModule
} }
// OpenWebAuth // OpenWebAuth
if (local_user() && $owa) { if (Session::getLocalUser() && $owa) {
$user = User::getById(local_user()); $user = User::getById(Session::getLocalUser());
// Extract the basepath // Extract the basepath
// NOTE: we need another solution because this does only work // NOTE: we need another solution because this does only work

View file

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

View file

@ -22,6 +22,7 @@
namespace Friendica\Module; namespace Friendica\Module;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; 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))); 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') { if ($type == 'item') {
$fields = ['uid', 'psid', 'private', 'uri-id']; $fields = ['uid', 'psid', 'private', 'uri-id'];
$model = Post::selectFirst($fields, $condition); $model = Post::selectFirst($fields, $condition);
@ -177,7 +178,7 @@ class PermissionTooltip extends \Friendica\BaseModule
private function fetchReceivers(int $uriId): string private function fetchReceivers(int $uriId): string
{ {
$own_url = ''; $own_url = '';
$uid = local_user(); $uid = Session::getLocalUser();
if ($uid) { if ($uid) {
$owner = User::getOwnerDataById($uid); $owner = User::getOwnerDataById($uid);
if (!empty($owner['url'])) { if (!empty($owner['url'])) {

View file

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

View file

@ -23,6 +23,7 @@ namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI; use Friendica\DI;
use Friendica\Network\HTTPClient\Client\HttpClientAccept; use Friendica\Network\HTTPClient\Client\HttpClientAccept;
@ -74,7 +75,7 @@ class Proxy extends BaseModule
throw new \Friendica\Network\HTTPException\BadRequestException(); 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']]); Logger::debug('Redirecting not logged in user to original address', ['url' => $request['url']]);
System::externalRedirect($request['url']); System::externalRedirect($request['url']);
} }
@ -83,7 +84,7 @@ class Proxy extends BaseModule
$request['url'] = str_replace(' ', '+', $request['url']); $request['url'] = str_replace(' ', '+', $request['url']);
// Fetch the content with the local user // 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(); $img_str = $fetchResult->getBody();
if (!$fetchResult->isSuccess() || empty($img_str)) { if (!$fetchResult->isSuccess() || empty($img_str)) {
@ -92,7 +93,7 @@ class Proxy extends BaseModule
// stop. // 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); $mime = Images::getMimeTypeByData($img_str);

View file

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