Skip to content

Commit

Permalink
Retrieve parameters from $_POST in navigation
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
  • Loading branch information
MauricioFauth authored and ibennetch committed Dec 11, 2018
1 parent 7237caf commit 5e88a88
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 52 deletions.
23 changes: 14 additions & 9 deletions js/navigation.js
Expand Up @@ -519,12 +519,13 @@ $(function () {
/** Hide navigation tree item */
$(document).on('click', 'a.hideNavItem.ajax', function (event) {
event.preventDefault();
var argSep = PMA_commonParams.get('arg_separator');
var params = $(this).getPostData();
params += argSep + 'ajax_request=true' + argSep + 'server=' + PMA_commonParams.get('server');
$.ajax({
type: 'POST',
data: {
server: PMA_commonParams.get('server'),
},
url: $(this).attr('href') + PMA_commonParams.get('arg_separator') + 'ajax_request=true',
data: params,
url: $(this).attr('href'),
success: function (data) {
if (typeof data !== 'undefined' && data.success === true) {
PMA_reloadNavigation();
Expand All @@ -539,7 +540,10 @@ $(function () {
$(document).on('click', 'a.showUnhide.ajax', function (event) {
event.preventDefault();
var $msg = PMA_ajaxShowMessage();
$.get($(this).attr('href') + PMA_commonParams.get('arg_separator') + 'ajax_request=1', function (data) {
var argSep = PMA_commonParams.get('arg_separator');
var params = $(this).getPostData();
params += argSep + 'ajax_request=true';
$.post($(this).attr('href'), params, function (data) {
if (typeof data !== 'undefined' && data.success === true) {
PMA_ajaxRemoveMessage($msg);
var buttonOptions = {};
Expand Down Expand Up @@ -570,12 +574,13 @@ $(function () {
event.preventDefault();
var $tr = $(this).parents('tr');
var $msg = PMA_ajaxShowMessage();
var argSep = PMA_commonParams.get('arg_separator');
var params = $(this).getPostData();
params += argSep + 'ajax_request=true' + argSep + 'server=' + PMA_commonParams.get('server');
$.ajax({
type: 'POST',
data: {
server: PMA_commonParams.get('server'),
},
url: $(this).attr('href') + PMA_commonParams.get('arg_separator') + 'ajax_request=true',
data: params,
url: $(this).attr('href'),
success: function (data) {
PMA_ajaxRemoveMessage($msg);
if (typeof data !== 'undefined' && data.success === true) {
Expand Down
8 changes: 4 additions & 4 deletions libraries/classes/Navigation/Navigation.php
Expand Up @@ -51,8 +51,8 @@ public function getDisplay()
}
$tree = new NavigationTree();
if (! $response->isAjax()
|| ! empty($_REQUEST['full'])
|| ! empty($_REQUEST['reload'])
|| ! empty($_POST['full'])
|| ! empty($_POST['reload'])
) {
if ($GLOBALS['cfg']['ShowDatabasesNavigationAsTree']) {
// provide database tree in navigation
Expand Down Expand Up @@ -230,8 +230,8 @@ public function getItemUnhideDialog($dbName, $itemType = null, $tableName = null

$html .= '<tr>';
$html .= '<td>' . htmlspecialchars($hiddenItem) . '</td>';
$html .= '<td style="width:80px"><a href="navigation.php'
. Url::getCommon($params) . '"'
$html .= '<td style="width:80px"><a href="navigation.php" data-post="'
. Url::getCommon($params, '') . '"'
. ' class="unhideNavItem ajax">'
. Util::getIcon('show', __('Show'))
. '</a></td>';
Expand Down
28 changes: 15 additions & 13 deletions libraries/classes/Navigation/NavigationTree.php
Expand Up @@ -93,8 +93,10 @@ class NavigationTree
public function __construct()
{
// Save the position at which we are in the database list
if (isset($_REQUEST['pos'])) {
$this->_pos = (int)$_REQUEST['pos'];
if (isset($_POST['pos'])) {
$this->_pos = (int) $_POST['pos'];
} elseif (isset($_GET['pos'])) {
$this->_pos = (int) $_GET['pos'];
}
if (!isset($this->_pos)) {
$this->_pos = $this->_getNavigationDbPos();
Expand All @@ -109,19 +111,19 @@ public function __construct()
$this->_pos3_value[0] = $_REQUEST['pos3_value'];
}
} else {
if (isset($_REQUEST['n0_aPath'])) {
if (isset($_POST['n0_aPath'])) {
$count = 0;
while (isset($_REQUEST['n' . $count . '_aPath'])) {
while (isset($_POST['n' . $count . '_aPath'])) {
$this->_aPath[$count] = $this->_parsePath(
$_REQUEST['n' . $count . '_aPath']
$_POST['n' . $count . '_aPath']
);
$index = 'n' . $count . '_pos2_';
$this->_pos2_name[$count] = $_REQUEST[$index . 'name'];
$this->_pos2_value[$count] = $_REQUEST[$index . 'value'];
$this->_pos2_name[$count] = $_POST[$index . 'name'];
$this->_pos2_value[$count] = $_POST[$index . 'value'];
$index = 'n' . $count . '_pos3_';
if (isset($_REQUEST[$index])) {
$this->_pos3_name[$count] = $_REQUEST[$index . 'name'];
$this->_pos3_value[$count] = $_REQUEST[$index . 'value'];
if (isset($_POST[$index])) {
$this->_pos3_name[$count] = $_POST[$index . 'name'];
$this->_pos3_value[$count] = $_POST[$index . 'value'];
}
$count++;
}
Expand All @@ -130,11 +132,11 @@ public function __construct()
if (isset($_REQUEST['vPath'])) {
$this->_vPath[0] = $this->_parsePath($_REQUEST['vPath']);
} else {
if (isset($_REQUEST['n0_vPath'])) {
if (isset($_POST['n0_vPath'])) {
$count = 0;
while (isset($_REQUEST['n' . $count . '_vPath'])) {
while (isset($_POST['n' . $count . '_vPath'])) {
$this->_vPath[$count] = $this->_parsePath(
$_REQUEST['n' . $count . '_vPath']
$_POST['n' . $count . '_vPath']
);
$count++;
}
Expand Down
4 changes: 2 additions & 2 deletions libraries/classes/Navigation/Nodes/NodeDatabase.php
Expand Up @@ -677,8 +677,8 @@ public function getHtmlForControlButtons()
'dbName' => $this->real_name,
);
$ret = '<span class="dbItemControls">'
. '<a href="navigation.php'
. Url::getCommon($params) . '"'
. '<a href="navigation.php" data-post="'
. Url::getCommon($params, '') . '"'
. ' class="showUnhide ajax">'
. Util::getImage(
'show',
Expand Down
4 changes: 2 additions & 2 deletions libraries/classes/Navigation/Nodes/NodeDatabaseChild.php
Expand Up @@ -48,8 +48,8 @@ public function getHtmlForControlButtons()
);

$ret = '<span class="navItemControls">'
. '<a href="navigation.php'
. Url::getCommon($params) . '"'
. '<a href="navigation.php" data-post="'
. Url::getCommon($params, '') . '"'
. ' class="hideNavItem ajax">'
. Util::getImage('hide', __('Hide'))
. '</a></span>';
Expand Down
40 changes: 20 additions & 20 deletions navigation.php
Expand Up @@ -26,49 +26,49 @@
exit;
}

if (isset($_REQUEST['getNaviSettings']) && $_REQUEST['getNaviSettings']) {
if (isset($_POST['getNaviSettings']) && $_POST['getNaviSettings']) {
$response->addJSON('message', PageSettings::getNaviSettings());
exit();
}

$relation = new Relation();
$cfgRelation = $relation->getRelationsParam();
if ($cfgRelation['navwork']) {
if (isset($_REQUEST['hideNavItem'])) {
if (! empty($_REQUEST['itemName'])
&& ! empty($_REQUEST['itemType'])
&& ! empty($_REQUEST['dbName'])
if (isset($_POST['hideNavItem'])) {
if (! empty($_POST['itemName'])
&& ! empty($_POST['itemType'])
&& ! empty($_POST['dbName'])
) {
$navigation->hideNavigationItem(
$_REQUEST['itemName'],
$_REQUEST['itemType'],
$_REQUEST['dbName'],
(! empty($_REQUEST['tableName']) ? $_REQUEST['tableName'] : null)
$_POST['itemName'],
$_POST['itemType'],
$_POST['dbName'],
(! empty($_POST['tableName']) ? $_POST['tableName'] : null)
);
}
exit;
}

if (isset($_REQUEST['unhideNavItem'])) {
if (! empty($_REQUEST['itemName'])
&& ! empty($_REQUEST['itemType'])
&& ! empty($_REQUEST['dbName'])
if (isset($_POST['unhideNavItem'])) {
if (! empty($_POST['itemName'])
&& ! empty($_POST['itemType'])
&& ! empty($_POST['dbName'])
) {
$navigation->unhideNavigationItem(
$_REQUEST['itemName'],
$_REQUEST['itemType'],
$_REQUEST['dbName'],
(! empty($_REQUEST['tableName']) ? $_REQUEST['tableName'] : null)
$_POST['itemName'],
$_POST['itemType'],
$_POST['dbName'],
(! empty($_POST['tableName']) ? $_POST['tableName'] : null)
);
}
exit;
}

if (isset($_REQUEST['showUnhideDialog'])) {
if (! empty($_REQUEST['dbName'])) {
if (isset($_POST['showUnhideDialog'])) {
if (! empty($_POST['dbName'])) {
$response->addJSON(
'message',
$navigation->getItemUnhideDialog($_REQUEST['dbName'])
$navigation->getItemUnhideDialog($_POST['dbName'])
);
}
exit;
Expand Down
2 changes: 1 addition & 1 deletion test/classes/Navigation/NavigationTest.php
Expand Up @@ -151,7 +151,7 @@ public function testGetItemUnhideDialog()
$html
);
$this->assertContains(
'<a href="navigation.php?'
'<a href="navigation.php" data-post="'
. 'unhideNavItem=1&amp;itemType=table&amp;'
. 'itemName=tableName&amp;dbName=db&amp;lang=en"'
. ' class="unhideNavItem ajax">',
Expand Down
2 changes: 1 addition & 1 deletion test/classes/Navigation/Nodes/NodeDatabaseChildTest.php
Expand Up @@ -78,7 +78,7 @@ public function testGetHtmlForControlButtons()
$html
);
$this->assertContains(
'<a href="navigation.php?'
'<a href="navigation.php" data-post="'
. 'hideNavItem=1&amp;itemType=itemType&amp;itemName=child'
. '&amp;dbName=parent&amp;lang=en" class="hideNavItem ajax">',
$html
Expand Down

0 comments on commit 5e88a88

Please sign in to comment.