1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Sql;
use PhpMyAdmin\CheckUserPrivileges;
use PhpMyAdmin\Controllers\AbstractController;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Sql;
use PhpMyAdmin\Template;
final class RelationalValuesController extends AbstractController
{
/** @var Sql */
private $sql;
/** @var CheckUserPrivileges */
private $checkUserPrivileges;
public function __construct(
ResponseRenderer $response,
Template $template,
Sql $sql,
CheckUserPrivileges $checkUserPrivileges
) {
parent::__construct($response, $template);
$this->sql = $sql;
$this->checkUserPrivileges = $checkUserPrivileges;
}
/**
* Get values for the relational columns
*
* During grid edit, if we have a relational field, show the dropdown for it.
*/
public function __invoke(): void
{
global $db, $table;
$this->checkUserPrivileges->getPrivileges();
$column = $_POST['column'];
if (
$_SESSION['tmpval']['relational_display'] === 'D'
&& isset($_POST['relation_key_or_display_column'])
&& $_POST['relation_key_or_display_column']
) {
$curr_value = $_POST['relation_key_or_display_column'];
} else {
$curr_value = $_POST['curr_value'];
}
$dropdown = $this->sql->getHtmlForRelationalColumnDropdown($db, $table, $column, $curr_value);
$this->response->addJSON('dropdown', $dropdown);
}
}
|