MINOR Clean up CMSMain::CanOrganiseSitetree

This commit is contained in:
Maxime Rainville 2019-01-11 23:56:40 +13:00
parent 75f41b56d5
commit 3a1329f61b
2 changed files with 27 additions and 2 deletions

View File

@ -756,7 +756,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
if (!SecurityToken::inst()->checkRequest($request)) {
return $this->httpError(400);
}
if (!Permission::check('SITETREE_REORGANISE') && !Permission::check('ADMIN')) {
if (!$this->CanOrganiseSitetree()) {
return $this->httpError(
403,
_t(
@ -862,11 +862,16 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
->setBody(json_encode($statusUpdates));
}
/**
* Whatever the current member has the permission to reorganise SiteTree objects.
* @return bool
*/
public function CanOrganiseSitetree()
{
return !Permission::check('SITETREE_REORGANISE') && !Permission::check('ADMIN') ? false : true;
return Permission::check('SITETREE_REORGANISE');
}
/**
* @return boolean
*/

View File

@ -660,4 +660,24 @@ class CMSMainTest extends FunctionalTest
$searchSchema
);
}
public function testCanOrganiseSitetree()
{
$cms = CMSMain::create();
$this->assertFalse($cms->CanOrganiseSitetree());
$this->logInWithPermission('CMS_ACCESS_CMSMain');
$this->assertFalse($cms->CanOrganiseSitetree());
$this->logOut();
$this->logInWithPermission('SITETREE_REORGANISE');
$this->assertTrue($cms->CanOrganiseSitetree());
$this->logOut();
$this->logInWithPermission('ADMIN');
$this->assertTrue($cms->CanOrganiseSitetree());
}
}