Translated using Weblate (Portuguese)
[phpmyadmin.git] / tbl_row_action.php
blobc04b332860619e4810aa6032e4b4befe02b5dfa1
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 if (! defined('ROOT_PATH')) {
15 define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
18 global $containerBuilder, $db, $goto, $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) {
44 case 'row_delete':
45 case 'row_edit':
46 case 'row_copy':
47 case 'row_export':
48 // leave as is
49 break;
51 case 'export':
52 $submit_mult = 'row_export';
53 break;
55 case 'delete':
56 $submit_mult = 'row_delete';
57 break;
59 case 'copy':
60 $submit_mult = 'row_copy';
61 break;
63 case 'edit':
64 default:
65 $submit_mult = 'row_edit';
66 break;
69 if (! empty($submit_mult)) {
70 if (isset($_POST['goto'])
71 && (! isset($_POST['rows_to_delete'])
72 || ! is_array($_POST['rows_to_delete']))
73 ) {
74 $response = Response::getInstance();
75 $response->setRequestStatus(false);
76 $response->addJSON('message', __('No row selected.'));
79 switch ($submit_mult) {
80 /** @noinspection PhpMissingBreakStatementInspection */
81 case 'row_copy':
82 $_POST['default_action'] = 'insert';
83 // no break to allow for fallthough
84 case 'row_edit':
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 /table/change script.
89 $where_clause = [];
90 if (isset($_POST['rows_to_delete'])
91 && is_array($_POST['rows_to_delete'])
92 ) {
93 foreach ($_POST['rows_to_delete'] as $i => $i_where_clause) {
94 $where_clause[] = $i_where_clause;
97 $active_page = Url::getFromRoute('/table/change');
98 include ROOT_PATH . 'libraries/entry_points/table/change.php';
99 break;
101 case 'row_export':
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 /table/change script.
109 $where_clause = [];
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';
119 break;
121 case 'row_delete':
122 default:
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'] = Url::getFromRoute('/table/sql');
135 $url_query = Url::getCommon($_url_params);
138 * Show result of multi submit operation
140 // sql_query is not set when user does not confirm multi-delete
141 if ((! empty($submit_mult) || isset($_POST['mult_btn']))
142 && ! empty($sql_query)
144 $disp_message = __('Your SQL query has been executed successfully.');
145 $disp_query = $sql_query;
148 if (isset($original_sql_query)) {
149 $sql_query = $original_sql_query;
152 if (isset($original_url_query)) {
153 $url_query = $original_url_query;
156 $active_page = Url::getFromRoute('/sql');
157 $sql = new Sql();
158 $sql->executeQueryAndSendQueryResponse(
159 null, // analyzed_sql_results
160 false, // is_gotofile
161 $db, // db
162 $table, // table
163 null, // find_real_end
164 null, // sql_query_for_bookmark
165 null, // extra_data
166 null, // message_to_show
167 null, // message
168 null, // sql_data
169 $goto, // goto
170 $pmaThemeImage, // pmaThemeImage
171 null, // disp_query
172 null, // disp_message
173 null, // query_type
174 $sql_query, // sql_query
175 null, // selectedTables
176 null // complete_query