mediamosa_statistics_streamrequests_list_form

Versions
mediamosa-21
mediamosa_statistics_streamrequests_list_form()

Code

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

<?php
function mediamosa_statistics_streamrequests_list_form() {

  // Get session.
  $session = isset($_SESSION['mediamosa_statistics_filter'][MEDIAMOSA_STATISTICS_FILTER_TYPE_STREAMREQUESTS]) ? $_SESSION['mediamosa_statistics_filter'][MEDIAMOSA_STATISTICS_FILTER_TYPE_STREAMREQUESTS] : 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'];

  $params = array(
    'app_id' => $app_ids,
    'month' => $month,
    'year' => $year,
  );

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

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

  $rows = array();

  foreach ($result['items'] as $row) {
    $rows[] = array(
      $row['app_id'],
      check_plain($row['mediafile_id']),
      mediamosa_lib::l_asset($row['asset_id'], $row['asset_id']),
      check_plain($row['owner_id']),
      check_plain($row['played']),
      );
  }

  //$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;
}
?>