ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTimingAccepted.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
25{
26 protected ilDBInterface $db;
27
28 private int $obj_id = 0;
29 private int $user_id = 0;
30 private bool $visible = false;
31 private string $remark = '';
32 private bool $accepted = false;
33
34 public function __construct(int $crs_id, int $a_usr_id)
35 {
36 global $DIC;
37
38 $this->db = $DIC->database();
39 $this->obj_id = $crs_id;
40 $this->user_id = $a_usr_id;
41 $this->__read();
42 }
43
44 public function getUserId(): int
45 {
46 return $this->user_id;
47 }
48
49 public function getCourseId(): int
50 {
51 return $this->obj_id;
52 }
53
54 public function accept(bool $a_status): void
55 {
56 $this->accepted = $a_status;
57 }
58
59 public function isAccepted(): bool
60 {
61 return $this->accepted;
62 }
63
64 public function setRemark(string $a_remark): void
65 {
66 $this->remark = $a_remark;
67 }
68
69 public function getRemark(): string
70 {
71 return $this->remark;
72 }
73
74 public function setVisible(bool $a_visible): void
75 {
76 $this->visible = $a_visible;
77 }
78
79 public function isVisible(): bool
80 {
81 return $this->visible;
82 }
83
84 public function update(): void
85 {
87 $this->create();
88 }
89
90 public function create(): void
91 {
92 $query = "INSERT INTO crs_timings_usr_accept (crs_id,usr_id,visible,accept,remark) " .
93 "VALUES( " .
94 $this->db->quote($this->getCourseId(), 'integer') . ", " .
95 $this->db->quote($this->getUserId(), 'integer') . ", " .
96 $this->db->quote($this->isVisible(), 'integer') . ", " .
97 $this->db->quote($this->isAccepted(), 'integer') . ", " .
98 $this->db->quote($this->getRemark(), 'text') . " " .
99 ")";
100 $res = $this->db->manipulate($query);
101 }
102
103 public function delete(): void
104 {
106 }
107
108 public function _delete(int $a_crs_id, int $a_usr_id): void
109 {
110 $query = "DELETE FROM crs_timings_usr_accept " .
111 "WHERE crs_id = " . $this->db->quote($a_crs_id, 'integer') . " " .
112 "AND usr_id = " . $this->db->quote($a_usr_id, 'integer') . " ";
113 $res = $this->db->manipulate($query);
114 }
115
116 public function _deleteByCourse(int $a_crs_id): void
117 {
118 $query = "DELETE FROM crs_timings_usr_accept " .
119 "WHERE crs_id = " . $this->db->quote($a_crs_id, 'integer') . " ";
120 $res = $this->db->manipulate($query);
121 }
122
123 public static function _deleteByUser(int $a_usr_id): void
124 {
125 global $DIC;
126
127 $ilDB = $DIC->database();
128 $query = "DELETE FROM crs_timings_usr_accept " .
129 "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . "";
130 $res = $ilDB->manipulate($query);
131 }
132
133 public function __read(): void
134 {
135 if ($this->obj_id <= 0 || $this->user_id <= 0) {
136 return;
137 }
138 $query = "SELECT * FROM crs_timings_usr_accept " .
139 "WHERE crs_id = " . $this->db->quote($this->getCourseId(), 'integer') . " " .
140 "AND usr_id = " . $this->db->quote($this->getUserId(), 'integer');
141 $res = $this->db->query($query);
142 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
143 $this->setVisible((bool) $row->visible);
144 $this->setRemark((string) $row->remark);
145 $this->accept((bool) $row->accept);
146 }
147 }
148}
class ilTimingAccepted
__construct(int $crs_id, int $a_usr_id)
_delete(int $a_crs_id, int $a_usr_id)
setRemark(string $a_remark)
static _deleteByUser(int $a_usr_id)
setVisible(bool $a_visible)
_deleteByCourse(int $a_crs_id)
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26