use Friendica\Module\BaseSettings;
use Friendica\Module\Security\Login;
use Friendica\Protocol\Email;
-use Friendica\Util\Strings;
use Friendica\Util\Temporal;
use Friendica\Worker\Delivery;
return;
}
- BaseSettings::content();
+ BaseSettings::createAside();
}
function settings_post(App $a)
}
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] == 'addon')) {
- BaseModule::checkFormSecurityTokenRedirectOnError('/settings/addon', 'settings_addon');
+ BaseModule::checkFormSecurityTokenRedirectOnError(DI::args()->getQueryString(), 'settings_addon');
Hook::callAll('addon_settings_post', $_POST);
+ DI::baseUrl()->redirect(DI::args()->getQueryString());
return;
}
$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']));
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'] ?? ''));
}
Hook::callAll('connector_settings_post', $_POST);
+ DI::baseUrl()->redirect(DI::args()->getQueryString());
return;
}
}
}
- $username = (!empty($_POST['username']) ? Strings::escapeTags(trim($_POST['username'])) : '');
- $email = (!empty($_POST['email']) ? Strings::escapeTags(trim($_POST['email'])) : '');
- $timezone = (!empty($_POST['timezone']) ? Strings::escapeTags(trim($_POST['timezone'])) : '');
- $language = (!empty($_POST['language']) ? Strings::escapeTags(trim($_POST['language'])) : '');
+ $username = (!empty($_POST['username']) ? trim($_POST['username']) : '');
+ $email = (!empty($_POST['email']) ? trim($_POST['email']) : '');
+ $timezone = (!empty($_POST['timezone']) ? trim($_POST['timezone']) : '');
+ $language = (!empty($_POST['language']) ? trim($_POST['language']) : '');
- $defloc = (!empty($_POST['defloc']) ? Strings::escapeTags(trim($_POST['defloc'])) : '');
- $maxreq = (!empty($_POST['maxreq']) ? intval($_POST['maxreq']) : 0);
- $expire = (!empty($_POST['expire']) ? intval($_POST['expire']) : 0);
+ $defloc = (!empty($_POST['defloc']) ? trim($_POST['defloc']) : '');
+ $maxreq = (!empty($_POST['maxreq']) ? intval($_POST['maxreq']) : 0);
+ $expire = (!empty($_POST['expire']) ? intval($_POST['expire']) : 0);
$def_gid = (!empty($_POST['group-selection']) ? intval($_POST['group-selection']) : 0);
if ($email != $user['email']) {
// check for the correct password
- if (!User::authenticate(intval(local_user()), $_POST['mpassword'])) {
+ try {
+ User::getIdFromPasswordAuthentication(local_user(), $_POST['mpassword']);
+ } catch (Exception $ex) {
$err .= DI::l10n()->t('Wrong Password.');
$email = $user['email'];
}
}
if (($timezone != $user['timezone']) && strlen($timezone)) {
- date_default_timezone_set($timezone);
+ $a->setTimeZone($timezone);
}
$aclFormatter = DI::aclFormatter();
if (!empty($_SESSION['submanage'])) {
notice(DI::l10n()->t('Permission denied.'));
- return;
+ return '';
}
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'oauth')) {
DBA::delete('application-token', ['application-id' => DI::args()->getArgv()[3], 'uid' => local_user()]);
DI::baseUrl()->redirect('settings/oauth/', true);
- return;
+ return '';
}
$applications = DBA::selectToArray('application-view', ['id', 'uid', 'name', 'website', 'scopes', 'created_at'], ['uid' => local_user()]);
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'addon')) {
$addon_settings_forms = [];
-
foreach (DI::dba()->selectToArray('hook', ['file', 'function'], ['hook' => 'addon_settings']) as $hook) {
- $data = '';
+ $data = [];
Hook::callSingle(DI::app(), 'addon_settings', [$hook['file'], $hook['function']], $data);
- $addon_settings_forms[] = $data;
+
+ if (!empty($data['href'])) {
+ $tpl = Renderer::getMarkupTemplate('settings/addon/link.tpl');
+ $addon_settings_forms[] = Renderer::replaceMacros($tpl, [
+ '$addon' => $data['addon'],
+ '$title' => $data['title'],
+ '$href' => $data['href'],
+ ]);
+ } elseif(!empty($data['addon'])) {
+ $tpl = Renderer::getMarkupTemplate('settings/addon/panel.tpl');
+ $addon_settings_forms[$data['addon']] = Renderer::replaceMacros($tpl, [
+ '$addon' => $data['addon'],
+ '$title' => $data['title'],
+ '$open' => (DI::args()->getArgv()[2] ?? '') === $data['addon'],
+ '$html' => $data['html'] ?? '',
+ '$submit' => $data['submit'] ?? DI::l10n()->t('Save Settings'),
+ ]);
+ }
}
$tpl = Renderer::getMarkupTemplate('settings/addons.tpl');
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 (is_site_admin()) {
+ 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 {
'$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, ''],
$profile = DBA::selectFirst('profile', [], ['uid' => local_user()]);
if (!DBA::isResult($profile)) {
notice(DI::l10n()->t('Unable to find your profile. Please contact your admin.'));
- return;
+ return '';
}
$user = User::getById($a->getLoggedInUserId());
$expire_network_only = DI::pConfig()->get(local_user(), 'expire', 'network_only', false);
if (!strlen($user['timezone'])) {
- $timezone = date_default_timezone_get();
+ $timezone = $a->getTimeZone();
}
// Set the account type to "Community" when the page is a community page but the account type doesn't fit