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 Session::getLocalUser() && $this->user_id && ($this->user_id == Session::getLocalUser());
+ return DI::userSession()->getLocalUserId() && $this->user_id && ($this->user_id == DI::userSession()->getLocalUserId());
}
/**
$adminlist = explode(',', str_replace(' ', '', $admin_email));
- return Session::getLocalUser() && $admin_email && $this->database->exists('user', ['uid' => $this->getLoggedInUserId(), 'email' => $adminlist]);
+ return DI::userSession()->getLocalUserId() && $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 != Session::getLocalUser())) {
+ if (!empty($this->profile_owner) && ($this->profile_owner != DI::userSession()->getLocalUserId())) {
// 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) && !Session::getLocalUser()) {
+ if ($this->database->isResult($user) && !DI::userSession()->getLocalUserId()) {
$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 != Session::getLocalUser())) {
+ if (!empty($this->profile_owner) && ($this->profile_owner != DI::userSession()->getLocalUserId())) {
// 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 (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
$page_mobile_theme = $this->pConfig->get($this->profile_owner, 'system', 'mobile-theme');
}
}
}
// ZRL
- if (!empty($_GET['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !Session::getLocalUser()) {
+ if (!empty($_GET['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !DI::userSession()->getLocalUserId()) {
// 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\DI;
use Friendica\Module\Response;
use Friendica\Network\HTTPException;
use Friendica\Util\Network;
*/
private function initHead(App $app, Arguments $args, L10n $l10n, IManageConfigValues $config, IManagePersonalConfigValues $pConfig)
{
- $interval = ((Session::getLocalUser()) ? $pConfig->get(Session::getLocalUser(), 'system', 'update_interval') : 40000);
+ $interval = ((DI::userSession()->getLocalUserId()) ? $pConfig->get(DI::userSession()->getLocalUserId(), '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' => Session::getLocalUser(),
+ '$local_user' => DI::userSession()->getLocalUserId(),
'$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\DI;
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 (!Session::getLocalUser() && Hook::isAddonApp($moduleName) && $privateapps) {
+ if (!DI::userSession()->getLocalUserId() && 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";
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\Theme;
use Friendica\Database\DBA;
+use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item as ItemModel;
use Friendica\Model\Post;
continue;
}
- if (Session::getPublicContact() == $activity['author-id']) {
+ if (DI::userSession()->getPublicContactId() == $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'] ?? Session::getLocalUser();
+ $x['profile_uid'] = $x['profile_uid'] ?? DI::userSession()->getLocalUserId();
$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(Session::getLocalUser(), 'categories') ? $this->l10n->t("Categories \x28comma-separated list\x29") : '',
+ '$placeholdercategory' => Feature::isEnabled(DI::userSession()->getLocalUserId(), '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(Session::getLocalUser(), 'frio', 'always_open_compose', false),
+ '$always_open_compose' => $this->pConfig->get(DI::userSession()->getLocalUserId(), '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 = (bool)Session::getLocalUser();
+ $ssl_state = (bool)DI::userSession()->getLocalUserId();
$live_update_div = '';
}
}
} elseif ($mode === 'notes') {
- $items = $this->addChildren($items, false, $order, Session::getLocalUser(), $mode);
+ $items = $this->addChildren($items, false, $order, DI::userSession()->getLocalUserId(), $mode);
if (!$update) {
$live_update_div = '<div id="live-notes"></div>' . "\r\n"
- . "<script> var profile_uid = " . Session::getLocalUser()
+ . "<script> var profile_uid = " . DI::userSession()->getLocalUserId()
. "; var netargs = '/?f='; </script>\r\n";
}
} elseif ($mode === 'display') {
$live_update_div = '<div id="live-search"></div>' . "\r\n";
}
- $page_dropping = Session::getLocalUser() && Session::getLocalUser() == $uid;
+ $page_dropping = DI::userSession()->getLocalUserId() && DI::userSession()->getLocalUserId() == $uid;
if (!$update) {
$_SESSION['return_path'] = $this->args->getQueryString();
'announce' => [],
];
- if ($this->pConfig->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
+ if ($this->pConfig->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike')) {
unset($conv_responses['dislike']);
}
$writable = $items[0]['writable'] || ($items[0]['uid'] == 0) && in_array($items[0]['network'], Protocol::FEDERATED);
}
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
$writable = false;
}
$threadsid++;
// prevent private email from leaking.
- if ($item['network'] === Protocol::MAIL && Session::getLocalUser() != $item['uid']) {
+ if ($item['network'] === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item['uid']) {
continue;
}
'announce' => null,
];
- if ($this->pConfig->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
+ if ($this->pConfig->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike')) {
unset($likebuttons['dislike']);
}
$body_html = ItemModel::prepareBody($item, true, $preview);
- [$categories, $folders] = $this->item->determineCategoriesTerms($item, Session::getLocalUser());
+ [$categories, $folders] = $this->item->determineCategoriesTerms($item, DI::userSession()->getLocalUserId());
if (!empty($item['title'])) {
$title = $item['title'];
- } elseif (!empty($item['content-warning']) && $this->pConfig->get(Session::getLocalUser(), 'system', 'disable_cw', false)) {
+ } elseif (!empty($item['content-warning']) && $this->pConfig->get(DI::userSession()->getLocalUserId(), '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 && Session::getLocalUser() != $item['uid']) {
+ if ($item['network'] === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item['uid']) {
continue;
}
private function getBlocklist(): array
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return [];
}
- $str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get(Session::getLocalUser(), 'system', 'blocked'));
+ $str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get(DI::userSession()->getLocalUserId(), '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(Session::getLocalUser(), 'system', 'display_resharer')) {
+ if (!empty($row['causer-id']) && $this->pConfig->get(DI::userSession()->getLocalUserId(), '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(Session::getLocalUser(), 'system', 'no_smart_threading', 0)) {
+ if (!$this->pConfig->get(DI::userSession()->getLocalUserId(), '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`",
- Session::getLocalUser(), Protocol::DFRN, Protocol::ACTIVITYPUB, Contact::TYPE_COMMUNITY, Session::getLocalUser()
+ DI::userSession()->getLocalUserId(), Protocol::DFRN, Protocol::ACTIVITYPUB, Contact::TYPE_COMMUNITY, DI::userSession()->getLocalUserId()
);
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\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Item as ItemModel;
$categories[] = [
'name' => $savedFolderName,
'url' => $url,
- 'removeurl' => Session::getLocalUser() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
+ 'removeurl' => DI::userSession()->getLocalUserId() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
'first' => $first,
'last' => false
];
$categories[count($categories) - 1]['last'] = true;
}
- if (Session::getLocalUser() == $uid) {
+ if (DI::userSession()->getLocalUserId() == $uid) {
foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::FILE) as $savedFolderName) {
$folders[] = [
'name' => $savedFolderName,
'url' => "#",
- 'removeurl' => Session::getLocalUser() == $uid ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : '',
+ 'removeurl' => DI::userSession()->getLocalUserId() == $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 (Session::getLocalUser() && Session::getLocalUser() == $item['uid'] && $item['gravity'] == ItemModel::GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
+ if (DI::userSession()->getLocalUserId() && DI::userSession()->getLocalUserId() == $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' => Session::getLocalUser(), 'uri-id' => $item['author-uri-id']];
+ $condition = ['uid' => DI::userSession()->getLocalUserId(), 'uri-id' => $item['author-uri-id']];
$contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
if (DBA::isResult($contact)) {
$cid = $contact['id'];
}
}
- if (Session::getLocalUser()) {
+ if (DI::userSession()->getLocalUserId()) {
$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'] == Session::getLocalUser())
+ $item['uid'] == DI::userSession()->getLocalUserId())
);
}
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
//Don't populate apps_menu if apps are private
$privateapps = DI::config()->get('config', 'private_addons', false);
- if (Session::getLocalUser() || !$privateapps) {
+ if (DI::userSession()->getLocalUserId() || !$privateapps) {
$arr = ['app_menu' => self::$app_menu];
Hook::callAll('app_menu', $arr);
*/
private static function getInfo(App $a): array
{
- $ssl_state = (bool) Session::getLocalUser();
+ $ssl_state = (bool) DI::userSession()->getLocalUserId();
/*
* Our network is distributed, and as you visit friends some of the
$userinfo = null;
// nav links: array of array('href', 'text', 'extra css classes', 'title')
- if (Session::isAuthenticated()) {
+ if (DI::userSession()->isAuthenticated()) {
$nav['logout'] = ['logout', DI::l10n()->t('Logout'), '', DI::l10n()->t('End this session')];
} else {
$nav['login'] = ['login', DI::l10n()->t('Login'), (DI::args()->getModuleName() == 'login' ? 'selected' : ''), DI::l10n()->t('Sign in')];
$homelink = DI::session()->get('visitor_home', '');
}
- if ((DI::args()->getModuleName() != 'home') && (! (Session::getLocalUser()))) {
+ if ((DI::args()->getModuleName() != 'home') && (! (DI::userSession()->getLocalUserId()))) {
$nav['home'] = [$homelink, DI::l10n()->t('Home'), '', DI::l10n()->t('Home Page')];
}
- if (intval(DI::config()->get('config', 'register_policy')) === \Friendica\Module\Register::OPEN && !Session::isAuthenticated()) {
+ if (intval(DI::config()->get('config', 'register_policy')) === \Friendica\Module\Register::OPEN && !DI::userSession()->isAuthenticated()) {
$nav['register'] = ['register', DI::l10n()->t('Register'), '', DI::l10n()->t('Create an account')];
}
$nav['apps'] = ['apps', DI::l10n()->t('Apps'), '', DI::l10n()->t('Addon applications, utilities, games')];
}
- if (Session::getLocalUser() || !DI::config()->get('system', 'local_search')) {
+ if (DI::userSession()->getLocalUserId() || !DI::config()->get('system', 'local_search')) {
$nav['search'] = ['search', DI::l10n()->t('Search'), '', DI::l10n()->t('Search site content')];
$nav['searchoption'] = [
}
}
- if ((Session::getLocalUser() || DI::config()->get('system', 'community_page_style') != Community::DISABLED_VISITOR) &&
+ if ((DI::userSession()->getLocalUserId() || 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 (Session::getLocalUser()) {
+ if (DI::userSession()->getLocalUserId()) {
$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 (Session::getLocalUser() && !empty($a->getLoggedInUserNickname())) {
+ if (DI::userSession()->getLocalUserId() && !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') ?: Session::getLocalUser())) {
+ if (User::hasIdentities(DI::session()->get('submanage') ?: DI::userSession()->getLocalUserId())) {
$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'))
- || (Session::getLocalUser() && intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_smilies')))
+ || (DI::userSession()->getLocalUserId() && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), '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(Session::getLocalUser(), 'system', 'invites_remaining'));
+ $x = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), '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 (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return '';
}
'ref' => $group['id'],
'name' => $group['name']
];
- }, Group::getByUserId(Session::getLocalUser()));
+ }, Group::getByUserId(DI::userSession()->getLocalUserId()));
return self::filter(
'group',
*/
public static function contactRels(string $baseurl, string $selected = ''): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return '';
}
*/
public static function networks(string $baseurl, string $selected = ''): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
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([Session::getLocalUser()], $networks));
+ $condition = array_merge([$query], array_merge([DI::userSession()->getLocalUserId()], $networks));
$r = DBA::select('contact', ['network'], $condition, ['group_by' => ['network'], 'order' => ['network']]);
*/
public static function fileAs(string $baseurl, string $selected = ''): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return '';
}
$terms = [];
- foreach (Post\Category::getArray(Session::getLocalUser(), Post\Category::FILE) as $savedFolderName) {
+ foreach (Post\Category::getArray(DI::userSession()->getLocalUserId(), Post\Category::FILE) as $savedFolderName) {
$terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName];
}
*/
public static function commonFriendsVisitor(int $uid, string $nickname): string
{
- if (Session::getLocalUser() == $uid) {
+ if (DI::userSession()->getLocalUserId() == $uid) {
return '';
}
- $visitorPCid = Session::getLocalUser() ? Contact::getPublicIdByUserId(Session::getLocalUser()) : Session::getRemoteUser();
+ $visitorPCid = DI::userSession()->getLocalUserId() ? Contact::getPublicIdByUserId(DI::userSession()->getLocalUserId()) : DI::userSession()->getRemoteUserId();
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' => Session::getLocalUser()]);
+ $saved_searches = DBA::select('search', ['id', 'term'], ['uid' => DI::userSession()->getLocalUserId()]);
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 (Session::getLocalUser()) {
+ if (DI::userSession()->getLocalUserId()) {
if ($contact['uid']) {
$id = $contact['id'];
$rel = $contact['rel'];
$pending = $contact['pending'];
} else {
- $pcontact = Contact::selectFirst([], ['uid' => Session::getLocalUser(), 'uri-id' => $contact['uri-id']]);
+ $pcontact = Contact::selectFirst([], ['uid' => DI::userSession()->getLocalUserId(), '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(Session::getLocalUser());
+ $contacts = self::getValidMessageRecipientsForUser(DI::userSession()->getLocalUserId());
$tpl = Renderer::getMarkupTemplate('acl/message_recipient.tpl');
$o = Renderer::replaceMacros($tpl, [
return $emptyResultList;
}
- $contactDetails = Contact::getByURLForUser($user_data['url'] ?? '', Session::getLocalUser());
+ $contactDetails = Contact::getByURLForUser($user_data['url'] ?? '', DI::userSession()->getLocalUserId());
$result = new ContactResult(
$user_data['name'] ?? '',
foreach ($profiles as $profile) {
$profile_url = $profile['profile_url'] ?? '';
- $contactDetails = Contact::getByURLForUser($profile_url, Session::getLocalUser());
+ $contactDetails = Contact::getByURLForUser($profile_url, DI::userSession()->getLocalUserId());
$result = new ContactResult(
$profile['name'] ?? '',
{
Logger::info('Searching', ['search' => $search, 'mode' => $mode, 'page' => $page]);
- if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
+ if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
return [];
}
use Friendica\BaseFactory;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
+use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Navigation\Notifications\Entity;
use Friendica\Navigation\Notifications\Exception\NoMessageException;
*/
public function createFromParams(array $contact, string $message, \DateTime $date, Uri $href, bool $seen = false): ValueObject\FormattedNavNotification
{
- $contact['photo'] = Contact::getAvatarUrlForUrl($contact['url'], Session::getLocalUser(), Proxy::SIZE_MICRO);
+ $contact['photo'] = Contact::getAvatarUrlForUrl($contact['url'], DI::userSession()->getLocalUserId(), Proxy::SIZE_MICRO);
$dateMySQL = $date->format(DateTimeFormat::MYSQL);
use Friendica\Content\Text\BBCode;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
-use Friendica\Core\Session;
use Friendica\Database\Database;
+use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Post;
$formattedNotifications = new FormattedNotifies();
try {
- $Notifies = $this->notify->selectForUser(Session::getLocalUser(), $conditions, $params);
+ $Notifies = $this->notify->selectForUser(DI::userSession()->getLocalUserId(), $conditions, $params);
foreach ($Notifies as $Notify) {
$formattedNotifications[] = new ValueObject\FormattedNotify(
*/
public function getNetworkList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies
{
- $condition = ['wall' => false, 'uid' => Session::getLocalUser()];
+ $condition = ['wall' => false, 'uid' => DI::userSession()->getLocalUserId()];
if (!$seen) {
$condition['unseen'] = true;
$formattedNotifications = new FormattedNotifies();
try {
- $userPosts = Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params);
+ $userPosts = Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params);
while ($userPost = $this->dba->fetch($userPosts)) {
$formattedNotifications[] = $this->createFromFormattedItem($this->formatItem($userPost));
}
*/
public function getPersonalList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies
{
- $condition = ['wall' => false, 'uid' => Session::getLocalUser(), 'author-id' => Session::getPublicContact()];
+ $condition = ['wall' => false, 'uid' => DI::userSession()->getLocalUserId(), 'author-id' => DI::userSession()->getPublicContactId()];
if (!$seen) {
$condition['unseen'] = true;
$formattedNotifications = new FormattedNotifies();
try {
- $userPosts = Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params);
+ $userPosts = Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params);
while ($userPost = $this->dba->fetch($userPosts)) {
$formattedNotifications[] = $this->createFromFormattedItem($this->formatItem($userPost));
}
*/
public function getHomeList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies
{
- $condition = ['wall' => true, 'uid' => Session::getLocalUser()];
+ $condition = ['wall' => true, 'uid' => DI::userSession()->getLocalUserId()];
if (!$seen) {
$condition['unseen'] = true;
$formattedNotifications = new FormattedNotifies();
try {
- $userPosts = Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params);
+ $userPosts = Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params);
while ($userPost = $this->dba->fetch($userPosts)) {
$formattedItem = $this->formatItem($userPost);
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Protocol;
-use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Database\Database;
+use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Module\BaseNotifications;
use Friendica\Navigation\Notifications\ValueObject;
'url' => $intro['furl'],
'zrl' => Contact::magicLink($intro['furl']),
'hidden' => $intro['hidden'] == 1,
- 'post_newfriend' => (intval($this->pConfig->get(Session::getLocalUser(), 'system', 'post_newfriend')) ? '1' : 0),
+ 'post_newfriend' => (intval($this->pConfig->get(DI::userSession()->getLocalUserId(), 'system', 'post_newfriend')) ? '1' : 0),
'note' => $intro['note'],
'request' => $intro['frequest'] . '?addr=' . $return_addr]);
'about' => BBCode::convert($intro['about'], false),
'keywords' => $intro['keywords'],
'hidden' => $intro['hidden'] == 1,
- 'post_newfriend' => (intval($this->pConfig->get(Session::getLocalUser(), 'system', 'post_newfriend')) ? '1' : 0),
+ 'post_newfriend' => (intval($this->pConfig->get(DI::userSession()->getLocalUserId(), 'system', 'post_newfriend')) ? '1' : 0),
'url' => $intro['url'],
'zrl' => Contact::magicLink($intro['url']),
'addr' => $intro['addr'],
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
}
if ($uid == -1) {
- $uid = Session::getLocalUser();
+ $uid = DI::userSession()->getLocalUserId();
}
if (empty($network) || ($network == Protocol::ACTIVITYPUB)) {
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
$this->setTemplate('wall');
$this->toplevel = $this->getId() == $this->getDataValue('parent');
- if (!empty(Session::getUserIDForVisitorContactID($this->getDataValue('contact-id')))) {
+ if (!empty(DI::userSession()->getUserIDForVisitorContactID($this->getDataValue('contact-id')))) {
$this->visiting = true;
}
if (!empty($data['children'])) {
foreach ($data['children'] as $item) {
// Only add will be displayed
- if ($item['network'] === Protocol::MAIL && Session::getLocalUser() != $item['uid']) {
+ if ($item['network'] === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item['uid']) {
continue;
} elseif (!DI::contentItem()->isVisibleActivity($item)) {
continue;
}
// You can always comment on Diaspora and OStatus items
- if (in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA]) && (Session::getLocalUser() == $item['uid'])) {
+ if (in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA]) && (DI::userSession()->getLocalUserId() == $item['uid'])) {
$item['writable'] = true;
}
$lock = ($item['private'] == Item::PRIVATE) ? $privacy : false;
$connector = !in_array($item['network'], Protocol::NATIVE_SUPPORT) ? DI::l10n()->t('Connector Message') : false;
- $shareable = in_array($conv->getProfileOwner(), [0, Session::getLocalUser()]) && $item['private'] != Item::PRIVATE;
+ $shareable = in_array($conv->getProfileOwner(), [0, DI::userSession()->getLocalUserId()]) && $item['private'] != Item::PRIVATE;
$announceable = $shareable && in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::TWITTER]);
// On Diaspora only toplevel posts can be reshared
$edpost = false;
- if (Session::getLocalUser()) {
+ if (DI::userSession()->getLocalUserId()) {
if (Strings::compareLink(DI::session()->get('my_url'), $item['author-link'])) {
if ($item['event-id'] != 0) {
$edpost = ['events/event/' . $item['event-id'], DI::l10n()->t('Edit')];
$edpost = ['editpost/' . $item['id'], DI::l10n()->t('Edit')];
}
}
- $dropping = in_array($item['uid'], [0, Session::getLocalUser()]);
+ $dropping = in_array($item['uid'], [0, DI::userSession()->getLocalUserId()]);
}
// Editing on items of not subscribed users isn't currently possible
$edpost = false;
}
- if (($this->getDataValue('uid') == Session::getLocalUser()) || $this->isVisiting()) {
+ if (($this->getDataValue('uid') == DI::userSession()->getLocalUserId()) || $this->isVisiting()) {
$dropping = true;
}
$drop = false;
$block = false;
- if (Session::getLocalUser()) {
+ if (DI::userSession()->getLocalUserId()) {
$drop = [
'dropping' => $dropping,
'pagedrop' => $item['pagedrop'],
];
}
- if (!$item['self'] && Session::getLocalUser()) {
+ if (!$item['self'] && DI::userSession()->getLocalUserId()) {
$block = [
'blocking' => true,
'block' => DI::l10n()->t('Block %s', $item['author-name']),
];
}
- $filer = Session::getLocalUser() ? DI::l10n()->t('Save to folder') : false;
+ $filer = DI::userSession()->getLocalUserId() ? DI::l10n()->t('Save to folder') : false;
$profile_name = $item['author-name'];
if (!empty($item['author-link']) && empty($item['author-name'])) {
$profile_name = $item['author-link'];
}
- if (Session::isAuthenticated()) {
+ if (DI::userSession()->isAuthenticated()) {
$author = ['uid' => 0, 'id' => $item['author-id'],
'network' => $item['author-network'], 'url' => $item['author-link']];
$profile_link = Contact::magicLinkByContact($author);
$tagger = '';
if ($this->isToplevel()) {
- if (Session::getLocalUser()) {
- $ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], Session::getLocalUser());
+ if (DI::userSession()->getLocalUserId()) {
+ $ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], DI::userSession()->getLocalUserId());
if ($item['mention'] || $ignored) {
$ignore = [
'do' => DI::l10n()->t('Ignore thread'),
'starred' => DI::l10n()->t('Starred'),
];
- if ($conv->getProfileOwner() == Session::getLocalUser() && ($item['uid'] != 0)) {
+ if ($conv->getProfileOwner() == DI::userSession()->getLocalUserId() && ($item['uid'] != 0)) {
if ($origin && in_array($item['private'], [Item::PUBLIC, Item::UNLISTED])) {
$ispinned = ($item['featured'] ? 'pinned' : 'unpinned');
$body_html = Item::prepareBody($item, true);
- list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item, Session::getLocalUser());
+ list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item, DI::userSession()->getLocalUserId());
if (!empty($item['title'])) {
$title = $item['title'];
- } elseif (!empty($item['content-warning']) && DI::pConfig()->get(Session::getLocalUser(), 'system', 'disable_cw', false)) {
+ } elseif (!empty($item['content-warning']) && DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'disable_cw', false)) {
$title = ucfirst($item['content-warning']);
} else {
$title = '';
}
- if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
+ if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike')) {
$buttons['dislike'] = false;
}
}
// Fetching of Diaspora posts doesn't always work. There are issues with reshares and possibly comments
- if (!Session::getLocalUser() && ($item['network'] != Protocol::DIASPORA) && !empty(DI::session()->get('remote_comment'))) {
+ if (!DI::userSession()->getLocalUserId() && ($item['network'] != Protocol::DIASPORA) && !empty(DI::session()->get('remote_comment'))) {
$remote_comment = [DI::l10n()->t('Comment this item on your system'), DI::l10n()->t('Remote comment'),
str_replace('{uri}', urlencode($item['uri']), DI::session()->get('remote_comment'))];
/*
* Only add what will be displayed
*/
- if ($item->getDataValue('network') === Protocol::MAIL && Session::getLocalUser() != $item->getDataValue('uid')) {
+ if ($item->getDataValue('network') === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item->getDataValue('uid')) {
return false;
} elseif ($activity->match($item->getDataValue('verb'), Activity::LIKE) ||
$activity->match($item->getDataValue('verb'), Activity::DISLIKE)) {
// This will allow us to comment on wall-to-wall items owned by our friends
// and community forums even if somebody else wrote the post.
// bug #517 - this fixes for conversation owner
- if ($conv->getMode() == 'profile' && $conv->getProfileOwner() == Session::getLocalUser()) {
+ if ($conv->getMode() == 'profile' && $conv->getProfileOwner() == DI::userSession()->getLocalUserId()) {
return true;
}
{
$a = DI::app();
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return '';
}
$owner = User::getOwnerDataById($a->getLoggedInUserId());
$item = $this->getData();
- if (!empty($item['content-warning']) && Feature::isEnabled(Session::getLocalUser(), 'add_abstract')) {
+ if (!empty($item['content-warning']) && Feature::isEnabled(DI::userSession()->getLocalUserId(), 'add_abstract')) {
$text = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $item['content-warning'] . "[/abstract]\n";
} else {
$text = '';
}
- if (!Feature::isEnabled(Session::getLocalUser(), 'explicit_mentions')) {
+ if (!Feature::isEnabled(DI::userSession()->getLocalUserId(), 'explicit_mentions')) {
return $text;
}
*/
$qcomment = null;
if (Addon::isEnabled('qcomment')) {
- $words = DI::pConfig()->get(Session::getLocalUser(), 'qcomment', 'words');
+ $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : [];
}
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Protocol\Activity;
use Friendica\Security\Security;
switch ($mode) {
case 'network':
case 'notes':
- $this->profile_owner = Session::getLocalUser();
+ $this->profile_owner = DI::userSession()->getLocalUserId();
$this->writable = true;
break;
case 'profile':
/*
* Only add will be displayed
*/
- if ($item->getDataValue('network') === Protocol::MAIL && Session::getLocalUser() != $item->getDataValue('uid')) {
+ if ($item->getDataValue('network') === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item->getDataValue('uid')) {
Logger::info('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').');
return false;
}
$result = [];
foreach ($this->parents as $item) {
- if ($item->getDataValue('network') === Protocol::MAIL && Session::getLocalUser() != $item->getDataValue('uid')) {
+ if ($item->getDataValue('network') === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item->getDataValue('uid')) {
continue;
}
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Hook;
-use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\System;
use Friendica\Database\Database;
'addr' => $this->remoteAddress,
]);
- Session::setVisitorsContacts();
+ DI::userSession()->setVisitorsContacts();
$member_since = strtotime($user_record['register_date']);
$this->session->set('new_member', time() < ($member_since + (60 * 60 * 24 * 14)));
use Exception;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
Hook::callAll('logged_in', $record);
- self::$current_user_id = Session::getLocalUser();
+ self::$current_user_id = DI::userSession()->getLocalUserId();
return self::$current_user_id;
}
namespace Friendica\Security;
use Friendica\Database\DBA;
+use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\User;
-use Friendica\Core\Session;
/**
* Secures that User is allow to do requests
{
static $verified = 0;
- if (!Session::isAuthenticated()) {
+ if (!DI::userSession()->isAuthenticated()) {
return false;
}
- $uid = Session::getLocalUser();
+ $uid = DI::userSession()->getLocalUserId();
if ($uid == $owner) {
return true;
}
- if (Session::getLocalUser() && ($owner == 0)) {
+ if (DI::userSession()->getLocalUserId() && ($owner == 0)) {
return true;
}
- if (!empty($cid = Session::getRemoteContactID($owner))) {
+ if (!empty($cid = DI::userSession()->getRemoteContactID($owner))) {
// use remembered decision and avoid a DB lookup for each and every display item
// DO NOT use this function if there are going to be multiple owners
// We have a contact-id for an authenticated remote user, this block determines if the contact
*/
public static function getPermissionsSQLByUserId(int $owner_id, bool $accessible = false)
{
- $local_user = Session::getLocalUser();
- $remote_contact = Session::getRemoteContactID($owner_id);
+ $local_user = DI::userSession()->getLocalUserId();
+ $remote_contact = DI::userSession()->getRemoteContactID($owner_id);
$acc_sql = '';
if ($accessible) {
use DateTime;
use DateTimeZone;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
bool $required = false): string
{
// First day of the week (0 = Sunday)
- $firstDay = DI::pConfig()->get(Session::getLocalUser(), 'system', 'first_day_of_week', 0);
+ $firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'first_day_of_week', 0);
$lang = substr(DI::l10n()->getCurrentLang(), 0, 2);