old boot.php functions replaced in src/module (4)

This commit is contained in:
Michael 2022-10-19 04:43:47 +00:00 committed by Hypolite Petovan
parent de6eabde58
commit d47d78f2d4
22 changed files with 140 additions and 158 deletions

View file

@ -50,7 +50,7 @@ class Contacts extends Module\BaseProfile
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
$is_owner = $profile['uid'] == local_user();
$is_owner = $profile['uid'] == Session::getLocalUser();
if ($profile['hide-friends'] && !$is_owner) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
@ -60,7 +60,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'] != local_user());
$tabs = self::getContactFilterTabs('profile/' . $nickname, $type, Session::isAuthenticated() && $profile['uid'] != Session::getLocalUser());
$condition = [
'uid' => $profile['uid'],

View file

@ -21,6 +21,7 @@
namespace Friendica\Module\Profile;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile as ProfileModel;
@ -42,7 +43,7 @@ class Media extends BaseProfile
DI::page()['htmlhead'] .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
}
$is_owner = local_user() == $profile['uid'];
$is_owner = Session::getLocalUser() == $profile['uid'];
$o = self::getTabsHTML($a, 'media', $is_owner, $profile['nickname'], $profile['hide-friends']);

View file

@ -84,11 +84,11 @@ class Profile extends BaseProfile
$remote_contact_id = Session::getRemoteContactID($profile['uid']);
if (DI::config()->get('system', 'block_public') && !local_user() && !$remote_contact_id) {
if (DI::config()->get('system', 'block_public') && !Session::getLocalUser() && !$remote_contact_id) {
return Login::form();
}
$is_owner = local_user() == $profile['uid'];
$is_owner = Session::getLocalUser() == $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 +102,7 @@ class Profile extends BaseProfile
Nav::setSelected('home');
$is_owner = local_user() == $profile['uid'];
$is_owner = Session::getLocalUser() == $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 +117,7 @@ class Profile extends BaseProfile
$view_as_contact_id = intval($_GET['viewas'] ?? 0);
$view_as_contacts = Contact::selectToArray(['id', 'name'], [
'uid' => local_user(),
'uid' => Session::getLocalUser(),
'rel' => [Contact::FOLLOWER, Contact::SHARING, Contact::FRIEND],
'network' => Protocol::DFRN,
'blocked' => false,
@ -247,7 +247,7 @@ class Profile extends BaseProfile
'$submit' => DI::l10n()->t('Submit'),
'$basic' => DI::l10n()->t('Basic'),
'$advanced' => DI::l10n()->t('Advanced'),
'$is_owner' => $profile['uid'] == local_user(),
'$is_owner' => $profile['uid'] == Session::getLocalUser(),
'$query_string' => DI::args()->getQueryString(),
'$basic_fields' => $basic_fields,
'$custom_fields' => $custom_fields,
@ -308,8 +308,8 @@ class Profile extends BaseProfile
}
// site block
$blocked = !local_user() && !$remote_contact_id && DI::config()->get('system', 'block_public');
$userblock = !local_user() && !$remote_contact_id && $profile['hidewall'];
$blocked = !Session::getLocalUser() && !$remote_contact_id && DI::config()->get('system', 'block_public');
$userblock = !Session::getLocalUser() && !$remote_contact_id && $profile['hidewall'];
if (!$blocked && !$userblock) {
$keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], $profile['pub_keywords'] ?? '');
if (strlen($keywords)) {

View file

@ -24,6 +24,7 @@ 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;
@ -35,7 +36,7 @@ class Schedule extends BaseProfile
{
protected function post(array $request = [])
{
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
@ -43,7 +44,7 @@ class Schedule extends BaseProfile
throw new HTTPException\BadRequestException();
}
if (!DBA::exists('delayed-post', ['id' => $_REQUEST['delete'], 'uid' => local_user()])) {
if (!DBA::exists('delayed-post', ['id' => $_REQUEST['delete'], 'uid' => Session::getLocalUser()])) {
throw new HTTPException\NotFoundException();
}
@ -52,7 +53,7 @@ class Schedule extends BaseProfile
protected function content(array $request = []): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
@ -61,7 +62,7 @@ class Schedule extends BaseProfile
$o = self::getTabsHTML($a, 'schedule', true, $a->getLoggedInUserNickname(), false);
$schedule = [];
$delayed = DBA::select('delayed-post', [], ['uid' => local_user()]);
$delayed = DBA::select('delayed-post', [], ['uid' => Session::getLocalUser()]);
while ($row = DBA::fetch($delayed)) {
$parameter = Post\Delayed::getParametersForid($row['id']);
if (empty($parameter)) {

View file

@ -92,19 +92,19 @@ class Status extends BaseProfile
$hashtags = $_GET['tag'] ?? '';
if (DI::config()->get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($profile['uid'])) {
if (DI::config()->get('system', 'block_public') && !Session::getLocalUser() && !Session::getRemoteContactID($profile['uid'])) {
return Login::form();
}
$o = '';
if ($profile['uid'] == local_user()) {
if ($profile['uid'] == Session::getLocalUser()) {
Nav::setSelected('home');
}
$remote_contact = Session::getRemoteContactID($profile['uid']);
$is_owner = local_user() == $profile['uid'];
$last_updated_key = "profile:" . $profile['uid'] . ":" . local_user() . ":" . $remote_contact;
$is_owner = Session::getLocalUser() == $profile['uid'];
$last_updated_key = "profile:" . $profile['uid'] . ":" . Session::getLocalUser() . ":" . $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 +166,10 @@ class Status extends BaseProfile
}
if (DI::mode()->isMobile()) {
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
$itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
DI::config()->get('system', 'itemspage_network_mobile'));
} else {
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
$itemspage_network = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
DI::config()->get('system', 'itemspage_network'));
}
@ -197,9 +197,9 @@ class Status extends BaseProfile
}
if ($is_owner) {
$unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => local_user()]);
$unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]);
if ($unseen) {
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]);
}
}