function plus1_form_alter in Plus 1 6.2
Implements hook_form_alter(). Add individual node vote disabling.
File
- ./
plus1.module, line 633 - A simple +1 voting widget module.
Code
function plus1_form_alter(&$form, $form_state, $form_id) {
if (variable_get('plus1_allow_disable', 0)) {
if (isset($form['type']) && isset($form['#node']) && substr($form_id, -10) == '_node_form') {
if (in_array($form['type']['#value'], variable_get('plus1_nodetypes', array()))) {
$noyes = array(
t('No'),
t('Yes'),
);
$form['plus1_voting'] = array(
'#type' => 'fieldset',
'#title' => t('Plus 1 Voting'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Get list of nodes that are disabled.
$skip = variable_get('plus1_disable_vote', array());
$disabled = empty($form['nid']['#value']) ? FALSE : isset($skip[$form['nid']['#value']]);
// Note that this will be handled in hook_nodeapi where we have a
// nid for new nodes.
$form['plus1_voting']['plus1_disable_vote'] = array(
'#type' => 'radios',
'#options' => $noyes,
'#title' => t('Disable voting on this post'),
'#default_value' => (int) $disabled,
'#description' => t('Note that "No" means voting is allowed. "Yes" means that it is not allowed for <strong>this</strong> post.'),
'#attributes' => array(
'class' => 'container-inline',
),
);
}
}
}
}