use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\L10n;
+use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Database\Database;
public function isLoggedIn(): bool
{
- return local_user() && $this->user_id && ($this->user_id == local_user());
+ return Session::getLocalUser() && $this->user_id && ($this->user_id == Session::getLocalUser());
}
/**
$adminlist = explode(',', str_replace(' ', '', $admin_email));
- return local_user() && $admin_email && $this->database->exists('user', ['uid' => $this->getLoggedInUserId(), 'email' => $adminlist]);
+ return Session::getLocalUser() && $admin_email && $this->database->exists('user', ['uid' => $this->getLoggedInUserId(), 'email' => $adminlist]);
}
/**
$page_theme = null;
// Find the theme that belongs to the user whose stuff we are looking at
- if (!empty($this->profile_owner) && ($this->profile_owner != local_user())) {
+ if (!empty($this->profile_owner) && ($this->profile_owner != Session::getLocalUser())) {
// Allow folks to override user themes and always use their own on their own site.
// This works only if the user is on the same server
$user = $this->database->selectFirst('user', ['theme'], ['uid' => $this->profile_owner]);
- if ($this->database->isResult($user) && !local_user()) {
+ if ($this->database->isResult($user) && !Session::getLocalUser()) {
$page_theme = $user['theme'];
}
}
$page_mobile_theme = null;
// Find the theme that belongs to the user whose stuff we are looking at
- if (!empty($this->profile_owner) && ($this->profile_owner != local_user())) {
+ if (!empty($this->profile_owner) && ($this->profile_owner != Session::getLocalUser())) {
// Allow folks to override user themes and always use their own on their own site.
// This works only if the user is on the same server
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
$page_mobile_theme = $this->pConfig->get($this->profile_owner, 'system', 'mobile-theme');
}
}
}
// ZRL
- if (!empty($_GET['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !local_user()) {
+ if (!empty($_GET['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !Session::getLocalUser()) {
// Only continue when the given profile link seems valid
// Valid profile links contain a path with "/profile/" and no query parameters
if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == '') &&
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
+use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Module\Response;
*/
private function initHead(App $app, Arguments $args, L10n $l10n, IManageConfigValues $config, IManagePersonalConfigValues $pConfig)
{
- $interval = ((local_user()) ? $pConfig->get(local_user(), 'system', 'update_interval') : 40000);
+ $interval = ((Session::getLocalUser()) ? $pConfig->get(Session::getLocalUser(), 'system', 'update_interval') : 40000);
// If the update is 'deactivated' set it to the highest integer number (~24 days)
if ($interval < 0) {
* being first
*/
$this->page['htmlhead'] = Renderer::replaceMacros($tpl, [
- '$local_user' => local_user(),
+ '$local_user' => Session::getLocalUser(),
'$generator' => 'Friendica' . ' ' . App::VERSION,
'$delitem' => $l10n->t('Delete this item?'),
'$blockAuthor' => $l10n->t('Block this author? They won\'t be able to follow you nor see your public posts, and you won\'t be able to see their posts and their notifications.'),
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Lock\Capability\ICanLock;
+use Friendica\Core\Session;
use Friendica\LegacyModule;
use Friendica\Module\HTTPException\MethodNotAllowed;
use Friendica\Module\HTTPException\PageNotFound;
if (Addon::isEnabled($moduleName) && file_exists("addon/{$moduleName}/{$moduleName}.php")) {
//Check if module is an app and if public access to apps is allowed or not
$privateapps = $this->config->get('config', 'private_addons', false);
- if ((!local_user()) && Hook::isAddonApp($moduleName) && $privateapps) {
+ if (!Session::getLocalUser() && Hook::isAddonApp($moduleName) && $privateapps) {
throw new MethodNotAllowedException($this->l10n->t("You must be logged in to use addons. "));
} else {
include_once "addon/{$moduleName}/{$moduleName}.php";
continue;
}
- if (public_contact() == $activity['author-id']) {
+ if (Session::getPublicContact() == $activity['author-id']) {
$conv_responses[$mode][$activity['thr-parent-id']]['self'] = 1;
}
$x['bang'] = $x['bang'] ?? '';
$x['visitor'] = $x['visitor'] ?? 'block';
$x['is_owner'] = $x['is_owner'] ?? true;
- $x['profile_uid'] = $x['profile_uid'] ?? local_user();
+ $x['profile_uid'] = $x['profile_uid'] ?? Session::getLocalUser();
$geotag = !empty($x['allow_location']) ? Renderer::replaceMacros(Renderer::getMarkupTemplate('jot_geotag.tpl'), []) : '';
'$title' => $x['title'] ?? '',
'$placeholdertitle' => $this->l10n->t('Set title'),
'$category' => $x['category'] ?? '',
- '$placeholdercategory' => Feature::isEnabled(local_user(), 'categories') ? $this->l10n->t("Categories \x28comma-separated list\x29") : '',
+ '$placeholdercategory' => Feature::isEnabled(Session::getLocalUser(), 'categories') ? $this->l10n->t("Categories \x28comma-separated list\x29") : '',
'$scheduled_at' => Temporal::getDateTimeField(
new \DateTime(),
new \DateTime('now + 6 months'),
'$browser' => $this->l10n->t('Browser'),
'$compose_link_title' => $this->l10n->t('Open Compose page'),
- '$always_open_compose' => $this->pConfig->get(local_user(), 'frio', 'always_open_compose', false),
+ '$always_open_compose' => $this->pConfig->get(Session::getLocalUser(), 'frio', 'always_open_compose', false),
]);
$this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
$this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
- $ssl_state = (local_user() ? true : false);
+ $ssl_state = (Session::getLocalUser() ? true : false);
$live_update_div = '';
}
}
} elseif ($mode === 'notes') {
- $items = $this->addChildren($items, false, $order, local_user(), $mode);
+ $items = $this->addChildren($items, false, $order, Session::getLocalUser(), $mode);
if (!$update) {
$live_update_div = '<div id="live-notes"></div>' . "\r\n"
- . "<script> var profile_uid = " . local_user()
+ . "<script> var profile_uid = " . Session::getLocalUser()
. "; var netargs = '/?f='; </script>\r\n";
}
} elseif ($mode === 'display') {
$live_update_div = '<div id="live-search"></div>' . "\r\n";
}
- $page_dropping = ((local_user() && local_user() == $uid) ? true : false);
+ $page_dropping = ((Session::getLocalUser() && Session::getLocalUser() == $uid) ? true : false);
if (!$update) {
$_SESSION['return_path'] = $this->args->getQueryString();
'announce' => [],
];
- if ($this->pConfig->get(local_user(), 'system', 'hide_dislike')) {
+ if ($this->pConfig->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
unset($conv_responses['dislike']);
}
$writable = $items[0]['writable'] || ($items[0]['uid'] == 0) && in_array($items[0]['network'], Protocol::FEDERATED);
}
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
$writable = false;
}
$threadsid++;
// prevent private email from leaking.
- if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
+ if ($item['network'] === Protocol::MAIL && Session::getLocalUser() != $item['uid']) {
continue;
}
'announce' => null,
];
- if ($this->pConfig->get(local_user(), 'system', 'hide_dislike')) {
+ if ($this->pConfig->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
unset($likebuttons['dislike']);
}
$body_html = ItemModel::prepareBody($item, true, $preview);
- [$categories, $folders] = $this->item->determineCategoriesTerms($item, local_user());
+ [$categories, $folders] = $this->item->determineCategoriesTerms($item, Session::getLocalUser());
if (!empty($item['title'])) {
$title = $item['title'];
- } elseif (!empty($item['content-warning']) && $this->pConfig->get(local_user(), 'system', 'disable_cw', false)) {
+ } elseif (!empty($item['content-warning']) && $this->pConfig->get(Session::getLocalUser(), 'system', 'disable_cw', false)) {
$title = ucfirst($item['content-warning']);
} else {
$title = '';
$this->builtinActivityPuller($item, $conv_responses);
// Only add what is visible
- if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
+ if ($item['network'] === Protocol::MAIL && Session::getLocalUser() != $item['uid']) {
continue;
}
private function getBlocklist(): array
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return [];
}
- $str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get(local_user(), 'system', 'blocked'));
+ $str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get(Session::getLocalUser(), 'system', 'blocked'));
if (empty($str_blocked)) {
return [];
}
$row['direction'] = ['direction' => 4, 'title' => $this->l10n->t('You subscribed to one or more tags in this post.')];
break;
case ItemModel::PR_ANNOUNCEMENT:
- if (!empty($row['causer-id']) && $this->pConfig->get(local_user(), 'system', 'display_resharer')) {
+ if (!empty($row['causer-id']) && $this->pConfig->get(Session::getLocalUser(), 'system', 'display_resharer')) {
$row['owner-id'] = $row['causer-id'];
$row['owner-link'] = $row['causer-link'];
$row['owner-avatar'] = $row['causer-avatar'];
$parents[$i]['children'] = $this->sortItemChildren($parents[$i]['children']);
}
- if (!$this->pConfig->get(local_user(), 'system', 'no_smart_threading', 0)) {
+ if (!$this->pConfig->get(Session::getLocalUser(), 'system', 'no_smart_threading', 0)) {
foreach ($parents as $i => $parent) {
$parents[$i] = $this->smartFlattenConversation($parent);
}
use Friendica\Content\Text\HTML;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
+use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
AND NOT `contact`.`pending` AND NOT `contact`.`archive`
AND `contact`.`uid` = ?
GROUP BY `contact`.`id`",
- local_user(), Protocol::DFRN, Protocol::ACTIVITYPUB, Contact::TYPE_COMMUNITY, local_user()
+ Session::getLocalUser(), Protocol::DFRN, Protocol::ACTIVITYPUB, Contact::TYPE_COMMUNITY, Session::getLocalUser()
);
return DBA::toArray($stmtContacts);
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
+use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
$categories[] = [
'name' => $savedFolderName,
'url' => $url,
- 'removeurl' => local_user() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
+ 'removeurl' => Session::getLocalUser() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
'first' => $first,
'last' => false
];
$categories[count($categories) - 1]['last'] = true;
}
- if (local_user() == $uid) {
+ if (Session::getLocalUser() == $uid) {
foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::FILE) as $savedFolderName) {
$folders[] = [
'name' => $savedFolderName,
'url' => "#",
- 'removeurl' => local_user() == $uid ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : '',
+ 'removeurl' => Session::getLocalUser() == $uid ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : '',
'first' => $first,
'last' => false
];
$sub_link = $contact_url = $pm_url = $status_link = '';
$photos_link = $posts_link = $block_link = $ignore_link = '';
- if (local_user() && local_user() == $item['uid'] && $item['gravity'] == ItemModel::GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
+ if (Session::getLocalUser() && Session::getLocalUser() == $item['uid'] && $item['gravity'] == ItemModel::GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
$sub_link = 'javascript:doFollowThread(' . $item['id'] . '); return false;';
}
$pcid = $item['author-id'];
$network = '';
$rel = 0;
- $condition = ['uid' => local_user(), 'uri-id' => $item['author-uri-id']];
+ $condition = ['uid' => Session::getLocalUser(), 'uri-id' => $item['author-uri-id']];
$contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
if (DBA::isResult($contact)) {
$cid = $contact['id'];
}
}
- if (local_user()) {
+ if (Session::getLocalUser()) {
$menu = [
$this->l10n->t('Follow Thread') => $sub_link,
$this->l10n->t('View Status') => $status_link,
return (!($this->activity->match($item['verb'], Activity::FOLLOW) &&
$item['object-type'] === Activity\ObjectType::NOTE &&
empty($item['self']) &&
- $item['uid'] == local_user())
+ $item['uid'] == Session::getLocalUser())
);
}
//Don't populate apps_menu if apps are private
$privateapps = DI::config()->get('config', 'private_addons', false);
- if (local_user() || !$privateapps) {
+ if (Session::getLocalUser() || !$privateapps) {
$arr = ['app_menu' => self::$app_menu];
Hook::callAll('app_menu', $arr);
*/
private static function getInfo(App $a): array
{
- $ssl_state = (bool) local_user();
+ $ssl_state = (bool) Session::getLocalUser();
/*
* Our network is distributed, and as you visit friends some of the
$homelink = DI::session()->get('visitor_home', '');
}
- if ((DI::args()->getModuleName() != 'home') && (! (local_user()))) {
+ if ((DI::args()->getModuleName() != 'home') && (! (Session::getLocalUser()))) {
$nav['home'] = [$homelink, DI::l10n()->t('Home'), '', DI::l10n()->t('Home Page')];
}
$nav['apps'] = ['apps', DI::l10n()->t('Apps'), '', DI::l10n()->t('Addon applications, utilities, games')];
}
- if (local_user() || !DI::config()->get('system', 'local_search')) {
+ if (Session::getLocalUser() || !DI::config()->get('system', 'local_search')) {
$nav['search'] = ['search', DI::l10n()->t('Search'), '', DI::l10n()->t('Search site content')];
$nav['searchoption'] = [
}
}
- if ((local_user() || DI::config()->get('system', 'community_page_style') != Community::DISABLED_VISITOR) &&
+ if ((Session::getLocalUser() || DI::config()->get('system', 'community_page_style') != Community::DISABLED_VISITOR) &&
!(DI::config()->get('system', 'community_page_style') == Community::DISABLED)) {
$nav['community'] = ['community', DI::l10n()->t('Community'), '', DI::l10n()->t('Conversations on this and other servers')];
}
- if (local_user()) {
+ if (Session::getLocalUser()) {
$nav['events'] = ['events', DI::l10n()->t('Events'), '', DI::l10n()->t('Events and Calendar')];
}
}
// The following nav links are only show to logged in users
- if (local_user() && !empty($a->getLoggedInUserNickname())) {
+ if (Session::getLocalUser() && !empty($a->getLoggedInUserNickname())) {
$nav['network'] = ['network', DI::l10n()->t('Network'), '', DI::l10n()->t('Conversations from your friends')];
$nav['home'] = ['profile/' . $a->getLoggedInUserNickname(), DI::l10n()->t('Home'), '', DI::l10n()->t('Your posts and conversations')];
$nav['messages']['outbox'] = ['message/sent', DI::l10n()->t('Outbox'), '', DI::l10n()->t('Outbox')];
$nav['messages']['new'] = ['message/new', DI::l10n()->t('New Message'), '', DI::l10n()->t('New Message')];
- if (User::hasIdentities(DI::session()->get('submanage') ?: local_user())) {
+ if (User::hasIdentities(DI::session()->get('submanage') ?: Session::getLocalUser())) {
$nav['delegation'] = ['delegation', DI::l10n()->t('Accounts'), '', DI::l10n()->t('Manage other pages')];
}
namespace Friendica\Content;
use Friendica\Core\Hook;
+use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Util\Strings;
public static function replaceFromArray(string $text, array $smilies, bool $no_images = false): string
{
if (intval(DI::config()->get('system', 'no_smilies'))
- || (local_user() && intval(DI::pConfig()->get(local_user(), 'system', 'no_smilies')))
+ || (Session::getLocalUser() && intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_smilies')))
) {
return $text;
}
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
+use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
$global_dir = Search::getGlobalDirectory();
if (DI::config()->get('system', 'invitation_only')) {
- $x = intval(DI::pConfig()->get(local_user(), 'system', 'invites_remaining'));
+ $x = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'invites_remaining'));
if ($x || DI::app()->isSiteAdmin()) {
DI::page()['aside'] .= '<div class="side-link widget" id="side-invite-remain">'
. DI::l10n()->tt('%d invitation available', '%d invitations available', $x)
*/
public static function groups(string $baseurl, string $selected = ''): string
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return '';
}
'ref' => $group['id'],
'name' => $group['name']
];
- }, Group::getByUserId(local_user()));
+ }, Group::getByUserId(Session::getLocalUser()));
return self::filter(
'group',
*/
public static function contactRels(string $baseurl, string $selected = ''): string
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return '';
}
*/
public static function networks(string $baseurl, string $selected = ''): string
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return '';
}
$networks = self::unavailableNetworks();
$query = "`uid` = ? AND NOT `deleted` AND `network` != '' AND NOT `network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")";
- $condition = array_merge([$query], array_merge([local_user()], $networks));
+ $condition = array_merge([$query], array_merge([Session::getLocalUser()], $networks));
$r = DBA::select('contact', ['network'], $condition, ['group_by' => ['network'], 'order' => ['network']]);
*/
public static function fileAs(string $baseurl, string $selected = ''): string
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return '';
}
$terms = [];
- foreach (Post\Category::getArray(local_user(), Post\Category::FILE) as $savedFolderName) {
+ foreach (Post\Category::getArray(Session::getLocalUser(), Post\Category::FILE) as $savedFolderName) {
$terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName];
}
*/
public static function commonFriendsVisitor(int $uid, string $nickname): string
{
- if (local_user() == $uid) {
+ if (Session::getLocalUser() == $uid) {
return '';
}
- $visitorPCid = local_user() ? Contact::getPublicIdByUserId(local_user()) : remote_user();
+ $visitorPCid = Session::getLocalUser() ? Contact::getPublicIdByUserId(Session::getLocalUser()) : Session::getRemoteUser();
if (!$visitorPCid) {
return '';
}
use Friendica\Core\Renderer;
use Friendica\Core\Search;
+use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
public static function getHTML($return_url, $search = '')
{
$saved = [];
- $saved_searches = DBA::select('search', ['id', 'term'], ['uid' => local_user()]);
+ $saved_searches = DBA::select('search', ['id', 'term'], ['uid' => Session::getLocalUser()]);
while ($saved_search = DBA::fetch($saved_searches)) {
$saved[] = [
'id' => $saved_search['id'],
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
+use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
$photo = Contact::getPhoto($contact);
- if (local_user()) {
+ if (Session::getLocalUser()) {
if ($contact['uid']) {
$id = $contact['id'];
$rel = $contact['rel'];
$pending = $contact['pending'];
} else {
- $pcontact = Contact::selectFirst([], ['uid' => local_user(), 'uri-id' => $contact['uri-id']]);
+ $pcontact = Contact::selectFirst([], ['uid' => Session::getLocalUser(), 'uri-id' => $contact['uri-id']]);
$id = $pcontact['id'] ?? 0;
$rel = $pcontact['rel'] ?? Contact::NOTHING;
$page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
$page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
- $contacts = self::getValidMessageRecipientsForUser(local_user());
+ $contacts = self::getValidMessageRecipientsForUser(Session::getLocalUser());
$tpl = Renderer::getMarkupTemplate('acl/message_recipient.tpl');
$o = Renderer::replaceMacros($tpl, [
return $emptyResultList;
}
- $contactDetails = Contact::getByURLForUser($user_data['url'] ?? '', local_user());
+ $contactDetails = Contact::getByURLForUser($user_data['url'] ?? '', Session::getLocalUser());
$result = new ContactResult(
$user_data['name'] ?? '',
foreach ($profiles as $profile) {
$profile_url = $profile['profile_url'] ?? '';
- $contactDetails = Contact::getByURLForUser($profile_url, local_user());
+ $contactDetails = Contact::getByURLForUser($profile_url, Session::getLocalUser());
$result = new ContactResult(
$profile['name'] ?? '',
$photos_link = '';
if ($uid == 0) {
- $uid = local_user();
+ $uid = Session::getLocalUser();
}
if (empty($contact['uid']) || ($contact['uid'] != $uid)) {
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)) {
}
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'));
}
$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 {
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);
}
}
}
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));
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';
}
namespace Friendica\Model\Contact;
+use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
AND NOT `contact`.`pending`
ORDER BY `contact`.`name` ASC',
$gid,
- local_user()
+ Session::getLocalUser()
);
if (DBA::isResult($stmt)) {
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;
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,
$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') , '', ''];
// 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' => ''];
}
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;
) AS `count`
FROM `group`
WHERE `group`.`uid` = ?;",
- local_user(),
- local_user()
+ Session::getLocalUser(),
+ Session::getLocalUser()
);
return DBA::toArray($stmt);
*/
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 '';
}
$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' : '');
}
// 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;
*/
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
*/
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)) {
// 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']);
}
$plink = $item['uri'];
}
- if (local_user()) {
+ if (Session::getLocalUser()) {
$ret = [
'href' => "display/" . $item['guid'],
'orig' => "display/" . $item['guid'],
use Friendica\Core\ACL;
use Friendica\Core\Logger;
+use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
$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) {
$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);
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'];
$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)) {
$post_id = self::insert(
[
- 'uid' => local_user(),
+ 'uid' => Session::getLocalUser(),
'guid' => $guid,
'convid' => $convid,
'from-name' => $me['name'],
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()]);
}
}
}
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;
{
$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) {
*/
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);
}
use BadMethodCallException;
use Friendica\Core\Logger;
+use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\Database;
use Friendica\Database\DBA;
{
$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']);
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') ?? '');
}
$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']]);
}
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', [
*/
public static function getBirthdays(): string
{
- if (!local_user() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
+ if (!Session::getLocalUser() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
return '';
}
$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(
ORDER BY `start`",
Contact::SHARING,
Contact::FRIEND,
- local_user(),
+ Session::getLocalUser(),
DateTimeFormat::utc('now + 6 days'),
DateTimeFormat::utcNow()
);
$a = DI::app();
$o = '';
- if (!local_user() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
+ if (!Session::getLocalUser() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
return $o;
}
$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 = [];
$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)) {
$my_url = self::getMyURL();
$my_url = Network::isUrlValid($my_url);
- if (empty($my_url) || local_user()) {
+ if (empty($my_url) || Session::getLocalUser()) {
return;
}
$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;
}
*/
public static function getThemeUid(App $a): int
{
- return local_user() ?: $a->getProfileOwner();
+ return Session::getLocalUser() ?: $a->getProfileOwner();
}
/**