Passed
Push — master ( 0c701c...192cf1 )
by Morris
36:10 queued 12s
created
apps/updatenotification/lib/Settings/Admin.php 1 patch
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -39,147 +39,147 @@
 block discarded – undo
39 39
 use OCP\Util;
40 40
 
41 41
 class Admin implements ISettings {
42
-	/** @var IConfig */
43
-	private $config;
44
-	/** @var UpdateChecker */
45
-	private $updateChecker;
46
-	/** @var IGroupManager */
47
-	private $groupManager;
48
-	/** @var IDateTimeFormatter */
49
-	private $dateTimeFormatter;
50
-	/** @var IFactory */
51
-	private $l10nFactory;
52
-	/** @var IRegistry */
53
-	private $subscriptionRegistry;
54
-
55
-	public function __construct(
56
-		IConfig $config,
57
-		UpdateChecker $updateChecker,
58
-		IGroupManager $groupManager,
59
-		IDateTimeFormatter $dateTimeFormatter,
60
-		IFactory $l10nFactory,
61
-		IRegistry $subscriptionRegistry
62
-	) {
63
-		$this->config = $config;
64
-		$this->updateChecker = $updateChecker;
65
-		$this->groupManager = $groupManager;
66
-		$this->dateTimeFormatter = $dateTimeFormatter;
67
-		$this->l10nFactory = $l10nFactory;
68
-		$this->subscriptionRegistry = $subscriptionRegistry;
69
-	}
70
-
71
-	/**
72
-	 * @return TemplateResponse
73
-	 */
74
-	public function getForm(): TemplateResponse {
75
-		$lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat');
76
-		$lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp);
77
-
78
-		$channels = [
79
-			'daily',
80
-			'beta',
81
-			'stable',
82
-			'production',
83
-		];
84
-		$currentChannel = Util::getChannel();
85
-		if ($currentChannel === 'git') {
86
-			$channels[] = 'git';
87
-		}
88
-
89
-		$updateState = $this->updateChecker->getUpdateState();
90
-
91
-		$notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true);
92
-
93
-		$defaultUpdateServerURL = 'https://updates.nextcloud.com/updater_server/';
94
-		$updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL);
95
-		$defaultCustomerUpdateServerURLPrefix = 'https://updates.nextcloud.com/customers/';
96
-
97
-		$isDefaultUpdateServerURL = $updateServerURL === $defaultUpdateServerURL
98
-			|| strpos($updateServerURL, $defaultCustomerUpdateServerURLPrefix) === 0;
99
-
100
-		$hasValidSubscription = $this->subscriptionRegistry->delegateHasValidSubscription();
101
-
102
-		$params = [
103
-			'isNewVersionAvailable' => !empty($updateState['updateAvailable']),
104
-			'isUpdateChecked' => $lastUpdateCheckTimestamp > 0,
105
-			'lastChecked' => $lastUpdateCheck,
106
-			'currentChannel' => $currentChannel,
107
-			'channels' => $channels,
108
-			'newVersion' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'],
109
-			'newVersionString' => empty($updateState['updateVersionString']) ? '' : $updateState['updateVersionString'],
110
-			'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'],
111
-			'changes' => $this->filterChanges($updateState['changes'] ?? []),
112
-			'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'],
113
-			'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'],
114
-			'isDefaultUpdateServerURL' => $isDefaultUpdateServerURL,
115
-			'updateServerURL' => $updateServerURL,
116
-			'notifyGroups' => $this->getSelectedGroups($notifyGroups),
117
-			'hasValidSubscription' => $hasValidSubscription,
118
-		];
119
-
120
-		$params = [
121
-			'json' => json_encode($params),
122
-		];
123
-
124
-		return new TemplateResponse('updatenotification', 'admin', $params, '');
125
-	}
126
-
127
-	protected function filterChanges(array $changes): array {
128
-		$filtered = [];
129
-		if (isset($changes['changelogURL'])) {
130
-			$filtered['changelogURL'] = $changes['changelogURL'];
131
-		}
132
-		if (!isset($changes['whatsNew'])) {
133
-			return $filtered;
134
-		}
135
-
136
-		$iterator = $this->l10nFactory->getLanguageIterator();
137
-		do {
138
-			$lang = $iterator->current();
139
-			if (isset($changes['whatsNew'][$lang])) {
140
-				$filtered['whatsNew'] = $changes['whatsNew'][$lang];
141
-				return $filtered;
142
-			}
143
-			$iterator->next();
144
-		} while ($lang !== 'en' && $iterator->valid());
145
-
146
-		return $filtered;
147
-	}
148
-
149
-	/**
150
-	 * @param array $groupIds
151
-	 * @return array
152
-	 */
153
-	protected function getSelectedGroups(array $groupIds): array {
154
-		$result = [];
155
-		foreach ($groupIds as $groupId) {
156
-			$group = $this->groupManager->get($groupId);
157
-
158
-			if ($group === null) {
159
-				continue;
160
-			}
161
-
162
-			$result[] = ['value' => $group->getGID(), 'label' => $group->getDisplayName()];
163
-		}
164
-
165
-		return $result;
166
-	}
167
-
168
-	/**
169
-	 * @return string the section ID, e.g. 'sharing'
170
-	 */
171
-	public function getSection(): string {
172
-		return 'overview';
173
-	}
174
-
175
-	/**
176
-	 * @return int whether the form should be rather on the top or bottom of
177
-	 * the admin section. The forms are arranged in ascending order of the
178
-	 * priority values. It is required to return a value between 0 and 100.
179
-	 *
180
-	 * E.g.: 70
181
-	 */
182
-	public function getPriority(): int {
183
-		return 11;
184
-	}
42
+    /** @var IConfig */
43
+    private $config;
44
+    /** @var UpdateChecker */
45
+    private $updateChecker;
46
+    /** @var IGroupManager */
47
+    private $groupManager;
48
+    /** @var IDateTimeFormatter */
49
+    private $dateTimeFormatter;
50
+    /** @var IFactory */
51
+    private $l10nFactory;
52
+    /** @var IRegistry */
53
+    private $subscriptionRegistry;
54
+
55
+    public function __construct(
56
+        IConfig $config,
57
+        UpdateChecker $updateChecker,
58
+        IGroupManager $groupManager,
59
+        IDateTimeFormatter $dateTimeFormatter,
60
+        IFactory $l10nFactory,
61
+        IRegistry $subscriptionRegistry
62
+    ) {
63
+        $this->config = $config;
64
+        $this->updateChecker = $updateChecker;
65
+        $this->groupManager = $groupManager;
66
+        $this->dateTimeFormatter = $dateTimeFormatter;
67
+        $this->l10nFactory = $l10nFactory;
68
+        $this->subscriptionRegistry = $subscriptionRegistry;
69
+    }
70
+
71
+    /**
72
+     * @return TemplateResponse
73
+     */
74
+    public function getForm(): TemplateResponse {
75
+        $lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat');
76
+        $lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp);
77
+
78
+        $channels = [
79
+            'daily',
80
+            'beta',
81
+            'stable',
82
+            'production',
83
+        ];
84
+        $currentChannel = Util::getChannel();
85
+        if ($currentChannel === 'git') {
86
+            $channels[] = 'git';
87
+        }
88
+
89
+        $updateState = $this->updateChecker->getUpdateState();
90
+
91
+        $notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true);
92
+
93
+        $defaultUpdateServerURL = 'https://updates.nextcloud.com/updater_server/';
94
+        $updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL);
95
+        $defaultCustomerUpdateServerURLPrefix = 'https://updates.nextcloud.com/customers/';
96
+
97
+        $isDefaultUpdateServerURL = $updateServerURL === $defaultUpdateServerURL
98
+            || strpos($updateServerURL, $defaultCustomerUpdateServerURLPrefix) === 0;
99
+
100
+        $hasValidSubscription = $this->subscriptionRegistry->delegateHasValidSubscription();
101
+
102
+        $params = [
103
+            'isNewVersionAvailable' => !empty($updateState['updateAvailable']),
104
+            'isUpdateChecked' => $lastUpdateCheckTimestamp > 0,
105
+            'lastChecked' => $lastUpdateCheck,
106
+            'currentChannel' => $currentChannel,
107
+            'channels' => $channels,
108
+            'newVersion' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'],
109
+            'newVersionString' => empty($updateState['updateVersionString']) ? '' : $updateState['updateVersionString'],
110
+            'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'],
111
+            'changes' => $this->filterChanges($updateState['changes'] ?? []),
112
+            'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'],
113
+            'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'],
114
+            'isDefaultUpdateServerURL' => $isDefaultUpdateServerURL,
115
+            'updateServerURL' => $updateServerURL,
116
+            'notifyGroups' => $this->getSelectedGroups($notifyGroups),
117
+            'hasValidSubscription' => $hasValidSubscription,
118
+        ];
119
+
120
+        $params = [
121
+            'json' => json_encode($params),
122
+        ];
123
+
124
+        return new TemplateResponse('updatenotification', 'admin', $params, '');
125
+    }
126
+
127
+    protected function filterChanges(array $changes): array {
128
+        $filtered = [];
129
+        if (isset($changes['changelogURL'])) {
130
+            $filtered['changelogURL'] = $changes['changelogURL'];
131
+        }
132
+        if (!isset($changes['whatsNew'])) {
133
+            return $filtered;
134
+        }
135
+
136
+        $iterator = $this->l10nFactory->getLanguageIterator();
137
+        do {
138
+            $lang = $iterator->current();
139
+            if (isset($changes['whatsNew'][$lang])) {
140
+                $filtered['whatsNew'] = $changes['whatsNew'][$lang];
141
+                return $filtered;
142
+            }
143
+            $iterator->next();
144
+        } while ($lang !== 'en' && $iterator->valid());
145
+
146
+        return $filtered;
147
+    }
148
+
149
+    /**
150
+     * @param array $groupIds
151
+     * @return array
152
+     */
153
+    protected function getSelectedGroups(array $groupIds): array {
154
+        $result = [];
155
+        foreach ($groupIds as $groupId) {
156
+            $group = $this->groupManager->get($groupId);
157
+
158
+            if ($group === null) {
159
+                continue;
160
+            }
161
+
162
+            $result[] = ['value' => $group->getGID(), 'label' => $group->getDisplayName()];
163
+        }
164
+
165
+        return $result;
166
+    }
167
+
168
+    /**
169
+     * @return string the section ID, e.g. 'sharing'
170
+     */
171
+    public function getSection(): string {
172
+        return 'overview';
173
+    }
174
+
175
+    /**
176
+     * @return int whether the form should be rather on the top or bottom of
177
+     * the admin section. The forms are arranged in ascending order of the
178
+     * priority values. It is required to return a value between 0 and 100.
179
+     *
180
+     * E.g.: 70
181
+     */
182
+    public function getPriority(): int {
183
+        return 11;
184
+    }
185 185
 }
Please login to merge, or discard this patch.