You are here

function signup_settings_page in Signup 5.2

Same name and namespace in other branches
  1. 5 signup.module \signup_settings_page()

Form builder for the settings page under admin/setttings/signup

1 string reference to 'signup_settings_page'
signup_menu in ./signup.module
Implementation of hook_menu().

File

./signup.module, line 1490
The Signup module (http://drupal.org/project/signup) manages replies to nodes. In particular, it's good for event management. Signup supports sending reminder emails and automatically closing signups for nodes with a start time, via the Event…

Code

function signup_settings_page() {
  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(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/settings/date-time'),
    )),
  );
  if (!module_exists('views')) {
    $form['adv_settings']['signup_no_views_user_info'] = array(
      '#title' => t('Display signup information on user profile pages'),
      '#type' => 'checkbox',
      '#default_value' => variable_get('signup_no_views_user_info', TRUE),
    );
  }
  $form['adv_settings']['signup_form_location'] = array(
    '#title' => t('Location of the signup form and related information'),
    '#type' => 'radios',
    '#options' => array(
      'node' => t('At the bottom of each node'),
      'tab' => t('On a separate %sign_up tab', array(
        '%sign_up' => t('Sign up'),
      )),
      '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 and additional signup-related information. This setting controls where this information 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>',
  );

  // 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.
  drupal_add_js(SIGNUP_PATH . '/js/admin.settings.js');
  drupal_add_css(SIGNUP_PATH . '/signup.css');

  // For each setting that should be hidden, signup.css will hide all the
  // settings on page load if.
  $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 at the bottom of 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>',
  );

  // If views.module is enabled provide the option to display the list
  // of signed-up users in a tab and/or at the bottom of the node.
  $display_options = array();
  $display_options['signup'] = t('Use the built-in listing');
  $views_help_text = '';
  if (module_exists('views')) {
    $display_options['embed-view'] = t('Embed a view');
    $views_help_text = t('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.');
  }
  else {
    $views_help_text = t('If you enable the !views_url, you will be able to embed a view directly onto the page for this listing.', array(
      '!views_url' => l(t('Views module'), 'http://drupal.org/project/views', array(), NULL, NULL, TRUE),
    ));
  }
  $display_options['none'] = t('Do not display a listing at all');
  $class = 'signup-display-signup-user-list-setting';
  if (variable_get('signup_form_location', 'node') == 'none') {
    $class .= ' js-hide';
  }
  $form['adv_settings']['signup_display_signup_user_list'] = array(
    '#title' => t('How to display the list of signed-up users'),
    '#type' => 'radios',
    '#options' => $display_options,
    '#default_value' => variable_get('signup_display_signup_user_list', 'signup'),
    '#description' => t('If the signup form is being displayed, users with the %view_signups permission can see a list of all users who have signed up. This setting controls if and how that list should be generated. !views_help_text', array(
      '%view_signups' => t('view all signups'),
      '!views_help_text' => $views_help_text,
    )),
    '#prefix' => '<div class="' . $class . '">',
    '#suffix' => '</div>',
  );
  if (module_exists('views')) {
    $class = 'signup-user-list-view-settings';
    if (variable_get('signup_form_location', 'node') == 'none' || variable_get('signup_display_signup_user_list', 'signup') != 'embed-view') {
      $class .= ' js-hide';
    }
    $form['adv_settings']['view_settings'] = array(
      '#prefix' => '<div class="' . $class . '">',
      '#suffix' => '</div>',
    );
    $views = array();
    $result = db_query("SELECT name, description, page, block FROM {view_view}");
    while ($view = db_fetch_object($result)) {
      $views[$view->name] = theme('signup_view_label', $view);
    }
    views_load_cache();

    // Necessary for _views_get_default_views().
    $default_views = _views_get_default_views();
    foreach ($default_views as $view) {
      if (!$views[$view->name]) {
        $views[$view->name] = theme('signup_view_label', $view);
      }
    }
    $form['adv_settings']['view_settings']['signup_user_list_view_name'] = array(
      '#title' => t('View to embed for the signup user list'),
      '#type' => 'select',
      '#options' => $views,
      '#default_value' => variable_get('signup_user_list_view_name', 'signup_user_list'),
      '#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 which display type(s) it defines are listed.  NOTE: if you enable or customize the view being used for this, you should strongly consider disabling the view's menu items to prevent a duplicate tab showing the same information."),
    );
    $form['adv_settings']['view_settings']['signup_user_list_view_type'] = array(
      '#title' => t('Display type of the view to embed for the signup user list'),
      '#type' => 'radios',
      '#options' => array(
        'embed' => t('Page'),
        'block' => t('Block'),
      ),
      '#default_value' => variable_get('signup_user_list_view_type', 'embed'),
      '#description' => t('Choose whether to use the Page or the Block display from the view. NOTE: if the selected display type is not provided by the view, nothing will be shown, so be sure that the display type is enabled and configured properly.'),
    );
  }

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