]> git.mxchange.org Git - friendica-addons.git/commitdiff
Changes: develop
authorRoland Häder <roland@mxchange.org>
Wed, 21 Dec 2022 14:36:08 +0000 (15:36 +0100)
committerRoland Häder <roland@mxchange.org>
Wed, 25 Jun 2025 02:25:07 +0000 (04:25 +0200)
- converted double-quotes to single
- added some more spaces for better readability
- removed some redudant empty lines
- fixed indenting (4 spaces to tab)

14 files changed:
catavatar/catavatar.php
discourse/discourse.php
fromapp/fromapp.php
irc/irc.php
libertree/libertree.php
ljpost/ljpost.php
opmlexport/opmlexport.php
planets/planets.php
public_server/public_server.php
randplace/randplace.php
saml/README.md [changed mode: 0755->0644]
saml/saml.php [changed mode: 0755->0644]
showmore/showmore.php
statusnet/statusnet.php

index 7b5f05c0dc079f326fc902a8c9a29be8f475c76e..3529df1f1279bffc3d5fa8630ef6ab4d89910859 100644 (file)
@@ -15,7 +15,7 @@ use Friendica\Model\Photo;
 use Friendica\Model\Profile;
 use Friendica\Network\HTTPException\NotFoundException;
 
-define("CATAVATAR_SIZE", 256);
+define('CATAVATAR_SIZE', 256);
 
 /**
  * Installs the addon hook
index b8d0d99603040636f7758c2e02e3bcd29558f78c..6137cc187a2fc455d1b2f219f9390cea8ed5e453 100644 (file)
@@ -59,8 +59,8 @@ function discourse_settings(array &$data)
 function discourse_settings_post()
 {
        if (!DI::userSession()->getLocalUserId() || empty($_POST['discourse-submit'])) {
-                return;
-        }
+               return;
+       }
 
        DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'discourse', 'enabled', intval($_POST['enabled']));
 }
index bb8a4fe618af512a74475bbf241134f763e09dec..6e46674b090b08b550d19ea8318c1ed9214de955 100644 (file)
@@ -51,7 +51,7 @@ function fromapp_settings(array &$data)
        ];
 }
 
-function fromapp_post_hook(&$item)
+function fromapp_post_hook(array &$item)
 {
        if (!DI::userSession()->getLocalUserId()) {
                return;
index db808a9952acb661c9d3eee173115e0c08975c6f..358aab9f1364c26cfbfec7cdd910a13759e289f4 100644 (file)
@@ -98,13 +98,14 @@ function irc_content()
        }
        DI::page()['aside'] .= '</ul></div>';
 
-        /* setting the channel(s) to auto connect */
+       /* setting the channel(s) to auto connect */
        if (DI::userSession()->getLocalUserId()) {
-           $autochans = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'irc', 'autochans');
-           if (!$autochans)
-               $autochans = DI::config()->get('irc','autochans');
+               $autochans = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'irc', 'autochans');
+               if (!$autochans) {
+                       $autochans = DI::config()->get('irc','autochans');
+               }
        } else {
-           $autochans = DI::config()->get('irc','autochans');
+               $autochans = DI::config()->get('irc','autochans');
        }
 
        if ($autochans) {
index 1489a029790585458d7228425afde55908256e05..260c0eaa2e87265bc3879d4a021359aa4d377d5a 100644 (file)
@@ -55,10 +55,10 @@ function libertree_settings(array &$data)
 
        $t    = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/libertree/');
        $html = Renderer::replaceMacros($t, [
-               '$enabled'         => ['libertree', DI::l10n()->t('Enable Libertree Post Addon'), $enabled],
-               '$ltree_url'       => ['libertree_url', DI::l10n()->t('Libertree site URL'), $ltree_url],
+               '$enabled'         => ['libertree',           DI::l10n()->t('Enable Libertree Post Addon'), $enabled],
+               '$ltree_url'       => ['libertree_url',       DI::l10n()->t('Libertree site URL'), $ltree_url],
                '$ltree_api_token' => ['libertree_api_token', DI::l10n()->t('Libertree API token'), $ltree_api_token],
-               '$bydefault'       => ['ij_bydefault', DI::l10n()->t('Post to Libertree by default'), $def_enabled],
+               '$bydefault'       => ['ij_bydefault',        DI::l10n()->t('Post to Libertree by default'), $def_enabled],
        ]);
 
        $data = [
@@ -73,10 +73,10 @@ function libertree_settings(array &$data)
 function libertree_settings_post(array &$b)
 {
        if (!empty($_POST['libertree-submit'])) {
-               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', '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']));
+               DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'libertree', 'libertree_url'      , trim($_POST['libertree_url']));
        }
 }
 
index fd7d1bd8e83ec237fde815cdd1e2cc1fa5a843a9..ae906f23978729e66f0ab19dddd14ef167ce7ef3 100644 (file)
@@ -66,10 +66,10 @@ function ljpost_settings(array &$data)
 
        $data = [
                'connector' => 'ljpost',
-               'title' => DI::l10n()->t('LiveJournal Export'),
-               'image' => 'addon/ljpost/livejournal.png',
+               'title'     => DI::l10n()->t('LiveJournal Export'),
+               'image'     => 'addon/ljpost/livejournal.png',
                'enabled'   => $enabled,
-               'html'  => $html,
+               'html'      => $html,
        ];
 }
 
