ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSCTask.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once './Services/Calendar/classes/class.ilDateTime.php';
6 
12 class ilSCTask
13 {
15  const STATUS_IN_PROGRESS = 1;
16  const STATUS_COMPLETED = 2;
17  const STATUS_FAILED = 3;
18 
19 
20 
21  private $id = 0;
22  private $grp_id = 0;
23  private $last_update = null;
24  private $status = 0;
25  private $identifier = '';
26 
27 
32  public function __construct($a_id = 0)
33  {
34  $this->id = $a_id;
35  $this->read();
36  }
37 
38  public function getId()
39  {
40  return $this->id;
41  }
42 
43  public function setGroupId($a_id)
44  {
45  $this->grp_id = $a_id;
46  }
47 
48  public function getGroupId()
49  {
50  return $this->grp_id;
51  }
52 
53  public function setIdentifier($a_ide)
54  {
55  $this->identifier = $a_ide;
56  }
57 
58  public function getIdentifier()
59  {
60  return $this->identifier;
61  }
62 
63 
64  public function setLastUpdate(ilDateTime $a_update)
65  {
66  $this->last_update = $a_update;
67  }
68 
73  public function getLastUpdate()
74  {
75  if (!$this->last_update) {
76  return $this->last_update = new ilDateTime();
77  }
78  return $this->last_update;
79  }
80 
81  public function setStatus($a_status)
82  {
83  $this->status = $a_status;
84  }
85 
90  public function getStatus()
91  {
92  return $this->status;
93  }
94 
98  public function isActive()
99  {
100  return true;
101  }
102 
106  public function read()
107  {
108  global $DIC;
109 
110  $ilDB = $DIC['ilDB'];
111 
112  if (!$this->getId()) {
113  return false;
114  }
115 
116  $query = 'SELECT * FROM sysc_tasks ' .
117  'WHERE id = ' . $ilDB->quote($this->getId(), 'integer');
118  $res = $ilDB->query($query);
119  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
120  $this->setGroupId($row->grp_id);
121  $this->setLastUpdate(new ilDateTime($row->last_update, IL_CAL_DATETIME, ilTimeZone::UTC));
122  $this->setStatus($row->status);
123  $this->setIdentifier($row->identifier);
124  }
125  return true;
126  }
127 
131  public function create()
132  {
133  global $DIC;
134 
135  $ilDB = $DIC['ilDB'];
136 
137  $this->id = $ilDB->nextId('sysc_tasks');
138 
139  $query = 'INSERT INTO sysc_tasks (id,grp_id,status,identifier) ' .
140  'VALUES ( ' .
141  $ilDB->quote($this->getId(), 'integer') . ', ' .
142  $ilDB->quote($this->getGroupId(), 'integer') . ', ' .
143  $ilDB->quote($this->getStatus(), 'integer') . ', ' .
144  $ilDB->quote($this->getIdentifier(), 'text') . ' ' .
145  ')';
146  $ilDB->manipulate($query);
147  return $this->getId();
148  }
149 
153  public function update()
154  {
155  global $DIC;
156 
157  $ilDB = $DIC['ilDB'];
158 
159  $query = 'UPDATE sysc_tasks SET ' .
160  'last_update = ' . $ilDB->quote($this->getLastUpdate()->get(IL_CAL_DATETIME, '', ilTimeZone::UTC), 'timestamp') . ', ' .
161  'status = ' . $ilDB->quote($this->getStatus(), 'integer') . ', ' .
162  'identifier = ' . $ilDB->quote($this->getIdentifier(), 'text') . ' ' .
163  'WHERE id = ' . $ilDB->quote($this->getId(), 'integer');
164  $ilDB->manipulate($query);
165  }
166 }
Defines a system check task.
__construct($a_id=0)
Constructor.
setStatus($a_status)
const IL_CAL_DATETIME
global $DIC
Definition: saml.php:7
const STATUS_FAILED
setIdentifier($a_ide)
getStatus()
Get status.
foreach($_POST as $key=> $value) $res
create()
Create new group.
Date and time handling
update()
Update task.
$query
const STATUS_IN_PROGRESS
$row
const STATUS_COMPLETED
global $ilDB
read()
Read group.
getLastUpdate()
Get last update date.
const STATUS_NOT_ATTEMPTED
setLastUpdate(ilDateTime $a_update)
setGroupId($a_id)