function quickbar_extras_form_alter in Quickbar 7.2
Same name and namespace in other branches
- 6 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_state['build_info']['args'][0];
$menus = variable_get('quickbar_role_menus', array());
$menu_used = isset($menus[arg(4)]) ? $menus[arg(4)] : '';
$form['quickbar_extras'] = array(
'#type' => 'fieldset',
'#title' => t('Extra settings'),
'#collapsible' => 1,
'#collapsed' => 0,
'#attributes' => array(
'class' => array(
'quickbar-extras',
),
),
);
// Pulls all menu links from the database
$query = db_select('menu_links', 'ml')
->fields('ml', array(
'mlid',
'link_title',
))
->condition('menu_name', $menu_used)
->condition('plid', 0)
->condition('hidden', 0)
->condition('link_path', '%\\%%', 'NOT LIKE')
->orderBy('weight', 'ASC')
->execute();
$settings = variable_get('quickbar_extras_settings_' . $rid, '');
$form['quickbar_extras']['organize'] = array(
'#type' => 'fieldset',
'#title' => t('Organize Menu Links'),
'#collapsible' => 1,
'#collapsed' => 0,
'#attributes' => array(
'class' => array(
'quickbar-organize',
),
),
);
while ($record = $query
->fetchAssoc()) {
$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,
),
),
);
$form['#submit'][] = 'quickbar_extras_configure_form_submit';
// Push submit button to bottom of form
$form['submit']['#weight'] = 1000;
}
}