function content_lock_warn_pending_locks in Content locking (anti-concurrent editing) 7
Same name and namespace in other branches
- 6.2 content_lock.module \content_lock_warn_pending_locks()
- 6 content_lock.module \content_lock_warn_pending_locks()
- 7.2 content_lock.module \content_lock_warn_pending_locks()
For every lock a user current have on any nodes, print a warning messagt with an link to release this node.
1 call to content_lock_warn_pending_locks()
- content_lock_node_view in ./
content_lock.module - Implement hook_node_view() to inform user if he's holding locks on other nodes.
File
- ./
content_lock.module, line 663 - Allows users to lock documents for modification.
Code
function content_lock_warn_pending_locks($uid) {
// cache
static $warned_nodes = array();
static $content_lock_messages_printed = false;
if ($content_lock_messages_printed) {
return;
}
if (array_key_exists($uid, $warned_nodes)) {
// do nothing
}
else {
// load form db
$warned_nodes[$uid] = array();
$query = db_select('content_lock', 'c')
->fields('c', array(
'nid',
))
->condition('c.uid', $uid);
$n = $query
->leftJoin('node', 'n', '%alias.nid = c.nid');
$query
->fields($n, array(
'title',
));
foreach ($query
->execute() as $lock) {
$warned_nodes[$uid][] = $lock;
}
}
foreach ($warned_nodes[$uid] as $lock) {
$nodetitle_link = l($lock->title, "node/{$lock->nid}");
$token = content_lock_get_release_token($lock->nid);
$releasethelock_link = l(t('release the lock'), "admin/content/{$lock->nid}/content_lock/releaseown", array(
'query' => array(
'token' => $token,
),
));
_content_lock_save_lock_warning(t("The node '!nodetitle_link' is locked by you. You may want to '!releasethelock_link' in order to allow others to edit.", array(
'!nodetitle_link' => $nodetitle_link,
'!releasethelock_link' => $releasethelock_link,
)), $lock->nid);
}
$content_lock_messages_printed = true;
}