diff options
Diffstat (limited to 'apps/settings/lib/Controller')
14 files changed, 61 insertions, 79 deletions
diff --git a/apps/settings/lib/Controller/AdminSettingsController.php b/apps/settings/lib/Controller/AdminSettingsController.php index e7b1a27a637..c50ffc6f1e7 100644 --- a/apps/settings/lib/Controller/AdminSettingsController.php +++ b/apps/settings/lib/Controller/AdminSettingsController.php @@ -82,7 +82,7 @@ class AdminSettingsController extends Controller { ); $formatted = $this->formatSettings($settings); // Do not show legacy forms for sub admins - if($section === 'additional' && !$isSubAdmin) { + if ($section === 'additional' && !$isSubAdmin) { $formatted['content'] .= $this->getLegacyForms(); } return $formatted; @@ -117,6 +117,4 @@ class AdminSettingsController extends Controller { return $out->fetchPage(); } - - } diff --git a/apps/settings/lib/Controller/AppSettingsController.php b/apps/settings/lib/Controller/AppSettingsController.php index f40a8024b6d..7dbbaca1a45 100644 --- a/apps/settings/lib/Controller/AppSettingsController.php +++ b/apps/settings/lib/Controller/AppSettingsController.php @@ -149,9 +149,9 @@ class AppSettingsController extends Controller { private function getAppsWithUpdates() { $appClass = new \OC_App(); $apps = $appClass->listAllApps(); - foreach($apps as $key => $app) { + foreach ($apps as $key => $app) { $newVersion = $this->installer->isUpdateAvailable($app['id']); - if($newVersion === false) { + if ($newVersion === false) { unset($apps[$key]); } } @@ -169,7 +169,6 @@ class AppSettingsController extends Controller { ]; } return $result; - } /** @@ -186,7 +185,7 @@ class AppSettingsController extends Controller { $formattedCategories = []; $categories = $this->categoryFetcher->get(); - foreach($categories as $category) { + foreach ($categories as $category) { $formattedCategories[] = [ 'id' => $category['id'], 'ident' => $category['id'], @@ -217,10 +216,10 @@ class AppSettingsController extends Controller { // add bundle information $bundles = $this->bundleFetcher->getBundles(); - foreach($bundles as $bundle) { - foreach($bundle->getAppIdentifiers() as $identifier) { - foreach($this->allApps as &$app) { - if($app['id'] === $identifier) { + foreach ($bundles as $bundle) { + foreach ($bundle->getAppIdentifiers() as $identifier) { + foreach ($this->allApps as &$app) { + if ($app['id'] === $identifier) { $app['bundleIds'][] = $bundle->getIdentifier(); continue; } @@ -240,7 +239,6 @@ class AppSettingsController extends Controller { * @throws \Exception */ public function listApps(): JSONResponse { - $this->fetchApps(); $apps = $this->getAllApps(); @@ -255,7 +253,7 @@ class AppSettingsController extends Controller { } $newVersion = $this->installer->isUpdateAvailable($appData['id']); - if($newVersion) { + if ($newVersion) { $appData['update'] = $newVersion; } @@ -307,16 +305,16 @@ class AppSettingsController extends Controller { $versionParser = new VersionParser(); $formattedApps = []; $apps = $this->appFetcher->get(); - foreach($apps as $app) { + foreach ($apps as $app) { // Skip all apps not in the requested category if ($requestedCategory !== '') { $isInCategory = false; - foreach($app['categories'] as $category) { - if($category === $requestedCategory) { + foreach ($app['categories'] as $category) { + if ($category === $requestedCategory) { $isInCategory = true; } } - if(!$isInCategory) { + if (!$isInCategory) { continue; } } @@ -326,28 +324,28 @@ class AppSettingsController extends Controller { } $nextCloudVersion = $versionParser->getVersion($app['releases'][0]['rawPlatformVersionSpec']); $nextCloudVersionDependencies = []; - if($nextCloudVersion->getMinimumVersion() !== '') { + if ($nextCloudVersion->getMinimumVersion() !== '') { $nextCloudVersionDependencies['nextcloud']['@attributes']['min-version'] = $nextCloudVersion->getMinimumVersion(); } - if($nextCloudVersion->getMaximumVersion() !== '') { + if ($nextCloudVersion->getMaximumVersion() !== '') { $nextCloudVersionDependencies['nextcloud']['@attributes']['max-version'] = $nextCloudVersion->getMaximumVersion(); } $phpVersion = $versionParser->getVersion($app['releases'][0]['rawPhpVersionSpec']); $existsLocally = \OC_App::getAppPath($app['id']) !== false; $phpDependencies = []; - if($phpVersion->getMinimumVersion() !== '') { + if ($phpVersion->getMinimumVersion() !== '') { $phpDependencies['php']['@attributes']['min-version'] = $phpVersion->getMinimumVersion(); } - if($phpVersion->getMaximumVersion() !== '') { + if ($phpVersion->getMaximumVersion() !== '') { $phpDependencies['php']['@attributes']['max-version'] = $phpVersion->getMaximumVersion(); } - if(isset($app['releases'][0]['minIntSize'])) { + if (isset($app['releases'][0]['minIntSize'])) { $phpDependencies['php']['@attributes']['min-int-size'] = $app['releases'][0]['minIntSize']; } $authors = ''; - foreach($app['authors'] as $key => $author) { + foreach ($app['authors'] as $key => $author) { $authors .= $author['name']; - if($key !== count($app['authors']) - 1) { + if ($key !== count($app['authors']) - 1) { $authors .= ', '; } } @@ -355,12 +353,12 @@ class AppSettingsController extends Controller { $currentLanguage = substr(\OC::$server->getL10NFactory()->findLanguage(), 0, 2); $enabledValue = $this->config->getAppValue($app['id'], 'enabled', 'no'); $groups = null; - if($enabledValue !== 'no' && $enabledValue !== 'yes') { + if ($enabledValue !== 'no' && $enabledValue !== 'yes') { $groups = $enabledValue; } $currentVersion = ''; - if($this->appManager->isInstalled($app['id'])) { + if ($this->appManager->isInstalled($app['id'])) { $currentVersion = $this->appManager->getAppVersion($app['id']); } else { $currentLanguage = $app['releases'][0]['version']; @@ -442,7 +440,7 @@ class AppSettingsController extends Controller { $installer = \OC::$server->query(Installer::class); $isDownloaded = $installer->isDownloaded($appId); - if(!$isDownloaded) { + if (!$isDownloaded) { $installer->downloadApp($appId); } @@ -458,7 +456,6 @@ class AppSettingsController extends Controller { } } return new JSONResponse(['data' => ['update_required' => $updateRequired]]); - } catch (\Exception $e) { $this->logger->logException($e); return new JSONResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_INTERNAL_SERVER_ERROR); @@ -515,7 +512,7 @@ class AppSettingsController extends Controller { public function uninstallApp(string $appId): JSONResponse { $appId = OC_App::cleanAppId($appId); $result = $this->installer->removeApp($appId); - if($result !== false) { + if ($result !== false) { $this->appManager->clearAppsCache(); return new JSONResponse(['data' => ['appid' => $appId]]); } @@ -558,5 +555,4 @@ class AppSettingsController extends Controller { $this->appManager->ignoreNextcloudRequirementForApp($appId); return new JSONResponse(); } - } diff --git a/apps/settings/lib/Controller/AuthSettingsController.php b/apps/settings/lib/Controller/AuthSettingsController.php index 405044746a3..0296a1ac5cb 100644 --- a/apps/settings/lib/Controller/AuthSettingsController.php +++ b/apps/settings/lib/Controller/AuthSettingsController.php @@ -126,8 +126,7 @@ class AuthSettingsController extends Controller { } catch (SessionNotAvailableException $ex) { return $this->getServiceNotAvailableResponse(); } - if ($this->userSession->getImpersonatingUserID() !== null) - { + if ($this->userSession->getImpersonatingUserID() !== null) { return $this->getServiceNotAvailableResponse(); } diff --git a/apps/settings/lib/Controller/CertificateController.php b/apps/settings/lib/Controller/CertificateController.php index d23821bdf9c..b7ce1749660 100644 --- a/apps/settings/lib/Controller/CertificateController.php +++ b/apps/settings/lib/Controller/CertificateController.php @@ -126,7 +126,6 @@ class CertificateController extends Controller { * @return DataResponse */ public function removePersonalRootCertificate($certificateIdentifier) { - if ($this->isCertificateImportAllowed() === false) { return new DataResponse(['Individual certificate management disabled'], Http::STATUS_FORBIDDEN); } @@ -168,7 +167,6 @@ class CertificateController extends Controller { * @return DataResponse */ public function removeSystemRootCertificate($certificateIdentifier) { - if ($this->isCertificateImportAllowed() === false) { return new DataResponse(['Individual certificate management disabled'], Http::STATUS_FORBIDDEN); } diff --git a/apps/settings/lib/Controller/ChangePasswordController.php b/apps/settings/lib/Controller/ChangePasswordController.php index 20b8357a6a9..439731b22eb 100644 --- a/apps/settings/lib/Controller/ChangePasswordController.php +++ b/apps/settings/lib/Controller/ChangePasswordController.php @@ -108,8 +108,8 @@ class ChangePasswordController extends Controller { 'status' => 'error' ]); } - // password policy app throws exception - } catch(HintException $e) { + // password policy app throws exception + } catch (HintException $e) { return new JSONResponse([ 'status' => 'error', 'data' => [ @@ -221,8 +221,8 @@ class ChangePasswordController extends Controller { } else { // now we know that everything is fine regarding the recovery password, let's try to change the password try { $result = $targetUser->setPassword($password, $recoveryPassword); - // password policy app throws exception - } catch(HintException $e) { + // password policy app throws exception + } catch (HintException $e) { return new JSONResponse([ 'status' => 'error', 'data' => [ @@ -256,8 +256,8 @@ class ChangePasswordController extends Controller { ], ]); } - // password policy app throws exception - } catch(HintException $e) { + // password policy app throws exception + } catch (HintException $e) { return new JSONResponse([ 'status' => 'error', 'data' => [ diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index e386f29a94e..a0d374e5b44 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -137,7 +137,7 @@ class CheckSetupController extends Controller { 'www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org' ]); - foreach($siteArray as $site) { + foreach ($siteArray as $site) { if ($this->isSiteReachable($site)) { return false; } @@ -208,40 +208,40 @@ class CheckSetupController extends Controller { // Don't run check when: // 1. Server has `has_internet_connection` set to false // 2. AppStore AND S2S is disabled - if(!$this->config->getSystemValue('has_internet_connection', true)) { + if (!$this->config->getSystemValue('has_internet_connection', true)) { return ''; } - if(!$this->config->getSystemValue('appstoreenabled', true) + if (!$this->config->getSystemValue('appstoreenabled', true) && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no' && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') { return ''; } $versionString = $this->getCurlVersion(); - if(isset($versionString['ssl_version'])) { + if (isset($versionString['ssl_version'])) { $versionString = $versionString['ssl_version']; } else { return ''; } $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing'); - if(!$this->config->getSystemValue('appstoreenabled', true)) { + if (!$this->config->getSystemValue('appstoreenabled', true)) { $features = (string)$this->l10n->t('Federated Cloud Sharing'); } // Check if at least OpenSSL after 1.01d or 1.0.2b - if(strpos($versionString, 'OpenSSL/') === 0) { + if (strpos($versionString, 'OpenSSL/') === 0) { $majorVersion = substr($versionString, 8, 5); $patchRelease = substr($versionString, 13, 6); - if(($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) || + if (($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) || ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) { return $this->l10n->t('cURL is using an outdated %1$s version (%2$s). Please update your operating system or features such as %3$s will not work reliably.', ['OpenSSL', $versionString, $features]); } } // Check if NSS and perform heuristic check - if(strpos($versionString, 'NSS/') === 0) { + if (strpos($versionString, 'NSS/') === 0) { try { $firstClient = $this->clientService->newClient(); $firstClient->get('https://nextcloud.com/'); @@ -249,7 +249,7 @@ class CheckSetupController extends Controller { $secondClient = $this->clientService->newClient(); $secondClient->get('https://nextcloud.com/'); } catch (ClientException $e) { - if($e->getResponse()->getStatusCode() === 400) { + if ($e->getResponse()->getStatusCode() === 400) { return $this->l10n->t('cURL is using an outdated %1$s version (%2$s). Please update your operating system or features such as %3$s will not work reliably.', ['NSS', $versionString, $features]); } } @@ -344,13 +344,13 @@ class CheckSetupController extends Controller { * @return DataResponse */ public function getFailedIntegrityCheckFiles() { - if(!$this->checker->isCodeCheckEnforced()) { + if (!$this->checker->isCodeCheckEnforced()) { return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.'); } $completeResults = $this->checker->getResults(); - if(!empty($completeResults)) { + if (!empty($completeResults)) { $formattedTextResponse = 'Technical information ===================== The following list covers which files have failed the integrity check. Please read @@ -360,12 +360,12 @@ them. Results ======= '; - foreach($completeResults as $context => $contextResult) { + foreach ($completeResults as $context => $contextResult) { $formattedTextResponse .= "- $context\n"; - foreach($contextResult as $category => $result) { + foreach ($contextResult as $category => $result) { $formattedTextResponse .= "\t- $category\n"; - if($category !== 'EXCEPTION') { + if ($category !== 'EXCEPTION') { foreach ($result as $key => $results) { $formattedTextResponse .= "\t\t- $key\n"; } @@ -374,7 +374,6 @@ Results $formattedTextResponse .= "\t\t- $results\n"; } } - } } @@ -406,23 +405,23 @@ Raw output protected function isOpcacheProperlySetup() { $iniWrapper = new IniGetWrapper(); - if(!$iniWrapper->getBool('opcache.enable')) { + if (!$iniWrapper->getBool('opcache.enable')) { return false; } - if(!$iniWrapper->getBool('opcache.save_comments')) { + if (!$iniWrapper->getBool('opcache.save_comments')) { return false; } - if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) { + if ($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) { return false; } - if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) { + if ($iniWrapper->getNumeric('opcache.memory_consumption') < 128) { return false; } - if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) { + if ($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) { return false; } diff --git a/apps/settings/lib/Controller/CommonSettingsTrait.php b/apps/settings/lib/Controller/CommonSettingsTrait.php index 7aa202429eb..f5c8bb465fd 100644 --- a/apps/settings/lib/Controller/CommonSettingsTrait.php +++ b/apps/settings/lib/Controller/CommonSettingsTrait.php @@ -38,7 +38,7 @@ use OCP\Settings\IIconSection; use OCP\Settings\IManager as ISettingsManager; use OCP\Settings\ISettings; -trait CommonSettingsTrait { +trait CommonSettingsTrait { /** @var ISettingsManager */ private $settingsManager; @@ -85,11 +85,11 @@ trait CommonSettingsTrait { protected function formatSections($sections, $currentSection, $type, $currentType, bool $subAdminOnly = false) { $templateParameters = []; /** @var \OCP\Settings\ISection[] $prioritizedSections */ - foreach($sections as $prioritizedSections) { + foreach ($sections as $prioritizedSections) { foreach ($prioritizedSections as $section) { - if($type === 'admin') { + if ($type === 'admin') { $settings = $this->settingsManager->getAdminSettings($section->getID(), $subAdminOnly); - } elseif($type === 'personal') { + } elseif ($type === 'personal') { $settings = $this->settingsManager->getPersonalSettings($section->getID()); } if (empty($settings) && !($section->getID() === 'additional' && count(\OC_App::getForms('admin')) > 0)) { diff --git a/apps/settings/lib/Controller/HelpController.php b/apps/settings/lib/Controller/HelpController.php index cf470d6af4b..58fb18ea2c5 100644 --- a/apps/settings/lib/Controller/HelpController.php +++ b/apps/settings/lib/Controller/HelpController.php @@ -71,7 +71,7 @@ class HelpController extends Controller { public function help(string $mode = 'user'): TemplateResponse { $this->navigationManager->setActiveEntry('help'); - if(!isset($mode) || $mode !== 'admin') { + if (!isset($mode) || $mode !== 'admin') { $mode = 'user'; } @@ -93,7 +93,5 @@ class HelpController extends Controller { $policy->addAllowedFrameDomain('\'self\''); $response->setContentSecurityPolicy($policy); return $response; - } - } diff --git a/apps/settings/lib/Controller/LogSettingsController.php b/apps/settings/lib/Controller/LogSettingsController.php index 648b0ff1c3b..31abc144371 100644 --- a/apps/settings/lib/Controller/LogSettingsController.php +++ b/apps/settings/lib/Controller/LogSettingsController.php @@ -51,7 +51,7 @@ class LogSettingsController extends Controller { * @return StreamResponse */ public function download() { - if(!$this->log instanceof Log) { + if (!$this->log instanceof Log) { throw new \UnexpectedValueException('Log file not available'); } $resp = new StreamResponse($this->log->getLogPath()); diff --git a/apps/settings/lib/Controller/MailSettingsController.php b/apps/settings/lib/Controller/MailSettingsController.php index 5dc0ff9d890..94f9d72cafd 100644 --- a/apps/settings/lib/Controller/MailSettingsController.php +++ b/apps/settings/lib/Controller/MailSettingsController.php @@ -93,10 +93,9 @@ class MailSettingsController extends Controller { $mail_smtpauth, $mail_smtpport, $mail_sendmailmode) { - $params = get_defined_vars(); $configs = []; - foreach($params as $key => $value) { + foreach ($params as $key => $value) { $configs[$key] = empty($value) ? null : $value; } @@ -168,5 +167,4 @@ class MailSettingsController extends Controller { return new DataResponse($this->l10n->t('You need to set your user email before being able to send test emails.'), Http::STATUS_BAD_REQUEST); } - } diff --git a/apps/settings/lib/Controller/PersonalSettingsController.php b/apps/settings/lib/Controller/PersonalSettingsController.php index 12d8af3af17..0aff8bee649 100644 --- a/apps/settings/lib/Controller/PersonalSettingsController.php +++ b/apps/settings/lib/Controller/PersonalSettingsController.php @@ -65,7 +65,6 @@ class PersonalSettingsController extends Controller { */ public function index($section) { return $this->getIndexResponse('personal', $section); - } /** @@ -75,7 +74,7 @@ class PersonalSettingsController extends Controller { protected function getSettings($section) { $settings = $this->settingsManager->getPersonalSettings($section); $formatted = $this->formatSettings($settings); - if($section === 'additional') { + if ($section === 'additional') { $formatted['content'] .= $this->getLegacyForms(); } return $formatted; diff --git a/apps/settings/lib/Controller/TwoFactorSettingsController.php b/apps/settings/lib/Controller/TwoFactorSettingsController.php index 77d8e882354..36b554c8181 100644 --- a/apps/settings/lib/Controller/TwoFactorSettingsController.php +++ b/apps/settings/lib/Controller/TwoFactorSettingsController.php @@ -56,5 +56,4 @@ class TwoFactorSettingsController extends Controller { return new JSONResponse($this->mandatoryTwoFactor->getState()); } - } diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index 5a4ebd122f8..abc4715df6c 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -172,7 +172,7 @@ class UsersController extends Controller { $groupsInfo->setSorting($sortGroupsBy); list($adminGroup, $groups) = $groupsInfo->get(); - if(!$isLDAPUsed && $this->appManager->isEnabledForUser('user_ldap')) { + if (!$isLDAPUsed && $this->appManager->isEnabledForUser('user_ldap')) { $isLDAPUsed = (bool)array_reduce($this->userManager->getBackends(), function ($ldapFound, $backend) { return $ldapFound || $backend instanceof User_Proxy; }); @@ -181,7 +181,7 @@ class UsersController extends Controller { $disabledUsers = -1; $userCount = 0; - if(!$isLDAPUsed) { + if (!$isLDAPUsed) { if ($this->isAdmin) { $disabledUsers = $this->userManager->countDisabledUsers(); $userCount = array_reduce($this->userManager->countUsers(), function ($v, $w) { @@ -193,7 +193,7 @@ class UsersController extends Controller { $userGroups = $this->groupManager->getUserGroups($user); $groupsNames = []; - foreach($groups as $key => $group) { + foreach ($groups as $key => $group) { // $userCount += (int)$group['usercount']; array_push($groupsNames, $group['name']); // we prevent subadmins from looking up themselves @@ -447,7 +447,6 @@ class UsersController extends Controller { * @return DataResponse */ public function getVerificationCode(string $account, bool $onlyVerificationCode): DataResponse { - $user = $this->userSession->getUser(); if ($user === null) { diff --git a/apps/settings/lib/Controller/WebAuthnController.php b/apps/settings/lib/Controller/WebAuthnController.php index cbc396b675f..c1ce7a6cf98 100644 --- a/apps/settings/lib/Controller/WebAuthnController.php +++ b/apps/settings/lib/Controller/WebAuthnController.php @@ -37,7 +37,6 @@ use OCP\IUserSession; use Webauthn\PublicKeyCredentialCreationOptions; class WebAuthnController extends Controller { - private const WEBAUTHN_REGISTRATION = 'webauthn_registration'; /** @var Manager */ |