- ad_weight_probability.module
authorjeremy
Fri, 3 Jul 2009 20:33:12 +0000 (20:33 +0000)
committerjeremy
Fri, 3 Jul 2009 20:33:12 +0000 (20:33 +0000)
    o feature #485244: display probability on ad overview page

channel/ad_channel.module
documentation/CHANGELOG.txt
weight/probability/ad_weight_probability.module

index c0a55a0..054da08 100644 (file)
@@ -302,14 +302,26 @@ function ad_channel_theme_registry_alter(&$theme_registry) {
 function ad_channel_ad_admin_ads($form) {
   $list = variable_get('ad_channel_admin_list', AD_CHANNEL_LIST_CHANNEL);
 
+  // Conditionally build the header based on list type and
+  // the availability of probability values from the 
+  // ad_weight_probability module
+  $header = array(theme('table_select_header_cell'), t('Title'));
+
   // Overview table:
-  if ($list == AD_CHANNEL_LIST_CHANNEL) {
-    $header = array(theme('table_select_header_cell'), t('Title'), t('Channel'), t('Type'), t('Status'), t('Operations'));
+  if ($list != AD_CHANNEL_LIST_CHANNEL) {
+    $header[] = t('Group');
   }
-  else {
-    $header = array(theme('table_select_header_cell'), t('Title'), t('Group'), t('Channel'), t('Type'), t('Status'), t('Operations'));
+
+  $header = array_merge($header, array(t('Channel')));
+
+  if (isset($form['probability']) && is_array($form['probability'])) {
+    $header[] = t('Probability');
   }
 
+  $header[] = t('Type');
+  $header[] = t('Status');
+  $header[] = t('Operations');
+
   $output = drupal_render($form['options']);
   if (isset($form['title']) && is_array($form['title'])) {
     foreach (element_children($form['title']) as $key) {
@@ -320,6 +332,9 @@ function ad_channel_ad_admin_ads($form) {
         $row[] = drupal_render($form['group'][$key]);
       }
       $row[] = drupal_render($form['channel'][$key]);
+      if (isset($form['probability']) && is_array($form['probability'])) {
+        $row[] = drupal_render($form['probability'][$key]);
+      }
       $row[] = drupal_render($form['adtype'][$key]);
       $row[] = drupal_render($form['adstatus'][$key]);
       $row[] = drupal_render($form['operations'][$key]);
index 8d36441..2451445 100644 (file)
@@ -5,6 +5,8 @@ July 3rd, 2009
     o bug #485218: proper filtering by group and by both group and channel
  - ad_cache_file.module
     o feature #485236: provide manual mechanism for flushing file cache
+ - ad_weight_probability.module
+    o feature #485244: display probability on ad overview page
 
 May 21st, 2009
  - ad.channel.module
index 9a3d763..601c017 100644 (file)
@@ -36,6 +36,19 @@ function ad_weight_probability_form_alter(&$form, &$form_state, $form_id) {
     );
     $form['weighting']['#weight'] = -1;
   }
+  // TODO: This hack requires that the ad_channel module is enabled to work.
+  // Ultimately ad.admin.inc should be enhanced to allow plug-in modules to
+  // modify the overview page.
+  else if ($form_id == 'ad_admin_ads' && function_exists('ad_channel_form_alter')) {
+    if (variable_get('ad_channel_admin_list', AD_CHANNEL_LIST_CHANNEL) != AD_CHANNEL_LIST_GROUP) {
+      $weights = _ad_weight_probability_weights();
+      foreach ($form['title'] as $aid => $value) {
+        $node->nid = $aid;
+        $result = _ad_weight_probability_node_load($node);
+        $form['probability'][$aid]['#value'] = $weights[$result['probability']];
+      }
+    }
+  }
 }
 
 /**