I'm trying to make a adminblock.module and the first part is to show the comments approval queue. I have it working but I would like the block to show only when there are comments to approve.
The && $items != "" in adminblock_block() is not working. Any tips or hints?
As you no doubt can tell I'm not a PHP programmer.
[?php
// adminblock.module v0.1.0, Fredrik Jonsson, 2004-07-15
// (Based on latest.module v0.1.0, John Clift, 11 Dec 2003)
function adminblock_help($section = "admin/help#adminblock") {
$output = "";
switch ($section) {
case 'admin/system/modules#description':
$output = t("Block that display the comments approval queue.");
break;
}
return $output;
}
// Database query to get the comments approval queue
// $nlimit sets the number of comments titles to display
function adminblock_content() {
$nlimit = 10;
$result = db_query_range("SELECT c.timestamp, c.subject, c.cid, c.status
FROM comments c
WHERE c.status = 1
ORDER BY c.timestamp
DESC ", 0, $nlimit);
while ($comment = db_fetch_object($result)) {
$items[] = check_output($comment->subject)." "." - ".format_date($comment->timestamp, "medium")." [".l(t("edit"),"admin/comment/edit/".$comment->cid)."]|[".l(t("delete"),"admin/comment/delete/".$comment->cid)."]";
}
$output = theme("item_list", $items);