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;
function irc_install()
@ -22,12 +21,12 @@ function irc_install()
function irc_addon_settings(App &$a, array &$data)
{
if (!Session::getLocalUser()) {
if (!DI::userSession()->getLocalUserId()) {
return;
}
$sitechats = DI::pConfig()->get(Session::getLocalUser(), 'irc', 'sitechats'); /* popular channels */
$autochans = DI::pConfig()->get(Session::getLocalUser(), 'irc', 'autochans'); /* auto connect chans */
$sitechats = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'irc', 'sitechats'); /* popular channels */
$autochans = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'irc', 'autochans'); /* auto connect chans */
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/irc/');
$html = Renderer::replaceMacros($t, [
@ -45,16 +44,16 @@ function irc_addon_settings(App &$a, array &$data)
function irc_addon_settings_post(App $a, array &$b)
{
if (!Session::getLocalUser()) {
if (!DI::userSession()->getLocalUserId()) {
return;
}
if (!empty($_POST['irc-submit'])) {
if (isset($_POST['autochans'])) {
DI::pConfig()->set(Session::getLocalUser(), 'irc', 'autochans', trim(($_POST['autochans'])));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'irc', 'autochans', trim(($_POST['autochans'])));
}
if (isset($_POST['sitechats'])) {
DI::pConfig()->set(Session::getLocalUser(), 'irc', 'sitechats', trim($_POST['sitechats']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'irc', 'sitechats', trim($_POST['sitechats']));
}
/* upid pop-up thing */
}
@ -78,8 +77,8 @@ function irc_content(App $a)
$o = '';
/* set the list of popular channels */
if (Session::getLocalUser()) {
$sitechats = DI::pConfig()->get( Session::getLocalUser(), 'irc', 'sitechats');
if (DI::userSession()->getLocalUserId()) {
$sitechats = DI::pConfig()->get( DI::userSession()->getLocalUserId(), 'irc', 'sitechats');
if (!$sitechats) {
$sitechats = DI::config()->get('irc', 'sitechats');
}
@ -101,8 +100,8 @@ function irc_content(App $a)
DI::page()['aside'] .= '</ul></div>';
/* setting the channel(s) to auto connect */
if (Session::getLocalUser()) {
$autochans = DI::pConfig()->get(Session::getLocalUser(), 'irc', 'autochans');
if (DI::userSession()->getLocalUserId()) {
$autochans = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'irc', 'autochans');
if (!$autochans)
$autochans = DI::config()->get('irc','autochans');
} else {