Completed
Pull Request — master (#8821)
by Joas
17:19
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 'server';
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 1;
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 'server';
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 1;
145
+    }
146 146
 }
Please login to merge, or discard this patch.
apps/updatenotification/lib/UpdateChecker.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -28,49 +28,49 @@
 block discarded – undo
28 28
 use OC\Updater\VersionCheck;
29 29
 
30 30
 class UpdateChecker {
31
-	/** @var VersionCheck */
32
-	private $updater;
31
+    /** @var VersionCheck */
32
+    private $updater;
33 33
 
34
-	/**
35
-	 * @param VersionCheck $updater
36
-	 */
37
-	public function __construct(VersionCheck $updater) {
38
-		$this->updater = $updater;
39
-	}
34
+    /**
35
+     * @param VersionCheck $updater
36
+     */
37
+    public function __construct(VersionCheck $updater) {
38
+        $this->updater = $updater;
39
+    }
40 40
 
41
-	/**
42
-	 * @return array
43
-	 */
44
-	public function getUpdateState(): array {
45
-		$data = $this->updater->check();
46
-		$result = [];
41
+    /**
42
+     * @return array
43
+     */
44
+    public function getUpdateState(): array {
45
+        $data = $this->updater->check();
46
+        $result = [];
47 47
 
48
-		if (isset($data['version']) && $data['version'] !== '' && $data['version'] !== []) {
49
-			$result['updateAvailable'] = true;
50
-			$result['updateVersion'] = $data['versionstring'];
51
-			$result['updaterEnabled'] = $data['autoupdater'] === '1';
52
-			$result['versionIsEol'] = $data['eol'] === '1';
53
-			if (strpos($data['web'], 'https://') === 0) {
54
-				$result['updateLink'] = $data['web'];
55
-			}
56
-			if (strpos($data['url'], 'https://') === 0) {
57
-				$result['downloadLink'] = $data['url'];
58
-			}
48
+        if (isset($data['version']) && $data['version'] !== '' && $data['version'] !== []) {
49
+            $result['updateAvailable'] = true;
50
+            $result['updateVersion'] = $data['versionstring'];
51
+            $result['updaterEnabled'] = $data['autoupdater'] === '1';
52
+            $result['versionIsEol'] = $data['eol'] === '1';
53
+            if (strpos($data['web'], 'https://') === 0) {
54
+                $result['updateLink'] = $data['web'];
55
+            }
56
+            if (strpos($data['url'], 'https://') === 0) {
57
+                $result['downloadLink'] = $data['url'];
58
+            }
59 59
 
60
-			return $result;
61
-		}
60
+            return $result;
61
+        }
62 62
 
63
-		return [];
64
-	}
63
+        return [];
64
+    }
65 65
 
66
-	/**
67
-	 * @param array $data
68
-	 */
69
-	public function populateJavaScriptVariables(array $data) {
70
-		$data['array']['oc_updateState'] =  json_encode([
71
-			'updateAvailable' => true,
72
-			'updateVersion' => $this->getUpdateState()['updateVersion'],
73
-			'updateLink' => $this->getUpdateState()['updateLink'] ?? '',
74
-		]);
75
-	}
66
+    /**
67
+     * @param array $data
68
+     */
69
+    public function populateJavaScriptVariables(array $data) {
70
+        $data['array']['oc_updateState'] =  json_encode([
71
+            'updateAvailable' => true,
72
+            'updateVersion' => $this->getUpdateState()['updateVersion'],
73
+            'updateLink' => $this->getUpdateState()['updateLink'] ?? '',
74
+        ]);
75
+    }
76 76
 }
Please login to merge, or discard this patch.