ProjectPermissionController: make sure groups don't exist before creating them

Adding logic to check for a group by external ID, before trying to create it.
This commit is contained in:
Dj Padzensky 2016-07-19 19:16:07 -07:00
parent d9d3788222
commit 57f66cc855
1 changed files with 7 additions and 1 deletions

View File

@ -147,7 +147,13 @@ class ProjectPermissionController extends BaseController
$values = $this->request->getValues();
if (empty($values['group_id']) && ! empty($values['external_id'])) {
$values['group_id'] = $this->groupModel->create($values['name'], $values['external_id']);
$group = $this->groupModel->getByExternalId($values['external_id']);
if ($group) {
$values['group_id'] = $group['id'];
}
else {
$values['group_id'] = $this->groupModel->create($values['name'], $values['external_id']);
}
}
if ($this->projectGroupRoleModel->addGroup($project['id'], $values['group_id'], $values['role'])) {