1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Controller for database privileges |
4
|
|
|
* @package PhpMyAdmin\Controllers\Database |
5
|
|
|
*/ |
6
|
|
|
declare(strict_types=1); |
7
|
|
|
|
8
|
|
|
namespace PhpMyAdmin\Controllers\Database; |
9
|
|
|
|
10
|
|
|
use PhpMyAdmin\DatabaseInterface; |
11
|
|
|
use PhpMyAdmin\Response; |
12
|
|
|
use PhpMyAdmin\Server\Privileges; |
13
|
|
|
use PhpMyAdmin\Template; |
14
|
|
|
use PhpMyAdmin\Util; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Controller for database privileges |
18
|
|
|
* @package PhpMyAdmin\Controllers\Database |
19
|
|
|
*/ |
20
|
|
|
class PrivilegesController extends AbstractController |
21
|
|
|
{ |
22
|
|
|
/** @var Privileges */ |
23
|
|
|
private $privileges; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param Response $response Response object |
27
|
|
|
* @param DatabaseInterface $dbi DatabaseInterface object |
28
|
|
|
* @param Template $template Template object |
29
|
|
|
* @param string $db Database name |
30
|
|
|
* @param Privileges $privileges Privileges object |
31
|
|
|
*/ |
32
|
|
|
public function __construct($response, $dbi, Template $template, $db, Privileges $privileges) |
33
|
|
|
{ |
34
|
|
|
parent::__construct($response, $dbi, $template, $db); |
35
|
|
|
$this->privileges = $privileges; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param array $params Request parameters |
40
|
|
|
* |
41
|
|
|
* @return string |
42
|
|
|
*/ |
43
|
|
|
public function index(array $params): string |
44
|
|
|
{ |
45
|
|
|
global $cfg, $pmaThemeImage, $text_dir, $is_createuser, $is_grantuser; |
46
|
|
|
|
47
|
|
|
$scriptName = Util::getScriptNameForOption( |
48
|
|
|
$cfg['DefaultTabDatabase'], |
49
|
|
|
'database' |
50
|
|
|
); |
51
|
|
|
|
52
|
|
|
$privileges = []; |
53
|
|
|
if ($this->dbi->isSuperuser()) { |
54
|
|
|
$privileges = $this->privileges->getAllPrivileges($params['checkprivsdb']); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return $this->template->render('database/privileges/index', [ |
58
|
|
|
'is_superuser' => $this->dbi->isSuperuser(), |
59
|
|
|
'db' => $params['checkprivsdb'], |
60
|
|
|
'database_url' => $scriptName, |
61
|
|
|
'pma_theme_image' => $pmaThemeImage, |
62
|
|
|
'text_dir' => $text_dir, |
63
|
|
|
'is_createuser' => $is_createuser, |
64
|
|
|
'is_grantuser' => $is_grantuser, |
65
|
|
|
'privileges' => $privileges, |
66
|
|
|
]); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|