Merge pull request #1265 from tractorcow/pulls/3.2/fix-archived-actions

BUG block adding children from archived pages
This commit is contained in:
Sam Minnée 2015-08-24 17:04:46 +12:00
commit da348f74e8
2 changed files with 29 additions and 0 deletions

View File

@ -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();
}

View File

@ -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());
}
}
/**#@+