You are here

function pwa_webpush_admin_configuration_validate in Progressive Web App 7.2

File

modules/pwa_webpush/pwa_webpush.admin.inc, line 111
PWA administration forms.

Code

function pwa_webpush_admin_configuration_validate($form, &$form_state) {
  $values =& $form_state['values'];
  $padding = (int) $values['pwa_webpush_notification_padding'];
  if ($padding > Encryption::MAX_PAYLOAD_LENGTH) {
    form_set_error('pwa_webpush_notification_padding', t('The padding size is higher than the maximum payload size allowed, the value must be smaller than @limit', [
      '@limit' => Encryption::MAX_PAYLOAD_LENGTH,
    ]));
  }
  elseif ($padding < 0) {
    form_set_error('pwa_webpush_notification_padding', t('The padding size must be higher or equal to 0'));
  }
  else {
    if ($padding > PWA_WEBPUSH_AUTOMATIC_PADDING_LIMIT) {
      drupal_set_message(t('Automatic padding is set higher than @limit, there might be problems delivering notifications to Firefox Mobile users.', [
        '@limit' => PWA_WEBPUSH_AUTOMATIC_PADDING_LIMIT,
      ]), 'warning');
    }
  }
}