You are here

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

Implements hook_block_save().

File

./google_admanager.module, line 185

Code

function google_admanager_block_save($delta = 0, $edit = array()) {
  if (!user_access('use PHP for settings') || substr($delta, 0, 10) !== 'superslot:') {
    return;
  }

  // When save account settings, delete blocks which belongs to the ad slots that have been removed
  $superslot = array();
  foreach ($edit as $key => $value) {
    if (preg_match('/superslot_(\\d+)_adslot/', $key)) {
      $php = $edit[str_replace('adslot', 'php', $key)];
      if (!empty($php)) {
        $superslot[$value] = $php;
      }
    }
  }
  $superslots = variable_get('google_admanager_superslots', array());
  $superslots[substr($delta, 10)] = $superslot;
  variable_set('google_admanager_superslots', $superslots);
}