Passed
Push — master ( 13e0a9...79e0b5 )
by Morris
09:24
created
lib/private/Repair.php 1 patch
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -62,176 +62,176 @@
 block discarded – undo
62 62
 
63 63
 class Repair implements IOutput {
64 64
 
65
-	/** @var IRepairStep[] */
66
-	private $repairSteps;
67
-
68
-	/** @var EventDispatcherInterface */
69
-	private $dispatcher;
70
-
71
-	/** @var string */
72
-	private $currentStep;
73
-
74
-	/**
75
-	 * Creates a new repair step runner
76
-	 *
77
-	 * @param IRepairStep[] $repairSteps array of RepairStep instances
78
-	 * @param EventDispatcherInterface $dispatcher
79
-	 */
80
-	public function __construct(array $repairSteps, EventDispatcherInterface $dispatcher) {
81
-		$this->repairSteps = $repairSteps;
82
-		$this->dispatcher  = $dispatcher;
83
-	}
84
-
85
-	/**
86
-	 * Run a series of repair steps for common problems
87
-	 */
88
-	public function run() {
89
-		if (count($this->repairSteps) === 0) {
90
-			$this->emit('\OC\Repair', 'info', array('No repair steps available'));
91
-
92
-			return;
93
-		}
94
-		// run each repair step
95
-		foreach ($this->repairSteps as $step) {
96
-			$this->currentStep = $step->getName();
97
-			$this->emit('\OC\Repair', 'step', [$this->currentStep]);
98
-			$step->run($this);
99
-		}
100
-	}
101
-
102
-	/**
103
-	 * Add repair step
104
-	 *
105
-	 * @param IRepairStep|string $repairStep repair step
106
-	 * @throws \Exception
107
-	 */
108
-	public function addStep($repairStep) {
109
-		if (is_string($repairStep)) {
110
-			try {
111
-				$s = \OC::$server->query($repairStep);
112
-			} catch (QueryException $e) {
113
-				if (class_exists($repairStep)) {
114
-					$s = new $repairStep();
115
-				} else {
116
-					throw new \Exception("Repair step '$repairStep' is unknown");
117
-				}
118
-			}
119
-
120
-			if ($s instanceof IRepairStep) {
121
-				$this->repairSteps[] = $s;
122
-			} else {
123
-				throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
124
-			}
125
-		} else {
126
-			$this->repairSteps[] = $repairStep;
127
-		}
128
-	}
129
-
130
-	/**
131
-	 * Returns the default repair steps to be run on the
132
-	 * command line or after an upgrade.
133
-	 *
134
-	 * @return IRepairStep[]
135
-	 */
136
-	public static function getRepairSteps() {
137
-		return [
138
-			new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false),
139
-			new RepairMimeTypes(\OC::$server->getConfig()),
140
-			new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
141
-			new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
142
-			new MoveUpdaterStepFile(\OC::$server->getConfig()),
143
-			new FixMountStorages(\OC::$server->getDatabaseConnection()),
144
-			new AddLogRotateJob(\OC::$server->getJobList()),
145
-			new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OC::$server->query(SCSSCacher::class), \OC::$server->query(JSCombiner::class)),
146
-			new ClearGeneratedAvatarCache(\OC::$server->getConfig(), \OC::$server->query(AvatarManager::class)),
147
-			new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()),
148
-			new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()),
149
-			new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->getLogger()),
150
-			new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()),
151
-			new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)),
152
-			\OC::$server->query(RemoveCypressFiles::class),
153
-			\OC::$server->query(SwitchUpdateChannel::class),
154
-		];
155
-	}
156
-
157
-	/**
158
-	 * Returns expensive repair steps to be run on the
159
-	 * command line with a special option.
160
-	 *
161
-	 * @return IRepairStep[]
162
-	 */
163
-	public static function getExpensiveRepairSteps() {
164
-		return [
165
-			new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager())
166
-		];
167
-	}
168
-
169
-	/**
170
-	 * Returns the repair steps to be run before an
171
-	 * upgrade.
172
-	 *
173
-	 * @return IRepairStep[]
174
-	 */
175
-	public static function getBeforeUpgradeRepairSteps() {
176
-		$connection = \OC::$server->getDatabaseConnection();
177
-		$config     = \OC::$server->getConfig();
178
-		$steps      = [
179
-			new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true),
180
-			new SqliteAutoincrement($connection),
181
-			new SaveAccountsTableData($connection, $config),
182
-			new DropAccountTermsTable($connection)
183
-		];
184
-
185
-		return $steps;
186
-	}
187
-
188
-	/**
189
-	 * @param string $scope
190
-	 * @param string $method
191
-	 * @param array $arguments
192
-	 */
193
-	public function emit($scope, $method, array $arguments = []) {
194
-		if (!is_null($this->dispatcher)) {
195
-			$this->dispatcher->dispatch("$scope::$method",
196
-				new GenericEvent("$scope::$method", $arguments));
197
-		}
198
-	}
199
-
200
-	public function info($string) {
201
-		// for now just emit as we did in the past
202
-		$this->emit('\OC\Repair', 'info', array($string));
203
-	}
204
-
205
-	/**
206
-	 * @param string $message
207
-	 */
208
-	public function warning($message) {
209
-		// for now just emit as we did in the past
210
-		$this->emit('\OC\Repair', 'warning', [$message]);
211
-	}
212
-
213
-	/**
214
-	 * @param int $max
215
-	 */
216
-	public function startProgress($max = 0) {
217
-		// for now just emit as we did in the past
218
-		$this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]);
219
-	}
220
-
221
-	/**
222
-	 * @param int $step
223
-	 * @param string $description
224
-	 */
225
-	public function advance($step = 1, $description = '') {
226
-		// for now just emit as we did in the past
227
-		$this->emit('\OC\Repair', 'advance', [$step, $description]);
228
-	}
229
-
230
-	/**
231
-	 * @param int $max
232
-	 */
233
-	public function finishProgress() {
234
-		// for now just emit as we did in the past
235
-		$this->emit('\OC\Repair', 'finishProgress', []);
236
-	}
65
+    /** @var IRepairStep[] */
66
+    private $repairSteps;
67
+
68
+    /** @var EventDispatcherInterface */
69
+    private $dispatcher;
70
+
71
+    /** @var string */
72
+    private $currentStep;
73
+
74
+    /**
75
+     * Creates a new repair step runner
76
+     *
77
+     * @param IRepairStep[] $repairSteps array of RepairStep instances
78
+     * @param EventDispatcherInterface $dispatcher
79
+     */
80
+    public function __construct(array $repairSteps, EventDispatcherInterface $dispatcher) {
81
+        $this->repairSteps = $repairSteps;
82
+        $this->dispatcher  = $dispatcher;
83
+    }
84
+
85
+    /**
86
+     * Run a series of repair steps for common problems
87
+     */
88
+    public function run() {
89
+        if (count($this->repairSteps) === 0) {
90
+            $this->emit('\OC\Repair', 'info', array('No repair steps available'));
91
+
92
+            return;
93
+        }
94
+        // run each repair step
95
+        foreach ($this->repairSteps as $step) {
96
+            $this->currentStep = $step->getName();
97
+            $this->emit('\OC\Repair', 'step', [$this->currentStep]);
98
+            $step->run($this);
99
+        }
100
+    }
101
+
102
+    /**
103
+     * Add repair step
104
+     *
105
+     * @param IRepairStep|string $repairStep repair step
106
+     * @throws \Exception
107
+     */
108
+    public function addStep($repairStep) {
109
+        if (is_string($repairStep)) {
110
+            try {
111
+                $s = \OC::$server->query($repairStep);
112
+            } catch (QueryException $e) {
113
+                if (class_exists($repairStep)) {
114
+                    $s = new $repairStep();
115
+                } else {
116
+                    throw new \Exception("Repair step '$repairStep' is unknown");
117
+                }
118
+            }
119
+
120
+            if ($s instanceof IRepairStep) {
121
+                $this->repairSteps[] = $s;
122
+            } else {
123
+                throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
124
+            }
125
+        } else {
126
+            $this->repairSteps[] = $repairStep;
127
+        }
128
+    }
129
+
130
+    /**
131
+     * Returns the default repair steps to be run on the
132
+     * command line or after an upgrade.
133
+     *
134
+     * @return IRepairStep[]
135
+     */
136
+    public static function getRepairSteps() {
137
+        return [
138
+            new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false),
139
+            new RepairMimeTypes(\OC::$server->getConfig()),
140
+            new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
141
+            new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
142
+            new MoveUpdaterStepFile(\OC::$server->getConfig()),
143
+            new FixMountStorages(\OC::$server->getDatabaseConnection()),
144
+            new AddLogRotateJob(\OC::$server->getJobList()),
145
+            new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OC::$server->query(SCSSCacher::class), \OC::$server->query(JSCombiner::class)),
146
+            new ClearGeneratedAvatarCache(\OC::$server->getConfig(), \OC::$server->query(AvatarManager::class)),
147
+            new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()),
148
+            new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()),
149
+            new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->getLogger()),
150
+            new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()),
151
+            new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)),
152
+            \OC::$server->query(RemoveCypressFiles::class),
153
+            \OC::$server->query(SwitchUpdateChannel::class),
154
+        ];
155
+    }
156
+
157
+    /**
158
+     * Returns expensive repair steps to be run on the
159
+     * command line with a special option.
160
+     *
161
+     * @return IRepairStep[]
162
+     */
163
+    public static function getExpensiveRepairSteps() {
164
+        return [
165
+            new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager())
166
+        ];
167
+    }
168
+
169
+    /**
170
+     * Returns the repair steps to be run before an
171
+     * upgrade.
172
+     *
173
+     * @return IRepairStep[]
174
+     */
175
+    public static function getBeforeUpgradeRepairSteps() {
176
+        $connection = \OC::$server->getDatabaseConnection();
177
+        $config     = \OC::$server->getConfig();
178
+        $steps      = [
179
+            new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true),
180
+            new SqliteAutoincrement($connection),
181
+            new SaveAccountsTableData($connection, $config),
182
+            new DropAccountTermsTable($connection)
183
+        ];
184
+
185
+        return $steps;
186
+    }
187
+
188
+    /**
189
+     * @param string $scope
190
+     * @param string $method
191
+     * @param array $arguments
192
+     */
193
+    public function emit($scope, $method, array $arguments = []) {
194
+        if (!is_null($this->dispatcher)) {
195
+            $this->dispatcher->dispatch("$scope::$method",
196
+                new GenericEvent("$scope::$method", $arguments));
197
+        }
198
+    }
199
+
200
+    public function info($string) {
201
+        // for now just emit as we did in the past
202
+        $this->emit('\OC\Repair', 'info', array($string));
203
+    }
204
+
205
+    /**
206
+     * @param string $message
207
+     */
208
+    public function warning($message) {
209
+        // for now just emit as we did in the past
210
+        $this->emit('\OC\Repair', 'warning', [$message]);
211
+    }
212
+
213
+    /**
214
+     * @param int $max
215
+     */
216
+    public function startProgress($max = 0) {
217
+        // for now just emit as we did in the past
218
+        $this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]);
219
+    }
220
+
221
+    /**
222
+     * @param int $step
223
+     * @param string $description
224
+     */
225
+    public function advance($step = 1, $description = '') {
226
+        // for now just emit as we did in the past
227
+        $this->emit('\OC\Repair', 'advance', [$step, $description]);
228
+    }
229
+
230
+    /**
231
+     * @param int $max
232
+     */
233
+    public function finishProgress() {
234
+        // for now just emit as we did in the past
235
+        $this->emit('\OC\Repair', 'finishProgress', []);
236
+    }
237 237
 }
