? microsummary_coder_cleanup.patch Index: microsummary.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/microsummary/microsummary.module,v retrieving revision 1.7.2.1 diff -u -p -r1.7.2.1 microsummary.module --- microsummary.module 9 Jun 2008 21:16:05 -0000 1.7.2.1 +++ microsummary.module 9 Jun 2008 21:22:11 -0000 @@ -3,7 +3,7 @@ /** * @file - * microsummary.module - basically provides module integration to Drupal + * microsummary.module - basically provides module integration to Drupal * and inserts the microsummary link into your site's pages. */ @@ -14,8 +14,8 @@ function microsummary_help($path, $arg) { switch ($path) { case 'admin/help#microsummary': - return t('Creates a simple microsummary for your site showing one of a couple things. - The default is to provide three different microsummaries. + return t('Creates a simple microsummary for your site showing one of a couple things. + The default is to provide three different microsummaries. The module can also be configured to show other microsummaries based upon nodes that the administrator has created.'); case 'admin/modules#description': @@ -119,52 +119,51 @@ function microsummary_admin_settings() { '#description' => t('An optional suffix for the microsummary. This value will be placed at the end of the microsummary bookmark. Firefox shows the user as few as the first 24 characters so this value may not be seen.'), ); - } + } return system_settings_form($form); } /** * callback for microsummary pages - * + * */ function microsummary_page($type) { - global $user; switch ($type) { case 'posts': $node_count = 0; - - //get some information about content + + // Get some information about content. if (!$user->uid) { - //return count new/updated nodes in last week + // Return count new/updated nodes in last week. $new = db_result(db_query(db_rewrite_sql("SELECT COUNT(DISTINCT n.nid) FROM {node} n WHERE n.created > %d"), time() - 30 * 24 * 60 * 60)); $updated = db_result(db_query(db_rewrite_sql("SELECT COUNT(DISTINCT n.nid) FROM {node} n WHERE n.changed > %d"), time() - 30 * 24 * 60 * 60)); } else { //return count new/updated nodes for this user $new = db_result(db_query(db_rewrite_sql("SELECT COUNT(DISTINCT n.nid) FROM {node} n LEFT OUTER JOIN {history} h ON n.nid = h.nid AND h.uid = %d WHERE h.nid IS NULL"), $user->uid)); - $updated = db_result(db_query(db_rewrite_sql("SELECT COUNT(DISTINCT n.nid) FROM {node} n INNER JOIN {history} h ON n.nid = h.nid WHERE h.uid = %d AND h.timestamp < n.changed"), $user->uid)); + $updated = db_result(db_query(db_rewrite_sql("SELECT COUNT(DISTINCT n.nid) FROM {node} n INNER JOIN {history} h ON n.nid = h.nid WHERE h.uid = %d AND h.timestamp < n.changed"), $user->uid)); //TODO: return count new comments for this user } $output = t('posts %new new %updated updated', - array('%new' => $new, '%updated' => $updated)); + array('%new' => $new, '%updated' => $updated)); break; + case 'users': //get some status on users $registered = db_result(db_query(db_rewrite_sql("SELECT COUNT(uid) FROM {users} WHERE status = 1;"))); $active = db_result(db_query(db_rewrite_sql("SELECT COUNT(uid) FROM {users} WHERE login > 0"))); - - $output = t('users: %registered registered %active active', - array('%new' => $new, '%updated' => $updated , '%registered' => $registered , '%active' => $active)); + $output = t('users: %registered registered %active active', + array('%new' => $new, '%updated' => $updated , '%registered' => $registered , '%active' => $active)); break; - - case 'blog': - $rec = db_fetch_object(db_query("SELECT title, created FROM {node} WHERE status = 1 ORDER BY created DESC LIMIT 1")); + + case 'blog': + $rec = db_fetch_object(db_query_range("SELECT title, created FROM {node} WHERE status = 1 ORDER BY created DESC", 0, 1)); $posted = format_date($rec->created, 'custom', variable_get('date_format_short', 'm/d/Y - H:i')); $output = t('%title posted: %posted', array('%title' => $rec->title, '%posted' => $posted)); break; - + case 'node': $node = node_load(arg(1)); $output = str_replace(array("\r\n", "\n", "\r"), "", check_markup($node->body, $node->format, FALSE)); @@ -187,36 +186,33 @@ function microsummary_block($op = 'list' else if ($op == 'view') { switch ($delta) { // Shows microsummary block - case 0 : + case 0: $block['content'] = microsummary_get_links(); $block['subject'] = ''; - - return $block; - - break; + return $block; } } } /** * function used to insert the microsummary links into the page - * + * * @param return * HTML formatted content suitable to be inserted in a block or theme */ function microsummary_get_links() { $output = ''; $nids = variable_get('microsummary_nids', FALSE); - + //Only parse this data if we need it. if (variable_get('microsummary_show_defaults', TRUE) || $nids) { $protocol = 'http://'; - + // Are we on a secure page? - if ($_SERVER['HTTPS']) { + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) { $protocol = 'https://'; } - + $protocol = 'http://'; //should microsummaries ever be on https? TODO: enable that. $host = getenv("SERVER_NAME"); if (variable_get('clean_url', 0)==0) { @@ -226,14 +222,14 @@ function microsummary_get_links() { $url_prefix = $protocol . $host . base_path(); } } - + // Only show the default microsummaries if they are enabled. if (variable_get('microsummary_show_defaults', TRUE)) { $output .= ''; $output .= ''; $output .= ''; } - + // If there are nodes configured for microsummary, advertise those. if ($nids) { foreach (explode(',', $nids) as $nid) {