You are here

function ad_report_menu in Advertisement 5.2

Same name and namespace in other branches
  1. 5 report/ad_report.module \ad_report_menu()
  2. 6.3 report/ad_report.module \ad_report_menu()
  3. 6 report/ad_report.module \ad_report_menu()
  4. 6.2 report/ad_report.module \ad_report_menu()
  5. 7 report/ad_report.module \ad_report_menu()

Implementation of hook_menu().

File

report/ad_report.module, line 14
Provides comprehensive charts and reports about advertising statistics.

Code

function ad_report_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/content/ad/report',
      'title' => t('Reports'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'ad_report_admin',
      ),
      'type' => MENU_LOCAL_TASK,
      'weight' => 1,
    );
    $items[] = array(
      'path' => 'admin/content/ad/report/display',
      'callback' => 'ad_report_admin_display',
      'type' => MENU_CALLBACK,
    );
  }
  else {
    if (arg(0) == 'node' && is_numeric(arg(1)) && ad_permission(arg(1), 'access statistics')) {
      $node = node_load(arg(1));
      if ($node->adtype) {
        $start = (int) arg(3);
        $end = (int) arg(4);
        $items[] = array(
          'path' => "node/{$node->nid}/report",
          'title' => t('Reports'),
          'callback' => 'ad_report_bargraph',
          'callback arguments' => array(
            $node,
            "node/{$node->nid}/report",
            'node',
            $start,
            $end,
          ),
          'type' => MENU_LOCAL_TASK,
          'access' => ad_permission($node->nid, 'generate reports'),
        );
      }
    }
    else {
      if (arg(0) == 'ad_report' && is_numeric(arg(1)) && is_numeric(arg(4)) && is_numeric(arg(5))) {
        if (arg(3) == 'node') {
          $access = ad_permission(arg(1), 'generate reports');
        }
        else {
          $access = user_access('generate administrative reports');
        }
        $id = arg(1);
        $type = arg(3);
        $start = (int) arg(4);
        $start_date = _ad_report_get_date_from_path($start);
        $end = (int) arg(5);
        $end_date = _ad_report_get_date_from_path($end);
        $items[] = array(
          'path' => "ad_report/{$id}/bargraph/{$type}/{$start}/{$end}",
          'title' => 'Bar graph',
          'callback' => 'ad_report_generate_bargraph',
          'callback arguments' => array(
            $id,
            $type,
            $start_date,
            $end_date,
          ),
          'type' => MENU_CALLBACK,
          'access' => $access,
        );
      }
      else {
        if (arg(0) == 'ad_report' && is_numeric(arg(3) && is_numeric(arg(4)))) {
        }
      }
    }
    $start = strtotime($_SESSION['ad_report_start']);
    $end = strtotime($_SESSION['ad_report_end']);
    $group = $_SESSION['ad_report_group'];
    if ($start && $end && is_array($group)) {
      $items[] = array(
        'path' => 'admin/content/ad/report/csv',
        'callback' => 'ad_report_admin_ad_table',
        'callback arguments' => array(
          $start,
          $end,
          $group,
          TRUE,
        ),
        'type' => MENU_CALLBACK,
      );
    }
  }
  return $items;
}