Completed
Pull Request — master (#9029)
by Julius
15:57
created
apps/updatenotification/lib/Settings/Admin.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -35,112 +35,112 @@
 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
-		$lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat');
68
-		$lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp);
69
-
70
-		$channels = [
71
-			'daily',
72
-			'beta',
73
-			'stable',
74
-			'production',
75
-		];
76
-		$currentChannel = Util::getChannel();
77
-		if ($currentChannel === 'git') {
78
-			$channels[] = 'git';
79
-		}
80
-
81
-		$updateState = $this->updateChecker->getUpdateState();
82
-
83
-		$notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true);
84
-
85
-		$defaultUpdateServerURL = 'https://updates.nextcloud.com/updater_server/';
86
-		$updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL);
87
-
88
-		$params = [
89
-			'isNewVersionAvailable' => !empty($updateState['updateAvailable']),
90
-			'isUpdateChecked' => $lastUpdateCheckTimestamp > 0,
91
-			'lastChecked' => $lastUpdateCheck,
92
-			'currentChannel' => $currentChannel,
93
-			'channels' => $channels,
94
-			'newVersionString' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'],
95
-			'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'],
96
-			'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'],
97
-			'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'],
98
-			'isDefaultUpdateServerURL' => $updateServerURL === $defaultUpdateServerURL,
99
-			'updateServerURL' => $updateServerURL,
100
-			'notifyGroups' => $this->getSelectedGroups($notifyGroups),
101
-		];
102
-
103
-		$params = [
104
-			'json' => json_encode($params),
105
-		];
106
-
107
-		return new TemplateResponse('updatenotification', 'admin', $params, '');
108
-	}
109
-
110
-	/**
111
-	 * @param array $groupIds
112
-	 * @return array
113
-	 */
114
-	protected function getSelectedGroups(array $groupIds): array {
115
-		$result = [];
116
-		foreach ($groupIds as $groupId) {
117
-			$group = $this->groupManager->get($groupId);
118
-
119
-			if ($group === null) {
120
-				continue;
121
-			}
122
-
123
-			$result[] = ['value' => $group->getGID(), 'label' => $group->getDisplayName()];
124
-		}
125
-
126
-		return $result;
127
-	}
128
-
129
-	/**
130
-	 * @return string the section ID, e.g. 'sharing'
131
-	 */
132
-	public function getSection(): string {
133
-		return 'overview';
134
-	}
135
-
136
-	/**
137
-	 * @return int whether the form should be rather on the top or bottom of
138
-	 * the admin section. The forms are arranged in ascending order of the
139
-	 * priority values. It is required to return a value between 0 and 100.
140
-	 *
141
-	 * E.g.: 70
142
-	 */
143
-	public function getPriority(): int {
144
-		return 11;
145
-	}
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
+        $lastUpdateCheckTimestamp = $this->config->getAppValue('core', 'lastupdatedat');
68
+        $lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($lastUpdateCheckTimestamp);
69
+
70
+        $channels = [
71
+            'daily',
72
+            'beta',
73
+            'stable',
74
+            'production',
75
+        ];
76
+        $currentChannel = Util::getChannel();
77
+        if ($currentChannel === 'git') {
78
+            $channels[] = 'git';
79
+        }
80
+
81
+        $updateState = $this->updateChecker->getUpdateState();
82
+
83
+        $notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true);
84
+
85
+        $defaultUpdateServerURL = 'https://updates.nextcloud.com/updater_server/';
86
+        $updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL);
87
+
88
+        $params = [
89
+            'isNewVersionAvailable' => !empty($updateState['updateAvailable']),
90
+            'isUpdateChecked' => $lastUpdateCheckTimestamp > 0,
91
+            'lastChecked' => $lastUpdateCheck,
92
+            'currentChannel' => $currentChannel,
93
+            'channels' => $channels,
94
+            'newVersionString' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'],
95
+            'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'],
96
+            'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'],
97
+            'versionIsEol' => empty($updateState['versionIsEol']) ? false : $updateState['versionIsEol'],
98
+            'isDefaultUpdateServerURL' => $updateServerURL === $defaultUpdateServerURL,
99
+            'updateServerURL' => $updateServerURL,
100
+            'notifyGroups' => $this->getSelectedGroups($notifyGroups),
101
+        ];
102
+
103
+        $params = [
104
+            'json' => json_encode($params),
105
+        ];
106
+
107
+        return new TemplateResponse('updatenotification', 'admin', $params, '');
108
+    }
109
+
110
+    /**
111
+     * @param array $groupIds
112
+     * @return array
113
+     */
114
+    protected function getSelectedGroups(array $groupIds): array {
115
+        $result = [];
116
+        foreach ($groupIds as $groupId) {
117
+            $group = $this->groupManager->get($groupId);
118
+
119
+            if ($group === null) {
120
+                continue;
121
+            }
122
+
123
+            $result[] = ['value' => $group->getGID(), 'label' => $group->getDisplayName()];
124
+        }
125
+
126
+        return $result;
127
+    }
128
+
129
+    /**
130
+     * @return string the section ID, e.g. 'sharing'
131
+     */
132
+    public function getSection(): string {
133
+        return 'overview';
134
+    }
135
+
136
+    /**
137
+     * @return int whether the form should be rather on the top or bottom of
138
+     * the admin section. The forms are arranged in ascending order of the
139
+     * priority values. It is required to return a value between 0 and 100.
140
+     *
141
+     * E.g.: 70
142
+     */
143
+    public function getPriority(): int {
144
+        return 11;
145
+    }
146 146
 }
Please login to merge, or discard this patch.