Translated using Weblate (Slovenian)
[phpmyadmin.git] / tbl_row_action.php
blobb26f1ecf89a22ef252f1ec2af174b8fc4d66ebec
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 $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) {
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 tbl_change.php 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 = 'tbl_change.php';
98 include ROOT_PATH . 'tbl_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 tbl_change.php 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'] = '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';
158 $sql = new Sql();
159 $sql->executeQueryAndSendQueryResponse(
160 null, // analyzed_sql_results
161 false, // is_gotofile
162 $db, // db
163 $table, // table
164 null, // find_real_end
165 null, // sql_query_for_bookmark
166 null, // extra_data
167 null, // message_to_show
168 null, // message
169 null, // sql_data
170 $goto, // goto
171 $pmaThemeImage, // pmaThemeImage
172 null, // disp_query
173 null, // disp_message
174 null, // query_type
175 $sql_query, // sql_query
176 null, // selectedTables
177 null // complete_query