tbl_row_action.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * handle row specifc actions like edit, delete, export
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. /**
  9. *
  10. */
  11. require_once 'libraries/common.inc.php';
  12. require_once 'libraries/mysql_charsets.lib.php';
  13. /**
  14. * No rows were selected => show again the query and tell that user.
  15. */
  16. if (! PMA_isValid($_REQUEST['rows_to_delete'], 'array')
  17. && ! isset($_REQUEST['mult_btn'])
  18. ) {
  19. $disp_message = __('No rows selected');
  20. $disp_query = '';
  21. include 'sql.php';
  22. exit;
  23. }
  24. if (isset($_REQUEST['submit_mult'])) {
  25. $submit_mult = $_REQUEST['submit_mult'];
  26. // workaround for IE problem:
  27. } elseif (isset($_REQUEST['submit_mult_delete_x'])) {
  28. $submit_mult = 'row_delete';
  29. } elseif (isset($_REQUEST['submit_mult_change_x'])) {
  30. $submit_mult = 'row_edit';
  31. } elseif (isset($_REQUEST['submit_mult_export_x'])) {
  32. $submit_mult = 'row_export';
  33. }
  34. // If the 'Ask for confirmation' button was pressed, this can only come
  35. // from 'delete' mode, so we set it straight away.
  36. if (isset($_REQUEST['mult_btn'])) {
  37. $submit_mult = 'row_delete';
  38. }
  39. switch($submit_mult) {
  40. case 'row_delete':
  41. case 'row_edit':
  42. case 'row_export':
  43. // leave as is
  44. break;
  45. case 'export':
  46. $submit_mult = 'row_export';
  47. break;
  48. case 'delete':
  49. $submit_mult = 'row_delete';
  50. break;
  51. default:
  52. case 'edit':
  53. $submit_mult = 'row_edit';
  54. break;
  55. }
  56. if (!empty($submit_mult)) {
  57. switch($submit_mult) {
  58. case 'row_edit':
  59. // As we got the rows to be edited from the
  60. // 'rows_to_delete' checkbox, we use the index of it as the
  61. // indicating WHERE clause. Then we build the array which is used
  62. // for the tbl_change.php script.
  63. $where_clause = array();
  64. foreach ($_REQUEST['rows_to_delete'] as $i => $i_where_clause) {
  65. $where_clause[] = urldecode($i_where_clause);
  66. }
  67. $active_page = 'tbl_change.php';
  68. include 'tbl_change.php';
  69. break;
  70. case 'row_export':
  71. // Needed to allow SQL export
  72. $single_table = true;
  73. // As we got the rows to be exported from the
  74. // 'rows_to_delete' checkbox, we use the index of it as the
  75. // indicating WHERE clause. Then we build the array which is used
  76. // for the tbl_change.php script.
  77. $where_clause = array();
  78. foreach ($_REQUEST['rows_to_delete'] as $i => $i_where_clause) {
  79. $where_clause[] = urldecode($i_where_clause);
  80. }
  81. $active_page = 'tbl_export.php';
  82. include 'tbl_export.php';
  83. break;
  84. case 'row_delete':
  85. default:
  86. $action = 'tbl_row_action.php';
  87. $err_url = 'tbl_row_action.php'
  88. . PMA_generate_common_url($GLOBALS['url_params']);
  89. if (! isset($_REQUEST['mult_btn'])) {
  90. $original_sql_query = $sql_query;
  91. if (! empty($url_query)) {
  92. $original_url_query = $url_query;
  93. }
  94. }
  95. include 'libraries/mult_submits.inc.php';
  96. $_url_params = $GLOBALS['url_params'];
  97. $_url_params['goto'] = 'tbl_sql.php';
  98. $url_query = PMA_generate_common_url($_url_params);
  99. /**
  100. * Show result of multi submit operation
  101. */
  102. // sql_query is not set when user does not confirm multi-delete
  103. if ((! empty($submit_mult) || isset($_REQUEST['mult_btn']))
  104. && ! empty($sql_query)
  105. ) {
  106. $disp_message = __('Your SQL query has been executed successfully');
  107. $disp_query = $sql_query;
  108. }
  109. if (isset($original_sql_query)) {
  110. $sql_query = $original_sql_query;
  111. }
  112. if (isset($original_url_query)) {
  113. $url_query = $original_url_query;
  114. }
  115. // this is because sql.php could call tbl_structure
  116. // which would think it needs to call mult_submits.inc.php:
  117. unset($submit_mult, $_REQUEST['mult_btn']);
  118. $active_page = 'sql.php';
  119. include 'sql.php';
  120. break;
  121. }
  122. }
  123. ?>