mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
BUGFIX: Change the default setting to include the main site. Users able to AccessAllSites should be able to access
the main site as well.
This commit is contained in:
parent
f0e93b1b3c
commit
fb998aec87
@ -408,7 +408,7 @@ JS;
|
||||
* @param $includeMainSite If true, the main site will be included if appropriate.
|
||||
* @param $mainSiteTitle The label to give to the main site
|
||||
*/
|
||||
function accessible_sites($permCode, $includeMainSite = false, $mainSiteTitle = "Main site", $member = null) {
|
||||
function accessible_sites($permCode, $includeMainSite = true, $mainSiteTitle = "Main site", $member = null) {
|
||||
// Rationalise member arguments
|
||||
if(!$member) $member = Member::currentUser();
|
||||
if(!$member) return new DataObjectSet();
|
||||
|
43
tests/SubsiteAdminFunctionalTest.php
Normal file
43
tests/SubsiteAdminFunctionalTest.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
class SubsiteAdminFunctionalTest extends FunctionalTest {
|
||||
static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
||||
static $use_draft_site = true;
|
||||
|
||||
protected $autoFollowRedirection = false;
|
||||
|
||||
/**
|
||||
* Admin should be able to access all subsites and the main site
|
||||
*/
|
||||
function testAdminCanAccessAllSubsites() {
|
||||
$member = $this->objFromFixture('Member', 'admin');
|
||||
Session::set("loggedInAs", $member->ID);
|
||||
|
||||
$this->get('admin/changesubsite?SubsiteID=0&ajax=1');
|
||||
$this->get('admin');
|
||||
$this->assertEquals(Subsite::currentSubsiteID(), '0', 'Can access main site');
|
||||
|
||||
$mainSubsite = $this->objFromFixture('Subsite_Template', 'main');
|
||||
$this->get("admin/changesubsite?SubsiteID={$mainSubsite->ID}&ajax=1");
|
||||
$this->get('admin');
|
||||
$this->assertEquals(Subsite::currentSubsiteID(), $mainSubsite->ID, 'Can access the subsite');
|
||||
}
|
||||
|
||||
/**
|
||||
* User which has AccessAllSubsites set to 1 should be able to access all subsites and main site,
|
||||
* even though he does not have the ADMIN permission.
|
||||
*/
|
||||
function testEditorCanAccessAllSubsites() {
|
||||
$member = $this->objFromFixture('Member', 'editor');
|
||||
Session::set("loggedInAs", $member->ID);
|
||||
|
||||
$this->get('admin/changesubsite?SubsiteID=0&ajax=1');
|
||||
$this->get('admin');
|
||||
$this->assertEquals(Subsite::currentSubsiteID(), '0', 'Can access main site');
|
||||
|
||||
$mainSubsite = $this->objFromFixture('Subsite_Template', 'main');
|
||||
$this->get("admin/changesubsite?SubsiteID={$mainSubsite->ID}&ajax=1");
|
||||
$this->get('admin');
|
||||
$this->assertEquals(Subsite::currentSubsiteID(), $mainSubsite->ID, 'Can access the subsite');
|
||||
}
|
||||
}
|
@ -112,4 +112,4 @@ class SubsiteAdminTest extends SapphireTest {
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@ -39,6 +39,9 @@ SubsiteDomain:
|
||||
IsPrimary: 1
|
||||
|
||||
SiteTree:
|
||||
mainSubsitePage:
|
||||
Title: MainSubsitePage
|
||||
SubsiteID: 0
|
||||
home:
|
||||
Title: Home
|
||||
SubsiteID: =>Subsite_Template.main
|
||||
@ -77,6 +80,10 @@ Group:
|
||||
Title: Admin
|
||||
Code: admin
|
||||
AccessAllSubsites: 1
|
||||
editor:
|
||||
Title: Editor
|
||||
Code: editor
|
||||
AccessAllSubsites: 1
|
||||
subsite1_group:
|
||||
Title: subsite1_group
|
||||
Code: subsite1_group
|
||||
@ -91,6 +98,15 @@ Permission:
|
||||
admin:
|
||||
Code: ADMIN
|
||||
GroupID: =>Group.admin
|
||||
editor1:
|
||||
Code: CMS_ACCESS_CMSMain
|
||||
GroupID: =>Group.editor
|
||||
editor2:
|
||||
Code: SITETREE_VIEW_ALL
|
||||
GroupID: =>Group.editor
|
||||
editor3:
|
||||
Code: VIEW_DRAFT_CONTENT
|
||||
GroupID: =>Group.editor
|
||||
accesscmsmain1:
|
||||
Code: CMS_ACCESS_CMSMain
|
||||
GroupID: =>Group.subsite1_group
|
||||
@ -111,9 +127,15 @@ Member:
|
||||
Email: admin@test.com
|
||||
Password: rangi
|
||||
Groups: =>Group.admin
|
||||
editor:
|
||||
FirstName: Editor
|
||||
Surname: User
|
||||
Email: editor@test.com
|
||||
Password: rangi
|
||||
Groups: =>Group.editor
|
||||
subsite1member:
|
||||
Email: subsite1member@test.com
|
||||
Groups: =>Group.subsite1_group
|
||||
subsite2member:
|
||||
Email: subsite2member@test.com
|
||||
Groups: =>Group.subsite2_group
|
||||
Groups: =>Group.subsite2_group
|
||||
|
Loading…
Reference in New Issue
Block a user