function publishcontent_form_node_form_alter in Publish Content 7
Same name and namespace in other branches
- 8 publishcontent.module \publishcontent_form_node_form_alter()
Implements hook_form_FORM_ID_alter().
Alter the node edit forms.
File
- ./
publishcontent.module, line 373 - Add link to publish or unpublish a node, with access control based on the node type
Code
function publishcontent_form_node_form_alter(&$form, &$form_state) {
if ($form['#form_id'] == 'node_delete_confirm') {
return;
}
$node = $form['#node'];
if (!variable_get('publishcontent_' . $node->type, FALSE)) {
// Publish content is not set or disabled for this content type.
return;
}
if (!publishcontent_publish_access($node)) {
if (!isset($node->nid)) {
// Ensure users without permission to publish can't do so because of the
// default setting in the content type. This setting controls the actual
// value in $form_state.
$form['options']['status']['#default_value'] = 0;
// These won't affect $form_state but also need to be updated.
$form['#node']->status = 0;
$node->status = 0;
}
if (empty($node->status)) {
// Publish content is unavailable for user without publish access.
return;
}
}
if (!empty($node->status) && !publishcontent_unpublish_access($node)) {
// Publish content is unavailable for user without unpublish access.
return;
}
if (_publishcontent_get_method() == PUBLISHCONTENT_METHOD_BUTTON) {
_publishcontent_configure_publish_button($form, $form_state);
}
else {
_publishcontent_configure_publish_checkbox($form, $form_state);
}
}