function promote_disable_form_alter in Promote Disable 7
Same name and namespace in other branches
- 8 promote_disable.module \promote_disable_form_alter()
Implements hook_form_alter().
File
- ./
promote_disable.module, line 88 - Primarily Drupal hooks and helper functions. This is the main module file for Promote Disable.
Code
function promote_disable_form_alter(&$form, &$form_state, $form_id) {
// Are we on a node form?
if (strpos($form_id, '_node_form') !== FALSE) {
// The current form's node type.
$node_type = $form['type']['#value'];
// Our saved front page node types.
$node_types = variable_get('promote_disable_node_types', array());
// Is this node type one we've set?
if (in_array($node_type, $node_types)) {
// Unset the form element.
unset($form['options']['promote']);
// Add a submit function to the start of the #submit array.
array_unshift($form['#submit'], '_promote_disable_form_submit');
}
// Our saved sticky page node types.
$node_types = variable_get('promote_disable_sticky_node_types', array());
// Is this node type one we've set?
if (in_array($node_type, $node_types)) {
// Unset the form element.
unset($form['options']['sticky']);
// Add a submit function to the start of the #submit array.
array_unshift($form['#submit'], '_promote_disable_sticky_form_submit');
}
}
elseif ($form_id == 'node_type_form') {
// The current form's node type.
$node_type = $form['type']['#default_value'];
// Our saved front page node types.
$node_types = variable_get('promote_disable_node_types', array());
// Is this node type one we've set?
if (in_array($node_type, $node_types)) {
// Remove the option.
unset($form['workflow']['node_options']['#options']['promote']);
}
// Our saved sticky node types.
$node_types = variable_get('promote_disable_sticky_node_types', array());
// Is this node type one we've set?
if (in_array($node_type, $node_types)) {
// Remove the option.
unset($form['workflow']['node_options']['#options']['sticky']);
}
}
}