Skip to content

Commit

Permalink
Only get Section if it exists
Browse files Browse the repository at this point in the history
Prevents crash when exporting user groups with locale permissions (like: "editLocale:nl_nl")
  • Loading branch information
Arjan Kleene committed Oct 19, 2015
1 parent 4ccc7d1 commit 8c544ac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions services/Schematic_UserGroupsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ private function getGroupPermissions($group, $permissions)
private function getPermissionDefinition($permission)
{
if (strpos($permission, ':') > -1) {
$source = false;
$permissionArray = explode(':', $permission);

if (strpos($permission, 'Asset') > -1) {
$source = $this->assetSourceById[$permissionArray[1]];
} else {
} elseif (isset($this->sectionsById[$permissionArray[1]])) {
$source = $this->sectionsById[$permissionArray[1]];
}

if ($source) {
$permission = $permissionArray[0].':'.$source->handle;
}
Expand Down Expand Up @@ -192,13 +194,15 @@ private function getPermissions(array $permissionDefinitions)
private function getPermission($permissionDefinition)
{
if (strpos($permissionDefinition, ':') > -1) {
$source = false;
$permissionArray = explode(':', $permissionDefinition);

if (strpos($permissionDefinition, 'Asset') > -1) {
$source = $this->assetSourceByHandle[$permissionArray[1]];
} else {
} elseif (isset($this->sectionsByHandle[$permissionArray[1]])) {
$source = $this->sectionsByHandle[$permissionArray[1]];
}

if ($source) {
$permissionDefinition = $permissionArray[0].':'.$source->id;
}
Expand Down

0 comments on commit 8c544ac

Please sign in to comment.