2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * handle row specific actions like edit, delete, export
8 declare(strict_types
=1);
10 use PhpMyAdmin\Response
;
14 if (! defined('ROOT_PATH')) {
15 define('ROOT_PATH', __DIR__
. DIRECTORY_SEPARATOR
);
18 global $db, $pmaThemeImage, $sql_query, $table;
20 require_once ROOT_PATH
. 'libraries/common.inc.php';
22 if (isset($_POST['submit_mult'])) {
23 $submit_mult = $_POST['submit_mult'];
24 // workaround for IE problem:
25 } elseif (isset($_POST['submit_mult_delete_x'])) {
26 $submit_mult = 'row_delete';
27 } elseif (isset($_POST['submit_mult_change_x'])) {
28 $submit_mult = 'row_edit';
29 } elseif (isset($_POST['submit_mult_export_x'])) {
30 $submit_mult = 'row_export';
33 // If the 'Ask for confirmation' button was pressed, this can only come
34 // from 'delete' mode, so we set it straight away.
35 if (isset($_POST['mult_btn'])) {
36 $submit_mult = 'row_delete';
39 if (! isset($submit_mult)) {
40 $submit_mult = 'row_edit';
43 switch ($submit_mult) {
52 $submit_mult = 'row_export';
56 $submit_mult = 'row_delete';
60 $submit_mult = 'row_copy';
65 $submit_mult = 'row_edit';
69 if (! empty($submit_mult)) {
70 if (isset($_POST['goto'])
71 && (! isset($_POST['rows_to_delete'])
72 ||
! is_array($_POST['rows_to_delete']))
74 $response = Response
::getInstance();
75 $response->setRequestStatus(false);
76 $response->addJSON('message', __('No row selected.'));
79 switch ($submit_mult) {
80 /** @noinspection PhpMissingBreakStatementInspection */
82 $_POST['default_action'] = 'insert';
83 // no break to allow for fallthough
85 // As we got the rows to be edited from the
86 // 'rows_to_delete' checkbox, we use the index of it as the
87 // indicating WHERE clause. Then we build the array which is used
88 // for the tbl_change.php script.
90 if (isset($_POST['rows_to_delete'])
91 && is_array($_POST['rows_to_delete'])
93 foreach ($_POST['rows_to_delete'] as $i => $i_where_clause) {
94 $where_clause[] = $i_where_clause;
97 $active_page = 'tbl_change.php';
98 include ROOT_PATH
. 'tbl_change.php';
102 // Needed to allow SQL export
103 $single_table = true;
105 // As we got the rows to be exported from the
106 // 'rows_to_delete' checkbox, we use the index of it as the
107 // indicating WHERE clause. Then we build the array which is used
108 // for the tbl_change.php script.
110 if (isset($_POST['rows_to_delete'])
111 && is_array($_POST['rows_to_delete'])
113 foreach ($_POST['rows_to_delete'] as $i => $i_where_clause) {
114 $where_clause[] = $i_where_clause;
117 $active_page = 'tbl_export.php';
118 include ROOT_PATH
. 'tbl_export.php';
123 $action = 'tbl_row_action.php';
124 $err_url = 'tbl_row_action.php'
125 . Url
::getCommon($GLOBALS['url_params']);
126 if (! isset($_POST['mult_btn'])) {
127 $original_sql_query = $sql_query;
128 if (! empty($url_query)) {
129 $original_url_query = $url_query;
132 include ROOT_PATH
. 'libraries/mult_submits.inc.php';
133 $_url_params = $GLOBALS['url_params'];
134 $_url_params['goto'] = 'tbl_sql.php';
135 $url_query = Url
::getCommon($_url_params);
139 * Show result of multi submit operation
141 // sql_query is not set when user does not confirm multi-delete
142 if ((! empty($submit_mult) ||
isset($_POST['mult_btn']))
143 && ! empty($sql_query)
145 $disp_message = __('Your SQL query has been executed successfully.');
146 $disp_query = $sql_query;
149 if (isset($original_sql_query)) {
150 $sql_query = $original_sql_query;
153 if (isset($original_url_query)) {
154 $url_query = $original_url_query;
157 $active_page = 'sql.php';
159 $sql->executeQueryAndSendQueryResponse(
160 null, // analyzed_sql_results
161 false, // is_gotofile
164 null, // find_real_end
165 null, // sql_query_for_bookmark
167 null, // message_to_show
171 $pmaThemeImage, // pmaThemeImage
173 null, // disp_message
175 $sql_query, // sql_query
176 null, // selectedTables
177 null // complete_query