ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilForumProperties.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11{
12 const VIEW_TREE = 1;
13 const VIEW_DATE = 2;
14 const VIEW_DATE_ASC = 2;
15 const VIEW_DATE_DESC = 3;
16
19
22
27 private $obj_id;
28
34
39 private $anonymized = 0; //false;
40
45 private $statistics_enabled = 0; //false;
46
51 private $post_activation_enabled = 0; //false;
52
61 private $notification_type = null;
62
67 private $admin_force_noti = false;
72 private $user_toggle_noti = false;
73
80 private $preset_subject = 1;
81
87 private $add_re_subject = 0;
88
89 private $mark_mod_posts = 0;
90
98 private $thread_sorting = 0;
99
104
109 private $db = null;
110
115
119 private static $instances = array();
120
121 protected function __construct($a_obj_id = 0)
122 {
123 global $DIC;
124
125 $this->db = $DIC->database();
126 $this->obj_id = $a_obj_id;
127 $this->read();
128 }
129
130 private function __clone()
131 {
132 }
133
138 public static function getInstance($a_obj_id = 0)
139 {
140 if (!self::$instances[$a_obj_id]) {
141 self::$instances[$a_obj_id] = new ilForumProperties($a_obj_id);
142 }
143
144 return self::$instances[$a_obj_id];
145 }
146
147 private function read()
148 {
149 if ($this->obj_id) {
150 $res = $this->db->queryf(
151 '
152 SELECT * FROM frm_settings
153 WHERE obj_id = %s',
154 array('integer'),
155 array($this->obj_id)
156 );
157
158 $row = $this->db->fetchObject($res);
159
160 if (is_object($row)) {
161 $this->default_view = $row->default_view;
162 $this->anonymized = $row->anonymized ;// == 1 ? true : false;
163 $this->statistics_enabled = $row->statistics_enabled ;// == 1 ? true : false;
164 $this->post_activation_enabled = $row->post_activation ;// == 1 ? true : false;
165 $this->admin_force_noti = $row->admin_force_noti == 1 ? true : false;
166 $this->user_toggle_noti = $row->user_toggle_noti == 1 ? true : false;
167 $this->preset_subject = $row->preset_subject;
168 $this->add_re_subject = $row->add_re_subject;
169
170 $this->notification_type = $row->notification_type == null ? 'default': $row->notification_type;
171 $this->mark_mod_posts = $row->mark_mod_posts == 1 ? true : false;
172 $this->thread_sorting = $row->thread_sorting == 1? true : false;
173 $this->setIsThreadRatingEnabled((bool) $row->thread_rating);
174 $this->file_upload_allowed = $row->file_upload_allowed == 1 ? true : false;
175
176 return true;
177 }
178
179 return false;
180 }
181
182 return false;
183 }
184
185 public function insert()
186 {
187 if ($this->obj_id) {
188 $this->db->insert(
189 'frm_settings',
190 array(
191 'obj_id' => array('integer', $this->obj_id),
192 'default_view' => array('integer', $this->default_view),
193 'anonymized' => array('integer', $this->anonymized),
194 'statistics_enabled' => array('integer', $this->statistics_enabled),
195 'post_activation' => array('integer', $this->post_activation_enabled),
196 'admin_force_noti' => array('integer', $this->admin_force_noti),
197 'user_toggle_noti' => array('integer', $this->user_toggle_noti),
198 'preset_subject' => array('integer', $this->preset_subject),
199 'add_re_subject' => array('integer', $this->add_re_subject),
200 'notification_type' => array('text', $this->notification_type),
201 'mark_mod_posts' => array('integer', $this->mark_mod_posts),
202 'thread_sorting' => array('integer', $this->thread_sorting),
203 'thread_rating' => array('integer', $this->isIsThreadRatingEnabled()),
204 'file_upload_allowed' => array('integer', $this->file_upload_allowed)
205 )
206 );
207
208 return true;
209 }
210
211 return false;
212 }
213
214 public function update()
215 {
216 if ($this->obj_id) {
217 $this->db->update(
218 'frm_settings',
219 array(
220 'default_view' => array('integer', $this->default_view),
221 'anonymized' => array('integer', $this->anonymized),
222 'statistics_enabled' => array('integer', $this->statistics_enabled),
223 'post_activation' => array('integer', $this->post_activation_enabled),
224 'admin_force_noti' => array('integer', $this->admin_force_noti),
225 'user_toggle_noti' => array('integer', $this->user_toggle_noti),
226 'preset_subject' => array('integer', $this->preset_subject),
227 'add_re_subject' => array('integer', $this->add_re_subject),
228 'notification_type' => array('text', $this->notification_type),
229 'mark_mod_posts' => array('integer', $this->mark_mod_posts),
230 'thread_sorting' => array('integer', $this->thread_sorting),
231 'thread_rating' => array('integer', $this->isIsThreadRatingEnabled()),
232 'file_upload_allowed' => array('integer', $this->file_upload_allowed)
233 ),
234 array(
235 'obj_id' => array('integer', $this->obj_id)
236 )
237 );
238 return true;
239 }
240 return false;
241 }
242
243 public function copy($a_new_obj_id)
244 {
245 if ($a_new_obj_id) {
246 $this->db->update(
247 'frm_settings',
248 array(
249 'default_view' => array('integer', $this->default_view),
250 'anonymized' => array('integer', $this->anonymized),
251 'statistics_enabled' => array('integer', $this->statistics_enabled),
252 'post_activation' => array('integer', $this->post_activation_enabled),
253 'admin_force_noti' => array('integer', $this->admin_force_noti),
254 'user_toggle_noti' => array('integer', $this->user_toggle_noti),
255 'preset_subject' => array('integer', $this->preset_subject),
256 'add_re_subject' => array('integer', $this->add_re_subject),
257 'notification_type' => array('text', $this->notification_type),
258 'mark_mod_posts' => array('integer', $this->mark_mod_posts),
259 'thread_sorting' => array('integer', $this->thread_sorting),
260 'thread_rating' => array('integer', $this->isIsThreadRatingEnabled()),
261 'file_upload_allowed' => array('integer', $this->file_upload_allowed)
262 ),
263 array(
264 'obj_id' => array('integer', $a_new_obj_id)
265 )
266 );
267 return true;
268 }
269
270 return false;
271 }
272
276 public function isIsThreadRatingEnabled()
277 {
279 }
280
285 {
286 $this->is_thread_rating_enabled = (bool) $is_thread_rating_enabled;
287 }
288
289 public function setDefaultView($a_default_view)
290 {
291 $this->default_view = $a_default_view;
292 }
293 public function getDefaultView()
294 {
295 return $this->default_view;
296 }
297 public function setStatisticsStatus($a_statistic_status)
298 {
299 $this->statistics_enabled = $a_statistic_status;
300 }
301 public function isStatisticEnabled()
302 {
304 }
305 public function setAnonymisation($a_anonymized)
306 {
307 $this->anonymized = $a_anonymized;
308 }
309 public function isAnonymized()
310 {
311 return $this->anonymized;
312 }
313 public static function _isAnonymized($a_obj_id)
314 {
315 global $DIC;
316 $ilDB = $DIC->database();
317
318 $result = $ilDB->queryf(
319 "SELECT anonymized FROM frm_settings WHERE obj_id = %s",
320 array('integer'),
321 array($a_obj_id)
322 );
323
324 while ($record = $ilDB->fetchAssoc($result)) {
325 return $record['anonymized'];
326 }
327
328 return 0;
329 }
330
331 public function setPostActivation($a_post_activation)
332 {
333 $this->post_activation_enabled = $a_post_activation;
334 }
335 public function isPostActivationEnabled()
336 {
338 }
339 public function setObjId($a_obj_id = 0)
340 {
341 $this->obj_id = $a_obj_id;
342 $this->read();
343 }
344 public function getObjId()
345 {
346 return $this->obj_id;
347 }
348
349 public function setAdminForceNoti($a_admin_force)
350 {
351 $this->admin_force_noti = $a_admin_force;
352 }
353
354 public function isAdminForceNoti()
355 {
357 }
358
359 public function setUserToggleNoti($a_user_toggle)
360 {
361 $this->user_toggle_noti = $a_user_toggle;
362 }
363
364 public function isUserToggleNoti()
365 {
367 }
368
369 public static function _isAdminForceNoti($a_obj_id)
370 {
371 global $DIC;
372 $ilDB = $DIC->database();
373
374 $res = $ilDB->queryF(
375 "SELECT admin_force_noti FROM frm_settings WHERE obj_id = %s",
376 array('integer'),
377 array($a_obj_id)
378 );
379 while ($record = $ilDB->fetchAssoc($res)) {
380 return $record['admin_force_noti'];
381 }
382
383 return 0;
384 }
385
386 public static function _isUserToggleNoti($a_obj_id)
387 {
388 global $DIC;
389 $ilDB = $DIC->database();
390
391 $res = $ilDB->queryF(
392 "SELECT user_toggle_noti FROM frm_settings WHERE obj_id = %s",
393 array('integer'),
394 array($a_obj_id)
395 );
396 while ($record = $ilDB->fetchAssoc($res)) {
397 return $record['user_toggle_noti'];
398 }
399 return 0;
400 }
401
402 public function setPresetSubject($a_preset_subject)
403 {
404 $this->preset_subject = $a_preset_subject;
405 }
406 public function getPresetSubject()
407 {
409 }
410 public function setAddReSubject($a_add_re_subject)
411 {
412 $this->add_re_subject = $a_add_re_subject;
413 }
414 public function getAddReSubject()
415 {
417 }
418
419 public function setNotificationType($a_notification_type)
420 {
421 if ($a_notification_type == null) {
422 $this->notification_type = 'default';
423 } else {
424 $this->notification_type = $a_notification_type;
425 }
426 }
427 public function getNotificationType()
428 {
430 }
431
432 public function getSubjectSetting()
433 {
434 if ($this->getPresetSubject() == 0
435 && $this->getAddReSubject() == 0) {
436 return "empty_subject";
437 } elseif ($this->getPresetSubject() == 1) {
438 return "preset_subject";
439 } elseif ($this->getAddReSubject() == 1) {
440 return "add_re_to_subject";
441 } else {
442 return "preset_subject";
443 }
444 }
445 public function setSubjectSetting($a_subject_setting)
446 {
447 if ($a_subject_setting == 'empty_subject') {
448 $this->setPresetSubject(0);
449 $this->setAddReSubject(0);
450 } elseif ($a_subject_setting == 'preset_subject') {
451 $this->setPresetSubject(1);
452 $this->setAddReSubject(0);
453 } elseif ($a_subject_setting == 'add_re_to_subject') {
454 $this->setPresetSubject(0);
455 $this->setAddReSubject(1);
456 }
457 }
458
459 public function setMarkModeratorPosts($a_mod_post)
460 {
461 $this->mark_mod_posts = $a_mod_post;
462 }
463
464 public function getMarkModeratorPosts()
465 {
467 }
468
469 public function setThreadSorting($a_thread_sorting)
470 {
471 $this->thread_sorting = $a_thread_sorting;
472 }
473 public function getThreadSorting()
474 {
476 }
477
481 public function getUserToggleNoti()
482 {
484 }
485
489 public function getAdminForceNoti()
490 {
492 }
493
498 public function setFileUploadAllowed($allowed)
499 {
500 $this->file_upload_allowed = $allowed;
501 }
502
506 public function getFileUploadAllowed()
507 {
509 }
510
514 public function isFileUploadAllowed()
515 {
516 if (self::isFileUploadGloballyAllowed()) {
517 return true;
518 }
519
520 if ((bool) $this->getFileUploadAllowed()) {
521 return true;
522 }
523
524 return false;
525 }
526
530 public static function isFileUploadGloballyAllowed()
531 {
532 global $DIC;
533 return $DIC->settings()->get('file_upload_allowed_fora', self::FILE_UPLOAD_GLOBALLY_ALLOWED) == self::FILE_UPLOAD_GLOBALLY_ALLOWED;
534 }
535
539 public static function isSendAttachmentsByMailEnabled()
540 {
541 global $DIC;
542 return $DIC->settings()->get('send_attachments_by_mail') == true ? true : false;
543 }
544}
$result
An exception for terminatinating execution or to throw for unit testing.
$anonymized
Defines if a forum is anonymized or not @access private.
static _isUserToggleNoti($a_obj_id)
setSubjectSetting($a_subject_setting)
setPostActivation($a_post_activation)
$admin_force_noti
Activation of (CRS/GRP) forum notification by mod/admin @access private.
$post_activation_enabled
Activation of new posts @access private.
$obj_id
Object id of current forum @access private.
setUserToggleNoti($a_user_toggle)
$db
DB Object @access private.
$preset_subject
Preset subject on reply.
setPresetSubject($a_preset_subject)
$add_re_subject
Add 'Re: ' to subject on reply.
$thread_sorting
sorting type for threads (manual sorting) 0 = default 1 = manual
setNotificationType($a_notification_type)
static _isAdminForceNoti($a_obj_id)
setAddReSubject($a_add_re_subject)
static _isAnonymized($a_obj_id)
setIsThreadRatingEnabled($is_thread_rating_enabled)
setStatisticsStatus($a_statistic_status)
$user_toggle_noti
Activation of allowing members to deactivate (CRS/GRP)forum notification @access private.
setAdminForceNoti($a_admin_force)
$statistics_enabled
Defines if a forum can show ranking statistics @access private.
setThreadSorting($a_thread_sorting)
static getInstance($a_obj_id=0)
$notification_type
Global notification-type setting (CRS/GRP) possible values: 'all_users', 'per_user',...
$default_view
Default view ( 1 => 'order by answers', 2 => 'order by date ascending', 3 => 'order by date descendin...
setDefaultView($a_default_view)
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
global $ilDB