old boot.php functions replaced in /src

This commit is contained in:
Michael 2022-10-19 04:26:41 +00:00 committed by Hypolite Petovan
parent 7fc37832f7
commit ee1acba9eb
22 changed files with 130 additions and 116 deletions

View file

@ -1103,7 +1103,7 @@ class Contact
$photos_link = '';
if ($uid == 0) {
$uid = local_user();
$uid = Session::getLocalUser();
}
if (empty($contact['uid']) || ($contact['uid'] != $uid)) {
@ -1506,10 +1506,10 @@ class Contact
if ($thread_mode) {
$condition = ["((`$contact_field` = ? AND `gravity` = ?) OR (`author-id` = ? AND `gravity` = ? AND `vid` = ? AND `thr-parent-id` = `parent-uri-id`)) AND " . $sql,
$cid, Item::GRAVITY_PARENT, $cid, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), local_user()];
$cid, Item::GRAVITY_PARENT, $cid, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Session::getLocalUser()];
} else {
$condition = ["`$contact_field` = ? AND `gravity` IN (?, ?) AND " . $sql,
$cid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, local_user()];
$cid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, Session::getLocalUser()];
}
if (!empty($parent)) {
@ -1527,10 +1527,10 @@ class Contact
}
if (DI::mode()->isMobile()) {
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
@ -1538,7 +1538,7 @@ class Contact
$params = ['order' => ['received' => true], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
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()]);
} else {
@ -1547,27 +1547,27 @@ class Contact
if ($thread_mode) {
$fields = ['uri-id', 'thr-parent-id', 'gravity', 'author-id', 'commented'];
$items = Post::toArray(Post::selectForUser(local_user(), $fields, $condition, $params));
$items = Post::toArray(Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params));
if ($pager->getStart() == 0) {
$cdata = self::getPublicAndUserContactID($cid, local_user());
$cdata = self::getPublicAndUserContactID($cid, Session::getLocalUser());
if (!empty($cdata['public'])) {
$pinned = Post\Collection::selectToArrayForContact($cdata['public'], Post\Collection::FEATURED, $fields);
$items = array_merge($items, $pinned);
}
}
$o .= DI::conversation()->create($items, 'contacts', $update, false, 'pinned_commented', local_user());
$o .= DI::conversation()->create($items, 'contacts', $update, false, 'pinned_commented', Session::getLocalUser());
} else {
$fields = array_merge(Item::DISPLAY_FIELDLIST, ['featured']);
$items = Post::toArray(Post::selectForUser(local_user(), $fields, $condition, $params));
$items = Post::toArray(Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params));
if ($pager->getStart() == 0) {
$cdata = self::getPublicAndUserContactID($cid, local_user());
$cdata = self::getPublicAndUserContactID($cid, Session::getLocalUser());
if (!empty($cdata['public'])) {
$condition = ["`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
$cdata['public'], Post\Collection::FEATURED];
$pinned = Post::toArray(Post::selectForUser(local_user(), $fields, $condition, $params));
$pinned = Post::toArray(Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params));
$items = array_merge($pinned, $items);
}
}
@ -1576,7 +1576,7 @@ class Contact
}
if (!$update) {
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));
@ -3286,7 +3286,7 @@ class Contact
return $url;
}
if (DI::pConfig()->get(local_user(), 'system', 'stay_local') && ($url == '')) {
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'stay_local') && ($url == '')) {
return 'contact/' . $contact['id'] . '/conversations';
}

View file

