Commit 44098bb9 authored by damiankloip's avatar damiankloip

Always use display configured path in access handler

parent 01d61ad1
......@@ -19,14 +19,17 @@ class views_plugin_access_menu extends views_plugin_access {
* In that case, we need to check access to the router path manually.
*/
function access($account) {
// Retrieve the original router path for this view, and check access to it.
// Get this based on the display property of this access plugin, not the
// view itself. The 'current display' could be set to something else, like
// default.
$path = $this->display->handler->get_option('path');
$item = menu_get_item($path);
// If we are on the original router path, the menu system has checked access already.
$item = menu_get_item();
if ($item['href'] == $_GET['q']) {
return TRUE;
}
// Retrieve the original router path for this view, and check access to it.
$path = $this->view->display_handler->get_option('path');
$item = menu_get_item($path);
return $item['access'];
}
......
......@@ -249,3 +249,39 @@ class AdminViewsPageDisplayTestCase extends AdminViewsWebTestCase {
return $view;
}
}
/**
* Tests default views.
*/
class AdminViewsAccessHandlerTestCase extends AdminViewsWebTestCase {
public static function getInfo() {
return array(
'name' => 'Access handler',
'description' => 'Tests views_plugin_access_menu handler.',
'group' => 'Administration views',
);
}
function setUp() {
parent::setUp(array('node'));
}
/**
* Tests access handler via views/ajax.
*/
function testAjaxAccess() {
$params = array(
'view_name' => 'admin_views_user',
'view_display_id' => 'system_1',
);
$response_data = $this->drupalGetAJAX('views/ajax', array('query' => $params));
$this->assertResponse(200);
// Check no views settings are returned.
$this->assertTrue(empty($response_data[0]['settings']['views']));
// The next item in the AJAX data will be the insert command containing the
// rendered view.
$this->assertTrue(empty($response_data[1]));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment