Fixed a bug where an error occurred when attempting to change the page type of 'Blog'

This commit is contained in:
Jake Bentvelzen 2015-10-14 14:00:24 +11:00
parent bb9beb3953
commit c3b0401ee5
1 changed files with 7 additions and 4 deletions

View File

@ -546,10 +546,13 @@ class Blog extends Page implements PermissionProvider {
$group = $this->getUserGroup();
foreach(array($this->Editors(), $this->Writers(), $this->Contributors()) as $levels) {
foreach($levels as $user) {
if(!$user->inGroup($group)) {
$user->Groups()->add($group);
// Must check if the method exists or else an error occurs when changing page type
if ($this->hasMethod('Editors')) {
foreach(array($this->Editors(), $this->Writers(), $this->Contributors()) as $levels) {
foreach($levels as $user) {
if(!$user->inGroup($group)) {
$user->Groups()->add($group);
}
}
}
}