From: Roland Häder Date: Wed, 21 Dec 2022 14:36:08 +0000 (+0100) Subject: Changes: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=55380b10fadca196633df913354ea06e004daf88;p=friendica-addons.git Changes: - converted double-quotes to single - added some more spaces for better readability - removed some redudant empty lines - fixed indenting (4 spaces to tab) --- diff --git a/catavatar/catavatar.php b/catavatar/catavatar.php index 7b5f05c0..3529df1f 100644 --- a/catavatar/catavatar.php +++ b/catavatar/catavatar.php @@ -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 diff --git a/discourse/discourse.php b/discourse/discourse.php index b8d0d996..6137cc18 100644 --- a/discourse/discourse.php +++ b/discourse/discourse.php @@ -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'])); } diff --git a/fromapp/fromapp.php b/fromapp/fromapp.php index bb8a4fe6..6e46674b 100644 --- a/fromapp/fromapp.php +++ b/fromapp/fromapp.php @@ -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; diff --git a/irc/irc.php b/irc/irc.php index db808a99..358aab9f 100644 --- a/irc/irc.php +++ b/irc/irc.php @@ -98,13 +98,14 @@ function irc_content() } DI::page()['aside'] .= ''; - /* 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) { diff --git a/libertree/libertree.php b/libertree/libertree.php index 1489a029..260c0eaa 100644 --- a/libertree/libertree.php +++ b/libertree/libertree.php @@ -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'])); } } diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index fd7d1bd8..ae906f23 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -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, ]; } diff --git a/opmlexport/opmlexport.php b/opmlexport/opmlexport.php index be1d335c..abc77973 100644 --- a/opmlexport/opmlexport.php +++ b/opmlexport/opmlexport.php @@ -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, diff --git a/planets/planets.php b/planets/planets.php index 8849010a..9a961aca 100644 --- a/planets/planets.php +++ b/planets/planets.php @@ -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()) { diff --git a/public_server/public_server.php b/public_server/public_server.php index 9cd0f667..b6797287 100644 --- a/public_server/public_server.php +++ b/public_server/public_server.php @@ -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'))], ]); } diff --git a/randplace/randplace.php b/randplace/randplace.php index 89a75f98..d6ea430e 100644 --- a/randplace/randplace.php +++ b/randplace/randplace.php @@ -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, [ diff --git a/saml/README.md b/saml/README.md old mode 100755 new mode 100644 diff --git a/saml/saml.php b/saml/saml.php old mode 100755 new mode 100644 index 83e4d3fd..de9e916e --- a/saml/saml.php +++ b/saml/saml.php @@ -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 [ diff --git a/showmore/showmore.php b/showmore/showmore.php index e326aa98..d89cc46d 100644 --- a/showmore/showmore.php +++ b/showmore/showmore.php @@ -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; } diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 8663aaea..eb637f2d 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -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');