Merge branch '2.7' into 2

This commit is contained in:
Guy Sartorelli 2022-12-19 03:00:28 +00:00
commit 6770dedc2a
No known key found for this signature in database
GPG Key ID: F313E3B9504D496A
7 changed files with 99 additions and 10 deletions

View File

@ -34,9 +34,6 @@
}
},
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
},
"expose": [
"client/javascript",
"client/css"
@ -44,4 +41,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}

View File

@ -53,11 +53,12 @@ eo:
one: 'Unu subreteja domajno'
other: '{count} subretejaj domajnoj'
PROTOCOL_AUTOMATIC: Aŭtomata
PROTOCOL_DESCRIPTION: 'Marki ĉi tion kiel la aprioran domajnon por ĉi tiu subretejo'
PROTOCOL_DESCRIPTION: 'Kiam generante ligilojn al ĉi tiu subretejo, uzu la elektitan protokolon.'
PROTOCOL_HTTP: 'http://'
PROTOCOL_HTTPS: 'https://'
Protocol: Protokolo
SINGULARNAME: 'Subreteja domajno'
ISPRIMARY_DESCRIPTION: 'Marki ĉi tion kiel la aprioran domajnon por ĉi tiu subretejo'
SilverStripe\Subsites\Pages\SubsitesVirtualPage:
DESCRIPTION: 'Vidigas la enhavon de paĝo en alia subretejo'
OverrideNote: 'Anstataŭigas hereditan valoron el la fonto'

View File

@ -53,11 +53,12 @@ nl:
one: 'Een subsite domein'
other: '{count} subsite domeinen'
PROTOCOL_AUTOMATIC: Automatisch
PROTOCOL_DESCRIPTION: 'Markeer als standaard domein voor deze subsite'
PROTOCOL_DESCRIPTION: 'Wordt gebruikt bij het genereren van links naar deze subsite. <br />''Automatisch'' houdt in dat het huidige protocol gebruikt zal worden.'
PROTOCOL_HTTP: 'http://'
PROTOCOL_HTTPS: 'https://'
Protocol: Protocol
SINGULARNAME: 'Subsite Domein'
ISPRIMARY_DESCRIPTION: 'Dit is de standaard domeinnaam voor deze subsite'
SilverStripe\Subsites\Pages\SubsitesVirtualPage:
DESCRIPTION: 'Toon de inhoud van een pagina op een andere subsite'
OverrideNote: 'Overschrijft de overgenomen tekst van de gelinkte pagina'

View File

