mirror of
https://github.com/friendica/friendica
synced 2025-04-27 07:50:10 +00:00
UserSession class [5] - Refactor src/Module/ files with DI
This commit is contained in:
parent
a729f3255d
commit
eecc456e0c
78 changed files with 455 additions and 530 deletions
|
@ -26,7 +26,6 @@ use Friendica\Core\ACL;
|
|||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -69,9 +68,9 @@ class Account extends BaseSettings
|
|||
}
|
||||
|
||||
// check if the old password was supplied correctly before changing it to the new value
|
||||
User::getIdFromPasswordAuthentication(Session::getLocalUser(), $request['opassword']);
|
||||
User::getIdFromPasswordAuthentication(DI::userSession()->getLocalUserId(), $request['opassword']);
|
||||
|
||||
$result = User::updatePassword(Session::getLocalUser(), $newpass);
|
||||
$result = User::updatePassword(DI::userSession()->getLocalUserId(), $newpass);
|
||||
if (!DBA::isResult($result)) {
|
||||
throw new Exception(DI::l10n()->t('Password update failed. Please try again.'));
|
||||
}
|
||||
|
@ -104,7 +103,7 @@ class Account extends BaseSettings
|
|||
if ($email != $user['email']) {
|
||||
// check for the correct password
|
||||
try {
|
||||
User::getIdFromPasswordAuthentication(Session::getLocalUser(), $request['mpassword']);
|
||||
User::getIdFromPasswordAuthentication(DI::userSession()->getLocalUserId(), $request['mpassword']);
|
||||
} catch (Exception $ex) {
|
||||
$err .= DI::l10n()->t('Wrong Password.');
|
||||
$email = $user['email'];
|
||||
|
@ -146,7 +145,7 @@ class Account extends BaseSettings
|
|||
$fields['openidserver'] = '';
|
||||
}
|
||||
|
||||
if (!User::update($fields, Session::getLocalUser())) {
|
||||
if (!User::update($fields, DI::userSession()->getLocalUserId())) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
|
||||
}
|
||||
|
||||
|
@ -175,8 +174,8 @@ class Account extends BaseSettings
|
|||
$str_group_deny = !empty($request['group_deny']) ? $aclFormatter->toString($request['group_deny']) : '';
|
||||
$str_contact_deny = !empty($request['contact_deny']) ? $aclFormatter->toString($request['contact_deny']) : '';
|
||||
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'unlisted', !empty($request['unlisted']));
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'accessible-photos', !empty($request['accessible-photos']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'unlisted', !empty($request['unlisted']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'accessible-photos', !empty($request['accessible-photos']));
|
||||
|
||||
$fields = [
|
||||
'allow_cid' => $str_contact_allow,
|
||||
|
@ -198,7 +197,7 @@ class Account extends BaseSettings
|
|||
'hide-friends' => $hide_friends
|
||||
];
|
||||
|
||||
if (!User::update($fields, Session::getLocalUser()) || !Profile::update($profile_fields, Session::getLocalUser())) {
|
||||
if (!User::update($fields, DI::userSession()->getLocalUserId()) || !Profile::update($profile_fields, DI::userSession()->getLocalUserId())) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
|
||||
}
|
||||
|
||||
|
@ -213,12 +212,12 @@ class Account extends BaseSettings
|
|||
$expire_starred = !empty($request['expire_starred']);
|
||||
$expire_network_only = !empty($request['expire_network_only']);
|
||||
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'expire', 'items', $expire_items);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'expire', 'notes', $expire_notes);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'expire', 'starred', $expire_starred);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'expire', 'network_only', $expire_network_only);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'expire', 'items', $expire_items);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'expire', 'notes', $expire_notes);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'expire', 'starred', $expire_starred);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'expire', 'network_only', $expire_network_only);
|
||||
|
||||
if (!User::update(['expire' => $expire], Session::getLocalUser())) {
|
||||
if (!User::update(['expire' => $expire], DI::userSession()->getLocalUserId())) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
|
||||
}
|
||||
|
||||
|
@ -273,7 +272,7 @@ class Account extends BaseSettings
|
|||
if (!empty($request['notify_activity_participation'])) {
|
||||
$notify_type = $notify_type | UserNotification::TYPE_ACTIVITY_PARTICIPATION;
|
||||
}
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'notify_type', $notify_type);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'notify_type', $notify_type);
|
||||
|
||||
if (!($notify_type & (UserNotification::TYPE_DIRECT_COMMENT + UserNotification::TYPE_DIRECT_THREAD_COMMENT))) {
|
||||
$notify_like = false;
|
||||
|
@ -281,28 +280,28 @@ class Account extends BaseSettings
|
|||
}
|
||||
|
||||
// Reset like notifications when they are going to be shown again
|
||||
if (!DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_like') && $notify_like) {
|
||||
DI::notification()->setAllSeenForUser(Session::getLocalUser(), ['vid' => Verb::getID(Activity::LIKE)]);
|
||||
if (!DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'notify_like') && $notify_like) {
|
||||
DI::notification()->setAllSeenForUser(DI::userSession()->getLocalUserId(), ['vid' => Verb::getID(Activity::LIKE)]);
|
||||
}
|
||||
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'notify_like', $notify_like);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'notify_like', $notify_like);
|
||||
|
||||
// Reset share notifications when they are going to be shown again
|
||||
if (!DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_announce') && $notify_announce) {
|
||||
DI::notification()->setAllSeenForUser(Session::getLocalUser(), ['vid' => Verb::getID(Activity::ANNOUNCE)]);
|
||||
if (!DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'notify_announce') && $notify_announce) {
|
||||
DI::notification()->setAllSeenForUser(DI::userSession()->getLocalUserId(), ['vid' => Verb::getID(Activity::ANNOUNCE)]);
|
||||
}
|
||||
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'notify_announce', $notify_announce);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'notify_announce', $notify_announce);
|
||||
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'email_textonly', !empty($request['email_textonly']));
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'detailed_notif', !empty($request['detailed_notif']));
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'notify_ignored', !empty($request['notify_ignored']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'email_textonly', !empty($request['email_textonly']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'detailed_notif', !empty($request['detailed_notif']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'notify_ignored', !empty($request['notify_ignored']));
|
||||
|
||||
$fields = [
|
||||
'notify-flags' => $notify,
|
||||
];
|
||||
|
||||
if (!User::update($fields, Session::getLocalUser())) {
|
||||
if (!User::update($fields, DI::userSession()->getLocalUserId())) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
|
||||
}
|
||||
|
||||
|
@ -328,7 +327,7 @@ class Account extends BaseSettings
|
|||
$profile_fields = [];
|
||||
|
||||
if ($account_type == User::ACCOUNT_TYPE_COMMUNITY) {
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'unlisted', true);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'unlisted', true);
|
||||
|
||||
$fields = [
|
||||
'allow_cid' => '',
|
||||
|
@ -351,7 +350,7 @@ class Account extends BaseSettings
|
|||
'account-type' => $account_type,
|
||||
]);
|
||||
|
||||
if (!User::update($fields, Session::getLocalUser()) || !empty($profile_fields) && !Profile::update($profile_fields, Session::getLocalUser())) {
|
||||
if (!User::update($fields, DI::userSession()->getLocalUserId()) || !empty($profile_fields) && !Profile::update($profile_fields, DI::userSession()->getLocalUserId())) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Settings were not updated.'));
|
||||
}
|
||||
|
||||
|
@ -376,7 +375,7 @@ class Account extends BaseSettings
|
|||
// "http" or "@" to be present in the string.
|
||||
// All other fields from the row will be ignored
|
||||
if ((strpos($csvRow[0], '@') !== false) || Network::isValidHttpUrl($csvRow[0])) {
|
||||
Worker::add(Worker::PRIORITY_MEDIUM, 'AddContact', Session::getLocalUser(), $csvRow[0]);
|
||||
Worker::add(Worker::PRIORITY_MEDIUM, 'AddContact', DI::userSession()->getLocalUserId(), $csvRow[0]);
|
||||
} else {
|
||||
Logger::notice('Invalid account', ['url' => $csvRow[0]]);
|
||||
}
|
||||
|
@ -395,7 +394,7 @@ class Account extends BaseSettings
|
|||
}
|
||||
|
||||
if (!empty($request['relocate-submit'])) {
|
||||
Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, Session::getLocalUser());
|
||||
Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, DI::userSession()->getLocalUserId());
|
||||
DI::sysmsg()->addInfo(DI::l10n()->t("Relocate message has been send to your contacts"));
|
||||
DI::baseUrl()->redirect($redirectUrl);
|
||||
}
|
||||
|
@ -407,11 +406,11 @@ class Account extends BaseSettings
|
|||
{
|
||||
parent::content();
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
$profile = DBA::selectFirst('profile', [], ['uid' => Session::getLocalUser()]);
|
||||
$profile = DBA::selectFirst('profile', [], ['uid' => DI::userSession()->getLocalUserId()]);
|
||||
if (!DBA::isResult($profile)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to find your profile. Please contact your admin.'));
|
||||
return '';
|
||||
|
@ -434,10 +433,10 @@ class Account extends BaseSettings
|
|||
$unkmail = $user['unkmail'];
|
||||
$cntunkmail = $user['cntunkmail'];
|
||||
|
||||
$expire_items = DI::pConfig()->get(Session::getLocalUser(), 'expire', 'items', true);
|
||||
$expire_notes = DI::pConfig()->get(Session::getLocalUser(), 'expire', 'notes', true);
|
||||
$expire_starred = DI::pConfig()->get(Session::getLocalUser(), 'expire', 'starred', true);
|
||||
$expire_network_only = DI::pConfig()->get(Session::getLocalUser(), 'expire', 'network_only', false);
|
||||
$expire_items = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'items', true);
|
||||
$expire_notes = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'notes', true);
|
||||
$expire_starred = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'starred', true);
|
||||
$expire_network_only = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'network_only', false);
|
||||
|
||||
if (!strlen($user['timezone'])) {
|
||||
$timezone = $a->getTimeZone();
|
||||
|
@ -551,7 +550,7 @@ class Account extends BaseSettings
|
|||
/* Installed langs */
|
||||
$lang_choices = DI::l10n()->getAvailableLanguages();
|
||||
|
||||
$notify_type = DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_type');
|
||||
$notify_type = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'notify_type');
|
||||
|
||||
$passwordRules = DI::l10n()->t('Allowed characters are a-z, A-Z, 0-9 and special characters except white spaces, accentuated letters and colon (:).')
|
||||
. (PASSWORD_DEFAULT === PASSWORD_BCRYPT ? ' ' . DI::l10n()->t('Password length is limited to 72 characters.') : '');
|
||||
|
@ -563,7 +562,7 @@ class Account extends BaseSettings
|
|||
|
||||
'$submit' => DI::l10n()->t('Save Settings'),
|
||||
'$baseurl' => DI::baseUrl()->get(true),
|
||||
'$uid' => Session::getLocalUser(),
|
||||
'$uid' => DI::userSession()->getLocalUserId(),
|
||||
'$form_security_token' => self::getFormSecurityToken('settings'),
|
||||
'$open' => $this->parameters['open'] ?? 'password',
|
||||
|
||||
|
@ -591,13 +590,13 @@ class Account extends BaseSettings
|
|||
'$profile_in_net_dir' => ['profile_in_netdirectory', DI::l10n()->t('Allow your profile to be searchable globally?'), $profile['net-publish'], DI::l10n()->t("Activate this setting if you want others to easily find and follow you. Your profile will be searchable on remote systems. This setting also determines whether Friendica will inform search engines that your profile should be indexed or not.") . $net_pub_desc],
|
||||
'$hide_friends' => ['hide-friends', DI::l10n()->t('Hide your contact/friend list from viewers of your profile?'), $profile['hide-friends'], DI::l10n()->t('A list of your contacts is displayed on your profile page. Activate this option to disable the display of your contact list.')],
|
||||
'$hide_wall' => ['hidewall', DI::l10n()->t('Hide your profile details from anonymous viewers?'), $user['hidewall'], DI::l10n()->t('Anonymous visitors will only see your profile picture, your display name and the nickname you are using on your profile page. Your public posts and replies will still be accessible by other means.')],
|
||||
'$unlisted' => ['unlisted', DI::l10n()->t('Make public posts unlisted'), DI::pConfig()->get(Session::getLocalUser(), 'system', 'unlisted'), DI::l10n()->t('Your public posts will not appear on the community pages or in search results, nor be sent to relay servers. However they can still appear on public feeds on remote servers.')],
|
||||
'$accessiblephotos' => ['accessible-photos', DI::l10n()->t('Make all posted pictures accessible'), DI::pConfig()->get(Session::getLocalUser(), 'system', 'accessible-photos'), DI::l10n()->t("This option makes every posted picture accessible via the direct link. This is a workaround for the problem that most other networks can't handle permissions on pictures. Non public pictures still won't be visible for the public on your photo albums though.")],
|
||||
'$unlisted' => ['unlisted', DI::l10n()->t('Make public posts unlisted'), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'unlisted'), DI::l10n()->t('Your public posts will not appear on the community pages or in search results, nor be sent to relay servers. However they can still appear on public feeds on remote servers.')],
|
||||
'$accessiblephotos' => ['accessible-photos', DI::l10n()->t('Make all posted pictures accessible'), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'accessible-photos'), DI::l10n()->t("This option makes every posted picture accessible via the direct link. This is a workaround for the problem that most other networks can't handle permissions on pictures. Non public pictures still won't be visible for the public on your photo albums though.")],
|
||||
'$blockwall' => ['blockwall', DI::l10n()->t('Allow friends to post to your profile page?'), (intval($user['blockwall']) ? '0' : '1'), DI::l10n()->t('Your contacts may write posts on your profile wall. These posts will be distributed to your contacts')],
|
||||
'$blocktags' => ['blocktags', DI::l10n()->t('Allow friends to tag your posts?'), (intval($user['blocktags']) ? '0' : '1'), DI::l10n()->t('Your contacts can add additional tags to your posts.')],
|
||||
'$unkmail' => ['unkmail', DI::l10n()->t('Permit unknown people to send you private mail?'), $unkmail, DI::l10n()->t('Friendica network users may send you private messages even if they are not in your contact list.')],
|
||||
'$cntunkmail' => ['cntunkmail', DI::l10n()->t('Maximum private messages per day from unknown people:'), $cntunkmail, DI::l10n()->t("(to prevent spam abuse)")],
|
||||
'$group_select' => Group::displayGroupSelection(Session::getLocalUser(), $user['def_gid']),
|
||||
'$group_select' => Group::displayGroupSelection(DI::userSession()->getLocalUserId(), $user['def_gid']),
|
||||
'$permissions' => DI::l10n()->t('Default Post Permissions'),
|
||||
'$aclselect' => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId()),
|
||||
|
||||
|
@ -623,8 +622,8 @@ class Account extends BaseSettings
|
|||
'$lbl_notify' => DI::l10n()->t('Create a desktop notification when:'),
|
||||
'$notify_tagged' => ['notify_tagged', DI::l10n()->t('Someone tagged you'), is_null($notify_type) || $notify_type & UserNotification::TYPE_EXPLICIT_TAGGED, ''],
|
||||
'$notify_direct_comment' => ['notify_direct_comment', DI::l10n()->t('Someone directly commented on your post'), is_null($notify_type) || $notify_type & (UserNotification::TYPE_IMPLICIT_TAGGED + UserNotification::TYPE_DIRECT_COMMENT + UserNotification::TYPE_DIRECT_THREAD_COMMENT), ''],
|
||||
'$notify_like' => ['notify_like', DI::l10n()->t('Someone liked your content'), DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_like'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')],
|
||||
'$notify_announce' => ['notify_announce', DI::l10n()->t('Someone shared your content'), DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_announce'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')],
|
||||
'$notify_like' => ['notify_like', DI::l10n()->t('Someone liked your content'), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'notify_like'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')],
|
||||
'$notify_announce' => ['notify_announce', DI::l10n()->t('Someone shared your content'), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'notify_announce'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')],
|
||||
'$notify_thread_comment' => ['notify_thread_comment', DI::l10n()->t('Someone commented in your thread'), is_null($notify_type) || $notify_type & UserNotification::TYPE_THREAD_COMMENT, ''],
|
||||
'$notify_comment_participation' => ['notify_comment_participation', DI::l10n()->t('Someone commented in a thread where you commented'), is_null($notify_type) || $notify_type & UserNotification::TYPE_COMMENT_PARTICIPATION, ''],
|
||||
'$notify_activity_participation' => ['notify_activity_participation', DI::l10n()->t('Someone commented in a thread where you interacted'), is_null($notify_type) || $notify_type & UserNotification::TYPE_ACTIVITY_PARTICIPATION, ''],
|
||||
|
@ -634,19 +633,19 @@ class Account extends BaseSettings
|
|||
'$email_textonly' => [
|
||||
'email_textonly',
|
||||
DI::l10n()->t('Text-only notification emails'),
|
||||
DI::pConfig()->get(Session::getLocalUser(), 'system', 'email_textonly'),
|
||||
DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'email_textonly'),
|
||||
DI::l10n()->t('Send text only notification emails, without the html part')
|
||||
],
|
||||
'$detailed_notif' => [
|
||||
'detailed_notif',
|
||||
DI::l10n()->t('Show detailled notifications'),
|
||||
DI::pConfig()->get(Session::getLocalUser(), 'system', 'detailed_notif'),
|
||||
DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'detailed_notif'),
|
||||
DI::l10n()->t('Per default, notifications are condensed to a single notification per item. When enabled every notification is displayed.')
|
||||
],
|
||||
'$notify_ignored' => [
|
||||
'notify_ignored',
|
||||
DI::l10n()->t('Show notifications of ignored contacts'),
|
||||
DI::pConfig()->get(Session::getLocalUser(), 'system', 'notify_ignored', true),
|
||||
DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'notify_ignored', true),
|
||||
DI::l10n()->t("You don't see posts from ignored contacts. But you still see their comments. This setting controls if you want to still receive regular notifications that are caused by ignored contacts or not.")
|
||||
],
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Module\Settings;
|
|||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
|
@ -59,14 +58,14 @@ class Delegation extends BaseSettings
|
|||
DI::sysmsg()->addInfo(DI::l10n()->t('Delegation successfully revoked.'));
|
||||
}
|
||||
|
||||
DBA::update('user', ['parent-uid' => $parent_uid], ['uid' => Session::getLocalUser()]);
|
||||
DBA::update('user', ['parent-uid' => $parent_uid], ['uid' => DI::userSession()->getLocalUserId()]);
|
||||
}
|
||||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
parent::content();
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
|
@ -85,11 +84,11 @@ class Delegation extends BaseSettings
|
|||
$user = User::getById($user_id, ['nickname']);
|
||||
if (DBA::isResult($user)) {
|
||||
$condition = [
|
||||
'uid' => Session::getLocalUser(),
|
||||
'uid' => DI::userSession()->getLocalUserId(),
|
||||
'nurl' => Strings::normaliseLink(DI::baseUrl() . '/profile/' . $user['nickname'])
|
||||
];
|
||||
if (DBA::exists('contact', $condition)) {
|
||||
DBA::insert('manage', ['uid' => $user_id, 'mid' => Session::getLocalUser()]);
|
||||
DBA::insert('manage', ['uid' => $user_id, 'mid' => DI::userSession()->getLocalUserId()]);
|
||||
}
|
||||
} else {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Delegate user not found.'));
|
||||
|
@ -104,12 +103,12 @@ class Delegation extends BaseSettings
|
|||
DI::baseUrl()->redirect('settings/delegation');
|
||||
}
|
||||
|
||||
DBA::delete('manage', ['uid' => $user_id, 'mid' => Session::getLocalUser()]);
|
||||
DBA::delete('manage', ['uid' => $user_id, 'mid' => DI::userSession()->getLocalUserId()]);
|
||||
DI::baseUrl()->redirect('settings/delegation');
|
||||
}
|
||||
|
||||
// find everybody that currently has delegated management to this account/page
|
||||
$delegates = DBA::selectToArray('user', [], ['`uid` IN (SELECT `uid` FROM `manage` WHERE `mid` = ?)', Session::getLocalUser()]);
|
||||
$delegates = DBA::selectToArray('user', [], ['`uid` IN (SELECT `uid` FROM `manage` WHERE `mid` = ?)', DI::userSession()->getLocalUserId()]);
|
||||
|
||||
$uids = [];
|
||||
foreach ($delegates as $user) {
|
||||
|
@ -120,7 +119,7 @@ class Delegation extends BaseSettings
|
|||
$potentials = [];
|
||||
$nicknames = [];
|
||||
|
||||
$condition = ['baseurl' => DI::baseUrl(), 'self' => false, 'uid' => Session::getLocalUser(), 'blocked' => false];
|
||||
$condition = ['baseurl' => DI::baseUrl(), 'self' => false, 'uid' => DI::userSession()->getLocalUserId(), 'blocked' => false];
|
||||
$contacts = DBA::select('contact', ['nick'], $condition);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
$nicknames[] = $contact['nick'];
|
||||
|
@ -137,8 +136,8 @@ class Delegation extends BaseSettings
|
|||
|
||||
$parent_user = null;
|
||||
$parent_password = null;
|
||||
$user = User::getById(Session::getLocalUser(), ['parent-uid', 'email']);
|
||||
if (DBA::isResult($user) && !DBA::exists('user', ['parent-uid' => Session::getLocalUser()])) {
|
||||
$user = User::getById(DI::userSession()->getLocalUserId(), ['parent-uid', 'email']);
|
||||
if (DBA::isResult($user) && !DBA::exists('user', ['parent-uid' => DI::userSession()->getLocalUserId()])) {
|
||||
$parent_uid = $user['parent-uid'];
|
||||
$parents = [0 => DI::l10n()->t('No parent user')];
|
||||
|
||||
|
@ -146,7 +145,7 @@ class Delegation extends BaseSettings
|
|||
$condition = ['email' => $user['email'], 'verified' => true, 'blocked' => false, 'parent-uid' => 0];
|
||||
$parent_users = DBA::selectToArray('user', $fields, $condition);
|
||||
foreach($parent_users as $parent) {
|
||||
if ($parent['uid'] != Session::getLocalUser()) {
|
||||
if ($parent['uid'] != DI::userSession()->getLocalUserId()) {
|
||||
$parents[$parent['uid']] = sprintf('%s (%s)', $parent['username'], $parent['nickname']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Module\Settings;
|
|||
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Theme;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -44,7 +43,7 @@ class Display extends BaseSettings
|
|||
|
||||
self::checkFormSecurityTokenRedirectOnError('/settings/display', 'settings_display');
|
||||
|
||||
$user = User::getById(Session::getLocalUser());
|
||||
$user = User::getById(DI::userSession()->getLocalUserId());
|
||||
|
||||
$theme = !empty($_POST['theme']) ? trim($_POST['theme']) : $user['theme'];
|
||||
$mobile_theme = !empty($_POST['mobile_theme']) ? trim($_POST['mobile_theme']) : '';
|
||||
|
@ -78,20 +77,20 @@ class Display extends BaseSettings
|
|||
}
|
||||
|
||||
if ($mobile_theme !== '') {
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'mobile_theme', $mobile_theme);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'mobile_theme', $mobile_theme);
|
||||
}
|
||||
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'itemspage_network' , $itemspage_network);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'itemspage_mobile_network', $itemspage_mobile_network);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'update_interval' , $browser_update);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'no_auto_update' , $no_auto_update);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'no_smilies' , !$enable_smile);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'infinite_scroll' , $infinite_scroll);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'no_smart_threading' , !$enable_smart_threading);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'hide_dislike' , !$enable_dislike);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'display_resharer' , $display_resharer);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'stay_local' , $stay_local);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'first_day_of_week' , $first_day_of_week);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network' , $itemspage_network);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network', $itemspage_mobile_network);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'update_interval' , $browser_update);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'no_auto_update' , $no_auto_update);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'no_smilies' , !$enable_smile);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll' , $infinite_scroll);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'no_smart_threading' , !$enable_smart_threading);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike' , !$enable_dislike);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'display_resharer' , $display_resharer);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'stay_local' , $stay_local);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'first_day_of_week' , $first_day_of_week);
|
||||
|
||||
if (in_array($theme, Theme::getAllowedList())) {
|
||||
if ($theme == $user['theme']) {
|
||||
|
@ -101,7 +100,7 @@ class Display extends BaseSettings
|
|||
theme_post(DI::app());
|
||||
}
|
||||
} else {
|
||||
DBA::update('user', ['theme' => $theme], ['uid' => Session::getLocalUser()]);
|
||||
DBA::update('user', ['theme' => $theme], ['uid' => DI::userSession()->getLocalUserId()]);
|
||||
}
|
||||
} else {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('The theme you chose isn\'t available.'));
|
||||
|
@ -116,7 +115,7 @@ class Display extends BaseSettings
|
|||
{
|
||||
parent::content();
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
|
@ -130,7 +129,7 @@ class Display extends BaseSettings
|
|||
$default_mobile_theme = 'none';
|
||||
}
|
||||
|
||||
$user = User::getById(Session::getLocalUser());
|
||||
$user = User::getById(DI::userSession()->getLocalUserId());
|
||||
|
||||
$allowed_themes = Theme::getAllowedList();
|
||||
|
||||
|
@ -159,26 +158,26 @@ class Display extends BaseSettings
|
|||
$theme_selected = $user['theme'] ?: $default_theme;
|
||||
$mobile_theme_selected = DI::session()->get('mobile-theme', $default_mobile_theme);
|
||||
|
||||
$itemspage_network = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network'));
|
||||
$itemspage_network = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network'));
|
||||
$itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : DI::config()->get('system', 'itemspage_network'));
|
||||
$itemspage_mobile_network = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network'));
|
||||
$itemspage_mobile_network = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network'));
|
||||
$itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
|
||||
$browser_update = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'update_interval'));
|
||||
$browser_update = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'update_interval'));
|
||||
if (intval($browser_update) != -1) {
|
||||
$browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds
|
||||
}
|
||||
|
||||
$no_auto_update = DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_auto_update', 0);
|
||||
$enable_smile = !DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_smilies', 0);
|
||||
$infinite_scroll = DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll', 0);
|
||||
$enable_smart_threading = !DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_smart_threading', 0);
|
||||
$enable_dislike = !DI::pConfig()->get(Session::getLocalUser(), 'system', 'hide_dislike', 0);
|
||||
$display_resharer = DI::pConfig()->get(Session::getLocalUser(), 'system', 'display_resharer', 0);
|
||||
$stay_local = DI::pConfig()->get(Session::getLocalUser(), 'system', 'stay_local', 0);
|
||||
$no_auto_update = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_auto_update', 0);
|
||||
$enable_smile = !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_smilies', 0);
|
||||
$infinite_scroll = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll', 0);
|
||||
$enable_smart_threading = !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_smart_threading', 0);
|
||||
$enable_dislike = !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike', 0);
|
||||
$display_resharer = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'display_resharer', 0);
|
||||
$stay_local = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'stay_local', 0);
|
||||
|
||||
|
||||
$first_day_of_week = DI::pConfig()->get(Session::getLocalUser(), 'system', 'first_day_of_week', 0);
|
||||
$first_day_of_week = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'first_day_of_week', 0);
|
||||
$weekdays = [
|
||||
0 => DI::l10n()->t("Sunday"),
|
||||
1 => DI::l10n()->t("Monday"),
|
||||
|
@ -207,7 +206,7 @@ class Display extends BaseSettings
|
|||
|
||||
'$form_security_token' => self::getFormSecurityToken('settings_display'),
|
||||
'$baseurl' => DI::baseUrl()->get(true),
|
||||
'$uid' => Session::getLocalUser(),
|
||||
'$uid' => DI::userSession()->getLocalUserId(),
|
||||
|
||||
'$theme' => ['theme', DI::l10n()->t('Display Theme:'), $theme_selected, '', $themes, true],
|
||||
'$mobile_theme' => ['mobile_theme', DI::l10n()->t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false],
|
||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\Core\ACL;
|
|||
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;
|
||||
|
@ -44,11 +43,11 @@ class Index extends BaseSettings
|
|||
{
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$profile = Profile::getByUID(Session::getLocalUser());
|
||||
$profile = Profile::getByUID(DI::userSession()->getLocalUserId());
|
||||
if (!DBA::isResult($profile)) {
|
||||
return;
|
||||
}
|
||||
|
@ -102,12 +101,12 @@ class Index extends BaseSettings
|
|||
}
|
||||
|
||||
$profileFieldsNew = self::getProfileFieldsFromInput(
|
||||
Session::getLocalUser(),
|
||||
DI::userSession()->getLocalUserId(),
|
||||
$_REQUEST['profile_field'],
|
||||
$_REQUEST['profile_field_order']
|
||||
);
|
||||
|
||||
DI::profileField()->saveCollectionForUser(Session::getLocalUser(), $profileFieldsNew);
|
||||
DI::profileField()->saveCollectionForUser(DI::userSession()->getLocalUserId(), $profileFieldsNew);
|
||||
|
||||
$result = Profile::update(
|
||||
[
|
||||
|
@ -125,7 +124,7 @@ class Index extends BaseSettings
|
|||
'pub_keywords' => $pub_keywords,
|
||||
'prv_keywords' => $prv_keywords,
|
||||
],
|
||||
Session::getLocalUser()
|
||||
DI::userSession()->getLocalUserId()
|
||||
);
|
||||
|
||||
if (!$result) {
|
||||
|
@ -138,7 +137,7 @@ class Index extends BaseSettings
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('You must be logged in to use this module'));
|
||||
return Login::form();
|
||||
}
|
||||
|
@ -147,7 +146,7 @@ class Index extends BaseSettings
|
|||
|
||||
$o = '';
|
||||
|
||||
$profile = User::getOwnerDataById(Session::getLocalUser());
|
||||
$profile = User::getOwnerDataById(DI::userSession()->getLocalUserId());
|
||||
if (!DBA::isResult($profile)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
@ -159,7 +158,7 @@ class Index extends BaseSettings
|
|||
|
||||
$custom_fields = [];
|
||||
|
||||
$profileFields = DI::profileField()->selectByUserId(Session::getLocalUser());
|
||||
$profileFields = DI::profileField()->selectByUserId(DI::userSession()->getLocalUserId());
|
||||
foreach ($profileFields as $profileField) {
|
||||
/** @var ProfileField $profileField */
|
||||
$defaultPermissions = $profileField->permissionSet->withAllowedContacts(
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module\Settings\Profile\Photo;
|
||||
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -35,7 +34,7 @@ class Crop extends BaseSettings
|
|||
{
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::isAuthenticated()) {
|
||||
if (!DI::userSession()->isAuthenticated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -58,7 +57,7 @@ class Crop extends BaseSettings
|
|||
|
||||
$path = 'profile/' . DI::app()->getLoggedInUserNickname();
|
||||
|
||||
$base_image = Photo::selectFirst([], ['resource-id' => $resource_id, 'uid' => Session::getLocalUser(), 'scale' => $scale]);
|
||||
$base_image = Photo::selectFirst([], ['resource-id' => $resource_id, 'uid' => DI::userSession()->getLocalUserId(), 'scale' => $scale]);
|
||||
if (DBA::isResult($base_image)) {
|
||||
$Image = Photo::getImageForPhoto($base_image);
|
||||
if (empty($Image)) {
|
||||
|
@ -67,7 +66,7 @@ class Crop extends BaseSettings
|
|||
|
||||
if ($Image->isValid()) {
|
||||
// If setting for the default profile, unset the profile photo flag from any other photos I own
|
||||
DBA::update('photo', ['profile' => 0], ['uid' => Session::getLocalUser()]);
|
||||
DBA::update('photo', ['profile' => 0], ['uid' => DI::userSession()->getLocalUserId()]);
|
||||
|
||||
// Normalizing expected square crop parameters
|
||||
$selectionW = $selectionH = min($selectionW, $selectionH);
|
||||
|
@ -92,11 +91,11 @@ class Crop extends BaseSettings
|
|||
$Image->scaleDown(300);
|
||||
}
|
||||
|
||||
$condition = ['resource-id' => $resource_id, 'uid' => Session::getLocalUser(), 'contact-id' => 0];
|
||||
$condition = ['resource-id' => $resource_id, 'uid' => DI::userSession()->getLocalUserId(), 'contact-id' => 0];
|
||||
|
||||
$r = Photo::store(
|
||||
$Image,
|
||||
Session::getLocalUser(),
|
||||
DI::userSession()->getLocalUserId(),
|
||||
0,
|
||||
$resource_id,
|
||||
$base_image['filename'],
|
||||
|
@ -114,7 +113,7 @@ class Crop extends BaseSettings
|
|||
|
||||
$r = Photo::store(
|
||||
$Image,
|
||||
Session::getLocalUser(),
|
||||
DI::userSession()->getLocalUserId(),
|
||||
0,
|
||||
$resource_id,
|
||||
$base_image['filename'],
|
||||
|
@ -132,7 +131,7 @@ class Crop extends BaseSettings
|
|||
|
||||
$r = Photo::store(
|
||||
$Image,
|
||||
Session::getLocalUser(),
|
||||
DI::userSession()->getLocalUserId(),
|
||||
0,
|
||||
$resource_id,
|
||||
$base_image['filename'],
|
||||
|
@ -146,12 +145,12 @@ class Crop extends BaseSettings
|
|||
Photo::update(['profile' => true], array_merge($condition, ['scale' => 6]));
|
||||
}
|
||||
|
||||
Contact::updateSelfFromUserID(Session::getLocalUser(), true);
|
||||
Contact::updateSelfFromUserID(DI::userSession()->getLocalUserId(), true);
|
||||
|
||||
DI::sysmsg()->addInfo(DI::l10n()->t('Shift-reload the page or clear browser cache if the new photo does not display immediately.'));
|
||||
|
||||
// Update global directory in background
|
||||
Profile::publishUpdate(Session::getLocalUser());
|
||||
Profile::publishUpdate(DI::userSession()->getLocalUserId());
|
||||
} else {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Unable to process image'));
|
||||
}
|
||||
|
@ -162,7 +161,7 @@ class Crop extends BaseSettings
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::isAuthenticated()) {
|
||||
if (!DI::userSession()->isAuthenticated()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
|
@ -170,7 +169,7 @@ class Crop extends BaseSettings
|
|||
|
||||
$resource_id = $this->parameters['guid'];
|
||||
|
||||
$photos = Photo::selectToArray([], ['resource-id' => $resource_id, 'uid' => Session::getLocalUser()], ['order' => ['scale' => false]]);
|
||||
$photos = Photo::selectToArray([], ['resource-id' => $resource_id, 'uid' => DI::userSession()->getLocalUserId()], ['order' => ['scale' => false]]);
|
||||
if (!DBA::isResult($photos)) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('Photo not found.'));
|
||||
}
|
||||
|
@ -185,14 +184,14 @@ class Crop extends BaseSettings
|
|||
// set an already uloaded photo as profile photo
|
||||
// if photo is in 'Profile Photos', change it in db
|
||||
if ($photos[0]['photo-type'] == Photo::USER_AVATAR && $havescale) {
|
||||
Photo::update(['profile' => false], ['uid' => Session::getLocalUser()]);
|
||||
Photo::update(['profile' => false], ['uid' => DI::userSession()->getLocalUserId()]);
|
||||
|
||||
Photo::update(['profile' => true], ['resource-id' => $resource_id, 'uid' => Session::getLocalUser()]);
|
||||
Photo::update(['profile' => true], ['resource-id' => $resource_id, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
|
||||
Contact::updateSelfFromUserID(Session::getLocalUser(), true);
|
||||
Contact::updateSelfFromUserID(DI::userSession()->getLocalUserId(), true);
|
||||
|
||||
// Update global directory in background
|
||||
Profile::publishUpdate(Session::getLocalUser());
|
||||
Profile::publishUpdate(DI::userSession()->getLocalUserId());
|
||||
|
||||
DI::sysmsg()->addInfo(DI::l10n()->t('Profile picture successfully updated.'));
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module\Settings\Profile\Photo;
|
||||
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Photo;
|
||||
|
@ -36,7 +35,7 @@ class Index extends BaseSettings
|
|||
{
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::isAuthenticated()) {
|
||||
if (!DI::userSession()->isAuthenticated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -92,13 +91,13 @@ class Index extends BaseSettings
|
|||
|
||||
$filename = '';
|
||||
|
||||
if (!Photo::store($Image, Session::getLocalUser(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 0, Photo::USER_AVATAR)) {
|
||||
if (!Photo::store($Image, DI::userSession()->getLocalUserId(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 0, Photo::USER_AVATAR)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Image upload failed.'));
|
||||
}
|
||||
|
||||
if ($width > 640 || $height > 640) {
|
||||
$Image->scaleDown(640);
|
||||
if (!Photo::store($Image, Session::getLocalUser(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 1, Photo::USER_AVATAR)) {
|
||||
if (!Photo::store($Image, DI::userSession()->getLocalUserId(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 1, Photo::USER_AVATAR)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Image size reduction [%s] failed.', '640'));
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +107,7 @@ class Index extends BaseSettings
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::isAuthenticated()) {
|
||||
if (!DI::userSession()->isAuthenticated()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
|
@ -118,7 +117,7 @@ class Index extends BaseSettings
|
|||
|
||||
$newuser = $args->get($args->getArgc() - 1) === 'new';
|
||||
|
||||
$contact = Contact::selectFirst(['avatar'], ['uid' => Session::getLocalUser(), 'self' => true]);
|
||||
$contact = Contact::selectFirst(['avatar'], ['uid' => DI::userSession()->getLocalUserId(), 'self' => true]);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('settings/profile/photo/index.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, [
|
||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\App;
|
|||
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;
|
||||
|
@ -52,11 +51,11 @@ class AppSpecific extends BaseSettings
|
|||
|
||||
$this->pConfig = $pConfig;
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified');
|
||||
$verified = $this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'verified');
|
||||
|
||||
if (!$verified) {
|
||||
$this->baseUrl->redirect('settings/2fa');
|
||||
|
@ -70,7 +69,7 @@ class AppSpecific extends BaseSettings
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,17 +82,17 @@ class AppSpecific extends BaseSettings
|
|||
if (empty($description)) {
|
||||
DI::sysmsg()->addNotice($this->t('App-specific password generation failed: The description is empty.'));
|
||||
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||
} elseif (AppSpecificPassword::checkDuplicateForUser(Session::getLocalUser(), $description)) {
|
||||
} elseif (AppSpecificPassword::checkDuplicateForUser(DI::userSession()->getLocalUserId(), $description)) {
|
||||
DI::sysmsg()->addNotice($this->t('App-specific password generation failed: This description already exists.'));
|
||||
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||
} else {
|
||||
$this->appSpecificPassword = AppSpecificPassword::generateForUser(Session::getLocalUser(), $_POST['description'] ?? '');
|
||||
$this->appSpecificPassword = AppSpecificPassword::generateForUser(DI::userSession()->getLocalUserId(), $_POST['description'] ?? '');
|
||||
DI::sysmsg()->addInfo($this->t('New app-specific password generated.'));
|
||||
}
|
||||
|
||||
break;
|
||||
case 'revoke_all' :
|
||||
AppSpecificPassword::deleteAllForUser(Session::getLocalUser());
|
||||
AppSpecificPassword::deleteAllForUser(DI::userSession()->getLocalUserId());
|
||||
DI::sysmsg()->addInfo($this->t('App-specific passwords successfully revoked.'));
|
||||
$this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||
break;
|
||||
|
@ -103,7 +102,7 @@ class AppSpecific extends BaseSettings
|
|||
if (!empty($_POST['revoke_id'])) {
|
||||
self::checkFormSecurityTokenRedirectOnError('settings/2fa/app_specific', 'settings_2fa_app_specific');
|
||||
|
||||
if (AppSpecificPassword::deleteForUser(Session::getLocalUser(), $_POST['revoke_id'])) {
|
||||
if (AppSpecificPassword::deleteForUser(DI::userSession()->getLocalUserId(), $_POST['revoke_id'])) {
|
||||
DI::sysmsg()->addInfo($this->t('App-specific password successfully revoked.'));
|
||||
}
|
||||
|
||||
|
@ -113,13 +112,13 @@ class AppSpecific extends BaseSettings
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return Login::form('settings/2fa/app_specific');
|
||||
}
|
||||
|
||||
parent::content();
|
||||
|
||||
$appSpecificPasswords = AppSpecificPassword::getListForUser(Session::getLocalUser());
|
||||
$appSpecificPasswords = AppSpecificPassword::getListForUser(DI::userSession()->getLocalUserId());
|
||||
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/app_specific.tpl'), [
|
||||
'$form_security_token' => self::getFormSecurityToken('settings_2fa_app_specific'),
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
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;
|
||||
|
@ -36,24 +35,24 @@ class Index extends BaseSettings
|
|||
{
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::checkFormSecurityTokenRedirectOnError('settings/2fa', 'settings_2fa');
|
||||
|
||||
try {
|
||||
User::getIdFromPasswordAuthentication(Session::getLocalUser(), $_POST['password'] ?? '');
|
||||
User::getIdFromPasswordAuthentication(DI::userSession()->getLocalUserId(), $_POST['password'] ?? '');
|
||||
|
||||
$has_secret = (bool)DI::pConfig()->get(Session::getLocalUser(), '2fa', 'secret');
|
||||
$verified = DI::pConfig()->get(Session::getLocalUser(), '2fa', 'verified');
|
||||
$has_secret = (bool)DI::pConfig()->get(DI::userSession()->getLocalUserId(), '2fa', 'secret');
|
||||
$verified = DI::pConfig()->get(DI::userSession()->getLocalUserId(), '2fa', 'verified');
|
||||
|
||||
switch ($_POST['action'] ?? '') {
|
||||
case 'enable':
|
||||
if (!$has_secret && !$verified) {
|
||||
$Google2FA = new Google2FA();
|
||||
|
||||
DI::pConfig()->set(Session::getLocalUser(), '2fa', 'secret', $Google2FA->generateSecretKey(32));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), '2fa', 'secret', $Google2FA->generateSecretKey(32));
|
||||
|
||||
DI::baseUrl()
|
||||
->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||
|
@ -61,9 +60,9 @@ class Index extends BaseSettings
|
|||
break;
|
||||
case 'disable':
|
||||
if ($has_secret) {
|
||||
RecoveryCode::deleteForUser(Session::getLocalUser());
|
||||
DI::pConfig()->delete(Session::getLocalUser(), '2fa', 'secret');
|
||||
DI::pConfig()->delete(Session::getLocalUser(), '2fa', 'verified');
|
||||
RecoveryCode::deleteForUser(DI::userSession()->getLocalUserId());
|
||||
DI::pConfig()->delete(DI::userSession()->getLocalUserId(), '2fa', 'secret');
|
||||
DI::pConfig()->delete(DI::userSession()->getLocalUserId(), '2fa', 'verified');
|
||||
DI::session()->remove('2fa');
|
||||
|
||||
DI::sysmsg()->addInfo(DI::l10n()->t('Two-factor authentication successfully disabled.'));
|
||||
|
@ -104,14 +103,14 @@ class Index extends BaseSettings
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return Login::form('settings/2fa');
|
||||
}
|
||||
|
||||
parent::content();
|
||||
|
||||
$has_secret = (bool) DI::pConfig()->get(Session::getLocalUser(), '2fa', 'secret');
|
||||
$verified = DI::pConfig()->get(Session::getLocalUser(), '2fa', 'verified');
|
||||
$has_secret = (bool) DI::pConfig()->get(DI::userSession()->getLocalUserId(), '2fa', 'secret');
|
||||
$verified = DI::pConfig()->get(DI::userSession()->getLocalUserId(), '2fa', 'verified');
|
||||
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/index.tpl'), [
|
||||
'$form_security_token' => self::getFormSecurityToken('settings_2fa'),
|
||||
|
@ -129,12 +128,12 @@ class Index extends BaseSettings
|
|||
|
||||
'$recovery_codes_title' => DI::l10n()->t('Recovery codes'),
|
||||
'$recovery_codes_remaining' => DI::l10n()->t('Remaining valid codes'),
|
||||
'$recovery_codes_count' => RecoveryCode::countValidForUser(Session::getLocalUser()),
|
||||
'$recovery_codes_count' => RecoveryCode::countValidForUser(DI::userSession()->getLocalUserId()),
|
||||
'$recovery_codes_message' => DI::l10n()->t('<p>These one-use codes can replace an authenticator app code in case you have lost access to it.</p>'),
|
||||
|
||||
'$app_specific_passwords_title' => DI::l10n()->t('App-specific passwords'),
|
||||
'$app_specific_passwords_remaining' => DI::l10n()->t('Generated app-specific passwords'),
|
||||
'$app_specific_passwords_count' => AppSpecificPassword::countForUser(Session::getLocalUser()),
|
||||
'$app_specific_passwords_count' => AppSpecificPassword::countForUser(DI::userSession()->getLocalUserId()),
|
||||
'$app_specific_passwords_message' => DI::l10n()->t('<p>These randomly generated passwords allow you to authenticate on apps not supporting two-factor authentication.</p>'),
|
||||
|
||||
'$action_title' => DI::l10n()->t('Actions'),
|
||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\App;
|
|||
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;
|
||||
|
@ -50,11 +49,11 @@ class Recovery extends BaseSettings
|
|||
|
||||
$this->pConfig = $pConfig;
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$secret = $this->pConfig->get(Session::getLocalUser(), '2fa', 'secret');
|
||||
$secret = $this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'secret');
|
||||
|
||||
if (!$secret) {
|
||||
$this->baseUrl->redirect('settings/2fa');
|
||||
|
@ -68,7 +67,7 @@ class Recovery extends BaseSettings
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -76,7 +75,7 @@ class Recovery extends BaseSettings
|
|||
self::checkFormSecurityTokenRedirectOnError('settings/2fa/recovery', 'settings_2fa_recovery');
|
||||
|
||||
if ($_POST['action'] == 'regenerate') {
|
||||
RecoveryCode::regenerateForUser(Session::getLocalUser());
|
||||
RecoveryCode::regenerateForUser(DI::userSession()->getLocalUserId());
|
||||
DI::sysmsg()->addInfo($this->t('New recovery codes successfully generated.'));
|
||||
$this->baseUrl->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||
}
|
||||
|
@ -85,19 +84,19 @@ class Recovery extends BaseSettings
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return Login::form('settings/2fa/recovery');
|
||||
}
|
||||
|
||||
parent::content();
|
||||
|
||||
if (!RecoveryCode::countValidForUser(Session::getLocalUser())) {
|
||||
RecoveryCode::generateForUser(Session::getLocalUser());
|
||||
if (!RecoveryCode::countValidForUser(DI::userSession()->getLocalUserId())) {
|
||||
RecoveryCode::generateForUser(DI::userSession()->getLocalUserId());
|
||||
}
|
||||
|
||||
$recoveryCodes = RecoveryCode::getListForUser(Session::getLocalUser());
|
||||
$recoveryCodes = RecoveryCode::getListForUser(DI::userSession()->getLocalUserId());
|
||||
|
||||
$verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified');
|
||||
$verified = $this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'verified');
|
||||
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/recovery.tpl'), [
|
||||
'$form_security_token' => self::getFormSecurityToken('settings_2fa_recovery'),
|
||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\App;
|
|||
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;
|
||||
|
@ -53,11 +52,11 @@ class Trusted extends BaseSettings
|
|||
$this->pConfig = $pConfig;
|
||||
$this->trustedBrowserRepo = $trustedBrowserRepo;
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified');
|
||||
$verified = $this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'verified');
|
||||
|
||||
if (!$verified) {
|
||||
$this->baseUrl->redirect('settings/2fa');
|
||||
|
@ -71,7 +70,7 @@ class Trusted extends BaseSettings
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -80,7 +79,7 @@ class Trusted extends BaseSettings
|
|||
|
||||
switch ($_POST['action']) {
|
||||
case 'remove_all':
|
||||
$this->trustedBrowserRepo->removeAllForUser(Session::getLocalUser());
|
||||
$this->trustedBrowserRepo->removeAllForUser(DI::userSession()->getLocalUserId());
|
||||
DI::sysmsg()->addInfo($this->t('Trusted browsers successfully removed.'));
|
||||
$this->baseUrl->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password'));
|
||||
break;
|
||||
|
@ -90,7 +89,7 @@ class Trusted extends BaseSettings
|
|||
if (!empty($_POST['remove_id'])) {
|
||||
self::checkFormSecurityTokenRedirectOnError('settings/2fa/trusted', 'settings_2fa_trusted');
|
||||
|
||||
if ($this->trustedBrowserRepo->removeForUser(Session::getLocalUser(), $_POST['remove_id'])) {
|
||||
if ($this->trustedBrowserRepo->removeForUser(DI::userSession()->getLocalUserId(), $_POST['remove_id'])) {
|
||||
DI::sysmsg()->addInfo($this->t('Trusted browser successfully removed.'));
|
||||
}
|
||||
|
||||
|
@ -103,7 +102,7 @@ class Trusted extends BaseSettings
|
|||
{
|
||||
parent::content();
|
||||
|
||||
$trustedBrowsers = $this->trustedBrowserRepo->selectAllByUid(Session::getLocalUser());
|
||||
$trustedBrowsers = $this->trustedBrowserRepo->selectAllByUid(DI::userSession()->getLocalUserId());
|
||||
|
||||
$parser = Parser::create();
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ use Friendica\App;
|
|||
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;
|
||||
|
@ -54,12 +53,12 @@ class Verify extends BaseSettings
|
|||
|
||||
$this->pConfig = $pConfig;
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$secret = $this->pConfig->get(Session::getLocalUser(), '2fa', 'secret');
|
||||
$verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified');
|
||||
$secret = $this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'secret');
|
||||
$verified = $this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'verified');
|
||||
|
||||
if ($secret && $verified) {
|
||||
$this->baseUrl->redirect('settings/2fa');
|
||||
|
@ -73,7 +72,7 @@ class Verify extends BaseSettings
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -82,10 +81,10 @@ class Verify extends BaseSettings
|
|||
|
||||
$google2fa = new Google2FA();
|
||||
|
||||
$valid = $google2fa->verifyKey($this->pConfig->get(Session::getLocalUser(), '2fa', 'secret'), $_POST['verify_code'] ?? '');
|
||||
$valid = $google2fa->verifyKey($this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'secret'), $_POST['verify_code'] ?? '');
|
||||
|
||||
if ($valid) {
|
||||
$this->pConfig->set(Session::getLocalUser(), '2fa', 'verified', true);
|
||||
$this->pConfig->set(DI::userSession()->getLocalUserId(), '2fa', 'verified', true);
|
||||
DI::session()->set('2fa', true);
|
||||
|
||||
DI::sysmsg()->addInfo($this->t('Two-factor authentication successfully activated.'));
|
||||
|
@ -99,7 +98,7 @@ class Verify extends BaseSettings
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return Login::form('settings/2fa/verify');
|
||||
}
|
||||
|
||||
|
@ -107,7 +106,7 @@ class Verify extends BaseSettings
|
|||
|
||||
$company = 'Friendica';
|
||||
$holder = DI::session()->get('my_address');
|
||||
$secret = $this->pConfig->get(Session::getLocalUser(), '2fa', 'secret');
|
||||
$secret = $this->pConfig->get(DI::userSession()->getLocalUserId(), '2fa', 'secret');
|
||||
|
||||
$otpauthUrl = (new Google2FA())->getQRCodeUrl($company, $holder, $secret);
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace Friendica\Module\Settings;
|
|||
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;
|
||||
|
@ -55,7 +54,7 @@ class UserExport extends BaseSettings
|
|||
*/
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
|
@ -101,17 +100,17 @@ class UserExport extends BaseSettings
|
|||
case "backup":
|
||||
header("Content-type: application/json");
|
||||
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '.' . $action . '"');
|
||||
self::exportAll(Session::getLocalUser());
|
||||
self::exportAll(DI::userSession()->getLocalUserId());
|
||||
break;
|
||||
case "account":
|
||||
header("Content-type: application/json");
|
||||
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '.' . $action . '"');
|
||||
self::exportAccount(Session::getLocalUser());
|
||||
self::exportAccount(DI::userSession()->getLocalUserId());
|
||||
break;
|
||||
case "contact":
|
||||
header("Content-type: application/csv");
|
||||
header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '-contacts.csv' . '"');
|
||||
self::exportContactsAsCSV(Session::getLocalUser());
|
||||
self::exportContactsAsCSV(DI::userSession()->getLocalUserId());
|
||||
break;
|
||||
}
|
||||
System::exit();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue