Merge pull request #12026 from annando/no-boot-src-module-2

old boot.php functions replaced in src/module (2)
This commit is contained in:
Hypolite Petovan 2022-10-19 09:13:45 -04:00 committed by GitHub
commit 83390d4b00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 102 additions and 88 deletions

View File

@ -22,6 +22,7 @@
namespace Friendica\Module\Admin;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Register;
@ -121,7 +122,7 @@ abstract class BaseUsers extends BaseAdmin
$user['login_date'] = Temporal::getRelativeDate($user['login_date']);
$user['lastitem_date'] = Temporal::getRelativeDate($user['last-item']);
$user['is_admin'] = in_array($user['email'], $adminlist);
$user['is_deletable'] = !$user['account_removed'] && intval($user['uid']) != local_user();
$user['is_deletable'] = !$user['account_removed'] && intval($user['uid']) != Session::getLocalUser();
$user['deleted'] = ($user['account_removed'] ? Temporal::getRelativeDate($user['account_expires_on']) : False);
return $user;

View File

@ -28,6 +28,7 @@ use Friendica\Content\Nav;
use Friendica\Content\Widget;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\Model;
use Friendica\Module\Contact;
@ -61,13 +62,13 @@ class Posts extends BaseModule
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return Login::form($_SERVER['REQUEST_URI']);
}
// Backward compatibility: Ensure to use the public contact when the user contact is provided
// Remove by version 2022.03
$data = Model\Contact::getPublicAndUserContactID(intval($this->parameters['id']), local_user());
$data = Model\Contact::getPublicAndUserContactID(intval($this->parameters['id']), Session::getLocalUser());
if (empty($data)) {
throw new NotFoundException($this->t('Contact not found.'));
}
@ -82,7 +83,7 @@ class Posts extends BaseModule
throw new NotFoundException($this->t('Contact not found.'));
}
$localRelationship = $this->localRelationship->getForUserContact(local_user(), $contact['id']);
$localRelationship = $this->localRelationship->getForUserContact(Session::getLocalUser(), $contact['id']);
if ($localRelationship->rel === Model\Contact::SELF) {
$this->baseUrl->redirect('profile/' . $contact['nick']);
}

View File

