Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f2cedb9576
@ -7,6 +7,12 @@
|
||||
*/
|
||||
|
||||
require_once 'libraries/common.inc.php';
|
||||
|
||||
// If request for fixing PMA tables.
|
||||
if (isset($_REQUEST['fix_pmadb'])) {
|
||||
PMA_fixPMATables($GLOBALS['db']);
|
||||
}
|
||||
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->addHTML(
|
||||
PMA_getRelationsParamDiagnostic(PMA_getRelationsParam())
|
||||
|
||||
@ -253,8 +253,7 @@ if (!$is_information_schema) {
|
||||
*/
|
||||
$response->addHTML(PMA_getHtmlForChangeDatabaseCharset($GLOBALS['db'], $table));
|
||||
|
||||
if ($num_tables > 0
|
||||
&& ! $cfgRelation['allworks']
|
||||
if (! $cfgRelation['allworks']
|
||||
&& $cfg['PmaNoRelation_DisableWarning'] == false
|
||||
) {
|
||||
$message = PMA_Message::notice(
|
||||
@ -270,9 +269,6 @@ if (!$is_information_schema) {
|
||||
if (!empty($cfg['Servers'][$server]['pmadb'])) {
|
||||
$message->isError(true);
|
||||
}
|
||||
$response->addHTML('<div class="operations_full_width">');
|
||||
$response->addHTML($message->getDisplay());
|
||||
$response->addHTML('</div>');
|
||||
} // end if
|
||||
} // end if (!$is_information_schema)
|
||||
|
||||
|
||||
@ -1439,6 +1439,20 @@ Navigation panel setup
|
||||
The maximum number of recently used tables shown in the navigation
|
||||
panel. Set this to 0 (zero) to disable the listing of recent tables.
|
||||
|
||||
.. config:option:: $cfg['ZeroConf']
|
||||
|
||||
:type: boolean
|
||||
:default: true
|
||||
|
||||
Enables Zero Configuration mode in which user will be offered a choice to
|
||||
create phpMyAdmin configuration storage in the current database
|
||||
or use existing, if already present.
|
||||
|
||||
.. note::
|
||||
If there is no central configuration storage defined then you may end up with
|
||||
different set of phpMyAdmin configuration storage tables for different
|
||||
databases.
|
||||
|
||||
.. config:option:: $cfg['NavigationLinkWithMainPanel']
|
||||
|
||||
:type: boolean
|
||||
|
||||
14
index.php
14
index.php
@ -513,7 +513,19 @@ if ($server > 0) {
|
||||
if (! $cfgRelation['allworks']
|
||||
&& $cfg['PmaNoRelation_DisableWarning'] == false
|
||||
) {
|
||||
$msg = PMA_Message::notice(__('The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. To find out why click %shere%s.'));
|
||||
$msg_text = __(
|
||||
'The phpMyAdmin configuration storage is not completely '
|
||||
. 'configured, some extended features have been deactivated. '
|
||||
. 'To find out why click %shere%s. '
|
||||
);
|
||||
if ($cfg['ZeroConf'] == true) {
|
||||
$msg_text .= __(
|
||||
'<br> '
|
||||
. 'Or alternately go to \'Operations\' tab of any database '
|
||||
. 'to set it up there.'
|
||||
);
|
||||
}
|
||||
$msg = PMA_Message::notice($msg_text);
|
||||
$msg->addParam(
|
||||
'<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?'
|
||||
. $common_url_query . '">',
|
||||
|
||||
@ -1147,4 +1147,10 @@ if (!empty($__redirect) && in_array($__redirect, $goto_whitelist)) {
|
||||
exit();
|
||||
}
|
||||
|
||||
// If Zero configuration mode enabled, check PMA tables in current db.
|
||||
if (isset($GLOBALS['cfg']['ZeroConf'])
|
||||
&& $GLOBALS['cfg']['ZeroConf'] == true
|
||||
) {
|
||||
PMA_checkAndFixPMATablesInCurrentDb();
|
||||
}
|
||||
?>
|
||||
|
||||
@ -316,6 +316,13 @@ $cfg['Servers'][$i]['hide_db'] = '';
|
||||
*/
|
||||
$cfg['Servers'][$i]['verbose'] = '';
|
||||
|
||||
/**
|
||||
* Zero Configuration mode.
|
||||
*
|
||||
* @global boolean $cfg['ZeroConf']
|
||||
*/
|
||||
$cfg['ZeroConf'] = true;
|
||||
|
||||
/**
|
||||
* Database used for Relation, Bookmark and PDF Features
|
||||
* (see examples/create_tables.sql)
|
||||
|
||||
@ -786,5 +786,10 @@ $strConfigCaptchaLoginPrivateKey_name = __('Private key for reCaptcha');
|
||||
|
||||
$strConfigSendErrorReports_desc = __('Choose the default action when sending error reports.');
|
||||
$strConfigSendErrorReports_name = __('Send error reports');
|
||||
$strConfigZeroConf_desc = __(
|
||||
'Enable Zero Configuration mode which lets you to setup phpMyAdmin '
|
||||
. 'configuration storage tables automatically.'
|
||||
);
|
||||
$strConfigZeroConf_name = __('Enable Zero Configuration mode');
|
||||
|
||||
?>
|
||||
|
||||
@ -145,6 +145,7 @@ $forms['Features']['Other_core_settings'] = array(
|
||||
'ProxyUser',
|
||||
'ProxyPass',
|
||||
'AllowThirdPartyFraming',
|
||||
'ZeroConf'
|
||||
);
|
||||
$forms['Sql_queries']['Sql_queries'] = array(
|
||||
'ShowSQL',
|
||||
|
||||
@ -35,7 +35,8 @@ $forms['Features']['General'] = array(
|
||||
'NumRecentTables',
|
||||
'NumFavoriteTables',
|
||||
'ShowHint',
|
||||
'SendErrorReports');
|
||||
'SendErrorReports'
|
||||
);
|
||||
$forms['Features']['Text_fields'] = array(
|
||||
'CharEditing',
|
||||
'MinSizeForInputField',
|
||||
|
||||
@ -952,4 +952,39 @@ function PMA_emptyRecursive($value)
|
||||
}
|
||||
return $empty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks and fixes configuration storage in current DB.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_checkAndFixPMATablesInCurrentDb()
|
||||
{
|
||||
if (isset($GLOBALS['db']) && ! empty($GLOBALS['db'])) {
|
||||
if (isset($GLOBALS['cfg']['Server']['pmadb'])
|
||||
&& empty($GLOBALS['cfg']['Server']['pmadb'])
|
||||
) {
|
||||
$default_tables = PMA_getDefaultPMATableNames();
|
||||
if (PMA_searchPMATablesInDb(
|
||||
$GLOBALS['db'],
|
||||
array_keys($default_tables)
|
||||
)
|
||||
) {
|
||||
PMA_fixPMATables($GLOBALS['db']);
|
||||
// Since configuration storage is updated, we need to
|
||||
// re-initialize the favorite and recent tables stored in the
|
||||
// session from the current configuration storage.
|
||||
include_once 'libraries/RecentFavoriteTable.class.php';
|
||||
$fav_tables = PMA_RecentFavoriteTable::getInstance('favorite');
|
||||
$recent_tables = PMA_RecentFavoriteTable::getInstance('recent');
|
||||
$_SESSION['tmpval']['favorite_tables'][$GLOBALS['server']]
|
||||
= $fav_tables->getFromDb();
|
||||
$_SESSION['tmpval']['recent_tables'][$GLOBALS['server']]
|
||||
= $recent_tables->getFromDb();
|
||||
// Reload navi panel to update the recent/favorite lists.
|
||||
$GLOBALS['reload'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -276,7 +276,7 @@ function PMA_getQueryStrFromSelected(
|
||||
|
||||
if ($deletes) {
|
||||
$_REQUEST['pos'] = PMA_calculatePosForLastPage(
|
||||
$db, $table, $_REQUEST['pos']
|
||||
$db, $table, isset($_REQUEST['pos']) ? $_REQUEST['pos'] : null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -107,6 +107,9 @@ function PMA_getRelationsParamDiagnostic($cfgRelation)
|
||||
. __('General relation features')
|
||||
. ' <font color="green">' . __('Disabled')
|
||||
. '</font>' . "\n";
|
||||
if (! empty($GLOBALS['db']) && $GLOBALS['cfg']['ZeroConf']) {
|
||||
$retval .= PMA_getHtmlFixPMATables();
|
||||
}
|
||||
} else {
|
||||
$retval .= '<table>' . "\n";
|
||||
$retval .= PMA_getDiagMessageForParameter(
|
||||
@ -298,33 +301,37 @@ function PMA_getRelationsParamDiagnostic($cfgRelation)
|
||||
);
|
||||
$retval .= '</table>' . "\n";
|
||||
|
||||
$retval .= '<p>' . __('Quick steps to setup advanced features:') . '</p>';
|
||||
$retval .= '<ul>';
|
||||
$retval .= '<li>';
|
||||
$retval .= __(
|
||||
'Create the needed tables with the '
|
||||
. '<code>examples/create_tables.sql</code>.'
|
||||
);
|
||||
$retval .= ' ' . PMA_Util::showDocu('setup', 'linked-tables');
|
||||
$retval .= '</li>';
|
||||
$retval .= '<li>';
|
||||
$retval .= __('Create a pma user and give access to these tables.');
|
||||
$retval .= ' ' . PMA_Util::showDocu('config', 'cfg_Servers_controluser');
|
||||
$retval .= '</li>';
|
||||
$retval .= '<li>';
|
||||
$retval .= __(
|
||||
'Enable advanced features in configuration file '
|
||||
. '(<code>config.inc.php</code>), for example by '
|
||||
. 'starting from <code>config.sample.inc.php</code>.'
|
||||
);
|
||||
$retval .= ' ' . PMA_Util::showDocu('setup', 'quick-install');
|
||||
$retval .= '</li>';
|
||||
$retval .= '<li>';
|
||||
$retval .= __(
|
||||
'Re-login to phpMyAdmin to load the updated configuration file.'
|
||||
);
|
||||
$retval .= '</li>';
|
||||
$retval .= '</ul>';
|
||||
if (! $cfgRelation['allworks']) {
|
||||
|
||||
$retval .= '<p>' . __('Quick steps to setup advanced features:')
|
||||
. '</p>';
|
||||
$retval .= '<ul>';
|
||||
$retval .= '<li>';
|
||||
$retval .= __(
|
||||
'Create the needed tables with the '
|
||||
. '<code>examples/create_tables.sql</code>.'
|
||||
);
|
||||
$retval .= ' ' . PMA_Util::showDocu('setup', 'linked-tables');
|
||||
$retval .= '</li>';
|
||||
$retval .= '<li>';
|
||||
$retval .= __('Create a pma user and give access to these tables.');
|
||||
$retval .= ' ' . PMA_Util::showDocu('config', 'cfg_Servers_controluser');
|
||||
$retval .= '</li>';
|
||||
$retval .= '<li>';
|
||||
$retval .= __(
|
||||
'Enable advanced features in configuration file '
|
||||
. '(<code>config.inc.php</code>), for example by '
|
||||
. 'starting from <code>config.sample.inc.php</code>.'
|
||||
);
|
||||
$retval .= ' ' . PMA_Util::showDocu('setup', 'quick-install');
|
||||
$retval .= '</li>';
|
||||
$retval .= '<li>';
|
||||
$retval .= __(
|
||||
'Re-login to phpMyAdmin to load the updated configuration file.'
|
||||
);
|
||||
$retval .= '</li>';
|
||||
$retval .= '</ul>';
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
@ -1723,4 +1730,156 @@ function PMA_searchColumnInForeigners($foreigners, $column)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches a DB for the existence of PMA tables.
|
||||
*
|
||||
* @param string $db Database
|
||||
* @param array $tables Default table names
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function PMA_searchPMATablesInDb($db, $tables)
|
||||
{
|
||||
$tab_rs = $GLOBALS['dbi']->getTables($db);
|
||||
|
||||
if ($tab_rs === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($tab_rs as $curr_table) {
|
||||
if (in_array($curr_table, $tables)) {
|
||||
$tables = array_diff($tables, array($curr_table));
|
||||
}
|
||||
}
|
||||
|
||||
if (count($tables) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns default PMA table names and their create queries.
|
||||
*
|
||||
* @return array table name, create query
|
||||
*/
|
||||
function PMA_getDefaultPMATableNames()
|
||||
{
|
||||
$pma_tables = array();
|
||||
if (PMA_DRIZZLE) {
|
||||
$create_tables_file = file_get_contents(
|
||||
'examples/create_tables_drizzle.sql'
|
||||
);
|
||||
} else {
|
||||
$create_tables_file = file_get_contents(
|
||||
'examples/create_tables.sql'
|
||||
);
|
||||
}
|
||||
|
||||
$queries = explode(';', $create_tables_file);
|
||||
|
||||
foreach ($queries as $query) {
|
||||
if (preg_match(
|
||||
'/CREATE TABLE IF NOT EXISTS `(.*)` \(/',
|
||||
$query,
|
||||
$table
|
||||
)
|
||||
) {
|
||||
$pma_tables[$table[1]] = $query . ';';
|
||||
}
|
||||
}
|
||||
|
||||
return $pma_tables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates PMA tables in the given db, updates if already exists.
|
||||
*
|
||||
* @param string $db Database
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_fixPMATables($db)
|
||||
{
|
||||
$default_tables = PMA_getDefaultPMATableNames();
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
|
||||
foreach ($default_tables as $table => $create_query) {
|
||||
$GLOBALS['dbi']->tryQuery($create_query);
|
||||
|
||||
if ($error = $GLOBALS['dbi']->getError()) {
|
||||
$GLOBALS['message'] = $error;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($table == 'pma__bookmark') {
|
||||
$GLOBALS['cfg']['Server']['bookmarktable'] = $table;
|
||||
} elseif ($table == 'pma__relation') {
|
||||
$GLOBALS['cfg']['Server']['relation'] = $table;
|
||||
} elseif ($table == 'pma__table_info') {
|
||||
$GLOBALS['cfg']['Server']['table_info'] = $table;
|
||||
} elseif ($table == 'pma__table_coords') {
|
||||
$GLOBALS['cfg']['Server']['table_coords'] = $table;
|
||||
} elseif ($table == 'pma__column_info') {
|
||||
$GLOBALS['cfg']['Server']['column_info'] = $table;
|
||||
} elseif ($table == 'pma__pdf_pages') {
|
||||
$GLOBALS['cfg']['Server']['pdf_pages'] = $table;
|
||||
} elseif ($table == 'pma__history') {
|
||||
$GLOBALS['cfg']['Server']['history'] = $table;
|
||||
} elseif ($table == 'pma__recent') {
|
||||
$GLOBALS['cfg']['Server']['recent'] = $table;
|
||||
} elseif ($table == 'pma__table_uiprefs') {
|
||||
$GLOBALS['cfg']['Server']['table_uiprefs'] = $table;
|
||||
} elseif ($table == 'pma__tracking') {
|
||||
$GLOBALS['cfg']['Server']['tracking'] = $table;
|
||||
} elseif ($table == 'pma__userconfig') {
|
||||
$GLOBALS['cfg']['Server']['userconfig'] = $table;
|
||||
} elseif ($table == 'pma__users') {
|
||||
$GLOBALS['cfg']['Server']['users'] = $table;
|
||||
} elseif ($table == 'pma__usergroups') {
|
||||
$GLOBALS['cfg']['Server']['usergroups'] = $table;
|
||||
} elseif ($table == 'pma__navigationhiding') {
|
||||
$GLOBALS['cfg']['Server']['navigationhiding'] = $table;
|
||||
} elseif ($table == 'pma__savedsearches') {
|
||||
$GLOBALS['cfg']['Server']['savedsearches'] = $table;
|
||||
} elseif ($table == 'pma__central_columns') {
|
||||
$GLOBALS['cfg']['Server']['central_columns'] = $table;
|
||||
} else if ($table == 'pma__designer_coords') {
|
||||
$GLOBALS['cfg']['Server']['designer_coords'] = $table;
|
||||
}
|
||||
}
|
||||
$GLOBALS['cfg']['Server']['pmadb'] = $db;
|
||||
$_SESSION['relation'][$GLOBALS['server']] = PMA_checkRelationsParam();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Html for PMA tables fixing anchor.
|
||||
*
|
||||
* @return string Html
|
||||
*/
|
||||
function PMA_getHtmlFixPMATables()
|
||||
{
|
||||
$retval = '';
|
||||
|
||||
$url_query = PMA_URL_getCommon($GLOBALS['db']);
|
||||
$url_query .= '&goto=db_operations.php&fix_pmadb=1';
|
||||
$message = PMA_Message::notice(
|
||||
__(
|
||||
'%sCreate%s the phpMyAdmin configuration storage in the '
|
||||
. 'current database.'
|
||||
)
|
||||
);
|
||||
$message->addParam(
|
||||
'<a href="' . $GLOBALS['cfg']['PmaAbsoluteUri']
|
||||
. 'chk_rel.php?' . $url_query . '">',
|
||||
false
|
||||
);
|
||||
$message->addParam('</a>', false);
|
||||
|
||||
$retval .= $message->getDisplay();
|
||||
|
||||
return $retval;
|
||||
}
|
||||
?>
|
||||
|
||||
@ -773,6 +773,8 @@ function PMA_getHtmlForBookmark($disp_mode, $cfgBookmark, $sql_query, $db, $tabl
|
||||
. '\'bkm_fields[bkm_label]\');"'
|
||||
. ' id="bookmarkQueryForm">';
|
||||
$html .= PMA_URL_getHiddenInputs();
|
||||
$html .= '<input type="hidden" name="db"'
|
||||
. ' value="' . htmlspecialchars($db) . '" />';
|
||||
$html .= '<input type="hidden" name="goto" value="' . $goto . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_database]"'
|
||||
. ' value="' . htmlspecialchars($db) . '" />';
|
||||
|
||||
@ -54,6 +54,10 @@ $error = null;
|
||||
if ($form_display->process(false) && !$form_display->hasErrors()) {
|
||||
// save settings
|
||||
$result = PMA_saveUserprefs($cf->getConfigArray());
|
||||
if (! isset($_REQUEST['ZeroConf'])) {
|
||||
$_SESSION['relation'][$GLOBALS['server']] = null;
|
||||
}
|
||||
|
||||
if ($result === true) {
|
||||
// reload config
|
||||
$GLOBALS['PMA_Config']->loadUserPreferences();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user