--- blogger/blogger.module 2008-06-17 22:36:34.000000000 -0400 +++ blogger/blogger.module 2009-04-13 09:43:31.000000000 -0400 @@ -3,29 +3,29 @@ /** * @file - * The Blogger module displays list of bloggers. + * The blogger module displays list of blogger. */ /** * Implementation of hook_help(). */ -function blogger_help($section) { - switch ($section) { +function blogger_help($path, $arg) { + switch ($path) { case 'admin/help#blogger': - $output = '

'. t('The Blogger module displays a list of bloggers.') .'

'; + $output = '

'. t('The blogger module displays a list of blogger.') .'

'; $output .= t("

You can configure:" ."

" ."

"); return $output; case 'admin/modules#description': - return t('Displays list of bloggers.'); + return t('Displays list of blogger.'); } } @@ -48,12 +48,27 @@ function blogger_admin_settings() { '#collapsible' => TRUE, '#collapsed' => FALSE ); - + + $roles = user_roles($membersonly = TRUE); + $role_options = array(); + + foreach ($roles as $rid => $name) { + $role_options[$rid] = $name; + } + + $form['blogger_settings']['blogger_roles'] = array( + '#type' => 'checkboxes', + '#title' => t('Roles to be displayed'), + '#default_value' => variable_get('blogger_roles', array()), + '#options' => $role_options, + '#description' => t('Users of the selected roles will be displayed in the blogger list.'), + ); + $form['blogger_settings']['blogger_maxdisp'] = array( '#type' => 'textfield', - '#title' => t('Maximum number of bloggers'), + '#title' => t('Maximum number of blogger'), '#default_value' => variable_get('blogger_maxdisp', 10), - '#description' => t("The maximum number of bloggers to display in the block."), + '#description' => t("The maximum number of blogger to display in the block."), '#maxlength' => '5', '#size' => '5'); $form['blogger_settings']['blogger_shownum'] = array( @@ -90,9 +105,9 @@ function blogger_admin_settings() { $form['blogger_settings_advanced']['blogger_on_blog_only'] = array( '#type' => 'checkbox', - '#title' => t('Show Blogger module when content type is blog only.'), + '#title' => t('Show blogger module when content type is blog only.'), '#default_value' => variable_get('blogger_on_blog_only', 0), - '#description' => t("Show Blogger module when content type is blog only, otherwise hide this module."), + '#description' => t("Show blogger module when content type is blog only, otherwise hide this module."), '#maxlength' => '1', '#size' => '1'); $form['blogger_settings_advanced']['blogger_exclude'] = array( @@ -138,25 +153,25 @@ function blogger_admin_settings() { * Menu callback. Prints a listing of active nodes on the site. */ -function blogger_menu($may_cache) { +function blogger_menu() { // Add main CSS functionality. drupal_add_css(drupal_get_path('module', 'blogger') .'/blogger.css'); $items = array(); - $items[] = array( - 'path' => 'admin/settings/blogger', - 'title' => t('Blogger'), - 'description' => t('Control how blogger displayed.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('blogger_admin_settings'), - 'access' => user_access('administer blogger'), + $items['admin/settings/blogger'] = array( + 'title' => 'blogger', + 'description' => 'Control how blogger displayed.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('blogger_admin_settings'), + 'access callback' => 'user_access', + 'access arguments' => array('administer blogger'), 'type' => MENU_NORMAL_ITEM); - $items[] = array( - 'path' => 'blogger/list', - 'title' => t('Blogger'), - 'callback' => 'blogger_page_list', - 'access' => user_access('access blogger'), + $items['blogger/list'] = array( + 'title' => 'blogger', + 'page callback' => 'blogger_page_list', + 'access callback' => user_access('access blogger'), + 'access arguments' => user_access('access blogger'), 'type' => MENU_CALLBACK); return $items; @@ -170,13 +185,14 @@ function blogger_menu($may_cache) { function blogger_block($op = 'list', $delta = 0) { if ($op == 'list') { - $blocks[0]['info'] = t('Bloggers'); + $blocks[0]['info'] = t('blogger'); return $blocks; } if ($op == 'view' && user_access('access blogger')) { - $maxdisp = variable_get("blogger_maxdisp", 10); + $maxdisp = variable_get("blogger_maxdisp", 10); + $blogger_roles = variable_get("blogger_roles", array()); $shownum = variable_get("blogger_shownum", 0); $blogger_order = variable_get("blogger_order", 0); $blogger_exclude = variable_get("blogger_exclude", "'0'"); @@ -189,7 +205,7 @@ function blogger_block($op = 'list', $de if ($blogger_on_blog_only) { if (arg(0) != 'blog') { - if (arg(0) == 'node' && is_numeric(arg(1))) { + if ($node = menu_get_object()) { $node = node_load(arg(1)); $content_type = $node->type; if ($content_type!='blog') {return FALSE;} @@ -201,7 +217,7 @@ function blogger_block($op = 'list', $de $sql = " SELECT n.uid, u.name, count(u.name) AS numitems, u.picture " ." FROM {node} n " - ." INNER JOIN {users} u ON u.uid = n.uid " + ." INNER JOIN {users} u ON u.uid = n.uid" ." WHERE n.type = 'blog' and n.status = 1 " ." and n.uid not in ($blogger_exclude) " ." GROUP BY n.uid" @@ -216,10 +232,11 @@ function blogger_block($op = 'list', $de $block_content = '
'; - if (!db_num_rows($results)) { - $block_content .= 'No blogger'; - $block_content .= '
'; - } else { +// if (!$results) { +// $block_content .= 'No blogger'; +// $block_content .= ''; +// } else + { $block_content .= ''; $i = 0; @@ -248,7 +265,7 @@ function blogger_block($op = 'list', $de .($blogger_avatar_height<>0 ? " height=$blogger_avatar_height " : " ") .">"; } else { - $showpict = ""; + $showpict = ""; } $block_content .= ''; @@ -267,12 +284,12 @@ function blogger_block($op = 'list', $de // add a more link to our page that displays all the links $block_content .= ''; } - $block['subject'] = t('Bloggers'); + $block['subject'] = t('blogger'); $block['content'] = $block_content; return $block; } @@ -290,14 +307,14 @@ function blogger_page_list() $blogger_avatar_width = variable_get("blogger_avatar_width", 0); $blogger_avatar_height = variable_get("blogger_avatar_height", 0); - $sql_counts = " SELECT DISTINCT (u.name)" - ." FROM {users} u" - ." INNER JOIN {node} n ON n.uid=u.uid" - ." WHERE u.name<>'' AND n.type='blog' AND n.status=1" - ; + $sql_counts = "SELECT COUNT(DISTINCT (name)) + FROM users INNER JOIN node + ON node.uid = users.uid + WHERE users.name <> '' + AND node.type = 'blog' + AND node.status = 1"; + $dse_sql_counts = db_query($sql_counts); - $cnt_sql_counts = db_num_rows($dse_sql_counts); - $sql_counts = "SELECT $cnt_sql_counts"; $sql = " SELECT n.uid, u.name, count(u.name) AS numitems, u.picture, n.title " ." FROM {node} n "