Skip to content

Commit

Permalink
Dev: Owners should be able to edit their participants (CPDB)
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Sep 28, 2016
1 parent a80dfae commit f88173d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion application/controllers/admin/participantsaction.php
Expand Up @@ -602,7 +602,6 @@ public function updateParticipant($aData, $extraAttributes)
ls\ajax\AjaxHelper::outputError(sprintf('Found no participant with id %s', $aData['participant_id']));
}

// Abort if no permission
if (!$participant->userHasPermissionToEdit()) {
ls\ajax\AjaxHelper::outputNoPermission();
}
Expand Down
6 changes: 6 additions & 0 deletions application/models/Participant.php
Expand Up @@ -2103,6 +2103,8 @@ public function userHasPermissionToEdit()
'participant_id' => $this->participant_id
));

$owner = $this->owner_uid == $userId;

if (Permission::model()->hasGlobalPermission('superadmin')) {
// Superadmins can do anything
return true;
Expand All @@ -2115,6 +2117,10 @@ public function userHasPermissionToEdit()
// Shared with this particular user
return true;
}
else if ($owner) {
// User owns this participant
return true;
}
else {
return false;
}
Expand Down

0 comments on commit f88173d

Please sign in to comment.