Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 104 lines (91 sloc) 2.798 kb
7ff8fed Initial revision
Olivier Müller authored
1 <?php
817e790 synced/fixed vim line
Sebastian Mendel authored
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
374abd5 fixed/added page level docblock
Sebastian Mendel authored
3 /**
4 *
e56949f Michal Čihař Use package name PhpMyAdmin
nijel authored
5 * @package PhpMyAdmin
374abd5 fixed/added page level docblock
Sebastian Mendel authored
6 */
7ff8fed Initial revision
Olivier Müller authored
7
0ab0ad6 Marc Delisle merge Loic's version
lem9 authored
8 /**
9 * Gets some core libraries
10 */
b2fd866 Leading ./ paths for includes can be omitted, part 2
Jo Michael authored
11 require_once 'libraries/common.inc.php';
7ff8fed Initial revision
Olivier Müller authored
12
7664661 Chanaka Indrajith Dharmarathna Implement class behavior of common.lib.php file
Chanaka authored
13 // Check parameters
e6894be Chanaka Indrajith Dharmarathna Renamed ->method() with PMA_Util::method()
Chanaka authored
14 PMA_Util::checkParameters(array('db', 'table'));
1293dc1 Michal Čihař Implemented database copying (RFE #996730), this forced separating code ...
nijel authored
15
0ab0ad6 Marc Delisle merge Loic's version
lem9 authored
16 /**
e726fe7 Fixed bug #444352 (Data Missing/POST Error)
Loïc Chapeaux authored
17 * Defines the url to return to in case of error in a sql statement
18 */
ad06b4a Michal Čihař Rename tbl_* files to drop useless _properties part.
nijel authored
19 $err_url = 'tbl_sql.php?' . PMA_generate_common_url($db, $table);
e726fe7 Fixed bug #444352 (Data Missing/POST Error)
Loïc Chapeaux authored
20
21
22 /**
0ab0ad6 Marc Delisle merge Loic's version
lem9 authored
23 * Selects the database to work with
24 */
2915b5c Alexander M. Turek Added MySQLi library; Removed calls to old mysql_wrappers library.
derrabus authored
25 PMA_DBI_select_db($db);
0ab0ad6 Marc Delisle merge Loic's version
lem9 authored
26
eda10ae make use of PMA_Message
Sebastian Mendel authored
27 $goto = $cfg['DefaultTabTable'];
28
84ae042 Michal Čihař Adding @package, third part.
nijel authored
29 /**
30 * $_REQUEST['target_db'] could be empty in case we came from an input field
823687a Marc Delisle bug #1859460, prevent an empty target_db field to produce a failure, tha...
lem9 authored
31 * (when there are many databases, no drop-down)
32 */
33 if (empty($_REQUEST['target_db'])) {
34 $_REQUEST['target_db'] = $db;
35 }
36
0ab0ad6 Marc Delisle merge Loic's version
lem9 authored
37 /**
38 * A target table name has been sent to this script -> do the work
39 */
eda10ae make use of PMA_Message
Sebastian Mendel authored
40 if (PMA_isValid($_REQUEST['new_name'])) {
41 if ($db == $_REQUEST['target_db'] && $table == $_REQUEST['new_name']) {
42 if (isset($_REQUEST['submit_move'])) {
7925c03 Marc Delisle gettext conversion
lem9 authored
43 $message = PMA_Message::error(__('Can\'t move table to same one!'));
eda10ae make use of PMA_Message
Sebastian Mendel authored
44 } else {
7925c03 Marc Delisle gettext conversion
lem9 authored
45 $message = PMA_Message::error(__('Can\'t copy table to same one!'));
eda10ae make use of PMA_Message
Sebastian Mendel authored
46 }
6acf4ac Atul Pratap Singh auto get back to the Table Operations tab
zixtor authored
47 $result = false;
4d46667 Michal Čihař Check for same table and db name when moving (RFE #734985).
nijel authored
48 } else {
3332151 Madhura Jayaratne Fix Checkstyle Warnings - Type: CloseBracketLine (Closing parenthesis of...
madhuracj authored
49 $result = PMA_Table::moveCopy(
50 $db, $table, $_REQUEST['target_db'], $_REQUEST['new_name'],
51 $_REQUEST['what'], isset($_REQUEST['submit_move']), 'one_table'
52 );
eda10ae make use of PMA_Message
Sebastian Mendel authored
53
54 if (isset($_REQUEST['submit_move'])) {
7925c03 Marc Delisle gettext conversion
lem9 authored
55 $message = PMA_Message::success(__('Table %s has been moved to %s.'));
98be3e0 Move to new table after copying cookiefied.
Garvin Hicking authored
56 } else {
7925c03 Marc Delisle gettext conversion
lem9 authored
57 $message = PMA_Message::success(__('Table %s has been copied to %s.'));
98be3e0 Move to new table after copying cookiefied.
Garvin Hicking authored
58 }
e6894be Chanaka Indrajith Dharmarathna Renamed ->method() with PMA_Util::method()
Chanaka authored
59 $old = PMA_Util::backquote($db) . '.'
60 . PMA_Util::backquote($table);
107fc46 make use of PMA_Message
Sebastian Mendel authored
61 $message->addParam($old);
e6894be Chanaka Indrajith Dharmarathna Renamed ->method() with PMA_Util::method()
Chanaka authored
62 $new = PMA_Util::backquote($_REQUEST['target_db']) . '.'
63 . PMA_Util::backquote($_REQUEST['new_name']);
107fc46 make use of PMA_Message
Sebastian Mendel authored
64 $message->addParam($new);
eda10ae make use of PMA_Message
Sebastian Mendel authored
65
66 /* Check: Work on new table or on old table? */
9a47688 Madhura Jayaratne Various coding style improvements
madhuracj authored
67 if (isset($_REQUEST['submit_move'])
68 || PMA_isValid($_REQUEST['switch_to_new'])
69 ) {
a16e723 Rouslan Placella Dropped PMA_ajaxResponse()
roccivic authored
70 $db = $_REQUEST['target_db'];
71 $table = $_REQUEST['new_name'];
eda10ae make use of PMA_Message
Sebastian Mendel authored
72 }
73 $reload = 1;
74 }
75 } else {
76 /**
77 * No new name for the table!
78 */
7925c03 Marc Delisle gettext conversion
lem9 authored
79 $message = PMA_Message::error(__('The table name is empty!'));
6acf4ac Atul Pratap Singh auto get back to the Table Operations tab
zixtor authored
80 $result = false;
7f919e6 removed tabs and/or trailing spaces
Loïc Chapeaux authored
81 }
0ab0ad6 Marc Delisle merge Loic's version
lem9 authored
82
a16e723 Rouslan Placella Dropped PMA_ajaxResponse()
roccivic authored
83 if ($GLOBALS['is_ajax_request'] == true) {
84 $response = PMA_Response::getInstance();
85 $response->addJSON('message', $message);
86 if ($message->isSuccess()) {
87 $response->addJSON('db', $GLOBALS['db']);
7664661 Chanaka Indrajith Dharmarathna Implement class behavior of common.lib.php file
Chanaka authored
88 $response->addJSON(
89 'sql_query',
e6894be Chanaka Indrajith Dharmarathna Renamed ->method() with PMA_Util::method()
Chanaka authored
90 PMA_Util::getMessage(null, $sql_query)
7664661 Chanaka Indrajith Dharmarathna Implement class behavior of common.lib.php file
Chanaka authored
91 );
a16e723 Rouslan Placella Dropped PMA_ajaxResponse()
roccivic authored
92 } else {
93 $response->isSuccess(false);
94 }
95 exit;
96 }
97
0ab0ad6 Marc Delisle merge Loic's version
lem9 authored
98 /**
99 * Back to the calling script
100 */
6acf4ac Atul Pratap Singh auto get back to the Table Operations tab
zixtor authored
101 $_message = $message;
102 unset($message);
7ff8fed Initial revision
Olivier Müller authored
103 ?>
Something went wrong with that request. Please try again.