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) {
$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]);
);
$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']];
+ }
+ }
+ }
}
/**