mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-06-07 09:54:27 +02:00
UserSession class - Refactor addon
This commit is contained in:
parent
8eca74cfab
commit
b0eb28143a
46 changed files with 534 additions and 580 deletions
|
@ -13,7 +13,6 @@ use Friendica\Content\Text\BBCode;
|
|||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Tag;
|
||||
|
@ -32,17 +31,17 @@ function ljpost_install()
|
|||
|
||||
function ljpost_jot_nets(App &$a, array &$jotnets_fields)
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DI::pConfig()->get(Session::getLocalUser(),'ljpost','post')) {
|
||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(),'ljpost','post')) {
|
||||
$jotnets_fields[] = [
|
||||
'type' => 'checkbox',
|
||||
'field' => [
|
||||
'ljpost_enable',
|
||||
DI::l10n()->t('Post to LiveJournal'),
|
||||
DI::pConfig()->get(Session::getLocalUser(), 'ljpost', 'post_by_default'),
|
||||
DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -50,13 +49,13 @@ function ljpost_jot_nets(App &$a, array &$jotnets_fields)
|
|||
|
||||
function ljpost_settings(App &$a, array &$data)
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$enabled = DI::pConfig()->get(Session::getLocalUser(), 'ljpost', 'post', false);
|
||||
$ij_username = DI::pConfig()->get(Session::getLocalUser(), 'ljpost', 'ij_username');
|
||||
$def_enabled = DI::pConfig()->get(Session::getLocalUser(), 'ljpost', 'post_by_default');
|
||||
$enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post', false);
|
||||
$ij_username = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'ij_username');
|
||||
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default');
|
||||
|
||||
$t= Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ljpost/');
|
||||
$html = Renderer::replaceMacros($t, [
|
||||
|
@ -78,10 +77,10 @@ function ljpost_settings(App &$a, array &$data)
|
|||
function ljpost_settings_post(App $a, array &$b)
|
||||
{
|
||||
if (!empty($_POST['ljpost-submit'])) {
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'ljpost', 'post', intval($_POST['ljpost']));
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'ljpost', 'post_by_default', intval($_POST['lj_bydefault']));
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'ljpost', 'lj_username', trim($_POST['lj_username']));
|
||||
DI::pConfig()->set(Session::getLocalUser(), 'ljpost', 'lj_password', trim($_POST['lj_password']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ljpost', 'post', intval($_POST['ljpost']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default', intval($_POST['lj_bydefault']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ljpost', 'lj_username', trim($_POST['lj_username']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ljpost', 'lj_password', trim($_POST['lj_password']));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +91,7 @@ function ljpost_post_local(App $a, array &$b)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!Session::getLocalUser() || (Session::getLocalUser() != $b['uid'])) {
|
||||
if (!DI::userSession()->getLocalUserId() || (DI::userSession()->getLocalUserId() != $b['uid'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -100,10 +99,10 @@ function ljpost_post_local(App $a, array &$b)
|
|||
return;
|
||||
}
|
||||
|
||||
$lj_post = intval(DI::pConfig()->get(Session::getLocalUser(),'ljpost','post'));
|
||||
$lj_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'ljpost','post'));
|
||||
$lj_enable = (($lj_post && !empty($_REQUEST['ljpost_enable'])) ? intval($_REQUEST['ljpost_enable']) : 0);
|
||||
|
||||
if ($b['api_source'] && intval(DI::pConfig()->get(Session::getLocalUser(), 'ljpost', 'post_by_default'))) {
|
||||
if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ljpost', 'post_by_default'))) {
|
||||
$lj_enable = 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue