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;
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$privateaddons = $config->get('config', 'private_addons');
- if ($privateaddons === "1" && !local_user()) {
+ if ($privateaddons === "1" && !Session::getLocalUser()) {
$baseUrl->redirect();
}
}
*/
public static function checkAdminAccess(bool $interactive = false)
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
if ($interactive) {
DI::sysmsg()->addNotice(DI::l10n()->t('Please login to continue.'));
Session::set('return_path', DI::args()->getQueryString());
use Friendica\Content\Pager;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
+use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Navigation\Notifications\ValueObject\FormattedNotify;
use Friendica\Network\HTTPException\ForbiddenException;
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
throw new ForbiddenException($this->t('Permission denied.'));
}
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;
$search = Network::convertToIdn($search);
if (DI::mode()->isMobile()) {
- $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
+ $itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
- $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
+ $itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
// in case the result is a contact result, add a contact-specific entry
if ($result instanceof ContactResult) {
- $contact = Model\Contact::getByURLForUser($result->getUrl(), local_user());
+ $contact = Model\Contact::getByURLForUser($result->getUrl(), Session::getLocalUser());
if (!empty($contact)) {
$entries[] = Contact::getContactTemplateVars($contact);
}
use Friendica\BaseModule;
use Friendica\Content\PageInfo;
+use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\Security\Login;
use Friendica\Network\HTTPException;
$config = DI::config();
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
$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;
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;
self::checkFormSecurityTokenRedirectOnError($redirectUrl, 'contact_batch_actions');
- $orig_records = Model\Contact::selectToArray(['id', 'uid'], ['id' => $_POST['contact_batch'], 'uid' => [0, local_user()], 'self' => false, 'deleted' => false]);
+ $orig_records = Model\Contact::selectToArray(['id', 'uid'], ['id' => $_POST['contact_batch'], 'uid' => [0, Session::getLocalUser()], 'self' => false, 'deleted' => false]);
$count_actions = 0;
foreach ($orig_records as $orig_record) {
- $cdata = Model\Contact::getPublicAndUserContactID($orig_record['id'], local_user());
- if (empty($cdata) || public_contact() === $cdata['public']) {
+ $cdata = Model\Contact::getPublicAndUserContactID($orig_record['id'], Session::getLocalUser());
+ if (empty($cdata) || Session::getPublicContact() === $cdata['public']) {
// No action available on your own contact
continue;
}
}
if (!empty($_POST['contacts_batch_block'])) {
- self::toggleBlockContact($cdata['public'], local_user());
+ self::toggleBlockContact($cdata['public'], Session::getLocalUser());
$count_actions++;
}
protected function post(array $request = [])
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
*/
public static function updateContactFromPoll(int $contact_id)
{
- $contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false]);
+ $contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => Session::getLocalUser(), 'deleted' => false]);
if (!DBA::isResult($contact)) {
return;
}
*/
private static function toggleIgnoreContact(int $contact_id)
{
- $ignored = !Model\Contact\User::isIgnored($contact_id, local_user());
- Model\Contact\User::setIgnored($contact_id, local_user(), $ignored);
+ $ignored = !Model\Contact\User::isIgnored($contact_id, Session::getLocalUser());
+ Model\Contact\User::setIgnored($contact_id, Session::getLocalUser(), $ignored);
}
protected function content(array $request = []): string
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return Login::form($_SERVER['REQUEST_URI']);
}
$_SESSION['return_path'] = DI::args()->getQueryString();
- $sql_values = [local_user()];
+ $sql_values = [Session::getLocalUser()];
// @TODO: Replace with parameter from router
$type = DI::args()->getArgv()[1] ?? '';
$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[] = local_user();
+ $sql_values[] = Session::getLocalUser();
break;
default:
$sql_extra = " AND NOT `archive` AND NOT `blocked` AND NOT `pending`";
$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'], local_user());
- $contact['readonly'] = Model\Contact\User::isIgnored($contact['id'], local_user());
+ $contact['blocked'] = Model\Contact\User::isBlocked($contact['id'], Session::getLocalUser());
+ $contact['readonly'] = Model\Contact\User::isIgnored($contact['id'], Session::getLocalUser());
$contacts[] = self::getContactTemplateVars($contact);
}
DBA::close($stmt);
public static function getTabsHTML(array $contact, int $active_tab)
{
$cid = $pcid = $contact['id'];
- $data = Model\Contact::getPublicAndUserContactID($contact['id'], local_user());
+ $data = Model\Contact::getPublicAndUserContactID($contact['id'], Session::getLocalUser());
if (!empty($data['user']) && ($contact['id'] == $data['public'])) {
$cid = $data['user'];
} elseif (!empty($data['public'])) {
{
$alt_text = '';
- if (!empty($contact['url']) && isset($contact['uid']) && ($contact['uid'] == 0) && local_user()) {
- $personal = Model\Contact::getByURL($contact['url'], false, ['uid', 'rel', 'self'], local_user());
+ 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($personal)) {
$contact['uid'] = $personal['uid'];
$contact['rel'] = $personal['rel'];
}
}
- if (!empty($contact['uid']) && !empty($contact['rel']) && local_user() == $contact['uid']) {
+ if (!empty($contact['uid']) && !empty($contact['rel']) && Session::getLocalUser() == $contact['uid']) {
switch ($contact['rel']) {
case Model\Contact::FRIEND:
$alt_text = DI::l10n()->t('Mutual Friendship');
{
protected function post(array $request = [])
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
return;
}
- $uid = local_user();
+ $uid = Session::getLocalUser();
$orig_record = User::getById(DI::app()->getLoggedInUserId());
if (DI::session()->get('submanage')) {
protected function content(array $request = []): string
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
throw new ForbiddenException(DI::l10n()->t('Permission denied.'));
}
- $identities = User::identities(DI::session()->get('submanage', local_user()));
+ $identities = User::identities(DI::session()->get('submanage', Session::getLocalUser()));
//getting additinal information for each identity
foreach ($identities as $key => $identity) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.'));
}
- if (local_user()) {
+ if (Session::getLocalUser()) {
DI::page()['aside'] .= Widget::findPeople();
DI::page()['aside'] .= Widget::follow();
}
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'], local_user());
+ $contact = Model\Contact::getByURLForUser($entry['url'], Session::getLocalUser());
if (!empty($contact)) {
$entries[] = Contact::getContactTemplateVars($contact);
}
namespace Friendica\Module;
use Friendica\BaseModule;
+use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Protocol\Feed as ProtocolFeed;
protected function rawContent(array $request = [])
{
$last_update = $this->getRequestValue($request, 'last_update', '');
- $nocache = !empty($request['nocache']) && local_user();
+ $nocache = !empty($request['nocache']) && Session::getLocalUser();
$type = null;
// @TODO: Replace with parameter from router
namespace Friendica\Module;
use Friendica\BaseModule;
+use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model\Contact;
protected function post(array $request = [])
{
parent::post($request);
- $uid = local_user();
+ $uid = Session::getLocalUser();
if (!$uid) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return;
$duplex = intval($_POST['duplex'] ?? 0);
$hidden = intval($_POST['hidden'] ?? 0);
- $intro = DI::intro()->selectOneById($intro_id, local_user());
+ $intro = DI::intro()->selectOneById($intro_id, Session::getLocalUser());
Contact\Introduction::confirm($intro, $duplex, $hidden);
DI::intro()->delete($intro);
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;
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
throw new ForbiddenException($this->t('Permission denied.'));
}
$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' => local_user()])) {
+ if (!$this->dba->exists('contact', ['id' => $cid, 'uid' => Session::getLocalUser()])) {
throw new NotFoundException($this->t('Contact not found.'));
}
}
// 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' => local_user()]);
+ $contact = $this->dba->selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => Session::getLocalUser()]);
if (empty($contact)) {
DI::sysmsg()->addNotice($this->t('Suggested contact not found.'));
return;
$note = Strings::escapeHtml(trim($_POST['note'] ?? ''));
$suggest = $this->friendSuggestRepo->save($this->friendSuggestFac->createNew(
- local_user(),
+ Session::getLocalUser(),
$cid,
$contact['name'],
$contact['url'],
{
$cid = intval($this->parameters['contact']);
- $contact = $this->dba->selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
+ $contact = $this->dba->selectFirst('contact', [], ['id' => $cid, 'uid' => Session::getLocalUser()]);
if (empty($contact)) {
DI::sysmsg()->addNotice($this->t('Contact not found.'));
$this->baseUrl->redirect();
AND NOT `archive`
AND NOT `deleted`
AND `notify` != ""',
- local_user(),
+ Session::getLocalUser(),
$cid,
Protocol::DFRN,
]);
use Friendica\BaseModule;
use Friendica\Core\Renderer;
+use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
$this->ajaxPost();
}
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect();
}
BaseModule::checkFormSecurityTokenRedirectOnError('/group/new', 'group_edit');
$name = trim($request['groupname']);
- $r = Model\Group::create(local_user(), $name);
+ $r = Model\Group::create(Session::getLocalUser(), $name);
if ($r) {
- $r = Model\Group::getIdByName(local_user(), $name);
+ $r = Model\Group::getIdByName(Session::getLocalUser(), $name);
if ($r) {
DI::baseUrl()->redirect('group/' . $r);
}
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' => local_user()]);
+ $group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => Session::getLocalUser()]);
if (!DBA::isResult($group)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
DI::baseUrl()->redirect('contact');
public function ajaxPost()
{
try {
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
throw new \Exception(DI::l10n()->t('Permission denied.'), 403);
}
$group_id = $this->parameters['group'];
$contact_id = $this->parameters['contact'];
- if (!Model\Group::exists($group_id, local_user())) {
+ if (!Model\Group::exists($group_id, Session::getLocalUser())) {
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, local_user());
+ $cdata = Model\Contact::getPublicAndUserContactID($contact_id, Session::getLocalUser());
if (empty($cdata['public'])) {
throw new \Exception(DI::l10n()->t('Contact not found.'), 404);
}
{
$change = false;
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
throw new \Friendica\Network\HTTPException\ForbiddenException();
}
}
// Switch to text mode interface if we have more than 'n' contacts or group members
- $switchtotext = DI::pConfig()->get(local_user(), 'system', 'groupedit_image_limit');
+ $switchtotext = DI::pConfig()->get(Session::getLocalUser(), 'system', 'groupedit_image_limit');
if (is_null($switchtotext)) {
$switchtotext = DI::config()->get('system', 'groupedit_image_limit', 200);
}
// @TODO: Replace with parameter from router
if (intval(DI::args()->getArgv()[2])) {
- if (!Model\Group::exists(DI::args()->getArgv()[2], local_user())) {
+ if (!Model\Group::exists(DI::args()->getArgv()[2], Session::getLocalUser())) {
DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
DI::baseUrl()->redirect('contact');
}
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' => local_user(), 'self' => false, 'pending' => false, 'blocked' => false])) {
+ if (DBA::exists('contact', ['id' => DI::args()->getArgv()[2], 'uid' => Session::getLocalUser(), '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' => local_user(), 'deleted' => false]);
+ $group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => Session::getLocalUser(), 'deleted' => false]);
if (!DBA::isResult($group)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
DI::baseUrl()->redirect('contact');
}
if ($nogroup) {
- $contacts = Model\Contact\Group::listUngrouped(local_user());
+ $contacts = Model\Contact\Group::listUngrouped(Session::getLocalUser());
} else {
$contacts_stmt = DBA::select('contact', [],
['rel' => [Model\Contact::FOLLOWER, Model\Contact::FRIEND, Model\Contact::SHARING],
- 'uid' => local_user(), 'pending' => false, 'blocked' => false, 'failed' => false, 'self' => false],
+ 'uid' => Session::getLocalUser(), 'pending' => false, 'blocked' => false, 'failed' => false, 'self' => false],
['order' => ['name']]
);
$contacts = DBA::toArray($contacts_stmt);
{
protected function content(array $request = []): string
{
- if ((local_user()) && ($this->parameters['action'] ?? '') === 'view') {
+ if ((Session::getLocalUser()) && ($this->parameters['action'] ?? '') === 'view') {
// A logged in user views a profile of a user
$nickname = DI::app()->getLoggedInUserNickname();
} elseif (empty($this->parameters['action'])) {
use Friendica\BaseModule;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
+use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\Security\Login;
Hook::callAll('home_init', $ret);
- if (local_user() && ($app->getLoggedInUserNickname())) {
+ if (Session::getLocalUser() && ($app->getLoggedInUserNickname())) {
DI::baseUrl()->redirect('network');
}
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;
{
protected function post(array $request = [])
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$max_invites = 50;
}
- $current_invites = intval(DI::pConfig()->get(local_user(), 'system', 'sent_invites'));
+ $current_invites = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'sent_invites'));
if ($current_invites > $max_invites) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Total invitation limit exceeded.'));
}
if ($config->get('system', 'invitation_only')) {
$invitation_only = true;
- $invites_remaining = DI::pConfig()->get(local_user(), 'system', 'invites_remaining');
+ $invites_remaining = DI::pConfig()->get(Session::getLocalUser(), 'system', 'invites_remaining');
if ((!$invites_remaining) && (!$app->isSiteAdmin())) {
throw new HTTPException\ForbiddenException();
}
}
- $user = User::getById(local_user());
+ $user = User::getById(Session::getLocalUser());
foreach ($recipients as $recipient) {
$recipient = trim($recipient);
if (!$app->isSiteAdmin()) {
$invites_remaining--;
if ($invites_remaining >= 0) {
- DI::pConfig()->set(local_user(), 'system', 'invites_remaining', $invites_remaining);
+ DI::pConfig()->set(Session::getLocalUser(), 'system', 'invites_remaining', $invites_remaining);
} else {
return;
}
if ($res) {
$total++;
$current_invites++;
- DI::pConfig()->set(local_user(), 'system', 'sent_invites', $current_invites);
+ DI::pConfig()->set(Session::getLocalUser(), '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;
protected function content(array $request = []): string
{
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
if ($config->get('system', 'invitation_only')) {
$inviteOnly = true;
- $x = DI::pConfig()->get(local_user(), 'system', 'invites_remaining');
+ $x = DI::pConfig()->get(Session::getLocalUser(), 'system', 'invites_remaining');
if ((!$x) && (!$app->isSiteAdmin())) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('You have no more invitations available'));
}
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\L10n;
+use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\Database;
use Friendica\Model\Contact;
}
// OpenWebAuth
- if (local_user() && $owa) {
- $user = User::getById(local_user());
+ if (Session::getLocalUser() && $owa) {
+ $user = User::getById(Session::getLocalUser());
// Extract the basepath
// NOTE: we need another solution because this does only work
namespace Friendica\Module;
use Friendica\BaseModule;
+use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
if (isset($this->parameters['nick'])) {
// Get infos about a specific nick (public)
$which = $this->parameters['nick'];
- } elseif (local_user() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') {
+ } elseif (Session::getLocalUser() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') {
// view infos about a known profile (needs a login)
$which = $a->getLoggedInUserNickname();
} else {
namespace Friendica\Module;
use Friendica\Core\Hook;
+use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
throw new HTTPException\BadRequestException(DI::l10n()->t('Wrong type "%s", expected one of: %s', $type, implode(', ', $expectedTypes)));
}
- $condition = ['id' => $referenceId, 'uid' => [0, local_user()]];
+ $condition = ['id' => $referenceId, 'uid' => [0, Session::getLocalUser()]];
if ($type == 'item') {
$fields = ['uid', 'psid', 'private', 'uri-id'];
$model = Post::selectFirst($fields, $condition);
private function fetchReceivers(int $uriId): string
{
$own_url = '';
- $uid = local_user();
+ $uid = Session::getLocalUser();
if ($uid) {
$owner = User::getOwnerDataById($uid);
if (!empty($owner['url'])) {
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;
return MPhoto::getPhoto($matches[1], $matches[2]);
}
- return MPhoto::createPhotoForExternalResource($url, (int)local_user(), $media['mimetype'] ?? '');
+ return MPhoto::createPhotoForExternalResource($url, (int)Session::getLocalUser(), $media['mimetype'] ?? '');
case 'media':
$media = DBA::selectFirst('post-media', ['url', 'mimetype', 'uri-id'], ['id' => $id, 'type' => Post\Media::IMAGE]);
if (empty($media)) {
return MPhoto::getPhoto($matches[1], $matches[2]);
}
- return MPhoto::createPhotoForExternalResource($media['url'], (int)local_user(), $media['mimetype']);
+ return MPhoto::createPhotoForExternalResource($media['url'], (int)Session::getLocalUser(), $media['mimetype']);
case 'link':
$link = DBA::selectFirst('post-link', ['url', 'mimetype'], ['id' => $id]);
if (empty($link)) {
return false;
}
- return MPhoto::createPhotoForExternalResource($link['url'], (int)local_user(), $link['mimetype'] ?? '');
+ return MPhoto::createPhotoForExternalResource($link['url'], (int)Session::getLocalUser(), $link['mimetype'] ?? '');
case 'contact':
$fields = ['uid', 'uri-id', 'url', 'nurl', 'avatar', 'photo', 'xmpp', 'addr', 'network', 'failed', 'updated'];
$contact = Contact::getById($id, $fields);
use Friendica\BaseModule;
use Friendica\Core\Logger;
+use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
throw new \Friendica\Network\HTTPException\BadRequestException();
}
- if (!local_user()) {
+ if (!Session::getLocalUser()) {
Logger::debug('Redirecting not logged in user to original address', ['url' => $request['url']]);
System::externalRedirect($request['url']);
}
$request['url'] = str_replace(' ', '+', $request['url']);
// Fetch the content with the local user
- $fetchResult = HTTPSignature::fetchRaw($request['url'], local_user(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE], 'timeout' => 10]);
+ $fetchResult = HTTPSignature::fetchRaw($request['url'], Session::getLocalUser(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE], 'timeout' => 10]);
$img_str = $fetchResult->getBody();
if (!$fetchResult->isSuccess() || empty($img_str)) {
// stop.
}
- Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => local_user(), 'image' => $request['url']]);
+ Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => Session::getLocalUser(), 'image' => $request['url']]);
$mime = Images::getMimeTypeByData($img_str);
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;
// 'block_extended_register' blocks all registrations, period.
$block = DI::config()->get('system', 'block_extended_register');
- if (local_user() && $block) {
+ if (Session::getLocalUser() && $block) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return '';
}
- if (local_user()) {
- $user = DBA::selectFirst('user', ['parent-uid'], ['uid' => local_user()]);
+ if (Session::getLocalUser()) {
+ $user = DBA::selectFirst('user', ['parent-uid'], ['uid' => Session::getLocalUser()]);
if (!empty($user['parent-uid'])) {
DI::sysmsg()->addNotice(DI::l10n()->t('Only parent users can create additional accounts.'));
return '';
}
}
- if (!local_user() && (intval(DI::config()->get('config', 'register_policy')) === self::CLOSED)) {
+ if (!Session::getLocalUser() && (intval(DI::config()->get('config', 'register_policy')) === self::CLOSED)) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return '';
}
$photo = $_REQUEST['photo'] ?? '';
$invite_id = $_REQUEST['invite_id'] ?? '';
- if (local_user() || DI::config()->get('system', 'no_openid')) {
+ if (Session::getLocalUser() || DI::config()->get('system', 'no_openid')) {
$fillwith = '';
$fillext = '';
$oidlabel = '';
'$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(local_user()),
+ '$additional' => !empty(Session::getLocalUser()),
'$parent_password' => ['parent_password', DI::l10n()->t('Parent Password:'), '', DI::l10n()->t('Please enter the password of the parent account to legitimize your request.')]
]);
$additional_account = false;
- if (!local_user() && !empty($arr['post']['parent_password'])) {
+ if (!Session::getLocalUser() && !empty($arr['post']['parent_password'])) {
DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return;
- } elseif (local_user() && !empty($arr['post']['parent_password'])) {
+ } elseif (Session::getLocalUser() && !empty($arr['post']['parent_password'])) {
try {
- Model\User::getIdFromPasswordAuthentication(local_user(), $arr['post']['parent_password']);
+ Model\User::getIdFromPasswordAuthentication(Session::getLocalUser(), $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 (local_user()) {
+ } elseif (Session::getLocalUser()) {
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));
}
if ($additional_account) {
- $user = DBA::selectFirst('user', ['email'], ['uid' => local_user()]);
+ $user = DBA::selectFirst('user', ['email'], ['uid' => Session::getLocalUser()]);
if (!DBA::isResult($user)) {
DI::sysmsg()->addNotice(DI::l10n()->t('User not found.'));
DI::baseUrl()->redirect('register');
}
if ($additional_account) {
- DBA::update('user', ['parent-uid' => local_user()], ['uid' => $user['uid']]);
+ DBA::update('user', ['parent-uid' => Session::getLocalUser()], ['uid' => $user['uid']]);
DI::sysmsg()->addInfo(DI::l10n()->t('The additional account was created.'));
DI::baseUrl()->redirect('delegation');
}