Completed
Pull Request — master (#9029)
by Julius
33:15 queued 18:20
created
apps/updatenotification/lib/Settings/Admin.php 1 patch
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -35,116 +35,116 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.