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;
Hook::register('connector_settings_post', 'addon/dwpost/dwpost.php', 'dwpost_settings_post');
}
-function dwpost_jot_nets(App $a, array &$jotnets_fields)
+function dwpost_jot_nets(array &$jotnets_fields)
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
- if (DI::pConfig()->get(Session::getLocalUser(), 'dwpost', 'post')) {
+ if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'dwpost', 'post')) {
$jotnets_fields[] = [
'type' => 'checkbox',
'field' => [
'dwpost_enable',
DI::l10n()->t('Post to Dreamwidth'),
- DI::pConfig()->get(Session::getLocalUser(), 'dwpost', 'post_by_default')
+ DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'dwpost', 'post_by_default')
]
];
}
}
-function dwpost_settings(App $a, array &$data)
+function dwpost_settings(array &$data)
{
- if (!Session::getLocalUser()) {
+ if (!DI::userSession()->getLocalUserId()) {
return;
}
- $enabled = DI::pConfig()->get(Session::getLocalUser(), 'dwpost', 'post', false);
- $dw_username = DI::pConfig()->get(Session::getLocalUser(), 'dwpost', 'dw_username');
- $def_enabled = DI::pConfig()->get(Session::getLocalUser(), 'dwpost', 'post_by_default');
+ $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'dwpost', 'post', false);
+ $dw_username = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'dwpost', 'dw_username');
+ $def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'dwpost', 'post_by_default');
$t = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/dwpost/');
$html = Renderer::replaceMacros($t, [
}
-function dwpost_settings_post(App $a, array &$b)
+function dwpost_settings_post(array &$b)
{
if (!empty($_POST['dwpost-submit'])) {
- DI::pConfig()->set(Session::getLocalUser(), 'dwpost', 'post', intval($_POST['dwpost']));
- DI::pConfig()->set(Session::getLocalUser(), 'dwpost', 'post_by_default', intval($_POST['dw_bydefault']));
- DI::pConfig()->set(Session::getLocalUser(), 'dwpost', 'dw_username', trim($_POST['dw_username']));
- DI::pConfig()->set(Session::getLocalUser(), 'dwpost', 'dw_password', trim($_POST['dw_password']));
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'dwpost', 'post', intval($_POST['dwpost']));
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'dwpost', 'post_by_default', intval($_POST['dw_bydefault']));
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'dwpost', 'dw_username', trim($_POST['dw_username']));
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'dwpost', 'dw_password', trim($_POST['dw_password']));
}
}
-function dwpost_post_local(App $a, array &$b)
+function dwpost_post_local(array &$b)
{
// This can probably be changed to allow editing by pointing to a different API endpoint
if ($b['edit']) {
return;
}
- if ((!Session::getLocalUser()) || (Session::getLocalUser() != $b['uid'])) {
+ if ((!DI::userSession()->getLocalUserId()) || (DI::userSession()->getLocalUserId() != $b['uid'])) {
return;
}
return;
}
- $dw_post = intval(DI::pConfig()->get(Session::getLocalUser(),'dwpost','post'));
+ $dw_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'dwpost','post'));
$dw_enable = (($dw_post && !empty($_REQUEST['dwpost_enable'])) ? intval($_REQUEST['dwpost_enable']) : 0);
- if ($b['api_source'] && intval(DI::pConfig()->get(Session::getLocalUser(),'dwpost','post_by_default'))) {
+ if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'dwpost','post_by_default'))) {
$dw_enable = 1;
}
$b['postopts'] .= 'dwpost';
}
-function dwpost_send(App $a, array &$b)
+function dwpost_send(array &$b)
{
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
return;
}
- if (!strstr($b['postopts'],'dwpost')) {
+ if (strpos($b['postopts'] ?? '', 'dwpost') === false) {
return;
}
return;
}
- $b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], $b['body']);
+ $b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], DI::contentItem()->addSharedPost($b));
/*
* dreamwidth post in the LJ user's timezone.