Translated using Weblate (Persian)
[phpmyadmin.git] / server_user_groups.php
blobcd0b269f450418a33c2fd74a38a56d66533932c6
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Displays the 'User groups' sub page under 'Users' page.
6 * @package PhpMyAdmin
7 */
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']) {
32 exit;
35 $header = $response->getHeader();
36 $scripts = $header->getScripts();
37 $scripts->addFile('server/user_groups.js');
39 /**
40 * Only allowed to superuser
42 if (! $dbi->isSuperuser()) {
43 $response->addHTML(
44 PhpMyAdmin\Message::error(__('No Privileges'))
45 ->getDisplay()
47 exit;
50 $response->addHTML('<div>');
51 $response->addHTML(Users::getHtmlForSubMenusOnUsersPage('server_user_groups.php'));
53 /**
54 * Delete user group
56 if (! empty($_POST['deleteUserGroup'])) {
57 UserGroups::delete($_POST['userGroup']);
60 /**
61 * Add a new user group
63 if (! empty($_POST['addUserGroupSubmit'])) {
64 UserGroups::edit($_POST['userGroup'], true);
67 /**
68 * Update a user group
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']));
85 } else {
86 // Display user groups table
87 $response->addHTML(UserGroups::getHtmlForUserGroupsTable());
90 $response->addHTML('</div>');