mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #2363 from open-sausages/pulls/4/CanOrganiseSitetree-clean-up
MINOR Clean up CMSMain::CanOrganiseSitetree
This commit is contained in:
commit
097d221150
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether 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
|
||||
*/
|
||||
|
@ -660,4 +660,22 @@ 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());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user