Merge branch 'master' of github.com:phpmyadmin/phpmyadmin

This commit is contained in:
Madhura Jayaratne 2015-07-06 13:17:34 +05:30
commit 69fd08be9c
39 changed files with 2353 additions and 1072 deletions

View File

@ -79,6 +79,8 @@ phpMyAdmin - ChangeLog
- bug #4972 Incorrect length computed for binary data
- bug Remove character set from create_tables_drizzle.sql
- bug #4973 Users overview needs clarification
- bug #4974 Creating a database from console doesn't update navigation panel
- bug #4844 FAQ 1.17 needs an update
4.4.10.0 (2015-06-17)
- bug #4950 Issues in database selection for replication

View File

@ -21,6 +21,7 @@ require_once 'libraries/mysql_charsets.inc.php';
/**
* functions implementation for this script
*/
require_once 'libraries/check_user_privileges.lib.php';
require_once 'libraries/operations.lib.php';
// add a javascript file for jQuery functions to handle Ajax actions

View File

@ -16,6 +16,7 @@ require_once 'libraries/mysql_charsets.inc.php';
/**
* Include all other files
*/
require_once 'libraries/check_user_privileges.lib.php';
require_once 'libraries/rte/rte_routines.lib.php';
/**

View File

@ -186,24 +186,16 @@ hosting provider is unwilling to change the settings:
.. _faq1_17:
1.17 Which MySQL versions does phpMyAdmin support?
--------------------------------------------------
1.17 Which Database versions does phpMyAdmin support?
-----------------------------------------------------
Since phpMyAdmin 3.0.x, only MySQL 5.0.1 and newer are supported. For
older MySQL versions, you need to use the latest 2.x branch.
phpMyAdmin can connect to your MySQL server using PHP's classic `MySQL
extension <http://php.net/mysql>`_ as well as the `improved MySQL
extension (MySQLi) <http://php.net/mysqli>`_ that is available in PHP
5.0. The latter one should be used unless you have a good reason not
to do so. When compiling PHP, we strongly recommend that you manually
link the MySQL extension of your choice to a MySQL client library of
at least the same minor version since the one that is bundled with
some PHP distributions is rather old and might cause problems see
:ref:`faq1_17a`. `MariaDB <http://mariadb.org/>`_ is also supported
(versions 5.1 and 5.2 were tested).
For `MySQL <http://www.mysql.com/>`_, versions 5.5 and newer are supported.
For older MySQL versions, our `Downloads <https://www.phpmyadmin.net/downloads/>`_ page offers older phpMyAdmin versions
(which may have become unsupported).
.. versionchanged:: 3.5
Since phpMyAdmin 3.5 `Drizzle <http://www.drizzle.org/>`_ is supported.
For `MariaDB <http://mariadb.org/>`_, versions 5.5 and newer are supported.
For `Drizzle <http://www.drizzle.org>`_, versions 7.1 and newer are supported.
.. _faq1_17a:
@ -1878,7 +1870,7 @@ to display the plot.
After the plot is generated, you can use the
mousewheel to zoom in and out of the plot. In addition, panning
feature is enabled to navigate through the plot. You can zoom-in to a
certail level of detail and use panning to locate your area of
certain level of detail and use panning to locate your area of
interest. Clicking on a point opens a dialogue box, displaying field
values of the data row represented by the point. You can edit the
values if required and click on submit to issue an update query. Basic
@ -1980,7 +1972,7 @@ On startup of the wizard, user gets to select upto what normal form they want to
normalize the table structure.
Here is an example table which you can use to test all of the three First, Second and
Third Normal From.
Third Normal Form.
.. code-block:: mysql
@ -2065,6 +2057,13 @@ Notes:
*column-related privileges* for the columns inside the table are also adjusted
to the table's new name.
* While adjusting privileges, the user performing the operation **must** have the following
privileges:
* SELECT, INSERT, UPDATE, DELETE privileges on following tables:
`mysql`.`db`, `mysql`.`columns_priv`, `mysql`.`tables_priv`, `mysql`.`procs_priv`
* FLUSH privilege (GLOBAL)
Thus, if you want to replicate the database/table/column/procedure as it is
while renaming/copying/moving these objects, make sure you have checked this option.

View File

@ -259,6 +259,7 @@ var PMA_console = {
.val(PMA_consoleMessages.appendQuery({sql_query: queryString}).message_id);
PMA_console.$requestForm.trigger('submit');
PMA_consoleInput.clear();
PMA_reloadNavigation();
},
ajaxCallback: function(data) {
if (data && data.console_message_id) {

View File

@ -14,6 +14,208 @@ if (! defined('PHPMYADMIN')) {
*/
$GLOBALS['is_superuser'] = $GLOBALS['dbi']->isSuperuser();
/**
* Check if user has required privileges for
* performing 'FLUSH PRIVILEGES' operation
*
* @return void
*/
function PMA_checkRequiredPrivilegesForFlushing()
{
$res = $GLOBALS['dbi']->tryQuery(
'FLUSH PRIVILEGES'
);
// Save the value
$GLOBALS['flush_priv'] = $res;
}
/**
* Check if user has required privileges for
* performing 'Adjust Privileges' operations
*
* @return void
*/
function PMA_checkRequiredPrivilgesForAdjust()
{
$privs_available = true;
// FOR DB PRIVS
$select_privs_available = $GLOBALS['dbi']->tryQuery(
'SELECT * FROM `mysql`.`db` LIMIT 1'
);
$privs_available = $select_privs_available && $privs_available;
if ($privs_available) {
$delete_privs_available = $GLOBALS['dbi']->tryQuery(
'DELETE FROM `mysql`.`db` WHERE `host` = "" AND '
. '`Db` = "" AND `User` = "" LIMIT 1;'
);
$privs_available = $delete_privs_available && $privs_available;
}
if ($privs_available) {
$insert_privs_available = $GLOBALS['dbi']->tryQuery(
'INSERT INTO `mysql`.`db`(`host`, `Db`, `User`) VALUES("pma_test_host", '
. '"mysql", "pma_test_user");'
);
// If successful test insert, delete the test row
if ($insert_privs_available) {
$GLOBALS['dbi']->tryQuery(
'DELETE FROM `mysql`.`db` WHERE host = "pma_test_host" AND '
. 'Db = "mysql" AND User = "pma_test_user" LIMIT 1;'
);
}
$privs_available = $insert_privs_available && $privs_available;
}
if ($privs_available) {
$update_privs_available = $GLOBALS['dbi']->tryQuery(
'UPDATE `mysql`.`db` SET `host` = "" WHERE `host` = "" AND '
. '`Db` = "" AND `User` = "" LIMIT 1;'
);
$privs_available = $update_privs_available && $privs_available;
}
// save the value
$GLOBALS['db_priv'] = $privs_available;
// reset the value
$privs_available = true;
// FOR COLUMNS_PRIV
$select_privs_available = $GLOBALS['dbi']->tryQuery(
'SELECT * FROM `mysql`.`columns_priv` LIMIT 1'
);
$privs_available = $select_privs_available && $privs_available;
if ($privs_available) {
$delete_privs_available = $GLOBALS['dbi']->tryQuery(
'DELETE FROM `mysql`.`columns_priv` WHERE `host` = "" AND '
. '`Db` = "" AND `User` = "" LIMIT 1;'
);
$privs_available = $delete_privs_available && $privs_available;
}
if ($privs_available) {
$insert_privs_available = $GLOBALS['dbi']->tryQuery(
'INSERT INTO `mysql`.`columns_priv`(`host`, `Db`, `User`, `Table_name`,'
. ' `Column_name`) VALUES("pma_test_host", '
. '"mysql", "pma_test_user", "", "")'
);
// If successful test insert, delete the test row
if ($insert_privs_available) {
$GLOBALS['dbi']->tryQuery(
'DELETE FROM `mysql`.`columns_priv` WHERE host = "pma_test_host" AND '
. 'Db = "mysql" AND User = "pma_test_user" AND Table_name = ""'
. ' AND Column_name = "" LIMIT 1;'
);
}
$privs_available = $insert_privs_available && $privs_available;
}
if ($privs_available) {
$update_privs_available = $GLOBALS['dbi']->tryQuery(
'UPDATE `mysql`.`columns_priv` SET `host` = "" WHERE `host` = "" AND '
. '`Db` = "" AND `User` = "" AND Column_name = "" AND Table_name = "" LIMIT 1;'
);
$privs_available = $update_privs_available && $privs_available;
}
// Save the value
$GLOBALS['col_priv'] = $privs_available;
// Reset the value
$privs_available = true;
// FOR TABLES_PRIV
$select_privs_available = $GLOBALS['dbi']->tryQuery(
'SELECT * FROM `mysql`.`tables_priv` LIMIT 1'
);
$privs_available = $select_privs_available && $privs_available;
if ($privs_available) {
$delete_privs_available = $GLOBALS['dbi']->tryQuery(
'DELETE FROM `mysql`.`tables_priv` WHERE `host` = "" AND '
. '`Db` = "" AND `User` = "" AND Table_name = "" LIMIT 1;'
);
$privs_available = $delete_privs_available && $privs_available;
}
if ($privs_available) {
$insert_privs_available = $GLOBALS['dbi']->tryQuery(
'INSERT INTO `mysql`.`tables_priv`(`host`, `Db`, `User`, `Table_name`'
. ') VALUES("pma_test_host", '
. '"mysql", "pma_test_user", "")'
);
// If successful test insert, delete the test row
if ($insert_privs_available) {
$GLOBALS['dbi']->tryQuery(
'DELETE FROM `mysql`.`tables_priv` WHERE host = "pma_test_host" AND '
. 'Db = "mysql" AND User = "pma_test_user" AND Table_name = "" LIMIT 1;'
);
}
$privs_available = $insert_privs_available && $privs_available;
}
if ($privs_available) {
$update_privs_available = $GLOBALS['dbi']->tryQuery(
'UPDATE `mysql`.`tables_priv` SET `host` = "" WHERE `host` = "" AND '
. '`Db` = "" AND `User` = "" AND Table_name = "" LIMIT 1;'
);
$privs_available = $update_privs_available && $privs_available;
}
// Save the value
$GLOBALS['table_priv'] = $privs_available;
// Reset the value
$privs_available = true;
// FOR PROCS_PRIV
$select_privs_available = $GLOBALS['dbi']->tryQuery(
'SELECT * FROM `mysql`.`procs_priv` LIMIT 1'
);
$privs_available = $select_privs_available && $privs_available;
if ($privs_available) {
$delete_privs_available = $GLOBALS['dbi']->tryQuery(
'DELETE FROM `mysql`.`procs_priv` WHERE `host` = "" AND '
. '`Db` = "" AND `User` = "" AND `Routine_name` = ""'
. ' AND `Routine_type` = "" LIMIT 1;'
);
$privs_available = $delete_privs_available && $privs_available;
}
if ($privs_available) {
$insert_privs_available = $GLOBALS['dbi']->tryQuery(
'INSERT INTO `mysql`.`procs_priv`(`host`, `Db`, `User`, `Routine_name`,'
. ' `Routine_type`) VALUES("pma_test_host", '
. '"mysql", "pma_test_user", "", "PROCEDURE")'
);
// If successful test insert, delete the test row
if ($insert_privs_available) {
$GLOBALS['dbi']->tryQuery(
'DELETE FROM `mysql`.`procs_priv` WHERE `host` = "pma_test_host" AND '
. '`Db` = "mysql" AND `User` = "pma_test_user" AND `Routine_name` = ""'
. ' AND `Routine_type` = "PROCEDURE" LIMIT 1;'
);
}
$privs_available = $insert_privs_available && $privs_available;
}
if ($privs_available) {
$update_privs_available = $GLOBALS['dbi']->tryQuery(
'UPDATE `mysql`.`procs_priv` SET `host` = "" WHERE `host` = "" AND '
. '`Db` = "" AND `User` = "" AND `Routine_name` = "" LIMIT 1;'
);
$privs_available = $update_privs_available && $privs_available;
}
// Save the value
$GLOBALS['proc_priv'] = $privs_available;
}
/**
* sets privilege information extracted from SHOW GRANTS result
*
@ -185,6 +387,13 @@ if (!PMA_DRIZZLE) {
} else {
PMA_analyseShowGrant();
}
// Check if privileges to 'mysql'.col_privs, 'mysql'.db,
// 'mysql'.table_privs, 'mysql'.proc_privs and privileges for
// flushing the privileges are available
PMA_checkRequiredPrivilegesForFlushing();
PMA_checkRequiredPrivilgesForAdjust();
} else {
// todo: for simple_user_policy only database with user's login can be created
// (unless logged in as root)

View File

@ -395,6 +395,7 @@ class FormDisplay
$opts['errors'] = $this->_errors[$work_path];
}
$type = '';
switch ($form->getOptionType($field)) {
case 'string':
$type = 'text';

View File

@ -0,0 +1,53 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds the PMA\TableController
*
* @package PMA
*/
namespace PMA\Controllers;
use PMA\DI\Container;
use PMA_DatabaseInterface;
use PMA_Response;
if (!defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/Response.class.php';
require_once 'libraries/di/Container.class.php';
require_once 'libraries/database_interface.inc.php';
/**
* Base class for all of controller
*
* @package PhpMyAdmin
*/
abstract class Controller
{
/**
* @var PMA_Response
*/
protected $response;
/**
* @var PMA_DatabaseInterface
*/
protected $dbi;
/**
* @var Container
*/
protected $container;
function __construct()
{
$container = Container::getDefaultContainer();
$this->container = $container;
$this->dbi = $this->container->get('dbi');
$this->response = PMA_Response::getInstance();
}
}

View File

@ -0,0 +1,223 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds the PMA\TableChartController
*
* @package PMA
*/
namespace PMA\Controllers\Table;
use PMA\DI\Container;
use PMA_Util;
use PMA_Message;
use PMA\Template;
use PMA\Controllers\TableController;
require_once 'libraries/common.inc.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/Message.class.php';
require_once 'libraries/Template.class.php';
require_once 'libraries/controllers/TableController.class.php';
/**
* Handles table related logic
*
* @package PhpMyAdmin
*/
class TableChartController extends TableController
{
/**
* @var string $sql_query
*/
protected $sql_query;
/**
* @var $url_query
*/
protected $url_query;
/**
* @var array $cfg
*/
protected $cfg;
function __construct($sql_query, $url_query, $cfg)
{
parent::__construct();
$this->sql_query = $sql_query;
$this->url_query = $url_query;
$this->cfg = $cfg;
}
/*
* Execute the query and return the result
*/
public function indexAction()
{
if (isset($_REQUEST['ajax_request'])
&& isset($_REQUEST['pos'])
&& isset($_REQUEST['session_max_rows'])
) {
$this->ajaxAction();
return;
}
// Throw error if no sql query is set
if (!isset($this->sql_query) || $this->sql_query == '') {
$this->response->isSuccess(false);
$this->response->addHTML(
PMA_Message::error(__('No SQL query was set to fetch data.'))
);
return;
}
$this->response->getHeader()->getScripts()->addFiles(array(
'chart.js',
'tbl_chart.js',
'jqplot/jquery.jqplot.js',
'jqplot/plugins/jqplot.barRenderer.js',
'jqplot/plugins/jqplot.canvasAxisLabelRenderer.js',
'jqplot/plugins/jqplot.canvasTextRenderer.js',
'jqplot/plugins/jqplot.categoryAxisRenderer.js',
'jqplot/plugins/jqplot.dateAxisRenderer.js',
'jqplot/plugins/jqplot.pointLabels.js',
'jqplot/plugins/jqplot.pieRenderer.js',
'jqplot/plugins/jqplot.highlighter.js'
));
/**
* Extract values for common work
* @todo Extract common files
*/
$db = &$this->db;
$table = &$this->table;
/**
* Runs common work
*/
if (/*overload*/
mb_strlen($this->table)
) {
$url_params['goto'] = PMA_Util::getScriptNameForOption(
$this->cfg['DefaultTabTable'], 'table'
);
$url_params['back'] = 'tbl_sql.php';
include 'libraries/tbl_common.inc.php';
include 'libraries/tbl_info.inc.php';
} elseif (/*overload*/
mb_strlen($this->db)
) {
$url_params['goto'] = PMA_Util::getScriptNameForOption(
$this->cfg['DefaultTabDatabase'], 'database'
);
$url_params['back'] = 'sql.php';
include 'libraries/db_common.inc.php';
include 'libraries/db_info.inc.php';
} else {
$url_params['goto'] = PMA_Util::getScriptNameForOption(
$this->cfg['DefaultTabServer'], 'server'
);
$url_params['back'] = 'sql.php';
include 'libraries/server_common.inc.php';
}
$data = array();
$result = $this->dbi->tryQuery($this->sql_query);
$fields_meta = $this->dbi->getFieldsMeta($result);
while ($row = $this->dbi->fetchAssoc($result)) {
$data[] = $row;
}
$keys = array_keys($data[0]);
$numeric_types = array('int', 'real');
$numeric_column_count = 0;
foreach ($keys as $idx => $key) {
if (in_array($fields_meta[$idx]->type, $numeric_types)) {
$numeric_column_count++;
}
}
if ($numeric_column_count == 0) {
$this->response->isSuccess(false);
$this->response->addJSON(
'message',
__('No numeric columns present in the table to plot.')
);
return;
}
$url_params['db'] = $this->db;
$url_params['reload'] = 1;
/**
* Displays the page
*/
$this->response->addHTML(Template::get('tbl_chart')
->render(array(
'url_query' => $this->url_query,
'url_params' => $url_params,
'keys' => $keys,
'fields_meta' => $fields_meta,
'numeric_types' => $numeric_types,
'numeric_column_count' => $numeric_column_count,
'sql_query' => $this->sql_query
)));
}
/**
* Handle ajax request
*/
public function ajaxAction()
{
/**
* Extract values for common work
* @todo Extract common files
*/
$db = &$this->db;
$table = &$this->table;
$tableLength = /*overload*/
mb_strlen($this->table);
$dbLength = /*overload*/
mb_strlen($this->db);
if ($tableLength && $dbLength) {
include './libraries/tbl_common.inc.php';
}
$sql_with_limit = sprintf(
'SELECT * FROM(%s) AS `temp_res` LIMIT %s, %s',
$this->sql_query,
$_REQUEST['pos'],
$_REQUEST['session_max_rows']
);
$data = array();
$result = $this->dbi->tryQuery($sql_with_limit);
while ($row = $this->dbi->fetchAssoc($result)) {
$data[] = $row;
}
if (empty($data)) {
$this->response->isSuccess(false);
$this->response->addJSON('message', __('No data to display'));
return;
}
$sanitized_data = array();
foreach ($data as $data_row_number => $data_row) {
$tmp_row = array();
foreach ($data_row as $data_column => $data_value) {
$tmp_row[htmlspecialchars($data_column)] = htmlspecialchars($data_value);
}
$sanitized_data[] = $tmp_row;
}
$this->response->isSuccess(true);
$this->response->addJSON('message', null);
$this->response->addJSON('chartData', json_encode($sanitized_data));
}
}

View File

@ -0,0 +1,42 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds the PMA\TableController
*
* @package PMA
*/
namespace PMA\Controllers;
use PMA\DI\Container;
if (!defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/controllers/Controller.class.php';
/**
* Handles table related logic
*
* @package PhpMyAdmin
*/
abstract class TableController extends Controller
{
/**
* @var string $db
*/
protected $db;
/**
* @var string $table
*/
protected $table;
function __construct()
{
parent::__construct();
$this->db = $this->container->get('db');
$this->table = $this->container->get('table');
}
}

View File

@ -0,0 +1,176 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds the PMA\TableIndexesController
*
* @package PMA
*/
namespace PMA\Controllers\Table;
use PMA\Template;
use PMA_GIS_Visualization;
use PMA_Message;
use PMA\Controllers\TableController;
require_once 'libraries/common.inc.php';
require_once 'libraries/db_common.inc.php';
require_once 'libraries/controllers/TableController.class.php';
require_once 'libraries/gis/GIS_Visualization.class.php';
require_once 'libraries/gis/GIS_Factory.class.php';
require_once 'libraries/Message.class.php';
class TableGisVisualizationController extends TableController
{
/**
* @var array $url_params
*/
protected $url_params;
/**
* @var string $sql_query
*/
protected $sql_query;
/**
* @var array $visualizationSettings
*/
protected $visualizationSettings;
/**
* @var PMA_GIS_Visualization $visualization
*/
protected $visualization;
public function __construct($sql_query, $url_params, $goto, $back, $visualizationSettings) {
parent::__construct();
$this->sql_query = $sql_query;
$this->url_params = $url_params;
$this->url_params['goto'] = $goto;
$this->url_params['back'] = $back;
$this->visualizationSettings = $visualizationSettings;
}
public function saveToFileAction() {
$this->response->disable();
$file_name = $this->visualizationSettings['spatialColumn'];
$save_format = $_REQUEST['fileFormat'];
$this->visualization->toFile($file_name, $save_format);
}
public function indexAction() {
// Throw error if no sql query is set
if (! isset($this->sql_query) || $this->sql_query == '') {
$this->response->isSuccess(false);
$this->response->addHTML(
PMA_Message::error(__('No SQL query was set to fetch data.'))
);
return;
}
// Execute the query and return the result
$result = $this->dbi->tryQuery($this->sql_query);
// Get the meta data of results
$meta = $this->dbi->getFieldsMeta($result);
// Find the candidate fields for label column and spatial column
$labelCandidates = array();
$spatialCandidates = array();
foreach ($meta as $column_meta) {
if ($column_meta->type == 'geometry') {
$spatialCandidates[] = $column_meta->name;
} else {
$labelCandidates[] = $column_meta->name;
}
}
// Get settings if any posted
if (PMA_isValid($_REQUEST['visualizationSettings'], 'array')) {
$this->visualizationSettings = $_REQUEST['visualizationSettings'];
}
if (! isset($this->visualizationSettings['labelColumn']) && isset($labelCandidates[0])) {
$this->visualizationSettings['labelColumn'] = '';
}
// If spatial column is not set, use first geometric column as spatial column
if (! isset($this->visualizationSettings['spatialColumn'])) {
$this->visualizationSettings['spatialColumn'] = $spatialCandidates[0];
}
// Convert geometric columns from bytes to text.
$pos = isset($_REQUEST['pos']) ? $_REQUEST['pos'] : $_SESSION['tmpval']['pos'];
if (isset($_REQUEST['session_max_rows'])) {
$rows = $_REQUEST['session_max_rows'];
} else {
if ($_SESSION['tmpval']['max_rows'] != 'all') {
$rows = $_SESSION['tmpval']['max_rows'];
} else {
$rows = $GLOBALS['cfg']['MaxRows'];
}
}
$this->visualization = PMA_GIS_Visualization::get(
$this->sql_query,
$this->visualizationSettings,
$rows,
$pos
);
if (isset($_REQUEST['saveToFile'])) {
$this->saveToFileAction();
return;
}
$this->response->getHeader()->getScripts()->addFiles(
array(
'openlayers/OpenLayers.js',
'jquery/jquery.svg.js',
'tbl_gis_visualization.js',
'OpenStreetMap.js'
)
);
// If all the rows contain SRID, use OpenStreetMaps on the initial loading.
if (! isset($_REQUEST['displayVisualization'])) {
if ($this->visualization->hasSrid())
unset($this->visualizationSettings['choice']);
$this->visualizationSettings['choice'] = 'useBaseLayer';
}
$this->visualization->setUserSpecifiedSettings($this->visualizationSettings);
if ($this->visualizationSettings != null) {
foreach ($this->visualization->getSettings() as $setting => $val) {
if (! isset($this->visualizationSettings[$setting])) {
$this->visualizationSettings[$setting] = $val;
}
}
}
/**
* Displays the page
*/
$this->url_params['sql_query'] = $this->sql_query;
$downloadUrl = 'tbl_gis_visualization.php' . PMA_URL_getCommon($this->url_params)
. '&saveToFile=true';
$svgSupport = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER <= 8)
? false : true;
$html = Template::get('gis_visualization/gis_visualization')->render(
array(
'url_params' => $this->url_params,
'downloadUrl' => $downloadUrl,
'labelCandidates' => $labelCandidates,
'spatialCandidates' => $spatialCandidates,
'visualizationSettings' => $this->visualizationSettings,
'sql_query' => $this->sql_query,
'visualization' => $this->visualization->toImage($svgSupport ? 'svg' : 'png'),
'svgSupport' => $svgSupport,
'drawOl' => $this->visualization->asOl()
)
);
$this->response->addHTML($html);
}
}

View File

@ -0,0 +1,159 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds the PMA\TableIndexesController
*
* @package PMA
*/
namespace PMA\Controllers\Table;
use PMA\Controllers\TableController;
use PMA_Index;
use PMA_Message;
use PMA_Response;
use PMA\Template;
use PMA_Util;
require_once 'libraries/common.inc.php';
require_once 'libraries/Index.class.php';
require_once 'libraries/Message.class.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/Index.class.php';
require_once 'libraries/controllers/TableController.class.php';
require_once 'libraries/Template.class.php';
class TableIndexesController extends TableController
{
/**
* @var PMA_Index $index
*/
protected $index;
function __construct($index)
{
parent::__construct();
$this->index = $index;
}
public function indexAction()
{
if (isset($_REQUEST['do_save_data'])) {
$this->doSaveDataAction();
return;
} // end builds the new index
$this->displayFormAction();
}
/**
* Display the form to edit/create an index
*/
public function displayFormAction()
{
include_once 'libraries/tbl_info.inc.php';
$add_fields = 0;
if (isset($_REQUEST['index']) && is_array($_REQUEST['index'])) {
// coming already from form
if (isset($_REQUEST['index']['columns']['names'])) {
$add_fields = count($_REQUEST['index']['columns']['names'])
- $this->index->getColumnCount();
}
if (isset($_REQUEST['add_fields'])) {
$add_fields += $_REQUEST['added_fields'];
}
} elseif (isset($_REQUEST['create_index'])) {
$add_fields = $_REQUEST['added_fields'];
} // end preparing form values
// Get fields and stores their name/type
if (isset($_REQUEST['create_edit_table'])) {
$fields = json_decode($_REQUEST['columns'], true);
$index_params = array(
'Non_unique' => ($_REQUEST['index']['Index_choice'] == 'UNIQUE') ? '0' : '1'
);
$this->index->set($index_params);
$add_fields = count($fields);
} else {
$fields = $this->dbi->getTable($this->db, $this->table)->getNameAndTypeOfTheColumns();
}
$form_params = array(
'db' => $this->db,
'table' => $this->table,
);
if (isset($_REQUEST['create_index'])) {
$form_params['create_index'] = 1;
} elseif (isset($_REQUEST['old_index'])) {
$form_params['old_index'] = $_REQUEST['old_index'];
} elseif (isset($_REQUEST['index'])) {
$form_params['old_index'] = $_REQUEST['index'];
}
$this->response->getHeader()->getScripts()->addFile('indexes.js');
$this->response->addHTML(Template::get('index_form')
->render(array(
'fields' => $fields,
'index' => $this->index,
'form_params' => $form_params,
'add_fields' => $add_fields
))
);
}
/**
* Process the data from the edit/create index form,
* run the query to build the new index
* and moves back to "tbl_sql.php"
*/
public function doSaveDataAction()
{
$error = false;
$sql_query = $this->dbi->getTable($this->db, $this->table)
->getSqlQueryForIndexCreateOrEdit($this->index, $error);
// If there is a request for SQL previewing.
if (isset($_REQUEST['preview_sql'])) {
PMA_Response::getInstance()->addJSON(
'sql_data',
Template::get('preview_sql')
->render(
array(
'query_data' => $sql_query
)
)
);
} elseif (!$error) {
$this->dbi->query($sql_query);
if ($GLOBALS['is_ajax_request'] == true) {
$message = PMA_Message::success(
__('Table %1$s has been altered successfully.')
);
$message->addParam($this->table);
$response = PMA_Response::getInstance();
$response->addJSON(
'message', PMA_Util::getMessage($message, $sql_query, 'success')
);
$response->addJSON(
'index_table', PMA_Index::getHtmlForIndexes(
$this->table, $this->db
)
);
} else {
include 'tbl_structure.php';
}
} else {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', $error);
}
}
}

View File

@ -0,0 +1,330 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds the PMA\TableRelationController
*
* @package PMA
*/
namespace PMA\Controllers\Table;
require_once 'libraries/common.inc.php';
require_once 'libraries/DatabaseInterface.class.php';
require_once 'libraries/controllers/TableController.class.php';
require_once 'libraries/index.lib.php';
require_once 'libraries/Template.class.php';
require_once 'libraries/Table.class.php';
require_once 'libraries/structure.lib.php';
require_once 'libraries/Index.class.php';
require_once 'libraries/Util.class.php';
use PMA_DatabaseInterface;
use PMA_Table;
use PMA_Index;
use PMA_Util;
use PMA\Controllers\TableController;
use PMA\Template;
/**
* Handles table relation logic
*
* @package PhpMyAdmin
*/
class TableRelationController extends TableController
{
/**
* @var array $options_array
*/
protected $options_array;
/**
* @var array $cfgRelation
*/
protected $cfgRelation;
/**
* @var array $existrel
*/
protected $existrel;
/**
* @var string $db
*/
protected $db;
/**
* @var string $table
*/
protected $table;
/**
* @var string $disp
*/
protected $disp;
/**
* @var string $tbl_storage_engine
*/
protected $tbl_storage_engine;
/**
* @var array $existrel_foreign
*/
protected $existrel_foreign;
/**
* @var PMA_Table $udp_query
*/
protected $upd_query;
public function __construct($options_array, $cfgRelation, $tbl_storage_engine,
$existrel, $existrel_foreign, $disp, $upd_query
) {
parent::__construct();
$this->options_array = $options_array;
$this->cfgRelation = $cfgRelation;
$this->tbl_storage_engine = $tbl_storage_engine;
$this->existrel = $existrel;
$this->existrel_foreign = $existrel_foreign;
$this->disp = $disp;
$this->upd_query = $upd_query;
}
public function indexAction()
{
// Send table of column names to populate corresponding dropdowns depending
// on the current selection
if (isset($_REQUEST['getDropdownValues'])
&& $_REQUEST['getDropdownValues'] === 'true'
) {
// if both db and table are selected
if (isset($_REQUEST['foreignTable'])) {
$this->getDropdownValueForTableAction();
} else { // if only the db is selected
$this->getDropdownValueForDbAction();
}
return;
}
$this->response->getHeader()->getScripts()->addFiles(
array(
'tbl_relation.js',
'indexes.js'
)
);
// Gets tables information
require_once 'libraries/tbl_info.inc.php';
// updates for Internal relations
if (isset($_POST['destination_db']) && $this->cfgRelation['relwork']) {
$this->updateForInternalRelationAction();
}
// updates for foreign keys
if (isset($_POST['destination_foreign_db'])) {
$this->updateForForeignKeysAction();
}
// Updates for display field
if ($this->cfgRelation['displaywork'] && isset($_POST['display_field'])) {
$this->updateForDisplayField();
}
// If we did an update, refresh our data
if (isset($_POST['destination_db']) && $this->cfgRelation['relwork']) {
$this->existrel = PMA_getForeigners($this->db, $this->table, '', 'internal');
}
if (isset($_POST['destination_foreign_db'])
&& PMA_Util::isForeignKeySupported($this->tbl_storage_engine)
) {
$this->existrel_foreign = PMA_getForeigners($this->db, $this->table, '', 'foreign');
}
if ($this->cfgRelation['displaywork']) {
$this->disp = PMA_getDisplayField($this->db, $this->table);
}
// display secondary level tabs if necessary
$engine = PMA_Table::sGetStatusInfo($this->db, $this->table, 'ENGINE');
$this->response->addHTML(PMA_getStructureSecondaryTabs($engine));
$this->response->addHTML('<div id="structure_content">');
/**
* Dialog
*/
// Now find out the columns of our $table
// need to use PMA_DatabaseInterface::QUERY_STORE with $this->dbi->numRows()
// in mysqli
$columns = $this->dbi->getColumns($this->db, $this->table);
// common form
$this->response->addHTML(Template::get('tbl_relation/common_form')->render(
array(
'db' => $this->db,
'table' => $this->table,
'columns' => $columns,
'cfgRelation' => $this->cfgRelation,
'tbl_storage_engine' => $this->tbl_storage_engine,
'existrel' => isset($this->existrel) ? $this->existrel : array(),
'existrel_foreign' => isset($this->existrel_foreign) ? $this->existrel_foreign['foreign_keys_data'] : array(),
'options_array' => $this->options_array
)
));
if (PMA_Util::isForeignKeySupported($this->tbl_storage_engine)) {
$this->response->addHTML(PMA_getHtmlForDisplayIndexes());
}
$this->response->addHTML('</div>');
}
public function updateForDisplayField()
{
if ($this->upd_query->updateDisplayField($this->disp, $_POST['display_field'], $this->cfgRelation)) {
$this->response->addHTML(PMA_Util::getMessage(
__('Display column was successfully updated.'),
'', 'success')
);
}
}
public function updateForForeignKeysAction()
{
$multi_edit_columns_name = isset($_REQUEST['foreign_key_fields_name'])
? $_REQUEST['foreign_key_fields_name']
: null;
// (for now, one index name only; we keep the definitions if the
// foreign db is not the same)
list($html, $preview_sql_data, $display_query, $seen_error) = $this->upd_query->updateForeignKeys(
$_POST['destination_foreign_db'],
$multi_edit_columns_name, $_POST['destination_foreign_table'],
$_POST['destination_foreign_column'], $this->options_array, $this->table,
isset($this->existrel_foreign) ? $this->existrel_foreign['foreign_keys_data'] : null
);
$this->response->addHTML($html);
// If there is a request for SQL previewing.
if (isset($_REQUEST['preview_sql'])) {
PMA_previewSQL($preview_sql_data);
}
if (!empty($display_query) && !$seen_error) {
$GLOBALS['display_query'] = $display_query;
$this->response->addHTML(PMA_Util::getMessage(
__('Your SQL query has been executed successfully.'),
null, 'success'
));
}
}
public function updateForInternalRelationAction()
{
$multi_edit_columns_name = isset($_REQUEST['fields_name'])
? $_REQUEST['fields_name']
: null;
if ($this->upd_query->updateInternalRelations(
$multi_edit_columns_name, $_POST['destination_db'], $_POST['destination_table'],
$_POST['destination_column'], $this->cfgRelation, isset($this->existrel) ? $this->existrel : null
)
) {
$this->response->addHTML(PMA_Util::getMessage(
__('Internal relations were successfully updated.'),
'', 'success'
));
}
}
/**
* Send table columns for foreign table dropdown
*
* @return void
*
*/
public function getDropdownValueForTableAction()
{
$foreignTable = $_REQUEST['foreignTable'];
$table_obj = new PMA_Table($foreignTable, $_REQUEST['foreignDb']);
// Since views do not have keys defined on them provide the full list of columns
if (PMA_Table::isView($_REQUEST['foreignDb'], $foreignTable)) {
$columnList = $table_obj->getColumns(false, false);
} else {
$columnList = $table_obj->getIndexedColumns(false, false);
}
$columns = array();
foreach ($columnList as $column) {
$columns[] = htmlspecialchars($column);
}
$this->response->addJSON('columns', $columns);
// @todo should be: $server->db($db)->table($table)->primary()
$primary = PMA_Index::getPrimary($foreignTable, $_REQUEST['foreignDb']);
if (false === $primary) {
return;
}
$this->response->addJSON('primary', array_keys($primary->getColumns()));
}
/**
* Send database selection values for dropdown
*
* @return void
*
*/
public function getDropdownValueForDbAction()
{
$tables = array();
$foreign = isset($_REQUEST['foreign']) && $_REQUEST['foreign'] === 'true';
// In Drizzle, 'SHOW TABLE STATUS' will show status only for the tables
// which are currently in the table cache. Hence we have to use 'SHOW TABLES'
// and manually retrieve table engine values.
if ($foreign && !PMA_DRIZZLE) {
$query = 'SHOW TABLE STATUS FROM '
. PMA_Util::backquote($_REQUEST['foreignDb']);
$tables_rs = $this->dbi->query(
$query,
null,
PMA_DatabaseInterface::QUERY_STORE
);
while ($row = $this->dbi->fetchArray($tables_rs)) {
if (isset($row['Engine'])
&& /*overload*/
mb_strtoupper($row['Engine']) == $this->tbl_storage_engine
) {
$tables[] = htmlspecialchars($row['Name']);
}
}
} else {
$query = 'SHOW TABLES FROM '
. PMA_Util::backquote($_REQUEST['foreignDb']);
$tables_rs = $this->dbi->query(
$query,
null,
PMA_DatabaseInterface::QUERY_STORE
);
while ($row = $this->dbi->fetchArray($tables_rs)) {
if ($foreign && PMA_DRIZZLE) {
$engine = /*overload*/
mb_strtoupper(
PMA_Table::sGetStatusInfo(
$_REQUEST['foreignDb'],
$row[0],
'Engine'
)
);
if (isset($engine) && $engine == $this->tbl_storage_engine) {
$tables[] = htmlspecialchars($row[0]);
}
} else {
$tables[] = htmlspecialchars($row[0]);
}
}
}
$this->response->addJSON('tables', $tables);
}
}

View File

@ -10,7 +10,8 @@ if (! defined('PHPMYADMIN')) {
exit;
}
require_once './libraries/DatabaseInterface.class.php';
require_once 'libraries/di/Container.class.php';
require_once 'libraries/DatabaseInterface.class.php';
if (defined('TESTSUITE')) {
/**
@ -81,4 +82,7 @@ if (defined('TESTSUITE')) {
}
}
$GLOBALS['dbi'] = new PMA_DatabaseInterface($extension);
?>
$container = \PMA\DI\Container::getDefaultContainer();
$container->set('PMA_DatabaseInterface', $GLOBALS['dbi']);
$container->alias('dbi', 'PMA_DatabaseInterface');

View File

@ -559,6 +559,26 @@ $GLOBALS['dummy_queries'] = array(
array(
'query' => "SHOW EVENTS FROM `default`",
'result' => array()
),
array(
'query' => "FLUSH PRIVILEGES",
'result' => array()
),
array(
'query' => "SELECT * FROM `mysql`.`db` LIMIT 1",
'result' => array()
),
array(
'query' => "SELECT * FROM `mysql`.`columns_priv` LIMIT 1",
'result' => array()
),
array(
'query' => "SELECT * FROM `mysql`.`tables_priv` LIMIT 1",
'result' => array()
),
array(
'query' => "SELECT * FROM `mysql`.`procs_priv` LIMIT 1",
'result' => array()
)
);
/**

View File

@ -0,0 +1,44 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds the PMA\DI\AliasItem class
*
* @package PMA
*/
namespace PMA\DI;
require_once 'libraries/di/Item.int.php';
class AliasItem implements Item
{
/** @var Container */
protected $container;
/** @var string */
protected $target;
/**
* Constructor
*
* @param Container $container
* @param string $target
*/
function __construct(Container $container, $target)
{
$this->container = $container;
$this->target = $target;
}
/**
* Get the target item
*
* @param array $params
* @return mixed
*/
public function get($params = array())
{
return $this->container->get($this->target, $params);
}
}

View File

@ -0,0 +1,154 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds the PMA\DI\Container class
*
* @package PMA
*/
namespace PMA\DI;
require_once 'libraries/di/Item.int.php';
require_once 'libraries/di/AliasItem.class.php';
require_once 'libraries/di/ValueItem.class.php';
require_once 'libraries/di/ServiceItem.class.php';
require_once 'libraries/di/FactoryItem.class.php';
class Container
{
/**
* @var Item[] $content
*/
protected $content = array();
/**
* @var Container
*/
protected static $defaultContainer;
/**
* Create a dependency injection container
*
* @param Container $base
*/
function __construct(Container $base = null)
{
if (isset($base)) {
$this->content = $base->content;
} else {
$this->alias('container', 'Container');
}
$this->set('Container', $this);
}
/**
* Get an object with given name and parameters
*
* @param string $name
* @param array $params
* @return mixed
*/
public function get($name, $params = array())
{
if (isset($this->content[$name])) {
return $this->content[$name]->get($params);
}
if (isset($GLOBALS[$name])) {
return $GLOBALS[$name];
}
return null;
}
/**
* Remove an object from container
*
* @param string $name
*/
public function remove($name)
{
unset($this->content[$name]);
}
/**
* Rename an object in container
*
* @param string $name
* @param string $newName
*/
public function rename($name, $newName)
{
$this->content[$newName] = $this->content[$name];
$this->remove($name);
}
/**
* Set values in the container
*
* @param string|array $name
* @param mixed $value
*/
public function set($name, $value = null)
{
if (is_array($name)) {
foreach ($name as $key => $val) {
$this->set($key, $val);
}
return;
}
$this->content[$name] = new ValueItem($value);
}
/**
* Register a service in the container
*
* @param string $name
* @param mixed $service
*/
public function service($name, $service = null)
{
if (!isset($service)) {
$service = $name;
}
$this->content[$name] = new ServiceItem($this, $service);
}
/**
* Register a factory in the container
*
* @param string $name
* @param mixed $factory
*/
public function factory($name, $factory = null)
{
if (!isset($factory)) {
$factory = $name;
}
$this->content[$name] = new FactoryItem($this, $factory);
}
/**
* Register an alias in the container
*
* @param string $name
* @param string $target
*/
public function alias($name, $target)
{
// The target may be not defined yet
$this->content[$name] = new AliasItem($this, $target);
}
/**
* Get the global default container
*/
public static function getDefaultContainer()
{
if (!isset(static::$defaultContainer)) {
static::$defaultContainer = new Container();
}
return static::$defaultContainer;
}
}

View File

@ -0,0 +1,37 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds the PMA\DI\FactoryItem class
*
* @package PMA
*/
namespace PMA\DI;
require_once 'libraries/di/ReflectorItem.class.php';
class FactoryItem extends ReflectorItem
{
/**
* Constructor
*
* @param Container $container
* @param mixed $definition
*/
function __construct(Container $container, $definition)
{
parent::__construct($container, $definition);
}
/**
* Construct an instance
*
* @param array $params
* @return mixed
*/
public function get($params = array())
{
return $this->invoke($params);
}
}

21
libraries/di/Item.int.php Normal file
View File

@ -0,0 +1,21 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds the PMA\DI\Item class
*
* @package PMA
*/
namespace PMA\DI;
interface Item
{
/**
* Get a value from the item
*
* @param array $params
* @return mixed
*/
public function get($params = array());
}

View File

@ -0,0 +1,120 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds the PMA\DI\ReflectorItem class
*
* @package PMA
*/
namespace PMA\DI;
require_once 'libraries/di/Item.int.php';
abstract class ReflectorItem implements Item
{
/** @var Container */
private $container;
/** @var \Reflector */
private $reflector;
/**
* Constructor
*
* @param Container $container
* @param mixed $definition
*/
public function __construct(Container $container, $definition)
{
$this->container = $container;
$this->reflector = self::resolveReflector($definition);
}
/**
* Invoke the reflector with given parameters
*
* @param array $params
* @return mixed
*/
protected function invoke($params = array())
{
$args = array();
$reflector = $this->reflector;
if ($reflector instanceof \ReflectionClass) {
$constructor = $reflector->getConstructor();
if (isset($constructor)) {
$args = $this->resolveArgs(
$constructor->getParameters(),
$params
);
}
return $reflector->newInstanceArgs($args);
}
/** @var \ReflectionFunctionAbstract $reflector */
$args = $this->resolveArgs(
$reflector->getParameters(),
$params
);
if ($reflector instanceof \ReflectionMethod) {
/** @var \ReflectionMethod $reflector */
return $reflector->invokeArgs(null, $args);
}
/** @var \ReflectionFunction $reflector */
return $reflector->invokeArgs($args);
}
/**
* Getting required arguments with given parameters
*
* @param \ReflectionParameter[] $required
* @param array $params
* @return array
*/
private function resolveArgs($required, $params = array())
{
$args = array();
foreach ($required as $param) {
$name = $param->getName();
$type = $param->getClass();
if (isset($type)) {
$type = $type->getName();
}
if (isset($params[$name])) {
$args[] = $params[$name];
} elseif (is_string($type) && isset($params[$type])) {
$args[] = $params[$type];
} else {
$content = $this->container->get($name);
if (isset($content)) {
$args[] = $content;
} elseif (is_string($type)) {
$args[] = $this->container->get($type);
} else {
$args[] = null;
}
}
}
return $args;
}
/**
* Resolve the reflection
*
* @param mixed $definition
* @return \Reflector
*/
private static function resolveReflector($definition)
{
if (function_exists($definition)) {
return new \ReflectionFunction($definition);
}
if (is_string($definition)) {
$definition = explode('::', $definition);
}
if (!isset($definition[1])) {
return new \ReflectionClass($definition[0]);
}
return new \ReflectionMethod($definition[0], $definition[1]);
}
}

View File

@ -0,0 +1,43 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds the PMA\DI\ServiceItem class
*
* @package PMA
*/
namespace PMA\DI;
require_once 'libraries/di/ReflectorItem.class.php';
class ServiceItem extends ReflectorItem
{
/** @var mixed */
protected $instance;
/**
* Constructor
*
* @param Container $container
* @param mixed $definition
*/
function __construct(Container $container, $definition)
{
parent::__construct($container, $definition);
}
/**
* Get the instance of the service
*
* @param array $params
* @return mixed
*/
public function get($params = array())
{
if (!isset($this->instance)) {
$this->instance = $this->invoke();
}
return $this->instance;
}
}

View File

@ -0,0 +1,39 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds the PMA\DI\ValueItem class
*
* @package PMA
*/
namespace PMA\DI;
require_once 'libraries/di/Item.int.php';
class ValueItem implements Item
{
/** @var mixed */
protected $value;
/**
* Constructor
*
* @param $value
*/
function __construct($value)
{
$this->value = $value;
}
/**
* Get the value
*
* @param array $params
* @return mixed
*/
public function get($params = array())
{
return $this->value;
}
}

View File

@ -617,5 +617,13 @@ class PMA_GIS_Visualization
}
return $results;
}
/**
* @param array $userSpecifiedSettings
*/
public function setUserSpecifiedSettings($userSpecifiedSettings)
{
$this->_userSpecifiedSettings = $userSpecifiedSettings;
}
}
?>