@ -34,6 +34,7 @@ use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
@ -74,7 +75,7 @@ class Profile extends BaseModule
protected function post(array $request = [])
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return;
}
@ -82,7 +83,7 @@ class Profile extends BaseModule
// Backward compatibility: The update still needs a user-specific contact ID
// Change to user-contact table check by version 2022.03
$cdata = Contact::getPublicAndUserContactID($contact_id, local_user());
$cdata = Contact::getPublicAndUserContactID($contact_id, Session::getLocalUser());
if (empty($cdata['user']) || !DBA::exists('contact', ['id' => $cdata['user'], 'deleted' => false])) {
return;
}
@ -124,20 +125,20 @@ class Profile extends BaseModule
$fields['info'] = $_POST['info'];
}
if (!Contact::update($fields, ['id' => $cdata['user'], 'uid' => local_user()])) {
if (!Contact::update($fields, ['id' => $cdata['user'], 'uid' => Session::getLocalUser()])) {
DI::sysmsg()->addNotice($this->t('Failed to update contact record.'));
}
}
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return Module\Security\Login::form($_SERVER['REQUEST_URI']);
}
// Backward compatibility: Ensure to use the public contact when the user contact is provided
// Remove by version 2022.03
$data = Contact::getPublicAndUserContactID(intval($this->parameters['id']), local_user());
$data = Contact::getPublicAndUserContactID(intval($this->parameters['id']), Session::getLocalUser());
if (empty($data)) {
throw new HTTPException\NotFoundException($this->t('Contact not found.'));
}
@ -152,7 +153,7 @@ class Profile extends BaseModule
throw new HTTPException\NotFoundException($this->t('Contact not found.'));
}
$localRelationship = $this->localRelationship->getForUserContact(local_user(), $contact['id']);
$localRelationship = $this->localRelationship->getForUserContact(Session::getLocalUser(), $contact['id']);
if ($localRelationship->rel === Contact::SELF) {
$this->baseUrl->redirect('profile/' . $contact['nick'] . '/profile');
@ -173,12 +174,12 @@ class Profile extends BaseModule
if ($cmd === 'block') {
if ($localRelationship->blocked) {
// @TODO Backward compatibility, replace with $localRelationship->unblock()
Contact\User::setBlocked($contact['id'], local_user(), false);
Contact\User::setBlocked($contact['id'], Session::getLocalUser(), false);
$message = $this->t('Contact has been unblocked');
} else {
// @TODO Backward compatibility, replace with $localRelationship->block()
Contact\User::setBlocked($contact['id'], local_user(), true);
Contact\User::setBlocked($contact['id'], Session::getLocalUser(), true);
$message = $this->t('Contact has been blocked');
}
@ -189,12 +190,12 @@ class Profile extends BaseModule
if ($cmd === 'ignore') {
if ($localRelationship->ignored) {
// @TODO Backward compatibility, replace with $localRelationship->unblock()
Contact\User::setIgnored($contact['id'], local_user(), false);
Contact\User::setIgnored($contact['id'], Session::getLocalUser(), false);
$message = $this->t('Contact has been unignored');
} else {
// @TODO Backward compatibility, replace with $localRelationship->block()
Contact\User::setIgnored($contact['id'], local_user(), true);
Contact\User::setIgnored($contact['id'], Session::getLocalUser(), true);
$message = $this->t('Contact has been ignored');
}
@ -223,8 +224,8 @@ class Profile extends BaseModule
'$baseurl' => $this->baseUrl->get(true),
]);
$contact['blocked'] = Contact\User::isBlocked($contact['id'], local_user());
$contact['readonly'] = Contact\User::isIgnored($contact['id'], local_user());
$contact['blocked'] = Contact\User::isBlocked($contact['id'], Session::getLocalUser());
$contact['readonly'] = Contact\User::isIgnored($contact['id'], Session::getLocalUser());
switch ($localRelationship->rel) {
case Contact::FRIEND: $relation_text = $this->t('You are mutual friends with %s', $contact['name']); break;
@ -485,7 +486,7 @@ class Profile extends BaseModule
*/
private static function updateContactFromProbe(int $contact_id)
{
$contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => [0, local_user()], 'deleted' => false]);
$contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => [0, Session::getLocalUser()], 'deleted' => false]);
if (!DBA::isResult($contact)) {
return;
}

View File

@ -27,6 +27,7 @@ use Friendica\Content\Nav;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\Database;
use Friendica\DI;
use Friendica\Model;
@ -54,11 +55,11 @@ class Revoke extends BaseModule
$this->dba = $dba;
if (!local_user()) {
if (!Session::getLocalUser()) {
return;
}
$data = Model\Contact::getPublicAndUserContactID($this->parameters['id'], local_user());
$data = Model\Contact::getPublicAndUserContactID($this->parameters['id'], Session::getLocalUser());
if (!$this->dba->isResult($data)) {
throw new HTTPException\NotFoundException($this->t('Unknown contact.'));
}
@ -80,7 +81,7 @@ class Revoke extends BaseModule
protected function post(array $request = [])
{
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new HTTPException\UnauthorizedException();
}
@ -95,7 +96,7 @@ class Revoke extends BaseModule
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return Login::form($_SERVER['REQUEST_URI']);
}

View File

