namespace Friendica\Module\Admin;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Register;
$user['login_date'] = Temporal::getRelativeDate($user['login_date']);
$user['lastitem_date'] = Temporal::getRelativeDate($user['last-item']);
$user['is_admin'] = in_array($user['email'], $adminlist);
- $user['is_deletable'] = !$user['account_removed'] && intval($user['uid']) != Session::getLocalUser();
+ $user['is_deletable'] = !$user['account_removed'] && intval($user['uid']) != DI::userSession()->getLocalUserId();
$user['deleted'] = ($user['account_removed'] ? Temporal::getRelativeDate($user['account_expires_on']) : False);
return $user;
use Friendica\Content\Pager;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
if (!empty($_POST['page_users_delete'])) {
foreach ($users as $uid) {
- if (Session::getLocalUser() != $uid) {
+ if (DI::userSession()->getLocalUserId() != $uid) {
User::remove($uid);
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
switch ($action) {
case 'delete':
- if (Session::getLocalUser() != $uid) {
+ if (DI::userSession()->getLocalUserId() != $uid) {
self::checkFormSecurityTokenRedirectOnError('admin/users/active', 'admin_users_active', 't');
// delete user
User::remove($uid);
if (!empty($_POST['page_users_delete'])) {
foreach ($users as $uid) {
- if (Session::getLocalUser() != $uid) {
+ if (DI::userSession()->getLocalUserId() != $uid) {
User::remove($uid);
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
switch ($action) {
case 'delete':
- if (Session::getLocalUser() != $uid) {
+ if (DI::userSession()->getLocalUserId() != $uid) {
self::checkFormSecurityTokenRedirectOnError('/admin/users/blocked', 'admin_users_blocked', 't');
// delete user
User::remove($uid);
if (!empty($_POST['page_users_delete'])) {
foreach ($users as $uid) {
- if (Session::getLocalUser() != $uid) {
+ if (DI::userSession()->getLocalUserId() != $uid) {
User::remove($uid);
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
switch ($action) {
case 'delete':
- if (Session::getLocalUser() != $uid) {
+ if (DI::userSession()->getLocalUserId() != $uid) {
self::checkFormSecurityTokenRedirectOnError(DI::baseUrl()->get(true), 'admin_users', 't');
// delete user
User::remove($uid);
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$privateaddons = $config->get('config', 'private_addons');
- if ($privateaddons === "1" && !Session::getLocalUser()) {
+ if ($privateaddons === "1" && !DI::userSession()->getLocalUserId()) {
$baseUrl->redirect();
}
}
use Friendica\BaseModule;
use Friendica\Core\Addon;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Network\HTTPException;
*/
public static function checkAdminAccess(bool $interactive = false)
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
if ($interactive) {
DI::sysmsg()->addNotice(DI::l10n()->t('Please login to continue.'));
DI::session()->set('return_path', DI::args()->getQueryString());
use Friendica\Content\Pager;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model;
use Friendica\Network\HTTPException;
$search = Network::convertToIdn($search);
if (DI::mode()->isMobile()) {
- $itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
+ $itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
- $itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
+ $itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
// in case the result is a contact result, add a contact-specific entry
if ($result instanceof ContactResult) {
- $contact = Model\Contact::getByURLForUser($result->getUrl(), Session::getLocalUser());
+ $contact = Model\Contact::getByURLForUser($result->getUrl(), DI::userSession()->getLocalUserId());
if (!empty($contact)) {
$entries[] = Contact::getContactTemplateVars($contact);
}
use Friendica\BaseModule;
use Friendica\Content\PageInfo;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\Security\Login;
use Friendica\Network\HTTPException;
$config = DI::config();
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
$output = '<h2>' . DI::l10n()->t('Login') . '</h2>';
$output .= Login::form(DI::args()->getQueryString(), intval($config->get('config', 'register_policy')) === Register::CLOSED ? false : true);
return $output;
use Friendica\Content\Widget;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
self::checkFormSecurityTokenRedirectOnError($redirectUrl, 'contact_batch_actions');
- $orig_records = Model\Contact::selectToArray(['id', 'uid'], ['id' => $_POST['contact_batch'], 'uid' => [0, Session::getLocalUser()], 'self' => false, 'deleted' => false]);
+ $orig_records = Model\Contact::selectToArray(['id', 'uid'], ['id' => $_POST['contact_batch'], 'uid' => [0, DI::userSession()->getLocalUserId()], 'self' => false, 'deleted' => false]);
$count_actions = 0;
foreach ($orig_records as $orig_record) {
- $cdata = Model\Contact::getPublicAndUserContactID($orig_record['id'], Session::getLocalUser());
- if (empty($cdata) || Session::getPublicContact() === $cdata['public']) {
+ $cdata = Model\Contact::getPublicAndUserContactID($orig_record['id'], DI::userSession()->getLocalUserId());
+ if (empty($cdata) || DI::userSession()->getPublicContactId() === $cdata['public']) {
// No action available on your own contact
continue;
}
}
if (!empty($_POST['contacts_batch_block'])) {
- self::toggleBlockContact($cdata['public'], Session::getLocalUser());
+ self::toggleBlockContact($cdata['public'], DI::userSession()->getLocalUserId());
$count_actions++;
}
protected function post(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
*/
public static function updateContactFromPoll(int $contact_id)
{
- $contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => Session::getLocalUser(), 'deleted' => false]);
+ $contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => DI::userSession()->getLocalUserId(), 'deleted' => false]);
if (!DBA::isResult($contact)) {
return;
}
*/
private static function toggleIgnoreContact(int $contact_id)
{
- $ignored = !Model\Contact\User::isIgnored($contact_id, Session::getLocalUser());
- Model\Contact\User::setIgnored($contact_id, Session::getLocalUser(), $ignored);
+ $ignored = !Model\Contact\User::isIgnored($contact_id, DI::userSession()->getLocalUserId());
+ Model\Contact\User::setIgnored($contact_id, DI::userSession()->getLocalUserId(), $ignored);
}
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return Login::form($_SERVER['REQUEST_URI']);
}
$_SESSION['return_path'] = DI::args()->getQueryString();
- $sql_values = [Session::getLocalUser()];
+ $sql_values = [DI::userSession()->getLocalUserId()];
// @TODO: Replace with parameter from router
$type = DI::args()->getArgv()[1] ?? '';
$sql_extra = " AND `pending` AND NOT `archive` AND NOT `failed` AND ((`rel` = ?)
OR `id` IN (SELECT `contact-id` FROM `intro` WHERE `intro`.`uid` = ? AND NOT `ignore`))";
$sql_values[] = Model\Contact::SHARING;
- $sql_values[] = Session::getLocalUser();
+ $sql_values[] = DI::userSession()->getLocalUserId();
break;
default:
$sql_extra = " AND NOT `archive` AND NOT `blocked` AND NOT `pending`";
$stmt = DBA::select('contact', [], $condition, ['order' => ['name'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]]);
while ($contact = DBA::fetch($stmt)) {
- $contact['blocked'] = Model\Contact\User::isBlocked($contact['id'], Session::getLocalUser());
- $contact['readonly'] = Model\Contact\User::isIgnored($contact['id'], Session::getLocalUser());
+ $contact['blocked'] = Model\Contact\User::isBlocked($contact['id'], DI::userSession()->getLocalUserId());
+ $contact['readonly'] = Model\Contact\User::isIgnored($contact['id'], DI::userSession()->getLocalUserId());
$contacts[] = self::getContactTemplateVars($contact);
}
DBA::close($stmt);
public static function getTabsHTML(array $contact, int $active_tab)
{
$cid = $pcid = $contact['id'];
- $data = Model\Contact::getPublicAndUserContactID($contact['id'], Session::getLocalUser());
+ $data = Model\Contact::getPublicAndUserContactID($contact['id'], DI::userSession()->getLocalUserId());
if (!empty($data['user']) && ($contact['id'] == $data['public'])) {
$cid = $data['user'];
} elseif (!empty($data['public'])) {
{
$alt_text = '';
- if (!empty($contact['url']) && isset($contact['uid']) && ($contact['uid'] == 0) && Session::getLocalUser()) {
- $personal = Model\Contact::getByURL($contact['url'], false, ['uid', 'rel', 'self'], Session::getLocalUser());
+ if (!empty($contact['url']) && isset($contact['uid']) && ($contact['uid'] == 0) && DI::userSession()->getLocalUserId()) {
+ $personal = Model\Contact::getByURL($contact['url'], false, ['uid', 'rel', 'self'], DI::userSession()->getLocalUserId());
if (!empty($personal)) {
$contact['uid'] = $personal['uid'];
$contact['rel'] = $personal['rel'];
}
}
- if (!empty($contact['uid']) && !empty($contact['rel']) && Session::getLocalUser() == $contact['uid']) {
+ if (!empty($contact['uid']) && !empty($contact['rel']) && DI::userSession()->getLocalUserId() == $contact['uid']) {
switch ($contact['rel']) {
case Model\Contact::FRIEND:
$alt_text = DI::l10n()->t('Mutual Friendship');
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\Database;
use Friendica\DI;
use Friendica\Model;
$this->dba = $dba;
$this->page = $page;
- if (!Session::isAuthenticated()) {
+ if (!DI::userSession()->isAuthenticated()) {
throw new ForbiddenException($this->t('Permission denied.'));
}
}
{
$cid = $this->parameters['id'];
- $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => Session::getLocalUser()]);
+ $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => DI::userSession()->getLocalUserId()]);
if (empty($contact)) {
throw new BadRequestException($this->t('Contact not found.'));
}
'nurl' => $nurl,
'poll' => $poll,
],
- ['id' => $contact['id'], 'uid' => Session::getLocalUser()]
+ ['id' => $contact['id'], 'uid' => DI::userSession()->getLocalUserId()]
);
if ($photo) {
{
$cid = $this->parameters['id'];
- $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => Session::getLocalUser()]);
+ $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => DI::userSession()->getLocalUserId()]);
if (empty($contact)) {
throw new BadRequestException($this->t('Contact not found.'));
}
use Friendica\Content\Pager;
use Friendica\Content\Widget;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model;
use Friendica\Model\User;
{
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\ForbiddenException();
}
throw new HTTPException\NotFoundException(DI::l10n()->t('Contact not found.'));
}
- $localContactId = Model\Contact::getPublicIdByUserId(Session::getLocalUser());
+ $localContactId = Model\Contact::getPublicIdByUserId(DI::userSession()->getLocalUserId());
DI::page()['aside'] = Widget\VCard::getHTML($contact);
use Friendica\BaseModule;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
$contact_url = $_REQUEST['url'] ?? '';
// Get out if the system doesn't have public access allowed
- if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
+ if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
throw new HTTPException\ForbiddenException();
}
// Search for contact data
// Look if the local user has got the contact
- if (Session::isAuthenticated()) {
- $contact = Contact::getByURLForUser($contact_url, Session::getLocalUser());
+ if (DI::userSession()->isAuthenticated()) {
+ $contact = Contact::getByURLForUser($contact_url, DI::userSession()->getLocalUserId());
} else {
$contact = Contact::getByURL($contact_url, false);
}
}
// Get the photo_menu - the menu if possible contact actions
- if (Session::isAuthenticated()) {
+ if (DI::userSession()->isAuthenticated()) {
$actions = Contact::photoMenu($contact);
} else {
$actions = [];
protected function post(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
// Backward compatibility: The update still needs a user-specific contact ID
// Change to user-contact table check by version 2022.03
- $cdata = Contact::getPublicAndUserContactID($contact_id, Session::getLocalUser());
+ $cdata = Contact::getPublicAndUserContactID($contact_id, DI::userSession()->getLocalUserId());
if (empty($cdata['user']) || !DBA::exists('contact', ['id' => $cdata['user'], 'deleted' => false])) {
return;
}
$fields['info'] = $_POST['info'];
}
- if (!Contact::update($fields, ['id' => $cdata['user'], 'uid' => Session::getLocalUser()])) {
+ if (!Contact::update($fields, ['id' => $cdata['user'], 'uid' => DI::userSession()->getLocalUserId()])) {
DI::sysmsg()->addNotice($this->t('Failed to update contact record.'));
}
}
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return Module\Security\Login::form($_SERVER['REQUEST_URI']);
}
// Backward compatibility: Ensure to use the public contact when the user contact is provided
// Remove by version 2022.03
- $data = Contact::getPublicAndUserContactID(intval($this->parameters['id']), Session::getLocalUser());
+ $data = Contact::getPublicAndUserContactID(intval($this->parameters['id']), DI::userSession()->getLocalUserId());
if (empty($data)) {
throw new HTTPException\NotFoundException($this->t('Contact not found.'));
}
throw new HTTPException\NotFoundException($this->t('Contact not found.'));
}
- $localRelationship = $this->localRelationship->getForUserContact(Session::getLocalUser(), $contact['id']);
+ $localRelationship = $this->localRelationship->getForUserContact(DI::userSession()->getLocalUserId(), $contact['id']);
if ($localRelationship->rel === Contact::SELF) {
$this->baseUrl->redirect('profile/' . $contact['nick'] . '/profile');
if ($cmd === 'block') {
if ($localRelationship->blocked) {
// @TODO Backward compatibility, replace with $localRelationship->unblock()
- Contact\User::setBlocked($contact['id'], Session::getLocalUser(), false);
+ Contact\User::setBlocked($contact['id'], DI::userSession()->getLocalUserId(), false);
$message = $this->t('Contact has been unblocked');
} else {
// @TODO Backward compatibility, replace with $localRelationship->block()
- Contact\User::setBlocked($contact['id'], Session::getLocalUser(), true);
+ Contact\User::setBlocked($contact['id'], DI::userSession()->getLocalUserId(), true);
$message = $this->t('Contact has been blocked');
}
if ($cmd === 'ignore') {
if ($localRelationship->ignored) {
// @TODO Backward compatibility, replace with $localRelationship->unblock()
- Contact\User::setIgnored($contact['id'], Session::getLocalUser(), false);
+ Contact\User::setIgnored($contact['id'], DI::userSession()->getLocalUserId(), false);
$message = $this->t('Contact has been unignored');
} else {
// @TODO Backward compatibility, replace with $localRelationship->block()
- Contact\User::setIgnored($contact['id'], Session::getLocalUser(), true);
+ Contact\User::setIgnored($contact['id'], DI::userSession()->getLocalUserId(), true);
$message = $this->t('Contact has been ignored');
}
'$baseurl' => $this->baseUrl->get(true),
]);
- $contact['blocked'] = Contact\User::isBlocked($contact['id'], Session::getLocalUser());
- $contact['readonly'] = Contact\User::isIgnored($contact['id'], Session::getLocalUser());
+ $contact['blocked'] = Contact\User::isBlocked($contact['id'], DI::userSession()->getLocalUserId());
+ $contact['readonly'] = Contact\User::isIgnored($contact['id'], DI::userSession()->getLocalUserId());
switch ($localRelationship->rel) {
case Contact::FRIEND: $relation_text = $this->t('You are mutual friends with %s', $contact['name']); break;
*/
private static function updateContactFromProbe(int $contact_id)
{
- $contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => [0, Session::getLocalUser()], 'deleted' => false]);
+ $contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => [0, DI::userSession()->getLocalUserId()], 'deleted' => false]);
if (!DBA::isResult($contact)) {
return;
}
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\Database;
use Friendica\DI;
use Friendica\Model;
$this->dba = $dba;
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
- $data = Model\Contact::getPublicAndUserContactID($this->parameters['id'], Session::getLocalUser());
+ $data = Model\Contact::getPublicAndUserContactID($this->parameters['id'], DI::userSession()->getLocalUserId());
if (!$this->dba->isResult($data)) {
throw new HTTPException\NotFoundException($this->t('Unknown contact.'));
}
protected function post(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\UnauthorizedException();
}
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return Login::form($_SERVER['REQUEST_URI']);
}
use Friendica\Content\Widget;
use Friendica\Content\Widget\TrendingTags;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
'$global_community_hint' => DI::l10n()->t("This community stream shows all public posts received by this node. They may not reflect the opinions of this node’s users.")
]);
- if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
+ if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
$o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
}
if (empty($_GET['mode']) || ($_GET['mode'] != 'raw')) {
$tabs = [];
- if ((Session::isAuthenticated() || in_array(self::$page_style, [self::LOCAL_AND_GLOBAL, self::LOCAL])) && empty(DI::config()->get('system', 'singleuser'))) {
+ if ((DI::userSession()->isAuthenticated() || in_array(self::$page_style, [self::LOCAL_AND_GLOBAL, self::LOCAL])) && empty(DI::config()->get('system', 'singleuser'))) {
$tabs[] = [
'label' => DI::l10n()->t('Local Community'),
'url' => 'community/local',
];
}
- if (Session::isAuthenticated() || in_array(self::$page_style, [self::LOCAL_AND_GLOBAL, self::GLOBAL])) {
+ if (DI::userSession()->isAuthenticated() || in_array(self::$page_style, [self::LOCAL_AND_GLOBAL, self::GLOBAL])) {
$tabs[] = [
'label' => DI::l10n()->t('Global Community'),
'url' => 'community/global',
DI::page()['aside'] .= Widget::accountTypes('community/' . self::$content, self::$accountTypeString);
- if (Session::getLocalUser() && DI::config()->get('system', 'community_no_sharer')) {
+ if (DI::userSession()->getLocalUserId() && DI::config()->get('system', 'community_no_sharer')) {
$path = self::$content;
if (!empty($this->parameters['accounttype'])) {
$path .= '/' . $this->parameters['accounttype'];
]);
}
- if (Feature::isEnabled(Session::getLocalUser(), 'trending_tags')) {
+ if (Feature::isEnabled(DI::userSession()->getLocalUserId(), 'trending_tags')) {
DI::page()['aside'] .= TrendingTags::getHTML(self::$content);
}
// We need the editor here to be able to reshare an item.
- if (Session::isAuthenticated()) {
+ if (DI::userSession()->isAuthenticated()) {
$o .= DI::conversation()->statusEditor([], 0, true);
}
}
return $o;
}
- $o .= DI::conversation()->create($items, 'community', false, false, 'commented', Session::getLocalUser());
+ $o .= DI::conversation()->create($items, 'community', false, false, 'commented', DI::userSession()->getLocalUserId());
$pager = new BoundariesPager(
DI::l10n(),
self::$itemsPerPage
);
- if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
+ if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader();
} else {
$o .= $pager->renderMinimal(count($items));
*/
protected function parseRequest()
{
- if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
+ if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.'));
}
}
// Check if we are allowed to display the content to visitors
- if (!Session::isAuthenticated()) {
+ if (!DI::userSession()->isAuthenticated()) {
$available = self::$page_style == self::LOCAL_AND_GLOBAL;
if (!$available) {
}
if (DI::mode()->isMobile()) {
- self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
+ self::$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
- self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
+ self::$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
$condition[0] .= " AND `id` = ?";
$condition[] = $item_id;
} else {
- if (Session::getLocalUser() && !empty($_REQUEST['no_sharer'])) {
+ if (DI::userSession()->getLocalUserId() && !empty($_REQUEST['no_sharer'])) {
$condition[0] .= " AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `post-user`.`uid` = ?)";
- $condition[] = Session::getLocalUser();
+ $condition[] = DI::userSession()->getLocalUserId();
}
if (isset($max_id)) {
use Friendica\Core\ACL;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return Login::form();
}
DI::page()['aside'] .= Widget::accountTypes($module, self::$accountTypeString);
DI::page()['aside'] .= Group::sidebarWidget($module, $module . '/group', 'standard', self::$groupId);
- DI::page()['aside'] .= ForumManager::widget($module . '/forum', Session::getLocalUser(), self::$forumContactId);
- DI::page()['aside'] .= Widget::postedByYear($module . '/archive', Session::getLocalUser(), false);
+ DI::page()['aside'] .= ForumManager::widget($module . '/forum', DI::userSession()->getLocalUserId(), self::$forumContactId);
+ DI::page()['aside'] .= Widget::postedByYear($module . '/archive', DI::userSession()->getLocalUserId(), false);
DI::page()['aside'] .= Widget::networks($module, !self::$forumContactId ? self::$network : '');
DI::page()['aside'] .= Widget\SavedSearches::getHTML(DI::args()->getQueryString());
DI::page()['aside'] .= Widget::fileAs('filed', '');
$items = self::getItems($table, $params);
- if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
+ if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
$o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
}
$allowedCids[] = (int) self::$forumContactId;
} elseif (self::$network) {
$condition = [
- 'uid' => Session::getLocalUser(),
+ 'uid' => DI::userSession()->getLocalUserId(),
'network' => self::$network,
'self' => false,
'blocked' => false,
}
if (self::$groupId) {
- $group = DBA::selectFirst('group', ['name'], ['id' => self::$groupId, 'uid' => Session::getLocalUser()]);
+ $group = DBA::selectFirst('group', ['name'], ['id' => self::$groupId, 'uid' => DI::userSession()->getLocalUserId()]);
if (!DBA::isResult($group)) {
DI::sysmsg()->addNotice(DI::l10n()->t('No such group'));
}
$ordering = '`commented`';
}
- $o .= DI::conversation()->create($items, 'network', false, false, $ordering, Session::getLocalUser());
+ $o .= DI::conversation()->create($items, 'network', false, false, $ordering, DI::userSession()->getLocalUserId());
- if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
+ if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader();
} else {
$pager = new BoundariesPager(
self::$forumContactId = $this->parameters['contact_id'] ?? 0;
- self::$selectedTab = DI::session()->get('network-tab', DI::pConfig()->get(Session::getLocalUser(), 'network.view', 'selected_tab', ''));
+ self::$selectedTab = DI::session()->get('network-tab', DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'network.view', 'selected_tab', ''));
if (!empty($get['star'])) {
self::$selectedTab = 'star';
}
DI::session()->set('network-tab', self::$selectedTab);
- DI::pConfig()->set(Session::getLocalUser(), 'network.view', 'selected_tab', self::$selectedTab);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'network.view', 'selected_tab', self::$selectedTab);
self::$accountTypeString = $get['accounttype'] ?? $this->parameters['accounttype'] ?? '';
self::$accountType = User::getAccountTypeByString(self::$accountTypeString);
self::$dateTo = $this->parameters['to'] ?? '';
if (DI::mode()->isMobile()) {
- self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
+ self::$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
- self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
+ self::$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
protected static function getItems(string $table, array $params, array $conditionFields = [])
{
- $conditionFields['uid'] = Session::getLocalUser();
+ $conditionFields['uid'] = DI::userSession()->getLocalUserId();
$conditionStrings = [];
if (!is_null(self::$accountType)) {
} elseif (self::$forumContactId) {
$conditionStrings = DBA::mergeConditions($conditionStrings,
["((`contact-id` = ?) OR `uri-id` IN (SELECT `parent-uri-id` FROM `post-user-view` WHERE (`contact-id` = ? AND `gravity` = ? AND `vid` = ? AND `uid` = ?)))",
- self::$forumContactId, self::$forumContactId, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Session::getLocalUser()]);
+ self::$forumContactId, self::$forumContactId, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), DI::userSession()->getLocalUserId()]);
}
// Currently only the order modes "received" and "commented" are in use
// level which items you've seen and which you haven't. If you're looking
// at the top level network page just mark everything seen.
if (!self::$groupId && !self::$forumContactId && !self::$star && !self::$mention) {
- $condition = ['unseen' => true, 'uid' => Session::getLocalUser()];
+ $condition = ['unseen' => true, 'uid' => DI::userSession()->getLocalUserId()];
self::setItemsSeenByCondition($condition);
} elseif (!empty($parents)) {
- $condition = ['unseen' => true, 'uid' => Session::getLocalUser(), 'parent-uri-id' => $parents];
+ $condition = ['unseen' => true, 'uid' => DI::userSession()->getLocalUserId(), 'parent-uri-id' => $parents];
self::setItemsSeenByCondition($condition);
}
use Friendica\BaseModule;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Protocol\ActivityPub;
use Friendica\Util\JsonLD;
try {
$source = json_decode($_REQUEST['source'], true);
$trust_source = true;
- $uid = Session::getLocalUser();
+ $uid = DI::userSession()->getLocalUserId();
$push = false;
if (!$source) {
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model;
use Friendica\Module\Response;
$this->httpClient = $httpClient;
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice($this->t('You must be logged in to use this module'));
$baseUrl->redirect();
}
if (!empty($_REQUEST['url'])) {
$url = $_REQUEST['url'];
- $contact = Model\Contact::getByURLForUser($url, Session::getLocalUser(), null);
+ $contact = Model\Contact::getByURLForUser($url, DI::userSession()->getLocalUserId(), null);
$xml = $this->httpClient->fetch($contact['poll'], HttpClientAccept::FEED_XML);
namespace Friendica\Module\Debug;
use Friendica\BaseModule;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Post;
{
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access denied.'));
}
$itemId = intval($this->parameters['item']);
- $item = Post::selectFirst(['body'], ['uid' => [0, Session::getLocalUser()], 'uri-id' => $itemId]);
+ $item = Post::selectFirst(['body'], ['uid' => [0, DI::userSession()->getLocalUserId()], 'uri-id' => $itemId]);
if (!empty($item)) {
if (DI::mode()->isAjax()) {
use Friendica\BaseModule;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Network\HTTPException;
use Friendica\Network\Probe as NetworkProbe;
{
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a probing.'));
}
use Friendica\BaseModule;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Network\Probe;
{
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a probing.'));
}
use Friendica\BaseModule;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Notification;
{
protected function post(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
- $uid = Session::getLocalUser();
+ $uid = DI::userSession()->getLocalUserId();
$orig_record = User::getById(DI::app()->getLoggedInUserId());
if (DI::session()->get('submanage')) {
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new ForbiddenException(DI::l10n()->t('Permission denied.'));
}
- $identities = User::identities(DI::session()->get('submanage', Session::getLocalUser()));
+ $identities = User::identities(DI::session()->get('submanage', DI::userSession()->getLocalUserId()));
//getting additinal information for each identity
foreach ($identities as $key => $identity) {
use Friendica\Content\Pager;
use Friendica\Content\Widget;
use Friendica\Core\Hook;
-use Friendica\Core\Session;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
use Friendica\DI;
$app = DI::app();
$config = DI::config();
- if (($config->get('system', 'block_public') && !Session::isAuthenticated()) ||
- ($config->get('system', 'block_local_dir') && !Session::isAuthenticated())) {
+ if (($config->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) ||
+ ($config->get('system', 'block_local_dir') && !DI::userSession()->isAuthenticated())) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.'));
}
- if (Session::getLocalUser()) {
+ if (DI::userSession()->getLocalUserId()) {
DI::page()['aside'] .= Widget::findPeople();
DI::page()['aside'] .= Widget::follow();
}
DI::sysmsg()->addNotice(DI::l10n()->t('No entries (some entries may be hidden).'));
} else {
foreach ($profiles['entries'] as $entry) {
- $contact = Model\Contact::getByURLForUser($entry['url'], Session::getLocalUser());
+ $contact = Model\Contact::getByURLForUser($entry['url'], DI::userSession()->getLocalUserId());
if (!empty($contact)) {
$entries[] = Contact::getContactTemplateVars($contact);
}
namespace Friendica\Module\Events;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
{
protected function rawContent(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\UnauthorizedException();
}
// get events by id or by date
if ($event_params['event_id']) {
- $r = Event::getListById(Session::getLocalUser(), $event_params['event_id']);
+ $r = Event::getListById(DI::userSession()->getLocalUserId(), $event_params['event_id']);
} else {
- $r = Event::getListByDate(Session::getLocalUser(), $event_params);
+ $r = Event::getListByDate(DI::userSession()->getLocalUserId(), $event_params);
}
$links = [];
namespace Friendica\Module;
use Friendica\BaseModule;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Protocol\Feed as ProtocolFeed;
protected function rawContent(array $request = [])
{
$last_update = $this->getRequestValue($request, 'last_update', '');
- $nocache = !empty($request['nocache']) && Session::getLocalUser();
+ $nocache = !empty($request['nocache']) && DI::userSession()->getLocalUserId();
$type = null;
// @TODO: Replace with parameter from router
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model;
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice($this->t('You must be logged in to use this module'));
$baseUrl->redirect();
}
if (!DBA::isResult($item)) {
throw new HTTPException\NotFoundException();
}
- Model\Post\Category::storeFileByURIId($item['uri-id'], Session::getLocalUser(), Model\Post\Category::FILE, $term);
+ Model\Post\Category::storeFileByURIId($item['uri-id'], DI::userSession()->getLocalUserId(), Model\Post\Category::FILE, $term);
}
// return filer dialog
- $filetags = Model\Post\Category::getArray(Session::getLocalUser(), Model\Post\Category::FILE);
+ $filetags = Model\Post\Category::getArray(DI::userSession()->getLocalUserId(), Model\Post\Category::FILE);
$tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
echo Renderer::replaceMacros($tpl, [
namespace Friendica\Module;
use Friendica\BaseModule;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model\Contact;
protected function post(array $request = [])
{
parent::post($request);
- $uid = Session::getLocalUser();
+ $uid = DI::userSession()->getLocalUserId();
if (!$uid) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return;
$duplex = intval($_POST['duplex'] ?? 0);
$hidden = intval($_POST['hidden'] ?? 0);
- $intro = DI::intro()->selectOneById($intro_id, Session::getLocalUser());
+ $intro = DI::intro()->selectOneById($intro_id, DI::userSession()->getLocalUserId());
Contact\Introduction::confirm($intro, $duplex, $hidden);
DI::intro()->delete($intro);
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\Worker;
use Friendica\Database\Database;
use Friendica\DI;
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new ForbiddenException($this->t('Permission denied.'));
}
$cid = intval($this->parameters['contact']);
// We do query the "uid" as well to ensure that it is our contact
- if (!$this->dba->exists('contact', ['id' => $cid, 'uid' => Session::getLocalUser()])) {
+ if (!$this->dba->exists('contact', ['id' => $cid, 'uid' => DI::userSession()->getLocalUserId()])) {
throw new NotFoundException($this->t('Contact not found.'));
}
}
// We do query the "uid" as well to ensure that it is our contact
- $contact = $this->dba->selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => Session::getLocalUser()]);
+ $contact = $this->dba->selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => DI::userSession()->getLocalUserId()]);
if (empty($contact)) {
DI::sysmsg()->addNotice($this->t('Suggested contact not found.'));
return;
$note = Strings::escapeHtml(trim($_POST['note'] ?? ''));
$suggest = $this->friendSuggestRepo->save($this->friendSuggestFac->createNew(
- Session::getLocalUser(),
+ DI::userSession()->getLocalUserId(),
$cid,
$contact['name'],
$contact['url'],
{
$cid = intval($this->parameters['contact']);
- $contact = $this->dba->selectFirst('contact', [], ['id' => $cid, 'uid' => Session::getLocalUser()]);
+ $contact = $this->dba->selectFirst('contact', [], ['id' => $cid, 'uid' => DI::userSession()->getLocalUserId()]);
if (empty($contact)) {
DI::sysmsg()->addNotice($this->t('Contact not found.'));
$this->baseUrl->redirect();
AND NOT `archive`
AND NOT `deleted`
AND `notify` != ""',
- Session::getLocalUser(),
+ DI::userSession()->getLocalUserId(),
$cid,
Protocol::DFRN,
]);
use Friendica\BaseModule;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
$this->ajaxPost();
}
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect();
}
BaseModule::checkFormSecurityTokenRedirectOnError('/group/new', 'group_edit');
$name = trim($request['groupname']);
- $r = Model\Group::create(Session::getLocalUser(), $name);
+ $r = Model\Group::create(DI::userSession()->getLocalUserId(), $name);
if ($r) {
- $r = Model\Group::getIdByName(Session::getLocalUser(), $name);
+ $r = Model\Group::getIdByName(DI::userSession()->getLocalUserId(), $name);
if ($r) {
DI::baseUrl()->redirect('group/' . $r);
}
if ((DI::args()->getArgc() == 2) && intval(DI::args()->getArgv()[1])) {
BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_edit');
- $group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => Session::getLocalUser()]);
+ $group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => DI::userSession()->getLocalUserId()]);
if (!DBA::isResult($group)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
DI::baseUrl()->redirect('contact');
public function ajaxPost()
{
try {
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new \Exception(DI::l10n()->t('Permission denied.'), 403);
}
$group_id = $this->parameters['group'];
$contact_id = $this->parameters['contact'];
- if (!Model\Group::exists($group_id, Session::getLocalUser())) {
+ if (!Model\Group::exists($group_id, DI::userSession()->getLocalUserId())) {
throw new \Exception(DI::l10n()->t('Unknown group.'), 404);
}
// @TODO Backward compatibility with user contacts, remove by version 2022.03
- $cdata = Model\Contact::getPublicAndUserContactID($contact_id, Session::getLocalUser());
+ $cdata = Model\Contact::getPublicAndUserContactID($contact_id, DI::userSession()->getLocalUserId());
if (empty($cdata['public'])) {
throw new \Exception(DI::l10n()->t('Contact not found.'), 404);
}
{
$change = false;
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new \Friendica\Network\HTTPException\ForbiddenException();
}
}
// Switch to text mode interface if we have more than 'n' contacts or group members
- $switchtotext = DI::pConfig()->get(Session::getLocalUser(), 'system', 'groupedit_image_limit');
+ $switchtotext = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'groupedit_image_limit');
if (is_null($switchtotext)) {
$switchtotext = DI::config()->get('system', 'groupedit_image_limit', 200);
}
// @TODO: Replace with parameter from router
if (intval(DI::args()->getArgv()[2])) {
- if (!Model\Group::exists(DI::args()->getArgv()[2], Session::getLocalUser())) {
+ if (!Model\Group::exists(DI::args()->getArgv()[2], DI::userSession()->getLocalUserId())) {
DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
DI::baseUrl()->redirect('contact');
}
if ((DI::args()->getArgc() > 2) && intval(DI::args()->getArgv()[1]) && intval(DI::args()->getArgv()[2])) {
BaseModule::checkFormSecurityTokenForbiddenOnError('group_member_change', 't');
- if (DBA::exists('contact', ['id' => DI::args()->getArgv()[2], 'uid' => Session::getLocalUser(), 'self' => false, 'pending' => false, 'blocked' => false])) {
+ if (DBA::exists('contact', ['id' => DI::args()->getArgv()[2], 'uid' => DI::userSession()->getLocalUserId(), 'self' => false, 'pending' => false, 'blocked' => false])) {
$change = intval(DI::args()->getArgv()[2]);
}
}
// @TODO: Replace with parameter from router
if ((DI::args()->getArgc() > 1) && intval(DI::args()->getArgv()[1])) {
- $group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => Session::getLocalUser(), 'deleted' => false]);
+ $group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => DI::userSession()->getLocalUserId(), 'deleted' => false]);
if (!DBA::isResult($group)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
DI::baseUrl()->redirect('contact');
}
if ($nogroup) {
- $contacts = Model\Contact\Group::listUngrouped(Session::getLocalUser());
+ $contacts = Model\Contact\Group::listUngrouped(DI::userSession()->getLocalUserId());
} else {
$contacts_stmt = DBA::select('contact', [],
['rel' => [Model\Contact::FOLLOWER, Model\Contact::FRIEND, Model\Contact::SHARING],
- 'uid' => Session::getLocalUser(), 'pending' => false, 'blocked' => false, 'failed' => false, 'self' => false],
+ 'uid' => DI::userSession()->getLocalUserId(), 'pending' => false, 'blocked' => false, 'failed' => false, 'self' => false],
['order' => ['name']]
);
$contacts = DBA::toArray($contacts_stmt);
namespace Friendica\Module;
use Friendica\BaseModule;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model\Profile;
use Friendica\Model\User;
{
protected function content(array $request = []): string
{
- if (Session::getLocalUser() && ($this->parameters['action'] ?? '') === 'view') {
+ if (DI::userSession()->getLocalUserId() && ($this->parameters['action'] ?? '') === 'view') {
// A logged in user views a profile of a user
$nickname = DI::app()->getLoggedInUserNickname();
} elseif (empty($this->parameters['action'])) {
$page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"" . $baseUrl->get() . "/dfrn_{$dfrn}/{$nickname}\" />\r\n";
}
- $block = (DI::config()->get('system', 'block_public') && !Session::isAuthenticated());
+ $block = (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated());
// check if blocked
if ($block) {
use Friendica\BaseModule;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\Security\Login;
Hook::callAll('home_init', $ret);
- if (Session::getLocalUser() && ($app->getLoggedInUserNickname())) {
+ if (DI::userSession()->getLocalUserId() && ($app->getLoggedInUserNickname())) {
DI::baseUrl()->redirect('network');
}
use Friendica\BaseModule;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model;
use Friendica\Model\User;
{
protected function post(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$max_invites = 50;
}
- $current_invites = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'sent_invites'));
+ $current_invites = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'sent_invites'));
if ($current_invites > $max_invites) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Total invitation limit exceeded.'));
}
if ($config->get('system', 'invitation_only')) {
$invitation_only = true;
- $invites_remaining = DI::pConfig()->get(Session::getLocalUser(), 'system', 'invites_remaining');
+ $invites_remaining = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'invites_remaining');
if ((!$invites_remaining) && (!$app->isSiteAdmin())) {
throw new HTTPException\ForbiddenException();
}
}
- $user = User::getById(Session::getLocalUser());
+ $user = User::getById(DI::userSession()->getLocalUserId());
foreach ($recipients as $recipient) {
$recipient = trim($recipient);
if (!$app->isSiteAdmin()) {
$invites_remaining--;
if ($invites_remaining >= 0) {
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'invites_remaining', $invites_remaining);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'invites_remaining', $invites_remaining);
} else {
return;
}
if ($res) {
$total++;
$current_invites++;
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'sent_invites', $current_invites);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'sent_invites', $current_invites);
if ($current_invites > $max_invites) {
DI::sysmsg()->addNotice(DI::l10n()->t('Invitation limit exceeded. Please contact your site administrator.'));
return;
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
if ($config->get('system', 'invitation_only')) {
$inviteOnly = true;
- $x = DI::pConfig()->get(Session::getLocalUser(), 'system', 'invites_remaining');
+ $x = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'invites_remaining');
if ((!$x) && (!$app->isSiteAdmin())) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('You have no more invitations available'));
}
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Item;
-use Friendica\Core\Session;
use Friendica\Model\Post;
use Friendica\Network\HTTPException;
use Friendica\Protocol\Diaspora;
{
protected function rawContent(array $request = [])
{
- if (!Session::isAuthenticated()) {
+ if (!DI::userSession()->isAuthenticated()) {
throw new HTTPException\ForbiddenException();
}
$itemId = $this->parameters['id'];
if (in_array($verb, ['announce', 'unannounce'])) {
- $item = Post::selectFirst(['network', 'uri-id'], ['id' => $itemId, 'uid' => [Session::getLocalUser(), 0]]);
+ $item = Post::selectFirst(['network', 'uri-id'], ['id' => $itemId, 'uid' => [DI::userSession()->getLocalUserId(), 0]]);
if ($item['network'] == Protocol::DIASPORA) {
- Diaspora::performReshare($item['uri-id'], Session::getLocalUser());
+ Diaspora::performReshare($item['uri-id'], DI::userSession()->getLocalUserId());
}
}
- if (!Item::performActivity($itemId, $verb, Session::getLocalUser())) {
+ if (!Item::performActivity($itemId, $verb, DI::userSession()->getLocalUserId())) {
throw new HTTPException\BadRequestException();
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\Theme;
use Friendica\Database\DBA;
use Friendica\DI;
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return Login::form('compose');
}
}
}
- $user = User::getById(Session::getLocalUser(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'default-location']);
+ $user = User::getById(DI::userSession()->getLocalUserId(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'default-location']);
$contact_allow_list = $this->ACLFormatter->expand($user['allow_cid']);
$group_allow_list = $this->ACLFormatter->expand($user['allow_gid']);
$contact = Contact::getById($a->getContactId());
- if ($this->pConfig->get(Session::getLocalUser(), 'system', 'set_creation_date')) {
+ if ($this->pConfig->get(DI::userSession()->getLocalUserId(), 'system', 'set_creation_date')) {
$created_at = Temporal::getDateTimeField(
new \DateTime(DBA::NULL_DATETIME),
new \DateTime('now'),
'location_disabled' => $this->l10n->t('Location services are disabled. Please check the website\'s permissions on your device'),
'wait' => $this->l10n->t('Please wait'),
'placeholdertitle' => $this->l10n->t('Set title'),
- 'placeholdercategory' => Feature::isEnabled(Session::getLocalUser(),'categories') ? $this->l10n->t('Categories (comma-separated list)') : '',
- 'always_open_compose' => $this->pConfig->get(Session::getLocalUser(), 'frio', 'always_open_compose',
+ 'placeholdercategory' => Feature::isEnabled(DI::userSession()->getLocalUserId(),'categories') ? $this->l10n->t('Categories (comma-separated list)') : '',
+ 'always_open_compose' => $this->pConfig->get(DI::userSession()->getLocalUserId(), 'frio', 'always_open_compose',
$this->config->get('frio', 'always_open_compose', false)) ? '' :
$this->l10n->t('You can make this page always open when you use the New Post button in the <a href="/settings/display">Theme Customization settings</a>.'),
],
namespace Friendica\Module\Item;
use Friendica\BaseModule;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Item;
{
$l10n = DI::l10n();
- if (!Session::isAuthenticated()) {
+ if (!DI::userSession()->isAuthenticated()) {
throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
}
$itemId = intval($this->parameters['id']);
- if (!Item::performActivity($itemId, 'follow', Session::getLocalUser())) {
+ if (!Item::performActivity($itemId, 'follow', DI::userSession()->getLocalUserId())) {
throw new HTTPException\BadRequestException($l10n->t('Unable to follow this item.'));
}
namespace Friendica\Module\Item;
use Friendica\BaseModule;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Item;
{
$l10n = DI::l10n();
- if (!Session::isAuthenticated()) {
+ if (!DI::userSession()->isAuthenticated()) {
throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
}
throw new HTTPException\NotFoundException();
}
- $ignored = !Post\ThreadUser::getIgnored($thread['uri-id'], Session::getLocalUser());
+ $ignored = !Post\ThreadUser::getIgnored($thread['uri-id'], DI::userSession()->getLocalUserId());
- if (in_array($thread['uid'], [0, Session::getLocalUser()])) {
- Post\ThreadUser::setIgnored($thread['uri-id'], Session::getLocalUser(), $ignored);
+ if (in_array($thread['uid'], [0, DI::userSession()->getLocalUserId()])) {
+ Post\ThreadUser::setIgnored($thread['uri-id'], DI::userSession()->getLocalUserId(), $ignored);
} else {
throw new HTTPException\BadRequestException();
}
namespace Friendica\Module\Item;
use Friendica\BaseModule;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
{
$l10n = DI::l10n();
- if (!Session::isAuthenticated()) {
+ if (!DI::userSession()->isAuthenticated()) {
throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
}
throw new HTTPException\NotFoundException();
}
- if (!in_array($item['uid'], [0, Session::getLocalUser()])) {
+ if (!in_array($item['uid'], [0, DI::userSession()->getLocalUserId()])) {
throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
}
$pinned = !$item['featured'];
if ($pinned) {
- Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, $item['author-id'], Session::getLocalUser());
+ Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, $item['author-id'], DI::userSession()->getLocalUserId());
} else {
- Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, Session::getLocalUser());
+ Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, DI::userSession()->getLocalUserId());
}
// See if we've been passed a return path to redirect to
namespace Friendica\Module\Item;
use Friendica\BaseModule;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
{
$l10n = DI::l10n();
- if (!Session::isAuthenticated()) {
+ if (!DI::userSession()->isAuthenticated()) {
throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
}
$itemId = intval($this->parameters['id']);
- $item = Post::selectFirstForUser(Session::getLocalUser(), ['uid', 'uri-id', 'starred'], ['uid' => [0, Session::getLocalUser()], 'id' => $itemId]);
+ $item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), ['uid', 'uri-id', 'starred'], ['uid' => [0, DI::userSession()->getLocalUserId()], 'id' => $itemId]);
if (empty($item)) {
throw new HTTPException\NotFoundException();
}
if ($item['uid'] == 0) {
- $stored = Item::storeForUserByUriId($item['uri-id'], Session::getLocalUser(), ['post-reason' => Item::PR_ACTIVITY]);
+ $stored = Item::storeForUserByUriId($item['uri-id'], DI::userSession()->getLocalUserId(), ['post-reason' => Item::PR_ACTIVITY]);
if (!empty($stored)) {
$item = Post::selectFirst(['starred'], ['id' => $stored]);
if (!DBA::isResult($item)) {
namespace Friendica\Module;
use Friendica\BaseModule;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
if (isset($this->parameters['nick'])) {
// Get infos about a specific nick (public)
$which = $this->parameters['nick'];
- } elseif (Session::getLocalUser() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') {
+ } elseif (DI::userSession()->getLocalUserId() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') {
// view infos about a known profile (needs a login)
$which = $a->getLoggedInUserNickname();
} else {
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Module\BaseNotifications;
'text' => (!$all ? $this->t('Show Ignored Requests') : $this->t('Hide Ignored Requests')),
];
- $owner = User::getOwnerDataById(Session::getLocalUser());
+ $owner = User::getOwnerDataById(DI::userSession()->getLocalUserId());
// Loop through all introduction notifications.This creates an array with the output html for each
// introduction
use Friendica\Contact\Introduction\Repository\Introduction;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
*/
protected function post(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\UnauthorizedException($this->l10n->t('Permission denied.'));
}
$request_id = $this->parameters['id'] ?? false;
if ($request_id) {
- $intro = $this->introductionRepo->selectOneById($request_id, Session::getLocalUser());
+ $intro = $this->introductionRepo->selectOneById($request_id, DI::userSession()->getLocalUserId());
switch ($_POST['submit']) {
case $this->l10n->t('Discard'):
*/
protected function rawContent(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\UnauthorizedException($this->l10n->t('Permission denied.'));
}
if ($this->args->get(1) === 'mark' && $this->args->get(2) === 'all') {
try {
- $this->notificationRepo->setAllSeenForUser(Session::getLocalUser());
- $success = $this->notifyRepo->setAllSeenForUser(Session::getLocalUser());
+ $this->notificationRepo->setAllSeenForUser(DI::userSession()->getLocalUserId());
+ $success = $this->notifyRepo->setAllSeenForUser(DI::userSession()->getLocalUserId());
} catch (\Exception $e) {
$this->logger->warning('set all seen failed.', ['exception' => $e]);
$success = false;
*/
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice($this->l10n->t('You must be logged in to show this page.'));
return Login::form();
}
private function handleNotify(int $notifyId)
{
$Notify = $this->notifyRepo->selectOneById($notifyId);
- if ($Notify->uid !== Session::getLocalUser()) {
+ if ($Notify->uid !== DI::userSession()->getLocalUserId()) {
throw new HTTPException\ForbiddenException();
}
- if ($this->pconfig->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
+ if ($this->pconfig->get(DI::userSession()->getLocalUserId(), 'system', 'detailed_notif')) {
$Notify->setSeen();
$this->notifyRepo->save($Notify);
} else {
private function handleNotification(int $notificationId)
{
$Notification = $this->notificationRepo->selectOneById($notificationId);
- if ($Notification->uid !== Session::getLocalUser()) {
+ if ($Notification->uid !== DI::userSession()->getLocalUserId()) {
throw new HTTPException\ForbiddenException();
}
- if ($this->pconfig->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
+ if ($this->pconfig->get(DI::userSession()->getLocalUserId(), 'system', 'detailed_notif')) {
$Notification->setSeen();
$this->notificationRepo->save($Notification);
} else {
use Friendica\Core\Cache\Enum\Duration;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
$today_birthday_count = 0;
- if (Session::getLocalUser()) {
- if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
- $notifications = $this->notificationRepo->selectDetailedForUser(Session::getLocalUser());
+ if (DI::userSession()->getLocalUserId()) {
+ if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'detailed_notif')) {
+ $notifications = $this->notificationRepo->selectDetailedForUser(DI::userSession()->getLocalUserId());
} else {
- $notifications = $this->notificationRepo->selectDigestForUser(Session::getLocalUser());
+ $notifications = $this->notificationRepo->selectDigestForUser(DI::userSession()->getLocalUserId());
}
$condition = [
"`unseen` AND `uid` = ? AND NOT `origin` AND (`vid` != ? OR `vid` IS NULL)",
- Session::getLocalUser(), Verb::getID(Activity::FOLLOW)
+ DI::userSession()->getLocalUserId(), Verb::getID(Activity::FOLLOW)
];
- $items = Post::selectForUser(Session::getLocalUser(), ['wall', 'uid', 'uri-id'], $condition, ['limit' => 1000]);
+ $items = Post::selectForUser(DI::userSession()->getLocalUserId(), ['wall', 'uid', 'uri-id'], $condition, ['limit' => 1000]);
if (DBA::isResult($items)) {
$items_unseen = Post::toArray($items, false);
$arr = ['items' => $items_unseen];
}
}
- $intros = $this->introductionRepo->selectForUser(Session::getLocalUser());
+ $intros = $this->introductionRepo->selectForUser(DI::userSession()->getLocalUserId());
$intro_count = $intros->count();
$myurl = DI::baseUrl() . '/profile/' . DI::app()->getLoggedInUserNickname();
- $mail_count = DBA::count('mail', ["`uid` = ? AND NOT `seen` AND `from-url` != ?", Session::getLocalUser(), $myurl]);
+ $mail_count = DBA::count('mail', ["`uid` = ? AND NOT `seen` AND `from-url` != ?", DI::userSession()->getLocalUserId(), $myurl]);
if (intval(DI::config()->get('config', 'register_policy')) === Register::APPROVE && DI::app()->isSiteAdmin()) {
$regs = \Friendica\Model\Register::getPending();
}
}
- $cachekey = 'ping:events:' . Session::getLocalUser();
+ $cachekey = 'ping:events:' . DI::userSession()->getLocalUserId();
$ev = DI::cache()->get($cachekey);
if (is_null($ev)) {
$ev = DBA::selectToArray('event', ['type', 'start'],
["`uid` = ? AND `start` < ? AND `finish` > ? AND NOT `ignore`",
- Session::getLocalUser(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utcNow()]);
+ DI::userSession()->getLocalUserId(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utcNow()]);
DI::cache()->set($cachekey, $ev, Duration::HOUR);
}
}
}
- $owner = User::getOwnerDataById(Session::getLocalUser());
+ $owner = User::getOwnerDataById(DI::userSession()->getLocalUserId());
$navNotifications = array_map(function (Entity\Notification $notification) use ($owner) {
if (!DI::notify()->NotifyOnDesktop($notification)) {
}
if (DBA::isResult($regs)) {
- if (count($regs) <= 1 || DI::pConfig()->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
+ if (count($regs) <= 1 || DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'detailed_notif')) {
foreach ($regs as $reg) {
$navNotifications[] = $this->formattedNavNotification->createFromParams(
[
namespace Friendica\Module\OAuth;
use Friendica\Core\Logger;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\BaseApi;
use Friendica\Security\OAuth;
unset($redirect_request['pagename']);
$redirect = 'oauth/authorize?' . http_build_query($redirect_request);
- $uid = Session::getLocalUser();
+ $uid = DI::userSession()->getLocalUserId();
if (empty($uid)) {
Logger::info('Redirect to login');
DI::app()->redirect('login?return_path=' . urlencode($redirect));
namespace Friendica\Module;
use Friendica\Core\Hook;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
throw new HTTPException\BadRequestException(DI::l10n()->t('Wrong type "%s", expected one of: %s', $type, implode(', ', $expectedTypes)));
}
- $condition = ['id' => $referenceId, 'uid' => [0, Session::getLocalUser()]];
+ $condition = ['id' => $referenceId, 'uid' => [0, DI::userSession()->getLocalUserId()]];
if ($type == 'item') {
$fields = ['uid', 'psid', 'private', 'uri-id'];
$model = Post::selectFirst($fields, $condition);
private function fetchReceivers(int $uriId): string
{
$own_url = '';
- $uid = Session::getLocalUser();
+ $uid = DI::userSession()->getLocalUserId();
if ($uid) {
$owner = User::getOwnerDataById($uid);
if (!empty($owner['url'])) {
use Friendica\BaseModule;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
return MPhoto::getPhoto($matches[1], $matches[2]);
}
- return MPhoto::createPhotoForExternalResource($url, (int)Session::getLocalUser(), $media['mimetype'] ?? '');
+ return MPhoto::createPhotoForExternalResource($url, (int)DI::userSession()->getLocalUserId(), $media['mimetype'] ?? '');
case 'media':
$media = DBA::selectFirst('post-media', ['url', 'mimetype', 'uri-id'], ['id' => $id, 'type' => Post\Media::IMAGE]);
if (empty($media)) {
return MPhoto::getPhoto($matches[1], $matches[2]);
}
- return MPhoto::createPhotoForExternalResource($media['url'], (int)Session::getLocalUser(), $media['mimetype']);
+ return MPhoto::createPhotoForExternalResource($media['url'], (int)DI::userSession()->getLocalUserId(), $media['mimetype']);
case 'link':
$link = DBA::selectFirst('post-link', ['url', 'mimetype'], ['id' => $id]);
if (empty($link)) {
return false;
}
- return MPhoto::createPhotoForExternalResource($link['url'], (int)Session::getLocalUser(), $link['mimetype'] ?? '');
+ return MPhoto::createPhotoForExternalResource($link['url'], (int)DI::userSession()->getLocalUserId(), $link['mimetype'] ?? '');
case 'contact':
$fields = ['uid', 'uri-id', 'url', 'nurl', 'avatar', 'photo', 'xmpp', 'addr', 'network', 'failed', 'updated'];
$contact = Contact::getById($id, $fields);
use Friendica\Content\Pager;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Module;
use Friendica\DI;
use Friendica\Model\Contact;
{
protected function content(array $request = []): string
{
- if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
+ if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
- $displayCommonTab = Session::isAuthenticated() && $profile['uid'] != Session::getLocalUser();
+ $displayCommonTab = DI::userSession()->isAuthenticated() && $profile['uid'] != DI::userSession()->getLocalUserId();
if (!$displayCommonTab) {
$a->redirect('profile/' . $nickname . '/contacts');
use Friendica\Content\Pager;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model;
{
protected function content(array $request = []): string
{
- if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
+ if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
- $is_owner = $profile['uid'] == Session::getLocalUser();
+ $is_owner = $profile['uid'] == DI::userSession()->getLocalUserId();
if ($profile['hide-friends'] && !$is_owner) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
$o = self::getTabsHTML($a, 'contacts', $is_owner, $profile['nickname'], $profile['hide-friends']);
- $tabs = self::getContactFilterTabs('profile/' . $nickname, $type, Session::isAuthenticated() && $profile['uid'] != Session::getLocalUser());
+ $tabs = self::getContactFilterTabs('profile/' . $nickname, $type, DI::userSession()->isAuthenticated() && $profile['uid'] != DI::userSession()->getLocalUserId());
$condition = [
'uid' => $profile['uid'],
namespace Friendica\Module\Profile;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile as ProfileModel;
DI::page()['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
}
- $is_owner = Session::getLocalUser() == $profile['uid'];
+ $is_owner = DI::userSession()->getLocalUserId() == $profile['uid'];
$o = self::getTabsHTML($a, 'media', $is_owner, $profile['nickname'], $profile['hide-friends']);
use Friendica\Core\Hook;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
throw new HTTPException\NotFoundException(DI::l10n()->t('Profile not found.'));
}
- $remote_contact_id = Session::getRemoteContactID($profile['uid']);
+ $remote_contact_id = DI::userSession()->getRemoteContactID($profile['uid']);
- if (DI::config()->get('system', 'block_public') && !Session::getLocalUser() && !$remote_contact_id) {
+ if (DI::config()->get('system', 'block_public') && !DI::userSession()->getLocalUserId() && !$remote_contact_id) {
return Login::form();
}
- $is_owner = Session::getLocalUser() == $profile['uid'];
+ $is_owner = DI::userSession()->getLocalUserId() == $profile['uid'];
if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact_id) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));
Nav::setSelected('home');
- $is_owner = Session::getLocalUser() == $profile['uid'];
+ $is_owner = DI::userSession()->getLocalUserId() == $profile['uid'];
$o = self::getTabsHTML($a, 'profile', $is_owner, $profile['nickname'], $profile['hide-friends']);
if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact_id) {
$view_as_contact_id = intval($_GET['viewas'] ?? 0);
$view_as_contacts = Contact::selectToArray(['id', 'name'], [
- 'uid' => Session::getLocalUser(),
+ 'uid' => DI::userSession()->getLocalUserId(),
'rel' => [Contact::FOLLOWER, Contact::SHARING, Contact::FRIEND],
'network' => Protocol::DFRN,
'blocked' => false,
'$submit' => DI::l10n()->t('Submit'),
'$basic' => DI::l10n()->t('Basic'),
'$advanced' => DI::l10n()->t('Advanced'),
- '$is_owner' => $profile['uid'] == Session::getLocalUser(),
+ '$is_owner' => $profile['uid'] == DI::userSession()->getLocalUserId(),
'$query_string' => DI::args()->getQueryString(),
'$basic_fields' => $basic_fields,
'$custom_fields' => $custom_fields,
}
// site block
- $blocked = !Session::getLocalUser() && !$remote_contact_id && DI::config()->get('system', 'block_public');
- $userblock = !Session::getLocalUser() && !$remote_contact_id && $profile['hidewall'];
+ $blocked = !DI::userSession()->getLocalUserId() && !$remote_contact_id && DI::config()->get('system', 'block_public');
+ $userblock = !DI::userSession()->getLocalUserId() && !$remote_contact_id && $profile['hidewall'];
if (!$blocked && !$userblock) {
$keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $profile['pub_keywords'] ?? '');
if (strlen($keywords)) {
use Friendica\BaseModule;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Post;
{
protected function post(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
throw new HTTPException\BadRequestException();
}
- if (!DBA::exists('delayed-post', ['id' => $_REQUEST['delete'], 'uid' => Session::getLocalUser()])) {
+ if (!DBA::exists('delayed-post', ['id' => $_REQUEST['delete'], 'uid' => DI::userSession()->getLocalUserId()])) {
throw new HTTPException\NotFoundException();
}
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$o = self::getTabsHTML($a, 'schedule', true, $a->getLoggedInUserNickname(), false);
$schedule = [];
- $delayed = DBA::select('delayed-post', [], ['uid' => Session::getLocalUser()]);
+ $delayed = DBA::select('delayed-post', [], ['uid' => DI::userSession()->getLocalUserId()]);
while ($row = DBA::fetch($delayed)) {
$parameter = Post\Delayed::getParametersForid($row['id']);
if (empty($parameter)) {
use Friendica\Content\Widget;
use Friendica\Core\ACL;
use Friendica\Core\Protocol;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
$hashtags = $_GET['tag'] ?? '';
- if (DI::config()->get('system', 'block_public') && !Session::getLocalUser() && !Session::getRemoteContactID($profile['uid'])) {
+ if (DI::config()->get('system', 'block_public') && !DI::userSession()->getLocalUserId() && !DI::userSession()->getRemoteContactID($profile['uid'])) {
return Login::form();
}
$o = '';
- if ($profile['uid'] == Session::getLocalUser()) {
+ if ($profile['uid'] == DI::userSession()->getLocalUserId()) {
Nav::setSelected('home');
}
- $remote_contact = Session::getRemoteContactID($profile['uid']);
- $is_owner = Session::getLocalUser() == $profile['uid'];
- $last_updated_key = "profile:" . $profile['uid'] . ":" . Session::getLocalUser() . ":" . $remote_contact;
+ $remote_contact = DI::userSession()->getRemoteContactID($profile['uid']);
+ $is_owner = DI::userSession()->getLocalUserId() == $profile['uid'];
+ $last_updated_key = "profile:" . $profile['uid'] . ":" . DI::userSession()->getLocalUserId() . ":" . $remote_contact;
if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact) {
DI::sysmsg()->addNotice(DI::l10n()->t('Access to this profile has been restricted.'));
}
if (DI::mode()->isMobile()) {
- $itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
+ $itemspage_network = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
- $itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
+ $itemspage_network = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
}
if ($is_owner) {
- $unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]);
+ $unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => DI::userSession()->getLocalUserId()]);
if ($unseen) {
- Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]);
+ Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => DI::userSession()->getLocalUserId()]);
}
}
use Friendica\BaseModule;
use Friendica\Core\Logger;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
throw new \Friendica\Network\HTTPException\BadRequestException();
}
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
Logger::debug('Redirecting not logged in user to original address', ['url' => $request['url']]);
System::externalRedirect($request['url']);
}
$request['url'] = str_replace(' ', '+', $request['url']);
// Fetch the content with the local user
- $fetchResult = HTTPSignature::fetchRaw($request['url'], Session::getLocalUser(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE], 'timeout' => 10]);
+ $fetchResult = HTTPSignature::fetchRaw($request['url'], DI::userSession()->getLocalUserId(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE], 'timeout' => 10]);
$img_str = $fetchResult->getBody();
if (!$fetchResult->isSuccess() || empty($img_str)) {
// stop.
}
- Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => Session::getLocalUser(), 'image' => $request['url']]);
+ Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => DI::userSession()->getLocalUserId(), 'image' => $request['url']]);
$mime = Images::getMimeTypeByData($img_str);
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
// 'block_extended_register' blocks all registrations, period.
$block = DI::config()->get('system', 'block_extended_register');
- if (Session::getLocalUser() && $block) {
+ if (DI::userSession()->getLocalUserId() && $block) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return '';
}
- if (Session::getLocalUser()) {
- $user = DBA::selectFirst('user', ['parent-uid'], ['uid' => Session::getLocalUser()]);
+ if (DI::userSession()->getLocalUserId()) {
+ $user = DBA::selectFirst('user', ['parent-uid'], ['uid' => DI::userSession()->getLocalUserId()]);
if (!empty($user['parent-uid'])) {
DI::sysmsg()->addNotice(DI::l10n()->t('Only parent users can create additional accounts.'));
return '';
}
}
- if (!Session::getLocalUser() && (intval(DI::config()->get('config', 'register_policy')) === self::CLOSED)) {
+ if (!DI::userSession()->getLocalUserId() && (intval(DI::config()->get('config', 'register_policy')) === self::CLOSED)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return '';
}
$photo = $_REQUEST['photo'] ?? '';
$invite_id = $_REQUEST['invite_id'] ?? '';
- if (Session::getLocalUser() || DI::config()->get('system', 'no_openid')) {
+ if (DI::userSession()->getLocalUserId() || DI::config()->get('system', 'no_openid')) {
$fillwith = '';
$fillext = '';
$oidlabel = '';
'$form_security_token' => BaseModule::getFormSecurityToken('register'),
'$explicit_content' => DI::config()->get('system', 'explicit_content', false),
'$explicit_content_note' => DI::l10n()->t('Note: This node explicitly contains adult content'),
- '$additional' => !empty(Session::getLocalUser()),
+ '$additional' => !empty(DI::userSession()->getLocalUserId()),
'$parent_password' => ['parent_password', DI::l10n()->t('Parent Password:'), '', DI::l10n()->t('Please enter the password of the parent account to legitimize your request.')]
]);
$additional_account = false;
- if (!Session::getLocalUser() && !empty($arr['post']['parent_password'])) {
+ if (!DI::userSession()->getLocalUserId() && !empty($arr['post']['parent_password'])) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return;
- } elseif (Session::getLocalUser() && !empty($arr['post']['parent_password'])) {
+ } elseif (DI::userSession()->getLocalUserId() && !empty($arr['post']['parent_password'])) {
try {
- Model\User::getIdFromPasswordAuthentication(Session::getLocalUser(), $arr['post']['parent_password']);
+ Model\User::getIdFromPasswordAuthentication(DI::userSession()->getLocalUserId(), $arr['post']['parent_password']);
} catch (\Exception $ex) {
DI::sysmsg()->addNotice(DI::l10n()->t("Password doesn't match."));
$regdata = ['nickname' => $arr['post']['nickname'], 'username' => $arr['post']['username']];
DI::baseUrl()->redirect('register?' . http_build_query($regdata));
}
$additional_account = true;
- } elseif (Session::getLocalUser()) {
+ } elseif (DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Please enter your password.'));
$regdata = ['nickname' => $arr['post']['nickname'], 'username' => $arr['post']['username']];
DI::baseUrl()->redirect('register?' . http_build_query($regdata));
}
if ($additional_account) {
- $user = DBA::selectFirst('user', ['email'], ['uid' => Session::getLocalUser()]);
+ $user = DBA::selectFirst('user', ['email'], ['uid' => DI::userSession()->getLocalUserId()]);
if (!DBA::isResult($user)) {
DI::sysmsg()->addNotice(DI::l10n()->t('User not found.'));
DI::baseUrl()->redirect('register');
}
if ($additional_account) {
- DBA::update('user', ['parent-uid' => Session::getLocalUser()], ['uid' => $user['uid']]);
+ DBA::update('user', ['parent-uid' => DI::userSession()->getLocalUserId()], ['uid' => $user['uid']]);
DI::sysmsg()->addInfo(DI::l10n()->t('The additional account was created.'));
DI::baseUrl()->redirect('delegation');
}
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Search;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
protected function rawContent(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this module.'));
}
Logger::info('ACL {action} - {subaction} - start', ['module' => 'acl', 'action' => 'content', 'subaction' => 'search', 'search' => $search, 'type' => $type, 'conversation' => $conv_id]);
$sql_extra = '';
- $condition = ["`uid` = ? AND NOT `deleted` AND NOT `pending` AND NOT `archive`", Session::getLocalUser()];
- $condition_group = ["`uid` = ? AND NOT `deleted`", Session::getLocalUser()];
+ $condition = ["`uid` = ? AND NOT `deleted` AND NOT `pending` AND NOT `archive`", DI::userSession()->getLocalUserId()];
+ $condition_group = ["`uid` = ? AND NOT `deleted`", DI::userSession()->getLocalUserId()];
if ($search != '') {
$sql_extra = "AND `name` LIKE '%%" . DBA::escape($search) . "%%'";
GROUP BY `group`.`name`, `group`.`id`
ORDER BY `group`.`name`
LIMIT ?, ?",
- Session::getLocalUser(),
+ DI::userSession()->getLocalUserId(),
$start,
$count
));
$condition = ["`parent` = ?", $conv_id];
$params = ['order' => ['author-name' => true]];
- $authors = Post::selectForUser(Session::getLocalUser(), ['author-link'], $condition, $params);
+ $authors = Post::selectForUser(DI::userSession()->getLocalUserId(), ['author-link'], $condition, $params);
$item_authors = [];
while ($author = Post::fetch($authors)) {
$item_authors[$author['author-link']] = $author['author-link'];
namespace Friendica\Module\Search;
use Friendica\Content\Widget;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\BaseSearch;
use Friendica\Module\Security\Login;
{
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return Login::form();
}
use Friendica\Content\Text\HTML;
use Friendica\Content\Widget;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
{
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return Login::form();
}
DI::page()['aside'] .= Widget::fileAs(DI::args()->getCommand(), $_GET['file'] ?? '');
- if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
+ if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
$o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
} else {
}
if (DI::mode()->isMobile()) {
- $itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
+ $itemspage_network = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
- $itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
+ $itemspage_network = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemspage_network);
- $term_condition = ['type' => Category::FILE, 'uid' => Session::getLocalUser()];
+ $term_condition = ['type' => Category::FILE, 'uid' => DI::userSession()->getLocalUserId()];
if ($file) {
$term_condition['name'] = $file;
}
if (count($posts) == 0) {
return '';
}
- $item_condition = ['uid' => [0, Session::getLocalUser()], 'uri-id' => $posts];
+ $item_condition = ['uid' => [0, DI::userSession()->getLocalUserId()], 'uri-id' => $posts];
$item_params = ['order' => ['uri-id' => true, 'uid' => true]];
- $items = Post::toArray(Post::selectForUser(Session::getLocalUser(), Item::DISPLAY_FIELDLIST, $item_condition, $item_params));
+ $items = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), Item::DISPLAY_FIELDLIST, $item_condition, $item_params));
- $o .= DI::conversation()->create($items, 'filed', false, false, '', Session::getLocalUser());
+ $o .= DI::conversation()->create($items, 'filed', false, false, '', DI::userSession()->getLocalUserId());
- if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
+ if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader();
} else {
$o .= $pager->renderMinimal($count);
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
{
$search = (!empty($_GET['q']) ? trim(rawurldecode($_GET['q'])) : '');
- if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
+ if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.'));
}
- if (DI::config()->get('system', 'local_search') && !Session::isAuthenticated()) {
+ if (DI::config()->get('system', 'local_search') && !DI::userSession()->isAuthenticated()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a search.'));
}
- if (DI::config()->get('system', 'permit_crawling') && !Session::isAuthenticated()) {
+ if (DI::config()->get('system', 'permit_crawling') && !DI::userSession()->isAuthenticated()) {
// Default values:
// 10 requests are "free", after the 11th only a call per minute is allowed
}
}
- if (Session::getLocalUser()) {
+ if (DI::userSession()->getLocalUserId()) {
DI::page()['aside'] .= Widget\SavedSearches::getHTML(Search::getSearchPath($search), $search);
}
// No items will be shown if the member has a blocked profile wall.
if (DI::mode()->isMobile()) {
- $itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
+ $itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
- $itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
+ $itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
if ($tag) {
Logger::info('Start tag search.', ['q' => $search]);
- $uriids = Tag::getURIIdListByTag($search, Session::getLocalUser(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
- $count = Tag::countByTag($search, Session::getLocalUser());
+ $uriids = Tag::getURIIdListByTag($search, DI::userSession()->getLocalUserId(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
+ $count = Tag::countByTag($search, DI::userSession()->getLocalUserId());
} else {
Logger::info('Start fulltext search.', ['q' => $search]);
- $uriids = Post\Content::getURIIdListBySearch($search, Session::getLocalUser(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
- $count = Post\Content::countBySearch($search, Session::getLocalUser());
+ $uriids = Post\Content::getURIIdListBySearch($search, DI::userSession()->getLocalUserId(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
+ $count = Post\Content::countBySearch($search, DI::userSession()->getLocalUserId());
}
if (!empty($uriids)) {
- $condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`))", 0, Session::getLocalUser()];
+ $condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`))", 0, DI::userSession()->getLocalUserId()];
$condition = DBA::mergeConditions($condition, ['uri-id' => $uriids]);
$params = ['order' => ['id' => true]];
- $items = Post::toArray(Post::selectForUser(Session::getLocalUser(), Item::DISPLAY_FIELDLIST, $condition, $params));
+ $items = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), Item::DISPLAY_FIELDLIST, $condition, $params));
}
if (empty($items)) {
return $o;
}
- if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
+ if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
$o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
}
Logger::info('Start Conversation.', ['q' => $search]);
- $o .= DI::conversation()->create($items, 'search', false, false, 'commented', Session::getLocalUser());
+ $o .= DI::conversation()->create($items, 'search', false, false, 'commented', DI::userSession()->getLocalUserId());
- if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
+ if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader();
} else {
$o .= $pager->renderMinimal($count);
$search = $matches[1];
}
- if (Session::getLocalUser()) {
+ if (DI::userSession()->getLocalUserId()) {
// User-specific contact URL/address search
- $contact_id = Contact::getIdForURL($search, Session::getLocalUser());
+ $contact_id = Contact::getIdForURL($search, DI::userSession()->getLocalUserId());
if (!$contact_id) {
// User-specific contact URL/address search and probe
$contact_id = Contact::getIdForURL($search);
$search = Network::convertToIdn($search);
- if (Session::getLocalUser()) {
+ if (DI::userSession()->getLocalUserId()) {
// Post URL search
- $item_id = Item::fetchByLink($search, Session::getLocalUser());
+ $item_id = Item::fetchByLink($search, DI::userSession()->getLocalUserId());
if (!$item_id) {
// If the user-specific search failed, we search and probe a public post
$item_id = Item::fetchByLink($search);
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Search;
-use Friendica\Core\Session;
use Friendica\Database\Database;
use Friendica\DI;
use Friendica\Module\Response;
$return_url = $_GET['return_url'] ?? Search::getSearchPath($search);
- if (Session::getLocalUser() && $search) {
+ if (DI::userSession()->getLocalUserId() && $search) {
switch ($action) {
case 'add':
- $fields = ['uid' => Session::getLocalUser(), 'term' => $search];
+ $fields = ['uid' => DI::userSession()->getLocalUserId(), 'term' => $search];
if (!$this->dba->exists('search', $fields)) {
if (!$this->dba->insert('search', $fields)) {
DI::sysmsg()->addNotice($this->t('Search term was not saved.'));
break;
case 'remove':
- if (!$this->dba->delete('search', ['uid' => Session::getLocalUser(), 'term' => $search])) {
+ if (!$this->dba->delete('search', ['uid' => DI::userSession()->getLocalUserId(), 'term' => $search])) {
DI::sysmsg()->addNotice($this->t('Search term was not removed.'));
}
break;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\DI;
use Friendica\Module\Register;
{
$return_path = $request['return_path'] ?? $this->session->pop('return_path', '') ;
- if (Session::getLocalUser()) {
+ if (DI::userSession()->getLocalUserId()) {
$this->baseUrl->redirect($return_path);
}
];
}
- if (Session::getLocalUser()) {
+ if (DI::userSession()->getLocalUserId()) {
$tpl = Renderer::getMarkupTemplate('logout.tpl');
} else {
DI::page()['htmlhead'] .= Renderer::replaceMacros(
use Friendica\Core\Cache\Capability\ICanCache;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
-use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\System;
use Friendica\DI;
protected function rawContent(array $request = [])
{
$visitor_home = null;
- if (Session::getRemoteUser()) {
+ if (DI::userSession()->getRemoteUserId()) {
$visitor_home = Profile::getMyURL();
$this->cache->delete('zrlInit:' . $visitor_home);
}
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\DI;
use Friendica\Model\User;
protected function post(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
$recovery_code = $_POST['recovery_code'] ?? '';
- if (RecoveryCode::existsForUser(Session::getLocalUser(), $recovery_code)) {
- RecoveryCode::markUsedForUser(Session::getLocalUser(), $recovery_code);
+ if (RecoveryCode::existsForUser(DI::userSession()->getLocalUserId(), $recovery_code)) {
+ RecoveryCode::markUsedForUser(DI::userSession()->getLocalUserId(), $recovery_code);
$this->session->set('2fa', true);
- DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(Session::getLocalUser())));
+ DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(DI::userSession()->getLocalUserId())));
$this->auth->setForUser($this->app, User::getById($this->app->getLoggedInUserId()), true, true);
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
$this->baseUrl->redirect();
}
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\DI;
use Friendica\Model\User\Cookie;
protected function post(array $request = [])
{
- if (!Session::getLocalUser() || !($this->cookie->get('2fa_cookie_hash'))) {
+ if (!DI::userSession()->getLocalUserId() || !($this->cookie->get('2fa_cookie_hash'))) {
return;
}
$this->baseUrl->redirect();
break;
case 'sign_out':
- $this->trustedBrowserRepository->removeForUser(Session::getLocalUser(), $this->cookie->get('2fa_cookie_hash'));
+ $this->trustedBrowserRepository->removeForUser(DI::userSession()->getLocalUserId(), $this->cookie->get('2fa_cookie_hash'));
$this->cookie->clear();
$this->session->clear();
protected function content(array $request = []): string
{
- if (!Session::getLocalUser() || !($this->cookie->get('2fa_cookie_hash'))) {
+ if (!DI::userSession()->getLocalUserId() || !($this->cookie->get('2fa_cookie_hash'))) {
$this->baseUrl->redirect();
}
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\DI;
use Friendica\Model\User;
protected function post(array $request = [])
{
- if (!Session::getLocalUser() || !$this->session->get('2fa')) {
+ if (!DI::userSession()->getLocalUserId() || !$this->session->get('2fa')) {
$this->logger->info('Invalid call', ['request' => $request]);
return;
}
switch ($action) {
case 'trust':
case 'dont_trust':
- $trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent(Session::getLocalUser(), $this->server['HTTP_USER_AGENT'], $action === 'trust');
+ $trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent(DI::userSession()->getLocalUserId(), $this->server['HTTP_USER_AGENT'], $action === 'trust');
try {
$this->trustedBrowserRepository->save($trustedBrowser);
protected function content(array $request = []): string
{
- if (!Session::getLocalUser() || !$this->session->get('2fa')) {
+ if (!DI::userSession()->getLocalUserId() || !$this->session->get('2fa')) {
$this->baseUrl->redirect();
}
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
-use Friendica\Core\Session;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
}
// check if the old password was supplied correctly before changing it to the new value
- User::getIdFromPasswordAuthentication(Session::getLocalUser(), $request['opassword']);
+ User::getIdFromPasswordAuthentication(DI::userSession()->getLocalUserId(), $request['opassword']);
- $result = User::updatePassword(Session::getLocalUser(), $newpass);
+ $result = User::updatePassword(DI::userSession()->getLocalUserId(), $newpass);
if (!DBA::isResult($result)) {
throw new Exception(DI::l10n()->t('Password update failed. Please try again.'));
}
if ($email != $user['email']) {
// check for the correct password
try {
- User::getIdFromPasswordAuthentication(Session::getLocalUser(), $request['mpassword']);
+ User::getIdFromPasswordAuthentication(DI::userSession()->getLocalUserId(), $request['mpassword']);
} catch (Exception $ex) {
$err .= DI::l10n()->t('Wrong Password.');
$email = $user['email'];
$fields['openidserver'] = '';
}
- if (!User::update($fields, Session::getLocalUser())) {
+ if (!User::update($fields, DI::userSession()->getLocalUserId())) {
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
$str_group_deny = !empty($request['group_deny']) ? $aclFormatter->toString($request['group_deny']) : '';
$str_contact_deny = !empty($request['contact_deny']) ? $aclFormatter->toString($request['contact_deny']) : '';
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'unlisted', !empty($request['unlisted']));
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'accessible-photos', !empty($request['accessible-photos']));
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'unlisted', !empty($request['unlisted']));
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'accessible-photos', !empty($request['accessible-photos']));
$fields = [
'allow_cid' => $str_contact_allow,
'hide-friends' => $hide_friends
];
- if (!User::update($fields, Session::getLocalUser()) || !Profile::update($profile_fields, Session::getLocalUser())) {
+ if (!User::update($fields, DI::userSession()->getLocalUserId()) || !Profile::update($profile_fields, DI::userSession()->getLocalUserId())) {
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
$expire_starred = !empty($request['expire_starred']);
$expire_network_only = !empty($request['expire_network_only']);
- DI::pConfig()->set(Session::getLocalUser(), 'expire', 'items', $expire_items);
- DI::pConfig()->set(Session::getLocalUser(), 'expire', 'notes', $expire_notes);
- DI::pConfig()->set(Session::getLocalUser(), 'expire', 'starred', $expire_starred);
- DI::pConfig()->set(Session::getLocalUser(), 'expire', 'network_only', $expire_network_only);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'expire', 'items', $expire_items);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'expire', 'notes', $expire_notes);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'expire', 'starred', $expire_starred);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'expire', 'network_only', $expire_network_only);
- if (!User::update(['expire' => $expire], Session::getLocalUser())) {
+ if (!User::update(['expire' => $expire], DI::userSession()->getLocalUserId())) {
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
if (!empty($request['notify_activity_participation'])) {
$notify_type = $notify_type | UserNotification::TYPE_ACTIVITY_PARTICIPATION;
}
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'notify_type', $notify_type);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'notify_type', $notify_type);
if (!($notify_type & (UserNotification::TYPE_DIRECT_COMMENT + UserNotification::TYPE_DIRECT_THREAD_COMMENT))) {
$notify_like = false;
}
// Reset like notifications when they are going to be shown again
- if (!DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_like') && $notify_like) {
- DI::notification()->setAllSeenForUser(Session::getLocalUser(), ['vid' => Verb::getID(Activity::LIKE)]);
+ if (!DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'notify_like') && $notify_like) {
+ DI::notification()->setAllSeenForUser(DI::userSession()->getLocalUserId(), ['vid' => Verb::getID(Activity::LIKE)]);
}
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'notify_like', $notify_like);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'notify_like', $notify_like);
// Reset share notifications when they are going to be shown again
- if (!DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_announce') && $notify_announce) {
- DI::notification()->setAllSeenForUser(Session::getLocalUser(), ['vid' => Verb::getID(Activity::ANNOUNCE)]);
+ if (!DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'notify_announce') && $notify_announce) {
+ DI::notification()->setAllSeenForUser(DI::userSession()->getLocalUserId(), ['vid' => Verb::getID(Activity::ANNOUNCE)]);
}
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'notify_announce', $notify_announce);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'notify_announce', $notify_announce);
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'email_textonly', !empty($request['email_textonly']));
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'detailed_notif', !empty($request['detailed_notif']));
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'notify_ignored', !empty($request['notify_ignored']));
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'email_textonly', !empty($request['email_textonly']));
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'detailed_notif', !empty($request['detailed_notif']));
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'notify_ignored', !empty($request['notify_ignored']));
$fields = [
'notify-flags' => $notify,
];
- if (!User::update($fields, Session::getLocalUser())) {
+ if (!User::update($fields, DI::userSession()->getLocalUserId())) {
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
$profile_fields = [];
if ($account_type == User::ACCOUNT_TYPE_COMMUNITY) {
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'unlisted', true);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'unlisted', true);
$fields = [
'allow_cid' => '',
'account-type' => $account_type,
]);
- if (!User::update($fields, Session::getLocalUser()) || !empty($profile_fields) && !Profile::update($profile_fields, Session::getLocalUser())) {
+ if (!User::update($fields, DI::userSession()->getLocalUserId()) || !empty($profile_fields) && !Profile::update($profile_fields, DI::userSession()->getLocalUserId())) {
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
// "http" or "@" to be present in the string.
// All other fields from the row will be ignored
if ((strpos($csvRow[0], '@') !== false) || Network::isValidHttpUrl($csvRow[0])) {
- Worker::add(Worker::PRIORITY_MEDIUM, 'AddContact', Session::getLocalUser(), $csvRow[0]);
+ Worker::add(Worker::PRIORITY_MEDIUM, 'AddContact', DI::userSession()->getLocalUserId(), $csvRow[0]);
} else {
Logger::notice('Invalid account', ['url' => $csvRow[0]]);
}
}
if (!empty($request['relocate-submit'])) {
- Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, Session::getLocalUser());
+ Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, DI::userSession()->getLocalUserId());
DI::sysmsg()->addInfo(DI::l10n()->t("Relocate message has been send to your contacts"));
DI::baseUrl()->redirect($redirectUrl);
}
{
parent::content();
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
- $profile = DBA::selectFirst('profile', [], ['uid' => Session::getLocalUser()]);
+ $profile = DBA::selectFirst('profile', [], ['uid' => DI::userSession()->getLocalUserId()]);
if (!DBA::isResult($profile)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to find your profile. Please contact your admin.'));
return '';
$unkmail = $user['unkmail'];
$cntunkmail = $user['cntunkmail'];
- $expire_items = DI::pConfig()->get(Session::getLocalUser(), 'expire', 'items', true);
- $expire_notes = DI::pConfig()->get(Session::getLocalUser(), 'expire', 'notes', true);
- $expire_starred = DI::pConfig()->get(Session::getLocalUser(), 'expire', 'starred', true);
- $expire_network_only = DI::pConfig()->get(Session::getLocalUser(), 'expire', 'network_only', false);
+ $expire_items = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'items', true);
+ $expire_notes = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'notes', true);
+ $expire_starred = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'starred', true);
+ $expire_network_only = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'network_only', false);
if (!strlen($user['timezone'])) {
$timezone = $a->getTimeZone();
/* Installed langs */
$lang_choices = DI::l10n()->getAvailableLanguages();
- $notify_type = DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_type');
+ $notify_type = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'notify_type');
$passwordRules = DI::l10n()->t('Allowed characters are a-z, A-Z, 0-9 and special characters except white spaces, accentuated letters and colon (:).')
. (PASSWORD_DEFAULT === PASSWORD_BCRYPT ? ' ' . DI::l10n()->t('Password length is limited to 72 characters.') : '');
'$submit' => DI::l10n()->t('Save Settings'),
'$baseurl' => DI::baseUrl()->get(true),
- '$uid' => Session::getLocalUser(),
+ '$uid' => DI::userSession()->getLocalUserId(),
'$form_security_token' => self::getFormSecurityToken('settings'),
'$open' => $this->parameters['open'] ?? 'password',
'$profile_in_net_dir' => ['profile_in_netdirectory', DI::l10n()->t('Allow your profile to be searchable globally?'), $profile['net-publish'], DI::l10n()->t("Activate this setting if you want others to easily find and follow you. Your profile will be searchable on remote systems. This setting also determines whether Friendica will inform search engines that your profile should be indexed or not.") . $net_pub_desc],
'$hide_friends' => ['hide-friends', DI::l10n()->t('Hide your contact/friend list from viewers of your profile?'), $profile['hide-friends'], DI::l10n()->t('A list of your contacts is displayed on your profile page. Activate this option to disable the display of your contact list.')],
'$hide_wall' => ['hidewall', DI::l10n()->t('Hide your profile details from anonymous viewers?'), $user['hidewall'], DI::l10n()->t('Anonymous visitors will only see your profile picture, your display name and the nickname you are using on your profile page. Your public posts and replies will still be accessible by other means.')],
- '$unlisted' => ['unlisted', DI::l10n()->t('Make public posts unlisted'), DI::pConfig()->get(Session::getLocalUser(), 'system', 'unlisted'), DI::l10n()->t('Your public posts will not appear on the community pages or in search results, nor be sent to relay servers. However they can still appear on public feeds on remote servers.')],
- '$accessiblephotos' => ['accessible-photos', DI::l10n()->t('Make all posted pictures accessible'), DI::pConfig()->get(Session::getLocalUser(), 'system', 'accessible-photos'), DI::l10n()->t("This option makes every posted picture accessible via the direct link. This is a workaround for the problem that most other networks can't handle permissions on pictures. Non public pictures still won't be visible for the public on your photo albums though.")],
+ '$unlisted' => ['unlisted', DI::l10n()->t('Make public posts unlisted'), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'unlisted'), DI::l10n()->t('Your public posts will not appear on the community pages or in search results, nor be sent to relay servers. However they can still appear on public feeds on remote servers.')],
+ '$accessiblephotos' => ['accessible-photos', DI::l10n()->t('Make all posted pictures accessible'), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'accessible-photos'), DI::l10n()->t("This option makes every posted picture accessible via the direct link. This is a workaround for the problem that most other networks can't handle permissions on pictures. Non public pictures still won't be visible for the public on your photo albums though.")],
'$blockwall' => ['blockwall', DI::l10n()->t('Allow friends to post to your profile page?'), (intval($user['blockwall']) ? '0' : '1'), DI::l10n()->t('Your contacts may write posts on your profile wall. These posts will be distributed to your contacts')],
'$blocktags' => ['blocktags', DI::l10n()->t('Allow friends to tag your posts?'), (intval($user['blocktags']) ? '0' : '1'), DI::l10n()->t('Your contacts can add additional tags to your posts.')],
'$unkmail' => ['unkmail', DI::l10n()->t('Permit unknown people to send you private mail?'), $unkmail, DI::l10n()->t('Friendica network users may send you private messages even if they are not in your contact list.')],
'$cntunkmail' => ['cntunkmail', DI::l10n()->t('Maximum private messages per day from unknown people:'), $cntunkmail, DI::l10n()->t("(to prevent spam abuse)")],
- '$group_select' => Group::displayGroupSelection(Session::getLocalUser(), $user['def_gid']),
+ '$group_select' => Group::displayGroupSelection(DI::userSession()->getLocalUserId(), $user['def_gid']),
'$permissions' => DI::l10n()->t('Default Post Permissions'),
'$aclselect' => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId()),
'$lbl_notify' => DI::l10n()->t('Create a desktop notification when:'),
'$notify_tagged' => ['notify_tagged', DI::l10n()->t('Someone tagged you'), is_null($notify_type) || $notify_type & UserNotification::TYPE_EXPLICIT_TAGGED, ''],
'$notify_direct_comment' => ['notify_direct_comment', DI::l10n()->t('Someone directly commented on your post'), is_null($notify_type) || $notify_type & (UserNotification::TYPE_IMPLICIT_TAGGED + UserNotification::TYPE_DIRECT_COMMENT + UserNotification::TYPE_DIRECT_THREAD_COMMENT), ''],
- '$notify_like' => ['notify_like', DI::l10n()->t('Someone liked your content'), DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_like'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')],
- '$notify_announce' => ['notify_announce', DI::l10n()->t('Someone shared your content'), DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_announce'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')],
+ '$notify_like' => ['notify_like', DI::l10n()->t('Someone liked your content'), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'notify_like'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')],
+ '$notify_announce' => ['notify_announce', DI::l10n()->t('Someone shared your content'), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'notify_announce'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')],
'$notify_thread_comment' => ['notify_thread_comment', DI::l10n()->t('Someone commented in your thread'), is_null($notify_type) || $notify_type & UserNotification::TYPE_THREAD_COMMENT, ''],
'$notify_comment_participation' => ['notify_comment_participation', DI::l10n()->t('Someone commented in a thread where you commented'), is_null($notify_type) || $notify_type & UserNotification::TYPE_COMMENT_PARTICIPATION, ''],
'$notify_activity_participation' => ['notify_activity_participation', DI::l10n()->t('Someone commented in a thread where you interacted'), is_null($notify_type) || $notify_type & UserNotification::TYPE_ACTIVITY_PARTICIPATION, ''],
'$email_textonly' => [
'email_textonly',
DI::l10n()->t('Text-only notification emails'),
- DI::pConfig()->get(Session::getLocalUser(), 'system', 'email_textonly'),
+ DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'email_textonly'),
DI::l10n()->t('Send text only notification emails, without the html part')
],
'$detailed_notif' => [
'detailed_notif',
DI::l10n()->t('Show detailled notifications'),
- DI::pConfig()->get(Session::getLocalUser(), 'system', 'detailed_notif'),
+ DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'detailed_notif'),
DI::l10n()->t('Per default, notifications are condensed to a single notification per item. When enabled every notification is displayed.')
],
'$notify_ignored' => [
'notify_ignored',
DI::l10n()->t('Show notifications of ignored contacts'),
- DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_ignored', true),
+ DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'notify_ignored', true),
DI::l10n()->t("You don't see posts from ignored contacts. But you still see their comments. This setting controls if you want to still receive regular notifications that are caused by ignored contacts or not.")
],
use Friendica\BaseModule;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
DI::sysmsg()->addInfo(DI::l10n()->t('Delegation successfully revoked.'));
}
- DBA::update('user', ['parent-uid' => $parent_uid], ['uid' => Session::getLocalUser()]);
+ DBA::update('user', ['parent-uid' => $parent_uid], ['uid' => DI::userSession()->getLocalUserId()]);
}
protected function content(array $request = []): string
{
parent::content();
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$user = User::getById($user_id, ['nickname']);
if (DBA::isResult($user)) {
$condition = [
- 'uid' => Session::getLocalUser(),
+ 'uid' => DI::userSession()->getLocalUserId(),
'nurl' => Strings::normaliseLink(DI::baseUrl() . '/profile/' . $user['nickname'])
];
if (DBA::exists('contact', $condition)) {
- DBA::insert('manage', ['uid' => $user_id, 'mid' => Session::getLocalUser()]);
+ DBA::insert('manage', ['uid' => $user_id, 'mid' => DI::userSession()->getLocalUserId()]);
}
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('Delegate user not found.'));
DI::baseUrl()->redirect('settings/delegation');
}
- DBA::delete('manage', ['uid' => $user_id, 'mid' => Session::getLocalUser()]);
+ DBA::delete('manage', ['uid' => $user_id, 'mid' => DI::userSession()->getLocalUserId()]);
DI::baseUrl()->redirect('settings/delegation');
}
// find everybody that currently has delegated management to this account/page
- $delegates = DBA::selectToArray('user', [], ['`uid` IN (SELECT `uid` FROM `manage` WHERE `mid` = ?)', Session::getLocalUser()]);
+ $delegates = DBA::selectToArray('user', [], ['`uid` IN (SELECT `uid` FROM `manage` WHERE `mid` = ?)', DI::userSession()->getLocalUserId()]);
$uids = [];
foreach ($delegates as $user) {
$potentials = [];
$nicknames = [];
- $condition = ['baseurl' => DI::baseUrl(), 'self' => false, 'uid' => Session::getLocalUser(), 'blocked' => false];
+ $condition = ['baseurl' => DI::baseUrl(), 'self' => false, 'uid' => DI::userSession()->getLocalUserId(), 'blocked' => false];
$contacts = DBA::select('contact', ['nick'], $condition);
while ($contact = DBA::fetch($contacts)) {
$nicknames[] = $contact['nick'];
$parent_user = null;
$parent_password = null;
- $user = User::getById(Session::getLocalUser(), ['parent-uid', 'email']);
- if (DBA::isResult($user) && !DBA::exists('user', ['parent-uid' => Session::getLocalUser()])) {
+ $user = User::getById(DI::userSession()->getLocalUserId(), ['parent-uid', 'email']);
+ if (DBA::isResult($user) && !DBA::exists('user', ['parent-uid' => DI::userSession()->getLocalUserId()])) {
$parent_uid = $user['parent-uid'];
$parents = [0 => DI::l10n()->t('No parent user')];
$condition = ['email' => $user['email'], 'verified' => true, 'blocked' => false, 'parent-uid' => 0];
$parent_users = DBA::selectToArray('user', $fields, $condition);
foreach($parent_users as $parent) {
- if ($parent['uid'] != Session::getLocalUser()) {
+ if ($parent['uid'] != DI::userSession()->getLocalUserId()) {
$parents[$parent['uid']] = sprintf('%s (%s)', $parent['username'], $parent['nickname']);
}
}
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\Theme;
use Friendica\Database\DBA;
use Friendica\DI;
self::checkFormSecurityTokenRedirectOnError('/settings/display', 'settings_display');
- $user = User::getById(Session::getLocalUser());
+ $user = User::getById(DI::userSession()->getLocalUserId());
$theme = !empty($_POST['theme']) ? trim($_POST['theme']) : $user['theme'];
$mobile_theme = !empty($_POST['mobile_theme']) ? trim($_POST['mobile_theme']) : '';
}
if ($mobile_theme !== '') {
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'mobile_theme', $mobile_theme);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'mobile_theme', $mobile_theme);
}
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'itemspage_network' , $itemspage_network);
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'itemspage_mobile_network', $itemspage_mobile_network);
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'update_interval' , $browser_update);
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'no_auto_update' , $no_auto_update);
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'no_smilies' , !$enable_smile);
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'infinite_scroll' , $infinite_scroll);
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'no_smart_threading' , !$enable_smart_threading);
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'hide_dislike' , !$enable_dislike);
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'display_resharer' , $display_resharer);
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'stay_local' , $stay_local);
- DI::pConfig()->set(Session::getLocalUser(), 'system', 'first_day_of_week' , $first_day_of_week);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network' , $itemspage_network);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network', $itemspage_mobile_network);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'update_interval' , $browser_update);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'no_auto_update' , $no_auto_update);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'no_smilies' , !$enable_smile);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll' , $infinite_scroll);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'no_smart_threading' , !$enable_smart_threading);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike' , !$enable_dislike);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'display_resharer' , $display_resharer);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'stay_local' , $stay_local);
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'first_day_of_week' , $first_day_of_week);
if (in_array($theme, Theme::getAllowedList())) {
if ($theme == $user['theme']) {
theme_post(DI::app());
}
} else {
- DBA::update('user', ['theme' => $theme], ['uid' => Session::getLocalUser()]);
+ DBA::update('user', ['theme' => $theme], ['uid' => DI::userSession()->getLocalUserId()]);
}
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('The theme you chose isn\'t available.'));
{
parent::content();
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$default_mobile_theme = 'none';
}
- $user = User::getById(Session::getLocalUser());
+ $user = User::getById(DI::userSession()->getLocalUserId());
$allowed_themes = Theme::getAllowedList();
$theme_selected = $user['theme'] ?: $default_theme;
$mobile_theme_selected = DI::session()->get('mobile-theme', $default_mobile_theme);
- $itemspage_network = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network'));
+ $itemspage_network = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network'));
$itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : DI::config()->get('system', 'itemspage_network'));
- $itemspage_mobile_network = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network'));
+ $itemspage_mobile_network = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network'));
$itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : DI::config()->get('system', 'itemspage_network_mobile'));
- $browser_update = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'update_interval'));
+ $browser_update = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'update_interval'));
if (intval($browser_update) != -1) {
$browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
}
- $no_auto_update = DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_auto_update', 0);
- $enable_smile = !DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_smilies', 0);
- $infinite_scroll = DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll', 0);
- $enable_smart_threading = !DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_smart_threading', 0);
- $enable_dislike = !DI::pConfig()->get(Session::getLocalUser(), 'system', 'hide_dislike', 0);
- $display_resharer = DI::pConfig()->get(Session::getLocalUser(), 'system', 'display_resharer', 0);
- $stay_local = DI::pConfig()->get(Session::getLocalUser(), 'system', 'stay_local', 0);
+ $no_auto_update = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_auto_update', 0);
+ $enable_smile = !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_smilies', 0);
+ $infinite_scroll = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll', 0);
+ $enable_smart_threading = !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_smart_threading', 0);
+ $enable_dislike = !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike', 0);
+ $display_resharer = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'display_resharer', 0);
+ $stay_local = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'stay_local', 0);
- $first_day_of_week = DI::pConfig()->get(Session::getLocalUser(), 'system', 'first_day_of_week', 0);
+ $first_day_of_week = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'first_day_of_week', 0);
$weekdays = [
0 => DI::l10n()->t("Sunday"),
1 => DI::l10n()->t("Monday"),
'$form_security_token' => self::getFormSecurityToken('settings_display'),
'$baseurl' => DI::baseUrl()->get(true),
- '$uid' => Session::getLocalUser(),
+ '$uid' => DI::userSession()->getLocalUserId(),
'$theme' => ['theme', DI::l10n()->t('Display Theme:'), $theme_selected, '', $themes, true],
'$mobile_theme' => ['mobile_theme', DI::l10n()->t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false],
use Friendica\Core\Hook;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\Theme;
use Friendica\Database\DBA;
use Friendica\DI;
{
protected function post(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
- $profile = Profile::getByUID(Session::getLocalUser());
+ $profile = Profile::getByUID(DI::userSession()->getLocalUserId());
if (!DBA::isResult($profile)) {
return;
}
}
$profileFieldsNew = self::getProfileFieldsFromInput(
- Session::getLocalUser(),
+ DI::userSession()->getLocalUserId(),
$_REQUEST['profile_field'],
$_REQUEST['profile_field_order']
);
- DI::profileField()->saveCollectionForUser(Session::getLocalUser(), $profileFieldsNew);
+ DI::profileField()->saveCollectionForUser(DI::userSession()->getLocalUserId(), $profileFieldsNew);
$result = Profile::update(
[
'pub_keywords' => $pub_keywords,
'prv_keywords' => $prv_keywords,
],
- Session::getLocalUser()
+ DI::userSession()->getLocalUserId()
);
if (!$result) {
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
DI::sysmsg()->addNotice(DI::l10n()->t('You must be logged in to use this module'));
return Login::form();
}
$o = '';
- $profile = User::getOwnerDataById(Session::getLocalUser());
+ $profile = User::getOwnerDataById(DI::userSession()->getLocalUserId());
if (!DBA::isResult($profile)) {
throw new HTTPException\NotFoundException();
}
$custom_fields = [];
- $profileFields = DI::profileField()->selectByUserId(Session::getLocalUser());
+ $profileFields = DI::profileField()->selectByUserId(DI::userSession()->getLocalUserId());
foreach ($profileFields as $profileField) {
/** @var ProfileField $profileField */
$defaultPermissions = $profileField->permissionSet->withAllowedContacts(
namespace Friendica\Module\Settings\Profile\Photo;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
{
protected function post(array $request = [])
{
- if (!Session::isAuthenticated()) {
+ if (!DI::userSession()->isAuthenticated()) {
return;
}
$path = 'profile/' . DI::app()->getLoggedInUserNickname();
- $base_image = Photo::selectFirst([], ['resource-id' => $resource_id, 'uid' => Session::getLocalUser(), 'scale' => $scale]);
+ $base_image = Photo::selectFirst([], ['resource-id' => $resource_id, 'uid' => DI::userSession()->getLocalUserId(), 'scale' => $scale]);
if (DBA::isResult($base_image)) {
$Image = Photo::getImageForPhoto($base_image);
if (empty($Image)) {
if ($Image->isValid()) {
// If setting for the default profile, unset the profile photo flag from any other photos I own
- DBA::update('photo', ['profile' => 0], ['uid' => Session::getLocalUser()]);
+ DBA::update('photo', ['profile' => 0], ['uid' => DI::userSession()->getLocalUserId()]);
// Normalizing expected square crop parameters
$selectionW = $selectionH = min($selectionW, $selectionH);
$Image->scaleDown(300);
}
- $condition = ['resource-id' => $resource_id, 'uid' => Session::getLocalUser(), 'contact-id' => 0];
+ $condition = ['resource-id' => $resource_id, 'uid' => DI::userSession()->getLocalUserId(), 'contact-id' => 0];
$r = Photo::store(
$Image,
- Session::getLocalUser(),
+ DI::userSession()->getLocalUserId(),
0,
$resource_id,
$base_image['filename'],
$r = Photo::store(
$Image,
- Session::getLocalUser(),
+ DI::userSession()->getLocalUserId(),
0,
$resource_id,
$base_image['filename'],
$r = Photo::store(
$Image,
- Session::getLocalUser(),
+ DI::userSession()->getLocalUserId(),
0,
$resource_id,
$base_image['filename'],
Photo::update(['profile' => true], array_merge($condition, ['scale' => 6]));
}
- Contact::updateSelfFromUserID(Session::getLocalUser(), true);
+ Contact::updateSelfFromUserID(DI::userSession()->getLocalUserId(), true);
DI::sysmsg()->addInfo(DI::l10n()->t('Shift-reload the page or clear browser cache if the new photo does not display immediately.'));
// Update global directory in background
- Profile::publishUpdate(Session::getLocalUser());
+ Profile::publishUpdate(DI::userSession()->getLocalUserId());
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to process image'));
}
protected function content(array $request = []): string
{
- if (!Session::isAuthenticated()) {
+ if (!DI::userSession()->isAuthenticated()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$resource_id = $this->parameters['guid'];
- $photos = Photo::selectToArray([], ['resource-id' => $resource_id, 'uid' => Session::getLocalUser()], ['order' => ['scale' => false]]);
+ $photos = Photo::selectToArray([], ['resource-id' => $resource_id, 'uid' => DI::userSession()->getLocalUserId()], ['order' => ['scale' => false]]);
if (!DBA::isResult($photos)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('Photo not found.'));
}
// set an already uloaded photo as profile photo
// if photo is in 'Profile Photos', change it in db
if ($photos[0]['photo-type'] == Photo::USER_AVATAR && $havescale) {
- Photo::update(['profile' => false], ['uid' => Session::getLocalUser()]);
+ Photo::update(['profile' => false], ['uid' => DI::userSession()->getLocalUserId()]);
- Photo::update(['profile' => true], ['resource-id' => $resource_id, 'uid' => Session::getLocalUser()]);
+ Photo::update(['profile' => true], ['resource-id' => $resource_id, 'uid' => DI::userSession()->getLocalUserId()]);
- Contact::updateSelfFromUserID(Session::getLocalUser(), true);
+ Contact::updateSelfFromUserID(DI::userSession()->getLocalUserId(), true);
// Update global directory in background
- Profile::publishUpdate(Session::getLocalUser());
+ Profile::publishUpdate(DI::userSession()->getLocalUserId());
DI::sysmsg()->addInfo(DI::l10n()->t('Profile picture successfully updated.'));
namespace Friendica\Module\Settings\Profile\Photo;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Photo;
{
protected function post(array $request = [])
{
- if (!Session::isAuthenticated()) {
+ if (!DI::userSession()->isAuthenticated()) {
return;
}
$filename = '';
- if (!Photo::store($Image, Session::getLocalUser(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 0, Photo::USER_AVATAR)) {
+ if (!Photo::store($Image, DI::userSession()->getLocalUserId(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 0, Photo::USER_AVATAR)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Image upload failed.'));
}
if ($width > 640 || $height > 640) {
$Image->scaleDown(640);
- if (!Photo::store($Image, Session::getLocalUser(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 1, Photo::USER_AVATAR)) {
+ if (!Photo::store($Image, DI::userSession()->getLocalUserId(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 1, Photo::USER_AVATAR)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Image size reduction [%s] failed.', '640'));
}
}
protected function content(array $request = []): string
{
- if (!Session::isAuthenticated()) {
+ if (!DI::userSession()->isAuthenticated()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$newuser = $args->get($args->getArgc() - 1) === 'new';
- $contact = Contact::selectFirst(['avatar'], ['uid' => Session::getLocalUser(), 'self' => true]);
+ $contact = Contact::selectFirst(['avatar'], ['uid' => DI::userSession()->getLocalUserId(), 'self' => true]);
$tpl = Renderer::getMarkupTemplate('settings/profile/photo/index.tpl');
$o = Renderer::replaceMacros($tpl, [
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\Response;
use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
$this->pConfig = $pConfig;
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
- $verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified');
+ $verified = $this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'verified');
if (!$verified) {
$this->baseUrl->redirect('settings/2fa');
protected function post(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
if (empty($description)) {
DI::sysmsg()->addNotice($this->t('App-specific password generation failed: The description is empty.'));
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
- } elseif (AppSpecificPassword::checkDuplicateForUser(Session::getLocalUser(), $description)) {
+ } elseif (AppSpecificPassword::checkDuplicateForUser(DI::userSession()->getLocalUserId(), $description)) {
DI::sysmsg()->addNotice($this->t('App-specific password generation failed: This description already exists.'));
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
} else {
- $this->appSpecificPassword = AppSpecificPassword::generateForUser(Session::getLocalUser(), $_POST['description'] ?? '');
+ $this->appSpecificPassword = AppSpecificPassword::generateForUser(DI::userSession()->getLocalUserId(), $_POST['description'] ?? '');
DI::sysmsg()->addInfo($this->t('New app-specific password generated.'));
}
break;
case 'revoke_all' :
- AppSpecificPassword::deleteAllForUser(Session::getLocalUser());
+ AppSpecificPassword::deleteAllForUser(DI::userSession()->getLocalUserId());
DI::sysmsg()->addInfo($this->t('App-specific passwords successfully revoked.'));
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
break;
if (!empty($_POST['revoke_id'])) {
self::checkFormSecurityTokenRedirectOnError('settings/2fa/app_specific', 'settings_2fa_app_specific');
- if (AppSpecificPassword::deleteForUser(Session::getLocalUser(), $_POST['revoke_id'])) {
+ if (AppSpecificPassword::deleteForUser(DI::userSession()->getLocalUserId(), $_POST['revoke_id'])) {
DI::sysmsg()->addInfo($this->t('App-specific password successfully revoked.'));
}
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return Login::form('settings/2fa/app_specific');
}
parent::content();
- $appSpecificPasswords = AppSpecificPassword::getListForUser(Session::getLocalUser());
+ $appSpecificPasswords = AppSpecificPassword::getListForUser(DI::userSession()->getLocalUserId());
return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/app_specific.tpl'), [
'$form_security_token' => self::getFormSecurityToken('settings_2fa_app_specific'),
namespace Friendica\Module\Settings\TwoFactor;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Network\HTTPException\FoundException;
use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
{
protected function post(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
self::checkFormSecurityTokenRedirectOnError('settings/2fa', 'settings_2fa');
try {
- User::getIdFromPasswordAuthentication(Session::getLocalUser(), $_POST['password'] ?? '');
+ User::getIdFromPasswordAuthentication(DI::userSession()->getLocalUserId(), $_POST['password'] ?? '');
- $has_secret = (bool)DI::pConfig()->get(Session::getLocalUser(), '2fa', 'secret');
- $verified = DI::pConfig()->get(Session::getLocalUser(), '2fa', 'verified');
+ $has_secret = (bool)DI::pConfig()->get(DI::userSession()->getLocalUserId(), '2fa', 'secret');
+ $verified = DI::pConfig()->get(DI::userSession()->getLocalUserId(), '2fa', 'verified');
switch ($_POST['action'] ?? '') {
case 'enable':
if (!$has_secret && !$verified) {
$Google2FA = new Google2FA();
- DI::pConfig()->set(Session::getLocalUser(), '2fa', 'secret', $Google2FA->generateSecretKey(32));
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), '2fa', 'secret', $Google2FA->generateSecretKey(32));
DI::baseUrl()
->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password'));
break;
case 'disable':
if ($has_secret) {
- RecoveryCode::deleteForUser(Session::getLocalUser());
- DI::pConfig()->delete(Session::getLocalUser(), '2fa', 'secret');
- DI::pConfig()->delete(Session::getLocalUser(), '2fa', 'verified');
+ RecoveryCode::deleteForUser(DI::userSession()->getLocalUserId());
+ DI::pConfig()->delete(DI::userSession()->getLocalUserId(), '2fa', 'secret');
+ DI::pConfig()->delete(DI::userSession()->getLocalUserId(), '2fa', 'verified');
DI::session()->remove('2fa');
DI::sysmsg()->addInfo(DI::l10n()->t('Two-factor authentication successfully disabled.'));
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return Login::form('settings/2fa');
}
parent::content();
- $has_secret = (bool) DI::pConfig()->get(Session::getLocalUser(), '2fa', 'secret');
- $verified = DI::pConfig()->get(Session::getLocalUser(), '2fa', 'verified');
+ $has_secret = (bool) DI::pConfig()->get(DI::userSession()->getLocalUserId(), '2fa', 'secret');
+ $verified = DI::pConfig()->get(DI::userSession()->getLocalUserId(), '2fa', 'verified');
return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/index.tpl'), [
'$form_security_token' => self::getFormSecurityToken('settings_2fa'),
'$recovery_codes_title' => DI::l10n()->t('Recovery codes'),
'$recovery_codes_remaining' => DI::l10n()->t('Remaining valid codes'),
- '$recovery_codes_count' => RecoveryCode::countValidForUser(Session::getLocalUser()),
+ '$recovery_codes_count' => RecoveryCode::countValidForUser(DI::userSession()->getLocalUserId()),
'$recovery_codes_message' => DI::l10n()->t('<p>These one-use codes can replace an authenticator app code in case you have lost access to it.</p>'),
'$app_specific_passwords_title' => DI::l10n()->t('App-specific passwords'),
'$app_specific_passwords_remaining' => DI::l10n()->t('Generated app-specific passwords'),
- '$app_specific_passwords_count' => AppSpecificPassword::countForUser(Session::getLocalUser()),
+ '$app_specific_passwords_count' => AppSpecificPassword::countForUser(DI::userSession()->getLocalUserId()),
'$app_specific_passwords_message' => DI::l10n()->t('<p>These randomly generated passwords allow you to authenticate on apps not supporting two-factor authentication.</p>'),
'$action_title' => DI::l10n()->t('Actions'),
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\Response;
use Friendica\Security\TwoFactor\Model\RecoveryCode;
$this->pConfig = $pConfig;
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
- $secret = $this->pConfig->get(Session::getLocalUser(), '2fa', 'secret');
+ $secret = $this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'secret');
if (!$secret) {
$this->baseUrl->redirect('settings/2fa');
protected function post(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
self::checkFormSecurityTokenRedirectOnError('settings/2fa/recovery', 'settings_2fa_recovery');
if ($_POST['action'] == 'regenerate') {
- RecoveryCode::regenerateForUser(Session::getLocalUser());
+ RecoveryCode::regenerateForUser(DI::userSession()->getLocalUserId());
DI::sysmsg()->addInfo($this->t('New recovery codes successfully generated.'));
$this->baseUrl->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password'));
}
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return Login::form('settings/2fa/recovery');
}
parent::content();
- if (!RecoveryCode::countValidForUser(Session::getLocalUser())) {
- RecoveryCode::generateForUser(Session::getLocalUser());
+ if (!RecoveryCode::countValidForUser(DI::userSession()->getLocalUserId())) {
+ RecoveryCode::generateForUser(DI::userSession()->getLocalUserId());
}
- $recoveryCodes = RecoveryCode::getListForUser(Session::getLocalUser());
+ $recoveryCodes = RecoveryCode::getListForUser(DI::userSession()->getLocalUserId());
- $verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified');
+ $verified = $this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'verified');
return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/recovery.tpl'), [
'$form_security_token' => self::getFormSecurityToken('settings_2fa_recovery'),
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\BaseSettings;
use Friendica\Module\Response;
$this->pConfig = $pConfig;
$this->trustedBrowserRepo = $trustedBrowserRepo;
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
- $verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified');
+ $verified = $this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'verified');
if (!$verified) {
$this->baseUrl->redirect('settings/2fa');
protected function post(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
switch ($_POST['action']) {
case 'remove_all':
- $this->trustedBrowserRepo->removeAllForUser(Session::getLocalUser());
+ $this->trustedBrowserRepo->removeAllForUser(DI::userSession()->getLocalUserId());
DI::sysmsg()->addInfo($this->t('Trusted browsers successfully removed.'));
$this->baseUrl->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password'));
break;
if (!empty($_POST['remove_id'])) {
self::checkFormSecurityTokenRedirectOnError('settings/2fa/trusted', 'settings_2fa_trusted');
- if ($this->trustedBrowserRepo->removeForUser(Session::getLocalUser(), $_POST['remove_id'])) {
+ if ($this->trustedBrowserRepo->removeForUser(DI::userSession()->getLocalUserId(), $_POST['remove_id'])) {
DI::sysmsg()->addInfo($this->t('Trusted browser successfully removed.'));
}
{
parent::content();
- $trustedBrowsers = $this->trustedBrowserRepo->selectAllByUid(Session::getLocalUser());
+ $trustedBrowsers = $this->trustedBrowserRepo->selectAllByUid(DI::userSession()->getLocalUserId());
$parser = Parser::create();
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\BaseSettings;
use Friendica\Module\Response;
$this->pConfig = $pConfig;
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
- $secret = $this->pConfig->get(Session::getLocalUser(), '2fa', 'secret');
- $verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified');
+ $secret = $this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'secret');
+ $verified = $this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'verified');
if ($secret && $verified) {
$this->baseUrl->redirect('settings/2fa');
protected function post(array $request = [])
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
$google2fa = new Google2FA();
- $valid = $google2fa->verifyKey($this->pConfig->get(Session::getLocalUser(), '2fa', 'secret'), $_POST['verify_code'] ?? '');
+ $valid = $google2fa->verifyKey($this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'secret'), $_POST['verify_code'] ?? '');
if ($valid) {
- $this->pConfig->set(Session::getLocalUser(), '2fa', 'verified', true);
+ $this->pConfig->set(DI::userSession()->getLocalUserId(), '2fa', 'verified', true);
DI::session()->set('2fa', true);
DI::sysmsg()->addInfo($this->t('Two-factor authentication successfully activated.'));
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return Login::form('settings/2fa/verify');
}
$company = 'Friendica';
$holder = DI::session()->get('my_address');
- $secret = $this->pConfig->get(Session::getLocalUser(), '2fa', 'secret');
+ $secret = $this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'secret');
$otpauthUrl = (new Google2FA())->getQRCodeUrl($company, $holder, $secret);
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
*/
protected function content(array $request = []): string
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
case "backup":
header("Content-type: application/json");
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '.' . $action . '"');
- self::exportAll(Session::getLocalUser());
+ self::exportAll(DI::userSession()->getLocalUserId());
break;
case "account":
header("Content-type: application/json");
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '.' . $action . '"');
- self::exportAccount(Session::getLocalUser());
+ self::exportAccount(DI::userSession()->getLocalUserId());
break;
case "contact":
header("Content-type: application/csv");
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '-contacts.csv' . '"');
- self::exportContactsAsCSV(Session::getLocalUser());
+ self::exportContactsAsCSV(DI::userSession()->getLocalUserId());
break;
}
System::exit();
namespace Friendica\Module\Update;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Module\Conversation\Community as CommunityModule;
$this->parseRequest();
$o = '';
- if (!empty($_GET['force']) || !DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_auto_update')) {
- $o = DI::conversation()->create(self::getItems(), 'community', true, false, 'commented', Session::getLocalUser());
+ if (!empty($_GET['force']) || !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_auto_update')) {
+ $o = DI::conversation()->create(self::getItems(), 'community', true, false, 'commented', DI::userSession()->getLocalUserId());
}
System::htmlUpdateExit($o);
namespace Friendica\Module\Update;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Item;
$ordering = '`commented`';
}
- $o = DI::conversation()->create($items, 'network', $profile_uid, false, $ordering, Session::getLocalUser());
+ $o = DI::conversation()->create($items, 'network', $profile_uid, false, $ordering, DI::userSession()->getLocalUserId());
}
System::htmlUpdateExit($o);
namespace Friendica\Module\Update;
use Friendica\BaseModule;
-use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
// Ensure we've got a profile owner if updating.
$a->setProfileOwner((int)($_GET['p'] ?? 0));
- if (DI::config()->get('system', 'block_public') && !Session::getLocalUser() && !Session::getRemoteContactID($a->getProfileOwner())) {
+ if (DI::config()->get('system', 'block_public') && !DI::userSession()->getLocalUserId() && !DI::userSession()->getRemoteContactID($a->getProfileOwner())) {
throw new ForbiddenException();
}
- $remote_contact = Session::getRemoteContactID($a->getProfileOwner());
- $is_owner = Session::getLocalUser() == $a->getProfileOwner();
- $last_updated_key = "profile:" . $a->getProfileOwner() . ":" . Session::getLocalUser() . ":" . $remote_contact;
+ $remote_contact = DI::userSession()->getRemoteContactID($a->getProfileOwner());
+ $is_owner = DI::userSession()->getLocalUserId() == $a->getProfileOwner();
+ $last_updated_key = "profile:" . $a->getProfileOwner() . ":" . DI::userSession()->getLocalUserId() . ":" . $remote_contact;
if (!$is_owner && !$remote_contact) {
$user = User::getById($a->getProfileOwner(), ['hidewall']);
$o = '';
- if (empty($_GET['force']) && DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_auto_update')) {
+ if (empty($_GET['force']) && DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_auto_update')) {
System::htmlUpdateExit($o);
}
}
if ($is_owner) {
- $unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]);
+ $unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => DI::userSession()->getLocalUserId()]);
if ($unseen) {
- Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]);
+ Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => DI::userSession()->getLocalUserId()]);
}
}