ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
33  private $default_view = self::VIEW_DATE_ASC;
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 
103  private $is_thread_rating_enabled = false;
104 
109  private $db = null;
110 
114  private $file_upload_allowed = 0;
115 
119  private static $instances = array();
120 
122  private $exists = false;
123 
124  protected function __construct($a_obj_id = 0)
125  {
126  global $DIC;
127 
128  $this->db = $DIC->database();
129  $this->obj_id = $a_obj_id;
130  $this->read();
131  }
132 
133  private function __clone()
134  {
135  }
136 
141  public static function getInstance($a_obj_id = 0)
142  {
143  if (!self::$instances[$a_obj_id]) {
144  self::$instances[$a_obj_id] = new ilForumProperties($a_obj_id);
145  }
146 
147  return self::$instances[$a_obj_id];
148  }
149 
150  private function read()
151  {
152  if ($this->obj_id) {
153  $res = $this->db->queryf(
154  '
155  SELECT * FROM frm_settings
156  WHERE obj_id = %s',
157  array('integer'),
158  array($this->obj_id)
159  );
160 
161  $row = $this->db->fetchObject($res);
162 
163  if (is_object($row)) {
164  $this->default_view = $row->default_view;
165  $this->anonymized = $row->anonymized;// == 1 ? true : false;
166  $this->statistics_enabled = $row->statistics_enabled;// == 1 ? true : false;
167  $this->post_activation_enabled = $row->post_activation;// == 1 ? true : false;
168  $this->admin_force_noti = $row->admin_force_noti == 1 ? true : false;
169  $this->user_toggle_noti = $row->user_toggle_noti == 1 ? true : false;
170  $this->preset_subject = $row->preset_subject;
171  $this->add_re_subject = $row->add_re_subject;
172 
173  $this->notification_type = $row->notification_type == null ? 'default' : $row->notification_type;
174  $this->mark_mod_posts = $row->mark_mod_posts == 1 ? true : false;
175  $this->thread_sorting = $row->thread_sorting == 1 ? true : false;
176  $this->setIsThreadRatingEnabled((bool) $row->thread_rating);
177  $this->file_upload_allowed = $row->file_upload_allowed == 1 ? true : false;
178 
179  $this->exists = true;
180  return true;
181  }
182 
183  return false;
184  }
185 
186  return false;
187  }
188 
189  public function insert()
190  {
191  if ($this->obj_id && !$this->exists) {
192  $this->db->insert(
193  'frm_settings',
194  array(
195  'obj_id' => array('integer', $this->obj_id),
196  'default_view' => array('integer', $this->default_view),
197  'anonymized' => array('integer', $this->anonymized),
198  'statistics_enabled' => array('integer', $this->statistics_enabled),
199  'post_activation' => array('integer', $this->post_activation_enabled),
200  'admin_force_noti' => array('integer', $this->admin_force_noti),
201  'user_toggle_noti' => array('integer', $this->user_toggle_noti),
202  'preset_subject' => array('integer', $this->preset_subject),
203  'add_re_subject' => array('integer', $this->add_re_subject),
204  'notification_type' => array('text', $this->notification_type),
205  'mark_mod_posts' => array('integer', $this->mark_mod_posts),
206  'thread_sorting' => array('integer', $this->thread_sorting),
207  'thread_rating' => array('integer', $this->isIsThreadRatingEnabled()),
208  'file_upload_allowed' => array('integer', $this->file_upload_allowed)
209  )
210  );
211 
212  $this->exists = true;
213  return true;
214  }
215 
216  return false;
217  }
218 
219  public function update()
220  {
221  if ($this->obj_id) {
222  if (!$this->exists) {
223  return $this->insert();
224  }
225 
226  $this->db->update(
227  'frm_settings',
228  array(
229  'default_view' => array('integer', $this->default_view),
230  'anonymized' => array('integer', $this->anonymized),
231  'statistics_enabled' => array('integer', $this->statistics_enabled),
232  'post_activation' => array('integer', $this->post_activation_enabled),
233  'admin_force_noti' => array('integer', $this->admin_force_noti),
234  'user_toggle_noti' => array('integer', $this->user_toggle_noti),
235  'preset_subject' => array('integer', $this->preset_subject),
236  'add_re_subject' => array('integer', $this->add_re_subject),
237  'notification_type' => array('text', $this->notification_type),
238  'mark_mod_posts' => array('integer', $this->mark_mod_posts),
239  'thread_sorting' => array('integer', $this->thread_sorting),
240  'thread_rating' => array('integer', $this->isIsThreadRatingEnabled()),
241  'file_upload_allowed' => array('integer', $this->file_upload_allowed)
242  ),
243  array(
244  'obj_id' => array('integer', $this->obj_id)
245  )
246  );
247  return true;
248  }
249  return false;
250  }
251 
252  public function copy($a_new_obj_id)
253  {
254  if ($a_new_obj_id) {
255  $this->db->update(
256  'frm_settings',
257  array(
258  'default_view' => array('integer', $this->default_view),
259  'anonymized' => array('integer', $this->anonymized),
260  'statistics_enabled' => array('integer', $this->statistics_enabled),
261  'post_activation' => array('integer', $this->post_activation_enabled),
262  'admin_force_noti' => array('integer', $this->admin_force_noti),
263  'user_toggle_noti' => array('integer', $this->user_toggle_noti),
264  'preset_subject' => array('integer', $this->preset_subject),
265  'add_re_subject' => array('integer', $this->add_re_subject),
266  'notification_type' => array('text', $this->notification_type),
267  'mark_mod_posts' => array('integer', $this->mark_mod_posts),
268  'thread_sorting' => array('integer', $this->thread_sorting),
269  'thread_rating' => array('integer', $this->isIsThreadRatingEnabled()),
270  'file_upload_allowed' => array('integer', $this->file_upload_allowed)
271  ),
272  array(
273  'obj_id' => array('integer', $a_new_obj_id)
274  )
275  );
276  return true;
277  }
278 
279  return false;
280  }
281 
285  public function isIsThreadRatingEnabled()
286  {
287  return (bool) $this->is_thread_rating_enabled;
288  }
289 
294  {
295  $this->is_thread_rating_enabled = (bool) $is_thread_rating_enabled;
296  }
297 
298  public function setDefaultView($a_default_view)
299  {
300  $this->default_view = $a_default_view;
301  }
302 
303  public function getDefaultView()
304  {
305  return (int) $this->default_view;
306  }
307 
308  public function setStatisticsStatus($a_statistic_status)
309  {
310  $this->statistics_enabled = $a_statistic_status;
311  }
312 
313  public function isStatisticEnabled()
314  {
316  }
317 
318  public function setAnonymisation($a_anonymized)
319  {
320  $this->anonymized = $a_anonymized;
321  }
322 
323  public function isAnonymized()
324  {
325  return $this->anonymized;
326  }
327 
328  public static function _isAnonymized($a_obj_id)
329  {
330  global $DIC;
331  $ilDB = $DIC->database();
332 
333  $result = $ilDB->queryf(
334  "SELECT anonymized FROM frm_settings WHERE obj_id = %s",
335  array('integer'),
336  array($a_obj_id)
337  );
338 
339  while ($record = $ilDB->fetchAssoc($result)) {
340  return $record['anonymized'];
341  }
342 
343  return 0;
344  }
345 
346  public function setPostActivation($a_post_activation)
347  {
348  $this->post_activation_enabled = $a_post_activation;
349  }
350 
351  public function isPostActivationEnabled()
352  {
354  }
355 
356  public function setObjId($a_obj_id = 0)
357  {
358  $this->obj_id = $a_obj_id;
359  $this->read();
360  }
361 
362  public function getObjId()
363  {
364  return $this->obj_id;
365  }
366 
367  public function setAdminForceNoti($a_admin_force)
368  {
369  $this->admin_force_noti = $a_admin_force;
370  }
371 
372  public function isAdminForceNoti()
373  {
375  }
376 
377  public function setUserToggleNoti($a_user_toggle)
378  {
379  $this->user_toggle_noti = $a_user_toggle;
380  }
381 
382  public function isUserToggleNoti()
383  {
385  }
386 
387  public static function _isAdminForceNoti($a_obj_id)
388  {
389  global $DIC;
390  $ilDB = $DIC->database();
391 
392  $res = $ilDB->queryF(
393  "SELECT admin_force_noti FROM frm_settings WHERE obj_id = %s",
394  array('integer'),
395  array($a_obj_id)
396  );
397  while ($record = $ilDB->fetchAssoc($res)) {
398  return $record['admin_force_noti'];
399  }
400 
401  return 0;
402  }
403 
404  public static function _isUserToggleNoti($a_obj_id)
405  {
406  global $DIC;
407  $ilDB = $DIC->database();
408 
409  $res = $ilDB->queryF(
410  "SELECT user_toggle_noti FROM frm_settings WHERE obj_id = %s",
411  array('integer'),
412  array($a_obj_id)
413  );
414  while ($record = $ilDB->fetchAssoc($res)) {
415  return $record['user_toggle_noti'];
416  }
417  return 0;
418  }
419 
420  public function setPresetSubject($a_preset_subject)
421  {
422  $this->preset_subject = $a_preset_subject;
423  }
424 
425  public function getPresetSubject()
426  {
427  return $this->preset_subject;
428  }
429 
430  public function setAddReSubject($a_add_re_subject)
431  {
432  $this->add_re_subject = $a_add_re_subject;
433  }
434 
435  public function getAddReSubject()
436  {
437  return $this->add_re_subject;
438  }
439 
440  public function setNotificationType($a_notification_type)
441  {
442  if ($a_notification_type == null) {
443  $this->notification_type = 'default';
444  } else {
445  $this->notification_type = $a_notification_type;
446  }
447  }
448 
449  public function getNotificationType()
450  {
452  }
453 
454  public function getSubjectSetting()
455  {
456  if ($this->getPresetSubject() == 0
457  && $this->getAddReSubject() == 0) {
458  return "empty_subject";
459  } else {
460  if ($this->getPresetSubject() == 1) {
461  return "preset_subject";
462  } else {
463  if ($this->getAddReSubject() == 1) {
464  return "add_re_to_subject";
465  } else {
466  return "preset_subject";
467  }
468  }
469  }
470  }
471 
472  public function setSubjectSetting($a_subject_setting)
473  {
474  if ($a_subject_setting == 'empty_subject') {
475  $this->setPresetSubject(0);
476  $this->setAddReSubject(0);
477  } else {
478  if ($a_subject_setting == 'preset_subject') {
479  $this->setPresetSubject(1);
480  $this->setAddReSubject(0);
481  } else {
482  if ($a_subject_setting == 'add_re_to_subject') {
483  $this->setPresetSubject(0);
484  $this->setAddReSubject(1);
485  }
486  }
487  }
488  }
489 
490  public function setMarkModeratorPosts($a_mod_post)
491  {
492  $this->mark_mod_posts = $a_mod_post;
493  }
494 
495  public function getMarkModeratorPosts()
496  {
497  return $this->mark_mod_posts;
498  }
499 
500  public function setThreadSorting($a_thread_sorting)
501  {
502  $this->thread_sorting = $a_thread_sorting;
503  }
504 
505  public function getThreadSorting()
506  {
507  return $this->thread_sorting;
508  }
509 
513  public function getUserToggleNoti()
514  {
516  }
517 
521  public function getAdminForceNoti()
522  {
524  }
525 
530  public function setFileUploadAllowed($allowed)
531  {
532  $this->file_upload_allowed = $allowed;
533  }
534 
538  public function getFileUploadAllowed()
539  {
541  }
542 
546  public function isFileUploadAllowed()
547  {
548  if (self::isFileUploadGloballyAllowed()) {
549  return true;
550  }
551 
552  if ((bool) $this->getFileUploadAllowed()) {
553  return true;
554  }
555 
556  return false;
557  }
558 
562  public static function isFileUploadGloballyAllowed()
563  {
564  global $DIC;
565  return $DIC->settings()->get(
566  'file_upload_allowed_fora',
567  self::FILE_UPLOAD_GLOBALLY_ALLOWED
568  ) == self::FILE_UPLOAD_GLOBALLY_ALLOWED;
569  }
570 
574  public static function isSendAttachmentsByMailEnabled()
575  {
576  global $DIC;
577  return $DIC->settings()->get('send_attachments_by_mail') == true ? true : false;
578  }
579 }
setThreadSorting($a_thread_sorting)
setPostActivation($a_post_activation)
setUserToggleNoti($a_user_toggle)
$statistics_enabled
Defines if a forum can show ranking statistics private.
$result
setStatisticsStatus($a_statistic_status)
setPresetSubject($a_preset_subject)
setAdminForceNoti($a_admin_force)
setDefaultView($a_default_view)
$user_toggle_noti
Activation of allowing members to deactivate (CRS/GRP)forum notification private.
$default_view
Default view ( 1 => &#39;order by answers&#39;, 2 => &#39;order by date ascending&#39;, 3 => &#39;order by date descendin...
$obj_id
Object id of current forum private.
$admin_force_noti
Activation of (CRS/GRP) forum notification by mod/admin private.
$thread_sorting
sorting type for threads (manual sorting) 0 = default 1 = manual
static _isAnonymized($a_obj_id)
static getInstance($a_obj_id=0)
setIsThreadRatingEnabled($is_thread_rating_enabled)
foreach($_POST as $key=> $value) $res
$add_re_subject
Add &#39;Re: &#39; to subject on reply.
static _isUserToggleNoti($a_obj_id)
static _isAdminForceNoti($a_obj_id)
setAddReSubject($a_add_re_subject)
$post_activation_enabled
Activation of new posts private.
global $ilDB
$DIC
Definition: xapitoken.php:46
$anonymized
Defines if a forum is anonymized or not private.
$preset_subject
Preset subject on reply.
setSubjectSetting($a_subject_setting)
setNotificationType($a_notification_type)
$notification_type
Global notification-type setting (CRS/GRP) possible values: &#39;all_users&#39;, &#39;per_user&#39;, null (default)