? userpoints_top_contributors-854868.patch
Index: userpoints_top_contributors.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/userpoints_top_contributors/userpoints_top_contributors.module,v
retrieving revision 1.1.4.6
diff -u -p -r1.1.4.6 userpoints_top_contributors.module
--- userpoints_top_contributors.module	12 Apr 2010 16:48:15 -0000	1.1.4.6
+++ userpoints_top_contributors.module	4 Oct 2010 23:39:10 -0000
@@ -17,15 +17,15 @@ function userpoints_top_contributors_men
     'title' => t('Top Contributors'),
     'access arguments' => array('view userpoints'),
     'type' => MENU_CALLBACK,
-  ); 
-  
+  );
+
   $items['userpoints/list/period'] = array(
     'title callback' => 'userpoints_top_contributors_list_period_title',
     'page callback' => 'userpoints_top_contributors_list',
     'access arguments' => array('view userpoints'),
     'type' => MENU_CALLBACK,
   );
-  
+
   return $items;
 }
 
@@ -33,7 +33,7 @@ function userpoints_top_contributors_men
  * Title callback for period page title.
  */
 function userpoints_top_contributors_list_period_title() {
-  $period = format_interval(variable_get(userpoints_top_contributors_period, 86400));
+  $period = format_interval(variable_get('userpoints_top_contributors_period', 86400));
   return t('Top Contributors: '. $period);
 }
 
@@ -41,7 +41,7 @@ function userpoints_top_contributors_cro
     // Refresh the top users data
     _userpoints_top_contributors_create_summary_data();
 }
