Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
9803ef4890
@ -73,6 +73,31 @@ $is_count = isset($analyzed_sql[0]['queryflags']['is_count']);
|
||||
// check for a real SELECT ... FROM
|
||||
$is_select = isset($analyzed_sql[0]['queryflags']['select_from']);
|
||||
|
||||
// checks whether the sorting order should be remembered
|
||||
if ($GLOBALS['cfg']['RememberSorting']
|
||||
&& ! ($is_count || $is_export || $is_func || $is_analyse)
|
||||
&& isset($analyzed_sql[0]['select_expr'])
|
||||
&& (count($analyzed_sql[0]['select_expr']) == 0)
|
||||
&& isset($analyzed_sql[0]['queryflags']['select_from'])
|
||||
&& count($analyzed_sql[0]['table_ref']) == 1
|
||||
) {
|
||||
$is_remember_sorting_order = true;
|
||||
} else {
|
||||
$is_remember_sorting_order = false;
|
||||
}
|
||||
|
||||
// checks whether a LIMIT clause should be added to the query
|
||||
if (($_SESSION['tmp_user_values']['max_rows'] != 'all')
|
||||
&& ! ($is_count || $is_export || $is_func || $is_analyse)
|
||||
&& isset($analyzed_sql[0]['queryflags']['select_from'])
|
||||
&& ! isset($analyzed_sql[0]['queryflags']['offset'])
|
||||
&& empty($analyzed_sql[0]['limit_clause'])
|
||||
) {
|
||||
$is_append_limit_clause = true;
|
||||
} else {
|
||||
$is_append_limit_clause = false;
|
||||
}
|
||||
|
||||
// If the query is a Select, extract the db and table names and modify
|
||||
// $db and $table, to have correct page headers, links and left frame.
|
||||
// db and table name may be enclosed with backquotes, db is optionnal,
|
||||
|
||||
@ -648,4 +648,56 @@ function PMA_getHtmlForOptionsList($values, $selected_values)
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTML for the Bookmark form
|
||||
*
|
||||
* @param string $db the current database
|
||||
* @param string $goto goto page url
|
||||
* @param string $bkm_sql_query the query to be bookmarked
|
||||
* @param string $bkm_user the user creating the bookmark
|
||||
*/
|
||||
function PMA_getHtmlForBookmark($db, $goto, $bkm_sql_query, $bkm_user)
|
||||
{
|
||||
$html = '<form action="sql.php" method="post"'
|
||||
. ' onsubmit="return ! emptyFormElements(this, \'bkm_fields[bkm_label]\');"'
|
||||
. ' id="bookmarkQueryForm">';
|
||||
$html .= PMA_generate_common_hidden_inputs();
|
||||
$html .= '<input type="hidden" name="goto" value="' . $goto . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_database]"'
|
||||
. ' value="' . htmlspecialchars($db) . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_user]"'
|
||||
. ' value="' . $bkm_user . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_sql_query]"' . ' value="'
|
||||
. $bkm_sql_query
|
||||
. '" />';
|
||||
$html .= '<fieldset>';
|
||||
$html .= '<legend>';
|
||||
$html .= PMA_Util::getIcon(
|
||||
'b_bookmark.png', __('Bookmark this SQL query'), true
|
||||
);
|
||||
$html .= '</legend>';
|
||||
$html .= '<div class="formelement">';
|
||||
$html .= '<label for="fields_label_">' . __('Label:') . '</label>';
|
||||
$html .= '<input type="text" id="fields_label_"'
|
||||
. ' name="bkm_fields[bkm_label]" value="" />';
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="formelement">';
|
||||
$html .= '<input type="checkbox" name="bkm_all_users"'
|
||||
. ' id="bkm_all_users" value="true" />';
|
||||
$html .= '<label for="bkm_all_users">'
|
||||
. __('Let every user access this bookmark')
|
||||
. '</label>';
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="clearfloat"></div>';
|
||||
$html .= '</fieldset>';
|
||||
$html .= '<fieldset class="tblFooters">';
|
||||
$html .= '<input type="hidden" name="store_bkm" value="1" />';
|
||||
$html .= '<input type="submit"'
|
||||
. ' value="' . __('Bookmark this SQL query') . '" />';
|
||||
$html .= '</fieldset>';
|
||||
$html .= '</form>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
?>
|
||||
|
||||
80
sql.php
80
sql.php
@ -313,24 +313,13 @@ if (isset($_REQUEST['btnDrop']) && $_REQUEST['btnDrop'] == __('No')) {
|
||||
$full_sql_query = $sql_query;
|
||||
|
||||
// Handle remembered sorting order, only for single table query
|
||||
if ($GLOBALS['cfg']['RememberSorting']
|
||||
&& ! ($is_count || $is_export || $is_func || $is_analyse)
|
||||
&& isset($analyzed_sql[0]['select_expr'])
|
||||
&& (count($analyzed_sql[0]['select_expr']) == 0)
|
||||
&& isset($analyzed_sql[0]['queryflags']['select_from'])
|
||||
&& count($analyzed_sql[0]['table_ref']) == 1
|
||||
) {
|
||||
if ($is_remember_sorting_order) {
|
||||
PMA_handleSortOrder($db, $table, $analyzed_sql, $full_sql_query);
|
||||
}
|
||||
|
||||
$sql_limit_to_append = '';
|
||||
// Do append a "LIMIT" clause?
|
||||
if (($_SESSION['tmp_user_values']['max_rows'] != 'all')
|
||||
&& ! ($is_count || $is_export || $is_func || $is_analyse)
|
||||
&& isset($analyzed_sql[0]['queryflags']['select_from'])
|
||||
&& ! isset($analyzed_sql[0]['queryflags']['offset'])
|
||||
&& empty($analyzed_sql[0]['limit_clause'])
|
||||
) {
|
||||
if ($is_append_limit_clause) {
|
||||
$sql_limit_to_append = ' LIMIT ' . $_SESSION['tmp_user_values']['pos']
|
||||
. ', ' . $_SESSION['tmp_user_values']['max_rows'] . " ";
|
||||
$full_sql_query = PMA_getSqlWithLimitClause(
|
||||
@ -360,7 +349,14 @@ if (($_SESSION['tmp_user_values']['max_rows'] != 'all')
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen($db)) {
|
||||
if (strlen($db)) {
|
||||
// Checks if the current database has changed
|
||||
// This could happen if the user sends a query like "USE `database`;"
|
||||
$current_db = $GLOBALS['dbi']->fetchValue('SELECT DATABASE()');
|
||||
if ($db !== $current_db) {
|
||||
$reload = 1;
|
||||
}
|
||||
unset($current_db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
}
|
||||
|
||||
@ -481,21 +477,6 @@ if (isset($GLOBALS['show_as_php']) || ! empty($GLOBALS['validatequery'])) {
|
||||
$profiling_results = $GLOBALS['dbi']->fetchResult('SHOW PROFILE;');
|
||||
}
|
||||
|
||||
// Checks if the current database has changed
|
||||
// This could happen if the user sends a query like "USE `database`;"
|
||||
/**
|
||||
* commented out auto-switching to active database - really required?
|
||||
* bug #2558 win: table list disappears (mixed case db names)
|
||||
* https://sourceforge.net/p/phpmyadmin/bugs/2558/
|
||||
* @todo RELEASE test and comit or rollback before release
|
||||
$current_db = $GLOBALS['dbi']->fetchValue('SELECT DATABASE()');
|
||||
if ($db !== $current_db) {
|
||||
$db = $current_db;
|
||||
$reload = 1;
|
||||
}
|
||||
unset($current_db);
|
||||
*/
|
||||
|
||||
// tmpfile remove after convert encoding appended by Y.Kawada
|
||||
if (function_exists('PMA_Kanji_fileConv')
|
||||
&& (isset($textfile) && file_exists($textfile))
|
||||
@ -1018,45 +999,10 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
|
||||
. PMA_generate_common_url($db, $table)
|
||||
. '&sql_query=' . urlencode($sql_query)
|
||||
. '&id_bookmark=1';
|
||||
|
||||
$html_output .= '<form action="sql.php" method="post"'
|
||||
. ' onsubmit="return ! emptyFormElements(this, \'bkm_fields[bkm_label]\');"'
|
||||
. ' id="bookmarkQueryForm">';
|
||||
$html_output .= PMA_generate_common_hidden_inputs();
|
||||
$html_output .= '<input type="hidden" name="goto" value="' . $goto . '" />';
|
||||
$html_output .= '<input type="hidden" name="bkm_fields[bkm_database]"'
|
||||
. ' value="' . htmlspecialchars($db) . '" />';
|
||||
$html_output .= '<input type="hidden" name="bkm_fields[bkm_user]"'
|
||||
. ' value="' . $cfg['Bookmark']['user'] . '" />';
|
||||
$html_output .= '<input type="hidden" name="bkm_fields[bkm_sql_query]"' . ' value="'
|
||||
. urlencode(isset($complete_query) ? $complete_query : $sql_query)
|
||||
. '" />';
|
||||
$html_output .= '<fieldset>';
|
||||
$html_output .= '<legend>';
|
||||
$html_output .= PMA_Util::getIcon(
|
||||
'b_bookmark.png', __('Bookmark this SQL query'), true
|
||||
$bkm_sql_query = urlencode(
|
||||
isset($complete_query) ? $complete_query : $sql_query
|
||||
);
|
||||
$html_output .= '</legend>';
|
||||
$html_output .= '<div class="formelement">';
|
||||
$html_output .= '<label for="fields_label_">' . __('Label:') . '</label>';
|
||||
$html_output .= '<input type="text" id="fields_label_"'
|
||||
. ' name="bkm_fields[bkm_label]" value="" />';
|
||||
$html_output .= '</div>';
|
||||
$html_output .= '<div class="formelement">';
|
||||
$html_output .= '<input type="checkbox" name="bkm_all_users"'
|
||||
. ' id="bkm_all_users" value="true" />';
|
||||
$html_output .= '<label for="bkm_all_users">'
|
||||
. __('Let every user access this bookmark')
|
||||
. '</label>';
|
||||
$html_output .= '</div>';
|
||||
$html_output .= '<div class="clearfloat"></div>';
|
||||
$html_output .= '</fieldset>';
|
||||
$html_output .= '<fieldset class="tblFooters">';
|
||||
$html_output .= '<input type="hidden" name="store_bkm" value="1" />';
|
||||
$html_output .= '<input type="submit"'
|
||||
. ' value="' . __('Bookmark this SQL query') . '" />';
|
||||
$html_output .= '</fieldset>';
|
||||
$html_output .= '</form>';
|
||||
$html_output .= PMA_getHtmlForBookmark($db, $goto, $bkm_sql_query, $cfg['Bookmark']['user']);
|
||||
} // end bookmark support
|
||||
|
||||
// Do print the page if required
|
||||
|
||||
Loading…
Reference in New Issue
Block a user