Merge pull request #12039 from nupplaphil/feat/session_util_Modules
UserSession class [3] - Refactor src/ files excluding Module/Model
This commit is contained in:
commit
40f734da58
|
@ -32,7 +32,7 @@ function removeme_post(App $a)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_SESSION['submanage'])) {
|
if (DI::userSession()->getSubManagedUserId()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ function settings_post(App $a)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_SESSION['submanage'])) {
|
if (DI::userSession()->getSubManagedUserId()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ function settings_content(App $a)
|
||||||
return Login::form();
|
return Login::form();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_SESSION['submanage'])) {
|
if (DI::userSession()->getSubManagedUserId()) {
|
||||||
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
|
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
46
src/App.php
46
src/App.php
|
@ -27,13 +27,13 @@ use Friendica\App\BaseURL;
|
||||||
use Friendica\Capabilities\ICanCreateResponses;
|
use Friendica\Capabilities\ICanCreateResponses;
|
||||||
use Friendica\Core\Config\Factory\Config;
|
use Friendica\Core\Config\Factory\Config;
|
||||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||||
|
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||||
use Friendica\Module\Maintenance;
|
use Friendica\Module\Maintenance;
|
||||||
use Friendica\Security\Authentication;
|
use Friendica\Security\Authentication;
|
||||||
use Friendica\Core\Config\ValueObject\Cache;
|
use Friendica\Core\Config\ValueObject\Cache;
|
||||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Theme;
|
use Friendica\Core\Theme;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
|
@ -134,6 +134,11 @@ class App
|
||||||
*/
|
*/
|
||||||
private $session;
|
private $session;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var IHandleUserSessions
|
||||||
|
*/
|
||||||
|
private $userSession;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the user ID
|
* Set the user ID
|
||||||
*
|
*
|
||||||
|
@ -158,7 +163,7 @@ class App
|
||||||
|
|
||||||
public function isLoggedIn(): bool
|
public function isLoggedIn(): bool
|
||||||
{
|
{
|
||||||
return Session::getLocalUser() && $this->user_id && ($this->user_id == Session::getLocalUser());
|
return $this->userSession->getLocalUserId() && $this->user_id && ($this->user_id == $this->userSession->getLocalUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,7 +177,7 @@ class App
|
||||||
|
|
||||||
$adminlist = explode(',', str_replace(' ', '', $admin_email));
|
$adminlist = explode(',', str_replace(' ', '', $admin_email));
|
||||||
|
|
||||||
return Session::getLocalUser() && $admin_email && $this->database->exists('user', ['uid' => $this->getLoggedInUserId(), 'email' => $adminlist]);
|
return $this->userSession->getLocalUserId() && $admin_email && $this->database->exists('user', ['uid' => $this->getLoggedInUserId(), 'email' => $adminlist]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -337,18 +342,19 @@ class App
|
||||||
* @param IManagePersonalConfigValues $pConfig Personal configuration
|
* @param IManagePersonalConfigValues $pConfig Personal configuration
|
||||||
* @param IHandleSessions $session The Session handler
|
* @param IHandleSessions $session The Session handler
|
||||||
*/
|
*/
|
||||||
public function __construct(Database $database, IManageConfigValues $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, IManagePersonalConfigValues $pConfig, IHandleSessions $session)
|
public function __construct(Database $database, IManageConfigValues $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, IManagePersonalConfigValues $pConfig, IHandleSessions $session, IHandleUserSessions $userSession)
|
||||||
{
|
{
|
||||||
$this->database = $database;
|
$this->database = $database;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->mode = $mode;
|
$this->mode = $mode;
|
||||||
$this->baseURL = $baseURL;
|
$this->baseURL = $baseURL;
|
||||||
$this->profiler = $profiler;
|
$this->profiler = $profiler;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
$this->args = $args;
|
$this->args = $args;
|
||||||
$this->pConfig = $pConfig;
|
$this->pConfig = $pConfig;
|
||||||
$this->session = $session;
|
$this->session = $session;
|
||||||
|
$this->userSession = $userSession;
|
||||||
|
|
||||||
$this->load();
|
$this->load();
|
||||||
}
|
}
|
||||||
|
@ -496,11 +502,11 @@ class App
|
||||||
|
|
||||||
$page_theme = null;
|
$page_theme = null;
|
||||||
// Find the theme that belongs to the user whose stuff we are looking at
|
// 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 != $this->userSession->getLocalUserId())) {
|
||||||
// Allow folks to override user themes and always use their own on their own site.
|
// 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
|
// This works only if the user is on the same server
|
||||||
$user = $this->database->selectFirst('user', ['theme'], ['uid' => $this->profile_owner]);
|
$user = $this->database->selectFirst('user', ['theme'], ['uid' => $this->profile_owner]);
|
||||||
if ($this->database->isResult($user) && !Session::getLocalUser()) {
|
if ($this->database->isResult($user) && !$this->userSession->getLocalUserId()) {
|
||||||
$page_theme = $user['theme'];
|
$page_theme = $user['theme'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -529,10 +535,10 @@ class App
|
||||||
|
|
||||||
$page_mobile_theme = null;
|
$page_mobile_theme = null;
|
||||||
// Find the theme that belongs to the user whose stuff we are looking at
|
// 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 != $this->userSession->getLocalUserId())) {
|
||||||
// Allow folks to override user themes and always use their own on their own site.
|
// 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
|
// This works only if the user is on the same server
|
||||||
if (!Session::getLocalUser()) {
|
if (!$this->userSession->getLocalUserId()) {
|
||||||
$page_mobile_theme = $this->pConfig->get($this->profile_owner, 'system', 'mobile-theme');
|
$page_mobile_theme = $this->pConfig->get($this->profile_owner, 'system', 'mobile-theme');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -629,7 +635,7 @@ class App
|
||||||
}
|
}
|
||||||
|
|
||||||
// ZRL
|
// ZRL
|
||||||
if (!empty($_GET['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !Session::getLocalUser()) {
|
if (!empty($_GET['zrl']) && $this->mode->isNormal() && !$this->mode->isBackend() && !$this->userSession->getLocalUserId()) {
|
||||||
// Only continue when the given profile link seems valid
|
// Only continue when the given profile link seems valid
|
||||||
// Valid profile links contain a path with "/profile/" and no query parameters
|
// Valid profile links contain a path with "/profile/" and no query parameters
|
||||||
if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == '') &&
|
if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == '') &&
|
||||||
|
@ -737,7 +743,7 @@ class App
|
||||||
$response = $module->run($input);
|
$response = $module->run($input);
|
||||||
$this->profiler->set(microtime(true) - $timestamp, 'content');
|
$this->profiler->set(microtime(true) - $timestamp, 'content');
|
||||||
if ($response->getHeaderLine(ICanCreateResponses::X_HEADER) === ICanCreateResponses::TYPE_HTML) {
|
if ($response->getHeaderLine(ICanCreateResponses::X_HEADER) === ICanCreateResponses::TYPE_HTML) {
|
||||||
$page->run($this, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig);
|
$page->run($this, $this->baseURL, $this->args, $this->mode, $response, $this->l10n, $this->profiler, $this->config, $pconfig, $this->userSession->getLocalUserId());
|
||||||
} else {
|
} else {
|
||||||
$page->exit($response);
|
$page->exit($response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ use Friendica\Core\Hook;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Theme;
|
use Friendica\Core\Theme;
|
||||||
use Friendica\Module\Response;
|
use Friendica\Module\Response;
|
||||||
|
@ -222,17 +221,18 @@ class Page implements ArrayAccess
|
||||||
* - Infinite scroll data
|
* - Infinite scroll data
|
||||||
* - head.tpl template
|
* - head.tpl template
|
||||||
*
|
*
|
||||||
* @param App $app The Friendica App instance
|
* @param App $app The Friendica App instance
|
||||||
* @param Arguments $args The Friendica App Arguments
|
* @param Arguments $args The Friendica App Arguments
|
||||||
* @param L10n $l10n The l10n language instance
|
* @param L10n $l10n The l10n language instance
|
||||||
* @param IManageConfigValues $config The Friendica configuration
|
* @param IManageConfigValues $config The Friendica configuration
|
||||||
* @param IManagePersonalConfigValues $pConfig The Friendica personal configuration (for user)
|
* @param IManagePersonalConfigValues $pConfig The Friendica personal configuration (for user)
|
||||||
|
* @param int $localUID The local user id
|
||||||
*
|
*
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
private function initHead(App $app, Arguments $args, L10n $l10n, IManageConfigValues $config, IManagePersonalConfigValues $pConfig)
|
private function initHead(App $app, Arguments $args, L10n $l10n, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, int $localUID)
|
||||||
{
|
{
|
||||||
$interval = ((Session::getLocalUser()) ? $pConfig->get(Session::getLocalUser(), 'system', 'update_interval') : 40000);
|
$interval = ($localUID ? $pConfig->get($localUID, 'system', 'update_interval') : 40000);
|
||||||
|
|
||||||
// If the update is 'deactivated' set it to the highest integer number (~24 days)
|
// If the update is 'deactivated' set it to the highest integer number (~24 days)
|
||||||
if ($interval < 0) {
|
if ($interval < 0) {
|
||||||
|
@ -277,7 +277,7 @@ class Page implements ArrayAccess
|
||||||
* being first
|
* being first
|
||||||
*/
|
*/
|
||||||
$this->page['htmlhead'] = Renderer::replaceMacros($tpl, [
|
$this->page['htmlhead'] = Renderer::replaceMacros($tpl, [
|
||||||
'$local_user' => Session::getLocalUser(),
|
'$local_user' => $localUID,
|
||||||
'$generator' => 'Friendica' . ' ' . App::VERSION,
|
'$generator' => 'Friendica' . ' ' . App::VERSION,
|
||||||
'$delitem' => $l10n->t('Delete this item?'),
|
'$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.'),
|
'$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.'),
|
||||||
|
@ -444,10 +444,11 @@ class Page implements ArrayAccess
|
||||||
* @param L10n $l10n The l10n language class
|
* @param L10n $l10n The l10n language class
|
||||||
* @param IManageConfigValues $config The Configuration of this node
|
* @param IManageConfigValues $config The Configuration of this node
|
||||||
* @param IManagePersonalConfigValues $pconfig The personal/user configuration
|
* @param IManagePersonalConfigValues $pconfig The personal/user configuration
|
||||||
|
* @param int $localUID The UID of the local user
|
||||||
*
|
*
|
||||||
* @throws HTTPException\InternalServerErrorException|HTTPException\ServiceUnavailableException
|
* @throws HTTPException\InternalServerErrorException|HTTPException\ServiceUnavailableException
|
||||||
*/
|
*/
|
||||||
public function run(App $app, BaseURL $baseURL, Arguments $args, Mode $mode, ResponseInterface $response, L10n $l10n, Profiler $profiler, IManageConfigValues $config, IManagePersonalConfigValues $pconfig)
|
public function run(App $app, BaseURL $baseURL, Arguments $args, Mode $mode, ResponseInterface $response, L10n $l10n, Profiler $profiler, IManageConfigValues $config, IManagePersonalConfigValues $pconfig, int $localUID)
|
||||||
{
|
{
|
||||||
$moduleName = $args->getModuleName();
|
$moduleName = $args->getModuleName();
|
||||||
|
|
||||||
|
@ -481,7 +482,7 @@ class Page implements ArrayAccess
|
||||||
* all the module functions have executed so that all
|
* all the module functions have executed so that all
|
||||||
* theme choices made by the modules can take effect.
|
* theme choices made by the modules can take effect.
|
||||||
*/
|
*/
|
||||||
$this->initHead($app, $args, $l10n, $config, $pconfig);
|
$this->initHead($app, $args, $l10n, $config, $pconfig, $localUID);
|
||||||
|
|
||||||
/* Build the page ending -- this is stuff that goes right before
|
/* Build the page ending -- this is stuff that goes right before
|
||||||
* the closing </body> tag
|
* the closing </body> tag
|
||||||
|
|
|
@ -34,7 +34,7 @@ use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Lock\Capability\ICanLock;
|
use Friendica\Core\Lock\Capability\ICanLock;
|
||||||
use Friendica\Core\Session;
|
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||||
use Friendica\LegacyModule;
|
use Friendica\LegacyModule;
|
||||||
use Friendica\Module\HTTPException\MethodNotAllowed;
|
use Friendica\Module\HTTPException\MethodNotAllowed;
|
||||||
use Friendica\Module\HTTPException\PageNotFound;
|
use Friendica\Module\HTTPException\PageNotFound;
|
||||||
|
@ -99,6 +99,9 @@ class Router
|
||||||
/** @var LoggerInterface */
|
/** @var LoggerInterface */
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
|
private $isLocalUser;
|
||||||
|
|
||||||
/** @var float */
|
/** @var float */
|
||||||
private $dice_profiler_threshold;
|
private $dice_profiler_threshold;
|
||||||
|
|
||||||
|
@ -121,9 +124,10 @@ class Router
|
||||||
* @param Arguments $args
|
* @param Arguments $args
|
||||||
* @param LoggerInterface $logger
|
* @param LoggerInterface $logger
|
||||||
* @param Dice $dice
|
* @param Dice $dice
|
||||||
|
* @param IHandleUserSessions $userSession
|
||||||
* @param RouteCollector|null $routeCollector
|
* @param RouteCollector|null $routeCollector
|
||||||
*/
|
*/
|
||||||
public function __construct(array $server, string $baseRoutesFilepath, L10n $l10n, ICanCache $cache, ICanLock $lock, IManageConfigValues $config, Arguments $args, LoggerInterface $logger, Dice $dice, RouteCollector $routeCollector = null)
|
public function __construct(array $server, string $baseRoutesFilepath, L10n $l10n, ICanCache $cache, ICanLock $lock, IManageConfigValues $config, Arguments $args, LoggerInterface $logger, Dice $dice, IHandleUserSessions $userSession, RouteCollector $routeCollector = null)
|
||||||
{
|
{
|
||||||
$this->baseRoutesFilepath = $baseRoutesFilepath;
|
$this->baseRoutesFilepath = $baseRoutesFilepath;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
|
@ -134,6 +138,7 @@ class Router
|
||||||
$this->dice = $dice;
|
$this->dice = $dice;
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
$this->isLocalUser = !empty($userSession->getLocalUserId());
|
||||||
$this->dice_profiler_threshold = $config->get('system', 'dice_profiler_threshold', 0);
|
$this->dice_profiler_threshold = $config->get('system', 'dice_profiler_threshold', 0);
|
||||||
|
|
||||||
$this->routeCollector = $routeCollector ?? new RouteCollector(new Std(), new GroupCountBased());
|
$this->routeCollector = $routeCollector ?? new RouteCollector(new Std(), new GroupCountBased());
|
||||||
|
@ -309,7 +314,7 @@ class Router
|
||||||
if (Addon::isEnabled($moduleName) && file_exists("addon/{$moduleName}/{$moduleName}.php")) {
|
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
|
//Check if module is an app and if public access to apps is allowed or not
|
||||||
$privateapps = $this->config->get('config', 'private_addons', false);
|
$privateapps = $this->config->get('config', 'private_addons', false);
|
||||||
if (!Session::getLocalUser() && Hook::isAddonApp($moduleName) && $privateapps) {
|
if (!$this->isLocalUser && Hook::isAddonApp($moduleName) && $privateapps) {
|
||||||
throw new MethodNotAllowedException($this->l10n->t("You must be logged in to use addons. "));
|
throw new MethodNotAllowedException($this->l10n->t("You must be logged in to use addons. "));
|
||||||
} else {
|
} else {
|
||||||
include_once "addon/{$moduleName}/{$moduleName}.php";
|
include_once "addon/{$moduleName}/{$moduleName}.php";
|
||||||
|
|
|
@ -32,8 +32,8 @@ use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||||
|
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||||
use Friendica\Core\Theme;
|
use Friendica\Core\Theme;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
@ -80,22 +80,25 @@ class Conversation
|
||||||
private $mode;
|
private $mode;
|
||||||
/** @var IHandleSessions */
|
/** @var IHandleSessions */
|
||||||
private $session;
|
private $session;
|
||||||
|
/** @var IHandleUserSessions */
|
||||||
|
private $userSession;
|
||||||
|
|
||||||
public function __construct(LoggerInterface $logger, Profiler $profiler, Activity $activity, L10n $l10n, Item $item, Arguments $args, BaseURL $baseURL, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, App\Page $page, App\Mode $mode, App $app, IHandleSessions $session)
|
public function __construct(LoggerInterface $logger, Profiler $profiler, Activity $activity, L10n $l10n, Item $item, Arguments $args, BaseURL $baseURL, IManageConfigValues $config, IManagePersonalConfigValues $pConfig, App\Page $page, App\Mode $mode, App $app, IHandleSessions $session, IHandleUserSessions $userSession)
|
||||||
{
|
{
|
||||||
$this->activity = $activity;
|
$this->activity = $activity;
|
||||||
$this->item = $item;
|
$this->item = $item;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->mode = $mode;
|
$this->mode = $mode;
|
||||||
$this->baseURL = $baseURL;
|
$this->baseURL = $baseURL;
|
||||||
$this->profiler = $profiler;
|
$this->profiler = $profiler;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
$this->args = $args;
|
$this->args = $args;
|
||||||
$this->pConfig = $pConfig;
|
$this->pConfig = $pConfig;
|
||||||
$this->page = $page;
|
$this->page = $page;
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
$this->session = $session;
|
$this->session = $session;
|
||||||
|
$this->userSession = $userSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,7 +175,7 @@ class Conversation
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Session::getPublicContact() == $activity['author-id']) {
|
if ($this->userSession->getPublicContactId() == $activity['author-id']) {
|
||||||
$conv_responses[$mode][$activity['thr-parent-id']]['self'] = 1;
|
$conv_responses[$mode][$activity['thr-parent-id']]['self'] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +300,7 @@ class Conversation
|
||||||
$x['bang'] = $x['bang'] ?? '';
|
$x['bang'] = $x['bang'] ?? '';
|
||||||
$x['visitor'] = $x['visitor'] ?? 'block';
|
$x['visitor'] = $x['visitor'] ?? 'block';
|
||||||
$x['is_owner'] = $x['is_owner'] ?? true;
|
$x['is_owner'] = $x['is_owner'] ?? true;
|
||||||
$x['profile_uid'] = $x['profile_uid'] ?? Session::getLocalUser();
|
$x['profile_uid'] = $x['profile_uid'] ?? $this->userSession->getLocalUserId();
|
||||||
|
|
||||||
|
|
||||||
$geotag = !empty($x['allow_location']) ? Renderer::replaceMacros(Renderer::getMarkupTemplate('jot_geotag.tpl'), []) : '';
|
$geotag = !empty($x['allow_location']) ? Renderer::replaceMacros(Renderer::getMarkupTemplate('jot_geotag.tpl'), []) : '';
|
||||||
|
@ -360,7 +363,7 @@ class Conversation
|
||||||
'$title' => $x['title'] ?? '',
|
'$title' => $x['title'] ?? '',
|
||||||
'$placeholdertitle' => $this->l10n->t('Set title'),
|
'$placeholdertitle' => $this->l10n->t('Set title'),
|
||||||
'$category' => $x['category'] ?? '',
|
'$category' => $x['category'] ?? '',
|
||||||
'$placeholdercategory' => Feature::isEnabled(Session::getLocalUser(), 'categories') ? $this->l10n->t("Categories \x28comma-separated list\x29") : '',
|
'$placeholdercategory' => Feature::isEnabled($this->userSession->getLocalUserId(), 'categories') ? $this->l10n->t("Categories \x28comma-separated list\x29") : '',
|
||||||
'$scheduled_at' => Temporal::getDateTimeField(
|
'$scheduled_at' => Temporal::getDateTimeField(
|
||||||
new \DateTime(),
|
new \DateTime(),
|
||||||
new \DateTime('now + 6 months'),
|
new \DateTime('now + 6 months'),
|
||||||
|
@ -398,7 +401,7 @@ class Conversation
|
||||||
'$browser' => $this->l10n->t('Browser'),
|
'$browser' => $this->l10n->t('Browser'),
|
||||||
|
|
||||||
'$compose_link_title' => $this->l10n->t('Open Compose page'),
|
'$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($this->userSession->getLocalUserId(), 'frio', 'always_open_compose', false),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
@ -437,7 +440,7 @@ class Conversation
|
||||||
$this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
|
$this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
|
||||||
$this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
|
$this->page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css'));
|
||||||
|
|
||||||
$ssl_state = (bool)Session::getLocalUser();
|
$ssl_state = (bool)$this->userSession->getLocalUserId();
|
||||||
|
|
||||||
$live_update_div = '';
|
$live_update_div = '';
|
||||||
|
|
||||||
|
@ -489,11 +492,11 @@ class Conversation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($mode === 'notes') {
|
} elseif ($mode === 'notes') {
|
||||||
$items = $this->addChildren($items, false, $order, Session::getLocalUser(), $mode);
|
$items = $this->addChildren($items, false, $order, $this->userSession->getLocalUserId(), $mode);
|
||||||
|
|
||||||
if (!$update) {
|
if (!$update) {
|
||||||
$live_update_div = '<div id="live-notes"></div>' . "\r\n"
|
$live_update_div = '<div id="live-notes"></div>' . "\r\n"
|
||||||
. "<script> var profile_uid = " . Session::getLocalUser()
|
. "<script> var profile_uid = " . $this->userSession->getLocalUserId()
|
||||||
. "; var netargs = '/?f='; </script>\r\n";
|
. "; var netargs = '/?f='; </script>\r\n";
|
||||||
}
|
}
|
||||||
} elseif ($mode === 'display') {
|
} elseif ($mode === 'display') {
|
||||||
|
@ -527,7 +530,7 @@ class Conversation
|
||||||
$live_update_div = '<div id="live-search"></div>' . "\r\n";
|
$live_update_div = '<div id="live-search"></div>' . "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$page_dropping = Session::getLocalUser() && Session::getLocalUser() == $uid;
|
$page_dropping = $this->userSession->getLocalUserId() && $this->userSession->getLocalUserId() == $uid;
|
||||||
|
|
||||||
if (!$update) {
|
if (!$update) {
|
||||||
$_SESSION['return_path'] = $this->args->getQueryString();
|
$_SESSION['return_path'] = $this->args->getQueryString();
|
||||||
|
@ -547,7 +550,7 @@ class Conversation
|
||||||
'announce' => [],
|
'announce' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($this->pConfig->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
|
if ($this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'hide_dislike')) {
|
||||||
unset($conv_responses['dislike']);
|
unset($conv_responses['dislike']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,7 +568,7 @@ class Conversation
|
||||||
$writable = $items[0]['writable'] || ($items[0]['uid'] == 0) && in_array($items[0]['network'], Protocol::FEDERATED);
|
$writable = $items[0]['writable'] || ($items[0]['uid'] == 0) && in_array($items[0]['network'], Protocol::FEDERATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Session::getLocalUser()) {
|
if (!$this->userSession->getLocalUserId()) {
|
||||||
$writable = false;
|
$writable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,7 +601,7 @@ class Conversation
|
||||||
$threadsid++;
|
$threadsid++;
|
||||||
|
|
||||||
// prevent private email from leaking.
|
// prevent private email from leaking.
|
||||||
if ($item['network'] === Protocol::MAIL && Session::getLocalUser() != $item['uid']) {
|
if ($item['network'] === Protocol::MAIL && $this->userSession->getLocalUserId() != $item['uid']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,17 +645,17 @@ class Conversation
|
||||||
'announce' => null,
|
'announce' => null,
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($this->pConfig->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
|
if ($this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'hide_dislike')) {
|
||||||
unset($likebuttons['dislike']);
|
unset($likebuttons['dislike']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$body_html = ItemModel::prepareBody($item, true, $preview);
|
$body_html = ItemModel::prepareBody($item, true, $preview);
|
||||||
|
|
||||||
[$categories, $folders] = $this->item->determineCategoriesTerms($item, Session::getLocalUser());
|
[$categories, $folders] = $this->item->determineCategoriesTerms($item, $this->userSession->getLocalUserId());
|
||||||
|
|
||||||
if (!empty($item['title'])) {
|
if (!empty($item['title'])) {
|
||||||
$title = $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($this->userSession->getLocalUserId(), 'system', 'disable_cw', false)) {
|
||||||
$title = ucfirst($item['content-warning']);
|
$title = ucfirst($item['content-warning']);
|
||||||
} else {
|
} else {
|
||||||
$title = '';
|
$title = '';
|
||||||
|
@ -746,7 +749,7 @@ class Conversation
|
||||||
$this->builtinActivityPuller($item, $conv_responses);
|
$this->builtinActivityPuller($item, $conv_responses);
|
||||||
|
|
||||||
// Only add what is visible
|
// Only add what is visible
|
||||||
if ($item['network'] === Protocol::MAIL && Session::getLocalUser() != $item['uid']) {
|
if ($item['network'] === Protocol::MAIL && $this->userSession->getLocalUserId() != $item['uid']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -791,11 +794,11 @@ class Conversation
|
||||||
|
|
||||||
private function getBlocklist(): array
|
private function getBlocklist(): array
|
||||||
{
|
{
|
||||||
if (!Session::getLocalUser()) {
|
if (!$this->userSession->getLocalUserId()) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get(Session::getLocalUser(), 'system', 'blocked'));
|
$str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'blocked'));
|
||||||
if (empty($str_blocked)) {
|
if (empty($str_blocked)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -865,7 +868,7 @@ class Conversation
|
||||||
$row['direction'] = ['direction' => 4, 'title' => $this->l10n->t('You subscribed to one or more tags in this post.')];
|
$row['direction'] = ['direction' => 4, 'title' => $this->l10n->t('You subscribed to one or more tags in this post.')];
|
||||||
break;
|
break;
|
||||||
case ItemModel::PR_ANNOUNCEMENT:
|
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($this->userSession->getLocalUserId(), 'system', 'display_resharer')) {
|
||||||
$row['owner-id'] = $row['causer-id'];
|
$row['owner-id'] = $row['causer-id'];
|
||||||
$row['owner-link'] = $row['causer-link'];
|
$row['owner-link'] = $row['causer-link'];
|
||||||
$row['owner-avatar'] = $row['causer-avatar'];
|
$row['owner-avatar'] = $row['causer-avatar'];
|
||||||
|
@ -1217,7 +1220,7 @@ class Conversation
|
||||||
$parents[$i]['children'] = $this->sortItemChildren($parents[$i]['children']);
|
$parents[$i]['children'] = $this->sortItemChildren($parents[$i]['children']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->pConfig->get(Session::getLocalUser(), 'system', 'no_smart_threading', 0)) {
|
if (!$this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'no_smart_threading', 0)) {
|
||||||
foreach ($parents as $i => $parent) {
|
foreach ($parents as $i => $parent) {
|
||||||
$parents[$i] = $this->smartFlattenConversation($parent);
|
$parents[$i] = $this->smartFlattenConversation($parent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ namespace Friendica\Content;
|
||||||
use Friendica\Content\Text\HTML;
|
use Friendica\Content\Text\HTML;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
@ -224,7 +223,7 @@ class ForumManager
|
||||||
AND NOT `contact`.`pending` AND NOT `contact`.`archive`
|
AND NOT `contact`.`pending` AND NOT `contact`.`archive`
|
||||||
AND `contact`.`uid` = ?
|
AND `contact`.`uid` = ?
|
||||||
GROUP BY `contact`.`id`",
|
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);
|
return DBA::toArray($stmtContacts);
|
||||||
|
|
|
@ -27,7 +27,7 @@ use Friendica\Core\Hook;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Session;
|
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
@ -53,12 +53,15 @@ class Item
|
||||||
private $l10n;
|
private $l10n;
|
||||||
/** @var Profiler */
|
/** @var Profiler */
|
||||||
private $profiler;
|
private $profiler;
|
||||||
|
/** @var IHandleUserSessions */
|
||||||
|
private $userSession;
|
||||||
|
|
||||||
public function __construct(Profiler $profiler, Activity $activity, L10n $l10n)
|
public function __construct(Profiler $profiler, Activity $activity, L10n $l10n, IHandleUserSessions $userSession)
|
||||||
{
|
{
|
||||||
$this->profiler = $profiler;
|
$this->profiler = $profiler;
|
||||||
$this->activity = $activity;
|
$this->activity = $activity;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
|
$this->userSession = $userSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,7 +113,7 @@ class Item
|
||||||
$categories[] = [
|
$categories[] = [
|
||||||
'name' => $savedFolderName,
|
'name' => $savedFolderName,
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
'removeurl' => Session::getLocalUser() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
|
'removeurl' => $this->userSession->getLocalUserId() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
|
||||||
'first' => $first,
|
'first' => $first,
|
||||||
'last' => false
|
'last' => false
|
||||||
];
|
];
|
||||||
|
@ -121,12 +124,12 @@ class Item
|
||||||
$categories[count($categories) - 1]['last'] = true;
|
$categories[count($categories) - 1]['last'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Session::getLocalUser() == $uid) {
|
if ($this->userSession->getLocalUserId() == $uid) {
|
||||||
foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::FILE) as $savedFolderName) {
|
foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::FILE) as $savedFolderName) {
|
||||||
$folders[] = [
|
$folders[] = [
|
||||||
'name' => $savedFolderName,
|
'name' => $savedFolderName,
|
||||||
'url' => "#",
|
'url' => "#",
|
||||||
'removeurl' => Session::getLocalUser() == $uid ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : '',
|
'removeurl' => $this->userSession->getLocalUserId() == $uid ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : '',
|
||||||
'first' => $first,
|
'first' => $first,
|
||||||
'last' => false
|
'last' => false
|
||||||
];
|
];
|
||||||
|
@ -332,7 +335,7 @@ class Item
|
||||||
$sub_link = $contact_url = $pm_url = $status_link = '';
|
$sub_link = $contact_url = $pm_url = $status_link = '';
|
||||||
$photos_link = $posts_link = $block_link = $ignore_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 ($this->userSession->getLocalUserId() && $this->userSession->getLocalUserId() == $item['uid'] && $item['gravity'] == ItemModel::GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
|
||||||
$sub_link = 'javascript:doFollowThread(' . $item['id'] . '); return false;';
|
$sub_link = 'javascript:doFollowThread(' . $item['id'] . '); return false;';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +352,7 @@ class Item
|
||||||
$pcid = $item['author-id'];
|
$pcid = $item['author-id'];
|
||||||
$network = '';
|
$network = '';
|
||||||
$rel = 0;
|
$rel = 0;
|
||||||
$condition = ['uid' => Session::getLocalUser(), 'uri-id' => $item['author-uri-id']];
|
$condition = ['uid' => $this->userSession->getLocalUserId(), 'uri-id' => $item['author-uri-id']];
|
||||||
$contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
|
$contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
|
||||||
if (DBA::isResult($contact)) {
|
if (DBA::isResult($contact)) {
|
||||||
$cid = $contact['id'];
|
$cid = $contact['id'];
|
||||||
|
@ -379,7 +382,7 @@ class Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Session::getLocalUser()) {
|
if ($this->userSession->getLocalUserId()) {
|
||||||
$menu = [
|
$menu = [
|
||||||
$this->l10n->t('Follow Thread') => $sub_link,
|
$this->l10n->t('Follow Thread') => $sub_link,
|
||||||
$this->l10n->t('View Status') => $status_link,
|
$this->l10n->t('View Status') => $status_link,
|
||||||
|
@ -440,7 +443,7 @@ class Item
|
||||||
return (!($this->activity->match($item['verb'], Activity::FOLLOW) &&
|
return (!($this->activity->match($item['verb'], Activity::FOLLOW) &&
|
||||||
$item['object-type'] === Activity\ObjectType::NOTE &&
|
$item['object-type'] === Activity\ObjectType::NOTE &&
|
||||||
empty($item['self']) &&
|
empty($item['self']) &&
|
||||||
$item['uid'] == Session::getLocalUser())
|
$item['uid'] == $this->userSession->getLocalUserId())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ namespace Friendica\Content;
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
@ -127,7 +126,7 @@ class Nav
|
||||||
|
|
||||||
//Don't populate apps_menu if apps are private
|
//Don't populate apps_menu if apps are private
|
||||||
$privateapps = DI::config()->get('config', 'private_addons', false);
|
$privateapps = DI::config()->get('config', 'private_addons', false);
|
||||||
if (Session::getLocalUser() || !$privateapps) {
|
if (DI::userSession()->getLocalUserId() || !$privateapps) {
|
||||||
$arr = ['app_menu' => self::$app_menu];
|
$arr = ['app_menu' => self::$app_menu];
|
||||||
|
|
||||||
Hook::callAll('app_menu', $arr);
|
Hook::callAll('app_menu', $arr);
|
||||||
|
@ -149,7 +148,7 @@ class Nav
|
||||||
*/
|
*/
|
||||||
private static function getInfo(App $a): array
|
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
|
* Our network is distributed, and as you visit friends some of the
|
||||||
|
@ -182,7 +181,7 @@ class Nav
|
||||||
$userinfo = null;
|
$userinfo = null;
|
||||||
|
|
||||||
// nav links: array of array('href', 'text', 'extra css classes', 'title')
|
// 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')];
|
$nav['logout'] = ['logout', DI::l10n()->t('Logout'), '', DI::l10n()->t('End this session')];
|
||||||
} else {
|
} else {
|
||||||
$nav['login'] = ['login', DI::l10n()->t('Login'), (DI::args()->getModuleName() == 'login' ? 'selected' : ''), DI::l10n()->t('Sign in')];
|
$nav['login'] = ['login', DI::l10n()->t('Login'), (DI::args()->getModuleName() == 'login' ? 'selected' : ''), DI::l10n()->t('Sign in')];
|
||||||
|
@ -211,11 +210,11 @@ class Nav
|
||||||
$homelink = DI::session()->get('visitor_home', '');
|
$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')];
|
$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['register'] = ['register', DI::l10n()->t('Register'), '', DI::l10n()->t('Create an account')];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +228,7 @@ class Nav
|
||||||
$nav['apps'] = ['apps', DI::l10n()->t('Apps'), '', DI::l10n()->t('Addon applications, utilities, games')];
|
$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['search'] = ['search', DI::l10n()->t('Search'), '', DI::l10n()->t('Search site content')];
|
||||||
|
|
||||||
$nav['searchoption'] = [
|
$nav['searchoption'] = [
|
||||||
|
@ -252,12 +251,12 @@ class Nav
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)) {
|
!(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')];
|
$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')];
|
$nav['events'] = ['events', DI::l10n()->t('Events'), '', DI::l10n()->t('Events and Calendar')];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +269,7 @@ class Nav
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following nav links are only show to logged in users
|
// 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['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['home'] = ['profile/' . $a->getLoggedInUserNickname(), DI::l10n()->t('Home'), '', DI::l10n()->t('Your posts and conversations')];
|
||||||
|
@ -288,7 +287,7 @@ class Nav
|
||||||
$nav['messages']['outbox'] = ['message/sent', DI::l10n()->t('Outbox'), '', DI::l10n()->t('Outbox')];
|
$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')];
|
$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::userSession()->getSubManagedUserId() ?: DI::userSession()->getLocalUserId())) {
|
||||||
$nav['delegation'] = ['delegation', DI::l10n()->t('Accounts'), '', DI::l10n()->t('Manage other pages')];
|
$nav['delegation'] = ['delegation', DI::l10n()->t('Accounts'), '', DI::l10n()->t('Manage other pages')];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
namespace Friendica\Content;
|
namespace Friendica\Content;
|
||||||
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
|
@ -214,7 +213,7 @@ class Smilies
|
||||||
public static function replaceFromArray(string $text, array $smilies, bool $no_images = false): string
|
public static function replaceFromArray(string $text, array $smilies, bool $no_images = false): string
|
||||||
{
|
{
|
||||||
if (intval(DI::config()->get('system', 'no_smilies'))
|
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;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ use Friendica\Core\Cache\Enum\Duration;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Search;
|
use Friendica\Core\Search;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
@ -67,7 +66,7 @@ class Widget
|
||||||
$global_dir = Search::getGlobalDirectory();
|
$global_dir = Search::getGlobalDirectory();
|
||||||
|
|
||||||
if (DI::config()->get('system', 'invitation_only')) {
|
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()) {
|
if ($x || DI::app()->isSiteAdmin()) {
|
||||||
DI::page()['aside'] .= '<div class="side-link widget" id="side-invite-remain">'
|
DI::page()['aside'] .= '<div class="side-link widget" id="side-invite-remain">'
|
||||||
. DI::l10n()->tt('%d invitation available', '%d invitations available', $x)
|
. DI::l10n()->tt('%d invitation available', '%d invitations available', $x)
|
||||||
|
@ -196,7 +195,7 @@ class Widget
|
||||||
*/
|
*/
|
||||||
public static function groups(string $baseurl, string $selected = ''): string
|
public static function groups(string $baseurl, string $selected = ''): string
|
||||||
{
|
{
|
||||||
if (!Session::getLocalUser()) {
|
if (!DI::userSession()->getLocalUserId()) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +204,7 @@ class Widget
|
||||||
'ref' => $group['id'],
|
'ref' => $group['id'],
|
||||||
'name' => $group['name']
|
'name' => $group['name']
|
||||||
];
|
];
|
||||||
}, Group::getByUserId(Session::getLocalUser()));
|
}, Group::getByUserId(DI::userSession()->getLocalUserId()));
|
||||||
|
|
||||||
return self::filter(
|
return self::filter(
|
||||||
'group',
|
'group',
|
||||||
|
@ -228,7 +227,7 @@ class Widget
|
||||||
*/
|
*/
|
||||||
public static function contactRels(string $baseurl, string $selected = ''): string
|
public static function contactRels(string $baseurl, string $selected = ''): string
|
||||||
{
|
{
|
||||||
if (!Session::getLocalUser()) {
|
if (!DI::userSession()->getLocalUserId()) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,13 +258,13 @@ class Widget
|
||||||
*/
|
*/
|
||||||
public static function networks(string $baseurl, string $selected = ''): string
|
public static function networks(string $baseurl, string $selected = ''): string
|
||||||
{
|
{
|
||||||
if (!Session::getLocalUser()) {
|
if (!DI::userSession()->getLocalUserId()) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$networks = self::unavailableNetworks();
|
$networks = self::unavailableNetworks();
|
||||||
$query = "`uid` = ? AND NOT `deleted` AND `network` != '' AND NOT `network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")";
|
$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']]);
|
$r = DBA::select('contact', ['network'], $condition, ['group_by' => ['network'], 'order' => ['network']]);
|
||||||
|
|
||||||
|
@ -300,12 +299,12 @@ class Widget
|
||||||
*/
|
*/
|
||||||
public static function fileAs(string $baseurl, string $selected = ''): string
|
public static function fileAs(string $baseurl, string $selected = ''): string
|
||||||
{
|
{
|
||||||
if (!Session::getLocalUser()) {
|
if (!DI::userSession()->getLocalUserId()) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$terms = [];
|
$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];
|
$terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,11 +361,11 @@ class Widget
|
||||||
*/
|
*/
|
||||||
public static function commonFriendsVisitor(int $uid, string $nickname): string
|
public static function commonFriendsVisitor(int $uid, string $nickname): string
|
||||||
{
|
{
|
||||||
if (Session::getLocalUser() == $uid) {
|
if (DI::userSession()->getLocalUserId() == $uid) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$visitorPCid = Session::getLocalUser() ? Contact::getPublicIdByUserId(Session::getLocalUser()) : Session::getRemoteUser();
|
$visitorPCid = DI::userSession()->getPublicContactId() ?: DI::userSession()->getRemoteUserId();
|
||||||
if (!$visitorPCid) {
|
if (!$visitorPCid) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Content\Widget;
|
||||||
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Search;
|
use Friendica\Core\Search;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
@ -38,7 +37,7 @@ class SavedSearches
|
||||||
public static function getHTML($return_url, $search = '')
|
public static function getHTML($return_url, $search = '')
|
||||||
{
|
{
|
||||||
$saved = [];
|
$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)) {
|
while ($saved_search = DBA::fetch($saved_searches)) {
|
||||||
$saved[] = [
|
$saved[] = [
|
||||||
'id' => $saved_search['id'],
|
'id' => $saved_search['id'],
|
||||||
|
|
|
@ -26,7 +26,6 @@ use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
@ -65,13 +64,13 @@ class VCard
|
||||||
|
|
||||||
$photo = Contact::getPhoto($contact);
|
$photo = Contact::getPhoto($contact);
|
||||||
|
|
||||||
if (Session::getLocalUser()) {
|
if (DI::userSession()->getLocalUserId()) {
|
||||||
if ($contact['uid']) {
|
if ($contact['uid']) {
|
||||||
$id = $contact['id'];
|
$id = $contact['id'];
|
||||||
$rel = $contact['rel'];
|
$rel = $contact['rel'];
|
||||||
$pending = $contact['pending'];
|
$pending = $contact['pending'];
|
||||||
} else {
|
} 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;
|
$id = $pcontact['id'] ?? 0;
|
||||||
$rel = $pcontact['rel'] ?? Contact::NOTHING;
|
$rel = $pcontact['rel'] ?? Contact::NOTHING;
|
||||||
|
|
|
@ -62,7 +62,7 @@ class ACL
|
||||||
$page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
|
$page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css'));
|
||||||
$page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.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');
|
$tpl = Renderer::getMarkupTemplate('acl/message_recipient.tpl');
|
||||||
$o = Renderer::replaceMacros($tpl, [
|
$o = Renderer::replaceMacros($tpl, [
|
||||||
|
|
|
@ -70,7 +70,7 @@ class Search
|
||||||
return $emptyResultList;
|
return $emptyResultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contactDetails = Contact::getByURLForUser($user_data['url'] ?? '', Session::getLocalUser());
|
$contactDetails = Contact::getByURLForUser($user_data['url'] ?? '', DI::userSession()->getLocalUserId());
|
||||||
|
|
||||||
$result = new ContactResult(
|
$result = new ContactResult(
|
||||||
$user_data['name'] ?? '',
|
$user_data['name'] ?? '',
|
||||||
|
@ -136,7 +136,7 @@ class Search
|
||||||
|
|
||||||
foreach ($profiles as $profile) {
|
foreach ($profiles as $profile) {
|
||||||
$profile_url = $profile['profile_url'] ?? '';
|
$profile_url = $profile['profile_url'] ?? '';
|
||||||
$contactDetails = Contact::getByURLForUser($profile_url, Session::getLocalUser());
|
$contactDetails = Contact::getByURLForUser($profile_url, DI::userSession()->getLocalUserId());
|
||||||
|
|
||||||
$result = new ContactResult(
|
$result = new ContactResult(
|
||||||
$profile['name'] ?? '',
|
$profile['name'] ?? '',
|
||||||
|
@ -211,7 +211,7 @@ class Search
|
||||||
{
|
{
|
||||||
Logger::info('Searching', ['search' => $search, 'mode' => $mode, 'page' => $page]);
|
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 [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,172 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @copyright Copyright (C) 2010-2022, the Friendica project
|
|
||||||
*
|
|
||||||
* @license GNU AGPL version 3 or any later version
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Friendica\Core;
|
|
||||||
|
|
||||||
use Friendica\Database\DBA;
|
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Model\Contact;
|
|
||||||
use Friendica\Util\Strings;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* High-level Session service class
|
|
||||||
*/
|
|
||||||
class Session
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Returns the user id of locally logged in user or false.
|
|
||||||
*
|
|
||||||
* @return int|bool user id or false
|
|
||||||
*/
|
|
||||||
public static function getLocalUser()
|
|
||||||
{
|
|
||||||
$session = DI::session();
|
|
||||||
|
|
||||||
if (!empty($session->get('authenticated')) && !empty($session->get('uid'))) {
|
|
||||||
return intval($session->get('uid'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the public contact id of logged in user or false.
|
|
||||||
*
|
|
||||||
* @return int|bool public contact id or false
|
|
||||||
*/
|
|
||||||
public static function getPublicContact()
|
|
||||||
{
|
|
||||||
static $public_contact_id = false;
|
|
||||||
|
|
||||||
$session = DI::session();
|
|
||||||
|
|
||||||
if (!$public_contact_id && !empty($session->get('authenticated'))) {
|
|
||||||
if (!empty($session->get('my_address'))) {
|
|
||||||
// Local user
|
|
||||||
$public_contact_id = intval(Contact::getIdForURL($session->get('my_address'), 0, false));
|
|
||||||
} elseif (!empty($session->get('visitor_home'))) {
|
|
||||||
// Remote user
|
|
||||||
$public_contact_id = intval(Contact::getIdForURL($session->get('visitor_home'), 0, false));
|
|
||||||
}
|
|
||||||
} elseif (empty($session->get('authenticated'))) {
|
|
||||||
$public_contact_id = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $public_contact_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns public contact id of authenticated site visitor or false
|
|
||||||
*
|
|
||||||
* @return int|bool visitor_id or false
|
|
||||||
*/
|
|
||||||
public static function getRemoteUser()
|
|
||||||
{
|
|
||||||
$session = DI::session();
|
|
||||||
|
|
||||||
if (empty($session->get('authenticated'))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($session->get('visitor_id'))) {
|
|
||||||
return intval($session->get('visitor_id'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the user contact ID of a visitor for the given user ID they are visiting
|
|
||||||
*
|
|
||||||
* @param integer $uid User ID
|
|
||||||
* @return integer
|
|
||||||
*/
|
|
||||||
public static function getRemoteContactID($uid)
|
|
||||||
{
|
|
||||||
$session = DI::session();
|
|
||||||
|
|
||||||
if (!empty($session->get('remote')[$uid])) {
|
|
||||||
$remote = $session->get('remote')[$uid];
|
|
||||||
} else {
|
|
||||||
$remote = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$local_user = !empty($session->get('authenticated')) ? $session->get('uid') : 0;
|
|
||||||
|
|
||||||
if (empty($remote) && ($local_user != $uid) && !empty($my_address = $session->get('my_address'))) {
|
|
||||||
$remote = Contact::getIdForURL($my_address, $uid, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $remote;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns User ID for given contact ID of the visitor
|
|
||||||
*
|
|
||||||
* @param integer $cid Contact ID
|
|
||||||
* @return integer User ID for given contact ID of the visitor
|
|
||||||
*/
|
|
||||||
public static function getUserIDForVisitorContactID($cid)
|
|
||||||
{
|
|
||||||
$session = DI::session();
|
|
||||||
|
|
||||||
if (empty($session->get('remote'))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_search($cid, $session->get('remote'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the session variable that contains the contact IDs for the visitor's contact URL
|
|
||||||
*
|
|
||||||
* @param string $url Contact URL
|
|
||||||
*/
|
|
||||||
public static function setVisitorsContacts()
|
|
||||||
{
|
|
||||||
$session = DI::session();
|
|
||||||
|
|
||||||
$session->set('remote', []);
|
|
||||||
$remote = [];
|
|
||||||
|
|
||||||
$remote_contacts = DBA::select('contact', ['id', 'uid'], ['nurl' => Strings::normaliseLink($session->get('my_url')), 'rel' => [Contact::FOLLOWER, Contact::FRIEND], 'self' => false]);
|
|
||||||
while ($contact = DBA::fetch($remote_contacts)) {
|
|
||||||
if (($contact['uid'] == 0) || Contact\User::isBlocked($contact['id'], $contact['uid'])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$remote[$contact['uid']] = $contact['id'];
|
|
||||||
}
|
|
||||||
DBA::close($remote_contacts);
|
|
||||||
$session->set('remote', $remote);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns if the current visitor is authenticated
|
|
||||||
*
|
|
||||||
* @return boolean "true" when visitor is either a local or remote user
|
|
||||||
*/
|
|
||||||
public static function isAuthenticated()
|
|
||||||
{
|
|
||||||
$session = DI::session();
|
|
||||||
|
|
||||||
return $session->get('authenticated', false);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -72,6 +72,20 @@ interface IHandleUserSessions
|
||||||
*/
|
*/
|
||||||
public function isAuthenticated(): bool;
|
public function isAuthenticated(): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns User ID of the managed user in case it's a different identity
|
||||||
|
*
|
||||||
|
* @return int|bool uid of the manager or false
|
||||||
|
*/
|
||||||
|
public function getSubManagedUserId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the User ID of the managed user in case it's a different identity
|
||||||
|
*
|
||||||
|
* @param int $managed_uid The user id of the managing user
|
||||||
|
*/
|
||||||
|
public function setSubManagedUserId(int $managed_uid): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the session variable that contains the contact IDs for the visitor's contact URL
|
* Set the session variable that contains the contact IDs for the visitor's contact URL
|
||||||
*
|
*
|
||||||
|
|
|
@ -118,4 +118,16 @@ class UserSession implements IHandleUserSessions
|
||||||
{
|
{
|
||||||
$this->session->set('remote', Contact::getVisitorByUrl($this->session->get('my_url')));
|
$this->session->set('remote', Contact::getVisitorByUrl($this->session->get('my_url')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
public function getSubManagedUserId()
|
||||||
|
{
|
||||||
|
return $this->session->get('submanage') ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
public function setSubManagedUserId(int $managed_uid): void
|
||||||
|
{
|
||||||
|
$this->session->set('submanage', $managed_uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Module\Admin\Users;
|
||||||
|
|
||||||
use Friendica\Content\Pager;
|
use Friendica\Content\Pager;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Module\Admin\Users;
|
||||||
|
|
||||||
use Friendica\Content\Pager;
|
use Friendica\Content\Pager;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
|
|
@ -63,7 +63,7 @@ abstract class BaseAdmin extends BaseModule
|
||||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('You don\'t have access to administration pages.'));
|
throw new HTTPException\ForbiddenException(DI::l10n()->t('You don\'t have access to administration pages.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_SESSION['submanage'])) {
|
if (DI::userSession()->getSubManagedUserId()) {
|
||||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Submanaged account can\'t access the administration pages. Please log back in as the main account.'));
|
throw new HTTPException\ForbiddenException(DI::l10n()->t('Submanaged account can\'t access the administration pages. Please log back in as the main account.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ use Friendica\Core\Hook;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
|
|
@ -45,8 +45,8 @@ class Delegation extends BaseModule
|
||||||
$uid = DI::userSession()->getLocalUserId();
|
$uid = DI::userSession()->getLocalUserId();
|
||||||
$orig_record = User::getById(DI::app()->getLoggedInUserId());
|
$orig_record = User::getById(DI::app()->getLoggedInUserId());
|
||||||
|
|
||||||
if (DI::session()->get('submanage')) {
|
if (DI::userSession()->getSubManagedUserId()) {
|
||||||
$user = User::getById(DI::session()->get('submanage'));
|
$user = User::getById(DI::userSession()->getSubManagedUserId());
|
||||||
if (DBA::isResult($user)) {
|
if (DBA::isResult($user)) {
|
||||||
$uid = intval($user['uid']);
|
$uid = intval($user['uid']);
|
||||||
$orig_record = $user;
|
$orig_record = $user;
|
||||||
|
@ -101,7 +101,7 @@ class Delegation extends BaseModule
|
||||||
DI::auth()->setForUser(DI::app(), $user, true, true);
|
DI::auth()->setForUser(DI::app(), $user, true, true);
|
||||||
|
|
||||||
if ($limited_id) {
|
if ($limited_id) {
|
||||||
DI::session()->set('submanage', $original_id);
|
DI::userSession()->setSubManagedUserId($original_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = [];
|
$ret = [];
|
||||||
|
@ -118,7 +118,7 @@ class Delegation extends BaseModule
|
||||||
throw new ForbiddenException(DI::l10n()->t('Permission denied.'));
|
throw new ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$identities = User::identities(DI::session()->get('submanage', DI::userSession()->getLocalUserId()));
|
$identities = User::identities(DI::userSession()->getSubManagedUserId() ?: DI::userSession()->getLocalUserId());
|
||||||
|
|
||||||
//getting additinal information for each identity
|
//getting additinal information for each identity
|
||||||
foreach ($identities as $key => $identity) {
|
foreach ($identities as $key => $identity) {
|
||||||
|
|
|
@ -76,7 +76,7 @@ class Delegation extends BaseSettings
|
||||||
$user_id = $args->get(3);
|
$user_id = $args->get(3);
|
||||||
|
|
||||||
if ($action === 'add' && $user_id) {
|
if ($action === 'add' && $user_id) {
|
||||||
if (DI::session()->get('submanage')) {
|
if (DI::userSession()->getSubManagedUserId()) {
|
||||||
DI::sysmsg()->addNotice(DI::l10n()->t('Delegated administrators can view but not change delegation permissions.'));
|
DI::sysmsg()->addNotice(DI::l10n()->t('Delegated administrators can view but not change delegation permissions.'));
|
||||||
DI::baseUrl()->redirect('settings/delegation');
|
DI::baseUrl()->redirect('settings/delegation');
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ class Delegation extends BaseSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action === 'remove' && $user_id) {
|
if ($action === 'remove' && $user_id) {
|
||||||
if (DI::session()->get('submanage')) {
|
if (DI::userSession()->getSubManagedUserId()) {
|
||||||
DI::sysmsg()->addNotice(DI::l10n()->t('Delegated administrators can view but not change delegation permissions.'));
|
DI::sysmsg()->addNotice(DI::l10n()->t('Delegated administrators can view but not change delegation permissions.'));
|
||||||
DI::baseUrl()->redirect('settings/delegation');
|
DI::baseUrl()->redirect('settings/delegation');
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Friendica\Navigation\Notifications\Factory;
|
||||||
|
|
||||||
use Friendica\BaseFactory;
|
use Friendica\BaseFactory;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Navigation\Notifications\Entity;
|
use Friendica\Navigation\Notifications\Entity;
|
||||||
use Friendica\Navigation\Notifications\Exception\NoMessageException;
|
use Friendica\Navigation\Notifications\Exception\NoMessageException;
|
||||||
|
@ -47,16 +47,19 @@ class FormattedNavNotification extends BaseFactory
|
||||||
private $baseUrl;
|
private $baseUrl;
|
||||||
/** @var \Friendica\Core\L10n */
|
/** @var \Friendica\Core\L10n */
|
||||||
private $l10n;
|
private $l10n;
|
||||||
|
/** @var IHandleUserSessions */
|
||||||
|
private $userSession;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $tpl;
|
private $tpl;
|
||||||
|
|
||||||
public function __construct(Notification $notification, \Friendica\App\BaseURL $baseUrl, \Friendica\Core\L10n $l10n, LoggerInterface $logger)
|
public function __construct(Notification $notification, \Friendica\App\BaseURL $baseUrl, \Friendica\Core\L10n $l10n, LoggerInterface $logger, IHandleUserSessions $userSession)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
|
|
||||||
$this->notification = $notification;
|
$this->notification = $notification;
|
||||||
$this->baseUrl = $baseUrl;
|
$this->baseUrl = $baseUrl;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
|
$this->userSession = $userSession;
|
||||||
|
|
||||||
$this->tpl = Renderer::getMarkupTemplate('notifications/nav/notify.tpl');
|
$this->tpl = Renderer::getMarkupTemplate('notifications/nav/notify.tpl');
|
||||||
}
|
}
|
||||||
|
@ -72,7 +75,7 @@ class FormattedNavNotification extends BaseFactory
|
||||||
*/
|
*/
|
||||||
public function createFromParams(array $contact, string $message, \DateTime $date, Uri $href, bool $seen = false): ValueObject\FormattedNavNotification
|
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'], $this->userSession->getLocalUserId(), Proxy::SIZE_MICRO);
|
||||||
|
|
||||||
$dateMySQL = $date->format(DateTimeFormat::MYSQL);
|
$dateMySQL = $date->format(DateTimeFormat::MYSQL);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ use Friendica\BaseFactory;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Session;
|
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
@ -64,15 +64,18 @@ class FormattedNotify extends BaseFactory
|
||||||
private $baseUrl;
|
private $baseUrl;
|
||||||
/** @var L10n */
|
/** @var L10n */
|
||||||
private $l10n;
|
private $l10n;
|
||||||
|
/** @var IHandleUserSessions */
|
||||||
|
private $userSession;
|
||||||
|
|
||||||
public function __construct(LoggerInterface $logger, Database $dba, Repository\Notify $notification, BaseURL $baseUrl, L10n $l10n)
|
public function __construct(LoggerInterface $logger, Database $dba, Repository\Notify $notification, BaseURL $baseUrl, L10n $l10n, IHandleUserSessions $userSession)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
|
|
||||||
$this->dba = $dba;
|
$this->dba = $dba;
|
||||||
$this->notify = $notification;
|
$this->notify = $notification;
|
||||||
$this->baseUrl = $baseUrl;
|
$this->baseUrl = $baseUrl;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
|
$this->userSession = $userSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -211,7 +214,7 @@ class FormattedNotify extends BaseFactory
|
||||||
|
|
||||||
$formattedNotifications = new FormattedNotifies();
|
$formattedNotifications = new FormattedNotifies();
|
||||||
try {
|
try {
|
||||||
$Notifies = $this->notify->selectForUser(Session::getLocalUser(), $conditions, $params);
|
$Notifies = $this->notify->selectForUser($this->userSession->getLocalUserId(), $conditions, $params);
|
||||||
|
|
||||||
foreach ($Notifies as $Notify) {
|
foreach ($Notifies as $Notify) {
|
||||||
$formattedNotifications[] = new ValueObject\FormattedNotify(
|
$formattedNotifications[] = new ValueObject\FormattedNotify(
|
||||||
|
@ -244,7 +247,7 @@ class FormattedNotify extends BaseFactory
|
||||||
*/
|
*/
|
||||||
public function getNetworkList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies
|
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' => $this->userSession->getLocalUserId()];
|
||||||
|
|
||||||
if (!$seen) {
|
if (!$seen) {
|
||||||
$condition['unseen'] = true;
|
$condition['unseen'] = true;
|
||||||
|
@ -257,7 +260,7 @@ class FormattedNotify extends BaseFactory
|
||||||
$formattedNotifications = new FormattedNotifies();
|
$formattedNotifications = new FormattedNotifies();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$userPosts = Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params);
|
$userPosts = Post::selectForUser($this->userSession->getLocalUserId(), $fields, $condition, $params);
|
||||||
while ($userPost = $this->dba->fetch($userPosts)) {
|
while ($userPost = $this->dba->fetch($userPosts)) {
|
||||||
$formattedNotifications[] = $this->createFromFormattedItem($this->formatItem($userPost));
|
$formattedNotifications[] = $this->createFromFormattedItem($this->formatItem($userPost));
|
||||||
}
|
}
|
||||||
|
@ -280,7 +283,7 @@ class FormattedNotify extends BaseFactory
|
||||||
*/
|
*/
|
||||||
public function getPersonalList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies
|
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' => $this->userSession->getLocalUserId(), 'author-id' => $this->userSession->getPublicContactId()];
|
||||||
|
|
||||||
if (!$seen) {
|
if (!$seen) {
|
||||||
$condition['unseen'] = true;
|
$condition['unseen'] = true;
|
||||||
|
@ -293,7 +296,7 @@ class FormattedNotify extends BaseFactory
|
||||||
$formattedNotifications = new FormattedNotifies();
|
$formattedNotifications = new FormattedNotifies();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$userPosts = Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params);
|
$userPosts = Post::selectForUser($this->userSession->getLocalUserId(), $fields, $condition, $params);
|
||||||
while ($userPost = $this->dba->fetch($userPosts)) {
|
while ($userPost = $this->dba->fetch($userPosts)) {
|
||||||
$formattedNotifications[] = $this->createFromFormattedItem($this->formatItem($userPost));
|
$formattedNotifications[] = $this->createFromFormattedItem($this->formatItem($userPost));
|
||||||
}
|
}
|
||||||
|
@ -316,7 +319,7 @@ class FormattedNotify extends BaseFactory
|
||||||
*/
|
*/
|
||||||
public function getHomeList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies
|
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' => $this->userSession->getLocalUserId()];
|
||||||
|
|
||||||
if (!$seen) {
|
if (!$seen) {
|
||||||
$condition['unseen'] = true;
|
$condition['unseen'] = true;
|
||||||
|
@ -329,7 +332,7 @@ class FormattedNotify extends BaseFactory
|
||||||
$formattedNotifications = new FormattedNotifies();
|
$formattedNotifications = new FormattedNotifies();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$userPosts = Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params);
|
$userPosts = Post::selectForUser($this->userSession->getLocalUserId(), $fields, $condition, $params);
|
||||||
while ($userPost = $this->dba->fetch($userPosts)) {
|
while ($userPost = $this->dba->fetch($userPosts)) {
|
||||||
$formattedItem = $this->formatItem($userPost);
|
$formattedItem = $this->formatItem($userPost);
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||||
|
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Module\BaseNotifications;
|
use Friendica\Module\BaseNotifications;
|
||||||
|
@ -56,10 +56,12 @@ class Introduction extends BaseFactory
|
||||||
private $pConfig;
|
private $pConfig;
|
||||||
/** @var IHandleSessions */
|
/** @var IHandleSessions */
|
||||||
private $session;
|
private $session;
|
||||||
|
/** @var IHandleUserSessions */
|
||||||
|
private $userSession;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $nick;
|
private $nick;
|
||||||
|
|
||||||
public function __construct(LoggerInterface $logger, Database $dba, BaseURL $baseUrl, L10n $l10n, App $app, IManagePersonalConfigValues $pConfig, IHandleSessions $session)
|
public function __construct(LoggerInterface $logger, Database $dba, BaseURL $baseUrl, L10n $l10n, App $app, IManagePersonalConfigValues $pConfig, IHandleSessions $session, IHandleUserSessions $userSession)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
|
|
||||||
|
@ -68,6 +70,7 @@ class Introduction extends BaseFactory
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
$this->pConfig = $pConfig;
|
$this->pConfig = $pConfig;
|
||||||
$this->session = $session;
|
$this->session = $session;
|
||||||
|
$this->userSession = $userSession;
|
||||||
$this->nick = $app->getLoggedInUserNickname() ?? '';
|
$this->nick = $app->getLoggedInUserNickname() ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +146,7 @@ class Introduction extends BaseFactory
|
||||||
'url' => $intro['furl'],
|
'url' => $intro['furl'],
|
||||||
'zrl' => Contact::magicLink($intro['furl']),
|
'zrl' => Contact::magicLink($intro['furl']),
|
||||||
'hidden' => $intro['hidden'] == 1,
|
'hidden' => $intro['hidden'] == 1,
|
||||||
'post_newfriend' => (intval($this->pConfig->get(Session::getLocalUser(), 'system', 'post_newfriend')) ? '1' : 0),
|
'post_newfriend' => (intval($this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'post_newfriend')) ? '1' : 0),
|
||||||
'note' => $intro['note'],
|
'note' => $intro['note'],
|
||||||
'request' => $intro['frequest'] . '?addr=' . $return_addr]);
|
'request' => $intro['frequest'] . '?addr=' . $return_addr]);
|
||||||
|
|
||||||
|
@ -168,7 +171,7 @@ class Introduction extends BaseFactory
|
||||||
'about' => BBCode::convert($intro['about'], false),
|
'about' => BBCode::convert($intro['about'], false),
|
||||||
'keywords' => $intro['keywords'],
|
'keywords' => $intro['keywords'],
|
||||||
'hidden' => $intro['hidden'] == 1,
|
'hidden' => $intro['hidden'] == 1,
|
||||||
'post_newfriend' => (intval($this->pConfig->get(Session::getLocalUser(), 'system', 'post_newfriend')) ? '1' : 0),
|
'post_newfriend' => (intval($this->pConfig->get($this->userSession->getLocalUserId(), 'system', 'post_newfriend')) ? '1' : 0),
|
||||||
'url' => $intro['url'],
|
'url' => $intro['url'],
|
||||||
'zrl' => Contact::magicLink($intro['url']),
|
'zrl' => Contact::magicLink($intro['url']),
|
||||||
'addr' => $intro['addr'],
|
'addr' => $intro['addr'],
|
||||||
|
|
|
@ -27,7 +27,6 @@ use Exception;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -317,7 +316,7 @@ class Probe
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($uid == -1) {
|
if ($uid == -1) {
|
||||||
$uid = Session::getLocalUser();
|
$uid = DI::userSession()->getLocalUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($network) || ($network == Protocol::ACTIVITYPUB)) {
|
if (empty($network) || ($network == Protocol::ACTIVITYPUB)) {
|
||||||
|
|
|
@ -28,7 +28,6 @@ use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
@ -87,7 +86,7 @@ class Post
|
||||||
$this->setTemplate('wall');
|
$this->setTemplate('wall');
|
||||||
$this->toplevel = $this->getId() == $this->getDataValue('parent');
|
$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;
|
$this->visiting = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,14 +103,14 @@ class Post
|
||||||
if (!empty($data['children'])) {
|
if (!empty($data['children'])) {
|
||||||
foreach ($data['children'] as $item) {
|
foreach ($data['children'] as $item) {
|
||||||
// Only add will be displayed
|
// 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;
|
continue;
|
||||||
} elseif (!DI::contentItem()->isVisibleActivity($item)) {
|
} elseif (!DI::contentItem()->isVisibleActivity($item)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// You can always comment on Diaspora and OStatus items
|
// 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;
|
$item['writable'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +205,7 @@ class Post
|
||||||
$lock = ($item['private'] == Item::PRIVATE) ? $privacy : false;
|
$lock = ($item['private'] == Item::PRIVATE) ? $privacy : false;
|
||||||
$connector = !in_array($item['network'], Protocol::NATIVE_SUPPORT) ? DI::l10n()->t('Connector Message') : 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]);
|
$announceable = $shareable && in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::TWITTER]);
|
||||||
|
|
||||||
// On Diaspora only toplevel posts can be reshared
|
// On Diaspora only toplevel posts can be reshared
|
||||||
|
@ -216,7 +215,7 @@ class Post
|
||||||
|
|
||||||
$edpost = false;
|
$edpost = false;
|
||||||
|
|
||||||
if (Session::getLocalUser()) {
|
if (DI::userSession()->getLocalUserId()) {
|
||||||
if (Strings::compareLink(DI::session()->get('my_url'), $item['author-link'])) {
|
if (Strings::compareLink(DI::session()->get('my_url'), $item['author-link'])) {
|
||||||
if ($item['event-id'] != 0) {
|
if ($item['event-id'] != 0) {
|
||||||
$edpost = ['events/event/' . $item['event-id'], DI::l10n()->t('Edit')];
|
$edpost = ['events/event/' . $item['event-id'], DI::l10n()->t('Edit')];
|
||||||
|
@ -224,7 +223,7 @@ class Post
|
||||||
$edpost = ['editpost/' . $item['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
|
// Editing on items of not subscribed users isn't currently possible
|
||||||
|
@ -234,7 +233,7 @@ class Post
|
||||||
$edpost = false;
|
$edpost = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($this->getDataValue('uid') == Session::getLocalUser()) || $this->isVisiting()) {
|
if (($this->getDataValue('uid') == DI::userSession()->getLocalUserId()) || $this->isVisiting()) {
|
||||||
$dropping = true;
|
$dropping = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +248,7 @@ class Post
|
||||||
|
|
||||||
$drop = false;
|
$drop = false;
|
||||||
$block = false;
|
$block = false;
|
||||||
if (Session::getLocalUser()) {
|
if (DI::userSession()->getLocalUserId()) {
|
||||||
$drop = [
|
$drop = [
|
||||||
'dropping' => $dropping,
|
'dropping' => $dropping,
|
||||||
'pagedrop' => $item['pagedrop'],
|
'pagedrop' => $item['pagedrop'],
|
||||||
|
@ -258,7 +257,7 @@ class Post
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$item['self'] && Session::getLocalUser()) {
|
if (!$item['self'] && DI::userSession()->getLocalUserId()) {
|
||||||
$block = [
|
$block = [
|
||||||
'blocking' => true,
|
'blocking' => true,
|
||||||
'block' => DI::l10n()->t('Block %s', $item['author-name']),
|
'block' => DI::l10n()->t('Block %s', $item['author-name']),
|
||||||
|
@ -266,14 +265,14 @@ class Post
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$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'];
|
$profile_name = $item['author-name'];
|
||||||
if (!empty($item['author-link']) && empty($item['author-name'])) {
|
if (!empty($item['author-link']) && empty($item['author-name'])) {
|
||||||
$profile_name = $item['author-link'];
|
$profile_name = $item['author-link'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Session::isAuthenticated()) {
|
if (DI::userSession()->isAuthenticated()) {
|
||||||
$author = ['uid' => 0, 'id' => $item['author-id'],
|
$author = ['uid' => 0, 'id' => $item['author-id'],
|
||||||
'network' => $item['author-network'], 'url' => $item['author-link']];
|
'network' => $item['author-network'], 'url' => $item['author-link']];
|
||||||
$profile_link = Contact::magicLinkByContact($author);
|
$profile_link = Contact::magicLinkByContact($author);
|
||||||
|
@ -327,8 +326,8 @@ class Post
|
||||||
$tagger = '';
|
$tagger = '';
|
||||||
|
|
||||||
if ($this->isToplevel()) {
|
if ($this->isToplevel()) {
|
||||||
if (Session::getLocalUser()) {
|
if (DI::userSession()->getLocalUserId()) {
|
||||||
$ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], Session::getLocalUser());
|
$ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], DI::userSession()->getLocalUserId());
|
||||||
if ($item['mention'] || $ignored) {
|
if ($item['mention'] || $ignored) {
|
||||||
$ignore = [
|
$ignore = [
|
||||||
'do' => DI::l10n()->t('Ignore thread'),
|
'do' => DI::l10n()->t('Ignore thread'),
|
||||||
|
@ -351,7 +350,7 @@ class Post
|
||||||
'starred' => DI::l10n()->t('Starred'),
|
'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])) {
|
if ($origin && in_array($item['private'], [Item::PUBLIC, Item::UNLISTED])) {
|
||||||
$ispinned = ($item['featured'] ? 'pinned' : 'unpinned');
|
$ispinned = ($item['featured'] ? 'pinned' : 'unpinned');
|
||||||
|
|
||||||
|
@ -397,17 +396,17 @@ class Post
|
||||||
|
|
||||||
$body_html = Item::prepareBody($item, true);
|
$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'])) {
|
if (!empty($item['title'])) {
|
||||||
$title = $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']);
|
$title = ucfirst($item['content-warning']);
|
||||||
} else {
|
} else {
|
||||||
$title = '';
|
$title = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
|
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike')) {
|
||||||
$buttons['dislike'] = false;
|
$buttons['dislike'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +433,7 @@ class Post
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetching of Diaspora posts doesn't always work. There are issues with reshares and possibly comments
|
// 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'),
|
$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'))];
|
str_replace('{uri}', urlencode($item['uri']), DI::session()->get('remote_comment'))];
|
||||||
|
|
||||||
|
@ -642,7 +641,7 @@ class Post
|
||||||
/*
|
/*
|
||||||
* Only add what will be displayed
|
* 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;
|
return false;
|
||||||
} elseif ($activity->match($item->getDataValue('verb'), Activity::LIKE) ||
|
} elseif ($activity->match($item->getDataValue('verb'), Activity::LIKE) ||
|
||||||
$activity->match($item->getDataValue('verb'), Activity::DISLIKE)) {
|
$activity->match($item->getDataValue('verb'), Activity::DISLIKE)) {
|
||||||
|
@ -850,7 +849,7 @@ class Post
|
||||||
// This will allow us to comment on wall-to-wall items owned by our friends
|
// 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.
|
// and community forums even if somebody else wrote the post.
|
||||||
// bug #517 - this fixes for conversation owner
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -898,20 +897,20 @@ class Post
|
||||||
{
|
{
|
||||||
$a = DI::app();
|
$a = DI::app();
|
||||||
|
|
||||||
if (!Session::getLocalUser()) {
|
if (!DI::userSession()->getLocalUserId()) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$owner = User::getOwnerDataById($a->getLoggedInUserId());
|
$owner = User::getOwnerDataById($a->getLoggedInUserId());
|
||||||
$item = $this->getData();
|
$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";
|
$text = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $item['content-warning'] . "[/abstract]\n";
|
||||||
} else {
|
} else {
|
||||||
$text = '';
|
$text = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Feature::isEnabled(Session::getLocalUser(), 'explicit_mentions')) {
|
if (!Feature::isEnabled(DI::userSession()->getLocalUserId(), 'explicit_mentions')) {
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -958,7 +957,7 @@ class Post
|
||||||
*/
|
*/
|
||||||
$qcomment = null;
|
$qcomment = null;
|
||||||
if (Addon::isEnabled('qcomment')) {
|
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) : [];
|
$qcomment = $words ? explode("\n", $words) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Object;
|
||||||
|
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Protocol\Activity;
|
use Friendica\Protocol\Activity;
|
||||||
use Friendica\Security\Security;
|
use Friendica\Security\Security;
|
||||||
|
@ -76,7 +75,7 @@ class Thread
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
case 'network':
|
case 'network':
|
||||||
case 'notes':
|
case 'notes':
|
||||||
$this->profile_owner = Session::getLocalUser();
|
$this->profile_owner = DI::userSession()->getLocalUserId();
|
||||||
$this->writable = true;
|
$this->writable = true;
|
||||||
break;
|
break;
|
||||||
case 'profile':
|
case 'profile':
|
||||||
|
@ -169,7 +168,7 @@ class Thread
|
||||||
/*
|
/*
|
||||||
* Only add will be displayed
|
* 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() .').');
|
Logger::info('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +201,7 @@ class Thread
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
foreach ($this->parents as $item) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ use Friendica\App;
|
||||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
|
@ -333,7 +332,7 @@ class Authentication
|
||||||
'addr' => $this->remoteAddress,
|
'addr' => $this->remoteAddress,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Session::setVisitorsContacts();
|
DI::userSession()->setVisitorsContacts();
|
||||||
|
|
||||||
$member_since = strtotime($user_record['register_date']);
|
$member_since = strtotime($user_record['register_date']);
|
||||||
$this->session->set('new_member', time() < ($member_since + (60 * 60 * 24 * 14)));
|
$this->session->set('new_member', time() < ($member_since + (60 * 60 * 24 * 14)));
|
||||||
|
|
|
@ -24,7 +24,6 @@ namespace Friendica\Security;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
@ -191,7 +190,7 @@ class BasicAuth
|
||||||
|
|
||||||
Hook::callAll('logged_in', $record);
|
Hook::callAll('logged_in', $record);
|
||||||
|
|
||||||
self::$current_user_id = Session::getLocalUser();
|
self::$current_user_id = DI::userSession()->getLocalUserId();
|
||||||
|
|
||||||
return self::$current_user_id;
|
return self::$current_user_id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,10 @@
|
||||||
namespace Friendica\Security;
|
namespace Friendica\Security;
|
||||||
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Core\Session;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Secures that User is allow to do requests
|
* Secures that User is allow to do requests
|
||||||
|
@ -36,20 +36,20 @@ class Security
|
||||||
{
|
{
|
||||||
static $verified = 0;
|
static $verified = 0;
|
||||||
|
|
||||||
if (!Session::isAuthenticated()) {
|
if (!DI::userSession()->isAuthenticated()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uid = Session::getLocalUser();
|
$uid = DI::userSession()->getLocalUserId();
|
||||||
if ($uid == $owner) {
|
if ($uid == $owner) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Session::getLocalUser() && ($owner == 0)) {
|
if (DI::userSession()->getLocalUserId() && ($owner == 0)) {
|
||||||
return true;
|
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
|
// 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
|
// 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
|
// We have a contact-id for an authenticated remote user, this block determines if the contact
|
||||||
|
@ -93,8 +93,8 @@ class Security
|
||||||
*/
|
*/
|
||||||
public static function getPermissionsSQLByUserId(int $owner_id, bool $accessible = false)
|
public static function getPermissionsSQLByUserId(int $owner_id, bool $accessible = false)
|
||||||
{
|
{
|
||||||
$local_user = Session::getLocalUser();
|
$local_user = DI::userSession()->getLocalUserId();
|
||||||
$remote_contact = Session::getRemoteContactID($owner_id);
|
$remote_contact = DI::userSession()->getRemoteContactID($owner_id);
|
||||||
$acc_sql = '';
|
$acc_sql = '';
|
||||||
|
|
||||||
if ($accessible) {
|
if ($accessible) {
|
||||||
|
|
|
@ -24,7 +24,6 @@ namespace Friendica\Util;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
@ -239,7 +238,7 @@ class Temporal
|
||||||
bool $required = false): string
|
bool $required = false): string
|
||||||
{
|
{
|
||||||
// First day of the week (0 = Sunday)
|
// 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);
|
$lang = substr(DI::l10n()->getCurrentLang(), 0, 2);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ use Friendica\App\Arguments;
|
||||||
use Friendica\App\Router;
|
use Friendica\App\Router;
|
||||||
use Friendica\Core\Config\ValueObject\Cache;
|
use Friendica\Core\Config\ValueObject\Cache;
|
||||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
use Friendica\Core\Session;
|
|
||||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Database\DBStructure;
|
use Friendica\Database\DBStructure;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user