Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / tbl_move_copy.php
blobb21f295585794bfd25107c008118311bb0a22cbf
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package PhpMyAdmin
6 */
8 /**
9 * Gets some core libraries
11 require_once 'libraries/common.inc.php';
13 // Check parameters
14 PMA_Util::checkParameters(array('db', 'table'));
16 /**
17 * Defines the url to return to in case of error in a sql statement
19 $err_url = 'tbl_sql.php?' . PMA_generate_common_url($db, $table);
22 /**
23 * Selects the database to work with
25 PMA_DBI_select_db($db);
27 $goto = $cfg['DefaultTabTable'];
29 /**
30 * $_REQUEST['target_db'] could be empty in case we came from an input field
31 * (when there are many databases, no drop-down)
33 if (empty($_REQUEST['target_db'])) {
34 $_REQUEST['target_db'] = $db;
37 /**
38 * A target table name has been sent to this script -> do the work
40 if (PMA_isValid($_REQUEST['new_name'])) {
41 if ($db == $_REQUEST['target_db'] && $table == $_REQUEST['new_name']) {
42 if (isset($_REQUEST['submit_move'])) {
43 $message = PMA_Message::error(__('Can\'t move table to same one!'));
44 } else {
45 $message = PMA_Message::error(__('Can\'t copy table to same one!'));
47 $result = false;
48 } else {
49 $result = PMA_Table::moveCopy(
50 $db, $table, $_REQUEST['target_db'], $_REQUEST['new_name'],
51 $_REQUEST['what'], isset($_REQUEST['submit_move']), 'one_table'
54 if (isset($_REQUEST['submit_move'])) {
55 $message = PMA_Message::success(__('Table %s has been moved to %s.'));
56 } else {
57 $message = PMA_Message::success(__('Table %s has been copied to %s.'));
59 $old = PMA_Util::backquote($db) . '.'
60 . PMA_Util::backquote($table);
61 $message->addParam($old);
62 $new = PMA_Util::backquote($_REQUEST['target_db']) . '.'
63 . PMA_Util::backquote($_REQUEST['new_name']);
64 $message->addParam($new);
66 /* Check: Work on new table or on old table? */
67 if (isset($_REQUEST['submit_move'])
68 || PMA_isValid($_REQUEST['switch_to_new'])
69 ) {
70 $db = $_REQUEST['target_db'];
71 $table = $_REQUEST['new_name'];
73 $reload = 1;
75 } else {
76 /**
77 * No new name for the table!
79 $message = PMA_Message::error(__('The table name is empty!'));
80 $result = false;
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']);
88 $response->addJSON(
89 'sql_query',
90 PMA_Util::getMessage(null, $sql_query)
92 } else {
93 $response->isSuccess(false);
95 exit;
98 /**
99 * Back to the calling script
101 $_message = $message;
102 unset($message);