Skip to content

Commit

Permalink
Change export order to help prevent user group permissions from being…
Browse files Browse the repository at this point in the history
… null.
  • Loading branch information
spAnser committed Feb 27, 2017
1 parent 30ac939 commit 7b93521
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions thearchitect/services/TheArchitectService.php
Original file line number Diff line number Diff line change
Expand Up @@ -698,12 +698,20 @@ public function exportConstruct($post, $includeID = false)
{
list($sections, $entryTypes) = $this->sectionExport($post, $includeID);
list($groups, $fields) = $this->fieldExport($post, $includeID);

$sources = $this->assetSourceExport($post, $includeID);
$transforms = $this->transformExport($post, $includeID);
$globals = $this->globalSetExport($post, $includeID);
$categories = $this->categoryGroupExport($post, $includeID);
$routes = $this->routeExport($post, $includeID);
$tags = $this->tagExport($post, $includeID);

// Get user groups info before uses. This seems to fix an issue with stripGroupPermissions. Where asking for userGroupPermissions returns null.
if (craft()->getEdition() == Craft::Pro) {
$userGroups = $this->userGroupsExport($post, $includeID);
} else {
$userGroups = null;
}
$users = $this->usersExport($post, $includeID);

// Add all Arrays into the final output array
Expand All @@ -719,16 +727,10 @@ public function exportConstruct($post, $includeID = false)
'routes' => $routes,
'tags' => $tags,
'users' => $users,
'userGroups' => (is_array($userGroups)) ? $userGroups[0] : null,
'userGroupPermissions' => (is_array($userGroups)) ? $userGroups[1] : null,
];

if (craft()->getEdition() == Craft::Pro) {
$userGroups = $this->userGroupsExport($post, $includeID);
if (is_array($userGroups)) {
$output['userGroups'] = $userGroups[0];
$output['userGroupPermissions'] = $userGroups[1];
}
}

// Remove empty sections from the output array
foreach ($output as $key => $value) {
if ($value == []) {
Expand Down

0 comments on commit 7b93521

Please sign in to comment.