Merge pull request #369 from creative-commoners/pulls/2.0/fix-edit-check

FIX Do no provide input for canEdit or canPublish if no subsites exist
This commit is contained in:
Dylan Wagstaff 2018-06-19 17:04:15 +12:00 committed by GitHub
commit f19b82f029
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -273,8 +273,10 @@ class SiteTreeSubsites extends DataExtension
* - Is in a group which has access to the subsite this page belongs to
* - Is in a group with edit permissions on the "main site"
*
* @param null $member
* @return bool
* If there are no subsites configured yet, this logic is skipped.
*
* @param Member|null $member
* @return bool|null
*/
public function canEdit($member = null)
{
@ -282,6 +284,11 @@ class SiteTreeSubsites extends DataExtension
$member = Security::getCurrentUser();
}
// Do not provide any input if there are no subsites configured
if (!Subsite::get()->count()) {
return null;
}
// Find the sites that this user has access to
$goodSites = Subsite::accessible_sites('CMS_ACCESS_CMSMain', true, 'all', $member)->column('ID');
@ -329,8 +336,8 @@ class SiteTreeSubsites extends DataExtension
}
/**
* @param null $member
* @return bool
* @param Member|null $member
* @return bool|null
*/
public function canPublish($member = null)
{