You are here

function dfp_adtest_alter_tag in Doubleclick for Publishers (DFP) 7.2

Same name and namespace in other branches
  1. 8 src/View/dfp.adtest.inc \dfp_adtest_alter_tag()
  2. 7 dfp.adtest.inc \dfp_adtest_alter_tag()

Alter tags for various adtest scenaroios.

1 call to dfp_adtest_alter_tag()
dfp_dfp_tag_load_alter in ./dfp.module
Alter a dfp tag object to integrate with the contexts module.

File

./dfp.adtest.inc, line 77
Creates a test page for DFP ads.

Code

function dfp_adtest_alter_tag(&$tag) {

  // Check for a submit on adtest form.
  if (isset($_GET['adunit_override'])) {

    // For security reasons, ensure that adunit_override contains only letters,
    // numbers, hyphens, dashes, periods, hard brackets and colons. Typically
    // only a site builder or an ad ops person will be using the adtest page so
    // if there is a problem with the adunit override value we can safely
    // display a somewhat technical message.
    if (!preg_match('@[^a-zA-Z0-9\\-_\\.\\[\\]\\:]+@', $_GET['adunit_override'])) {
      $tag->adunit = $_GET['adunit_override'];
    }
    else {
      drupal_set_message(t('The adunit_override query string can only contain letters, numbers, hyphens, dashes, periods, hard brackets and colons. Please doublecheck the override string you were provided.'), 'error');
    }
  }

  // Check for an "adtest" query string variable.
  if (isset($_GET['adtest'])) {
    $tag->adunit = variable_get('dfp_adtest_adunit', '');
  }
}