ILIAS  release_7 Revision v7.30-3-g800a261c036
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
5include_once './Services/Calendar/classes/class.ilDateTime.php';
6
13{
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}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
@classDescription Date and time handling
Defines a system check task.
__construct($a_id=0)
Constructor.
const STATUS_COMPLETED
const STATUS_FAILED
getStatus()
Get status.
const STATUS_IN_PROGRESS
create()
Create new group.
const STATUS_NOT_ATTEMPTED
setStatus($a_status)
setGroupId($a_id)
update()
Update task.
setLastUpdate(ilDateTime $a_update)
getLastUpdate()
Get last update date.
read()
Read group.
setIdentifier($a_ide)
global $DIC
Definition: goto.php:24
$query
foreach($_POST as $key=> $value) $res
global $ilDB