old boot.functions replaced in /mod

This commit is contained in:
Michael 2022-10-19 04:14:42 +00:00
parent ae82737445
commit 5874de4743
25 changed files with 193 additions and 176 deletions

View File

@ -116,7 +116,7 @@ function cal_content(App $a)
$remote_contact = $contact_id && DBA::exists('contact', ['id' => $contact_id, 'uid' => $owner['uid']]); $remote_contact = $contact_id && DBA::exists('contact', ['id' => $contact_id, 'uid' => $owner['uid']]);
$is_owner = local_user() == $owner['uid']; $is_owner = Session::getLocalUser() == $owner['uid'];
if ($owner['hidewall'] && !$is_owner && !$remote_contact) { if ($owner['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.'));
@ -278,7 +278,7 @@ function cal_content(App $a)
// If it the own calendar return to the events page // If it the own calendar return to the events page
// otherwise to the profile calendar page // otherwise to the profile calendar page
if (local_user() === $owner_uid) { if (Session::getLocalUser() === $owner_uid) {
$return_path = "events"; $return_path = "events";
} else { } else {
$return_path = "cal/" . $nick; $return_path = "cal/" . $nick;

View File

@ -53,7 +53,7 @@ function display_init(App $a)
$nick = ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : ''); $nick = ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : '');
$item = null; $item = null;
$item_user = local_user(); $item_user = Session::getLocalUser();
$fields = ['uri-id', 'parent-uri-id', 'author-id', 'author-link', 'body', 'uid', 'guid', 'gravity']; $fields = ['uri-id', 'parent-uri-id', 'author-id', 'author-link', 'body', 'uid', 'guid', 'gravity'];
@ -62,18 +62,18 @@ function display_init(App $a)
$nick = ''; $nick = '';
// Does the local user have this item? // Does the local user have this item?
if (local_user()) { if (Session::getLocalUser()) {
$item = Post::selectFirstForUser(local_user(), $fields, ['guid' => DI::args()->getArgv()[1], 'uid' => local_user()]); $item = Post::selectFirstForUser(Session::getLocalUser(), $fields, ['guid' => DI::args()->getArgv()[1], 'uid' => Session::getLocalUser()]);
if (DBA::isResult($item)) { if (DBA::isResult($item)) {
$nick = $a->getLoggedInUserNickname(); $nick = $a->getLoggedInUserNickname();
} }
} }
// Is this item private but could be visible to the remove visitor? // Is this item private but could be visible to the remove visitor?
if (!DBA::isResult($item) && remote_user()) { if (!DBA::isResult($item) && Session::getRemoteUser()) {
$item = Post::selectFirst($fields, ['guid' => DI::args()->getArgv()[1], 'private' => Item::PRIVATE, 'origin' => true]); $item = Post::selectFirst($fields, ['guid' => DI::args()->getArgv()[1], 'private' => Item::PRIVATE, 'origin' => true]);
if (DBA::isResult($item)) { if (DBA::isResult($item)) {
if (!Contact::isFollower(remote_user(), $item['uid'])) { if (!Contact::isFollower(Session::getRemoteUser(), $item['uid'])) {
$item = null; $item = null;
} else { } else {
$item_user = $item['uid']; $item_user = $item['uid'];
@ -83,14 +83,14 @@ function display_init(App $a)
// Is it an item with uid=0? // Is it an item with uid=0?
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
$item = Post::selectFirstForUser(local_user(), $fields, ['guid' => DI::args()->getArgv()[1], 'private' => [Item::PUBLIC, Item::UNLISTED], 'uid' => 0]); $item = Post::selectFirstForUser(Session::getLocalUser(), $fields, ['guid' => DI::args()->getArgv()[1], 'private' => [Item::PUBLIC, Item::UNLISTED], 'uid' => 0]);
} }
} elseif (DI::args()->getArgc() >= 3 && $nick == 'feed-item') { } elseif (DI::args()->getArgc() >= 3 && $nick == 'feed-item') {
$uri_id = DI::args()->getArgv()[2]; $uri_id = DI::args()->getArgv()[2];
if (substr($uri_id, -5) == '.atom') { if (substr($uri_id, -5) == '.atom') {
$uri_id = substr($uri_id, 0, -5); $uri_id = substr($uri_id, 0, -5);
} }
$item = Post::selectFirstForUser(local_user(), $fields, ['uri-id' => $uri_id, 'private' => [Item::PUBLIC, Item::UNLISTED], 'uid' => 0]); $item = Post::selectFirstForUser(Session::getLocalUser(), $fields, ['uri-id' => $uri_id, 'private' => [Item::PUBLIC, Item::UNLISTED], 'uid' => 0]);
} }
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
@ -126,7 +126,7 @@ function display_fetchauthor($item)
if (Diaspora::isReshare($item['body'], true)) { if (Diaspora::isReshare($item['body'], true)) {
$shared = Item::getShareArray($item); $shared = Item::getShareArray($item);
if (!empty($shared['profile'])) { if (!empty($shared['profile'])) {
$contact = Contact::getByURLForUser($shared['profile'], local_user()); $contact = Contact::getByURLForUser($shared['profile'], Session::getLocalUser());
} }
} }
@ -181,18 +181,18 @@ function display_content(App $a, $update = false, $update_uid = 0)
if (DI::args()->getArgc() == 2) { if (DI::args()->getArgc() == 2) {
$fields = ['uri-id', 'parent-uri-id', 'uid']; $fields = ['uri-id', 'parent-uri-id', 'uid'];
if (local_user()) { if (Session::getLocalUser()) {
$condition = ['guid' => DI::args()->getArgv()[1], 'uid' => [0, local_user()]]; $condition = ['guid' => DI::args()->getArgv()[1], 'uid' => [0, Session::getLocalUser()]];
$item = Post::selectFirstForUser(local_user(), $fields, $condition, ['order' => ['uid' => true]]); $item = Post::selectFirstForUser(Session::getLocalUser(), $fields, $condition, ['order' => ['uid' => true]]);
if (DBA::isResult($item)) { if (DBA::isResult($item)) {
$uri_id = $item['uri-id']; $uri_id = $item['uri-id'];
$parent_uri_id = $item['parent-uri-id']; $parent_uri_id = $item['parent-uri-id'];
} }
} }
if (($parent_uri_id == 0) && remote_user()) { if (($parent_uri_id == 0) && Session::getRemoteUser()) {
$item = Post::selectFirst($fields, ['guid' => DI::args()->getArgv()[1], 'private' => Item::PRIVATE, 'origin' => true]); $item = Post::selectFirst($fields, ['guid' => DI::args()->getArgv()[1], 'private' => Item::PRIVATE, 'origin' => true]);
if (DBA::isResult($item) && Contact::isFollower(remote_user(), $item['uid'])) { if (DBA::isResult($item) && Contact::isFollower(Session::getRemoteUser(), $item['uid'])) {
$uri_id = $item['uri-id']; $uri_id = $item['uri-id'];
$parent_uri_id = $item['parent-uri-id']; $parent_uri_id = $item['parent-uri-id'];
} }
@ -200,7 +200,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
if ($parent_uri_id == 0) { if ($parent_uri_id == 0) {
$condition = ['private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => DI::args()->getArgv()[1], 'uid' => 0]; $condition = ['private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => DI::args()->getArgv()[1], 'uid' => 0];
$item = Post::selectFirstForUser(local_user(), $fields, $condition); $item = Post::selectFirstForUser(Session::getLocalUser(), $fields, $condition);
if (DBA::isResult($item)) { if (DBA::isResult($item)) {
$uri_id = $item['uri-id']; $uri_id = $item['uri-id'];
$parent_uri_id = $item['parent-uri-id']; $parent_uri_id = $item['parent-uri-id'];
@ -213,9 +213,9 @@ function display_content(App $a, $update = false, $update_uid = 0)
throw new HTTPException\NotFoundException(DI::l10n()->t('The requested item doesn\'t exist or has been deleted.')); throw new HTTPException\NotFoundException(DI::l10n()->t('The requested item doesn\'t exist or has been deleted.'));
} }
if (!DI::pConfig()->get(local_user(), 'system', 'detailed_notif')) { if (!DI::pConfig()->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
DI::notification()->setAllSeenForUser(local_user(), ['parent-uri-id' => $item['parent-uri-id']]); DI::notification()->setAllSeenForUser(Session::getLocalUser(), ['parent-uri-id' => $item['parent-uri-id']]);
DI::notify()->setAllSeenForUser(local_user(), ['parent-uri-id' => $item['parent-uri-id']]); DI::notify()->setAllSeenForUser(Session::getLocalUser(), ['parent-uri-id' => $item['parent-uri-id']]);
} }
// We are displaying an "alternate" link if that post was public. See issue 2864 // We are displaying an "alternate" link if that post was public. See issue 2864
@ -234,11 +234,11 @@ function display_content(App $a, $update = false, $update_uid = 0)
'$conversation' => $conversation]); '$conversation' => $conversation]);
$is_remote_contact = false; $is_remote_contact = false;
$item_uid = local_user(); $item_uid = Session::getLocalUser();
$page_uid = 0; $page_uid = 0;
$parent = null; $parent = null;
if (!local_user() && !empty($parent_uri_id)) { if (!Session::getLocalUser() && !empty($parent_uri_id)) {
$parent = Post::selectFirst(['uid'], ['uri-id' => $parent_uri_id, 'wall' => true]); $parent = Post::selectFirst(['uid'], ['uri-id' => $parent_uri_id, 'wall' => true]);
} }
@ -252,11 +252,11 @@ function display_content(App $a, $update = false, $update_uid = 0)
$page_uid = $item['uid']; $page_uid = $item['uid'];
} }
if (!empty($page_uid) && ($page_uid != local_user())) { if (!empty($page_uid) && ($page_uid != Session::getLocalUser())) {
$page_user = User::getById($page_uid); $page_user = User::getById($page_uid);
} }
$is_owner = local_user() && (in_array($page_uid, [local_user(), 0])); $is_owner = Session::getLocalUser() && (in_array($page_uid, [Session::getLocalUser(), 0]));
if (!empty($page_user['hidewall']) && !$is_owner && !$is_remote_contact) { if (!empty($page_user['hidewall']) && !$is_owner && !$is_remote_contact) {
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.'));
@ -268,8 +268,8 @@ function display_content(App $a, $update = false, $update_uid = 0)
} }
$sql_extra = Item::getPermissionsSQLByUserId($page_uid); $sql_extra = Item::getPermissionsSQLByUserId($page_uid);
if (local_user() && (local_user() == $page_uid)) { if (Session::getLocalUser() && (Session::getLocalUser() == $page_uid)) {
$condition = ['parent-uri-id' => $parent_uri_id, 'uid' => local_user(), 'unseen' => true]; $condition = ['parent-uri-id' => $parent_uri_id, 'uid' => Session::getLocalUser(), 'unseen' => true];
$unseen = Post::exists($condition); $unseen = Post::exists($condition);
} else { } else {
$unseen = false; $unseen = false;
@ -290,11 +290,11 @@ function display_content(App $a, $update = false, $update_uid = 0)
$item['uri-id'] = $item['parent-uri-id']; $item['uri-id'] = $item['parent-uri-id'];
if ($unseen) { if ($unseen) {
$condition = ['parent-uri-id' => $parent_uri_id, 'uid' => local_user(), 'unseen' => true]; $condition = ['parent-uri-id' => $parent_uri_id, 'uid' => Session::getLocalUser(), 'unseen' => true];
Item::update(['unseen' => false], $condition); Item::update(['unseen' => false], $condition);
} }
if (!$update && local_user()) { if (!$update && Session::getLocalUser()) {
$o .= "<script> var netargs = '?uri_id=" . $item['uri-id'] . "'; </script>"; $o .= "<script> var netargs = '?uri_id=" . $item['uri-id'] . "'; </script>";
} }

View File

@ -23,6 +23,7 @@ use Friendica\App;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Core\Hook; use Friendica\Core\Hook;
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\Contact; use Friendica\Model\Contact;
@ -34,7 +35,7 @@ function editpost_content(App $a)
{ {
$o = ''; $o = '';
if (!local_user()) { if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return; return;
} }
@ -49,14 +50,14 @@ function editpost_content(App $a)
$fields = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', $fields = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
'body', 'title', 'uri-id', 'wall', 'post-type', 'guid']; 'body', 'title', 'uri-id', 'wall', 'post-type', 'guid'];
$item = Post::selectFirstForUser(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]); $item = Post::selectFirstForUser(Session::getLocalUser(), $fields, ['id' => $post_id, 'uid' => Session::getLocalUser()]);
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Item not found')); DI::sysmsg()->addNotice(DI::l10n()->t('Item not found'));
return; return;
} }
$user = User::getById(local_user()); $user = User::getById(Session::getLocalUser());
$geotag = ''; $geotag = '';
@ -118,8 +119,8 @@ function editpost_content(App $a)
'$jotnets' => $jotnets, '$jotnets' => $jotnets,
'$title' => $item['title'], '$title' => $item['title'],
'$placeholdertitle' => DI::l10n()->t('Set title'), '$placeholdertitle' => DI::l10n()->t('Set title'),
'$category' => Post\Category::getCSVByURIId($item['uri-id'], local_user(), Post\Category::CATEGORY), '$category' => Post\Category::getCSVByURIId($item['uri-id'], Session::getLocalUser(), Post\Category::CATEGORY),
'$placeholdercategory' => (Feature::isEnabled(local_user(),'categories') ? DI::l10n()->t("Categories \x28comma-separated list\x29") : ''), '$placeholdercategory' => (Feature::isEnabled(Session::getLocalUser(),'categories') ? DI::l10n()->t("Categories \x28comma-separated list\x29") : ''),
'$emtitle' => DI::l10n()->t('Example: bob@example.com, mary@example.com'), '$emtitle' => DI::l10n()->t('Example: bob@example.com, mary@example.com'),
'$lockstate' => $lockstate, '$lockstate' => $lockstate,
'$acl' => '', // populate_acl((($group) ? $group_acl : $a->user)), '$acl' => '', // populate_acl((($group) ? $group_acl : $a->user)),

View File

@ -27,6 +27,7 @@ use Friendica\Core\ACL;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Theme; use Friendica\Core\Theme;
use Friendica\Core\Worker; use Friendica\Core\Worker;
@ -46,7 +47,7 @@ use Friendica\Worker\Delivery;
function events_init(App $a) function events_init(App $a)
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
return; return;
} }
@ -54,7 +55,7 @@ function events_init(App $a)
DI::page()['aside'] = ''; DI::page()['aside'] = '';
} }
$cal_widget = CalendarExport::getHTML(local_user()); $cal_widget = CalendarExport::getHTML(Session::getLocalUser());
DI::page()['aside'] .= $cal_widget; DI::page()['aside'] .= $cal_widget;
@ -64,13 +65,13 @@ function events_init(App $a)
function events_post(App $a) function events_post(App $a)
{ {
Logger::debug('post', ['request' => $_REQUEST]); Logger::debug('post', ['request' => $_REQUEST]);
if (!local_user()) { if (!Session::getLocalUser()) {
return; return;
} }
$event_id = !empty($_POST['event_id']) ? intval($_POST['event_id']) : 0; $event_id = !empty($_POST['event_id']) ? intval($_POST['event_id']) : 0;
$cid = !empty($_POST['cid']) ? intval($_POST['cid']) : 0; $cid = !empty($_POST['cid']) ? intval($_POST['cid']) : 0;
$uid = local_user(); $uid = Session::getLocalUser();
$start_text = Strings::escapeHtml($_REQUEST['start_text'] ?? ''); $start_text = Strings::escapeHtml($_REQUEST['start_text'] ?? '');
$finish_text = Strings::escapeHtml($_REQUEST['finish_text'] ?? ''); $finish_text = Strings::escapeHtml($_REQUEST['finish_text'] ?? '');
@ -214,7 +215,7 @@ function events_post(App $a)
function events_content(App $a) function events_content(App $a)
{ {
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();
} }
@ -224,11 +225,11 @@ function events_content(App $a)
} }
if ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[1] === 'ignore') && intval(DI::args()->getArgv()[2])) { if ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[1] === 'ignore') && intval(DI::args()->getArgv()[2])) {
DBA::update('event', ['ignore' => true], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]); DBA::update('event', ['ignore' => true], ['id' => DI::args()->getArgv()[2], 'uid' => Session::getLocalUser()]);
} }
if ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[1] === 'unignore') && intval(DI::args()->getArgv()[2])) { if ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[1] === 'unignore') && intval(DI::args()->getArgv()[2])) {
DBA::update('event', ['ignore' => false], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]); DBA::update('event', ['ignore' => false], ['id' => DI::args()->getArgv()[2], 'uid' => Session::getLocalUser()]);
} }
if ($a->getThemeInfoValue('events_in_profile')) { if ($a->getThemeInfoValue('events_in_profile')) {
@ -323,9 +324,9 @@ function events_content(App $a)
// get events by id or by date // get events by id or by date
if ($event_params['event_id']) { if ($event_params['event_id']) {
$r = Event::getListById(local_user(), $event_params['event_id']); $r = Event::getListById(Session::getLocalUser(), $event_params['event_id']);
} else { } else {
$r = Event::getListByDate(local_user(), $event_params); $r = Event::getListByDate(Session::getLocalUser(), $event_params);
} }
$links = []; $links = [];
@ -396,7 +397,7 @@ function events_content(App $a)
} }
if (($mode === 'edit' || $mode === 'copy') && $event_id) { if (($mode === 'edit' || $mode === 'copy') && $event_id) {
$orig_event = DBA::selectFirst('event', [], ['id' => $event_id, 'uid' => local_user()]); $orig_event = DBA::selectFirst('event', [], ['id' => $event_id, 'uid' => Session::getLocalUser()]);
} }
// Passed parameters overrides anything found in the DB // Passed parameters overrides anything found in the DB
@ -405,8 +406,8 @@ function events_content(App $a)
$share_disabled = ''; $share_disabled = '';
if (empty($orig_event)) { if (empty($orig_event)) {
$orig_event = User::getById(local_user(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']);; $orig_event = User::getById(Session::getLocalUser(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']);;
} elseif ($orig_event['allow_cid'] !== '<' . local_user() . '>' } elseif ($orig_event['allow_cid'] !== '<' . Session::getLocalUser() . '>'
|| $orig_event['allow_gid'] || $orig_event['allow_gid']
|| $orig_event['deny_cid'] || $orig_event['deny_cid']
|| $orig_event['deny_gid']) { || $orig_event['deny_gid']) {
@ -524,11 +525,11 @@ function events_content(App $a)
// Remove an event from the calendar and its related items // Remove an event from the calendar and its related items
if ($mode === 'drop' && $event_id) { if ($mode === 'drop' && $event_id) {
$ev = Event::getListById(local_user(), $event_id); $ev = Event::getListById(Session::getLocalUser(), $event_id);
// Delete only real events (no birthdays) // Delete only real events (no birthdays)
if (DBA::isResult($ev) && $ev[0]['type'] == 'event') { if (DBA::isResult($ev) && $ev[0]['type'] == 'event') {
Item::deleteForUser(['id' => $ev[0]['itemid']], local_user()); Item::deleteForUser(['id' => $ev[0]['itemid']], Session::getLocalUser());
} }
if (Post::exists(['id' => $ev[0]['itemid']])) { if (Post::exists(['id' => $ev[0]['itemid']])) {

View File

@ -24,6 +24,7 @@
use Friendica\App; use Friendica\App;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
@ -38,7 +39,7 @@ use Friendica\Util\Strings;
*/ */
function fbrowser_content(App $a) function fbrowser_content(App $a)
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
System::exit(); System::exit();
} }
@ -65,7 +66,7 @@ function fbrowser_content(App $a)
if (DI::args()->getArgc() == 2) { if (DI::args()->getArgc() == 2) {
$photos = DBA::toArray(DBA::p("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = ? AND NOT `photo-type` IN (?, ?)", $photos = DBA::toArray(DBA::p("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = ? AND NOT `photo-type` IN (?, ?)",
local_user(), Session::getLocalUser(),
Photo::CONTACT_AVATAR, Photo::CONTACT_AVATAR,
Photo::CONTACT_BANNER Photo::CONTACT_BANNER
)); ));
@ -84,7 +85,7 @@ function fbrowser_content(App $a)
min(`scale`) AS `hiq`, max(`scale`) AS `loq`, ANY_VALUE(`desc`) AS `desc`, ANY_VALUE(`created`) AS `created` min(`scale`) AS `hiq`, max(`scale`) AS `loq`, ANY_VALUE(`desc`) AS `desc`, ANY_VALUE(`created`) AS `created`
FROM `photo` WHERE `uid` = ? $sql_extra AND NOT `photo-type` IN (?, ?) FROM `photo` WHERE `uid` = ? $sql_extra AND NOT `photo-type` IN (?, ?)
GROUP BY `resource-id` $sql_extra2", GROUP BY `resource-id` $sql_extra2",
local_user(), Session::getLocalUser(),
Photo::CONTACT_AVATAR, Photo::CONTACT_AVATAR,
Photo::CONTACT_BANNER Photo::CONTACT_BANNER
)); ));
@ -124,7 +125,7 @@ function fbrowser_content(App $a)
break; break;
case "file": case "file":
if (DI::args()->getArgc()==2) { if (DI::args()->getArgc()==2) {
$files = DBA::selectToArray('attach', ['id', 'filename', 'filetype'], ['uid' => local_user()]); $files = DBA::selectToArray('attach', ['id', 'filename', 'filetype'], ['uid' => Session::getLocalUser()]);
function _map_files2($rr) function _map_files2($rr)
{ {

View File

@ -23,6 +23,7 @@ use Friendica\App;
use Friendica\Content\Widget; use Friendica\Content\Widget;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile; use Friendica\Model\Profile;
@ -35,7 +36,7 @@ use Friendica\Util\Strings;
function follow_post(App $a) function follow_post(App $a)
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Access denied.')); throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
} }
@ -52,13 +53,13 @@ function follow_content(App $a)
{ {
$return_path = 'contact'; $return_path = 'contact';
if (!local_user()) { if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect($return_path); DI::baseUrl()->redirect($return_path);
// NOTREACHED // NOTREACHED
} }
$uid = local_user(); $uid = Session::getLocalUser();
$url = Probe::cleanURI(trim($_REQUEST['url'] ?? '')); $url = Probe::cleanURI(trim($_REQUEST['url'] ?? ''));
@ -195,7 +196,7 @@ function follow_process(App $a, string $url)
function follow_remote_item($url) function follow_remote_item($url)
{ {
$item_id = Item::fetchByLink($url, local_user()); $item_id = Item::fetchByLink($url, 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($url); $item_id = Item::fetchByLink($url);

View File

@ -62,7 +62,7 @@ function item_post(App $a) {
throw new HTTPException\ForbiddenException(); throw new HTTPException\ForbiddenException();
} }
$uid = local_user(); $uid = Session::getLocalUser();
if (!empty($_REQUEST['dropitems'])) { if (!empty($_REQUEST['dropitems'])) {
$arr_drop = explode(',', $_REQUEST['dropitems']); $arr_drop = explode(',', $_REQUEST['dropitems']);
@ -107,7 +107,7 @@ function item_post(App $a) {
$toplevel_user_id = null; $toplevel_user_id = null;
$objecttype = null; $objecttype = null;
$profile_uid = ($_REQUEST['profile_uid'] ?? 0) ?: local_user(); $profile_uid = ($_REQUEST['profile_uid'] ?? 0) ?: Session::getLocalUser();
$posttype = ($_REQUEST['post_type'] ?? '') ?: Item::PT_ARTICLE; $posttype = ($_REQUEST['post_type'] ?? '') ?: Item::PT_ARTICLE;
if ($parent_item_id || $thr_parent_uri) { if ($parent_item_id || $thr_parent_uri) {
@ -139,7 +139,7 @@ function item_post(App $a) {
// When commenting on a public post then store the post for the current user // When commenting on a public post then store the post for the current user
// This enables interaction like starring and saving into folders // This enables interaction like starring and saving into folders
if ($toplevel_item['uid'] == 0) { if ($toplevel_item['uid'] == 0) {
$stored = Item::storeForUserByUriId($toplevel_item['uri-id'], local_user(), ['post-reason' => Item::PR_ACTIVITY]); $stored = Item::storeForUserByUriId($toplevel_item['uri-id'], Session::getLocalUser(), ['post-reason' => Item::PR_ACTIVITY]);
Logger::info('Public item stored for user', ['uri-id' => $toplevel_item['uri-id'], 'uid' => $uid, 'stored' => $stored]); Logger::info('Public item stored for user', ['uri-id' => $toplevel_item['uri-id'], 'uid' => $uid, 'stored' => $stored]);
if ($stored) { if ($stored) {
$toplevel_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $stored]); $toplevel_item = Post::selectFirst(Item::ITEM_FIELDLIST, ['id' => $stored]);
@ -169,16 +169,16 @@ function item_post(App $a) {
} }
// Ensure that the user id in a thread always stay the same // Ensure that the user id in a thread always stay the same
if (!is_null($toplevel_user_id) && in_array($toplevel_user_id, [local_user(), 0])) { if (!is_null($toplevel_user_id) && in_array($toplevel_user_id, [Session::getLocalUser(), 0])) {
$profile_uid = $toplevel_user_id; $profile_uid = $toplevel_user_id;
} }
// Allow commenting if it is an answer to a public post // Allow commenting if it is an answer to a public post
$allow_comment = local_user() && $toplevel_item_id && in_array($toplevel_item['private'], [Item::PUBLIC, Item::UNLISTED]) && in_array($toplevel_item['network'], Protocol::FEDERATED); $allow_comment = Session::getLocalUser() && $toplevel_item_id && in_array($toplevel_item['private'], [Item::PUBLIC, Item::UNLISTED]) && in_array($toplevel_item['network'], Protocol::FEDERATED);
// Now check that valid personal details have been provided // Now check that valid personal details have been provided
if (!Security::canWriteToUserWall($profile_uid) && !$allow_comment) { if (!Security::canWriteToUserWall($profile_uid) && !$allow_comment) {
Logger::warning('Permission denied.', ['local' => local_user(), 'profile_uid' => $profile_uid, 'toplevel_item_id' => $toplevel_item_id, 'network' => $toplevel_item['network']]); Logger::warning('Permission denied.', ['local' => Session::getLocalUser(), 'profile_uid' => $profile_uid, 'toplevel_item_id' => $toplevel_item_id, 'network' => $toplevel_item['network']]);
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
if ($return_path) { if ($return_path) {
DI::baseUrl()->redirect($return_path); DI::baseUrl()->redirect($return_path);
@ -324,9 +324,9 @@ function item_post(App $a) {
$pubmail_enabled = ($_REQUEST['pubmail_enable'] ?? false) && !$private; $pubmail_enabled = ($_REQUEST['pubmail_enable'] ?? false) && !$private;
// if using the API, we won't see pubmail_enable - figure out if it should be set // if using the API, we won't see pubmail_enable - figure out if it should be set
if ($api_source && $profile_uid && $profile_uid == local_user() && !$private) { if ($api_source && $profile_uid && $profile_uid == Session::getLocalUser() && !$private) {
if (function_exists('imap_open') && !DI::config()->get('system', 'imap_disabled')) { if (function_exists('imap_open') && !DI::config()->get('system', 'imap_disabled')) {
$pubmail_enabled = DBA::exists('mailacct', ["`uid` = ? AND `server` != ? AND `pubmail`", local_user(), '']); $pubmail_enabled = DBA::exists('mailacct', ["`uid` = ? AND `server` != ? AND `pubmail`", Session::getLocalUser(), '']);
} }
} }
@ -363,9 +363,9 @@ function item_post(App $a) {
$self = false; $self = false;
$contact_id = 0; $contact_id = 0;
if (local_user() && ((local_user() == $profile_uid) || $allow_comment)) { if (Session::getLocalUser() && ((Session::getLocalUser() == $profile_uid) || $allow_comment)) {
$self = true; $self = true;
$author = DBA::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]); $author = DBA::selectFirst('contact', [], ['uid' => Session::getLocalUser(), 'self' => true]);
} elseif (!empty(Session::getRemoteContactID($profile_uid))) { } elseif (!empty(Session::getRemoteContactID($profile_uid))) {
$author = DBA::selectFirst('contact', [], ['id' => Session::getRemoteContactID($profile_uid)]); $author = DBA::selectFirst('contact', [], ['id' => Session::getRemoteContactID($profile_uid)]);
} }
@ -375,7 +375,7 @@ function item_post(App $a) {
} }
// get contact info for owner // get contact info for owner
if ($profile_uid == local_user() || $allow_comment) { if ($profile_uid == Session::getLocalUser() || $allow_comment) {
$contact_record = $author ?: []; $contact_record = $author ?: [];
} else { } else {
$contact_record = DBA::selectFirst('contact', [], ['uid' => $profile_uid, 'self' => true]) ?: []; $contact_record = DBA::selectFirst('contact', [], ['uid' => $profile_uid, 'self' => true]) ?: [];
@ -385,7 +385,7 @@ function item_post(App $a) {
if ($posttype != Item::PT_PERSONAL_NOTE) { if ($posttype != Item::PT_PERSONAL_NOTE) {
// Look for any tags and linkify them // Look for any tags and linkify them
$item = [ $item = [
'uid' => local_user() ? local_user() : $profile_uid, 'uid' => Session::getLocalUser() ? Session::getLocalUser() : $profile_uid,
'gravity' => $toplevel_item_id ? Item::GRAVITY_COMMENT : Item::GRAVITY_PARENT, 'gravity' => $toplevel_item_id ? Item::GRAVITY_COMMENT : Item::GRAVITY_PARENT,
'network' => $network, 'network' => $network,
'body' => $body, 'body' => $body,
@ -734,7 +734,7 @@ function item_post(App $a) {
Hook::callAll('post_local_end', $datarray); Hook::callAll('post_local_end', $datarray);
if (strlen($emailcc) && $profile_uid == local_user()) { if (strlen($emailcc) && $profile_uid == Session::getLocalUser()) {
$recipients = explode(',', $emailcc); $recipients = explode(',', $emailcc);
if (count($recipients)) { if (count($recipients)) {
foreach ($recipients as $recipient) { foreach ($recipients as $recipient) {
@ -794,9 +794,9 @@ function item_content(App $a)
switch ($args->get(1)) { switch ($args->get(1)) {
case 'drop': case 'drop':
if (DI::mode()->isAjax()) { if (DI::mode()->isAjax()) {
Item::deleteForUser(['id' => $args->get(2)], local_user()); Item::deleteForUser(['id' => $args->get(2)], Session::getLocalUser());
// ajax return: [<item id>, 0 (no perm) | <owner id>] // ajax return: [<item id>, 0 (no perm) | <owner id>]
System::jsonExit([intval($args->get(2)), local_user()]); System::jsonExit([intval($args->get(2)), Session::getLocalUser()]);
} else { } else {
if (!empty($args->get(3))) { if (!empty($args->get(3))) {
$o = drop_item($args->get(2), $args->get(3)); $o = drop_item($args->get(2), $args->get(3));
@ -807,16 +807,16 @@ function item_content(App $a)
break; break;
case 'block': case 'block':
$item = Post::selectFirstForUser(local_user(), ['guid', 'author-id', 'parent', 'gravity'], ['id' => $args->get(2)]); $item = Post::selectFirstForUser(Session::getLocalUser(), ['guid', 'author-id', 'parent', 'gravity'], ['id' => $args->get(2)]);
if (empty($item['author-id'])) { if (empty($item['author-id'])) {
throw new HTTPException\NotFoundException('Item not found'); throw new HTTPException\NotFoundException('Item not found');
} }
Contact\User::setBlocked($item['author-id'], local_user(), true); Contact\User::setBlocked($item['author-id'], Session::getLocalUser(), true);
if (DI::mode()->isAjax()) { if (DI::mode()->isAjax()) {
// ajax return: [<item id>, 0 (no perm) | <owner id>] // ajax return: [<item id>, 0 (no perm) | <owner id>]
System::jsonExit([intval($args->get(2)), local_user()]); System::jsonExit([intval($args->get(2)), Session::getLocalUser()]);
} else { } else {
item_redirect_after_action($item, $args->get(3)); item_redirect_after_action($item, $args->get(3));
} }
@ -835,7 +835,7 @@ function item_content(App $a)
function drop_item(int $id, string $return = ''): string function drop_item(int $id, string $return = ''): string
{ {
// Locate item to be deleted // Locate item to be deleted
$item = Post::selectFirstForUser(local_user(), ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', 'parent'], ['id' => $id]); $item = Post::selectFirstForUser(Session::getLocalUser(), ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', 'parent'], ['id' => $id]);
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Item not found.')); DI::sysmsg()->addNotice(DI::l10n()->t('Item not found.'));
@ -854,14 +854,14 @@ function drop_item(int $id, string $return = ''): string
$contact_id = $item['contact-id']; $contact_id = $item['contact-id'];
} }
if ((local_user() == $item['uid']) || $contact_id) { if ((Session::getLocalUser() == $item['uid']) || $contact_id) {
// delete the item // delete the item
Item::deleteForUser(['id' => $item['id']], local_user()); Item::deleteForUser(['id' => $item['id']], Session::getLocalUser());
item_redirect_after_action($item, $return); item_redirect_after_action($item, $return);
//NOTREACHED //NOTREACHED
} else { } else {
Logger::warning('Permission denied.', ['local' => local_user(), 'uid' => $item['uid'], 'cid' => $contact_id]); Logger::warning('Permission denied.', ['local' => Session::getLocalUser(), 'uid' => $item['uid'], 'cid' => $contact_id]);
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('display/' . $item['guid']); DI::baseUrl()->redirect('display/' . $item['guid']);
//NOTREACHED //NOTREACHED
@ -880,7 +880,7 @@ function item_redirect_after_action(array $item, string $returnUrlHex)
// Check if delete a comment // Check if delete a comment
if ($item['gravity'] == Item::GRAVITY_COMMENT) { if ($item['gravity'] == Item::GRAVITY_COMMENT) {
if (!empty($item['parent'])) { if (!empty($item['parent'])) {
$parentitem = Post::selectFirstForUser(local_user(), ['guid'], ['id' => $item['parent']]); $parentitem = Post::selectFirstForUser(Session::getLocalUser(), ['guid'], ['id' => $item['parent']]);
} }
// Return to parent guid // Return to parent guid

View File

@ -23,6 +23,7 @@ use Friendica\App;
use Friendica\Content\Widget; use Friendica\Content\Widget;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Search; use Friendica\Core\Search;
use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
@ -44,7 +45,7 @@ use Friendica\Module\Contact as ModuleContact;
*/ */
function match_content(App $a) function match_content(App $a)
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
return ''; return '';
} }
@ -53,7 +54,7 @@ function match_content(App $a)
$_SESSION['return_path'] = DI::args()->getCommand(); $_SESSION['return_path'] = DI::args()->getCommand();
$profile = Profile::getByUID(local_user()); $profile = Profile::getByUID(Session::getLocalUser());
if (!DBA::isResult($profile)) { if (!DBA::isResult($profile)) {
return ''; return '';
@ -67,10 +68,10 @@ function match_content(App $a)
$tags = trim($profile['pub_keywords'] . ' ' . $profile['prv_keywords']); $tags = trim($profile['pub_keywords'] . ' ' . $profile['prv_keywords']);
if (DI::mode()->isMobile()) { if (DI::mode()->isMobile()) {
$limit = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network', $limit = 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 {
$limit = DI::pConfig()->get(local_user(), 'system', 'itemspage_network', $limit = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network')); DI::config()->get('system', 'itemspage_network'));
} }
@ -114,12 +115,12 @@ function match_get_contacts($msearch, $entries, $limit)
} }
// Already known contact // Already known contact
$contact = Contact::getByURL($profile->url, null, ['rel'], local_user()); $contact = Contact::getByURL($profile->url, null, ['rel'], Session::getLocalUser());
if (!empty($contact) && in_array($contact['rel'], [Contact::FRIEND, Contact::SHARING])) { if (!empty($contact) && in_array($contact['rel'], [Contact::FRIEND, Contact::SHARING])) {
continue; continue;
} }
$contact = Contact::getByURLForUser($profile->url, local_user()); $contact = Contact::getByURLForUser($profile->url, Session::getLocalUser());
if (!empty($contact)) { if (!empty($contact)) {
$entries[$contact['id']] = ModuleContact::getContactTemplateVars($contact); $entries[$contact['id']] = ModuleContact::getContactTemplateVars($contact);
} }

View File

@ -25,6 +25,7 @@ use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Core\ACL; use Friendica\Core\ACL;
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\Contact; use Friendica\Model\Contact;
@ -39,7 +40,7 @@ function message_init(App $a)
$tabs = ''; $tabs = '';
if (DI::args()->getArgc() > 1 && is_numeric(DI::args()->getArgv()[1])) { if (DI::args()->getArgc() > 1 && is_numeric(DI::args()->getArgv()[1])) {
$tabs = render_messages(get_messages(local_user(), 0, 5), 'mail_list.tpl'); $tabs = render_messages(get_messages(Session::getLocalUser(), 0, 5), 'mail_list.tpl');
} }
$new = [ $new = [
@ -65,7 +66,7 @@ function message_init(App $a)
function message_post(App $a) function message_post(App $a)
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return; return;
} }
@ -110,7 +111,7 @@ function message_content(App $a)
$o = ''; $o = '';
Nav::setSelected('messages'); Nav::setSelected('messages');
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();
} }
@ -144,28 +145,28 @@ function message_content(App $a)
$cmd = DI::args()->getArgv()[1]; $cmd = DI::args()->getArgv()[1];
if ($cmd === 'drop') { if ($cmd === 'drop') {
$message = DBA::selectFirst('mail', ['convid'], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]); $message = DBA::selectFirst('mail', ['convid'], ['id' => DI::args()->getArgv()[2], 'uid' => Session::getLocalUser()]);
if(!DBA::isResult($message)){ if(!DBA::isResult($message)){
DI::sysmsg()->addNotice(DI::l10n()->t('Conversation not found.')); DI::sysmsg()->addNotice(DI::l10n()->t('Conversation not found.'));
DI::baseUrl()->redirect('message'); DI::baseUrl()->redirect('message');
} }
if (!DBA::delete('mail', ['id' => DI::args()->getArgv()[2], 'uid' => local_user()])) { if (!DBA::delete('mail', ['id' => DI::args()->getArgv()[2], 'uid' => Session::getLocalUser()])) {
DI::sysmsg()->addNotice(DI::l10n()->t('Message was not deleted.')); DI::sysmsg()->addNotice(DI::l10n()->t('Message was not deleted.'));
} }
$conversation = DBA::selectFirst('mail', ['id'], ['convid' => $message['convid'], 'uid' => local_user()]); $conversation = DBA::selectFirst('mail', ['id'], ['convid' => $message['convid'], 'uid' => Session::getLocalUser()]);
if(!DBA::isResult($conversation)){ if(!DBA::isResult($conversation)){
DI::baseUrl()->redirect('message'); DI::baseUrl()->redirect('message');
} }
DI::baseUrl()->redirect('message/' . $conversation['id'] ); DI::baseUrl()->redirect('message/' . $conversation['id'] );
} else { } else {
$parentmail = DBA::selectFirst('mail', ['parent-uri'], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]); $parentmail = DBA::selectFirst('mail', ['parent-uri'], ['id' => DI::args()->getArgv()[2], 'uid' => Session::getLocalUser()]);
if (DBA::isResult($parentmail)) { if (DBA::isResult($parentmail)) {
$parent = $parentmail['parent-uri']; $parent = $parentmail['parent-uri'];
if (!DBA::delete('mail', ['parent-uri' => $parent, 'uid' => local_user()])) { if (!DBA::delete('mail', ['parent-uri' => $parent, 'uid' => Session::getLocalUser()])) {
DI::sysmsg()->addNotice(DI::l10n()->t('Conversation was not removed.')); DI::sysmsg()->addNotice(DI::l10n()->t('Conversation was not removed.'));
} }
} }
@ -215,11 +216,11 @@ function message_content(App $a)
$o .= $header; $o .= $header;
$total = DBA::count('mail', ['uid' => local_user()], ['distinct' => true, 'expression' => 'parent-uri']); $total = DBA::count('mail', ['uid' => Session::getLocalUser()], ['distinct' => true, 'expression' => 'parent-uri']);
$pager = new Pager(DI::l10n(), DI::args()->getQueryString()); $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
$r = get_messages(local_user(), $pager->getStart(), $pager->getItemsPerPage()); $r = get_messages(Session::getLocalUser(), $pager->getStart(), $pager->getItemsPerPage());
if (!DBA::isResult($r)) { if (!DBA::isResult($r)) {
DI::sysmsg()->addNotice(DI::l10n()->t('No messages.')); DI::sysmsg()->addNotice(DI::l10n()->t('No messages.'));
@ -243,14 +244,14 @@ function message_content(App $a)
LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
WHERE `mail`.`uid` = ? AND `mail`.`id` = ? WHERE `mail`.`uid` = ? AND `mail`.`id` = ?
LIMIT 1", LIMIT 1",
local_user(), Session::getLocalUser(),
DI::args()->getArgv()[1] DI::args()->getArgv()[1]
); );
if (DBA::isResult($message)) { if (DBA::isResult($message)) {
$contact_id = $message['contact-id']; $contact_id = $message['contact-id'];
$params = [ $params = [
local_user(), Session::getLocalUser(),
$message['parent-uri'] $message['parent-uri']
]; ];
@ -272,7 +273,7 @@ function message_content(App $a)
$messages = DBA::toArray($messages_stmt); $messages = DBA::toArray($messages_stmt);
DBA::update('mail', ['seen' => 1], ['parent-uri' => $message['parent-uri'], 'uid' => local_user()]); DBA::update('mail', ['seen' => 1], ['parent-uri' => $message['parent-uri'], 'uid' => Session::getLocalUser()]);
} else { } else {
$messages = false; $messages = false;
} }

View File

@ -22,6 +22,7 @@
use Friendica\App; use Friendica\App;
use Friendica\Content\Nav; use Friendica\Content\Nav;
use Friendica\Content\Pager; use Friendica\Content\Pager;
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;
@ -30,7 +31,7 @@ use Friendica\Module\BaseProfile;
function notes_init(App $a) function notes_init(App $a)
{ {
if (! local_user()) { if (! Session::getLocalUser()) {
return; return;
} }
@ -40,7 +41,7 @@ function notes_init(App $a)
function notes_content(App $a, bool $update = false) function notes_content(App $a, bool $update = false)
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return; return;
} }
@ -52,7 +53,7 @@ function notes_content(App $a, bool $update = false)
$x = [ $x = [
'lockstate' => 'lock', 'lockstate' => 'lock',
'acl' => \Friendica\Core\ACL::getSelfOnlyHTML(local_user(), DI::l10n()->t('Personal notes are visible only by yourself.')), 'acl' => \Friendica\Core\ACL::getSelfOnlyHTML(Session::getLocalUser(), DI::l10n()->t('Personal notes are visible only by yourself.')),
'button' => DI::l10n()->t('Save'), 'button' => DI::l10n()->t('Save'),
'acl_data' => '', 'acl_data' => '',
]; ];
@ -60,14 +61,14 @@ function notes_content(App $a, bool $update = false)
$o .= DI::conversation()->statusEditor($x, $a->getContactId()); $o .= DI::conversation()->statusEditor($x, $a->getContactId());
} }
$condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => Item::GRAVITY_PARENT, $condition = ['uid' => Session::getLocalUser(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => Item::GRAVITY_PARENT,
'contact-id'=> $a->getContactId()]; 'contact-id'=> $a->getContactId()];
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'));
} }
@ -75,7 +76,7 @@ function notes_content(App $a, bool $update = false)
$params = ['order' => ['created' => true], $params = ['order' => ['created' => true],
'limit' => [$pager->getStart(), $pager->getItemsPerPage()]]; 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
$r = Post::selectThreadForUser(local_user(), ['uri-id'], $condition, $params); $r = Post::selectThreadForUser(Session::getLocalUser(), ['uri-id'], $condition, $params);
$count = 0; $count = 0;

View File

@ -22,6 +22,7 @@
use Friendica\App; use Friendica\App;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI; use Friendica\DI;
use Friendica\Module\Response; use Friendica\Module\Response;
@ -97,7 +98,7 @@ function oexchange_init(App $a)
function oexchange_content(App $a) function oexchange_content(App $a)
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
$o = Login::form(); $o = Login::form();
return $o; return $o;
} }
@ -119,7 +120,7 @@ function oexchange_content(App $a)
$post = []; $post = [];
$post['profile_uid'] = local_user(); $post['profile_uid'] = Session::getLocalUser();
$post['return'] = '/oexchange/done'; $post['return'] = '/oexchange/done';
$post['body'] = HTML::toBBCode($s); $post['body'] = HTML::toBBCode($s);

View File

@ -21,6 +21,7 @@
use Friendica\App; use Friendica\App;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Session;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\APContact; use Friendica\Model\APContact;
use Friendica\Model\Contact; use Friendica\Model\Contact;
@ -29,7 +30,7 @@ use Friendica\Protocol\ActivityPub;
function ostatus_subscribe_content(App $a): string function ostatus_subscribe_content(App $a): string
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('ostatus_subscribe'); DI::baseUrl()->redirect('ostatus_subscribe');
// NOTREACHED // NOTREACHED
@ -37,7 +38,7 @@ function ostatus_subscribe_content(App $a): string
$o = '<h2>' . DI::l10n()->t('Subscribing to contacts') . '</h2>'; $o = '<h2>' . DI::l10n()->t('Subscribing to contacts') . '</h2>';
$uid = local_user(); $uid = Session::getLocalUser();
$counter = intval($_REQUEST['counter'] ?? 0); $counter = intval($_REQUEST['counter'] ?? 0);

View File

@ -69,7 +69,7 @@ function photos_init(App $a)
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
} }
$is_owner = (local_user() && (local_user() == $owner['uid'])); $is_owner = (Session::getLocalUser() && (Session::getLocalUser() == $owner['uid']));
$albums = Photo::getAlbums($owner['uid']); $albums = Photo::getAlbums($owner['uid']);
@ -96,7 +96,7 @@ function photos_init(App $a)
} }
} }
if (local_user() && $owner['uid'] == local_user()) { if (Session::getLocalUser() && $owner['uid'] == Session::getLocalUser()) {
$can_post = true; $can_post = true;
} else { } else {
$can_post = false; $can_post = false;
@ -148,7 +148,7 @@ function photos_post(App $a)
$page_owner_uid = intval($user['uid']); $page_owner_uid = intval($user['uid']);
$community_page = $user['page-flags'] == User::PAGE_FLAGS_COMMUNITY; $community_page = $user['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
if (local_user() && (local_user() == $page_owner_uid)) { if (Session::getLocalUser() && (Session::getLocalUser() == $page_owner_uid)) {
$can_post = true; $can_post = true;
} elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) { } elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
$contact_id = Session::getRemoteContactID($page_owner_uid); $contact_id = Session::getRemoteContactID($page_owner_uid);
@ -229,7 +229,7 @@ function photos_post(App $a)
)); ));
} else { } else {
$r = DBA::toArray(DBA::p("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `uid` = ? AND `album` = ?", $r = DBA::toArray(DBA::p("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `uid` = ? AND `album` = ?",
local_user(), Session::getLocalUser(),
$album $album
)); ));
} }
@ -268,7 +268,7 @@ function photos_post(App $a)
$condition = ['contact-id' => $visitor, 'uid' => $page_owner_uid, 'resource-id' => DI::args()->getArgv()[3]]; $condition = ['contact-id' => $visitor, 'uid' => $page_owner_uid, 'resource-id' => DI::args()->getArgv()[3]];
} else { } else {
$condition = ['uid' => local_user(), 'resource-id' => DI::args()->getArgv()[3]]; $condition = ['uid' => Session::getLocalUser(), 'resource-id' => DI::args()->getArgv()[3]];
} }
$photo = DBA::selectFirst('photo', ['resource-id'], $condition); $photo = DBA::selectFirst('photo', ['resource-id'], $condition);
@ -840,7 +840,7 @@ function photos_content(App $a)
$community_page = (($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false); $community_page = (($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
if (local_user() && (local_user() == $owner_uid)) { if (Session::getLocalUser() && (Session::getLocalUser() == $owner_uid)) {
$can_post = true; $can_post = true;
} elseif ($community_page && !empty(Session::getRemoteContactID($owner_uid))) { } elseif ($community_page && !empty(Session::getRemoteContactID($owner_uid))) {
$contact_id = Session::getRemoteContactID($owner_uid); $contact_id = Session::getRemoteContactID($owner_uid);
@ -862,13 +862,13 @@ function photos_content(App $a)
$remote_contact = DBA::isResult($contact); $remote_contact = DBA::isResult($contact);
} }
if (!$remote_contact && local_user()) { if (!$remote_contact && Session::getLocalUser()) {
$contact_id = $_SESSION['cid']; $contact_id = $_SESSION['cid'];
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]); $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
} }
if ($user['hidewall'] && (local_user() != $owner_uid) && !$remote_contact) { if ($user['hidewall'] && (Session::getLocalUser() != $owner_uid) && !$remote_contact) {
DI::sysmsg()->addNotice(DI::l10n()->t('Access to this item is restricted.')); DI::sysmsg()->addNotice(DI::l10n()->t('Access to this item is restricted.'));
return; return;
} }
@ -878,7 +878,7 @@ function photos_content(App $a)
$o = ""; $o = "";
// tabs // tabs
$is_owner = (local_user() && (local_user() == $owner_uid)); $is_owner = (Session::getLocalUser() && (Session::getLocalUser() == $owner_uid));
$o .= BaseProfile::getTabsHTML($a, 'photos', $is_owner, $user['nickname'], $profile['hide-friends']); $o .= BaseProfile::getTabsHTML($a, 'photos', $is_owner, $user['nickname'], $profile['hide-friends']);
// Display upload form // Display upload form
@ -1197,7 +1197,7 @@ function photos_content(App $a)
} }
if ( if (
$ph[0]['uid'] == local_user() $ph[0]['uid'] == Session::getLocalUser()
&& (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid']) || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid'])) && (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid']) || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid']))
) { ) {
$tools['lock'] = DI::l10n()->t('Private Photo'); $tools['lock'] = DI::l10n()->t('Private Photo');
@ -1237,7 +1237,7 @@ function photos_content(App $a)
$params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]]; $params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
$items = Post::toArray(Post::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params)); $items = Post::toArray(Post::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params));
if (local_user() == $link_item['uid']) { if (Session::getLocalUser() == $link_item['uid']) {
Item::update(['unseen' => false], ['parent' => $link_item['parent']]); Item::update(['unseen' => false], ['parent' => $link_item['parent']]);
} }
} }
@ -1315,7 +1315,7 @@ function photos_content(App $a)
*/ */
$qcomment = null; $qcomment = null;
if (Addon::isEnabled('qcomment')) { if (Addon::isEnabled('qcomment')) {
$words = DI::pConfig()->get(local_user(), 'qcomment', 'words'); $words = DI::pConfig()->get(Session::getLocalUser(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : []; $qcomment = $words ? explode("\n", $words) : [];
} }
@ -1346,7 +1346,7 @@ function photos_content(App $a)
'attendmaybe' => [] 'attendmaybe' => []
]; ];
if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) { if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
unset($conv_responses['dislike']); unset($conv_responses['dislike']);
} }
@ -1371,7 +1371,7 @@ function photos_content(App $a)
*/ */
$qcomment = null; $qcomment = null;
if (Addon::isEnabled('qcomment')) { if (Addon::isEnabled('qcomment')) {
$words = DI::pConfig()->get(local_user(), 'qcomment', 'words'); $words = DI::pConfig()->get(Session::getLocalUser(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : []; $qcomment = $words ? explode("\n", $words) : [];
} }
@ -1413,7 +1413,7 @@ function photos_content(App $a)
$sparkle = ''; $sparkle = '';
} }
$dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == local_user())); $dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == Session::getLocalUser()));
$drop = [ $drop = [
'dropping' => $dropping, 'dropping' => $dropping,
'pagedrop' => false, 'pagedrop' => false,
@ -1445,7 +1445,7 @@ function photos_content(App $a)
*/ */
$qcomment = null; $qcomment = null;
if (Addon::isEnabled('qcomment')) { if (Addon::isEnabled('qcomment')) {
$words = DI::pConfig()->get(local_user(), 'qcomment', 'words'); $words = DI::pConfig()->get(Session::getLocalUser(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : []; $qcomment = $words ? explode("\n", $words) : [];
} }
@ -1484,7 +1484,7 @@ function photos_content(App $a)
'$dislike' => DI::l10n()->t('Dislike'), '$dislike' => DI::l10n()->t('Dislike'),
'$wait' => DI::l10n()->t('Please wait'), '$wait' => DI::l10n()->t('Please wait'),
'$dislike_title' => DI::l10n()->t('I don\'t like this (toggle)'), '$dislike_title' => DI::l10n()->t('I don\'t like this (toggle)'),
'$hide_dislike' => DI::pConfig()->get(local_user(), 'system', 'hide_dislike'), '$hide_dislike' => DI::pConfig()->get(Session::getLocalUser(), 'system', 'hide_dislike'),
'$responses' => $responses, '$responses' => $responses,
'$return_path' => DI::args()->getQueryString(), '$return_path' => DI::args()->getQueryString(),
]); ]);

View File

@ -52,7 +52,7 @@ function redir_init(App $a) {
} }
$fields = ['id', 'uid', 'nurl', 'url', 'addr', 'name']; $fields = ['id', 'uid', 'nurl', 'url', 'addr', 'name'];
$contact = DBA::selectFirst('contact', $fields, ['id' => $cid, 'uid' => [0, local_user()]]); $contact = DBA::selectFirst('contact', $fields, ['id' => $cid, 'uid' => [0, Session::getLocalUser()]]);
if (!DBA::isResult($contact)) { if (!DBA::isResult($contact)) {
throw new \Friendica\Network\HTTPException\NotFoundException(DI::l10n()->t('Contact not found.')); throw new \Friendica\Network\HTTPException\NotFoundException(DI::l10n()->t('Contact not found.'));
} }
@ -65,10 +65,10 @@ function redir_init(App $a) {
$a->redirect($url ?: $contact_url); $a->redirect($url ?: $contact_url);
} }
if ($contact['uid'] == 0 && local_user()) { if ($contact['uid'] == 0 && Session::getLocalUser()) {
// Let's have a look if there is an established connection // Let's have a look if there is an established connection
// between the public contact we have found and the local user. // between the public contact we have found and the local user.
$contact = DBA::selectFirst('contact', $fields, ['nurl' => $contact['nurl'], 'uid' => local_user()]); $contact = DBA::selectFirst('contact', $fields, ['nurl' => $contact['nurl'], 'uid' => Session::getLocalUser()]);
if (DBA::isResult($contact)) { if (DBA::isResult($contact)) {
$cid = $contact['id']; $cid = $contact['id'];
@ -83,7 +83,7 @@ function redir_init(App $a) {
} }
} }
if (remote_user()) { if (Session::getRemoteUser()) {
$host = substr(DI::baseUrl()->getUrlPath() . (DI::baseUrl()->getUrlPath() ? '/' . DI::baseUrl()->getUrlPath() : ''), strpos(DI::baseUrl()->getUrlPath(), '://') + 3); $host = substr(DI::baseUrl()->getUrlPath() . (DI::baseUrl()->getUrlPath() ? '/' . DI::baseUrl()->getUrlPath() : ''), strpos(DI::baseUrl()->getUrlPath(), '://') + 3);
$remotehost = substr($contact['addr'], strpos($contact['addr'], '@') + 1); $remotehost = substr($contact['addr'], strpos($contact['addr'], '@') + 1);
@ -91,7 +91,7 @@ function redir_init(App $a) {
// with the local contact. Otherwise the local user would ask the local contact // with the local contact. Otherwise the local user would ask the local contact
// for authentification everytime he/she is visiting a profile page of the local // for authentification everytime he/she is visiting a profile page of the local
// contact. // contact.
if (($host == $remotehost) && (Session::getRemoteContactID(Session::get('visitor_visiting')) == Session::get('visitor_id'))) { if (($host == $remotehost) && (Session::getRemoteContactID(DI::session()->get('visitor_visiting')) == DI::session()->get('visitor_id'))) {
// Remote user is already authenticated. // Remote user is already authenticated.
redir_check_url($contact_url, $url); redir_check_url($contact_url, $url);
$target_url = $url ?: $contact_url; $target_url = $url ?: $contact_url;

View File

@ -21,6 +21,7 @@
use Friendica\App; use Friendica\App;
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;
@ -28,7 +29,7 @@ use Friendica\Util\Strings;
function removeme_post(App $a) function removeme_post(App $a)
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
return; return;
} }
@ -64,7 +65,7 @@ function removeme_post(App $a)
->withMessage( ->withMessage(
$l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('User deleted their account'), $l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('User deleted their account'),
$l10n->t('On your Friendica node an user deleted their account. Please ensure that their data is removed from the backups.'), $l10n->t('On your Friendica node an user deleted their account. Please ensure that their data is removed from the backups.'),
$l10n->t('The user id is %d', local_user())) $l10n->t('The user id is %d', Session::getLocalUser()))
->forUser($admin) ->forUser($admin)
->withRecipient($admin['email']) ->withRecipient($admin['email'])
->build(); ->build();
@ -83,7 +84,7 @@ function removeme_post(App $a)
function removeme_content(App $a) function removeme_content(App $a)
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
DI::baseUrl()->redirect(); DI::baseUrl()->redirect();
} }

View File

@ -21,13 +21,14 @@
use Friendica\App; use Friendica\App;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
function repair_ostatus_content(App $a) { function repair_ostatus_content(App $a) {
if (!local_user()) { if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('ostatus_repair'); DI::baseUrl()->redirect('ostatus_repair');
// NOTREACHED // NOTREACHED
@ -35,7 +36,7 @@ function repair_ostatus_content(App $a) {
$o = '<h2>' . DI::l10n()->t('Resubscribing to OStatus contacts') . '</h2>'; $o = '<h2>' . DI::l10n()->t('Resubscribing to OStatus contacts') . '</h2>';
$uid = local_user(); $uid = Session::getLocalUser();
$counter = intval($_REQUEST['counter'] ?? 0); $counter = intval($_REQUEST['counter'] ?? 0);

View File

@ -26,6 +26,7 @@ use Friendica\Content\Nav;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
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;
@ -36,7 +37,7 @@ use Friendica\Protocol\Email;
function settings_init(App $a) function settings_init(App $a)
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return; return;
} }
@ -69,12 +70,12 @@ function settings_post(App $a)
BaseModule::checkFormSecurityTokenRedirectOnError(DI::args()->getQueryString(), 'settings_connectors'); BaseModule::checkFormSecurityTokenRedirectOnError(DI::args()->getQueryString(), 'settings_connectors');
if (!empty($_POST['general-submit'])) { if (!empty($_POST['general-submit'])) {
DI::pConfig()->set(local_user(), 'system', 'accept_only_sharer', intval($_POST['accept_only_sharer'])); DI::pConfig()->set(Session::getLocalUser(), 'system', 'accept_only_sharer', intval($_POST['accept_only_sharer']));
DI::pConfig()->set(local_user(), 'system', 'disable_cw', !intval($_POST['enable_cw'])); DI::pConfig()->set(Session::getLocalUser(), 'system', 'disable_cw', !intval($_POST['enable_cw']));
DI::pConfig()->set(local_user(), 'system', 'no_intelligent_shortening', !intval($_POST['enable_smart_shortening'])); DI::pConfig()->set(Session::getLocalUser(), 'system', 'no_intelligent_shortening', !intval($_POST['enable_smart_shortening']));
DI::pConfig()->set(local_user(), 'system', 'simple_shortening', intval($_POST['simple_shortening'])); DI::pConfig()->set(Session::getLocalUser(), 'system', 'simple_shortening', intval($_POST['simple_shortening']));
DI::pConfig()->set(local_user(), 'system', 'attach_link_title', intval($_POST['attach_link_title'])); DI::pConfig()->set(Session::getLocalUser(), 'system', 'attach_link_title', intval($_POST['attach_link_title']));
DI::pConfig()->set(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']); DI::pConfig()->set(Session::getLocalUser(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']);
} elseif (!empty($_POST['mail-submit'])) { } elseif (!empty($_POST['mail-submit'])) {
$mail_server = $_POST['mail_server'] ?? ''; $mail_server = $_POST['mail_server'] ?? '';
$mail_port = $_POST['mail_port'] ?? ''; $mail_port = $_POST['mail_port'] ?? '';
@ -87,13 +88,13 @@ function settings_post(App $a)
$mail_pubmail = $_POST['mail_pubmail'] ?? ''; $mail_pubmail = $_POST['mail_pubmail'] ?? '';
if (function_exists('imap_open') && !DI::config()->get('system', 'imap_disabled')) { if (function_exists('imap_open') && !DI::config()->get('system', 'imap_disabled')) {
if (!DBA::exists('mailacct', ['uid' => local_user()])) { if (!DBA::exists('mailacct', ['uid' => Session::getLocalUser()])) {
DBA::insert('mailacct', ['uid' => local_user()]); DBA::insert('mailacct', ['uid' => Session::getLocalUser()]);
} }
if (strlen($mail_pass)) { if (strlen($mail_pass)) {
$pass = ''; $pass = '';
openssl_public_encrypt($mail_pass, $pass, $user['pubkey']); openssl_public_encrypt($mail_pass, $pass, $user['pubkey']);
DBA::update('mailacct', ['pass' => bin2hex($pass)], ['uid' => local_user()]); DBA::update('mailacct', ['pass' => bin2hex($pass)], ['uid' => Session::getLocalUser()]);
} }
$r = DBA::update('mailacct', [ $r = DBA::update('mailacct', [
@ -106,10 +107,10 @@ function settings_post(App $a)
'mailbox' => 'INBOX', 'mailbox' => 'INBOX',
'reply_to' => $mail_replyto, 'reply_to' => $mail_replyto,
'pubmail' => $mail_pubmail 'pubmail' => $mail_pubmail
], ['uid' => local_user()]); ], ['uid' => Session::getLocalUser()]);
Logger::debug('updating mailaccount', ['response' => $r]); Logger::debug('updating mailaccount', ['response' => $r]);
$mailacct = DBA::selectFirst('mailacct', [], ['uid' => local_user()]); $mailacct = DBA::selectFirst('mailacct', [], ['uid' => Session::getLocalUser()]);
if (DBA::isResult($mailacct)) { if (DBA::isResult($mailacct)) {
$mb = Email::constructMailboxName($mailacct); $mb = Email::constructMailboxName($mailacct);
@ -135,7 +136,7 @@ function settings_post(App $a)
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/features', 'settings_features'); BaseModule::checkFormSecurityTokenRedirectOnError('/settings/features', 'settings_features');
foreach ($_POST as $k => $v) { foreach ($_POST as $k => $v) {
if (strpos($k, 'feature_') === 0) { if (strpos($k, 'feature_') === 0) {
DI::pConfig()->set(local_user(), 'feature', substr($k, 8), ((intval($v)) ? 1 : 0)); DI::pConfig()->set(Session::getLocalUser(), 'feature', substr($k, 8), ((intval($v)) ? 1 : 0));
} }
} }
return; return;
@ -147,7 +148,7 @@ function settings_content(App $a)
$o = ''; $o = '';
Nav::setSelected('settings'); Nav::setSelected('settings');
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();
} }
@ -161,12 +162,12 @@ function settings_content(App $a)
if ((DI::args()->getArgc() > 3) && (DI::args()->getArgv()[2] === 'delete')) { if ((DI::args()->getArgc() > 3) && (DI::args()->getArgv()[2] === 'delete')) {
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/oauth', 'settings_oauth', 't'); BaseModule::checkFormSecurityTokenRedirectOnError('/settings/oauth', 'settings_oauth', 't');
DBA::delete('application-token', ['application-id' => DI::args()->getArgv()[3], 'uid' => local_user()]); DBA::delete('application-token', ['application-id' => DI::args()->getArgv()[3], 'uid' => Session::getLocalUser()]);
DI::baseUrl()->redirect('settings/oauth/', true); DI::baseUrl()->redirect('settings/oauth/', true);
return ''; return '';
} }
$applications = DBA::selectToArray('application-view', ['id', 'uid', 'name', 'website', 'scopes', 'created_at'], ['uid' => local_user()]); $applications = DBA::selectToArray('application-view', ['id', 'uid', 'name', 'website', 'scopes', 'created_at'], ['uid' => Session::getLocalUser()]);
$tpl = Renderer::getMarkupTemplate('settings/oauth.tpl'); $tpl = Renderer::getMarkupTemplate('settings/oauth.tpl');
$o .= Renderer::replaceMacros($tpl, [ $o .= Renderer::replaceMacros($tpl, [
@ -225,7 +226,7 @@ function settings_content(App $a)
$arr[$fname] = []; $arr[$fname] = [];
$arr[$fname][0] = $fdata[0]; $arr[$fname][0] = $fdata[0];
foreach (array_slice($fdata,1) as $f) { foreach (array_slice($fdata,1) as $f) {
$arr[$fname][1][] = ['feature_' . $f[0], $f[1], Feature::isEnabled(local_user(), $f[0]), $f[2]]; $arr[$fname][1][] = ['feature_' . $f[0], $f[1], Feature::isEnabled(Session::getLocalUser(), $f[0]), $f[2]];
} }
} }
@ -240,12 +241,12 @@ function settings_content(App $a)
} }
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'connectors')) { if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'connectors')) {
$accept_only_sharer = intval(DI::pConfig()->get(local_user(), 'system', 'accept_only_sharer')); $accept_only_sharer = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'accept_only_sharer'));
$enable_cw = !intval(DI::pConfig()->get(local_user(), 'system', 'disable_cw')); $enable_cw = !intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'disable_cw'));
$enable_smart_shortening = !intval(DI::pConfig()->get(local_user(), 'system', 'no_intelligent_shortening')); $enable_smart_shortening = !intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_intelligent_shortening'));
$simple_shortening = intval(DI::pConfig()->get(local_user(), 'system', 'simple_shortening')); $simple_shortening = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'simple_shortening'));
$attach_link_title = intval(DI::pConfig()->get(local_user(), 'system', 'attach_link_title')); $attach_link_title = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'attach_link_title'));
$legacy_contact = DI::pConfig()->get(local_user(), 'ostatus', 'legacy_contact'); $legacy_contact = DI::pConfig()->get(Session::getLocalUser(), 'ostatus', 'legacy_contact');
if (!empty($legacy_contact)) { if (!empty($legacy_contact)) {
/// @todo Isn't it supposed to be a $a->internalRedirect() call? /// @todo Isn't it supposed to be a $a->internalRedirect() call?
@ -279,7 +280,7 @@ function settings_content(App $a)
$mail_disabled = ((function_exists('imap_open') && (!DI::config()->get('system', 'imap_disabled'))) ? 0 : 1); $mail_disabled = ((function_exists('imap_open') && (!DI::config()->get('system', 'imap_disabled'))) ? 0 : 1);
if (!$mail_disabled) { if (!$mail_disabled) {
$mailacct = DBA::selectFirst('mailacct', [], ['uid' => local_user()]); $mailacct = DBA::selectFirst('mailacct', [], ['uid' => Session::getLocalUser()]);
} else { } else {
$mailacct = null; $mailacct = null;
} }

View File

@ -21,6 +21,7 @@
use Friendica\App; use Friendica\App;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
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;
@ -30,7 +31,7 @@ use Friendica\Model\Post;
function share_init(App $a) { function share_init(App $a) {
$post_id = ((DI::args()->getArgc() > 1) ? intval(DI::args()->getArgv()[1]) : 0); $post_id = ((DI::args()->getArgc() > 1) ? intval(DI::args()->getArgv()[1]) : 0);
if (!$post_id || !local_user()) { if (!$post_id || !Session::getLocalUser()) {
System::exit(); System::exit();
} }

View File

@ -22,6 +22,7 @@
use Friendica\App; use Friendica\App;
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\Contact; use Friendica\Model\Contact;
@ -30,7 +31,7 @@ use Friendica\Network\HTTPException;
function suggest_content(App $a) function suggest_content(App $a)
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
} }
@ -39,7 +40,7 @@ function suggest_content(App $a)
DI::page()['aside'] .= Widget::findPeople(); DI::page()['aside'] .= Widget::findPeople();
DI::page()['aside'] .= Widget::follow(); DI::page()['aside'] .= Widget::follow();
$contacts = Contact\Relation::getSuggestions(local_user()); $contacts = Contact\Relation::getSuggestions(Session::getLocalUser());
if (!DBA::isResult($contacts)) { if (!DBA::isResult($contacts)) {
return DI::l10n()->t('No suggestions available. If this is a new site, please try again in 24 hours.'); return DI::l10n()->t('No suggestions available. If this is a new site, please try again in 24 hours.');
} }

View File

@ -63,13 +63,13 @@ function tagger_content(App $a)
$owner_uid = $item['uid']; $owner_uid = $item['uid'];
if (local_user() != $owner_uid) { if (Session::getLocalUser() != $owner_uid) {
return; return;
} }
$contact = Contact::selectFirst([], ['self' => true, 'uid' => local_user()]); $contact = Contact::selectFirst([], ['self' => true, 'uid' => Session::getLocalUser()]);
if (!DBA::isResult($contact)) { if (!DBA::isResult($contact)) {
Logger::warning('Self contact not found.', ['uid' => local_user()]); Logger::warning('Self contact not found.', ['uid' => Session::getLocalUser()]);
return; return;
} }

View File

@ -21,6 +21,7 @@
use Friendica\App; use Friendica\App;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
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;
@ -28,7 +29,7 @@ use Friendica\Model\Tag;
function tagrm_post(App $a) function tagrm_post(App $a)
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
DI::baseUrl()->redirect($_SESSION['photo_return']); DI::baseUrl()->redirect($_SESSION['photo_return']);
} }
@ -61,7 +62,7 @@ function update_tags($item_id, $tags)
return; return;
} }
$item = Post::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => local_user()]); $item = Post::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => Session::getLocalUser()]);
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
return; return;
} }
@ -81,7 +82,7 @@ function tagrm_content(App $a)
$photo_return = $_SESSION['photo_return'] ?? ''; $photo_return = $_SESSION['photo_return'] ?? '';
if (!local_user()) { if (!Session::getLocalUser()) {
DI::baseUrl()->redirect($photo_return); DI::baseUrl()->redirect($photo_return);
// NOTREACHED // NOTREACHED
} }
@ -97,7 +98,7 @@ function tagrm_content(App $a)
// NOTREACHED // NOTREACHED
} }
$item = Post::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => local_user()]); $item = Post::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => Session::getLocalUser()]);
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
DI::baseUrl()->redirect($photo_return); DI::baseUrl()->redirect($photo_return);
} }