Please login to merge, or discard this patch.
lib/private/Repair/NC17/SwitchUpdateChannel.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -31,30 +31,30 @@
 block discarded – undo
31 31
  */
32 32
 class SwitchUpdateChannel implements IRepairStep {
33 33
 
34
-	/** @var IConfig */
35
-	private $config;
36
-
37
-	/** @var IRegistry */
38
-	private $subscriptionRegistry;
39
-
40
-	public function __construct(IConfig $config, IRegistry $subscriptionRegistry) {
41
-		$this->config = $config;
42
-		$this->subscriptionRegistry = $subscriptionRegistry;
43
-	}
44
-
45
-	public function getName(): string {
46
-		return 'Switches from deprecated "production" to "stable" update channel';
47
-	}
48
-
49
-	public function run(IOutput $output): void {
50
-		$currentChannel = $this->config->getSystemValue('updater.release.channel', 'stable');
51
-
52
-		if ($currentChannel === 'production') {
53
-			if ($this->subscriptionRegistry->delegateHasValidSubscription()) {
54
-				$this->config->setSystemValue('updater.release.channel', 'enterprise');
55
-			} else {
56
-				$this->config->setSystemValue('updater.release.channel', 'stable');
57
-			}
58
-		}
59
-	}
34
+    /** @var IConfig */
35
+    private $config;
36
+
37
+    /** @var IRegistry */
38
+    private $subscriptionRegistry;
39
+
40
+    public function __construct(IConfig $config, IRegistry $subscriptionRegistry) {
41
+        $this->config = $config;
42
+        $this->subscriptionRegistry = $subscriptionRegistry;
43
+    }
44
+
45
+    public function getName(): string {
46
+        return 'Switches from deprecated "production" to "stable" update channel';
47
+    }
48
+
49
+    public function run(IOutput $output): void {
50
+        $currentChannel = $this->config->getSystemValue('updater.release.channel', 'stable');
51
+
52
+        if ($currentChannel === 'production') {
53
+            if ($this->subscriptionRegistry->delegateHasValidSubscription()) {
54
+                $this->config->setSystemValue('updater.release.channel', 'enterprise');
55
+            } else {
56
+                $this->config->setSystemValue('updater.release.channel', 'stable');
57
+            }
58
+        }
59
+    }
60 60
 }
