function _content_lock_node_form_handler_button in Content locking (anti-concurrent editing) 7.3
Node and node revision handler button.
1 call to _content_lock_node_form_handler_button()
- content_lock_node_form_handler in includes/
content_lock.node.inc - Node and node revision handler.
File
- includes/
content_lock.node.inc, line 98 - content_lock.node.inc
Code
function _content_lock_node_form_handler_button(&$form, $form_state, $form_id) {
// If we're on the node form.
$node = empty($form['#node']) ? NULL : $form['#node'];
$nid = empty($form['nid']['#value']) ? NULL : $form['nid']['#value'];
if (!empty($form['#node_revision'])) {
$node = $form['#node_revision'];
$nid = $node->nid;
}
if (!empty($node) && !empty($nid) && ($form_id == $node->type . '_node_form' || $form_id == 'node_revision_revert_confirm')) {
// Revert node.
if ($form_id == 'node_revision_revert_confirm') {
/* Hijack the default cancel link to become a lock-releasing link */
$destination = 'node/' . $nid . '/revisions';
if (!empty($form['actions']['cancel']['#href'])) {
$destination = $form['actions']['cancel']['#href'];
}
$form['actions']['cancel']['#href'] = 'admin/content/' . $nid . '/content_lock/releaseown';
$form['actions']['cancel'] += array(
'#options' => array(),
);
$form['actions']['cancel']['#options'] += array(
'query' => array(
'token' => content_lock_get_release_token($nid),
'destination' => $destination,
),
);
}
else {
if ($node->nid) {
$form['actions']['cancel'] = array(
'#type' => 'button',
'#weight' => 2000,
'#value' => t('Cancel edit'),
'#validate' => array(
'_content_lock_node_form_handler_cancel_submit',
),
);
if (isset($form['actions']['delete'])) {
$form['actions']['delete']['#weight'] = 2001;
}
}
}
}
}