CheckRelationsController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * Displays status of phpMyAdmin configuration storage
  4. */
  5. declare(strict_types=1);
  6. namespace PhpMyAdmin\Controllers;
  7. use PhpMyAdmin\Relation;
  8. use PhpMyAdmin\Response;
  9. use PhpMyAdmin\Template;
  10. class CheckRelationsController extends AbstractController
  11. {
  12. /** @var Relation */
  13. private $relation;
  14. /**
  15. * @param Response $response
  16. */
  17. public function __construct($response, Template $template, Relation $relation)
  18. {
  19. parent::__construct($response, $template);
  20. $this->relation = $relation;
  21. }
  22. public function index(): void
  23. {
  24. global $db;
  25. $params = [
  26. 'create_pmadb' => $_POST['create_pmadb'] ?? null,
  27. 'fixall_pmadb' => $_POST['fixall_pmadb'] ?? null,
  28. 'fix_pmadb' => $_POST['fix_pmadb'] ?? null,
  29. ];
  30. // If request for creating the pmadb
  31. if (isset($params['create_pmadb']) && $this->relation->createPmaDatabase()) {
  32. $this->relation->fixPmaTables('phpmyadmin');
  33. }
  34. // If request for creating all PMA tables.
  35. if (isset($params['fixall_pmadb'])) {
  36. $this->relation->fixPmaTables($db);
  37. }
  38. $cfgRelation = $this->relation->getRelationsParam();
  39. // If request for creating missing PMA tables.
  40. if (isset($params['fix_pmadb'])) {
  41. $this->relation->fixPmaTables($cfgRelation['db']);
  42. }
  43. $this->response->addHTML($this->relation->getRelationsParamDiagnostic($cfgRelation));
  44. }
  45. }