function plus1_forums_form_alter in Plus 1 6.2
Implements hook_form_alter(). Add individual node vote disabling.
File
- ./
plus1_forums.module, line 30 - Limit which forums allow voting.
Code
function plus1_forums_form_alter(&$form, $form_state, $form_id) {
// drupal_set_message($form_id);
switch ($form_id) {
case 'plus1_settings':
$form['plus1_forums_fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Forum settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#weight' => -3,
);
$fora = forum_get_forums();
$forums_list = array();
foreach ($fora as $forum) {
$forums_list[$forum->tid] = $forum->name;
}
if ($forums_list) {
$form['plus1_forums_fieldset']['plus1_forums'] = array(
'#type' => 'checkboxes',
'#options' => $forums_list,
'#title' => t('Allow voting on these forums'),
'#default_value' => variable_get('plus1_forums', array()),
'#attributes' => array(
'class' => 'container-inline',
),
);
}
return;
case 'forum_form_forum':
$noyes = array(
t('No'),
t('Yes'),
);
$state = FALSE;
if (isset($form['tid'])) {
$enabled = variable_get('plus1_forums', array());
$state = in_array($form['tid']['#value'], $enabled);
}
$form['plus1_enable'] = array(
'#type' => 'radios',
'#options' => $noyes,
'#title' => t('Allow voting on this forum'),
'#default_value' => (int) $state,
'#description' => t('Do you want to allow Plus 1 module voting for this forum?'),
'#attributes' => array(
'class' => 'container-inline',
),
);
$form['submit']['#weight'] = 99;
$form['delete']['#weight'] = 99;
// By letting the standard submit handler run first, we will get a tid
// filled in for new forums.
$form['#submit'][] = '_plus1_forums_form_submit';
return;
}
}