FOSSology  4.4.0
Open Source License Compliance by Open Source Software
AjaxJobInfo.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\UI\Ajax;
9 
13 use Symfony\Component\HttpFoundation\Request;
14 use Symfony\Component\HttpFoundation\Response;
15 
17 {
18  const NAME = "jobinfo";
20  private $dbManager;
21 
22  function __construct()
23  {
24  parent::__construct(self::NAME, array(
25  self::PERMISSION => Auth::PERM_READ
26  // , 'outputtype' => 'JSON'
27  ));
28 
29  $this->dbManager = $this->getObject('db.manager');
30  }
31 
36  protected function handle(Request $request)
37  {
38  $userId = $_SESSION['UserId'];
39  $jqIds = (array) $request->get('jqIds');
40 
41  $result = array();
42  foreach ($jqIds as $jq_pk) {
43  $jobInfo = $this->dbManager->getSingleRow(
44  "SELECT jobqueue.jq_end_bits as end_bits FROM jobqueue INNER JOIN job ON jobqueue.jq_job_fk = job.job_pk
45  WHERE jobqueue.jq_pk = $1 AND job_user_fk = $2",
46  array($jq_pk, $userId)
47  );
48  if ($jobInfo !== false) {
49  $result[$jq_pk] = array('end_bits' => $jobInfo['end_bits']);
50  }
51  }
52 
54  $status = empty($result) ? Response::HTTP_INTERNAL_SERVER_ERROR : Response::HTTP_OK;
55  if (empty($result)) {
56  $result = array("error" => "no info");
57  }
58  $response = new Response(json_encode($result),$status,array('content-type'=>'text/json'));
59  return $response;
60  }
61 }
62 
63 register_plugin(new AjaxJobInfo());
Contains the constants and helpers for authentication of user.
Definition: Auth.php:24
handle(Request $request)
Definition: AjaxJobInfo.php:36
ReportCachePurgeAll()
Purge all records from the report cache.
fo_dbManager * dbManager
fo_dbManager object
Definition: process.c:16