mediamosa_statistics_popularstreams_list_form

Versions
mediamosa-21
mediamosa_statistics_popularstreams_list_form()

Code

sites/all/modules/mediamosa/modules/statistics/mediamosa_statistics_popularstreams.inc, line 47

<?php
function mediamosa_statistics_popularstreams_list_form() {

  // Get session.
  $session = isset($_SESSION['mediamosa_statistics_filter'][MEDIAMOSA_STATISTICS_FILTER_TYPE_POPULARSTREAMS]) ? $_SESSION['mediamosa_statistics_filter'][MEDIAMOSA_STATISTICS_FILTER_TYPE_POPULARSTREAMS] : array();

  // Get app owners.
  $app_owners = mediamosa_app::collect_app_owners();

  $app_ids = array();
  if (!empty($session['app_id'])) {
    $app_ids[] = $session['app_id'];
  }
  if (!empty($session['app_owner']) && isset($app_owners[$session['app_owner']])) {
    $app_ids += $app_owners[$session['app_owner']];
  }
  $year = empty($session['year']) ? date('Y') : $session['year'];
  $month = empty($session['month']) ? date('n') : $session['month'];
  $month_end = empty($session['month_end']) ? ($month + 1) : $session['month_end'];
  if ($month_end > 12) {
    $month_end = 1;
    $year_end = $year + 1;
  }
  $year_end = empty($session['year_end']) ? (isset($year_end) ? $year_end : $year) : $session['year_end'];

  $params = array(
    'app_id' => $app_ids,
    'begindate' => $year . '-' . $month,
    'enddate' => $year_end . '-' . $month_end,
  );

  // Do the rest call.
  $result = mediamosa_response_connector::static_do_restcall_drupal('statistics/streams', 'GET', $params);

  // Our header.
  $header = array(
    array('data' => t('Played')),
    array('data' => t('App ID')),
    array('data' => t('Filename')),
    array('data' => t('Owner ID')),
  );

  $rows = array();
  foreach ($result['items'] as $row) {
    $title = empty($row['filename']) ? $row['mediafile_id'] : $row['filename'];

    $rows[] = array(
      $row['requested'] .'x',
      $row['app_id'],
      mediamosa_lib::l_asset($row['asset_id'], $title),
      check_plain($row['owner_id']),
      );
  }

  //$form['pager_top'] = array('#theme' => 'pager');
  $form['table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No stream requests found.')
  );
  //$form['pager_bottom'] = array('#theme' => 'pager');

  return $form;
}
?>