@ -74,7 +74,7 @@ class Community extends BaseModule
'$global_community_hint' => DI::l10n()->t("This community stream shows all public posts received by this node. They may not reflect the opinions of this nodes users.")
]);
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');
$o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
}
@ -111,7 +111,7 @@ class Community extends BaseModule
DI::page()['aside'] .= Widget::accountTypes('community/' . self::$content, self::$accountTypeString);
if (local_user() && DI::config()->get('system', 'community_no_sharer')) {
if (Session::getLocalUser() && DI::config()->get('system', 'community_no_sharer')) {
$path = self::$content;
if (!empty($this->parameters['accounttype'])) {
$path .= '/' . $this->parameters['accounttype'];
@ -140,7 +140,7 @@ class Community extends BaseModule
]);
}
if (Feature::isEnabled(local_user(), 'trending_tags')) {
if (Feature::isEnabled(Session::getLocalUser(), 'trending_tags')) {
DI::page()['aside'] .= TrendingTags::getHTML(self::$content);
}
@ -157,7 +157,7 @@ class Community extends BaseModule
return $o;
}
$o .= DI::conversation()->create($items, 'community', false, false, 'commented', local_user());
$o .= DI::conversation()->create($items, 'community', false, false, 'commented', Session::getLocalUser());
$pager = new BoundariesPager(
DI::l10n(),
@ -167,7 +167,7 @@ class Community extends BaseModule
self::$itemsPerPage
);
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader();
} else {
$o .= $pager->renderMinimal(count($items));
@ -230,10 +230,10 @@ class Community extends BaseModule
}
if (DI::mode()->isMobile()) {
self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
@ -335,9 +335,9 @@ class Community extends BaseModule
$condition[0] .= " AND `id` = ?";
$condition[] = $item_id;
} else {
if (local_user() && !empty($_REQUEST['no_sharer'])) {
if (Session::getLocalUser() && !empty($_REQUEST['no_sharer'])) {
$condition[0] .= " AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `post-user`.`uid` = ?)";
$condition[] = local_user();
$condition[] = Session::getLocalUser();
}
if (isset($max_id)) {

View File

@ -78,7 +78,7 @@ class Network extends BaseModule
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return Login::form();
}
@ -88,8 +88,8 @@ class Network extends BaseModule
DI::page()['aside'] .= Widget::accountTypes($module, self::$accountTypeString);
DI::page()['aside'] .= Group::sidebarWidget($module, $module . '/group', 'standard', self::$groupId);
DI::page()['aside'] .= ForumManager::widget($module . '/forum', local_user(), self::$forumContactId);
DI::page()['aside'] .= Widget::postedByYear($module . '/archive', local_user(), false);
DI::page()['aside'] .= ForumManager::widget($module . '/forum', Session::getLocalUser(), self::$forumContactId);
DI::page()['aside'] .= Widget::postedByYear($module . '/archive', Session::getLocalUser(), false);
DI::page()['aside'] .= Widget::networks($module, !self::$forumContactId ? self::$network : '');
DI::page()['aside'] .= Widget\SavedSearches::getHTML(DI::args()->getQueryString());
DI::page()['aside'] .= Widget::fileAs('filed', '');
@ -105,7 +105,7 @@ class Network extends BaseModule
$items = self::getItems($table, $params);
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');
$o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
}
@ -138,7 +138,7 @@ class Network extends BaseModule
$allowedCids[] = (int) self::$forumContactId;
} elseif (self::$network) {
$condition = [
'uid' => local_user(),
'uid' => Session::getLocalUser(),
'network' => self::$network,
'self' => false,
'blocked' => false,
@ -168,7 +168,7 @@ class Network extends BaseModule
}
if (self::$groupId) {
$group = DBA::selectFirst('group', ['name'], ['id' => self::$groupId, 'uid' => local_user()]);
$group = DBA::selectFirst('group', ['name'], ['id' => self::$groupId, 'uid' => Session::getLocalUser()]);
if (!DBA::isResult($group)) {
DI::sysmsg()->addNotice(DI::l10n()->t('No such group'));
}
@ -199,9 +199,9 @@ class Network extends BaseModule
$ordering = '`commented`';
}
$o .= DI::conversation()->create($items, 'network', false, false, $ordering, local_user());
$o .= DI::conversation()->create($items, 'network', false, false, $ordering, Session::getLocalUser());
if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader();
} else {
$pager = new BoundariesPager(
@ -307,7 +307,7 @@ class Network extends BaseModule
self::$forumContactId = $this->parameters['contact_id'] ?? 0;
self::$selectedTab = DI::session()->get('network-tab', DI::pConfig()->get(local_user(), 'network.view', 'selected_tab', ''));
self::$selectedTab = DI::session()->get('network-tab', DI::pConfig()->get(Session::getLocalUser(), 'network.view', 'selected_tab', ''));
if (!empty($get['star'])) {
self::$selectedTab = 'star';
@ -346,7 +346,7 @@ class Network extends BaseModule
}
DI::session()->set('network-tab', self::$selectedTab);
DI::pConfig()->set(local_user(), 'network.view', 'selected_tab', self::$selectedTab);
DI::pConfig()->set(Session::getLocalUser(), 'network.view', 'selected_tab', self::$selectedTab);
self::$accountTypeString = $get['accounttype'] ?? $this->parameters['accounttype'] ?? '';
self::$accountType = User::getAccountTypeByString(self::$accountTypeString);
@ -357,10 +357,10 @@ class Network extends BaseModule
self::$dateTo = $this->parameters['to'] ?? '';
if (DI::mode()->isMobile()) {
self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
@ -385,7 +385,7 @@ class Network extends BaseModule
protected static function getItems(string $table, array $params, array $conditionFields = [])
{
$conditionFields['uid'] = local_user();
$conditionFields['uid'] = Session::getLocalUser();
$conditionStrings = [];
if (!is_null(self::$accountType)) {
@ -414,7 +414,7 @@ class Network extends BaseModule
} elseif (self::$forumContactId) {
$conditionStrings = DBA::mergeConditions($conditionStrings,
["((`contact-id` = ?) OR `uri-id` IN (SELECT `parent-uri-id` FROM `post-user-view` WHERE (`contact-id` = ? AND `gravity` = ? AND `vid` = ? AND `uid` = ?)))",
self::$forumContactId, self::$forumContactId, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), local_user()]);
self::$forumContactId, self::$forumContactId, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Session::getLocalUser()]);
}
// Currently only the order modes "received" and "commented" are in use
@ -478,10 +478,10 @@ class Network extends BaseModule
// level which items you've seen and which you haven't. If you're looking
// at the top level network page just mark everything seen.
if (!self::$groupId && !self::$forumContactId && !self::$star && !self::$mention) {
$condition = ['unseen' => true, 'uid' => local_user()];
$condition = ['unseen' => true, 'uid' => Session::getLocalUser()];
self::setItemsSeenByCondition($condition);
} elseif (!empty($parents)) {
$condition = ['unseen' => true, 'uid' => local_user(), 'parent-uri-id' => $parents];
$condition = ['unseen' => true, 'uid' => Session::getLocalUser(), 'parent-uri-id' => $parents];
self::setItemsSeenByCondition($condition);
}

View File

@ -23,6 +23,7 @@ namespace Friendica\Module\Debug;
use Friendica\BaseModule;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Protocol\ActivityPub;
use Friendica\Util\JsonLD;
@ -41,7 +42,7 @@ class ActivityPubConversion extends BaseModule
try {
$source = json_decode($_REQUEST['source'], true);
$trust_source = true;
$uid = local_user();
$uid = Session::getLocalUser();
$push = false;
if (!$source) {

View File

@ -25,6 +25,7 @@ use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model;
use Friendica\Module\Response;
@ -48,7 +49,7 @@ class Feed extends BaseModule
$this->httpClient = $httpClient;
if (!local_user()) {
if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice($this->t('You must be logged in to use this module'));
$baseUrl->redirect();
}
@ -60,7 +61,7 @@ class Feed extends BaseModule
if (!empty($_REQUEST['url'])) {
$url = $_REQUEST['url'];
$contact = Model\Contact::getByURLForUser($url, local_user(), null);
$contact = Model\Contact::getByURLForUser($url, Session::getLocalUser(), null);
$xml = $this->httpClient->fetch($contact['poll'], HttpClientAccept::FEED_XML);

View File

@ -22,6 +22,7 @@
namespace Friendica\Module\Debug;
use Friendica\BaseModule;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Post;
@ -34,7 +35,7 @@ class ItemBody extends BaseModule
{
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access denied.'));
}
@ -44,7 +45,7 @@ class ItemBody extends BaseModule
$itemId = intval($this->parameters['item']);
$item = Post::selectFirst(['body'], ['uid' => [0, local_user()], 'uri-id' => $itemId]);
$item = Post::selectFirst(['body'], ['uid' => [0, Session::getLocalUser()], 'uri-id' => $itemId]);
if (!empty($item)) {
if (DI::mode()->isAjax()) {

View File

@ -23,6 +23,7 @@ namespace Friendica\Module\Debug;
use Friendica\BaseModule;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Network\HTTPException;
use Friendica\Network\Probe as NetworkProbe;
@ -34,7 +35,7 @@ class Probe extends BaseModule
{
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a probing.'));
}

View File

@ -23,6 +23,7 @@ namespace Friendica\Module\Debug;
use Friendica\BaseModule;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Network\Probe;
@ -33,7 +34,7 @@ class WebFinger extends BaseModule
{
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a probing.'));
}

View File

@ -21,6 +21,7 @@
namespace Friendica\Module\Events;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
@ -35,7 +36,7 @@ class Json extends \Friendica\BaseModule
{
protected function rawContent(array $request = [])
{
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new HTTPException\UnauthorizedException();
}
@ -69,9 +70,9 @@ class Json extends \Friendica\BaseModule
// get events by id or by date
if ($event_params['event_id']) {
$r = Event::getListById(local_user(), $event_params['event_id']);
$r = Event::getListById(Session::getLocalUser(), $event_params['event_id']);
} else {
$r = Event::getListByDate(local_user(), $event_params);
$r = Event::getListByDate(Session::getLocalUser(), $event_params);
}
$links = [];

View File

@ -24,6 +24,7 @@ namespace Friendica\Module\Filer;
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Post;
@ -55,7 +56,7 @@ class RemoveTag extends BaseModule
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException();
}
@ -107,7 +108,7 @@ class RemoveTag extends BaseModule
return 404;
}
if (!Post\Category::deleteFileByURIId($item['uri-id'], local_user(), $type, $term)) {
if (!Post\Category::deleteFileByURIId($item['uri-id'], Session::getLocalUser(), $type, $term)) {
$this->systemMessages->addNotice($this->l10n->t('Item was not removed'));
return 500;
}

View File

@ -25,6 +25,7 @@ use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model;
@ -43,7 +44,7 @@ class SaveTag extends BaseModule
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
if (!local_user()) {
if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice($this->t('You must be logged in to use this module'));
$baseUrl->redirect();
}
@ -62,11 +63,11 @@ class SaveTag extends BaseModule
if (!DBA::isResult($item)) {
throw new HTTPException\NotFoundException();
}
Model\Post\Category::storeFileByURIId($item['uri-id'], local_user(), Model\Post\Category::FILE, $term);
Model\Post\Category::storeFileByURIId($item['uri-id'], Session::getLocalUser(), Model\Post\Category::FILE, $term);
}
// return filer dialog
$filetags = Model\Post\Category::getArray(local_user(), Model\Post\Category::FILE);
$filetags = Model\Post\Category::getArray(Session::getLocalUser(), Model\Post\Category::FILE);
$tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
echo Renderer::replaceMacros($tpl, [

View File

@ -51,13 +51,13 @@ class Activity extends BaseModule
$itemId = $this->parameters['id'];
if (in_array($verb, ['announce', 'unannounce'])) {
$item = Post::selectFirst(['network', 'uri-id'], ['id' => $itemId, 'uid' => [local_user(), 0]]);
$item = Post::selectFirst(['network', 'uri-id'], ['id' => $itemId, 'uid' => [Session::getLocalUser(), 0]]);
if ($item['network'] == Protocol::DIASPORA) {
Diaspora::performReshare($item['uri-id'], local_user());
Diaspora::performReshare($item['uri-id'], Session::getLocalUser());
}
}
if (!Item::performActivity($itemId, $verb, local_user())) {
if (!Item::performActivity($itemId, $verb, Session::getLocalUser())) {
throw new HTTPException\BadRequestException();
}

View File

@ -31,6 +31,7 @@ use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\Theme;
use Friendica\Database\DBA;
use Friendica\DI;
@ -88,7 +89,7 @@ class Compose extends BaseModule
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return Login::form('compose');
}
@ -110,7 +111,7 @@ class Compose extends BaseModule
}
}
$user = User::getById(local_user(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'default-location']);
$user = User::getById(Session::getLocalUser(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'default-location']);
$contact_allow_list = $this->ACLFormatter->expand($user['allow_cid']);
$group_allow_list = $this->ACLFormatter->expand($user['allow_gid']);
@ -167,7 +168,7 @@ class Compose extends BaseModule
$contact = Contact::getById($a->getContactId());
if ($this->pConfig->get(local_user(), 'system', 'set_creation_date')) {
if ($this->pConfig->get(Session::getLocalUser(), 'system', 'set_creation_date')) {
$created_at = Temporal::getDateTimeField(
new \DateTime(DBA::NULL_DATETIME),
new \DateTime('now'),
@ -203,8 +204,8 @@ class Compose extends BaseModule
'location_disabled' => $this->l10n->t('Location services are disabled. Please check the website\'s permissions on your device'),
'wait' => $this->l10n->t('Please wait'),
'placeholdertitle' => $this->l10n->t('Set title'),
'placeholdercategory' => Feature::isEnabled(local_user(),'categories') ? $this->l10n->t('Categories (comma-separated list)') : '',
'always_open_compose' => $this->pConfig->get(local_user(), 'frio', 'always_open_compose',
'placeholdercategory' => Feature::isEnabled(Session::getLocalUser(),'categories') ? $this->l10n->t('Categories (comma-separated list)') : '',
'always_open_compose' => $this->pConfig->get(Session::getLocalUser(), 'frio', 'always_open_compose',
$this->config->get('frio', 'always_open_compose', false)) ? '' :
$this->l10n->t('You can make this page always open when you use the New Post button in the <a href="/settings/display">Theme Customization settings</a>.'),
],

View File

@ -48,7 +48,7 @@ class Follow extends BaseModule
$itemId = intval($this->parameters['id']);
if (!Item::performActivity($itemId, 'follow', local_user())) {
if (!Item::performActivity($itemId, 'follow', Session::getLocalUser())) {
throw new HTTPException\BadRequestException($l10n->t('Unable to follow this item.'));
}

View File

@ -55,10 +55,10 @@ class Ignore extends BaseModule
throw new HTTPException\NotFoundException();
}
$ignored = !Post\ThreadUser::getIgnored($thread['uri-id'], local_user());
$ignored = !Post\ThreadUser::getIgnored($thread['uri-id'], Session::getLocalUser());
if (in_array($thread['uid'], [0, local_user()])) {
Post\ThreadUser::setIgnored($thread['uri-id'], local_user(), $ignored);
if (in_array($thread['uid'], [0, Session::getLocalUser()])) {
Post\ThreadUser::setIgnored($thread['uri-id'], Session::getLocalUser(), $ignored);
} else {
throw new HTTPException\BadRequestException();
}

View File

@ -53,16 +53,16 @@ class Pin extends BaseModule
throw new HTTPException\NotFoundException();
}
if (!in_array($item['uid'], [0, local_user()])) {
if (!in_array($item['uid'], [0, Session::getLocalUser()])) {
throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
}
$pinned = !$item['featured'];
if ($pinned) {
Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, $item['author-id'], local_user());
Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, $item['author-id'], Session::getLocalUser());
} else {
Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, local_user());
Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, Session::getLocalUser());
}
// See if we've been passed a return path to redirect to

View File

@ -50,13 +50,13 @@ class Star extends BaseModule
$itemId = intval($this->parameters['id']);
$item = Post::selectFirstForUser(local_user(), ['uid', 'uri-id', 'starred'], ['uid' => [0, local_user()], 'id' => $itemId]);
$item = Post::selectFirstForUser(Session::getLocalUser(), ['uid', 'uri-id', 'starred'], ['uid' => [0, Session::getLocalUser()], 'id' => $itemId]);
if (empty($item)) {
throw new HTTPException\NotFoundException();
}
if ($item['uid'] == 0) {
$stored = Item::storeForUserByUriId($item['uri-id'], local_user(), ['post-reason' => Item::PR_ACTIVITY]);
$stored = Item::storeForUserByUriId($item['uri-id'], Session::getLocalUser(), ['post-reason' => Item::PR_ACTIVITY]);
if (!empty($stored)) {
$item = Post::selectFirst(['starred'], ['id' => $stored]);
if (!DBA::isResult($item)) {

View File

@ -26,6 +26,7 @@ use Friendica\BaseModule;
use Friendica\Contact\Introduction\Repository\Introduction;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
@ -72,14 +73,14 @@ class Notification extends BaseModule
*/
protected function post(array $request = [])
{
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new HTTPException\UnauthorizedException($this->l10n->t('Permission denied.'));
}
$request_id = $this->parameters['id'] ?? false;
if ($request_id) {
$intro = $this->introductionRepo->selectOneById($request_id, local_user());
$intro = $this->introductionRepo->selectOneById($request_id, Session::getLocalUser());
switch ($_POST['submit']) {
case $this->l10n->t('Discard'):
@ -103,14 +104,14 @@ class Notification extends BaseModule
*/
protected function rawContent(array $request = [])
{
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new HTTPException\UnauthorizedException($this->l10n->t('Permission denied.'));
}
if ($this->args->get(1) === 'mark' && $this->args->get(2) === 'all') {
try {
$this->notificationRepo->setAllSeenForUser(local_user());
$success = $this->notifyRepo->setAllSeenForUser(local_user());
$this->notificationRepo->setAllSeenForUser(Session::getLocalUser());
$success = $this->notifyRepo->setAllSeenForUser(Session::getLocalUser());
} catch (\Exception $e) {
$this->logger->warning('set all seen failed.', ['exception' => $e]);
$success = false;
@ -131,7 +132,7 @@ class Notification extends BaseModule
*/
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice($this->l10n->t('You must be logged in to show this page.'));
return Login::form();
}
@ -150,11 +151,11 @@ class Notification extends BaseModule
private function handleNotify(int $notifyId)
{
$Notify = $this->notifyRepo->selectOneById($notifyId);
if ($Notify->uid !== local_user()) {
if ($Notify->uid !== Session::getLocalUser()) {
throw new HTTPException\ForbiddenException();
}
if ($this->pconfig->get(local_user(), 'system', 'detailed_notif')) {
if ($this->pconfig->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
$Notify->setSeen();
$this->notifyRepo->save($Notify);
} else {
@ -175,11 +176,11 @@ class Notification extends BaseModule
private function handleNotification(int $notificationId)
{
$Notification = $this->notificationRepo->selectOneById($notificationId);
if ($Notification->uid !== local_user()) {
if ($Notification->uid !== Session::getLocalUser()) {
throw new HTTPException\ForbiddenException();
}
if ($this->pconfig->get(local_user(), 'system', 'detailed_notif')) {
if ($this->pconfig->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
$Notification->setSeen();
$this->notificationRepo->save($Notification);
} else {