View File

@ -23,6 +23,7 @@ use Friendica\App;
use Friendica\Content\Widget; use Friendica\Content\Widget;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
@ -31,7 +32,7 @@ use Friendica\Util\Strings;
function unfollow_post(App $a) function unfollow_post(App $a)
{ {
if (!local_user()) { if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('login'); DI::baseUrl()->redirect('login');
// NOTREACHED // NOTREACHED
@ -46,17 +47,17 @@ function unfollow_content(App $a)
{ {
$base_return_path = 'contact'; $base_return_path = 'contact';
if (!local_user()) { if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('login'); DI::baseUrl()->redirect('login');
// NOTREACHED // NOTREACHED
} }
$uid = local_user(); $uid = Session::getLocalUser();
$url = trim($_REQUEST['url']); $url = trim($_REQUEST['url']);
$condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)", $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)",
local_user(), Contact::SHARING, Contact::FRIEND, Strings::normaliseLink($url), Session::getLocalUser(), Contact::SHARING, Contact::FRIEND, Strings::normaliseLink($url),
Strings::normaliseLink($url), $url]; Strings::normaliseLink($url), $url];
$contact = DBA::selectFirst('contact', ['url', 'id', 'uid', 'network', 'addr', 'name'], $condition); $contact = DBA::selectFirst('contact', ['url', 'id', 'uid', 'network', 'addr', 'name'], $condition);
@ -118,7 +119,7 @@ function unfollow_process(string $url)
{ {
$base_return_path = 'contact'; $base_return_path = 'contact';
$uid = local_user(); $uid = Session::getLocalUser();
$owner = User::getOwnerDataById($uid); $owner = User::getOwnerDataById($uid);
if (!$owner) { if (!$owner) {

View File

@ -22,6 +22,7 @@
*/ */
use Friendica\App; use Friendica\App;
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;
@ -30,7 +31,7 @@ use Friendica\Model\Contact;
function update_contact_content(App $a) function update_contact_content(App $a)
{ {
if (!empty(DI::args()->get(1)) && (!empty($_GET['force']) || !DI::pConfig()->get(local_user(), 'system', 'no_auto_update'))) { if (!empty(DI::args()->get(1)) && (!empty($_GET['force']) || !DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_auto_update'))) {
$contact = Contact::getById(DI::args()->get(1), ['id', 'deleted']); $contact = Contact::getById(DI::args()->get(1), ['id', 'deleted']);
if (DBA::isResult($contact) && empty($contact['deleted'])) { if (DBA::isResult($contact) && empty($contact['deleted'])) {
DI::page()['aside'] = ''; DI::page()['aside'] = '';

View File

@ -55,7 +55,7 @@ function wall_attach_post(App $a) {
$page_owner_cid = $owner['id']; $page_owner_cid = $owner['id'];
$community_page = $owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY; $community_page = $owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
if (local_user() && (local_user() == $page_owner_uid)) { if (Session::getLocalUser() && (Session::getLocalUser() == $page_owner_uid)) {
$can_post = true; $can_post = true;
} elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) { } elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
$contact_id = Session::getRemoteContactID($page_owner_uid); $contact_id = Session::getRemoteContactID($page_owner_uid);

View File

@ -76,7 +76,7 @@ function wall_upload_post(App $a, $desktopmode = true)
$page_owner_nick = $user['nickname']; $page_owner_nick = $user['nickname'];
$community_page = (($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false); $community_page = (($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
if ((local_user()) && (local_user() == $page_owner_uid)) { if ((Session::getLocalUser()) && (Session::getLocalUser() == $page_owner_uid)) {
$can_post = true; $can_post = true;
} elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) { } elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
$contact_id = Session::getRemoteContactID($page_owner_uid); $contact_id = Session::getRemoteContactID($page_owner_uid);