Merge pull request #12027 from annando/no-boot-src-module-3
old boot.php functions replaced in src/module (3)
This commit is contained in:
commit
de6eabde58
|
@ -23,6 +23,7 @@ namespace Friendica\Module\Admin\Users;
|
||||||
|
|
||||||
use Friendica\Content\Pager;
|
use Friendica\Content\Pager;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Core\Session;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
@ -54,7 +55,7 @@ class Index extends BaseUsers
|
||||||
|
|
||||||
if (!empty($_POST['page_users_delete'])) {
|
if (!empty($_POST['page_users_delete'])) {
|
||||||
foreach ($users as $uid) {
|
foreach ($users as $uid) {
|
||||||
if (local_user() != $uid) {
|
if (Session::getLocalUser() != $uid) {
|
||||||
User::remove($uid);
|
User::remove($uid);
|
||||||
} else {
|
} else {
|
||||||
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
|
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
|
||||||
|
@ -85,7 +86,7 @@ class Index extends BaseUsers
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'delete':
|
case 'delete':
|
||||||
if (local_user() != $uid) {
|
if (Session::getLocalUser() != $uid) {
|
||||||
self::checkFormSecurityTokenRedirectOnError(DI::baseUrl()->get(true), 'admin_users', 't');
|
self::checkFormSecurityTokenRedirectOnError(DI::baseUrl()->get(true), 'admin_users', 't');
|
||||||
// delete user
|
// delete user
|
||||||
User::remove($uid);
|
User::remove($uid);
|
||||||
|
|
|
@ -66,7 +66,7 @@ class Advanced extends BaseModule
|
||||||
{
|
{
|
||||||
$cid = $this->parameters['id'];
|
$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)) {
|
if (empty($contact)) {
|
||||||
throw new BadRequestException($this->t('Contact not found.'));
|
throw new BadRequestException($this->t('Contact not found.'));
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ class Advanced extends BaseModule
|
||||||
'nurl' => $nurl,
|
'nurl' => $nurl,
|
||||||
'poll' => $poll,
|
'poll' => $poll,
|
||||||
],
|
],
|
||||||
['id' => $contact['id'], 'uid' => local_user()]
|
['id' => $contact['id'], 'uid' => Session::getLocalUser()]
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($photo) {
|
if ($photo) {
|
||||||
|
@ -105,7 +105,7 @@ class Advanced extends BaseModule
|
||||||
{
|
{
|
||||||
$cid = $this->parameters['id'];
|
$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)) {
|
if (empty($contact)) {
|
||||||
throw new BadRequestException($this->t('Contact not found.'));
|
throw new BadRequestException($this->t('Contact not found.'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\BaseModule;
|
||||||
use Friendica\Content\Pager;
|
use Friendica\Content\Pager;
|
||||||
use Friendica\Content\Widget;
|
use Friendica\Content\Widget;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Core\Session;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model;
|
use Friendica\Model;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
@ -35,9 +36,7 @@ class Contacts extends BaseModule
|
||||||
{
|
{
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
{
|
{
|
||||||
$app = DI::app();
|
if (!Session::getLocalUser()) {
|
||||||
|
|
||||||
if (!local_user()) {
|
|
||||||
throw new HTTPException\ForbiddenException();
|
throw new HTTPException\ForbiddenException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ class Contacts extends BaseModule
|
||||||
throw new HTTPException\NotFoundException(DI::l10n()->t('Contact not found.'));
|
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);
|
DI::page()['aside'] = Widget\VCard::getHTML($contact);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ use Friendica\Content\Nav;
|
||||||
use Friendica\Content\Widget;
|
use Friendica\Content\Widget;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
|
use Friendica\Core\Session;
|
||||||
use Friendica\Core\Theme;
|
use Friendica\Core\Theme;
|
||||||
use Friendica\Model;
|
use Friendica\Model;
|
||||||
use Friendica\Module\Contact;
|
use Friendica\Module\Contact;
|
||||||
|
@ -67,13 +68,13 @@ class Conversations extends BaseModule
|
||||||
|
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
return Login::form($_SERVER['REQUEST_URI']);
|
return Login::form($_SERVER['REQUEST_URI']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backward compatibility: Ensure to use the public contact when the user contact is provided
|
// Backward compatibility: Ensure to use the public contact when the user contact is provided
|
||||||
// Remove by version 2022.03
|
// 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)) {
|
if (empty($data)) {
|
||||||
throw new NotFoundException($this->t('Contact not found.'));
|
throw new NotFoundException($this->t('Contact not found.'));
|
||||||
}
|
}
|
||||||
|
@ -88,7 +89,7 @@ class Conversations extends BaseModule
|
||||||
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) {
|
if ($localRelationship->rel === Model\Contact::SELF) {
|
||||||
$this->baseUrl->redirect('profile/' . $contact['nick']);
|
$this->baseUrl->redirect('profile/' . $contact['nick']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ class Hovercard extends BaseModule
|
||||||
// Search for contact data
|
// Search for contact data
|
||||||
// Look if the local user has got the contact
|
// Look if the local user has got the contact
|
||||||
if (Session::isAuthenticated()) {
|
if (Session::isAuthenticated()) {
|
||||||
$contact = Contact::getByURLForUser($contact_url, local_user());
|
$contact = Contact::getByURLForUser($contact_url, Session::getLocalUser());
|
||||||
} else {
|
} else {
|
||||||
$contact = Contact::getByURL($contact_url, false);
|
$contact = Contact::getByURL($contact_url, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Core\Session;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Module\BaseNotifications;
|
use Friendica\Module\BaseNotifications;
|
||||||
|
@ -98,7 +99,7 @@ class Introductions extends BaseNotifications
|
||||||
'text' => (!$all ? $this->t('Show Ignored Requests') : $this->t('Hide Ignored Requests')),
|
'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
|
// Loop through all introduction notifications.This creates an array with the output html for each
|
||||||
// introduction
|
// introduction
|
||||||
|
|
|
@ -28,6 +28,7 @@ use Friendica\Content\ForumManager;
|
||||||
use Friendica\Core\Cache\Enum\Duration;
|
use Friendica\Core\Cache\Enum\Duration;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Core\Session;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -90,18 +91,18 @@ class Ping extends BaseModule
|
||||||
$today_birthday_count = 0;
|
$today_birthday_count = 0;
|
||||||
|
|
||||||
|
|
||||||
if (local_user()) {
|
if (Session::getLocalUser()) {
|
||||||
if (DI::pConfig()->get(local_user(), 'system', 'detailed_notif')) {
|
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
|
||||||
$notifications = $this->notificationRepo->selectDetailedForUser(local_user());
|
$notifications = $this->notificationRepo->selectDetailedForUser(Session::getLocalUser());
|
||||||
} else {
|
} else {
|
||||||
$notifications = $this->notificationRepo->selectDigestForUser(local_user());
|
$notifications = $this->notificationRepo->selectDigestForUser(Session::getLocalUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition = [
|
$condition = [
|
||||||
"`unseen` AND `uid` = ? AND NOT `origin` AND (`vid` != ? OR `vid` IS NULL)",
|
"`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)) {
|
if (DBA::isResult($items)) {
|
||||||
$items_unseen = Post::toArray($items, false);
|
$items_unseen = Post::toArray($items, false);
|
||||||
$arr = ['items' => $items_unseen];
|
$arr = ['items' => $items_unseen];
|
||||||
|
@ -139,12 +140,12 @@ class Ping extends BaseModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$intros = $this->introductionRepo->selectForUser(local_user());
|
$intros = $this->introductionRepo->selectForUser(Session::getLocalUser());
|
||||||
|
|
||||||
$intro_count = $intros->count();
|
$intro_count = $intros->count();
|
||||||
|
|
||||||
$myurl = DI::baseUrl() . '/profile/' . DI::app()->getLoggedInUserNickname();
|
$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()) {
|
if (intval(DI::config()->get('config', 'register_policy')) === Register::APPROVE && DI::app()->isSiteAdmin()) {
|
||||||
$regs = \Friendica\Model\Register::getPending();
|
$regs = \Friendica\Model\Register::getPending();
|
||||||
|
@ -154,16 +155,14 @@ class Ping extends BaseModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$cachekey = 'ping:events:' . local_user();
|
$cachekey = 'ping:events:' . Session::getLocalUser();
|
||||||
$ev = DI::cache()->get($cachekey);
|
$ev = DI::cache()->get($cachekey);
|
||||||
if (is_null($ev)) {
|
if (is_null($ev)) {
|
||||||
$ev = DBA::selectToArray('event', ['type', 'start'],
|
$ev = DBA::selectToArray('event', ['type', 'start'],
|
||||||
["`uid` = ? AND `start` < ? AND `finish` > ? AND NOT `ignore`",
|
["`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);
|
DI::cache()->set($cachekey, $ev, Duration::HOUR);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (DBA::isResult($ev)) {
|
if (DBA::isResult($ev)) {
|
||||||
$all_events = count($ev);
|
$all_events = count($ev);
|
||||||
|
@ -189,7 +188,7 @@ class Ping extends BaseModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$owner = User::getOwnerDataById(local_user());
|
$owner = User::getOwnerDataById(Session::getLocalUser());
|
||||||
|
|
||||||
$navNotifications = array_map(function (Entity\Notification $notification) use ($owner) {
|
$navNotifications = array_map(function (Entity\Notification $notification) use ($owner) {
|
||||||
if (!DI::notify()->NotifyOnDesktop($notification)) {
|
if (!DI::notify()->NotifyOnDesktop($notification)) {
|
||||||
|
@ -216,7 +215,7 @@ class Ping extends BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DBA::isResult($regs)) {
|
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) {
|
foreach ($regs as $reg) {
|
||||||
$navNotifications[] = $this->formattedNavNotification->createFromParams(
|
$navNotifications[] = $this->formattedNavNotification->createFromParams(
|
||||||
[
|
[
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
namespace Friendica\Module\OAuth;
|
namespace Friendica\Module\OAuth;
|
||||||
|
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
|
use Friendica\Core\Session;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Module\BaseApi;
|
use Friendica\Module\BaseApi;
|
||||||
use Friendica\Security\OAuth;
|
use Friendica\Security\OAuth;
|
||||||
|
@ -70,7 +71,7 @@ class Authorize extends BaseApi
|
||||||
unset($redirect_request['pagename']);
|
unset($redirect_request['pagename']);
|
||||||
$redirect = 'oauth/authorize?' . http_build_query($redirect_request);
|
$redirect = 'oauth/authorize?' . http_build_query($redirect_request);
|
||||||
|
|
||||||
$uid = local_user();
|
$uid = Session::getLocalUser();
|
||||||
if (empty($uid)) {
|
if (empty($uid)) {
|
||||||
Logger::info('Redirect to login');
|
Logger::info('Redirect to login');
|
||||||
DI::app()->redirect('login?return_path=' . urlencode($redirect));
|
DI::app()->redirect('login?return_path=' . urlencode($redirect));
|
||||||
|
|
|
@ -56,7 +56,7 @@ class Common extends BaseProfile
|
||||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
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) {
|
if (!$displayCommonTab) {
|
||||||
$a->redirect('profile/' . $nickname . '/contacts');
|
$a->redirect('profile/' . $nickname . '/contacts');
|
||||||
|
|
|
@ -59,14 +59,14 @@ class Delegation extends BaseSettings
|
||||||
DI::sysmsg()->addInfo(DI::l10n()->t('Delegation successfully revoked.'));
|
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
|
protected function content(array $request = []): string
|
||||||
{
|
{
|
||||||
parent::content();
|
parent::content();
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,11 +85,11 @@ class Delegation extends BaseSettings
|
||||||
$user = User::getById($user_id, ['nickname']);
|
$user = User::getById($user_id, ['nickname']);
|
||||||
if (DBA::isResult($user)) {
|
if (DBA::isResult($user)) {
|
||||||
$condition = [
|
$condition = [
|
||||||
'uid' => local_user(),
|
'uid' => Session::getLocalUser(),
|
||||||
'nurl' => Strings::normaliseLink(DI::baseUrl() . '/profile/' . $user['nickname'])
|
'nurl' => Strings::normaliseLink(DI::baseUrl() . '/profile/' . $user['nickname'])
|
||||||
];
|
];
|
||||||
if (DBA::exists('contact', $condition)) {
|
if (DBA::exists('contact', $condition)) {
|
||||||
DBA::insert('manage', ['uid' => $user_id, 'mid' => local_user()]);
|
DBA::insert('manage', ['uid' => $user_id, 'mid' => Session::getLocalUser()]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DI::sysmsg()->addNotice(DI::l10n()->t('Delegate user not found.'));
|
DI::sysmsg()->addNotice(DI::l10n()->t('Delegate user not found.'));
|
||||||
|
@ -104,12 +104,12 @@ class Delegation extends BaseSettings
|
||||||
DI::baseUrl()->redirect('settings/delegation');
|
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');
|
DI::baseUrl()->redirect('settings/delegation');
|
||||||
}
|
}
|
||||||
|
|
||||||
// find everybody that currently has delegated management to this account/page
|
// 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 = [];
|
$uids = [];
|
||||||
foreach ($delegates as $user) {
|
foreach ($delegates as $user) {
|
||||||
|
@ -120,7 +120,7 @@ class Delegation extends BaseSettings
|
||||||
$potentials = [];
|
$potentials = [];
|
||||||
$nicknames = [];
|
$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);
|
$contacts = DBA::select('contact', ['nick'], $condition);
|
||||||
while ($contact = DBA::fetch($contacts)) {
|
while ($contact = DBA::fetch($contacts)) {
|
||||||
$nicknames[] = $contact['nick'];
|
$nicknames[] = $contact['nick'];
|
||||||
|
@ -137,8 +137,8 @@ class Delegation extends BaseSettings
|
||||||
|
|
||||||
$parent_user = null;
|
$parent_user = null;
|
||||||
$parent_password = null;
|
$parent_password = null;
|
||||||
$user = User::getById(local_user(), ['parent-uid', 'email']);
|
$user = User::getById(Session::getLocalUser(), ['parent-uid', 'email']);
|
||||||
if (DBA::isResult($user) && !DBA::exists('user', ['parent-uid' => local_user()])) {
|
if (DBA::isResult($user) && !DBA::exists('user', ['parent-uid' => Session::getLocalUser()])) {
|
||||||
$parent_uid = $user['parent-uid'];
|
$parent_uid = $user['parent-uid'];
|
||||||
$parents = [0 => DI::l10n()->t('No parent user')];
|
$parents = [0 => DI::l10n()->t('No parent user')];
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ class Delegation extends BaseSettings
|
||||||
$condition = ['email' => $user['email'], 'verified' => true, 'blocked' => false, 'parent-uid' => 0];
|
$condition = ['email' => $user['email'], 'verified' => true, 'blocked' => false, 'parent-uid' => 0];
|
||||||
$parent_users = DBA::selectToArray('user', $fields, $condition);
|
$parent_users = DBA::selectToArray('user', $fields, $condition);
|
||||||
foreach($parent_users as $parent) {
|
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']);
|
$parents[$parent['uid']] = sprintf('%s (%s)', $parent['username'], $parent['nickname']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Display extends BaseSettings
|
||||||
|
|
||||||
self::checkFormSecurityTokenRedirectOnError('/settings/display', 'settings_display');
|
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'];
|
$theme = !empty($_POST['theme']) ? trim($_POST['theme']) : $user['theme'];
|
||||||
$mobile_theme = !empty($_POST['mobile_theme']) ? trim($_POST['mobile_theme']) : '';
|
$mobile_theme = !empty($_POST['mobile_theme']) ? trim($_POST['mobile_theme']) : '';
|
||||||
|
@ -78,20 +78,20 @@ class Display extends BaseSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($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(Session::getLocalUser(), 'system', 'itemspage_network' , $itemspage_network);
|
||||||
DI::pConfig()->set(local_user(), 'system', 'itemspage_mobile_network', $itemspage_mobile_network);
|
DI::pConfig()->set(Session::getLocalUser(), 'system', 'itemspage_mobile_network', $itemspage_mobile_network);
|
||||||
DI::pConfig()->set(local_user(), 'system', 'update_interval' , $browser_update);
|
DI::pConfig()->set(Session::getLocalUser(), 'system', 'update_interval' , $browser_update);
|
||||||
DI::pConfig()->set(local_user(), 'system', 'no_auto_update' , $no_auto_update);
|
DI::pConfig()->set(Session::getLocalUser(), 'system', 'no_auto_update' , $no_auto_update);
|
||||||
DI::pConfig()->set(local_user(), 'system', 'no_smilies' , !$enable_smile);
|
DI::pConfig()->set(Session::getLocalUser(), 'system', 'no_smilies' , !$enable_smile);
|
||||||
DI::pConfig()->set(local_user(), 'system', 'infinite_scroll' , $infinite_scroll);
|
DI::pConfig()->set(Session::getLocalUser(), 'system', 'infinite_scroll' , $infinite_scroll);
|
||||||
DI::pConfig()->set(local_user(), 'system', 'no_smart_threading' , !$enable_smart_threading);
|
DI::pConfig()->set(Session::getLocalUser(), 'system', 'no_smart_threading' , !$enable_smart_threading);
|
||||||
DI::pConfig()->set(local_user(), 'system', 'hide_dislike' , !$enable_dislike);
|
DI::pConfig()->set(Session::getLocalUser(), 'system', 'hide_dislike' , !$enable_dislike);
|
||||||
DI::pConfig()->set(local_user(), 'system', 'display_resharer' , $display_resharer);
|
DI::pConfig()->set(Session::getLocalUser(), 'system', 'display_resharer' , $display_resharer);
|
||||||
DI::pConfig()->set(local_user(), 'system', 'stay_local' , $stay_local);
|
DI::pConfig()->set(Session::getLocalUser(), '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', 'first_day_of_week' , $first_day_of_week);
|
||||||
|
|
||||||
if (in_array($theme, Theme::getAllowedList())) {
|
if (in_array($theme, Theme::getAllowedList())) {
|
||||||
if ($theme == $user['theme']) {
|
if ($theme == $user['theme']) {
|
||||||
|
@ -101,7 +101,7 @@ class Display extends BaseSettings
|
||||||
theme_post(DI::app());
|
theme_post(DI::app());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DBA::update('user', ['theme' => $theme], ['uid' => local_user()]);
|
DBA::update('user', ['theme' => $theme], ['uid' => Session::getLocalUser()]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DI::sysmsg()->addNotice(DI::l10n()->t('The theme you chose isn\'t available.'));
|
DI::sysmsg()->addNotice(DI::l10n()->t('The theme you chose isn\'t available.'));
|
||||||
|
@ -116,7 +116,7 @@ class Display extends BaseSettings
|
||||||
{
|
{
|
||||||
parent::content();
|
parent::content();
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ class Display extends BaseSettings
|
||||||
$default_mobile_theme = 'none';
|
$default_mobile_theme = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::getById(local_user());
|
$user = User::getById(Session::getLocalUser());
|
||||||
|
|
||||||
$allowed_themes = Theme::getAllowedList();
|
$allowed_themes = Theme::getAllowedList();
|
||||||
|
|
||||||
|
@ -159,26 +159,26 @@ class Display extends BaseSettings
|
||||||
$theme_selected = $user['theme'] ?: $default_theme;
|
$theme_selected = $user['theme'] ?: $default_theme;
|
||||||
$mobile_theme_selected = DI::session()->get('mobile-theme', $default_mobile_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_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'));
|
$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) {
|
if (intval($browser_update) != -1) {
|
||||||
$browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
|
$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);
|
$no_auto_update = DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_auto_update', 0);
|
||||||
$enable_smile = !DI::pConfig()->get(local_user(), 'system', 'no_smilies', 0);
|
$enable_smile = !DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_smilies', 0);
|
||||||
$infinite_scroll = DI::pConfig()->get(local_user(), 'system', 'infinite_scroll', 0);
|
$infinite_scroll = DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll', 0);
|
||||||
$enable_smart_threading = !DI::pConfig()->get(local_user(), 'system', 'no_smart_threading', 0);
|
$enable_smart_threading = !DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_smart_threading', 0);
|
||||||
$enable_dislike = !DI::pConfig()->get(local_user(), 'system', 'hide_dislike', 0);
|
$enable_dislike = !DI::pConfig()->get(Session::getLocalUser(), 'system', 'hide_dislike', 0);
|
||||||
$display_resharer = DI::pConfig()->get(local_user(), 'system', 'display_resharer', 0);
|
$display_resharer = DI::pConfig()->get(Session::getLocalUser(), 'system', 'display_resharer', 0);
|
||||||
$stay_local = DI::pConfig()->get(local_user(), 'system', 'stay_local', 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 = [
|
$weekdays = [
|
||||||
0 => DI::l10n()->t("Sunday"),
|
0 => DI::l10n()->t("Sunday"),
|
||||||
1 => DI::l10n()->t("Monday"),
|
1 => DI::l10n()->t("Monday"),
|
||||||
|
@ -207,7 +207,7 @@ class Display extends BaseSettings
|
||||||
|
|
||||||
'$form_security_token' => self::getFormSecurityToken('settings_display'),
|
'$form_security_token' => self::getFormSecurityToken('settings_display'),
|
||||||
'$baseurl' => DI::baseUrl()->get(true),
|
'$baseurl' => DI::baseUrl()->get(true),
|
||||||
'$uid' => local_user(),
|
'$uid' => Session::getLocalUser(),
|
||||||
|
|
||||||
'$theme' => ['theme', DI::l10n()->t('Display Theme:'), $theme_selected, '', $themes, true],
|
'$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],
|
'$mobile_theme' => ['mobile_theme', DI::l10n()->t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false],
|
||||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\Core\ACL;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Core\Session;
|
||||||
use Friendica\Core\Theme;
|
use Friendica\Core\Theme;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -43,11 +44,11 @@ class Index extends BaseSettings
|
||||||
{
|
{
|
||||||
protected function post(array $request = [])
|
protected function post(array $request = [])
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = Profile::getByUID(local_user());
|
$profile = Profile::getByUID(Session::getLocalUser());
|
||||||
if (!DBA::isResult($profile)) {
|
if (!DBA::isResult($profile)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -101,12 +102,12 @@ class Index extends BaseSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
$profileFieldsNew = self::getProfileFieldsFromInput(
|
$profileFieldsNew = self::getProfileFieldsFromInput(
|
||||||
local_user(),
|
Session::getLocalUser(),
|
||||||
$_REQUEST['profile_field'],
|
$_REQUEST['profile_field'],
|
||||||
$_REQUEST['profile_field_order']
|
$_REQUEST['profile_field_order']
|
||||||
);
|
);
|
||||||
|
|
||||||
DI::profileField()->saveCollectionForUser(local_user(), $profileFieldsNew);
|
DI::profileField()->saveCollectionForUser(Session::getLocalUser(), $profileFieldsNew);
|
||||||
|
|
||||||
$result = Profile::update(
|
$result = Profile::update(
|
||||||
[
|
[
|
||||||
|
@ -124,7 +125,7 @@ class Index extends BaseSettings
|
||||||
'pub_keywords' => $pub_keywords,
|
'pub_keywords' => $pub_keywords,
|
||||||
'prv_keywords' => $prv_keywords,
|
'prv_keywords' => $prv_keywords,
|
||||||
],
|
],
|
||||||
local_user()
|
Session::getLocalUser()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
|
@ -137,7 +138,7 @@ class Index extends BaseSettings
|
||||||
|
|
||||||
protected function content(array $request = []): string
|
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'));
|
DI::sysmsg()->addNotice(DI::l10n()->t('You must be logged in to use this module'));
|
||||||
return Login::form();
|
return Login::form();
|
||||||
}
|
}
|
||||||
|
@ -146,7 +147,7 @@ class Index extends BaseSettings
|
||||||
|
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
$profile = User::getOwnerDataById(local_user());
|
$profile = User::getOwnerDataById(Session::getLocalUser());
|
||||||
if (!DBA::isResult($profile)) {
|
if (!DBA::isResult($profile)) {
|
||||||
throw new HTTPException\NotFoundException();
|
throw new HTTPException\NotFoundException();
|
||||||
}
|
}
|
||||||
|
@ -158,7 +159,7 @@ class Index extends BaseSettings
|
||||||
|
|
||||||
$custom_fields = [];
|
$custom_fields = [];
|
||||||
|
|
||||||
$profileFields = DI::profileField()->selectByUserId(local_user());
|
$profileFields = DI::profileField()->selectByUserId(Session::getLocalUser());
|
||||||
foreach ($profileFields as $profileField) {
|
foreach ($profileFields as $profileField) {
|
||||||
/** @var ProfileField $profileField */
|
/** @var ProfileField $profileField */
|
||||||
$defaultPermissions = $profileField->permissionSet->withAllowedContacts(
|
$defaultPermissions = $profileField->permissionSet->withAllowedContacts(
|
||||||
|
|
|
@ -58,7 +58,7 @@ class Crop extends BaseSettings
|
||||||
|
|
||||||
$path = 'profile/' . DI::app()->getLoggedInUserNickname();
|
$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)) {
|
if (DBA::isResult($base_image)) {
|
||||||
$Image = Photo::getImageForPhoto($base_image);
|
$Image = Photo::getImageForPhoto($base_image);
|
||||||
if (empty($Image)) {
|
if (empty($Image)) {
|
||||||
|
@ -67,7 +67,7 @@ class Crop extends BaseSettings
|
||||||
|
|
||||||
if ($Image->isValid()) {
|
if ($Image->isValid()) {
|
||||||
// If setting for the default profile, unset the profile photo flag from any other photos I own
|
// 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
|
// Normalizing expected square crop parameters
|
||||||
$selectionW = $selectionH = min($selectionW, $selectionH);
|
$selectionW = $selectionH = min($selectionW, $selectionH);
|
||||||
|
@ -92,11 +92,11 @@ class Crop extends BaseSettings
|
||||||
$Image->scaleDown(300);
|
$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(
|
$r = Photo::store(
|
||||||
$Image,
|
$Image,
|
||||||
local_user(),
|
Session::getLocalUser(),
|
||||||
0,
|
0,
|
||||||
$resource_id,
|
$resource_id,
|
||||||
$base_image['filename'],
|
$base_image['filename'],
|
||||||
|
@ -114,7 +114,7 @@ class Crop extends BaseSettings
|
||||||
|
|
||||||
$r = Photo::store(
|
$r = Photo::store(
|
||||||
$Image,
|
$Image,
|
||||||
local_user(),
|
Session::getLocalUser(),
|
||||||
0,
|
0,
|
||||||
$resource_id,
|
$resource_id,
|
||||||
$base_image['filename'],
|
$base_image['filename'],
|
||||||
|
@ -132,7 +132,7 @@ class Crop extends BaseSettings
|
||||||
|
|
||||||
$r = Photo::store(
|
$r = Photo::store(
|
||||||
$Image,
|
$Image,
|
||||||
local_user(),
|
Session::getLocalUser(),
|
||||||
0,
|
0,
|
||||||
$resource_id,
|
$resource_id,
|
||||||
$base_image['filename'],
|
$base_image['filename'],
|
||||||
|
@ -146,12 +146,12 @@ class Crop extends BaseSettings
|
||||||
Photo::update(['profile' => true], array_merge($condition, ['scale' => 6]));
|
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.'));
|
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
|
// Update global directory in background
|
||||||
Profile::publishUpdate(local_user());
|
Profile::publishUpdate(Session::getLocalUser());
|
||||||
} else {
|
} else {
|
||||||
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to process image'));
|
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to process image'));
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ class Crop extends BaseSettings
|
||||||
|
|
||||||
$resource_id = $this->parameters['guid'];
|
$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)) {
|
if (!DBA::isResult($photos)) {
|
||||||
throw new HTTPException\NotFoundException(DI::l10n()->t('Photo not found.'));
|
throw new HTTPException\NotFoundException(DI::l10n()->t('Photo not found.'));
|
||||||
}
|
}
|
||||||
|
@ -185,14 +185,14 @@ class Crop extends BaseSettings
|
||||||
// set an already uloaded photo as profile photo
|
// set an already uloaded photo as profile photo
|
||||||
// if photo is in 'Profile Photos', change it in db
|
// if photo is in 'Profile Photos', change it in db
|
||||||
if ($photos[0]['photo-type'] == Photo::USER_AVATAR && $havescale) {
|
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
|
// Update global directory in background
|
||||||
Profile::publishUpdate(local_user());
|
Profile::publishUpdate(Session::getLocalUser());
|
||||||
|
|
||||||
DI::sysmsg()->addInfo(DI::l10n()->t('Profile picture successfully updated.'));
|
DI::sysmsg()->addInfo(DI::l10n()->t('Profile picture successfully updated.'));
|
||||||
|
|
||||||
|
|
|
@ -92,13 +92,13 @@ class Index extends BaseSettings
|
||||||
|
|
||||||
$filename = '';
|
$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.'));
|
DI::sysmsg()->addNotice(DI::l10n()->t('Image upload failed.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($width > 640 || $height > 640) {
|
if ($width > 640 || $height > 640) {
|
||||||
$Image->scaleDown(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'));
|
DI::sysmsg()->addNotice(DI::l10n()->t('Image size reduction [%s] failed.', '640'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ class Index extends BaseSettings
|
||||||
|
|
||||||
$newuser = $args->get($args->getArgc() - 1) === 'new';
|
$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');
|
$tpl = Renderer::getMarkupTemplate('settings/profile/photo/index.tpl');
|
||||||
$o = Renderer::replaceMacros($tpl, [
|
$o = Renderer::replaceMacros($tpl, [
|
||||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\App;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Core\Session;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Module\Response;
|
use Friendica\Module\Response;
|
||||||
use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
|
use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
|
||||||
|
@ -51,11 +52,11 @@ class AppSpecific extends BaseSettings
|
||||||
|
|
||||||
$this->pConfig = $pConfig;
|
$this->pConfig = $pConfig;
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$verified = $this->pConfig->get(local_user(), '2fa', 'verified');
|
$verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified');
|
||||||
|
|
||||||
if (!$verified) {
|
if (!$verified) {
|
||||||
$this->baseUrl->redirect('settings/2fa');
|
$this->baseUrl->redirect('settings/2fa');
|
||||||
|
@ -69,7 +70,7 @@ class AppSpecific extends BaseSettings
|
||||||
|
|
||||||
protected function post(array $request = [])
|
protected function post(array $request = [])
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,17 +83,17 @@ class AppSpecific extends BaseSettings
|
||||||
if (empty($description)) {
|
if (empty($description)) {
|
||||||
DI::sysmsg()->addNotice($this->t('App-specific password generation failed: The description is empty.'));
|
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'));
|
$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.'));
|
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'));
|
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||||
} else {
|
} 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.'));
|
DI::sysmsg()->addInfo($this->t('New app-specific password generated.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'revoke_all' :
|
case 'revoke_all' :
|
||||||
AppSpecificPassword::deleteAllForUser(local_user());
|
AppSpecificPassword::deleteAllForUser(Session::getLocalUser());
|
||||||
DI::sysmsg()->addInfo($this->t('App-specific passwords successfully revoked.'));
|
DI::sysmsg()->addInfo($this->t('App-specific passwords successfully revoked.'));
|
||||||
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||||
break;
|
break;
|
||||||
|
@ -102,7 +103,7 @@ class AppSpecific extends BaseSettings
|
||||||
if (!empty($_POST['revoke_id'])) {
|
if (!empty($_POST['revoke_id'])) {
|
||||||
self::checkFormSecurityTokenRedirectOnError('settings/2fa/app_specific', 'settings_2fa_app_specific');
|
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.'));
|
DI::sysmsg()->addInfo($this->t('App-specific password successfully revoked.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,13 +113,13 @@ class AppSpecific extends BaseSettings
|
||||||
|
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
return Login::form('settings/2fa/app_specific');
|
return Login::form('settings/2fa/app_specific');
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::content();
|
parent::content();
|
||||||
|
|
||||||
$appSpecificPasswords = AppSpecificPassword::getListForUser(local_user());
|
$appSpecificPasswords = AppSpecificPassword::getListForUser(Session::getLocalUser());
|
||||||
|
|
||||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/app_specific.tpl'), [
|
return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/app_specific.tpl'), [
|
||||||
'$form_security_token' => self::getFormSecurityToken('settings_2fa_app_specific'),
|
'$form_security_token' => self::getFormSecurityToken('settings_2fa_app_specific'),
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
namespace Friendica\Module\Settings\TwoFactor;
|
namespace Friendica\Module\Settings\TwoFactor;
|
||||||
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Core\Session;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Network\HTTPException\FoundException;
|
use Friendica\Network\HTTPException\FoundException;
|
||||||
use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
|
use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
|
||||||
|
@ -35,24 +36,24 @@ class Index extends BaseSettings
|
||||||
{
|
{
|
||||||
protected function post(array $request = [])
|
protected function post(array $request = [])
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::checkFormSecurityTokenRedirectOnError('settings/2fa', 'settings_2fa');
|
self::checkFormSecurityTokenRedirectOnError('settings/2fa', 'settings_2fa');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
User::getIdFromPasswordAuthentication(local_user(), $_POST['password'] ?? '');
|
User::getIdFromPasswordAuthentication(Session::getLocalUser(), $_POST['password'] ?? '');
|
||||||
|
|
||||||
$has_secret = (bool)DI::pConfig()->get(local_user(), '2fa', 'secret');
|
$has_secret = (bool)DI::pConfig()->get(Session::getLocalUser(), '2fa', 'secret');
|
||||||
$verified = DI::pConfig()->get(local_user(), '2fa', 'verified');
|
$verified = DI::pConfig()->get(Session::getLocalUser(), '2fa', 'verified');
|
||||||
|
|
||||||
switch ($_POST['action'] ?? '') {
|
switch ($_POST['action'] ?? '') {
|
||||||
case 'enable':
|
case 'enable':
|
||||||
if (!$has_secret && !$verified) {
|
if (!$has_secret && !$verified) {
|
||||||
$Google2FA = new Google2FA();
|
$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()
|
DI::baseUrl()
|
||||||
->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||||
|
@ -60,9 +61,9 @@ class Index extends BaseSettings
|
||||||
break;
|
break;
|
||||||
case 'disable':
|
case 'disable':
|
||||||
if ($has_secret) {
|
if ($has_secret) {
|
||||||
RecoveryCode::deleteForUser(local_user());
|
RecoveryCode::deleteForUser(Session::getLocalUser());
|
||||||
DI::pConfig()->delete(local_user(), '2fa', 'secret');
|
DI::pConfig()->delete(Session::getLocalUser(), '2fa', 'secret');
|
||||||
DI::pConfig()->delete(local_user(), '2fa', 'verified');
|
DI::pConfig()->delete(Session::getLocalUser(), '2fa', 'verified');
|
||||||
DI::session()->remove('2fa');
|
DI::session()->remove('2fa');
|
||||||
|
|
||||||
DI::sysmsg()->addInfo(DI::l10n()->t('Two-factor authentication successfully disabled.'));
|
DI::sysmsg()->addInfo(DI::l10n()->t('Two-factor authentication successfully disabled.'));
|
||||||
|
@ -103,14 +104,14 @@ class Index extends BaseSettings
|
||||||
|
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
return Login::form('settings/2fa');
|
return Login::form('settings/2fa');
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::content();
|
parent::content();
|
||||||
|
|
||||||
$has_secret = (bool) DI::pConfig()->get(local_user(), '2fa', 'secret');
|
$has_secret = (bool) DI::pConfig()->get(Session::getLocalUser(), '2fa', 'secret');
|
||||||
$verified = DI::pConfig()->get(local_user(), '2fa', 'verified');
|
$verified = DI::pConfig()->get(Session::getLocalUser(), '2fa', 'verified');
|
||||||
|
|
||||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/index.tpl'), [
|
return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/index.tpl'), [
|
||||||
'$form_security_token' => self::getFormSecurityToken('settings_2fa'),
|
'$form_security_token' => self::getFormSecurityToken('settings_2fa'),
|
||||||
|
@ -128,12 +129,12 @@ class Index extends BaseSettings
|
||||||
|
|
||||||
'$recovery_codes_title' => DI::l10n()->t('Recovery codes'),
|
'$recovery_codes_title' => DI::l10n()->t('Recovery codes'),
|
||||||
'$recovery_codes_remaining' => DI::l10n()->t('Remaining valid 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>'),
|
'$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_title' => DI::l10n()->t('App-specific passwords'),
|
||||||
'$app_specific_passwords_remaining' => DI::l10n()->t('Generated 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>'),
|
'$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'),
|
'$action_title' => DI::l10n()->t('Actions'),
|
||||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\App;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Core\Session;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Module\Response;
|
use Friendica\Module\Response;
|
||||||
use Friendica\Security\TwoFactor\Model\RecoveryCode;
|
use Friendica\Security\TwoFactor\Model\RecoveryCode;
|
||||||
|
@ -49,11 +50,11 @@ class Recovery extends BaseSettings
|
||||||
|
|
||||||
$this->pConfig = $pConfig;
|
$this->pConfig = $pConfig;
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$secret = $this->pConfig->get(local_user(), '2fa', 'secret');
|
$secret = $this->pConfig->get(Session::getLocalUser(), '2fa', 'secret');
|
||||||
|
|
||||||
if (!$secret) {
|
if (!$secret) {
|
||||||
$this->baseUrl->redirect('settings/2fa');
|
$this->baseUrl->redirect('settings/2fa');
|
||||||
|
@ -67,7 +68,7 @@ class Recovery extends BaseSettings
|
||||||
|
|
||||||
protected function post(array $request = [])
|
protected function post(array $request = [])
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ class Recovery extends BaseSettings
|
||||||
self::checkFormSecurityTokenRedirectOnError('settings/2fa/recovery', 'settings_2fa_recovery');
|
self::checkFormSecurityTokenRedirectOnError('settings/2fa/recovery', 'settings_2fa_recovery');
|
||||||
|
|
||||||
if ($_POST['action'] == 'regenerate') {
|
if ($_POST['action'] == 'regenerate') {
|
||||||
RecoveryCode::regenerateForUser(local_user());
|
RecoveryCode::regenerateForUser(Session::getLocalUser());
|
||||||
DI::sysmsg()->addInfo($this->t('New recovery codes successfully generated.'));
|
DI::sysmsg()->addInfo($this->t('New recovery codes successfully generated.'));
|
||||||
$this->baseUrl->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
$this->baseUrl->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||||
}
|
}
|
||||||
|
@ -84,19 +85,19 @@ class Recovery extends BaseSettings
|
||||||
|
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
return Login::form('settings/2fa/recovery');
|
return Login::form('settings/2fa/recovery');
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::content();
|
parent::content();
|
||||||
|
|
||||||
if (!RecoveryCode::countValidForUser(local_user())) {
|
if (!RecoveryCode::countValidForUser(Session::getLocalUser())) {
|
||||||
RecoveryCode::generateForUser(local_user());
|
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'), [
|
return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/recovery.tpl'), [
|
||||||
'$form_security_token' => self::getFormSecurityToken('settings_2fa_recovery'),
|
'$form_security_token' => self::getFormSecurityToken('settings_2fa_recovery'),
|
||||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\App;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Core\Session;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Module\BaseSettings;
|
use Friendica\Module\BaseSettings;
|
||||||
use Friendica\Module\Response;
|
use Friendica\Module\Response;
|
||||||
|
@ -52,11 +53,11 @@ class Trusted extends BaseSettings
|
||||||
$this->pConfig = $pConfig;
|
$this->pConfig = $pConfig;
|
||||||
$this->trustedBrowserRepo = $trustedBrowserRepo;
|
$this->trustedBrowserRepo = $trustedBrowserRepo;
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$verified = $this->pConfig->get(local_user(), '2fa', 'verified');
|
$verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified');
|
||||||
|
|
||||||
if (!$verified) {
|
if (!$verified) {
|
||||||
$this->baseUrl->redirect('settings/2fa');
|
$this->baseUrl->redirect('settings/2fa');
|
||||||
|
@ -70,7 +71,7 @@ class Trusted extends BaseSettings
|
||||||
|
|
||||||
protected function post(array $request = [])
|
protected function post(array $request = [])
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +80,7 @@ class Trusted extends BaseSettings
|
||||||
|
|
||||||
switch ($_POST['action']) {
|
switch ($_POST['action']) {
|
||||||
case 'remove_all':
|
case 'remove_all':
|
||||||
$this->trustedBrowserRepo->removeAllForUser(local_user());
|
$this->trustedBrowserRepo->removeAllForUser(Session::getLocalUser());
|
||||||
DI::sysmsg()->addInfo($this->t('Trusted browsers successfully removed.'));
|
DI::sysmsg()->addInfo($this->t('Trusted browsers successfully removed.'));
|
||||||
$this->baseUrl->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
$this->baseUrl->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||||
break;
|
break;
|
||||||
|
@ -89,7 +90,7 @@ class Trusted extends BaseSettings
|
||||||
if (!empty($_POST['remove_id'])) {
|
if (!empty($_POST['remove_id'])) {
|
||||||
self::checkFormSecurityTokenRedirectOnError('settings/2fa/trusted', 'settings_2fa_trusted');
|
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.'));
|
DI::sysmsg()->addInfo($this->t('Trusted browser successfully removed.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +103,7 @@ class Trusted extends BaseSettings
|
||||||
{
|
{
|
||||||
parent::content();
|
parent::content();
|
||||||
|
|
||||||
$trustedBrowsers = $this->trustedBrowserRepo->selectAllByUid(local_user());
|
$trustedBrowsers = $this->trustedBrowserRepo->selectAllByUid(Session::getLocalUser());
|
||||||
|
|
||||||
$parser = Parser::create();
|
$parser = Parser::create();
|
||||||
|
|
||||||
|
|
|
@ -54,12 +54,12 @@ class Verify extends BaseSettings
|
||||||
|
|
||||||
$this->pConfig = $pConfig;
|
$this->pConfig = $pConfig;
|
||||||
|
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$secret = $this->pConfig->get(local_user(), '2fa', 'secret');
|
$secret = $this->pConfig->get(Session::getLocalUser(), '2fa', 'secret');
|
||||||
$verified = $this->pConfig->get(local_user(), '2fa', 'verified');
|
$verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified');
|
||||||
|
|
||||||
if ($secret && $verified) {
|
if ($secret && $verified) {
|
||||||
$this->baseUrl->redirect('settings/2fa');
|
$this->baseUrl->redirect('settings/2fa');
|
||||||
|
@ -73,7 +73,7 @@ class Verify extends BaseSettings
|
||||||
|
|
||||||
protected function post(array $request = [])
|
protected function post(array $request = [])
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,10 +82,10 @@ class Verify extends BaseSettings
|
||||||
|
|
||||||
$google2fa = new Google2FA();
|
$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) {
|
if ($valid) {
|
||||||
$this->pConfig->set(local_user(), '2fa', 'verified', true);
|
$this->pConfig->set(Session::getLocalUser(), '2fa', 'verified', true);
|
||||||
DI::session()->set('2fa', true);
|
DI::session()->set('2fa', true);
|
||||||
|
|
||||||
DI::sysmsg()->addInfo($this->t('Two-factor authentication successfully activated.'));
|
DI::sysmsg()->addInfo($this->t('Two-factor authentication successfully activated.'));
|
||||||
|
@ -99,7 +99,7 @@ class Verify extends BaseSettings
|
||||||
|
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
return Login::form('settings/2fa/verify');
|
return Login::form('settings/2fa/verify');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class Verify extends BaseSettings
|
||||||
|
|
||||||
$company = 'Friendica';
|
$company = 'Friendica';
|
||||||
$holder = DI::session()->get('my_address');
|
$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);
|
$otpauthUrl = (new Google2FA())->getQRCodeUrl($company, $holder, $secret);
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Module\Settings;
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Core\Session;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -54,7 +55,7 @@ class UserExport extends BaseSettings
|
||||||
*/
|
*/
|
||||||
protected function content(array $request = []): string
|
protected function content(array $request = []): string
|
||||||
{
|
{
|
||||||
if (!local_user()) {
|
if (!Session::getLocalUser()) {
|
||||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,17 +101,17 @@ class UserExport extends BaseSettings
|
||||||
case "backup":
|
case "backup":
|
||||||
header("Content-type: application/json");
|
header("Content-type: application/json");
|
||||||
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '.' . $action . '"');
|
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '.' . $action . '"');
|
||||||
self::exportAll(local_user());
|
self::exportAll(Session::getLocalUser());
|
||||||
break;
|
break;
|
||||||
case "account":
|
case "account":
|
||||||
header("Content-type: application/json");
|
header("Content-type: application/json");
|
||||||
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '.' . $action . '"');
|
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '.' . $action . '"');
|
||||||
self::exportAccount(local_user());
|
self::exportAccount(Session::getLocalUser());
|
||||||
break;
|
break;
|
||||||
case "contact":
|
case "contact":
|
||||||
header("Content-type: application/csv");
|
header("Content-type: application/csv");
|
||||||
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '-contacts.csv' . '"');
|
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '-contacts.csv' . '"');
|
||||||
self::exportContactsAsCSV(local_user());
|
self::exportContactsAsCSV(Session::getLocalUser());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
System::exit();
|
System::exit();
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Update;
|
namespace Friendica\Module\Update;
|
||||||
|
|
||||||
|
use Friendica\Core\Session;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Module\Conversation\Community as CommunityModule;
|
use Friendica\Module\Conversation\Community as CommunityModule;
|
||||||
|
@ -38,8 +39,8 @@ class Community extends CommunityModule
|
||||||
$this->parseRequest();
|
$this->parseRequest();
|
||||||
|
|
||||||
$o = '';
|
$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')) {
|
||||||
$o = DI::conversation()->create(self::getItems(), 'community', true, false, 'commented', local_user());
|
$o = DI::conversation()->create(self::getItems(), 'community', true, false, 'commented', Session::getLocalUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
System::htmlUpdateExit($o);
|
System::htmlUpdateExit($o);
|
||||||
|
|
|
@ -42,13 +42,13 @@ class Profile extends BaseModule
|
||||||
// Ensure we've got a profile owner if updating.
|
// Ensure we've got a profile owner if updating.
|
||||||
$a->setProfileOwner((int)($_GET['p'] ?? 0));
|
$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();
|
throw new ForbiddenException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$remote_contact = Session::getRemoteContactID($a->getProfileOwner());
|
$remote_contact = Session::getRemoteContactID($a->getProfileOwner());
|
||||||
$is_owner = local_user() == $a->getProfileOwner();
|
$is_owner = Session::getLocalUser() == $a->getProfileOwner();
|
||||||
$last_updated_key = "profile:" . $a->getProfileOwner() . ":" . local_user() . ":" . $remote_contact;
|
$last_updated_key = "profile:" . $a->getProfileOwner() . ":" . Session::getLocalUser() . ":" . $remote_contact;
|
||||||
|
|
||||||
if (!$is_owner && !$remote_contact) {
|
if (!$is_owner && !$remote_contact) {
|
||||||
$user = User::getById($a->getProfileOwner(), ['hidewall']);
|
$user = User::getById($a->getProfileOwner(), ['hidewall']);
|
||||||
|
@ -59,7 +59,7 @@ class Profile extends BaseModule
|
||||||
|
|
||||||
$o = '';
|
$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);
|
System::htmlUpdateExit($o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,9 +110,9 @@ class Profile extends BaseModule
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($is_owner) {
|
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) {
|
if ($unseen) {
|
||||||
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
|
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user