function content_lock_node_ajax_callback in Content locking (anti-concurrent editing) 7.2
Same name and namespace in other branches
- 7.3 includes/content_lock.ajax.inc \content_lock_node_ajax_callback()
AJAX callback to lock a node manually.
Parameters
object $node: The node to lock.
string $token: The CSRF token.
1 string reference to 'content_lock_node_ajax_callback'
- content_lock_menu in ./
content_lock.module - Implements hook_menu().
File
- ./
content_lock.module, line 646 - Allows users to lock documents for modification.
Code
function content_lock_node_ajax_callback($node, $token) {
global $user;
// Only lock the node if we have a valid CSRF token.
if (drupal_valid_token($token, $node->nid)) {
content_lock_node($node->nid, $user->uid);
// Add the javascript that unlocks the node when the user navigates away
// from the page.
$form = array(
'nid' => array(
'#value' => $node->nid,
),
);
_content_lock_add_unload_js($form, array());
}
else {
drupal_set_message(t('The content could not be locked.'));
}
$commands = array();
$commands[] = ajax_command_remove('div.messages');
$commands[] = ajax_command_before('#block-system-main', theme('status_messages'));
ajax_deliver(array(
'#type' => 'ajax',
'#commands' => $commands,
));
}