diff options
Diffstat (limited to 'apps/updatenotification')
-rw-r--r-- | apps/updatenotification/js/admin.js | 16 | ||||
-rw-r--r-- | apps/updatenotification/lib/Controller/AdminController.php | 5 | ||||
-rw-r--r-- | apps/updatenotification/lib/Notification/BackgroundJob.php | 11 | ||||
-rw-r--r-- | apps/updatenotification/templates/admin.php | 7 |
4 files changed, 37 insertions, 2 deletions
diff --git a/apps/updatenotification/js/admin.js b/apps/updatenotification/js/admin.js index 3bc5dd21527..e5c942fbdab 100644 --- a/apps/updatenotification/js/admin.js +++ b/apps/updatenotification/js/admin.js @@ -39,8 +39,16 @@ $(document).ready(function(){ }); }); }); + $('#release-channel').change(function() { var newChannel = $('#release-channel').find(":selected").val(); + + if (newChannel === 'git' || newChannel === 'daily') { + $('#oca_updatenotification_groups').addClass('hidden'); + } else { + $('#oca_updatenotification_groups').removeClass('hidden'); + } + $.post( OC.generateUrl('/apps/updatenotification/channel'), { @@ -51,4 +59,12 @@ $(document).ready(function(){ } ); }); + + var $notificationTargetGroups = $('#oca_updatenotification_groups_list'); + OC.Settings.setupGroupsSelect($notificationTargetGroups); + $notificationTargetGroups.change(function(ev) { + var groups = ev.val || []; + groups = JSON.stringify(groups); + OC.AppConfig.setValue('updatenotification', 'notify_groups', groups); + }); }); diff --git a/apps/updatenotification/lib/Controller/AdminController.php b/apps/updatenotification/lib/Controller/AdminController.php index 5dbcc685809..c622b9690a7 100644 --- a/apps/updatenotification/lib/Controller/AdminController.php +++ b/apps/updatenotification/lib/Controller/AdminController.php @@ -100,12 +100,17 @@ class AdminController extends Controller { unset($channels[$key]); } $updateState = $this->updateChecker->getUpdateState(); + + $notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]')); + $params = [ 'isNewVersionAvailable' => ($updateState === []) ? false : true, 'lastChecked' => $lastUpdateCheck, 'currentChannel' => $currentChannel, 'channels' => $channels, 'newVersionString' => ($updateState === []) ? '' : $updateState['updateVersion'], + + 'notify_groups' => implode('|', $notifyGroups), ]; return new TemplateResponse($this->appName, 'admin', $params, ''); diff --git a/apps/updatenotification/lib/Notification/BackgroundJob.php b/apps/updatenotification/lib/Notification/BackgroundJob.php index 7661f073e7b..f2cf7e1cd85 100644 --- a/apps/updatenotification/lib/Notification/BackgroundJob.php +++ b/apps/updatenotification/lib/Notification/BackgroundJob.php @@ -28,6 +28,7 @@ use OC\Updater\VersionCheck; use OCP\App\IAppManager; use OCP\Http\Client\IClientService; use OCP\IConfig; +use OCP\IGroup; use OCP\IGroupManager; use OCP\IUser; use OCP\Notification\IManager; @@ -149,8 +150,14 @@ class BackgroundJob extends TimedJob { return $this->users; } - $groupToNotify = $this->groupManager->get('admin'); - $this->users = $groupToNotify->getUsers(); + $notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]')); + foreach ($notifyGroups as $group) { + $groupToNotify = $this->groupManager->get($group); + if ($groupToNotify instanceof IGroup) { + $this->users = array_merge($this->users, $groupToNotify->getUsers()); + } + } + return $this->users; } diff --git a/apps/updatenotification/templates/admin.php b/apps/updatenotification/templates/admin.php index c1adc8d0d3e..e74ed23a94c 100644 --- a/apps/updatenotification/templates/admin.php +++ b/apps/updatenotification/templates/admin.php @@ -39,4 +39,11 @@ <p> <em><?php p($l->t('You can always update to a newer version / experimental channel. But you can never downgrade to a more stable channel.')); ?></em> </p> + + + <p id="oca_updatenotification_groups" class="<?php if (in_array($currentChannel, ['daily', 'git'])) p('hidden'); ?>"> + <br /> + <?php p($l->t('Notify members of the following groups about available updates:')); ?> + <input name="oca_updatenotification_groups_list" type="hidden" id="oca_updatenotification_groups_list" value="<?php p($_['notify_groups']) ?>" style="width: 400px"> + </p> </form> |