BLUE
PHP 7.4.33
Path:
/usr/share/phpmyadmin/libraries/classes/Controllers/Server
Run
Logout
Edit File
Size: 3.29 KB
Close
/usr/share/phpmyadmin/libraries/classes/Controllers/Server/UserGroupsFormController.php
Text
Base64
<?php declare(strict_types=1); namespace PhpMyAdmin\Controllers\Server; use PhpMyAdmin\CheckUserPrivileges; use PhpMyAdmin\ConfigStorage\Features\ConfigurableMenusFeature; use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\Controllers\AbstractController; use PhpMyAdmin\DatabaseInterface; use PhpMyAdmin\ResponseRenderer; use PhpMyAdmin\Template; use PhpMyAdmin\Util; use function __; use function sprintf; use function strlen; final class UserGroupsFormController extends AbstractController { /** @var Relation */ private $relation; /** @var DatabaseInterface */ private $dbi; public function __construct( ResponseRenderer $response, Template $template, Relation $relation, DatabaseInterface $dbi ) { parent::__construct($response, $template); $this->relation = $relation; $this->dbi = $dbi; } public function __invoke(): void { $this->response->setAjax(true); if (! isset($_GET['username']) || strlen((string) $_GET['username']) === 0) { $this->response->setRequestStatus(false); $this->response->setHttpResponseCode(400); $this->response->addJSON('message', __('Missing parameter:') . ' username'); return; } $username = $_GET['username']; $checkUserPrivileges = new CheckUserPrivileges($this->dbi); $checkUserPrivileges->getPrivileges(); $configurableMenusFeature = $this->relation->getRelationParameters()->configurableMenusFeature; if ($configurableMenusFeature === null) { $this->response->setRequestStatus(false); $this->response->setHttpResponseCode(400); $this->response->addJSON('message', __('User groups management is not enabled.')); return; } $form = $this->getHtmlToChooseUserGroup($username, $configurableMenusFeature); $this->response->addJSON('message', $form); } /** * Displays a dropdown to select the user group with menu items configured to each of them. */ private function getHtmlToChooseUserGroup( string $username, ConfigurableMenusFeature $configurableMenusFeature ): string { $groupTable = Util::backquote($configurableMenusFeature->database) . '.' . Util::backquote($configurableMenusFeature->userGroups); $userTable = Util::backquote($configurableMenusFeature->database) . '.' . Util::backquote($configurableMenusFeature->users); $sqlQuery = sprintf( 'SELECT `usergroup` FROM %s WHERE `username` = \'%s\'', $userTable, $this->dbi->escapeString($username) ); $userGroup = $this->dbi->fetchValue($sqlQuery, 0, DatabaseInterface::CONNECT_CONTROL); $allUserGroups = []; $sqlQuery = 'SELECT DISTINCT `usergroup` FROM ' . $groupTable; $result = $this->dbi->tryQueryAsControlUser($sqlQuery); if ($result) { while ($row = $result->fetchRow()) { $allUserGroups[$row[0]] = $row[0]; } } return $this->template->render('server/privileges/choose_user_group', [ 'all_user_groups' => $allUserGroups, 'user_group' => $userGroup, 'params' => ['username' => $username], ]); } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 4 × Files: 14
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
Databases
DIR
-
drwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Privileges
DIR
-
drwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Status
DIR
-
drwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Variables
DIR
-
drwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
BinlogController.php
3.64 KB
lrwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
CollationsController.php
2.22 KB
lrwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DatabasesController.php
10.96 KB
lrwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
EnginesController.php
955 B
lrwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ExportController.php
2.53 KB
lrwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ImportController.php
4.26 KB
lrwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
PluginsController.php
1.71 KB
lrwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
PrivilegesController.php
15.59 KB
lrwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ReplicationController.php
3.52 KB
lrwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ShowEngineController.php
1.87 KB
lrwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
SqlController.php
1.32 KB
lrwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
UserGroupsController.php
3.11 KB
lrwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
UserGroupsFormController.php
3.29 KB
lrwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
VariablesController.php
4.29 KB
lrwxr-xr-x
2023-02-07 16:26:36
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).