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(DI::baseUrl()->get(true), 'admin_users', 't');
// delete user
User::remove($uid);
{
$cid = $this->parameters['id'];
- $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => local_user()]);
+ $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => Session::getLocalUser()]);
if (empty($contact)) {
throw new BadRequestException($this->t('Contact not found.'));
}
'nurl' => $nurl,
'poll' => $poll,
],
- ['id' => $contact['id'], 'uid' => local_user()]
+ ['id' => $contact['id'], 'uid' => Session::getLocalUser()]
);
if ($photo) {
{
$cid = $this->parameters['id'];
- $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => local_user()]);
+ $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => Session::getLocalUser()]);
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
{
- $app = DI::app();
-
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException();
}
throw new HTTPException\NotFoundException(DI::l10n()->t('Contact not found.'));
}
- $localContactId = Model\Contact::getPublicIdByUserId(local_user());
+ $localContactId = Model\Contact::getPublicIdByUserId(Session::getLocalUser());
DI::page()['aside'] = Widget\VCard::getHTML($contact);
use Friendica\Content\Widget;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
+use Friendica\Core\Session;
use Friendica\Core\Theme;
use Friendica\Model;
use Friendica\Module\Contact;
protected function content(array $request = []): string
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return 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 = Model\Contact::getPublicAndUserContactID(intval($this->parameters['id']), local_user());
+ $data = Model\Contact::getPublicAndUserContactID(intval($this->parameters['id']), Session::getLocalUser());
if (empty($data)) {
throw new NotFoundException($this->t('Contact not found.'));
}
throw new NotFoundException($this->t('Contact not found.'));
}
- $localRelationship = $this->localRelationship->getForUserContact(local_user(), $contact['id']);
+ $localRelationship = $this->localRelationship->getForUserContact(Session::getLocalUser(), $contact['id']);
if ($localRelationship->rel === Model\Contact::SELF) {
$this->baseUrl->redirect('profile/' . $contact['nick']);
}
// Search for contact data
// Look if the local user has got the contact
if (Session::isAuthenticated()) {
- $contact = Contact::getByURLForUser($contact_url, local_user());
+ $contact = Contact::getByURLForUser($contact_url, Session::getLocalUser());
} else {
$contact = Contact::getByURL($contact_url, false);
}
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(local_user());
+ $owner = User::getOwnerDataById(Session::getLocalUser());
// Loop through all introduction notifications.This creates an array with the output html for each
// introduction
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 (local_user()) {
- if (DI::pConfig()->get(local_user(), 'system', 'detailed_notif')) {
- $notifications = $this->notificationRepo->selectDetailedForUser(local_user());
+ if (Session::getLocalUser()) {
+ if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
+ $notifications = $this->notificationRepo->selectDetailedForUser(Session::getLocalUser());
} else {
- $notifications = $this->notificationRepo->selectDigestForUser(local_user());
+ $notifications = $this->notificationRepo->selectDigestForUser(Session::getLocalUser());
}
$condition = [
"`unseen` AND `uid` = ? AND NOT `origin` AND (`vid` != ? OR `vid` IS NULL)",
- local_user(), Verb::getID(Activity::FOLLOW)
+ Session::getLocalUser(), Verb::getID(Activity::FOLLOW)
];
- $items = Post::selectForUser(local_user(), ['wall', 'uid', 'uri-id'], $condition, ['limit' => 1000]);
+ $items = Post::selectForUser(Session::getLocalUser(), ['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(local_user());
+ $intros = $this->introductionRepo->selectForUser(Session::getLocalUser());
$intro_count = $intros->count();
$myurl = DI::baseUrl() . '/profile/' . DI::app()->getLoggedInUserNickname();
- $mail_count = DBA::count('mail', ["`uid` = ? AND NOT `seen` AND `from-url` != ?", local_user(), $myurl]);
+ $mail_count = DBA::count('mail', ["`uid` = ? AND NOT `seen` AND `from-url` != ?", Session::getLocalUser(), $myurl]);
if (intval(DI::config()->get('config', 'register_policy')) === Register::APPROVE && DI::app()->isSiteAdmin()) {
$regs = \Friendica\Model\Register::getPending();
}
}
- $cachekey = 'ping:events:' . local_user();
+ $cachekey = 'ping:events:' . Session::getLocalUser();
$ev = DI::cache()->get($cachekey);
if (is_null($ev)) {
$ev = DBA::selectToArray('event', ['type', 'start'],
["`uid` = ? AND `start` < ? AND `finish` > ? AND NOT `ignore`",
- local_user(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utcNow()]);
+ Session::getLocalUser(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utcNow()]);
if (DBA::isResult($ev)) {
DI::cache()->set($cachekey, $ev, Duration::HOUR);
}
}
}
- $owner = User::getOwnerDataById(local_user());
+ $owner = User::getOwnerDataById(Session::getLocalUser());
$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(local_user(), 'system', 'detailed_notif')) {
+ if (count($regs) <= 1 || DI::pConfig()->get(Session::getLocalUser(), '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 = local_user();
+ $uid = Session::getLocalUser();
if (empty($uid)) {
Logger::info('Redirect to login');
DI::app()->redirect('login?return_path=' . urlencode($redirect));
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
- $displayCommonTab = Session::isAuthenticated() && $profile['uid'] != local_user();
+ $displayCommonTab = Session::isAuthenticated() && $profile['uid'] != Session::getLocalUser();
if (!$displayCommonTab) {
$a->redirect('profile/' . $nickname . '/contacts');
DI::sysmsg()->addInfo(DI::l10n()->t('Delegation successfully revoked.'));
}
- DBA::update('user', ['parent-uid' => $parent_uid], ['uid' => local_user()]);
+ DBA::update('user', ['parent-uid' => $parent_uid], ['uid' => Session::getLocalUser()]);
}
protected function content(array $request = []): string
{
parent::content();
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$user = User::getById($user_id, ['nickname']);
if (DBA::isResult($user)) {
$condition = [
- 'uid' => local_user(),
+ 'uid' => Session::getLocalUser(),
'nurl' => Strings::normaliseLink(DI::baseUrl() . '/profile/' . $user['nickname'])
];
if (DBA::exists('contact', $condition)) {
- DBA::insert('manage', ['uid' => $user_id, 'mid' => local_user()]);
+ DBA::insert('manage', ['uid' => $user_id, 'mid' => Session::getLocalUser()]);
}
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('Delegate user not found.'));
DI::baseUrl()->redirect('settings/delegation');
}
- DBA::delete('manage', ['uid' => $user_id, 'mid' => local_user()]);
+ DBA::delete('manage', ['uid' => $user_id, 'mid' => Session::getLocalUser()]);
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` = ?)', local_user()]);
+ $delegates = DBA::selectToArray('user', [], ['`uid` IN (SELECT `uid` FROM `manage` WHERE `mid` = ?)', Session::getLocalUser()]);
$uids = [];
foreach ($delegates as $user) {
$potentials = [];
$nicknames = [];
- $condition = ['baseurl' => DI::baseUrl(), 'self' => false, 'uid' => local_user(), 'blocked' => false];
+ $condition = ['baseurl' => DI::baseUrl(), 'self' => false, 'uid' => Session::getLocalUser(), '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(local_user(), ['parent-uid', 'email']);
- if (DBA::isResult($user) && !DBA::exists('user', ['parent-uid' => local_user()])) {
+ $user = User::getById(Session::getLocalUser(), ['parent-uid', 'email']);
+ if (DBA::isResult($user) && !DBA::exists('user', ['parent-uid' => Session::getLocalUser()])) {
$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'] != local_user()) {
+ if ($parent['uid'] != Session::getLocalUser()) {
$parents[$parent['uid']] = sprintf('%s (%s)', $parent['username'], $parent['nickname']);
}
}
self::checkFormSecurityTokenRedirectOnError('/settings/display', 'settings_display');
- $user = User::getById(local_user());
+ $user = User::getById(Session::getLocalUser());
$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(local_user(), 'system', 'mobile_theme', $mobile_theme);
+ DI::pConfig()->set(Session::getLocalUser(), 'system', 'mobile_theme', $mobile_theme);
}
- DI::pConfig()->set(local_user(), 'system', 'itemspage_network' , $itemspage_network);
- DI::pConfig()->set(local_user(), 'system', 'itemspage_mobile_network', $itemspage_mobile_network);
- DI::pConfig()->set(local_user(), 'system', 'update_interval' , $browser_update);
- DI::pConfig()->set(local_user(), 'system', 'no_auto_update' , $no_auto_update);
- DI::pConfig()->set(local_user(), 'system', 'no_smilies' , !$enable_smile);
- DI::pConfig()->set(local_user(), 'system', 'infinite_scroll' , $infinite_scroll);
- DI::pConfig()->set(local_user(), 'system', 'no_smart_threading' , !$enable_smart_threading);
- DI::pConfig()->set(local_user(), 'system', 'hide_dislike' , !$enable_dislike);
- DI::pConfig()->set(local_user(), 'system', 'display_resharer' , $display_resharer);
- DI::pConfig()->set(local_user(), 'system', 'stay_local' , $stay_local);
- DI::pConfig()->set(local_user(), 'system', 'first_day_of_week' , $first_day_of_week);
+ 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);
if (in_array($theme, Theme::getAllowedList())) {
if ($theme == $user['theme']) {
theme_post(DI::app());
}
} else {
- DBA::update('user', ['theme' => $theme], ['uid' => local_user()]);
+ DBA::update('user', ['theme' => $theme], ['uid' => Session::getLocalUser()]);
}
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('The theme you chose isn\'t available.'));
{
parent::content();
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$default_mobile_theme = 'none';
}
- $user = User::getById(local_user());
+ $user = User::getById(Session::getLocalUser());
$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(local_user(), 'system', 'itemspage_network'));
+ $itemspage_network = intval(DI::pConfig()->get(Session::getLocalUser(), '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(local_user(), 'system', 'itemspage_mobile_network'));
+ $itemspage_mobile_network = intval(DI::pConfig()->get(Session::getLocalUser(), '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(local_user(), 'system', 'update_interval'));
+ $browser_update = intval(DI::pConfig()->get(Session::getLocalUser(), '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(local_user(), 'system', 'no_auto_update', 0);
- $enable_smile = !DI::pConfig()->get(local_user(), 'system', 'no_smilies', 0);
- $infinite_scroll = DI::pConfig()->get(local_user(), 'system', 'infinite_scroll', 0);
- $enable_smart_threading = !DI::pConfig()->get(local_user(), 'system', 'no_smart_threading', 0);
- $enable_dislike = !DI::pConfig()->get(local_user(), 'system', 'hide_dislike', 0);
- $display_resharer = DI::pConfig()->get(local_user(), 'system', 'display_resharer', 0);
- $stay_local = DI::pConfig()->get(local_user(), 'system', 'stay_local', 0);
+ $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);
- $first_day_of_week = DI::pConfig()->get(local_user(), 'system', 'first_day_of_week', 0);
+ $first_day_of_week = DI::pConfig()->get(Session::getLocalUser(), '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' => local_user(),
+ '$uid' => Session::getLocalUser(),
'$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 (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
- $profile = Profile::getByUID(local_user());
+ $profile = Profile::getByUID(Session::getLocalUser());
if (!DBA::isResult($profile)) {
return;
}
}
$profileFieldsNew = self::getProfileFieldsFromInput(
- local_user(),
+ Session::getLocalUser(),
$_REQUEST['profile_field'],
$_REQUEST['profile_field_order']
);
- DI::profileField()->saveCollectionForUser(local_user(), $profileFieldsNew);
+ DI::profileField()->saveCollectionForUser(Session::getLocalUser(), $profileFieldsNew);
$result = Profile::update(
[
'pub_keywords' => $pub_keywords,
'prv_keywords' => $prv_keywords,
],
- local_user()
+ Session::getLocalUser()
);
if (!$result) {
protected function content(array $request = []): string
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice(DI::l10n()->t('You must be logged in to use this module'));
return Login::form();
}
$o = '';
- $profile = User::getOwnerDataById(local_user());
+ $profile = User::getOwnerDataById(Session::getLocalUser());
if (!DBA::isResult($profile)) {
throw new HTTPException\NotFoundException();
}
$custom_fields = [];
- $profileFields = DI::profileField()->selectByUserId(local_user());
+ $profileFields = DI::profileField()->selectByUserId(Session::getLocalUser());
foreach ($profileFields as $profileField) {
/** @var ProfileField $profileField */
$defaultPermissions = $profileField->permissionSet->withAllowedContacts(
$path = 'profile/' . DI::app()->getLoggedInUserNickname();
- $base_image = Photo::selectFirst([], ['resource-id' => $resource_id, 'uid' => local_user(), 'scale' => $scale]);
+ $base_image = Photo::selectFirst([], ['resource-id' => $resource_id, 'uid' => Session::getLocalUser(), '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' => local_user()]);
+ DBA::update('photo', ['profile' => 0], ['uid' => Session::getLocalUser()]);
// Normalizing expected square crop parameters
$selectionW = $selectionH = min($selectionW, $selectionH);
$Image->scaleDown(300);
}
- $condition = ['resource-id' => $resource_id, 'uid' => local_user(), 'contact-id' => 0];
+ $condition = ['resource-id' => $resource_id, 'uid' => Session::getLocalUser(), 'contact-id' => 0];
$r = Photo::store(
$Image,
- local_user(),
+ Session::getLocalUser(),
0,
$resource_id,
$base_image['filename'],
$r = Photo::store(
$Image,
- local_user(),
+ Session::getLocalUser(),
0,
$resource_id,
$base_image['filename'],
$r = Photo::store(
$Image,
- local_user(),
+ Session::getLocalUser(),
0,
$resource_id,
$base_image['filename'],
Photo::update(['profile' => true], array_merge($condition, ['scale' => 6]));
}
- Contact::updateSelfFromUserID(local_user(), true);
+ Contact::updateSelfFromUserID(Session::getLocalUser(), 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(local_user());
+ Profile::publishUpdate(Session::getLocalUser());
} else {
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to process image'));
}
$resource_id = $this->parameters['guid'];
- $photos = Photo::selectToArray([], ['resource-id' => $resource_id, 'uid' => local_user()], ['order' => ['scale' => false]]);
+ $photos = Photo::selectToArray([], ['resource-id' => $resource_id, 'uid' => Session::getLocalUser()], ['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' => local_user()]);
+ Photo::update(['profile' => false], ['uid' => Session::getLocalUser()]);
- Photo::update(['profile' => true], ['resource-id' => $resource_id, 'uid' => local_user()]);
+ Photo::update(['profile' => true], ['resource-id' => $resource_id, 'uid' => Session::getLocalUser()]);
- Contact::updateSelfFromUserID(local_user(), true);
+ Contact::updateSelfFromUserID(Session::getLocalUser(), true);
// Update global directory in background
- Profile::publishUpdate(local_user());
+ Profile::publishUpdate(Session::getLocalUser());
DI::sysmsg()->addInfo(DI::l10n()->t('Profile picture successfully updated.'));
$filename = '';
- if (!Photo::store($Image, local_user(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 0, Photo::USER_AVATAR)) {
+ if (!Photo::store($Image, Session::getLocalUser(), 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, local_user(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 1, Photo::USER_AVATAR)) {
+ if (!Photo::store($Image, Session::getLocalUser(), 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'));
}
}
$newuser = $args->get($args->getArgc() - 1) === 'new';
- $contact = Contact::selectFirst(['avatar'], ['uid' => local_user(), 'self' => true]);
+ $contact = Contact::selectFirst(['avatar'], ['uid' => Session::getLocalUser(), '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 (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
- $verified = $this->pConfig->get(local_user(), '2fa', 'verified');
+ $verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified');
if (!$verified) {
$this->baseUrl->redirect('settings/2fa');
protected function post(array $request = [])
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
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(local_user(), $description)) {
+ } elseif (AppSpecificPassword::checkDuplicateForUser(Session::getLocalUser(), $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(local_user(), $_POST['description'] ?? '');
+ $this->appSpecificPassword = AppSpecificPassword::generateForUser(Session::getLocalUser(), $_POST['description'] ?? '');
DI::sysmsg()->addInfo($this->t('New app-specific password generated.'));
}
break;
case 'revoke_all' :
- AppSpecificPassword::deleteAllForUser(local_user());
+ AppSpecificPassword::deleteAllForUser(Session::getLocalUser());
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(local_user(), $_POST['revoke_id'])) {
+ if (AppSpecificPassword::deleteForUser(Session::getLocalUser(), $_POST['revoke_id'])) {
DI::sysmsg()->addInfo($this->t('App-specific password successfully revoked.'));
}
protected function content(array $request = []): string
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return Login::form('settings/2fa/app_specific');
}
parent::content();
- $appSpecificPasswords = AppSpecificPassword::getListForUser(local_user());
+ $appSpecificPasswords = AppSpecificPassword::getListForUser(Session::getLocalUser());
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 (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
self::checkFormSecurityTokenRedirectOnError('settings/2fa', 'settings_2fa');
try {
- User::getIdFromPasswordAuthentication(local_user(), $_POST['password'] ?? '');
+ User::getIdFromPasswordAuthentication(Session::getLocalUser(), $_POST['password'] ?? '');
- $has_secret = (bool)DI::pConfig()->get(local_user(), '2fa', 'secret');
- $verified = DI::pConfig()->get(local_user(), '2fa', 'verified');
+ $has_secret = (bool)DI::pConfig()->get(Session::getLocalUser(), '2fa', 'secret');
+ $verified = DI::pConfig()->get(Session::getLocalUser(), '2fa', 'verified');
switch ($_POST['action'] ?? '') {
case 'enable':
if (!$has_secret && !$verified) {
$Google2FA = new Google2FA();
- DI::pConfig()->set(local_user(), '2fa', 'secret', $Google2FA->generateSecretKey(32));
+ DI::pConfig()->set(Session::getLocalUser(), '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(local_user());
- DI::pConfig()->delete(local_user(), '2fa', 'secret');
- DI::pConfig()->delete(local_user(), '2fa', 'verified');
+ RecoveryCode::deleteForUser(Session::getLocalUser());
+ DI::pConfig()->delete(Session::getLocalUser(), '2fa', 'secret');
+ DI::pConfig()->delete(Session::getLocalUser(), '2fa', 'verified');
DI::session()->remove('2fa');
DI::sysmsg()->addInfo(DI::l10n()->t('Two-factor authentication successfully disabled.'));
protected function content(array $request = []): string
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return Login::form('settings/2fa');
}
parent::content();
- $has_secret = (bool) DI::pConfig()->get(local_user(), '2fa', 'secret');
- $verified = DI::pConfig()->get(local_user(), '2fa', 'verified');
+ $has_secret = (bool) DI::pConfig()->get(Session::getLocalUser(), '2fa', 'secret');
+ $verified = DI::pConfig()->get(Session::getLocalUser(), '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(local_user()),
+ '$recovery_codes_count' => RecoveryCode::countValidForUser(Session::getLocalUser()),
'$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(local_user()),
+ '$app_specific_passwords_count' => AppSpecificPassword::countForUser(Session::getLocalUser()),
'$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 (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
- $secret = $this->pConfig->get(local_user(), '2fa', 'secret');
+ $secret = $this->pConfig->get(Session::getLocalUser(), '2fa', 'secret');
if (!$secret) {
$this->baseUrl->redirect('settings/2fa');
protected function post(array $request = [])
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
self::checkFormSecurityTokenRedirectOnError('settings/2fa/recovery', 'settings_2fa_recovery');
if ($_POST['action'] == 'regenerate') {
- RecoveryCode::regenerateForUser(local_user());
+ RecoveryCode::regenerateForUser(Session::getLocalUser());
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 (!local_user()) {
+ if (!Session::getLocalUser()) {
return Login::form('settings/2fa/recovery');
}
parent::content();
- if (!RecoveryCode::countValidForUser(local_user())) {
- RecoveryCode::generateForUser(local_user());
+ if (!RecoveryCode::countValidForUser(Session::getLocalUser())) {
+ RecoveryCode::generateForUser(Session::getLocalUser());
}
- $recoveryCodes = RecoveryCode::getListForUser(local_user());
+ $recoveryCodes = RecoveryCode::getListForUser(Session::getLocalUser());
- $verified = $this->pConfig->get(local_user(), '2fa', 'verified');
+ $verified = $this->pConfig->get(Session::getLocalUser(), '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 (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
- $verified = $this->pConfig->get(local_user(), '2fa', 'verified');
+ $verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified');
if (!$verified) {
$this->baseUrl->redirect('settings/2fa');
protected function post(array $request = [])
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
switch ($_POST['action']) {
case 'remove_all':
- $this->trustedBrowserRepo->removeAllForUser(local_user());
+ $this->trustedBrowserRepo->removeAllForUser(Session::getLocalUser());
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(local_user(), $_POST['remove_id'])) {
+ if ($this->trustedBrowserRepo->removeForUser(Session::getLocalUser(), $_POST['remove_id'])) {
DI::sysmsg()->addInfo($this->t('Trusted browser successfully removed.'));
}
{
parent::content();
- $trustedBrowsers = $this->trustedBrowserRepo->selectAllByUid(local_user());
+ $trustedBrowsers = $this->trustedBrowserRepo->selectAllByUid(Session::getLocalUser());
$parser = Parser::create();
$this->pConfig = $pConfig;
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
- $secret = $this->pConfig->get(local_user(), '2fa', 'secret');
- $verified = $this->pConfig->get(local_user(), '2fa', 'verified');
+ $secret = $this->pConfig->get(Session::getLocalUser(), '2fa', 'secret');
+ $verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified');
if ($secret && $verified) {
$this->baseUrl->redirect('settings/2fa');
protected function post(array $request = [])
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
$google2fa = new Google2FA();
- $valid = $google2fa->verifyKey($this->pConfig->get(local_user(), '2fa', 'secret'), $_POST['verify_code'] ?? '');
+ $valid = $google2fa->verifyKey($this->pConfig->get(Session::getLocalUser(), '2fa', 'secret'), $_POST['verify_code'] ?? '');
if ($valid) {
- $this->pConfig->set(local_user(), '2fa', 'verified', true);
+ $this->pConfig->set(Session::getLocalUser(), '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 (!local_user()) {
+ if (!Session::getLocalUser()) {
return Login::form('settings/2fa/verify');
}
$company = 'Friendica';
$holder = DI::session()->get('my_address');
- $secret = $this->pConfig->get(local_user(), '2fa', 'secret');
+ $secret = $this->pConfig->get(Session::getLocalUser(), '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 (!local_user()) {
+ if (!Session::getLocalUser()) {
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(local_user());
+ self::exportAll(Session::getLocalUser());
break;
case "account":
header("Content-type: application/json");
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '.' . $action . '"');
- self::exportAccount(local_user());
+ self::exportAccount(Session::getLocalUser());
break;
case "contact":
header("Content-type: application/csv");
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '-contacts.csv' . '"');
- self::exportContactsAsCSV(local_user());
+ self::exportContactsAsCSV(Session::getLocalUser());
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(local_user(), 'system', 'no_auto_update')) {
- $o = DI::conversation()->create(self::getItems(), 'community', true, false, 'commented', local_user());
+ 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());
}
System::htmlUpdateExit($o);
// Ensure we've got a profile owner if updating.
$a->setProfileOwner((int)($_GET['p'] ?? 0));
- if (DI::config()->get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($a->getProfileOwner())) {
+ if (DI::config()->get('system', 'block_public') && !Session::getLocalUser() && !Session::getRemoteContactID($a->getProfileOwner())) {
throw new ForbiddenException();
}
$remote_contact = Session::getRemoteContactID($a->getProfileOwner());
- $is_owner = local_user() == $a->getProfileOwner();
- $last_updated_key = "profile:" . $a->getProfileOwner() . ":" . local_user() . ":" . $remote_contact;
+ $is_owner = Session::getLocalUser() == $a->getProfileOwner();
+ $last_updated_key = "profile:" . $a->getProfileOwner() . ":" . Session::getLocalUser() . ":" . $remote_contact;
if (!$is_owner && !$remote_contact) {
$user = User::getById($a->getProfileOwner(), ['hidewall']);
$o = '';
- if (empty($_GET['force']) && DI::pConfig()->get(local_user(), 'system', 'no_auto_update')) {
+ if (empty($_GET['force']) && DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_auto_update')) {
System::htmlUpdateExit($o);
}
}
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()]);
}
}