Translation update done using Pootle.
[phpmyadmin.git] / tbl_move_copy.php
blob00a8a3981d06f2f34eb2712badb3e87820decd9c
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
15 PMA_checkParameters(array('db', 'table'));
17 /**
18 * Defines the url to return to in case of error in a sql statement
20 $err_url = 'tbl_sql.php?' . PMA_generate_common_url($db, $table);
23 /**
24 * Selects the database to work with
26 PMA_DBI_select_db($db);
28 $goto = $cfg['DefaultTabTable'];
30 /**
31 * $_REQUEST['target_db'] could be empty in case we came from an input field
32 * (when there are many databases, no drop-down)
34 if (empty($_REQUEST['target_db'])) {
35 $_REQUEST['target_db'] = $db;
38 /**
39 * A target table name has been sent to this script -> do the work
41 if (PMA_isValid($_REQUEST['new_name'])) {
42 if ($db == $_REQUEST['target_db'] && $table == $_REQUEST['new_name']) {
43 if (isset($_REQUEST['submit_move'])) {
44 $message = PMA_Message::error(__('Can\'t move table to same one!'));
45 } else {
46 $message = PMA_Message::error(__('Can\'t copy table to same one!'));
48 $result = false;
49 } else {
50 $result = PMA_Table::moveCopy($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name'],
51 $_REQUEST['what'], isset($_REQUEST['submit_move']), 'one_table');
53 if (isset($_REQUEST['submit_move'])) {
54 $message = PMA_Message::success(__('Table %s has been moved to %s.'));
55 } else {
56 $message = PMA_Message::success(__('Table %s has been copied to %s.'));
58 $old = PMA_backquote($db) . '.' . PMA_backquote($table);
59 $message->addParam($old);
60 $new = PMA_backquote($_REQUEST['target_db']) . '.' . PMA_backquote($_REQUEST['new_name']);
61 $message->addParam($new);
63 /* Check: Work on new table or on old table? */
64 if (isset($_REQUEST['submit_move']) || PMA_isValid($_REQUEST['switch_to_new'])) {
65 $db = $_REQUEST['target_db'];
66 $table = $_REQUEST['new_name'];
69 if ( $_REQUEST['ajax_request'] == true) {
70 $extra_data['sql_query'] = PMA_showMessage(null, $sql_query);
71 $extra_data['db'] = $GLOBALS['db'];
72 PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
75 $reload = 1;
77 } else {
78 /**
79 * No new name for the table!
81 $message = PMA_Message::error(__('The table name is empty!'));
82 $result = false;
85 /**
86 * Back to the calling script
88 $_message = $message;
89 unset($message);