Index: blogroll.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/blogroll/blogroll.module,v retrieving revision 1.6 diff -u -w -b -r1.6 blogroll.module --- blogroll.module 11 Jan 2005 23:40:15 -0000 1.6 +++ blogroll.module 21 Jan 2005 16:16:06 -0000 @@ -37,8 +37,7 @@ if ($may_cache) { $items[] = array('path' => 'blogroll/edit', 'title' => t('edit blogroll'), 'callback' => 'blogroll_edit', - 'access' => user_access('edit own blog'), // depends on blog.module - 'type' => MENU_CALLBACK); + 'access' => user_access('edit own blog')); // depends on blog.module $items[] = array('path' => 'blogroll/script', 'title' => t('blogroll'), 'callback' => 'blogroll_script', 'access' => TRUE, @@ -105,6 +104,33 @@ } /** + * _blogroll_query + * + * create the query necessary for the page on display +*/ +function _blogroll_query() { + + $pagetype = arg(0); + $pageowner = arg(1); + if (($pagetype == 'blog') AND (is_numeric($pageowner))) { + $output = 'SELECT b.uid, b.name, b.url, b.weight FROM {blogroll} b'; + $output .= " WHERE b.uid = $pageowner"; + $output .= ' ORDER BY weight, name'; + } else { + $nid = arg(1); + $output = 'SELECT b.name, b.url, Count(b.url) AS popularity FROM {blogroll} b'; + if (is_numeric($nid)) { + // getthe uid of the author of the page + if ($node = db_fetch_object(db_query("SELECT n.uid FROM {node} n WHERE n.nid = $nid"))) { + $output .= " WHERE b.uid = $node->uid"; + } + } + $output .= ' GROUP BY url, name ORDER BY popularity DESC, name'; + } + return $output; +} + +/** * Implementation of hook_block(); * * @param $op @@ -122,18 +148,31 @@ return $block; case('view'): if (user_access('access content')) { - $output = ''); + // wait until now to avoid adding empty list tags that make the header show up even though + // there's really no content + if ($output) { + $output = ""; + // but if the user is looking at his own page, the block with an edit link will display + // even if the rest of the block is empty if ($user->uid == $request_uid) { // owner viewing own blog $output .= ''; } + } $block['subject'] = t('Blogroll'); $block['content'] = $output; + break; + } + default: { + + } + } } return $block; }