mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1265 from tractorcow/pulls/3.2/fix-archived-actions
BUG block adding children from archived pages
This commit is contained in:
commit
da348f74e8
@ -862,6 +862,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
* @return bool True if the current user can add children
|
||||
*/
|
||||
public function canAddChildren($member = null) {
|
||||
// Disable adding children to archived pages
|
||||
if($this->getIsDeletedFromStage()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$member || !(is_a($member, 'Member')) || is_numeric($member)) {
|
||||
$member = Member::currentUserID();
|
||||
}
|
||||
|
@ -1148,6 +1148,30 @@ class SiteTreeTest extends SapphireTest {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test archived page behaviour
|
||||
*/
|
||||
public function testArchivedPages() {
|
||||
$this->logInWithPermission('ADMIN');
|
||||
|
||||
$page = $this->objFromFixture('Page', 'home');
|
||||
$this->assertTrue($page->canAddChildren());
|
||||
$this->assertFalse($page->getIsDeletedFromStage());
|
||||
$this->assertFalse($page->isPublished());
|
||||
|
||||
// Publish
|
||||
$page->doPublish();
|
||||
$this->assertTrue($page->canAddChildren());
|
||||
$this->assertFalse($page->getIsDeletedFromStage());
|
||||
$this->assertTrue($page->isPublished());
|
||||
|
||||
// Archive
|
||||
$page->doArchive();
|
||||
$this->assertFalse($page->canAddChildren());
|
||||
$this->assertTrue($page->getIsDeletedFromStage());
|
||||
$this->assertFalse($page->isPublished());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**#@+
|
||||
|
Loading…
Reference in New Issue
Block a user