FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
JobDao.php
1 <?php
2 /***********************************************************
3  * Copyright (C) 2015 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\Lib\Dao;
20 
22 use Monolog\Logger;
23 
24 class JobDao
25 {
27  private $dbManager;
29  private $logger;
30 
31  function __construct(DbManager $dbManager, Logger $logger)
32  {
33  $this->dbManager = $dbManager;
34  $this->logger = $logger;
35  }
36 
37  public function getAllJobStatus($uploadId, $userId, $groupId)
38  {
39  $result = array();
40  $stmt = __METHOD__;
41  $this->dbManager->prepare($stmt,
42  "SELECT jobqueue.jq_pk as jq_pk,
43  jobqueue.jq_end_bits as end_bits
44  FROM jobqueue
45  INNER JOIN job
46  ON jobqueue.jq_job_fk = job.job_pk
47  LEFT JOIN group_user_member gm
48  ON gm.user_fk = job_user_fk
49  WHERE job.job_upload_fk = $1
50  AND (job_user_fk = $2
51  OR gm.group_fk = $3)");
52 
53  $res = $this->dbManager->execute($stmt, array($uploadId, $userId, $groupId));
54  while ($row = $this->dbManager->fetchArray($res)) {
55  $result[$row['jq_pk']] = $row['end_bits'];
56  }
57  $this->dbManager->freeResult($res);
58 
59  return $result;
60  }
61 
62  public function hasActionPermissionsOnJob($jobId, $userId, $groupId)
63  {
64  $result = array();
65  $stmt = __METHOD__;
66  $this->dbManager->prepare($stmt,
67  "SELECT *
68  FROM job
69  LEFT JOIN group_user_member gm
70  ON gm.user_fk = job_user_fk
71  WHERE job_pk = $1
72  AND (job_user_fk = $2
73  OR gm.group_fk = $3)");
74 
75  $res = $this->dbManager->execute($stmt, array($jobId, $userId, $groupId));
76  while ($row = $this->dbManager->fetchArray($res)) {
77  $result[$row['jq_pk']] = $row['end_bits'];
78  }
79  $this->dbManager->freeResult($res);
80 
81  return $result;
82  }
83 }
fo_dbManager * dbManager
fo_dbManager object
Definition: process.c:28