2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * handle row specific actions like edit, delete, export
9 use PhpMyAdmin\Response
;
16 require_once 'libraries/common.inc.php';
18 if (isset($_POST['submit_mult'])) {
19 $submit_mult = $_POST['submit_mult'];
20 // workaround for IE problem:
21 } elseif (isset($_POST['submit_mult_delete_x'])) {
22 $submit_mult = 'row_delete';
23 } elseif (isset($_POST['submit_mult_change_x'])) {
24 $submit_mult = 'row_edit';
25 } elseif (isset($_POST['submit_mult_export_x'])) {
26 $submit_mult = 'row_export';
29 // If the 'Ask for confirmation' button was pressed, this can only come
30 // from 'delete' mode, so we set it straight away.
31 if (isset($_POST['mult_btn'])) {
32 $submit_mult = 'row_delete';
35 if (! isset($submit_mult)) {
36 $submit_mult = 'row_edit';
39 switch($submit_mult) {
48 $submit_mult = 'row_export';
52 $submit_mult = 'row_delete';
56 $submit_mult = 'row_copy';
61 $submit_mult = 'row_edit';
65 if (!empty($submit_mult)) {
67 if (isset($_POST['goto'])
68 && (! isset($_POST['rows_to_delete'])
69 ||
! is_array($_POST['rows_to_delete']))
71 $response = Response
::getInstance();
72 $response->setRequestStatus(false);
73 $response->addJSON('message', __('No row selected.'));
76 switch($submit_mult) {
77 /** @noinspection PhpMissingBreakStatementInspection */
79 $_POST['default_action'] = 'insert';
80 // no break to allow for fallthough
82 // As we got the rows to be edited from the
83 // 'rows_to_delete' checkbox, we use the index of it as the
84 // indicating WHERE clause. Then we build the array which is used
85 // for the tbl_change.php script.
86 $where_clause = array();
87 if (isset($_POST['rows_to_delete'])
88 && is_array($_POST['rows_to_delete'])
90 foreach ($_POST['rows_to_delete'] as $i => $i_where_clause) {
91 $where_clause[] = $i_where_clause;
94 $active_page = 'tbl_change.php';
95 include 'tbl_change.php';
99 // Needed to allow SQL export
100 $single_table = true;
102 // As we got the rows to be exported from the
103 // 'rows_to_delete' checkbox, we use the index of it as the
104 // indicating WHERE clause. Then we build the array which is used
105 // for the tbl_change.php script.
106 $where_clause = array();
107 if (isset($_POST['rows_to_delete'])
108 && is_array($_POST['rows_to_delete'])
110 foreach ($_POST['rows_to_delete'] as $i => $i_where_clause) {
111 $where_clause[] = $i_where_clause;
114 $active_page = 'tbl_export.php';
115 include 'tbl_export.php';
120 $action = 'tbl_row_action.php';
121 $err_url = 'tbl_row_action.php'
122 . Url
::getCommon($GLOBALS['url_params']);
123 if (! isset($_POST['mult_btn'])) {
124 $original_sql_query = $sql_query;
125 if (! empty($url_query)) {
126 $original_url_query = $url_query;
129 include 'libraries/mult_submits.inc.php';
130 $_url_params = $GLOBALS['url_params'];
131 $_url_params['goto'] = 'tbl_sql.php';
132 $url_query = Url
::getCommon($_url_params);
136 * Show result of multi submit operation
138 // sql_query is not set when user does not confirm multi-delete
139 if ((! empty($submit_mult) ||
isset($_POST['mult_btn']))
140 && ! empty($sql_query)
142 $disp_message = __('Your SQL query has been executed successfully.');
143 $disp_query = $sql_query;
146 if (isset($original_sql_query)) {
147 $sql_query = $original_sql_query;
150 if (isset($original_url_query)) {
151 $url_query = $original_url_query;
154 $active_page = 'sql.php';
156 $sql->executeQueryAndSendQueryResponse(
157 null, // analyzed_sql_results
158 false, // is_gotofile
161 null, // find_real_end
162 null, // sql_query_for_bookmark
164 null, // message_to_show
168 $pmaThemeImage, // pmaThemeImage
170 null, // disp_message
172 $sql_query, // sql_query
173 null, // selectedTables
174 null // complete_query