ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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_TREE;
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  static private $instances = array();
120 
121  protected function __construct($a_obj_id = 0)
122  {
123  global $ilDB;
124 
125  $this->db = $ilDB;
126  $this->obj_id = $a_obj_id;
127  $this->read();
128  }
129 
130  private function __clone()
131  {
132  }
133 
138  static public function getInstance($a_obj_id = 0)
139  {
140  if (!self::$instances[$a_obj_id])
141  {
142  self::$instances[$a_obj_id] = new ilForumProperties($a_obj_id);
143  }
144 
145  return self::$instances[$a_obj_id];
146  }
147 
148  private function read()
149  {
150  if ($this->obj_id)
151  {
152  $res = $this->db->queryf('
153  SELECT * FROM frm_settings
154  WHERE obj_id = %s',
155  array('integer'), array($this->obj_id));
156 
157  $row = $this->db->fetchObject($res);
158 
159  if (is_object($row))
160  {
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  {
189  $this->db->insert('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  {
218  $this->db->update('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  {
247  $this->db->update('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  {
278  return (bool)$this->is_thread_rating_enabled;
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  static function _isAnonymized($a_obj_id)
314  {
315  global $ilDB;
316 
317  $result = $ilDB->queryf("SELECT anonymized FROM frm_settings WHERE obj_id = %s",
318  array('integer'),array($a_obj_id));
319 
320  while($record = $ilDB->fetchAssoc($result))
321  {
322  return $record['anonymized'];
323  }
324 
325  return 0;
326  }
327 
328  public function setPostActivation($a_post_activation)
329  {
330  $this->post_activation_enabled = $a_post_activation;
331  }
332  public function isPostActivationEnabled()
333  {
335  }
336  public function setObjId($a_obj_id = 0)
337  {
338  $this->obj_id = $a_obj_id;
339  $this->read();
340  }
341  public function getObjId()
342  {
343  return $this->obj_id;
344  }
345 
346  public function setAdminForceNoti($a_admin_force)
347  {
348  $this->admin_force_noti = $a_admin_force;
349  }
350 
351  public function isAdminForceNoti()
352  {
354  }
355 
356  public function setUserToggleNoti($a_user_toggle)
357  {
358  $this->user_toggle_noti = $a_user_toggle;
359  }
360 
361  public function isUserToggleNoti()
362  {
364  }
365 
366  static function _isAdminForceNoti($a_obj_id)
367  {
368  global $ilDB;
369 
370  $res = $ilDB->queryF("SELECT admin_force_noti FROM frm_settings WHERE obj_id = %s",
371  array('integer'),
372  array($a_obj_id));
373  while($record = $ilDB->fetchAssoc($res))
374  {
375  return $record['admin_force_noti'];
376  }
377 
378  return 0;
379  }
380 
381  static function _isUserToggleNoti($a_obj_id)
382  {
383  global $ilDB;
384 
385  $res = $ilDB->queryF("SELECT user_toggle_noti FROM frm_settings WHERE obj_id = %s",
386  array('integer'),
387  array($a_obj_id));
388  while($record = $ilDB->fetchAssoc($res))
389  {
390  return $record['user_toggle_noti'];
391  }
392  return 0;
393  }
394 
395  public function setPresetSubject($a_preset_subject)
396  {
397  $this->preset_subject = $a_preset_subject;
398  }
399  public function getPresetSubject()
400  {
401  return $this->preset_subject;
402  }
403  public function setAddReSubject($a_add_re_subject)
404  {
405  $this->add_re_subject = $a_add_re_subject;
406  }
407  public function getAddReSubject()
408  {
409  return $this->add_re_subject;
410  }
411 
412  public function setNotificationType($a_notification_type)
413  {
414  if($a_notification_type == null)
415  $this->notification_type = 'default';
416  else
417  $this->notification_type = $a_notification_type;
418  }
419  public function getNotificationType()
420  {
422  }
423 
424  public function getSubjectSetting()
425  {
426  if($this->getPresetSubject() == 0
427  && $this->getAddReSubject() == 0)
428  {
429  return "empty_subject";
430  }
431  else if($this->getPresetSubject() == 1)
432  {
433  return "preset_subject";
434  }
435  else if($this->getAddReSubject() == 1)
436  {
437  return "add_re_to_subject";
438  }
439  else return "preset_subject";
440  }
441  public function setSubjectSetting($a_subject_setting)
442  {
443  if($a_subject_setting == 'empty_subject')
444  {
445  $this->setPresetSubject(0);
446  $this->setAddReSubject(0);
447  }
448  else if($a_subject_setting == 'preset_subject')
449  {
450  $this->setPresetSubject(1);
451  $this->setAddReSubject(0);
452  }
453  else if($a_subject_setting == 'add_re_to_subject')
454  {
455  $this->setPresetSubject(0);
456  $this->setAddReSubject(1);
457  }
458  }
459 
460  public function setMarkModeratorPosts($a_mod_post)
461  {
462  $this->mark_mod_posts = $a_mod_post;
463  }
464 
465  public function getMarkModeratorPosts()
466  {
467  return $this->mark_mod_posts;
468  }
469 
470  public function setThreadSorting($a_thread_sorting)
471  {
472  $this->thread_sorting = $a_thread_sorting;
473  }
474  public function getThreadSorting()
475  {
476  return $this->thread_sorting;
477  }
478 
482  public function getUserToggleNoti()
483  {
485  }
486 
490  public function getAdminForceNoti()
491  {
493  }
494 
499  public function setFileUploadAllowed($allowed)
500  {
501  $this->file_upload_allowed = $allowed;
502  }
503 
507  public function getFileUploadAllowed()
508  {
510  }
511 
515  public function isFileUploadAllowed()
516  {
517  if(self::isFileUploadGloballyAllowed())
518  {
519  return true;
520  }
521 
522  if((bool)$this->getFileUploadAllowed())
523  {
524  return true;
525  }
526 
527  return false;
528  }
529 
533  public static function isFileUploadGloballyAllowed()
534  {
538  global $ilSetting;
539 
540  return $ilSetting->get('file_upload_allowed_fora', self::FILE_UPLOAD_GLOBALLY_ALLOWED) == self::FILE_UPLOAD_GLOBALLY_ALLOWED;
541  }
542 
546  public static function isSendAttachmentsByMailEnabled()
547  {
551  global $ilSetting;
552 
553  return $ilSetting->get('send_attachments_by_mail') == true ? true : false;
554  }
555 }
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)
$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)
Create styles array
The data for the language used.
global $ilSetting
Definition: privfeed.php:17
$post_activation_enabled
Activation of new posts private.
global $ilDB
$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)