]> git.mxchange.org Git - friendica.git/blobdiff - mod/settings.php
Reenable Twitter/Favorites tests
[friendica.git] / mod / settings.php
index 54484d8a90f762e4d4a48ea275c2d6c97cefd421..632517f16554e7e86d29850c0af7db6928bacd68 100644 (file)
@@ -72,7 +72,7 @@ function settings_post(App $a)
        $user = User::getById($a->getLoggedInUserId());
 
        if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] == 'connectors')) {
-               BaseModule::checkFormSecurityTokenRedirectOnError('/settings/connectors', 'settings_connectors');
+               BaseModule::checkFormSecurityTokenRedirectOnError(DI::args()->getQueryString(), 'settings_connectors');
 
                if (!empty($_POST['general-submit'])) {
                        DI::pConfig()->set(local_user(), 'system', 'accept_only_sharer', intval($_POST['accept_only_sharer']));
@@ -81,7 +81,7 @@ function settings_post(App $a)
                        DI::pConfig()->set(local_user(), 'system', 'simple_shortening', intval($_POST['simple_shortening']));
                        DI::pConfig()->set(local_user(), 'system', 'attach_link_title', intval($_POST['attach_link_title']));
                        DI::pConfig()->set(local_user(), 'ostatus', 'legacy_contact', $_POST['legacy_contact']);
-               } elseif (!empty($_POST['imap-submit'])) {
+               } elseif (!empty($_POST['mail-submit'])) {
                        $mail_server       =                 $_POST['mail_server']       ?? '';
                        $mail_port         =                 $_POST['mail_port']         ?? '';
                        $mail_ssl          = strtolower(trim($_POST['mail_ssl']          ?? ''));
@@ -133,6 +133,7 @@ function settings_post(App $a)
                }
 
                Hook::callAll('connector_settings_post', $_POST);
+               DI::baseUrl()->redirect(DI::args()->getQueryString());
                return;
        }
 
@@ -507,8 +508,22 @@ function settings_content(App $a)
                        DI::page()['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . DI::baseUrl().'/ostatus_subscribe?url=' . urlencode($legacy_contact) . '">';
                }
 
-               $settings_connectors = '';
-               Hook::callAll('connector_settings', $settings_connectors);
+               $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')));
@@ -565,11 +580,11 @@ function settings_content(App $a)
                        '$repair_ostatus_url' => DI::baseUrl() . '/repair_ostatus',
                        '$repair_ostatus_text' => DI::l10n()->t('Repair OStatus subscriptions'),
 
-                       '$settings_connectors' => $settings_connectors,
+                       '$connector_settings_forms' => $connector_settings_forms,
 
-                       '$h_imap' => DI::l10n()->t('Email/Mailbox Setup'),
-                       '$imap_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."),
-                       '$imap_lastcheck' => ['imap_lastcheck', DI::l10n()->t('Last successful email check:'), $mail_chk, ''],
+                       '$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, ''],