diff --git a/apps/updatenotification/js/admin.js b/apps/updatenotification/js/admin.js index 3bc5dd2152..e5c942fbda 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 5dbcc68580..c622b9690a 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 7661f073e7..f2cf7e1cd8 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 c1adc8d0d3..e74ed23a94 100644 --- a/apps/updatenotification/templates/admin.php +++ b/apps/updatenotification/templates/admin.php @@ -39,4 +39,11 @@

t('You can always update to a newer version / experimental channel. But you can never downgrade to a more stable channel.')); ?>

+ + +

+
+ t('Notify members of the following groups about available updates:')); ?> + +