/my/tbl_row_action.php

https://github.com/cabenitez/factuweb · PHP · 165 lines · 85 code · 25 blank · 55 comment · 11 complexity · e1402f56c43f24fa696e1eefdf938531 MD5 · raw file

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * handle row specifc actions like edit, delete, export
  5. *
  6. * @version $Id: tbl_row_action.php 10714 2007-10-04 09:22:50Z cybot_tm $
  7. */
  8. /**
  9. * do not globalize/import request variables
  10. * can only be enabled if all included files are switched superglobals too
  11. * but leave this here to show that this file is 'superglobalized'
  12. define('PMA_NO_VARIABLES_IMPORT', true);
  13. */
  14. /**
  15. *
  16. */
  17. require_once './libraries/common.inc.php';
  18. require_once './libraries/mysql_charsets.lib.php';
  19. /**
  20. * No rows were selected => show again the query and tell that user.
  21. */
  22. if (! PMA_isValid($_REQUEST['rows_to_delete'], 'array')
  23. && ! isset($_REQUEST['mult_btn'])) {
  24. $disp_message = $strNoRowsSelected;
  25. $disp_query = '';
  26. require './sql.php';
  27. require_once './libraries/footer.inc.php';
  28. }
  29. if (isset($_REQUEST['submit_mult'])) {
  30. $submit_mult = $_REQUEST['submit_mult'];
  31. // workaround for IE problem:
  32. } elseif (isset($_REQUEST['submit_mult_delete_x'])) {
  33. $submit_mult = 'row_delete';
  34. } elseif (isset($_REQUEST['submit_mult_change_x'])) {
  35. $submit_mult = 'row_edit';
  36. } elseif (isset($_REQUEST['submit_mult_export_x'])) {
  37. $submit_mult = 'row_export';
  38. }
  39. // garvin: If the 'Ask for confirmation' button was pressed, this can only come
  40. // from 'delete' mode, so we set it straight away.
  41. if (isset($_REQUEST['mult_btn'])) {
  42. $submit_mult = 'row_delete';
  43. }
  44. switch($submit_mult) {
  45. case 'row_delete':
  46. case 'row_edit':
  47. case 'row_export':
  48. // leave as is
  49. break;
  50. case $GLOBALS['strExport']:
  51. $submit_mult = 'row_export';
  52. break;
  53. case $GLOBALS['strDelete']:
  54. case $GLOBALS['strKill']:
  55. $submit_mult = 'row_delete';
  56. break;
  57. default:
  58. case $GLOBALS['strEdit']:
  59. $submit_mult = 'row_edit';
  60. break;
  61. }
  62. $GLOBALS['js_include'][] = 'tbl_change.js';
  63. $GLOBALS['js_include'][] = 'functions.js';
  64. require_once './libraries/header.inc.php';
  65. if (!empty($submit_mult)) {
  66. switch($submit_mult) {
  67. case 'row_edit':
  68. // garvin: As we got the fields to be edited from the 'rows_to_delete'
  69. // checkbox, we use the index of it as the
  70. // indicating primary key. Then we built the array which is used for
  71. // the tbl_change.php script.
  72. /**
  73. * urldecode should not be needed here
  74. $primary_key = array();
  75. foreach ($_REQUEST['rows_to_delete'] as $i_primary_key => $del_query) {
  76. $primary_key[] = urldecode($i_primary_key);
  77. }
  78. */
  79. $primary_key = array_keys($_REQUEST['rows_to_delete']);
  80. $active_page = 'tbl_change.php';
  81. include './tbl_change.php';
  82. break;
  83. case 'row_export':
  84. // Needed to allow SQL export
  85. $single_table = TRUE;
  86. //$sql_query = urldecode($sql_query);
  87. // garvin: As we got the fields to be edited from the 'rows_to_delete'
  88. // checkbox, we use the index of it as the
  89. // indicating primary key. Then we built the array which is used for
  90. // the tbl_change.php script.
  91. /**
  92. * urldecode should not be needed here
  93. $primary_key = array();
  94. foreach ($_REQUEST['rows_to_delete'] as $i_primary_key => $del_query) {
  95. $primary_key[] = urldecode($i_primary_key);
  96. }
  97. */
  98. $primary_key = array_keys($_REQUEST['rows_to_delete']);
  99. $active_page = 'tbl_export.php';
  100. include './tbl_export.php';
  101. break;
  102. case 'row_delete':
  103. default:
  104. $action = 'tbl_row_action.php';
  105. $err_url = 'tbl_row_action.php' . PMA_generate_common_url($GLOBALS['url_params']);
  106. if (! isset($_REQUEST['mult_btn'])) {
  107. $original_sql_query = $sql_query;
  108. $original_url_query = $url_query;
  109. }
  110. require './libraries/mult_submits.inc.php';
  111. $_url_params = $GLOBALS['url_params'];
  112. $_url_params['goto'] = 'tbl_sql.php';
  113. $url_query = PMA_generate_common_url($_url_params);
  114. /**
  115. * Show result of multi submit operation
  116. */
  117. // sql_query is not set when user does not confirm multi-delete
  118. if ((!empty($submit_mult) || isset($_REQUEST['mult_btn'])) && ! empty($sql_query)) {
  119. $disp_message = $strSuccess;
  120. $disp_query = $sql_query;
  121. }
  122. if (isset($original_sql_query)) {
  123. $sql_query = $original_sql_query;
  124. }
  125. if (isset($original_url_query)) {
  126. $url_query = $original_url_query;
  127. }
  128. // this is because sql.php could call tbl_structure
  129. // which would think it needs to call mult_submits.inc.php:
  130. unset($submit_mult, $_REQUEST['mult_btn']);
  131. $active_page = 'sql.php';
  132. require './sql.php';
  133. /**
  134. * Displays the footer
  135. */
  136. require_once './libraries/footer.inc.php';
  137. break;
  138. }
  139. }
  140. ?>