From 45c44391197ad27318f1f062f8e456ef19f69444 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 4 Nov 2022 23:47:42 -0400 Subject: [PATCH] Move settings/connectors to src/Module --- mod/settings.php | 185 ------------- src/Module/BaseSettings.php | 3 +- src/Module/Settings/Connectors.php | 249 ++++++++++++++++++ static/routes.config.php | 17 +- .../settings/{addon => addons}/connector.tpl | 0 view/templates/settings/connectors.tpl | 6 +- .../settings/{addon => addons}/connector.tpl | 0 .../frio/templates/settings/connectors.tpl | 12 +- 8 files changed, 269 insertions(+), 203 deletions(-) create mode 100644 src/Module/Settings/Connectors.php rename view/templates/settings/{addon => addons}/connector.tpl (100%) rename view/theme/frio/templates/settings/{addon => addons}/connector.tpl (100%) diff --git a/mod/settings.php b/mod/settings.php index 290a2d374c..619f40b3e0 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -55,74 +55,6 @@ function settings_post(App $a) return; } - $user = User::getById($a->getLoggedInUserId()); - - if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] == 'connectors')) { - BaseModule::checkFormSecurityTokenRedirectOnError(DI::args()->getQueryString(), 'settings_connectors'); - - if (!empty($_POST['general-submit'])) { - DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'accept_only_sharer', intval($_POST['accept_only_sharer'])); - DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'disable_cw', !intval($_POST['enable_cw'])); - DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'no_intelligent_shortening', !intval($_POST['enable_smart_shortening'])); - DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'simple_shortening', intval($_POST['simple_shortening'])); - DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'attach_link_title', intval($_POST['attach_link_title'])); - DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']); - } elseif (!empty($_POST['mail-submit'])) { - $mail_server = $_POST['mail_server'] ?? ''; - $mail_port = $_POST['mail_port'] ?? ''; - $mail_ssl = strtolower(trim($_POST['mail_ssl'] ?? '')); - $mail_user = $_POST['mail_user'] ?? ''; - $mail_pass = trim($_POST['mail_pass'] ?? ''); - $mail_action = trim($_POST['mail_action'] ?? ''); - $mail_movetofolder = trim($_POST['mail_movetofolder'] ?? ''); - $mail_replyto = $_POST['mail_replyto'] ?? ''; - $mail_pubmail = $_POST['mail_pubmail'] ?? ''; - - if (function_exists('imap_open') && !DI::config()->get('system', 'imap_disabled')) { - if (!DBA::exists('mailacct', ['uid' => DI::userSession()->getLocalUserId()])) { - DBA::insert('mailacct', ['uid' => DI::userSession()->getLocalUserId()]); - } - if (strlen($mail_pass)) { - $pass = ''; - openssl_public_encrypt($mail_pass, $pass, $user['pubkey']); - DBA::update('mailacct', ['pass' => bin2hex($pass)], ['uid' => DI::userSession()->getLocalUserId()]); - } - - $r = DBA::update('mailacct', [ - 'server' => $mail_server, - 'port' => $mail_port, - 'ssltype' => $mail_ssl, - 'user' => $mail_user, - 'action' => $mail_action, - 'movetofolder' => $mail_movetofolder, - 'mailbox' => 'INBOX', - 'reply_to' => $mail_replyto, - 'pubmail' => $mail_pubmail - ], ['uid' => DI::userSession()->getLocalUserId()]); - - Logger::debug('updating mailaccount', ['response' => $r]); - $mailacct = DBA::selectFirst('mailacct', [], ['uid' => DI::userSession()->getLocalUserId()]); - if (DBA::isResult($mailacct)) { - $mb = Email::constructMailboxName($mailacct); - - if (strlen($mailacct['server'])) { - $dcrpass = ''; - openssl_private_decrypt(hex2bin($mailacct['pass']), $dcrpass, $user['prvkey']); - $mbox = Email::connect($mb, $mail_user, $dcrpass); - unset($dcrpass); - if (!$mbox) { - DI::sysmsg()->addNotice(DI::l10n()->t('Failed to connect with email account using the settings provided.')); - } - } - } - } - } - - Hook::callAll('connector_settings_post', $_POST); - DI::baseUrl()->redirect(DI::args()->getQueryString()); - return; - } - if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'features')) { BaseModule::checkFormSecurityTokenRedirectOnError('/settings/features', 'settings_features'); foreach ($_POST as $k => $v) { @@ -170,121 +102,4 @@ function settings_content(App $a) ]); return $o; } - - if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'connectors')) { - $accept_only_sharer = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'accept_only_sharer')); - $enable_cw = !intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'disable_cw')); - $enable_smart_shortening = !intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'no_intelligent_shortening')); - $simple_shortening = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'simple_shortening')); - $attach_link_title = intval(DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'attach_link_title')); - $legacy_contact = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ostatus', 'legacy_contact'); - - if (!empty($legacy_contact)) { - /// @todo Isn't it supposed to be a $a->internalRedirect() call? - DI::page()['htmlhead'] = ''; - } - - $connector_settings_forms = []; - foreach (DI::dba()->selectToArray('hook', ['file', 'function'], ['hook' => 'connector_settings']) as $hook) { - $data = []; - Hook::callSingle(DI::app(), 'connector_settings', [$hook['file'], $hook['function']], $data); - - $tpl = Renderer::getMarkupTemplate('settings/addon/connector.tpl'); - $connector_settings_forms[$data['connector']] = Renderer::replaceMacros($tpl, [ - '$connector' => $data['connector'], - '$title' => $data['title'], - '$image' => $data['image'] ?? '', - '$enabled' => $data['enabled'] ?? true, - '$open' => (DI::args()->getArgv()[2] ?? '') === $data['connector'], - '$html' => $data['html'] ?? '', - '$submit' => $data['submit'] ?? DI::l10n()->t('Save Settings'), - ]); - } - - if ($a->isSiteAdmin()) { - $diasp_enabled = DI::l10n()->t('Built-in support for %s connectivity is %s', DI::l10n()->t('Diaspora (Socialhome, Hubzilla)'), ((DI::config()->get('system', 'diaspora_enabled')) ? DI::l10n()->t('enabled') : DI::l10n()->t('disabled'))); - $ostat_enabled = DI::l10n()->t('Built-in support for %s connectivity is %s', DI::l10n()->t('OStatus (GNU Social)'), ((DI::config()->get('system', 'ostatus_disabled')) ? DI::l10n()->t('disabled') : DI::l10n()->t('enabled'))); - } else { - $diasp_enabled = ""; - $ostat_enabled = ""; - } - - $mail_disabled = ((function_exists('imap_open') && (!DI::config()->get('system', 'imap_disabled'))) ? 0 : 1); - if (!$mail_disabled) { - $mailacct = DBA::selectFirst('mailacct', [], ['uid' => DI::userSession()->getLocalUserId()]); - } else { - $mailacct = null; - } - - $mail_server = $mailacct['server'] ?? ''; - $mail_port = (!empty($mailacct['port']) && is_numeric($mailacct['port'])) ? (int)$mailacct['port'] : ''; - $mail_ssl = $mailacct['ssltype'] ?? ''; - $mail_user = $mailacct['user'] ?? ''; - $mail_replyto = $mailacct['reply_to'] ?? ''; - $mail_pubmail = $mailacct['pubmail'] ?? 0; - $mail_action = $mailacct['action'] ?? 0; - $mail_movetofolder = $mailacct['movetofolder'] ?? ''; - $mail_chk = $mailacct['last_check'] ?? DBA::NULL_DATETIME; - - - $tpl = Renderer::getMarkupTemplate('settings/connectors.tpl'); - - $mail_disabled_message = ($mail_disabled ? DI::l10n()->t('Email access is disabled on this site.') : ''); - - $ssl_options = ['TLS' => 'TLS', 'SSL' => 'SSL']; - - if (DI::config()->get('system', 'insecure_imap')) { - $ssl_options['notls'] = DI::l10n()->t('None'); - } - - $o .= Renderer::replaceMacros($tpl, [ - '$form_security_token' => BaseModule::getFormSecurityToken("settings_connectors"), - - '$title' => DI::l10n()->t('Social Networks'), - - '$diasp_enabled' => $diasp_enabled, - '$ostat_enabled' => $ostat_enabled, - - '$general_settings' => DI::l10n()->t('General Social Media Settings'), - '$accept_only_sharer' => [ - 'accept_only_sharer', - DI::l10n()->t('Followed content scope'), - $accept_only_sharer, - DI::l10n()->t('By default, conversations in which your follows participated but didn\'t start will be shown in your timeline. You can turn this behavior off, or expand it to the conversations in which your follows liked a post.'), - [ - Item::COMPLETION_NONE => DI::l10n()->t('Only conversations my follows started'), - Item::COMPLETION_COMMENT => DI::l10n()->t('Conversations my follows started or commented on (default)'), - Item::COMPLETION_LIKE => DI::l10n()->t('Any conversation my follows interacted with, including likes'), - ] - ], - '$enable_cw' => ['enable_cw', DI::l10n()->t('Enable Content Warning'), $enable_cw, DI::l10n()->t('Users on networks like Mastodon or Pleroma are able to set a content warning field which collapse their post by default. This enables the automatic collapsing instead of setting the content warning as the post title. Doesn\'t affect any other content filtering you eventually set up.')], - '$enable_smart_shortening' => ['enable_smart_shortening', DI::l10n()->t('Enable intelligent shortening'), $enable_smart_shortening, DI::l10n()->t('Normally the system tries to find the best link to add to shortened posts. If disabled, every shortened post will always point to the original friendica post.')], - '$simple_shortening' => ['simple_shortening', DI::l10n()->t('Enable simple text shortening'), $simple_shortening, DI::l10n()->t('Normally the system shortens posts at the next line feed. If this option is enabled then the system will shorten the text at the maximum character limit.')], - '$attach_link_title' => ['attach_link_title', DI::l10n()->t('Attach the link title'), $attach_link_title, DI::l10n()->t('When activated, the title of the attached link will be added as a title on posts to Diaspora. This is mostly helpful with "remote-self" contacts that share feed content.')], - '$legacy_contact' => ['legacy_contact', DI::l10n()->t('Your legacy ActivityPub/GNU Social account'), $legacy_contact, DI::l10n()->t("If you enter your old account name from an ActivityPub based system or your GNU Social/Statusnet account name here (in the format user@domain.tld), your contacts will be added automatically. The field will be emptied when done.")], - - '$repair_ostatus_url' => 'ostatus/repair', - '$repair_ostatus_text' => DI::l10n()->t('Repair OStatus subscriptions'), - - '$connector_settings_forms' => $connector_settings_forms, - - '$h_mail' => DI::l10n()->t('Email/Mailbox Setup'), - '$mail_desc' => DI::l10n()->t("If you wish to communicate with email contacts using this service \x28optional\x29, please specify how to connect to your mailbox."), - '$mail_lastcheck' => ['mail_lastcheck', DI::l10n()->t('Last successful email check:'), $mail_chk, ''], - '$mail_disabled' => $mail_disabled_message, - '$mail_server' => ['mail_server', DI::l10n()->t('IMAP server name:'), $mail_server, ''], - '$mail_port' => ['mail_port', DI::l10n()->t('IMAP port:'), $mail_port, ''], - '$mail_ssl' => ['mail_ssl', DI::l10n()->t('Security:'), strtoupper($mail_ssl), '', $ssl_options], - '$mail_user' => ['mail_user', DI::l10n()->t('Email login name:'), $mail_user, ''], - '$mail_pass' => ['mail_pass', DI::l10n()->t('Email password:'), '', ''], - '$mail_replyto' => ['mail_replyto', DI::l10n()->t('Reply-to address:'), $mail_replyto, 'Optional'], - '$mail_pubmail' => ['mail_pubmail', DI::l10n()->t('Send public posts to all email contacts:'), $mail_pubmail, ''], - '$mail_action' => ['mail_action', DI::l10n()->t('Action after import:'), $mail_action, '', [0 => DI::l10n()->t('None'), 1 => DI::l10n()->t('Delete'), 2 => DI::l10n()->t('Mark as seen'), 3 => DI::l10n()->t('Move to folder')]], - '$mail_movetofolder' => ['mail_movetofolder', DI::l10n()->t('Move to folder:'), $mail_movetofolder, ''], - '$submit' => DI::l10n()->t('Save Settings'), - ]); - - Hook::callAll('display_settings', $o); - return $o; - } } diff --git a/src/Module/BaseSettings.php b/src/Module/BaseSettings.php index 142a8941c8..a31b9d8a3c 100644 --- a/src/Module/BaseSettings.php +++ b/src/Module/BaseSettings.php @@ -126,7 +126,7 @@ class BaseSettings extends BaseModule $tabs[] = [ 'label' => $this->t('Social Networks'), 'url' => 'settings/connectors', - 'selected' => static::class == Settings\SocialNetworks::class ? 'active' : '', + 'selected' => static::class == Settings\Connectors::class ? 'active' : '', 'accesskey' => 'w', ]; @@ -165,7 +165,6 @@ class BaseSettings extends BaseModule 'accesskey' => 'r', ]; - $tabtpl = Renderer::getMarkupTemplate('generic_links_widget.tpl'); $this->page['aside'] = Renderer::replaceMacros($tabtpl, [ '$title' => $this->t('Settings'), diff --git a/src/Module/Settings/Connectors.php b/src/Module/Settings/Connectors.php new file mode 100644 index 0000000000..969d74d054 --- /dev/null +++ b/src/Module/Settings/Connectors.php @@ -0,0 +1,249 @@ +. + * + */ + +namespace Friendica\Module\Settings; + +use Friendica\App; +use Friendica\Core\Config\Capability\IManageConfigValues; +use Friendica\Core\Hook; +use Friendica\Core\L10n; +use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; +use Friendica\Core\Renderer; +use Friendica\Core\Session\Capability\IHandleUserSessions; +use Friendica\Database\Database; +use Friendica\Database\DBA; +use Friendica\Model\Item; +use Friendica\Model\User; +use Friendica\Module\BaseSettings; +use Friendica\Module\Response; +use Friendica\Navigation\SystemMessages; +use Friendica\Protocol\Email; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; + +class Connectors extends BaseSettings +{ + /** @var IManageConfigValues */ + private $config; + /** @var IManagePersonalConfigValues */ + private $pconfig; + /** @var Database */ + private $database; + /** @var SystemMessages */ + private $systemMessages; + /** @var App */ + private $app; + + public function __construct(App $app, SystemMessages $systemMessages, Database $database, IManagePersonalConfigValues $pconfig, IManageConfigValues $config, IHandleUserSessions $session, App\Page $page, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) + { + parent::__construct($session, $page, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + + $this->config = $config; + $this->pconfig = $pconfig; + $this->database = $database; + $this->systemMessages = $systemMessages; + $this->app = $app; + } + + protected function post(array $request = []) + { + BaseSettings::checkFormSecurityTokenRedirectOnError($this->args->getQueryString(), 'settings_connectors'); + + $user = User::getById($this->session->getLocalUserId()); + + if (!empty($request['general-submit'])) { + $this->pconfig->set($this->session->getLocalUserId(), 'system', 'accept_only_sharer', intval($request['accept_only_sharer'])); + $this->pconfig->set($this->session->getLocalUserId(), 'system', 'disable_cw', !intval($request['enable_cw'])); + $this->pconfig->set($this->session->getLocalUserId(), 'system', 'no_intelligent_shortening', !intval($request['enable_smart_shortening'])); + $this->pconfig->set($this->session->getLocalUserId(), 'system', 'simple_shortening', intval($request['simple_shortening'])); + $this->pconfig->set($this->session->getLocalUserId(), 'system', 'attach_link_title', intval($request['attach_link_title'])); + $this->pconfig->set($this->session->getLocalUserId(), 'ostatus', 'legacy_contact', $request['legacy_contact']); + } elseif (!empty($request['mail-submit']) && function_exists('imap_open') && !$this->config->get('system', 'imap_disabled')) { + $mail_server = $request['mail_server'] ?? ''; + $mail_port = $request['mail_port'] ?? ''; + $mail_ssl = strtolower(trim($request['mail_ssl'] ?? '')); + $mail_user = $request['mail_user'] ?? ''; + $mail_pass = trim($request['mail_pass'] ?? ''); + $mail_action = trim($request['mail_action'] ?? ''); + $mail_movetofolder = trim($request['mail_movetofolder'] ?? ''); + $mail_replyto = $request['mail_replyto'] ?? ''; + $mail_pubmail = $request['mail_pubmail'] ?? ''; + + if (!$this->database->exists('mailacct', ['uid' => $this->session->getLocalUserId()])) { + $this->database->insert('mailacct', ['uid' => $this->session->getLocalUserId()]); + } + + if (strlen($mail_pass)) { + $pass = ''; + openssl_public_encrypt($mail_pass, $pass, $user['pubkey']); + $this->database->update('mailacct', ['pass' => bin2hex($pass)], ['uid' => $this->session->getLocalUserId()]); + } + + $r = $this->database->update('mailacct', [ + 'server' => $mail_server, + 'port' => $mail_port, + 'ssltype' => $mail_ssl, + 'user' => $mail_user, + 'action' => $mail_action, + 'movetofolder' => $mail_movetofolder, + 'mailbox' => 'INBOX', + 'reply_to' => $mail_replyto, + 'pubmail' => $mail_pubmail + ], ['uid' => $this->session->getLocalUserId()]); + + $this->logger->debug('updating mailaccount', ['response' => $r]); + $mailacct = $this->database->selectFirst('mailacct', [], ['uid' => $this->session->getLocalUserId()]); + if ($this->database->isResult($mailacct)) { + if (strlen($mailacct['server'])) { + $dcrpass = ''; + openssl_private_decrypt(hex2bin($mailacct['pass']), $dcrpass, $user['prvkey']); + $mbox = Email::connect(Email::constructMailboxName($mailacct), $mail_user, $dcrpass); + unset($dcrpass); + if (!$mbox) { + $this->systemMessages->addNotice($this->t('Failed to connect with email account using the settings provided.')); + } + } + } + } + + Hook::callAll('connector_settings_post', $request); + $this->baseUrl->redirect($this->args->getQueryString()); + } + + protected function content(array $request = []): string + { + parent::content($request); + + $accept_only_sharer = intval($this->pconfig->get($this->session->getLocalUserId(), 'system', 'accept_only_sharer')); + $enable_cw = !intval($this->pconfig->get($this->session->getLocalUserId(), 'system', 'disable_cw')); + $enable_smart_shortening = !intval($this->pconfig->get($this->session->getLocalUserId(), 'system', 'no_intelligent_shortening')); + $simple_shortening = intval($this->pconfig->get($this->session->getLocalUserId(), 'system', 'simple_shortening')); + $attach_link_title = intval($this->pconfig->get($this->session->getLocalUserId(), 'system', 'attach_link_title')); + $legacy_contact = $this->pconfig->get($this->session->getLocalUserId(), 'ostatus', 'legacy_contact'); + + if (!empty($legacy_contact)) { + $this->baseUrl->redirect('ostatus_subscribe?url=' . urlencode($legacy_contact)); + } + + $connector_settings_forms = []; + foreach ($this->database->selectToArray('hook', ['file', 'function'], ['hook' => 'connector_settings']) as $hook) { + $data = []; + Hook::callSingle($this->app, 'connector_settings', [$hook['file'], $hook['function']], $data); + + $tpl = Renderer::getMarkupTemplate('settings/addons/connector.tpl'); + $connector_settings_forms[$data['connector']] = Renderer::replaceMacros($tpl, [ + '$connector' => $data['connector'], + '$title' => $data['title'], + '$image' => $data['image'] ?? '', + '$enabled' => $data['enabled'] ?? true, + '$open' => ($this->parameters['connector'] ?? '') === $data['connector'], + '$html' => $data['html'] ?? '', + '$submit' => $data['submit'] ?? $this->t('Save Settings'), + ]); + } + + if ($this->app->isSiteAdmin()) { + $diasp_enabled = $this->config->get('system', 'diaspora_enabled') ? + $this->t('Built-in support for %s connectivity is enabled', $this->t('Diaspora (Socialhome, Hubzilla)')) : + $this->t('Built-in support for %s connectivity is disabled', $this->t('Diaspora (Socialhome, Hubzilla)')); + $ostat_enabled = $this->config->get('system', 'ostatus_disabled') ? + $this->t('Built-in support for %s connectivity is disabled', $this->t('OStatus (GNU Social)')) : + $this->t('Built-in support for %s connectivity is enabled', $this->t('OStatus (GNU Social)')); + } else { + $diasp_enabled = ''; + $ostat_enabled = ''; + } + + $mail_enabled = function_exists('imap_open') && !$this->config->get('system', 'imap_disabled'); + if ($mail_enabled) { + $mail_account = $this->database->selectFirst('mailacct', [], ['uid' => $this->session->getLocalUserId()]); + $mail_disabled = ''; + } else { + $mail_account = null; + $mail_disabled = $this->t('Email access is disabled on this site.'); + } + + $mail_server = $mail_account['server'] ?? ''; + $mail_port = (!empty($mail_account['port']) && is_numeric($mail_account['port'])) ? (int)$mail_account['port'] : ''; + $mail_ssl = $mail_account['ssltype'] ?? ''; + $mail_user = $mail_account['user'] ?? ''; + $mail_replyto = $mail_account['reply_to'] ?? ''; + $mail_pubmail = $mail_account['pubmail'] ?? 0; + $mail_action = $mail_account['action'] ?? 0; + $mail_movetofolder = $mail_account['movetofolder'] ?? ''; + $mail_chk = $mail_account['last_check'] ?? DBA::NULL_DATETIME; + + $ssl_options = ['TLS' => 'TLS', 'SSL' => 'SSL']; + if ($this->config->get('system', 'insecure_imap')) { + $ssl_options['notls'] = $this->t('None'); + } + + $tpl = Renderer::getMarkupTemplate('settings/connectors.tpl'); + $o = Renderer::replaceMacros($tpl, [ + '$form_security_token' => BaseSettings::getFormSecurityToken("settings_connectors"), + + '$title' => $this->t('Social Networks'), + + '$diasp_enabled' => $diasp_enabled, + '$ostat_enabled' => $ostat_enabled, + + '$general_settings' => $this->t('General Social Media Settings'), + '$accept_only_sharer' => [ + 'accept_only_sharer', + $this->t('Followed content scope'), + $accept_only_sharer, + $this->t('By default, conversations in which your follows participated but didn\'t start will be shown in your timeline. You can turn this behavior off, or expand it to the conversations in which your follows liked a post.'), + [ + Item::COMPLETION_NONE => $this->t('Only conversations my follows started'), + Item::COMPLETION_COMMENT => $this->t('Conversations my follows started or commented on (default)'), + Item::COMPLETION_LIKE => $this->t('Any conversation my follows interacted with, including likes'), + ] + ], + '$enable_cw' => ['enable_cw', $this->t('Enable Content Warning'), $enable_cw, $this->t('Users on networks like Mastodon or Pleroma are able to set a content warning field which collapse their post by default. This enables the automatic collapsing instead of setting the content warning as the post title. Doesn\'t affect any other content filtering you eventually set up.')], + '$enable_smart_shortening' => ['enable_smart_shortening', $this->t('Enable intelligent shortening'), $enable_smart_shortening, $this->t('Normally the system tries to find the best link to add to shortened posts. If disabled, every shortened post will always point to the original friendica post.')], + '$simple_shortening' => ['simple_shortening', $this->t('Enable simple text shortening'), $simple_shortening, $this->t('Normally the system shortens posts at the next line feed. If this option is enabled then the system will shorten the text at the maximum character limit.')], + '$attach_link_title' => ['attach_link_title', $this->t('Attach the link title'), $attach_link_title, $this->t('When activated, the title of the attached link will be added as a title on posts to Diaspora. This is mostly helpful with "remote-self" contacts that share feed content.')], + '$legacy_contact' => ['legacy_contact', $this->t('Your legacy ActivityPub/GNU Social account'), $legacy_contact, $this->t('If you enter your old account name from an ActivityPub based system or your GNU Social/Statusnet account name here (in the format user@domain.tld), your contacts will be added automatically. The field will be emptied when done.')], + + '$repair_ostatus_url' => 'ostatus/repair', + '$repair_ostatus_text' => $this->t('Repair OStatus subscriptions'), + + '$connector_settings_forms' => $connector_settings_forms, + + '$h_mail' => $this->t('Email/Mailbox Setup'), + '$mail_desc' => $this->t("If you wish to communicate with email contacts using this service \x28optional\x29, please specify how to connect to your mailbox."), + '$mail_lastcheck' => ['mail_lastcheck', $this->t('Last successful email check:'), $mail_chk, ''], + '$mail_disabled' => $mail_disabled, + '$mail_server' => ['mail_server', $this->t('IMAP server name:'), $mail_server, ''], + '$mail_port' => ['mail_port', $this->t('IMAP port:'), $mail_port, ''], + '$mail_ssl' => ['mail_ssl', $this->t('Security:'), strtoupper($mail_ssl), '', $ssl_options], + '$mail_user' => ['mail_user', $this->t('Email login name:'), $mail_user, ''], + '$mail_pass' => ['mail_pass', $this->t('Email password:'), '', ''], + '$mail_replyto' => ['mail_replyto', $this->t('Reply-to address:'), $mail_replyto, 'Optional'], + '$mail_pubmail' => ['mail_pubmail', $this->t('Send public posts to all email contacts:'), $mail_pubmail, ''], + '$mail_action' => ['mail_action', $this->t('Action after import:'), $mail_action, '', [0 => $this->t('None'), 1 => $this->t('Delete'), 2 => $this->t('Mark as seen'), 3 => $this->t('Move to folder')]], + '$mail_movetofolder' => ['mail_movetofolder', $this->t('Move to folder:'), $mail_movetofolder, ''], + '$submit' => $this->t('Save Settings'), + ]); + + return $o; + } +} diff --git a/static/routes.config.php b/static/routes.config.php index ef80922e38..d2d430a8c2 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -592,14 +592,8 @@ return [ '[/]' => [Module\Settings\Account::class, [R::GET, R::POST]], '/{open}' => [Module\Settings\Account::class, [R::GET, R::POST]], ], - '/addons[/{addon}]' => [Module\Settings\Addons::class, [R::GET, R::POST]], - '/2fa' => [ - '[/]' => [Module\Settings\TwoFactor\Index::class, [R::GET, R::POST]], - '/recovery' => [Module\Settings\TwoFactor\Recovery::class, [R::GET, R::POST]], - '/app_specific' => [Module\Settings\TwoFactor\AppSpecific::class, [R::GET, R::POST]], - '/verify' => [Module\Settings\TwoFactor\Verify::class, [R::GET, R::POST]], - '/trusted' => [Module\Settings\TwoFactor\Trusted::class, [R::GET, R::POST]], - ], + '/addons[/{addon}]' => [Module\Settings\Addons::class, [R::GET, R::POST]], + '/connectors[/{connector}]' => [Module\Settings\Connectors::class, [R::GET, R::POST]], '/delegation[/{action}/{user_id}]' => [Module\Settings\Delegation::class, [R::GET, R::POST]], '/display' => [Module\Settings\Display::class, [R::GET, R::POST]], '/oauth' => [Module\Settings\OAuth::class, [R::GET, R::POST]], @@ -610,6 +604,13 @@ return [ ], '/removeme' => [Module\Settings\RemoveMe::class, [R::GET, R::POST]], '/userexport[/{action}]' => [Module\Settings\UserExport::class, [R::GET ]], + '/2fa' => [ + '[/]' => [Module\Settings\TwoFactor\Index::class, [R::GET, R::POST]], + '/recovery' => [Module\Settings\TwoFactor\Recovery::class, [R::GET, R::POST]], + '/app_specific' => [Module\Settings\TwoFactor\AppSpecific::class, [R::GET, R::POST]], + '/verify' => [Module\Settings\TwoFactor\Verify::class, [R::GET, R::POST]], + '/trusted' => [Module\Settings\TwoFactor\Trusted::class, [R::GET, R::POST]], + ], ], '/network' => [ diff --git a/view/templates/settings/addon/connector.tpl b/view/templates/settings/addons/connector.tpl similarity index 100% rename from view/templates/settings/addon/connector.tpl rename to view/templates/settings/addons/connector.tpl diff --git a/view/templates/settings/connectors.tpl b/view/templates/settings/connectors.tpl index 8010cc982d..1cd0f73cd6 100644 --- a/view/templates/settings/connectors.tpl +++ b/view/templates/settings/connectors.tpl @@ -27,7 +27,6 @@
-{{if !$mail_disabled}}

{{$h_mail}}

+ {{if $mail_disabled}} +

{{$mail_disabled}}

+ {{else}}

{{$mail_desc nofilter}}

{{include file="field_custom.tpl" field=$mail_lastcheck}} {{include file="field_input.tpl" field=$mail_server}} @@ -53,9 +55,9 @@
+ {{/if}}
-{{/if}} {{foreach $connector_settings_forms as $addon => $connector_settings_form}}
diff --git a/view/theme/frio/templates/settings/addon/connector.tpl b/view/theme/frio/templates/settings/addons/connector.tpl similarity index 100% rename from view/theme/frio/templates/settings/addon/connector.tpl rename to view/theme/frio/templates/settings/addons/connector.tpl diff --git a/view/theme/frio/templates/settings/connectors.tpl b/view/theme/frio/templates/settings/connectors.tpl index dc32c174f3..409512d5ea 100644 --- a/view/theme/frio/templates/settings/connectors.tpl +++ b/view/theme/frio/templates/settings/connectors.tpl @@ -1,5 +1,5 @@
- {{include file="section_title.tpl" title=$title}} + {{include file="section_title.tpl" title=$title}}

{{$diasp_enabled}}

{{$ostat_enabled}}

@@ -38,8 +38,6 @@
-{{if !$mail_disabled}} -
@@ -52,7 +50,9 @@
- + {{if $mail_disabled}} +

{{$mail_disabled}}

+ {{else}}

{{$mail_desc nofilter}}

{{include file="field_custom.tpl" field=$mail_lastcheck}} @@ -68,15 +68,15 @@
-{{/if}} {{foreach $connector_settings_forms as $addon => $connector_settings_form}}
- {{$connector_settings_form nofilter}} + {{$connector_settings_form nofilter}}
{{/foreach}} -- 2.39.5