ILIAS  release_8 Revision v8.24
class.ilForumProperties.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 public const VIEW_TREE = 1;
28 public const VIEW_DATE = 2;
29 public const VIEW_DATE_ASC = 2;
30 public const VIEW_DATE_DESC = 3;
34 public const FILE_UPLOAD_INDIVIDUAL = 1;
35 public const THREAD_SORTING_DEFAULT = 0;
36 public const THREAD_SORTING_MANUAL = 1;
37
39 private static array $instances = [];
40
42 private int $obj_id;
44 private bool $anonymized = false;
45 private bool $statistics_enabled = false;
46 private bool $post_activation_enabled = false;
51 private string $notification_type = 'default';
53 private bool $admin_force_noti = false;
55 private bool $user_toggle_noti = false;
57 private bool $preset_subject = true;
61 private bool $add_re_subject = false;
62 private bool $mark_mod_posts = false;
64 private bool $is_thread_rating_enabled = false;
65 private bool $file_upload_allowed = false;
66 protected int $styleId = 0;
67 private bool $exists = false;
68 private ?int $lp_req_num_postings = null;
69 protected \ILIAS\Style\Content\Object\ObjectFacade $content_style_service;
70
71 protected function __construct(int $a_obj_id = 0)
72 {
73 global $DIC;
74
75 $this->db = $DIC->database();
76 $this->obj_id = $a_obj_id;
77 $this->read();
78 $this->content_style_service = $DIC
79 ->contentStyle()
80 ->domain()
81 ->styleForObjId($a_obj_id);
82 }
83
84 private function __clone()
85 {
86 }
87
88 public static function getInstance(int $a_obj_id = 0): self
89 {
90 if (!isset(self::$instances[$a_obj_id])) {
91 self::$instances[$a_obj_id] = new self($a_obj_id);
92 }
93
94 return self::$instances[$a_obj_id];
95 }
96
97 private function read(): void
98 {
99 if ($this->obj_id) {
100 $res = $this->db->queryF(
101 'SELECT * FROM frm_settings WHERE obj_id = %s',
102 ['integer'],
103 [$this->obj_id]
104 );
105
106 $row = $this->db->fetchObject($res);
107 if (is_object($row)) {
108 $this->exists = true;
109
110 $this->default_view = (int) $row->default_view;
111 $this->anonymized = (bool) $row->anonymized;
112 $this->statistics_enabled = (bool) $row->statistics_enabled;
113 $this->post_activation_enabled = (bool) $row->post_activation;
114 $this->admin_force_noti = (bool) $row->admin_force_noti;
115 $this->user_toggle_noti = (bool) $row->user_toggle_noti;
116 $this->preset_subject = (bool) $row->preset_subject;
117 $this->add_re_subject = (bool) $row->add_re_subject;
118 $this->interested_events = (int) $row->interested_events;
119
120 $this->notification_type = $row->notification_type ?? 'default';
121 $this->mark_mod_posts = (bool) $row->mark_mod_posts;
122 $this->thread_sorting = (int) $row->thread_sorting;
123 $this->is_thread_rating_enabled = (bool) $row->thread_rating;
124 $this->file_upload_allowed = (bool) $row->file_upload_allowed;
125 if (is_numeric($row->lp_req_num_postings)) {
126 $this->lp_req_num_postings = (int) $row->lp_req_num_postings;
127 }
128 }
129 }
130 }
131
132 public function insert(): void
133 {
134 if ($this->obj_id && !$this->exists) {
135 $this->db->insert(
136 'frm_settings',
137 [
138 'obj_id' => ['integer', $this->obj_id],
139 'default_view' => ['integer', $this->default_view],
140 'anonymized' => ['integer', (int) $this->anonymized],
141 'statistics_enabled' => ['integer', (int) $this->statistics_enabled],
142 'post_activation' => ['integer', (int) $this->post_activation_enabled],
143 'admin_force_noti' => ['integer', (int) $this->admin_force_noti],
144 'user_toggle_noti' => ['integer', (int) $this->user_toggle_noti],
145 'preset_subject' => ['integer', (int) $this->preset_subject],
146 'add_re_subject' => ['integer', (int) $this->add_re_subject],
147 'notification_type' => ['text', $this->notification_type],
148 'mark_mod_posts' => ['integer', (int) $this->mark_mod_posts],
149 'thread_sorting' => ['integer', $this->thread_sorting],
150 'thread_rating' => ['integer', (int) $this->is_thread_rating_enabled],
151 'file_upload_allowed' => ['integer', (int) $this->file_upload_allowed],
152 'lp_req_num_postings' => ['integer', $this->lp_req_num_postings],
153 'interested_events' => ['integer', $this->interested_events]
154 ]
155 );
156 $this->exists = true;
157 }
158 }
159
160 public function update(): void
161 {
162 if ($this->obj_id) {
163 if (!$this->exists) {
164 $this->insert();
165 return;
166 }
167
168 $this->db->update(
169 'frm_settings',
170 [
171 'default_view' => ['integer', $this->default_view],
172 'anonymized' => ['integer', (int) $this->anonymized],
173 'statistics_enabled' => ['integer', (int) $this->statistics_enabled],
174 'post_activation' => ['integer', (int) $this->post_activation_enabled],
175 'admin_force_noti' => ['integer', (int) $this->admin_force_noti],
176 'user_toggle_noti' => ['integer', (int) $this->user_toggle_noti],
177 'preset_subject' => ['integer', (int) $this->preset_subject],
178 'add_re_subject' => ['integer', (int) $this->add_re_subject],
179 'notification_type' => ['text', $this->notification_type],
180 'mark_mod_posts' => ['integer', (int) $this->mark_mod_posts],
181 'thread_sorting' => ['integer', $this->thread_sorting],
182 'thread_rating' => ['integer', (int) $this->is_thread_rating_enabled],
183 'file_upload_allowed' => ['integer', (int) $this->file_upload_allowed],
184 'lp_req_num_postings' => ['integer', (int) $this->lp_req_num_postings],
185 'interested_events' => ['integer', $this->interested_events]
186 ],
187 [
188 'obj_id' => ['integer', $this->obj_id]
189 ]
190 );
191 }
192 }
193
194 public function copy(int $a_new_obj_id): bool
195 {
196 if ($a_new_obj_id) {
197 $this->content_style_service->cloneTo($a_new_obj_id);
198
199 $this->db->update(
200 'frm_settings',
201 [
202 'default_view' => ['integer', $this->default_view],
203 'anonymized' => ['integer', (int) $this->anonymized],
204 'statistics_enabled' => ['integer', (int) $this->statistics_enabled],
205 'post_activation' => ['integer', (int) $this->post_activation_enabled],
206 'admin_force_noti' => ['integer', (int) $this->admin_force_noti],
207 'user_toggle_noti' => ['integer', (int) $this->user_toggle_noti],
208 'preset_subject' => ['integer', (int) $this->preset_subject],
209 'add_re_subject' => ['integer', (int) $this->add_re_subject],
210 'notification_type' => ['text', $this->notification_type],
211 'mark_mod_posts' => ['integer', (int) $this->mark_mod_posts],
212 'thread_sorting' => ['integer', $this->thread_sorting],
213 'thread_rating' => ['integer', (int) $this->is_thread_rating_enabled],
214 'file_upload_allowed' => ['integer', (int) $this->file_upload_allowed],
215 'lp_req_num_postings' => ['integer', $this->lp_req_num_postings],
216 'interested_events' => ['integer', $this->interested_events]
217 ],
218 [
219 'obj_id' => ['integer', $a_new_obj_id]
220 ]
221 );
222
223 return true;
224 }
225
226 return false;
227 }
228
229 public function isIsThreadRatingEnabled(): bool
230 {
232 }
233
235 {
236 $this->is_thread_rating_enabled = $is_thread_rating_enabled;
237 }
238
239 public function setDefaultView($a_default_view): void
240 {
241 $this->default_view = $a_default_view;
242 }
243
244 public function getDefaultView(): int
245 {
246 return $this->default_view;
247 }
248
249 public function setStatisticsStatus(bool $a_statistic_status): void
250 {
251 $this->statistics_enabled = $a_statistic_status;
252 }
253
254 public function isStatisticEnabled(): bool
255 {
257 }
258
259 public function setAnonymisation(bool $a_anonymized): void
260 {
261 $this->anonymized = $a_anonymized;
262 }
263
264 public function isAnonymized(): bool
265 {
266 return $this->anonymized;
267 }
268
269 public static function _isAnonymized(int $a_obj_id): bool
270 {
271 global $DIC;
272 $ilDB = $DIC->database();
273
274 $result = $ilDB->queryF(
275 'SELECT anonymized FROM frm_settings WHERE obj_id = %s',
276 ['integer'],
277 [$a_obj_id]
278 );
279
280 while ($record = $ilDB->fetchAssoc($result)) {
281 return (bool) $record['anonymized'];
282 }
283
284 return false;
285 }
286
287 public function setPostActivation(bool $a_post_activation): void
288 {
289 $this->post_activation_enabled = $a_post_activation;
290 }
291
292 public function isPostActivationEnabled(): bool
293 {
295 }
296
297 public function setObjId(int $a_obj_id): void
298 {
299 $this->obj_id = $a_obj_id;
300 $this->read();
301 }
302
303 public function getObjId(): int
304 {
305 return $this->obj_id;
306 }
307
308 public function setAdminForceNoti(bool $a_admin_force): void
309 {
310 $this->admin_force_noti = $a_admin_force;
311 }
312
313 public function isAdminForceNoti(): bool
314 {
316 }
317
318 public function setUserToggleNoti(bool $a_user_toggle): void
319 {
320 $this->user_toggle_noti = $a_user_toggle;
321 }
322
323 public function isUserToggleNoti(): bool
324 {
326 }
327
328 public static function _isAdminForceNoti(int $a_obj_id): bool
329 {
330 global $DIC;
331
332 $ilDB = $DIC->database();
333
334 $res = $ilDB->queryF(
335 'SELECT admin_force_noti FROM frm_settings WHERE obj_id = %s',
336 ['integer'],
337 [$a_obj_id]
338 );
339 if ($record = $ilDB->fetchAssoc($res)) {
340 return (bool) $record['admin_force_noti'];
341 }
342
343 return false;
344 }
345
346 public static function _isUserToggleNoti(int $a_obj_id): bool
347 {
348 global $DIC;
349
350 $ilDB = $DIC->database();
351
352 $res = $ilDB->queryF(
353 'SELECT user_toggle_noti FROM frm_settings WHERE obj_id = %s',
354 ['integer'],
355 [$a_obj_id]
356 );
357 while ($record = $ilDB->fetchAssoc($res)) {
358 return (bool) $record['user_toggle_noti'];
359 }
360
361 return false;
362 }
363
364 public function setPresetSubject(bool $a_preset_subject): void
365 {
366 $this->preset_subject = $a_preset_subject;
367 }
368
369 public function isSubjectPreset(): bool
370 {
372 }
373
374 public function setAddReSubject(bool $a_add_re_subject): void
375 {
376 $this->add_re_subject = $a_add_re_subject;
377 }
378
379 public function isSubjectAdded(): bool
380 {
382 }
383
384 public function setNotificationType(?string $a_notification_type): void
385 {
386 if ($a_notification_type === null) {
387 $this->notification_type = 'default';
388 } else {
389 $this->notification_type = $a_notification_type;
390 }
391 }
392
393 public function getNotificationType(): string
394 {
396 }
397
398 public function getSubjectSetting(): string
399 {
400 if (!$this->isSubjectPreset() && !$this->isSubjectAdded()) {
401 return "empty_subject";
402 }
403
404 if ($this->isSubjectPreset()) {
405 return "preset_subject";
406 }
407
408 if ($this->isSubjectAdded()) {
409 return "add_re_to_subject";
410 }
411
412 return "preset_subject";
413 }
414
415 public function setSubjectSetting($a_subject_setting): void
416 {
417 if ($a_subject_setting === 'empty_subject') {
418 $this->setPresetSubject(false);
419 $this->setAddReSubject(false);
420 } elseif ($a_subject_setting === 'preset_subject') {
421 $this->setPresetSubject(true);
422 $this->setAddReSubject(false);
423 } elseif ($a_subject_setting === 'add_re_to_subject') {
424 $this->setPresetSubject(false);
425 $this->setAddReSubject(true);
426 }
427 }
428
429 public function setMarkModeratorPosts(bool $a_mod_post): void
430 {
431 $this->mark_mod_posts = $a_mod_post;
432 }
433
434 public function getMarkModeratorPosts(): bool
435 {
437 }
438
439 public function setThreadSorting(int $a_thread_sorting): void
440 {
441 $this->thread_sorting = $a_thread_sorting;
442 }
443
444 public function getThreadSorting(): int
445 {
447 }
448
449 public function getUserToggleNoti(): bool
450 {
452 }
453
454 public function getAdminForceNoti(): bool
455 {
457 }
458
459 public function setFileUploadAllowed(bool $allowed): void
460 {
461 $this->file_upload_allowed = $allowed;
462 }
463
464 public function getFileUploadAllowed(): bool
465 {
467 }
468
469 public function isFileUploadAllowed(): bool
470 {
471 if (self::isFileUploadGloballyAllowed()) {
472 return true;
473 }
474
475 if ($this->getFileUploadAllowed()) {
476 return true;
477 }
478
479 return false;
480 }
481
482 public static function isFileUploadGloballyAllowed(): bool
483 {
484 global $DIC;
485
486 return (
487 (int) $DIC->settings()->get('file_upload_allowed_fora') === self::FILE_UPLOAD_GLOBALLY_ALLOWED
488 );
489 }
490
491 public static function isSendAttachmentsByMailEnabled(): bool
492 {
493 global $DIC;
494
495 return (bool) $DIC->settings()->get('send_attachments_by_mail');
496 }
497
498 public function getInterestedEvents(): int
499 {
501 }
502
503 public function setInterestedEvents(int $interested_events): void
504 {
505 $this->interested_events = $interested_events;
506 }
507
508 public function getLpReqNumPostings(): ?int
509 {
511 }
512
513 public function setLpReqNumPostings(?int $lp_req_num_postings): void
514 {
515 $this->lp_req_num_postings = $lp_req_num_postings;
516 }
517}
static _isAdminForceNoti(int $a_obj_id)
static _isUserToggleNoti(int $a_obj_id)
setUserToggleNoti(bool $a_user_toggle)
setSubjectSetting($a_subject_setting)
int $interested_events
Preset notification events for forced notification.
bool $user_toggle_noti
Activation of allowing members to deactivate (CRS/GRP)forum notification.
__construct(int $a_obj_id=0)
static _isAnonymized(int $a_obj_id)
setMarkModeratorPosts(bool $a_mod_post)
setFileUploadAllowed(bool $allowed)
setPostActivation(bool $a_post_activation)
static getInstance(int $a_obj_id=0)
string $notification_type
Global notification-type setting (CRS/GRP) possible values: 'all_users', 'per_user',...
setAdminForceNoti(bool $a_admin_force)
setAnonymisation(bool $a_anonymized)
setLpReqNumPostings(?int $lp_req_num_postings)
ILIAS Style Content Object ObjectFacade $content_style_service
setPresetSubject(bool $a_preset_subject)
setIsThreadRatingEnabled(bool $is_thread_rating_enabled)
setInterestedEvents(int $interested_events)
bool $preset_subject
If deactivated, user is forced to enter a new subject on repliees.
setNotificationType(?string $a_notification_type)
bool $admin_force_noti
Activation of (CRS/GRP) forum notification by mod/admin.
setThreadSorting(int $a_thread_sorting)
setAddReSubject(bool $a_add_re_subject)
bool $add_re_subject
Add 'Re: ' to subject on reply.
setDefaultView($a_default_view)
setStatisticsStatus(bool $a_statistic_status)
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
$res
Definition: ltiservices.php:69