mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-10 18:38:49 +00:00
UserSession class - Refactor addon
This commit is contained in:
parent
8eca74cfab
commit
b0eb28143a
46 changed files with 534 additions and 580 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue