function settings_init(App $a)
{
- if (!local_user()) {
- notice(DI::l10n()->t('Permission denied.'));
+ if (!DI::userSession()->getLocalUserId()) {
+ DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return;
}
function settings_post(App $a)
{
if (!$a->isLoggedIn()) {
- notice(DI::l10n()->t('Permission denied.'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return;
}
- if (!empty($_SESSION['submanage'])) {
+ if (DI::userSession()->getSubManagedUserId()) {
return;
}
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', 'disable_cw', !intval($_POST['enable_cw']));
- DI::pConfig()->set(local_user(), 'system', 'no_intelligent_shortening', !intval($_POST['enable_smart_shortening']));
- 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']);
+ 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_pubmail = $_POST['mail_pubmail'] ?? '';
if (function_exists('imap_open') && !DI::config()->get('system', 'imap_disabled')) {
- if (!DBA::exists('mailacct', ['uid' => local_user()])) {
- DBA::insert('mailacct', ['uid' => local_user()]);
+ 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' => local_user()]);
+ DBA::update('mailacct', ['pass' => bin2hex($pass)], ['uid' => DI::userSession()->getLocalUserId()]);
}
$r = DBA::update('mailacct', [
'mailbox' => 'INBOX',
'reply_to' => $mail_replyto,
'pubmail' => $mail_pubmail
- ], ['uid' => local_user()]);
+ ], ['uid' => DI::userSession()->getLocalUserId()]);
- Logger::notice('updating mailaccount', ['response' => $r]);
- $mailacct = DBA::selectFirst('mailacct', [], ['uid' => local_user()]);
+ Logger::debug('updating mailaccount', ['response' => $r]);
+ $mailacct = DBA::selectFirst('mailacct', [], ['uid' => DI::userSession()->getLocalUserId()]);
if (DBA::isResult($mailacct)) {
$mb = Email::constructMailboxName($mailacct);
$mbox = Email::connect($mb, $mail_user, $dcrpass);
unset($dcrpass);
if (!$mbox) {
- notice(DI::l10n()->t('Failed to connect with email account using the settings provided.'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('Failed to connect with email account using the settings provided.'));
}
}
}
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/features', 'settings_features');
foreach ($_POST as $k => $v) {
if (strpos($k, 'feature_') === 0) {
- DI::pConfig()->set(local_user(), 'feature', substr($k, 8), ((intval($v)) ? 1 : 0));
+ DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'feature', substr($k, 8), ((intval($v)) ? 1 : 0));
}
}
return;
$o = '';
Nav::setSelected('settings');
- if (!local_user()) {
- //notice(DI::l10n()->t('Permission denied.'));
+ if (!DI::userSession()->getLocalUserId()) {
+ //DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return Login::form();
}
- if (!empty($_SESSION['submanage'])) {
- notice(DI::l10n()->t('Permission denied.'));
+ if (DI::userSession()->getSubManagedUserId()) {
+ DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return '';
}
if ((DI::args()->getArgc() > 3) && (DI::args()->getArgv()[2] === 'delete')) {
BaseModule::checkFormSecurityTokenRedirectOnError('/settings/oauth', 'settings_oauth', 't');
- DBA::delete('application-token', ['application-id' => DI::args()->getArgv()[3], 'uid' => local_user()]);
+ DBA::delete('application-token', ['application-id' => DI::args()->getArgv()[3], 'uid' => DI::userSession()->getLocalUserId()]);
DI::baseUrl()->redirect('settings/oauth/', true);
return '';
}
- $applications = DBA::selectToArray('application-view', ['id', 'uid', 'name', 'website', 'scopes', 'created_at'], ['uid' => local_user()]);
+ $applications = DBA::selectToArray('application-view', ['id', 'uid', 'name', 'website', 'scopes', 'created_at'], ['uid' => DI::userSession()->getLocalUserId()]);
$tpl = Renderer::getMarkupTemplate('settings/oauth.tpl');
$o .= Renderer::replaceMacros($tpl, [
$arr[$fname] = [];
$arr[$fname][0] = $fdata[0];
foreach (array_slice($fdata,1) as $f) {
- $arr[$fname][1][] = ['feature_' . $f[0], $f[1], Feature::isEnabled(local_user(), $f[0]), $f[2]];
+ $arr[$fname][1][] = ['feature_' . $f[0], $f[1], Feature::isEnabled(DI::userSession()->getLocalUserId(), $f[0]), $f[2]];
}
}
}
if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'connectors')) {
- $accept_only_sharer = intval(DI::pConfig()->get(local_user(), 'system', 'accept_only_sharer'));
- $enable_cw = !intval(DI::pConfig()->get(local_user(), 'system', 'disable_cw'));
- $enable_smart_shortening = !intval(DI::pConfig()->get(local_user(), 'system', 'no_intelligent_shortening'));
- $simple_shortening = intval(DI::pConfig()->get(local_user(), 'system', 'simple_shortening'));
- $attach_link_title = intval(DI::pConfig()->get(local_user(), 'system', 'attach_link_title'));
- $legacy_contact = DI::pConfig()->get(local_user(), 'ostatus', 'legacy_contact');
+ $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?
$mail_disabled = ((function_exists('imap_open') && (!DI::config()->get('system', 'imap_disabled'))) ? 0 : 1);
if (!$mail_disabled) {
- $mailacct = DBA::selectFirst('mailacct', [], ['uid' => local_user()]);
+ $mailacct = DBA::selectFirst('mailacct', [], ['uid' => DI::userSession()->getLocalUserId()]);
} else {
$mailacct = null;
}