diff --git a/plugins/views_plugin_display.inc b/plugins/views_plugin_display.inc index fd8de19e..8fe55602 100644 --- a/plugins/views_plugin_display.inc +++ b/plugins/views_plugin_display.inc @@ -515,6 +515,7 @@ class views_plugin_display extends views_plugin { 'defaults' => array( 'default' => array( 'access' => TRUE, + 'access_options' => TRUE, 'cache' => TRUE, 'query' => TRUE, 'title' => TRUE, diff --git a/tests/views_ui.test b/tests/views_ui.test index 8a7e0e16..e00298a8 100644 --- a/tests/views_ui.test +++ b/tests/views_ui.test @@ -1037,4 +1037,73 @@ class ViewsUIWizardOverrideDisplaysTestCase extends ViewsUIWizardHelper { $this->assertText($view['page[title]']); } + /** + * Test multiple overridden page displays with different permissions. + */ + function testPageDisplaysWithDifferentPermissions() { + // Create a basic view with no displays. + $view['human_name'] = $this->randomName(16); + $view['name'] = strtolower($this->randomName(16)); + $view['page[create]'] = FALSE; + $view['block[create]'] = FALSE; + + $this->drupalPost('admin/structure/views/add', $view, t('Continue & edit')); + + // Add 4 page displays. Using different permissions for each one. + $displays = array( + 'page_1' => 'administer modules', + 'page_2' => 'administer nodes', + 'page_3' => 'access content', + 'page_4' => 'bypass node access', + ); + + foreach ($displays as $display => $permission) { + // Add a new Page, Set it permissions to 'administer modules'. + $edit = array(); + $this->drupalPost("admin/structure/views/view/{$view['name']}/edit", $edit, t('Add Page')); + + $edit = array( + 'path' => "my-path", + ); + $this->drupalPost("admin/structure/views/nojs/display/{$view['name']}/$display/path", $edit, t('Apply')); + + $edit = array( + 'override[dropdown]' => $display, + 'access_options[perm]' => $permission, + ); + $this->drupalPost("admin/structure/views/nojs/display/{$view['name']}/$display/access_options", $edit, t('Apply')); + } + + // Save all the displays. + $this->drupalPost("admin/structure/views/view/{$view['name']}/edit/page_4", array(), t('Save')); + + foreach ($displays as $display => $permission) { + $this->drupalGet("admin/structure/views/nojs/display/{$view['name']}/$display/access_options"); + // Check the permissions are the same after save all the displays. + $this->assertOptionSelected('edit-access-options-perm', $permission); + } + + // Now set page_1, page_2, and page_4 to defaults + foreach (array('page_1', 'page_2', 'page_4') as $display) { + $edit = array( + 'override[dropdown]' => 'default', + 'access_options[perm]' => 'administer nodes', + ); + $this->drupalPost("admin/structure/views/nojs/display/{$view['name']}/$display/access_options", $edit, t('Apply')); + } + + // Save all the displays + $this->drupalPost("admin/structure/views/view/{$view['name']}/edit/page_4", array(), t('Save')); + + // Finally check that only 'page_3' have a different permission assigned. + foreach (array('page_1', 'page_2', 'page_3', 'page_4') as $display) { + $this->drupalGet("admin/structure/views/nojs/display/{$view['name']}/$display/access_options"); + $permission = 'administer nodes'; + if ($display == 'page_3') { + $permission = 'access content'; + } + $this->assertOptionSelected('edit-access-options-perm', $permission); + } + } + } diff --git a/views.install b/views.install index 92c7abc1..695d3a9a 100644 --- a/views.install +++ b/views.install @@ -648,3 +648,14 @@ function views_update_7302() { db_drop_field('cache_views_data', 'headers'); } } + +/** + * Show a recommendation to the user to check the configuration of their views' + * access control settings. + * + * @see https://www.drupal.org/project/views/issues/1174588 + */ +function views_update_7303() { + return t("Previously when changing access settings on a view display it could unexpectedly change the setting on other non-overridden displays of that view.
+ This issue has now been fixed, however it is recommended that for all your views you check that the settings under 'Page settings > Access' are correct."); +}