-    
+
 /**
  * Implementation of hook_form_alter().
  *
@@ -52,7 +52,7 @@ function userpoints_top_contributors_for
     // Shift system_settings_form buttons.
     $weight = $form['buttons']['#weight'];
     $form['buttons']['#weight'] = $weight + 1;
-    
+
     $group = "top_contributors";
     $form[$group] = array(
       '#type' => 'fieldset',
@@ -61,19 +61,19 @@ function userpoints_top_contributors_for
       '#collapsed' => TRUE,
       '#description' => t(''),
     );
-    
+
     $form[$group]['userpoints_top_contributors_block_usercount'] = array(
       '#type'          => 'select',
       '#title'         => t('Users per block'),
-      '#default_value' => variable_get(userpoints_top_contributors_block_usercount, 30),
+      '#default_value' => variable_get('userpoints_top_contributors_block_usercount', 30),
       '#options'       => array(5 => 5, 10 => 10, 15 => 15),
-      '#description'   => t('Limit how many users to display in the Top Contributors block.'), 
+      '#description'   => t('Limit how many users to display in the Top Contributors block.'),
     );
-    
+
     $form[$group]['userpoints_top_contributors_period'] = array(
       '#type'          => 'select',
       '#title'         => t('Period for top users block and page'),
-      '#default_value' => variable_get(userpoints_top_contributors_period, 86400),
+      '#default_value' => variable_get('userpoints_top_contributors_period', 86400),
       '#options'       => drupal_map_assoc(
         array(86400, 172800, 259200, 259200, 432000, 604800, 1209600, 1814400, 2419200), 'format_interval'),
       '#description'   => t('Time block used to calculate contributions made in
@@ -81,11 +81,11 @@ function userpoints_top_contributors_for
                             want the "Contributions by period" block and page to
                             list the top contributors in the past week.'),
     );
-    
+
     $form[$group]['userpoints_top_contributors_page_intro'] = array(
       '#type'          => 'textarea',
       '#title'         => t("Page Introduction"),
-      '#default_value' => variable_get(userpoints_top_contributors_page_intro, '<p>Here\'s a list of our community\'s top contributors. Click any of the column headings to change the sort order of the table.</p>'),
+      '#default_value' => variable_get('userpoints_top_contributors_page_intro', '<p>Here\'s a list of our community\'s top contributors. Click any of the column headings to change the sort order of the table.</p>'),
       '#cols'          => 70,
       '#rows'          => 4,
       '#description'   => t("Text to display at the top of the Top Contributors pages."),
@@ -97,19 +97,19 @@ function userpoints_top_contributors_lis
   global $user;
   $list_type = db_escape_string(arg(2));
   $cron_last = variable_get('cron_last', NULL);
-  
+
   $sql = "SELECT p.uid, p.rank, u.name, p.period_points, p.current_points, p.lifetime_points
           FROM {userpoints_top_contributors} p
           INNER JOIN {users} u
           USING (uid)";
 
   $sql_cnt = "SELECT COUNT(uid) FROM {userpoints_top_contributors}";
-  
+
   if ($list_type == 'all') {
     $header = array(
       array('data' => t('Rank'), 'field' => 'p.rank'),
       array('data' => t('User'), 'field' => 'u.name'),
-      array('data' => t(format_interval(variable_get(userpoints_top_contributors_period, 86400))), 'field' => 'period_points', 'style' => 'text-align:right'),
+      array('data' => t(format_interval(variable_get('userpoints_top_contributors_period', 86400))), 'field' => 'period_points', 'style' => 'text-align:right'),
       array('data' => t('Current'), 'field' => 'current_points', 'style' => 'text-align:right'),
       array('data' => t('Lifetime'), 'field' => 'lifetime_points', 'sort' => 'desc', 'style' => 'text-align:right'),
     );
@@ -118,12 +118,12 @@ function userpoints_top_contributors_lis
       $header = array(
       array('data' => t('Rank'), 'field' => 'p.rank'),
       array('data' => t('User'), 'field' => 'u.name'),
-      array('data' => t(format_interval(variable_get(userpoints_top_contributors_period, 86400))), 'field' => 'period_points', 'sort' => 'desc', 'style' => 'text-align:right'),
+      array('data' => t(format_interval(variable_get('userpoints_top_contributors_period', 86400))), 'field' => 'period_points', 'sort' => 'desc', 'style' => 'text-align:right'),
       array('data' => t('Current'), 'field' => 'current_points', 'style' => 'text-align:right'),
       array('data' => t('Lifetime'), 'field' => 'lifetime_points', 'style' => 'text-align:right'),
     );
   }
-  
+
   $sql .= tablesort_sql($header);
   $usr_cnt = variable_get(USERPOINTS_REPORT_USERCOUNT, 30);
   $result = pager_query($sql, $usr_cnt, 0, $sql_cnt);
@@ -135,7 +135,7 @@ function userpoints_top_contributors_lis
       $details = '&nbsp;&nbsp;('. l(t('details'), 'myuserpoints/'. $data->uid) .')';
     }
     else {
-      $details = '';  
+      $details = '';
     }
     $rows[] = array(
       array('data' => $data->rank .'.', 'style' => 'text-align:left'),
@@ -146,7 +146,7 @@ function userpoints_top_contributors_lis
     );
   }
 
-  $output = t(variable_get(userpoints_top_contributors_page_intro, 'Here\'s a list of our community\'s top contributors. Click any of the column headings to change the sort order of the table.'));
+  $output = t(variable_get('userpoints_top_contributors_page_intro', 'Here\'s a list of our community\'s top contributors. Click any of the column headings to change the sort order of the table.'));
   $output .= '<p>'. t('Updated !time ago.', array('!time' => format_interval(time() - $cron_last))) .'</p>';
   $output .= theme('table', $header, $rows);
   $output .= theme('pager', NULL, $usr_cnt, 0);
@@ -157,7 +157,7 @@ function userpoints_top_contributors_lis
 function userpoints_top_contributors_block($op = 'list', $delta = 0, $edit = array()) {
   global $user;
 
-  $usr_cnt = variable_get(userpoints_top_contributors_block_usercount, 10);
+  $usr_cnt = variable_get('userpoints_top_contributors_block_usercount', 10);
 
   switch ($op) {
     case 'list':
@@ -169,14 +169,14 @@ function userpoints_top_contributors_blo
       if (user_access('view userpoints')) {
         if ($delta == 0) {
           $title = t('Top Contributors');
-          
+
           $result = db_query_range("SELECT p.uid, u.name, p.lifetime_points
                                     FROM {userpoints_top_contributors} p
                                     INNER JOIN {users} u
                                     USING (uid)
                                     GROUP BY p.uid
                                     ORDER BY p.lifetime_points DESC", 0, $usr_cnt);
-          
+
           while ($data = db_fetch_object($result)) {
             $rows[] = array(
                 array('data' => theme('username', $data)),
@@ -195,12 +195,12 @@ function userpoints_top_contributors_blo
             array('data' => t('!Points', userpoints_translation()), 'style' => 'text-align:right')
           );
           $content = theme('table', $header, $rows);
-        
+
           // more link
           $content .= '<div class="more-link">'. l(t('more'), 'userpoints/list/all', array('title' => t('All users by !points', userpoints_translation()))) .'</div>';
         }
         else {
-          $title = t('Top Contributors: '. format_interval(variable_get(userpoints_top_contributors_period, 86400)));
+          $title = t('Top Contributors: '. format_interval(variable_get('userpoints_top_contributors_period', 86400)));
           $result = db_query_range('SELECT p.uid, u.name, p.period_points
                                     FROM {userpoints_top_contributors} p
                                     INNER JOIN {users} u
@@ -218,11 +218,11 @@ function userpoints_top_contributors_blo
             array('data' => t('!Points', userpoints_translation()), 'style' => 'text-align:right')
           );
           $content = theme('table', $header, $rows);
-          
+
           // more link
           $content .= '<div class="more-link">'. l(t('more'), 'userpoints/list/period', array('title' => t('All users by !period', userpoints_translation()))) .'</div>';
         }
-        
+
       $block['subject'] = $title;
       $block['content'] = $content;
       return $block;
@@ -238,21 +238,21 @@ function userpoints_top_contributors_use
         // Get the points for the user
         $lifetime_points = number_format(userpoints_get_max_points($account->uid, 'all'));
         $current_points = number_format(userpoints_get_current_points($account->uid, 'all'));
-      
+
         if (user_access('administer userpoints')) {
           $current_points = $current_points .'&nbsp;&nbsp;'. l(t('details'), 'myuserpoints/'. $account->uid, array('title' => t('Details'))) .'&nbsp;&nbsp;'. l(t('manage'), 'admin/user/userpoints/add/'. $account->uid, array('title' => t('Add points')));
         }
-      
+
         $disp_points[] = array(
           'title' => t('Lifetime'),
           'value' => $lifetime_points,
           );
-      
+
         $disp_points[] = array(
           'title' => t('Current'),
           'value' => $current_points,
           );
-      
+
         return array(t('!Points', userpoints_translation()) => $disp_points);
       }
     break;
@@ -261,7 +261,7 @@ function userpoints_top_contributors_use
 
 function _userpoints_top_contributors_create_summary_data() {
 
-  $period = time() - variable_get(userpoints_top_contributors_period, 86400);
+  $period = time() - variable_get('userpoints_top_contributors_period', 86400);
 
   // Empty the userpoints_top_contributors table
   db_query("TRUNCATE TABLE {userpoints_top_contributors}");
@@ -273,7 +273,7 @@ function _userpoints_top_contributors_cr
     WHERE status = 0 AND points > 0
     GROUP BY uid"
   );
-  
+
   // Populate the rank field
   $result = db_query("SELECT *
     FROM {userpoints_top_contributors}
@@ -289,13 +289,13 @@ function _userpoints_top_contributors_cr
           $current_points = $data->lifetime_points;
           $rank++;
       }
-     
+
     db_query("UPDATE {userpoints_top_contributors}
       SET rank = %d
       WHERE uid = %d", $rank, $data->uid
     );
   }
-  
+
   // Populate it with current_points
   db_query("UPDATE {userpoints_top_contributors} AS up
     INNER
@@ -308,7 +308,7 @@ function _userpoints_top_contributors_cr
         ON q.uid = up.uid
        SET up.current_points = q.cp"
   );
-  
+
   // Populate it with period_points
   db_query("UPDATE {userpoints_top_contributors} AS up
     INNER
