Merge pull request #431 from xmujay/0609_monitor
[phpmyadmin/aamir.git] / view_operations.php
blob3be8ce94d6aacd6962be1539c2232496f5718450
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * View manipulations
6 * @package PhpMyAdmin
7 */
9 /**
12 require_once './libraries/common.inc.php';
14 $pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
16 /**
17 * Runs common work
19 require './libraries/tbl_common.inc.php';
20 $url_query .= '&amp;goto=view_operations.php&amp;back=view_operations.php';
21 $url_params['goto'] = $url_params['back'] = 'view_operations.php';
23 /**
24 * Gets tables informations
27 require './libraries/tbl_info.inc.php';
28 $reread_info = false;
30 /**
31 * Updates if required
33 if (isset($_REQUEST['submitoptions'])) {
34 $_message = '';
35 $warning_messages = array();
37 if (isset($_REQUEST['new_name'])) {
38 if ($pma_table->rename($_REQUEST['new_name'])) {
39 $_message .= $pma_table->getLastMessage();
40 $result = true;
41 $GLOBALS['table'] = $pma_table->getName();
42 $reread_info = true;
43 $reload = true;
44 } else {
45 $_message .= $pma_table->getLastError();
46 $result = false;
51 if (isset($result)) {
52 // set to success by default, because result set could be empty
53 // (for example, a table rename)
54 $_type = 'success';
55 if (empty($_message)) {
56 $_message = $result
57 ? __('Your SQL query has been executed successfully')
58 : __('Error');
59 // $result should exist, regardless of $_message
60 $_type = $result ? 'success' : 'error';
62 if (! empty($warning_messages)) {
63 $_message = new PMA_Message;
64 $_message->addMessages($warning_messages);
65 $_message->isError(true);
66 unset($warning_messages);
68 echo PMA_Util::getMessage(
69 $_message, $sql_query, $_type, $is_view = true
71 unset($_message, $_type);
74 $url_params['goto'] = 'view_operations.php';
75 $url_params['back'] = 'view_operations.php';
77 /**
78 * Displays the page
81 <!-- Table operations -->
82 <div class="operations_half_width">
83 <form method="post" action="view_operations.php">
84 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
85 <input type="hidden" name="reload" value="1" />
86 <fieldset>
87 <legend><?php echo __('Operations'); ?></legend>
89 <table>
90 <!-- Change view name -->
91 <tr><td><?php echo __('Rename view to'); ?></td>
92 <td><input type="text" size="20" name="new_name" onfocus="this.select()"
93 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" />
94 </td>
95 </tr>
96 </table>
97 </fieldset>
98 <fieldset class="tblFooters">
99 <input type="submit" name="submitoptions" value="<?php echo __('Go'); ?>" />
100 </fieldset>
101 </form>
102 </div>