You are here

function quickbar_extras_form_alter in Quickbar 6

Same name and namespace in other branches
  1. 7.2 modules/quickbar_extras/quickbar_extras.module \quickbar_extras_form_alter()

Implements hook_form_alter().

File

modules/quickbar_extras/quickbar_extras.module, line 16

Code

function quickbar_extras_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'quickbar_configure_form') {
    $rid = $form['#parameters'][2];
    $menu_used = variable_get('quickbar_' . $rid, '');
    $form['quickbar_extras'] = array(
      '#type' => 'fieldset',
      '#title' => t('Extra settings'),
      '#collapsible' => 1,
      '#collapsed' => 0,
      '#attributes' => array(
        'class' => array(
          'quickbar-extras',
        ),
      ),
    );
    $settings = variable_get('quickbar_extras_settings_' . $rid, '');

    // Pulls all menu links from the database
    $sql_select = 'mlid , link_title from {menu_links}';
    $sql_where = '(menu_name = "%s") AND (plid = 0) AND (hidden = 0) AND (link_path NOT LIKE "%\\%%")';
    $sql = "select {$sql_select} where {$sql_where} order by weight ASC";
    $query = db_query($sql, $menu_used);
    $form['quickbar_extras']['organize'] = array(
      '#type' => 'fieldset',
      '#title' => t('Organize Menu Links'),
      '#collapsible' => 1,
      '#collapsed' => 0,
      '#attributes' => array(
        'class' => array(
          'quickbar-organize',
        ),
      ),
    );
    while ($record = db_fetch_array($query)) {
      $mlid = $record['mlid'];
      $title = $record['link_title'];
      $form['quickbar_extras']['organize']['mlid_' . $mlid] = array(
        '#type' => 'select',
        '#title' => $title,
        '#options' => array(
          'left' => t('Left'),
          'right' => t('Right'),
        ),
        '#default_value' => isset($settings['menu']['mlid_' . $mlid]) ? $settings['menu']['mlid_' . $mlid] : 'left',
        '#attributes' => array(
          'class' => array(
            'menu-options',
          ),
        ),
      );
    }
    $form['quickbar_extras']['user'] = array(
      '#type' => 'fieldset',
      '#title' => t('User Settings'),
      '#collapsible' => 1,
      '#collapsed' => 1,
      '#attributes' => array(
        'class' => array(
          'user-settings',
        ),
      ),
      'show_username' => array(
        '#type' => 'checkbox',
        '#title' => t('Show username in toolbar'),
        '#description' => t('If checked, the username will show on the right side of the toolbar.'),
        '#default_value' => isset($settings['show_username']) ? $settings['show_username'] : 0,
      ),
      'options' => array(
        '#type' => 'fieldset',
        '#title' => 'Username Options',
        '#attributes' => array(
          'id' => 'username-options',
        ),
        'show_username_prefix' => array(
          '#type' => 'textfield',
          '#title' => t('Prefix to username'),
          '#description' => t("This field's data will be displayed before the username. Be sure to include a space after the text if necessary."),
          '#default_value' => isset($settings['show_username_prefix']) ? $settings['show_username_prefix'] : 'Hello, ',
        ),
        'show_username_suffix' => array(
          '#type' => 'textfield',
          '#title' => t('Suffix to username'),
          '#description' => t("This field's data will be displayed after the username. Be sure to include a space before the text if necessary."),
          '#default_value' => isset($settings['show_username_suffix']) ? $settings['show_username_suffix'] : '!',
        ),
        'show_username_link' => array(
          '#type' => 'checkbox',
          '#title' => t('Username links to user profile page'),
          '#description' => t('If checked, the username will be a link that the user can use to access their profile page.'),
          '#default_value' => isset($settings['show_username_link']) ? $settings['show_username_link'] : 0,
        ),
        'show_logout_link_prefix' => array(
          '#type' => 'textfield',
          '#title' => t('Prefix to the log  link'),
          '#description' => t("This field's data will be displayed before the log out. Be sure to include a space after the text if necessary."),
          '#default_value' => isset($settings['show_logout_link_prefix']) ? $settings['show_logout_link_prefix'] : '',
        ),
        'show_logout_link_suffix' => array(
          '#type' => 'textfield',
          '#title' => t('Suffix to the log  link'),
          '#description' => t("This field's data will be displayed after the log out. Be sure to include a space before the text if necessary."),
          '#default_value' => isset($settings['show_logout_link_suffix']) ? $settings['show_logout_link_suffix'] : '',
        ),
        'show_logout_link' => array(
          '#type' => 'checkbox',
          '#title' => t('Include a Log out link'),
          '#description' => t('If checked, the username will be followed by a log out link.'),
          '#default_value' => isset($settings['show_logout_link']) ? $settings['show_logout_link'] : 0,
        ),
      ),
    );
    $form['#submit'][] = 'quickbar_extras_configure_form_submit';

    // Push submit button to bottom of form
    $form['submit']['#weight'] = 1000;
  }
}