ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
77 return $this->last_update = new ilDateTime();
78 }
79 return $this->last_update;
80 }
81
82 public function setStatus($a_status)
83 {
84 $this->status = $a_status;
85 }
86
91 public function getStatus()
92 {
93 return $this->status;
94 }
95
99 public function read()
100 {
101 global $ilDB;
102
103 if(!$this->getId())
104 {
105 return false;
106 }
107
108 $query = 'SELECT * FROM sysc_tasks '.
109 'WHERE id = '.$ilDB->quote($this->getId(),'integer');
110 $res = $ilDB->query($query);
111 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
112 {
113 $this->setGroupId($row->grp_id);
114 $this->setLastUpdate(new ilDateTime($row->last_update,IL_CAL_DATETIME,'UTC'));
115 $this->setStatus($row->status);
116 $this->setIdentifier($row->identifier);
117 }
118 return true;
119 }
120
124 public function create()
125 {
126 global $ilDB;
127
128 $this->id = $ilDB->nextId('sysc_tasks');
129
130 $query = 'INSERT INTO sysc_tasks (id,grp_id,status,identifier) '.
131 'VALUES ( '.
132 $ilDB->quote($this->getId(),'integer').', '.
133 $ilDB->quote($this->getGroupId(),'integer').', '.
134 $ilDB->quote($this->getStatus(),'integer').', '.
135 $ilDB->quote($this->getIdentifier(),'text').' '.
136 ')';
137 $ilDB->manipulate($query);
138 return $this->getId();
139 }
140
144 public function update()
145 {
146 global $ilDB;
147
148 $query = 'UPDATE sysc_tasks SET '.
149 'last_update = '.$ilDB->quote($this->getLastUpdate()->get(IL_CAL_DATETIME,'',UTC),'timestamp').', '.
150 'status = '.$ilDB->quote($this->getStatus(),'integer').', '.
151 'identifier = '.$ilDB->quote($this->getIdentifier(),'text').' '.
152 'WHERE id = '.$ilDB->quote($this->getId(),'integer');
153 $ilDB->manipulate($query);
154 }
155}
156?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
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 $ilDB