X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=mod%2Fsettings.php;h=45f5f96c54ed3967793c879a01c6d896faaeca69;hb=05b15f28249ac83a160cbbdca9fe044c4e664b47;hp=2e21c26824cda40987c484c45a278426fb5e150f;hpb=08ead524339a43f29c809ca63514e40cd24dee9c;p=friendica.git diff --git a/mod/settings.php b/mod/settings.php index 2e21c26824..45f5f96c54 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -36,8 +36,8 @@ use Friendica\Protocol\Email; 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; } @@ -47,11 +47,11 @@ function settings_init(App $a) 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; } @@ -69,12 +69,12 @@ function settings_post(App $a) 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'] ?? ''; @@ -87,13 +87,13 @@ function settings_post(App $a) $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', [ @@ -106,10 +106,10 @@ function settings_post(App $a) 'mailbox' => 'INBOX', 'reply_to' => $mail_replyto, 'pubmail' => $mail_pubmail - ], ['uid' => local_user()]); + ], ['uid' => DI::userSession()->getLocalUserId()]); Logger::debug('updating mailaccount', ['response' => $r]); - $mailacct = DBA::selectFirst('mailacct', [], ['uid' => local_user()]); + $mailacct = DBA::selectFirst('mailacct', [], ['uid' => DI::userSession()->getLocalUserId()]); if (DBA::isResult($mailacct)) { $mb = Email::constructMailboxName($mailacct); @@ -119,7 +119,7 @@ function settings_post(App $a) $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.')); } } } @@ -135,7 +135,7 @@ function settings_post(App $a) 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; @@ -147,13 +147,13 @@ function settings_content(App $a) $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 ''; } @@ -161,12 +161,12 @@ function settings_content(App $a) 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, [ @@ -225,7 +225,7 @@ function settings_content(App $a) $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]]; } } @@ -240,12 +240,12 @@ function settings_content(App $a) } 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? @@ -279,7 +279,7 @@ function settings_content(App $a) $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; }