ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSCGroup.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
25{
26 private int $id = 0;
27 private string $component_id = '';
28 private string $component_type = '';
29 private ?ilDateTime $last_update = null;
30 private int $status = 0;
31 protected ilDBInterface $db;
32
33 public function __construct(int $a_id = 0)
34 {
35 global $DIC;
36 $this->db = $DIC->database();
37 $this->id = $a_id;
38 $this->read();
39 }
40
41 public static function lookupComponent(int $a_id): string
42 {
43 global $DIC;
44
45 $ilDB = $DIC->database();
46
47 $query = 'SELECT component FROM sysc_groups ' .
48 'WHERE id = ' . $ilDB->quote($a_id, ilDBConstants::T_INTEGER);
49 $res = $ilDB->query($query);
50 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
51 return (string) $row->component;
52 }
53 return '';
54 }
55
56 public function getId(): int
57 {
58 return $this->id;
59 }
60
61 public function setComponentId(string $a_comp): void
62 {
63 $this->component_id = $a_comp;
64 }
65
66 public function getComponentId(): string
67 {
69 }
70
71 public function setLastUpdate(ilDateTime $a_update): void
72 {
73 $this->last_update = $a_update;
74 }
75
76 public function getLastUpdate(): ilDateTime
77 {
78 if (!$this->last_update) {
79 return $this->last_update = new ilDateTime();
80 }
81 return $this->last_update;
82 }
83
84 public function setStatus(int $a_status): void
85 {
86 $this->status = $a_status;
87 }
88
89 public function getStatus(): int
90 {
91 return $this->status;
92 }
93
94 public function read(): bool
95 {
96 if (!$this->getId()) {
97 return false;
98 }
99
100 $query = 'SELECT * FROM sysc_groups ' .
101 'WHERE id = ' . $this->db->quote($this->getId(), ilDBConstants::T_INTEGER);
102 $res = $this->db->query($query);
103 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
104 $this->setComponentId((string) $row->component);
105 $this->setLastUpdate(new ilDateTime($row->last_update, IL_CAL_DATETIME, ilTimeZone::UTC));
106 $this->setStatus((int) $row->status);
107 }
108 return true;
109 }
110
111 public function create(): int
112 {
113 $this->id = $this->db->nextId('sysc_groups');
114
115 $query = 'INSERT INTO sysc_groups (id,component,status) ' .
116 'VALUES ( ' .
117 $this->db->quote($this->getId(), ilDBConstants::T_INTEGER) . ', ' .
118 $this->db->quote($this->getComponentId(), ilDBConstants::T_TEXT) . ', ' .
119 $this->db->quote($this->getStatus(), ilDBConstants::T_INTEGER) . ' ' .
120 ')';
121 $this->db->manipulate($query);
122 return $this->getId();
123 }
124}
const IL_CAL_DATETIME
@classDescription Date and time handling
Defines a system check group including different tasks of a component.
string $component_type
__construct(int $a_id=0)
setStatus(int $a_status)
ilDBInterface $db
string $component_id
ilDateTime $last_update
setLastUpdate(ilDateTime $a_update)
setComponentId(string $a_comp)
static lookupComponent(int $a_id)
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26