use Friendica\Model\Profile;
use Friendica\Network\HTTPException\NotFoundException;
-define("CATAVATAR_SIZE", 256);
+define('CATAVATAR_SIZE', 256);
/**
* Installs the addon hook
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']));
}
];
}
-function fromapp_post_hook(&$item)
+function fromapp_post_hook(array &$item)
{
if (!DI::userSession()->getLocalUserId()) {
return;
$apps = explode(',', $app);
$item['app'] = trim($apps[mt_rand(0, count($apps)-1)]);
-
+
return;
}
}
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) {
$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 = [
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','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', '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']));
}
}
return;
}
- $ltree_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'libertree','post'));
+ $ltree_post = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post'));
$ltree_enable = (($ltree_post && !empty($_REQUEST['libertree_enable'])) ? intval($_REQUEST['libertree_enable']) : 0);
- if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(),'libertree','post_by_default'))) {
+ if ($b['api_source'] && intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'libertree', 'post_by_default'))) {
$ltree_enable = 1;
}
$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,
];
}
function opmlexport()
{
$condition = [
- 'uid' => DI::userSession()->getLocalUserId(),
- 'self' => false,
+ 'uid' => DI::userSession()->getLocalUserId(),
+ 'self' => false,
'deleted' => false,
'archive' => false,
'blocked' => false,
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()) {
$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'))],
]);
}
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, [
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
+use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
EOL;
}
-function saml_is_configured()
+function saml_is_configured(): bool
{
return
DI::config()->get('saml', 'idp_id') &&
$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()
}
$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()
}
}
-function saml_input($key, $label, $description)
+function saml_input($key, $label, $description): array
{
return [
'$' . $key => [
}
}
-function saml_settings()
+function saml_settings(): array
{
return [
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;
}
}
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');