ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilSCTasks.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/SystemCheck/classes/class.ilSCTask.php';
6
13{
14
18 private static $instances = array();
19
20 private $grp_id = 0;
21 private $tasks = array();
22
26 private function __construct($a_grp_id)
27 {
28 $this->grp_id = $a_grp_id;
29 $this->read();
30 }
31
36 public static function getInstanceByGroupId($a_group_id)
37 {
38 if(!array_key_exists($a_group_id, self::$instances))
39 {
40 return self::$instances[$a_group_id] = new self($a_group_id);
41 }
42 return self::$instances[$a_group_id];
43 }
44
50 public function updateFromComponentDefinition($a_identifier)
51 {
52 foreach($this->getTasks() as $task)
53 {
54 if($task->getIdentifier() == $a_identifier)
55 {
56 return TRUE;
57 }
58 }
59
60 $task = new ilSCTask();
61 $task->setGroupId($this->getGroupId());
62 $task->setIdentifier($a_identifier);
63 $task->create();
64
65 return $task->getId();
66 }
67
68
69
76 public static function lookupGroupId($a_task_id)
77 {
78 global $ilDB;
79
80 $query = 'SELECT grp_id FROM sysc_tasks '.
81 'WHERE id = '.$ilDB->quote($a_task_id,'integer');
82 $res = $ilDB->query($query);
83 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
84 {
85 return $row->grp_id;
86 }
87 return 0;
88 }
89
94 public static function lookupCompleted($a_grp_id)
95 {
96 global $ilDB;
97
98 $query = 'SELECT count(id) num FROM sysc_tasks '.
99 'WHERE status = '.$ilDB->quote(ilSCTask::STATUS_COMPLETED,'integer').' '.
100 'AND grp_id = '.$ilDB->quote($a_grp_id,'integer');
101 $res = $ilDB->query($query);
102 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
103 {
104 return $row->num;
105 }
106 return 0;
107 }
108
113 public static function lookupFailed($a_grp_id)
114 {
115 global $ilDB;
116
117 $query = 'SELECT count(id) num FROM sysc_tasks '.
118 'WHERE status = '.$ilDB->quote(ilSCTask::STATUS_FAILED,'integer').' '.
119 'AND grp_id = '.$ilDB->quote($a_grp_id,'integer');
120 $res = $ilDB->query($query);
121 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
122 {
123 return $row->num;
124 }
125 return 0;
126 }
127
134 public static function lookupLastUpdate($a_grp_id)
135 {
136 global $ilDB;
137
138 $query = 'SELECT MAX(last_update) last_update FROM sysc_tasks '.
139 'WHERE status = '.$ilDB->quote(ilSCTask::STATUS_FAILED,'integer').' '.
140 'AND grp_id = '.$ilDB->quote($a_grp_id,'integer');
141 $res = $ilDB->query($query);
142
143 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
144 {
145 return new ilDateTime($row->last_update,IL_CAL_DATETIME,'UTC');
146 }
147 return new ilDateTime(time(),IL_CAL_UNIX);
148 }
149
150 public function getGroupId()
151 {
152 return $this->grp_id;
153 }
154
159 public function getTasks()
160 {
161 return (array) $this->tasks;
162 }
163
167 protected function read()
168 {
169 global $ilDB;
170
171 $query = 'SELECT id FROM sysc_tasks '.
172 'ORDER BY id ';
173 $res = $ilDB->query($query);
174
175 $this->tasks = array();
176 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
177 {
178 $this->tasks[] = new ilSCTask($row->id);
179 }
180 }
181}
182?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
const IL_CAL_UNIX
const IL_CAL_DATETIME
@classDescription Date and time handling
Defines a system check task.
const STATUS_COMPLETED
const STATUS_FAILED
Description of class.
read()
read groups
static getInstanceByGroupId($a_group_id)
Get singleton instance.
getTasks()
Get groups.
static lookupFailed($a_grp_id)
@global type $ilDB
static $instances
static lookupCompleted($a_grp_id)
@global type $ilDB
static lookupGroupId($a_task_id)
Lookup group id by task id @global type $ilDB.
static lookupLastUpdate($a_grp_id)
Lookup last update of group tasks @global type $ilDB.
__construct($a_grp_id)
Singleton constructor.
updateFromComponentDefinition($a_identifier)
Update from module/service reader.
$task
GENERAL INFORMATION:
global $ilDB