Index: l10n_community/l10n_community.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/l10n_server/l10n_community/Attic/l10n_community.module,v
retrieving revision 1.1.2.23.2.63
diff -u -r1.1.2.23.2.63 l10n_community.module
--- l10n_community/l10n_community.module	27 Dec 2009 08:55:11 -0000	1.1.2.23.2.63
+++ l10n_community/l10n_community.module	31 Dec 2009 19:15:51 -0000
@@ -35,6 +35,11 @@
  */
 define('L10N_STATUS_HAS_SUGGESTION', 8);
 
+/**
+ * Define one day expiring time.
+ */
+define('L10N_1_DAY_EXPIRING_TIME', time() + 60 * 60 * 24);
+
 // = Core hooks ================================================================
 
 /**
@@ -411,6 +416,12 @@
           'enabled' => 1,
           'region' => 'left'
         ),
+        'latest_translations' => array(
+          'info' => t('Latest translations'),
+        ),
+        'top_translators' => array(
+          'info' => t('Top translators'),
+        ),
       );
       return $blocks;
 
@@ -426,6 +437,16 @@
             return l10n_community_block_stats();
           }
           return;
+        case 'latest_translations':
+          if (user_access('access localization community')) {
+            return l10n_community_block_latest_translations();
+          }
+          return;
+        case 'top_translators':
+          if (user_access('access localization community')) {
+            return l10n_community_block_top_translators();
+          }
+          return;
       }
   }
 }
@@ -550,6 +571,71 @@
 }
 
 /**
+ * Latest translations block.
+ */
+function l10n_community_block_latest_translations() {
+  $cid = 'l10n:latest_translations';
+  if ($cache = cache_get($cid)) {
+    $blockcontent = $cache->data;
+  }
+  else {
+    $translations = array();
+    $query = db_query_range("SELECT language, translation, uid_entered FROM {l10n_community_translation} WHERE is_active = 1 ORDER BY time_entered DESC", 0, 10);
+    $browse_translations = FALSE;
+    if (user_access('browse translations')) {
+      $browse_translations = TRUE;
+    }
+    while ($translation = db_fetch_object($query)) {
+      $translation->translation = strip_tags($translation->translation);
+      $language = $translation->language;
+      $translation->account = user_load($translation->uid_entered);
+      $translation->translation = truncate_utf8($translation->translation, 60, TRUE, FALSE);
+      $link_to_translation = '';
+      if ($browse_translations) {
+        $l_query = array(
+          'attributes' => array('title' => t('Browse')),
+          'query' => array(
+            'search' => $translation->translation,),
+        );
+        $link_to_translation = l(t('Browse'), 'translate/languages/' . $language .'/view', $l_query);
+        $link_to_translation = ' [' . $link_to_translation .']';
+      }
+
+      $translations[] =  t('@translation!Browse by !account ', array('@translation' => $translation->translation, '!account' => theme('username', $translation->account), '!Browse' => $link_to_translation));
+    }
+    $blockcontent =  theme('item_list', $translations);
+    cache_set($cid, $blockcontent, 'cache', L10N_1_DAY_EXPIRING_TIME);
+  }
+  return array(
+    'subject' => t('Latest translations'),
+    'content' => $blockcontent,
+  );
+}
+
+/**
+ * Top translators block.
+ */
+function l10n_community_block_top_translators() {
+  $cid = 'l10n:top_translators';
+  if ($cache = cache_get($cid)) {
+    $blockcontent = $cache->data;
+  }
+  else {
+    $translators = array();
+    $query = db_query_range("SELECT uid_entered, COUNT(tid) AS tid_count FROM {l10n_community_translation} WHERE uid_entered != 0 AND is_suggestion = 0 AND is_active = 1 GROUP BY uid_entered ORDER BY tid_count DESC", 0, 10);
+    while ($translator = db_fetch_object($query)) {
+      $translators[] = theme('username', user_load($translator->uid_entered)) .' '. format_plural($translator->tid_count, '1 approved translation', '@count approved translations');
+    }
+    $blockcontent = theme('item_list', $translators);
+    cache_set($cid, $blockcontent, 'cache', L10N_1_DAY_EXPIRING_TIME);
+  }
+  return array(
+    'subject' => t('Top translators'),
+    'content' => $blockcontent,
+  );
+}
+
+/**
  * Implementation of hook_user().
  */
 function l10n_community_user($op, &$edit, &$account, $category = NULL) {
