pmd_save_pos.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Save handler for PMD
  5. *
  6. * @package PhpMyAdmin-Designer
  7. */
  8. /**
  9. *
  10. */
  11. require_once './libraries/common.inc.php';
  12. require_once 'libraries/pmd_common.php';
  13. $cfgRelation = PMA_getRelationsParam();
  14. if (! $cfgRelation['designerwork']) {
  15. PMD_errorSave();
  16. }
  17. /**
  18. * Sets globals from $_POST
  19. */
  20. $post_params = array(
  21. 'die_save_pos',
  22. );
  23. foreach ($post_params as $one_post_param) {
  24. if (isset($_POST[$one_post_param])) {
  25. $GLOBALS[$one_post_param] = $_POST[$one_post_param];
  26. }
  27. }
  28. foreach ($_POST['t_x'] as $key => $value) {
  29. // table name decode (post PDF exp/imp)
  30. $KEY = empty($_POST['IS_AJAX']) ? urldecode($key) : $key;
  31. list($DB,$TAB) = explode(".", $KEY);
  32. PMA_queryAsControlUser(
  33. 'DELETE FROM ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
  34. . '.' . PMA_Util::backquote($GLOBALS['cfgRelation']['designer_coords'])
  35. . ' WHERE `db_name` = \'' . PMA_Util::sqlAddSlashes($DB) . '\''
  36. . ' AND `table_name` = \'' . PMA_Util::sqlAddSlashes($TAB) . '\'',
  37. true, PMA_DatabaseInterface::QUERY_STORE
  38. );
  39. PMA_queryAsControlUser(
  40. 'INSERT INTO ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
  41. . '.' . PMA_Util::backquote($GLOBALS['cfgRelation']['designer_coords'])
  42. . ' (db_name, table_name, x, y, v, h)'
  43. . ' VALUES ('
  44. . '\'' . PMA_Util::sqlAddSlashes($DB) . '\', '
  45. . '\'' . PMA_Util::sqlAddSlashes($TAB) . '\', '
  46. . '\'' . PMA_Util::sqlAddSlashes($_POST['t_x'][$key]) . '\', '
  47. . '\'' . PMA_Util::sqlAddSlashes($_POST['t_y'][$key]) . '\', '
  48. . '\'' . PMA_Util::sqlAddSlashes($_POST['t_v'][$key]) . '\', '
  49. . '\'' . PMA_Util::sqlAddSlashes($_POST['t_h'][$key]) . '\')',
  50. true, PMA_DatabaseInterface::QUERY_STORE
  51. );
  52. }
  53. //----------------------------------------------------------------------------
  54. /**
  55. * Error handler
  56. *
  57. * @return void
  58. */
  59. function PMD_errorSave()
  60. {
  61. global $die_save_pos; // if this file included
  62. if (! empty($die_save_pos)) {
  63. header("Content-Type: text/xml; charset=utf-8");
  64. header("Cache-Control: no-cache");
  65. die(
  66. '<root act="save_pos" return="'
  67. . __('Error saving coordinates for Designer.')
  68. . '"></root>'
  69. );
  70. }
  71. }
  72. if (! empty($die_save_pos)) {
  73. header("Content-Type: text/xml; charset=utf-8");
  74. header("Cache-Control: no-cache");
  75. echo '<root act="save_pos" return="'
  76. . __('Modifications have been saved') . '"></root>';
  77. }
  78. ?>