UserSession class - Refactor addon

This commit is contained in:
Philipp 2022-10-20 23:51:49 +02:00
parent 8eca74cfab
commit b0eb28143a
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
46 changed files with 534 additions and 580 deletions

View file

@ -10,7 +10,6 @@
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Util\Strings;
@ -25,11 +24,11 @@ function superblock_install()
function superblock_addon_settings(App &$a, array &$data)
{
if (!Session::getLocalUser()) {
if (!DI::userSession()->getLocalUserId()) {
return;
}
$blocked = DI::pConfig()->get(Session::getLocalUser(), 'system', 'blocked', '');
$blocked = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'blocked', '');
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/superblock/');
$html = Renderer::replaceMacros($t, [
@ -45,12 +44,12 @@ function superblock_addon_settings(App &$a, array &$data)
function superblock_addon_settings_post(App $a, array &$b)
{
if (!Session::getLocalUser()) {
if (!DI::userSession()->getLocalUserId()) {
return;
}
if (!empty($_POST['superblock-submit'])) {
DI::pConfig()->set(Session::getLocalUser(), 'system', 'blocked',trim($_POST['superblock-words']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'blocked',trim($_POST['superblock-words']));
}
}
@ -90,11 +89,11 @@ function superblock_enotify_store(App $a, array &$b)
function superblock_conversation_start(App $a, array &$b)
{
if (!Session::getLocalUser()) {
if (!DI::userSession()->getLocalUserId()) {
return;
}
$words = DI::pConfig()->get(Session::getLocalUser(), 'system', 'blocked');
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'blocked');
if ($words) {
$a->data['superblock'] = explode(',', $words);
}
@ -113,7 +112,7 @@ EOT;
function superblock_item_photo_menu(App $a, array &$b)
{
if (!Session::getLocalUser() || $b['item']['self']) {
if (!DI::userSession()->getLocalUserId() || $b['item']['self']) {
return;
}
@ -140,11 +139,11 @@ function superblock_module() {}
function superblock_init(App $a)
{
if (!Session::getLocalUser()) {
if (!DI::userSession()->getLocalUserId()) {
return;
}
$words = DI::pConfig()->get(Session::getLocalUser(), 'system', 'blocked');
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'blocked');
if (array_key_exists('block', $_GET) && $_GET['block']) {
if (strlen($words))
@ -152,6 +151,6 @@ function superblock_init(App $a)
$words .= trim($_GET['block']);
}
DI::pConfig()->set(Session::getLocalUser(), 'system', 'blocked', $words);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'blocked', $words);
exit();
}