Replace PhpMyAdmin\Relation static calls
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
parent
46ceeea14f
commit
d98658187a
@ -35,10 +35,12 @@ $header = $response->getHeader();
|
||||
$header->disableMenuAndConsole();
|
||||
$header->setBodyId('body_browse_foreigners');
|
||||
|
||||
$relation = new Relation();
|
||||
|
||||
/**
|
||||
* Displays the frame
|
||||
*/
|
||||
$foreigners = Relation::getForeigners($db, $table);
|
||||
$foreigners = $relation->getForeigners($db, $table);
|
||||
$browseForeigners = new BrowseForeigners(
|
||||
$GLOBALS['cfg']['LimitChars'],
|
||||
$GLOBALS['cfg']['MaxRows'],
|
||||
@ -50,7 +52,7 @@ $foreign_limit = $browseForeigners->getForeignLimit(
|
||||
isset($_REQUEST['foreign_showAll']) ? $_REQUEST['foreign_showAll'] : null
|
||||
);
|
||||
|
||||
$foreignData = Relation::getForeignData(
|
||||
$foreignData = $relation->getForeignData(
|
||||
$foreigners, $_REQUEST['field'], true,
|
||||
isset($_REQUEST['foreign_filter'])
|
||||
? $_REQUEST['foreign_filter']
|
||||
|
||||
14
chk_rel.php
14
chk_rel.php
@ -10,25 +10,27 @@ use PhpMyAdmin\Response;
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
|
||||
$relation = new Relation();
|
||||
|
||||
// If request for creating the pmadb
|
||||
if (isset($_REQUEST['create_pmadb'])) {
|
||||
if (Relation::createPmaDatabase()) {
|
||||
Relation::fixPmaTables('phpmyadmin');
|
||||
if ($relation->createPmaDatabase()) {
|
||||
$relation->fixPmaTables('phpmyadmin');
|
||||
}
|
||||
}
|
||||
|
||||
// If request for creating all PMA tables.
|
||||
if (isset($_REQUEST['fixall_pmadb'])) {
|
||||
Relation::fixPmaTables($GLOBALS['db']);
|
||||
$relation->fixPmaTables($GLOBALS['db']);
|
||||
}
|
||||
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
// If request for creating missing PMA tables.
|
||||
if (isset($_REQUEST['fix_pmadb'])) {
|
||||
Relation::fixPmaTables($cfgRelation['db']);
|
||||
$relation->fixPmaTables($cfgRelation['db']);
|
||||
}
|
||||
|
||||
$response = Response::getInstance();
|
||||
$response->addHTML(
|
||||
Relation::getRelationsParamDiagnostic($cfgRelation)
|
||||
$relation->getRelationsParamDiagnostic($cfgRelation)
|
||||
);
|
||||
|
||||
@ -34,10 +34,12 @@ $response = Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
$header->enablePrintView();
|
||||
|
||||
$relation = new Relation();
|
||||
|
||||
/**
|
||||
* Gets the relations settings
|
||||
*/
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
/**
|
||||
* Check parameters
|
||||
@ -50,7 +52,7 @@ PhpMyAdmin\Util::checkParameters(array('db'));
|
||||
$err_url = 'db_sql.php' . Url::getCommon(array('db' => $db));
|
||||
|
||||
if ($cfgRelation['commwork']) {
|
||||
$comment = Relation::getDbComment($db);
|
||||
$comment = $relation->getDbComment($db);
|
||||
|
||||
/**
|
||||
* Displays DB comment
|
||||
@ -69,7 +71,7 @@ $tables = $GLOBALS['dbi']->getTables($db);
|
||||
|
||||
$count = 0;
|
||||
foreach ($tables as $table) {
|
||||
$comments = Relation::getComments($db, $table);
|
||||
$comments = $relation->getComments($db, $table);
|
||||
|
||||
echo '<div>' , "\n";
|
||||
|
||||
@ -95,7 +97,7 @@ foreach ($tables as $table) {
|
||||
$columns = $GLOBALS['dbi']->getColumns($db, $table);
|
||||
|
||||
// Check if we can use Relations
|
||||
list($res_rel, $have_rel) = Relation::getRelationsAndStatus(
|
||||
list($res_rel, $have_rel) = $relation->getRelationsAndStatus(
|
||||
! empty($cfgRelation['relation']), $db, $table
|
||||
);
|
||||
|
||||
@ -171,7 +173,7 @@ foreach ($tables as $table) {
|
||||
|
||||
if ($have_rel) {
|
||||
echo ' <td>';
|
||||
if ($foreigner = Relation::searchColumnInForeigners($res_rel, $column_name)) {
|
||||
if ($foreigner = $relation->searchColumnInForeigners($res_rel, $column_name)) {
|
||||
echo htmlspecialchars(
|
||||
$foreigner['foreign_table']
|
||||
. ' -> '
|
||||
|
||||
@ -210,15 +210,16 @@ if (strlen($GLOBALS['db']) > 0
|
||||
/**
|
||||
* Settings for relations stuff
|
||||
*/
|
||||
$relation = new Relation();
|
||||
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
/**
|
||||
* Check if comments were updated
|
||||
* (must be done before displaying the menu tabs)
|
||||
*/
|
||||
if (isset($_REQUEST['comment'])) {
|
||||
Relation::setDbComment($GLOBALS['db'], $_REQUEST['comment']);
|
||||
$relation->setDbComment($GLOBALS['db'], $_REQUEST['comment']);
|
||||
}
|
||||
|
||||
require 'libraries/db_common.inc.php';
|
||||
|
||||
@ -22,7 +22,8 @@ require_once 'libraries/common.inc.php';
|
||||
$response = Response::getInstance();
|
||||
|
||||
// Gets the relation settings
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
$savedSearchList = array();
|
||||
$savedSearch = null;
|
||||
|
||||
@ -111,7 +111,8 @@ if ($num_tables == 0 && count($data['ddlog']) == 0) {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
// Prepare statement to get HEAD version
|
||||
$all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
|
||||
@ -122,7 +123,7 @@ $all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
|
||||
' GROUP BY table_name' .
|
||||
' ORDER BY table_name ASC';
|
||||
|
||||
$all_tables_result = Relation::queryAsControlUser($all_tables_query);
|
||||
$all_tables_result = $relation->queryAsControlUser($all_tables_query);
|
||||
|
||||
// If a HEAD version exists
|
||||
if (is_object($all_tables_result)
|
||||
|
||||
@ -399,6 +399,8 @@ if ($save_on_server) {
|
||||
} // end download
|
||||
}
|
||||
|
||||
$relation = new Relation();
|
||||
|
||||
// Fake loop just to allow skip of remain of this code by break, I'd really
|
||||
// need exceptions here :-)
|
||||
do {
|
||||
@ -417,7 +419,7 @@ do {
|
||||
|| isset($GLOBALS[$what . '_comments']);
|
||||
$do_mime = isset($GLOBALS[$what . '_mime']);
|
||||
if ($do_relation || $do_comments || $do_mime) {
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
}
|
||||
|
||||
// Include dates in export?
|
||||
|
||||
@ -594,8 +594,10 @@ if (@file_exists('config')) {
|
||||
);
|
||||
}
|
||||
|
||||
$relation = new Relation();
|
||||
|
||||
if ($server > 0) {
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
if (! $cfgRelation['allworks']
|
||||
&& $cfg['PmaNoRelation_DisableWarning'] == false
|
||||
) {
|
||||
|
||||
@ -218,7 +218,8 @@ class Bookmark
|
||||
return $cfgBookmark;
|
||||
}
|
||||
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
if ($cfgRelation['bookmarkwork']) {
|
||||
$cfgBookmark = array(
|
||||
'user' => $user,
|
||||
|
||||
@ -57,6 +57,11 @@ class CentralColumns
|
||||
*/
|
||||
private $disableIs;
|
||||
|
||||
/**
|
||||
* @var Relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -70,6 +75,8 @@ class CentralColumns
|
||||
$this->maxRows = (int) $GLOBALS['cfg']['MaxRows'];
|
||||
$this->charEditing = $GLOBALS['cfg']['CharEditing'];
|
||||
$this->disableIs = (bool) $GLOBALS['cfg']['Server']['DisableIS'];
|
||||
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,7 +93,7 @@ class CentralColumns
|
||||
return $cfgCentralColumns;
|
||||
}
|
||||
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
|
||||
if ($cfgRelation['centralcolumnswork']) {
|
||||
$cfgCentralColumns = array(
|
||||
@ -486,7 +493,7 @@ class CentralColumns
|
||||
$has_list = $this->getFromTable($db, $table, true);
|
||||
$this->dbi->selectDb($db);
|
||||
foreach ($has_list as $column) {
|
||||
$column_status = Relation::checkChildForeignReferences(
|
||||
$column_status = $this->relation->checkChildForeignReferences(
|
||||
$db, $table, $column['col_name']
|
||||
);
|
||||
//column definition can only be changed if
|
||||
|
||||
@ -27,14 +27,6 @@ class Console
|
||||
*/
|
||||
private $_isEnabled;
|
||||
|
||||
/**
|
||||
* Creates a new class instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_isEnabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether we are servicing an ajax request.
|
||||
*
|
||||
@ -43,6 +35,20 @@ class Console
|
||||
*/
|
||||
private $_isAjax;
|
||||
|
||||
/**
|
||||
* @var Relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Creates a new class instance
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_isEnabled = true;
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ajax flag to indicate whether
|
||||
* we are servicing an ajax request
|
||||
@ -124,23 +130,23 @@ class Console
|
||||
public function getDisplay()
|
||||
{
|
||||
if ((! $this->_isAjax) && $this->_isEnabled) {
|
||||
$cfgBookmark = Bookmark::getParams($GLOBALS['cfg']['Server']['user']);
|
||||
$cfgBookmark = Bookmark::getParams(
|
||||
$GLOBALS['cfg']['Server']['user']
|
||||
);
|
||||
|
||||
$image = Util::getImage('console', __('SQL Query Console'));
|
||||
$_sql_history = Relation::getHistory($GLOBALS['cfg']['Server']['user']);
|
||||
$_sql_history = $this->relation->getHistory(
|
||||
$GLOBALS['cfg']['Server']['user']
|
||||
);
|
||||
$bookmarkContent = static::getBookmarkContent();
|
||||
|
||||
return Template::get('console/display')
|
||||
->render(
|
||||
array(
|
||||
'cfg_bookmark' => $cfgBookmark,
|
||||
'image' => $image,
|
||||
'sql_history' => $_sql_history,
|
||||
'bookmark_content' => $bookmarkContent,
|
||||
)
|
||||
);
|
||||
return Template::get('console/display')->render([
|
||||
'cfg_bookmark' => $cfgBookmark,
|
||||
'image' => $image,
|
||||
'sql_history' => $_sql_history,
|
||||
'bookmark_content' => $bookmarkContent,
|
||||
]);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -55,6 +55,20 @@ class DatabaseStructureController extends DatabaseController
|
||||
*/
|
||||
protected $_is_show_stats;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct($response, $dbi, $db)
|
||||
{
|
||||
parent::__construct($response, $dbi, $db);
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves databse information for further use
|
||||
*
|
||||
@ -229,7 +243,7 @@ class DatabaseStructureController extends DatabaseController
|
||||
|
||||
// Request for Synchronization of favorite tables.
|
||||
if (isset($_REQUEST['sync_favorite_tables'])) {
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if ($cfgRelation['favoritework']) {
|
||||
$this->synchronizeFavoriteTables($fav_instance, $user, $favorite_tables);
|
||||
}
|
||||
|
||||
@ -53,6 +53,11 @@ class TableRelationController extends TableController
|
||||
*/
|
||||
protected $upd_query;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -83,6 +88,7 @@ class TableRelationController extends TableController
|
||||
$this->existrel = $existrel;
|
||||
$this->existrel_foreign = $existrel_foreign;
|
||||
$this->upd_query = $upd_query;
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,14 +139,14 @@ class TableRelationController extends TableController
|
||||
|
||||
// If we did an update, refresh our data
|
||||
if (isset($_POST['destination_db']) && $this->cfgRelation['relwork']) {
|
||||
$this->existrel = Relation::getForeigners(
|
||||
$this->existrel = $this->relation->getForeigners(
|
||||
$this->db, $this->table, '', 'internal'
|
||||
);
|
||||
}
|
||||
if (isset($_POST['destination_foreign_db'])
|
||||
&& Util::isForeignKeySupported($this->tbl_storage_engine)
|
||||
) {
|
||||
$this->existrel_foreign = Relation::getForeigners(
|
||||
$this->existrel_foreign = $this->relation->getForeigners(
|
||||
$this->db, $this->table, '', 'foreign'
|
||||
);
|
||||
}
|
||||
@ -156,7 +162,7 @@ class TableRelationController extends TableController
|
||||
'table' => $GLOBALS['table']
|
||||
),
|
||||
'is_foreign_key_supported' => Util::isForeignKeySupported($engine),
|
||||
'cfg_relation' => Relation::getRelationsParam(),
|
||||
'cfg_relation' => $this->relation->getRelationsParam(),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@ -80,6 +80,11 @@ class TableSearchController extends TableController
|
||||
|
||||
protected $url_query;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -104,6 +109,7 @@ class TableSearchController extends TableController
|
||||
$this->_columnCollations = array();
|
||||
$this->_geomColumnFlag = false;
|
||||
$this->_foreigners = array();
|
||||
$this->relation = new Relation();
|
||||
// Loads table's information
|
||||
$this->_loadTableInfo();
|
||||
$this->_connectionCharSet = $this->dbi->fetchValue(
|
||||
@ -162,7 +168,7 @@ class TableSearchController extends TableController
|
||||
} // end for
|
||||
|
||||
// Retrieve foreign keys
|
||||
$this->_foreigners = Relation::getForeigners($this->db, $this->table);
|
||||
$this->_foreigners = $this->relation->getForeigners($this->db, $this->table);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -270,7 +276,7 @@ class TableSearchController extends TableController
|
||||
|
||||
//Set default datalabel if not selected
|
||||
if (!isset($_POST['zoom_submit']) || $_POST['dataLabel'] == '') {
|
||||
$dataLabel = Relation::getDisplayField($this->db, $this->table);
|
||||
$dataLabel = $this->relation->getDisplayField($this->db, $this->table);
|
||||
} else {
|
||||
$dataLabel = $_POST['dataLabel'];
|
||||
}
|
||||
@ -870,7 +876,7 @@ class TableSearchController extends TableController
|
||||
)
|
||||
);
|
||||
//Gets link to browse foreign data(if any) and criteria inputbox
|
||||
$foreignData = Relation::getForeignData(
|
||||
$foreignData = $this->relation->getForeignData(
|
||||
$this->_foreigners, $this->_columnNames[$column_index], false, '', ''
|
||||
);
|
||||
$value = Template::get('table/search/input_box')->render(
|
||||
|
||||
@ -73,6 +73,11 @@ class TableStructureController extends TableController
|
||||
*/
|
||||
private $createAddField;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* TableStructureController constructor
|
||||
*
|
||||
@ -121,6 +126,7 @@ class TableStructureController extends TableController
|
||||
$this->table_obj = $this->dbi->getTable($this->db, $this->table);
|
||||
|
||||
$this->createAddField = new CreateAddField($dbi);
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -278,7 +284,7 @@ class TableStructureController extends TableController
|
||||
'table' => $this->table
|
||||
),
|
||||
'is_foreign_key_supported' => Util::isForeignKeySupported($engine),
|
||||
'cfg_relation' => Relation::getRelationsParam(),
|
||||
'cfg_relation' => $this->relation->getRelationsParam(),
|
||||
)
|
||||
)
|
||||
);
|
||||
@ -325,7 +331,7 @@ class TableStructureController extends TableController
|
||||
/**
|
||||
* Gets the relation settings
|
||||
*/
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
|
||||
/**
|
||||
* Runs common work
|
||||
@ -1047,7 +1053,7 @@ class TableStructureController extends TableController
|
||||
if (isset($_REQUEST['field_orig']) && is_array($_REQUEST['field_orig'])) {
|
||||
foreach ($_REQUEST['field_orig'] as $fieldindex => $fieldcontent) {
|
||||
if ($_REQUEST['field_name'][$fieldindex] != $fieldcontent) {
|
||||
Relation::renameField(
|
||||
$this->relation->renameField(
|
||||
$this->db, $this->table, $fieldcontent,
|
||||
$_REQUEST['field_name'][$fieldindex]
|
||||
);
|
||||
@ -1184,7 +1190,7 @@ class TableStructureController extends TableController
|
||||
$mime_map = array();
|
||||
|
||||
if ($GLOBALS['cfg']['ShowPropertyComments']) {
|
||||
$comments_map = Relation::getComments($this->db, $this->table);
|
||||
$comments_map = $this->relation->getComments($this->db, $this->table);
|
||||
if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
|
||||
$mime_map = Transformations::getMIME($this->db, $this->table, true);
|
||||
}
|
||||
|
||||
@ -22,6 +22,19 @@ use PhpMyAdmin\Util;
|
||||
*/
|
||||
class Designer
|
||||
{
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for displaying the page edit/delete form
|
||||
*
|
||||
@ -32,7 +45,7 @@ class Designer
|
||||
*/
|
||||
public function getHtmlForEditOrDeletePages($db, $operation)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
return Template::get('database/designer/edit_delete_pages')->render([
|
||||
'db' => $db,
|
||||
'operation' => $operation,
|
||||
@ -50,7 +63,7 @@ class Designer
|
||||
*/
|
||||
public function getHtmlForPageSaveAs($db)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
return Template::get('database/designer/page_save_as')->render([
|
||||
'db' => $db,
|
||||
'pdfwork' => $cfgRelation['pdfwork'],
|
||||
@ -67,13 +80,13 @@ class Designer
|
||||
*/
|
||||
private function getPageIdsAndNames($db)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
$page_query = "SELECT `page_nr`, `page_descr` FROM "
|
||||
. Util::backquote($cfgRelation['db']) . "."
|
||||
. Util::backquote($cfgRelation['pdf_pages'])
|
||||
. " WHERE db_name = '" . $GLOBALS['dbi']->escapeString($db) . "'"
|
||||
. " ORDER BY `page_descr`";
|
||||
$page_rs = Relation::queryAsControlUser(
|
||||
$page_rs = $this->relation->queryAsControlUser(
|
||||
$page_query,
|
||||
false,
|
||||
DatabaseInterface::QUERY_STORE
|
||||
@ -137,7 +150,7 @@ class Designer
|
||||
array $script_display_field,
|
||||
$display_page
|
||||
) {
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
return Template::get('database/designer/js_fields')->render([
|
||||
'server' => $GLOBALS['server'],
|
||||
'db' => $_GET['db'],
|
||||
@ -178,7 +191,7 @@ class Designer
|
||||
{
|
||||
$params = [];
|
||||
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
|
||||
if ($GLOBALS['cfgRelation']['designersettingswork']) {
|
||||
$query = 'SELECT `settings_data` FROM '
|
||||
|
||||
@ -20,6 +20,19 @@ use PhpMyAdmin\Util;
|
||||
*/
|
||||
class Common
|
||||
{
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves table info and stores it in $GLOBALS['designer']
|
||||
*
|
||||
@ -65,7 +78,7 @@ class Common
|
||||
$one_table['ENGINE']
|
||||
);
|
||||
|
||||
$DF = Relation::getDisplayField($GLOBALS['db'], $one_table['TABLE_NAME']);
|
||||
$DF = $this->relation->getDisplayField($GLOBALS['db'], $one_table['TABLE_NAME']);
|
||||
if ($DF != '') {
|
||||
$retval[$GLOBALS['designer_url']["TABLE_NAME_SMALL"][$i]] = $DF;
|
||||
}
|
||||
@ -126,7 +139,7 @@ class Common
|
||||
DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
while ($val = @$GLOBALS['dbi']->fetchRow($alltab_rs)) {
|
||||
$row = Relation::getForeigners($GLOBALS['db'], $val[0], '', 'internal');
|
||||
$row = $this->relation->getForeigners($GLOBALS['db'], $val[0], '', 'internal');
|
||||
|
||||
if ($row !== false) {
|
||||
foreach ($row as $field => $value) {
|
||||
@ -140,7 +153,7 @@ class Common
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$row = Relation::getForeigners($GLOBALS['db'], $val[0], '', 'foreign');
|
||||
$row = $this->relation->getForeigners($GLOBALS['db'], $val[0], '', 'foreign');
|
||||
|
||||
if ($row !== false) {
|
||||
foreach ($row['foreign_keys_data'] as $one_key) {
|
||||
@ -250,7 +263,7 @@ class Common
|
||||
*/
|
||||
public function getTablePositions($pg)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if (! $cfgRelation['pdfwork']) {
|
||||
return null;
|
||||
}
|
||||
@ -284,7 +297,7 @@ class Common
|
||||
*/
|
||||
public function getPageName($pg)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if (! $cfgRelation['pdfwork']) {
|
||||
return null;
|
||||
}
|
||||
@ -312,7 +325,7 @@ class Common
|
||||
*/
|
||||
public function deletePage($pg)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if (! $cfgRelation['pdfwork']) {
|
||||
return false;
|
||||
}
|
||||
@ -320,7 +333,7 @@ class Common
|
||||
$query = "DELETE FROM " . Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['table_coords'])
|
||||
. " WHERE " . Util::backquote('pdf_page_number') . " = " . intval($pg);
|
||||
$success = Relation::queryAsControlUser(
|
||||
$success = $this->relation->queryAsControlUser(
|
||||
$query, true, DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
@ -328,7 +341,7 @@ class Common
|
||||
$query = "DELETE FROM " . Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['pdf_pages'])
|
||||
. " WHERE " . Util::backquote('page_nr') . " = " . intval($pg);
|
||||
$success = Relation::queryAsControlUser(
|
||||
$success = $this->relation->queryAsControlUser(
|
||||
$query, true, DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
}
|
||||
@ -346,7 +359,7 @@ class Common
|
||||
*/
|
||||
public function getDefaultPage($db)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if (! $cfgRelation['pdfwork']) {
|
||||
return null;
|
||||
}
|
||||
@ -381,7 +394,7 @@ class Common
|
||||
*/
|
||||
public function getLoadingPage($db)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if (! $cfgRelation['pdfwork']) {
|
||||
return null;
|
||||
}
|
||||
@ -421,9 +434,9 @@ class Common
|
||||
*/
|
||||
public function createNewPage($pageName, $db)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if ($cfgRelation['pdfwork']) {
|
||||
$pageNumber = Relation::createPage(
|
||||
$pageNumber = $this->relation->createPage(
|
||||
$pageName,
|
||||
$cfgRelation,
|
||||
$db
|
||||
@ -442,7 +455,7 @@ class Common
|
||||
*/
|
||||
public function saveTablePositions($pg)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if (! $cfgRelation['pdfwork']) {
|
||||
return false;
|
||||
}
|
||||
@ -457,7 +470,7 @@ class Common
|
||||
. " AND `pdf_page_number` = '" . $GLOBALS['dbi']->escapeString($pg)
|
||||
. "'";
|
||||
|
||||
$res = Relation::queryAsControlUser(
|
||||
$res = $this->relation->queryAsControlUser(
|
||||
$query,
|
||||
true,
|
||||
DatabaseInterface::QUERY_STORE
|
||||
@ -484,7 +497,7 @@ class Common
|
||||
. "'" . $GLOBALS['dbi']->escapeString($_REQUEST['t_x'][$key]) . "', "
|
||||
. "'" . $GLOBALS['dbi']->escapeString($_REQUEST['t_y'][$key]) . "')";
|
||||
|
||||
$res = Relation::queryAsControlUser(
|
||||
$res = $this->relation->queryAsControlUser(
|
||||
$query, true, DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
}
|
||||
@ -503,7 +516,7 @@ class Common
|
||||
*/
|
||||
public function saveDisplayField($db, $table, $field)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if (!$cfgRelation['displaywork']) {
|
||||
return false;
|
||||
}
|
||||
@ -542,8 +555,8 @@ class Common
|
||||
&& $type_T1 == $type_T2
|
||||
) {
|
||||
// relation exists?
|
||||
$existrel_foreign = Relation::getForeigners($DB2, $T2, '', 'foreign');
|
||||
$foreigner = Relation::searchColumnInForeigners($existrel_foreign, $F2);
|
||||
$existrel_foreign = $this->relation->getForeigners($DB2, $T2, '', 'foreign');
|
||||
$foreigner = $this->relation->searchColumnInForeigners($existrel_foreign, $F2);
|
||||
if ($foreigner
|
||||
&& isset($foreigner['constraint'])
|
||||
) {
|
||||
@ -629,7 +642,7 @@ class Common
|
||||
. "'" . $GLOBALS['dbi']->escapeString($T1) . "', "
|
||||
. "'" . $GLOBALS['dbi']->escapeString($F1) . "')";
|
||||
|
||||
if (Relation::queryAsControlUser($q, false, DatabaseInterface::QUERY_STORE)
|
||||
if ($this->relation->queryAsControlUser($q, false, DatabaseInterface::QUERY_STORE)
|
||||
) {
|
||||
return array(true, __('Internal relationship has been added.'));
|
||||
}
|
||||
@ -667,8 +680,8 @@ class Common
|
||||
&& $type_T1 == $type_T2
|
||||
) {
|
||||
// InnoDB
|
||||
$existrel_foreign = Relation::getForeigners($DB2, $T2, '', 'foreign');
|
||||
$foreigner = Relation::searchColumnInForeigners($existrel_foreign, $F2);
|
||||
$existrel_foreign = $this->relation->getForeigners($DB2, $T2, '', 'foreign');
|
||||
$foreigner = $this->relation->searchColumnInForeigners($existrel_foreign, $F2);
|
||||
|
||||
if (isset($foreigner['constraint'])) {
|
||||
$upd_query = 'ALTER TABLE ' . Util::backquote($DB2)
|
||||
@ -698,7 +711,7 @@ class Common
|
||||
. " AND foreign_table = '" . $GLOBALS['dbi']->escapeString($T1) . "'"
|
||||
. " AND foreign_field = '" . $GLOBALS['dbi']->escapeString($F1) . "'";
|
||||
|
||||
$result = Relation::queryAsControlUser(
|
||||
$result = $this->relation->queryAsControlUser(
|
||||
$delete_query,
|
||||
false,
|
||||
DatabaseInterface::QUERY_STORE
|
||||
@ -725,7 +738,7 @@ class Common
|
||||
*/
|
||||
public function saveSetting($index, $value)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
$cfgDesigner = array(
|
||||
'user' => $GLOBALS['cfg']['Server']['user'],
|
||||
'db' => $cfgRelation['db'],
|
||||
@ -757,7 +770,7 @@ class Common
|
||||
. " WHERE username = '"
|
||||
. $GLOBALS['dbi']->escapeString($cfgDesigner['user']) . "';";
|
||||
|
||||
$success = Relation::queryAsControlUser($save_query);
|
||||
$success = $this->relation->queryAsControlUser($save_query);
|
||||
} else {
|
||||
$save_data = array($index => $value);
|
||||
|
||||
@ -768,7 +781,7 @@ class Common
|
||||
. " VALUES('" . $cfgDesigner['user'] . "',"
|
||||
. " '" . json_encode($save_data) . "');";
|
||||
|
||||
$success = Relation::queryAsControlUser($query);
|
||||
$success = $this->relation->queryAsControlUser($query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -212,6 +212,33 @@ class Qbe
|
||||
*/
|
||||
private $_currentSearch = null;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Public Constructor
|
||||
*
|
||||
* @param string $dbname Database name
|
||||
* @param array $savedSearchList List of saved searches
|
||||
* @param SavedSearches $currentSearch Current search id
|
||||
*/
|
||||
public function __construct(
|
||||
$dbname,
|
||||
array $savedSearchList = array(),
|
||||
$currentSearch = null
|
||||
) {
|
||||
$this->_db = $dbname;
|
||||
$this->_savedSearchList = $savedSearchList;
|
||||
$this->_currentSearch = $currentSearch;
|
||||
$this->_loadCriterias();
|
||||
// Sets criteria parameters
|
||||
$this->_setSearchParams();
|
||||
$this->_setCriteriaTablesAndColumns();
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize criterias
|
||||
*
|
||||
@ -241,25 +268,6 @@ class Qbe
|
||||
return $this->_currentSearch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public Constructor
|
||||
*
|
||||
* @param string $dbname Database name
|
||||
* @param array $savedSearchList List of saved searches
|
||||
* @param SavedSearches $currentSearch Current search id
|
||||
*/
|
||||
public function __construct(
|
||||
$dbname, array $savedSearchList = array(), $currentSearch = null
|
||||
) {
|
||||
$this->_db = $dbname;
|
||||
$this->_savedSearchList = $savedSearchList;
|
||||
$this->_currentSearch = $currentSearch;
|
||||
$this->_loadCriterias();
|
||||
// Sets criteria parameters
|
||||
$this->_setSearchParams();
|
||||
$this->_setCriteriaTablesAndColumns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets search parameters
|
||||
*
|
||||
@ -1395,7 +1403,7 @@ class Qbe
|
||||
// So we select candidate tables which are foreign tables.
|
||||
$foreign_tables = array();
|
||||
foreach ($candidate_columns as $one_table) {
|
||||
$foreigners = Relation::getForeigners($this->_db, $one_table);
|
||||
$foreigners = $this->relation->getForeigners($this->_db, $one_table);
|
||||
foreach ($foreigners as $key => $foreigner) {
|
||||
if ($key != 'foreign_keys_data') {
|
||||
if (in_array($foreigner['foreign_table'], $candidate_columns)) {
|
||||
@ -1584,7 +1592,7 @@ class Qbe
|
||||
// having relationships with unfinalized tables
|
||||
foreach ($unfinalized as $oneTable) {
|
||||
|
||||
$references = Relation::getChildReferences($this->_db, $oneTable);
|
||||
$references = $this->relation->getChildReferences($this->_db, $oneTable);
|
||||
foreach ($references as $column => $columnReferences) {
|
||||
foreach ($columnReferences as $reference) {
|
||||
|
||||
@ -1667,7 +1675,7 @@ class Qbe
|
||||
{
|
||||
$relations[$oneTable] = array();
|
||||
|
||||
$foreigners = Relation::getForeigners($GLOBALS['db'], $oneTable);
|
||||
$foreigners = $this->relation->getForeigners($GLOBALS['db'], $oneTable);
|
||||
foreach ($foreigners as $field => $foreigner) {
|
||||
// Foreign keys data
|
||||
if ($field == 'foreign_keys_data') {
|
||||
|
||||
@ -117,6 +117,11 @@ class DatabaseInterface
|
||||
*/
|
||||
public $types;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -133,6 +138,7 @@ class DatabaseInterface
|
||||
$this->_table_cache = array();
|
||||
$this->_current_user = array();
|
||||
$this->types = new Types($this);
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1528,15 +1534,15 @@ class DatabaseInterface
|
||||
// If Zero configuration mode enabled, check PMA tables in current db.
|
||||
if ($GLOBALS['cfg']['ZeroConf'] == true) {
|
||||
if (strlen($GLOBALS['db'])) {
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if (empty($cfgRelation['db'])) {
|
||||
Relation::fixPmaTables($GLOBALS['db'], false);
|
||||
$this->relation->fixPmaTables($GLOBALS['db'], false);
|
||||
}
|
||||
}
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if (empty($cfgRelation['db'])) {
|
||||
if ($GLOBALS['dblist']->databases->exists('phpmyadmin')) {
|
||||
Relation::fixPmaTables('phpmyadmin', false);
|
||||
$this->relation->fixPmaTables('phpmyadmin', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +27,19 @@ use PhpMyAdmin\Util;
|
||||
*/
|
||||
class Export
|
||||
{
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs appropriate checked statement for checkbox.
|
||||
*
|
||||
@ -139,7 +152,7 @@ class Export
|
||||
private function getOptionsForTemplates($exportType)
|
||||
{
|
||||
// Get the relation settings
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
|
||||
$query = "SELECT `id`, `template_name` FROM "
|
||||
. Util::backquote($cfgRelation['db']) . '.'
|
||||
@ -149,7 +162,7 @@ class Export
|
||||
. "' AND `export_type` = '" . $GLOBALS['dbi']->escapeString($exportType) . "'"
|
||||
. " ORDER BY `template_name`;";
|
||||
|
||||
$result = Relation::queryAsControlUser($query);
|
||||
$result = $this->relation->queryAsControlUser($query);
|
||||
|
||||
$templates = [];
|
||||
if ($result !== false) {
|
||||
@ -643,7 +656,7 @@ class Export
|
||||
$unlimNumRows,
|
||||
$multiValues
|
||||
) {
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
|
||||
if (isset($_REQUEST['single_table'])) {
|
||||
$GLOBALS['single_table'] = $_REQUEST['single_table'];
|
||||
@ -758,7 +771,7 @@ class Export
|
||||
break;
|
||||
}
|
||||
|
||||
$result = Relation::queryAsControlUser($query, false);
|
||||
$result = $this->relation->queryAsControlUser($query, false);
|
||||
|
||||
$response = Response::getInstance();
|
||||
if (! $result) {
|
||||
|
||||
@ -185,6 +185,10 @@ class Results
|
||||
*/
|
||||
public $transformation_info;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Get any property of this class
|
||||
@ -200,7 +204,6 @@ class Results
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set values for any property of this class
|
||||
*
|
||||
@ -216,7 +219,6 @@ class Results
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for PhpMyAdmin\Display\Results class
|
||||
*
|
||||
@ -229,6 +231,8 @@ class Results
|
||||
*/
|
||||
public function __construct($db, $table, $goto, $sql_query)
|
||||
{
|
||||
$this->relation = new Relation();
|
||||
|
||||
$this->_setDefaultTransformations();
|
||||
|
||||
$this->__set('db', $db);
|
||||
@ -243,7 +247,7 @@ class Results
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _setDefaultTransformations()
|
||||
private function _setDefaultTransformations()
|
||||
{
|
||||
$json_highlighting_data = array(
|
||||
'libraries/classes/Plugins/Transformations/Output/Text_Plain_Json.php',
|
||||
@ -310,7 +314,7 @@ class Results
|
||||
)
|
||||
);
|
||||
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if ($cfgRelation['db']) {
|
||||
$this->transformation_info[$cfgRelation['db']] = array();
|
||||
$relDb = &$this->transformation_info[$cfgRelation['db']];
|
||||
@ -1575,7 +1579,7 @@ class Results
|
||||
if (empty($field->table)) {
|
||||
continue;
|
||||
}
|
||||
$ret[$field->table] = Relation::getComments(
|
||||
$ret[$field->table] = $this->relation->getComments(
|
||||
empty($field->database) ? $this->__get('db') : $field->database,
|
||||
$field->table
|
||||
);
|
||||
@ -4602,7 +4606,7 @@ class Results
|
||||
// configuration storage. If no PMA storage, we won't be able
|
||||
// to use the "column to display" notion (for example show
|
||||
// the name related to a numeric id).
|
||||
$exist_rel = Relation::getForeigners(
|
||||
$exist_rel = $this->relation->getForeigners(
|
||||
$this->__get('db'), $this->__get('table'), '', self::POSITION_BOTH
|
||||
);
|
||||
|
||||
@ -4610,7 +4614,7 @@ class Results
|
||||
|
||||
foreach ($exist_rel as $master_field => $rel) {
|
||||
if ($master_field != 'foreign_keys_data') {
|
||||
$display_field = Relation::getDisplayField(
|
||||
$display_field = $this->relation->getDisplayField(
|
||||
$rel['foreign_db'], $rel['foreign_table']
|
||||
);
|
||||
$map[$master_field] = array(
|
||||
@ -4622,7 +4626,7 @@ class Results
|
||||
} else {
|
||||
foreach ($rel as $key => $one_key) {
|
||||
foreach ($one_key['index_list'] as $index => $one_field) {
|
||||
$display_field = Relation::getDisplayField(
|
||||
$display_field = $this->relation->getDisplayField(
|
||||
isset($one_key['ref_db_name'])
|
||||
? $one_key['ref_db_name']
|
||||
: $GLOBALS['db'],
|
||||
|
||||
@ -31,6 +31,11 @@ class ErrorReport
|
||||
*/
|
||||
private $httpRequest;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -40,6 +45,7 @@ class ErrorReport
|
||||
{
|
||||
$this->httpRequest = $httpRequest;
|
||||
$this->submissionUrl = 'https://reports.phpmyadmin.net/incidents/create';
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,7 +72,7 @@ class ErrorReport
|
||||
*/
|
||||
public function getData($exceptionType = 'js')
|
||||
{
|
||||
$relParams = Relation::getRelationsParam();
|
||||
$relParams = $this->relation->getRelationsParam();
|
||||
// common params for both, php & js exceptions
|
||||
$report = [
|
||||
"pma_version" => PMA_VERSION,
|
||||
|
||||
@ -55,6 +55,11 @@ class Footer
|
||||
*/
|
||||
private $_isEnabled;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Creates a new class instance
|
||||
*/
|
||||
@ -63,6 +68,7 @@ class Footer
|
||||
$this->_isEnabled = true;
|
||||
$this->_scripts = new Scripts();
|
||||
$this->_isMinimal = false;
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -245,7 +251,7 @@ class Footer
|
||||
&& isset($GLOBALS['dbi'])
|
||||
&& $GLOBALS['dbi']->isUserType('logged')
|
||||
) {
|
||||
Relation::setHistory(
|
||||
$this->relation->setHistory(
|
||||
Core::ifSetOr($GLOBALS['db'], ''),
|
||||
Core::ifSetOr($GLOBALS['table'], ''),
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
|
||||
@ -33,6 +33,11 @@ class InsertEdit
|
||||
*/
|
||||
private $dbi;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -41,6 +46,7 @@ class InsertEdit
|
||||
public function __construct(DatabaseInterface $dbi)
|
||||
{
|
||||
$this->dbi = $dbi;
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -567,7 +573,7 @@ class InsertEdit
|
||||
array $foreigners,
|
||||
array $foreignData
|
||||
) {
|
||||
$foreigner = Relation::searchColumnInForeigners($foreigners, $column['Field']);
|
||||
$foreigner = $this->relation->searchColumnInForeigners($foreigners, $column['Field']);
|
||||
if (mb_strstr($column['True_Type'], 'enum')) {
|
||||
if (mb_strlen($column['Type']) > 20) {
|
||||
$nullify_code = '1';
|
||||
@ -895,7 +901,7 @@ class InsertEdit
|
||||
. ($readOnly ? ' disabled' : '')
|
||||
. ' tabindex="' . ($tabindex + $tabindex_for_value) . '"'
|
||||
. ' id="field_' . $idindex . '_3">';
|
||||
$html_output .= Relation::foreignDropdown(
|
||||
$html_output .= $this->relation->foreignDropdown(
|
||||
$foreignData['disp_row'],
|
||||
$foreignData['foreign_field'],
|
||||
$foreignData['foreign_display'],
|
||||
@ -2361,8 +2367,8 @@ class InsertEdit
|
||||
array $map,
|
||||
$relation_field
|
||||
) {
|
||||
$foreigner = Relation::searchColumnInForeigners($map, $relation_field);
|
||||
$display_field = Relation::getDisplayField(
|
||||
$foreigner = $this->relation->searchColumnInForeigners($map, $relation_field);
|
||||
$display_field = $this->relation->getDisplayField(
|
||||
$foreigner['foreign_db'],
|
||||
$foreigner['foreign_table']
|
||||
);
|
||||
@ -2410,7 +2416,7 @@ class InsertEdit
|
||||
$dispval,
|
||||
$relation_field_value
|
||||
) {
|
||||
$foreigner = Relation::searchColumnInForeigners($map, $relation_field);
|
||||
$foreigner = $this->relation->searchColumnInForeigners($map, $relation_field);
|
||||
if ('K' == $_SESSION['tmpval']['relational_display']) {
|
||||
// user chose "relational key" in the display options, so
|
||||
// the title contains the display field
|
||||
@ -2909,7 +2915,7 @@ class InsertEdit
|
||||
$comments_map = array();
|
||||
|
||||
if ($GLOBALS['cfg']['ShowPropertyComments']) {
|
||||
$comments_map = Relation::getComments($db, $table);
|
||||
$comments_map = $this->relation->getComments($db, $table);
|
||||
}
|
||||
|
||||
return $comments_map;
|
||||
@ -3198,7 +3204,7 @@ class InsertEdit
|
||||
|
||||
// The function column
|
||||
// -------------------
|
||||
$foreignData = Relation::getForeignData(
|
||||
$foreignData = $this->relation->getForeignData(
|
||||
$foreigners,
|
||||
$column['Field'],
|
||||
false,
|
||||
|
||||
@ -42,6 +42,11 @@ class Menu
|
||||
*/
|
||||
private $_table;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Creates a new instance of Menu
|
||||
*
|
||||
@ -52,8 +57,9 @@ class Menu
|
||||
public function __construct($server, $db, $table)
|
||||
{
|
||||
$this->_server = $server;
|
||||
$this->_db = $db;
|
||||
$this->_table = $table;
|
||||
$this->_db = $db;
|
||||
$this->_table = $table;
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,7 +144,7 @@ class Menu
|
||||
return Util::cacheGet($cache_key);
|
||||
}
|
||||
$allowedTabs = Util::getMenuTabList($level);
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if ($cfgRelation['menuswork']) {
|
||||
$groupTable = Util::backquote($cfgRelation['db'])
|
||||
. "."
|
||||
@ -153,7 +159,7 @@ class Menu
|
||||
. $userTable . " WHERE `username` = '"
|
||||
. $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']) . "')";
|
||||
|
||||
$result = Relation::queryAsControlUser($sql_query, false);
|
||||
$result = $this->relation->queryAsControlUser($sql_query, false);
|
||||
if ($result) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
|
||||
$tabName = mb_substr(
|
||||
@ -293,12 +299,12 @@ class Menu
|
||||
} // end if
|
||||
} else {
|
||||
// no table selected, display database comment if present
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
|
||||
// Get additional information about tables for tooltip is done
|
||||
// in Util::getDbInfo() only once
|
||||
if ($cfgRelation['commwork']) {
|
||||
$comment = Relation::getDbComment($this->_db);
|
||||
$comment = $this->relation->getDbComment($this->_db);
|
||||
/**
|
||||
* Displays table comment
|
||||
*/
|
||||
@ -449,7 +455,7 @@ class Menu
|
||||
/**
|
||||
* Gets the relation settings
|
||||
*/
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
|
||||
$tabs = array();
|
||||
|
||||
|
||||
@ -22,6 +22,19 @@ use PhpMyAdmin\Util;
|
||||
*/
|
||||
class Navigation
|
||||
{
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the navigation tree, or part of it
|
||||
*
|
||||
@ -99,7 +112,7 @@ class Navigation
|
||||
. "'" . $GLOBALS['dbi']->escapeString($dbName) . "',"
|
||||
. "'" . (! empty($tableName)? $GLOBALS['dbi']->escapeString($tableName) : "" )
|
||||
. "')";
|
||||
Relation::queryAsControlUser($sqlQuery, false);
|
||||
$this->relation->queryAsControlUser($sqlQuery, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,7 +163,7 @@ class Navigation
|
||||
? " AND `table_name`='" . $GLOBALS['dbi']->escapeString($tableName) . "'"
|
||||
: ""
|
||||
);
|
||||
Relation::queryAsControlUser($sqlQuery, false);
|
||||
$this->relation->queryAsControlUser($sqlQuery, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,7 +189,7 @@ class Navigation
|
||||
. " AND `db_name`='" . $GLOBALS['dbi']->escapeString($dbName) . "'"
|
||||
. " AND `table_name`='"
|
||||
. (! empty($tableName) ? $GLOBALS['dbi']->escapeString($tableName) : '') . "'";
|
||||
$result = Relation::queryAsControlUser($sqlQuery, false);
|
||||
$result = $this->relation->queryAsControlUser($sqlQuery, false);
|
||||
|
||||
$hidden = array();
|
||||
if ($result) {
|
||||
|
||||
@ -102,6 +102,11 @@ class Node
|
||||
*/
|
||||
public $pos3 = 0;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
protected $relation;
|
||||
|
||||
/**
|
||||
* Initialises the class by setting the mandatory variables
|
||||
*
|
||||
@ -120,6 +125,7 @@ class Node
|
||||
$this->type = Node::CONTAINER;
|
||||
}
|
||||
$this->is_group = (bool)$is_group;
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -803,7 +809,7 @@ class Node
|
||||
*/
|
||||
public function getNavigationHidingData()
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if ($cfgRelation['navwork']) {
|
||||
$navTable = Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote(
|
||||
|
||||
@ -387,7 +387,7 @@ class NodeDatabase extends Node
|
||||
}
|
||||
|
||||
// Remove hidden items so that they are not displayed in navigation tree
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if ($cfgRelation['navwork']) {
|
||||
$hiddenItems = $this->getHiddenItems(substr($type, 0, -1));
|
||||
foreach ($retval as $key => $item) {
|
||||
@ -411,7 +411,7 @@ class NodeDatabase extends Node
|
||||
public function getHiddenItems($type)
|
||||
{
|
||||
$db = $this->real_name;
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if (empty($cfgRelation['navigationhiding'])) {
|
||||
return array();
|
||||
}
|
||||
@ -422,7 +422,7 @@ class NodeDatabase extends Node
|
||||
. " AND `item_type`='" . $type
|
||||
. "'" . " AND `db_name`='" . $GLOBALS['dbi']->escapeString($db)
|
||||
. "'";
|
||||
$result = Relation::queryAsControlUser($sqlQuery, false);
|
||||
$result = $this->relation->queryAsControlUser($sqlQuery, false);
|
||||
$hiddenItems = array();
|
||||
if ($result) {
|
||||
while ($row = $GLOBALS['dbi']->fetchArray($result)) {
|
||||
@ -669,7 +669,7 @@ class NodeDatabase extends Node
|
||||
public function getHtmlForControlButtons()
|
||||
{
|
||||
$ret = '';
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if ($cfgRelation['navwork']) {
|
||||
if ($this->hiddenCount > 0) {
|
||||
$params = array(
|
||||
|
||||
@ -35,7 +35,7 @@ abstract class NodeDatabaseChild extends Node
|
||||
public function getHtmlForControlButtons()
|
||||
{
|
||||
$ret = '';
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if ($cfgRelation['navwork']) {
|
||||
$db = $this->realParent()->real_name;
|
||||
$item = $this->real_name;
|
||||
|
||||
@ -29,6 +29,11 @@ class Normalization
|
||||
*/
|
||||
private $dbi;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -37,6 +42,7 @@ class Normalization
|
||||
public function __construct(DatabaseInterface $dbi)
|
||||
{
|
||||
$this->dbi = $dbi;
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,7 +117,7 @@ class Normalization
|
||||
$table,
|
||||
array $columnMeta = []
|
||||
) {
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
$contentCells = [];
|
||||
$availableMime = [];
|
||||
$mimeMap = [];
|
||||
@ -119,7 +125,7 @@ class Normalization
|
||||
$mimeMap = Transformations::getMIME($db, $table);
|
||||
$availableMime = Transformations::getAvailableMIMEtypes();
|
||||
}
|
||||
$commentsMap = Relation::getComments($db, $table);
|
||||
$commentsMap = $this->relation->getComments($db, $table);
|
||||
for ($columnNumber = 0; $columnNumber < $numFields; $columnNumber++) {
|
||||
$contentCells[$columnNumber] = [
|
||||
'column_number' => $columnNumber,
|
||||
|
||||
@ -27,6 +27,19 @@ use PhpMyAdmin\Util;
|
||||
*/
|
||||
class Operations
|
||||
{
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTML output for database comment
|
||||
*
|
||||
@ -48,7 +61,7 @@ class Operations
|
||||
$html_output .= '</legend>';
|
||||
$html_output .= '<input type="text" name="comment" '
|
||||
. 'class="textfield"'
|
||||
. 'value="' . htmlspecialchars(Relation::getDbComment($db)) . '" />'
|
||||
. 'value="' . htmlspecialchars($this->relation->getDbComment($db)) . '" />'
|
||||
. '</fieldset>';
|
||||
$html_output .= '<fieldset class="tblFooters">'
|
||||
. '<input type="submit" value="' . __('Go') . '" />'
|
||||
@ -1284,7 +1297,7 @@ class Operations
|
||||
|
||||
// display "Add constraints" choice only if there are
|
||||
// foreign keys
|
||||
if (Relation::getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
|
||||
if ($this->relation->getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
|
||||
$html_output .= '<input type="checkbox" name="add_constraints" '
|
||||
. 'value="1" id="checkbox_constraints" checked="checked"/>';
|
||||
$html_output .= '<label for="checkbox_constraints">'
|
||||
|
||||
@ -34,6 +34,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setProperties();
|
||||
}
|
||||
|
||||
@ -370,7 +371,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
|
||||
// Check if we can use Relations
|
||||
list($res_rel, $have_rel) = Relation::getRelationsAndStatus(
|
||||
list($res_rel, $have_rel) = $this->relation->getRelationsAndStatus(
|
||||
$do_relation && !empty($cfgRelation['relation']),
|
||||
$db,
|
||||
$table
|
||||
@ -403,7 +404,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
$schema_insert .= '<td class="print"><strong>'
|
||||
. __('Comments')
|
||||
. '</strong></td>';
|
||||
$comments = Relation::getComments($db, $table);
|
||||
$comments = $this->relation->getComments($db, $table);
|
||||
}
|
||||
if ($do_mime && $cfgRelation['mimework']) {
|
||||
$schema_insert .= '<td class="print"><strong>'
|
||||
|
||||
@ -34,9 +34,9 @@ class ExportLatex extends ExportPlugin
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// initialize the specific export sql variables
|
||||
$this->initSpecificVariables();
|
||||
|
||||
$this->setProperties();
|
||||
}
|
||||
|
||||
@ -496,7 +496,7 @@ class ExportLatex extends ExportPlugin
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
|
||||
// Check if we can use Relations
|
||||
list($res_rel, $have_rel) = Relation::getRelationsAndStatus(
|
||||
list($res_rel, $have_rel) = $this->relation->getRelationsAndStatus(
|
||||
$do_relation && !empty($cfgRelation['relation']),
|
||||
$db,
|
||||
$table
|
||||
@ -532,7 +532,7 @@ class ExportLatex extends ExportPlugin
|
||||
}
|
||||
if ($do_comments) {
|
||||
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . __('Comments') . '}}';
|
||||
$comments = Relation::getComments($db, $table);
|
||||
$comments = $this->relation->getComments($db, $table);
|
||||
}
|
||||
if ($do_mime && $cfgRelation['mimework']) {
|
||||
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{MIME}}';
|
||||
|
||||
@ -35,6 +35,7 @@ class ExportOdt extends ExportPlugin
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$GLOBALS['odt_buffer'] = '';
|
||||
$this->setProperties();
|
||||
}
|
||||
@ -454,7 +455,7 @@ class ExportOdt extends ExportPlugin
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
|
||||
// Check if we can use Relations
|
||||
list($res_rel, $have_rel) = Relation::getRelationsAndStatus(
|
||||
list($res_rel, $have_rel) = $this->relation->getRelationsAndStatus(
|
||||
$do_relation && !empty($cfgRelation['relation']),
|
||||
$db,
|
||||
$table
|
||||
@ -499,7 +500,7 @@ class ExportOdt extends ExportPlugin
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>' . __('Comments') . '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
$comments = Relation::getComments($db, $table);
|
||||
$comments = $this->relation->getComments($db, $table);
|
||||
}
|
||||
if ($do_mime && $cfgRelation['mimework']) {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
@ -520,7 +521,7 @@ class ExportOdt extends ExportPlugin
|
||||
$col_as
|
||||
);
|
||||
if ($do_relation && $have_rel) {
|
||||
$foreigner = Relation::searchColumnInForeigners($res_rel, $field_name);
|
||||
$foreigner = $this->relation->searchColumnInForeigners($res_rel, $field_name);
|
||||
if ($foreigner) {
|
||||
$rtable = $foreigner['foreign_table'];
|
||||
$rfield = $foreigner['foreign_field'];
|
||||
|
||||
@ -51,6 +51,7 @@ class ExportSql extends ExportPlugin
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setProperties();
|
||||
|
||||
// Avoids undefined variables, use NULL so isset() returns false
|
||||
@ -998,7 +999,7 @@ class ExportSql extends ExportPlugin
|
||||
$tables,
|
||||
array $metadataTypes
|
||||
) {
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if (!isset($cfgRelation['db'])) {
|
||||
return true;
|
||||
}
|
||||
@ -1050,7 +1051,7 @@ class ExportSql extends ExportPlugin
|
||||
$table,
|
||||
array $metadataTypes
|
||||
) {
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
|
||||
if (isset($table)) {
|
||||
$types = array(
|
||||
@ -1839,7 +1840,7 @@ class ExportSql extends ExportPlugin
|
||||
$schema_create = '';
|
||||
|
||||
// Check if we can use Relations
|
||||
list($res_rel, $have_rel) = Relation::getRelationsAndStatus(
|
||||
list($res_rel, $have_rel) = $this->relation->getRelationsAndStatus(
|
||||
$do_relation && !empty($cfgRelation['relation']),
|
||||
$db,
|
||||
$table
|
||||
|
||||
@ -34,6 +34,7 @@ class ExportTexytext extends ExportPlugin
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setProperties();
|
||||
}
|
||||
|
||||
@ -364,7 +365,7 @@ class ExportTexytext extends ExportPlugin
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
|
||||
// Check if we can use Relations
|
||||
list($res_rel, $have_rel) = Relation::getRelationsAndStatus(
|
||||
list($res_rel, $have_rel) = $this->relation->getRelationsAndStatus(
|
||||
$do_relation && !empty($cfgRelation['relation']),
|
||||
$db,
|
||||
$table
|
||||
@ -384,7 +385,7 @@ class ExportTexytext extends ExportPlugin
|
||||
}
|
||||
if ($do_comments) {
|
||||
$text_output .= '|' . __('Comments');
|
||||
$comments = Relation::getComments($db, $table);
|
||||
$comments = $this->relation->getComments($db, $table);
|
||||
}
|
||||
if ($do_mime && $cfgRelation['mimework']) {
|
||||
$text_output .= '|' . htmlspecialchars('MIME');
|
||||
|
||||
@ -26,6 +26,46 @@ class Pdf extends PdfLib
|
||||
var $tablewidths;
|
||||
var $headerset;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructs PDF and configures standard parameters.
|
||||
*
|
||||
* @param string $orientation page orientation
|
||||
* @param string $unit unit
|
||||
* @param string $format the format used for pages
|
||||
* @param boolean $unicode true means that the input text is unicode
|
||||
* @param string $encoding charset encoding; default is UTF-8.
|
||||
* @param boolean $diskcache if true reduce the RAM memory usage by caching
|
||||
* temporary data on filesystem (slower).
|
||||
* @param boolean $pdfa If TRUE set the document to PDF/A mode.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function __construct(
|
||||
$orientation = 'P',
|
||||
$unit = 'mm',
|
||||
$format = 'A4',
|
||||
$unicode = true,
|
||||
$encoding = 'UTF-8',
|
||||
$diskcache = false,
|
||||
$pdfa = false
|
||||
) {
|
||||
parent::__construct(
|
||||
$orientation,
|
||||
$unit,
|
||||
$format,
|
||||
$unicode,
|
||||
$encoding,
|
||||
$diskcache,
|
||||
$pdfa
|
||||
);
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add page if needed.
|
||||
*
|
||||
@ -461,7 +501,7 @@ class Pdf extends PdfLib
|
||||
if ($do_relation) {
|
||||
// Find which tables are related with the current one and write it in
|
||||
// an array
|
||||
$res_rel = Relation::getForeigners($db, $table);
|
||||
$res_rel = $this->relation->getForeigners($db, $table);
|
||||
$have_rel = !empty($res_rel);
|
||||
} else {
|
||||
$have_rel = false;
|
||||
@ -514,7 +554,7 @@ class Pdf extends PdfLib
|
||||
// Now let's start to write the table structure
|
||||
|
||||
if ($do_comments) {
|
||||
$comments = Relation::getComments($db, $table);
|
||||
$comments = $this->relation->getComments($db, $table);
|
||||
}
|
||||
if ($do_mime && $cfgRelation['mimework']) {
|
||||
$mime_map = Transformations::getMIME($db, $table, true);
|
||||
|
||||
@ -28,9 +28,19 @@ abstract class ExportPlugin
|
||||
* @var \PhpMyAdmin\Properties\Plugins\ExportPluginProperties
|
||||
*/
|
||||
protected $properties;
|
||||
|
||||
/**
|
||||
* Common methods, must be overwritten by all export plugins
|
||||
* @var Relation $relation
|
||||
*/
|
||||
protected $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs export header
|
||||
@ -350,7 +360,7 @@ abstract class ExportPlugin
|
||||
array $aliases = array()
|
||||
) {
|
||||
$relation = '';
|
||||
$foreigner = Relation::searchColumnInForeigners($res_rel, $field_name);
|
||||
$foreigner = $this->relation->searchColumnInForeigners($res_rel, $field_name);
|
||||
if ($foreigner) {
|
||||
$ftable = $foreigner['foreign_table'];
|
||||
$ffield = $foreigner['foreign_field'];
|
||||
|
||||
@ -84,7 +84,7 @@ class DiaRelationSchema extends ExportRelationSchema
|
||||
|
||||
$seen_a_relation = false;
|
||||
foreach ($alltables as $one_table) {
|
||||
$exist_rel = Relation::getForeigners($this->db, $one_table, '', 'both');
|
||||
$exist_rel = $this->relation->getForeigners($this->db, $one_table, '', 'both');
|
||||
if (!$exist_rel) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ class EpsRelationSchema extends ExportRelationSchema
|
||||
|
||||
$seen_a_relation = false;
|
||||
foreach ($alltables as $one_table) {
|
||||
$exist_rel = Relation::getForeigners($this->db, $one_table, '', 'both');
|
||||
$exist_rel = $this->relation->getForeigners($this->db, $one_table, '', 'both');
|
||||
if (!$exist_rel) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -21,6 +21,22 @@ use PhpMyAdmin\Util;
|
||||
*/
|
||||
class ExportRelationSchema
|
||||
{
|
||||
protected $db;
|
||||
protected $diagram;
|
||||
protected $showColor;
|
||||
protected $tableDimension;
|
||||
protected $sameWide;
|
||||
protected $showKeys;
|
||||
protected $orientation;
|
||||
protected $paper;
|
||||
protected $pageNumber;
|
||||
protected $offline;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
protected $relation;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@ -33,19 +49,9 @@ class ExportRelationSchema
|
||||
$this->diagram = $diagram;
|
||||
$this->setPageNumber($_REQUEST['page_number']);
|
||||
$this->setOffline(isset($_REQUEST['offline_export']));
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
protected $db;
|
||||
protected $diagram;
|
||||
protected $showColor;
|
||||
protected $tableDimension;
|
||||
protected $sameWide;
|
||||
protected $showKeys;
|
||||
protected $orientation;
|
||||
protected $paper;
|
||||
protected $pageNumber;
|
||||
protected $offline;
|
||||
|
||||
/**
|
||||
* Set Page Number
|
||||
*
|
||||
@ -266,7 +272,7 @@ class ExportRelationSchema
|
||||
. Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
|
||||
. Util::backquote($GLOBALS['cfgRelation']['pdf_pages'])
|
||||
. ' WHERE page_nr = ' . $this->pageNumber;
|
||||
$_name_rs = Relation::queryAsControlUser($_name_sql);
|
||||
$_name_rs = $this->relation->queryAsControlUser($_name_sql);
|
||||
$_name_row = $GLOBALS['dbi']->fetchRow($_name_rs);
|
||||
$filename = $_name_row[0] . $extension;
|
||||
}
|
||||
|
||||
@ -54,6 +54,11 @@ class Pdf extends PdfLib
|
||||
private $_withDoc;
|
||||
private $_db;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructs PDF for schema export.
|
||||
*
|
||||
@ -73,6 +78,7 @@ class Pdf extends PdfLib
|
||||
$this->_pageNumber = $pageNumber;
|
||||
$this->_withDoc = $withDoc;
|
||||
$this->_db = $db;
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -242,7 +248,7 @@ class Pdf extends PdfLib
|
||||
. Util::backquote($GLOBALS['cfgRelation']['pdf_pages'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($this->_db)
|
||||
. '\' AND page_nr = \'' . $this->_pageNumber . '\'';
|
||||
$test_rs = Relation::queryAsControlUser($test_query);
|
||||
$test_rs = $this->relation->queryAsControlUser($test_query);
|
||||
$pages = @$GLOBALS['dbi']->fetchAssoc($test_rs);
|
||||
$pg_name = ucfirst($pages['page_descr']);
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ class PdfRelationSchema extends ExportRelationSchema
|
||||
// and finding its foreigns is OK (then we can support innodb)
|
||||
$seen_a_relation = false;
|
||||
foreach ($alltables as $one_table) {
|
||||
$exist_rel = Relation::getForeigners($this->db, $one_table, '', 'both');
|
||||
$exist_rel = $this->relation->getForeigners($this->db, $one_table, '', 'both');
|
||||
if (!$exist_rel) {
|
||||
continue;
|
||||
}
|
||||
@ -547,8 +547,8 @@ class PdfRelationSchema extends ExportRelationSchema
|
||||
$this->diagram->SetFont($this->_ff, '', 8);
|
||||
$this->diagram->ln();
|
||||
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$comments = Relation::getComments($this->db, $table);
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
$comments = $this->relation->getComments($this->db, $table);
|
||||
if ($cfgRelation['mimework']) {
|
||||
$mime_map = Transformations::getMIME($this->db, $table, true);
|
||||
}
|
||||
@ -584,7 +584,7 @@ class PdfRelationSchema extends ExportRelationSchema
|
||||
|
||||
// Find which tables are related with the current one and write it in
|
||||
// an array
|
||||
$res_rel = Relation::getForeigners($this->db, $table);
|
||||
$res_rel = $this->relation->getForeigners($this->db, $table);
|
||||
|
||||
/**
|
||||
* Displays the comments of the table if MySQL >= 3.23
|
||||
@ -680,7 +680,7 @@ class PdfRelationSchema extends ExportRelationSchema
|
||||
$this->diagram->SetLink(
|
||||
$this->diagram->PMA_links['doc'][$table][$field_name], -1
|
||||
);
|
||||
$foreigner = Relation::searchColumnInForeigners($res_rel, $field_name);
|
||||
$foreigner = $this->relation->searchColumnInForeigners($res_rel, $field_name);
|
||||
|
||||
$linksTo = '';
|
||||
if ($foreigner) {
|
||||
|
||||
@ -104,7 +104,7 @@ class SvgRelationSchema extends ExportRelationSchema
|
||||
|
||||
$seen_a_relation = false;
|
||||
foreach ($alltables as $one_table) {
|
||||
$exist_rel = Relation::getForeigners($this->db, $one_table, '', 'both');
|
||||
$exist_rel = $this->relation->getForeigners($this->db, $one_table, '', 'both');
|
||||
if (!$exist_rel) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -37,6 +37,11 @@ abstract class TableStats
|
||||
public $heightCell = 0;
|
||||
protected $offline;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
protected $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -63,6 +68,8 @@ abstract class TableStats
|
||||
|
||||
$this->offline = $offline;
|
||||
|
||||
$this->relation = new Relation();
|
||||
|
||||
// checks whether the table exists
|
||||
// and loads fields
|
||||
$this->validateTableAndLoadFields();
|
||||
@ -139,7 +146,7 @@ abstract class TableStats
|
||||
*/
|
||||
protected function loadDisplayField()
|
||||
{
|
||||
$this->displayfield = Relation::getDisplayField($this->db, $this->tableName);
|
||||
$this->displayfield = $this->relation->getDisplayField($this->db, $this->tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -47,6 +47,11 @@ class RecentFavoriteTable
|
||||
*/
|
||||
private static $_instances = array();
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Creates a new instance of RecentFavoriteTable
|
||||
*
|
||||
@ -56,6 +61,7 @@ class RecentFavoriteTable
|
||||
*/
|
||||
private function __construct($type)
|
||||
{
|
||||
$this->relation = new Relation();
|
||||
$this->_tableType = $type;
|
||||
$server_id = $GLOBALS['server'];
|
||||
if (! isset($_SESSION['tmpval'][$this->_tableType . '_tables'][$server_id])
|
||||
@ -105,7 +111,7 @@ class RecentFavoriteTable
|
||||
" WHERE `username` = '" . $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']) . "'";
|
||||
|
||||
$return = array();
|
||||
$result = Relation::queryAsControlUser($sql_query, false);
|
||||
$result = $this->relation->queryAsControlUser($sql_query, false);
|
||||
if ($result) {
|
||||
$row = $GLOBALS['dbi']->fetchArray($result);
|
||||
if (isset($row[0])) {
|
||||
@ -350,7 +356,7 @@ class RecentFavoriteTable
|
||||
if ($server_id == 0) {
|
||||
return '';
|
||||
}
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
// Not to show this once list is synchronized.
|
||||
if ($cfgRelation['favoritework'] && ! isset($_SESSION['tmpval']['favorites_synced'][$server_id])) {
|
||||
$params = array('ajax_request' => true, 'favorite_table' => true,
|
||||
@ -383,7 +389,7 @@ class RecentFavoriteTable
|
||||
*/
|
||||
private function _getPmaTable()
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if (! empty($cfgRelation['db'])
|
||||
&& ! empty($cfgRelation[$this->_tableType])
|
||||
) {
|
||||
|
||||
@ -28,7 +28,8 @@ class RelationCleanup
|
||||
*/
|
||||
public static function column($db, $table, $column)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
if ($cfgRelation['commwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
@ -39,7 +40,7 @@ class RelationCleanup
|
||||
. '\''
|
||||
. ' AND column_name = \'' . $GLOBALS['dbi']->escapeString($column)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['displaywork']) {
|
||||
@ -51,7 +52,7 @@ class RelationCleanup
|
||||
. '\''
|
||||
. ' AND display_field = \'' . $GLOBALS['dbi']->escapeString($column)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['relwork']) {
|
||||
@ -64,7 +65,7 @@ class RelationCleanup
|
||||
. '\''
|
||||
. ' AND master_field = \'' . $GLOBALS['dbi']->escapeString($column)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
@ -75,7 +76,7 @@ class RelationCleanup
|
||||
. '\''
|
||||
. ' AND foreign_field = \'' . $GLOBALS['dbi']->escapeString($column)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +90,8 @@ class RelationCleanup
|
||||
*/
|
||||
public static function table($db, $table)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
if ($cfgRelation['commwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
@ -98,7 +100,7 @@ class RelationCleanup
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['displaywork']) {
|
||||
@ -108,7 +110,7 @@ class RelationCleanup
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['pdfwork']) {
|
||||
@ -118,7 +120,7 @@ class RelationCleanup
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['relwork']) {
|
||||
@ -129,7 +131,7 @@ class RelationCleanup
|
||||
. '\''
|
||||
. ' AND master_table = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
@ -138,7 +140,7 @@ class RelationCleanup
|
||||
. '\''
|
||||
. ' AND foreign_table = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['uiprefswork']) {
|
||||
@ -148,7 +150,7 @@ class RelationCleanup
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
|
||||
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['navwork']) {
|
||||
@ -161,7 +163,7 @@ class RelationCleanup
|
||||
. ' OR (item_name = \'' . $GLOBALS['dbi']->escapeString($table)
|
||||
. '\''
|
||||
. ' AND item_type = \'table\'))';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,14 +176,15 @@ class RelationCleanup
|
||||
*/
|
||||
public static function database($db)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
if ($cfgRelation['commwork']) {
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['column_info'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['bookmarkwork']) {
|
||||
@ -189,7 +192,7 @@ class RelationCleanup
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['bookmark'])
|
||||
. ' WHERE dbase = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['displaywork']) {
|
||||
@ -197,7 +200,7 @@ class RelationCleanup
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['table_info'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['pdfwork']) {
|
||||
@ -205,13 +208,13 @@ class RelationCleanup
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['pdf_pages'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['table_coords'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['relwork']) {
|
||||
@ -220,14 +223,14 @@ class RelationCleanup
|
||||
. '.' . Util::backquote($cfgRelation['relation'])
|
||||
. ' WHERE master_db = \''
|
||||
. $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
|
||||
$remove_query = 'DELETE FROM '
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['relation'])
|
||||
. ' WHERE foreign_db = \'' . $GLOBALS['dbi']->escapeString($db)
|
||||
. '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['uiprefswork']) {
|
||||
@ -235,7 +238,7 @@ class RelationCleanup
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['table_uiprefs'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['navwork']) {
|
||||
@ -243,7 +246,7 @@ class RelationCleanup
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['navigationhiding'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['savedsearcheswork']) {
|
||||
@ -251,7 +254,7 @@ class RelationCleanup
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['savedsearches'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['centralcolumnswork']) {
|
||||
@ -259,7 +262,7 @@ class RelationCleanup
|
||||
. Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['central_columns'])
|
||||
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,7 +275,8 @@ class RelationCleanup
|
||||
*/
|
||||
public static function user($username)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
if ($cfgRelation['bookmarkwork']) {
|
||||
$remove_query = "DELETE FROM "
|
||||
@ -280,7 +284,7 @@ class RelationCleanup
|
||||
. "." . Util::backquote($cfgRelation['bookmark'])
|
||||
. " WHERE `user` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['historywork']) {
|
||||
@ -289,7 +293,7 @@ class RelationCleanup
|
||||
. "." . Util::backquote($cfgRelation['history'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['recentwork']) {
|
||||
@ -298,7 +302,7 @@ class RelationCleanup
|
||||
. "." . Util::backquote($cfgRelation['recent'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['favoritework']) {
|
||||
@ -307,7 +311,7 @@ class RelationCleanup
|
||||
. "." . Util::backquote($cfgRelation['favorite'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['uiprefswork']) {
|
||||
@ -316,7 +320,7 @@ class RelationCleanup
|
||||
. "." . Util::backquote($cfgRelation['table_uiprefs'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['userconfigwork']) {
|
||||
@ -325,7 +329,7 @@ class RelationCleanup
|
||||
. "." . Util::backquote($cfgRelation['userconfig'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['menuswork']) {
|
||||
@ -334,7 +338,7 @@ class RelationCleanup
|
||||
. "." . Util::backquote($cfgRelation['users'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['navwork']) {
|
||||
@ -343,7 +347,7 @@ class RelationCleanup
|
||||
. "." . Util::backquote($cfgRelation['navigationhiding'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['savedsearcheswork']) {
|
||||
@ -352,7 +356,7 @@ class RelationCleanup
|
||||
. "." . Util::backquote($cfgRelation['savedsearches'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
|
||||
if ($cfgRelation['designersettingswork']) {
|
||||
@ -361,7 +365,7 @@ class RelationCleanup
|
||||
. "." . Util::backquote($cfgRelation['designer_settings'])
|
||||
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($remove_query);
|
||||
$relation->queryAsControlUser($remove_query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,6 +49,28 @@ class SavedSearches
|
||||
*/
|
||||
private $_searchName = null;
|
||||
|
||||
/**
|
||||
* Criterias
|
||||
* @var array
|
||||
*/
|
||||
private $_criterias = null;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Public constructor
|
||||
*
|
||||
* @param array $config Global configuration
|
||||
*/
|
||||
public function __construct(array $config)
|
||||
{
|
||||
$this->setConfig($config);
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter of id
|
||||
*
|
||||
@ -100,12 +122,6 @@ class SavedSearches
|
||||
return $this->_searchName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Criterias
|
||||
* @var array
|
||||
*/
|
||||
private $_criterias = null;
|
||||
|
||||
/**
|
||||
* Setter of config
|
||||
*
|
||||
@ -239,16 +255,6 @@ class SavedSearches
|
||||
return $this->_dbname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public constructor
|
||||
*
|
||||
* @param array $config Global configuration
|
||||
*/
|
||||
public function __construct(array $config)
|
||||
{
|
||||
$this->setConfig($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the search
|
||||
*
|
||||
@ -313,7 +319,7 @@ class SavedSearches
|
||||
. "'" . $GLOBALS['dbi']->escapeString(json_encode($this->getCriterias()))
|
||||
. "')";
|
||||
|
||||
$result = (bool)Relation::queryAsControlUser($sqlQuery);
|
||||
$result = (bool) $this->relation->queryAsControlUser($sqlQuery);
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
@ -347,7 +353,7 @@ class SavedSearches
|
||||
. "`search_data` = '"
|
||||
. $GLOBALS['dbi']->escapeString(json_encode($this->getCriterias())) . "' "
|
||||
. "WHERE id = " . $this->getId();
|
||||
return (bool)Relation::queryAsControlUser($sqlQuery);
|
||||
return (bool) $this->relation->queryAsControlUser($sqlQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -375,7 +381,7 @@ class SavedSearches
|
||||
$sqlQuery = "DELETE FROM " . $savedSearchesTbl
|
||||
. "WHERE id = '" . $GLOBALS['dbi']->escapeString($this->getId()) . "'";
|
||||
|
||||
return (bool)Relation::queryAsControlUser($sqlQuery);
|
||||
return (bool) $this->relation->queryAsControlUser($sqlQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -403,7 +409,7 @@ class SavedSearches
|
||||
. "FROM " . $savedSearchesTbl . " "
|
||||
. "WHERE id = '" . $GLOBALS['dbi']->escapeString($this->getId()) . "' ";
|
||||
|
||||
$resList = Relation::queryAsControlUser($sqlQuery);
|
||||
$resList = $this->relation->queryAsControlUser($sqlQuery);
|
||||
|
||||
if (false === ($oneResult = $GLOBALS['dbi']->fetchArray($resList))) {
|
||||
$message = Message::error(__('Error while loading the search.'));
|
||||
@ -450,7 +456,7 @@ class SavedSearches
|
||||
|
||||
$sqlQuery .= "order by search_name ASC ";
|
||||
|
||||
$resList = Relation::queryAsControlUser($sqlQuery);
|
||||
$resList = $this->relation->queryAsControlUser($sqlQuery);
|
||||
|
||||
$list = array();
|
||||
while ($oneResult = $GLOBALS['dbi']->fetchArray($resList)) {
|
||||
|
||||
@ -526,7 +526,8 @@ class Privileges
|
||||
*/
|
||||
public static function getHtmlToChooseUserGroup($username)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
$groupTable = Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['usergroups']);
|
||||
$userTable = Util::backquote($cfgRelation['db'])
|
||||
@ -543,7 +544,7 @@ class Privileges
|
||||
|
||||
$allUserGroups = array('' => '');
|
||||
$sql_query = "SELECT DISTINCT `usergroup` FROM " . $groupTable;
|
||||
$result = Relation::queryAsControlUser($sql_query, false);
|
||||
$result = $relation->queryAsControlUser($sql_query, false);
|
||||
if ($result) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$allUserGroups[$row[0]] = $row[0];
|
||||
@ -573,7 +574,8 @@ class Privileges
|
||||
*/
|
||||
public static function setUserGroup($username, $userGroup)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
if (empty($cfgRelation['db']) || empty($cfgRelation['users']) || empty($cfgRelation['usergroups'])) {
|
||||
return;
|
||||
}
|
||||
@ -602,7 +604,7 @@ class Privileges
|
||||
}
|
||||
}
|
||||
if (isset($upd_query)) {
|
||||
Relation::queryAsControlUser($upd_query);
|
||||
$relation->queryAsControlUser($upd_query);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2867,7 +2869,8 @@ class Privileges
|
||||
*/
|
||||
public static function getUserGroupCount()
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
$user_group_table = Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['usergroups']);
|
||||
$sql_query = 'SELECT COUNT(*) FROM ' . $user_group_table;
|
||||
@ -2887,7 +2890,8 @@ class Privileges
|
||||
*/
|
||||
public static function getUserGroupForUser($username)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
if (empty($cfgRelation['db'])
|
||||
|| empty($cfgRelation['users'])
|
||||
@ -2925,6 +2929,7 @@ class Privileges
|
||||
public static function getExtraDataForAjaxBehavior(
|
||||
$password, $sql_query, $hostname, $username
|
||||
) {
|
||||
$relation = new Relation();
|
||||
if (isset($GLOBALS['dbname'])) {
|
||||
//if (preg_match('/\\\\(?:_|%)/i', $dbname)) {
|
||||
if (preg_match('/(?<!\\\\)(?:_|%)/i', $GLOBALS['dbname'])) {
|
||||
@ -2978,7 +2983,7 @@ class Privileges
|
||||
|
||||
// if $cfg['Servers'][$i]['users'] and $cfg['Servers'][$i]['usergroups'] are
|
||||
// enabled
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
if (!empty($cfgRelation['users']) && !empty($cfgRelation['usergroups'])) {
|
||||
$new_user_string .= '<td class="usrGroup"></td>';
|
||||
}
|
||||
@ -3586,12 +3591,13 @@ class Privileges
|
||||
*/
|
||||
public static function getHtmlTableBodyForUserRights(array $db_rights)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
if ($cfgRelation['menuswork']) {
|
||||
$users_table = Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['users']);
|
||||
$sql_query = 'SELECT * FROM ' . $users_table;
|
||||
$result = Relation::queryAsControlUser($sql_query, false);
|
||||
$result = $relation->queryAsControlUser($sql_query, false);
|
||||
$group_assignment = array();
|
||||
if ($result) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
|
||||
|
||||
@ -27,17 +27,18 @@ class UserGroups
|
||||
*/
|
||||
public static function getHtmlForListingUsersofAGroup($userGroup)
|
||||
{
|
||||
$relation = new Relation();
|
||||
$html_output = '<h2>'
|
||||
. sprintf(__('Users of \'%s\' user group'), htmlspecialchars($userGroup))
|
||||
. '</h2>';
|
||||
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
$usersTable = Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['users']);
|
||||
$sql_query = "SELECT `username` FROM " . $usersTable
|
||||
. " WHERE `usergroup`='" . $GLOBALS['dbi']->escapeString($userGroup)
|
||||
. "'";
|
||||
$result = Relation::queryAsControlUser($sql_query, false);
|
||||
$result = $relation->queryAsControlUser($sql_query, false);
|
||||
if ($result) {
|
||||
if ($GLOBALS['dbi']->numRows($result) == 0) {
|
||||
$html_output .= '<p>'
|
||||
@ -70,12 +71,13 @@ class UserGroups
|
||||
*/
|
||||
public static function getHtmlForUserGroupsTable()
|
||||
{
|
||||
$relation = new Relation();
|
||||
$html_output = '<h2>' . __('User groups') . '</h2>';
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
$groupTable = Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['usergroups']);
|
||||
$sql_query = "SELECT * FROM " . $groupTable . " ORDER BY `usergroup` ASC";
|
||||
$result = Relation::queryAsControlUser($sql_query, false);
|
||||
$result = $relation->queryAsControlUser($sql_query, false);
|
||||
|
||||
if ($result && $GLOBALS['dbi']->numRows($result)) {
|
||||
$html_output .= '<form name="userGroupsForm" id="userGroupsForm"'
|
||||
@ -189,7 +191,8 @@ class UserGroups
|
||||
*/
|
||||
public static function delete($userGroup)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
$userTable = Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['users']);
|
||||
$groupTable = Util::backquote($cfgRelation['db'])
|
||||
@ -197,11 +200,11 @@ class UserGroups
|
||||
$sql_query = "DELETE FROM " . $userTable
|
||||
. " WHERE `usergroup`='" . $GLOBALS['dbi']->escapeString($userGroup)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($sql_query, true);
|
||||
$relation->queryAsControlUser($sql_query, true);
|
||||
$sql_query = "DELETE FROM " . $groupTable
|
||||
. " WHERE `usergroup`='" . $GLOBALS['dbi']->escapeString($userGroup)
|
||||
. "'";
|
||||
Relation::queryAsControlUser($sql_query, true);
|
||||
$relation->queryAsControlUser($sql_query, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,6 +216,7 @@ class UserGroups
|
||||
*/
|
||||
public static function getHtmlToEditUserGroup($userGroup = null)
|
||||
{
|
||||
$relation = new Relation();
|
||||
$html_output = '';
|
||||
if ($userGroup == null) {
|
||||
$html_output .= '<h2>' . __('Add user group') . '</h2>';
|
||||
@ -253,13 +257,13 @@ class UserGroups
|
||||
'table' => array()
|
||||
);
|
||||
if ($userGroup != null) {
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
$groupTable = Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['usergroups']);
|
||||
$sql_query = "SELECT * FROM " . $groupTable
|
||||
. " WHERE `usergroup`='" . $GLOBALS['dbi']->escapeString($userGroup)
|
||||
. "'";
|
||||
$result = Relation::queryAsControlUser($sql_query, false);
|
||||
$result = $relation->queryAsControlUser($sql_query, false);
|
||||
if ($result) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
|
||||
$key = $row['tab'];
|
||||
@ -337,8 +341,9 @@ class UserGroups
|
||||
*/
|
||||
public static function edit($userGroup, $new = false)
|
||||
{
|
||||
$relation = new Relation();
|
||||
$tabs = Util::getMenuTabList();
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
$groupTable = Util::backquote($cfgRelation['db'])
|
||||
. "." . Util::backquote($cfgRelation['usergroups']);
|
||||
|
||||
@ -346,7 +351,7 @@ class UserGroups
|
||||
$sql_query = "DELETE FROM " . $groupTable
|
||||
. " WHERE `usergroup`='" . $GLOBALS['dbi']->escapeString($userGroup)
|
||||
. "';";
|
||||
Relation::queryAsControlUser($sql_query, true);
|
||||
$relation->queryAsControlUser($sql_query, true);
|
||||
}
|
||||
|
||||
$sql_query = "INSERT INTO " . $groupTable
|
||||
@ -366,6 +371,6 @@ class UserGroups
|
||||
}
|
||||
}
|
||||
$sql_query .= ";";
|
||||
Relation::queryAsControlUser($sql_query, true);
|
||||
$relation->queryAsControlUser($sql_query, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,6 +34,19 @@ use PhpMyAdmin\Util;
|
||||
*/
|
||||
class Sql
|
||||
{
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses and analyzes the given SQL query.
|
||||
*
|
||||
@ -192,9 +205,9 @@ class Sql
|
||||
*/
|
||||
private function getHtmlForRelationalColumnDropdown($db, $table, $column, $curr_value)
|
||||
{
|
||||
$foreigners = Relation::getForeigners($db, $table, $column);
|
||||
$foreigners = $this->relation->getForeigners($db, $table, $column);
|
||||
|
||||
$foreignData = Relation::getForeignData($foreigners, $column, false, '', '');
|
||||
$foreignData = $this->relation->getForeignData($foreigners, $column, false, '', '');
|
||||
|
||||
if ($foreignData['disp_row'] == null) {
|
||||
//Handle the case when number of values
|
||||
@ -214,7 +227,7 @@ class Sql
|
||||
. __('Browse foreign values')
|
||||
. '</a>';
|
||||
} else {
|
||||
$dropdown = Relation::foreignDropdown(
|
||||
$dropdown = $this->relation->foreignDropdown(
|
||||
$foreignData['disp_row'],
|
||||
$foreignData['foreign_field'],
|
||||
$foreignData['foreign_display'],
|
||||
|
||||
@ -23,6 +23,11 @@ class SystemDatabase
|
||||
*/
|
||||
protected $dbi;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Get instance of SystemDatabase
|
||||
*
|
||||
@ -32,6 +37,7 @@ class SystemDatabase
|
||||
function __construct(DatabaseInterface $dbi)
|
||||
{
|
||||
$this->dbi = $dbi;
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,7 +50,7 @@ class SystemDatabase
|
||||
*/
|
||||
public function getExistingTransformationData($db)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
|
||||
// Get the existing transformation details of the same database
|
||||
// from pma__column_info table
|
||||
@ -71,7 +77,7 @@ class SystemDatabase
|
||||
function getNewTransformationDataSql(
|
||||
$pma_transformation_data, array $column_map, $view_name, $db
|
||||
) {
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
|
||||
// Need to store new transformation details for VIEW
|
||||
$new_transformations_sql = sprintf(
|
||||
|
||||
@ -76,6 +76,11 @@ class Table
|
||||
*/
|
||||
protected $_dbi;
|
||||
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -91,6 +96,7 @@ class Table
|
||||
$this->_dbi = $dbi;
|
||||
$this->_name = $table_name;
|
||||
$this->_db_name = $db_name;
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -746,7 +752,7 @@ class Table
|
||||
*
|
||||
* @return string field specification
|
||||
*/
|
||||
static public function generateAlter($oldcol, $newcol, $type, $length,
|
||||
public static function generateAlter($oldcol, $newcol, $type, $length,
|
||||
$attribute, $collation, $null, $default_type, $default_value,
|
||||
$extra, $comment, $virtuality, $expression, $move_to
|
||||
) {
|
||||
@ -778,9 +784,10 @@ class Table
|
||||
*
|
||||
* @return int|boolean
|
||||
*/
|
||||
static public function duplicateInfo($work, $pma_table, array $get_fields,
|
||||
public static function duplicateInfo($work, $pma_table, array $get_fields,
|
||||
array $where_fields, array $new_fields
|
||||
) {
|
||||
$relation = new Relation();
|
||||
$last_id = -1;
|
||||
|
||||
if (!isset($GLOBALS['cfgRelation']) || !$GLOBALS['cfgRelation'][$work]) {
|
||||
@ -815,7 +822,7 @@ class Table
|
||||
|
||||
// must use DatabaseInterface::QUERY_STORE here, since we execute
|
||||
// another query inside the loop
|
||||
$table_copy_rs = Relation::queryAsControlUser(
|
||||
$table_copy_rs = $relation->queryAsControlUser(
|
||||
$table_copy_query, true, DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
@ -835,7 +842,7 @@ class Table
|
||||
. implode('\', \'', $value_parts) . '\', \''
|
||||
. implode('\', \'', $new_value_parts) . '\')';
|
||||
|
||||
Relation::queryAsControlUser($new_table_query);
|
||||
$relation->queryAsControlUser($new_table_query);
|
||||
$last_id = $GLOBALS['dbi']->insertId();
|
||||
} // end while
|
||||
|
||||
@ -857,12 +864,13 @@ class Table
|
||||
*
|
||||
* @return bool true if success, false otherwise
|
||||
*/
|
||||
static public function moveCopy($source_db, $source_table, $target_db,
|
||||
public static function moveCopy($source_db, $source_table, $target_db,
|
||||
$target_table, $what, $move, $mode
|
||||
) {
|
||||
|
||||
global $err_url;
|
||||
|
||||
$relation = new Relation();
|
||||
|
||||
// Try moving the tables directly, using native `RENAME` statement.
|
||||
if ($move && $what == 'data') {
|
||||
$tbl = new Table($source_table, $source_db);
|
||||
@ -1173,7 +1181,7 @@ class Table
|
||||
}
|
||||
}
|
||||
|
||||
Relation::getRelationsParam();
|
||||
$relation->getRelationsParam();
|
||||
|
||||
// Drops old table if the user has requested to move it
|
||||
if ($move) {
|
||||
@ -1192,7 +1200,7 @@ class Table
|
||||
$GLOBALS['dbi']->query($sql_drop_query);
|
||||
|
||||
// Renable table in configuration storage
|
||||
Relation::renameTable(
|
||||
$relation->renameTable(
|
||||
$source_db, $target_db,
|
||||
$source_table, $target_table
|
||||
);
|
||||
@ -1210,7 +1218,7 @@ class Table
|
||||
|
||||
if ($GLOBALS['cfgRelation']['commwork']) {
|
||||
// Get all comments and MIME-Types for current table
|
||||
$comments_copy_rs = Relation::queryAsControlUser(
|
||||
$comments_copy_rs = $relation->queryAsControlUser(
|
||||
'SELECT column_name, comment'
|
||||
. ($GLOBALS['cfgRelation']['mimework']
|
||||
? ', mimetype, transformation, transformation_options'
|
||||
@ -1258,7 +1266,7 @@ class Table
|
||||
. '\''
|
||||
: '')
|
||||
. ')';
|
||||
Relation::queryAsControlUser($new_comment_query);
|
||||
$relation->queryAsControlUser($new_comment_query);
|
||||
} // end while
|
||||
$GLOBALS['dbi']->freeResult($comments_copy_rs);
|
||||
unset($comments_copy_rs);
|
||||
@ -1497,7 +1505,7 @@ class Table
|
||||
$this->_db_name = $new_db;
|
||||
|
||||
// Renable table in configuration storage
|
||||
Relation::renameTable(
|
||||
$this->relation->renameTable(
|
||||
$old_db, $new_db,
|
||||
$old_name, $new_name
|
||||
);
|
||||
@ -1692,7 +1700,7 @@ class Table
|
||||
*/
|
||||
protected function getUiPrefsFromDb()
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
$pma_table = Util::backquote($cfgRelation['db']) . "."
|
||||
. Util::backquote($cfgRelation['table_uiprefs']);
|
||||
|
||||
@ -1702,7 +1710,7 @@ class Table
|
||||
. " AND `db_name` = '" . $GLOBALS['dbi']->escapeString($this->_db_name) . "'"
|
||||
. " AND `table_name` = '" . $GLOBALS['dbi']->escapeString($this->_name) . "'";
|
||||
|
||||
$row = $this->_dbi->fetchArray(Relation::queryAsControlUser($sql_query));
|
||||
$row = $this->_dbi->fetchArray($this->relation->queryAsControlUser($sql_query));
|
||||
if (isset($row[0])) {
|
||||
return json_decode($row[0], true);
|
||||
}
|
||||
@ -1717,7 +1725,7 @@ class Table
|
||||
*/
|
||||
protected function saveUiPrefsToDb()
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
$pma_table = Util::backquote($cfgRelation['db']) . "."
|
||||
. Util::backquote($cfgRelation['table_uiprefs']);
|
||||
|
||||
@ -1792,7 +1800,7 @@ class Table
|
||||
*/
|
||||
protected function loadUiPrefs()
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
$server_id = $GLOBALS['server'];
|
||||
|
||||
// set session variable if it's still undefined
|
||||
@ -1930,7 +1938,7 @@ class Table
|
||||
$this->uiprefs[$property] = $value;
|
||||
|
||||
// check if pmadb is set
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if ($cfgRelation['uiprefswork']) {
|
||||
return $this->saveUiprefsToDb();
|
||||
}
|
||||
@ -1953,7 +1961,7 @@ class Table
|
||||
unset($this->uiprefs[$property]);
|
||||
|
||||
// check if pmadb is set
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if ($cfgRelation['uiprefswork']) {
|
||||
return $this->saveUiprefsToDb();
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ class Tracker
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
static public function enable()
|
||||
public static function enable()
|
||||
{
|
||||
self::$enabled = true;
|
||||
}
|
||||
@ -61,7 +61,7 @@ class Tracker
|
||||
*
|
||||
* @return boolean (true=on|false=off)
|
||||
*/
|
||||
static public function isActive()
|
||||
public static function isActive()
|
||||
{
|
||||
if (! self::$enabled) {
|
||||
return false;
|
||||
@ -70,7 +70,8 @@ class Tracker
|
||||
* from Relation::getRelationsParam
|
||||
*/
|
||||
self::$enabled = false;
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
/* Restore original state */
|
||||
self::$enabled = true;
|
||||
if (! $cfgRelation['trackingwork']) {
|
||||
@ -121,7 +122,7 @@ class Tracker
|
||||
*
|
||||
* @return boolean true or false
|
||||
*/
|
||||
static public function isTracked($dbname, $tablename)
|
||||
public static function isTracked($dbname, $tablename)
|
||||
{
|
||||
if (! self::$enabled) {
|
||||
return false;
|
||||
@ -134,7 +135,8 @@ class Tracker
|
||||
* from Relation::getRelationsParam
|
||||
*/
|
||||
self::$enabled = false;
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
/* Restore original state */
|
||||
self::$enabled = true;
|
||||
if (! $cfgRelation['trackingwork']) {
|
||||
@ -158,7 +160,7 @@ class Tracker
|
||||
*
|
||||
* @return string Comment, contains date and username
|
||||
*/
|
||||
static public function getLogComment()
|
||||
public static function getLogComment()
|
||||
{
|
||||
$date = Util::date('Y-m-d H:i:s');
|
||||
$user = preg_replace('/\s+/', ' ', $GLOBALS['cfg']['Server']['user']);
|
||||
@ -180,11 +182,13 @@ class Tracker
|
||||
*
|
||||
* @return int result of version insertion
|
||||
*/
|
||||
static public function createVersion($dbname, $tablename, $version,
|
||||
public static function createVersion($dbname, $tablename, $version,
|
||||
$tracking_set = '', $is_view = false
|
||||
) {
|
||||
global $sql_backquotes, $export_type;
|
||||
|
||||
$relation = new Relation();
|
||||
|
||||
if ($tracking_set == '') {
|
||||
$tracking_set
|
||||
= $GLOBALS['cfg']['Server']['tracking_default_statements'];
|
||||
@ -270,7 +274,7 @@ class Tracker
|
||||
'" . $GLOBALS['dbi']->escapeString($tracking_set)
|
||||
. "' )";
|
||||
|
||||
$result = Relation::queryAsControlUser($sql_query);
|
||||
$result = $relation->queryAsControlUser($sql_query);
|
||||
|
||||
if ($result) {
|
||||
// Deactivate previous version
|
||||
@ -292,8 +296,10 @@ class Tracker
|
||||
*
|
||||
* @return int result of version insertion
|
||||
*/
|
||||
static public function deleteTracking($dbname, $tablename, $version = '')
|
||||
public static function deleteTracking($dbname, $tablename, $version = '')
|
||||
{
|
||||
$relation = new Relation();
|
||||
|
||||
$sql_query = "/*NOTRACK*/\n"
|
||||
. "DELETE FROM " . self::_getTrackingTable()
|
||||
. " WHERE `db_name` = '"
|
||||
@ -304,7 +310,7 @@ class Tracker
|
||||
$sql_query .= " AND `version` = '"
|
||||
. $GLOBALS['dbi']->escapeString($version) . "'";
|
||||
}
|
||||
$result = Relation::queryAsControlUser($sql_query);
|
||||
$result = $relation->queryAsControlUser($sql_query);
|
||||
|
||||
return $result;
|
||||
}
|
||||
@ -322,9 +328,11 @@ class Tracker
|
||||
*
|
||||
* @return int result of version insertion
|
||||
*/
|
||||
static public function createDatabaseVersion($dbname, $version, $query,
|
||||
public static function createDatabaseVersion($dbname, $version, $query,
|
||||
$tracking_set = 'CREATE DATABASE,ALTER DATABASE,DROP DATABASE'
|
||||
) {
|
||||
$relation = new Relation();
|
||||
|
||||
$date = Util::date('Y-m-d H:i:s');
|
||||
|
||||
if ($tracking_set == '') {
|
||||
@ -366,7 +374,7 @@ class Tracker
|
||||
'" . $GLOBALS['dbi']->escapeString($tracking_set)
|
||||
. "' )";
|
||||
|
||||
$result = Relation::queryAsControlUser($sql_query);
|
||||
$result = $relation->queryAsControlUser($sql_query);
|
||||
|
||||
return $result;
|
||||
}
|
||||
@ -388,6 +396,7 @@ class Tracker
|
||||
static private function _changeTracking($dbname, $tablename,
|
||||
$version, $new_state
|
||||
) {
|
||||
$relation = new Relation();
|
||||
|
||||
$sql_query = " UPDATE " . self::_getTrackingTable() .
|
||||
" SET `tracking_active` = '" . $new_state . "' " .
|
||||
@ -395,7 +404,7 @@ class Tracker
|
||||
" AND `table_name` = '" . $GLOBALS['dbi']->escapeString($tablename) . "' " .
|
||||
" AND `version` = '" . $GLOBALS['dbi']->escapeString($version) . "' ";
|
||||
|
||||
$result = Relation::queryAsControlUser($sql_query);
|
||||
$result = $relation->queryAsControlUser($sql_query);
|
||||
|
||||
return $result;
|
||||
}
|
||||
@ -413,9 +422,11 @@ class Tracker
|
||||
*
|
||||
* @return bool result of change
|
||||
*/
|
||||
static public function changeTrackingData($dbname, $tablename,
|
||||
public static function changeTrackingData($dbname, $tablename,
|
||||
$version, $type, $new_data
|
||||
) {
|
||||
$relation = new Relation();
|
||||
|
||||
if ($type == 'DDL') {
|
||||
$save_to = 'schema_sql';
|
||||
} elseif ($type == 'DML') {
|
||||
@ -441,7 +452,7 @@ class Tracker
|
||||
" AND `table_name` = '" . $GLOBALS['dbi']->escapeString($tablename) . "' " .
|
||||
" AND `version` = '" . $GLOBALS['dbi']->escapeString($version) . "' ";
|
||||
|
||||
$result = Relation::queryAsControlUser($sql_query);
|
||||
$result = $relation->queryAsControlUser($sql_query);
|
||||
|
||||
return (boolean) $result;
|
||||
}
|
||||
@ -457,7 +468,7 @@ class Tracker
|
||||
*
|
||||
* @return int result of SQL query
|
||||
*/
|
||||
static public function activateTracking($dbname, $tablename, $version)
|
||||
public static function activateTracking($dbname, $tablename, $version)
|
||||
{
|
||||
return self::_changeTracking($dbname, $tablename, $version, 1);
|
||||
}
|
||||
@ -474,7 +485,7 @@ class Tracker
|
||||
*
|
||||
* @return int result of SQL query
|
||||
*/
|
||||
static public function deactivateTracking($dbname, $tablename, $version)
|
||||
public static function deactivateTracking($dbname, $tablename, $version)
|
||||
{
|
||||
return self::_changeTracking($dbname, $tablename, $version, 0);
|
||||
}
|
||||
@ -492,8 +503,10 @@ class Tracker
|
||||
*
|
||||
* @return int (-1 if no version exists | > 0 if a version exists)
|
||||
*/
|
||||
static public function getVersion($dbname, $tablename, $statement = null)
|
||||
public static function getVersion($dbname, $tablename, $statement = null)
|
||||
{
|
||||
$relation = new Relation();
|
||||
|
||||
$sql_query = " SELECT MAX(version) FROM " . self::_getTrackingTable() .
|
||||
" WHERE `db_name` = '" . $GLOBALS['dbi']->escapeString($dbname) . "' " .
|
||||
" AND `table_name` = '" . $GLOBALS['dbi']->escapeString($tablename) . "' ";
|
||||
@ -502,7 +515,7 @@ class Tracker
|
||||
$sql_query .= " AND FIND_IN_SET('"
|
||||
. $statement . "',tracking) > 0" ;
|
||||
}
|
||||
$row = $GLOBALS['dbi']->fetchArray(Relation::queryAsControlUser($sql_query));
|
||||
$row = $GLOBALS['dbi']->fetchArray($relation->queryAsControlUser($sql_query));
|
||||
return isset($row[0])
|
||||
? $row[0]
|
||||
: -1;
|
||||
@ -521,8 +534,10 @@ class Tracker
|
||||
* @return mixed record DDM log, DDL log, structure snapshot, tracked
|
||||
* statements.
|
||||
*/
|
||||
static public function getTrackedData($dbname, $tablename, $version)
|
||||
public static function getTrackedData($dbname, $tablename, $version)
|
||||
{
|
||||
$relation = new Relation();
|
||||
|
||||
$sql_query = " SELECT * FROM " . self::_getTrackingTable() .
|
||||
" WHERE `db_name` = '" . $GLOBALS['dbi']->escapeString($dbname) . "' ";
|
||||
if (! empty($tablename)) {
|
||||
@ -532,7 +547,7 @@ class Tracker
|
||||
$sql_query .= " AND `version` = '" . $GLOBALS['dbi']->escapeString($version)
|
||||
. "' " . " ORDER BY `version` DESC LIMIT 1";
|
||||
|
||||
$mixed = $GLOBALS['dbi']->fetchAssoc(Relation::queryAsControlUser($sql_query));
|
||||
$mixed = $GLOBALS['dbi']->fetchAssoc($relation->queryAsControlUser($sql_query));
|
||||
|
||||
// Parse log
|
||||
$log_schema_entries = explode('# log ', $mixed['schema_sql']);
|
||||
@ -629,7 +644,7 @@ class Tracker
|
||||
* @return mixed Array containing identifier, type and tablename.
|
||||
*
|
||||
*/
|
||||
static public function parseQuery($query)
|
||||
public static function parseQuery($query)
|
||||
{
|
||||
// Usage of PMA_SQP does not work here
|
||||
//
|
||||
@ -776,8 +791,10 @@ class Tracker
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
static public function handleQuery($query)
|
||||
public static function handleQuery($query)
|
||||
{
|
||||
$relation = new Relation();
|
||||
|
||||
// If query is marked as untouchable, leave
|
||||
if (mb_strstr($query, "/*NOTRACK*/")) {
|
||||
return;
|
||||
@ -877,7 +894,7 @@ class Tracker
|
||||
. $GLOBALS['dbi']->escapeString($result['tablename']) . "' " .
|
||||
" AND `version` = '" . $GLOBALS['dbi']->escapeString($version) . "' ";
|
||||
|
||||
Relation::queryAsControlUser($sql_query);
|
||||
$relation->queryAsControlUser($sql_query);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -889,7 +906,8 @@ class Tracker
|
||||
*/
|
||||
private static function _getTrackingTable()
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
return Util::backquote($cfgRelation['db'])
|
||||
. '.' . Util::backquote($cfgRelation['tracking']);
|
||||
}
|
||||
|
||||
@ -117,7 +117,8 @@ class Tracking
|
||||
*/
|
||||
public static function getListOfVersionsOfTable()
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
$sql_query = " SELECT * FROM " .
|
||||
Util::backquote($cfgRelation['db']) . "." .
|
||||
Util::backquote($cfgRelation['tracking']) .
|
||||
@ -127,7 +128,7 @@ class Tracking
|
||||
$GLOBALS['dbi']->escapeString($_REQUEST['table']) . "' " .
|
||||
" ORDER BY version DESC ";
|
||||
|
||||
return Relation::queryAsControlUser($sql_query);
|
||||
return $relation->queryAsControlUser($sql_query);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -268,7 +269,8 @@ class Tracking
|
||||
*/
|
||||
public static function getSqlResultForSelectableTables()
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
$sql_query = " SELECT DISTINCT db_name, table_name FROM " .
|
||||
Util::backquote($cfgRelation['db']) . "." .
|
||||
@ -277,7 +279,7 @@ class Tracking
|
||||
"' " .
|
||||
" ORDER BY db_name, table_name";
|
||||
|
||||
return Relation::queryAsControlUser($sql_query);
|
||||
return $relation->queryAsControlUser($sql_query);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1217,6 +1219,7 @@ class Tracking
|
||||
$textDir,
|
||||
array $cfgRelation
|
||||
) {
|
||||
$relation = new Relation();
|
||||
$versions = [];
|
||||
while ($oneResult = $GLOBALS['dbi']->fetchArray($allTablesResult)) {
|
||||
list($tableName, $versionNumber) = $oneResult;
|
||||
@ -1229,7 +1232,7 @@ class Tracking
|
||||
. $GLOBALS['dbi']->escapeString($tableName)
|
||||
. '\' AND `version` = \'' . $versionNumber . '\'';
|
||||
|
||||
$tableResult = Relation::queryAsControlUser($tableQuery);
|
||||
$tableResult = $relation->queryAsControlUser($tableQuery);
|
||||
$versionData = $GLOBALS['dbi']->fetchArray($tableResult);
|
||||
$versionData['status_button'] = self::getStatusButton(
|
||||
$versionData,
|
||||
|
||||
@ -250,7 +250,8 @@ class Transformations
|
||||
*/
|
||||
public static function getMIME($db, $table, $strict = false, $fullName = false)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
if (! $cfgRelation['mimework']) {
|
||||
return false;
|
||||
@ -327,7 +328,8 @@ class Transformations
|
||||
public static function setMIME($db, $table, $key, $mimetype, $transformation,
|
||||
$transformationOpts, $inputTransform, $inputTransformOpts, $forcedelete = false
|
||||
) {
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
if (! $cfgRelation['mimework']) {
|
||||
return false;
|
||||
@ -355,7 +357,7 @@ class Transformations
|
||||
AND `table_name` = \'' . $GLOBALS['dbi']->escapeString($table) . '\'
|
||||
AND `column_name` = \'' . $GLOBALS['dbi']->escapeString($key) . '\'';
|
||||
|
||||
$test_rs = Relation::queryAsControlUser(
|
||||
$test_rs = $relation->queryAsControlUser(
|
||||
$test_qry, true, DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
@ -409,7 +411,7 @@ class Transformations
|
||||
}
|
||||
|
||||
if (isset($upd_query)) {
|
||||
return Relation::queryAsControlUser($upd_query);
|
||||
return $relation->queryAsControlUser($upd_query);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -432,7 +434,8 @@ class Transformations
|
||||
*/
|
||||
public static function clear($db, $table = '', $column = '')
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
if (! isset($cfgRelation['column_info'])) {
|
||||
return false;
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
*/
|
||||
namespace PhpMyAdmin\Twig;
|
||||
|
||||
use PhpMyAdmin\Relation;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
@ -24,28 +25,29 @@ class RelationExtension extends AbstractExtension
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
$relation = new Relation();
|
||||
return array(
|
||||
new TwigFunction(
|
||||
'Relation_foreignDropdown',
|
||||
'PhpMyAdmin\Relation::foreignDropdown',
|
||||
[$relation, 'foreignDropdown'],
|
||||
array('is_safe' => array('html'))
|
||||
),
|
||||
new TwigFunction(
|
||||
'Relation_getDisplayField',
|
||||
'PhpMyAdmin\Relation::getDisplayField',
|
||||
[$relation, 'getDisplayField'],
|
||||
array('is_safe' => array('html'))
|
||||
),
|
||||
new TwigFunction(
|
||||
'Relation_getForeignData',
|
||||
'PhpMyAdmin\Relation::getForeignData'
|
||||
[$relation, 'getForeignData']
|
||||
),
|
||||
new TwigFunction(
|
||||
'Relation_getTables',
|
||||
'PhpMyAdmin\Relation::getTables'
|
||||
[$relation, 'getTables']
|
||||
),
|
||||
new TwigFunction(
|
||||
'Relation_searchColumnInForeigners',
|
||||
'PhpMyAdmin\Relation::searchColumnInForeigners'
|
||||
[$relation, 'searchColumnInForeigners']
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -23,6 +23,19 @@ use PhpMyAdmin\Util;
|
||||
*/
|
||||
class UserPreferences
|
||||
{
|
||||
/**
|
||||
* @var Relation $relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Common initialization for user preferences modification pages
|
||||
*
|
||||
@ -56,7 +69,7 @@ class UserPreferences
|
||||
*/
|
||||
public function load()
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
if (! $cfgRelation['userconfigwork']) {
|
||||
// no pmadb table, use session storage
|
||||
if (! isset($_SESSION['userconfig'])) {
|
||||
@ -94,7 +107,7 @@ class UserPreferences
|
||||
*/
|
||||
public function save(array $config_array)
|
||||
{
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $this->relation->getRelationsParam();
|
||||
$server = isset($GLOBALS['server'])
|
||||
? $GLOBALS['server']
|
||||
: $GLOBALS['cfg']['ServerDefault'];
|
||||
|
||||
@ -29,6 +29,8 @@ Util::checkParameters(
|
||||
|
||||
global $db, $table;
|
||||
|
||||
$relation = new Relation();
|
||||
|
||||
/**
|
||||
* Initialize to avoid code execution path warnings
|
||||
*/
|
||||
@ -87,9 +89,9 @@ if (isset($selected) && is_array($selected)) {
|
||||
|
||||
$is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
|
||||
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
$comments_map = Relation::getComments($db, $table);
|
||||
$comments_map = $relation->getComments($db, $table);
|
||||
|
||||
$move_columns = array();
|
||||
if (isset($fields_meta)) {
|
||||
@ -119,12 +121,12 @@ if (isset($_REQUEST['submit_num_fields'])
|
||||
$regenerate = 1;
|
||||
}
|
||||
|
||||
$foreigners = Relation::getForeigners($db, $table, '', 'foreign');
|
||||
$foreigners = $relation->getForeigners($db, $table, '', 'foreign');
|
||||
$child_references = null;
|
||||
// From MySQL 5.6.6 onwards columns with foreign keys can be renamed.
|
||||
// Hence, no need to get child references
|
||||
if ($GLOBALS['dbi']->getVersion() < 50606) {
|
||||
$child_references = Relation::getChildReferences($db, $table);
|
||||
$child_references = $relation->getChildReferences($db, $table);
|
||||
}
|
||||
|
||||
for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
|
||||
@ -287,7 +289,7 @@ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
|
||||
&& isset($form_params['table'])
|
||||
&& $GLOBALS['dbi']->getVersion() < 50606
|
||||
) {
|
||||
$columnMeta['column_status'] = Relation::checkChildForeignReferences(
|
||||
$columnMeta['column_status'] = $relation->checkChildForeignReferences(
|
||||
$form_params['db'],
|
||||
$form_params['table'],
|
||||
$columnMeta['Field'],
|
||||
|
||||
@ -64,7 +64,8 @@ if (!empty($_GET['saved'])) {
|
||||
}
|
||||
|
||||
// warn about using session storage for settings
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
if (! $cfgRelation['userconfigwork']) {
|
||||
$msg = __(
|
||||
'Your preferences will be saved for current session only. Storing them '
|
||||
|
||||
@ -31,7 +31,8 @@ if (isset($_REQUEST['getNaviSettings']) && $_REQUEST['getNaviSettings']) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
if ($cfgRelation['navwork']) {
|
||||
if (isset($_REQUEST['hideNavItem'])) {
|
||||
if (! empty($_REQUEST['itemName'])
|
||||
|
||||
@ -19,7 +19,8 @@ require_once 'libraries/common.inc.php';
|
||||
* get all variables needed for exporting relational schema
|
||||
* in $cfgRelation
|
||||
*/
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
if (! isset($_REQUEST['export_type'])) {
|
||||
Util::checkParameters(array('export_type'));
|
||||
|
||||
@ -25,7 +25,8 @@ require_once 'libraries/common.inc.php';
|
||||
*/
|
||||
require_once 'libraries/check_user_privileges.inc.php';
|
||||
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
/**
|
||||
* Does the common work
|
||||
|
||||
@ -12,7 +12,8 @@ use PhpMyAdmin\Server\Users;
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
|
||||
Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$relation->getRelationsParam();
|
||||
if (! $GLOBALS['cfgRelation']['menuswork']) {
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -87,7 +87,8 @@ if (! empty($disp_message)) {
|
||||
$table_columns = $insertEdit->getTableColumns($db, $table);
|
||||
|
||||
// retrieve keys into foreign fields, if any
|
||||
$foreigners = Relation::getForeigners($db, $table);
|
||||
$relation = new Relation();
|
||||
$foreigners = $relation->getForeigners($db, $table);
|
||||
|
||||
// Retrieve form parameters for insert/edit form
|
||||
$_form_params = $insertEdit->getFormParametersForInsertForm(
|
||||
|
||||
@ -23,7 +23,8 @@ $scripts = $header->getScripts();
|
||||
$scripts->addFile('export.js');
|
||||
|
||||
// Get the relation settings
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
$displayExport = new Export();
|
||||
|
||||
|
||||
@ -44,7 +44,8 @@ $url_params['goto'] = $url_params['back'] = 'tbl_operations.php';
|
||||
/**
|
||||
* Gets relation settings
|
||||
*/
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
// reselect current db (needed in some cases probably due to
|
||||
// the calling of PhpMyAdmin\Relation)
|
||||
@ -460,7 +461,7 @@ unset($partition_names);
|
||||
|
||||
if ($cfgRelation['relwork'] && ! $pma_table->isEngine("INNODB")) {
|
||||
$GLOBALS['dbi']->selectDb($GLOBALS['db']);
|
||||
$foreign = Relation::getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'internal');
|
||||
$foreign = $relation->getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'internal');
|
||||
|
||||
if (! empty($foreign)) {
|
||||
$response->addHTML(
|
||||
|
||||
@ -42,7 +42,8 @@ $options_array = array(
|
||||
'NO_ACTION' => 'NO ACTION',
|
||||
'RESTRICT' => 'RESTRICT',
|
||||
);
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
$tbl_storage_engine = mb_strtoupper(
|
||||
$dbi->getTable($db, $table)->getStatusInfo('Engine')
|
||||
);
|
||||
@ -55,12 +56,12 @@ $dependency_definitions = array(
|
||||
"upd_query" => $upd_query
|
||||
);
|
||||
if ($cfgRelation['relwork']) {
|
||||
$dependency_definitions['existrel'] = Relation::getForeigners(
|
||||
$dependency_definitions['existrel'] = $relation->getForeigners(
|
||||
$db, $table, '', 'internal'
|
||||
);
|
||||
}
|
||||
if (Util::isForeignKeySupported($tbl_storage_engine)) {
|
||||
$dependency_definitions['existrel_foreign'] = Relation::getForeigners(
|
||||
$dependency_definitions['existrel_foreign'] = $relation->getForeigners(
|
||||
$db, $table, '', 'foreign'
|
||||
);
|
||||
}
|
||||
|
||||
@ -47,6 +47,8 @@ $scripts->addFile('sql.js');
|
||||
$scripts->addFile('indexes.js');
|
||||
$scripts->addFile('gis_data_editor.js');
|
||||
|
||||
$relation = new Relation();
|
||||
|
||||
$insertEdit = new InsertEdit($GLOBALS['dbi']);
|
||||
|
||||
// check whether insert row mode, if so include tbl_change.php
|
||||
@ -384,7 +386,7 @@ if ($response->isAjax() && ! isset($_POST['ajax_page_request'])) {
|
||||
*/
|
||||
if (isset($_REQUEST['rel_fields_list']) && $_REQUEST['rel_fields_list'] != '') {
|
||||
|
||||
$map = Relation::getForeigners($db, $table, '', 'both');
|
||||
$map = $relation->getForeigners($db, $table, '', 'both');
|
||||
|
||||
$relation_fields = array();
|
||||
parse_str($_REQUEST['rel_fields_list'], $relation_fields);
|
||||
|
||||
@ -45,7 +45,8 @@ class TableSearchControllerTest extends PmaTestCase
|
||||
$GLOBALS['db'] = 'db';
|
||||
$GLOBALS['table'] = 'table';
|
||||
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
|
||||
$GLOBALS['cfgRelation'] = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$GLOBALS['cfgRelation'] = $relation->getRelationsParam();
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
|
||||
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')
|
||||
|
||||
@ -54,7 +54,8 @@ class DiaRelationSchemaTest extends PmaTestCase
|
||||
'relwork' => 'relwork',
|
||||
'relation' => 'relation'
|
||||
);
|
||||
Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$relation->getRelationsParam();
|
||||
|
||||
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
|
||||
@ -55,7 +55,8 @@ class EpsRelationSchemaTest extends PmaTestCase
|
||||
'relwork' => 'relwork',
|
||||
'relation' => 'relation'
|
||||
);
|
||||
Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$relation->getRelationsParam();
|
||||
|
||||
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
|
||||
@ -67,7 +67,8 @@ class PdfRelationSchemaTest extends PmaTestCase
|
||||
'column_info' => 'column_info',
|
||||
'pdf_pages' => 'pdf_pages'
|
||||
);
|
||||
Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$relation->getRelationsParam();
|
||||
|
||||
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
|
||||
@ -54,7 +54,8 @@ class SvgRelationSchemaTest extends PmaTestCase
|
||||
'relwork' => 'relwork',
|
||||
'relation' => 'relation'
|
||||
);
|
||||
Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$relation->getRelationsParam();
|
||||
|
||||
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
|
||||
@ -22,6 +22,11 @@ use PHPUnit\Framework\TestCase;
|
||||
*/
|
||||
class RelationCleanupTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Relation
|
||||
*/
|
||||
private $relation;
|
||||
|
||||
/**
|
||||
* Prepares environment for the test.
|
||||
*
|
||||
@ -54,6 +59,7 @@ class RelationCleanupTest extends TestCase
|
||||
$GLOBALS['cfg']['Server']['export_templates'] = 'pma__export_templates';
|
||||
|
||||
$this->redefineRelation();
|
||||
$this->relation = new Relation();
|
||||
}
|
||||
|
||||
|
||||
@ -82,13 +88,13 @@ class RelationCleanupTest extends TestCase
|
||||
$this->redefineRelation();
|
||||
|
||||
//the $cfgRelation value before cleanup column
|
||||
$cfgRelation = Relation::checkRelationsParam();
|
||||
$cfgRelation = $this->relation->checkRelationsParam();
|
||||
$this->assertEquals(
|
||||
true,
|
||||
$cfgRelation['commwork']
|
||||
);
|
||||
//validate Relation::getDbComments when commwork = true
|
||||
$db_comments = Relation::getDbComments();
|
||||
$db_comments = $this->relation->getDbComments();
|
||||
$this->assertEquals(
|
||||
array('db_name0' => 'comment0','db_name1' => 'comment1'),
|
||||
$db_comments
|
||||
@ -99,7 +105,7 @@ class RelationCleanupTest extends TestCase
|
||||
$cfgRelation['displaywork']
|
||||
);
|
||||
//validate Relation::getDisplayField when displaywork = true
|
||||
$display_field = Relation::getDisplayField($db, $table);
|
||||
$display_field = $this->relation->getDisplayField($db, $table);
|
||||
$this->assertEquals(
|
||||
'PMA_display_field',
|
||||
$display_field
|
||||
@ -125,7 +131,7 @@ class RelationCleanupTest extends TestCase
|
||||
RelationCleanup::column($db, $table, $column);
|
||||
|
||||
//the $cfgRelation value after cleanup column
|
||||
$cfgRelation = Relation::checkRelationsParam();
|
||||
$cfgRelation = $this->relation->checkRelationsParam();
|
||||
|
||||
$is_defined_column_info
|
||||
= isset($cfgRelation['column_info'])? $cfgRelation['column_info'] : null;
|
||||
@ -161,7 +167,7 @@ class RelationCleanupTest extends TestCase
|
||||
$this->redefineRelation();
|
||||
|
||||
//the $cfgRelation value before cleanup column
|
||||
$cfgRelation = Relation::checkRelationsParam();
|
||||
$cfgRelation = $this->relation->checkRelationsParam();
|
||||
$this->assertEquals(
|
||||
'column_info',
|
||||
$cfgRelation['column_info']
|
||||
@ -183,7 +189,7 @@ class RelationCleanupTest extends TestCase
|
||||
RelationCleanup::table($db, $table);
|
||||
|
||||
//the $cfgRelation value after cleanup column
|
||||
$cfgRelation = Relation::checkRelationsParam();
|
||||
$cfgRelation = $this->relation->checkRelationsParam();
|
||||
|
||||
$is_defined_column_info
|
||||
= isset($cfgRelation['column_info'])? $cfgRelation['column_info'] : null;
|
||||
@ -225,7 +231,7 @@ class RelationCleanupTest extends TestCase
|
||||
$this->redefineRelation();
|
||||
|
||||
//the $cfgRelation value before cleanup column
|
||||
$cfgRelation = Relation::checkRelationsParam();
|
||||
$cfgRelation = $this->relation->checkRelationsParam();
|
||||
$this->assertEquals(
|
||||
'column_info',
|
||||
$cfgRelation['column_info']
|
||||
@ -255,7 +261,7 @@ class RelationCleanupTest extends TestCase
|
||||
RelationCleanup::database($db);
|
||||
|
||||
//the value after cleanup column
|
||||
$cfgRelation = Relation::checkRelationsParam();
|
||||
$cfgRelation = $this->relation->checkRelationsParam();
|
||||
|
||||
$is_defined_column_info
|
||||
= isset($cfgRelation['column_info'])? $cfgRelation['column_info'] : null;
|
||||
|
||||
@ -42,7 +42,8 @@ class TableTest extends PmaTestCase
|
||||
$GLOBALS['sql_drop_table'] = true;
|
||||
$GLOBALS['cfg']['Server']['table_uiprefs'] = "pma__table_uiprefs";
|
||||
|
||||
$GLOBALS['cfgRelation'] = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$GLOBALS['cfgRelation'] = $relation->getRelationsParam();
|
||||
$GLOBALS['dblist'] = new DataBasePMAMock();
|
||||
$GLOBALS['dblist']->databases = new DataBaseMock();
|
||||
|
||||
|
||||
@ -21,7 +21,8 @@ define('IS_TRANSFORMATION_WRAPPER', true);
|
||||
*/
|
||||
require_once './libraries/common.inc.php';
|
||||
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
$relation = new Relation();
|
||||
$cfgRelation = $relation->getRelationsParam();
|
||||
|
||||
/**
|
||||
* Ensures db and table are valid, else moves to the "parent" script
|
||||
|
||||
Loading…
Reference in New Issue
Block a user