Please login to merge, or discard this patch.
apps/updatenotification/lib/Settings/Admin.php 1 patch
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -38,147 +38,147 @@
 block discarded – undo
38 38
 use OCP\Util;
39 39
 
40 40
 class Admin implements ISettings {
41
-	/** @var IConfig */
42
-	private $config;
43
-	/** @var UpdateChecker */
44
-	private $updateChecker;
45
-	/** @var IGroupManager */
46
-	private $groupManager;
47
-	/** @var IDateTimeFormatter */
48
-	private $dateTimeFormatter;
49
-	/** @var IFactory */
50
-	private $l10nFactory;
51
-	/** @var IRegistry */
52
-	private $subscriptionRegistry;
53
-
54
-	public function __construct(
55
-		IConfig $config,
56
-		UpdateChecker $updateChecker,
57
-		IGroupManager $groupManager,
58
-		IDateTimeFormatter $dateTimeFormatter,
59
-		IFactory $l10nFactory,
60
-		IRegistry $subscriptionRegistry
61
-	) {
62
-		$this->config = $config;
63
-		$this->updateChecker = $updateChecker;
64
-		$this->groupManager = $groupManager;
65
-		$this->dateTimeFormatter = $dateTimeFormatter;
66
-		$this->l10nFactory = $l10nFactory;
67
-		$this->subscriptionRegistry = $subscriptionRegistry;
68
-	}
69
-
70
-	/**
71
-	 * @return TemplateResponse
72
-	 */
73
-	public function getForm(): TemplateResponse {
74
-		$lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat');
75
-		$lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp);
76
-
77
-		$channels = [
78
-			'daily',
79
-			'beta',
80
-			'stable',
81
-			'production',
82
-		];
83
-		$currentChannel = Util::getChannel();
84
-		if ($currentChannel === 'git') {
85
-			$channels[] = 'git';
86
-		}
87
-
88
-		$updateState = $this->updateChecker->getUpdateState();
89
-
90
-		$notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true);
91
-
92
-		$defaultUpdateServerURL = 'https://updates.nextcloud.com/updater_server/';
93
-		$updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL);
94
-		$defaultCustomerUpdateServerURLPrefix = 'https://updates.nextcloud.com/customers/';
95
-
96
-		$isDefaultUpdateServerURL = $updateServerURL === $defaultUpdateServerURL
97
-			|| $updateServerURL === substr($updateServerURL, 0, strlen($defaultCustomerUpdateServerURLPrefix));
98
-
99
-		$hasValidSubscription = $this->subscriptionRegistry->delegateHasValidSubscription();
100
-
101
-		$params = [
102
-			'isNewVersionAvailable' => !empty($updateState['updateAvailable']),
103
-			'isUpdateChecked' => $lastUpdateCheckTimestamp > 0,
104
-			'lastChecked' => $lastUpdateCheck,
105
-			'currentChannel' => $currentChannel,
106
-			'channels' => $channels,
107
-			'newVersion' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'],
108
-			'newVersionString' => empty($updateState['updateVersionString']) ? '' : $updateState['updateVersionString'],
109
-			'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'],
110
-			'changes' => $this->filterChanges($updateState['changes'] ?? []),
111
-			'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'],
112
-			'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'],
113
-			'isDefaultUpdateServerURL' => $isDefaultUpdateServerURL,
114
-			'updateServerURL' => $updateServerURL,
115
-			'notifyGroups' => $this->getSelectedGroups($notifyGroups),
116
-			'hasValidSubscription' => $hasValidSubscription,
117
-		];
118
-
119
-		$params = [
120
-			'json' => json_encode($params),
121
-		];
122
-
123
-		return new TemplateResponse('updatenotification', 'admin', $params, '');
124
-	}
125
-
126
-	protected function filterChanges(array $changes): array {
127
-		$filtered = [];
128
-		if(isset($changes['changelogURL'])) {
129
-			$filtered['changelogURL'] = $changes['changelogURL'];
130
-		}
131
-		if(!isset($changes['whatsNew'])) {
132
-			return $filtered;
133
-		}
134
-
135
-		$iterator = $this->l10nFactory->getLanguageIterator();
136
-		do {
137
-			$lang = $iterator->current();
138
-			if(isset($changes['whatsNew'][$lang])) {
139
-				$filtered['whatsNew'] = $changes['whatsNew'][$lang];
140
-				return $filtered;
141
-			}
142
-			$iterator->next();
143
-		} while($lang !== 'en' && $iterator->valid());
144
-
145
-		return $filtered;
146
-	}
147
-
148
-	/**
149
-	 * @param array $groupIds
150
-	 * @return array
151
-	 */
152
-	protected function getSelectedGroups(array $groupIds): array {
153
-		$result = [];
154
-		foreach ($groupIds as $groupId) {
155
-			$group = $this->groupManager->get($groupId);
156
-
157
-			if ($group === null) {
158
-				continue;
159
-			}
160
-
161
-			$result[] = ['value' => $group->getGID(), 'label' => $group->getDisplayName()];
162
-		}
163
-
164
-		return $result;
165
-	}
166
-
167
-	/**
168
-	 * @return string the section ID, e.g. 'sharing'
169
-	 */
170
-	public function getSection(): string {
171
-		return 'overview';
172
-	}
173
-
174
-	/**
175
-	 * @return int whether the form should be rather on the top or bottom of
176
-	 * the admin section. The forms are arranged in ascending order of the
177
-	 * priority values. It is required to return a value between 0 and 100.
178
-	 *
179
-	 * E.g.: 70
180
-	 */
181
-	public function getPriority(): int {
182
-		return 11;
183
-	}
41
+    /** @var IConfig */
42
+    private $config;
43
+    /** @var UpdateChecker */
44
+    private $updateChecker;
45
+    /** @var IGroupManager */
46
+    private $groupManager;
47
+    /** @var IDateTimeFormatter */
48
+    private $dateTimeFormatter;
49
+    /** @var IFactory */
50
+    private $l10nFactory;
51
+    /** @var IRegistry */
52
+    private $subscriptionRegistry;
53
+
54
+    public function __construct(
55
+        IConfig $config,
56
+        UpdateChecker $updateChecker,
57
+        IGroupManager $groupManager,
58
+        IDateTimeFormatter $dateTimeFormatter,
59
+        IFactory $l10nFactory,
60
+        IRegistry $subscriptionRegistry
61
+    ) {
62
+        $this->config = $config;
63
+        $this->updateChecker = $updateChecker;
64
+        $this->groupManager = $groupManager;
65
+        $this->dateTimeFormatter = $dateTimeFormatter;
66
+        $this->l10nFactory = $l10nFactory;
67
+        $this->subscriptionRegistry = $subscriptionRegistry;
68
+    }
69
+
70
+    /**
71
+     * @return TemplateResponse
72
+     */
73
+    public function getForm(): TemplateResponse {
74
+        $lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat');
75
+        $lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp);
76
+
77
+        $channels = [
78
+            'daily',
79
+            'beta',
80
+            'stable',
81
+            'production',
82
+        ];
83
+        $currentChannel = Util::getChannel();
84
+        if ($currentChannel === 'git') {
85
+            $channels[] = 'git';
86
+        }
87
+
88
+        $updateState = $this->updateChecker->getUpdateState();
89
+
90
+        $notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true);
91
+
92
+        $defaultUpdateServerURL = 'https://updates.nextcloud.com/updater_server/';
93
+        $updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL);
94
+        $defaultCustomerUpdateServerURLPrefix = 'https://updates.nextcloud.com/customers/';
95
+
96
+        $isDefaultUpdateServerURL = $updateServerURL === $defaultUpdateServerURL
97
+            || $updateServerURL === substr($updateServerURL, 0, strlen($defaultCustomerUpdateServerURLPrefix));
98
+
99
+        $hasValidSubscription = $this->subscriptionRegistry->delegateHasValidSubscription();
100
+
101
+        $params = [
102
+            'isNewVersionAvailable' => !empty($updateState['updateAvailable']),
103
+            'isUpdateChecked' => $lastUpdateCheckTimestamp > 0,
104
+            'lastChecked' => $lastUpdateCheck,
105
+            'currentChannel' => $currentChannel,
106
+            'channels' => $channels,
107
+            'newVersion' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'],
108
+            'newVersionString' => empty($updateState['updateVersionString']) ? '' : $updateState['updateVersionString'],
109
+            'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'],
110
+            'changes' => $this->filterChanges($updateState['changes'] ?? []),
111
+            'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'],
112
+            'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'],
113
+            'isDefaultUpdateServerURL' => $isDefaultUpdateServerURL,
114
+            'updateServerURL' => $updateServerURL,
115
+            'notifyGroups' => $this->getSelectedGroups($notifyGroups),
116
+            'hasValidSubscription' => $hasValidSubscription,
117
+        ];
118
+
119
+        $params = [
120
+            'json' => json_encode($params),
121
+        ];
122
+
123
+        return new TemplateResponse('updatenotification', 'admin', $params, '');
124
+    }
125
+
126
+    protected function filterChanges(array $changes): array {
127
+        $filtered = [];
128
+        if(isset($changes['changelogURL'])) {
129
+            $filtered['changelogURL'] = $changes['changelogURL'];
130
+        }
131
+        if(!isset($changes['whatsNew'])) {
132
+            return $filtered;
133
+        }
134
+
135
+        $iterator = $this->l10nFactory->getLanguageIterator();
136
+        do {
137
+            $lang = $iterator->current();
138
+            if(isset($changes['whatsNew'][$lang])) {
139
+                $filtered['whatsNew'] = $changes['whatsNew'][$lang];
140
+                return $filtered;
141
+            }
142
+            $iterator->next();
143
+        } while($lang !== 'en' && $iterator->valid());
144
+
145
+        return $filtered;
146
+    }
147
+
148
+    /**
149
+     * @param array $groupIds
150
+     * @return array
151
+     */
152
+    protected function getSelectedGroups(array $groupIds): array {
153
+        $result = [];
154
+        foreach ($groupIds as $groupId) {
155
+            $group = $this->groupManager->get($groupId);
156
+
157
+            if ($group === null) {
158
+                continue;
159
+            }
160
+
161
+            $result[] = ['value' => $group->getGID(), 'label' => $group->getDisplayName()];
162
+        }
163
+
164
+        return $result;
165
+    }
166
+
167
+    /**
168
+     * @return string the section ID, e.g. 'sharing'
169
+     */
170
+    public function getSection(): string {
171
+        return 'overview';
172
+    }
173
+
174
+    /**
175
+     * @return int whether the form should be rather on the top or bottom of
176
+     * the admin section. The forms are arranged in ascending order of the
177
+     * priority values. It is required to return a value between 0 and 100.
178
+     *
179
+     * E.g.: 70
180
+     */
181
+    public function getPriority(): int {
182
+        return 11;
183
+    }
184 184
 }
Please login to merge, or discard this patch.