Completed
Pull Request — master (#7933)
by Joas
18:33
created
apps/updatenotification/templates/admin.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 /**
4 4
  * @copyright (c) 2018 Joas Schilling <[email protected]>
5 5
  *
Please login to merge, or discard this patch.
apps/updatenotification/lib/AppInfo/Application.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -32,53 +32,53 @@
 block discarded – undo
32 32
 use OCP\Util;
33 33
 
34 34
 class Application extends App {
35
-	public function __construct() {
36
-		parent::__construct('updatenotification', []);
37
-	}
35
+    public function __construct() {
36
+        parent::__construct('updatenotification', []);
37
+    }
38 38
 
39
-	public function register() {
40
-		$server = $this->getContainer()->getServer();
39
+    public function register() {
40
+        $server = $this->getContainer()->getServer();
41 41
 
42
-		if ($server->getConfig()->getSystemValue('updatechecker', true) !== true) {
43
-			// Updater check is disabled
44
-			return;
45
-		}
42
+        if ($server->getConfig()->getSystemValue('updatechecker', true) !== true) {
43
+            // Updater check is disabled
44
+            return;
45
+        }
46 46
 
47
-		$user = $server->getUserSession()->getUser();
48
-		if (!$user instanceof IUser) {
49
-			// Nothing to do for guests
50
-			return;
51
-		}
47
+        $user = $server->getUserSession()->getUser();
48
+        if (!$user instanceof IUser) {
49
+            // Nothing to do for guests
50
+            return;
51
+        }
52 52
 
53
-		if ($server->getAppManager()->isEnabledForUser('notifications')) {
54
-			// Notifications app is available, so we register.
55
-			// Since notifications also work for non-admins we don't check this here.
56
-			$this->registerNotifier();
57
-		} else if ($server->getGroupManager()->isAdmin($user->getUID())) {
58
-			try {
59
-				$updateChecker = $this->getContainer()->query(UpdateChecker::class);
60
-			} catch (QueryException $e) {
61
-				$server->getLogger()->logException($e);
62
-				return;
63
-			}
53
+        if ($server->getAppManager()->isEnabledForUser('notifications')) {
54
+            // Notifications app is available, so we register.
55
+            // Since notifications also work for non-admins we don't check this here.
56
+            $this->registerNotifier();
57
+        } else if ($server->getGroupManager()->isAdmin($user->getUID())) {
58
+            try {
59
+                $updateChecker = $this->getContainer()->query(UpdateChecker::class);
60
+            } catch (QueryException $e) {
61
+                $server->getLogger()->logException($e);
62
+                return;
63
+            }
64 64
 
65
-			if ($updateChecker->getUpdateState() !== []) {
66
-				Util::addScript('updatenotification', 'legacy-notification');
67
-				\OC_Hook::connect('\OCP\Config', 'js', $updateChecker, 'populateJavaScriptVariables');
68
-			}
69
-		}
70
-	}
65
+            if ($updateChecker->getUpdateState() !== []) {
66
+                Util::addScript('updatenotification', 'legacy-notification');
67
+                \OC_Hook::connect('\OCP\Config', 'js', $updateChecker, 'populateJavaScriptVariables');
68
+            }
69
+        }
70
+    }
71 71
 
72
-	public function registerNotifier() {
73
-		$notificationsManager = $this->getContainer()->getServer()->getNotificationManager();
74
-		$notificationsManager->registerNotifier(function() {
75
-			return  $this->getContainer()->query(Notifier::class);
76
-		}, function() {
77
-			$l = $this->getContainer()->getServer()->getL10N('updatenotification');
78
-			return [
79
-				'id' => 'updatenotification',
80
-				'name' => $l->t('Update notifications'),
81
-			];
82
-		});
83
-	}
72
+    public function registerNotifier() {
73
+        $notificationsManager = $this->getContainer()->getServer()->getNotificationManager();
74
+        $notificationsManager->registerNotifier(function() {
75
+            return  $this->getContainer()->query(Notifier::class);
76
+        }, function() {
77
+            $l = $this->getContainer()->getServer()->getL10N('updatenotification');
78
+            return [
79
+                'id' => 'updatenotification',
80
+                'name' => $l->t('Update notifications'),
81
+            ];
82
+        });
83
+    }
84 84
 }
Please login to merge, or discard this patch.
apps/updatenotification/lib/Settings/Admin.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 /**
4 4
  * @copyright Copyright (c) 2016, ownCloud, Inc.
5 5
  *
Please login to merge, or discard this 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
-
86
-		$defaultUpdateServerURL = 'https://updates.nextcloud.com/server/';
87
-		$updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL);
88
-
89
-		$params = [
90
-			'isNewVersionAvailable' => !empty($updateState['updateAvailable']),
91
-			'isUpdateChecked' => $lastUpdateCheckTimestamp > 0,
92
-			'lastChecked' => $lastUpdateCheck,
93
-			'currentChannel' => $currentChannel,
94
-			'channels' => $channels,
95
-			'newVersionString' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'],
96
-			'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'],
97
-			'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'],
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
+
86
+        $defaultUpdateServerURL = 'https://updates.nextcloud.com/server/';
87
+        $updateServerURL = $this->config->getSystemValue('updater.server.url', $defaultUpdateServerURL);
88
+
89
+        $params = [
90
+            'isNewVersionAvailable' => !empty($updateState['updateAvailable']),
91
+            'isUpdateChecked' => $lastUpdateCheckTimestamp > 0,
92
+            'lastChecked' => $lastUpdateCheck,
93
+            'currentChannel' => $currentChannel,
94
+            'channels' => $channels,
95
+            'newVersionString' => empty($updateState['updateVersion']) ? '' : $updateState['updateVersion'],
96
+            'downloadLink' => empty($updateState['downloadLink']) ? '' : $updateState['downloadLink'],
97
+            'updaterEnabled' => empty($updateState['updaterEnabled']) ? false : $updateState['updaterEnabled'],
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.