You are here

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

Same name and namespace in other branches
  1. 6.2 content_lock.module \content_lock_overview()
  2. 7.3 includes/content_lock.pages.inc \content_lock_overview()
  3. 7 content_lock.module \content_lock_overview()
  4. 7.2 content_lock.module \content_lock_overview()

Build an overview of locked documents.

Parameters

$account: A user object.

1 string reference to 'content_lock_overview'
content_lock_menu in ./content_lock.module
Implementation of hook_menu().

File

./content_lock.module, line 441
Allows users to lock documents for modification.

Code

function content_lock_overview($account = NULL) {
  $header = array(
    array(
      'data' => t('Title'),
      'field' => 'n.title',
      'sort' => 'asc',
    ),
  );
  if (!$account) {
    $header[] = array(
      'data' => t('Username'),
      'field' => 'u.name',
    );
    $uid = NULL;
  }
  else {
    $uid = $account->uid;
  }
  $header[] = array(
    'data' => t('Locked since'),
    'field' => 'c.timestamp',
  );
  $header[] = t('Operations');
  $rows = array();
  $add_sql = $uid ? " WHERE c.uid = %d" : '';
  $result = pager_query('SELECT c.*, n.title, u.name FROM {content_lock} c INNER JOIN {node} n ON n.nid = c.nid INNER JOIN {users} u ON u.uid = c.uid' . $add_sql . tablesort_sql($header), 50, 0, NULL, $uid);
  $url = $uid ? "user/{$uid}/content_lock/release" : 'admin/content/node/content_lock/release';
  while ($data = db_fetch_object($result)) {
    $row = array();
    $row[] = l($data->title, "node/{$data->nid}");
    if (!$uid) {
      $row[] = theme('username', user_load(array(
        'uid' => $data->uid,
      )));
    }
    $row[] = format_date($data->timestamp, 'small');
    $row[] = l(t('release lock'), "{$url}/{$data->nid}");
    $rows[] = $row;
  }
  $output = theme('table', $header, $rows, array(
    'id' => 'content_lock',
  ));
  if (!$rows) {
    $output .= t('No locked documents.');
  }
  else {
    if ($pager = theme('pager', array(), 50, 0)) {
      $output .= $pager;
    }
  }
  return $output;
}