FOSSology  4.4.0
Open Source License Compliance by Open Source Software
AdminObligationToCSV.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014-2017 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\UI\Page;
9 
12 use Symfony\Component\HttpFoundation\Request;
13 use Symfony\Component\HttpFoundation\Response;
14 
16 {
17  const NAME = "admin_obligation_to_csv";
18 
19  function __construct()
20  {
21  parent::__construct(self::NAME, array(
22  self::TITLE => "Admin Obligation CSV Export",
23  self::MENU_LIST => "Admin::Obligation Admin::CSV Export",
24  self::REQUIRES_LOGIN => true,
25  self::PERMISSION => Auth::PERM_ADMIN
26  ));
27  }
28 
33  protected function handle(Request $request)
34  {
35  $obligationCsvExport = new \Fossology\Lib\Application\ObligationCsvExport($this->getObject('db.manager'));
36  $content = $obligationCsvExport->createCsv(intval($request->get('rf')));
37  $fileName = "fossology-obligations-export-".date("YMj-Gis");
38  $headers = array(
39  'Content-type' => 'text/csv, charset=UTF-8',
40  'Content-Disposition' => 'attachment; filename='.$fileName.'.csv',
41  'Pragma' => 'no-cache',
42  'Cache-Control' => 'no-cache, must-revalidate, maxage=1, post-check=0, pre-check=0',
43  'Expires' => 'Expires: Thu, 19 Nov 1981 08:52:00 GMT');
44 
45  return new Response($content, Response::HTTP_OK, $headers);
46  }
47 }
48 
49 register_plugin(new AdminObligationToCSV());
Contains the constants and helpers for authentication of user.
Definition: Auth.php:24