2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Displays the 'User groups' sub page under 'Users' page.
8 declare(strict_types
=1);
10 use PhpMyAdmin\DatabaseInterface
;
11 use PhpMyAdmin\Relation
;
12 use PhpMyAdmin\Response
;
13 use PhpMyAdmin\Server\UserGroups
;
14 use PhpMyAdmin\Server\Users
;
16 if (! defined('ROOT_PATH')) {
17 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
20 require_once ROOT_PATH
. 'libraries/common.inc.php';
22 /** @var Response $response */
23 $response = $containerBuilder->get(Response
::class);
25 /** @var DatabaseInterface $dbi */
26 $dbi = $containerBuilder->get(DatabaseInterface
::class);
28 /** @var Relation $relation */
29 $relation = $containerBuilder->get('relation');
30 $cfgRelation = $relation->getRelationsParam();
31 if (! $cfgRelation['menuswork']) {
35 $header = $response->getHeader();
36 $scripts = $header->getScripts();
37 $scripts->addFile('server/user_groups.js');
40 * Only allowed to superuser
42 if (! $dbi->isSuperuser()) {
44 PhpMyAdmin\Message
::error(__('No Privileges'))
50 $response->addHTML('<div>');
51 $response->addHTML(Users
::getHtmlForSubMenusOnUsersPage('server_user_groups.php'));
56 if (! empty($_POST['deleteUserGroup'])) {
57 UserGroups
::delete($_POST['userGroup']);
61 * Add a new user group
63 if (! empty($_POST['addUserGroupSubmit'])) {
64 UserGroups
::edit($_POST['userGroup'], true);
70 if (! empty($_POST['editUserGroupSubmit'])) {
71 UserGroups
::edit($_POST['userGroup']);
74 if (isset($_POST['viewUsers'])) {
75 // Display users belonging to a user group
76 $response->addHTML(UserGroups
::getHtmlForListingUsersofAGroup($_POST['userGroup']));
79 if (isset($_GET['addUserGroup'])) {
80 // Display add user group dialog
81 $response->addHTML(UserGroups
::getHtmlToEditUserGroup());
82 } elseif (isset($_POST['editUserGroup'])) {
83 // Display edit user group dialog
84 $response->addHTML(UserGroups
::getHtmlToEditUserGroup($_POST['userGroup']));
86 // Display user groups table
87 $response->addHTML(UserGroups
::getHtmlForUserGroupsTable());
90 $response->addHTML('</div>');