2016-10-22 14:57:10 +00:00
|
|
|
<?php
|
|
|
|
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
|
|
|
/**
|
|
|
|
* View manipulations
|
|
|
|
*
|
|
|
|
* @package PhpMyAdmin
|
|
|
|
*/
|
2018-04-14 09:18:00 +00:00
|
|
|
use PhpMyAdmin\Message;
|
|
|
|
use PhpMyAdmin\Operations;
|
|
|
|
use PhpMyAdmin\Response;
|
|
|
|
use PhpMyAdmin\Table;
|
|
|
|
use PhpMyAdmin\Url;
|
|
|
|
use PhpMyAdmin\Util;
|
2016-10-22 14:57:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
require_once './libraries/common.inc.php';
|
|
|
|
|
|
|
|
$pma_table = new Table($GLOBALS['table'], $GLOBALS['db']);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load JavaScript files
|
|
|
|
*/
|
|
|
|
$response = Response::getInstance();
|
|
|
|
$header = $response->getHeader();
|
|
|
|
$scripts = $header->getScripts();
|
|
|
|
$scripts->addFile('tbl_operations.js');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Runs common work
|
|
|
|
*/
|
|
|
|
require './libraries/tbl_common.inc.php';
|
|
|
|
$url_query .= '&goto=view_operations.php&back=view_operations.php';
|
|
|
|
$url_params['goto'] = $url_params['back'] = 'view_operations.php';
|
|
|
|
|
2018-04-14 09:18:00 +00:00
|
|
|
$operations = new Operations();
|
2016-10-22 14:57:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates if required
|
|
|
|
*/
|
2018-04-14 09:18:00 +00:00
|
|
|
$_message = new Message;
|
2017-04-20 10:55:30 +00:00
|
|
|
$_type = 'success';
|
2018-12-16 14:31:03 +00:00
|
|
|
if (isset($_POST['submitoptions'])) {
|
2016-10-22 14:57:10 +00:00
|
|
|
|
2018-12-16 14:31:03 +00:00
|
|
|
if (isset($_POST['new_name'])) {
|
|
|
|
if ($pma_table->rename($_POST['new_name'])) {
|
2017-04-20 10:55:30 +00:00
|
|
|
$_message->addText($pma_table->getLastMessage());
|
2016-10-22 14:57:10 +00:00
|
|
|
$result = true;
|
|
|
|
$GLOBALS['table'] = $pma_table->getName();
|
2018-04-14 09:18:00 +00:00
|
|
|
/* Force reread after rename */
|
|
|
|
$pma_table->getStatusInfo(null, true);
|
2016-10-22 14:57:10 +00:00
|
|
|
$reload = true;
|
|
|
|
} else {
|
2017-04-20 10:55:30 +00:00
|
|
|
$_message->addText($pma_table->getLastError());
|
2016-10-22 14:57:10 +00:00
|
|
|
$result = false;
|
|
|
|
}
|
|
|
|
}
|
2017-04-20 10:55:30 +00:00
|
|
|
|
2018-04-14 09:18:00 +00:00
|
|
|
$warning_messages = $operations->getWarningMessagesArray();
|
2016-10-22 14:57:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($result)) {
|
|
|
|
// set to success by default, because result set could be empty
|
|
|
|
// (for example, a table rename)
|
2017-04-20 10:55:30 +00:00
|
|
|
if (empty($_message->getString())) {
|
|
|
|
if ($result) {
|
|
|
|
$_message->addText(
|
|
|
|
__('Your SQL query has been executed successfully.')
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$_message->addText(__('Error'));
|
|
|
|
}
|
2016-10-22 14:57:10 +00:00
|
|
|
// $result should exist, regardless of $_message
|
|
|
|
$_type = $result ? 'success' : 'error';
|
|
|
|
}
|
|
|
|
if (! empty($warning_messages)) {
|
2017-04-20 10:55:30 +00:00
|
|
|
$_message->addMessagesString($warning_messages);
|
2016-10-22 14:57:10 +00:00
|
|
|
$_message->isError(true);
|
|
|
|
unset($warning_messages);
|
|
|
|
}
|
2018-04-14 09:18:00 +00:00
|
|
|
echo Util::getMessage(
|
2016-10-22 14:57:10 +00:00
|
|
|
$_message, $sql_query, $_type
|
|
|
|
);
|
|
|
|
}
|
2017-04-20 10:55:30 +00:00
|
|
|
unset($_message, $_type);
|
2016-10-22 14:57:10 +00:00
|
|
|
|
|
|
|
$url_params['goto'] = 'view_operations.php';
|
|
|
|
$url_params['back'] = 'view_operations.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays the page
|
|
|
|
*/
|
|
|
|
?>
|
|
|
|
<!-- Table operations -->
|
2018-04-14 09:18:00 +00:00
|
|
|
<div>
|
2016-10-22 14:57:10 +00:00
|
|
|
<form method="post" action="view_operations.php">
|
2018-04-14 09:18:00 +00:00
|
|
|
<?php echo Url::getHiddenInputs($GLOBALS['db'], $GLOBALS['table']); ?>
|
2016-10-22 14:57:10 +00:00
|
|
|
<input type="hidden" name="reload" value="1" />
|
|
|
|
<fieldset>
|
|
|
|
<legend><?php echo __('Operations'); ?></legend>
|
|
|
|
|
|
|
|
<table>
|
|
|
|
<!-- Change view name -->
|
|
|
|
<tr><td><?php echo __('Rename view to'); ?></td>
|
2018-04-14 09:18:00 +00:00
|
|
|
<td><input type="text" name="new_name" onfocus="this.select()"
|
2016-10-22 14:57:10 +00:00
|
|
|
value="<?php echo htmlspecialchars($GLOBALS['table']); ?>"
|
|
|
|
required />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</fieldset>
|
|
|
|
<fieldset class="tblFooters">
|
|
|
|
<input type="hidden" name="submitoptions" value="1" />
|
|
|
|
<input type="submit" value="<?php echo __('Go'); ?>" />
|
|
|
|
</fieldset>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
$drop_view_url_params = array_merge(
|
|
|
|
$url_params,
|
|
|
|
array(
|
2018-04-14 09:18:00 +00:00
|
|
|
'sql_query' => 'DROP VIEW ' . Util::backquote(
|
2016-10-22 14:57:10 +00:00
|
|
|
$GLOBALS['table']
|
|
|
|
),
|
|
|
|
'goto' => 'tbl_structure.php',
|
|
|
|
'reload' => '1',
|
|
|
|
'purge' => '1',
|
|
|
|
'message_to_show' => sprintf(
|
|
|
|
__('View %s has been dropped.'),
|
|
|
|
htmlspecialchars($GLOBALS['table'])
|
|
|
|
),
|
|
|
|
'table' => $GLOBALS['table']
|
|
|
|
)
|
|
|
|
);
|
2018-04-14 09:18:00 +00:00
|
|
|
echo '<div>';
|
2016-10-22 14:57:10 +00:00
|
|
|
echo '<fieldset class="caution">';
|
|
|
|
echo '<legend>' , __('Delete data or table') , '</legend>';
|
|
|
|
|
|
|
|
echo '<ul>';
|
2018-04-14 09:18:00 +00:00
|
|
|
echo $operations->getDeleteDataOrTablelink(
|
2016-10-22 14:57:10 +00:00
|
|
|
$drop_view_url_params,
|
|
|
|
'DROP VIEW',
|
|
|
|
__('Delete the view (DROP)'),
|
|
|
|
'drop_view_anchor'
|
|
|
|
);
|
|
|
|
echo '</ul>';
|
|
|
|
echo '</fieldset>';
|
|
|
|
echo '</div>';
|