Merge pull request #12028 from annando/no-boot-src-module-4

old boot.php functions replaced in src/module (4)
This commit is contained in:
Hypolite Petovan 2022-10-19 09:48:29 -04:00 committed by GitHub
commit 5b2af862d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 1562 additions and 1580 deletions

View file

@ -26,38 +26,3 @@
* communications are free and open and flow between alternate providers as * communications are free and open and flow between alternate providers as
* easily as email does today. * easily as email does today.
*/ */
use Friendica\Core\Session;
/**
* Returns the user id of locally logged in user or false.
*
* @return int|bool user id or false
* @deprecated since version 2022.12, use Core\Session::getLocalUser() instead
*/
function local_user()
{
return Session::getLocalUser();
}
/**
* Returns the public contact id of logged in user or false.
*
* @return int|bool public contact id or false
* @deprecated since version 2022.12, use Core\Session:: getPublicContact() instead
*/
function public_contact()
{
return Session::getPublicContact();
}
/**
* Returns public contact id of authenticated site visitor or false
*
* @return int|bool visitor_id or false
* @deprecated since version 2022.12, use Core\Session:: getRemoteUser() instead
*/
function remote_user()
{
return Session::getRemoteUser();
}

View file

@ -23,6 +23,7 @@ namespace Friendica\Module\Admin\Users;
use Friendica\Content\Pager; use Friendica\Content\Pager;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\User; use Friendica\Model\User;
@ -47,7 +48,7 @@ class Active extends BaseUsers
if (!empty($_POST['page_users_delete'])) { if (!empty($_POST['page_users_delete'])) {
foreach ($users as $uid) { foreach ($users as $uid) {
if (local_user() != $uid) { if (Session::getLocalUser() != $uid) {
User::remove($uid); User::remove($uid);
} else { } else {
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself')); DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
@ -78,7 +79,7 @@ class Active extends BaseUsers
switch ($action) { switch ($action) {
case 'delete': case 'delete':
if (local_user() != $uid) { if (Session::getLocalUser() != $uid) {
self::checkFormSecurityTokenRedirectOnError('admin/users/active', 'admin_users_active', 't'); self::checkFormSecurityTokenRedirectOnError('admin/users/active', 'admin_users_active', 't');
// delete user // delete user
User::remove($uid); User::remove($uid);

View file

@ -23,6 +23,7 @@ namespace Friendica\Module\Admin\Users;
use Friendica\Content\Pager; use Friendica\Content\Pager;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\User; use Friendica\Model\User;
@ -48,7 +49,7 @@ class Blocked extends BaseUsers
if (!empty($_POST['page_users_delete'])) { if (!empty($_POST['page_users_delete'])) {
foreach ($users as $uid) { foreach ($users as $uid) {
if (local_user() != $uid) { if (Session::getLocalUser() != $uid) {
User::remove($uid); User::remove($uid);
} else { } else {
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself')); DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
@ -79,7 +80,7 @@ class Blocked extends BaseUsers
switch ($action) { switch ($action) {
case 'delete': case 'delete':
if (local_user() != $uid) { if (Session::getLocalUser() != $uid) {
self::checkFormSecurityTokenRedirectOnError('/admin/users/blocked', 'admin_users_blocked', 't'); self::checkFormSecurityTokenRedirectOnError('/admin/users/blocked', 'admin_users_blocked', 't');
// delete user // delete user
User::remove($uid); User::remove($uid);

View file

@ -50,7 +50,7 @@ class Contacts extends Module\BaseProfile
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
} }
$is_owner = $profile['uid'] == local_user(); $is_owner = $profile['uid'] == Session::getLocalUser();
if ($profile['hide-friends'] && !$is_owner) { if ($profile['hide-friends'] && !$is_owner) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
@ -60,7 +60,7 @@ class Contacts extends Module\BaseProfile
$o = self::getTabsHTML($a, 'contacts', $is_owner, $profile['nickname'], $profile['hide-friends']); $o = self::getTabsHTML($a, 'contacts', $is_owner, $profile['nickname'], $profile['hide-friends']);
$tabs = self::getContactFilterTabs('profile/' . $nickname, $type, Session::isAuthenticated() && $profile['uid'] != local_user()); $tabs = self::getContactFilterTabs('profile/' . $nickname, $type, Session::isAuthenticated() && $profile['uid'] != Session::getLocalUser());
$condition = [ $condition = [
'uid' => $profile['uid'], 'uid' => $profile['uid'],

View file

@ -21,6 +21,7 @@
namespace Friendica\Module\Profile; namespace Friendica\Module\Profile;
use Friendica\Core\Session;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile as ProfileModel; use Friendica\Model\Profile as ProfileModel;
@ -42,7 +43,7 @@ class Media extends BaseProfile
DI::page()['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n"; DI::page()['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
} }
$is_owner = local_user() == $profile['uid']; $is_owner = Session::getLocalUser() == $profile['uid'];
$o = self::getTabsHTML($a, 'media', $is_owner, $profile['nickname'], $profile['hide-friends']); $o = self::getTabsHTML($a, 'media', $is_owner, $profile['nickname'], $profile['hide-friends']);

View file

@ -84,11 +84,11 @@ class Profile extends BaseProfile
$remote_contact_id = Session::getRemoteContactID($profile['uid']); $remote_contact_id = Session::getRemoteContactID($profile['uid']);
if (DI::config()->get('system', 'block_public') && !local_user() && !$remote_contact_id) { if (DI::config()->get('system', 'block_public') && !Session::getLocalUser() && !$remote_contact_id) {
return Login::form(); return Login::form();
} }
$is_owner = local_user() == $profile['uid']; $is_owner = Session::getLocalUser() == $profile['uid'];
if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact_id) { if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact_id) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.')); throw new HTTPException\ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));
@ -102,7 +102,7 @@ class Profile extends BaseProfile
Nav::setSelected('home'); Nav::setSelected('home');
$is_owner = local_user() == $profile['uid']; $is_owner = Session::getLocalUser() == $profile['uid'];
$o = self::getTabsHTML($a, 'profile', $is_owner, $profile['nickname'], $profile['hide-friends']); $o = self::getTabsHTML($a, 'profile', $is_owner, $profile['nickname'], $profile['hide-friends']);
if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact_id) { if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact_id) {
@ -117,7 +117,7 @@ class Profile extends BaseProfile
$view_as_contact_id = intval($_GET['viewas'] ?? 0); $view_as_contact_id = intval($_GET['viewas'] ?? 0);
$view_as_contacts = Contact::selectToArray(['id', 'name'], [ $view_as_contacts = Contact::selectToArray(['id', 'name'], [
'uid' => local_user(), 'uid' => Session::getLocalUser(),
'rel' => [Contact::FOLLOWER, Contact::SHARING, Contact::FRIEND], 'rel' => [Contact::FOLLOWER, Contact::SHARING, Contact::FRIEND],
'network' => Protocol::DFRN, 'network' => Protocol::DFRN,
'blocked' => false, 'blocked' => false,
@ -247,7 +247,7 @@ class Profile extends BaseProfile
'$submit' => DI::l10n()->t('Submit'), '$submit' => DI::l10n()->t('Submit'),
'$basic' => DI::l10n()->t('Basic'), '$basic' => DI::l10n()->t('Basic'),
'$advanced' => DI::l10n()->t('Advanced'), '$advanced' => DI::l10n()->t('Advanced'),
'$is_owner' => $profile['uid'] == local_user(), '$is_owner' => $profile['uid'] == Session::getLocalUser(),
'$query_string' => DI::args()->getQueryString(), '$query_string' => DI::args()->getQueryString(),
'$basic_fields' => $basic_fields, '$basic_fields' => $basic_fields,
'$custom_fields' => $custom_fields, '$custom_fields' => $custom_fields,
@ -308,8 +308,8 @@ class Profile extends BaseProfile
} }
// site block // site block
$blocked = !local_user() && !$remote_contact_id && DI::config()->get('system', 'block_public'); $blocked = !Session::getLocalUser() && !$remote_contact_id && DI::config()->get('system', 'block_public');
$userblock = !local_user() && !$remote_contact_id && $profile['hidewall']; $userblock = !Session::getLocalUser() && !$remote_contact_id && $profile['hidewall'];
if (!$blocked && !$userblock) { if (!$blocked && !$userblock) {
$keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $profile['pub_keywords'] ?? ''); $keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $profile['pub_keywords'] ?? '');
if (strlen($keywords)) { if (strlen($keywords)) {

View file

@ -24,6 +24,7 @@ namespace Friendica\Module\Profile;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Post; use Friendica\Model\Post;
@ -35,7 +36,7 @@ class Schedule extends BaseProfile
{ {
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.'));
} }
@ -43,7 +44,7 @@ class Schedule extends BaseProfile
throw new HTTPException\BadRequestException(); throw new HTTPException\BadRequestException();
} }
if (!DBA::exists('delayed-post', ['id' => $_REQUEST['delete'], 'uid' => local_user()])) { if (!DBA::exists('delayed-post', ['id' => $_REQUEST['delete'], 'uid' => Session::getLocalUser()])) {
throw new HTTPException\NotFoundException(); throw new HTTPException\NotFoundException();
} }
@ -52,7 +53,7 @@ class Schedule extends BaseProfile
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.'));
} }
@ -61,7 +62,7 @@ class Schedule extends BaseProfile
$o = self::getTabsHTML($a, 'schedule', true, $a->getLoggedInUserNickname(), false); $o = self::getTabsHTML($a, 'schedule', true, $a->getLoggedInUserNickname(), false);
$schedule = []; $schedule = [];
$delayed = DBA::select('delayed-post', [], ['uid' => local_user()]); $delayed = DBA::select('delayed-post', [], ['uid' => Session::getLocalUser()]);
while ($row = DBA::fetch($delayed)) { while ($row = DBA::fetch($delayed)) {
$parameter = Post\Delayed::getParametersForid($row['id']); $parameter = Post\Delayed::getParametersForid($row['id']);
if (empty($parameter)) { if (empty($parameter)) {

View file

@ -92,19 +92,19 @@ class Status extends BaseProfile
$hashtags = $_GET['tag'] ?? ''; $hashtags = $_GET['tag'] ?? '';
if (DI::config()->get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($profile['uid'])) { if (DI::config()->get('system', 'block_public') && !Session::getLocalUser() && !Session::getRemoteContactID($profile['uid'])) {
return Login::form(); return Login::form();
} }
$o = ''; $o = '';
if ($profile['uid'] == local_user()) { if ($profile['uid'] == Session::getLocalUser()) {
Nav::setSelected('home'); Nav::setSelected('home');
} }
$remote_contact = Session::getRemoteContactID($profile['uid']); $remote_contact = Session::getRemoteContactID($profile['uid']);
$is_owner = local_user() == $profile['uid']; $is_owner = Session::getLocalUser() == $profile['uid'];
$last_updated_key = "profile:" . $profile['uid'] . ":" . local_user() . ":" . $remote_contact; $last_updated_key = "profile:" . $profile['uid'] . ":" . Session::getLocalUser() . ":" . $remote_contact;
if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact) { if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact) {
DI::sysmsg()->addNotice(DI::l10n()->t('Access to this profile has been restricted.')); DI::sysmsg()->addNotice(DI::l10n()->t('Access to this profile has been restricted.'));
@ -166,10 +166,10 @@ class Status extends BaseProfile
} }
if (DI::mode()->isMobile()) { if (DI::mode()->isMobile()) {
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network', $itemspage_network = 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 {
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_network', $itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network')); DI::config()->get('system', 'itemspage_network'));
} }
@ -197,9 +197,9 @@ class Status extends BaseProfile
} }
if ($is_owner) { if ($is_owner) {
$unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => local_user()]); $unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]);
if ($unseen) { if ($unseen) {
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]); Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]);
} }
} }

View file

@ -27,6 +27,7 @@ use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Search; use Friendica\Core\Search;
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;
@ -51,7 +52,7 @@ class Acl extends BaseModule
protected function rawContent(array $request = []) protected function rawContent(array $request = [])
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this module.')); throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this module.'));
} }
@ -113,8 +114,8 @@ class Acl extends BaseModule
Logger::info('ACL {action} - {subaction} - start', ['module' => 'acl', 'action' => 'content', 'subaction' => 'search', 'search' => $search, 'type' => $type, 'conversation' => $conv_id]); Logger::info('ACL {action} - {subaction} - start', ['module' => 'acl', 'action' => 'content', 'subaction' => 'search', 'search' => $search, 'type' => $type, 'conversation' => $conv_id]);
$sql_extra = ''; $sql_extra = '';
$condition = ["`uid` = ? AND NOT `deleted` AND NOT `pending` AND NOT `archive`", local_user()]; $condition = ["`uid` = ? AND NOT `deleted` AND NOT `pending` AND NOT `archive`", Session::getLocalUser()];
$condition_group = ["`uid` = ? AND NOT `deleted`", local_user()]; $condition_group = ["`uid` = ? AND NOT `deleted`", Session::getLocalUser()];
if ($search != '') { if ($search != '') {
$sql_extra = "AND `name` LIKE '%%" . DBA::escape($search) . "%%'"; $sql_extra = "AND `name` LIKE '%%" . DBA::escape($search) . "%%'";
@ -176,7 +177,7 @@ class Acl extends BaseModule
GROUP BY `group`.`name`, `group`.`id` GROUP BY `group`.`name`, `group`.`id`
ORDER BY `group`.`name` ORDER BY `group`.`name`
LIMIT ?, ?", LIMIT ?, ?",
local_user(), Session::getLocalUser(),
$start, $start,
$count $count
)); ));
@ -251,7 +252,7 @@ class Acl extends BaseModule
$condition = ["`parent` = ?", $conv_id]; $condition = ["`parent` = ?", $conv_id];
$params = ['order' => ['author-name' => true]]; $params = ['order' => ['author-name' => true]];
$authors = Post::selectForUser(local_user(), ['author-link'], $condition, $params); $authors = Post::selectForUser(Session::getLocalUser(), ['author-link'], $condition, $params);
$item_authors = []; $item_authors = [];
while ($author = Post::fetch($authors)) { while ($author = Post::fetch($authors)) {
$item_authors[$author['author-link']] = $author['author-link']; $item_authors[$author['author-link']] = $author['author-link'];

View file

@ -22,6 +22,7 @@
namespace Friendica\Module\Search; namespace Friendica\Module\Search;
use Friendica\Content\Widget; use Friendica\Content\Widget;
use Friendica\Core\Session;
use Friendica\DI; use Friendica\DI;
use Friendica\Module\BaseSearch; use Friendica\Module\BaseSearch;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
@ -33,7 +34,7 @@ class Directory extends BaseSearch
{ {
protected function content(array $request = []): string protected function content(array $request = []): string
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return Login::form(); return Login::form();
} }

View file

@ -26,6 +26,7 @@ use Friendica\Content\Pager;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
use Friendica\Content\Widget; use Friendica\Content\Widget;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Item; use Friendica\Model\Item;
@ -38,13 +39,13 @@ class Filed extends BaseSearch
{ {
protected function content(array $request = []): string protected function content(array $request = []): string
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
return Login::form(); return Login::form();
} }
DI::page()['aside'] .= Widget::fileAs(DI::args()->getCommand(), $_GET['file'] ?? ''); DI::page()['aside'] .= Widget::fileAs(DI::args()->getCommand(), $_GET['file'] ?? '');
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') { if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl'); $tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
$o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]); $o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
} else { } else {
@ -59,10 +60,10 @@ class Filed extends BaseSearch
} }
if (DI::mode()->isMobile()) { if (DI::mode()->isMobile()) {
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network', $itemspage_network = 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 {
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_network', $itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network')); DI::config()->get('system', 'itemspage_network'));
} }
@ -70,7 +71,7 @@ class Filed extends BaseSearch
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemspage_network); $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemspage_network);
$term_condition = ['type' => Category::FILE, 'uid' => local_user()]; $term_condition = ['type' => Category::FILE, 'uid' => Session::getLocalUser()];
if ($file) { if ($file) {
$term_condition['name'] = $file; $term_condition['name'] = $file;
} }
@ -93,14 +94,14 @@ class Filed extends BaseSearch
if (count($posts) == 0) { if (count($posts) == 0) {
return ''; return '';
} }
$item_condition = ['uid' => [0, local_user()], 'uri-id' => $posts]; $item_condition = ['uid' => [0, Session::getLocalUser()], 'uri-id' => $posts];
$item_params = ['order' => ['uri-id' => true, 'uid' => true]]; $item_params = ['order' => ['uri-id' => true, 'uid' => true]];
$items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $item_condition, $item_params)); $items = Post::toArray(Post::selectForUser(Session::getLocalUser(), Item::DISPLAY_FIELDLIST, $item_condition, $item_params));
$o .= DI::conversation()->create($items, 'filed', false, false, '', local_user()); $o .= DI::conversation()->create($items, 'filed', false, false, '', Session::getLocalUser());
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) { if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader(); $o .= HTML::scrollLoader();
} else { } else {
$o .= $pager->renderMinimal($count); $o .= $pager->renderMinimal($count);

View file

@ -94,7 +94,7 @@ class Index extends BaseSearch
} }
} }
if (local_user()) { if (Session::getLocalUser()) {
DI::page()['aside'] .= Widget\SavedSearches::getHTML(Search::getSearchPath($search), $search); DI::page()['aside'] .= Widget\SavedSearches::getHTML(Search::getSearchPath($search), $search);
} }
@ -161,10 +161,10 @@ class Index extends BaseSearch
// No items will be shown if the member has a blocked profile wall. // No items will be shown if the member has a blocked profile wall.
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'));
} }
@ -174,19 +174,19 @@ class Index extends BaseSearch
if ($tag) { if ($tag) {
Logger::info('Start tag search.', ['q' => $search]); Logger::info('Start tag search.', ['q' => $search]);
$uriids = Tag::getURIIdListByTag($search, local_user(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid); $uriids = Tag::getURIIdListByTag($search, Session::getLocalUser(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
$count = Tag::countByTag($search, local_user()); $count = Tag::countByTag($search, Session::getLocalUser());
} else { } else {
Logger::info('Start fulltext search.', ['q' => $search]); Logger::info('Start fulltext search.', ['q' => $search]);
$uriids = Post\Content::getURIIdListBySearch($search, local_user(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid); $uriids = Post\Content::getURIIdListBySearch($search, Session::getLocalUser(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
$count = Post\Content::countBySearch($search, local_user()); $count = Post\Content::countBySearch($search, Session::getLocalUser());
} }
if (!empty($uriids)) { if (!empty($uriids)) {
$condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`))", 0, local_user()]; $condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`))", 0, Session::getLocalUser()];
$condition = DBA::mergeConditions($condition, ['uri-id' => $uriids]); $condition = DBA::mergeConditions($condition, ['uri-id' => $uriids]);
$params = ['order' => ['id' => true]]; $params = ['order' => ['id' => true]];
$items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params)); $items = Post::toArray(Post::selectForUser(Session::getLocalUser(), Item::DISPLAY_FIELDLIST, $condition, $params));
} }
if (empty($items)) { if (empty($items)) {
@ -196,7 +196,7 @@ class Index extends BaseSearch
return $o; return $o;
} }
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) { if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl'); $tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
$o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]); $o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
} }
@ -213,9 +213,9 @@ class Index extends BaseSearch
Logger::info('Start Conversation.', ['q' => $search]); Logger::info('Start Conversation.', ['q' => $search]);
$o .= DI::conversation()->create($items, 'search', false, false, 'commented', local_user()); $o .= DI::conversation()->create($items, 'search', false, false, 'commented', Session::getLocalUser());
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) { if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader(); $o .= HTML::scrollLoader();
} else { } else {
$o .= $pager->renderMinimal($count); $o .= $pager->renderMinimal($count);
@ -254,9 +254,9 @@ class Index extends BaseSearch
$search = $matches[1]; $search = $matches[1];
} }
if (local_user()) { if (Session::getLocalUser()) {
// User-specific contact URL/address search // User-specific contact URL/address search
$contact_id = Contact::getIdForURL($search, local_user()); $contact_id = Contact::getIdForURL($search, Session::getLocalUser());
if (!$contact_id) { if (!$contact_id) {
// User-specific contact URL/address search and probe // User-specific contact URL/address search and probe
$contact_id = Contact::getIdForURL($search); $contact_id = Contact::getIdForURL($search);
@ -293,9 +293,9 @@ class Index extends BaseSearch
$search = Network::convertToIdn($search); $search = Network::convertToIdn($search);
if (local_user()) { if (Session::getLocalUser()) {
// Post URL search // Post URL search
$item_id = Item::fetchByLink($search, local_user()); $item_id = Item::fetchByLink($search, Session::getLocalUser());
if (!$item_id) { if (!$item_id) {
// If the user-specific search failed, we search and probe a public post // If the user-specific search failed, we search and probe a public post
$item_id = Item::fetchByLink($search); $item_id = Item::fetchByLink($search);

View file

@ -25,6 +25,7 @@ use Friendica\App;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Search; use Friendica\Core\Search;
use Friendica\Core\Session;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\DI; use Friendica\DI;
use Friendica\Module\Response; use Friendica\Module\Response;
@ -50,10 +51,10 @@ class Saved extends BaseModule
$return_url = $_GET['return_url'] ?? Search::getSearchPath($search); $return_url = $_GET['return_url'] ?? Search::getSearchPath($search);
if (local_user() && $search) { if (Session::getLocalUser() && $search) {
switch ($action) { switch ($action) {
case 'add': case 'add':
$fields = ['uid' => local_user(), 'term' => $search]; $fields = ['uid' => Session::getLocalUser(), 'term' => $search];
if (!$this->dba->exists('search', $fields)) { if (!$this->dba->exists('search', $fields)) {
if (!$this->dba->insert('search', $fields)) { if (!$this->dba->insert('search', $fields)) {
DI::sysmsg()->addNotice($this->t('Search term was not saved.')); DI::sysmsg()->addNotice($this->t('Search term was not saved.'));
@ -64,7 +65,7 @@ class Saved extends BaseModule
break; break;
case 'remove': case 'remove':
if (!$this->dba->delete('search', ['uid' => local_user(), 'term' => $search])) { if (!$this->dba->delete('search', ['uid' => Session::getLocalUser(), 'term' => $search])) {
DI::sysmsg()->addNotice($this->t('Search term was not removed.')); DI::sysmsg()->addNotice($this->t('Search term was not removed.'));
} }
break; break;

View file

@ -27,6 +27,7 @@ use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions; use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\DI; use Friendica\DI;
use Friendica\Module\Register; use Friendica\Module\Register;
@ -62,7 +63,7 @@ class Login extends BaseModule
{ {
$return_path = $request['return_path'] ?? $this->session->pop('return_path', '') ; $return_path = $request['return_path'] ?? $this->session->pop('return_path', '') ;
if (local_user()) { if (Session::getLocalUser()) {
$this->baseUrl->redirect($return_path); $this->baseUrl->redirect($return_path);
} }
@ -126,7 +127,7 @@ class Login extends BaseModule
]; ];
} }
if (local_user()) { if (Session::getLocalUser()) {
$tpl = Renderer::getMarkupTemplate('logout.tpl'); $tpl = Renderer::getMarkupTemplate('logout.tpl');
} else { } else {
DI::page()['htmlhead'] .= Renderer::replaceMacros( DI::page()['htmlhead'] .= Renderer::replaceMacros(

View file

@ -26,6 +26,7 @@ use Friendica\BaseModule;
use Friendica\Core\Cache\Capability\ICanCache; use Friendica\Core\Cache\Capability\ICanCache;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions; use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI; use Friendica\DI;
@ -63,7 +64,7 @@ class Logout extends BaseModule
protected function rawContent(array $request = []) protected function rawContent(array $request = [])
{ {
$visitor_home = null; $visitor_home = null;
if (remote_user()) { if (Session::getRemoteUser()) {
$visitor_home = Profile::getMyURL(); $visitor_home = Profile::getMyURL();
$this->cache->delete('zrlInit:' . $visitor_home); $this->cache->delete('zrlInit:' . $visitor_home);
} }

View file

@ -24,6 +24,7 @@ namespace Friendica\Module\Security;
use Friendica\App; use Friendica\App;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Module\Response; use Friendica\Module\Response;
@ -54,13 +55,13 @@ class PasswordTooLong extends \Friendica\BaseModule
} }
// check if the old password was supplied correctly before changing it to the new value // check if the old password was supplied correctly before changing it to the new value
User::getIdFromPasswordAuthentication(local_user(), $request['password_current']); User::getIdFromPasswordAuthentication(Session::getLocalUser(), $request['password_current']);
if (strlen($request['password_current']) <= 72) { if (strlen($request['password_current']) <= 72) {
throw new \Exception($this->l10n->t('Password does not need changing.')); throw new \Exception($this->l10n->t('Password does not need changing.'));
} }
$result = User::updatePassword(local_user(), $newpass); $result = User::updatePassword(Session::getLocalUser(), $newpass);
if (!DBA::isResult($result)) { if (!DBA::isResult($result)) {
throw new \Exception($this->l10n->t('Password update failed. Please try again.')); throw new \Exception($this->l10n->t('Password update failed. Please try again.'));
} }

View file

@ -25,6 +25,7 @@ use Friendica\App;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions; use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\User; use Friendica\Model\User;
@ -59,7 +60,7 @@ class Recovery extends BaseModule
protected function post(array $request = []) protected function post(array $request = [])
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
return; return;
} }
@ -68,10 +69,10 @@ class Recovery extends BaseModule
$recovery_code = $_POST['recovery_code'] ?? ''; $recovery_code = $_POST['recovery_code'] ?? '';
if (RecoveryCode::existsForUser(local_user(), $recovery_code)) { if (RecoveryCode::existsForUser(Session::getLocalUser(), $recovery_code)) {
RecoveryCode::markUsedForUser(local_user(), $recovery_code); RecoveryCode::markUsedForUser(Session::getLocalUser(), $recovery_code);
$this->session->set('2fa', true); $this->session->set('2fa', true);
DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(local_user()))); DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(Session::getLocalUser())));
$this->auth->setForUser($this->app, User::getById($this->app->getLoggedInUserId()), true, true); $this->auth->setForUser($this->app, User::getById($this->app->getLoggedInUserId()), true, true);
@ -84,7 +85,7 @@ class Recovery extends BaseModule
protected function content(array $request = []): string protected function content(array $request = []): string
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
$this->baseUrl->redirect(); $this->baseUrl->redirect();
} }

View file

@ -25,6 +25,7 @@ use Friendica\App;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions; use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\User\Cookie; use Friendica\Model\User\Cookie;
@ -61,7 +62,7 @@ class SignOut extends BaseModule
protected function post(array $request = []) protected function post(array $request = [])
{ {
if (!local_user() || !($this->cookie->get('2fa_cookie_hash'))) { if (!Session::getLocalUser() || !($this->cookie->get('2fa_cookie_hash'))) {
return; return;
} }
@ -80,7 +81,7 @@ class SignOut extends BaseModule
$this->baseUrl->redirect(); $this->baseUrl->redirect();
break; break;
case 'sign_out': case 'sign_out':
$this->trustedBrowserRepository->removeForUser(local_user(), $this->cookie->get('2fa_cookie_hash')); $this->trustedBrowserRepository->removeForUser(Session::getLocalUser(), $this->cookie->get('2fa_cookie_hash'));
$this->cookie->clear(); $this->cookie->clear();
$this->session->clear(); $this->session->clear();
@ -95,7 +96,7 @@ class SignOut extends BaseModule
protected function content(array $request = []): string protected function content(array $request = []): string
{ {
if (!local_user() || !($this->cookie->get('2fa_cookie_hash'))) { if (!Session::getLocalUser() || !($this->cookie->get('2fa_cookie_hash'))) {
$this->baseUrl->redirect(); $this->baseUrl->redirect();
} }

View file

@ -25,6 +25,7 @@ use Friendica\App;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions; use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\User; use Friendica\Model\User;
@ -74,7 +75,7 @@ class Trust extends BaseModule
protected function post(array $request = []) protected function post(array $request = [])
{ {
if (!local_user() || !$this->session->get('2fa')) { if (!Session::getLocalUser() || !$this->session->get('2fa')) {
$this->logger->info('Invalid call', ['request' => $request]); $this->logger->info('Invalid call', ['request' => $request]);
return; return;
} }
@ -87,7 +88,7 @@ class Trust extends BaseModule
switch ($action) { switch ($action) {
case 'trust': case 'trust':
case 'dont_trust': case 'dont_trust':
$trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent(local_user(), $this->server['HTTP_USER_AGENT'], $action === 'trust'); $trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent(Session::getLocalUser(), $this->server['HTTP_USER_AGENT'], $action === 'trust');
try { try {
$this->trustedBrowserRepository->save($trustedBrowser); $this->trustedBrowserRepository->save($trustedBrowser);
@ -115,7 +116,7 @@ class Trust extends BaseModule
protected function content(array $request = []): string protected function content(array $request = []): string
{ {
if (!local_user() || !$this->session->get('2fa')) { if (!Session::getLocalUser() || !$this->session->get('2fa')) {
$this->baseUrl->redirect(); $this->baseUrl->redirect();
} }

View file

@ -26,6 +26,7 @@ use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions; use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Module\Response; use Friendica\Module\Response;
use Friendica\Util\Profiler; use Friendica\Util\Profiler;
@ -57,7 +58,7 @@ class Verify extends BaseModule
protected function post(array $request = []) protected function post(array $request = [])
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
return; return;
} }
@ -66,7 +67,7 @@ class Verify extends BaseModule
$code = $request['verify_code'] ?? ''; $code = $request['verify_code'] ?? '';
$valid = (new Google2FA())->verifyKey($this->pConfig->get(local_user(), '2fa', 'secret'), $code); $valid = (new Google2FA())->verifyKey($this->pConfig->get(Session::getLocalUser(), '2fa', 'secret'), $code);
// The same code can't be used twice even if it's valid // The same code can't be used twice even if it's valid
if ($valid && $this->session->get('2fa') !== $code) { if ($valid && $this->session->get('2fa') !== $code) {
@ -81,7 +82,7 @@ class Verify extends BaseModule
protected function content(array $request = []): string protected function content(array $request = []): string
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
$this->baseUrl->redirect(); $this->baseUrl->redirect();
} }

View file

@ -26,6 +26,7 @@ use Friendica\Core\ACL;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Search; use Friendica\Core\Search;
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;
@ -68,9 +69,9 @@ class Account extends BaseSettings
} }
// check if the old password was supplied correctly before changing it to the new value // check if the old password was supplied correctly before changing it to the new value
User::getIdFromPasswordAuthentication(local_user(), $request['opassword']); User::getIdFromPasswordAuthentication(Session::getLocalUser(), $request['opassword']);
$result = User::updatePassword(local_user(), $newpass); $result = User::updatePassword(Session::getLocalUser(), $newpass);
if (!DBA::isResult($result)) { if (!DBA::isResult($result)) {
throw new Exception(DI::l10n()->t('Password update failed. Please try again.')); throw new Exception(DI::l10n()->t('Password update failed. Please try again.'));
} }
@ -103,7 +104,7 @@ class Account extends BaseSettings
if ($email != $user['email']) { if ($email != $user['email']) {
// check for the correct password // check for the correct password
try { try {
User::getIdFromPasswordAuthentication(local_user(), $request['mpassword']); User::getIdFromPasswordAuthentication(Session::getLocalUser(), $request['mpassword']);
} catch (Exception $ex) { } catch (Exception $ex) {
$err .= DI::l10n()->t('Wrong Password.'); $err .= DI::l10n()->t('Wrong Password.');
$email = $user['email']; $email = $user['email'];
@ -145,7 +146,7 @@ class Account extends BaseSettings
$fields['openidserver'] = ''; $fields['openidserver'] = '';
} }
if (!User::update($fields, local_user())) { if (!User::update($fields, Session::getLocalUser())) {
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.')); DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
} }
@ -174,8 +175,8 @@ class Account extends BaseSettings
$str_group_deny = !empty($request['group_deny']) ? $aclFormatter->toString($request['group_deny']) : ''; $str_group_deny = !empty($request['group_deny']) ? $aclFormatter->toString($request['group_deny']) : '';
$str_contact_deny = !empty($request['contact_deny']) ? $aclFormatter->toString($request['contact_deny']) : ''; $str_contact_deny = !empty($request['contact_deny']) ? $aclFormatter->toString($request['contact_deny']) : '';
DI::pConfig()->set(local_user(), 'system', 'unlisted', !empty($request['unlisted'])); DI::pConfig()->set(Session::getLocalUser(), 'system', 'unlisted', !empty($request['unlisted']));
DI::pConfig()->set(local_user(), 'system', 'accessible-photos', !empty($request['accessible-photos'])); DI::pConfig()->set(Session::getLocalUser(), 'system', 'accessible-photos', !empty($request['accessible-photos']));
$fields = [ $fields = [
'allow_cid' => $str_contact_allow, 'allow_cid' => $str_contact_allow,
@ -197,7 +198,7 @@ class Account extends BaseSettings
'hide-friends' => $hide_friends 'hide-friends' => $hide_friends
]; ];
if (!User::update($fields, local_user()) || !Profile::update($profile_fields, local_user())) { if (!User::update($fields, Session::getLocalUser()) || !Profile::update($profile_fields, Session::getLocalUser())) {
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.')); DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
} }
@ -212,12 +213,12 @@ class Account extends BaseSettings
$expire_starred = !empty($request['expire_starred']); $expire_starred = !empty($request['expire_starred']);
$expire_network_only = !empty($request['expire_network_only']); $expire_network_only = !empty($request['expire_network_only']);
DI::pConfig()->set(local_user(), 'expire', 'items', $expire_items); DI::pConfig()->set(Session::getLocalUser(), 'expire', 'items', $expire_items);
DI::pConfig()->set(local_user(), 'expire', 'notes', $expire_notes); DI::pConfig()->set(Session::getLocalUser(), 'expire', 'notes', $expire_notes);
DI::pConfig()->set(local_user(), 'expire', 'starred', $expire_starred); DI::pConfig()->set(Session::getLocalUser(), 'expire', 'starred', $expire_starred);
DI::pConfig()->set(local_user(), 'expire', 'network_only', $expire_network_only); DI::pConfig()->set(Session::getLocalUser(), 'expire', 'network_only', $expire_network_only);
if (!User::update(['expire' => $expire], local_user())) { if (!User::update(['expire' => $expire], Session::getLocalUser())) {
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.')); DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
} }
@ -272,7 +273,7 @@ class Account extends BaseSettings
if (!empty($request['notify_activity_participation'])) { if (!empty($request['notify_activity_participation'])) {
$notify_type = $notify_type | UserNotification::TYPE_ACTIVITY_PARTICIPATION; $notify_type = $notify_type | UserNotification::TYPE_ACTIVITY_PARTICIPATION;
} }
DI::pConfig()->set(local_user(), 'system', 'notify_type', $notify_type); DI::pConfig()->set(Session::getLocalUser(), 'system', 'notify_type', $notify_type);
if (!($notify_type & (UserNotification::TYPE_DIRECT_COMMENT + UserNotification::TYPE_DIRECT_THREAD_COMMENT))) { if (!($notify_type & (UserNotification::TYPE_DIRECT_COMMENT + UserNotification::TYPE_DIRECT_THREAD_COMMENT))) {
$notify_like = false; $notify_like = false;
@ -280,28 +281,28 @@ class Account extends BaseSettings
} }
// Reset like notifications when they are going to be shown again // Reset like notifications when they are going to be shown again
if (!DI::pConfig()->get(local_user(), 'system', 'notify_like') && $notify_like) { if (!DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_like') && $notify_like) {
DI::notification()->setAllSeenForUser(local_user(), ['vid' => Verb::getID(Activity::LIKE)]); DI::notification()->setAllSeenForUser(Session::getLocalUser(), ['vid' => Verb::getID(Activity::LIKE)]);
} }
DI::pConfig()->set(local_user(), 'system', 'notify_like', $notify_like); DI::pConfig()->set(Session::getLocalUser(), 'system', 'notify_like', $notify_like);
// Reset share notifications when they are going to be shown again // Reset share notifications when they are going to be shown again
if (!DI::pConfig()->get(local_user(), 'system', 'notify_announce') && $notify_announce) { if (!DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_announce') && $notify_announce) {
DI::notification()->setAllSeenForUser(local_user(), ['vid' => Verb::getID(Activity::ANNOUNCE)]); DI::notification()->setAllSeenForUser(Session::getLocalUser(), ['vid' => Verb::getID(Activity::ANNOUNCE)]);
} }
DI::pConfig()->set(local_user(), 'system', 'notify_announce', $notify_announce); DI::pConfig()->set(Session::getLocalUser(), 'system', 'notify_announce', $notify_announce);
DI::pConfig()->set(local_user(), 'system', 'email_textonly', !empty($request['email_textonly'])); DI::pConfig()->set(Session::getLocalUser(), 'system', 'email_textonly', !empty($request['email_textonly']));
DI::pConfig()->set(local_user(), 'system', 'detailed_notif', !empty($request['detailed_notif'])); DI::pConfig()->set(Session::getLocalUser(), 'system', 'detailed_notif', !empty($request['detailed_notif']));
DI::pConfig()->set(local_user(), 'system', 'notify_ignored', !empty($request['notify_ignored'])); DI::pConfig()->set(Session::getLocalUser(), 'system', 'notify_ignored', !empty($request['notify_ignored']));
$fields = [ $fields = [
'notify-flags' => $notify, 'notify-flags' => $notify,
]; ];
if (!User::update($fields, local_user())) { if (!User::update($fields, Session::getLocalUser())) {
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.')); DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
} }
@ -327,7 +328,7 @@ class Account extends BaseSettings
$profile_fields = []; $profile_fields = [];
if ($account_type == User::ACCOUNT_TYPE_COMMUNITY) { if ($account_type == User::ACCOUNT_TYPE_COMMUNITY) {
DI::pConfig()->set(local_user(), 'system', 'unlisted', true); DI::pConfig()->set(Session::getLocalUser(), 'system', 'unlisted', true);
$fields = [ $fields = [
'allow_cid' => '', 'allow_cid' => '',
@ -350,7 +351,7 @@ class Account extends BaseSettings
'account-type' => $account_type, 'account-type' => $account_type,
]); ]);
if (!User::update($fields, local_user()) || !empty($profile_fields) && !Profile::update($profile_fields, local_user())) { if (!User::update($fields, Session::getLocalUser()) || !empty($profile_fields) && !Profile::update($profile_fields, Session::getLocalUser())) {
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.')); DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
} }
@ -375,7 +376,7 @@ class Account extends BaseSettings
// "http" or "@" to be present in the string. // "http" or "@" to be present in the string.
// All other fields from the row will be ignored // All other fields from the row will be ignored
if ((strpos($csvRow[0], '@') !== false) || Network::isValidHttpUrl($csvRow[0])) { if ((strpos($csvRow[0], '@') !== false) || Network::isValidHttpUrl($csvRow[0])) {
Worker::add(Worker::PRIORITY_MEDIUM, 'AddContact', local_user(), $csvRow[0]); Worker::add(Worker::PRIORITY_MEDIUM, 'AddContact', Session::getLocalUser(), $csvRow[0]);
} else { } else {
Logger::notice('Invalid account', ['url' => $csvRow[0]]); Logger::notice('Invalid account', ['url' => $csvRow[0]]);
} }
@ -394,7 +395,7 @@ class Account extends BaseSettings
} }
if (!empty($request['relocate-submit'])) { if (!empty($request['relocate-submit'])) {
Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, local_user()); Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, Session::getLocalUser());
DI::sysmsg()->addInfo(DI::l10n()->t("Relocate message has been send to your contacts")); DI::sysmsg()->addInfo(DI::l10n()->t("Relocate message has been send to your contacts"));
DI::baseUrl()->redirect($redirectUrl); DI::baseUrl()->redirect($redirectUrl);
} }
@ -406,11 +407,11 @@ class Account extends BaseSettings
{ {
parent::content(); parent::content();
if (!local_user()) { if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
} }
$profile = DBA::selectFirst('profile', [], ['uid' => local_user()]); $profile = DBA::selectFirst('profile', [], ['uid' => Session::getLocalUser()]);
if (!DBA::isResult($profile)) { if (!DBA::isResult($profile)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to find your profile. Please contact your admin.')); DI::sysmsg()->addNotice(DI::l10n()->t('Unable to find your profile. Please contact your admin.'));
return ''; return '';
@ -433,10 +434,10 @@ class Account extends BaseSettings
$unkmail = $user['unkmail']; $unkmail = $user['unkmail'];
$cntunkmail = $user['cntunkmail']; $cntunkmail = $user['cntunkmail'];
$expire_items = DI::pConfig()->get(local_user(), 'expire', 'items', true); $expire_items = DI::pConfig()->get(Session::getLocalUser(), 'expire', 'items', true);
$expire_notes = DI::pConfig()->get(local_user(), 'expire', 'notes', true); $expire_notes = DI::pConfig()->get(Session::getLocalUser(), 'expire', 'notes', true);
$expire_starred = DI::pConfig()->get(local_user(), 'expire', 'starred', true); $expire_starred = DI::pConfig()->get(Session::getLocalUser(), 'expire', 'starred', true);
$expire_network_only = DI::pConfig()->get(local_user(), 'expire', 'network_only', false); $expire_network_only = DI::pConfig()->get(Session::getLocalUser(), 'expire', 'network_only', false);
if (!strlen($user['timezone'])) { if (!strlen($user['timezone'])) {
$timezone = $a->getTimeZone(); $timezone = $a->getTimeZone();
@ -550,7 +551,7 @@ class Account extends BaseSettings
/* Installed langs */ /* Installed langs */
$lang_choices = DI::l10n()->getAvailableLanguages(); $lang_choices = DI::l10n()->getAvailableLanguages();
$notify_type = DI::pConfig()->get(local_user(), 'system', 'notify_type'); $notify_type = DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_type');
$passwordRules = DI::l10n()->t('Allowed characters are a-z, A-Z, 0-9 and special characters except white spaces, accentuated letters and colon (:).') $passwordRules = DI::l10n()->t('Allowed characters are a-z, A-Z, 0-9 and special characters except white spaces, accentuated letters and colon (:).')
. (PASSWORD_DEFAULT === PASSWORD_BCRYPT ? ' ' . DI::l10n()->t('Password length is limited to 72 characters.') : ''); . (PASSWORD_DEFAULT === PASSWORD_BCRYPT ? ' ' . DI::l10n()->t('Password length is limited to 72 characters.') : '');
@ -562,7 +563,7 @@ class Account extends BaseSettings
'$submit' => DI::l10n()->t('Save Settings'), '$submit' => DI::l10n()->t('Save Settings'),
'$baseurl' => DI::baseUrl()->get(true), '$baseurl' => DI::baseUrl()->get(true),
'$uid' => local_user(), '$uid' => Session::getLocalUser(),
'$form_security_token' => self::getFormSecurityToken('settings'), '$form_security_token' => self::getFormSecurityToken('settings'),
'$open' => $this->parameters['open'] ?? 'password', '$open' => $this->parameters['open'] ?? 'password',
@ -590,13 +591,13 @@ class Account extends BaseSettings
'$profile_in_net_dir' => ['profile_in_netdirectory', DI::l10n()->t('Allow your profile to be searchable globally?'), $profile['net-publish'], DI::l10n()->t("Activate this setting if you want others to easily find and follow you. Your profile will be searchable on remote systems. This setting also determines whether Friendica will inform search engines that your profile should be indexed or not.") . $net_pub_desc], '$profile_in_net_dir' => ['profile_in_netdirectory', DI::l10n()->t('Allow your profile to be searchable globally?'), $profile['net-publish'], DI::l10n()->t("Activate this setting if you want others to easily find and follow you. Your profile will be searchable on remote systems. This setting also determines whether Friendica will inform search engines that your profile should be indexed or not.") . $net_pub_desc],
'$hide_friends' => ['hide-friends', DI::l10n()->t('Hide your contact/friend list from viewers of your profile?'), $profile['hide-friends'], DI::l10n()->t('A list of your contacts is displayed on your profile page. Activate this option to disable the display of your contact list.')], '$hide_friends' => ['hide-friends', DI::l10n()->t('Hide your contact/friend list from viewers of your profile?'), $profile['hide-friends'], DI::l10n()->t('A list of your contacts is displayed on your profile page. Activate this option to disable the display of your contact list.')],
'$hide_wall' => ['hidewall', DI::l10n()->t('Hide your profile details from anonymous viewers?'), $user['hidewall'], DI::l10n()->t('Anonymous visitors will only see your profile picture, your display name and the nickname you are using on your profile page. Your public posts and replies will still be accessible by other means.')], '$hide_wall' => ['hidewall', DI::l10n()->t('Hide your profile details from anonymous viewers?'), $user['hidewall'], DI::l10n()->t('Anonymous visitors will only see your profile picture, your display name and the nickname you are using on your profile page. Your public posts and replies will still be accessible by other means.')],
'$unlisted' => ['unlisted', DI::l10n()->t('Make public posts unlisted'), DI::pConfig()->get(local_user(), 'system', 'unlisted'), DI::l10n()->t('Your public posts will not appear on the community pages or in search results, nor be sent to relay servers. However they can still appear on public feeds on remote servers.')], '$unlisted' => ['unlisted', DI::l10n()->t('Make public posts unlisted'), DI::pConfig()->get(Session::getLocalUser(), 'system', 'unlisted'), DI::l10n()->t('Your public posts will not appear on the community pages or in search results, nor be sent to relay servers. However they can still appear on public feeds on remote servers.')],
'$accessiblephotos' => ['accessible-photos', DI::l10n()->t('Make all posted pictures accessible'), DI::pConfig()->get(local_user(), 'system', 'accessible-photos'), DI::l10n()->t("This option makes every posted picture accessible via the direct link. This is a workaround for the problem that most other networks can't handle permissions on pictures. Non public pictures still won't be visible for the public on your photo albums though.")], '$accessiblephotos' => ['accessible-photos', DI::l10n()->t('Make all posted pictures accessible'), DI::pConfig()->get(Session::getLocalUser(), 'system', 'accessible-photos'), DI::l10n()->t("This option makes every posted picture accessible via the direct link. This is a workaround for the problem that most other networks can't handle permissions on pictures. Non public pictures still won't be visible for the public on your photo albums though.")],
'$blockwall' => ['blockwall', DI::l10n()->t('Allow friends to post to your profile page?'), (intval($user['blockwall']) ? '0' : '1'), DI::l10n()->t('Your contacts may write posts on your profile wall. These posts will be distributed to your contacts')], '$blockwall' => ['blockwall', DI::l10n()->t('Allow friends to post to your profile page?'), (intval($user['blockwall']) ? '0' : '1'), DI::l10n()->t('Your contacts may write posts on your profile wall. These posts will be distributed to your contacts')],
'$blocktags' => ['blocktags', DI::l10n()->t('Allow friends to tag your posts?'), (intval($user['blocktags']) ? '0' : '1'), DI::l10n()->t('Your contacts can add additional tags to your posts.')], '$blocktags' => ['blocktags', DI::l10n()->t('Allow friends to tag your posts?'), (intval($user['blocktags']) ? '0' : '1'), DI::l10n()->t('Your contacts can add additional tags to your posts.')],
'$unkmail' => ['unkmail', DI::l10n()->t('Permit unknown people to send you private mail?'), $unkmail, DI::l10n()->t('Friendica network users may send you private messages even if they are not in your contact list.')], '$unkmail' => ['unkmail', DI::l10n()->t('Permit unknown people to send you private mail?'), $unkmail, DI::l10n()->t('Friendica network users may send you private messages even if they are not in your contact list.')],
'$cntunkmail' => ['cntunkmail', DI::l10n()->t('Maximum private messages per day from unknown people:'), $cntunkmail, DI::l10n()->t("(to prevent spam abuse)")], '$cntunkmail' => ['cntunkmail', DI::l10n()->t('Maximum private messages per day from unknown people:'), $cntunkmail, DI::l10n()->t("(to prevent spam abuse)")],
'$group_select' => Group::displayGroupSelection(local_user(), $user['def_gid']), '$group_select' => Group::displayGroupSelection(Session::getLocalUser(), $user['def_gid']),
'$permissions' => DI::l10n()->t('Default Post Permissions'), '$permissions' => DI::l10n()->t('Default Post Permissions'),
'$aclselect' => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId()), '$aclselect' => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId()),
@ -622,8 +623,8 @@ class Account extends BaseSettings
'$lbl_notify' => DI::l10n()->t('Create a desktop notification when:'), '$lbl_notify' => DI::l10n()->t('Create a desktop notification when:'),
'$notify_tagged' => ['notify_tagged', DI::l10n()->t('Someone tagged you'), is_null($notify_type) || $notify_type & UserNotification::TYPE_EXPLICIT_TAGGED, ''], '$notify_tagged' => ['notify_tagged', DI::l10n()->t('Someone tagged you'), is_null($notify_type) || $notify_type & UserNotification::TYPE_EXPLICIT_TAGGED, ''],
'$notify_direct_comment' => ['notify_direct_comment', DI::l10n()->t('Someone directly commented on your post'), is_null($notify_type) || $notify_type & (UserNotification::TYPE_IMPLICIT_TAGGED + UserNotification::TYPE_DIRECT_COMMENT + UserNotification::TYPE_DIRECT_THREAD_COMMENT), ''], '$notify_direct_comment' => ['notify_direct_comment', DI::l10n()->t('Someone directly commented on your post'), is_null($notify_type) || $notify_type & (UserNotification::TYPE_IMPLICIT_TAGGED + UserNotification::TYPE_DIRECT_COMMENT + UserNotification::TYPE_DIRECT_THREAD_COMMENT), ''],
'$notify_like' => ['notify_like', DI::l10n()->t('Someone liked your content'), DI::pConfig()->get(local_user(), 'system', 'notify_like'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')], '$notify_like' => ['notify_like', DI::l10n()->t('Someone liked your content'), DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_like'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')],
'$notify_announce' => ['notify_announce', DI::l10n()->t('Someone shared your content'), DI::pConfig()->get(local_user(), 'system', 'notify_announce'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')], '$notify_announce' => ['notify_announce', DI::l10n()->t('Someone shared your content'), DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_announce'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')],
'$notify_thread_comment' => ['notify_thread_comment', DI::l10n()->t('Someone commented in your thread'), is_null($notify_type) || $notify_type & UserNotification::TYPE_THREAD_COMMENT, ''], '$notify_thread_comment' => ['notify_thread_comment', DI::l10n()->t('Someone commented in your thread'), is_null($notify_type) || $notify_type & UserNotification::TYPE_THREAD_COMMENT, ''],
'$notify_comment_participation' => ['notify_comment_participation', DI::l10n()->t('Someone commented in a thread where you commented'), is_null($notify_type) || $notify_type & UserNotification::TYPE_COMMENT_PARTICIPATION, ''], '$notify_comment_participation' => ['notify_comment_participation', DI::l10n()->t('Someone commented in a thread where you commented'), is_null($notify_type) || $notify_type & UserNotification::TYPE_COMMENT_PARTICIPATION, ''],
'$notify_activity_participation' => ['notify_activity_participation', DI::l10n()->t('Someone commented in a thread where you interacted'), is_null($notify_type) || $notify_type & UserNotification::TYPE_ACTIVITY_PARTICIPATION, ''], '$notify_activity_participation' => ['notify_activity_participation', DI::l10n()->t('Someone commented in a thread where you interacted'), is_null($notify_type) || $notify_type & UserNotification::TYPE_ACTIVITY_PARTICIPATION, ''],
@ -633,19 +634,19 @@ class Account extends BaseSettings
'$email_textonly' => [ '$email_textonly' => [
'email_textonly', 'email_textonly',
DI::l10n()->t('Text-only notification emails'), DI::l10n()->t('Text-only notification emails'),
DI::pConfig()->get(local_user(), 'system', 'email_textonly'), DI::pConfig()->get(Session::getLocalUser(), 'system', 'email_textonly'),
DI::l10n()->t('Send text only notification emails, without the html part') DI::l10n()->t('Send text only notification emails, without the html part')
], ],
'$detailed_notif' => [ '$detailed_notif' => [
'detailed_notif', 'detailed_notif',
DI::l10n()->t('Show detailled notifications'), DI::l10n()->t('Show detailled notifications'),
DI::pConfig()->get(local_user(), 'system', 'detailed_notif'), DI::pConfig()->get(Session::getLocalUser(), 'system', 'detailed_notif'),
DI::l10n()->t('Per default, notifications are condensed to a single notification per item. When enabled every notification is displayed.') DI::l10n()->t('Per default, notifications are condensed to a single notification per item. When enabled every notification is displayed.')
], ],
'$notify_ignored' => [ '$notify_ignored' => [
'notify_ignored', 'notify_ignored',
DI::l10n()->t('Show notifications of ignored contacts'), DI::l10n()->t('Show notifications of ignored contacts'),
DI::pConfig()->get(local_user(), 'system', 'notify_ignored', true), DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_ignored', true),
DI::l10n()->t("You don't see posts from ignored contacts. But you still see their comments. This setting controls if you want to still receive regular notifications that are caused by ignored contacts or not.") DI::l10n()->t("You don't see posts from ignored contacts. But you still see their comments. This setting controls if you want to still receive regular notifications that are caused by ignored contacts or not.")
], ],

View file

@ -21,6 +21,7 @@
namespace Friendica\Module\Update; namespace Friendica\Module\Update;
use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Item; use Friendica\Model\Item;
@ -75,7 +76,7 @@ class Network extends NetworkModule
$ordering = '`commented`'; $ordering = '`commented`';
} }
$o = DI::conversation()->create($items, 'network', $profile_uid, false, $ordering, local_user()); $o = DI::conversation()->create($items, 'network', $profile_uid, false, $ordering, Session::getLocalUser());
} }
System::htmlUpdateExit($o); System::htmlUpdateExit($o);

File diff suppressed because it is too large Load diff