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
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module\Admin;
|
||||
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Register;
|
||||
|
@ -122,7 +121,7 @@ abstract class BaseUsers extends BaseAdmin
|
|||
$user['login_date'] = Temporal::getRelativeDate($user['login_date']);
|
||||
$user['lastitem_date'] = Temporal::getRelativeDate($user['last-item']);
|
||||
$user['is_admin'] = in_array($user['email'], $adminlist);
|
||||
$user['is_deletable'] = !$user['account_removed'] && intval($user['uid']) != Session::getLocalUser();
|
||||
$user['is_deletable'] = !$user['account_removed'] && intval($user['uid']) != DI::userSession()->getLocalUserId();
|
||||
$user['deleted'] = ($user['account_removed'] ? Temporal::getRelativeDate($user['account_expires_on']) : False);
|
||||
|
||||
return $user;
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Module\Admin\Users;
|
|||
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
|
@ -48,7 +47,7 @@ class Active extends BaseUsers
|
|||
|
||||
if (!empty($_POST['page_users_delete'])) {
|
||||
foreach ($users as $uid) {
|
||||
if (Session::getLocalUser() != $uid) {
|
||||
if (DI::userSession()->getLocalUserId() != $uid) {
|
||||
User::remove($uid);
|
||||
} else {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
|
||||
|
@ -79,7 +78,7 @@ class Active extends BaseUsers
|
|||
|
||||
switch ($action) {
|
||||
case 'delete':
|
||||
if (Session::getLocalUser() != $uid) {
|
||||
if (DI::userSession()->getLocalUserId() != $uid) {
|
||||
self::checkFormSecurityTokenRedirectOnError('admin/users/active', 'admin_users_active', 't');
|
||||
// delete user
|
||||
User::remove($uid);
|
||||
|
|
|
@ -49,7 +49,7 @@ class Blocked extends BaseUsers
|
|||
|
||||
if (!empty($_POST['page_users_delete'])) {
|
||||
foreach ($users as $uid) {
|
||||
if (Session::getLocalUser() != $uid) {
|
||||
if (DI::userSession()->getLocalUserId() != $uid) {
|
||||
User::remove($uid);
|
||||
} else {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
|
||||
|
@ -80,7 +80,7 @@ class Blocked extends BaseUsers
|
|||
|
||||
switch ($action) {
|
||||
case 'delete':
|
||||
if (Session::getLocalUser() != $uid) {
|
||||
if (DI::userSession()->getLocalUserId() != $uid) {
|
||||
self::checkFormSecurityTokenRedirectOnError('/admin/users/blocked', 'admin_users_blocked', 't');
|
||||
// delete user
|
||||
User::remove($uid);
|
||||
|
|
|
@ -55,7 +55,7 @@ class Index extends BaseUsers
|
|||
|
||||
if (!empty($_POST['page_users_delete'])) {
|
||||
foreach ($users as $uid) {
|
||||
if (Session::getLocalUser() != $uid) {
|
||||
if (DI::userSession()->getLocalUserId() != $uid) {
|
||||
User::remove($uid);
|
||||
} else {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself'));
|
||||
|
@ -86,7 +86,7 @@ class Index extends BaseUsers
|
|||
|
||||
switch ($action) {
|
||||
case 'delete':
|
||||
if (Session::getLocalUser() != $uid) {
|
||||
if (DI::userSession()->getLocalUserId() != $uid) {
|
||||
self::checkFormSecurityTokenRedirectOnError(DI::baseUrl()->get(true), 'admin_users', 't');
|
||||
// delete user
|
||||
User::remove($uid);
|
||||
|
|
|
@ -28,7 +28,6 @@ use Friendica\Content\Nav;
|
|||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Util\Profiler;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
@ -43,7 +42,7 @@ class Apps extends BaseModule
|
|||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$privateaddons = $config->get('config', 'private_addons');
|
||||
if ($privateaddons === "1" && !Session::getLocalUser()) {
|
||||
if ($privateaddons === "1" && !DI::userSession()->getLocalUserId()) {
|
||||
$baseUrl->redirect();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace Friendica\Module;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
|
@ -50,7 +49,7 @@ abstract class BaseAdmin extends BaseModule
|
|||
*/
|
||||
public static function checkAdminAccess(bool $interactive = false)
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
if ($interactive) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Please login to continue.'));
|
||||
DI::session()->set('return_path', DI::args()->getQueryString());
|
||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\BaseModule;
|
|||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
@ -83,10 +82,10 @@ class BaseSearch extends BaseModule
|
|||
$search = Network::convertToIdn($search);
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
|
||||
$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
} else {
|
||||
$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
|
||||
$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
}
|
||||
|
||||
|
@ -126,7 +125,7 @@ class BaseSearch extends BaseModule
|
|||
|
||||
// in case the result is a contact result, add a contact-specific entry
|
||||
if ($result instanceof ContactResult) {
|
||||
$contact = Model\Contact::getByURLForUser($result->getUrl(), Session::getLocalUser());
|
||||
$contact = Model\Contact::getByURLForUser($result->getUrl(), DI::userSession()->getLocalUserId());
|
||||
if (!empty($contact)) {
|
||||
$entries[] = Contact::getContactTemplateVars($contact);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Module;
|
|||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\PageInfo;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Security\Login;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
@ -41,7 +40,7 @@ class Bookmarklet extends BaseModule
|
|||
|
||||
$config = DI::config();
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
$output = '<h2>' . DI::l10n()->t('Login') . '</h2>';
|
||||
$output .= Login::form(DI::args()->getQueryString(), intval($config->get('config', 'register_policy')) === Register::CLOSED ? false : true);
|
||||
return $output;
|
||||
|
|
|
@ -28,7 +28,6 @@ use Friendica\Content\Pager;
|
|||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Theme;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -60,12 +59,12 @@ class Contact extends BaseModule
|
|||
|
||||
self::checkFormSecurityTokenRedirectOnError($redirectUrl, 'contact_batch_actions');
|
||||
|
||||
$orig_records = Model\Contact::selectToArray(['id', 'uid'], ['id' => $_POST['contact_batch'], 'uid' => [0, Session::getLocalUser()], 'self' => false, 'deleted' => false]);
|
||||
$orig_records = Model\Contact::selectToArray(['id', 'uid'], ['id' => $_POST['contact_batch'], 'uid' => [0, DI::userSession()->getLocalUserId()], 'self' => false, 'deleted' => false]);
|
||||
|
||||
$count_actions = 0;
|
||||
foreach ($orig_records as $orig_record) {
|
||||
$cdata = Model\Contact::getPublicAndUserContactID($orig_record['id'], Session::getLocalUser());
|
||||
if (empty($cdata) || Session::getPublicContact() === $cdata['public']) {
|
||||
$cdata = Model\Contact::getPublicAndUserContactID($orig_record['id'], DI::userSession()->getLocalUserId());
|
||||
if (empty($cdata) || DI::userSession()->getPublicContactId() === $cdata['public']) {
|
||||
// No action available on your own contact
|
||||
continue;
|
||||
}
|
||||
|
@ -76,7 +75,7 @@ class Contact extends BaseModule
|
|||
}
|
||||
|
||||
if (!empty($_POST['contacts_batch_block'])) {
|
||||
self::toggleBlockContact($cdata['public'], Session::getLocalUser());
|
||||
self::toggleBlockContact($cdata['public'], DI::userSession()->getLocalUserId());
|
||||
$count_actions++;
|
||||
}
|
||||
|
||||
|
@ -94,7 +93,7 @@ class Contact extends BaseModule
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -114,7 +113,7 @@ class Contact extends BaseModule
|
|||
*/
|
||||
public static function updateContactFromPoll(int $contact_id)
|
||||
{
|
||||
$contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => Session::getLocalUser(), 'deleted' => false]);
|
||||
$contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => DI::userSession()->getLocalUserId(), 'deleted' => false]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
return;
|
||||
}
|
||||
|
@ -154,13 +153,13 @@ class Contact extends BaseModule
|
|||
*/
|
||||
private static function toggleIgnoreContact(int $contact_id)
|
||||
{
|
||||
$ignored = !Model\Contact\User::isIgnored($contact_id, Session::getLocalUser());
|
||||
Model\Contact\User::setIgnored($contact_id, Session::getLocalUser(), $ignored);
|
||||
$ignored = !Model\Contact\User::isIgnored($contact_id, DI::userSession()->getLocalUserId());
|
||||
Model\Contact\User::setIgnored($contact_id, DI::userSession()->getLocalUserId(), $ignored);
|
||||
}
|
||||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return Login::form($_SERVER['REQUEST_URI']);
|
||||
}
|
||||
|
||||
|
@ -204,7 +203,7 @@ class Contact extends BaseModule
|
|||
|
||||
$_SESSION['return_path'] = DI::args()->getQueryString();
|
||||
|
||||
$sql_values = [Session::getLocalUser()];
|
||||
$sql_values = [DI::userSession()->getLocalUserId()];
|
||||
|
||||
// @TODO: Replace with parameter from router
|
||||
$type = DI::args()->getArgv()[1] ?? '';
|
||||
|
@ -230,7 +229,7 @@ class Contact extends BaseModule
|
|||
$sql_extra = " AND `pending` AND NOT `archive` AND NOT `failed` AND ((`rel` = ?)
|
||||
OR `id` IN (SELECT `contact-id` FROM `intro` WHERE `intro`.`uid` = ? AND NOT `ignore`))";
|
||||
$sql_values[] = Model\Contact::SHARING;
|
||||
$sql_values[] = Session::getLocalUser();
|
||||
$sql_values[] = DI::userSession()->getLocalUserId();
|
||||
break;
|
||||
default:
|
||||
$sql_extra = " AND NOT `archive` AND NOT `blocked` AND NOT `pending`";
|
||||
|
@ -299,8 +298,8 @@ class Contact extends BaseModule
|
|||
$stmt = DBA::select('contact', [], $condition, ['order' => ['name'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]]);
|
||||
|
||||
while ($contact = DBA::fetch($stmt)) {
|
||||
$contact['blocked'] = Model\Contact\User::isBlocked($contact['id'], Session::getLocalUser());
|
||||
$contact['readonly'] = Model\Contact\User::isIgnored($contact['id'], Session::getLocalUser());
|
||||
$contact['blocked'] = Model\Contact\User::isBlocked($contact['id'], DI::userSession()->getLocalUserId());
|
||||
$contact['readonly'] = Model\Contact\User::isIgnored($contact['id'], DI::userSession()->getLocalUserId());
|
||||
$contacts[] = self::getContactTemplateVars($contact);
|
||||
}
|
||||
DBA::close($stmt);
|
||||
|
@ -424,7 +423,7 @@ class Contact extends BaseModule
|
|||
public static function getTabsHTML(array $contact, int $active_tab)
|
||||
{
|
||||
$cid = $pcid = $contact['id'];
|
||||
$data = Model\Contact::getPublicAndUserContactID($contact['id'], Session::getLocalUser());
|
||||
$data = Model\Contact::getPublicAndUserContactID($contact['id'], DI::userSession()->getLocalUserId());
|
||||
if (!empty($data['user']) && ($contact['id'] == $data['public'])) {
|
||||
$cid = $data['user'];
|
||||
} elseif (!empty($data['public'])) {
|
||||
|
@ -500,8 +499,8 @@ class Contact extends BaseModule
|
|||
{
|
||||
$alt_text = '';
|
||||
|
||||
if (!empty($contact['url']) && isset($contact['uid']) && ($contact['uid'] == 0) && Session::getLocalUser()) {
|
||||
$personal = Model\Contact::getByURL($contact['url'], false, ['uid', 'rel', 'self'], Session::getLocalUser());
|
||||
if (!empty($contact['url']) && isset($contact['uid']) && ($contact['uid'] == 0) && DI::userSession()->getLocalUserId()) {
|
||||
$personal = Model\Contact::getByURL($contact['url'], false, ['uid', 'rel', 'self'], DI::userSession()->getLocalUserId());
|
||||
if (!empty($personal)) {
|
||||
$contact['uid'] = $personal['uid'];
|
||||
$contact['rel'] = $personal['rel'];
|
||||
|
@ -509,7 +508,7 @@ class Contact extends BaseModule
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($contact['uid']) && !empty($contact['rel']) && Session::getLocalUser() == $contact['uid']) {
|
||||
if (!empty($contact['uid']) && !empty($contact['rel']) && DI::userSession()->getLocalUserId() == $contact['uid']) {
|
||||
switch ($contact['rel']) {
|
||||
case Model\Contact::FRIEND:
|
||||
$alt_text = DI::l10n()->t('Mutual Friendship');
|
||||
|
|
|
@ -28,7 +28,6 @@ use Friendica\Content\Widget;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
|
@ -57,7 +56,7 @@ class Advanced extends BaseModule
|
|||
$this->dba = $dba;
|
||||
$this->page = $page;
|
||||
|
||||
if (!Session::isAuthenticated()) {
|
||||
if (!DI::userSession()->isAuthenticated()) {
|
||||
throw new ForbiddenException($this->t('Permission denied.'));
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +65,7 @@ class Advanced extends BaseModule
|
|||
{
|
||||
$cid = $this->parameters['id'];
|
||||
|
||||
$contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => Session::getLocalUser()]);
|
||||
$contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
if (empty($contact)) {
|
||||
throw new BadRequestException($this->t('Contact not found.'));
|
||||
}
|
||||
|
@ -87,7 +86,7 @@ class Advanced extends BaseModule
|
|||
'nurl' => $nurl,
|
||||
'poll' => $poll,
|
||||
],
|
||||
['id' => $contact['id'], 'uid' => Session::getLocalUser()]
|
||||
['id' => $contact['id'], 'uid' => DI::userSession()->getLocalUserId()]
|
||||
);
|
||||
|
||||
if ($photo) {
|
||||
|
@ -105,7 +104,7 @@ class Advanced extends BaseModule
|
|||
{
|
||||
$cid = $this->parameters['id'];
|
||||
|
||||
$contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => Session::getLocalUser()]);
|
||||
$contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
if (empty($contact)) {
|
||||
throw new BadRequestException($this->t('Contact not found.'));
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\BaseModule;
|
|||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
use Friendica\Model\User;
|
||||
|
@ -36,7 +35,7 @@ class Contacts extends BaseModule
|
|||
{
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
|
@ -54,7 +53,7 @@ class Contacts extends BaseModule
|
|||
throw new HTTPException\NotFoundException(DI::l10n()->t('Contact not found.'));
|
||||
}
|
||||
|
||||
$localContactId = Model\Contact::getPublicIdByUserId(Session::getLocalUser());
|
||||
$localContactId = Model\Contact::getPublicIdByUserId(DI::userSession()->getLocalUserId());
|
||||
|
||||
DI::page()['aside'] = Widget\VCard::getHTML($contact);
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Module\Contact;
|
|||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -41,7 +40,7 @@ class Hovercard extends BaseModule
|
|||
$contact_url = $_REQUEST['url'] ?? '';
|
||||
|
||||
// Get out if the system doesn't have public access allowed
|
||||
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
|
||||
throw new HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
|
@ -70,8 +69,8 @@ class Hovercard extends BaseModule
|
|||
|
||||
// Search for contact data
|
||||
// Look if the local user has got the contact
|
||||
if (Session::isAuthenticated()) {
|
||||
$contact = Contact::getByURLForUser($contact_url, Session::getLocalUser());
|
||||
if (DI::userSession()->isAuthenticated()) {
|
||||
$contact = Contact::getByURLForUser($contact_url, DI::userSession()->getLocalUserId());
|
||||
} else {
|
||||
$contact = Contact::getByURL($contact_url, false);
|
||||
}
|
||||
|
@ -81,7 +80,7 @@ class Hovercard extends BaseModule
|
|||
}
|
||||
|
||||
// Get the photo_menu - the menu if possible contact actions
|
||||
if (Session::isAuthenticated()) {
|
||||
if (DI::userSession()->isAuthenticated()) {
|
||||
$actions = Contact::photoMenu($contact);
|
||||
} else {
|
||||
$actions = [];
|
||||
|
|
|
@ -75,7 +75,7 @@ class Profile extends BaseModule
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ class Profile extends BaseModule
|
|||
|
||||
// Backward compatibility: The update still needs a user-specific contact ID
|
||||
// Change to user-contact table check by version 2022.03
|
||||
$cdata = Contact::getPublicAndUserContactID($contact_id, Session::getLocalUser());
|
||||
$cdata = Contact::getPublicAndUserContactID($contact_id, DI::userSession()->getLocalUserId());
|
||||
if (empty($cdata['user']) || !DBA::exists('contact', ['id' => $cdata['user'], 'deleted' => false])) {
|
||||
return;
|
||||
}
|
||||
|
@ -125,20 +125,20 @@ class Profile extends BaseModule
|
|||
$fields['info'] = $_POST['info'];
|
||||
}
|
||||
|
||||
if (!Contact::update($fields, ['id' => $cdata['user'], 'uid' => Session::getLocalUser()])) {
|
||||
if (!Contact::update($fields, ['id' => $cdata['user'], 'uid' => DI::userSession()->getLocalUserId()])) {
|
||||
DI::sysmsg()->addNotice($this->t('Failed to update contact record.'));
|
||||
}
|
||||
}
|
||||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return Module\Security\Login::form($_SERVER['REQUEST_URI']);
|
||||
}
|
||||
|
||||
// Backward compatibility: Ensure to use the public contact when the user contact is provided
|
||||
// Remove by version 2022.03
|
||||
$data = Contact::getPublicAndUserContactID(intval($this->parameters['id']), Session::getLocalUser());
|
||||
$data = Contact::getPublicAndUserContactID(intval($this->parameters['id']), DI::userSession()->getLocalUserId());
|
||||
if (empty($data)) {
|
||||
throw new HTTPException\NotFoundException($this->t('Contact not found.'));
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ class Profile extends BaseModule
|
|||
throw new HTTPException\NotFoundException($this->t('Contact not found.'));
|
||||
}
|
||||
|
||||
$localRelationship = $this->localRelationship->getForUserContact(Session::getLocalUser(), $contact['id']);
|
||||
$localRelationship = $this->localRelationship->getForUserContact(DI::userSession()->getLocalUserId(), $contact['id']);
|
||||
|
||||
if ($localRelationship->rel === Contact::SELF) {
|
||||
$this->baseUrl->redirect('profile/' . $contact['nick'] . '/profile');
|
||||
|
@ -174,12 +174,12 @@ class Profile extends BaseModule
|
|||
if ($cmd === 'block') {
|
||||
if ($localRelationship->blocked) {
|
||||
// @TODO Backward compatibility, replace with $localRelationship->unblock()
|
||||
Contact\User::setBlocked($contact['id'], Session::getLocalUser(), false);
|
||||
Contact\User::setBlocked($contact['id'], DI::userSession()->getLocalUserId(), false);
|
||||
|
||||
$message = $this->t('Contact has been unblocked');
|
||||
} else {
|
||||
// @TODO Backward compatibility, replace with $localRelationship->block()
|
||||
Contact\User::setBlocked($contact['id'], Session::getLocalUser(), true);
|
||||
Contact\User::setBlocked($contact['id'], DI::userSession()->getLocalUserId(), true);
|
||||
$message = $this->t('Contact has been blocked');
|
||||
}
|
||||
|
||||
|
@ -190,12 +190,12 @@ class Profile extends BaseModule
|
|||
if ($cmd === 'ignore') {
|
||||
if ($localRelationship->ignored) {
|
||||
// @TODO Backward compatibility, replace with $localRelationship->unblock()
|
||||
Contact\User::setIgnored($contact['id'], Session::getLocalUser(), false);
|
||||
Contact\User::setIgnored($contact['id'], DI::userSession()->getLocalUserId(), false);
|
||||
|
||||
$message = $this->t('Contact has been unignored');
|
||||
} else {
|
||||
// @TODO Backward compatibility, replace with $localRelationship->block()
|
||||
Contact\User::setIgnored($contact['id'], Session::getLocalUser(), true);
|
||||
Contact\User::setIgnored($contact['id'], DI::userSession()->getLocalUserId(), true);
|
||||
$message = $this->t('Contact has been ignored');
|
||||
}
|
||||
|
||||
|
@ -224,8 +224,8 @@ class Profile extends BaseModule
|
|||
'$baseurl' => $this->baseUrl->get(true),
|
||||
]);
|
||||
|
||||
$contact['blocked'] = Contact\User::isBlocked($contact['id'], Session::getLocalUser());
|
||||
$contact['readonly'] = Contact\User::isIgnored($contact['id'], Session::getLocalUser());
|
||||
$contact['blocked'] = Contact\User::isBlocked($contact['id'], DI::userSession()->getLocalUserId());
|
||||
$contact['readonly'] = Contact\User::isIgnored($contact['id'], DI::userSession()->getLocalUserId());
|
||||
|
||||
switch ($localRelationship->rel) {
|
||||
case Contact::FRIEND: $relation_text = $this->t('You are mutual friends with %s', $contact['name']); break;
|
||||
|
@ -486,7 +486,7 @@ class Profile extends BaseModule
|
|||
*/
|
||||
private static function updateContactFromProbe(int $contact_id)
|
||||
{
|
||||
$contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => [0, Session::getLocalUser()], 'deleted' => false]);
|
||||
$contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => [0, DI::userSession()->getLocalUserId()], 'deleted' => false]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ use Friendica\Content\Nav;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
|
@ -55,11 +54,11 @@ class Revoke extends BaseModule
|
|||
|
||||
$this->dba = $dba;
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = Model\Contact::getPublicAndUserContactID($this->parameters['id'], Session::getLocalUser());
|
||||
$data = Model\Contact::getPublicAndUserContactID($this->parameters['id'], DI::userSession()->getLocalUserId());
|
||||
if (!$this->dba->isResult($data)) {
|
||||
throw new HTTPException\NotFoundException($this->t('Unknown contact.'));
|
||||
}
|
||||
|
@ -81,7 +80,7 @@ class Revoke extends BaseModule
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\UnauthorizedException();
|
||||
}
|
||||
|
||||
|
@ -96,7 +95,7 @@ class Revoke extends BaseModule
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return Login::form($_SERVER['REQUEST_URI']);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ use Friendica\Content\Text\HTML;
|
|||
use Friendica\Content\Widget;
|
||||
use Friendica\Content\Widget\TrendingTags;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -74,7 +73,7 @@ class Community extends BaseModule
|
|||
'$global_community_hint' => DI::l10n()->t("This community stream shows all public posts received by this node. They may not reflect the opinions of this node’s users.")
|
||||
]);
|
||||
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
|
||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
|
||||
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
|
||||
}
|
||||
|
@ -82,7 +81,7 @@ class Community extends BaseModule
|
|||
if (empty($_GET['mode']) || ($_GET['mode'] != 'raw')) {
|
||||
$tabs = [];
|
||||
|
||||
if ((Session::isAuthenticated() || in_array(self::$page_style, [self::LOCAL_AND_GLOBAL, self::LOCAL])) && empty(DI::config()->get('system', 'singleuser'))) {
|
||||
if ((DI::userSession()->isAuthenticated() || in_array(self::$page_style, [self::LOCAL_AND_GLOBAL, self::LOCAL])) && empty(DI::config()->get('system', 'singleuser'))) {
|
||||
$tabs[] = [
|
||||
'label' => DI::l10n()->t('Local Community'),
|
||||
'url' => 'community/local',
|
||||
|
@ -93,7 +92,7 @@ class Community extends BaseModule
|
|||
];
|
||||
}
|
||||
|
||||
if (Session::isAuthenticated() || in_array(self::$page_style, [self::LOCAL_AND_GLOBAL, self::GLOBAL])) {
|
||||
if (DI::userSession()->isAuthenticated() || in_array(self::$page_style, [self::LOCAL_AND_GLOBAL, self::GLOBAL])) {
|
||||
$tabs[] = [
|
||||
'label' => DI::l10n()->t('Global Community'),
|
||||
'url' => 'community/global',
|
||||
|
@ -111,7 +110,7 @@ class Community extends BaseModule
|
|||
|
||||
DI::page()['aside'] .= Widget::accountTypes('community/' . self::$content, self::$accountTypeString);
|
||||
|
||||
if (Session::getLocalUser() && DI::config()->get('system', 'community_no_sharer')) {
|
||||
if (DI::userSession()->getLocalUserId() && DI::config()->get('system', 'community_no_sharer')) {
|
||||
$path = self::$content;
|
||||
if (!empty($this->parameters['accounttype'])) {
|
||||
$path .= '/' . $this->parameters['accounttype'];
|
||||
|
@ -140,12 +139,12 @@ class Community extends BaseModule
|
|||
]);
|
||||
}
|
||||
|
||||
if (Feature::isEnabled(Session::getLocalUser(), 'trending_tags')) {
|
||||
if (Feature::isEnabled(DI::userSession()->getLocalUserId(), 'trending_tags')) {
|
||||
DI::page()['aside'] .= TrendingTags::getHTML(self::$content);
|
||||
}
|
||||
|
||||
// We need the editor here to be able to reshare an item.
|
||||
if (Session::isAuthenticated()) {
|
||||
if (DI::userSession()->isAuthenticated()) {
|
||||
$o .= DI::conversation()->statusEditor([], 0, true);
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +156,7 @@ class Community extends BaseModule
|
|||
return $o;
|
||||
}
|
||||
|
||||
$o .= DI::conversation()->create($items, 'community', false, false, 'commented', Session::getLocalUser());
|
||||
$o .= DI::conversation()->create($items, 'community', false, false, 'commented', DI::userSession()->getLocalUserId());
|
||||
|
||||
$pager = new BoundariesPager(
|
||||
DI::l10n(),
|
||||
|
@ -167,7 +166,7 @@ class Community extends BaseModule
|
|||
self::$itemsPerPage
|
||||
);
|
||||
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
|
||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
|
||||
$o .= HTML::scrollLoader();
|
||||
} else {
|
||||
$o .= $pager->renderMinimal(count($items));
|
||||
|
@ -184,7 +183,7 @@ class Community extends BaseModule
|
|||
*/
|
||||
protected function parseRequest()
|
||||
{
|
||||
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.'));
|
||||
}
|
||||
|
||||
|
@ -213,7 +212,7 @@ class Community extends BaseModule
|
|||
}
|
||||
|
||||
// Check if we are allowed to display the content to visitors
|
||||
if (!Session::isAuthenticated()) {
|
||||
if (!DI::userSession()->isAuthenticated()) {
|
||||
$available = self::$page_style == self::LOCAL_AND_GLOBAL;
|
||||
|
||||
if (!$available) {
|
||||
|
@ -230,10 +229,10 @@ class Community extends BaseModule
|
|||
}
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
|
||||
self::$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
} else {
|
||||
self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
|
||||
self::$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
}
|
||||
|
||||
|
@ -335,9 +334,9 @@ class Community extends BaseModule
|
|||
$condition[0] .= " AND `id` = ?";
|
||||
$condition[] = $item_id;
|
||||
} else {
|
||||
if (Session::getLocalUser() && !empty($_REQUEST['no_sharer'])) {
|
||||
if (DI::userSession()->getLocalUserId() && !empty($_REQUEST['no_sharer'])) {
|
||||
$condition[0] .= " AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `post-user`.`uid` = ?)";
|
||||
$condition[] = Session::getLocalUser();
|
||||
$condition[] = DI::userSession()->getLocalUserId();
|
||||
}
|
||||
|
||||
if (isset($max_id)) {
|
||||
|
|
|
@ -30,7 +30,6 @@ use Friendica\Content\Text\HTML;
|
|||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -78,7 +77,7 @@ class Network extends BaseModule
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
|
@ -88,8 +87,8 @@ class Network extends BaseModule
|
|||
|
||||
DI::page()['aside'] .= Widget::accountTypes($module, self::$accountTypeString);
|
||||
DI::page()['aside'] .= Group::sidebarWidget($module, $module . '/group', 'standard', self::$groupId);
|
||||
DI::page()['aside'] .= ForumManager::widget($module . '/forum', Session::getLocalUser(), self::$forumContactId);
|
||||
DI::page()['aside'] .= Widget::postedByYear($module . '/archive', Session::getLocalUser(), false);
|
||||
DI::page()['aside'] .= ForumManager::widget($module . '/forum', DI::userSession()->getLocalUserId(), self::$forumContactId);
|
||||
DI::page()['aside'] .= Widget::postedByYear($module . '/archive', DI::userSession()->getLocalUserId(), false);
|
||||
DI::page()['aside'] .= Widget::networks($module, !self::$forumContactId ? self::$network : '');
|
||||
DI::page()['aside'] .= Widget\SavedSearches::getHTML(DI::args()->getQueryString());
|
||||
DI::page()['aside'] .= Widget::fileAs('filed', '');
|
||||
|
@ -105,7 +104,7 @@ class Network extends BaseModule
|
|||
|
||||
$items = self::getItems($table, $params);
|
||||
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
|
||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
|
||||
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
|
||||
}
|
||||
|
@ -138,7 +137,7 @@ class Network extends BaseModule
|
|||
$allowedCids[] = (int) self::$forumContactId;
|
||||
} elseif (self::$network) {
|
||||
$condition = [
|
||||
'uid' => Session::getLocalUser(),
|
||||
'uid' => DI::userSession()->getLocalUserId(),
|
||||
'network' => self::$network,
|
||||
'self' => false,
|
||||
'blocked' => false,
|
||||
|
@ -168,7 +167,7 @@ class Network extends BaseModule
|
|||
}
|
||||
|
||||
if (self::$groupId) {
|
||||
$group = DBA::selectFirst('group', ['name'], ['id' => self::$groupId, 'uid' => Session::getLocalUser()]);
|
||||
$group = DBA::selectFirst('group', ['name'], ['id' => self::$groupId, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
if (!DBA::isResult($group)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('No such group'));
|
||||
}
|
||||
|
@ -199,9 +198,9 @@ class Network extends BaseModule
|
|||
$ordering = '`commented`';
|
||||
}
|
||||
|
||||
$o .= DI::conversation()->create($items, 'network', false, false, $ordering, Session::getLocalUser());
|
||||
$o .= DI::conversation()->create($items, 'network', false, false, $ordering, DI::userSession()->getLocalUserId());
|
||||
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
|
||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
|
||||
$o .= HTML::scrollLoader();
|
||||
} else {
|
||||
$pager = new BoundariesPager(
|
||||
|
@ -307,7 +306,7 @@ class Network extends BaseModule
|
|||
|
||||
self::$forumContactId = $this->parameters['contact_id'] ?? 0;
|
||||
|
||||
self::$selectedTab = DI::session()->get('network-tab', DI::pConfig()->get(Session::getLocalUser(), 'network.view', 'selected_tab', ''));
|
||||
self::$selectedTab = DI::session()->get('network-tab', DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'network.view', 'selected_tab', ''));
|
||||
|
||||
if (!empty($get['star'])) {
|
||||
self::$selectedTab = 'star';
|
||||
|
@ -346,7 +345,7 @@ class Network extends BaseModule
|
|||
}
|
||||
|
||||
DI::session()->set('network-tab', self::$selectedTab);
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'network.view', 'selected_tab', self::$selectedTab);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'network.view', 'selected_tab', self::$selectedTab);
|
||||
|
||||
self::$accountTypeString = $get['accounttype'] ?? $this->parameters['accounttype'] ?? '';
|
||||
self::$accountType = User::getAccountTypeByString(self::$accountTypeString);
|
||||
|
@ -357,10 +356,10 @@ class Network extends BaseModule
|
|||
self::$dateTo = $this->parameters['to'] ?? '';
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
|
||||
self::$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
} else {
|
||||
self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
|
||||
self::$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
}
|
||||
|
||||
|
@ -385,7 +384,7 @@ class Network extends BaseModule
|
|||
|
||||
protected static function getItems(string $table, array $params, array $conditionFields = [])
|
||||
{
|
||||
$conditionFields['uid'] = Session::getLocalUser();
|
||||
$conditionFields['uid'] = DI::userSession()->getLocalUserId();
|
||||
$conditionStrings = [];
|
||||
|
||||
if (!is_null(self::$accountType)) {
|
||||
|
@ -414,7 +413,7 @@ class Network extends BaseModule
|
|||
} elseif (self::$forumContactId) {
|
||||
$conditionStrings = DBA::mergeConditions($conditionStrings,
|
||||
["((`contact-id` = ?) OR `uri-id` IN (SELECT `parent-uri-id` FROM `post-user-view` WHERE (`contact-id` = ? AND `gravity` = ? AND `vid` = ? AND `uid` = ?)))",
|
||||
self::$forumContactId, self::$forumContactId, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Session::getLocalUser()]);
|
||||
self::$forumContactId, self::$forumContactId, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), DI::userSession()->getLocalUserId()]);
|
||||
}
|
||||
|
||||
// Currently only the order modes "received" and "commented" are in use
|
||||
|
@ -478,10 +477,10 @@ class Network extends BaseModule
|
|||
// level which items you've seen and which you haven't. If you're looking
|
||||
// at the top level network page just mark everything seen.
|
||||
if (!self::$groupId && !self::$forumContactId && !self::$star && !self::$mention) {
|
||||
$condition = ['unseen' => true, 'uid' => Session::getLocalUser()];
|
||||
$condition = ['unseen' => true, 'uid' => DI::userSession()->getLocalUserId()];
|
||||
self::setItemsSeenByCondition($condition);
|
||||
} elseif (!empty($parents)) {
|
||||
$condition = ['unseen' => true, 'uid' => Session::getLocalUser(), 'parent-uri-id' => $parents];
|
||||
$condition = ['unseen' => true, 'uid' => DI::userSession()->getLocalUserId(), 'parent-uri-id' => $parents];
|
||||
self::setItemsSeenByCondition($condition);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Module\Debug;
|
|||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\JsonLD;
|
||||
|
@ -42,7 +41,7 @@ class ActivityPubConversion extends BaseModule
|
|||
try {
|
||||
$source = json_decode($_REQUEST['source'], true);
|
||||
$trust_source = true;
|
||||
$uid = Session::getLocalUser();
|
||||
$uid = DI::userSession()->getLocalUserId();
|
||||
$push = false;
|
||||
|
||||
if (!$source) {
|
||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\App;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
use Friendica\Module\Response;
|
||||
|
@ -49,7 +48,7 @@ class Feed extends BaseModule
|
|||
|
||||
$this->httpClient = $httpClient;
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
DI::sysmsg()->addNotice($this->t('You must be logged in to use this module'));
|
||||
$baseUrl->redirect();
|
||||
}
|
||||
|
@ -61,7 +60,7 @@ class Feed extends BaseModule
|
|||
if (!empty($_REQUEST['url'])) {
|
||||
$url = $_REQUEST['url'];
|
||||
|
||||
$contact = Model\Contact::getByURLForUser($url, Session::getLocalUser(), null);
|
||||
$contact = Model\Contact::getByURLForUser($url, DI::userSession()->getLocalUserId(), null);
|
||||
|
||||
$xml = $this->httpClient->fetch($contact['poll'], HttpClientAccept::FEED_XML);
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module\Debug;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Post;
|
||||
|
@ -35,7 +34,7 @@ class ItemBody extends BaseModule
|
|||
{
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access denied.'));
|
||||
}
|
||||
|
||||
|
@ -45,7 +44,7 @@ class ItemBody extends BaseModule
|
|||
|
||||
$itemId = intval($this->parameters['item']);
|
||||
|
||||
$item = Post::selectFirst(['body'], ['uid' => [0, Session::getLocalUser()], 'uri-id' => $itemId]);
|
||||
$item = Post::selectFirst(['body'], ['uid' => [0, DI::userSession()->getLocalUserId()], 'uri-id' => $itemId]);
|
||||
|
||||
if (!empty($item)) {
|
||||
if (DI::mode()->isAjax()) {
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Module\Debug;
|
|||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Network\Probe as NetworkProbe;
|
||||
|
@ -35,7 +34,7 @@ class Probe extends BaseModule
|
|||
{
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a probing.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Module\Debug;
|
|||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\Probe;
|
||||
|
||||
|
@ -34,7 +33,7 @@ class WebFinger extends BaseModule
|
|||
{
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a probing.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace Friendica\Module;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Notification;
|
||||
|
@ -39,11 +38,11 @@ class Delegation extends BaseModule
|
|||
{
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$uid = Session::getLocalUser();
|
||||
$uid = DI::userSession()->getLocalUserId();
|
||||
$orig_record = User::getById(DI::app()->getLoggedInUserId());
|
||||
|
||||
if (DI::session()->get('submanage')) {
|
||||
|
@ -115,11 +114,11 @@ class Delegation extends BaseModule
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
$identities = User::identities(DI::session()->get('submanage', Session::getLocalUser()));
|
||||
$identities = User::identities(DI::session()->get('submanage', DI::userSession()->getLocalUserId()));
|
||||
|
||||
//getting additinal information for each identity
|
||||
foreach ($identities as $key => $identity) {
|
||||
|
|
|
@ -26,7 +26,6 @@ use Friendica\Content\Nav;
|
|||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\DI;
|
||||
|
@ -44,12 +43,12 @@ class Directory extends BaseModule
|
|||
$app = DI::app();
|
||||
$config = DI::config();
|
||||
|
||||
if (($config->get('system', 'block_public') && !Session::isAuthenticated()) ||
|
||||
($config->get('system', 'block_local_dir') && !Session::isAuthenticated())) {
|
||||
if (($config->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) ||
|
||||
($config->get('system', 'block_local_dir') && !DI::userSession()->isAuthenticated())) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.'));
|
||||
}
|
||||
|
||||
if (Session::getLocalUser()) {
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
DI::page()['aside'] .= Widget::findPeople();
|
||||
DI::page()['aside'] .= Widget::follow();
|
||||
}
|
||||
|
@ -75,7 +74,7 @@ class Directory extends BaseModule
|
|||
DI::sysmsg()->addNotice(DI::l10n()->t('No entries (some entries may be hidden).'));
|
||||
} else {
|
||||
foreach ($profiles['entries'] as $entry) {
|
||||
$contact = Model\Contact::getByURLForUser($entry['url'], Session::getLocalUser());
|
||||
$contact = Model\Contact::getByURLForUser($entry['url'], DI::userSession()->getLocalUserId());
|
||||
if (!empty($contact)) {
|
||||
$entries[] = Contact::getContactTemplateVars($contact);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
namespace Friendica\Module\Events;
|
||||
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -36,7 +35,7 @@ class Json extends \Friendica\BaseModule
|
|||
{
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\UnauthorizedException();
|
||||
}
|
||||
|
||||
|
@ -70,9 +69,9 @@ class Json extends \Friendica\BaseModule
|
|||
|
||||
// get events by id or by date
|
||||
if ($event_params['event_id']) {
|
||||
$r = Event::getListById(Session::getLocalUser(), $event_params['event_id']);
|
||||
$r = Event::getListById(DI::userSession()->getLocalUserId(), $event_params['event_id']);
|
||||
} else {
|
||||
$r = Event::getListByDate(Session::getLocalUser(), $event_params);
|
||||
$r = Event::getListByDate(DI::userSession()->getLocalUserId(), $event_params);
|
||||
}
|
||||
|
||||
$links = [];
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Protocol\Feed as ProtocolFeed;
|
||||
|
@ -47,7 +46,7 @@ class Feed extends BaseModule
|
|||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$last_update = $this->getRequestValue($request, 'last_update', '');
|
||||
$nocache = !empty($request['nocache']) && Session::getLocalUser();
|
||||
$nocache = !empty($request['nocache']) && DI::userSession()->getLocalUserId();
|
||||
|
||||
$type = null;
|
||||
// @TODO: Replace with parameter from router
|
||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\App;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
|
@ -44,7 +43,7 @@ class SaveTag extends BaseModule
|
|||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
DI::sysmsg()->addNotice($this->t('You must be logged in to use this module'));
|
||||
$baseUrl->redirect();
|
||||
}
|
||||
|
@ -63,11 +62,11 @@ class SaveTag extends BaseModule
|
|||
if (!DBA::isResult($item)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
Model\Post\Category::storeFileByURIId($item['uri-id'], Session::getLocalUser(), Model\Post\Category::FILE, $term);
|
||||
Model\Post\Category::storeFileByURIId($item['uri-id'], DI::userSession()->getLocalUserId(), Model\Post\Category::FILE, $term);
|
||||
}
|
||||
|
||||
// return filer dialog
|
||||
$filetags = Model\Post\Category::getArray(Session::getLocalUser(), Model\Post\Category::FILE);
|
||||
$filetags = Model\Post\Category::getArray(DI::userSession()->getLocalUserId(), Model\Post\Category::FILE);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
|
||||
echo Renderer::replaceMacros($tpl, [
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
||||
|
@ -34,7 +33,7 @@ class FollowConfirm extends BaseModule
|
|||
protected function post(array $request = [])
|
||||
{
|
||||
parent::post($request);
|
||||
$uid = Session::getLocalUser();
|
||||
$uid = DI::userSession()->getLocalUserId();
|
||||
if (!$uid) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
|
||||
return;
|
||||
|
@ -44,7 +43,7 @@ class FollowConfirm extends BaseModule
|
|||
$duplex = intval($_POST['duplex'] ?? 0);
|
||||
$hidden = intval($_POST['hidden'] ?? 0);
|
||||
|
||||
$intro = DI::intro()->selectOneById($intro_id, Session::getLocalUser());
|
||||
$intro = DI::intro()->selectOneById($intro_id, DI::userSession()->getLocalUserId());
|
||||
|
||||
Contact\Introduction::confirm($intro, $duplex, $hidden);
|
||||
DI::intro()->delete($intro);
|
||||
|
|
|
@ -26,7 +26,6 @@ use Friendica\BaseModule;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\DI;
|
||||
|
@ -54,7 +53,7 @@ class FriendSuggest extends BaseModule
|
|||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new ForbiddenException($this->t('Permission denied.'));
|
||||
}
|
||||
|
||||
|
@ -68,7 +67,7 @@ class FriendSuggest extends BaseModule
|
|||
$cid = intval($this->parameters['contact']);
|
||||
|
||||
// We do query the "uid" as well to ensure that it is our contact
|
||||
if (!$this->dba->exists('contact', ['id' => $cid, 'uid' => Session::getLocalUser()])) {
|
||||
if (!$this->dba->exists('contact', ['id' => $cid, 'uid' => DI::userSession()->getLocalUserId()])) {
|
||||
throw new NotFoundException($this->t('Contact not found.'));
|
||||
}
|
||||
|
||||
|
@ -78,7 +77,7 @@ class FriendSuggest extends BaseModule
|
|||
}
|
||||
|
||||
// We do query the "uid" as well to ensure that it is our contact
|
||||
$contact = $this->dba->selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => Session::getLocalUser()]);
|
||||
$contact = $this->dba->selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
if (empty($contact)) {
|
||||
DI::sysmsg()->addNotice($this->t('Suggested contact not found.'));
|
||||
return;
|
||||
|
@ -87,7 +86,7 @@ class FriendSuggest extends BaseModule
|
|||
$note = Strings::escapeHtml(trim($_POST['note'] ?? ''));
|
||||
|
||||
$suggest = $this->friendSuggestRepo->save($this->friendSuggestFac->createNew(
|
||||
Session::getLocalUser(),
|
||||
DI::userSession()->getLocalUserId(),
|
||||
$cid,
|
||||
$contact['name'],
|
||||
$contact['url'],
|
||||
|
@ -105,7 +104,7 @@ class FriendSuggest extends BaseModule
|
|||
{
|
||||
$cid = intval($this->parameters['contact']);
|
||||
|
||||
$contact = $this->dba->selectFirst('contact', [], ['id' => $cid, 'uid' => Session::getLocalUser()]);
|
||||
$contact = $this->dba->selectFirst('contact', [], ['id' => $cid, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
if (empty($contact)) {
|
||||
DI::sysmsg()->addNotice($this->t('Contact not found.'));
|
||||
$this->baseUrl->redirect();
|
||||
|
@ -121,7 +120,7 @@ class FriendSuggest extends BaseModule
|
|||
AND NOT `archive`
|
||||
AND NOT `deleted`
|
||||
AND `notify` != ""',
|
||||
Session::getLocalUser(),
|
||||
DI::userSession()->getLocalUserId(),
|
||||
$cid,
|
||||
Protocol::DFRN,
|
||||
]);
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Module;
|
|||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -37,7 +36,7 @@ class Group extends BaseModule
|
|||
$this->ajaxPost();
|
||||
}
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
|
||||
DI::baseUrl()->redirect();
|
||||
}
|
||||
|
@ -47,9 +46,9 @@ class Group extends BaseModule
|
|||
BaseModule::checkFormSecurityTokenRedirectOnError('/group/new', 'group_edit');
|
||||
|
||||
$name = trim($request['groupname']);
|
||||
$r = Model\Group::create(Session::getLocalUser(), $name);
|
||||
$r = Model\Group::create(DI::userSession()->getLocalUserId(), $name);
|
||||
if ($r) {
|
||||
$r = Model\Group::getIdByName(Session::getLocalUser(), $name);
|
||||
$r = Model\Group::getIdByName(DI::userSession()->getLocalUserId(), $name);
|
||||
if ($r) {
|
||||
DI::baseUrl()->redirect('group/' . $r);
|
||||
}
|
||||
|
@ -63,7 +62,7 @@ class Group extends BaseModule
|
|||
if ((DI::args()->getArgc() == 2) && intval(DI::args()->getArgv()[1])) {
|
||||
BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_edit');
|
||||
|
||||
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => Session::getLocalUser()]);
|
||||
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
if (!DBA::isResult($group)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
|
||||
DI::baseUrl()->redirect('contact');
|
||||
|
@ -80,7 +79,7 @@ class Group extends BaseModule
|
|||
public function ajaxPost()
|
||||
{
|
||||
try {
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new \Exception(DI::l10n()->t('Permission denied.'), 403);
|
||||
}
|
||||
|
||||
|
@ -88,12 +87,12 @@ class Group extends BaseModule
|
|||
$group_id = $this->parameters['group'];
|
||||
$contact_id = $this->parameters['contact'];
|
||||
|
||||
if (!Model\Group::exists($group_id, Session::getLocalUser())) {
|
||||
if (!Model\Group::exists($group_id, DI::userSession()->getLocalUserId())) {
|
||||
throw new \Exception(DI::l10n()->t('Unknown group.'), 404);
|
||||
}
|
||||
|
||||
// @TODO Backward compatibility with user contacts, remove by version 2022.03
|
||||
$cdata = Model\Contact::getPublicAndUserContactID($contact_id, Session::getLocalUser());
|
||||
$cdata = Model\Contact::getPublicAndUserContactID($contact_id, DI::userSession()->getLocalUserId());
|
||||
if (empty($cdata['public'])) {
|
||||
throw new \Exception(DI::l10n()->t('Contact not found.'), 404);
|
||||
}
|
||||
|
@ -143,7 +142,7 @@ class Group extends BaseModule
|
|||
{
|
||||
$change = false;
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new \Friendica\Network\HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
|
@ -158,7 +157,7 @@ class Group extends BaseModule
|
|||
}
|
||||
|
||||
// Switch to text mode interface if we have more than 'n' contacts or group members
|
||||
$switchtotext = DI::pConfig()->get(Session::getLocalUser(), 'system', 'groupedit_image_limit');
|
||||
$switchtotext = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'groupedit_image_limit');
|
||||
if (is_null($switchtotext)) {
|
||||
$switchtotext = DI::config()->get('system', 'groupedit_image_limit', 200);
|
||||
}
|
||||
|
@ -210,7 +209,7 @@ class Group extends BaseModule
|
|||
|
||||
// @TODO: Replace with parameter from router
|
||||
if (intval(DI::args()->getArgv()[2])) {
|
||||
if (!Model\Group::exists(DI::args()->getArgv()[2], Session::getLocalUser())) {
|
||||
if (!Model\Group::exists(DI::args()->getArgv()[2], DI::userSession()->getLocalUserId())) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
|
||||
DI::baseUrl()->redirect('contact');
|
||||
}
|
||||
|
@ -226,14 +225,14 @@ class Group extends BaseModule
|
|||
if ((DI::args()->getArgc() > 2) && intval(DI::args()->getArgv()[1]) && intval(DI::args()->getArgv()[2])) {
|
||||
BaseModule::checkFormSecurityTokenForbiddenOnError('group_member_change', 't');
|
||||
|
||||
if (DBA::exists('contact', ['id' => DI::args()->getArgv()[2], 'uid' => Session::getLocalUser(), 'self' => false, 'pending' => false, 'blocked' => false])) {
|
||||
if (DBA::exists('contact', ['id' => DI::args()->getArgv()[2], 'uid' => DI::userSession()->getLocalUserId(), 'self' => false, 'pending' => false, 'blocked' => false])) {
|
||||
$change = intval(DI::args()->getArgv()[2]);
|
||||
}
|
||||
}
|
||||
|
||||
// @TODO: Replace with parameter from router
|
||||
if ((DI::args()->getArgc() > 1) && intval(DI::args()->getArgv()[1])) {
|
||||
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => Session::getLocalUser(), 'deleted' => false]);
|
||||
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => DI::userSession()->getLocalUserId(), 'deleted' => false]);
|
||||
if (!DBA::isResult($group)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
|
||||
DI::baseUrl()->redirect('contact');
|
||||
|
@ -316,11 +315,11 @@ class Group extends BaseModule
|
|||
}
|
||||
|
||||
if ($nogroup) {
|
||||
$contacts = Model\Contact\Group::listUngrouped(Session::getLocalUser());
|
||||
$contacts = Model\Contact\Group::listUngrouped(DI::userSession()->getLocalUserId());
|
||||
} else {
|
||||
$contacts_stmt = DBA::select('contact', [],
|
||||
['rel' => [Model\Contact::FOLLOWER, Model\Contact::FRIEND, Model\Contact::SHARING],
|
||||
'uid' => Session::getLocalUser(), 'pending' => false, 'blocked' => false, 'failed' => false, 'self' => false],
|
||||
'uid' => DI::userSession()->getLocalUserId(), 'pending' => false, 'blocked' => false, 'failed' => false, 'self' => false],
|
||||
['order' => ['name']]
|
||||
);
|
||||
$contacts = DBA::toArray($contacts_stmt);
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Model\User;
|
||||
|
@ -36,7 +35,7 @@ class HCard extends BaseModule
|
|||
{
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (Session::getLocalUser() && ($this->parameters['action'] ?? '') === 'view') {
|
||||
if (DI::userSession()->getLocalUserId() && ($this->parameters['action'] ?? '') === 'view') {
|
||||
// A logged in user views a profile of a user
|
||||
$nickname = DI::app()->getLoggedInUserNickname();
|
||||
} elseif (empty($this->parameters['action'])) {
|
||||
|
@ -78,7 +77,7 @@ class HCard extends BaseModule
|
|||
$page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"" . $baseUrl->get() . "/dfrn_{$dfrn}/{$nickname}\" />\r\n";
|
||||
}
|
||||
|
||||
$block = (DI::config()->get('system', 'block_public') && !Session::isAuthenticated());
|
||||
$block = (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated());
|
||||
|
||||
// check if blocked
|
||||
if ($block) {
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace Friendica\Module;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Security\Login;
|
||||
|
||||
|
@ -43,7 +42,7 @@ class Home extends BaseModule
|
|||
|
||||
Hook::callAll('home_init', $ret);
|
||||
|
||||
if (Session::getLocalUser() && ($app->getLoggedInUserNickname())) {
|
||||
if (DI::userSession()->getLocalUserId() && ($app->getLoggedInUserNickname())) {
|
||||
DI::baseUrl()->redirect('network');
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace Friendica\Module;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
use Friendica\Model\User;
|
||||
|
@ -39,7 +38,7 @@ class Invite extends BaseModule
|
|||
{
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
|
@ -53,7 +52,7 @@ class Invite extends BaseModule
|
|||
$max_invites = 50;
|
||||
}
|
||||
|
||||
$current_invites = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'sent_invites'));
|
||||
$current_invites = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'sent_invites'));
|
||||
if ($current_invites > $max_invites) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Total invitation limit exceeded.'));
|
||||
}
|
||||
|
@ -68,13 +67,13 @@ class Invite extends BaseModule
|
|||
|
||||
if ($config->get('system', 'invitation_only')) {
|
||||
$invitation_only = true;
|
||||
$invites_remaining = DI::pConfig()->get(Session::getLocalUser(), 'system', 'invites_remaining');
|
||||
$invites_remaining = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'invites_remaining');
|
||||
if ((!$invites_remaining) && (!$app->isSiteAdmin())) {
|
||||
throw new HTTPException\ForbiddenException();
|
||||
}
|
||||
}
|
||||
|
||||
$user = User::getById(Session::getLocalUser());
|
||||
$user = User::getById(DI::userSession()->getLocalUserId());
|
||||
|
||||
foreach ($recipients as $recipient) {
|
||||
$recipient = trim($recipient);
|
||||
|
@ -91,7 +90,7 @@ class Invite extends BaseModule
|
|||
if (!$app->isSiteAdmin()) {
|
||||
$invites_remaining--;
|
||||
if ($invites_remaining >= 0) {
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'invites_remaining', $invites_remaining);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'invites_remaining', $invites_remaining);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -113,7 +112,7 @@ class Invite extends BaseModule
|
|||
if ($res) {
|
||||
$total++;
|
||||
$current_invites++;
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'system', 'sent_invites', $current_invites);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'sent_invites', $current_invites);
|
||||
if ($current_invites > $max_invites) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Invitation limit exceeded. Please contact your site administrator.'));
|
||||
return;
|
||||
|
@ -128,7 +127,7 @@ class Invite extends BaseModule
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
|
@ -139,7 +138,7 @@ class Invite extends BaseModule
|
|||
|
||||
if ($config->get('system', 'invitation_only')) {
|
||||
$inviteOnly = true;
|
||||
$x = DI::pConfig()->get(Session::getLocalUser(), 'system', 'invites_remaining');
|
||||
$x = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'invites_remaining');
|
||||
if ((!$x) && (!$app->isSiteAdmin())) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('You have no more invitations available'));
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ use Friendica\Core\Protocol;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Protocol\Diaspora;
|
||||
|
@ -39,7 +38,7 @@ class Activity extends BaseModule
|
|||
{
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
if (!Session::isAuthenticated()) {
|
||||
if (!DI::userSession()->isAuthenticated()) {
|
||||
throw new HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
|
@ -51,13 +50,13 @@ class Activity extends BaseModule
|
|||
$itemId = $this->parameters['id'];
|
||||
|
||||
if (in_array($verb, ['announce', 'unannounce'])) {
|
||||
$item = Post::selectFirst(['network', 'uri-id'], ['id' => $itemId, 'uid' => [Session::getLocalUser(), 0]]);
|
||||
$item = Post::selectFirst(['network', 'uri-id'], ['id' => $itemId, 'uid' => [DI::userSession()->getLocalUserId(), 0]]);
|
||||
if ($item['network'] == Protocol::DIASPORA) {
|
||||
Diaspora::performReshare($item['uri-id'], Session::getLocalUser());
|
||||
Diaspora::performReshare($item['uri-id'], DI::userSession()->getLocalUserId());
|
||||
}
|
||||
}
|
||||
|
||||
if (!Item::performActivity($itemId, $verb, Session::getLocalUser())) {
|
||||
if (!Item::performActivity($itemId, $verb, DI::userSession()->getLocalUserId())) {
|
||||
throw new HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ use Friendica\Core\Hook;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Theme;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -89,7 +88,7 @@ class Compose extends BaseModule
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return Login::form('compose');
|
||||
}
|
||||
|
||||
|
@ -111,7 +110,7 @@ class Compose extends BaseModule
|
|||
}
|
||||
}
|
||||
|
||||
$user = User::getById(Session::getLocalUser(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'default-location']);
|
||||
$user = User::getById(DI::userSession()->getLocalUserId(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'default-location']);
|
||||
|
||||
$contact_allow_list = $this->ACLFormatter->expand($user['allow_cid']);
|
||||
$group_allow_list = $this->ACLFormatter->expand($user['allow_gid']);
|
||||
|
@ -168,7 +167,7 @@ class Compose extends BaseModule
|
|||
|
||||
$contact = Contact::getById($a->getContactId());
|
||||
|
||||
if ($this->pConfig->get(Session::getLocalUser(), 'system', 'set_creation_date')) {
|
||||
if ($this->pConfig->get(DI::userSession()->getLocalUserId(), 'system', 'set_creation_date')) {
|
||||
$created_at = Temporal::getDateTimeField(
|
||||
new \DateTime(DBA::NULL_DATETIME),
|
||||
new \DateTime('now'),
|
||||
|
@ -204,8 +203,8 @@ class Compose extends BaseModule
|
|||
'location_disabled' => $this->l10n->t('Location services are disabled. Please check the website\'s permissions on your device'),
|
||||
'wait' => $this->l10n->t('Please wait'),
|
||||
'placeholdertitle' => $this->l10n->t('Set title'),
|
||||
'placeholdercategory' => Feature::isEnabled(Session::getLocalUser(),'categories') ? $this->l10n->t('Categories (comma-separated list)') : '',
|
||||
'always_open_compose' => $this->pConfig->get(Session::getLocalUser(), 'frio', 'always_open_compose',
|
||||
'placeholdercategory' => Feature::isEnabled(DI::userSession()->getLocalUserId(),'categories') ? $this->l10n->t('Categories (comma-separated list)') : '',
|
||||
'always_open_compose' => $this->pConfig->get(DI::userSession()->getLocalUserId(), 'frio', 'always_open_compose',
|
||||
$this->config->get('frio', 'always_open_compose', false)) ? '' :
|
||||
$this->l10n->t('You can make this page always open when you use the New Post button in the <a href="/settings/display">Theme Customization settings</a>.'),
|
||||
],
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module\Item;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -38,7 +37,7 @@ class Follow extends BaseModule
|
|||
{
|
||||
$l10n = DI::l10n();
|
||||
|
||||
if (!Session::isAuthenticated()) {
|
||||
if (!DI::userSession()->isAuthenticated()) {
|
||||
throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
|
||||
}
|
||||
|
||||
|
@ -48,7 +47,7 @@ class Follow extends BaseModule
|
|||
|
||||
$itemId = intval($this->parameters['id']);
|
||||
|
||||
if (!Item::performActivity($itemId, 'follow', Session::getLocalUser())) {
|
||||
if (!Item::performActivity($itemId, 'follow', DI::userSession()->getLocalUserId())) {
|
||||
throw new HTTPException\BadRequestException($l10n->t('Unable to follow this item.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module\Item;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -38,7 +37,7 @@ class Ignore extends BaseModule
|
|||
{
|
||||
$l10n = DI::l10n();
|
||||
|
||||
if (!Session::isAuthenticated()) {
|
||||
if (!DI::userSession()->isAuthenticated()) {
|
||||
throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
|
||||
}
|
||||
|
||||
|
@ -55,10 +54,10 @@ class Ignore extends BaseModule
|
|||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
$ignored = !Post\ThreadUser::getIgnored($thread['uri-id'], Session::getLocalUser());
|
||||
$ignored = !Post\ThreadUser::getIgnored($thread['uri-id'], DI::userSession()->getLocalUserId());
|
||||
|
||||
if (in_array($thread['uid'], [0, Session::getLocalUser()])) {
|
||||
Post\ThreadUser::setIgnored($thread['uri-id'], Session::getLocalUser(), $ignored);
|
||||
if (in_array($thread['uid'], [0, DI::userSession()->getLocalUserId()])) {
|
||||
Post\ThreadUser::setIgnored($thread['uri-id'], DI::userSession()->getLocalUserId(), $ignored);
|
||||
} else {
|
||||
throw new HTTPException\BadRequestException();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module\Item;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -38,7 +37,7 @@ class Pin extends BaseModule
|
|||
{
|
||||
$l10n = DI::l10n();
|
||||
|
||||
if (!Session::isAuthenticated()) {
|
||||
if (!DI::userSession()->isAuthenticated()) {
|
||||
throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
|
||||
}
|
||||
|
||||
|
@ -53,16 +52,16 @@ class Pin extends BaseModule
|
|||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
if (!in_array($item['uid'], [0, Session::getLocalUser()])) {
|
||||
if (!in_array($item['uid'], [0, DI::userSession()->getLocalUserId()])) {
|
||||
throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
|
||||
}
|
||||
|
||||
$pinned = !$item['featured'];
|
||||
|
||||
if ($pinned) {
|
||||
Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, $item['author-id'], Session::getLocalUser());
|
||||
Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, $item['author-id'], DI::userSession()->getLocalUserId());
|
||||
} else {
|
||||
Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, Session::getLocalUser());
|
||||
Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, DI::userSession()->getLocalUserId());
|
||||
}
|
||||
|
||||
// See if we've been passed a return path to redirect to
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module\Item;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -39,7 +38,7 @@ class Star extends BaseModule
|
|||
{
|
||||
$l10n = DI::l10n();
|
||||
|
||||
if (!Session::isAuthenticated()) {
|
||||
if (!DI::userSession()->isAuthenticated()) {
|
||||
throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
|
||||
}
|
||||
|
||||
|
@ -50,13 +49,13 @@ class Star extends BaseModule
|
|||
$itemId = intval($this->parameters['id']);
|
||||
|
||||
|
||||
$item = Post::selectFirstForUser(Session::getLocalUser(), ['uid', 'uri-id', 'starred'], ['uid' => [0, Session::getLocalUser()], 'id' => $itemId]);
|
||||
$item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), ['uid', 'uri-id', 'starred'], ['uid' => [0, DI::userSession()->getLocalUserId()], 'id' => $itemId]);
|
||||
if (empty($item)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
if ($item['uid'] == 0) {
|
||||
$stored = Item::storeForUserByUriId($item['uri-id'], Session::getLocalUser(), ['post-reason' => Item::PR_ACTIVITY]);
|
||||
$stored = Item::storeForUserByUriId($item['uri-id'], DI::userSession()->getLocalUserId(), ['post-reason' => Item::PR_ACTIVITY]);
|
||||
if (!empty($stored)) {
|
||||
$item = Post::selectFirst(['starred'], ['id' => $stored]);
|
||||
if (!DBA::isResult($item)) {
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -43,7 +42,7 @@ class NoScrape extends BaseModule
|
|||
if (isset($this->parameters['nick'])) {
|
||||
// Get infos about a specific nick (public)
|
||||
$which = $this->parameters['nick'];
|
||||
} elseif (Session::getLocalUser() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') {
|
||||
} elseif (DI::userSession()->getLocalUserId() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') {
|
||||
// view infos about a known profile (needs a login)
|
||||
$which = $a->getLoggedInUserNickname();
|
||||
} else {
|
||||
|
|
|
@ -30,7 +30,6 @@ use Friendica\Content\Text\BBCode;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\BaseNotifications;
|
||||
|
@ -99,7 +98,7 @@ class Introductions extends BaseNotifications
|
|||
'text' => (!$all ? $this->t('Show Ignored Requests') : $this->t('Hide Ignored Requests')),
|
||||
];
|
||||
|
||||
$owner = User::getOwnerDataById(Session::getLocalUser());
|
||||
$owner = User::getOwnerDataById(DI::userSession()->getLocalUserId());
|
||||
|
||||
// Loop through all introduction notifications.This creates an array with the output html for each
|
||||
// introduction
|
||||
|
|
|
@ -26,7 +26,6 @@ use Friendica\BaseModule;
|
|||
use Friendica\Contact\Introduction\Repository\Introduction;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -73,14 +72,14 @@ class Notification extends BaseModule
|
|||
*/
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\UnauthorizedException($this->l10n->t('Permission denied.'));
|
||||
}
|
||||
|
||||
$request_id = $this->parameters['id'] ?? false;
|
||||
|
||||
if ($request_id) {
|
||||
$intro = $this->introductionRepo->selectOneById($request_id, Session::getLocalUser());
|
||||
$intro = $this->introductionRepo->selectOneById($request_id, DI::userSession()->getLocalUserId());
|
||||
|
||||
switch ($_POST['submit']) {
|
||||
case $this->l10n->t('Discard'):
|
||||
|
@ -104,14 +103,14 @@ class Notification extends BaseModule
|
|||
*/
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\UnauthorizedException($this->l10n->t('Permission denied.'));
|
||||
}
|
||||
|
||||
if ($this->args->get(1) === 'mark' && $this->args->get(2) === 'all') {
|
||||
try {
|
||||
$this->notificationRepo->setAllSeenForUser(Session::getLocalUser());
|
||||
$success = $this->notifyRepo->setAllSeenForUser(Session::getLocalUser());
|
||||
$this->notificationRepo->setAllSeenForUser(DI::userSession()->getLocalUserId());
|
||||
$success = $this->notifyRepo->setAllSeenForUser(DI::userSession()->getLocalUserId());
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->warning('set all seen failed.', ['exception' => $e]);
|
||||
$success = false;
|
||||
|
@ -132,7 +131,7 @@ class Notification extends BaseModule
|
|||
*/
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
DI::sysmsg()->addNotice($this->l10n->t('You must be logged in to show this page.'));
|
||||
return Login::form();
|
||||
}
|
||||
|
@ -151,11 +150,11 @@ class Notification extends BaseModule
|
|||
private function handleNotify(int $notifyId)
|
||||
{
|
||||
$Notify = $this->notifyRepo->selectOneById($notifyId);
|
||||
if ($Notify->uid !== Session::getLocalUser()) {
|
||||
if ($Notify->uid !== DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
if ($this->pconfig->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
|
||||
if ($this->pconfig->get(DI::userSession()->getLocalUserId(), 'system', 'detailed_notif')) {
|
||||
$Notify->setSeen();
|
||||
$this->notifyRepo->save($Notify);
|
||||
} else {
|
||||
|
@ -176,11 +175,11 @@ class Notification extends BaseModule
|
|||
private function handleNotification(int $notificationId)
|
||||
{
|
||||
$Notification = $this->notificationRepo->selectOneById($notificationId);
|
||||
if ($Notification->uid !== Session::getLocalUser()) {
|
||||
if ($Notification->uid !== DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
if ($this->pconfig->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
|
||||
if ($this->pconfig->get(DI::userSession()->getLocalUserId(), 'system', 'detailed_notif')) {
|
||||
$Notification->setSeen();
|
||||
$this->notificationRepo->save($Notification);
|
||||
} else {
|
||||
|
|
|
@ -28,7 +28,6 @@ use Friendica\Content\ForumManager;
|
|||
use Friendica\Core\Cache\Enum\Duration;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -91,18 +90,18 @@ class Ping extends BaseModule
|
|||
$today_birthday_count = 0;
|
||||
|
||||
|
||||
if (Session::getLocalUser()) {
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
|
||||
$notifications = $this->notificationRepo->selectDetailedForUser(Session::getLocalUser());
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'detailed_notif')) {
|
||||
$notifications = $this->notificationRepo->selectDetailedForUser(DI::userSession()->getLocalUserId());
|
||||
} else {
|
||||
$notifications = $this->notificationRepo->selectDigestForUser(Session::getLocalUser());
|
||||
$notifications = $this->notificationRepo->selectDigestForUser(DI::userSession()->getLocalUserId());
|
||||
}
|
||||
|
||||
$condition = [
|
||||
"`unseen` AND `uid` = ? AND NOT `origin` AND (`vid` != ? OR `vid` IS NULL)",
|
||||
Session::getLocalUser(), Verb::getID(Activity::FOLLOW)
|
||||
DI::userSession()->getLocalUserId(), Verb::getID(Activity::FOLLOW)
|
||||
];
|
||||
$items = Post::selectForUser(Session::getLocalUser(), ['wall', 'uid', 'uri-id'], $condition, ['limit' => 1000]);
|
||||
$items = Post::selectForUser(DI::userSession()->getLocalUserId(), ['wall', 'uid', 'uri-id'], $condition, ['limit' => 1000]);
|
||||
if (DBA::isResult($items)) {
|
||||
$items_unseen = Post::toArray($items, false);
|
||||
$arr = ['items' => $items_unseen];
|
||||
|
@ -140,12 +139,12 @@ class Ping extends BaseModule
|
|||
}
|
||||
}
|
||||
|
||||
$intros = $this->introductionRepo->selectForUser(Session::getLocalUser());
|
||||
$intros = $this->introductionRepo->selectForUser(DI::userSession()->getLocalUserId());
|
||||
|
||||
$intro_count = $intros->count();
|
||||
|
||||
$myurl = DI::baseUrl() . '/profile/' . DI::app()->getLoggedInUserNickname();
|
||||
$mail_count = DBA::count('mail', ["`uid` = ? AND NOT `seen` AND `from-url` != ?", Session::getLocalUser(), $myurl]);
|
||||
$mail_count = DBA::count('mail', ["`uid` = ? AND NOT `seen` AND `from-url` != ?", DI::userSession()->getLocalUserId(), $myurl]);
|
||||
|
||||
if (intval(DI::config()->get('config', 'register_policy')) === Register::APPROVE && DI::app()->isSiteAdmin()) {
|
||||
$regs = \Friendica\Model\Register::getPending();
|
||||
|
@ -155,12 +154,12 @@ class Ping extends BaseModule
|
|||
}
|
||||
}
|
||||
|
||||
$cachekey = 'ping:events:' . Session::getLocalUser();
|
||||
$cachekey = 'ping:events:' . DI::userSession()->getLocalUserId();
|
||||
$ev = DI::cache()->get($cachekey);
|
||||
if (is_null($ev)) {
|
||||
$ev = DBA::selectToArray('event', ['type', 'start'],
|
||||
["`uid` = ? AND `start` < ? AND `finish` > ? AND NOT `ignore`",
|
||||
Session::getLocalUser(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utcNow()]);
|
||||
DI::userSession()->getLocalUserId(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utcNow()]);
|
||||
DI::cache()->set($cachekey, $ev, Duration::HOUR);
|
||||
}
|
||||
|
||||
|
@ -188,7 +187,7 @@ class Ping extends BaseModule
|
|||
}
|
||||
}
|
||||
|
||||
$owner = User::getOwnerDataById(Session::getLocalUser());
|
||||
$owner = User::getOwnerDataById(DI::userSession()->getLocalUserId());
|
||||
|
||||
$navNotifications = array_map(function (Entity\Notification $notification) use ($owner) {
|
||||
if (!DI::notify()->NotifyOnDesktop($notification)) {
|
||||
|
@ -215,7 +214,7 @@ class Ping extends BaseModule
|
|||
}
|
||||
|
||||
if (DBA::isResult($regs)) {
|
||||
if (count($regs) <= 1 || DI::pConfig()->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
|
||||
if (count($regs) <= 1 || DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'detailed_notif')) {
|
||||
foreach ($regs as $reg) {
|
||||
$navNotifications[] = $this->formattedNavNotification->createFromParams(
|
||||
[
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module\OAuth;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Security\OAuth;
|
||||
|
@ -71,7 +70,7 @@ class Authorize extends BaseApi
|
|||
unset($redirect_request['pagename']);
|
||||
$redirect = 'oauth/authorize?' . http_build_query($redirect_request);
|
||||
|
||||
$uid = Session::getLocalUser();
|
||||
$uid = DI::userSession()->getLocalUserId();
|
||||
if (empty($uid)) {
|
||||
Logger::info('Redirect to login');
|
||||
DI::app()->redirect('login?return_path=' . urlencode($redirect));
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -50,7 +49,7 @@ class PermissionTooltip extends \Friendica\BaseModule
|
|||
throw new HTTPException\BadRequestException(DI::l10n()->t('Wrong type "%s", expected one of: %s', $type, implode(', ', $expectedTypes)));
|
||||
}
|
||||
|
||||
$condition = ['id' => $referenceId, 'uid' => [0, Session::getLocalUser()]];
|
||||
$condition = ['id' => $referenceId, 'uid' => [0, DI::userSession()->getLocalUserId()]];
|
||||
if ($type == 'item') {
|
||||
$fields = ['uid', 'psid', 'private', 'uri-id'];
|
||||
$model = Post::selectFirst($fields, $condition);
|
||||
|
@ -178,7 +177,7 @@ class PermissionTooltip extends \Friendica\BaseModule
|
|||
private function fetchReceivers(int $uriId): string
|
||||
{
|
||||
$own_url = '';
|
||||
$uid = Session::getLocalUser();
|
||||
$uid = DI::userSession()->getLocalUserId();
|
||||
if ($uid) {
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
if (!empty($owner['url'])) {
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace Friendica\Module;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -259,7 +258,7 @@ class Photo extends BaseModule
|
|||
return MPhoto::getPhoto($matches[1], $matches[2]);
|
||||
}
|
||||
|
||||
return MPhoto::createPhotoForExternalResource($url, (int)Session::getLocalUser(), $media['mimetype'] ?? '');
|
||||
return MPhoto::createPhotoForExternalResource($url, (int)DI::userSession()->getLocalUserId(), $media['mimetype'] ?? '');
|
||||
case 'media':
|
||||
$media = DBA::selectFirst('post-media', ['url', 'mimetype', 'uri-id'], ['id' => $id, 'type' => Post\Media::IMAGE]);
|
||||
if (empty($media)) {
|
||||
|
@ -270,14 +269,14 @@ class Photo extends BaseModule
|
|||
return MPhoto::getPhoto($matches[1], $matches[2]);
|
||||
}
|
||||
|
||||
return MPhoto::createPhotoForExternalResource($media['url'], (int)Session::getLocalUser(), $media['mimetype']);
|
||||
return MPhoto::createPhotoForExternalResource($media['url'], (int)DI::userSession()->getLocalUserId(), $media['mimetype']);
|
||||
case 'link':
|
||||
$link = DBA::selectFirst('post-link', ['url', 'mimetype'], ['id' => $id]);
|
||||
if (empty($link)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return MPhoto::createPhotoForExternalResource($link['url'], (int)Session::getLocalUser(), $link['mimetype'] ?? '');
|
||||
return MPhoto::createPhotoForExternalResource($link['url'], (int)DI::userSession()->getLocalUserId(), $link['mimetype'] ?? '');
|
||||
case 'contact':
|
||||
$fields = ['uid', 'uri-id', 'url', 'nurl', 'avatar', 'photo', 'xmpp', 'addr', 'network', 'failed', 'updated'];
|
||||
$contact = Contact::getById($id, $fields);
|
||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\Content\Nav;
|
|||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Module;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -37,7 +36,7 @@ class Common extends BaseProfile
|
|||
{
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
||||
}
|
||||
|
||||
|
@ -56,7 +55,7 @@ class Common extends BaseProfile
|
|||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
$displayCommonTab = Session::isAuthenticated() && $profile['uid'] != Session::getLocalUser();
|
||||
$displayCommonTab = DI::userSession()->isAuthenticated() && $profile['uid'] != DI::userSession()->getLocalUserId();
|
||||
|
||||
if (!$displayCommonTab) {
|
||||
$a->redirect('profile/' . $nickname . '/contacts');
|
||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\Content\Nav;
|
|||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
|
@ -36,7 +35,7 @@ class Contacts extends Module\BaseProfile
|
|||
{
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
||||
}
|
||||
|
||||
|
@ -50,7 +49,7 @@ class Contacts extends Module\BaseProfile
|
|||
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
|
||||
}
|
||||
|
||||
$is_owner = $profile['uid'] == Session::getLocalUser();
|
||||
$is_owner = $profile['uid'] == DI::userSession()->getLocalUserId();
|
||||
|
||||
if ($profile['hide-friends'] && !$is_owner) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
|
@ -60,7 +59,7 @@ class Contacts extends Module\BaseProfile
|
|||
|
||||
$o = self::getTabsHTML($a, 'contacts', $is_owner, $profile['nickname'], $profile['hide-friends']);
|
||||
|
||||
$tabs = self::getContactFilterTabs('profile/' . $nickname, $type, Session::isAuthenticated() && $profile['uid'] != Session::getLocalUser());
|
||||
$tabs = self::getContactFilterTabs('profile/' . $nickname, $type, DI::userSession()->isAuthenticated() && $profile['uid'] != DI::userSession()->getLocalUserId());
|
||||
|
||||
$condition = [
|
||||
'uid' => $profile['uid'],
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
namespace Friendica\Module\Profile;
|
||||
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Profile as ProfileModel;
|
||||
|
@ -43,7 +42,7 @@ class Media extends BaseProfile
|
|||
DI::page()['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
|
||||
}
|
||||
|
||||
$is_owner = Session::getLocalUser() == $profile['uid'];
|
||||
$is_owner = DI::userSession()->getLocalUserId() == $profile['uid'];
|
||||
|
||||
$o = self::getTabsHTML($a, 'media', $is_owner, $profile['nickname'], $profile['hide-friends']);
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ use Friendica\Content\Text\HTML;
|
|||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -82,13 +81,13 @@ class Profile extends BaseProfile
|
|||
throw new HTTPException\NotFoundException(DI::l10n()->t('Profile not found.'));
|
||||
}
|
||||
|
||||
$remote_contact_id = Session::getRemoteContactID($profile['uid']);
|
||||
$remote_contact_id = DI::userSession()->getRemoteContactID($profile['uid']);
|
||||
|
||||
if (DI::config()->get('system', 'block_public') && !Session::getLocalUser() && !$remote_contact_id) {
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->getLocalUserId() && !$remote_contact_id) {
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
$is_owner = Session::getLocalUser() == $profile['uid'];
|
||||
$is_owner = DI::userSession()->getLocalUserId() == $profile['uid'];
|
||||
|
||||
if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact_id) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));
|
||||
|
@ -102,7 +101,7 @@ class Profile extends BaseProfile
|
|||
|
||||
Nav::setSelected('home');
|
||||
|
||||
$is_owner = Session::getLocalUser() == $profile['uid'];
|
||||
$is_owner = DI::userSession()->getLocalUserId() == $profile['uid'];
|
||||
$o = self::getTabsHTML($a, 'profile', $is_owner, $profile['nickname'], $profile['hide-friends']);
|
||||
|
||||
if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact_id) {
|
||||
|
@ -117,7 +116,7 @@ class Profile extends BaseProfile
|
|||
$view_as_contact_id = intval($_GET['viewas'] ?? 0);
|
||||
|
||||
$view_as_contacts = Contact::selectToArray(['id', 'name'], [
|
||||
'uid' => Session::getLocalUser(),
|
||||
'uid' => DI::userSession()->getLocalUserId(),
|
||||
'rel' => [Contact::FOLLOWER, Contact::SHARING, Contact::FRIEND],
|
||||
'network' => Protocol::DFRN,
|
||||
'blocked' => false,
|
||||
|
@ -247,7 +246,7 @@ class Profile extends BaseProfile
|
|||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$basic' => DI::l10n()->t('Basic'),
|
||||
'$advanced' => DI::l10n()->t('Advanced'),
|
||||
'$is_owner' => $profile['uid'] == Session::getLocalUser(),
|
||||
'$is_owner' => $profile['uid'] == DI::userSession()->getLocalUserId(),
|
||||
'$query_string' => DI::args()->getQueryString(),
|
||||
'$basic_fields' => $basic_fields,
|
||||
'$custom_fields' => $custom_fields,
|
||||
|
@ -308,8 +307,8 @@ class Profile extends BaseProfile
|
|||
}
|
||||
|
||||
// site block
|
||||
$blocked = !Session::getLocalUser() && !$remote_contact_id && DI::config()->get('system', 'block_public');
|
||||
$userblock = !Session::getLocalUser() && !$remote_contact_id && $profile['hidewall'];
|
||||
$blocked = !DI::userSession()->getLocalUserId() && !$remote_contact_id && DI::config()->get('system', 'block_public');
|
||||
$userblock = !DI::userSession()->getLocalUserId() && !$remote_contact_id && $profile['hidewall'];
|
||||
if (!$blocked && !$userblock) {
|
||||
$keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $profile['pub_keywords'] ?? '');
|
||||
if (strlen($keywords)) {
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace Friendica\Module\Profile;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Post;
|
||||
|
@ -36,7 +35,7 @@ class Schedule extends BaseProfile
|
|||
{
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
|
@ -44,7 +43,7 @@ class Schedule extends BaseProfile
|
|||
throw new HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
if (!DBA::exists('delayed-post', ['id' => $_REQUEST['delete'], 'uid' => Session::getLocalUser()])) {
|
||||
if (!DBA::exists('delayed-post', ['id' => $_REQUEST['delete'], 'uid' => DI::userSession()->getLocalUserId()])) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
|
@ -53,7 +52,7 @@ class Schedule extends BaseProfile
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
|
@ -62,7 +61,7 @@ class Schedule extends BaseProfile
|
|||
$o = self::getTabsHTML($a, 'schedule', true, $a->getLoggedInUserNickname(), false);
|
||||
|
||||
$schedule = [];
|
||||
$delayed = DBA::select('delayed-post', [], ['uid' => Session::getLocalUser()]);
|
||||
$delayed = DBA::select('delayed-post', [], ['uid' => DI::userSession()->getLocalUserId()]);
|
||||
while ($row = DBA::fetch($delayed)) {
|
||||
$parameter = Post\Delayed::getParametersForid($row['id']);
|
||||
if (empty($parameter)) {
|
||||
|
|
|
@ -26,7 +26,6 @@ use Friendica\Content\Pager;
|
|||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -92,19 +91,19 @@ class Status extends BaseProfile
|
|||
|
||||
$hashtags = $_GET['tag'] ?? '';
|
||||
|
||||
if (DI::config()->get('system', 'block_public') && !Session::getLocalUser() && !Session::getRemoteContactID($profile['uid'])) {
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->getLocalUserId() && !DI::userSession()->getRemoteContactID($profile['uid'])) {
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
$o = '';
|
||||
|
||||
if ($profile['uid'] == Session::getLocalUser()) {
|
||||
if ($profile['uid'] == DI::userSession()->getLocalUserId()) {
|
||||
Nav::setSelected('home');
|
||||
}
|
||||
|
||||
$remote_contact = Session::getRemoteContactID($profile['uid']);
|
||||
$is_owner = Session::getLocalUser() == $profile['uid'];
|
||||
$last_updated_key = "profile:" . $profile['uid'] . ":" . Session::getLocalUser() . ":" . $remote_contact;
|
||||
$remote_contact = DI::userSession()->getRemoteContactID($profile['uid']);
|
||||
$is_owner = DI::userSession()->getLocalUserId() == $profile['uid'];
|
||||
$last_updated_key = "profile:" . $profile['uid'] . ":" . DI::userSession()->getLocalUserId() . ":" . $remote_contact;
|
||||
|
||||
if (!empty($profile['hidewall']) && !$is_owner && !$remote_contact) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Access to this profile has been restricted.'));
|
||||
|
@ -166,10 +165,10 @@ class Status extends BaseProfile
|
|||
}
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
|
||||
$itemspage_network = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
} else {
|
||||
$itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
|
||||
$itemspage_network = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
}
|
||||
|
||||
|
@ -197,9 +196,9 @@ class Status extends BaseProfile
|
|||
}
|
||||
|
||||
if ($is_owner) {
|
||||
$unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]);
|
||||
$unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
if ($unseen) {
|
||||
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]);
|
||||
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace Friendica\Module;
|
|||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
|
@ -75,7 +74,7 @@ class Proxy extends BaseModule
|
|||
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
Logger::debug('Redirecting not logged in user to original address', ['url' => $request['url']]);
|
||||
System::externalRedirect($request['url']);
|
||||
}
|
||||
|
@ -84,7 +83,7 @@ class Proxy extends BaseModule
|
|||
$request['url'] = str_replace(' ', '+', $request['url']);
|
||||
|
||||
// Fetch the content with the local user
|
||||
$fetchResult = HTTPSignature::fetchRaw($request['url'], Session::getLocalUser(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE], 'timeout' => 10]);
|
||||
$fetchResult = HTTPSignature::fetchRaw($request['url'], DI::userSession()->getLocalUserId(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE], 'timeout' => 10]);
|
||||
$img_str = $fetchResult->getBody();
|
||||
|
||||
if (!$fetchResult->isSuccess() || empty($img_str)) {
|
||||
|
@ -93,7 +92,7 @@ class Proxy extends BaseModule
|
|||
// stop.
|
||||
}
|
||||
|
||||
Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => Session::getLocalUser(), 'image' => $request['url']]);
|
||||
Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => DI::userSession()->getLocalUserId(), 'image' => $request['url']]);
|
||||
|
||||
$mime = Images::getMimeTypeByData($img_str);
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ use Friendica\Core\Hook;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -74,20 +73,20 @@ class Register extends BaseModule
|
|||
// 'block_extended_register' blocks all registrations, period.
|
||||
$block = DI::config()->get('system', 'block_extended_register');
|
||||
|
||||
if (Session::getLocalUser() && $block) {
|
||||
if (DI::userSession()->getLocalUserId() && $block) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
|
||||
return '';
|
||||
}
|
||||
|
||||
if (Session::getLocalUser()) {
|
||||
$user = DBA::selectFirst('user', ['parent-uid'], ['uid' => Session::getLocalUser()]);
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
$user = DBA::selectFirst('user', ['parent-uid'], ['uid' => DI::userSession()->getLocalUserId()]);
|
||||
if (!empty($user['parent-uid'])) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Only parent users can create additional accounts.'));
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
if (!Session::getLocalUser() && (intval(DI::config()->get('config', 'register_policy')) === self::CLOSED)) {
|
||||
if (!DI::userSession()->getLocalUserId() && (intval(DI::config()->get('config', 'register_policy')) === self::CLOSED)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
|
||||
return '';
|
||||
}
|
||||
|
@ -109,7 +108,7 @@ class Register extends BaseModule
|
|||
$photo = $_REQUEST['photo'] ?? '';
|
||||
$invite_id = $_REQUEST['invite_id'] ?? '';
|
||||
|
||||
if (Session::getLocalUser() || DI::config()->get('system', 'no_openid')) {
|
||||
if (DI::userSession()->getLocalUserId() || DI::config()->get('system', 'no_openid')) {
|
||||
$fillwith = '';
|
||||
$fillext = '';
|
||||
$oidlabel = '';
|
||||
|
@ -180,7 +179,7 @@ class Register extends BaseModule
|
|||
'$form_security_token' => BaseModule::getFormSecurityToken('register'),
|
||||
'$explicit_content' => DI::config()->get('system', 'explicit_content', false),
|
||||
'$explicit_content_note' => DI::l10n()->t('Note: This node explicitly contains adult content'),
|
||||
'$additional' => !empty(Session::getLocalUser()),
|
||||
'$additional' => !empty(DI::userSession()->getLocalUserId()),
|
||||
'$parent_password' => ['parent_password', DI::l10n()->t('Parent Password:'), '', DI::l10n()->t('Please enter the password of the parent account to legitimize your request.')]
|
||||
|
||||
]);
|
||||
|
@ -203,19 +202,19 @@ class Register extends BaseModule
|
|||
|
||||
$additional_account = false;
|
||||
|
||||
if (!Session::getLocalUser() && !empty($arr['post']['parent_password'])) {
|
||||
if (!DI::userSession()->getLocalUserId() && !empty($arr['post']['parent_password'])) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
|
||||
return;
|
||||
} elseif (Session::getLocalUser() && !empty($arr['post']['parent_password'])) {
|
||||
} elseif (DI::userSession()->getLocalUserId() && !empty($arr['post']['parent_password'])) {
|
||||
try {
|
||||
Model\User::getIdFromPasswordAuthentication(Session::getLocalUser(), $arr['post']['parent_password']);
|
||||
Model\User::getIdFromPasswordAuthentication(DI::userSession()->getLocalUserId(), $arr['post']['parent_password']);
|
||||
} catch (\Exception $ex) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t("Password doesn't match."));
|
||||
$regdata = ['nickname' => $arr['post']['nickname'], 'username' => $arr['post']['username']];
|
||||
DI::baseUrl()->redirect('register?' . http_build_query($regdata));
|
||||
}
|
||||
$additional_account = true;
|
||||
} elseif (Session::getLocalUser()) {
|
||||
} elseif (DI::userSession()->getLocalUserId()) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Please enter your password.'));
|
||||
$regdata = ['nickname' => $arr['post']['nickname'], 'username' => $arr['post']['username']];
|
||||
DI::baseUrl()->redirect('register?' . http_build_query($regdata));
|
||||
|
@ -263,7 +262,7 @@ class Register extends BaseModule
|
|||
}
|
||||
|
||||
if ($additional_account) {
|
||||
$user = DBA::selectFirst('user', ['email'], ['uid' => Session::getLocalUser()]);
|
||||
$user = DBA::selectFirst('user', ['email'], ['uid' => DI::userSession()->getLocalUserId()]);
|
||||
if (!DBA::isResult($user)) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('User not found.'));
|
||||
DI::baseUrl()->redirect('register');
|
||||
|
@ -307,7 +306,7 @@ class Register extends BaseModule
|
|||
}
|
||||
|
||||
if ($additional_account) {
|
||||
DBA::update('user', ['parent-uid' => Session::getLocalUser()], ['uid' => $user['uid']]);
|
||||
DBA::update('user', ['parent-uid' => DI::userSession()->getLocalUserId()], ['uid' => $user['uid']]);
|
||||
DI::sysmsg()->addInfo(DI::l10n()->t('The additional account was created.'));
|
||||
DI::baseUrl()->redirect('delegation');
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ use Friendica\Core\Hook;
|
|||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -52,7 +51,7 @@ class Acl extends BaseModule
|
|||
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this module.'));
|
||||
}
|
||||
|
||||
|
@ -114,8 +113,8 @@ class Acl extends BaseModule
|
|||
Logger::info('ACL {action} - {subaction} - start', ['module' => 'acl', 'action' => 'content', 'subaction' => 'search', 'search' => $search, 'type' => $type, 'conversation' => $conv_id]);
|
||||
|
||||
$sql_extra = '';
|
||||
$condition = ["`uid` = ? AND NOT `deleted` AND NOT `pending` AND NOT `archive`", Session::getLocalUser()];
|
||||
$condition_group = ["`uid` = ? AND NOT `deleted`", Session::getLocalUser()];
|
||||
$condition = ["`uid` = ? AND NOT `deleted` AND NOT `pending` AND NOT `archive`", DI::userSession()->getLocalUserId()];
|
||||
$condition_group = ["`uid` = ? AND NOT `deleted`", DI::userSession()->getLocalUserId()];
|
||||
|
||||
if ($search != '') {
|
||||
$sql_extra = "AND `name` LIKE '%%" . DBA::escape($search) . "%%'";
|
||||
|
@ -177,7 +176,7 @@ class Acl extends BaseModule
|
|||
GROUP BY `group`.`name`, `group`.`id`
|
||||
ORDER BY `group`.`name`
|
||||
LIMIT ?, ?",
|
||||
Session::getLocalUser(),
|
||||
DI::userSession()->getLocalUserId(),
|
||||
$start,
|
||||
$count
|
||||
));
|
||||
|
@ -252,7 +251,7 @@ class Acl extends BaseModule
|
|||
|
||||
$condition = ["`parent` = ?", $conv_id];
|
||||
$params = ['order' => ['author-name' => true]];
|
||||
$authors = Post::selectForUser(Session::getLocalUser(), ['author-link'], $condition, $params);
|
||||
$authors = Post::selectForUser(DI::userSession()->getLocalUserId(), ['author-link'], $condition, $params);
|
||||
$item_authors = [];
|
||||
while ($author = Post::fetch($authors)) {
|
||||
$item_authors[$author['author-link']] = $author['author-link'];
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module\Search;
|
||||
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseSearch;
|
||||
use Friendica\Module\Security\Login;
|
||||
|
@ -34,7 +33,7 @@ class Directory extends BaseSearch
|
|||
{
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
|
||||
return Login::form();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ use Friendica\Content\Pager;
|
|||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -39,13 +38,13 @@ class Filed extends BaseSearch
|
|||
{
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return Login::form();
|
||||
}
|
||||
|
||||
DI::page()['aside'] .= Widget::fileAs(DI::args()->getCommand(), $_GET['file'] ?? '');
|
||||
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
|
||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
|
||||
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
|
||||
$o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
|
||||
} else {
|
||||
|
@ -60,10 +59,10 @@ class Filed extends BaseSearch
|
|||
}
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
|
||||
$itemspage_network = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
} else {
|
||||
$itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
|
||||
$itemspage_network = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
}
|
||||
|
||||
|
@ -71,7 +70,7 @@ class Filed extends BaseSearch
|
|||
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemspage_network);
|
||||
|
||||
$term_condition = ['type' => Category::FILE, 'uid' => Session::getLocalUser()];
|
||||
$term_condition = ['type' => Category::FILE, 'uid' => DI::userSession()->getLocalUserId()];
|
||||
if ($file) {
|
||||
$term_condition['name'] = $file;
|
||||
}
|
||||
|
@ -94,14 +93,14 @@ class Filed extends BaseSearch
|
|||
if (count($posts) == 0) {
|
||||
return '';
|
||||
}
|
||||
$item_condition = ['uid' => [0, Session::getLocalUser()], 'uri-id' => $posts];
|
||||
$item_condition = ['uid' => [0, DI::userSession()->getLocalUserId()], 'uri-id' => $posts];
|
||||
$item_params = ['order' => ['uri-id' => true, 'uid' => true]];
|
||||
|
||||
$items = Post::toArray(Post::selectForUser(Session::getLocalUser(), Item::DISPLAY_FIELDLIST, $item_condition, $item_params));
|
||||
$items = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), Item::DISPLAY_FIELDLIST, $item_condition, $item_params));
|
||||
|
||||
$o .= DI::conversation()->create($items, 'filed', false, false, '', Session::getLocalUser());
|
||||
$o .= DI::conversation()->create($items, 'filed', false, false, '', DI::userSession()->getLocalUserId());
|
||||
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
|
||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
|
||||
$o .= HTML::scrollLoader();
|
||||
} else {
|
||||
$o .= $pager->renderMinimal($count);
|
||||
|
|
|
@ -31,7 +31,6 @@ use Friendica\Core\L10n;
|
|||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -61,15 +60,15 @@ class Index extends BaseSearch
|
|||
{
|
||||
$search = (!empty($_GET['q']) ? trim(rawurldecode($_GET['q'])) : '');
|
||||
|
||||
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->isAuthenticated()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.'));
|
||||
}
|
||||
|
||||
if (DI::config()->get('system', 'local_search') && !Session::isAuthenticated()) {
|
||||
if (DI::config()->get('system', 'local_search') && !DI::userSession()->isAuthenticated()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a search.'));
|
||||
}
|
||||
|
||||
if (DI::config()->get('system', 'permit_crawling') && !Session::isAuthenticated()) {
|
||||
if (DI::config()->get('system', 'permit_crawling') && !DI::userSession()->isAuthenticated()) {
|
||||
// Default values:
|
||||
// 10 requests are "free", after the 11th only a call per minute is allowed
|
||||
|
||||
|
@ -94,7 +93,7 @@ class Index extends BaseSearch
|
|||
}
|
||||
}
|
||||
|
||||
if (Session::getLocalUser()) {
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
DI::page()['aside'] .= Widget\SavedSearches::getHTML(Search::getSearchPath($search), $search);
|
||||
}
|
||||
|
||||
|
@ -161,10 +160,10 @@ class Index extends BaseSearch
|
|||
// No items will be shown if the member has a blocked profile wall.
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
|
||||
$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
} else {
|
||||
$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
|
||||
$itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
}
|
||||
|
||||
|
@ -174,19 +173,19 @@ class Index extends BaseSearch
|
|||
|
||||
if ($tag) {
|
||||
Logger::info('Start tag search.', ['q' => $search]);
|
||||
$uriids = Tag::getURIIdListByTag($search, Session::getLocalUser(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
|
||||
$count = Tag::countByTag($search, Session::getLocalUser());
|
||||
$uriids = Tag::getURIIdListByTag($search, DI::userSession()->getLocalUserId(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
|
||||
$count = Tag::countByTag($search, DI::userSession()->getLocalUserId());
|
||||
} else {
|
||||
Logger::info('Start fulltext search.', ['q' => $search]);
|
||||
$uriids = Post\Content::getURIIdListBySearch($search, Session::getLocalUser(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
|
||||
$count = Post\Content::countBySearch($search, Session::getLocalUser());
|
||||
$uriids = Post\Content::getURIIdListBySearch($search, DI::userSession()->getLocalUserId(), $pager->getStart(), $pager->getItemsPerPage(), $last_uriid);
|
||||
$count = Post\Content::countBySearch($search, DI::userSession()->getLocalUserId());
|
||||
}
|
||||
|
||||
if (!empty($uriids)) {
|
||||
$condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`))", 0, Session::getLocalUser()];
|
||||
$condition = ["(`uid` = ? OR (`uid` = ? AND NOT `global`))", 0, DI::userSession()->getLocalUserId()];
|
||||
$condition = DBA::mergeConditions($condition, ['uri-id' => $uriids]);
|
||||
$params = ['order' => ['id' => true]];
|
||||
$items = Post::toArray(Post::selectForUser(Session::getLocalUser(), Item::DISPLAY_FIELDLIST, $condition, $params));
|
||||
$items = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), Item::DISPLAY_FIELDLIST, $condition, $params));
|
||||
}
|
||||
|
||||
if (empty($items)) {
|
||||
|
@ -196,7 +195,7 @@ class Index extends BaseSearch
|
|||
return $o;
|
||||
}
|
||||
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
|
||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
|
||||
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
|
||||
}
|
||||
|
@ -213,9 +212,9 @@ class Index extends BaseSearch
|
|||
|
||||
Logger::info('Start Conversation.', ['q' => $search]);
|
||||
|
||||
$o .= DI::conversation()->create($items, 'search', false, false, 'commented', Session::getLocalUser());
|
||||
$o .= DI::conversation()->create($items, 'search', false, false, 'commented', DI::userSession()->getLocalUserId());
|
||||
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
|
||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'infinite_scroll')) {
|
||||
$o .= HTML::scrollLoader();
|
||||
} else {
|
||||
$o .= $pager->renderMinimal($count);
|
||||
|
@ -254,9 +253,9 @@ class Index extends BaseSearch
|
|||
$search = $matches[1];
|
||||
}
|
||||
|
||||
if (Session::getLocalUser()) {
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
// User-specific contact URL/address search
|
||||
$contact_id = Contact::getIdForURL($search, Session::getLocalUser());
|
||||
$contact_id = Contact::getIdForURL($search, DI::userSession()->getLocalUserId());
|
||||
if (!$contact_id) {
|
||||
// User-specific contact URL/address search and probe
|
||||
$contact_id = Contact::getIdForURL($search);
|
||||
|
@ -293,9 +292,9 @@ class Index extends BaseSearch
|
|||
|
||||
$search = Network::convertToIdn($search);
|
||||
|
||||
if (Session::getLocalUser()) {
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
// Post URL search
|
||||
$item_id = Item::fetchByLink($search, Session::getLocalUser());
|
||||
$item_id = Item::fetchByLink($search, DI::userSession()->getLocalUserId());
|
||||
if (!$item_id) {
|
||||
// If the user-specific search failed, we search and probe a public post
|
||||
$item_id = Item::fetchByLink($search);
|
||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\App;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Response;
|
||||
|
@ -51,10 +50,10 @@ class Saved extends BaseModule
|
|||
|
||||
$return_url = $_GET['return_url'] ?? Search::getSearchPath($search);
|
||||
|
||||
if (Session::getLocalUser() && $search) {
|
||||
if (DI::userSession()->getLocalUserId() && $search) {
|
||||
switch ($action) {
|
||||
case 'add':
|
||||
$fields = ['uid' => Session::getLocalUser(), 'term' => $search];
|
||||
$fields = ['uid' => DI::userSession()->getLocalUserId(), 'term' => $search];
|
||||
if (!$this->dba->exists('search', $fields)) {
|
||||
if (!$this->dba->insert('search', $fields)) {
|
||||
DI::sysmsg()->addNotice($this->t('Search term was not saved.'));
|
||||
|
@ -65,7 +64,7 @@ class Saved extends BaseModule
|
|||
break;
|
||||
|
||||
case 'remove':
|
||||
if (!$this->dba->delete('search', ['uid' => Session::getLocalUser(), 'term' => $search])) {
|
||||
if (!$this->dba->delete('search', ['uid' => DI::userSession()->getLocalUserId(), 'term' => $search])) {
|
||||
DI::sysmsg()->addNotice($this->t('Search term was not removed.'));
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -27,7 +27,6 @@ use Friendica\Core\Config\Capability\IManageConfigValues;
|
|||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Register;
|
||||
|
@ -63,7 +62,7 @@ class Login extends BaseModule
|
|||
{
|
||||
$return_path = $request['return_path'] ?? $this->session->pop('return_path', '') ;
|
||||
|
||||
if (Session::getLocalUser()) {
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
$this->baseUrl->redirect($return_path);
|
||||
}
|
||||
|
||||
|
@ -127,7 +126,7 @@ class Login extends BaseModule
|
|||
];
|
||||
}
|
||||
|
||||
if (Session::getLocalUser()) {
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
$tpl = Renderer::getMarkupTemplate('logout.tpl');
|
||||
} else {
|
||||
DI::page()['htmlhead'] .= Renderer::replaceMacros(
|
||||
|
|
|
@ -26,7 +26,6 @@ use Friendica\BaseModule;
|
|||
use Friendica\Core\Cache\Capability\ICanCache;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
|
@ -64,7 +63,7 @@ class Logout extends BaseModule
|
|||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$visitor_home = null;
|
||||
if (Session::getRemoteUser()) {
|
||||
if (DI::userSession()->getRemoteUserId()) {
|
||||
$visitor_home = Profile::getMyURL();
|
||||
$this->cache->delete('zrlInit:' . $visitor_home);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\App;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
|
@ -60,7 +59,7 @@ class Recovery extends BaseModule
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -69,10 +68,10 @@ class Recovery extends BaseModule
|
|||
|
||||
$recovery_code = $_POST['recovery_code'] ?? '';
|
||||
|
||||
if (RecoveryCode::existsForUser(Session::getLocalUser(), $recovery_code)) {
|
||||
RecoveryCode::markUsedForUser(Session::getLocalUser(), $recovery_code);
|
||||
if (RecoveryCode::existsForUser(DI::userSession()->getLocalUserId(), $recovery_code)) {
|
||||
RecoveryCode::markUsedForUser(DI::userSession()->getLocalUserId(), $recovery_code);
|
||||
$this->session->set('2fa', true);
|
||||
DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(Session::getLocalUser())));
|
||||
DI::sysmsg()->addInfo($this->t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(DI::userSession()->getLocalUserId())));
|
||||
|
||||
$this->auth->setForUser($this->app, User::getById($this->app->getLoggedInUserId()), true, true);
|
||||
|
||||
|
@ -85,7 +84,7 @@ class Recovery extends BaseModule
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
$this->baseUrl->redirect();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\App;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User\Cookie;
|
||||
|
@ -62,7 +61,7 @@ class SignOut extends BaseModule
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser() || !($this->cookie->get('2fa_cookie_hash'))) {
|
||||
if (!DI::userSession()->getLocalUserId() || !($this->cookie->get('2fa_cookie_hash'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -81,7 +80,7 @@ class SignOut extends BaseModule
|
|||
$this->baseUrl->redirect();
|
||||
break;
|
||||
case 'sign_out':
|
||||
$this->trustedBrowserRepository->removeForUser(Session::getLocalUser(), $this->cookie->get('2fa_cookie_hash'));
|
||||
$this->trustedBrowserRepository->removeForUser(DI::userSession()->getLocalUserId(), $this->cookie->get('2fa_cookie_hash'));
|
||||
$this->cookie->clear();
|
||||
$this->session->clear();
|
||||
|
||||
|
@ -96,7 +95,7 @@ class SignOut extends BaseModule
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser() || !($this->cookie->get('2fa_cookie_hash'))) {
|
||||
if (!DI::userSession()->getLocalUserId() || !($this->cookie->get('2fa_cookie_hash'))) {
|
||||
$this->baseUrl->redirect();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ use Friendica\App;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
|
@ -75,7 +74,7 @@ class Trust extends BaseModule
|
|||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
if (!Session::getLocalUser() || !$this->session->get('2fa')) {
|
||||
if (!DI::userSession()->getLocalUserId() || !$this->session->get('2fa')) {
|
||||
$this->logger->info('Invalid call', ['request' => $request]);
|
||||
return;
|
||||
}
|
||||
|
@ -88,7 +87,7 @@ class Trust extends BaseModule
|
|||
switch ($action) {
|
||||
case 'trust':
|
||||
case 'dont_trust':
|
||||
$trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent(Session::getLocalUser(), $this->server['HTTP_USER_AGENT'], $action === 'trust');
|
||||
$trustedBrowser = $this->trustedBrowserFactory->createForUserWithUserAgent(DI::userSession()->getLocalUserId(), $this->server['HTTP_USER_AGENT'], $action === 'trust');
|
||||
try {
|
||||
$this->trustedBrowserRepository->save($trustedBrowser);
|
||||
|
||||
|
@ -116,7 +115,7 @@ class Trust extends BaseModule
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser() || !$this->session->get('2fa')) {
|
||||
if (!DI::userSession()->getLocalUserId() || !$this->session->get('2fa')) {
|
||||
$this->baseUrl->redirect();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
namespace Friendica\Module\Update;
|
||||
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Conversation\Community as CommunityModule;
|
||||
|
@ -39,8 +38,8 @@ class Community extends CommunityModule
|
|||
$this->parseRequest();
|
||||
|
||||
$o = '';
|
||||
if (!empty($_GET['force']) || !DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_auto_update')) {
|
||||
$o = DI::conversation()->create(self::getItems(), 'community', true, false, 'commented', Session::getLocalUser());
|
||||
if (!empty($_GET['force']) || !DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_auto_update')) {
|
||||
$o = DI::conversation()->create(self::getItems(), 'community', true, false, 'commented', DI::userSession()->getLocalUserId());
|
||||
}
|
||||
|
||||
System::htmlUpdateExit($o);
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
namespace Friendica\Module\Update;
|
||||
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -76,7 +75,7 @@ class Network extends NetworkModule
|
|||
$ordering = '`commented`';
|
||||
}
|
||||
|
||||
$o = DI::conversation()->create($items, 'network', $profile_uid, false, $ordering, Session::getLocalUser());
|
||||
$o = DI::conversation()->create($items, 'network', $profile_uid, false, $ordering, DI::userSession()->getLocalUserId());
|
||||
}
|
||||
|
||||
System::htmlUpdateExit($o);
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace Friendica\Module\Update;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -42,13 +41,13 @@ class Profile extends BaseModule
|
|||
// Ensure we've got a profile owner if updating.
|
||||
$a->setProfileOwner((int)($_GET['p'] ?? 0));
|
||||
|
||||
if (DI::config()->get('system', 'block_public') && !Session::getLocalUser() && !Session::getRemoteContactID($a->getProfileOwner())) {
|
||||
if (DI::config()->get('system', 'block_public') && !DI::userSession()->getLocalUserId() && !DI::userSession()->getRemoteContactID($a->getProfileOwner())) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
|
||||
$remote_contact = Session::getRemoteContactID($a->getProfileOwner());
|
||||
$is_owner = Session::getLocalUser() == $a->getProfileOwner();
|
||||
$last_updated_key = "profile:" . $a->getProfileOwner() . ":" . Session::getLocalUser() . ":" . $remote_contact;
|
||||
$remote_contact = DI::userSession()->getRemoteContactID($a->getProfileOwner());
|
||||
$is_owner = DI::userSession()->getLocalUserId() == $a->getProfileOwner();
|
||||
$last_updated_key = "profile:" . $a->getProfileOwner() . ":" . DI::userSession()->getLocalUserId() . ":" . $remote_contact;
|
||||
|
||||
if (!$is_owner && !$remote_contact) {
|
||||
$user = User::getById($a->getProfileOwner(), ['hidewall']);
|
||||
|
@ -59,7 +58,7 @@ class Profile extends BaseModule
|
|||
|
||||
$o = '';
|
||||
|
||||
if (empty($_GET['force']) && DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_auto_update')) {
|
||||
if (empty($_GET['force']) && DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_auto_update')) {
|
||||
System::htmlUpdateExit($o);
|
||||
}
|
||||
|
||||
|
@ -110,9 +109,9 @@ class Profile extends BaseModule
|
|||
}
|
||||
|
||||
if ($is_owner) {
|
||||
$unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]);
|
||||
$unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
if ($unseen) {
|
||||
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]);
|
||||
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => DI::userSession()->getLocalUserId()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue