/**
  * @action getCsv
  * @param int $id
  * @param KalturaKeyValueArray $params
  * @return file
  */
 public function getCsvAction($id, KalturaKeyValueArray $params = null)
 {
     $dbReport = ReportPeer::retrieveByPK($id);
     if (is_null($dbReport)) {
         throw new KalturaAPIException(KalturaErrors::REPORT_NOT_FOUND, $id);
     }
     $query = $dbReport->getQuery();
     $this->addPartnerIdToParams($params);
     $execParams = KalturaReportHelper::getValidateExecutionParameters($dbReport, $params);
     $kReportsManager = new kReportManager($dbReport);
     list($columns, $rows) = $kReportsManager->execute($execParams);
     $fileName = array('Report', $id, $this->getPartnerId());
     foreach ($params as $param) {
         $fileName[] = $param->key;
         $fileName[] = $param->value;
     }
     $fileName = implode('_', $fileName) . '.csv';
     header('Content-Type: text/csv');
     header("Content-Disposition: attachment; filename=\"{$fileName}\"");
     echo "";
     // a fix for excel, copied from myReportsMgr
     echo implode(',', $columns) . "\n";
     foreach ($rows as $row) {
         echo implode(',', $row) . "\n";
     }
     die;
 }
Ejemplo n.º 2
0
 /**
  * @action executeDebug
  * @param int $id
  * @param KalturaKeyValueArray $params
  * @return KalturaReportResponse
  */
 function executeDebugAction($id, KalturaKeyValueArray $params = null)
 {
     $dbReport = ReportPeer::retrieveByPK($id);
     if (is_null($dbReport)) {
         throw new KalturaAPIException(KalturaErrors::REPORT_NOT_FOUND, $id);
     }
     $query = $dbReport->getQuery();
     $matches = null;
     $execParams = KalturaReportHelper::getValidateExecutionParameters($dbReport, $params);
     try {
         $kReportsManager = new kReportManager($dbReport);
         list($columns, $rows) = $kReportsManager->execute($execParams);
     } catch (Exception $ex) {
         KalturaLog::err($ex);
         KalturaLog::info('Rethrowing KalturaAPIException with the exception details');
         throw new KalturaAPIException(KalturaErrors::INTERNAL_SERVERL_ERROR_DEBUG, $ex->getMessage());
     }
     $reportResponse = KalturaReportResponse::fromColumnsAndRows($columns, $rows);
     return $reportResponse;
 }