@ -116,9 +116,9 @@ class FileSubsites extends DataExtension
}
// Check the CMS_ACCESS_SecurityAdmin privileges on the subsite that owns this group
$subsiteID = SubsiteState::singleton()->getSubsiteId();
if ($subsiteID && $subsiteID == $this->owner->SubsiteID) {
return true;
$currentSubsiteID = SubsiteState::singleton()->getSubsiteId();
if ($currentSubsiteID && $currentSubsiteID !== $this->owner->SubsiteID) {
return false;
}
return SubsiteState::singleton()->withState(function (SubsiteState $newState) use ($member) {

View File

@ -30,6 +30,7 @@ use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\Subsites\Service\ThemeResolver;
use SilverStripe\Subsites\State\SubsiteState;
use SilverStripe\View\SSViewer;
use SilverStripe\VersionedAdmin\Controllers\HistoryViewerController;
/**
* Extension for the SiteTree object to add subsites support
@ -118,10 +119,12 @@ class SiteTreeSubsites extends DataExtension
$subsitesMap = new Map(ArrayList::create());
}
$viewingPageHistory = Controller::has_curr() && Controller::curr() instanceof HistoryViewerController;
// Master page edit field (only allowed from default subsite to avoid inconsistent relationships)
$isDefaultSubsite = $this->owner->SubsiteID == 0 || $this->owner->Subsite()->DefaultSite;
if ($isDefaultSubsite && $subsitesMap->count()) {
if ($isDefaultSubsite && $subsitesMap->count() && !$viewingPageHistory) {
$fields->addFieldToTab(
'Root.Main',
ToggleCompositeField::create(

View File

@ -8,6 +8,7 @@ use SilverStripe\Core\Config\Config;
use SilverStripe\Forms\FieldList;
use SilverStripe\Subsites\Extensions\FileSubsites;
use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\Security\Member;
class FileSubsitesTest extends BaseSubsiteTest
{
@ -65,4 +66,64 @@ class FileSubsitesTest extends BaseSubsiteTest
$file->onAfterUpload();
$this->assertEquals($folder->SubsiteID, $file->SubsiteID);
}
/**
* @dataProvider provideTestCanEdit
*/
public function testCanEdit(
string $fileKey,
string $memberKey,
string $currentSubsiteKey,
bool $expected
): void {
$file = $this->objFromFixture(File::class, $fileKey);
$subsiteID = ($currentSubsiteKey === 'mainsite')
? 0 : $this->objFromFixture(Subsite::class, $currentSubsiteKey)->ID;
$member = $this->objFromFixture(Member::class, $memberKey);
Subsite::changeSubsite($subsiteID);
$this->assertSame($expected, $file->canEdit($member));
}
public function provideTestCanEdit(): array
{
$ret = [];
$data = [
// file
'subsite1file' => [
// member - has permissions to edit the file
'filetestyes' => [
// current subite => expected canEdit()
'subsite1' => true,
'subsite2' => false,
'mainsite' => true
],
// member - does not have permissions to edit the file
'filetestno' => [
'subsite1' => false,
'subsite2' => false,
'mainsite' => false
],
],
'mainsitefile' => [
'filetestyes' => [
'subsite1' => true,
'subsite2' => true,
'mainsite' => true
],
'filetestno' => [
'subsite1' => false,
'subsite2' => false,
'mainsite' => false
],
]
];
foreach (array_keys($data) as $fileKey) {
foreach (array_keys($data[$fileKey]) as $memberKey) {
foreach ($data[$fileKey][$memberKey] as $currentSubsiteKey => $expected) {
$ret[] = [$fileKey, $memberKey, $currentSubsiteKey, $expected];
}
}
}
return $ret;
}
}

View File

@ -172,6 +172,10 @@ SilverStripe\Security\Group:
Code: subsite1_group_via_role
AccessAllSubsites: 1
Roles: =>SilverStripe\Security\PermissionRole.role1
filetest:
Title: filetest
Code: filetest
AccessAllSubsites: 1
SilverStripe\Security\Permission:
admin:
Code: ADMIN
@ -206,6 +210,9 @@ SilverStripe\Security\Permission:
adminsubsite1:
Code: ADMIN
GroupID: =>SilverStripe\Security\Group.subsite1admins
filetest:
Code: CMS_ACCESS_CMSMain
GroupID: =>SilverStripe\Security\Group.filetest
SilverStripe\Security\Member:
admin:
@ -235,7 +242,26 @@ SilverStripe\Security\Member:
subsite1member2:
Email: subsite1member2@test.com
Groups: =>SilverStripe\Security\Group.subsite1_group_via_role
filetestyes:
Email: filetestyes@test.com
Groups: =>SilverStripe\Security\Group.filetest
filetestno:
Email: filetestno@test.com
SilverStripe\SiteConfig\SiteConfig:
config:
CanCreateTopLevelType: LoggedInUsers
SilverStripe\Assets\File:
subsite1file:
Name: subsitefile.pdf
Title: subsitefile
SubsiteID: =>SilverStripe\Subsites\Model\Subsite.subsite1
CanEditType: OnlyTheseUsers
EditorGroups: =>SilverStripe\Security\Group.filetest
mainsitefile:
Name: mainsitefile.pdf
Title: mainsitefile
SubsiteID: 0
CanEditType: OnlyTheseUsers
EditorGroups: =>SilverStripe\Security\Group.filetest