This module enables admins to display a block with the comments approval queue and the node moderation queue. Each item will have a edit and delete link.
I made it for my own site and thought maybe someone else also could make use of it.
/**
* @file
* adminblock.module 4.5.0v2, Fredrik Jonsson, 2005-02-17
* Enables admins to display a block with the comments approval queue and
* the node moderation queue.
*
* The block will only show for users with "administer nodes" privilages.
*
* If there are no comments to approve and no nodes to moderate
* the block will not show.
*/
/**
* Implementation of hook_help().
*/
function adminblock_help($section = "admin/help#adminblock") {
switch ($section) {
case 'admin/modules#description':
$output = t("Block that display the comments approval queue and the node moderation queue.");
break;
}
return $output;
}
/**
* Implementation of hook_block().
*
* Generates a block with the comments approval queue and
* the node moderation queue.
* $nlimit sets the number of comments and nodes to display
*/
function adminblock_block($op = 'list', $delta = 0) {
if ($op == 'list') {
$blocks[0]['info'] = t('Admin block');
return $blocks;
}
else if (user_access('administer nodes')) {
$nlimit = 10;
$result = db_query_range('SELECT c.timestamp, c.subject, c.cid
FROM {comments} c
WHERE c.status = 1
ORDER BY c.timestamp DESC ', 0, $nlimit);
$items = array();
while ($comment = db_fetch_object($result)) {
$items[] = $comment->subject .' - '. format_date($comment->timestamp, 'medium'). ' ['. l(t('edit'),'admin/comment/edit/'. $comment->cid) .']|['.l(t('delete'),'admin/comment/delete/'. $comment->cid) .']';
}
$result2 = db_query_range('SELECT n.nid, n.title, n.changed, u.name, u.uid
FROM {node} n
INNER JOIN {users} u ON n.uid = u.uid
WHERE n.status = 0 AND n.moderate = 1
ORDER BY n.changed DESC', 0, $nlimit);
$items2 = array();
while ($node = db_fetch_object($result2)) {
$items2[] = $node->title .' - '. format_date($node->changed, 'medium'). ' ['. l(t('edit'),'node/'. $node->nid .'/edit') .']|['.l(t('delete'),'admin/node/delete/'. $node->nid) .']';
}
$block['subject'] = t('Admin block');
if ($items) {
$block['content'] = theme('item_list', $items, t('Comments queue'));
$block['content'] .= '<div class="more-link">'. l(t('more'), 'admin/comment/list/approval', array ('title' => t('Administer the approval queue'))). '</div>';
}
if ($items2) {
$block['content'] .= theme('item_list', $items2, t('Content queue'));
$block['content'] .= '<div class="more-link">'. l(t('more'), 'admin/node', array ('title' => t('Administer content'))). '</div>';
}
return $block;
}
}