function content_lock_overview in Content locking (anti-concurrent editing) 7.3
Same name and namespace in other branches
- 6.2 content_lock.module \content_lock_overview()
- 6 content_lock.module \content_lock_overview()
- 7 content_lock.module \content_lock_overview()
- 7.2 content_lock.module \content_lock_overview()
Build an overview of locked documents.
Parameters
object $account: User account.
Return value
string Overview list.
Throws
\Exception
1 string reference to 'content_lock_overview'
- content_lock_menu in ./
content_lock.module - Implements hook_menu().
File
- includes/
content_lock.pages.inc, line 19 - Common pages for the Content Lock module.
Code
function content_lock_overview($account = NULL) {
global $user;
// @TODO old checkout code, review.
$header = array(
array(
'data' => t('Title'),
'field' => 'n.title',
'sort' => 'asc',
),
);
// In the case of an admin, we do not have uid, as he sees all locks.
if (!is_object($account)) {
$header[] = array(
'data' => t('Username'),
'field' => 'u.name',
);
$uid = NULL;
}
else {
$uid = $account->uid;
}
$header[] = array(
'data' => t('Locked since'),
'field' => 'c.timestamp',
);
if ($uid == $user->uid || user_access('administer checked out documents')) {
$header[] = t('Operations');
}
$query = db_select('content_lock', 'c')
->extend('TableSort')
->fields('c');
$n = $query
->join('node', 'n', '%alias.nid = c.entity_id');
$query
->fields($n, array(
'title',
));
$u = $query
->join('users', 'u', '%alias.uid = c.uid');
$query
->fields($u, array(
'name',
));
if ($uid) {
$query
->condition('c.uid', $uid);
}
$query
->orderByHeader($header);
$rows = array();
foreach ($query
->execute() as $data) {
$url = $uid ? "admin/content/" . $data->entity_id . "/content_lock/releaseown" : 'admin/content/content_lock/release/' . $data->entity_id;
$row = array();
$row[] = l($data->title, "node/{$data->entity_id}");
if (!$uid) {
$row[] = theme('username', array(
'account' => user_load($data->uid),
));
}
$row[] = format_date($data->timestamp, 'small');
if ($uid == $user->uid || user_access('administer checked out documents')) {
$row[] = l(t('release lock'), $url, array(
'query' => array(
'token' => content_lock_get_release_token($data->entity_id),
),
));
}
$rows[] = $row;
}
$output = theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'id' => 'content_lock',
),
'empty' => t('No locked documents.'),
));
$output .= theme('pager', array(
'quantity' => 50,
));
return $output;
}