From 9ea5d7051273ab6e0538057aa6376d4fe994d4f1 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 4 Apr 2025 15:09:32 +0200 Subject: [PATCH 1/8] users: Rename to contacts --- application/clicommands/MigrateCommand.php | 2 +- ...sController.php => ContactsController.php} | 5 ++-- application/controllers/UserController.php | 2 +- configuration.php | 24 +++++++++++-------- doc/04-Security.md | 2 +- doc/10-Migration.md | 2 +- library/Icingadb/Common/Auth.php | 10 +++++++- library/Icingadb/Common/Links.php | 2 +- library/Icingadb/Compat/UrlMigrator.php | 2 +- .../Icingadb/Model/NotificationHistory.php | 2 +- .../Icingadb/Widget/Detail/EventDetail.php | 8 +++---- .../Icingadb/Widget/Detail/ObjectDetail.php | 6 ++--- .../Widget/Detail/UsergroupDetail.php | 2 +- .../clicommands/MigrateCommandTest.php | 2 +- 14 files changed, 41 insertions(+), 30 deletions(-) rename application/controllers/{UsersController.php => ContactsController.php} (96%) diff --git a/application/clicommands/MigrateCommand.php b/application/clicommands/MigrateCommand.php index 17892bb4..0bc91ba7 100644 --- a/application/clicommands/MigrateCommand.php +++ b/application/clicommands/MigrateCommand.php @@ -357,7 +357,7 @@ class MigrateCommand extends Command } elseif ($permission === 'no-monitoring/contacts') { $changed = true; $updatedPermissions[] = $permission; - $role['icingadb/denylist/routes'] = 'users,usergroups'; + $role['icingadb/denylist/routes'] = 'contacts,usergroups'; } else { $updatedPermissions[] = $permission; } diff --git a/application/controllers/UsersController.php b/application/controllers/ContactsController.php similarity index 96% rename from application/controllers/UsersController.php rename to application/controllers/ContactsController.php index ea4a87f3..9d4cbfb8 100644 --- a/application/controllers/UsersController.php +++ b/application/controllers/ContactsController.php @@ -12,9 +12,8 @@ use Icinga\Module\Icingadb\Widget\ItemList\ObjectList; use Icinga\Module\Icingadb\Web\Control\ViewModeSwitcher; use ipl\Web\Control\LimitControl; use ipl\Web\Control\SortControl; -use ipl\Web\Url; -class UsersController extends Controller +class ContactsController extends Controller { public function init() { @@ -25,7 +24,7 @@ class UsersController extends Controller public function indexAction() { - $this->addTitleTab(t('Users')); + $this->addTitleTab(t('Contacts')); $db = $this->getDb(); diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php index 6afc0921..bd29e9f4 100644 --- a/application/controllers/UserController.php +++ b/application/controllers/UserController.php @@ -18,7 +18,7 @@ class UserController extends Controller public function init() { - $this->assertRouteAccess('users'); + $this->assertRouteAccess('contacts'); $this->addTitleTab(t('User')); diff --git a/configuration.php b/configuration.php index 16a25f46..098ef01f 100644 --- a/configuration.php +++ b/configuration.php @@ -382,17 +382,18 @@ namespace Icinga\Module\Icingadb { ]); } - if (! array_key_exists('users', $routeDenylist)) { - $overviewSection->add(N_('Users'), [ - 'description' => $this->translate('List users'), - 'url' => 'icingadb/users', + if ( + ! array_key_exists('users', $routeDenylist) // TODO: Remove with 1.3, compat only + && ! array_key_exists('contacts', $routeDenylist) + ) { + $overviewSection->add(N_('Contacts'), [ + 'description' => $this->translate('List contacts'), + 'url' => 'icingadb/contacts', 'priority' => 100, 'icon' => 'user-friends' ]); } - - $overviewSection->add(N_('Comments'), [ 'url' => 'icingadb/comments', 'description' => $this->translate('List comments'), @@ -510,11 +511,14 @@ namespace Icinga\Module\Icingadb { ]); } - if (! array_key_exists('users', $routeDenylist)) { - $section->add(N_('Users'), [ - 'url' => 'icingadb/users', + if ( + ! array_key_exists('users', $routeDenylist) // TODO: Remove with 1.3, compat only + && ! array_key_exists('contacts', $routeDenylist) + ) { + $section->add(N_('Contacts'), [ + 'url' => 'icingadb/contacts', 'priority' => 80, - 'description' => $this->translate('List users'), + 'description' => $this->translate('List contacts'), 'icon' => 'user-friends' ]); } diff --git a/doc/04-Security.md b/doc/04-Security.md index d3e7545d..81bc0be0 100644 --- a/doc/04-Security.md +++ b/doc/04-Security.md @@ -77,7 +77,7 @@ icingadb/denylist/variables | Hide custom variables of Icinga objects that are p `icingadb/denylist/routes` will block users from accessing defined routes and from related information elsewhere. For example, if `hostgroups` are part of the list a user won't have access to the hostgroup overview nor to a host's groups shown in its detail area. This should be a comma separated list. Possible values are: hostgroups, servicegroups, -users, usergroups +contacts, usergroups `icingadb/denylist/variables` will block users from accessing certain custom variables. A user affected by this won't see that those variables even exist. This should be a comma separated list of [variable paths](#variable-paths). It is diff --git a/doc/10-Migration.md b/doc/10-Migration.md index 43fa1dbd..583fdda9 100644 --- a/doc/10-Migration.md +++ b/doc/10-Migration.md @@ -150,7 +150,7 @@ The command permissions have not changed. It is only the module identifier that `monitoring/command/*` is now `icingadb/command/*` The `no-monitoring/contacts` permission (or *fake refusal*) is now a restriction: `icingadb/denylist/routes`. -Add `users,usergroups` to it to achieve the same effect. +Add `contacts,usergroups` to it to achieve the same effect. ### Perform The Migration diff --git a/library/Icingadb/Common/Auth.php b/library/Icingadb/Common/Auth.php index 0cabff7b..10bb3ed0 100644 --- a/library/Icingadb/Common/Auth.php +++ b/library/Icingadb/Common/Auth.php @@ -41,7 +41,15 @@ trait Auth return StringHelper::trimSplit($restriction); }, $this->getAuth()->getRestrictions('icingadb/denylist/routes')))); - return ! array_key_exists($name, $routeDenylist); + if (! array_key_exists($name, $routeDenylist)) { + if ($name === 'contacts' && array_key_exists('users', $routeDenylist)) { + return false; // TODO: Remove with 1.3, compat only + } + + return true; + } + + return false; } /** diff --git a/library/Icingadb/Common/Links.php b/library/Icingadb/Common/Links.php index 5968e5fb..a8ab79f8 100644 --- a/library/Icingadb/Common/Links.php +++ b/library/Icingadb/Common/Links.php @@ -128,7 +128,7 @@ abstract class Links public static function users(): Url { - return Url::fromPath('icingadb/users'); + return Url::fromPath('icingadb/contacts'); } public static function usergroups(): Url diff --git a/library/Icingadb/Compat/UrlMigrator.php b/library/Icingadb/Compat/UrlMigrator.php index f6a4a4ae..61e50a58 100644 --- a/library/Icingadb/Compat/UrlMigrator.php +++ b/library/Icingadb/Compat/UrlMigrator.php @@ -32,7 +32,7 @@ class UrlMigrator 'monitoring/list/hostgroups' => ['hostgroups', 'icingadb/hostgroups'], 'monitoring/list/servicegroups' => ['servicegroups', 'icingadb/servicegroups'], 'monitoring/list/contactgroups' => ['contactgroups', 'icingadb/usergroups'], - 'monitoring/list/contacts' => ['contacts', 'icingadb/users'], + 'monitoring/list/contacts' => ['contacts', 'icingadb/contacts'], 'monitoring/list/comments' => ['comments', 'icingadb/comments'], 'monitoring/list/downtimes' => ['downtimes', 'icingadb/downtimes'], 'monitoring/list/eventhistory' => ['history', 'icingadb/history'], diff --git a/library/Icingadb/Model/NotificationHistory.php b/library/Icingadb/Model/NotificationHistory.php index 08903ad6..bb2ad475 100644 --- a/library/Icingadb/Model/NotificationHistory.php +++ b/library/Icingadb/Model/NotificationHistory.php @@ -80,7 +80,7 @@ class NotificationHistory extends Model 'previous_hard_state' => t('Previous Hard State'), 'author' => t('Notification Author'), 'text' => t('Notification Text'), - 'users_notified' => t('Users Notified') + 'users_notified' => t('Contacts Notified') ]; } diff --git a/library/Icingadb/Widget/Detail/EventDetail.php b/library/Icingadb/Widget/Detail/EventDetail.php index f0d0fb07..70ad21a5 100644 --- a/library/Icingadb/Widget/Detail/EventDetail.php +++ b/library/Icingadb/Widget/Detail/EventDetail.php @@ -152,14 +152,14 @@ class EventDetail extends BaseHtmlElement $eventInfo[] = new HorizontalKeyValue($objectKey, $objectInfo); - $notifiedUsers = [new HtmlElement('h2', null, Text::create(t('Notified Users')))]; + $notifiedUsers = [new HtmlElement('h2', null, Text::create(t('Notified Contacts')))]; if ($notification->users_notified === 0) { $notifiedUsers[] = new EmptyState(t('None', 'notified users: none')); - } elseif (! $this->isPermittedRoute('users')) { + } elseif (! $this->isPermittedRoute('contacts')) { $notifiedUsers[] = Text::create(sprintf(tp( - 'This notification was sent to a single user', - 'This notification was sent to %d users', + 'This notification was sent to a single contact', + 'This notification was sent to %d contacts', $notification->users_notified ), $notification->users_notified)); } elseif ($notification->users_notified > 0) { diff --git a/library/Icingadb/Widget/Detail/ObjectDetail.php b/library/Icingadb/Widget/Detail/ObjectDetail.php index 3b8e4678..0d20e9b4 100644 --- a/library/Icingadb/Widget/Detail/ObjectDetail.php +++ b/library/Icingadb/Widget/Detail/ObjectDetail.php @@ -402,8 +402,8 @@ class ObjectDetail extends BaseHtmlElement return [ Html::tag('h2', t('Notifications')), new HorizontalKeyValue( - t('Users'), - $userList->hasContent() ? $userList : new EmptyState(t('No users configured.')) + t('Contacts'), + $userList->hasContent() ? $userList : new EmptyState(t('No contacts configured.')) ), new HorizontalKeyValue( t('User Groups'), @@ -574,7 +574,7 @@ class ObjectDetail extends BaseHtmlElement } $userQuery = null; - if ($this->isPermittedRoute('users')) { + if ($this->isPermittedRoute('contacts')) { $userQuery = User::on($this->getDb()); $userQuery->filter($objectFilter); $this->applyRestrictions($userQuery); diff --git a/library/Icingadb/Widget/Detail/UsergroupDetail.php b/library/Icingadb/Widget/Detail/UsergroupDetail.php index c980ed57..6ae1cf26 100644 --- a/library/Icingadb/Widget/Detail/UsergroupDetail.php +++ b/library/Icingadb/Widget/Detail/UsergroupDetail.php @@ -74,7 +74,7 @@ class UsergroupDetail extends BaseHtmlElement ))->setBaseTarget('_next'); return [ - new HtmlElement('h2', null, Text::create(t('Users'))), + new HtmlElement('h2', null, Text::create(t('Contacts'))), new ObjectList($users), $showMoreLink ]; diff --git a/test/php/application/clicommands/MigrateCommandTest.php b/test/php/application/clicommands/MigrateCommandTest.php index 2f591aca..28be8f78 100644 --- a/test/php/application/clicommands/MigrateCommandTest.php +++ b/test/php/application/clicommands/MigrateCommandTest.php @@ -499,7 +499,7 @@ class MigrateCommandTest extends TestCase ], 'no-monitoring-contacts' => [ 'permissions' => 'module/monitoring,no-monitoring/contacts', - 'icingadb/denylist/routes' => 'users,usergroups' + 'icingadb/denylist/routes' => 'contacts,usergroups' ], 'reporting-only' => [ 'permissions' => 'module/reporting' From d39f6eed81a6cc377db600111e52cff1c8ce95b8 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 4 Apr 2025 15:30:08 +0200 Subject: [PATCH 2/8] users: Add fallback route which redirects to contacts --- application/controllers/UsersController.php | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 application/controllers/UsersController.php diff --git a/application/controllers/UsersController.php b/application/controllers/UsersController.php new file mode 100644 index 00000000..293007f8 --- /dev/null +++ b/application/controllers/UsersController.php @@ -0,0 +1,28 @@ +getRequest()->getUrl(); + $url->setPath(preg_replace( + '~^icingadb/users(?=/|$)~', + 'icingadb/contacts', + $url->getPath() + )); + + $this->getResponse() + ->setHttpResponseCode(301) + ->setHeader('Location', $url->getAbsoluteUrl()) + ->sendResponse(); + } +} From 19135bccebeed59482484b0f3ed7d86ce1b91020 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 4 Apr 2025 15:42:23 +0200 Subject: [PATCH 3/8] user: Rename to contact --- .../{UserController.php => ContactController.php} | 6 +++--- library/Icingadb/Common/Links.php | 2 +- .../Icingadb/Web/Control/SearchBar/ObjectSuggestions.php | 2 +- library/Icingadb/Widget/ItemList/ObjectList.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename application/controllers/{UserController.php => ContactController.php} (88%) diff --git a/application/controllers/UserController.php b/application/controllers/ContactController.php similarity index 88% rename from application/controllers/UserController.php rename to application/controllers/ContactController.php index bd29e9f4..3115fb10 100644 --- a/application/controllers/UserController.php +++ b/application/controllers/ContactController.php @@ -11,7 +11,7 @@ use Icinga\Module\Icingadb\Widget\Detail\ObjectHeader; use Icinga\Module\Icingadb\Widget\Detail\UserDetail; use ipl\Stdlib\Filter; -class UserController extends Controller +class ContactController extends Controller { /** @var User The user object */ protected $user; @@ -20,7 +20,7 @@ class UserController extends Controller { $this->assertRouteAccess('contacts'); - $this->addTitleTab(t('User')); + $this->addTitleTab(t('Contact')); $name = $this->params->getRequired('name'); @@ -31,7 +31,7 @@ class UserController extends Controller $user = $query->first(); if ($user === null) { - throw new NotFoundError(t('User not found')); + throw new NotFoundError(t('Contact not found')); } $this->user = $user; diff --git a/library/Icingadb/Common/Links.php b/library/Icingadb/Common/Links.php index a8ab79f8..cfabd421 100644 --- a/library/Icingadb/Common/Links.php +++ b/library/Icingadb/Common/Links.php @@ -118,7 +118,7 @@ abstract class Links public static function user(User $user): Url { - return Url::fromPath('icingadb/user', ['name' => $user->name]); + return Url::fromPath('icingadb/contact', ['name' => $user->name]); } public static function usergroup(Usergroup $usergroup): Url diff --git a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php index 0ffa1648..af196ecd 100644 --- a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php +++ b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php @@ -55,7 +55,7 @@ class ObjectSuggestions extends Suggestions 'service' => t('Service %s', '..'), 'servicegroup' => t('Servicegroup %s', '..'), 'timeperiod' => t('Timeperiod %s', '..'), - 'user' => t('User %s', '..'), + 'user' => t('Contact %s', '..'), 'usergroup' => t('Usergroup %s', '..') ]; } diff --git a/library/Icingadb/Widget/ItemList/ObjectList.php b/library/Icingadb/Widget/ItemList/ObjectList.php index d471647b..f5b88486 100644 --- a/library/Icingadb/Widget/ItemList/ObjectList.php +++ b/library/Icingadb/Widget/ItemList/ObjectList.php @@ -209,7 +209,7 @@ class ObjectList extends ItemList case $data instanceof User: $this - ->setDetailUrl(Url::fromPath('icingadb/user')) + ->setDetailUrl(Url::fromPath('icingadb/contact')) ->addDetailFilterAttribute($item, Filter::equal('name', $object->name)); break; From 61d4b2eddfda20a704324c8fff58e52dad06e61e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 4 Apr 2025 15:44:50 +0200 Subject: [PATCH 4/8] user: Add fallback route which redirects to contact --- application/controllers/UserController.php | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 application/controllers/UserController.php diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php new file mode 100644 index 00000000..6d64f844 --- /dev/null +++ b/application/controllers/UserController.php @@ -0,0 +1,28 @@ +getRequest()->getUrl(); + $url->setPath(preg_replace( + '~^icingadb/user(?=/|$)~', + 'icingadb/contact', + $url->getPath() + )); + + $this->getResponse() + ->setHttpResponseCode(301) + ->setHeader('Location', $url->getAbsoluteUrl()) + ->sendResponse(); + } +} From e66661196bc82a5d016ea1c910b4ec35ac578048 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 4 Apr 2025 15:53:41 +0200 Subject: [PATCH 5/8] usergroups: Rename to contactgroups --- application/clicommands/MigrateCommand.php | 2 +- ...roller.php => ContactgroupsController.php} | 4 ++-- .../controllers/UsergroupController.php | 2 +- configuration.php | 22 ++++++++++++------- doc/04-Security.md | 2 +- doc/10-Migration.md | 2 +- library/Icingadb/Common/Auth.php | 2 ++ library/Icingadb/Common/Links.php | 2 +- library/Icingadb/Compat/UrlMigrator.php | 2 +- .../Icingadb/Widget/Detail/ObjectDetail.php | 6 ++--- .../clicommands/MigrateCommandTest.php | 2 +- 11 files changed, 28 insertions(+), 20 deletions(-) rename application/controllers/{UsergroupsController.php => ContactgroupsController.php} (96%) diff --git a/application/clicommands/MigrateCommand.php b/application/clicommands/MigrateCommand.php index 0bc91ba7..74b4ac4a 100644 --- a/application/clicommands/MigrateCommand.php +++ b/application/clicommands/MigrateCommand.php @@ -357,7 +357,7 @@ class MigrateCommand extends Command } elseif ($permission === 'no-monitoring/contacts') { $changed = true; $updatedPermissions[] = $permission; - $role['icingadb/denylist/routes'] = 'contacts,usergroups'; + $role['icingadb/denylist/routes'] = 'contacts,contactgroups'; } else { $updatedPermissions[] = $permission; } diff --git a/application/controllers/UsergroupsController.php b/application/controllers/ContactgroupsController.php similarity index 96% rename from application/controllers/UsergroupsController.php rename to application/controllers/ContactgroupsController.php index 4a024117..a19d9b1d 100644 --- a/application/controllers/UsergroupsController.php +++ b/application/controllers/ContactgroupsController.php @@ -14,7 +14,7 @@ use ipl\Web\Control\LimitControl; use ipl\Web\Control\SortControl; use ipl\Web\Url; -class UsergroupsController extends Controller +class ContactgroupsController extends Controller { public function init() { @@ -25,7 +25,7 @@ class UsergroupsController extends Controller public function indexAction() { - $this->addTitleTab(t('User Groups')); + $this->addTitleTab(t('Contact Groups')); $db = $this->getDb(); diff --git a/application/controllers/UsergroupController.php b/application/controllers/UsergroupController.php index 9ea90b9b..af2753bb 100644 --- a/application/controllers/UsergroupController.php +++ b/application/controllers/UsergroupController.php @@ -18,7 +18,7 @@ class UsergroupController extends Controller public function init() { - $this->assertRouteAccess('usergroups'); + $this->assertRouteAccess('contactgroups'); $this->addTitleTab(t('User Group')); diff --git a/configuration.php b/configuration.php index 098ef01f..72f04b09 100644 --- a/configuration.php +++ b/configuration.php @@ -373,10 +373,13 @@ namespace Icinga\Module\Icingadb { ]); } - if (! array_key_exists('usergroups', $routeDenylist)) { - $overviewSection->add(N_('User Groups'), [ - 'description' => $this->translate('List user groups'), - 'url' => 'icingadb/usergroups', + if ( + ! array_key_exists('usergroups', $routeDenylist) // TODO: Remove with 1.3, compat only + && ! array_key_exists('contactgroups', $routeDenylist) + ) { + $overviewSection->add(N_('Contact Groups'), [ + 'description' => $this->translate('List contact groups'), + 'url' => 'icingadb/contactgroups', 'priority' => 90, 'icon' => 'users' ]); @@ -502,11 +505,14 @@ namespace Icinga\Module\Icingadb { ]); } - if (! array_key_exists('usergroups', $routeDenylist)) { - $section->add(N_('User Groups'), [ - 'url' => 'icingadb/usergroups', + if ( + ! array_key_exists('usergroups', $routeDenylist) // TODO: Remove with 1.3, compat only + && ! array_key_exists('contactgroups', $routeDenylist) + ) { + $section->add(N_('Contact Groups'), [ + 'url' => 'icingadb/contactgroups', 'priority' => 70, - 'description' => $this->translate('List user groups'), + 'description' => $this->translate('List contact groups'), 'icon' => 'users' ]); } diff --git a/doc/04-Security.md b/doc/04-Security.md index 81bc0be0..c6653d93 100644 --- a/doc/04-Security.md +++ b/doc/04-Security.md @@ -77,7 +77,7 @@ icingadb/denylist/variables | Hide custom variables of Icinga objects that are p `icingadb/denylist/routes` will block users from accessing defined routes and from related information elsewhere. For example, if `hostgroups` are part of the list a user won't have access to the hostgroup overview nor to a host's groups shown in its detail area. This should be a comma separated list. Possible values are: hostgroups, servicegroups, -contacts, usergroups +contacts, contactgroups `icingadb/denylist/variables` will block users from accessing certain custom variables. A user affected by this won't see that those variables even exist. This should be a comma separated list of [variable paths](#variable-paths). It is diff --git a/doc/10-Migration.md b/doc/10-Migration.md index 583fdda9..a03b608b 100644 --- a/doc/10-Migration.md +++ b/doc/10-Migration.md @@ -150,7 +150,7 @@ The command permissions have not changed. It is only the module identifier that `monitoring/command/*` is now `icingadb/command/*` The `no-monitoring/contacts` permission (or *fake refusal*) is now a restriction: `icingadb/denylist/routes`. -Add `contacts,usergroups` to it to achieve the same effect. +Add `contacts,contactgroups` to it to achieve the same effect. ### Perform The Migration diff --git a/library/Icingadb/Common/Auth.php b/library/Icingadb/Common/Auth.php index 10bb3ed0..59e18b77 100644 --- a/library/Icingadb/Common/Auth.php +++ b/library/Icingadb/Common/Auth.php @@ -44,6 +44,8 @@ trait Auth if (! array_key_exists($name, $routeDenylist)) { if ($name === 'contacts' && array_key_exists('users', $routeDenylist)) { return false; // TODO: Remove with 1.3, compat only + } elseif ($name === 'contactgroups' && array_key_exists('usergroups', $routeDenylist)) { + return false; // TODO: Remove with 1.3, compat only } return true; diff --git a/library/Icingadb/Common/Links.php b/library/Icingadb/Common/Links.php index cfabd421..0de05e10 100644 --- a/library/Icingadb/Common/Links.php +++ b/library/Icingadb/Common/Links.php @@ -133,7 +133,7 @@ abstract class Links public static function usergroups(): Url { - return Url::fromPath('icingadb/usergroups'); + return Url::fromPath('icingadb/contactgroups'); } public static function event(History $event): Url diff --git a/library/Icingadb/Compat/UrlMigrator.php b/library/Icingadb/Compat/UrlMigrator.php index 61e50a58..882d13fd 100644 --- a/library/Icingadb/Compat/UrlMigrator.php +++ b/library/Icingadb/Compat/UrlMigrator.php @@ -31,7 +31,7 @@ class UrlMigrator 'monitoring/service/history' => ['service', 'icingadb/service/history'], 'monitoring/list/hostgroups' => ['hostgroups', 'icingadb/hostgroups'], 'monitoring/list/servicegroups' => ['servicegroups', 'icingadb/servicegroups'], - 'monitoring/list/contactgroups' => ['contactgroups', 'icingadb/usergroups'], + 'monitoring/list/contactgroups' => ['contactgroups', 'icingadb/contactgroups'], 'monitoring/list/contacts' => ['contacts', 'icingadb/contacts'], 'monitoring/list/comments' => ['comments', 'icingadb/comments'], 'monitoring/list/downtimes' => ['downtimes', 'icingadb/downtimes'], diff --git a/library/Icingadb/Widget/Detail/ObjectDetail.php b/library/Icingadb/Widget/Detail/ObjectDetail.php index 0d20e9b4..12557595 100644 --- a/library/Icingadb/Widget/Detail/ObjectDetail.php +++ b/library/Icingadb/Widget/Detail/ObjectDetail.php @@ -406,10 +406,10 @@ class ObjectDetail extends BaseHtmlElement $userList->hasContent() ? $userList : new EmptyState(t('No contacts configured.')) ), new HorizontalKeyValue( - t('User Groups'), + t('Contact Groups'), $usergroupList->hasContent() ? $usergroupList - : new EmptyState(t('No user groups configured.')) + : new EmptyState(t('No contact groups configured.')) ) ]; } @@ -587,7 +587,7 @@ class ObjectDetail extends BaseHtmlElement } } - if ($this->isPermittedRoute('usergroups')) { + if ($this->isPermittedRoute('contactgroups')) { $usergroupQuery = Usergroup::on($this->getDb()); $usergroupQuery->filter($objectFilter); $this->applyRestrictions($usergroupQuery); diff --git a/test/php/application/clicommands/MigrateCommandTest.php b/test/php/application/clicommands/MigrateCommandTest.php index 28be8f78..c82a10ed 100644 --- a/test/php/application/clicommands/MigrateCommandTest.php +++ b/test/php/application/clicommands/MigrateCommandTest.php @@ -499,7 +499,7 @@ class MigrateCommandTest extends TestCase ], 'no-monitoring-contacts' => [ 'permissions' => 'module/monitoring,no-monitoring/contacts', - 'icingadb/denylist/routes' => 'contacts,usergroups' + 'icingadb/denylist/routes' => 'contacts,contactgroups' ], 'reporting-only' => [ 'permissions' => 'module/reporting' From 4bfe0eacacdb38a3b484e69e1cb1a79bbac41268 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 4 Apr 2025 16:01:29 +0200 Subject: [PATCH 6/8] usergroups: Add fallback route which redirects to contactgroups --- .../controllers/UsergroupsController.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 application/controllers/UsergroupsController.php diff --git a/application/controllers/UsergroupsController.php b/application/controllers/UsergroupsController.php new file mode 100644 index 00000000..306a69f7 --- /dev/null +++ b/application/controllers/UsergroupsController.php @@ -0,0 +1,28 @@ +getRequest()->getUrl(); + $url->setPath(preg_replace( + '~^icingadb/usergroups(?=/|$)~', + 'icingadb/contactgroups', + $url->getPath() + )); + + $this->getResponse() + ->setHttpResponseCode(301) + ->setHeader('Location', $url->getAbsoluteUrl()) + ->sendResponse(); + } +} From 04b8e220fd9981f34d06c77f756233d1b8ca46c4 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 4 Apr 2025 16:05:56 +0200 Subject: [PATCH 7/8] usergroup: Rename to contactgroup --- ...rgroupController.php => ContactgroupController.php} | 6 +++--- library/Icingadb/Common/Links.php | 2 +- library/Icingadb/Model/Usergroup.php | 10 +++++----- .../Web/Control/SearchBar/ObjectSuggestions.php | 2 +- library/Icingadb/Widget/ItemList/ObjectList.php | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) rename application/controllers/{UsergroupController.php => ContactgroupController.php} (87%) diff --git a/application/controllers/UsergroupController.php b/application/controllers/ContactgroupController.php similarity index 87% rename from application/controllers/UsergroupController.php rename to application/controllers/ContactgroupController.php index af2753bb..22fcf4c7 100644 --- a/application/controllers/UsergroupController.php +++ b/application/controllers/ContactgroupController.php @@ -11,7 +11,7 @@ use Icinga\Module\Icingadb\Widget\Detail\ObjectHeader; use Icinga\Module\Icingadb\Widget\Detail\UsergroupDetail; use ipl\Stdlib\Filter; -class UsergroupController extends Controller +class ContactgroupController extends Controller { /** @var Usergroup The usergroup object */ protected $usergroup; @@ -20,7 +20,7 @@ class UsergroupController extends Controller { $this->assertRouteAccess('contactgroups'); - $this->addTitleTab(t('User Group')); + $this->addTitleTab(t('Contact Group')); $name = $this->params->getRequired('name'); @@ -31,7 +31,7 @@ class UsergroupController extends Controller $usergroup = $query->first(); if ($usergroup === null) { - throw new NotFoundError(t('User group not found')); + throw new NotFoundError(t('Contact group not found')); } $this->usergroup = $usergroup; diff --git a/library/Icingadb/Common/Links.php b/library/Icingadb/Common/Links.php index 0de05e10..d9649591 100644 --- a/library/Icingadb/Common/Links.php +++ b/library/Icingadb/Common/Links.php @@ -123,7 +123,7 @@ abstract class Links public static function usergroup(Usergroup $usergroup): Url { - return Url::fromPath('icingadb/usergroup', ['name' => $usergroup->name]); + return Url::fromPath('icingadb/contactgroup', ['name' => $usergroup->name]); } public static function users(): Url diff --git a/library/Icingadb/Model/Usergroup.php b/library/Icingadb/Model/Usergroup.php index 281c9ce5..405cf6ee 100644 --- a/library/Icingadb/Model/Usergroup.php +++ b/library/Icingadb/Model/Usergroup.php @@ -49,11 +49,11 @@ class Usergroup extends Model { return [ 'environment_id' => t('Environment Id'), - 'name_checksum' => t('Usergroup Name Checksum'), - 'properties_checksum' => t('Usergroup Properties Checksum'), - 'name' => t('Usergroup Name'), - 'name_ci' => t('Usergroup Name (CI)'), - 'display_name' => t('Usergroup Display Name'), + 'name_checksum' => t('Contactgroup Name Checksum'), + 'properties_checksum' => t('Contactgroup Properties Checksum'), + 'name' => t('Contactgroup Name'), + 'name_ci' => t('Contactgroup Name (CI)'), + 'display_name' => t('Contactgroup Display Name'), 'zone_id' => t('Zone Id') ]; } diff --git a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php index af196ecd..7244704f 100644 --- a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php +++ b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php @@ -56,7 +56,7 @@ class ObjectSuggestions extends Suggestions 'servicegroup' => t('Servicegroup %s', '..'), 'timeperiod' => t('Timeperiod %s', '..'), 'user' => t('Contact %s', '..'), - 'usergroup' => t('Usergroup %s', '..') + 'usergroup' => t('Contactgroup %s', '..') ]; } diff --git a/library/Icingadb/Widget/ItemList/ObjectList.php b/library/Icingadb/Widget/ItemList/ObjectList.php index f5b88486..40a84e5d 100644 --- a/library/Icingadb/Widget/ItemList/ObjectList.php +++ b/library/Icingadb/Widget/ItemList/ObjectList.php @@ -215,7 +215,7 @@ class ObjectList extends ItemList break; case $object instanceof Usergroup: $this - ->setDetailUrl(Url::fromPath('icingadb/usergroup')) + ->setDetailUrl(Url::fromPath('icingadb/contactgroup')) ->addDetailFilterAttribute($item, Filter::equal('name', $object->name)); break; From 09df9368bf9439e173f2e974b1cca2371d00faed Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 4 Apr 2025 16:09:05 +0200 Subject: [PATCH 8/8] usergroup: Add fallback route which redirects to contactgroup --- .../controllers/UsergroupController.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 application/controllers/UsergroupController.php diff --git a/application/controllers/UsergroupController.php b/application/controllers/UsergroupController.php new file mode 100644 index 00000000..c3546415 --- /dev/null +++ b/application/controllers/UsergroupController.php @@ -0,0 +1,28 @@ +getRequest()->getUrl(); + $url->setPath(preg_replace( + '~^icingadb/usergroup(?=/|$)~', + 'icingadb/contactgroup', + $url->getPath() + )); + + $this->getResponse() + ->setHttpResponseCode(301) + ->setHeader('Location', $url->getAbsoluteUrl()) + ->sendResponse(); + } +}