function _content_lock_show_warnings_pending in Content locking (anti-concurrent editing) 7.3
Warn pending locks.
For every lock a user current have on any nodes, print a warning message with an link to release this node.
Parameters
int $uid: User ID.
1 call to _content_lock_show_warnings_pending()
- content_lock_node_view in ./
content_lock.module - Implements hook_node_view().
File
- includes/
content_lock.func.inc, line 105 - content_lock.func.inc
Code
function _content_lock_show_warnings_pending($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)) {
// Load form db.
$warned_nodes[$uid] = array();
$query = db_select('content_lock', 'c')
->fields('c', array(
'entity_id',
))
->fields('c', array(
'entity_type',
))
->condition('c.uid', $uid);
$n = $query
->leftJoin('node', 'n', '%alias.nid = c.entity_id');
$query
->fields($n, array(
'title',
));
// Fetch locked entities.
foreach ($query
->execute() as $lock) {
$warned_nodes[$uid][] = $lock;
}
}
foreach ($warned_nodes[$uid] as $lock) {
$nodetitle_link = l($lock->title, "node/{$lock->entity_id}");
$token = content_lock_get_release_token($lock->entity_id);
$releasethelock_link = l(t('release the lock'), "admin/content/{$lock->entity_id}/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->entity_id);
}
$content_lock_messages_printed = TRUE;
}