ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSCGroups.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
25{
26 private static ?ilSCGroups $instance = null;
27
28 private array $groups = array();
29
30 protected ilDBInterface $db;
31
32 private function __construct()
33 {
34 global $DIC;
35
36 $this->db = $DIC->database();
37 $this->read();
38 }
39
40 public static function getInstance(): ilSCGroups
41 {
42 return self::$instance ?? (self::$instance = new self());
43 }
44
45 public function updateFromComponentDefinition(string $a_component_id): int
46 {
47 foreach ($this->getGroups() as $group) {
48 if ($group->getComponentId() === $a_component_id) {
49 return $group->getId();
50 }
51 }
52
53 $component_group = new ilSCGroup();
54 $component_group->setComponentId($a_component_id);
55 $component_group->create();
56
57 return $component_group->getId();
58 }
59
60 public function lookupGroupByComponentId(string $a_component_id): int
61 {
62 $query = 'SELECT id FROM sysc_groups ' .
63 'WHERE component = ' . $this->db->quote($a_component_id, ilDBConstants::T_TEXT);
64 $res = $this->db->query($query);
65 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
66 return (int) $row->id;
67 }
68 return 0;
69 }
70
74 public function getGroups(): array
75 {
76 return $this->groups;
77 }
78
79 protected function read(): void
80 {
81 $query = 'SELECT id FROM sysc_groups ' .
82 'ORDER BY id ';
83 $res = $this->db->query($query);
84
85 $this->groups = array();
86 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
87 $this->groups[] = new ilSCGroup((int) $row->id);
88 }
89 }
90}
Defines a system check group including different tasks of a component.
Description of class.
static ilSCGroups $instance
static getInstance()
updateFromComponentDefinition(string $a_component_id)
lookupGroupByComponentId(string $a_component_id)
ilDBInterface $db
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26