Commit 271898ba authored by jeffam's avatar jeffam
Browse files

Issue #3258272 by jeffam, a-fro: Prevent modification of locked registrations

parent 05d44d74
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -19,6 +19,15 @@ class RegistrationForm extends ContentEntityForm {
    $form = parent::buildForm($form, $form_state);
    $form_state->set('registration', $this->entity);

    // Prevent edits to fields on locked registrations.
    if ($this->entity->locked->value) {
      foreach (array_keys($this->entity->getFields()) as $field_name) {
        if (isset($form[$field_name]) && $field_name !== 'locked') {
          $form[$field_name]['#disabled'] = TRUE;
        }
      }
    }

    // Change the 'Save' submit button label.
    $form['actions']['submit']['#value'] = $this->entity->isNew() ? $this->t('Register') : $this->t('Update Registration');

+10 −0
Original line number Diff line number Diff line
@@ -23,6 +23,16 @@ class ParticipantAccessControlHandler extends EntityAccessControlHandler {
      case 'view':
      case 'update':
      case 'delete':
        // Participants of locked registrations can't be edited or deleted.
        if ($operation === 'update' || $operation === 'delete') {
          /** @var \Drupal\erf\Entity\RegistrationInterface $registration */
          foreach ($entity->getRegistrations() as $registration) {
            if ($registration->locked->value) {
              return AccessResult::forbidden('Deletion or editing not allowed when registration is locked.');
            }
          }
        }

        if ($this->ownsRegistration($entity, $account)) {
          return AccessResult::allowedIfHasPermission($account, 'manage own registrations');
        }