Improve select all checkbox process on designer and fix a bug
[phpmyadmin.git] / tbl_row_action.php
blob6aa2b2e5597fff30e2772de2262a5625bd51302c
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * handle row specific actions like edit, delete, export
6 * @package PhpMyAdmin
7 */
9 use PhpMyAdmin\Response;
10 use PhpMyAdmin\Sql;
11 use PhpMyAdmin\Url;
13 /**
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) {
40 case 'row_delete':
41 case 'row_edit':
42 case 'row_copy':
43 case 'row_export':
44 // leave as is
45 break;
47 case 'export':
48 $submit_mult = 'row_export';
49 break;
51 case 'delete':
52 $submit_mult = 'row_delete';
53 break;
55 case 'copy':
56 $submit_mult = 'row_copy';
57 break;
59 case 'edit':
60 default:
61 $submit_mult = 'row_edit';
62 break;
65 if (!empty($submit_mult)) {
67 if (isset($_POST['goto'])
68 && (! isset($_POST['rows_to_delete'])
69 || ! is_array($_POST['rows_to_delete']))
70 ) {
71 $response = Response::getInstance();
72 $response->setRequestStatus(false);
73 $response->addJSON('message', __('No row selected.'));
76 switch($submit_mult) {
77 /** @noinspection PhpMissingBreakStatementInspection */
78 case 'row_copy':
79 $_POST['default_action'] = 'insert';
80 // no break to allow for fallthough
81 case 'row_edit':
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'])
89 ) {
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';
96 break;
98 case 'row_export':
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';
116 break;
118 case 'row_delete':
119 default:
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';
155 $sql = new Sql();
156 $sql->executeQueryAndSendQueryResponse(
157 null, // analyzed_sql_results
158 false, // is_gotofile
159 $db, // db
160 $table, // table
161 null, // find_real_end
162 null, // sql_query_for_bookmark
163 null, // extra_data
164 null, // message_to_show
165 null, // message
166 null, // sql_data
167 $goto, // goto
168 $pmaThemeImage, // pmaThemeImage
169 null, // disp_query
170 null, // disp_message
171 null, // query_type
172 $sql_query, // sql_query
173 null, // selectedTables
174 null // complete_query