2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * handle row specific actions like edit, delete, export
12 require_once 'libraries/common.inc.php';
13 require_once 'libraries/mysql_charsets.inc.php';
14 require_once 'libraries/sql.lib.php';
16 if (isset($_REQUEST['submit_mult'])) {
17 $submit_mult = $_REQUEST['submit_mult'];
18 // workaround for IE problem:
19 } elseif (isset($_REQUEST['submit_mult_delete_x'])) {
20 $submit_mult = 'row_delete';
21 } elseif (isset($_REQUEST['submit_mult_change_x'])) {
22 $submit_mult = 'row_edit';
23 } elseif (isset($_REQUEST['submit_mult_export_x'])) {
24 $submit_mult = 'row_export';
27 // If the 'Ask for confirmation' button was pressed, this can only come
28 // from 'delete' mode, so we set it straight away.
29 if (isset($_REQUEST['mult_btn'])) {
30 $submit_mult = 'row_delete';
33 if (! isset($submit_mult)) {
34 $submit_mult = 'row_edit';
37 switch($submit_mult) {
46 $submit_mult = 'row_export';
50 $submit_mult = 'row_delete';
54 $submit_mult = 'row_copy';
59 $submit_mult = 'row_edit';
63 if (!empty($submit_mult)) {
65 if (isset($_REQUEST['goto'])
66 && (! isset($_REQUEST['rows_to_delete'])
67 ||
! is_array($_REQUEST['rows_to_delete']))
69 $response = PMA\libraries\Response
::getInstance();
70 $response->setRequestStatus(false);
71 $response->addJSON('message', __('No row selected.'));
74 switch($submit_mult) {
75 /** @noinspection PhpMissingBreakStatementInspection */
77 $_REQUEST['default_action'] = 'insert';
78 // no break to allow for fallthough
80 // As we got the rows to be edited from the
81 // 'rows_to_delete' checkbox, we use the index of it as the
82 // indicating WHERE clause. Then we build the array which is used
83 // for the tbl_change.php script.
84 $where_clause = array();
85 if (isset($_REQUEST['rows_to_delete'])
86 && is_array($_REQUEST['rows_to_delete'])
88 foreach ($_REQUEST['rows_to_delete'] as $i => $i_where_clause) {
89 $where_clause[] = urldecode($i_where_clause);
92 $active_page = 'tbl_change.php';
93 include 'tbl_change.php';
97 // Needed to allow SQL export
100 // As we got the rows to be exported from the
101 // 'rows_to_delete' checkbox, we use the index of it as the
102 // indicating WHERE clause. Then we build the array which is used
103 // for the tbl_change.php script.
104 $where_clause = array();
105 if (isset($_REQUEST['rows_to_delete'])
106 && is_array($_REQUEST['rows_to_delete'])
108 foreach ($_REQUEST['rows_to_delete'] as $i => $i_where_clause) {
109 $where_clause[] = urldecode($i_where_clause);
112 $active_page = 'tbl_export.php';
113 include 'tbl_export.php';
118 $action = 'tbl_row_action.php';
119 $err_url = 'tbl_row_action.php'
120 . PMA_URL_getCommon($GLOBALS['url_params']);
121 if (! isset($_REQUEST['mult_btn'])) {
122 $original_sql_query = $sql_query;
123 if (! empty($url_query)) {
124 $original_url_query = $url_query;
127 include 'libraries/mult_submits.inc.php';
128 $_url_params = $GLOBALS['url_params'];
129 $_url_params['goto'] = 'tbl_sql.php';
130 $url_query = PMA_URL_getCommon($_url_params);
134 * Show result of multi submit operation
136 // sql_query is not set when user does not confirm multi-delete
137 if ((! empty($submit_mult) ||
isset($_REQUEST['mult_btn']))
138 && ! empty($sql_query)
140 $disp_message = __('Your SQL query has been executed successfully.');
141 $disp_query = $sql_query;
144 if (isset($original_sql_query)) {
145 $sql_query = $original_sql_query;
148 if (isset($original_url_query)) {
149 $url_query = $original_url_query;
152 $active_page = 'sql.php';
154 * Parse and analyze the query
156 include_once 'libraries/parse_analyze.lib.php';
158 $analyzed_sql_results,
161 ) = PMA_parseAnalyze($sql_query, $db);
162 // @todo: possibly refactor
163 extract($analyzed_sql_results);
165 PMA_executeQueryAndSendQueryResponse(
166 $analyzed_sql_results, // analyzed_sql_results
167 false, // is_gotofile
170 null, // find_real_end
171 null, // sql_query_for_bookmark
173 null, // message_to_show
177 $pmaThemeImage, // pmaThemeImage
179 null, // disp_message
181 $sql_query, // sql_query
182 null, // selectedTables
183 null // complete_query