diff --git adminblock.info adminblock.info
index f7f23d5..e9d8969 100644
--- adminblock.info
+++ adminblock.info
@@ -2,4 +2,4 @@
 name = Admin block
 description = Block that display the comments approval queue, the node moderation queue and the trackback queue.
 package = Administration
-core = 6.x
\ No newline at end of file
+core = 7.x
\ No newline at end of file
diff --git adminblock.module adminblock.module
index bb0d4bf..61e5af7 100644
--- adminblock.module
+++ adminblock.module
@@ -15,69 +15,83 @@
  */
 
 /**
- * Implementation of hook_block().
+ * Implements hook_block_info().
+ */
+function adminblock_block_info() {
+  $blocks[0]['info'] = t('Admin block');
+  $blocks[0]['properties']['administrative'] = TRUE;
+  return $blocks;
+}
+
+/**
+ * Implements hook_block_view().
  *
  * $nlimit sets the number of comments, nodes and trackbacks to display
  */
-function adminblock_block($op = 'list', $delta = 0, $edit = array()) {
-  if ($op == 'list') {
-    $blocks[0]['info'] = t('Admin block');
-    return $blocks;
-  }
-  else if ($op == 'view') {
-    $nlimit = 10;
-    $items = array();
-    $items2 = array();
-    $items3 = array();
-
-    if (user_access('administer comments')) {
-      $result = db_query_range('SELECT c.timestamp, c.subject, c.cid, c.nid, n.title
-        FROM {comments} c
-        INNER JOIN {node} n ON c.nid = n.nid
-        WHERE c.status = 1
-        ORDER BY c.timestamp DESC ', 0, $nlimit);
-      $comment_delete_path = module_exists('mollom') && mollom_get_mode('comment_form') ? 'mollom/report/comment/' : 'comment/delete/';
-      while ($comment = db_fetch_object($result)) {
-        $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_path . $comment->cid) .']';
-      }
-    }
+function adminblock_block_view($delta) {
+  $nlimit = 10;
+  $items = array();
+  $items2 = array();
+  $items3 = array();
 
-    if (user_access('administer nodes')) {
-      $result2 = db_query_range('SELECT n.nid, n.title, n.type, n.changed, u.name, u.uid
-        FROM {node} n
-        INNER JOIN {users} u ON n.uid = u.uid
-        WHERE n.status = 0
-        ORDER BY n.changed DESC', 0, $nlimit);
-      while ($node = db_fetch_object($result2)) {
-        $node_delete_path = module_exists('mollom') && mollom_get_mode($node->type .'_node_form') ? 'mollom/report/node/'. $node->nid : 'node/'. $node->nid .'/delete';
-        $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_delete_path) .']';
-      }
+  if (user_access('administer comments')) {
+    $select = db_select('comment', 'c');
+    $select->innerJoin('node', 'n', 'c.nid = n.nid');
+    $result = $select
+      ->fields('c', array('created', 'subject', 'cid', 'nid'))
+      ->fields('n', array('title'))
+      ->condition('c.status', 1)
+      ->orderBy('c.created', 'DESC')
+      ->range(0, $nlimit)
+      ->execute();
+    $comment_delete_path = module_exists('mollom') && mollom_get_mode('comment_form') ? 'mollom/report/comment/' : 'comment/delete/';
+    foreach ($result as $comment) {
+      $items[] = check_plain($comment->subject) .' - '. format_date($comment->created, 'medium') .'<br />['. l(t('node'), 'node/'. $comment->nid, array('fragment' => 'comment-'. $comment->cid, 'attributes' => array('title' => $comment->title))) .'] ['. l(t('edit'), 'comment/'. $comment->cid .'/edit') .'] ['. l(t('delete'), $comment_delete_path . $comment->cid) .']';
     }
+  }
 
-    if (module_exists('trackback') && user_access('administer trackbacks')) {
-      $result3 = db_query_range('SELECT t.created, t.subject, t.trid
-        FROM {trackback_received} t
-        WHERE t.status = 0
-        ORDER BY t.created DESC ', 0, $nlimit);
-      while ($trackback = db_fetch_object($result3)) {
-        $items3[] = check_plain($trackback->subject) .' - '. format_date($trackback->created, 'medium') .'<br />['. l(t('edit'), 'trackback/edit/'. $trackback->trid) .'] ['. l(t('delete'), 'trackback/delete/'. $trackback->trid) .']';
-      }
+  if (user_access('administer nodes')) {
+    $select = db_select('node', 'n');
+    $select->innerJoin('users', 'u', 'n.uid = u.uid');
+    $result = $select
+      ->fields('n', array('nid', 'title', 'type', 'changed'))
+      ->fields('u', array('name', 'uid'))
+      ->condition('n.status', 0)
+      ->orderBy('n.changed', 'DESC')
+      ->range(0, $nlimit)
+      ->execute();
+    foreach ($result as $node) {
+      $node_delete_path = module_exists('mollom') && mollom_get_mode($node->type .'_node_form') ? 'mollom/report/node/'. $node->nid : 'node/'. $node->nid .'/delete';
+      $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_delete_path) .']';
     }
+  }
 
-    $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/content/comment/approval', array('attributes' => 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/content/node', array('attributes' => array('title' => t('Administer content')))) .'</div>';
-    }
-    if ($items3) {
-      $block['content'] .= theme('item_list', $items3, t('Trackback queue'));
-      $block['content'] .= '<div class="more-link">'. l(t('more'), 'admin/content/trackback/list/approval', array('attributes' => array('title' => t('Administer trackbacks')))) .'</div>';
+  if (module_exists('trackback') && user_access('administer trackbacks')) {
+    $select = db_select('trackback_received', 't');
+    $result = $select
+      ->fields('t', array('created', 'subject', 'trid'))
+      ->condition('t.status', 0)
+      ->orderBy('t.created', 'DESC')
+      ->range(0, $nlimit)
+      ->execute();
+    foreach ($result as $trackback) {
+      $items3[] = check_plain($trackback->subject) .' - '. format_date($trackback->created, 'medium') .'<br />['. l(t('edit'), 'trackback/edit/'. $trackback->trid) .'] ['. l(t('delete'), 'trackback/delete/'. $trackback->trid) .']';
     }
+  }
 
-    return $block;
+  $block['subject'] = t('Admin block');
+  if ($items) {
+    $block['content'] = theme('item_list', array('items' => $items, 'title' => t('Comments queue')));
+    $block['content'] .= '<div class="more-link">'. l(t('more'), 'admin/content/comment/approval', array('attributes' => array('title' => t('Administer the approval queue')))) .'</div>';
   }
+  if ($items2) {
+    $block['content'] .= theme('item_list', array('items' => $items2, 'title' => t('Content queue')));
+    $block['content'] .= '<div class="more-link">'. l(t('more'), 'admin/content/node', array('attributes' => array('title' => t('Administer content')))) .'</div>';
+  }
+  if ($items3) {
+    $block['content'] .= theme('item_list', array('items' => $items3, 'title' => t('Trackback queue')));
+    $block['content'] .= '<div class="more-link">'. l(t('more'), 'admin/content/trackback/list/approval', array('attributes' => array('title' => t('Administer trackbacks')))) .'</div>';
+  }
+
+  return $block;
 }