index be1d335cfa593e568230fbd139bbc23080fad4f4..abc77973f3302e0d6897b73d94de3a068dc21d59 100644 (file)
@@ -24,8 +24,8 @@ function opmlexport_install()
 function opmlexport()
 {
        $condition = [
-               'uid' => DI::userSession()->getLocalUserId(),
-               'self' => false,
+               'uid'     => DI::userSession()->getLocalUserId(),
+               'self'    => false,
                'deleted' => false,
                'archive' => false,
                'blocked' => false,
index 8849010ad1ca887e995b33aeb35300feed9e0039..9a961aca5a75d7d35bcc7bd5a98c69ba67e7ce5f 100644 (file)
@@ -79,38 +79,28 @@ function planets_post_hook(&$item)
        return;
 }
 
-
-
-
 /**
- *
  * Callback from the settings post function.
  * $post contains the $_POST array.
  * We will make sure we've got a valid user account
  * and if so set our configuration setting for this person.
- *
  */
-
-function planets_settings_post($post)
+function planets_settings_post(array $post)
 {
        if (!DI::userSession()->getLocalUserId()) {
                return;
        }
-       if ($_POST['planets-submit']) {
-               DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'planets', 'enable' ,intval($_POST['planets']));
+       if ($post['planets-submit']) {
+               DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'planets', 'enable' ,intval($post['planets']));
        }
 }
 
 
 /**
- *
  * Called from the Addon Setting form.
  * Add our own settings info to the page.
  *
  */
-
-
-
 function planets_settings(array &$data)
 {
        if(!DI::userSession()->getLocalUserId()) {
index 9cd0f66732623ff2954f800a15820f96d9190663..b6797287b0bf11bb34cab190d5b3b616a391a62b 100644 (file)
@@ -138,14 +138,14 @@ function public_server_addon_admin(string &$o)
        $token = BaseModule::getFormSecurityToken('publicserver');
        $t = Renderer::getMarkupTemplate('admin.tpl', 'addon/public_server');
        $o = Renderer::replaceMacros($t, [
-               '$submit' => DI::l10n()->t('Save Settings'),
+               '$submit'              => DI::l10n()->t('Save Settings'),
                '$form_security_token' => $token,
-               '$infotext' => DI::l10n()->t('Set any of these options to 0 to deactivate it.'),
-               '$expiredays' => ["expiredays", "Expire Days", intval(DI::config()->get('public_server', 'expiredays')), "When an account is created on the site, it is given a hard "],
-               '$expireposts' => ["expireposts", "Expire Posts", intval(DI::config()->get('public_server', 'expireposts')), "Set the default days for posts to expire here"],
-               '$nologin' => ["nologin", "No Login", intval(DI::config()->get('public_server', 'nologin')), "Remove users who have never logged in after nologin days "],
-               '$flagusers' => ["flagusers", "Flag users", intval(DI::config()->get('public_server', 'flagusers')), "Remove users who last logged in over flagusers days ago"],
-               '$flagposts' => ["flagposts", "Flag posts", intval(DI::config()->get('public_server', 'flagposts')), "For users who last logged in over flagposts days ago set post expiry days to flagpostsexpire "],
-               '$flagpostsexpire' => ["flagpostsexpire", "Flag posts expire", intval(DI::config()->get('public_server', 'flagpostsexpire'))],
+               '$infotext'            => DI::l10n()->t('Set any of these options to 0 to deactivate it.'),
+               '$expiredays'          => ['expiredays', 'Expire Days', intval(DI::config()->get('public_server', 'expiredays')), 'When an account is created on the site, it is given a hard '],
+               '$expireposts'         => ['expireposts', 'Expire Posts', intval(DI::config()->get('public_server', 'expireposts')), 'Set the default days for posts to expire here'],
+               '$nologin'             => ['nologin', 'No Login', intval(DI::config()->get('public_server', 'nologin')), 'Remove users who have never logged in after nologin days '],
+               '$flagusers'           => ['flagusers', 'Flag users', intval(DI::config()->get('public_server', 'flagusers')), 'Remove users who last logged in over flagusers days ago'],
+               '$flagposts'           => ['flagposts', 'Flag posts', intval(DI::config()->get('public_server', 'flagposts')), 'For users who last logged in over flagposts days ago set post expiry days to flagpostsexpire '],
+               '$flagpostsexpire'     => ['flagpostsexpire', 'Flag posts expire', intval(DI::config()->get('public_server', 'flagpostsexpire'))],
        ]);
 }
index 89a75f98e40ec6e014dd1799617c7bc880e1f3e1..d6ea430eaa7c7a3bc9e8156721b8b3bc38fdd38e 100644 (file)
@@ -140,7 +140,7 @@ function randplace_settings(array &$data)
                return;
        }
 
