]> git.mxchange.org Git - friendica-addons.git/blobdiff - dwpost/dwpost.php
invidious/invidious.php aktualisiert
[friendica-addons.git] / dwpost / dwpost.php
index ed7ac4922cf540240feeb57725764063180e88dc..6c1742e416959f987fc7e2dc812676db91e5d112 100644 (file)
@@ -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;
@@ -30,34 +29,34 @@ function dwpost_install()
        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, [
@@ -77,24 +76,24 @@ function dwpost_settings(App $a, array &$data)
 }
 
 
-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;
        }
 
@@ -102,11 +101,11 @@ function dwpost_post_local(App $a, array &$b)
                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;
        }
 
@@ -121,13 +120,13 @@ function dwpost_post_local(App $a, array &$b)
        $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;
        }
 
@@ -135,7 +134,7 @@ function dwpost_send(App $a, array &$b)
                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.