FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
AdminLicenseToCSV.php
1 <?php
2 /***********************************************************
3  * Copyright (C) 2014-2017 Siemens AG
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * version 2 as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  ***********************************************************/
18 
19 namespace Fossology\UI\Page;
20 
25 
27 {
28  const NAME = "admin_license_to_csv";
29 
30  function __construct()
31  {
32  parent::__construct(self::NAME, array(
33  self::TITLE => "Admin License CSV Export",
34  self::MENU_LIST => "Admin::License Admin::CSV Export",
35  self::REQUIRES_LOGIN => true,
36  self::PERMISSION => Auth::PERM_ADMIN
37  ));
38  }
39 
44  protected function handle(Request $request)
45  {
46  $licenseCsvExport = new \Fossology\Lib\Application\LicenseCsvExport($this->getObject('db.manager'));
47  $content = $licenseCsvExport->createCsv(intval($request->get('rf')));
48  $fileName = "fossology-license-export-".date("YMj-Gis");
49  $headers = array(
50  'Content-type' => 'text/csv, charset=UTF-8',
51  'Content-Disposition' => 'attachment; filename='.$fileName.'.csv',
52  'Pragma' => 'no-cache',
53  'Cache-Control' => 'no-cache, must-revalidate, maxage=1, post-check=0, pre-check=0',
54  'Expires' => 'Expires: Thu, 19 Nov 1981 08:52:00 GMT');
55 
56  return new Response($content, Response::HTTP_OK, $headers);
57  }
58 }
59 
60 register_plugin(new AdminLicenseToCSV());