You are here

function signup_settings_form in Signup 7

Same name and namespace in other branches
  1. 6.2 includes/admin.settings.inc \signup_settings_form()
  2. 6 includes/admin.settings.inc \signup_settings_form()

Form builder for the settings page under admin/config/people/signup

2 string references to 'signup_settings_form'
signup_menu in ./signup.module
Implements hook_menu().
signup_roles_form_alter in modules/signup_roles/signup_roles.module
Implements hook_form_alter().

File

includes/admin.settings.inc, line 10
Code required for the signup settings page (admin/config/people/signup).

Code

function signup_settings_form($form, &$form_state) {
  module_load_include('inc', 'signup', 'includes/node_settings');
  if (signup_site_has_dates()) {
    $form['signup_close_early'] = array(
      '#title' => t('Close x hours before'),
      '#type' => 'textfield',
      '#default_value' => variable_get('signup_close_early', 1),
      '#size' => 5,
      '#maxlength' => 10,
      '#description' => t('The number of hours before the event which signups will no longer be allowed. Use negative numbers to close signups after the event start (example: -12).'),
    );
  }
  $form['node_defaults'] = array(
    '#type' => 'fieldset',
    '#title' => t('Default signup information'),
    '#description' => t('New signup-enabled nodes will start with these settings.'),
    '#collapsible' => TRUE,
  );
  $form['node_defaults']['signup_node_settings_form'] = signup_node_settings_form(array(), array(), NULL, NULL, signup_site_has_dates());
  $form['adv_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Advanced settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['adv_settings']['signup_date_format'] = array(
    '#title' => t('Format string for displaying signup-related dates'),
    '#type' => 'select',
    '#options' => array(
      'small' => t('Small'),
      'medium' => t('Medium'),
      'large' => t('Large'),
    ),
    '#default_value' => variable_get('signup_date_format', 'small'),
    '#description' => t('Whenever this module needs to print a date (both in the administrative interface, and in the various e-mail messages it can send), this setting controls which date format string to use. The format strings are defined at the <a href="!settings_url">Date and time settings page</a>.', array(
      '!settings_url' => url('admin/config/date-time'),
    )),
  );
  $form['adv_settings']['signup_ignore_default_fields'] = array(
    '#type' => 'checkbox',
    '#title' => t('Ignore default Signup fields'),
    '#description' => t('Signup comes with Name and Phone fields that are separate from user profile fields. Ignore these fields if only authenticated users will be signing up on this site.'),
    '#default_value' => variable_get('signup_ignore_default_fields', 0),
  );
  $form['adv_settings']['signup_form_location'] = array(
    '#title' => t('Location of the signup form'),
    '#type' => 'radios',
    '#options' => array(
      'node' => t('Included on each node'),
      'tab' => t('Under the %signups tab', array(
        '%signups' => t('Signups'),
      )),
      'none' => t('Do not display signup form'),
    ),
    '#default_value' => variable_get('signup_form_location', 'node'),
    '#description' => t('On every signup-enabled node, users with permission to sign up can be presented with a form. This setting controls where this form should be displayed: either directly on the node itself, on a separate tab, or not at all.'),
    '#prefix' => '<div class="signup-form-location-radios">',
    '#suffix' => '</div>',
  );
  $form['adv_settings']['signup_user_reg_form'] = array(
    '#title' => t('Allow registering users to sign up for nodes from the user registration form'),
    '#type' => 'checkbox',
    '#default_value' => variable_get('signup_user_reg_form', 0),
    '#description' => t('Users will see a checkbox for each event that they sign up for. Note that these checkboxes will appear even if anonymous users lack the "sign up for content" permission because they will be signed up once their account has been created and they are registered users.'),
  );

  // The rest of the advanced settings are conditional on if/where the signup
  // form is being displayed.  We use jQuery to hide settings when they're not
  // relevant.
  $signup_path = drupal_get_path('module', 'signup');
  drupal_add_js($signup_path . '/js/admin.settings.js');

  // For each setting that should be hidden, system.css will hide all the
  // settings on page load if JS is enabled.
  $class = 'signup-fieldset_collapsed-setting';
  if (variable_get('signup_form_location', 'node') != 'node') {
    $class .= ' js-hide';
  }
  $form['adv_settings']['signup_fieldset_collapsed'] = array(
    '#title' => t('Default fieldset behavior for per-node signup form'),
    '#type' => 'radios',
    '#options' => array(
      1 => t('Collapsed'),
      0 => t('Expanded'),
    ),
    '#default_value' => variable_get('signup_fieldset_collapsed', 1),
    '#description' => t('If the signup form is included on each node, the signup form will be encapsulated in a collapsible fieldset. This setting controls if that fieldset is expanded or collapsed by default.'),
    '#prefix' => '<div class="' . $class . '">',
    '#suffix' => '</div>',
  );
  $list_options = array(
    'embed-view' => t('Embed a view on each node'),
    'embed-view-tab' => t('Embed a view under the %signups tab', array(
      '%signups' => t('Signups'),
    )),
    'none' => t('Do not display a listing at all'),
  );
  $form['adv_settings']['signup_display_signup_user_list'] = array(
    '#title' => t('How to display the list of signed-up users'),
    '#type' => 'radios',
    '#options' => $list_options,
    '#default_value' => variable_get('signup_display_signup_user_list', 'embed-view'),
    '#description' => t('Users with the %view_signups permission can be presented with a list of all users who have signed up. This setting controls if, how, and where that list should be generated. If you choose to embed a view, you will be able to select which view you want to use below. The view you select will have a single argument passed in, the node id (nid) of the signup-enabled node being viewed. You can also use views to display this listing on its own tab or in a block if you disable this setting.', array(
      '%view_signups' => t('view all signups'),
    )),
    '#prefix' => '<div class="signup-display-signup-user-list-setting">',
    '#suffix' => '</div>',
    '#weight' => 1,
  );
  $admin_options = array(
    'embed-view' => t('Embed a view'),
    'none' => t('Do not display a listing at all'),
  );
  $form['adv_settings']['signup_display_signup_admin_list'] = array(
    '#title' => t('How to display the administrative list of signed-up users'),
    '#type' => 'radios',
    '#options' => $admin_options,
    '#default_value' => variable_get('signup_display_signup_admin_list', 'embed-view'),
    '#description' => t('Users with permission to administer signups for a given node will see a list of users of all users who have signed up. This setting controls if and how that list should be generated. If you choose to embed a view, you will be able to select which view you want to use below. The view you select will have a single argument passed in, the node id (nid) of the signup-enabled node being viewed. You can also use views to display this listing on its own tab or in a block if you disable this setting.', array(
      '%view_signups' => t('view all signups'),
    )),
    '#prefix' => '<div class="signup-display-signup-admin-list-setting">',
    '#suffix' => '</div>',
    '#weight' => 5,
  );
  $class = 'signup-user-list-view-settings';
  $user_list = variable_get('signup_display_signup_user_list', 'embed-view');
  if ($user_list == 'none') {
    $class .= ' js-hide';
  }
  $form['adv_settings']['view_settings'] = array(
    '#prefix' => '<div class="' . $class . '">',
    '#suffix' => '</div>',
    '#weight' => 2,
  );
  $views = views_get_all_views();
  foreach ($views as $view) {
    foreach (array_keys($view->display) as $display_id) {
      if ($display_id != 'default' || 1) {
        $key = $view->name . ':' . $display_id;
        $view_options[$key] = theme('signup_settings_view_label', array(
          'view' => $view,
          'display_id' => $display_id,
        ));
      }
    }
  }
  $form['adv_settings']['view_settings']['signup_user_list_view'] = array(
    '#title' => t('View to embed for the signup user list'),
    '#type' => 'select',
    '#options' => $view_options,
    '#default_value' => variable_get('signup_user_list_view', 'signup_user_list:default'),
    '#description' => t("If the signup user list is being generated by embedding a view, this selects which view should be used. The view's name, description, and display(s) it defines are listed."),
  );
  $class = 'signup-admin-list-view-settings';
  if (variable_get('signup_display_signup_admin_list', 'embed-view') != 'embed-view') {
    $class .= ' js-hide';
  }
  $form['adv_settings']['admin_view_settings'] = array(
    '#prefix' => '<div class="' . $class . '">',
    '#suffix' => '</div>',
    '#weight' => 6,
  );

  // $view_options is still initialized from above.
  $form['adv_settings']['admin_view_settings']['signup_admin_list_view'] = array(
    '#title' => t('View to embed for the signup administrative list'),
    '#type' => 'select',
    '#options' => $view_options,
    '#default_value' => _signup_get_admin_list_view(),
    '#description' => t("If the administer signups user list is being generated by embedding a view, this selects which view should be used. The view's name, description, and display(s) it defines are listed."),
  );

  // Use our own submit handler, so we can do some processing before
  // we hand control to system_settings_form_submit.
  $form = system_settings_form($form);
  unset($form['#submit']);
  $form['#submit'][] = 'signup_settings_form_submit';
  return $form;
}