UserSession class - Refactor addon
This commit is contained in:
parent
8eca74cfab
commit
b0eb28143a
46 changed files with 534 additions and 580 deletions
|
@ -11,7 +11,6 @@ use Friendica\Content\Text\BBCode;
|
|||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Post;
|
||||
|
@ -28,17 +27,17 @@ function libertree_install()
|
|||
|
||||
function libertree_jot_nets(App &$a, array &$jotnets_fields)
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DI::pConfig()->get(Session::getLocalUser(), 'libertree', 'post')) {
|
||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post')) {
|
||||
$jotnets_fields[] = [
|
||||
'type' => 'checkbox',
|
||||
'field' => [
|
||||
'libertree_enable',
|
||||
DI::l10n()->t('Post to libertree'),
|
||||
DI::pConfig()->get(Session::getLocalUser(), 'libertree', 'post_by_default'),
|
||||
DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post_by_default'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -46,14 +45,14 @@ function libertree_jot_nets(App &$a, array &$jotnets_fields)
|
|||
|
||||
function libertree_settings(App $a, array &$data)
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$enabled = DI::pConfig()->get(Session::getLocalUser(), 'libertree', 'post', false);
|
||||
$ltree_api_token = DI::pConfig()->get(Session::getLocalUser(), 'libertree', 'libertree_api_token');
|
||||
$ltree_url = DI::pConfig()->get(Session::getLocalUser(), 'libertree', 'libertree_url');
|
||||
$def_enabled = DI::pConfig()->get(Session::getLocalUser(), 'libertree', 'post_by_default');
|
||||
$enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post', false);
|
||||
$ltree_api_token = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'libertree_api_token');
|
||||
$ltree_url = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'libertree_url');
|
||||
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post_by_default');
|
||||
|
||||
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/libertree/');
|
||||
$html = Renderer::replaceMacros($t, [
|
||||
|
@ -75,10 +74,10 @@ function libertree_settings(App $a, array &$data)
|
|||
function libertree_settings_post(App $a, array &$b)
|
||||
{
|
||||
if (!empty($_POST['libertree-submit'])) {
|
||||
DI::pConfig()->set(Session::getLocalUser(),'libertree','post',intval($_POST['libertree']));
|
||||
DI::pConfig()->set(Session::getLocalUser(),'libertree','post_by_default',intval($_POST['libertree_bydefault']));
|
||||
DI::pConfig()->set(Session::getLocalUser(),'libertree','libertree_api_token',trim($_POST['libertree_api_token']));
|
||||
DI::pConfig()->set(Session::getLocalUser(),'libertree','libertree_url',trim($_POST['libertree_url']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','post',intval($_POST['libertree']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','post_by_default',intval($_POST['libertree_bydefault']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','libertree_api_token',trim($_POST['libertree_api_token']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(),'libertree','libertree_url',trim($_POST['libertree_url']));
|
||||
|
||||
}
|
||||
|
||||
|
@ -108,7 +107,7 @@ function libertree_post_local(App $a, array &$b)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!Session::getLocalUser() || (Session::getLocalUser() != $b['uid'])) {
|
||||
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -116,11 +115,11 @@ function libertree_post_local(App $a, array &$b)
|
|||
return;
|
||||
}
|
||||
|
||||
$ltree_post = intval(DI::pConfig()->get(Session::getLocalUser(),'libertree','post'));
|
||||
$ltree_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'libertree','post'));
|
||||
|
||||
$ltree_enable = (($ltree_post && !empty($_REQUEST['libertree_enable'])) ? intval($_REQUEST['libertree_enable']) : 0);
|
||||
|
||||
if ($b['api_source'] && intval(DI::pConfig()->get(Session::getLocalUser(),'libertree','post_by_default'))) {
|
||||
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'libertree','post_by_default'))) {
|
||||
$ltree_enable = 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue