Skip to content
Snippets Groups Projects

Issue #3307886: Transition form prevents custom access control

1 file
+ 1
19
Compare changes
  • Side-by-side
  • Inline
@@ -83,25 +83,7 @@ class WebformWorkflowTransitionConfirmForm extends ConfirmFormBase {
@@ -83,25 +83,7 @@ class WebformWorkflowTransitionConfirmForm extends ConfirmFormBase {
$this->transition = $this->workflow->getTypePlugin()
$this->transition = $this->workflow->getTypePlugin()
->getTransition($transition);
->getTransition($transition);
// Create generic confirmation form:
return parent::buildForm($form, $form_state);
$form = parent::buildForm($form, $form_state);
// Check access to transition, for better UX:
/** @var \Drupal\webform_workflows_element\Service\WebformWorkflowsManager $workflows_manager */
$workflows_manager = Drupal::service('webform_workflows_element.manager');
$account = Drupal::currentUser();
$access = $workflows_manager->checkAccessForSubmissionAndTransition($this->workflow, $account, $this->webform, $this->transition);
if (!$access) {
$form['actions']['submit']['#access'] = FALSE;
$form['actions']['cancel']['#title'] = $this->t('Cancel');
$form['description']['#markup'] = $this->t('Either the "@transition" transition is not possible or you do not have sufficient access to perform it on submission @id as part of the "@workflow" workflow.', [
'@workflow' => $this->workflow->label(),
'@transition' => $this->transition->label(),
'@id' => $this->webform_submission->id(),
]);
}
return $form;
}
}
/**
/**
Loading