You are here

protected function LegalAdminTermsForm::legalConditionsUpdated in Legal 8

Same name and namespace in other branches
  1. 2.0.x src/Form/LegalAdminTermsForm.php \Drupal\legal\Form\LegalAdminTermsForm::legalConditionsUpdated()

Check if T&Cs have been updated.

Parameters

array $new: Newly created T&Cs.

Return value

bool TRUE if the newly created T&Cs are different from the current T&Cs.

1 call to LegalAdminTermsForm::legalConditionsUpdated()
LegalAdminTermsForm::submitForm in src/Form/LegalAdminTermsForm.php
Form submission handler.

File

src/Form/LegalAdminTermsForm.php, line 424

Class

LegalAdminTermsForm
Settings form for administering content of Terms & Conditions.

Namespace

Drupal\legal\Form

Code

protected function legalConditionsUpdated(array $new) {
  $previous_same_language = legal_get_conditions($new['language']);
  $previous = legal_get_conditions();
  if ($previous_same_language['conditions'] != $new['conditions']['value'] && $previous['conditions'] != $new['conditions']['value']) {
    return TRUE;
  }
  $count = count($new['extras']);
  for ($counter = 1; $counter <= $count; $counter++) {
    $previous_same_language_extra = isset($previous_same_language['extras']['extras-' . $counter]) ? $previous_same_language['extras']['extras-' . $counter] : '';
    $previous_extra = isset($previous['extras']['extras-' . $counter]) ? $previous['extras']['extras-' . $counter] : '';
    if ($previous_same_language_extra != $new['extras']['extras-' . $counter] && $previous_extra != $new['extras']['extras-' . $counter]) {
      return TRUE;
    }
  }
  return FALSE;
}