function content_lock_warn_pending_locks in Content locking (anti-concurrent editing) 6.2
Same name and namespace in other branches
- 6 content_lock.module \content_lock_warn_pending_locks()
- 7 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_nodeapi in ./
content_lock.module - Implementation of hook_nodeapi().
File
- ./
content_lock.module, line 598 - 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();
$result = db_query("SELECT cl.nid,n.title FROM {content_lock} as cl LEFT JOIN {node} as n on cl.nid=n.nid WHERE cl.uid = %d", $uid);
while ($lock = db_fetch_object($result)) {
$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;
}