Index: views_cloud_plugin_summary_style_cloud.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views_cloud/views_cloud_plugin_summary_style_cloud.inc,v
retrieving revision 1.5
diff -u -r1.5 views_cloud_plugin_summary_style_cloud.inc
--- views_cloud_plugin_summary_style_cloud.inc	9 Aug 2010 21:39:02 -0000	1.5
+++ views_cloud_plugin_summary_style_cloud.inc	14 Jan 2011 20:46:57 -0000
@@ -12,6 +12,7 @@
     $options['sizes'] = array('default' => '7');
     $options['font_size'] = array('default' => '');
     $options['algorithm'] = array('default' => 'log');
+    $options['count_filter'] = array('default' => 0);
     return $options;
   }
 
@@ -24,8 +25,9 @@
       '#options' => array(
         'desc' => t('Most popular items by count'),
         'random' => t('Random items'),
+        'none' => t('Do not override'),
       ),
-      '#description' => t('This will ignore all normal sorting and sort instead by the item count.'),
+      '#description' => t('This will ignore the view sort settings and sort instead in the specified manner.'),
       '#default_value' => $this->options['sort'],
     );
 
@@ -36,6 +38,13 @@
       '#default_value' => $this->options['randomize'],
     );
 
+    $form['count_filter'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Count threshold'),
+      '#default_value' => $this->options['count_filter'],
+      '#description' => t('Enter a positive number to show only records with a count equal or greater than this number. Set to 0 to show all.'),
+    );
+
     $form['sizes'] = array(
       '#type' => 'select',
       '#title' => t('Number of font sizes'),
@@ -78,11 +87,12 @@
 
     // Add a filter to include a certain count threshold.
     if ($this->options['count_filter']) {
-      $this->view->query->add_where(0, 'num_records > %d', $this->options['count_filter']);
+      $this->view->query->add_having(0, 'num_records >= %d', $this->options['count_filter']);
     }
 
-    // Override normal sorting and sort by number of results.
-    if ($this->options['sort'] == 'random') {
+    // Override normal sorting
+    switch ($this->options['sort']) {
+    case 'random':
       global $db_type;
       switch ($db_type) {
         case 'mysql':
@@ -98,10 +108,14 @@
         $this->view->query->add_field(NULL, $formula, 'random', array('aggregate' => TRUE));
         $this->view->query->orderby[] = 'random DESC';
       }
-    }
-    elseif ($this->options['sort']) {
+      break;
+
+    case 'desc':
       $this->view->query->orderby = array();
-      $this->view->query->add_orderby(NULL, NULL, $this->options['sort'], 'num_records');
+      $this->view->query->add_orderby(NULL, NULL, 'DESC', 'num_records');
+      break;
+
+      // Note: default case - do nothing.
     }
   }
 }
