You are here

function signup_date_field_check_config in Signup 7

Same name and namespace in other branches
  1. 5.2 includes/date.inc \signup_date_field_check_config()
  2. 6.2 includes/date.inc \signup_date_field_check_config()
  3. 6 includes/date.inc \signup_date_field_check_config()

Check that the date and signup configuration for a node type makes sense.

This validates that if a node type is signup enabled, that it either has a signup date field selected (for autoclose and reminder emails), or that the signup date field has been explicitly set to 'None'. It warns the site administrator if they have signup-enabled a node type and not defined any date fields at all, or if they have date fields but haven't selected the one to use for signup functionality.

Parameters

string $type: The node type to check signup and CCK date field configuration on.

string $name: Human readable name of the node type to check.

See also

signup_help()

1 call to signup_date_field_check_config()
signup_date_check_node_types in includes/date.inc
Check the signup and date configuration on node types depending on the URL.

File

includes/date.inc, line 233
Code to support using CCK date fields for time-based signup functionality.

Code

function signup_date_field_check_config($type, $name) {
  $signup_default_state = variable_get('signup_node_default_state_' . $type, 'disabled');
  $signup_scheduler = _signup_get_node_type_scheduler($type);
  if ($signup_scheduler != 'event' && $signup_default_state != 'disabled') {

    // Signups aren't disabled on this node type, see if there's a date field.
    $signup_date_field = signup_date_field($type);
    if ($signup_date_field != 'none') {
      $type_url = str_replace('_', '-', $type);
      $placeholders = array(
        '%node_type' => $name,
        '%signup_date_field' => t('Date field to use with signup'),
        '@type_admin_url' => url('admin/content/node-type/' . $type_url),
        '@type_add_field_url' => url('admin/content/node-type/' . $type_url . '/fields'),
        '%none' => '<' . t('none') . '>',
      );

      // Administrator hasn't specifically turned off date support...
      if (signup_field_names($type)) {

        // Node type has some date fields...
        if ($signup_date_field == 0) {
          drupal_set_message(t('You have enabled the %node_type content type for signups, and have added one or more date fields, but have not selected a date field for use with signup. You can modify the %signup_date_field setting at the <a href="@type_admin_url">%node_type configuration page</a> to select a date field to use, or disable this warning by selecting %none.', $placeholders), 'warning');
        }
      }
      else {

        // No date fields at all.
        drupal_set_message(t('You have enabled the %node_type content type for signups but have not added a date field. You can either <a href="@type_add_field_url">add a date field</a>, or disable this warning by selecting %none for the %signup_date_field setting at the <a href="@type_admin_url">%node_type configuration page</a>.', $placeholders), 'warning');
      }
    }
  }
}