user_preferences.inc.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Common header for user preferences pages
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. use PhpMyAdmin\Config\Forms\User\UserFormList;
  9. use PhpMyAdmin\Message;
  10. use PhpMyAdmin\Relation;
  11. use PhpMyAdmin\Sanitize;
  12. use PhpMyAdmin\TwoFactor;
  13. if (!defined('PHPMYADMIN')) {
  14. exit;
  15. }
  16. // build user preferences menu
  17. $form_param = isset($_GET['form']) ? $_GET['form'] : null;
  18. $tabs_icons = array(
  19. 'Features' => 'b_tblops',
  20. 'Sql' => 'b_sql',
  21. 'Navi' => 'b_select',
  22. 'Main' => 'b_props',
  23. 'Import' => 'b_import',
  24. 'Export' => 'b_export');
  25. $content = PhpMyAdmin\Util::getHtmlTab(
  26. array(
  27. 'link' => 'prefs_manage.php',
  28. 'text' => __('Manage your settings')
  29. )
  30. ) . "\n";
  31. /* Second authentication factor */
  32. $content .= PhpMyAdmin\Util::getHtmlTab(
  33. array(
  34. 'link' => 'prefs_twofactor.php',
  35. 'text' => __('Two-factor authentication')
  36. )
  37. ) . "\n";
  38. $script_name = basename($GLOBALS['PMA_PHP_SELF']);
  39. foreach (UserFormList::getAll() as $formset) {
  40. $formset_class = UserFormList::get($formset);
  41. $tab = array(
  42. 'link' => 'prefs_forms.php',
  43. 'text' => $formset_class::getName(),
  44. 'icon' => $tabs_icons[$formset],
  45. 'active' => ($script_name == 'prefs_forms.php' && $formset == $form_param));
  46. $content .= PhpMyAdmin\Util::getHtmlTab($tab, array('form' => $formset))
  47. . "\n";
  48. }
  49. echo PhpMyAdmin\Template::get('list/unordered')->render(
  50. array(
  51. 'id' => 'topmenu2',
  52. 'class' => 'user_prefs_tabs',
  53. 'content' => $content,
  54. )
  55. );
  56. echo '<div class="clearfloat"></div>';
  57. // show "configuration saved" message and reload navigation panel if needed
  58. if (!empty($_GET['saved'])) {
  59. Message::rawSuccess(__('Configuration has been saved.'))->display();
  60. }
  61. // warn about using session storage for settings
  62. $relation = new Relation();
  63. $cfgRelation = $relation->getRelationsParam();
  64. if (! $cfgRelation['userconfigwork']) {
  65. $msg = __(
  66. 'Your preferences will be saved for current session only. Storing them '
  67. . 'permanently requires %sphpMyAdmin configuration storage%s.'
  68. );
  69. $msg = Sanitize::sanitize(
  70. sprintf($msg, '[doc@linked-tables]', '[/doc]')
  71. );
  72. Message::notice($msg)->display();
  73. }