Translated using Weblate (Estonian)
[phpmyadmin.git] / tbl_row_action.php
blobae3b451cf8bbdde63f25f6a17b2575c9b88ae696
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 */
8 declare(strict_types=1);
10 use PhpMyAdmin\Response;
11 use PhpMyAdmin\Sql;
12 use PhpMyAdmin\Url;
14 /**
17 require_once 'libraries/common.inc.php';
19 if (isset($_REQUEST['submit_mult'])) {
20 $submit_mult = $_REQUEST['submit_mult'];
21 // workaround for IE problem:
22 } elseif (isset($_REQUEST['submit_mult_delete_x'])) {
23 $submit_mult = 'row_delete';
24 } elseif (isset($_REQUEST['submit_mult_change_x'])) {
25 $submit_mult = 'row_edit';
26 } elseif (isset($_REQUEST['submit_mult_export_x'])) {
27 $submit_mult = 'row_export';
30 // If the 'Ask for confirmation' button was pressed, this can only come
31 // from 'delete' mode, so we set it straight away.
32 if (isset($_REQUEST['mult_btn'])) {
33 $submit_mult = 'row_delete';
36 if (! isset($submit_mult)) {
37 $submit_mult = 'row_edit';
40 switch ($submit_mult) {
41 case 'row_delete':
42 case 'row_edit':
43 case 'row_copy':
44 case 'row_export':
45 // leave as is
46 break;
48 case 'export':
49 $submit_mult = 'row_export';
50 break;
52 case 'delete':
53 $submit_mult = 'row_delete';
54 break;
56 case 'copy':
57 $submit_mult = 'row_copy';
58 break;
60 case 'edit':
61 default:
62 $submit_mult = 'row_edit';
63 break;
66 if (!empty($submit_mult)) {
67 if (isset($_REQUEST['goto'])
68 && (! isset($_REQUEST['rows_to_delete'])
69 || ! is_array($_REQUEST['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 $_REQUEST['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 = [];
87 if (isset($_REQUEST['rows_to_delete'])
88 && is_array($_REQUEST['rows_to_delete'])
89 ) {
90 foreach ($_REQUEST['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 = [];
107 if (isset($_REQUEST['rows_to_delete'])
108 && is_array($_REQUEST['rows_to_delete'])
110 foreach ($_REQUEST['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($_REQUEST['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($_REQUEST['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