You are here

function ad_channel_admin_report_submit in Advertisement 6.2

Same name and namespace in other branches
  1. 6.3 channel/ad_channel.module \ad_channel_admin_report_submit()
  2. 7 channel/ad_channel.module \ad_channel_admin_report_submit()
1 string reference to 'ad_channel_admin_report_submit'
ad_channel_form_alter in channel/ad_channel.module
Implementation of hook_form_alter(). Generate a form for selecting channels to associate with an advertisement.

File

channel/ad_channel.module, line 383
Ad Channel module.

Code

function ad_channel_admin_report_submit($form, $form_state) {
  if ($form_state['clicked_button']['#value'] == t('Reset report')) {
    unset($_SESSION['ad_report_channel']);
  }
  else {
    if ($form_state['clicked_button']['#value'] == t('Generate report')) {
      if (isset($form_state['values']['channel']) && is_array($form_state['values']['channel'])) {
        $channels = array();
        $any = FALSE;
        foreach ($form_state['values']['channel'] as $chid) {
          if (is_numeric($chid)) {
            $channels[] = $chid;
          }
          else {
            if ($chid == 'none') {
              $channels[-1] = 'none';
            }
            else {
              $any = TRUE;
            }
          }
        }
        if (!$any && !empty($channels)) {
          $_SESSION['ad_report_channel'] = $channels;
        }
        else {
          if (isset($_SESSION['ad_report_channel'])) {
            unset($_SESSION['ad_report_channel']);
          }
        }
      }
    }
  }
}