Merge branch 'master' of ssh://git.autonomic.zone:2222/autonomic-cooperative/opencase
This commit is contained in:
@ -156,11 +156,14 @@ function _opencase_cases_redirect_to_home($form, &$form_state) {
|
||||
|
||||
// Upon deletion of an activity, go to the related case if there is one, otherwise to its target.
|
||||
function _opencase_cases_delete_activity_redirect($form, &$form_state) {
|
||||
if (!IsEmpty($form_state->getFormObject()->getEntity()->oc_case)) {
|
||||
$case_id = $form_state->getFormObject()->getEntity()->oc_case->target_id;
|
||||
$entity = $form_state->getFormObject()->getEntity();
|
||||
// for some reason this fires when deleting an activity type, shouldn't do but.s
|
||||
if ($entity instanceof \Drupal\opencase_entities\Entity\OCActivityType) return;
|
||||
if (!IsEmpty($entity->oc_case)) {
|
||||
$case_id = $entity->oc_case->target_id;
|
||||
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_id]);
|
||||
} else {
|
||||
$target_actor_id = $form_state->getFormObject()->getEntity()->oc_target->target_id;
|
||||
$target_actor_id = $entity->oc_target->target_id;
|
||||
$form_state->setRedirect('entity.oc_actor.canonical', ['oc_actor' => $target_actor_id]);
|
||||
}
|
||||
}
|
||||
|
@ -25,12 +25,12 @@ class OCActivityAccessControlHandler extends EntityAccessControlHandler {
|
||||
return AccessResult::allowedIfHasPermission($account, 'view unpublished activity entities');
|
||||
}
|
||||
return AccessResult::allowedIf(
|
||||
$account->hasPermission('view published case entities') // activity permissions are inherited from case
|
||||
$account->hasPermission('view published activity entities')
|
||||
|| $entity->getOwner()->id() == $account->id()
|
||||
);
|
||||
case 'update': // allowed only if a) they can see the case the activity is on and b) they can edit activities
|
||||
return AccessResult::allowedIf(
|
||||
$account->hasPermission('edit activity entities') // activity permissions are inherited from case
|
||||
$account->hasPermission('edit activity entities')
|
||||
|| $entity->getOwner()->id() == $account->id()
|
||||
);
|
||||
case 'delete': // allowed only if a) they can see the case the activity is on and b) they can delete activities
|
||||
|
Reference in New Issue
Block a user