You are here

function google_admanager_block_configure in DFP Small Business (Google Ad Manager) 7.2

Implements hook_block_configure().

File

./google_admanager.module, line 134

Code

function google_admanager_block_configure($delta = 0) {

  // Reuse the 'use PHP for settings' from block.module
  if (!user_access('use PHP for settings') || substr($delta, 0, 10) !== 'superslot:') {
    return;
  }
  $superslots = variable_get('google_admanager_superslots', array());
  $name = substr($delta, 10);
  if (!isset($superslots[$name])) {
    return;
  }
  $form = array();
  $form['google_admanager_visibility'] = array(
    '#type' => 'fieldset',
    '#title' => t('Ad slots visibility'),
    '#description' => t('Use PHP code to define ad slot visibility. For example, to display an ad slot only to anonymous user, use <em>return empty($GLOBALS[\'user\']->uid);</em>. Or, to simple enable an ad slot, use <em>return TRUE;</em>'),
  );
  $ad_slots = array_values(_google_admanager_get_ad_slots());
  $ad_slots = array_combine($ad_slots, $ad_slots);
  $superslot = $superslots[$name];

  // Create 5 empty slots configuration
  // @TODO: It could be better to implement AHAH form
  $superslot += array(
    'fake slot1' => '',
    'fake slot2' => '',
    'fake slot3' => '',
  );
  $i = 1;
  foreach ($superslot as $ad_slot => $php) {
    $form['google_admanager_visibility']['superslot_' . $i . '_adslot'] = array(
      '#type' => 'select',
      '#title' => t('Ad slot'),
      '#default_value' => $ad_slot,
      '#options' => $ad_slots,
    );
    $form['google_admanager_visibility']['superslot_' . $i++ . '_php'] = array(
      '#type' => 'textfield',
      '#title' => t('PHP code for visibility condition'),
      '#default_value' => $php,
    );
  }
  return $form;
}