Add ChangeLog entry for #15592
[phpmyadmin.git] / view_operations.php
blob5fd9ab8f0a6dae1a1f44acae5fbc00e649dbb0a1
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * View manipulations
6 * @package PhpMyAdmin
7 */
8 use PhpMyAdmin\Message;
9 use PhpMyAdmin\Operations;
10 use PhpMyAdmin\Response;
11 use PhpMyAdmin\Table;
12 use PhpMyAdmin\Url;
13 use PhpMyAdmin\Util;
15 /**
18 require_once './libraries/common.inc.php';
20 $pma_table = new Table($GLOBALS['table'], $GLOBALS['db']);
22 /**
23 * Load JavaScript files
25 $response = Response::getInstance();
26 $header = $response->getHeader();
27 $scripts = $header->getScripts();
28 $scripts->addFile('tbl_operations.js');
30 /**
31 * Runs common work
33 require './libraries/tbl_common.inc.php';
34 $url_query .= '&amp;goto=view_operations.php&amp;back=view_operations.php';
35 $url_params['goto'] = $url_params['back'] = 'view_operations.php';
37 $operations = new Operations();
39 /**
40 * Updates if required
42 $_message = new Message;
43 $_type = 'success';
44 if (isset($_POST['submitoptions'])) {
46 if (isset($_POST['new_name'])) {
47 if ($pma_table->rename($_POST['new_name'])) {
48 $_message->addText($pma_table->getLastMessage());
49 $result = true;
50 $GLOBALS['table'] = $pma_table->getName();
51 /* Force reread after rename */
52 $pma_table->getStatusInfo(null, true);
53 $reload = true;
54 } else {
55 $_message->addText($pma_table->getLastError());
56 $result = false;
60 $warning_messages = $operations->getWarningMessagesArray();
63 if (isset($result)) {
64 // set to success by default, because result set could be empty
65 // (for example, a table rename)
66 if (empty($_message->getString())) {
67 if ($result) {
68 $_message->addText(
69 __('Your SQL query has been executed successfully.')
71 } else {
72 $_message->addText(__('Error'));
74 // $result should exist, regardless of $_message
75 $_type = $result ? 'success' : 'error';
77 if (! empty($warning_messages)) {
78 $_message->addMessagesString($warning_messages);
79 $_message->isError(true);
80 unset($warning_messages);
82 echo Util::getMessage(
83 $_message, $sql_query, $_type
86 unset($_message, $_type);
88 $url_params['goto'] = 'view_operations.php';
89 $url_params['back'] = 'view_operations.php';
91 /**
92 * Displays the page
95 <!-- Table operations -->
96 <div>
97 <form method="post" action="view_operations.php">
98 <?php echo Url::getHiddenInputs($GLOBALS['db'], $GLOBALS['table']); ?>
99 <input type="hidden" name="reload" value="1" />
100 <fieldset>
101 <legend><?php echo __('Operations'); ?></legend>
103 <table>
104 <!-- Change view name -->
105 <tr><td><?php echo __('Rename view to'); ?></td>
106 <td><input type="text" name="new_name" onfocus="this.select()"
107 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>"
108 required />
109 </td>
110 </tr>
111 </table>
112 </fieldset>
113 <fieldset class="tblFooters">
114 <input type="hidden" name="submitoptions" value="1" />
115 <input type="submit" value="<?php echo __('Go'); ?>" />
116 </fieldset>
117 </form>
118 </div>
119 <?php
120 $drop_view_url_params = array_merge(
121 $url_params,
122 array(
123 'sql_query' => 'DROP VIEW ' . Util::backquote(
124 $GLOBALS['table']
126 'goto' => 'tbl_structure.php',
127 'reload' => '1',
128 'purge' => '1',
129 'message_to_show' => sprintf(
130 __('View %s has been dropped.'),
131 htmlspecialchars($GLOBALS['table'])
133 'table' => $GLOBALS['table']
136 echo '<div>';
137 echo '<fieldset class="caution">';
138 echo '<legend>' , __('Delete data or table') , '</legend>';
140 echo '<ul>';
141 echo $operations->getDeleteDataOrTablelink(
142 $drop_view_url_params,
143 'DROP VIEW',
144 __('Delete the view (DROP)'),
145 'drop_view_anchor'
147 echo '</ul>';
148 echo '</fieldset>';
149 echo '</div>';