/[drupal]/contributions/modules/adminblock/adminblock.module
ViewVC logotype

Contents of /contributions/modules/adminblock/adminblock.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.18 - (show annotations) (download) (as text)
Thu Jun 12 07:47:24 2008 UTC (17 months, 1 week ago) by frjo
Branch: MAIN
CVS Tags: HEAD
Changes since 1.17: +2 -2 lines
File MIME type: text/x-php
Correct path for the more link for trackbacks. Patch by chip in issue #265314, thanks
1 <?php
2 // $Id: adminblock.module,v 1.17 2008/04/16 20:06:52 frjo Exp $
3
4 /**
5 * @file
6 * Author: Fredrik Jonsson fredrik at combonet dot se
7 * Enables admins to display a block with the comments approval queue,
8 * the node moderation queue and the trackback queue.
9 *
10 * The block will only show for users with
11 * "administer comments/nodes/trackback" privilages.
12 *
13 * If there are no comments to approve, no nodes to moderate
14 * and no trackbacks to approve the block will not show.
15 */
16
17 /**
18 * Implementation of hook_block().
19 *
20 * $nlimit sets the number of comments, nodes and trackbacks to display
21 */
22 function adminblock_block($op = 'list', $delta = 0, $edit = array()) {
23 if ($op == 'list') {
24 $blocks[0]['info'] = t('Admin block');
25 return $blocks;
26 }
27 else if ($op == 'view') {
28 $nlimit = 10;
29
30 if (user_access('administer comments')) {
31 $result = db_query_range('SELECT c.timestamp, c.subject, c.cid, c.nid, n.title
32 FROM {comments} c
33 INNER JOIN {node} n ON c.nid = n.nid
34 WHERE c.status = 1
35 ORDER BY c.timestamp DESC ', 0, $nlimit);
36 $items = array();
37 while ($comment = db_fetch_object($result)) {
38 $items[] = check_plain($comment->subject) .' - '. format_date($comment->timestamp, 'medium') .'<br />['. l(t('node'), 'node/'. $comment->nid, array('fragment' => 'comment-'. $comment->cid, 'attributes' => array('title' => $comment->title))) .'] ['. l(t('edit'), 'comment/edit/'. $comment->cid) .'] ['. l(t('delete'), 'comment/delete/'. $comment->cid) .']';
39 }
40 }
41
42 if (user_access('administer nodes')) {
43 $result2 = db_query_range('SELECT n.nid, n.title, n.changed, u.name, u.uid
44 FROM {node} n
45 INNER JOIN {users} u ON n.uid = u.uid
46 WHERE n.status = 0
47 ORDER BY n.changed DESC', 0, $nlimit);
48 $items2 = array();
49 while ($node = db_fetch_object($result2)) {
50 $items2[] = check_plain($node->title) .' - '. format_date($node->changed, 'medium') .'<br />['. l(t('By @user', array('@user' => $node->name)), 'user/'. $node->uid) .'] ['. l(t('edit'), 'node/'. $node->nid .'/edit') .'] ['. l(t('delete'), 'node/'. $node->nid .'/delete') .']';
51 }
52 }
53
54 if (module_exists('trackback') && user_access('administer trackbacks')) {
55 $result3 = db_query_range('SELECT t.created, t.subject, t.nid, t.trid, t.excerpt
56 FROM {trackback_received} t
57 INNER JOIN {node} n ON t.nid = n.nid
58 WHERE t.status = 0
59 ORDER BY t.created DESC ', 0, $nlimit);
60 $items3 = array();
61 while ($trackback = db_fetch_object($result3)) {
62 $items3[] = check_plain($trackback->subject) .' - '. format_date($trackback->created, 'medium') .'<br />['. l(t('edit'), 'admin/content/trackback/edit/'. $trackback->trid) .'] ['. l(t('delete'), 'admin/content/trackback/delete/'. $trackback->trid) .']';
63 }
64 }
65
66 $block['subject'] = t('Admin block');
67 if ($items) {
68 $block['content'] = theme('item_list', $items, t('Comments queue'));
69 $block['content'] .= '<div class="more-link">'. l(t('more'), 'admin/content/comment/approval', array('attributes' => array('title' => t('Administer the approval queue')))) .'</div>';
70 }
71 if ($items2) {
72 $block['content'] .= theme('item_list', $items2, t('Content queue'));
73 $block['content'] .= '<div class="more-link">'. l(t('more'), 'admin/content/node', array('attributes' => array('title' => t('Administer content')))) .'</div>';
74 }
75 if ($items3) {
76 $block['content'] .= theme('item_list', $items3, t('Trackback queue'));
77 $block['content'] .= '<div class="more-link">'. l(t('more'), 'admin/content/trackback/list/approval', array('attributes' => array('title' => t('Administer trackbacks')))) .'</div>';
78 }
79
80 return $block;
81 }
82 }

  ViewVC Help
Powered by ViewVC 1.1.2