server_user_groups.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Displays the 'User groups' sub page under 'Users' page.
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. use PhpMyAdmin\Relation;
  9. use PhpMyAdmin\Response;
  10. use PhpMyAdmin\Server\UserGroups;
  11. use PhpMyAdmin\Server\Users;
  12. require_once 'libraries/common.inc.php';
  13. $relation = new Relation();
  14. $cfgRelation = $relation->getRelationsParam();
  15. if (! $cfgRelation['menuswork']) {
  16. exit;
  17. }
  18. $response = Response::getInstance();
  19. $header = $response->getHeader();
  20. $scripts = $header->getScripts();
  21. $scripts->addFile('server_user_groups.js');
  22. /**
  23. * Only allowed to superuser
  24. */
  25. if (! $GLOBALS['dbi']->isSuperuser()) {
  26. $response->addHTML(
  27. PhpMyAdmin\Message::error(__('No Privileges'))
  28. ->getDisplay()
  29. );
  30. exit;
  31. }
  32. $response->addHTML('<div>');
  33. $response->addHTML(Users::getHtmlForSubMenusOnUsersPage('server_user_groups.php'));
  34. /**
  35. * Delete user group
  36. */
  37. if (! empty($_POST['deleteUserGroup'])) {
  38. UserGroups::delete($_POST['userGroup']);
  39. }
  40. /**
  41. * Add a new user group
  42. */
  43. if (! empty($_POST['addUserGroupSubmit'])) {
  44. UserGroups::edit($_POST['userGroup'], true);
  45. }
  46. /**
  47. * Update a user group
  48. */
  49. if (! empty($_POST['editUserGroupSubmit'])) {
  50. UserGroups::edit($_POST['userGroup']);
  51. }
  52. if (isset($_POST['viewUsers'])) {
  53. // Display users belonging to a user group
  54. $response->addHTML(UserGroups::getHtmlForListingUsersofAGroup($_POST['userGroup']));
  55. }
  56. if (isset($_GET['addUserGroup'])) {
  57. // Display add user group dialog
  58. $response->addHTML(UserGroups::getHtmlToEditUserGroup());
  59. } elseif (isset($_POST['editUserGroup'])) {
  60. // Display edit user group dialog
  61. $response->addHTML(UserGroups::getHtmlToEditUserGroup($_POST['userGroup']));
  62. } else {
  63. // Display user groups table
  64. $response->addHTML(UserGroups::getHtmlForUserGroupsTable());
  65. }
  66. $response->addHTML('</div>');