You are here

function content_lock_warn_pending_locks in Content locking (anti-concurrent editing) 6

Same name and namespace in other branches
  1. 6.2 content_lock.module \content_lock_warn_pending_locks()
  2. 7 content_lock.module \content_lock_warn_pending_locks()
  3. 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 503
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) {
    $editlink = l(t('editing'), "node/{$lock->nid}/edit");
    $unlocklinkhere = l(t('here'), "admin/content/{$lock->nid}/content_lock/releaseown");
    _content_lock_save_lock_warning(t("You are currently preventing the node '!nodetitle' from being edited. You may want to let others edit this node by clicking !unlocklinkhere, or finish !edit the node.", array(
      '!nodetitle' => $lock->title,
      '!edit' => $editlink,
      '!unlocklinkhere' => $unlocklinkhere,
    )), $lock->nid);
  }
  $content_lock_messages_printed = true;
}