@@ -31,102 +31,102 @@ |
||
31 | 31 | use OCP\Settings\ISettings; |
32 | 32 | |
33 | 33 | trait CommonSettingsTrait { |
34 | - /** @var ISettingsManager */ |
|
35 | - private $settingsManager; |
|
36 | - |
|
37 | - /** @var INavigationManager */ |
|
38 | - private $navigationManager; |
|
39 | - |
|
40 | - /** |
|
41 | - * @param string $currentSection |
|
42 | - * @return array |
|
43 | - */ |
|
44 | - private function getNavigationParameters($currentType, $currentSection) { |
|
45 | - $templateParameters = [ |
|
46 | - 'personal' => $this->formatPersonalSections($currentType, $currentSection), |
|
47 | - 'admin' => [] |
|
48 | - ]; |
|
49 | - |
|
50 | - if(\OC_User::isAdminUser(\OC_User::getUser())) { |
|
51 | - $templateParameters['admin'] = $this->formatAdminSections($currentType, $currentSection); |
|
52 | - } |
|
53 | - |
|
54 | - return [ |
|
55 | - 'forms' => $templateParameters |
|
56 | - ]; |
|
57 | - } |
|
58 | - |
|
59 | - protected function formatSections($sections, $currentSection, $type, $currentType) { |
|
60 | - $templateParameters = []; |
|
61 | - /** @var \OCP\Settings\ISection[] $prioritizedSections */ |
|
62 | - foreach($sections as $prioritizedSections) { |
|
63 | - foreach ($prioritizedSections as $section) { |
|
64 | - if($type === 'admin') { |
|
65 | - $settings = $this->settingsManager->getAdminSettings($section->getID()); |
|
66 | - } else if($type === 'personal') { |
|
67 | - $settings = $this->settingsManager->getPersonalSettings($section->getID()); |
|
68 | - } |
|
69 | - if (empty($settings) && !($section->getID() === 'additional' && count(\OC_App::getForms('admin')) > 0)) { |
|
70 | - continue; |
|
71 | - } |
|
72 | - |
|
73 | - $icon = ''; |
|
74 | - if ($section instanceof IIconSection) { |
|
75 | - $icon = $section->getIcon(); |
|
76 | - } |
|
77 | - |
|
78 | - $active = $section->getID() === $currentSection |
|
79 | - && $type === $currentType; |
|
80 | - |
|
81 | - $templateParameters[] = [ |
|
82 | - 'anchor' => $section->getID(), |
|
83 | - 'section-name' => $section->getName(), |
|
84 | - 'active' => $active, |
|
85 | - 'icon' => $icon, |
|
86 | - ]; |
|
87 | - } |
|
88 | - } |
|
89 | - return $templateParameters; |
|
90 | - } |
|
91 | - |
|
92 | - protected function formatPersonalSections($currentType, $currentSections) { |
|
93 | - $sections = $this->settingsManager->getPersonalSections(); |
|
94 | - $templateParameters = $this->formatSections($sections, $currentSections, 'personal', $currentType); |
|
95 | - |
|
96 | - return $templateParameters; |
|
97 | - } |
|
98 | - |
|
99 | - protected function formatAdminSections($currentType, $currentSections) { |
|
100 | - $sections = $this->settingsManager->getAdminSections(); |
|
101 | - $templateParameters = $this->formatSections($sections, $currentSections, 'admin', $currentType); |
|
102 | - |
|
103 | - return $templateParameters; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * @param ISettings[] $settings |
|
108 | - * @return array |
|
109 | - */ |
|
110 | - private function formatSettings($settings) { |
|
111 | - $html = ''; |
|
112 | - foreach ($settings as $prioritizedSettings) { |
|
113 | - foreach ($prioritizedSettings as $setting) { |
|
114 | - /** @var \OCP\Settings\ISettings $setting */ |
|
115 | - $form = $setting->getForm(); |
|
116 | - $html .= $form->renderAs('')->render(); |
|
117 | - } |
|
118 | - } |
|
119 | - return ['content' => $html]; |
|
120 | - } |
|
121 | - |
|
122 | - private function getIndexResponse($type, $section) { |
|
123 | - $this->navigationManager->setActiveEntry('settings'); |
|
124 | - $templateParams = []; |
|
125 | - $templateParams = array_merge($templateParams, $this->getNavigationParameters($type, $section)); |
|
126 | - $templateParams = array_merge($templateParams, $this->getSettings($section)); |
|
127 | - |
|
128 | - return new TemplateResponse('settings', 'settings/frame', $templateParams); |
|
129 | - } |
|
130 | - |
|
131 | - abstract protected function getSettings($section); |
|
34 | + /** @var ISettingsManager */ |
|
35 | + private $settingsManager; |
|
36 | + |
|
37 | + /** @var INavigationManager */ |
|
38 | + private $navigationManager; |
|
39 | + |
|
40 | + /** |
|
41 | + * @param string $currentSection |
|
42 | + * @return array |
|
43 | + */ |
|
44 | + private function getNavigationParameters($currentType, $currentSection) { |
|
45 | + $templateParameters = [ |
|
46 | + 'personal' => $this->formatPersonalSections($currentType, $currentSection), |
|
47 | + 'admin' => [] |
|
48 | + ]; |
|
49 | + |
|
50 | + if(\OC_User::isAdminUser(\OC_User::getUser())) { |
|
51 | + $templateParameters['admin'] = $this->formatAdminSections($currentType, $currentSection); |
|
52 | + } |
|
53 | + |
|
54 | + return [ |
|
55 | + 'forms' => $templateParameters |
|
56 | + ]; |
|
57 | + } |
|
58 | + |
|
59 | + protected function formatSections($sections, $currentSection, $type, $currentType) { |
|
60 | + $templateParameters = []; |
|
61 | + /** @var \OCP\Settings\ISection[] $prioritizedSections */ |
|
62 | + foreach($sections as $prioritizedSections) { |
|
63 | + foreach ($prioritizedSections as $section) { |
|
64 | + if($type === 'admin') { |
|
65 | + $settings = $this->settingsManager->getAdminSettings($section->getID()); |
|
66 | + } else if($type === 'personal') { |
|
67 | + $settings = $this->settingsManager->getPersonalSettings($section->getID()); |
|
68 | + } |
|
69 | + if (empty($settings) && !($section->getID() === 'additional' && count(\OC_App::getForms('admin')) > 0)) { |
|
70 | + continue; |
|
71 | + } |
|
72 | + |
|
73 | + $icon = ''; |
|
74 | + if ($section instanceof IIconSection) { |
|
75 | + $icon = $section->getIcon(); |
|
76 | + } |
|
77 | + |
|
78 | + $active = $section->getID() === $currentSection |
|
79 | + && $type === $currentType; |
|
80 | + |
|
81 | + $templateParameters[] = [ |
|
82 | + 'anchor' => $section->getID(), |
|
83 | + 'section-name' => $section->getName(), |
|
84 | + 'active' => $active, |
|
85 | + 'icon' => $icon, |
|
86 | + ]; |
|
87 | + } |
|
88 | + } |
|
89 | + return $templateParameters; |
|
90 | + } |
|
91 | + |
|
92 | + protected function formatPersonalSections($currentType, $currentSections) { |
|
93 | + $sections = $this->settingsManager->getPersonalSections(); |
|
94 | + $templateParameters = $this->formatSections($sections, $currentSections, 'personal', $currentType); |
|
95 | + |
|
96 | + return $templateParameters; |
|
97 | + } |
|
98 | + |
|
99 | + protected function formatAdminSections($currentType, $currentSections) { |
|
100 | + $sections = $this->settingsManager->getAdminSections(); |
|
101 | + $templateParameters = $this->formatSections($sections, $currentSections, 'admin', $currentType); |
|
102 | + |
|
103 | + return $templateParameters; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * @param ISettings[] $settings |
|
108 | + * @return array |
|
109 | + */ |
|
110 | + private function formatSettings($settings) { |
|
111 | + $html = ''; |
|
112 | + foreach ($settings as $prioritizedSettings) { |
|
113 | + foreach ($prioritizedSettings as $setting) { |
|
114 | + /** @var \OCP\Settings\ISettings $setting */ |
|
115 | + $form = $setting->getForm(); |
|
116 | + $html .= $form->renderAs('')->render(); |
|
117 | + } |
|
118 | + } |
|
119 | + return ['content' => $html]; |
|
120 | + } |
|
121 | + |
|
122 | + private function getIndexResponse($type, $section) { |
|
123 | + $this->navigationManager->setActiveEntry('settings'); |
|
124 | + $templateParams = []; |
|
125 | + $templateParams = array_merge($templateParams, $this->getNavigationParameters($type, $section)); |
|
126 | + $templateParams = array_merge($templateParams, $this->getSettings($section)); |
|
127 | + |
|
128 | + return new TemplateResponse('settings', 'settings/frame', $templateParams); |
|
129 | + } |
|
130 | + |
|
131 | + abstract protected function getSettings($section); |
|
132 | 132 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | use OCP\Settings\IIconSection; |
31 | 31 | use OCP\Settings\ISettings; |
32 | 32 | |
33 | -trait CommonSettingsTrait { |
|
33 | +trait CommonSettingsTrait { |
|
34 | 34 | /** @var ISettingsManager */ |
35 | 35 | private $settingsManager; |
36 | 36 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | 'admin' => [] |
48 | 48 | ]; |
49 | 49 | |
50 | - if(\OC_User::isAdminUser(\OC_User::getUser())) { |
|
50 | + if (\OC_User::isAdminUser(\OC_User::getUser())) { |
|
51 | 51 | $templateParameters['admin'] = $this->formatAdminSections($currentType, $currentSection); |
52 | 52 | } |
53 | 53 | |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | protected function formatSections($sections, $currentSection, $type, $currentType) { |
60 | 60 | $templateParameters = []; |
61 | 61 | /** @var \OCP\Settings\ISection[] $prioritizedSections */ |
62 | - foreach($sections as $prioritizedSections) { |
|
62 | + foreach ($sections as $prioritizedSections) { |
|
63 | 63 | foreach ($prioritizedSections as $section) { |
64 | - if($type === 'admin') { |
|
64 | + if ($type === 'admin') { |
|
65 | 65 | $settings = $this->settingsManager->getAdminSettings($section->getID()); |
66 | - } else if($type === 'personal') { |
|
66 | + } else if ($type === 'personal') { |
|
67 | 67 | $settings = $this->settingsManager->getPersonalSettings($section->getID()); |
68 | 68 | } |
69 | 69 | if (empty($settings) && !($section->getID() === 'additional' && count(\OC_App::getForms('admin')) > 0)) { |
@@ -27,10 +27,6 @@ |
||
27 | 27 | namespace OC\Settings\Admin; |
28 | 28 | |
29 | 29 | use Doctrine\DBAL\Connection; |
30 | -use Doctrine\DBAL\DBALException; |
|
31 | -use Doctrine\DBAL\Platforms\SqlitePlatform; |
|
32 | -use OC\Lock\DBLockingProvider; |
|
33 | -use OC\Lock\NoopLockingProvider; |
|
34 | 30 | use OCP\AppFramework\Http\TemplateResponse; |
35 | 31 | use OCP\IConfig; |
36 | 32 | use OCP\IDBConnection; |
@@ -40,67 +40,67 @@ |
||
40 | 40 | use OCP\Settings\ISettings; |
41 | 41 | |
42 | 42 | class Server implements ISettings { |
43 | - /** @var IDBConnection|Connection */ |
|
44 | - private $db; |
|
45 | - /** @var IRequest */ |
|
46 | - private $request; |
|
47 | - /** @var IConfig */ |
|
48 | - private $config; |
|
49 | - /** @var ILockingProvider */ |
|
50 | - private $lockingProvider; |
|
51 | - /** @var IL10N */ |
|
52 | - private $l; |
|
43 | + /** @var IDBConnection|Connection */ |
|
44 | + private $db; |
|
45 | + /** @var IRequest */ |
|
46 | + private $request; |
|
47 | + /** @var IConfig */ |
|
48 | + private $config; |
|
49 | + /** @var ILockingProvider */ |
|
50 | + private $lockingProvider; |
|
51 | + /** @var IL10N */ |
|
52 | + private $l; |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param IDBConnection $db |
|
56 | - * @param IRequest $request |
|
57 | - * @param IConfig $config |
|
58 | - * @param ILockingProvider $lockingProvider |
|
59 | - * @param IL10N $l |
|
60 | - */ |
|
61 | - public function __construct(IDBConnection $db, |
|
62 | - IRequest $request, |
|
63 | - IConfig $config, |
|
64 | - ILockingProvider $lockingProvider, |
|
65 | - IL10N $l) { |
|
66 | - $this->db = $db; |
|
67 | - $this->request = $request; |
|
68 | - $this->config = $config; |
|
69 | - $this->lockingProvider = $lockingProvider; |
|
70 | - $this->l = $l; |
|
71 | - } |
|
54 | + /** |
|
55 | + * @param IDBConnection $db |
|
56 | + * @param IRequest $request |
|
57 | + * @param IConfig $config |
|
58 | + * @param ILockingProvider $lockingProvider |
|
59 | + * @param IL10N $l |
|
60 | + */ |
|
61 | + public function __construct(IDBConnection $db, |
|
62 | + IRequest $request, |
|
63 | + IConfig $config, |
|
64 | + ILockingProvider $lockingProvider, |
|
65 | + IL10N $l) { |
|
66 | + $this->db = $db; |
|
67 | + $this->request = $request; |
|
68 | + $this->config = $config; |
|
69 | + $this->lockingProvider = $lockingProvider; |
|
70 | + $this->l = $l; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @return TemplateResponse |
|
75 | - */ |
|
76 | - public function getForm() { |
|
77 | - $parameters = [ |
|
78 | - // Background jobs |
|
79 | - 'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'), |
|
80 | - 'lastcron' => $this->config->getAppValue('core', 'lastcron', false), |
|
81 | - 'cronErrors' => $this->config->getAppValue('core', 'cronErrors'), |
|
82 | - 'cli_based_cron_possible' => function_exists('posix_getpwuid'), |
|
83 | - 'cli_based_cron_user' => function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir . 'config.php'))['name'] : '', |
|
84 | - ]; |
|
73 | + /** |
|
74 | + * @return TemplateResponse |
|
75 | + */ |
|
76 | + public function getForm() { |
|
77 | + $parameters = [ |
|
78 | + // Background jobs |
|
79 | + 'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'), |
|
80 | + 'lastcron' => $this->config->getAppValue('core', 'lastcron', false), |
|
81 | + 'cronErrors' => $this->config->getAppValue('core', 'cronErrors'), |
|
82 | + 'cli_based_cron_possible' => function_exists('posix_getpwuid'), |
|
83 | + 'cli_based_cron_user' => function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir . 'config.php'))['name'] : '', |
|
84 | + ]; |
|
85 | 85 | |
86 | - return new TemplateResponse('settings', 'settings/admin/server', $parameters, ''); |
|
87 | - } |
|
86 | + return new TemplateResponse('settings', 'settings/admin/server', $parameters, ''); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return string the section ID, e.g. 'sharing' |
|
91 | - */ |
|
92 | - public function getSection() { |
|
93 | - return 'server'; |
|
94 | - } |
|
89 | + /** |
|
90 | + * @return string the section ID, e.g. 'sharing' |
|
91 | + */ |
|
92 | + public function getSection() { |
|
93 | + return 'server'; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @return int whether the form should be rather on the top or bottom of |
|
98 | - * the admin section. The forms are arranged in ascending order of the |
|
99 | - * priority values. It is required to return a value between 0 and 100. |
|
100 | - * |
|
101 | - * E.g.: 70 |
|
102 | - */ |
|
103 | - public function getPriority() { |
|
104 | - return 0; |
|
105 | - } |
|
96 | + /** |
|
97 | + * @return int whether the form should be rather on the top or bottom of |
|
98 | + * the admin section. The forms are arranged in ascending order of the |
|
99 | + * priority values. It is required to return a value between 0 and 100. |
|
100 | + * |
|
101 | + * E.g.: 70 |
|
102 | + */ |
|
103 | + public function getPriority() { |
|
104 | + return 0; |
|
105 | + } |
|
106 | 106 | } |
@@ -80,7 +80,7 @@ |
||
80 | 80 | 'lastcron' => $this->config->getAppValue('core', 'lastcron', false), |
81 | 81 | 'cronErrors' => $this->config->getAppValue('core', 'cronErrors'), |
82 | 82 | 'cli_based_cron_possible' => function_exists('posix_getpwuid'), |
83 | - 'cli_based_cron_user' => function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir . 'config.php'))['name'] : '', |
|
83 | + 'cli_based_cron_user' => function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir.'config.php'))['name'] : '', |
|
84 | 84 | ]; |
85 | 85 | |
86 | 86 | return new TemplateResponse('settings', 'settings/admin/server', $parameters, ''); |
@@ -37,118 +37,118 @@ |
||
37 | 37 | use OCP\Settings\ISettings; |
38 | 38 | |
39 | 39 | class Overview implements ISettings { |
40 | - /** @var IDBConnection|Connection */ |
|
41 | - private $db; |
|
42 | - /** @var IRequest */ |
|
43 | - private $request; |
|
44 | - /** @var IConfig */ |
|
45 | - private $config; |
|
46 | - /** @var ILockingProvider */ |
|
47 | - private $lockingProvider; |
|
48 | - /** @var IL10N */ |
|
49 | - private $l; |
|
40 | + /** @var IDBConnection|Connection */ |
|
41 | + private $db; |
|
42 | + /** @var IRequest */ |
|
43 | + private $request; |
|
44 | + /** @var IConfig */ |
|
45 | + private $config; |
|
46 | + /** @var ILockingProvider */ |
|
47 | + private $lockingProvider; |
|
48 | + /** @var IL10N */ |
|
49 | + private $l; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param IDBConnection $db |
|
53 | - * @param IRequest $request |
|
54 | - * @param IConfig $config |
|
55 | - * @param ILockingProvider $lockingProvider |
|
56 | - * @param IL10N $l |
|
57 | - */ |
|
58 | - public function __construct(IDBConnection $db, |
|
59 | - IRequest $request, |
|
60 | - IConfig $config, |
|
61 | - ILockingProvider $lockingProvider, |
|
62 | - IL10N $l) { |
|
63 | - $this->db = $db; |
|
64 | - $this->request = $request; |
|
65 | - $this->config = $config; |
|
66 | - $this->lockingProvider = $lockingProvider; |
|
67 | - $this->l = $l; |
|
68 | - } |
|
51 | + /** |
|
52 | + * @param IDBConnection $db |
|
53 | + * @param IRequest $request |
|
54 | + * @param IConfig $config |
|
55 | + * @param ILockingProvider $lockingProvider |
|
56 | + * @param IL10N $l |
|
57 | + */ |
|
58 | + public function __construct(IDBConnection $db, |
|
59 | + IRequest $request, |
|
60 | + IConfig $config, |
|
61 | + ILockingProvider $lockingProvider, |
|
62 | + IL10N $l) { |
|
63 | + $this->db = $db; |
|
64 | + $this->request = $request; |
|
65 | + $this->config = $config; |
|
66 | + $this->lockingProvider = $lockingProvider; |
|
67 | + $this->l = $l; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @return TemplateResponse |
|
72 | - */ |
|
73 | - public function getForm() { |
|
74 | - try { |
|
75 | - if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) { |
|
76 | - $invalidTransactionIsolationLevel = false; |
|
77 | - } else { |
|
78 | - $invalidTransactionIsolationLevel = $this->db->getTransactionIsolation() !== Connection::TRANSACTION_READ_COMMITTED; |
|
79 | - } |
|
80 | - } catch (DBALException $e) { |
|
81 | - // ignore |
|
82 | - $invalidTransactionIsolationLevel = false; |
|
83 | - } |
|
70 | + /** |
|
71 | + * @return TemplateResponse |
|
72 | + */ |
|
73 | + public function getForm() { |
|
74 | + try { |
|
75 | + if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) { |
|
76 | + $invalidTransactionIsolationLevel = false; |
|
77 | + } else { |
|
78 | + $invalidTransactionIsolationLevel = $this->db->getTransactionIsolation() !== Connection::TRANSACTION_READ_COMMITTED; |
|
79 | + } |
|
80 | + } catch (DBALException $e) { |
|
81 | + // ignore |
|
82 | + $invalidTransactionIsolationLevel = false; |
|
83 | + } |
|
84 | 84 | |
85 | - $envPath = getenv('PATH'); |
|
85 | + $envPath = getenv('PATH'); |
|
86 | 86 | |
87 | - // warn if outdated version of a memcache module is used |
|
88 | - $caches = [ |
|
89 | - 'apcu' => ['name' => $this->l->t('APCu'), 'version' => '4.0.6'], |
|
90 | - 'redis' => ['name' => $this->l->t('Redis'), 'version' => '2.2.5'], |
|
91 | - ]; |
|
92 | - $outdatedCaches = []; |
|
93 | - foreach ($caches as $php_module => $data) { |
|
94 | - $isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<'); |
|
95 | - if ($isOutdated) { |
|
96 | - $outdatedCaches[$php_module] = $data; |
|
97 | - } |
|
98 | - } |
|
87 | + // warn if outdated version of a memcache module is used |
|
88 | + $caches = [ |
|
89 | + 'apcu' => ['name' => $this->l->t('APCu'), 'version' => '4.0.6'], |
|
90 | + 'redis' => ['name' => $this->l->t('Redis'), 'version' => '2.2.5'], |
|
91 | + ]; |
|
92 | + $outdatedCaches = []; |
|
93 | + foreach ($caches as $php_module => $data) { |
|
94 | + $isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<'); |
|
95 | + if ($isOutdated) { |
|
96 | + $outdatedCaches[$php_module] = $data; |
|
97 | + } |
|
98 | + } |
|
99 | 99 | |
100 | - if ($this->lockingProvider instanceof NoopLockingProvider) { |
|
101 | - $fileLockingType = 'none'; |
|
102 | - } else if ($this->lockingProvider instanceof DBLockingProvider) { |
|
103 | - $fileLockingType = 'db'; |
|
104 | - } else { |
|
105 | - $fileLockingType = 'cache'; |
|
106 | - } |
|
100 | + if ($this->lockingProvider instanceof NoopLockingProvider) { |
|
101 | + $fileLockingType = 'none'; |
|
102 | + } else if ($this->lockingProvider instanceof DBLockingProvider) { |
|
103 | + $fileLockingType = 'db'; |
|
104 | + } else { |
|
105 | + $fileLockingType = 'cache'; |
|
106 | + } |
|
107 | 107 | |
108 | - $suggestedOverwriteCliUrl = ''; |
|
109 | - if ($this->config->getSystemValue('overwrite.cli.url', '') === '') { |
|
110 | - $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT; |
|
111 | - if (!$this->config->getSystemValue('config_is_read_only', false)) { |
|
112 | - // Set the overwrite URL when it was not set yet. |
|
113 | - $this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl); |
|
114 | - $suggestedOverwriteCliUrl = ''; |
|
115 | - } |
|
116 | - } |
|
108 | + $suggestedOverwriteCliUrl = ''; |
|
109 | + if ($this->config->getSystemValue('overwrite.cli.url', '') === '') { |
|
110 | + $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT; |
|
111 | + if (!$this->config->getSystemValue('config_is_read_only', false)) { |
|
112 | + // Set the overwrite URL when it was not set yet. |
|
113 | + $this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl); |
|
114 | + $suggestedOverwriteCliUrl = ''; |
|
115 | + } |
|
116 | + } |
|
117 | 117 | |
118 | - $parameters = [ |
|
119 | - // Diagnosis |
|
120 | - 'readOnlyConfigEnabled' => \OC_Helper::isReadOnlyConfigEnabled(), |
|
121 | - 'isLocaleWorking' => \OC_Util::isSetLocaleWorking(), |
|
122 | - 'isAnnotationsWorking' => \OC_Util::isAnnotationsWorking(), |
|
123 | - 'checkForWorkingWellKnownSetup' => $this->config->getSystemValue('check_for_working_wellknown_setup', true), |
|
124 | - 'has_fileinfo' => \OC_Util::fileInfoLoaded(), |
|
125 | - 'invalidTransactionIsolationLevel' => $invalidTransactionIsolationLevel, |
|
126 | - 'getenvServerNotWorking' => empty($envPath), |
|
127 | - 'OutdatedCacheWarning' => $outdatedCaches, |
|
128 | - 'fileLockingType' => $fileLockingType, |
|
129 | - 'suggestedOverwriteCliUrl' => $suggestedOverwriteCliUrl, |
|
130 | - 'lastcron' => $this->config->getAppValue('core', 'lastcron', false), |
|
131 | - 'cronErrors' => $this->config->getAppValue('core', 'cronErrors'), |
|
132 | - ]; |
|
118 | + $parameters = [ |
|
119 | + // Diagnosis |
|
120 | + 'readOnlyConfigEnabled' => \OC_Helper::isReadOnlyConfigEnabled(), |
|
121 | + 'isLocaleWorking' => \OC_Util::isSetLocaleWorking(), |
|
122 | + 'isAnnotationsWorking' => \OC_Util::isAnnotationsWorking(), |
|
123 | + 'checkForWorkingWellKnownSetup' => $this->config->getSystemValue('check_for_working_wellknown_setup', true), |
|
124 | + 'has_fileinfo' => \OC_Util::fileInfoLoaded(), |
|
125 | + 'invalidTransactionIsolationLevel' => $invalidTransactionIsolationLevel, |
|
126 | + 'getenvServerNotWorking' => empty($envPath), |
|
127 | + 'OutdatedCacheWarning' => $outdatedCaches, |
|
128 | + 'fileLockingType' => $fileLockingType, |
|
129 | + 'suggestedOverwriteCliUrl' => $suggestedOverwriteCliUrl, |
|
130 | + 'lastcron' => $this->config->getAppValue('core', 'lastcron', false), |
|
131 | + 'cronErrors' => $this->config->getAppValue('core', 'cronErrors'), |
|
132 | + ]; |
|
133 | 133 | |
134 | - return new TemplateResponse('settings', 'settings/admin/overview', $parameters, ''); |
|
135 | - } |
|
134 | + return new TemplateResponse('settings', 'settings/admin/overview', $parameters, ''); |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * @return string the section ID, e.g. 'sharing' |
|
139 | - */ |
|
140 | - public function getSection() { |
|
141 | - return 'overview'; |
|
142 | - } |
|
137 | + /** |
|
138 | + * @return string the section ID, e.g. 'sharing' |
|
139 | + */ |
|
140 | + public function getSection() { |
|
141 | + return 'overview'; |
|
142 | + } |
|
143 | 143 | |
144 | - /** |
|
145 | - * @return int whether the form should be rather on the top or bottom of |
|
146 | - * the admin section. The forms are arranged in ascending order of the |
|
147 | - * priority values. It is required to return a value between 0 and 100. |
|
148 | - * |
|
149 | - * E.g.: 70 |
|
150 | - */ |
|
151 | - public function getPriority() { |
|
152 | - return 10; |
|
153 | - } |
|
144 | + /** |
|
145 | + * @return int whether the form should be rather on the top or bottom of |
|
146 | + * the admin section. The forms are arranged in ascending order of the |
|
147 | + * priority values. It is required to return a value between 0 and 100. |
|
148 | + * |
|
149 | + * E.g.: 70 |
|
150 | + */ |
|
151 | + public function getPriority() { |
|
152 | + return 10; |
|
153 | + } |
|
154 | 154 | } |
@@ -107,7 +107,7 @@ |
||
107 | 107 | |
108 | 108 | $suggestedOverwriteCliUrl = ''; |
109 | 109 | if ($this->config->getSystemValue('overwrite.cli.url', '') === '') { |
110 | - $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT; |
|
110 | + $suggestedOverwriteCliUrl = $this->request->getServerProtocol().'://'.$this->request->getInsecureServerHost().\OC::$WEBROOT; |
|
111 | 111 | if (!$this->config->getSystemValue('config_is_read_only', false)) { |
112 | 112 | // Set the overwrite URL when it was not set yet. |
113 | 113 | $this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl); |
@@ -58,34 +58,34 @@ |
||
58 | 58 | |
59 | 59 | class AdminOverview extends Admin { |
60 | 60 | |
61 | - /** |
|
62 | - * @return TemplateResponse |
|
63 | - */ |
|
64 | - public function getForm(): TemplateResponse { |
|
65 | - $params = [ |
|
66 | - 'json' => json_encode($this->getFormParams(false)), |
|
67 | - 'withSettings' => false, |
|
68 | - ]; |
|
61 | + /** |
|
62 | + * @return TemplateResponse |
|
63 | + */ |
|
64 | + public function getForm(): TemplateResponse { |
|
65 | + $params = [ |
|
66 | + 'json' => json_encode($this->getFormParams(false)), |
|
67 | + 'withSettings' => false, |
|
68 | + ]; |
|
69 | 69 | |
70 | - return new TemplateResponse('updatenotification', 'admin', $params, ''); |
|
70 | + return new TemplateResponse('updatenotification', 'admin', $params, ''); |
|
71 | 71 | |
72 | - } |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return string the section ID, e.g. 'sharing' |
|
76 | - */ |
|
77 | - public function getSection(): string { |
|
78 | - return 'overview'; |
|
79 | - } |
|
74 | + /** |
|
75 | + * @return string the section ID, e.g. 'sharing' |
|
76 | + */ |
|
77 | + public function getSection(): string { |
|
78 | + return 'overview'; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @return int whether the form should be rather on the top or bottom of |
|
83 | - * the admin section. The forms are arranged in ascending order of the |
|
84 | - * priority values. It is required to return a value between 0 and 100. |
|
85 | - * |
|
86 | - * E.g.: 70 |
|
87 | - */ |
|
88 | - public function getPriority(): int { |
|
89 | - return 50; |
|
90 | - } |
|
81 | + /** |
|
82 | + * @return int whether the form should be rather on the top or bottom of |
|
83 | + * the admin section. The forms are arranged in ascending order of the |
|
84 | + * priority values. It is required to return a value between 0 and 100. |
|
85 | + * |
|
86 | + * E.g.: 70 |
|
87 | + */ |
|
88 | + public function getPriority(): int { |
|
89 | + return 50; |
|
90 | + } |
|
91 | 91 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | * |
22 | 22 | */ |
23 | 23 | |
24 | -declare(strict_types=1); |
|
24 | +declare(strict_types = 1); |
|
25 | 25 | /** |
26 | 26 | * @copyright Copyright (c) 2016, ownCloud, Inc. |
27 | 27 | * |
@@ -35,116 +35,116 @@ |
||
35 | 35 | use OCP\Util; |
36 | 36 | |
37 | 37 | class Admin implements ISettings { |
38 | - /** @var IConfig */ |
|
39 | - private $config; |
|
40 | - /** @var UpdateChecker */ |
|
41 | - private $updateChecker; |
|
42 | - /** @var IGroupManager */ |
|
43 | - private $groupManager; |
|
44 | - /** @var IDateTimeFormatter */ |
|
45 | - private $dateTimeFormatter; |
|
46 | - |
|
47 | - /** |
|
48 | - * @param IConfig $config |
|
49 | - * @param UpdateChecker $updateChecker |
|
50 | - * @param IGroupManager $groupManager |
|
51 | - * @param IDateTimeFormatter $dateTimeFormatter |
|
52 | - */ |
|
53 | - public function __construct(IConfig $config, |
|
54 | - UpdateChecker $updateChecker, |
|
55 | - IGroupManager $groupManager, |
|
56 | - IDateTimeFormatter $dateTimeFormatter) { |
|
57 | - $this->config = $config; |
|
58 | - $this->updateChecker = $updateChecker; |
|
59 | - $this->groupManager = $groupManager; |
|
60 | - $this->dateTimeFormatter = $dateTimeFormatter; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * @return TemplateResponse |
|
65 | - */ |
|
66 | - public function getForm(): TemplateResponse { |
|
67 | - $params = [ |
|
68 | - 'json' => json_encode($this->getFormParams(true)), |
|
69 | - 'withSettings' => true, |
|
70 | - ]; |
|
71 | - |
|
72 | - return new TemplateResponse('updatenotification', 'admin', $params, ''); |
|
73 | - } |
|
74 | - |
|
75 | - protected function getFormParams($withSettings = true): array { |
|
76 | - $lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat'); |
|
77 | - $lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp); |
|
78 | - |
|
79 | - $channels = [ |
|
80 | - 'daily', |
|
81 | - 'beta', |
|
82 | - 'stable', |
|
83 | - 'production', |
|
84 | - ]; |
|
85 | - $currentChannel = Util::getChannel(); |
|
86 | - if ($currentChannel === 'git') { |
|
87 | - $channels[] = 'git'; |
|
88 | - } |
|
89 | - |
|
90 | - $updateState = $this->updateChecker->getUpdateState(); |
|
91 | - |
|
92 | - $notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true); |
|
93 | - |
|
94 | - $defaultUpdateServerURL = 'https://updates.nextcloud.com/updater_server/'; |
|
95 | - $updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL); |
|
96 | - |
|
97 | - return [ |
|
98 | - 'isNewVersionAvailable' => !empty($updateState['updateAvailable']), |
|
99 | - 'isUpdateChecked' => $lastUpdateCheckTimestamp > 0, |
|
100 | - 'lastChecked' => $lastUpdateCheck, |
|
101 | - 'currentChannel' => $currentChannel, |
|
102 | - 'channels' => $channels, |
|
103 | - 'newVersionString' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'], |
|
104 | - 'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'], |
|
105 | - 'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'], |
|
106 | - 'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'], |
|
107 | - 'isDefaultUpdateServerURL' => $updateServerURL === $defaultUpdateServerURL, |
|
108 | - 'updateServerURL' => $updateServerURL, |
|
109 | - 'notifyGroups' => $this->getSelectedGroups($notifyGroups), |
|
110 | - 'withSettings' => $withSettings, |
|
111 | - ]; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * @param array $groupIds |
|
116 | - * @return array |
|
117 | - */ |
|
118 | - protected function getSelectedGroups(array $groupIds): array { |
|
119 | - $result = []; |
|
120 | - foreach ($groupIds as $groupId) { |
|
121 | - $group = $this->groupManager->get($groupId); |
|
122 | - |
|
123 | - if ($group === null) { |
|
124 | - continue; |
|
125 | - } |
|
126 | - |
|
127 | - $result[] = ['value' => $group->getGID(), 'label' => $group->getDisplayName()]; |
|
128 | - } |
|
129 | - |
|
130 | - return $result; |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * @return string the section ID, e.g. 'sharing' |
|
135 | - */ |
|
136 | - public function getSection(): string { |
|
137 | - return 'server'; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * @return int whether the form should be rather on the top or bottom of |
|
142 | - * the admin section. The forms are arranged in ascending order of the |
|
143 | - * priority values. It is required to return a value between 0 and 100. |
|
144 | - * |
|
145 | - * E.g.: 70 |
|
146 | - */ |
|
147 | - public function getPriority(): int { |
|
148 | - return 90; |
|
149 | - } |
|
38 | + /** @var IConfig */ |
|
39 | + private $config; |
|
40 | + /** @var UpdateChecker */ |
|
41 | + private $updateChecker; |
|
42 | + /** @var IGroupManager */ |
|
43 | + private $groupManager; |
|
44 | + /** @var IDateTimeFormatter */ |
|
45 | + private $dateTimeFormatter; |
|
46 | + |
|
47 | + /** |
|
48 | + * @param IConfig $config |
|
49 | + * @param UpdateChecker $updateChecker |
|
50 | + * @param IGroupManager $groupManager |
|
51 | + * @param IDateTimeFormatter $dateTimeFormatter |
|
52 | + */ |
|
53 | + public function __construct(IConfig $config, |
|
54 | + UpdateChecker $updateChecker, |
|
55 | + IGroupManager $groupManager, |
|
56 | + IDateTimeFormatter $dateTimeFormatter) { |
|
57 | + $this->config = $config; |
|
58 | + $this->updateChecker = $updateChecker; |
|
59 | + $this->groupManager = $groupManager; |
|
60 | + $this->dateTimeFormatter = $dateTimeFormatter; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * @return TemplateResponse |
|
65 | + */ |
|
66 | + public function getForm(): TemplateResponse { |
|
67 | + $params = [ |
|
68 | + 'json' => json_encode($this->getFormParams(true)), |
|
69 | + 'withSettings' => true, |
|
70 | + ]; |
|
71 | + |
|
72 | + return new TemplateResponse('updatenotification', 'admin', $params, ''); |
|
73 | + } |
|
74 | + |
|
75 | + protected function getFormParams($withSettings = true): array { |
|
76 | + $lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat'); |
|
77 | + $lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp); |
|
78 | + |
|
79 | + $channels = [ |
|
80 | + 'daily', |
|
81 | + 'beta', |
|
82 | + 'stable', |
|
83 | + 'production', |
|
84 | + ]; |
|
85 | + $currentChannel = Util::getChannel(); |
|
86 | + if ($currentChannel === 'git') { |
|
87 | + $channels[] = 'git'; |
|
88 | + } |
|
89 | + |
|
90 | + $updateState = $this->updateChecker->getUpdateState(); |
|
91 | + |
|
92 | + $notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true); |
|
93 | + |
|
94 | + $defaultUpdateServerURL = 'https://updates.nextcloud.com/updater_server/'; |
|
95 | + $updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL); |
|
96 | + |
|
97 | + return [ |
|
98 | + 'isNewVersionAvailable' => !empty($updateState['updateAvailable']), |
|
99 | + 'isUpdateChecked' => $lastUpdateCheckTimestamp > 0, |
|
100 | + 'lastChecked' => $lastUpdateCheck, |
|
101 | + 'currentChannel' => $currentChannel, |
|
102 | + 'channels' => $channels, |
|
103 | + 'newVersionString' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'], |
|
104 | + 'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'], |
|
105 | + 'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'], |
|
106 | + 'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'], |
|
107 | + 'isDefaultUpdateServerURL' => $updateServerURL === $defaultUpdateServerURL, |
|
108 | + 'updateServerURL' => $updateServerURL, |
|
109 | + 'notifyGroups' => $this->getSelectedGroups($notifyGroups), |
|
110 | + 'withSettings' => $withSettings, |
|
111 | + ]; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * @param array $groupIds |
|
116 | + * @return array |
|
117 | + */ |
|
118 | + protected function getSelectedGroups(array $groupIds): array { |
|
119 | + $result = []; |
|
120 | + foreach ($groupIds as $groupId) { |
|
121 | + $group = $this->groupManager->get($groupId); |
|
122 | + |
|
123 | + if ($group === null) { |
|
124 | + continue; |
|
125 | + } |
|
126 | + |
|
127 | + $result[] = ['value' => $group->getGID(), 'label' => $group->getDisplayName()]; |
|
128 | + } |
|
129 | + |
|
130 | + return $result; |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * @return string the section ID, e.g. 'sharing' |
|
135 | + */ |
|
136 | + public function getSection(): string { |
|
137 | + return 'server'; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * @return int whether the form should be rather on the top or bottom of |
|
142 | + * the admin section. The forms are arranged in ascending order of the |
|
143 | + * priority values. It is required to return a value between 0 and 100. |
|
144 | + * |
|
145 | + * E.g.: 70 |
|
146 | + */ |
|
147 | + public function getPriority(): int { |
|
148 | + return 90; |
|
149 | + } |
|
150 | 150 | } |