3.3.3-rc1
[phpmyadmin/tyronm.git] / tbl_move_copy.php
blob208dcd6274385a1bb7217f586ee147a3779c2953
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 * @package phpMyAdmin
7 */
9 /**
10 * Gets some core libraries
12 require_once './libraries/common.inc.php';
13 require_once './libraries/Table.class.php';
15 // Check parameters
17 PMA_checkParameters(array('db', 'table'));
19 /**
20 * Defines the url to return to in case of error in a sql statement
22 $err_url = 'tbl_sql.php?' . PMA_generate_common_url($db, $table);
25 /**
26 * Selects the database to work with
28 PMA_DBI_select_db($db);
30 $goto = $cfg['DefaultTabTable'];
32 /**
33 * $_REQUEST['target_db'] could be empty in case we came from an input field
34 * (when there are many databases, no drop-down)
36 if (empty($_REQUEST['target_db'])) {
37 $_REQUEST['target_db'] = $db;
40 /**
41 * A target table name has been sent to this script -> do the work
43 if (PMA_isValid($_REQUEST['new_name'])) {
44 if ($db == $_REQUEST['target_db'] && $table == $_REQUEST['new_name']) {
45 if (isset($_REQUEST['submit_move'])) {
46 $message = PMA_Message::error('strMoveTableSameNames');
47 } else {
48 $message = PMA_Message::error('strCopyTableSameNames');
50 $goto = './tbl_operations.php';
51 } else {
52 PMA_Table::moveCopy($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name'],
53 $_REQUEST['what'], isset($_REQUEST['submit_move']), 'one_table');
55 if (isset($_REQUEST['submit_move'])) {
56 $message = PMA_Message::success('strMoveTableOK');
57 } else {
58 $message = PMA_Message::success('strCopyTableOK');
60 $old = PMA_backquote($db) . '.' . PMA_backquote($table);
61 $message->addParam($old);
62 $new = PMA_backquote($_REQUEST['target_db']) . '.' . PMA_backquote($_REQUEST['new_name']);
63 $message->addParam($new);
65 /* Check: Work on new table or on old table? */
66 if (isset($_REQUEST['submit_move']) || PMA_isValid($_REQUEST['switch_to_new'])) {
67 $db = $_REQUEST['target_db'];
68 $table = $_REQUEST['new_name'];
70 $reload = 1;
72 $disp_query = $sql_query;
73 $disp_message = $message;
74 unset($sql_query, $message);
76 $goto = $cfg['DefaultTabTable'];
78 } else {
79 /**
80 * No new name for the table!
82 $message = PMA_Message::error('strTableEmpty');
83 $goto = './tbl_operations.php';
86 /**
87 * Back to the calling script
89 require $goto;