FOSSology  4.4.0
Open Source License Compliance by Open Source Software
AdminObligationToJSON.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2024 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_json";
18 
19  function __construct()
20  {
21  parent::__construct(self::NAME, array(
22  self::TITLE => "Admin Obligation JSON Export",
23  self::MENU_LIST => "Admin::Obligation Admin::JSON 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')), true);
37  $fileName = "fossology-obligations-export-".date("YMj-Gis");
38  $headers = array(
39  'Content-type' => 'text/json, charset=UTF-8',
40  'Content-Disposition' => 'attachment; filename='.$fileName.'.json',
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 AdminObligationToJSON());
Contains the constants and helpers for authentication of user.
Definition: Auth.php:24