function modr8_form_alter in modr8 7
Same name and namespace in other branches
- 5 modr8.module \modr8_form_alter()
- 6 modr8.module \modr8_form_alter()
Implements hook_form_alter()
File
- ./
modr8.module, line 219 - Easy dedicated content moderation
Code
function modr8_form_alter(&$form, $form_state, $form_id) {
if (isset($form['type']['#value']) && $form['type']['#value'] . '_node_form' == $form_id) {
$moderate_checkbox = array(
'#type' => 'checkbox',
'#title' => t('In moderation queue'),
'#default_value' => $form['#node']->moderate,
'#weight' => 24,
'#description' => t('This %type will be placed in moderation if the %moderate checkbox is selected.', array(
'%type' => node_type_get_name($form['#node']),
'%moderate' => t('In moderation queue'),
)),
);
if (user_access('administer nodes')) {
$form['options']['moderate'] = $moderate_checkbox;
}
elseif (user_access('moderate content')) {
$form['moderate'] = $moderate_checkbox;
}
else {
$form['moderate'] = array(
'#type' => 'value',
'#value' => $form['#node']->moderate,
);
if ($form['#node']->moderate) {
$form['modr8_message'] = array(
'#type' => 'markup',
'#markup' => theme('modr8_message', array(
'0' => FALSE,
'1' => $form['#node']->type,
'2' => 'node_form',
)),
'#weight' => -100,
);
}
}
}
elseif ($form_id == 'node_type_form') {
$form['workflow']['node_options']['#options']['moderate'] = t('In moderation queue');
}
elseif ($form_id == 'modr8_filter_form') {
// Unset the internal form token and id fields for this admin filter form,
// since it is posted as a GET and doesn't need the drupal form system.
unset($form['form_build_id'], $form['form_id'], $form['#token'], $form['#build_id']);
}
}