You are here

function notifications_anonymous_admin_settings_form_validate in Notifications 6.4

Validate admin settings

1 string reference to 'notifications_anonymous_admin_settings_form_validate'
notifications_anonymous_admin_settings_form in notifications_anonymous/notifications_anonymous.pages.inc
Admin settings form

File

notifications_anonymous/notifications_anonymous.pages.inc, line 134
Notifications for anonymous users

Code

function notifications_anonymous_admin_settings_form_validate($form, &$form_state) {
  $send_methods = array_filter($form_state['values']['notifications_anonymous_send_methods']);
  $form_state['values']['notifications_anonymous_send_methods'] = $send_methods;

  // Check we have only one of each type
  $types = array();
  foreach ($send_methods as $method) {
    $type = messaging_method_info($method, 'address_type');
    if (in_array($type, $types)) {
      form_set_error('notifications_anonymous_send_methods', t('Only one method of each type is allowed.'));
      break;
    }
    $types[] = $type;
  }
}