ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilSCGroups.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.ilSCGroup.php';
6
13{
14
18 private static $instance = null;
19
20 private $groups = array();
21
25 private function __construct()
26 {
27 $this->read();
28 }
29
34 public static function getInstance()
35 {
36 if(self::$instance == NULL)
37 {
38 return self::$instance = new self();
39 }
40 return self::$instance;
41 }
42
47 public function updateFromComponentDefinition($a_component_id)
48 {
49 foreach($this->getGroups() as $group)
50 {
51 if($group->getComponentId() == $a_component_id)
52 {
53 return $group->getId();
54 }
55 }
56
57 $component_group = new ilSCGroup();
58 $component_group->setComponentId($a_component_id);
59 $component_group->create();
60
61 return $component_group->getId();
62 }
63
67 public function lookupGroupByComponentId($a_component_id)
68 {
69 global $ilDB;
70
71 $query = 'SELECT id FROM sysc_groups '.
72 'WHERE component = '.$ilDB->quote($a_component_id,'text');
73 $res = $ilDB->query($query);
74 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
75 {
76 return $row->id;
77 }
78 return 0;
79 }
80
81
86 public function getGroups()
87 {
88 return (array) $this->groups;
89 }
90
94 protected function read()
95 {
96 global $ilDB;
97
98 $query = 'SELECT id FROM sysc_groups '.
99 'ORDER BY id ';
100 $res = $ilDB->query($query);
101
102 $this->groups = array();
103 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
104 {
105 $this->groups[] = new ilSCGroup($row->id);
106 }
107 }
108}
109?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
Defines a system check group including different tasks of a component.
Description of class.
read()
read groups
lookupGroupByComponentId($a_component_id)
getGroups()
Get groups.
static getInstance()
Get singleton instance.
updateFromComponentDefinition($a_component_id)
Update from component definition reader.
__construct()
Singleton constructor.
global $ilDB