3 * Bacula® - The Network Backup Solution
4 * Baculum - Bacula web interface
6 * Copyright (C) 2013-2014 Marcin Haba
8 * The main author of Baculum is Marcin Haba.
9 * The main author of Bacula is Kern Sibbald, with contributions from many
10 * others, a complete list can be found in the file AUTHORS.
12 * You may use this file and others of this release according to the
13 * license defined in the LICENSE file, which includes the Affero General
14 * Public License, v3.0 ("AGPLv3") and some additional permissions and
15 * terms pursuant to its AGPLv3 Section 7.
17 * Bacula® is a registered trademark of Kern Sibbald.
20 class JobManager extends TModule {
22 public function getJobs($limit) {
23 $criteria = new TActiveRecordCriteria;
25 $cfg = $this->Application->getModule('configuration');
26 $appCfg = $cfg->getApplicationConfig();
27 if($cfg->isPostgreSQLType($appCfg['db']['type'])) {
28 $order = strtolower($order);
30 $criteria->OrdersBy[$order] = 'desc';
31 if(is_int($limit) && $limit > 0) {
32 $criteria->Limit = $limit;
34 return JobRecord::finder()->findAll($criteria);
37 public function getJobById($id) {
38 return JobRecord::finder()->findByjobid($id);
41 public function getJobByName($name) {
42 return JobRecord::finder()->findByname($name);
45 public function deleteJobById($id) {
46 return JobRecord::finder()->deleteByjobid($id);
49 public function getRecentJobids($jobname, $clientid) {
50 $sql = "name='$jobname' AND clientid='$clientid' AND jobstatus IN ('T', 'W') AND level IN ('F', 'I', 'D') ORDER BY endtime DESC";
51 $finder = JobRecord::finder();
52 $jobs = $finder->findAll($sql);
57 foreach($jobs as $job) {
58 if($job->level == 'F') {
59 $jobids[] = $job->jobid;
61 } elseif($job->level == 'D' && $waitForFull === false) {
62 $jobids[] = $job->jobid;
64 } elseif($job->level == 'I' && $waitForFull === false) {
65 $jobids[] = $job->jobid;