--- ad-5.x-1.x-dev/ad_views.inc	2008-02-05 16:52:34.000000000 -0800
+++ ad/ad_views.inc	2008-04-15 22:58:54.000000000 -0700
@@ -207,9 +207,23 @@ function ad_views_default_views() {
     $views[$view->name] = $view;
   }
 
+  $ad_vid = _ad_get_vid();
+  $term_node_table_name = 'term_node_'. $ad_vid;
+
   // Build blocks to display all ads of each group.
   $groups = ad_handler_filter_group('');
   foreach ($groups as $group) {
+    $terms = taxonomy_get_term_by_name($group);
+    foreach ($terms as $item) {
+      if ($item->vid == $ad_vid) {
+        $group_tid = $item->tid;
+      }
+    }
+    if (!isset($group_tid)) {
+      watchdog('ad', t('Unable to create View for @group', array('@group' => $group)));
+      continue;
+    }
+  
     $view = new stdClass();
     $view->name = t('active_@group_group_ads', array('@group' => $group));
     $view->description = t('Display all active @group ads in a block.', array('@group' => $group));
@@ -239,8 +253,26 @@ function ad_views_default_views() {
         'options' => '1',
       ),
     );
+    $view->filter = array (
+      array (
+        'tablename' => 'ads',
+        'field' => 'adstatus',
+        'operator' => 'OR',
+        'options' => '',
+        'value' => array (
+          0 => 'active',
+        ),
+      ),
+      array (
+        'tablename' => $term_node_table_name,
+        'field' => 'tid',
+        'operator' => 'OR',
+        'options' => '',
+        'value' => array (0 => $group_tid),
+      ),
+    );
     $view->exposed_filter = array();
-    $view->requires = array(ads);
+    $view->requires = array(ads, $term_node_table_name);
     $views[$view->name] = $view;
   }
 