@ -21,6 +21,7 @@
namespace Friendica\Model\Contact;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
@ -53,7 +54,7 @@ class Group
AND NOT `contact`.`pending`
ORDER BY `contact`.`name` ASC',
$gid,
local_user()
Session::getLocalUser()
);
if (DBA::isResult($stmt)) {

View file

@ -26,6 +26,7 @@ use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
@ -410,7 +411,7 @@ class Event
public static function getStrings(): array
{
// First day of the week (0 = Sunday).
$firstDay = DI::pConfig()->get(local_user(), 'system', 'first_day_of_week', 0);
$firstDay = DI::pConfig()->get(Session::getLocalUser(), 'system', 'first_day_of_week', 0);
$i18n = [
"firstDay" => $firstDay,
@ -608,7 +609,7 @@ class Event
$edit = null;
$copy = null;
$drop = null;
if (local_user() && local_user() == $event['uid'] && $event['type'] == 'event') {
if (Session::getLocalUser() && Session::getLocalUser() == $event['uid'] && $event['type'] == 'event') {
$edit = !$event['cid'] ? [DI::baseUrl() . '/events/event/' . $event['id'], DI::l10n()->t('Edit event') , '', ''] : null;
$copy = !$event['cid'] ? [DI::baseUrl() . '/events/copy/' . $event['id'] , DI::l10n()->t('Duplicate event'), '', ''] : null;
$drop = [DI::baseUrl() . '/events/drop/' . $event['id'] , DI::l10n()->t('Delete event') , '', ''];
@ -775,7 +776,7 @@ class Event
// Does the user who requests happen to be the owner of the events
// requested? then show all of your events, otherwise only those that
// don't have limitations set in allow_cid and allow_gid.
if (local_user() != $uid) {
if (Session::getLocalUser() != $uid) {
$conditions += ['allow_cid' => '', 'allow_gid' => ''];
}

View file

@ -25,6 +25,7 @@ use Friendica\BaseModule;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\DI;
@ -187,8 +188,8 @@ class Group
) AS `count`
FROM `group`
WHERE `group`.`uid` = ?;",
local_user(),
local_user()
Session::getLocalUser(),
Session::getLocalUser()
);
return DBA::toArray($stmt);
@ -526,7 +527,7 @@ class Group
*/
public static function sidebarWidget(string $every = 'contact', string $each = 'group', string $editmode = 'standard', $group_id = '', int $cid = 0)
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return '';
}
@ -544,7 +545,7 @@ class Group
$member_of = self::getIdsByContactId($cid);
}
$stmt = DBA::select('group', [], ['deleted' => false, 'uid' => local_user(), 'cid' => null], ['order' => ['name']]);
$stmt = DBA::select('group', [], ['deleted' => false, 'uid' => Session::getLocalUser(), 'cid' => null], ['order' => ['name']]);
while ($group = DBA::fetch($stmt)) {
$selected = (($group_id == $group['id']) ? ' group-selected' : '');

View file

@ -1066,7 +1066,7 @@ class Item
}
// We have to tell the hooks who we are - this really should be improved
if (!local_user()) {
if (!Session::getLocalUser()) {
$_SESSION['authenticated'] = true;
$_SESSION['uid'] = $uid;
$dummy_session = true;
@ -2775,7 +2775,7 @@ class Item
*/
public static function getPermissionsConditionArrayByUserId(int $owner_id): array
{
$local_user = local_user();
$local_user = Session::getLocalUser();
$remote_user = Session::getRemoteContactID($owner_id);
// default permissions - anonymous user
@ -2807,7 +2807,7 @@ class Item
*/
public static function getPermissionsSQLByUserId(int $owner_id, string $table = ''): string
{
$local_user = local_user();
$local_user = Session::getLocalUser();
$remote_user = Session::getRemoteContactID($owner_id);
if (!empty($table)) {
@ -3006,8 +3006,8 @@ class Item
// Compile eventual content filter reasons
$filter_reasons = [];
if (!$is_preview && public_contact() != $item['author-id']) {
if (!empty($item['content-warning']) && (!local_user() || !DI::pConfig()->get(local_user(), 'system', 'disable_cw', false))) {
if (!$is_preview && Session::getPublicContact() != $item['author-id']) {
if (!empty($item['content-warning']) && (!Session::getLocalUser() || !DI::pConfig()->get(Session::getLocalUser(), 'system', 'disable_cw', false))) {
$filter_reasons[] = DI::l10n()->t('Content warning: %s', $item['content-warning']);
}
@ -3443,7 +3443,7 @@ class Item
$plink = $item['uri'];
}
if (local_user()) {
if (Session::getLocalUser()) {
$ret = [
'href' => "display/" . $item['guid'],
'orig' => "display/" . $item['guid'],

View file

@ -23,6 +23,7 @@ namespace Friendica\Model;
use Friendica\Core\ACL;
use Friendica\Core\Logger;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
@ -137,12 +138,12 @@ class Mail
$subject = DI::l10n()->t('[no subject]');
}
$me = DBA::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]);
$me = DBA::selectFirst('contact', [], ['uid' => Session::getLocalUser(), 'self' => true]);
if (!DBA::isResult($me)) {
return -2;
}
$contacts = ACL::getValidMessageRecipientsForUser(local_user());
$contacts = ACL::getValidMessageRecipientsForUser(Session::getLocalUser());
$contactIndex = array_search($recipient, array_column($contacts, 'id'));
if ($contactIndex === false) {
@ -151,7 +152,7 @@ class Mail
$contact = $contacts[$contactIndex];
Photo::setPermissionFromBody($body, local_user(), $me['id'], '<' . $contact['id'] . '>', '', '', '');
Photo::setPermissionFromBody($body, Session::getLocalUser(), $me['id'], '<' . $contact['id'] . '>', '', '', '');
$guid = System::createUUID();
$uri = Item::newURI($guid);
@ -164,7 +165,7 @@ class Mail
if (strlen($replyto)) {
$reply = true;
$condition = ["`uid` = ? AND (`uri` = ? OR `parent-uri` = ?)",
local_user(), $replyto, $replyto];
Session::getLocalUser(), $replyto, $replyto];
$mail = DBA::selectFirst('mail', ['convid'], $condition);
if (DBA::isResult($mail)) {
$convid = $mail['convid'];
@ -177,7 +178,7 @@ class Mail
$conv_guid = System::createUUID();
$convuri = $contact['addr'] . ':' . $conv_guid;
$fields = ['uid' => local_user(), 'guid' => $conv_guid, 'creator' => $me['addr'],
$fields = ['uid' => Session::getLocalUser(), 'guid' => $conv_guid, 'creator' => $me['addr'],
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
'subject' => $subject, 'recips' => $contact['addr'] . ';' . $me['addr']];
if (DBA::insert('conv', $fields)) {
@ -196,7 +197,7 @@ class Mail
$post_id = self::insert(
[
'uid' => local_user(),
'uid' => Session::getLocalUser(),
'guid' => $guid,
'convid' => $convid,
'from-name' => $me['name'],
@ -232,7 +233,7 @@ class Mail
foreach ($images as $image) {
$image_rid = Photo::ridFromURI($image);
if (!empty($image_rid)) {
Photo::update(['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_rid, 'album' => 'Wall Photos', 'uid' => local_user()]);
Photo::update(['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_rid, 'album' => 'Wall Photos', 'uid' => Session::getLocalUser()]);
}
}
}

View file

@ -23,9 +23,9 @@ namespace Friendica\Model;
use Friendica\Core\Cache\Enum\Duration;
use Friendica\Core\Logger;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Core\Storage\Type\ExternalResource;
use Friendica\Core\Storage\Exception\InvalidClassStorageException;
@ -639,10 +639,10 @@ class Photo
{
$sql_extra = Security::getPermissionsSQLByUserId($uid);
$avatar_type = (local_user() && (local_user() == $uid)) ? self::USER_AVATAR : self::DEFAULT;
$banner_type = (local_user() && (local_user() == $uid)) ? self::USER_BANNER : self::DEFAULT;
$avatar_type = (Session::getLocalUser() && (Session::getLocalUser() == $uid)) ? self::USER_AVATAR : self::DEFAULT;
$banner_type = (Session::getLocalUser() && (Session::getLocalUser() == $uid)) ? self::USER_BANNER : self::DEFAULT;
$key = 'photo_albums:' . $uid . ':' . local_user() . ':' . remote_user();
$key = 'photo_albums:' . $uid . ':' . Session::getLocalUser() . ':' . Session::getRemoteUser();
$albums = DI::cache()->get($key);
if (is_null($albums) || $update) {
@ -681,7 +681,7 @@ class Photo
*/
public static function clearAlbumCache(int $uid)
{
$key = 'photo_albums:' . $uid . ':' . local_user() . ':' . remote_user();
$key = 'photo_albums:' . $uid . ':' . Session::getLocalUser() . ':' . Session::getRemoteUser();
DI::cache()->set($key, null, Duration::DAY);
}

View file

@ -23,6 +23,7 @@ namespace Friendica\Model;
use BadMethodCallException;
use Friendica\Core\Logger;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\Database;
use Friendica\Database\DBA;
@ -508,7 +509,7 @@ class Post
{
$affected = 0;
Logger::info('Start Update', ['fields' => $fields, 'condition' => $condition, 'uid' => local_user(),'callstack' => System::callstack(10)]);
Logger::info('Start Update', ['fields' => $fields, 'condition' => $condition, 'uid' => Session::getLocalUser(),'callstack' => System::callstack(10)]);
// Don't allow changes to fields that are responsible for the relation between the records
unset($fields['id']);

View file

@ -239,7 +239,7 @@ class Profile
DI::page()['title'] = $profile['name'] . ' @ ' . DI::config()->get('config', 'sitename');
if (!local_user()) {
if (!Session::getLocalUser()) {
$a->setCurrentTheme($profile['theme']);
$a->setCurrentMobileTheme(DI::pConfig()->get($a->getProfileOwner(), 'system', 'mobile_theme') ?? '');
}
@ -295,8 +295,8 @@ class Profile
$profile_contact = [];
if (local_user() && ($profile['uid'] ?? 0) != local_user()) {
$profile_contact = Contact::getByURL($profile['nurl'], null, [], local_user());
if (Session::getLocalUser() && ($profile['uid'] ?? 0) != Session::getLocalUser()) {
$profile_contact = Contact::getByURL($profile['nurl'], null, [], Session::getLocalUser());
}
if (!empty($profile['cid']) && self::getMyURL()) {
$profile_contact = Contact::selectFirst([], ['id' => $profile['cid']]);
@ -413,7 +413,7 @@ class Profile
}
if (!$block && $show_contacts) {
$contact_block = ContactBlock::getHTML($profile, local_user());
$contact_block = ContactBlock::getHTML($profile, Session::getLocalUser());
if (is_array($profile) && !$profile['hide-friends']) {
$contact_count = DBA::count('contact', [
@ -493,7 +493,7 @@ class Profile
*/
public static function getBirthdays(): string
{
if (!local_user() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
if (!Session::getLocalUser() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
return '';
}
@ -506,7 +506,7 @@ class Profile
$bd_short = DI::l10n()->t('F d');
$cacheKey = 'get_birthdays:' . local_user();
$cacheKey = 'get_birthdays:' . Session::getLocalUser();
$events = DI::cache()->get($cacheKey);
if (is_null($events)) {
$result = DBA::p(
@ -523,7 +523,7 @@ class Profile
ORDER BY `start`",
Contact::SHARING,
Contact::FRIEND,
local_user(),
Session::getLocalUser(),
DateTimeFormat::utc('now + 6 days'),
DateTimeFormat::utcNow()
);
@ -595,7 +595,7 @@ class Profile
$a = DI::app();
$o = '';
if (!local_user() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
if (!Session::getLocalUser() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
return $o;
}
@ -610,7 +610,7 @@ class Profile
$classtoday = '';
$condition = ["`uid` = ? AND `type` != 'birthday' AND `start` < ? AND `start` >= ?",
local_user(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utc('now - 1 days')];
Session::getLocalUser(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utc('now - 1 days')];
$s = DBA::select('event', [], $condition, ['order' => ['start']]);
$r = [];
@ -620,7 +620,7 @@ class Profile
$total = 0;
while ($rr = DBA::fetch($s)) {
$condition = ['parent-uri' => $rr['uri'], 'uid' => $rr['uid'], 'author-id' => public_contact(),
$condition = ['parent-uri' => $rr['uri'], 'uid' => $rr['uid'], 'author-id' => Session::getPublicContact(),
'vid' => [Verb::getID(Activity::ATTEND), Verb::getID(Activity::ATTENDMAYBE)],
'visible' => true, 'deleted' => false];
if (!Post::exists($condition)) {
@ -712,7 +712,7 @@ class Profile
$my_url = self::getMyURL();
$my_url = Network::isUrlValid($my_url);
if (empty($my_url) || local_user()) {
if (empty($my_url) || Session::getLocalUser()) {
return;
}
@ -730,7 +730,7 @@ class Profile
$contact = DBA::selectFirst('contact',['id', 'url'], ['id' => $cid]);
if (DBA::isResult($contact) && remote_user() && remote_user() == $contact['id']) {
if (DBA::isResult($contact) && Session::getRemoteUser() && Session::getRemoteUser() == $contact['id']) {
Logger::info('The visitor ' . $my_url . ' is already authenticated');
return;
}
@ -916,7 +916,7 @@ class Profile
*/
public static function getThemeUid(App $a): int
{
return local_user() ?: $a->getProfileOwner();
return Session::getLocalUser() ?: $a->getProfileOwner();
}
/**