You are here

function ad_admin_ads in Advertisement 5.2

Same name and namespace in other branches
  1. 5 ad.module \ad_admin_ads()
  2. 6.3 ad.admin.inc \ad_admin_ads()
  3. 6 ad.admin.inc \ad_admin_ads()
  4. 6.2 ad.admin.inc \ad_admin_ads()
  5. 7 ad.admin.inc \ad_admin_ads()

Provide a filterable list of advertisements.

1 string reference to 'ad_admin_ads'
ad_admin_list in ./ad.module
Build default ad administration page.

File

./ad.module, line 1375
An advertising system for Drupal powered websites.

Code

function ad_admin_ads() {
  $filter = ad_build_filter_query();
  $result = pager_query('SELECT a.*, n.* FROM {ads} a INNER JOIN {node} n ON a.aid = n.nid ' . $filter['join'] . ' ' . $filter['where'] . ' ORDER BY n.changed DESC', 50, 0, NULL, $filter['args']);
  $form['options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Update options'),
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
  );
  $options = array();
  foreach (module_invoke_all('ad_operations') as $operation => $array) {
    $options[$operation] = $array['label'];
  }
  $form['options']['operation'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => 'approve',
  );
  $form['options']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
  );
  $destination = drupal_get_destination();
  while ($ad = db_fetch_object($result)) {
    $ads[$ad->aid] = '';
    $form['title'][$ad->aid] = array(
      '#value' => l($ad->title, 'node/' . $ad->aid),
    );
    $form['group'][$ad->aid] = array(
      '#value' => _ad_get_group($ad->aid),
    );
    $form['adtype'][$ad->aid] = array(
      '#value' => $ad->adtype,
    );
    $form['adstatus'][$ad->aid] = array(
      '#value' => $ad->adstatus,
    );
    $form['operations'][$ad->aid] = array(
      '#value' => l(t('edit'), 'node/' . $ad->aid . '/edit', array(), $destination),
    );
  }
  $form['ads'] = array(
    '#type' => 'checkboxes',
    '#options' => $ads,
  );
  $form['pager'] = array(
    '#value' => theme('pager', NULL, 50, 0),
  );
  return $form;
}