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

@ -12,7 +12,6 @@ use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model\Notification;
@ -32,10 +31,10 @@ function gnot_install()
* and if so set our configuration setting for this person.
*/
function gnot_settings_post(App $a, $post) {
if(! Session::getLocalUser() || empty($_POST['gnot-submit']))
if(! DI::userSession()->getLocalUserId() || empty($_POST['gnot-submit']))
return;
DI::pConfig()->set(Session::getLocalUser(),'gnot','enable',intval($_POST['gnot']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'gnot','enable',intval($_POST['gnot']));
}
/**
@ -44,11 +43,11 @@ function gnot_settings_post(App $a, $post) {
*/
function gnot_settings(App &$a, array &$data)
{
if (!Session::getLocalUser()) {
if (!DI::userSession()->getLocalUserId()) {
return;
}
$gnot = intval(DI::pConfig()->get(Session::getLocalUser(), 'gnot', 'enable'));
$gnot = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'gnot', 'enable'));
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/gnot/');
$html = Renderer::replaceMacros($t, [