View File

@ -77,11 +77,31 @@ function PMA_getHtmlForRenameDatabase($db)
$html_output .= '<input id="new_db_name" type="text" name="newname" '
. 'maxlength="64" size="30" class="textfield" value="" '
. 'required="required" />';
$html_output .= '<input type="checkbox" name="adjust_privileges" value="1"'
. 'id="checkbox_adjust_privileges" checked="checked" />';
$html_output .= '<label for="checkbox_adjust_privileges">'
. __('Adjust Privileges') . PMA_Util::showDocu('faq', 'faq6-39')
. '</label><br />';
if (! PMA_DRIZZLE) {
if (isset($GLOBALS['db_priv']) && $GLOBALS['db_priv']
&& isset($GLOBALS['table_priv']) && $GLOBALS['table_priv']
&& isset($GLOBALS['col_priv']) && $GLOBALS['col_priv']
&& isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv']
&& isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']
) {
$html_output .= '<input type="checkbox" name="adjust_privileges" value="1"'
. 'id="checkbox_adjust_privileges" checked="checked" />';
} else {
$html_output .= '<input type="checkbox" name="adjust_privileges" value="1"'
. 'id="checkbox_adjust_privileges" '
. 'title="' . __(
'You don\'t have sufficient privileges to perform this '
. 'operation; Please refer to the documentation for more details'
)
. '" disabled/>';
}
$html_output .= '<label for="checkbox_adjust_privileges">'
. __('Adjust Privileges') . PMA_Util::showDocu('faq', 'faq6-39')
. '</label><br />';
}
$html_output .= ''
. '</fieldset>'
. '<fieldset class="tblFooters">'
@ -205,11 +225,30 @@ function PMA_getHtmlForCopyDatabase($db)
$html_output .= '<label for="checkbox_constraints">'
. __('Add constraints') . '</label><br />';
$html_output .= '<br />';
$html_output .= '<input type="checkbox" name="adjust_privileges" value="1"'
. 'id="checkbox_privileges" checked="checked" />';
$html_output .= '<label for="checkbox_privileges">'
. __('Adjust Privileges') . PMA_Util::showDocu('faq', 'faq6-39')
. '</label><br />';
if (! PMA_DRIZZLE) {
if (isset($GLOBALS['db_priv']) && $GLOBALS['db_priv']
&& isset($GLOBALS['table_priv']) && $GLOBALS['table_priv']
&& isset($GLOBALS['col_priv']) && $GLOBALS['col_priv']
&& isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv']
&& isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']
) {
$html_output .= '<input type="checkbox" name="adjust_privileges" value="1"'
. 'id="checkbox_privileges" checked="checked" />';
} else {
$html_output .= '<input type="checkbox" name="adjust_privileges" value="1"'
. 'id="checkbox_privileges"'
. 'title="' . __(
'You don\'t have sufficient privileges to perform this '
. 'operation; Please refer to the documentation for more details'
)
. '" disabled/>';
}
$html_output .= '<label for="checkbox_privileges">'
. __('Adjust Privileges') . PMA_Util::showDocu('faq', 'faq6-39')
. '</label><br />';
}
$html_output .= '<input type="checkbox" name="switch_to_new" value="true"'
. 'id="checkbox_switch"'
. ((isset($pma_switch_to_new) && $pma_switch_to_new == 'true')
@ -544,36 +583,44 @@ function PMA_handleTheViews($views, $move, $db)
*/
function PMA_AdjustPrivileges_moveDB($oldDb, $newname)
{
$GLOBALS['dbi']->selectDb('mysql');
if (! PMA_DRIZZLE) {
if (isset($GLOBALS['db_priv']) && $GLOBALS['db_priv']
&& isset($GLOBALS['table_priv']) && $GLOBALS['table_priv']
&& isset($GLOBALS['col_priv']) && $GLOBALS['col_priv']
&& isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv']
&& isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']
) {
$GLOBALS['dbi']->selectDb('mysql');
// For Db specific privileges
$query_db_specific = 'UPDATE ' . PMA_Util::backquote('db')
. 'SET Db = "' . $newname
. '" where Db = "' . $oldDb . '";';
$GLOBALS['dbi']->query($query_db_specific);
// For Db specific privileges
$query_db_specific = 'UPDATE ' . PMA_Util::backquote('db')
. 'SET Db = "' . $newname
. '" where Db = "' . $oldDb . '";';
$GLOBALS['dbi']->query($query_db_specific);
// For table specific privileges
$query_table_specific = 'UPDATE ' . PMA_Util::backquote('tables_priv')
. 'SET Db = "' . $newname
. '" where Db = "' . $oldDb . '";';
$GLOBALS['dbi']->query($query_table_specific);
// For table specific privileges
$query_table_specific = 'UPDATE ' . PMA_Util::backquote('tables_priv')
. 'SET Db = "' . $newname
. '" where Db = "' . $oldDb . '";';
$GLOBALS['dbi']->query($query_table_specific);
// For column specific privileges
$query_col_specific = 'UPDATE ' . PMA_Util::backquote('columns_priv')
. 'SET Db = "' . $newname
. '" where Db = "' . $oldDb . '";';
$GLOBALS['dbi']->query($query_col_specific);
// For column specific privileges
$query_col_specific = 'UPDATE ' . PMA_Util::backquote('columns_priv')
. 'SET Db = "' . $newname
. '" where Db = "' . $oldDb . '";';
$GLOBALS['dbi']->query($query_col_specific);
// For procedures specific privileges
$query_proc_specific = 'UPDATE ' . PMA_Util::backquote('procs_priv')
. 'SET Db = "' . $newname
. '" where Db = "' . $oldDb . '";';
$GLOBALS['dbi']->query($query_proc_specific);
// Finally FLUSH the new privileges
$flush_query = "FLUSH PRIVILEGES;";
$GLOBALS['dbi']->query($flush_query);
// For procedures specific privileges
$query_proc_specific = 'UPDATE ' . PMA_Util::backquote('procs_priv')
. 'SET Db = "' . $newname
. '" where Db = "' . $oldDb . '";';
$GLOBALS['dbi']->query($query_proc_specific);
// Finally FLUSH the new privileges
$flush_query = "FLUSH PRIVILEGES;";
$GLOBALS['dbi']->query($flush_query);
}
}
}
/**
@ -586,85 +633,92 @@ function PMA_AdjustPrivileges_moveDB($oldDb, $newname)
*/
function PMA_AdjustPrivileges_copyDB($oldDb, $newname)
{
if (! PMA_DRIZZLE) {
if (isset($GLOBALS['db_priv']) && $GLOBALS['db_priv']
&& isset($GLOBALS['table_priv']) && $GLOBALS['table_priv']
&& isset($GLOBALS['col_priv']) && $GLOBALS['col_priv']
&& isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv']
&& isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']
) {
$GLOBALS['dbi']->selectDb('mysql');
$GLOBALS['dbi']->selectDb('mysql');
$query_db_specific_old = 'SELECT * FROM '
. PMA_Util::backquote('db') . ' WHERE '
. 'Db = "' . $oldDb . '";';
$query_db_specific_old = 'SELECT * FROM '
. PMA_Util::backquote('db') . ' WHERE '
. 'Db = "' . $oldDb . '";';
$old_privs_db = $GLOBALS['dbi']->fetchResult($query_db_specific_old, 0);
$old_privs_db = $GLOBALS['dbi']->fetchResult($query_db_specific_old, 0);
foreach ($old_privs_db as $old_priv) {
$newDb_db_privs_query = 'INSERT INTO '
. PMA_Util::backquote('db') . ' VALUES("'
. $old_priv[0] . '", "' . $newname . '", "' . $old_priv[2] . '", "'
. $old_priv[3] . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "'
. $old_priv[6] . '", "' . $old_priv[7] . '", "' . $old_priv[8] . '", "'
. $old_priv[9] . '", "' . $old_priv[10] . '", "' . $old_priv[11] . '", "'
. $old_priv[12] . '", "' . $old_priv[13] . '", "' . $old_priv[14] . '", "'
. $old_priv[15] . '", "' . $old_priv[16] . '", "' . $old_priv[17] . '", "'
. $old_priv[18] . '", "' . $old_priv[19] . '", "' . $old_priv[20] . '", "'
. $old_priv[21] . '");';
foreach ($old_privs_db as $old_priv) {
$newDb_db_privs_query = 'INSERT INTO '
. PMA_Util::backquote('db') . ' VALUES("'
. $old_priv[0] . '", "' . $newname . '", "' . $old_priv[2] . '", "'
. $old_priv[3] . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "'
. $old_priv[6] . '", "' . $old_priv[7] . '", "' . $old_priv[8] . '", "'
. $old_priv[9] . '", "' . $old_priv[10] . '", "' . $old_priv[11] . '", "'
. $old_priv[12] . '", "' . $old_priv[13] . '", "' . $old_priv[14] . '", "'
. $old_priv[15] . '", "' . $old_priv[16] . '", "' . $old_priv[17] . '", "'
. $old_priv[18] . '", "' . $old_priv[19] . '", "' . $old_priv[20] . '", "'
. $old_priv[21] . '");';
$GLOBALS['dbi']->query($newDb_db_privs_query);
}
$GLOBALS['dbi']->query($newDb_db_privs_query);
// For Table Specific privileges
$query_table_specific_old = 'SELECT * FROM '
. PMA_Util::backquote('tables_priv') . ' WHERE '
. 'Db = "' . $oldDb . '";';
$old_privs_table = $GLOBALS['dbi']->fetchResult($query_table_specific_old, 0);
foreach ($old_privs_table as $old_priv) {
$newDb_table_privs_query = 'INSERT INTO '
. PMA_Util::backquote('tables_priv') . ' VALUES("'
. $old_priv[0] . '", "' . $newname . '", "' . $old_priv[2] . '", "'
. $old_priv[3] . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "'
. $old_priv[6] . '", "' . $old_priv[7] . '");';
$GLOBALS['dbi']->query($newDb_table_privs_query);
}
// For Column Specific privileges
$query_col_specific_old = 'SELECT * FROM '
. PMA_Util::backquote('columns_priv') . ' WHERE '
. 'Db = "' . $oldDb . '";';
$old_privs_col = $GLOBALS['dbi']->fetchResult($query_col_specific_old, 0);
foreach ($old_privs_col as $old_priv) {
$newDb_col_privs_query = 'INSERT INTO '
. PMA_Util::backquote('columns_priv') . ' VALUES("'
. $old_priv[0] . '", "' . $newname . '", "' . $old_priv[2] . '", "'
. $old_priv[3] . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "'
. $old_priv[6] . '");';
$GLOBALS['dbi']->query($newDb_col_privs_query);
}
// For Procedure Specific privileges
$query_proc_specific_old = 'SELECT * FROM '
. PMA_Util::backquote('procs_priv') . ' WHERE '
. 'Db = "' . $oldDb . '";';
$old_privs_proc = $GLOBALS['dbi']->fetchResult($query_proc_specific_old, 0);
foreach ($old_privs_proc as $old_priv) {
$newDb_proc_privs_query = 'INSERT INTO '
. PMA_Util::backquote('procs_priv') . ' VALUES("'
. $old_priv[0] . '", "' . $newname . '", "' . $old_priv[2] . '", "'
. $old_priv[3] . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "'
. $old_priv[6] . '", "' . $old_priv[7] . '");';
$GLOBALS['dbi']->query($newDb_proc_privs_query);
}
// Finally FLUSH the new privileges
$flush_query = "FLUSH PRIVILEGES;";
$GLOBALS['dbi']->query($flush_query);
}
}
// For Table Specific privileges
$query_table_specific_old = 'SELECT * FROM '
. PMA_Util::backquote('tables_priv') . ' WHERE '
. 'Db = "' . $oldDb . '";';
$old_privs_table = $GLOBALS['dbi']->fetchResult($query_table_specific_old, 0);
foreach ($old_privs_table as $old_priv) {
$newDb_table_privs_query = 'INSERT INTO '
. PMA_Util::backquote('tables_priv') . ' VALUES("'
. $old_priv[0] . '", "' . $newname . '", "' . $old_priv[2] . '", "'
. $old_priv[3] . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "'
. $old_priv[6] . '", "' . $old_priv[7] . '");';
$GLOBALS['dbi']->query($newDb_table_privs_query);
}
// For Column Specific privileges
$query_col_specific_old = 'SELECT * FROM '
. PMA_Util::backquote('columns_priv') . ' WHERE '
. 'Db = "' . $oldDb . '";';
$old_privs_col = $GLOBALS['dbi']->fetchResult($query_col_specific_old, 0);
foreach ($old_privs_col as $old_priv) {
$newDb_col_privs_query = 'INSERT INTO '
. PMA_Util::backquote('columns_priv') . ' VALUES("'
. $old_priv[0] . '", "' . $newname . '", "' . $old_priv[2] . '", "'
. $old_priv[3] . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "'
. $old_priv[6] . '");';
$GLOBALS['dbi']->query($newDb_col_privs_query);
}
// For Procedure Specific privileges
$query_proc_specific_old = 'SELECT * FROM '
. PMA_Util::backquote('procs_priv') . ' WHERE '
. 'Db = "' . $oldDb . '";';
$old_privs_proc = $GLOBALS['dbi']->fetchResult($query_proc_specific_old, 0);
foreach ($old_privs_proc as $old_priv) {
$newDb_proc_privs_query = 'INSERT INTO '
. PMA_Util::backquote('procs_priv') . ' VALUES("'
. $old_priv[0] . '", "' . $newname . '", "' . $old_priv[2] . '", "'
. $old_priv[3] . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "'
. $old_priv[6] . '", "' . $old_priv[7] . '");';
$GLOBALS['dbi']->query($newDb_proc_privs_query);
}
// Finally FLUSH the new privileges
$flush_query = "FLUSH PRIVILEGES;";
$GLOBALS['dbi']->query($flush_query);
}
/**
@ -789,15 +843,30 @@ function PMA_getHtmlForMoveTable()
. 'value="1" id="checkbox_auto_increment_mv" checked="checked" />'
. '<label for="checkbox_auto_increment_mv">'
. __('Add AUTO_INCREMENT value')
. '</label><br />'
. '<input type="checkbox" name="adjust_privileges" value="1" '
. 'id="checkbox_privileges_tables_move" checked="checked" />'
. '<label for="checkbox_privileges_tables_move">'
. __('Adjust Privileges') . PMA_Util::showDocu('faq', 'faq6-39')
. '</label><br />'
. '</fieldset>';
. '</label><br />';
$html_output .= '<fieldset class="tblFooters">'
if (! PMA_DRIZZLE) {
if (isset($GLOBALS['table_priv']) && $GLOBALS['table_priv']
&& isset($GLOBALS['col_priv']) && $GLOBALS['col_priv']
&& isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']
) {
$html_output .= '<input type="checkbox" name="adjust_privileges" value="1" '
. 'id="checkbox_privileges_tables_move" checked="checked" />';
} else {
$html_output .= '<input type="checkbox" name="adjust_privileges" value="1" '
. 'id="checkbox_privileges_tables_move"'
. 'title="' . __(
'You don\'t have sufficient privileges to perform this '
. 'operation; Please refer to the documentation for more details'
)
. '" disabled/>';
}
$html_output .= '<label for="checkbox_privileges_tables_move">'
. __('Adjust Privileges') . PMA_Util::showDocu('faq', 'faq6-39')
. '</label><br />';
}
$html_output .= '</fieldset><fieldset class="tblFooters">'
. '<input type="submit" name="submit_move" value="' . __('Go') . '" />'
. '</fieldset>'
. '</form>'
@ -868,14 +937,30 @@ function PMA_getHtmlForRenameTable()
. 'value="' . htmlspecialchars($GLOBALS['table'])
. '" required="required" />'
. '</td></tr>'
. '<tr><td></td><td>'
. '<input type="checkbox" name="adjust_privileges" value="1" '
. 'id="checkbox_privileges_table_options" checked="checked" />'
. '<label for="checkbox_privileges_table_options">'
. __('Adjust Privileges') . PMA_Util::showDocu('faq', 'faq6-39')
. '</label>'
. '</td>'
. '</tr>';
. '<tr><td></td><td>';
if (! PMA_DRIZZLE) {
if (isset($GLOBALS['table_priv']) && $GLOBALS['table_priv']
&& isset($GLOBALS['col_priv']) && $GLOBALS['col_priv']
&& isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']
) {
$html_output .= '<input type="checkbox" name="adjust_privileges" value="1" '
. 'id="checkbox_privileges_table_options" checked="checked" />';
} else {
$html_output .= '<input type="checkbox" name="adjust_privileges" value="1" '
. 'id="checkbox_privileges_table_options" '
. 'title="' . __(
'You don\'t have sufficient privileges to perform this '
. 'operation; Please refer to the documentation for more details'
)
. '" disabled/>';
}
$html_output .= '<label for="checkbox_privileges_table_options">'
. __('Adjust Privileges') . PMA_Util::showDocu('faq', 'faq6-39')
. '</label>';
}
$html_output .= '</td></tr>';
return $html_output;
}
@ -1207,11 +1292,27 @@ function PMA_getHtmlForCopytable()
} // endif
$html_output .= '<br />';
$html_output .= '<input type="checkbox" name="adjust_privileges" value="1"'
. 'id="checkbox_adjust_privileges" checked="checked" />'
. '<label for="checkbox_adjust_privileges">'
. __('Adjust Privileges') . PMA_Util::showDocu('faq', 'faq6-39')
. '</label><br />';
if (! PMA_DRIZZLE) {
if (isset($GLOBALS['table_priv']) && $GLOBALS['table_priv']
&& isset($GLOBALS['col_priv']) && $GLOBALS['col_priv']
&& isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']
) {
$html_output .= '<input type="checkbox" name="adjust_privileges" value="1"'
. 'id="checkbox_adjust_privileges" checked="checked" />';
} else {
$html_output .= '<input type="checkbox" name="adjust_privileges" value="1"'
. 'id="checkbox_adjust_privileges" '
. 'title="' . __(
'You don\'t have sufficient privileges to perform this '
. 'operation; Please refer to the documentation for more details'
)
. '" disabled/>';
}
$html_output .= '<label for="checkbox_adjust_privileges">'
. __('Adjust Privileges') . PMA_Util::showDocu('faq', 'faq6-39')
. '</label><br />';
}
if (isset($_COOKIE['pma_switch_to_new'])
&& $_COOKIE['pma_switch_to_new'] == 'true'
@ -1844,24 +1945,30 @@ function PMA_getQueryAndResultForPartition()
*/
function PMA_AdjustPrivileges_renameOrMoveTable($oldDb, $oldTable, $newDb, $newTable)
{
$GLOBALS['dbi']->selectDb('mysql');
if (! PMA_DRIZZLE) {
if (isset($GLOBALS['table_priv']) && $GLOBALS['table_priv']
&& isset($GLOBALS['col_priv']) && $GLOBALS['col_priv']
&& isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']
) {
$GLOBALS['dbi']->selectDb('mysql');
// For table specific privileges
$query_table_specific = 'UPDATE ' . PMA_Util::backquote('tables_priv')
. 'SET Db = "' . $newDb . '", Table_name = "' . $newTable
. '" where Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";';
$GLOBALS['dbi']->query($query_table_specific);
// For table specific privileges
$query_table_specific = 'UPDATE ' . PMA_Util::backquote('tables_priv')
. 'SET Db = "' . $newDb . '", Table_name = "' . $newTable
. '" where Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";';
$GLOBALS['dbi']->query($query_table_specific);
// For column specific privileges
$query_col_specific = 'UPDATE ' . PMA_Util::backquote('columns_priv')
. 'SET Db = "' . $newDb . '", Table_name = "' . $newTable
. '" where Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";';
$GLOBALS['dbi']->query($query_col_specific);
// Finally FLUSH the new privileges
$flush_query = "FLUSH PRIVILEGES;";
$GLOBALS['dbi']->query($flush_query);
// For column specific privileges
$query_col_specific = 'UPDATE ' . PMA_Util::backquote('columns_priv')
. 'SET Db = "' . $newDb . '", Table_name = "' . $newTable
. '" where Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";';
$GLOBALS['dbi']->query($query_col_specific);
// Finally FLUSH the new privileges
$flush_query = "FLUSH PRIVILEGES;";
$GLOBALS['dbi']->query($flush_query);
}
}
}
/**
@ -1876,46 +1983,52 @@ function PMA_AdjustPrivileges_renameOrMoveTable($oldDb, $oldTable, $newDb, $newT
*/
function PMA_AdjustPrivileges_copyTable($oldDb, $oldTable, $newDb, $newTable)
{
$GLOBALS['dbi']->selectDb('mysql');
if (! PMA_DRIZZLE) {
if (isset($GLOBALS['table_priv']) && $GLOBALS['table_priv']
&& isset($GLOBALS['col_priv']) && $GLOBALS['col_priv']
&& isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']
) {
$GLOBALS['dbi']->selectDb('mysql');
// For Table Specific privileges
$query_table_specific_old = 'SELECT * FROM '
. PMA_Util::backquote('tables_priv') . ' where '
. 'Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";';
// For Table Specific privileges
$query_table_specific_old = 'SELECT * FROM '
. PMA_Util::backquote('tables_priv') . ' where '
. 'Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";';
$old_privs_table = $GLOBALS['dbi']->fetchResult($query_table_specific_old, 0);
$old_privs_table = $GLOBALS['dbi']->fetchResult($query_table_specific_old, 0);
foreach ($old_privs_table as $old_priv) {
$newDb_table_privs_query = 'INSERT INTO '
. PMA_Util::backquote('tables_priv') . ' VALUES("'
. $old_priv[0] . '", "' . $newDb . '", "' . $old_priv[2] . '", "'
. $newTable . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "'
. $old_priv[6] . '", "' . $old_priv[7] . '");';
foreach ($old_privs_table as $old_priv) {
$newDb_table_privs_query = 'INSERT INTO '
. PMA_Util::backquote('tables_priv') . ' VALUES("'
. $old_priv[0] . '", "' . $newDb . '", "' . $old_priv[2] . '", "'
. $newTable . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "'
. $old_priv[6] . '", "' . $old_priv[7] . '");';
$GLOBALS['dbi']->query($newDb_table_privs_query);
$GLOBALS['dbi']->query($newDb_table_privs_query);
}
// For Column Specific privileges
$query_col_specific_old = 'SELECT * FROM '
. PMA_Util::backquote('columns_priv') . ' WHERE '
. 'Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";';
$old_privs_col = $GLOBALS['dbi']->fetchResult($query_col_specific_old, 0);
foreach ($old_privs_col as $old_priv) {
$newDb_col_privs_query = 'INSERT INTO '
. PMA_Util::backquote('columns_priv') . ' VALUES("'
. $old_priv[0] . '", "' . $newDb . '", "' . $old_priv[2] . '", "'
. $newTable . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "'
. $old_priv[6] . '");';
$GLOBALS['dbi']->query($newDb_col_privs_query);
}
// Finally FLUSH the new privileges
$flush_query = "FLUSH PRIVILEGES;";
$GLOBALS['dbi']->query($flush_query);
}
}
// For Column Specific privileges
$query_col_specific_old = 'SELECT * FROM '
. PMA_Util::backquote('columns_priv') . ' WHERE '
. 'Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";';
$old_privs_col = $GLOBALS['dbi']->fetchResult($query_col_specific_old, 0);
foreach ($old_privs_col as $old_priv) {
$newDb_col_privs_query = 'INSERT INTO '
. PMA_Util::backquote('columns_priv') . ' VALUES("'
. $old_priv[0] . '", "' . $newDb . '", "' . $old_priv[2] . '", "'
. $newTable . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "'
. $old_priv[6] . '");';
$GLOBALS['dbi']->query($newDb_col_privs_query);
}
// Finally FLUSH the new privileges
$flush_query = "FLUSH PRIVILEGES;";
$GLOBALS['dbi']->query($flush_query);
}
/**

View File

@ -301,21 +301,28 @@ function PMA_RTN_handleEditor()
$db, $_REQUEST['item_original_type'],
$_REQUEST['item_original_name']
);
// Backup the Old Privileges before dropping
// if $_REQUEST['item_adjust_privileges'] set
$privilegesBackup = array();
if (isset($_REQUEST['item_adjust_privileges'])
&& ! empty($_REQUEST['item_adjust_privileges'])
) {
$privilegesBackupQuery = 'SELECT * FROM ' . PMA_Util::backquote('mysql')
. '.' . PMA_Util::backquote('procs_priv')
. ' where Routine_name = "' . $_REQUEST['item_original_name']
. '" AND Routine_type = "' . $_REQUEST['item_original_type']
. '";';
$privilegesBackup = $GLOBALS['dbi']->fetchResult(
$privilegesBackupQuery, 0
);
if (! defined('PMA_DRIZZLE') || ! PMA_DRIZZLE) {
if (isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv']
&& isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']
) {
// Backup the Old Privileges before dropping
// if $_REQUEST['item_adjust_privileges'] set
$privilegesBackup = array();
if (isset($_REQUEST['item_adjust_privileges'])
&& ! empty($_REQUEST['item_adjust_privileges'])
) {
$privilegesBackupQuery = 'SELECT * FROM ' . PMA_Util::backquote('mysql')
. '.' . PMA_Util::backquote('procs_priv')
. ' where Routine_name = "' . $_REQUEST['item_original_name']
. '" AND Routine_type = "' . $_REQUEST['item_original_type']
. '";';
$privilegesBackup = $GLOBALS['dbi']->fetchResult(
$privilegesBackupQuery, 0
);
}
}
}
$drop_routine = "DROP {$_REQUEST['item_original_type']} "
@ -355,23 +362,30 @@ function PMA_RTN_handleEditor()
// Default value
$resultAdjust = false;
// Insert all the previous privileges
// but with the new name and the new type
foreach ($privilegesBackup as $priv) {
$adjustProcPrivilege = 'INSERT INTO '
. PMA_Util::backquote('mysql') . '.'
. PMA_Util::backquote('procs_priv')
. ' VALUES("' . $priv[0] . '", "'
. $priv[1] . '", "' . $priv[2] . '", "'
. $_REQUEST['item_name'] . '", "'
. $_REQUEST['item_type'] . '", "'
. $priv[5] . '", "'
. $priv[6] . '", "'
. $priv[7] . '");';
$resultAdjust = $GLOBALS['dbi']->query(
$adjustProcPrivilege
);
if (! defined('PMA_DRIZZLE') || ! PMA_DRIZZLE) {
if (isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv']
&& isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']
) {
// Insert all the previous privileges
// but with the new name and the new type
foreach ($privilegesBackup as $priv) {
$adjustProcPrivilege = 'INSERT INTO '
. PMA_Util::backquote('mysql') . '.'
. PMA_Util::backquote('procs_priv')
. ' VALUES("' . $priv[0] . '", "'
. $priv[1] . '", "' . $priv[2] . '", "'
. $_REQUEST['item_name'] . '", "'
. $_REQUEST['item_type'] . '", "'
. $priv[5] . '", "'
. $priv[6] . '", "'
. $priv[7] . '");';
$resultAdjust = $GLOBALS['dbi']->query(
$adjustProcPrivilege
);
}
}
}
if ($resultAdjust) {
// Flush the Privileges
$flushPrivQuery = 'FLUSH PRIVILEGES;';
@ -1101,10 +1115,25 @@ function PMA_RTN_getEditorForm($mode, $operation, $routine)
$retval .= " <td>" . __('Adjust Privileges');
$retval .= PMA_Util::showDocu('faq', 'faq6-39');
$retval .= "</td>";
$retval .= " <td><input type='checkbox' name='item_adjust_privileges'"
. " value='1' checked /></td>";
if (! defined('PMA_DRIZZLE') || ! PMA_DRIZZLE) {
if (isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv']
&& isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']
) {
$retval .= " <td><input type='checkbox' name='item_adjust_privileges'"
. " value='1' checked /></td>";
} else {
$retval .= " <td><input type='checkbox' name='item_adjust_privileges'"
. " value='1' "
. "title='" . __(
"You do not have sufficient privileges to perform this "
. "operation; Please refer to the documentation for more details"
)
. "' disabled/></td>";
}
}
$retval .= "</tr>";
}
$retval .= "<tr>";
$retval .= " <td>" . __('Definer') . "</td>";
$retval .= " <td><input type='text' name='item_definer'";

View File

@ -466,7 +466,7 @@ function PMA_dropMultiDatabases()
'table' => $GLOBALS['table']);
}
//the following variables will be used on mult_submits.inc.php
global $selected, $mult_btn;
global $query_type, $selected, $mult_btn;
include 'libraries/mult_submits.inc.php';
unset($action, $submit_mult, $err_url, $selected_db, $GLOBALS['db']);

View File

@ -1129,7 +1129,7 @@ function PMA_getHtmlForNotAttachedPrivilegesToTableSpecificColumn($row)
*
* @param string $db the database
* @param string $table the table
* @param string $row first row from result or boolean false
* @param array $row first row from result or boolean false
*
* @return string $html_output
*/

View File

@ -2491,6 +2491,7 @@ function PMA_displayHtmlForColumnChange($db, $table, $selected, $action)
/**
* Form for changing properties.
*/
include_once 'libraries/check_user_privileges.lib.php';
include 'libraries/tbl_columns_definition_form.inc.php';
}
@ -2784,26 +2785,33 @@ function PMA_adjustColumnPrivileges($db, $table, $adjust_privileges)
{
$changed = false;
$GLOBALS['dbi']->selectDb('mysql');
if (! defined('PMA_DRIZZLE') || ! PMA_DRIZZLE) {
if (isset($GLOBALS['col_priv']) && $GLOBALS['col_priv']
&& isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']
) {
// For Column specific privileges
foreach ($adjust_privileges as $oldCol => $newCol) {
$query_adjust_col_privileges = 'UPDATE '
. PMA_Util::backquote('columns_priv') . ' '
. 'SET Column_name = "' . $newCol . '" '
. 'WHERE Db = "' . $db . '" AND Table_name = "' . $table
. '" AND Column_name = "' . $oldCol . '";';
$GLOBALS['dbi']->selectDb('mysql');
$GLOBALS['dbi']->query($query_adjust_col_privileges);
// For Column specific privileges
foreach ($adjust_privileges as $oldCol => $newCol) {
$query_adjust_col_privileges = 'UPDATE '
. PMA_Util::backquote('columns_priv') . ' '
. 'SET Column_name = "' . $newCol . '" '
. 'WHERE Db = "' . $db . '" AND Table_name = "' . $table
. '" AND Column_name = "' . $oldCol . '";';
// i.e. if atleast one column privileges adjusted
$changed = true;
}
$GLOBALS['dbi']->query($query_adjust_col_privileges);
if ($changed) {
// Finally FLUSH the new privileges
$flushPrivQuery = "FLUSH PRIVILEGES;";
$GLOBALS['dbi']->query($flushPrivQuery);
// i.e. if atleast one column privileges adjusted
$changed = true;
}
if ($changed) {
// Finally FLUSH the new privileges
$flushPrivQuery = "FLUSH PRIVILEGES;";
$GLOBALS['dbi']->query($flushPrivQuery);
}
}
}
return $changed;

View File

@ -6,15 +6,19 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
if (!defined('PHPMYADMIN')) {
exit;
}
/**
* Check parameters
*/
require_once './libraries/Util.class.php';
require_once './libraries/Template.class.php';
require_once 'libraries/di/Container.class.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/Template.class.php';
require_once 'libraries/util.lib.php';
use PMA\Util;
PMA_Util::checkParameters(array('server', 'db', 'table', 'action', 'num_fields'));
@ -22,13 +26,13 @@ PMA_Util::checkParameters(array('server', 'db', 'table', 'action', 'num_fields')
* Initialize to avoid code execution path warnings
*/
if (! isset($num_fields)) {
if (!isset($num_fields)) {
$num_fields = 0;
}
if (! isset($mime_map)) {
if (!isset($mime_map)) {
$mime_map = null;
}
if (! isset($columnMeta)) {
if (!isset($columnMeta)) {
$columnMeta = array();
}
@ -49,21 +53,22 @@ $length_values_input_size = 8;
$content_cells = array();
/** @var string $db */
$form_params = array(
'db' => $db
);
if ($action == 'tbl_create.php') {
$form_params['reload'] = 1;
} elseif ($action == 'tbl_addfield.php') {
if (isset($_REQUEST['field_where'])) {
$form_params['field_where'] = $_REQUEST['field_where'];
}
if (isset($_REQUEST['field_where'])) {
$form_params['after_field'] = $_REQUEST['after_field'];
}
$form_params['table'] = $table;
} else {
if ($action == 'tbl_addfield.php') {
$form_params = array_merge($form_params, array(
'field_where' => Util\get($_REQUEST, 'field_where')
));
if (isset($_REQUEST['field_where'])) {
$form_params['after_field'] = $_REQUEST['after_field'];
}
}
$form_params['table'] = $table;
}
@ -71,13 +76,10 @@ if (isset($num_fields)) {
$form_params['orig_num_fields'] = $num_fields;
}
if (isset($_REQUEST['field_where'])) {
$form_params['orig_field_where'] = $_REQUEST['field_where'];
}
if (isset($_REQUEST['after_field'])) {
$form_params['orig_after_field'] = $_REQUEST['after_field'];
}
$form_params = array_merge($form_params, array(
'orig_field_where' => Util\get($_REQUEST, 'field_where'),
'orig_after_field' => Util\get($_REQUEST, 'after_field'),
));
if (isset($selected) && is_array($selected)) {
foreach ($selected as $o_fld_nr => $o_fld_val) {
@ -90,12 +92,13 @@ $is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
require_once './libraries/transformations.lib.php';
$cfgRelation = PMA_getRelationsParam();
$comments_map = PMA_getComments($db, $table);
$move_columns = array();
if (isset($fields_meta)) {
$move_columns = $GLOBALS['dbi']->getTable($db, $table)->getColumnsMeta();
/** @var PMA_DatabaseInterface $dbi */
$dbi = \PMA\DI\Container::getDefaultContainer()->get('dbi');
$move_columns = $dbi->getTable($db, $table)->getColumnsMeta();
}
$available_mime = array();
@ -134,52 +137,33 @@ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
$extracted_columnspec = array();
if (!empty($regenerate)) {
$columnMeta['Field'] = isset($_REQUEST['field_name'][$columnNumber])
? $_REQUEST['field_name'][$columnNumber]
: false;
$columnMeta['Type'] = isset($_REQUEST['field_type'][$columnNumber])
? $_REQUEST['field_type'][$columnNumber]
: false;
$columnMeta['Collation'] = isset($_REQUEST['field_collation'][$columnNumber])
? $_REQUEST['field_collation'][$columnNumber]
: '';
$columnMeta['Null'] = isset($_REQUEST['field_null'][$columnNumber])
? $_REQUEST['field_null'][$columnNumber]
: '';
$columnMeta = array_merge($columnMeta, array(
'Field' => Util\get($_REQUEST, "field_name.${columnNumber}", false),
'Type' => Util\get($_REQUEST, "field_type.${columnNumber}", false),
'Collation' => Util\get($_REQUEST, "field_collation.${columnNumber}", ''),
'Null' => Util\get($_REQUEST, "field_null.${columnNumber}", ''),
'DefaultType' => Util\get($_REQUEST, "field_default_type.${columnNumber}", 'NONE'),
'DefaultValue' => Util\get($_REQUEST, "field_default_value.${columnNumber}", ''),
'Extra' => Util\get($_REQUEST, "field_extra.${columnNumber}", false),
));
$columnMeta['Key'] = '';
if (isset($_REQUEST['field_key'][$columnNumber])) {
$parts = explode('_', $_REQUEST['field_key'][$columnNumber], 2);
if (count($parts) == 2 && $parts[1] == $columnNumber) {
switch ($parts[0]) {
case 'primary':
$columnMeta['Key'] = 'PRI';
break;
case 'index':
$columnMeta['Key'] = 'MUL';
break;
case 'unique':
$columnMeta['Key'] = 'UNI';
break;
case 'fulltext':
$columnMeta['Key'] = 'FULLTEXT';
break;
case 'spatial':
$columnMeta['Key'] = 'SPATIAL';
break;
}
}
$parts = explode('_', Util\get($_REQUEST, "field_key.${columnNumber}", ''), 2);
if (count($parts) == 2 && $parts[1] == $columnNumber) {
$columnMeta['Key'] = Util\get(array(
'primary' => 'PRI',
'index' => 'MUL',
'unique' => 'UNI',
'fulltext' => 'FULLTEXT',
'spatial' => 'SPATIAL'
), $parts[0], '');
}
// put None in the drop-down for Default, when someone adds a field
$columnMeta['DefaultType']
= isset($_REQUEST['field_default_type'][$columnNumber])
? $_REQUEST['field_default_type'][$columnNumber]
: 'NONE';
$columnMeta['DefaultValue']
= isset($_REQUEST['field_default_value'][$columnNumber])
? $_REQUEST['field_default_value'][$columnNumber]
: '';
$columnMeta['Comment'] =
isset($submit_fulltext[$columnNumber])
&& ($submit_fulltext[$columnNumber] == $columnNumber)
? 'FULLTEXT' : false;
switch ($columnMeta['DefaultType']) {
case 'NONE':
@ -194,71 +178,42 @@ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
break;
}
$columnMeta['Extra']
= (isset($_REQUEST['field_extra'][$columnNumber])
? $_REQUEST['field_extra'][$columnNumber]
: false);
$columnMeta['Comment']
= (isset($submit_fulltext[$columnNumber])
&& ($submit_fulltext[$columnNumber] == $columnNumber)
? 'FULLTEXT'
: false);
$length = Util\get($_REQUEST, "field_length.${columnNumber}", $length);
$submit_attribute = Util\get($_REQUEST, "field_attribute.${columnNumber}", false);
$comments_map[$columnMeta['Field']] = Util\get($_REQUEST, "field_comments.${columnNumber}");
$length
= (isset($_REQUEST['field_length'][$columnNumber])
? $_REQUEST['field_length'][$columnNumber]
: $length);
$mime_map[$columnMeta['Field']] = array_merge(
$mime_map[$columnMeta['Field']],
array(
'mimetype' => Util\get($_REQUEST, "field_mimetype.${$columnNumber}"),
'transformation' => Util\get($_REQUEST, "field_transformation.${$columnNumber}"),
'transformation_options' => Util\get($_REQUEST, "field_transformation_options.${$columnNumber}")
)
);
$submit_attribute
= (isset($_REQUEST['field_attribute'][$columnNumber])
? $_REQUEST['field_attribute'][$columnNumber]
: false);
if (isset($_REQUEST['field_comments'][$columnNumber])) {
$comments_map[$columnMeta['Field']]
= $_REQUEST['field_comments'][$columnNumber];
}
if (isset($_REQUEST['field_mimetype'][$columnNumber])) {
$mime_map[$columnMeta['Field']]['mimetype']
= $_REQUEST['field_mimetype'][$columnNumber];
}
if (isset($_REQUEST['field_transformation'][$columnNumber])) {
$mime_map[$columnMeta['Field']]['transformation']
= $_REQUEST['field_transformation'][$columnNumber];
}
if (isset($_REQUEST['field_transformation_options'][$columnNumber])) {
$mime_map[$columnMeta['Field']]['transformation_options']
= $_REQUEST['field_transformation_options'][$columnNumber];
}
}
elseif (isset($fields_meta[$columnNumber]))
{
} elseif (isset($fields_meta[$columnNumber])) {
$columnMeta = $fields_meta[$columnNumber];
switch ($columnMeta['Default']) {
case null:
if (is_null($columnMeta['Default'])) { // null
if ($columnMeta['Null'] == 'YES') {
$columnMeta['DefaultType'] = 'NULL';
$columnMeta['DefaultType'] = 'NULL';
$columnMeta['DefaultValue'] = '';
} else {
$columnMeta['DefaultType'] = 'NONE';
$columnMeta['DefaultType'] = 'NONE';
$columnMeta['DefaultValue'] = '';
}
} else { // empty
$columnMeta['DefaultType'] = 'USER_DEFINED';
$columnMeta['DefaultType'] = 'USER_DEFINED';
$columnMeta['DefaultValue'] = $columnMeta['Default'];
}
break;
case 'CURRENT_TIMESTAMP':
$columnMeta['DefaultType'] = 'CURRENT_TIMESTAMP';
$columnMeta['DefaultType'] = 'CURRENT_TIMESTAMP';
$columnMeta['DefaultValue'] = '';
break;
default:
$columnMeta['DefaultType'] = 'USER_DEFINED';
$columnMeta['DefaultType'] = 'USER_DEFINED';
$columnMeta['DefaultValue'] = $columnMeta['Default'];
break;
}
@ -325,12 +280,14 @@ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
if (isset($columnMeta['Type'])) {
// keep in uppercase because the new type will be in uppercase
$form_params['field_type_orig[' . $columnNumber . ']']
= /*overload*/mb_strtoupper($type);
= /*overload*/
mb_strtoupper($type);
if (isset($columnMeta['column_status'])
&& !$columnMeta['column_status']['isEditable']
) {
$form_params['field_type[' . $columnNumber . ']']
= /*overload*/mb_strtoupper($type);
= /*overload*/
mb_strtoupper($type);
}
} else {
$form_params['field_type_orig[' . $columnNumber . ']'] = '';
@ -340,50 +297,15 @@ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
$form_params['field_length_orig[' . $columnNumber . ']'] = $length;
// old column default
$form_params['field_default_value_orig[' . $columnNumber . ']']
= (isset($columnMeta['Default']) ? $columnMeta['Default'] : '');
$form_params['field_default_type_orig[' . $columnNumber . ']']
= (isset($columnMeta['DefaultType']) ? $columnMeta['DefaultType'] : '');
// old column collation
if (isset($columnMeta['Collation'])) {
$form_params['field_collation_orig[' . $columnNumber . ']']
= $columnMeta['Collation'];
} else {
$form_params['field_collation_orig[' . $columnNumber . ']'] = '';
}
// old column attribute
if (isset($extracted_columnspec['attribute'])) {
$form_params['field_attribute_orig[' . $columnNumber . ']']
= trim($extracted_columnspec['attribute']);
} else {
$form_params['field_attribute_orig[' . $columnNumber . ']'] = '';
}
// old column null
if (isset($columnMeta['Null'])) {
$form_params['field_null_orig[' . $columnNumber . ']']
= $columnMeta['Null'];
} else {
$form_params['field_null_orig[' . $columnNumber . ']'] = '';
}
// old column extra (for auto_increment)
if (isset($columnMeta['Extra'])) {
$form_params['field_extra_orig[' . $columnNumber . ']']
= $columnMeta['Extra'];
} else {
$form_params['field_extra_orig[' . $columnNumber . ']'] = '';
}
// old column comment
if (isset($columnMeta['Comment'])) {
$form_params['field_comments_orig[' . $columnNumber . ']']
= $columnMeta['Comment'];
} else {
$form_params['field_comment_orig[' . $columnNumber . ']'] = '';
}
$form_params = array_merge($form_params, array(
"field_default_value_orig[${columnNumber}]" => Util\get($columnMeta, 'Default', ''),
"field_default_type_orig[${columnNumber}]" => Util\get($columnMeta, 'DefaultType', ''),
"field_collation_orig[${columnNumber}]" => Util\get($columnMeta, 'Collation', ''),
"field_attribute_orig[${columnNumber}]" => trim(Util\get($extracted_columnspec, 'attribute', '')),
"field_null_orig[${columnNumber}]" => Util\get($columnMeta, 'Null', ''),
"field_extra_orig[${columnNumber}]" => Util\get($columnMeta, 'Extra', ''),
"field_comments_orig[${columnNumber}]" => Util\get($columnMeta, 'Comment', ''),
));
}
$content_cells[$columnNumber] = array(
@ -411,15 +333,15 @@ $html = PMA\Template::get('columns_definitions/column_definitions_form')
'mimework' => $cfgRelation['mimework'],
'action' => $action,
'form_params' => $form_params,
'content_cells' => $content_cells
'content_cells' => $content_cells,
'privs_available' => $privs_available
));
unset($form_params);
$response = PMA_Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('jquery/jquery.uitablefilter.js');
$scripts->addFile('indexes.js');
$response->getHeader()->getScripts()->addFiles(array(
'jquery/jquery.uitablefilter.js',
'indexes.js'
));
$response->addHTML($html);
?>

26
libraries/util.lib.php Normal file
View File

@ -0,0 +1,26 @@
<?php
namespace PMA\Util;
/**
* Access to a multidimensional array by dot notation
*
* @param array $array
* @param string|array $path
* @param mixed $default
* @return mixed
*/
function get($array, $path, $default = null) {
if (is_string($path)) {
$path = explode('.', $path);
}
$p = array_shift($path);
while (isset($p)) {
if (!isset($array[$p])) {
return $default;
}
$array = $array[$p];
$p = array_shift($path);
}
return $array;
}

View File

@ -4,10 +4,10 @@ msgstr ""
"Project-Id-Version: phpMyAdmin 4.5.0-dev\n"
"Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n"
"POT-Creation-Date: 2015-06-28 06:20-0400\n"
"PO-Revision-Date: 2015-06-23 16:27+0200\n"
"PO-Revision-Date: 2015-07-04 11:08+0200\n"
"Last-Translator: dingo thirteen <dingo13@gmail.com>\n"
"Language-Team: Dutch <https://hosted.weblate.org/projects/phpmyadmin/master/"
"nl/>\n"
"Language-Team: Dutch "
"<https://hosted.weblate.org/projects/phpmyadmin/master/nl/>\n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@ -275,7 +275,6 @@ msgid "Data"
msgstr "Data"
#: db_export.php:54
#, fuzzy
#| msgid "Select All"
msgid "Select all"
msgstr "Alles selecteren"
@ -6145,16 +6144,14 @@ msgid "Customize appearance of the navigation panel."
msgstr "Weergaveopties voor het navigatiepaneel."
#: libraries/config/messages.inc.php:248
#, fuzzy
#| msgid "Navigation panel"
msgid "Navigation tree"
msgstr "Navigatiepaneel"
msgstr "Navigatie boomstructuur"
#: libraries/config/messages.inc.php:249
#, fuzzy
#| msgid "Customize navigation panel"
msgid "Customize the navigation tree."
msgstr "Aanpassen navigatiepaneel"
msgstr "Aanpassen navigatie boomstructuur."
#: libraries/config/messages.inc.php:250 libraries/select_server.lib.php:46
#: setup/frames/index.inc.php:144
@ -6757,64 +6754,56 @@ msgid "Enable navigation tree expansion"
msgstr "Uitklappen van de navigatiestructuur inschakelen"
#: libraries/config/messages.inc.php:487
#, fuzzy
#| msgid "Show/Hide tables list"
msgid "Show tables in tree"
msgstr "Toon/verberg lijst met tabellen"
msgstr "Toon tabellen in boomstructuur"
#: libraries/config/messages.inc.php:489
#, fuzzy
#| msgid ""
#| "Whether to offer the possibility of tree expansion in the navigation "
#| "panel."
msgid "Whether to show tables under database in the navigation tree"
msgstr ""
"Of uitklappen van de boomstructuur aangeboden mag worden in het "
"navigatiepaneel."
msgstr "Of tabellen getoond worden in de navigatie boomstructuur"
#: libraries/config/messages.inc.php:490
#, fuzzy
#| msgid "Show versions"
msgid "Show views in tree"
msgstr "Versies weergeven"
msgstr "Versies weergeven in boomstructuur"
#: libraries/config/messages.inc.php:492
#, fuzzy
#| msgid "Show databases navigation as tree"
msgid "Whether to show views under database in the navigation tree"
msgstr "Geef databases navigatiescherm weer als boomstructuur"
msgstr "Of views getoond worden onder database in de navigatie boomstructuur"
#: libraries/config/messages.inc.php:493
#, fuzzy
#| msgid "Show function fields"
msgid "Show functions in tree"
msgstr "Toon functievelden"
msgstr "Toon functies in boomstructuur"
#: libraries/config/messages.inc.php:495
msgid "Whether to show functions under database in the navigation tree"
msgstr ""
msgstr "Of functies getoond worden onder database in de navigatie boomstructuur"
#: libraries/config/messages.inc.php:496
#, fuzzy
#| msgid "Show processes"
msgid "Show procedures in tree"
msgstr "Laat processen zien"
msgstr "Laat procedures zien een boomstructuur"
#: libraries/config/messages.inc.php:498
msgid "Whether to show procedures under database in the navigation tree"
msgstr ""
"Of procedures getoond worden onder database in de navigatie boomstructuur"
#: libraries/config/messages.inc.php:499
#, fuzzy
#| msgid "Show versions"
msgid "Show events in tree"
msgstr "Versies weergeven"
msgstr "Toon gebeurtenissen in een boomstructuur"
#: libraries/config/messages.inc.php:501
#, fuzzy
#| msgid "Show databases navigation as tree"
msgid "Whether to show events under database in the navigation tree"
msgstr "Geef databases navigatiescherm weer als boomstructuur"
msgstr ""
"Of gebeurtenissen getoond worden onder database in de navigatie boomstructuur"
#: libraries/config/messages.inc.php:503
msgid "Maximum number of recently used tables; set 0 to disable."
@ -6843,6 +6832,8 @@ msgstr "Waar de tabelregellinks getoond worden"
#: libraries/config/messages.inc.php:510
msgid "Whether to show row links even in the absence of a unique key."
msgstr ""
"Of links naar rijen getoond worden zelfs bij afwezigheid van een uniek "
"sleutelveld."
#: libraries/config/messages.inc.php:511
msgid "Show row links anyway"
@ -8259,16 +8250,14 @@ msgid "View output as text"
msgstr "Bekijk output als tekst"
#: libraries/display_export.lib.php:660
#, fuzzy
#| msgid "Export views as tables"
msgid "Export databases as separate files"
msgstr "Views exporteren als tabellen"
msgstr "Exporteer databases as afzonderlijke bestanden"
#: libraries/display_export.lib.php:662
#, fuzzy
#| msgid "Export table headers"
msgid "Export tables as separate files"
msgstr "Exporteer tabel kopregels"
msgstr "Exporteer tabellen als afzonderlijke bestanden"
#: libraries/display_export.lib.php:692 libraries/display_export.lib.php:814
msgid "Rename exported databases/tables/columns"
@ -9283,10 +9272,9 @@ msgid "An error has occurred while loading the navigation display"
msgstr "Er is een fout opgetreden bij het laden van de navigatieweergave"
#: libraries/navigation/Navigation.class.php:192
#, fuzzy
#| msgid "Group name:"
msgid "Groups:"
msgstr "Groepsnaam:"
msgstr "Groepen:"
#: libraries/navigation/Navigation.class.php:193
msgid "Events:"
@ -11165,10 +11153,9 @@ msgid "Managing Central list of columns"
msgstr "Beheer van centrale lijst van kolommen"
#: libraries/relation.lib.php:324
#, fuzzy
#| msgid "Remember table's sorting"
msgid "Remembering Designer Settings"
msgstr "De tabelsortering onthouden"
msgstr "Onthoud Ontwerper Instellingen"
#: libraries/relation.lib.php:332
msgid "Quick steps to setup advanced features:"

View File

@ -6,151 +6,22 @@
* @package PhpMyAdmin
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/Template.class.php';
use PMA\Template;
namespace PMA;
/*
* Execute the query and return the result
*/
if (isset($_REQUEST['ajax_request'])
&& isset($_REQUEST['pos'])
&& isset($_REQUEST['session_max_rows'])
) {
$response = PMA_Response::getInstance();
require_once 'libraries/di/Container.class.php';
require_once 'libraries/controllers/TableChartController.class.php';
$tableLength = /*overload*/mb_strlen($GLOBALS['table']);
$dbLength = /*overload*/mb_strlen($GLOBALS['db']);
if ($tableLength && $dbLength) {
include './libraries/tbl_common.inc.php';
}
$container = DI\Container::getDefaultContainer();
$container->factory('PMA\Controllers\Table\TableChartController');
$container->alias('TableChartController', 'PMA\Controllers\Table\TableChartController');
$sql_with_limit = 'SELECT * FROM( ' . $sql_query . ' ) AS `temp_res` LIMIT '
. $_REQUEST['pos'] . ', ' . $_REQUEST['session_max_rows'];
$data = array();
$result = $GLOBALS['dbi']->tryQuery($sql_with_limit);
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
$data[] = $row;
}
if (empty($data)) {
$response->isSuccess(false);
$response->addJSON('message', __('No data to display'));
exit;
}
$sanitized_data = array();
foreach ($data as $data_row_number => $data_row) {
$tmp_row = array();
foreach ($data_row as $data_column => $data_value) {
$tmp_row[htmlspecialchars($data_column)] = htmlspecialchars($data_value);
}
$sanitized_data[] = $tmp_row;
}
$response->isSuccess(true);
$response->addJSON('message', null);
$response->addJSON('chartData', json_encode($sanitized_data));
unset($sanitized_data);
exit;
}
$response = PMA_Response::getInstance();
// Throw error if no sql query is set
if (! isset($sql_query) || $sql_query == '') {
$response->isSuccess(false);
$response->addHTML(
PMA_Message::error(__('No SQL query was set to fetch data.'))
);
exit;
}
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('chart.js');
$scripts->addFile('tbl_chart.js');
$scripts->addFile('jqplot/jquery.jqplot.js');
$scripts->addFile('jqplot/plugins/jqplot.barRenderer.js');
$scripts->addFile('jqplot/plugins/jqplot.canvasAxisLabelRenderer.js');
$scripts->addFile('jqplot/plugins/jqplot.canvasTextRenderer.js');
$scripts->addFile('jqplot/plugins/jqplot.categoryAxisRenderer.js');
$scripts->addFile('jqplot/plugins/jqplot.dateAxisRenderer.js');
$scripts->addFile('jqplot/plugins/jqplot.pointLabels.js');
$scripts->addFile('jqplot/plugins/jqplot.pieRenderer.js');
$scripts->addFile('jqplot/plugins/jqplot.highlighter.js');
/**
* Runs common work
*/
if (/*overload*/mb_strlen($GLOBALS['table'])) {
$url_params['goto'] = PMA_Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabTable'], 'table'
);
$url_params['back'] = 'tbl_sql.php';
include 'libraries/tbl_common.inc.php';
include 'libraries/tbl_info.inc.php';
} elseif (/*overload*/mb_strlen($GLOBALS['db'])) {
$url_params['goto'] = PMA_Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabDatabase'], 'database'
);
$url_params['back'] = 'sql.php';
include 'libraries/db_common.inc.php';
include 'libraries/db_info.inc.php';
} else {
$url_params['goto'] = PMA_Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabServer'], 'server'
);
$url_params['back'] = 'sql.php';
include 'libraries/server_common.inc.php';
}
$data = array();
$result = $GLOBALS['dbi']->tryQuery($sql_query);
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
$data[] = $row;
}
$keys = array_keys($data[0]);
$numeric_types = array('int', 'real');
$numeric_column_count = 0;
foreach ($keys as $idx => $key) {
if (in_array($fields_meta[$idx]->type, $numeric_types)) {
$numeric_column_count++;
}
}
if ($numeric_column_count == 0) {
$response->isSuccess(false);
$response->addJSON(
'message',
__('No numeric columns present in the table to plot.')
);
exit;
}
// get settings if any posted
$chartSettings = array();
if (PMA_isValid($_REQUEST['chartSettings'], 'array')) {
$chartSettings = $_REQUEST['chartSettings'];
}
$url_params['db'] = $GLOBALS['db'];
$url_params['reload'] = 1;
/**
* Displays the page
*/
$response->addHTML(
Template::get('tbl_chart')
->render(
array(
'url_query' => $url_query,
'url_params' => $url_params,
'keys' => $keys,
'fields_meta' => $fields_meta,
'numeric_types' => $numeric_types,
'numeric_column_count' => $numeric_column_count,
'sql_query' => $sql_query
)
)
/* Define dependencies for the concerned controller */
$dependency_definitions = array(
"sql_query" => &$GLOBALS['sql_query'],
"url_query" => &$GLOBALS['url_query'],
"cfg" => &$GLOBALS['cfg']
);
/** @var Controllers\Table\TableChartController $controller */
$controller = $container->get('TableChartController', $dependency_definitions);
$controller->indexAction();

View File

@ -6,126 +6,27 @@
* @package PhpMyAdmin
*/
require_once 'libraries/common.inc.php';
require_once './libraries/gis/GIS_Visualization.class.php';
require_once './libraries/gis/GIS_Factory.class.php';
namespace PMA;
// Runs common work
require_once 'libraries/db_common.inc.php';
$url_params['goto'] = PMA_Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabDatabase'], 'database'
);
$url_params['back'] = 'sql.php';
use PMA_Util;
$response = PMA_Response::getInstance();
// Throw error if no sql query is set
if (! isset($sql_query) || $sql_query == '') {
$response->isSuccess(false);
$response->addHTML(
PMA_Message::error(__('No SQL query was set to fetch data.'))
);
exit;
}
require_once 'libraries/di/Container.class.php';
require_once 'libraries/controllers/TableGisVisualizationController.class.php';
require_once 'libraries/Util.class.php';
// Execute the query and return the result
$result = $GLOBALS['dbi']->tryQuery($sql_query);
// Get the meta data of results
$meta = $GLOBALS['dbi']->getFieldsMeta($result);
$container = DI\Container::getDefaultContainer();
$container->factory('PMA\Controllers\Table\TableGisVisualizationController');
$container->alias('TableGisVisualizationController', 'PMA\Controllers\Table\TableGisVisualizationController');
// Find the candidate fields for label column and spatial column
$labelCandidates = array(); $spatialCandidates = array();
foreach ($meta as $column_meta) {
if ($column_meta->type == 'geometry') {
$spatialCandidates[] = $column_meta->name;
} else {
$labelCandidates[] = $column_meta->name;
}
}
// Get settings if any posted
$visualizationSettings = array();
if (PMA_isValid($_REQUEST['visualizationSettings'], 'array')) {
$visualizationSettings = $_REQUEST['visualizationSettings'];
}
if (! isset($visualizationSettings['labelColumn']) && isset($labelCandidates[0])) {
$visualizationSettings['labelColumn'] = '';
}
// If spatial column is not set, use first geometric column as spatial column
if (! isset($visualizationSettings['spatialColumn'])) {
$visualizationSettings['spatialColumn'] = $spatialCandidates[0];
}
// Convert geometric columns from bytes to text.
$pos = isset($_REQUEST['pos']) ? $_REQUEST['pos'] : $_SESSION['tmpval']['pos'];
if (isset($_REQUEST['session_max_rows'])) {
$rows = $_REQUEST['session_max_rows'];
} else {
if ($_SESSION['tmpval']['max_rows'] != 'all') {
$rows = $_SESSION['tmpval']['max_rows'];
} else {
$rows = $GLOBALS['cfg']['MaxRows'];
}
}
if (isset($_REQUEST['saveToFile'])) {
$response->disable();
$file_name = $visualizationSettings['spatialColumn'];
$save_format = $_REQUEST['fileFormat'];
$visualization = PMA_GIS_Visualization::get($sql_query, $visualizationSettings, $rows, $pos);
$visualization->toFile($file_name, $save_format);
exit();
}
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('openlayers/OpenLayers.js');
$scripts->addFile('jquery/jquery.svg.js');
$scripts->addFile('tbl_gis_visualization.js');
$scripts->addFile('OpenStreetMap.js');
// If all the rows contain SRID, use OpenStreetMaps on the initial loading.
if (! isset($_REQUEST['displayVisualization'])) {
$visualization = PMA_GIS_Visualization::get($sql_query, $visualizationSettings, $rows, $pos);
if ($visualization->hasSrid())
unset($visualizationSettings['choice']);
$visualizationSettings['choice'] = 'useBaseLayer';
}
$svgSupport = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER <= 8)
? false : true;
$format = $svgSupport ? 'svg' : 'png';
$visualization = PMA_GIS_Visualization::get($sql_query, $visualizationSettings, $rows, $pos);
if ($visualizationSettings != null) {
foreach ($visualization->getSettings() as $setting => $val) {
if (! isset($visualizationSettings[$setting])) {
$visualizationSettings[$setting] = $val;
}
}
}
$result = $visualization->toImage($format);
/**
* Displays the page
*/
$url_params['sql_query'] = $sql_query;
$downloadUrl = 'tbl_gis_visualization.php' . PMA_URL_getCommon($url_params)
. '&saveToFile=true';
$html = PMA\Template::get('gis_visualization/gis_visualization')->render(
array(
'url_params' => $url_params,
'downloadUrl' => $downloadUrl,
'labelCandidates' => $labelCandidates,
'spatialCandidates' => $spatialCandidates,
'visualizationSettings' => $visualizationSettings,
'sql_query' => $sql_query,
'visualization' => $result,
'svgSupport' => $svgSupport,
'drawOl' => $visualization->asOl()
)
/* Define dependencies for the concerned controller */
$dependency_definitions = array(
"sql_query" => &$GLOBALS['sql_query'],
"url_params" => &$GLOBALS['url_params'],
"goto" => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database'),
"back" => 'sql.php',
"visualizationSettings" => array()
);
$response->addHTML($html);
/** @var Controllers\Table\TableGisVisualizationController $controller */
$controller = $container->get('TableGisVisualizationController', $dependency_definitions);
$controller->indexAction();

View File

@ -6,131 +6,41 @@
* @package PhpMyAdmin
*/
/**
* Gets some core libraries
*/
require_once 'libraries/common.inc.php';
namespace PMA;
use PMA_Index;
require_once 'libraries/di/Container.class.php';
require_once 'libraries/controllers/TableIndexesController.class.php';
require_once 'libraries/Index.class.php';
require_once 'libraries/Template.class.php';
if (! isset($_REQUEST['create_edit_table'])) {
include_once 'libraries/tbl_common.inc.php';
$container = DI\Container::getDefaultContainer();
$container->factory('PMA\Controllers\Table\TableIndexesController');
$container->alias('TableIndexesController', 'PMA\Controllers\Table\TableIndexesController');
/* Define dependencies for the concerned controller */
$db = $container->get('db');
$table = $container->get('table');
$dbi = $container->get('dbi');
if (!isset($_REQUEST['create_edit_table'])) {
include_once 'libraries/tbl_common.inc.php';
}
if (isset($_REQUEST['index'])) {
if (is_array($_REQUEST['index'])) {
// coming already from form
$index = new PMA_Index($_REQUEST['index']);
} else {
$index = $GLOBALS['dbi']->getTable($db, $table)
->getIndex($_REQUEST['index']);
}
if (is_array($_REQUEST['index'])) {
// coming already from form
$index = new PMA_Index($_REQUEST['index']);
} else {
$index = $dbi->getTable($db, $table)->getIndex($_REQUEST['index']);
}
} else {
$index = new PMA_Index;
$index = new PMA_Index;
}
/**
* Process the data from the edit/create index form,
* run the query to build the new index
* and moves back to "tbl_sql.php"
*/
if (isset($_REQUEST['do_save_data'])) {
$error = false;
$sql_query = $GLOBALS['dbi']->getTable($db, $table)
->getSqlQueryForIndexCreateOrEdit($index, $error);
// If there is a request for SQL previewing.
if (isset($_REQUEST['preview_sql'])) {
PMA_Response::getInstance()->addJSON(
'sql_data',
PMA\Template::get('preview_sql')
->render(
array(
'query_data' => $sql_query
)
)
);
} elseif (!$error) {
$GLOBALS['dbi']->query($sql_query);
if ($GLOBALS['is_ajax_request'] == true) {
$message = PMA_Message::success(
__('Table %1$s has been altered successfully.')
);
$message->addParam($table);
$response = PMA_Response::getInstance();
$response->addJSON(
'message', PMA_Util::getMessage($message, $sql_query, 'success')
);
$response->addJSON('index_table', PMA_Index::getHtmlForIndexes($table, $db));
} else {
include 'tbl_structure.php';
}
} else {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', $error);
}
exit;
} // end builds the new index
/**
* Display the form to edit/create an index
*/
require_once 'libraries/tbl_info.inc.php';
$add_fields = 0;
if (isset($_REQUEST['index']) && is_array($_REQUEST['index'])) {
// coming already from form
if (isset($_REQUEST['index']['columns']['names'])) {
$add_fields = count($_REQUEST['index']['columns']['names'])
- $index->getColumnCount();
}
if (isset($_REQUEST['add_fields'])) {
$add_fields += $_REQUEST['added_fields'];
}
} elseif (isset($_REQUEST['create_index'])) {
$add_fields = $_REQUEST['added_fields'];
} // end preparing form values
// Get fields and stores their name/type
if (isset($_REQUEST['create_edit_table'])) {
$fields = json_decode($_REQUEST['columns'], true);
$index_params = array(
'Non_unique' => ($_REQUEST['index']['Index_choice'] == 'UNIQUE') ? '0' : '1'
);
$index->set($index_params);
$add_fields = count($fields);
} else {
$fields = $GLOBALS['dbi']->getTable($db, $table)->getNameAndTypeOfTheColumns();
}
$form_params = array(
'db' => $db,
'table' => $table,
$dependency_definitions = array(
"index" => $index
);
if (isset($_REQUEST['create_index'])) {
$form_params['create_index'] = 1;
} elseif (isset($_REQUEST['old_index'])) {
$form_params['old_index'] = $_REQUEST['old_index'];
} elseif (isset($_REQUEST['index'])) {
$form_params['old_index'] = $_REQUEST['index'];
}
$response = PMA_Response::getInstance();
$response->addHTML(PMA\Template::get('index_form')
->render(array(
'fields' => $fields,
'index' => $index,
'form_params' => $form_params,
'add_fields' => $add_fields
))
);
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('indexes.js');
/** @var Controllers\Table\TableIndexesController $controller */
$controller = $container->get('TableIndexesController', $dependency_definitions);
$controller->indexAction();

View File

@ -14,6 +14,7 @@ require_once 'libraries/common.inc.php';
/**
* functions implementation for this script
*/
require_once 'libraries/check_user_privileges.lib.php';
require_once 'libraries/operations.lib.php';
$pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);

View File

@ -15,251 +15,61 @@
*/
/**
* Gets some core libraries
* Get the TableRelationController
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/index.lib.php';
require_once 'libraries/Template.class.php';
namespace PMA;
use PMA_Table;
use PMA_Util;
require_once 'libraries/di/Container.class.php';
require_once 'libraries/controllers/TableRelationController.class.php';
require_once 'libraries/Table.class.php';
require_once 'libraries/structure.lib.php';
require_once 'libraries/Util.class.php';
$response = PMA_Response::getInstance();
// Send table of column names to populate corresponding dropdowns depending
// on the current selection
if (isset($_REQUEST['getDropdownValues'])
&& $_REQUEST['getDropdownValues'] === 'true'
) {
if (isset($_REQUEST['foreignTable'])) { // if both db and table are selected
$foreignTable = $_REQUEST['foreignTable'];
$table_obj = new PMA_Table($foreignTable, $_REQUEST['foreignDb']);
// Since views do not have keys defined on them provide the full list of columns
if (PMA_Table::isView($_REQUEST['foreignDb'], $foreignTable)) {
$columnList = $table_obj->getColumns(false, false);
} else {
$columnList = $table_obj->getIndexedColumns(false, false);
}
$columns = array();
foreach ($columnList as $column) {
$columns[] = htmlspecialchars($column);
}
$response->addJSON('columns', $columns);
// @todo should be: $server->db($db)->table($table)->primary()
$primary = PMA_Index::getPrimary($foreignTable, $_REQUEST['foreignDb']);
if (false === $primary) {
return;
}
$primarycols = array_keys($primary->getColumns());
$response->addJSON('primary', $primarycols);
} else { // if only the db is selected
$tables = array();
$foreign = isset($_REQUEST['foreign']) && $_REQUEST['foreign'] === 'true';
if ($foreign) {
$tbl_storage_engine = /*overload*/mb_strtoupper(
PMA_Table::sGetStatusInfo(
$_REQUEST['db'],
$_REQUEST['table'],
'Engine'
)
);
}
// In Drizzle, 'SHOW TABLE STATUS' will show status only for the tables
// which are currently in the table cache. Hence we have to use 'SHOW TABLES'
// and manually retrieve table engine values.
if ($foreign && ! PMA_DRIZZLE) {
$query = 'SHOW TABLE STATUS FROM '
. PMA_Util::backquote($_REQUEST['foreignDb']);
$tables_rs = $GLOBALS['dbi']->query(
$query,
null,
PMA_DatabaseInterface::QUERY_STORE
);
while ($row = $GLOBALS['dbi']->fetchArray($tables_rs)) {
if (isset($row['Engine'])
&& /*overload*/mb_strtoupper($row['Engine']) == $tbl_storage_engine
) {
$tables[] = htmlspecialchars($row['Name']);
}
}
} else {
$query = 'SHOW TABLES FROM '
. PMA_Util::backquote($_REQUEST['foreignDb']);
$tables_rs = $GLOBALS['dbi']->query(
$query,
null,
PMA_DatabaseInterface::QUERY_STORE
);
while ($row = $GLOBALS['dbi']->fetchArray($tables_rs)) {
if ($foreign && PMA_DRIZZLE) {
$engine = /*overload*/mb_strtoupper(
PMA_Table::sGetStatusInfo(
$_REQUEST['foreignDb'],
$row[0],
'Engine'
)
);
if (isset($engine) && $engine == $tbl_storage_engine) {
$tables[] = htmlspecialchars($row[0]);
}
} else {
$tables[] = htmlspecialchars($row[0]);
}
}
}
$response->addJSON('tables', $tables);
}
exit;
}
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('tbl_relation.js');
$scripts->addFile('indexes.js');
/**
* Gets tables information
*/
require_once 'libraries/tbl_info.inc.php';
$container = DI\Container::getDefaultContainer();
$container->factory('PMA\Controllers\Table\TableRelationController');
$container->alias('TableRelationController', 'PMA\Controllers\Table\TableRelationController');
/* Define dependencies for the concerned controller */
$db = $container->get('db');
$table = $container->get('table');
$dbi = $container->get('dbi');
$options_array = array(
'CASCADE' => 'CASCADE',
'SET_NULL' => 'SET NULL',
'NO_ACTION' => 'NO ACTION',
'RESTRICT' => 'RESTRICT',
'CASCADE' => 'CASCADE',
'SET_NULL' => 'SET NULL',
'NO_ACTION' => 'NO ACTION',
'RESTRICT' => 'RESTRICT',
);
/**
* Gets the relation settings
*/
$cfgRelation = PMA_getRelationsParam();
$tbl_storage_engine = /*overload*/
mb_strtoupper(
PMA_Table::sGetStatusInfo(
$db,
$table,
'Engine'
)
);
$upd_query = new PMA_Table($table, $db, $dbi);
/**
* Updates
*/
if ($cfgRelation['relwork']) {
$existrel = PMA_getForeigners($db, $table, '', 'internal');
}
if (PMA_Util::isForeignKeySupported($tbl_storage_engine)) {
$existrel_foreign = PMA_getForeigners($db, $table, '', 'foreign');
}
if ($cfgRelation['displaywork']) {
$disp = PMA_getDisplayField($db, $table);
} else {
$disp = '';
}
// will be used in the logic for internal relations and foreign keys:
$multi_edit_columns_name = isset($_REQUEST['fields_name'])
? $_REQUEST['fields_name']
: null;
$html_output = '';
$upd_query = new PMA_Table($table, $db, $GLOBALS['dbi']);
// u p d a t e s f o r I n t e r n a l r e l a t i o n s
if (isset($_POST['destination_db']) && $cfgRelation['relwork']) {
if ($upd_query->updateInternalRelations(
$multi_edit_columns_name, $_POST['destination_db'], $_POST['destination_table'],
$_POST['destination_column'], $cfgRelation, isset($existrel) ? $existrel : null
)) {
$html_output .= PMA_Util::getMessage(
__('Internal relations were successfully updated.'),
'', 'success'
);
}
} // end if (updates for internal relations)
$multi_edit_columns_name = isset($_REQUEST['foreign_key_fields_name'])
? $_REQUEST['foreign_key_fields_name']
: null;
// u p d a t e s f o r f o r e i g n k e y s
// (for now, one index name only; we keep the definitions if the
// foreign db is not the same)
if (isset($_POST['destination_foreign_db'])) {
list($html, $preview_sql_data, $display_query, $seen_error) = $upd_query->updateForeignKeys(
$_POST['destination_foreign_db'],
$multi_edit_columns_name, $_POST['destination_foreign_table'],
$_POST['destination_foreign_column'], $options_array, $table,
isset($existrel_foreign) ? $existrel_foreign['foreign_keys_data'] : null
);
$html_output .= $html;
// If there is a request for SQL previewing.
if (isset($_REQUEST['preview_sql'])) {
PMA_previewSQL($preview_sql_data);
}
if (! empty($display_query) && ! $seen_error) {
$GLOBALS['display_query'] = $display_query;
$html_output .= PMA_Util::getMessage(
__('Your SQL query has been executed successfully.'),
null, 'success'
);
}
} // end if isset($destination_foreign)
// U p d a t e s f o r d i s p l a y f i e l d
if ($cfgRelation['displaywork'] && isset($_POST['display_field'])) {
if ($upd_query->updateDisplayField($disp, $_POST['display_field'], $cfgRelation)) {
$html_output .= PMA_Util::getMessage(
__('Display column was successfully updated.'),
'', 'success'
);
}
} // end if
// If we did an update, refresh our data
if (isset($_POST['destination_db']) && $cfgRelation['relwork']) {
$existrel = PMA_getForeigners($db, $table, '', 'internal');
}
if (isset($_POST['destination_foreign_db'])
&& PMA_Util::isForeignKeySupported($tbl_storage_engine)
) {
$existrel_foreign = PMA_getForeigners($db, $table, '', 'foreign');
}
if ($cfgRelation['displaywork']) {
$disp = PMA_getDisplayField($db, $table);
}
// display secondary level tabs if necessary
$engine = PMA_Table::sGetStatusInfo($db, $table, 'ENGINE');
$response->addHTML(PMA_getStructureSecondaryTabs($engine));
$response->addHTML('<div id="structure_content">');
/**
* Dialog
*/
// Now find out the columns of our $table
// need to use PMA_DatabaseInterface::QUERY_STORE with $GLOBALS['dbi']->numRows()
// in mysqli
$columns = $GLOBALS['dbi']->getColumns($db, $table);
// common form
$html_output .= PMA\Template::get('tbl_relation/common_form')->render(
array(
'db' => $db,
'table' => $table,
'columns' => $columns,
'cfgRelation' => $cfgRelation,
'tbl_storage_engine' => $tbl_storage_engine,
'existrel' => isset($existrel) ? $existrel : array(),
'existrel_foreign' => isset($existrel_foreign) ? $existrel_foreign['foreign_keys_data'] : array(),
'options_array' => $options_array
)
$dependency_definitions = array(
"options_array" => $options_array,
"cfgRelation" => $cfgRelation,
"tbl_storage_engine" => $tbl_storage_engine,
"upd_query" => $upd_query
);
if (PMA_Util::isForeignKeySupported($tbl_storage_engine)) {
$html_output .= PMA_getHtmlForDisplayIndexes();
if ($cfgRelation['relwork']) {
$dependency_definitions['existrel'] = PMA_getForeigners($db, $table, '', 'internal');
}
if (PMA_Util::isForeignKeySupported($tbl_storage_engine)) {
$dependency_definitions['existrel_foreign'] = PMA_getForeigners($db, $table, '', 'foreign');
}
if ($cfgRelation['displaywork']) {
$dependency_definitions['disp'] = PMA_getDisplayField($db, $table);
} else {
$dependency_definitions['disp'] = 'asas';
}
// Render HTML output
$response->addHTML($html_output);
$response->addHTML('</div>');
/** @var Controllers\Table\TableRelationController $controller */
$controller = $container->get('TableRelationController', $dependency_definitions);
$controller->indexAction();

View File

@ -19,6 +19,7 @@ PMA_PageSettings::showGroup('TableStructure');
/**
* Function implementations for this script
*/
require_once 'libraries/check_user_privileges.lib.php';
require_once 'libraries/structure.lib.php';
require_once 'libraries/index.lib.php';
require_once 'libraries/sql.lib.php';

View File

@ -1,6 +1,18 @@
<input name="field_adjust_privileges[<?php echo $columnNumber; ?>]"
id="field_<?php echo $columnNumber; ?>_<?php echo ($ci - $ci_offset); ?>"
checked="checked"
type="checkbox"
value="NULL"
class="allow_null"/>
<?php if ($privs_available) : ?>
<input name="field_adjust_privileges[<?php echo $columnNumber; ?>]"
id="field_<?php echo $columnNumber; ?>_<?php echo ($ci - $ci_offset); ?>"
checked="checked"
type="checkbox"
value="NULL"
class="allow_null"/>
<?php else : ?>
<input name="field_adjust_privileges[<?php echo $columnNumber; ?>]"
id="field_<?php echo $columnNumber; ?>_<?php echo ($ci - $ci_offset); ?>"
disabled
type="checkbox"
value="NULL"
class="allow_null"
title="<?php echo __('You don\'t have sufficient privileges to perform this '
. 'operation; Please refer to the documentation for more details');?>"/>
<?php endif; ?>

View File

@ -84,14 +84,17 @@ $ci_offset = -1;
'columnMeta' => isset($columnMeta) ? $columnMeta : null
)); ?>
</td>
<?php if (isset($_REQUEST['change_column']) && !empty($_REQUEST['change_column'])): ?>
<?php if (isset($_REQUEST['change_column']) && !empty($_REQUEST['change_column']) && ! PMA_DRIZZLE): ?>
<!-- column Adjust Privileges, Only for 'Edit' Column(s) -->
<td class="center">
<?php $privs_available = isset($GLOBALS['col_priv']) && $GLOBALS['col_priv']
&& isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']; ?>
<?php echo PMA\Template::get('columns_definitions/column_adjust_privileges')
->render(array(
'columnNumber' => $columnNumber,
'ci' => $ci++,
'ci_offset' => $ci_offset
'ci_offset' => $ci_offset,
'privs_available' => $privs_available
)); ?>
</td>
<?php endif; ?>