ILIAS  release_8 Revision v8.24
class.ilConsultationHourGroup.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
6
11{
12 private int $group_id = 0;
13 private int $usr_id = 0;
14 private int $num_assignments = 1;
15 private string $title = '';
16
17 protected ilDBInterface $db;
18
19 public function __construct(int $a_group_id = 0)
20 {
21 global $DIC;
22
23 $this->db = $DIC->database();
24 $this->group_id = $a_group_id;
25 $this->read();
26 }
27
28 public function getGroupId(): int
29 {
30 return $this->group_id;
31 }
32
33 public function setUserId(int $a_id): void
34 {
35 $this->usr_id = $a_id;
36 }
37
38 public function getUserId(): int
39 {
40 return $this->usr_id;
41 }
42
43 public function setMaxAssignments(int $a_num): void
44 {
45 $this->num_assignments = $a_num;
46 }
47
48 public function getMaxAssignments(): int
49 {
51 }
52
53 public function setTitle(string $a_title): void
54 {
55 $this->title = $a_title;
56 }
57
58 public function getTitle(): string
59 {
60 return $this->title;
61 }
62
63 public function save(): int
64 {
65 $this->group_id = $this->db->nextId('cal_ch_group');
66 $query = 'INSERT INTO cal_ch_group (grp_id,usr_id,multiple_assignments,title) ' .
67 'VALUES ( ' .
68 $this->db->quote($this->getGroupId(), 'integer') . ', ' .
69 $this->db->quote($this->getUserId(), 'integer') . ', ' .
70 $this->db->quote($this->getMaxAssignments(), 'integer') . ', ' .
71 $this->db->quote($this->getTitle(), 'text') .
72 ')';
73 $this->db->manipulate($query);
74 return $this->getGroupId();
75 }
76
77 public function update(): void
78 {
79 $query = 'UPDATE cal_ch_group SET ' .
80 'usr_id = ' . $this->db->quote($this->getUserId(), 'integer') . ', ' .
81 'multiple_assignments = ' . $this->db->quote($this->getMaxAssignments(), 'integer') . ', ' .
82 'title = ' . $this->db->quote($this->getTitle(), 'text') . ' ' .
83 'WHERE grp_id = ' . $this->db->quote($this->getGroupId(), 'integer');
84 $this->db->manipulate($query);
85 }
86
87 public function delete(): void
88 {
89 $query = 'DELETE FROM cal_ch_group ' .
90 'WHERE grp_id = ' . $this->db->quote($this->getGroupId(), 'integer');
91 $this->db->manipulate($query);
93 }
94
95 protected function read(): void
96 {
97 if (!$this->getGroupId()) {
98 return;
99 }
100 $query = 'SELECT * FROM cal_ch_group ' .
101 'WHERE grp_id = ' . $this->db->quote($this->getGroupId(), 'integer');
102 $res = $this->db->query($query);
103 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
104 $this->setUserId((int) $row->usr_id);
105 $this->setTitle($row->title);
106 $this->setMaxAssignments((int) $row->multiple_assignments);
107 }
108 }
109}
static resetGroup(int $a_group_id)
Reset booking group (in case of deletion)
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
$query