* communications are free and open and flow between alternate providers as
* easily as email does today.
*/
-
-use Friendica\Core\Session;
-
-/**
- * Returns the user id of locally logged in user or false.
- *
- * @return int|bool user id or false
- * @deprecated since version 2022.12, use Core\Session::getLocalUser() instead
- */
-function local_user()
-{
- return Session::getLocalUser();
-}
-
-/**
- * Returns the public contact id of logged in user or false.
- *
- * @return int|bool public contact id or false
- * @deprecated since version 2022.12, use Core\Session:: getPublicContact() instead
- */
-function public_contact()
-{
- return Session::getPublicContact();
-}
-
-/**
- * Returns public contact id of authenticated site visitor or false
- *
- * @return int|bool visitor_id or false
- * @deprecated since version 2022.12, use Core\Session:: getRemoteUser() instead
- */
-function remote_user()
-{
- return Session::getRemoteUser();
-}
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 (local_user() != $uid) {
+ if (Session::getLocalUser() != $uid) {
User::remove($uid);
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
switch ($action) {
case 'delete':
- if (local_user() != $uid) {
+ if (Session::getLocalUser() != $uid) {
self::checkFormSecurityTokenRedirectOnError('admin/users/active', 'admin_users_active', 't');
// delete user
User::remove($uid);
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 (local_user() != $uid) {
+ if (Session::getLocalUser() != $uid) {
User::remove($uid);
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
switch ($action) {
case 'delete':
- if (local_user() != $uid) {
+ if (Session::getLocalUser() != $uid) {
self::checkFormSecurityTokenRedirectOnError('/admin/users/blocked', 'admin_users_blocked', 't');
// delete user
User::remove($uid);
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
- $is_owner = $profile['uid'] == local_user();
+ $is_owner = $profile['uid'] == Session::getLocalUser();
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'] != local_user());
+ $tabs = self::getContactFilterTabs('profile/' . $nickname, $type, Session::isAuthenticated() && $profile['uid'] != Session::getLocalUser());
$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 = local_user() == $profile['uid'];
+ $is_owner = Session::getLocalUser() == $profile['uid'];
$o = self::getTabsHTML($a, 'media', $is_owner, $profile['nickname'], $profile['hide-friends']);
$remote_contact_id = Session::getRemoteContactID($profile['uid']);
- if (DI::config()->get('system', 'block_public') && !local_user() && !$remote_contact_id) {
+ if (DI::config()->get('system', 'block_public') && !Session::getLocalUser() && !$remote_contact_id) {
return Login::form();
}
- $is_owner = local_user() == $profile['uid'];
+ $is_owner = Session::getLocalUser() == $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 = local_user() == $profile['uid'];
+ $is_owner = Session::getLocalUser() == $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' => local_user(),
+ 'uid' => Session::getLocalUser(),
'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'] == local_user(),
+ '$is_owner' => $profile['uid'] == Session::getLocalUser(),
'$query_string' => DI::args()->getQueryString(),
'$basic_fields' => $basic_fields,
'$custom_fields' => $custom_fields,
}
// site block
- $blocked = !local_user() && !$remote_contact_id && DI::config()->get('system', 'block_public');
- $userblock = !local_user() && !$remote_contact_id && $profile['hidewall'];
+ $blocked = !Session::getLocalUser() && !$remote_contact_id && DI::config()->get('system', 'block_public');
+ $userblock = !Session::getLocalUser() && !$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 (!local_user()) {
+ if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
throw new HTTPException\BadRequestException();
}
- if (!DBA::exists('delayed-post', ['id' => $_REQUEST['delete'], 'uid' => local_user()])) {
+ if (!DBA::exists('delayed-post', ['id' => $_REQUEST['delete'], 'uid' => Session::getLocalUser()])) {
throw new HTTPException\NotFoundException();
}
protected function content(array $request = []): string
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
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' => local_user()]);
+ $delayed = DBA::select('delayed-post', [], ['uid' => Session::getLocalUser()]);
while ($row = DBA::fetch($delayed)) {
$parameter = Post\Delayed::getParametersForid($row['id']);
if (empty($parameter)) {
$hashtags = $_GET['tag'] ?? '';
- if (DI::config()->get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($profile['uid'])) {
+ if (DI::config()->get('system', 'block_public') && !Session::getLocalUser() && !Session::getRemoteContactID($profile['uid'])) {
return Login::form();
}
$o = '';
- if ($profile['uid'] == local_user()) {
+ if ($profile['uid'] == Session::getLocalUser()) {
Nav::setSelected('home');
}
$remote_contact = Session::getRemoteContactID($profile['uid']);
- $is_owner = local_user() == $profile['uid'];
- $last_updated_key = "profile:" . $profile['uid'] . ":" . local_user() . ":" . $remote_contact;
+ $is_owner = Session::getLocalUser() == $profile['uid'];
+ $last_updated_key = "profile:" . $profile['uid'] . ":" . Session::getLocalUser() . ":" . $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(local_user(), 'system', 'itemspage_mobile_network',
+ $itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
- $itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
+ $itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
}
if ($is_owner) {
- $unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => local_user()]);
+ $unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]);
if ($unseen) {
- Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
+ Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]);
}
}
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 (!local_user()) {
+ if (!Session::getLocalUser()) {
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`", local_user()];
- $condition_group = ["`uid` = ? AND NOT `deleted`", local_user()];
+ $condition = ["`uid` = ? AND NOT `deleted` AND NOT `pending` AND NOT `archive`", Session::getLocalUser()];
+ $condition_group = ["`uid` = ? AND NOT `deleted`", Session::getLocalUser()];
if ($search != '') {
$sql_extra = "AND `name` LIKE '%%" . DBA::escape($search) . "%%'";
GROUP BY `group`.`name`, `group`.`id`
ORDER BY `group`.`name`
LIMIT ?, ?",
- local_user(),
+ Session::getLocalUser(),
$start,
$count
));
$condition = ["`parent` = ?", $conv_id];
$params = ['order' => ['author-name' => true]];
- $authors = Post::selectForUser(local_user(), ['author-link'], $condition, $params);
+ $authors = Post::selectForUser(Session::getLocalUser(), ['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 (!local_user()) {
+ if (!Session::getLocalUser()) {
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 (!local_user()) {
+ if (!Session::getLocalUser()) {
return Login::form();
}
DI::page()['aside'] .= Widget::fileAs(DI::args()->getCommand(), $_GET['file'] ?? '');
- if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
+ if (DI::pConfig()->get(Session::getLocalUser(), '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(local_user(), 'system', 'itemspage_mobile_network',
+ $itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
- $itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
+ $itemspage_network = DI::pConfig()->get(Session::getLocalUser(), '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' => local_user()];
+ $term_condition = ['type' => Category::FILE, 'uid' => Session::getLocalUser()];
if ($file) {
$term_condition['name'] = $file;
}
if (count($posts) == 0) {
return '';
}
- $item_condition = ['uid' => [0, local_user()], 'uri-id' => $posts];
+ $item_condition = ['uid' => [0, Session::getLocalUser()], 'uri-id' => $posts];
$item_params = ['order' => ['uri-id' => true, 'uid' => true]];
- $items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $item_condition, $item_params));
+ $items = Post::toArray(Post::selectForUser(Session::getLocalUser(), Item::DISPLAY_FIELDLIST, $item_condition, $item_params));
- $o .= DI::conversation()->create($items, 'filed', false, false, '', local_user());
+ $o .= DI::conversation()->create($items, 'filed', false, false, '', Session::getLocalUser());
- if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
+ if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader();
} else {
$o .= $pager->renderMinimal($count);
}
}
- if (local_user()) {
+ if (Session::getLocalUser()) {
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(local_user(), 'system', 'itemspage_mobile_network',
+ $itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
- $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
+ $itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
if ($tag) {
Logger::info('Start tag search.', ['q' => $search]);
- $uriids = Tag::getURIIdListByTag($search, local_user(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
- $count = Tag::countByTag($search, local_user());
+ $uriids = Tag::getURIIdListByTag($search, Session::getLocalUser(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
+ $count = Tag::countByTag($search, Session::getLocalUser());
} else {
Logger::info('Start fulltext search.', ['q' => $search]);
- $uriids = Post\Content::getURIIdListBySearch($search, local_user(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
- $count = Post\Content::countBySearch($search, local_user());
+ $uriids = Post\Content::getURIIdListBySearch($search, Session::getLocalUser(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
+ $count = Post\Content::countBySearch($search, Session::getLocalUser());
}
if (!empty($uriids)) {
- $condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`))", 0, local_user()];
+ $condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`))", 0, Session::getLocalUser()];
$condition = DBA::mergeConditions($condition, ['uri-id' => $uriids]);
$params = ['order' => ['id' => true]];
- $items = Post::toArray(Post::selectForUser(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params));
+ $items = Post::toArray(Post::selectForUser(Session::getLocalUser(), Item::DISPLAY_FIELDLIST, $condition, $params));
}
if (empty($items)) {
return $o;
}
- if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
+ if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
$o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
}
Logger::info('Start Conversation.', ['q' => $search]);
- $o .= DI::conversation()->create($items, 'search', false, false, 'commented', local_user());
+ $o .= DI::conversation()->create($items, 'search', false, false, 'commented', Session::getLocalUser());
- if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
+ if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader();
} else {
$o .= $pager->renderMinimal($count);
$search = $matches[1];
}
- if (local_user()) {
+ if (Session::getLocalUser()) {
// User-specific contact URL/address search
- $contact_id = Contact::getIdForURL($search, local_user());
+ $contact_id = Contact::getIdForURL($search, Session::getLocalUser());
if (!$contact_id) {
// User-specific contact URL/address search and probe
$contact_id = Contact::getIdForURL($search);
$search = Network::convertToIdn($search);
- if (local_user()) {
+ if (Session::getLocalUser()) {
// Post URL search
- $item_id = Item::fetchByLink($search, local_user());
+ $item_id = Item::fetchByLink($search, Session::getLocalUser());
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 (local_user() && $search) {
+ if (Session::getLocalUser() && $search) {
switch ($action) {
case 'add':
- $fields = ['uid' => local_user(), 'term' => $search];
+ $fields = ['uid' => Session::getLocalUser(), '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' => local_user(), 'term' => $search])) {
+ if (!$this->dba->delete('search', ['uid' => Session::getLocalUser(), '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 (local_user()) {
+ if (Session::getLocalUser()) {
$this->baseUrl->redirect($return_path);
}
];
}
- if (local_user()) {
+ if (Session::getLocalUser()) {
$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 (remote_user()) {
+ if (Session::getRemoteUser()) {
$visitor_home = Profile::getMyURL();
$this->cache->delete('zrlInit:' . $visitor_home);
}
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
+use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\Model\User;
use Friendica\Module\Response;
}
// check if the old password was supplied correctly before changing it to the new value
- User::getIdFromPasswordAuthentication(local_user(), $request['password_current']);
+ User::getIdFromPasswordAuthentication(Session::getLocalUser(), $request['password_current']);
if (strlen($request['password_current']) <= 72) {
throw new \Exception($this->l10n->t('Password does not need changing.'));
}
- $result = User::updatePassword(local_user(), $newpass);
+ $result = User::updatePassword(Session::getLocalUser(), $newpass);
if (!DBA::isResult($result)) {
throw new \Exception($this->l10n->t('Password update failed. Please try again.'));
}
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 (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
$recovery_code = $_POST['recovery_code'] ?? '';
- if (RecoveryCode::existsForUser(local_user(), $recovery_code)) {
- RecoveryCode::markUsedForUser(local_user(), $recovery_code);
+ if (RecoveryCode::existsForUser(Session::getLocalUser(), $recovery_code)) {
+ RecoveryCode::markUsedForUser(Session::getLocalUser(), $recovery_code);
$this->session->set('2fa', true);
- DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(local_user())));
+ DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(Session::getLocalUser())));
$this->auth->setForUser($this->app, User::getById($this->app->getLoggedInUserId()), true, true);
protected function content(array $request = []): string
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
$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 (!local_user() || !($this->cookie->get('2fa_cookie_hash'))) {
+ if (!Session::getLocalUser() || !($this->cookie->get('2fa_cookie_hash'))) {
return;
}
$this->baseUrl->redirect();
break;
case 'sign_out':
- $this->trustedBrowserRepository->removeForUser(local_user(), $this->cookie->get('2fa_cookie_hash'));
+ $this->trustedBrowserRepository->removeForUser(Session::getLocalUser(), $this->cookie->get('2fa_cookie_hash'));
$this->cookie->clear();
$this->session->clear();
protected function content(array $request = []): string
{
- if (!local_user() || !($this->cookie->get('2fa_cookie_hash'))) {
+ if (!Session::getLocalUser() || !($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 (!local_user() || !$this->session->get('2fa')) {
+ if (!Session::getLocalUser() || !$this->session->get('2fa')) {
$this->logger->info('Invalid call', ['request' => $request]);
return;
}
switch ($action) {
case 'trust':
case 'dont_trust':
- $trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent(local_user(), $this->server['HTTP_USER_AGENT'], $action === 'trust');
+ $trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent(Session::getLocalUser(), $this->server['HTTP_USER_AGENT'], $action === 'trust');
try {
$this->trustedBrowserRepository->save($trustedBrowser);
protected function content(array $request = []): string
{
- if (!local_user() || !$this->session->get('2fa')) {
+ if (!Session::getLocalUser() || !$this->session->get('2fa')) {
$this->baseUrl->redirect();
}
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Renderer;
+use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Module\Response;
use Friendica\Util\Profiler;
protected function post(array $request = [])
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
$code = $request['verify_code'] ?? '';
- $valid = (new Google2FA())->verifyKey($this->pConfig->get(local_user(), '2fa', 'secret'), $code);
+ $valid = (new Google2FA())->verifyKey($this->pConfig->get(Session::getLocalUser(), '2fa', 'secret'), $code);
// The same code can't be used twice even if it's valid
if ($valid && $this->session->get('2fa') !== $code) {
protected function content(array $request = []): string
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
$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(local_user(), $request['opassword']);
+ User::getIdFromPasswordAuthentication(Session::getLocalUser(), $request['opassword']);
- $result = User::updatePassword(local_user(), $newpass);
+ $result = User::updatePassword(Session::getLocalUser(), $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(local_user(), $request['mpassword']);
+ User::getIdFromPasswordAuthentication(Session::getLocalUser(), $request['mpassword']);
} catch (Exception $ex) {
$err .= DI::l10n()->t('Wrong Password.');
$email = $user['email'];
$fields['openidserver'] = '';
}
- if (!User::update($fields, local_user())) {
+ if (!User::update($fields, Session::getLocalUser())) {
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(local_user(), 'system', 'unlisted', !empty($request['unlisted']));
- DI::pConfig()->set(local_user(), 'system', 'accessible-photos', !empty($request['accessible-photos']));
+ DI::pConfig()->set(Session::getLocalUser(), 'system', 'unlisted', !empty($request['unlisted']));
+ DI::pConfig()->set(Session::getLocalUser(), 'system', 'accessible-photos', !empty($request['accessible-photos']));
$fields = [
'allow_cid' => $str_contact_allow,
'hide-friends' => $hide_friends
];
- if (!User::update($fields, local_user()) || !Profile::update($profile_fields, local_user())) {
+ if (!User::update($fields, Session::getLocalUser()) || !Profile::update($profile_fields, Session::getLocalUser())) {
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(local_user(), 'expire', 'items', $expire_items);
- DI::pConfig()->set(local_user(), 'expire', 'notes', $expire_notes);
- DI::pConfig()->set(local_user(), 'expire', 'starred', $expire_starred);
- DI::pConfig()->set(local_user(), 'expire', 'network_only', $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);
- if (!User::update(['expire' => $expire], local_user())) {
+ if (!User::update(['expire' => $expire], Session::getLocalUser())) {
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(local_user(), 'system', 'notify_type', $notify_type);
+ DI::pConfig()->set(Session::getLocalUser(), '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(local_user(), 'system', 'notify_like') && $notify_like) {
- DI::notification()->setAllSeenForUser(local_user(), ['vid' => Verb::getID(Activity::LIKE)]);
+ if (!DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_like') && $notify_like) {
+ DI::notification()->setAllSeenForUser(Session::getLocalUser(), ['vid' => Verb::getID(Activity::LIKE)]);
}
- DI::pConfig()->set(local_user(), 'system', 'notify_like', $notify_like);
+ DI::pConfig()->set(Session::getLocalUser(), 'system', 'notify_like', $notify_like);
// Reset share notifications when they are going to be shown again
- if (!DI::pConfig()->get(local_user(), 'system', 'notify_announce') && $notify_announce) {
- DI::notification()->setAllSeenForUser(local_user(), ['vid' => Verb::getID(Activity::ANNOUNCE)]);
+ if (!DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_announce') && $notify_announce) {
+ DI::notification()->setAllSeenForUser(Session::getLocalUser(), ['vid' => Verb::getID(Activity::ANNOUNCE)]);
}
- DI::pConfig()->set(local_user(), 'system', 'notify_announce', $notify_announce);
+ DI::pConfig()->set(Session::getLocalUser(), 'system', 'notify_announce', $notify_announce);
- DI::pConfig()->set(local_user(), 'system', 'email_textonly', !empty($request['email_textonly']));
- DI::pConfig()->set(local_user(), 'system', 'detailed_notif', !empty($request['detailed_notif']));
- DI::pConfig()->set(local_user(), 'system', 'notify_ignored', !empty($request['notify_ignored']));
+ 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']));
$fields = [
'notify-flags' => $notify,
];
- if (!User::update($fields, local_user())) {
+ if (!User::update($fields, Session::getLocalUser())) {
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
}
$profile_fields = [];
if ($account_type == User::ACCOUNT_TYPE_COMMUNITY) {
- DI::pConfig()->set(local_user(), 'system', 'unlisted', true);
+ DI::pConfig()->set(Session::getLocalUser(), 'system', 'unlisted', true);
$fields = [
'allow_cid' => '',
'account-type' => $account_type,
]);
- if (!User::update($fields, local_user()) || !empty($profile_fields) && !Profile::update($profile_fields, local_user())) {
+ if (!User::update($fields, Session::getLocalUser()) || !empty($profile_fields) && !Profile::update($profile_fields, Session::getLocalUser())) {
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', local_user(), $csvRow[0]);
+ Worker::add(Worker::PRIORITY_MEDIUM, 'AddContact', Session::getLocalUser(), $csvRow[0]);
} else {
Logger::notice('Invalid account', ['url' => $csvRow[0]]);
}
}
if (!empty($request['relocate-submit'])) {
- Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, local_user());
+ Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, Session::getLocalUser());
DI::sysmsg()->addInfo(DI::l10n()->t("Relocate message has been send to your contacts"));
DI::baseUrl()->redirect($redirectUrl);
}
{
parent::content();
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
- $profile = DBA::selectFirst('profile', [], ['uid' => local_user()]);
+ $profile = DBA::selectFirst('profile', [], ['uid' => Session::getLocalUser()]);
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(local_user(), 'expire', 'items', true);
- $expire_notes = DI::pConfig()->get(local_user(), 'expire', 'notes', true);
- $expire_starred = DI::pConfig()->get(local_user(), 'expire', 'starred', true);
- $expire_network_only = DI::pConfig()->get(local_user(), 'expire', 'network_only', false);
+ $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);
if (!strlen($user['timezone'])) {
$timezone = $a->getTimeZone();
/* Installed langs */
$lang_choices = DI::l10n()->getAvailableLanguages();
- $notify_type = DI::pConfig()->get(local_user(), 'system', 'notify_type');
+ $notify_type = DI::pConfig()->get(Session::getLocalUser(), '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' => local_user(),
+ '$uid' => Session::getLocalUser(),
'$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(local_user(), '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(local_user(), '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(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.")],
'$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(local_user(), $user['def_gid']),
+ '$group_select' => Group::displayGroupSelection(Session::getLocalUser(), $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(local_user(), '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(local_user(), '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(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_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(local_user(), 'system', 'email_textonly'),
+ DI::pConfig()->get(Session::getLocalUser(), '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(local_user(), 'system', 'detailed_notif'),
+ DI::pConfig()->get(Session::getLocalUser(), '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(local_user(), 'system', 'notify_ignored', true),
+ DI::pConfig()->get(Session::getLocalUser(), '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.")
],
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, local_user());
+ $o = DI::conversation()->create($items, 'network', $profile_uid, false, $ordering, Session::getLocalUser());
}
System::htmlUpdateExit($o);