-       $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(),'randplace','enable');
+       $enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'randplace', 'enable');
 
        $t    = Renderer::getMarkupTemplate('settings.tpl', 'addon/randplace/');
        $html = Renderer::replaceMacros($t, [
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 83e4d3f..de9e916
@@ -9,6 +9,7 @@
 use Friendica\Content\Text\BBCode;
 use Friendica\Core\Hook;
 use Friendica\Core\Renderer;
+use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\User;
@@ -110,7 +111,7 @@ if ( document.getElementById('wrapper_password') != null ) {
 EOL;
 }
 
-function saml_is_configured()
+function saml_is_configured(): bool
 {
        return
                DI::config()->get('saml', 'idp_id') &&
@@ -132,11 +133,8 @@ function saml_sso_initiate(string &$body)
 
        $auth = new \OneLogin\Saml2\Auth(saml_settings());
        $ssoBuiltUrl = $auth->login(null, [], false, false, true);
-       DI::session()->set('AuthNRequestID', $auth->getLastRequestID());
-       header('Pragma: no-cache');
-       header('Cache-Control: no-cache, must-revalidate');
-       header('Location: ' . $ssoBuiltUrl);
-       exit();
+       $_SESSION['AuthNRequestID'] = $auth->getLastRequestID();
+       System::externalRedirect($ssoBuiltUrl, 302, true);
 }
 
 function saml_sso_reply()
@@ -196,13 +194,9 @@ function saml_slo_initiate()
        }
 
        $auth = new \OneLogin\Saml2\Auth(saml_settings());
-
        $sloBuiltUrl = $auth->logout();
-       DI::session()->set('LogoutRequestID', $auth->getLastRequestID());
-       header('Pragma: no-cache');
-       header('Cache-Control: no-cache, must-revalidate');
-       header('Location: ' . $sloBuiltUrl);
-       exit();
+       $_SESSION['LogoutRequestID'] = $auth->getLastRequestID();
+       System::externalRedirect($sloBuiltUrl, 302, true);
 }
 
 function saml_slo_reply()
@@ -226,7 +220,7 @@ function saml_slo_reply()
        }
 }
 
-function saml_input($key, $label, $description)
+function saml_input($key, $label, $description): array
 {
        return [
                '$' . $key => [
@@ -352,7 +346,7 @@ function saml_create_user($username, $email, $name)
        }
 }
 
-function saml_settings()
+function saml_settings(): array
 {
        return [
 
index e326aa98cc30d8abe0d6d27b8661662b645ecc0f..d89cc46da55723ad9748b7f3f06df86bd525bd4c 100644 (file)
@@ -108,7 +108,7 @@ function showmore_prepare_body(&$hook_data)
 
        if (get_body_length($hook_data['html']) > $chars) {
                $found = true;
-               $shortened = trim(showmore_cutitem($hook_data['html'], $chars)) . "...";
+               $shortened = trim(showmore_cutitem($hook_data['html'], $chars)) . '...';
        } else {
                $found = false;
        }
index 8663aaea7732082f73c2c44ef0003113af58b0c1..eb637f2d27ac071360ed3924d1708d02fd3a072e 100644 (file)
@@ -89,8 +89,8 @@ function statusnet_settings_post($post)
        }
 
        if (!empty($_POST['statusnet-disconnect'])) {
-               /*               * *
-                * if the GNU Social-disconnect button is clicked, clear the GNU Social configuration
+               /*
+                * If the GNU Social-disconnect button is clicked, clear the GNU Social configuration
                 */
                DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'statusnet', 'consumerkey');
                DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'statusnet', 'consumersecret');