Merge pull request #12022 from annando/no-boot-various

old boot.php functions replaced in various places
This commit is contained in:
Hypolite Petovan 2022-10-19 07:50:42 -04:00 committed by GitHub
commit 7fc37832f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 183 additions and 105 deletions

View File

@ -281,7 +281,7 @@ $data = [
'submit' => [
'catavatar-usecat' => DI::l10n()->t('Use Cat as Avatar'),
'catavatar-morecat' => DI::l10n()->t('Another random Cat!'),
'catavatar-emailcat' => DI::pConfig()->get(local_user(), 'catavatar', 'seed', false) ? DI::l10n()->t('Reset to email Cat') : null,
'catavatar-emailcat' => DI::pConfig()->get(Session::getLocalUser(), 'catavatar', 'seed', false) ? DI::l10n()->t('Reset to email Cat') : null,
],
];
```

View File

@ -30,7 +30,7 @@ function doSomething(array $intros)
}
}
$intros = \Friendica\Database\DBA::selectToArray('intros', [], ['uid' => local_user()]);
$intros = \Friendica\Database\DBA::selectToArray('intros', [], ['uid' => Session::getLocalUser()]);
doSomething($intros);
```
@ -47,7 +47,7 @@ function doSomething(\Friendica\Contact\Introductions\Collection\Introductions $
}
/** @var $intros \Friendica\Contact\Introductions\Collection\Introductions */
$intros = \Friendica\DI::intro()->selecForUser(local_user());
$intros = \Friendica\DI::intro()->selecForUser(Session::getLocalUser());
doSomething($intros);
```

View File

@ -123,13 +123,13 @@ The selected 1st part will be saved in the database by the theme_post function.
function theme_post(App $a){
// non local users shall not pass
if (! local_user()) {
if (!Session::getLocalUser()) {
return;
}
// if the one specific submit button was pressed then proceed
if (isset($_POST['duepuntozero-settings-submit'])){
// and save the selection key into the personal config of the user
DI::pConfig()->set(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
DI::pConfig()->set(Session::getLocalUser(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
}
}
@ -137,7 +137,7 @@ Now that this information is set in the database, what should friendica do with
For this, have a look at the theme.php file of the *duepunto zero*.
There you'll find somethink alike
$colorset = DI::pConfig()->get( local_user(), 'duepuntozero','colorset');
$colorset = DI::pConfig()->get(Session::getLocalUser(), 'duepuntozero','colorset');
if (!$colorset)
$colorset = DI::config()->get('duepuntozero', 'colorset');
if ($colorset) {

View File

@ -23,6 +23,7 @@ namespace Friendica\Navigation\Notifications\Factory;
use Friendica\BaseFactory;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Model\Contact;
use Friendica\Navigation\Notifications\Entity;
use Friendica\Navigation\Notifications\Exception\NoMessageException;
@ -71,7 +72,7 @@ class FormattedNavNotification extends BaseFactory
*/
public function createFromParams(array $contact, string $message, \DateTime $date, Uri $href, bool $seen = false): ValueObject\FormattedNavNotification
{
$contact['photo'] = Contact::getAvatarUrlForUrl($contact['url'], local_user(), Proxy::SIZE_MICRO);
$contact['photo'] = Contact::getAvatarUrlForUrl($contact['url'], Session::getLocalUser(), Proxy::SIZE_MICRO);
$dateMySQL = $date->format(DateTimeFormat::MYSQL);

View File

@ -27,6 +27,7 @@ use Friendica\BaseFactory;
use Friendica\Content\Text\BBCode;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\Session;
use Friendica\Database\Database;
use Friendica\Model\Contact;
use Friendica\Model\Item;
@ -210,7 +211,7 @@ class FormattedNotify extends BaseFactory
$formattedNotifications = new FormattedNotifies();
try {
$Notifies = $this->notify->selectForUser(local_user(), $conditions, $params);
$Notifies = $this->notify->selectForUser(Session::getLocalUser(), $conditions, $params);
foreach ($Notifies as $Notify) {
$formattedNotifications[] = new ValueObject\FormattedNotify(
@ -243,7 +244,7 @@ class FormattedNotify extends BaseFactory
*/
public function getNetworkList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies
{
$condition = ['wall' => false, 'uid' => local_user()];
$condition = ['wall' => false, 'uid' => Session::getLocalUser()];
if (!$seen) {
$condition['unseen'] = true;
@ -256,7 +257,7 @@ class FormattedNotify extends BaseFactory
$formattedNotifications = new FormattedNotifies();
try {
$userPosts = Post::selectForUser(local_user(), $fields, $condition, $params);
$userPosts = Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params);
while ($userPost = $this->dba->fetch($userPosts)) {
$formattedNotifications[] = $this->createFromFormattedItem($this->formatItem($userPost));
}
@ -279,7 +280,7 @@ class FormattedNotify extends BaseFactory
*/
public function getPersonalList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies
{
$condition = ['wall' => false, 'uid' => local_user(), 'author-id' => public_contact()];
$condition = ['wall' => false, 'uid' => Session::getLocalUser(), 'author-id' => Session::getPublicContact()];
if (!$seen) {
$condition['unseen'] = true;
@ -292,7 +293,7 @@ class FormattedNotify extends BaseFactory
$formattedNotifications = new FormattedNotifies();
try {
$userPosts = Post::selectForUser(local_user(), $fields, $condition, $params);
$userPosts = Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params);
while ($userPost = $this->dba->fetch($userPosts)) {
$formattedNotifications[] = $this->createFromFormattedItem($this->formatItem($userPost));
}
@ -315,7 +316,7 @@ class FormattedNotify extends BaseFactory
*/
public function getHomeList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies
{
$condition = ['wall' => true, 'uid' => local_user()];
$condition = ['wall' => true, 'uid' => Session::getLocalUser()];
if (!$seen) {
$condition['unseen'] = true;
@ -328,7 +329,7 @@ class FormattedNotify extends BaseFactory
$formattedNotifications = new FormattedNotifies();
try {
$userPosts = Post::selectForUser(local_user(), $fields, $condition, $params);
$userPosts = Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params);
while ($userPost = $this->dba->fetch($userPosts)) {
$formattedItem = $this->formatItem($userPost);

View File

@ -29,6 +29,7 @@ use Friendica\Content\Text\BBCode;
use Friendica\Core\L10n;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\Core\Protocol;
use Friendica\Core\Session;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Database\Database;
use Friendica\Model\Contact;
@ -142,7 +143,7 @@ class Introduction extends BaseFactory
'url' => $intro['furl'],
'zrl' => Contact::magicLink($intro['furl']),
'hidden' => $intro['hidden'] == 1,
'post_newfriend' => (intval($this->pConfig->get(local_user(), 'system', 'post_newfriend')) ? '1' : 0),
'post_newfriend' => (intval($this->pConfig->get(Session::getLocalUser(), 'system', 'post_newfriend')) ? '1' : 0),
'note' => $intro['note'],
'request' => $intro['frequest'] . '?addr=' . $return_addr]);
@ -167,7 +168,7 @@ class Introduction extends BaseFactory
'about' => BBCode::convert($intro['about'], false),
'keywords' => $intro['keywords'],
'hidden' => $intro['hidden'] == 1,
'post_newfriend' => (intval($this->pConfig->get(local_user(), 'system', 'post_newfriend')) ? '1' : 0),
'post_newfriend' => (intval($this->pConfig->get(Session::getLocalUser(), 'system', 'post_newfriend')) ? '1' : 0),
'url' => $intro['url'],
'zrl' => Contact::magicLink($intro['url']),
'addr' => $intro['addr'],

View File

@ -27,6 +27,7 @@ use Exception;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
@ -316,7 +317,7 @@ class Probe
}
if ($uid == -1) {
$uid = local_user();
$uid = Session::getLocalUser();
}
if (empty($network) || ($network == Protocol::ACTIVITYPUB)) {

View File

@ -104,14 +104,14 @@ class Post
if (!empty($data['children'])) {
foreach ($data['children'] as $item) {
// Only add will be displayed
if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
if ($item['network'] === Protocol::MAIL && Session::getLocalUser() != $item['uid']) {
continue;
} elseif (!DI::contentItem()->isVisibleActivity($item)) {
continue;
}
// You can always comment on Diaspora and OStatus items
if (in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA]) && (local_user() == $item['uid'])) {
if (in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA]) && (Session::getLocalUser() == $item['uid'])) {
$item['writable'] = true;
}
@ -206,7 +206,7 @@ class Post
$lock = ($item['private'] == Item::PRIVATE) ? $privacy : false;
$connector = !in_array($item['network'], Protocol::NATIVE_SUPPORT) ? DI::l10n()->t('Connector Message') : false;
$shareable = in_array($conv->getProfileOwner(), [0, local_user()]) && $item['private'] != Item::PRIVATE;
$shareable = in_array($conv->getProfileOwner(), [0, Session::getLocalUser()]) && $item['private'] != Item::PRIVATE;
$announceable = $shareable && in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::TWITTER]);
// On Diaspora only toplevel posts can be reshared
@ -216,7 +216,7 @@ class Post
$edpost = false;
if (local_user()) {
if (Session::getLocalUser()) {
if (Strings::compareLink(DI::session()->get('my_url'), $item['author-link'])) {
if ($item['event-id'] != 0) {
$edpost = ['events/event/' . $item['event-id'], DI::l10n()->t('Edit')];
@ -224,7 +224,7 @@ class Post
$edpost = ['editpost/' . $item['id'], DI::l10n()->t('Edit')];
}
}
$dropping = in_array($item['uid'], [0, local_user()]);
$dropping = in_array($item['uid'], [0, Session::getLocalUser()]);
}
// Editing on items of not subscribed users isn't currently possible
@ -234,7 +234,7 @@ class Post
$edpost = false;
}
if (($this->getDataValue('uid') == local_user()) || $this->isVisiting()) {
if (($this->getDataValue('uid') == Session::getLocalUser()) || $this->isVisiting()) {
$dropping = true;
}
@ -249,7 +249,7 @@ class Post
$drop = false;
$block = false;
if (local_user()) {
if (Session::getLocalUser()) {
$drop = [
'dropping' => $dropping,
'pagedrop' => $item['pagedrop'],
@ -258,7 +258,7 @@ class Post
];
}
if (!$item['self'] && local_user()) {
if (!$item['self'] && Session::getLocalUser()) {
$block = [
'blocking' => true,
'block' => DI::l10n()->t('Block %s', $item['author-name']),
@ -266,7 +266,7 @@ class Post
];
}
$filer = local_user() ? DI::l10n()->t('Save to folder') : false;
$filer = Session::getLocalUser() ? DI::l10n()->t('Save to folder') : false;
$profile_name = $item['author-name'];
if (!empty($item['author-link']) && empty($item['author-name'])) {
@ -327,8 +327,8 @@ class Post
$tagger = '';
if ($this->isToplevel()) {
if (local_user()) {
$ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], local_user());
if (Session::getLocalUser()) {
$ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], Session::getLocalUser());
if ($item['mention'] || $ignored) {
$ignore = [
'do' => DI::l10n()->t('Ignore thread'),
@ -351,7 +351,7 @@ class Post
'starred' => DI::l10n()->t('Starred'),
];
if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) {
if ($conv->getProfileOwner() == Session::getLocalUser() && ($item['uid'] != 0)) {
if ($origin && in_array($item['private'], [Item::PUBLIC, Item::UNLISTED])) {
$ispinned = ($item['featured'] ? 'pinned' : 'unpinned');
@ -397,17 +397,17 @@ class Post
$body_html = Item::prepareBody($item, true);
list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item, local_user());
list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item, Session::getLocalUser());
if (!empty($item['title'])) {
$title = $item['title'];
} elseif (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) {
} elseif (!empty($item['content-warning']) && DI::pConfig()->get(Session::getLocalUser(), 'system', 'disable_cw', false)) {
$title = ucfirst($item['content-warning']);
} else {
$title = '';
}
if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) {
if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'hide_dislike')) {
$buttons['dislike'] = false;
}
@ -434,7 +434,7 @@ class Post
}
// Fetching of Diaspora posts doesn't always work. There are issues with reshares and possibly comments
if (!local_user() && ($item['network'] != Protocol::DIASPORA) && !empty(DI::session()->get('remote_comment'))) {
if (!Session::getLocalUser() && ($item['network'] != Protocol::DIASPORA) && !empty(DI::session()->get('remote_comment'))) {
$remote_comment = [DI::l10n()->t('Comment this item on your system'), DI::l10n()->t('Remote comment'),
str_replace('{uri}', urlencode($item['uri']), DI::session()->get('remote_comment'))];
@ -642,7 +642,7 @@ class Post
/*
* Only add what will be displayed
*/
if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {
if ($item->getDataValue('network') === Protocol::MAIL && Session::getLocalUser() != $item->getDataValue('uid')) {
return false;
} elseif ($activity->match($item->getDataValue('verb'), Activity::LIKE) ||
$activity->match($item->getDataValue('verb'), Activity::DISLIKE)) {
@ -850,7 +850,7 @@ class Post
// This will allow us to comment on wall-to-wall items owned by our friends
// and community forums even if somebody else wrote the post.
// bug #517 - this fixes for conversation owner
if ($conv->getMode() == 'profile' && $conv->getProfileOwner() == local_user()) {
if ($conv->getMode() == 'profile' && $conv->getProfileOwner() == Session::getLocalUser()) {
return true;
}
@ -898,20 +898,20 @@ class Post
{
$a = DI::app();
if (!local_user()) {
if (!Session::getLocalUser()) {
return '';
}
$owner = User::getOwnerDataById($a->getLoggedInUserId());
$item = $this->getData();
if (!empty($item['content-warning']) && Feature::isEnabled(local_user(), 'add_abstract')) {
if (!empty($item['content-warning']) && Feature::isEnabled(Session::getLocalUser(), 'add_abstract')) {
$text = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $item['content-warning'] . "[/abstract]\n";
} else {
$text = '';
}
if (!Feature::isEnabled(local_user(), 'explicit_mentions')) {
if (!Feature::isEnabled(Session::getLocalUser(), 'explicit_mentions')) {
return $text;
}
@ -958,7 +958,7 @@ class Post
*/
$qcomment = null;
if (Addon::isEnabled('qcomment')) {
$words = DI::pConfig()->get(local_user(), 'qcomment', 'words');
$words = DI::pConfig()->get(Session::getLocalUser(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : [];
}

View File

@ -23,6 +23,7 @@ namespace Friendica\Object;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Protocol\Activity;
use Friendica\Security\Security;
@ -75,7 +76,7 @@ class Thread
switch ($mode) {
case 'network':
case 'notes':
$this->profile_owner = local_user();
$this->profile_owner = Session::getLocalUser();
$this->writable = true;
break;
case 'profile':
@ -168,7 +169,7 @@ class Thread
/*
* Only add will be displayed
*/
if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {
if ($item->getDataValue('network') === Protocol::MAIL && Session::getLocalUser() != $item->getDataValue('uid')) {
Logger::info('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').');
return false;
}
@ -201,7 +202,7 @@ class Thread
$result = [];
foreach ($this->parents as $item) {
if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) {
if ($item->getDataValue('network') === Protocol::MAIL && Session::getLocalUser() != $item->getDataValue('uid')) {
continue;
}

View File

@ -191,7 +191,7 @@ class BasicAuth
Hook::callAll('logged_in', $record);
self::$current_user_id = local_user();
self::$current_user_id = Session::getLocalUser();
return self::$current_user_id;
}

View File

@ -40,12 +40,12 @@ class Security
return false;
}
$uid = local_user();
$uid = Session::getLocalUser();
if ($uid == $owner) {
return true;
}
if (local_user() && ($owner == 0)) {
if (Session::getLocalUser() && ($owner == 0)) {
return true;
}
@ -93,7 +93,7 @@ class Security
*/
public static function getPermissionsSQLByUserId(int $owner_id, bool $accessible = false)
{
$local_user = local_user();
$local_user = Session::getLocalUser();
$remote_contact = Session::getRemoteContactID($owner_id);
$acc_sql = '';

View File

@ -24,6 +24,7 @@ namespace Friendica\Util;
use DateTime;
use DateTimeZone;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
@ -238,7 +239,7 @@ class Temporal
bool $required = false): string
{
// First day of the week (0 = Sunday)
$firstDay = DI::pConfig()->get(local_user(), 'system', 'first_day_of_week', 0);
$firstDay = DI::pConfig()->get(Session::getLocalUser(), 'system', 'first_day_of_week', 0);
$lang = substr(DI::l10n()->getCurrentLang(), 0, 2);

View File

@ -1,19 +1,36 @@
<?php
/**
* Theme settings
* @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
use Friendica\App;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
function theme_content(App $a)
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return;
}
$colorset = DI::pConfig()->get(local_user(), 'duepuntozero', 'colorset');
$colorset = DI::pConfig()->get(Session::getLocalUser(), 'duepuntozero', 'colorset');
$user = true;
return clean_form($a, $colorset, $user);
@ -21,12 +38,12 @@ function theme_content(App $a)
function theme_post(App $a)
{
if (! local_user()) {
if (! Session::getLocalUser()) {
return;
}
if (isset($_POST['duepuntozero-settings-submit'])) {
DI::pConfig()->set(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
DI::pConfig()->set(Session::getLocalUser(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']);
}
}
@ -59,7 +76,7 @@ function clean_form(App $a, &$colorset, $user)
];
if ($user) {
$color = DI::pConfig()->get(local_user(), 'duepuntozero', 'colorset');
$color = DI::pConfig()->get(Session::getLocalUser(), 'duepuntozero', 'colorset');
} else {
$color = DI::config()->get('duepuntozero', 'colorset');
}

View File

@ -21,6 +21,7 @@
use Friendica\App;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
/*
@ -34,7 +35,7 @@ function duepuntozero_init(App $a) {
$colorset = null;
if (DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) {
$colorset = DI::pConfig()->get(local_user(), 'duepuntozero', 'colorset');
$colorset = DI::pConfig()->get(Session::getLocalUser(), 'duepuntozero', 'colorset');
if (!$colorset)
$colorset = DI::config()->get('duepuntozero', 'colorset'); // user setting have priority, then node settings
}

View File

@ -21,13 +21,14 @@
use Friendica\App;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
require_once 'view/theme/frio/php/Image.php';
function theme_post(App $a)
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return;
}
@ -47,12 +48,12 @@ function theme_post(App $a)
'always_open_compose',
] as $field) {
if (isset($_POST['frio_' . $field])) {
DI::pConfig()->set(local_user(), 'frio', $field, $_POST['frio_' . $field]);
DI::pConfig()->set(Session::getLocalUser(), 'frio', $field, $_POST['frio_' . $field]);
}
}
DI::pConfig()->set(local_user(), 'frio', 'css_modified', time());
DI::pConfig()->set(Session::getLocalUser(), 'frio', 'css_modified', time());
}
}
@ -88,13 +89,13 @@ function theme_admin_post(App $a)
function theme_content(): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return '';
}
$arr = [
'scheme' => DI::pConfig()->get(local_user(), 'frio', 'scheme',
DI::pConfig()->get(local_user(), 'frio', 'schema',
'scheme' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'scheme',
DI::pConfig()->get(Session::getLocalUser(), 'frio', 'schema',
DI::config()->get('frio', 'scheme',
DI::config()->get('frio', 'schema')
)
@ -102,15 +103,15 @@ function theme_content(): string
),
'share_string' => '',
'scheme_accent' => DI::pConfig()->get(local_user(), 'frio', 'scheme_accent' , DI::config()->get('frio', 'scheme_accent')),
'nav_bg' => DI::pConfig()->get(local_user(), 'frio', 'nav_bg' , DI::config()->get('frio', 'nav_bg')),
'nav_icon_color' => DI::pConfig()->get(local_user(), 'frio', 'nav_icon_color' , DI::config()->get('frio', 'nav_icon_color')),
'link_color' => DI::pConfig()->get(local_user(), 'frio', 'link_color' , DI::config()->get('frio', 'link_color')),
'background_color' => DI::pConfig()->get(local_user(), 'frio', 'background_color' , DI::config()->get('frio', 'background_color')),
'contentbg_transp' => DI::pConfig()->get(local_user(), 'frio', 'contentbg_transp' , DI::config()->get('frio', 'contentbg_transp')),
'background_image' => DI::pConfig()->get(local_user(), 'frio', 'background_image' , DI::config()->get('frio', 'background_image')),
'bg_image_option' => DI::pConfig()->get(local_user(), 'frio', 'bg_image_option' , DI::config()->get('frio', 'bg_image_option')),
'always_open_compose' => DI::pConfig()->get(local_user(), 'frio', 'always_open_compose', DI::config()->get('frio', 'always_open_compose', false)),
'scheme_accent' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'scheme_accent' , DI::config()->get('frio', 'scheme_accent')),
'nav_bg' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'nav_bg' , DI::config()->get('frio', 'nav_bg')),
'nav_icon_color' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'nav_icon_color' , DI::config()->get('frio', 'nav_icon_color')),
'link_color' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'link_color' , DI::config()->get('frio', 'link_color')),
'background_color' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'background_color' , DI::config()->get('frio', 'background_color')),
'contentbg_transp' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'contentbg_transp' , DI::config()->get('frio', 'contentbg_transp')),
'background_image' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'background_image' , DI::config()->get('frio', 'background_image')),
'bg_image_option' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'bg_image_option' , DI::config()->get('frio', 'bg_image_option')),
'always_open_compose' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'always_open_compose', DI::config()->get('frio', 'always_open_compose', false)),
];
return frio_form($arr);
@ -118,7 +119,7 @@ function theme_content(): string
function theme_admin(): string
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return '';
}

View File

@ -34,6 +34,7 @@
* 'overwrites' => Variables which overwriting custom settings
*/
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Util\Strings;
@ -42,7 +43,7 @@ function get_scheme_info($scheme)
$theme = DI::app()->getCurrentTheme();
$themepath = 'view/theme/' . $theme . '/';
if (empty($scheme)) {
$scheme = DI::pConfig()->get(local_user(), 'frio', 'scheme', DI::pConfig()->get(local_user(), 'frio', 'schema', '---'));
$scheme = DI::pConfig()->get(Session::getLocalUser(), 'frio', 'scheme', DI::pConfig()->get(Session::getLocalUser(), 'frio', 'schema', '---'));
}
$scheme = Strings::sanitizeFilePathItem($scheme);

View File

@ -215,8 +215,8 @@ function frio_remote_nav(App $a, array &$nav_info)
$fields = ['id', 'url', 'avatar', 'micro', 'name', 'nick', 'baseurl', 'updated'];
if ($a->isLoggedIn()) {
$remoteUser = Contact::selectFirst($fields, ['uid' => $a->getLoggedInUserId(), 'self' => true]);
} elseif (!local_user() && remote_user()) {
$remoteUser = Contact::getById(remote_user(), $fields);
} elseif (!Session::getLocalUser() && Session::getRemoteUser()) {
$remoteUser = Contact::getById(Session::getRemoteUser(), $fields);
$nav_info['nav']['remote'] = DI::l10n()->t('Guest');
} elseif (Profile::getMyURL()) {
$remoteUser = Contact::getByURL($homelink, null, $fields);
@ -233,7 +233,7 @@ function frio_remote_nav(App $a, array &$nav_info)
$server_url = $remoteUser['baseurl'];
}
if (!local_user() && !empty($server_url) && !is_null($remoteUser)) {
if (!Session::getLocalUser() && !empty($server_url) && !is_null($remoteUser)) {
// user menu
$nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'], DI::l10n()->t('Status'), '', DI::l10n()->t('Your posts and conversations')];
$nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'] . '/profile', DI::l10n()->t('Profile'), '', DI::l10n()->t('Your profile page')];
@ -257,8 +257,8 @@ function frio_display_item(App $a, &$arr)
// Add follow to the item menu
$followThread = [];
if (
local_user()
&& in_array($arr['item']['uid'], [0, local_user()])
Session::getLocalUser()
&& in_array($arr['item']['uid'], [0, Session::getLocalUser()])
&& $arr['item']['gravity'] == Item::GRAVITY_PARENT
&& !$arr['item']['self']
&& !$arr['item']['mention']

View File

@ -1,35 +1,52 @@
<?php
/**
* Theme settings
* @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
use Friendica\App;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
function theme_content(App $a) {
if (!local_user()) {
if (!Session::getLocalUser()) {
return;
}
$align = DI::pConfig()->get(local_user(), 'quattro', 'align' );
$color = DI::pConfig()->get(local_user(), 'quattro', 'color' );
$tfs = DI::pConfig()->get(local_user(),"quattro","tfs");
$pfs = DI::pConfig()->get(local_user(),"quattro","pfs");
$align = DI::pConfig()->get(Session::getLocalUser(), 'quattro', 'align' );
$color = DI::pConfig()->get(Session::getLocalUser(), 'quattro', 'color' );
$tfs = DI::pConfig()->get(Session::getLocalUser(),"quattro","tfs");
$pfs = DI::pConfig()->get(Session::getLocalUser(),"quattro","pfs");
return quattro_form($a,$align, $color, $tfs, $pfs);
}
function theme_post(App $a) {
if (! local_user()) {
if (! Session::getLocalUser()) {
return;
}
if (isset($_POST['quattro-settings-submit'])){
DI::pConfig()->set(local_user(), 'quattro', 'align', $_POST['quattro_align']);
DI::pConfig()->set(local_user(), 'quattro', 'color', $_POST['quattro_color']);
DI::pConfig()->set(local_user(), 'quattro', 'tfs', $_POST['quattro_tfs']);
DI::pConfig()->set(local_user(), 'quattro', 'pfs', $_POST['quattro_pfs']);
DI::pConfig()->set(Session::getLocalUser(), 'quattro', 'align', $_POST['quattro_align']);
DI::pConfig()->set(Session::getLocalUser(), 'quattro', 'color', $_POST['quattro_color']);
DI::pConfig()->set(Session::getLocalUser(), 'quattro', 'tfs', $_POST['quattro_tfs']);
DI::pConfig()->set(Session::getLocalUser(), 'quattro', 'pfs', $_POST['quattro_pfs']);
}
}

View File

@ -1,17 +1,34 @@
<?php
/**
* Theme settings
* @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
use Friendica\App;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
require_once __DIR__ . '/theme.php';
function theme_content(App $a)
{
if (!local_user()) {
if (!Session::getLocalUser()) {
return;
}
@ -19,7 +36,7 @@ function theme_content(App $a)
return;
}
$style = DI::pConfig()->get(local_user(), 'vier', 'style');
$style = DI::pConfig()->get(Session::getLocalUser(), 'vier', 'style');
if ($style == "") {
$style = DI::config()->get('vier', 'style');
@ -42,18 +59,18 @@ function theme_content(App $a)
function theme_post(App $a)
{
if (! local_user()) {
if (! Session::getLocalUser()) {
return;
}
if (isset($_POST['vier-settings-submit'])) {
DI::pConfig()->set(local_user(), 'vier', 'style', $_POST['vier_style']);
DI::pConfig()->set(local_user(), 'vier', 'show_pages', $_POST['vier_show_pages']);
DI::pConfig()->set(local_user(), 'vier', 'show_profiles', $_POST['vier_show_profiles']);
DI::pConfig()->set(local_user(), 'vier', 'show_helpers', $_POST['vier_show_helpers']);
DI::pConfig()->set(local_user(), 'vier', 'show_services', $_POST['vier_show_services']);
DI::pConfig()->set(local_user(), 'vier', 'show_friends', $_POST['vier_show_friends']);
DI::pConfig()->set(local_user(), 'vier', 'show_lastusers', $_POST['vier_show_lastusers']);
DI::pConfig()->set(Session::getLocalUser(), 'vier', 'style', $_POST['vier_style']);
DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_pages', $_POST['vier_show_pages']);
DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_profiles', $_POST['vier_show_profiles']);
DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_helpers', $_POST['vier_show_helpers']);
DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_services', $_POST['vier_show_services']);
DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_friends', $_POST['vier_show_friends']);
DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_lastusers', $_POST['vier_show_lastusers']);
}
}

View File

@ -1,5 +1,22 @@
<?php
/**
* @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Name: Vier
* Version: 1.2
* Author: Fabio <http://kirgroup.com/profile/fabrixxm>
@ -14,6 +31,7 @@ use Friendica\Content\ForumManager;
use Friendica\Core\Addon;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
@ -35,7 +53,7 @@ function vier_init(App $a)
DI::mode()->has(App\Mode::MAINTENANCEDISABLED)
&& (
$args->get(0) === 'profile' && $args->get(1) === ($a->getLoggedInUserNickname() ?? '')
|| $args->get(0) === 'network' && local_user()
|| $args->get(0) === 'network' && Session::getLocalUser()
)
) {
vier_community_info();
@ -97,8 +115,8 @@ EOT;
function get_vier_config($key, $default = false, $admin = false)
{
if (local_user() && !$admin) {
$result = DI::pConfig()->get(local_user(), "vier", $key);
if (Session::getLocalUser() && !$admin) {
$result = DI::pConfig()->get(Session::getLocalUser(), "vier", $key);
if (!is_null($result)) {
return $result;
}
@ -127,7 +145,7 @@ function vier_community_info()
// comunity_profiles
if ($show_profiles) {
$contacts = Contact\Relation::getSuggestions(local_user(), 0, 9);
$contacts = Contact\Relation::getSuggestions(Session::getLocalUser(), 0, 9);
$tpl = Renderer::getMarkupTemplate('ch_directory_item.tpl');
if (DBA::isResult($contacts)) {
@ -174,7 +192,7 @@ function vier_community_info()
}
//right_aside FIND FRIENDS
if ($show_friends && local_user()) {
if ($show_friends && Session::getLocalUser()) {
$nv = [];
$nv['findpeople'] = DI::l10n()->t('Find People');
$nv['desc'] = DI::l10n()->t('Enter name or interest');
@ -193,8 +211,8 @@ function vier_community_info()
}
//Community_Pages at right_aside
if ($show_pages && local_user()) {
$aside['$page'] = ForumManager::widget('network/forum', local_user());;
if ($show_pages && Session::getLocalUser()) {
$aside['$page'] = ForumManager::widget('network/forum', Session::getLocalUser());;
}
// END Community Page