ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilForumPostsDeleted.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 private readonly ilDBInterface $db;
28 protected int $deleted_id = 0;
29 protected string $deleted_date;
30 protected string $deleted_by = '';
31 protected string $forum_title = '';
32 protected string $thread_title = '';
33 protected string $post_title = '';
34 protected string $post_message = '';
35 protected string $post_date = '';
36 protected int $obj_id = 0;
37 protected int $ref_id = 0;
38 protected int $thread_id = 0;
39 protected int $forum_id = 0;
40 protected int $pos_display_user_id = 0;
41 protected string $pos_usr_alias = '';
42 protected bool $thread_deleted = false;
43
45 {
46 global $DIC;
47
48 $this->db = $DIC->database();
49
50 if ($provider !== null) {
51 if (
52 $provider->objPost->getUserAlias() && $provider->objPost->getDisplayUserId() === 0 &&
53 $provider->objPost->getPosAuthorId() === $DIC->user()->getId()
54 ) {
55 $this->setDeletedBy($provider->objPost->getUserAlias());
56 } else {
57 $user = $DIC->user();
58 $this->setDeletedBy($user->getLogin());
59 }
60
61 $this->setDeletedDate(date('Y-m-d H:i:s'));
62 $this->setForumTitle($provider->getForumTitle());
63 $this->setThreadTitle($provider->getThreadTitle());
64 $this->setPostTitle($provider->getPostTitle());
65
66 if ($provider->isPostCensored()) {
67 $this->setPostMessage($provider->getCensorshipComment());
68 } else {
69 $this->setPostMessage($provider->getPostMessage());
70 }
71
72 $this->setPostDate($provider->getPostDate());
73 $this->setObjId($provider->getObjId());
74 $this->setRefId($provider->getRefId());
75 $this->setThreadId($provider->getThreadId());
76 $this->setForumId($provider->getForumId());
77 $this->setPosDisplayUserId($provider->getPosDisplayUserId());
78 $this->setPosUserAlias($provider->getPosUserAlias());
79 }
80 }
81
82 public function insert(): void
83 {
84 $next_id = $this->db->nextId('frm_posts_deleted');
85
86 $this->db->insert('frm_posts_deleted', [
87 'deleted_id' => ['integer', $next_id],
88 'deleted_date' => ['timestamp', $this->getDeletedDate()],
89 'deleted_by' => ['text', $this->getDeletedBy()],
90 'forum_title' => ['text', $this->getForumTitle()],
91 'thread_title' => ['text', $this->getThreadTitle()],
92 'post_title' => ['text', $this->getPostTitle()],
93 'post_message' => ['text', $this->getPostMessage()],
94
95 'post_date' => ['timestamp', $this->getPostDate()],
96 'obj_id' => ['integer', $this->getObjId()],
97 'ref_id' => ['integer', $this->getRefId()],
98 'thread_id' => ['integer', $this->getThreadId()],
99 'forum_id' => ['integer', $this->getForumId()],
100 'pos_display_user_id' => ['integer', $this->getPosDisplayUserId()],
101 'pos_usr_alias' => ['text', $this->getPosUserAlias()],
102 'is_thread_deleted' => ['integer', $this->isThreadDeleted()]
103 ]);
104 }
105
106 public function deleteNotifiedEntries(): void
107 {
108 $this->db->manipulateF('DELETE FROM frm_posts_deleted WHERE deleted_id > %s', ['integer'], [0]);
109 }
110
111 public function getDeletedId(): int
112 {
113 return $this->deleted_id;
114 }
115
116 public function setDeletedId(int $deleted_id): void
117 {
118 $this->deleted_id = $deleted_id;
119 }
120
121 public function getDeletedDate(): string
122 {
123 return $this->deleted_date;
124 }
125
126 public function setDeletedDate(string $deleted_date): void
127 {
128 $this->deleted_date = $deleted_date;
129 }
130
131 public function getDeletedBy(): string
132 {
133 return $this->deleted_by;
134 }
135
136 public function setDeletedBy(string $deleted_by): void
137 {
138 $this->deleted_by = $deleted_by;
139 }
140
141 public function getForumTitle(): string
142 {
143 return $this->forum_title;
144 }
145
146 public function setForumTitle(string $forum_title): void
147 {
148 $this->forum_title = $forum_title;
149 }
150
151 public function getThreadTitle(): string
152 {
153 return $this->thread_title;
154 }
155
156 public function setThreadTitle(string $thread_title): void
157 {
158 $this->thread_title = $thread_title;
159 }
160
161 public function getPostTitle(): string
162 {
163 return $this->post_title;
164 }
165
166 public function setPostTitle(string $post_title): void
167 {
168 $this->post_title = $post_title;
169 }
170
171 public function getPostMessage(): string
172 {
173 return $this->post_message;
174 }
175
176 public function setPostMessage(string $post_message): void
177 {
178 $this->post_message = $post_message;
179 }
180
181 public function getPostDate(): string
182 {
183 return $this->post_date;
184 }
185
186 public function setPostDate(string $post_date): void
187 {
188 $this->post_date = $post_date;
189 }
190
191 public function getObjId(): int
192 {
193 return $this->obj_id;
194 }
195
196 public function setObjId(int $obj_id): void
197 {
198 $this->obj_id = $obj_id;
199 }
200
201 public function getRefId(): int
202 {
203 return $this->ref_id;
204 }
205
206 public function setRefId(int $ref_id): void
207 {
208 $this->ref_id = $ref_id;
209 }
210
211 public function getThreadId(): int
212 {
213 return $this->thread_id;
214 }
215
216 public function setThreadId(int $thread_id): void
217 {
218 $this->thread_id = $thread_id;
219 }
220
221 public function getForumId(): int
222 {
223 return $this->forum_id;
224 }
225
226 public function setForumId(int $forum_id): void
227 {
228 $this->forum_id = $forum_id;
229 }
230
231 public function getPosDisplayUserId(): int
232 {
234 }
235
236 public function setPosDisplayUserId(int $pos_display_user_id): void
237 {
238 $this->pos_display_user_id = $pos_display_user_id;
239 }
240
241 public function getPosUserAlias(): string
242 {
244 }
245
246 public function setPosUserAlias(string $pos_usr_alias): void
247 {
248 $this->pos_usr_alias = $pos_usr_alias;
249 }
250
251 public function isThreadDeleted(): bool
252 {
254 }
255
256 public function setThreadDeleted(bool $thread_deleted): void
257 {
258 $this->thread_deleted = $thread_deleted;
259 }
260}
Class ilForumNotificationDataProvider.
Class ilForumPostsDeleted.
readonly ilDBInterface $db
setThreadTitle(string $thread_title)
setPostTitle(string $post_title)
setPosDisplayUserId(int $pos_display_user_id)
setThreadDeleted(bool $thread_deleted)
setPosUserAlias(string $pos_usr_alias)
__construct(?ilForumNotificationDataProvider $provider=null)
setPostMessage(string $post_message)
setDeletedDate(string $deleted_date)
setForumTitle(string $forum_title)
setDeletedBy(string $deleted_by)
Interface ilDBInterface.
$provider
Definition: ltitoken.php:80
global $DIC
Definition: shib_login.php:26