ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 read()
99  {
100  global $ilDB;
101 
102  if (!$this->getId()) {
103  return false;
104  }
105 
106  $query = 'SELECT * FROM sysc_tasks ' .
107  'WHERE id = ' . $ilDB->quote($this->getId(), 'integer');
108  $res = $ilDB->query($query);
109  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
110  $this->setGroupId($row->grp_id);
111  $this->setLastUpdate(new ilDateTime($row->last_update, IL_CAL_DATETIME, ilTimeZone::UTC));
112  $this->setStatus($row->status);
113  $this->setIdentifier($row->identifier);
114  }
115  return true;
116  }
117 
121  public function create()
122  {
123  global $ilDB;
124 
125  $this->id = $ilDB->nextId('sysc_tasks');
126 
127  $query = 'INSERT INTO sysc_tasks (id,grp_id,status,identifier) ' .
128  'VALUES ( ' .
129  $ilDB->quote($this->getId(), 'integer') . ', ' .
130  $ilDB->quote($this->getGroupId(), 'integer') . ', ' .
131  $ilDB->quote($this->getStatus(), 'integer') . ', ' .
132  $ilDB->quote($this->getIdentifier(), 'text') . ' ' .
133  ')';
134  $ilDB->manipulate($query);
135  return $this->getId();
136  }
137 
141  public function update()
142  {
143  global $ilDB;
144 
145  $query = 'UPDATE sysc_tasks SET ' .
146  'last_update = ' . $ilDB->quote($this->getLastUpdate()->get(IL_CAL_DATETIME, '', ilTimeZone::UTC), 'timestamp') . ', ' .
147  'status = ' . $ilDB->quote($this->getStatus(), 'integer') . ', ' .
148  'identifier = ' . $ilDB->quote($this->getIdentifier(), 'text') . ' ' .
149  'WHERE id = ' . $ilDB->quote($this->getId(), 'integer');
150  $ilDB->manipulate($query);
151  }
152 }
Defines a system check task.
__construct($a_id=0)
Constructor.
setStatus($a_status)
const IL_CAL_DATETIME
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
const STATUS_COMPLETED
global $ilDB
read()
Read group.
getLastUpdate()
Get last update date.
const STATUS_NOT_ATTEMPTED
setLastUpdate(ilDateTime $a_update)
setGroupId($a_id)