FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
AjaxJobInfo.php
1 <?php
2 /***********************************************************
3  * Copyright (C) 2014 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\Ajax;
20 
26 
28 {
29  const NAME = "jobinfo";
31  private $dbManager;
32 
33  function __construct()
34  {
35  parent::__construct(self::NAME, array(
36  self::PERMISSION => Auth::PERM_READ
37  // , 'outputtype' => 'JSON'
38  ));
39 
40  $this->dbManager = $this->getObject('db.manager');
41  }
42 
47  protected function handle(Request $request)
48  {
49  $userId = $_SESSION['UserId'];
50  $jqIds = (array) $request->get('jqIds');
51 
52  $result = array();
53  foreach ($jqIds as $jq_pk) {
54  $jobInfo = $this->dbManager->getSingleRow(
55  "SELECT jobqueue.jq_end_bits as end_bits FROM jobqueue INNER JOIN job ON jobqueue.jq_job_fk = job.job_pk
56  WHERE jobqueue.jq_pk = $1 AND job_user_fk = $2",
57  array($jq_pk, $userId)
58  );
59  if ($jobInfo !== false) {
60  $result[$jq_pk] = array('end_bits' => $jobInfo['end_bits']);
61  }
62  }
63 
65  $status = empty($result) ? Response::HTTP_INTERNAL_SERVER_ERROR : Response::HTTP_OK;
66  if (empty($result)) {
67  $result = array("error" => "no info");
68  }
69  $response = new Response(json_encode($result),$status,array('content-type'=>'text/json'));
70  return $response;
71  }
72 }
73 
74 register_plugin(new AjaxJobInfo());
handle(Request $request)
Definition: AjaxJobInfo.php:47
ReportCachePurgeAll()
Purge all records from the report cache.
fo_dbManager * dbManager
fo_dbManager object
Definition: process.c:28