ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 
24  private $obj_id;
25 
30  private $default_view = self::VIEW_TREE;
31 
36  private $anonymized = 0; //false;
37 
42  private $statistics_enabled = 0; //false;
43 
48  private $post_activation_enabled = 0; //false;
49 
58  private $notification_type = null;
59 
64  private $admin_force_noti = false;
69  private $user_toggle_noti = false;
70 
77  private $preset_subject = 1;
78 
84  private $add_re_subject = 0;
85 
86  private $mark_mod_posts = 0;
87 
95  private $thread_sorting = 0;
96 
100  private $is_thread_rating_enabled = false;
101 
106  private $db = null;
107 
111  static private $instances = array();
112 
113  protected function __construct($a_obj_id = 0)
114  {
115  global $ilDB;
116 
117  $this->db = $ilDB;
118  $this->obj_id = $a_obj_id;
119  $this->read();
120  }
121 
122  private function __clone()
123  {
124  }
125 
130  static public function getInstance($a_obj_id = 0)
131  {
132  if (!self::$instances[$a_obj_id])
133  {
134  self::$instances[$a_obj_id] = new ilForumProperties($a_obj_id);
135  }
136 
137  return self::$instances[$a_obj_id];
138  }
139 
140  private function read()
141  {
142  if ($this->obj_id)
143  {
144  $res = $this->db->queryf('
145  SELECT * FROM frm_settings
146  WHERE obj_id = %s',
147  array('integer'), array($this->obj_id));
148 
149  $row = $this->db->fetchObject($res);
150 
151  if (is_object($row))
152  {
153  $this->default_view = $row->default_view;
154  $this->anonymized = $row->anonymized ;// == 1 ? true : false;
155  $this->statistics_enabled = $row->statistics_enabled ;// == 1 ? true : false;
156  $this->post_activation_enabled = $row->post_activation ;// == 1 ? true : false;
157  $this->admin_force_noti = $row->admin_force_noti == 1 ? true : false;
158  $this->user_toggle_noti = $row->user_toggle_noti == 1 ? true : false;
159  $this->preset_subject = $row->preset_subject;
160  $this->add_re_subject = $row->add_re_subject;
161 
162  $this->notification_type = $row->notification_type == null ? 'default': $row->notification_type;
163  $this->mark_mod_posts = $row->mark_mod_posts == 1 ? true : false;
164  $this->thread_sorting = $row->thread_sorting == 1? true : false;
165  $this->setIsThreadRatingEnabled((bool)$row->thread_rating);
166 
167  return true;
168  }
169 
170  return false;
171  }
172 
173  return false;
174  }
175 
176  public function insert()
177  {
178  if ($this->obj_id)
179  {
180  $this->db->insert('frm_settings',
181  array( 'obj_id' => array('integer', $this->obj_id),
182  'default_view' => array('integer', $this->default_view),
183  'anonymized' => array('integer', $this->anonymized),
184  'statistics_enabled'=> array('integer', $this->statistics_enabled),
185  'post_activation' => array('integer', $this->post_activation_enabled),
186  'admin_force_noti' => array('integer', $this->admin_force_noti),
187  'user_toggle_noti' => array('integer', $this->user_toggle_noti),
188  'preset_subject' => array('integer', $this->preset_subject),
189  'add_re_subject' => array('integer', $this->add_re_subject),
190  'notification_type' => array('text', $this->notification_type),
191  'mark_mod_posts' => array('integer', $this->mark_mod_posts),
192  'thread_sorting' => array('integer', $this->thread_sorting),
193  'thread_rating' => array('integer', $this->isIsThreadRatingEnabled())
194  )
195  );
196 
197  return true;
198  }
199 
200  return false;
201  }
202 
203  public function update()
204  {
205  if ($this->obj_id)
206  {
207  $this->db->update('frm_settings',
208  array( 'default_view' => array('integer', $this->default_view),
209  'anonymized' => array('integer', $this->anonymized),
210  'statistics_enabled'=> array('integer', $this->statistics_enabled),
211  'post_activation' => array('integer', $this->post_activation_enabled),
212  'admin_force_noti' => array('integer', $this->admin_force_noti),
213  'user_toggle_noti' => array('integer', $this->user_toggle_noti),
214  'preset_subject' => array('integer', $this->preset_subject),
215  'add_re_subject' => array('integer', $this->add_re_subject),
216  'notification_type' => array('text', $this->notification_type),
217  'mark_mod_posts' => array('integer', $this->mark_mod_posts),
218  'thread_sorting' => array('integer', $this->thread_sorting),
219  'thread_rating' => array('integer', $this->isIsThreadRatingEnabled())
220  ),
221  array( 'obj_id' => array('integer', $this->obj_id))
222  );
223  return true;
224  }
225  return false;
226  }
227 
228  public function copy($a_new_obj_id)
229  {
230  if ($a_new_obj_id)
231  {
232  $this->db->update('frm_settings',
233  array(
234  'default_view' => array('integer', $this->default_view),
235  'anonymized' => array('integer', $this->anonymized),
236  'statistics_enabled'=> array('integer', $this->statistics_enabled),
237  'post_activation' => array('integer', $this->post_activation_enabled),
238  'admin_force_noti' => array('integer', $this->admin_force_noti),
239  'user_toggle_noti' => array('integer', $this->user_toggle_noti),
240  'preset_subject' => array('integer', $this->preset_subject),
241  'add_re_subject' => array('integer', $this->add_re_subject),
242  'notification_type' => array('text', $this->notification_type),
243  'mark_mod_posts' => array('integer', $this->mark_mod_posts),
244  'thread_sorting' => array('integer', $this->thread_sorting),
245  'thread_rating' => array('integer', $this->isIsThreadRatingEnabled())
246  ),
247  array(
248  'obj_id' => array('integer', $a_new_obj_id)
249  )
250  );
251  return true;
252  }
253 
254  return false;
255  }
256 
260  public function isIsThreadRatingEnabled()
261  {
262  return (bool)$this->is_thread_rating_enabled;
263  }
264 
269  {
270  $this->is_thread_rating_enabled = (bool)$is_thread_rating_enabled;
271  }
272 
273  public function setDefaultView($a_default_view)
274  {
275  $this->default_view = $a_default_view;
276  }
277  public function getDefaultView()
278  {
279  return $this->default_view;
280  }
281  public function setStatisticsStatus($a_statistic_status)
282  {
283  $this->statistics_enabled = $a_statistic_status;
284  }
285  public function isStatisticEnabled()
286  {
288  }
289  public function setAnonymisation($a_anonymized)
290  {
291  $this->anonymized = $a_anonymized;
292  }
293  public function isAnonymized()
294  {
295  return $this->anonymized;
296  }
297  static function _isAnonymized($a_obj_id)
298  {
299  global $ilDB;
300 
301  $result = $ilDB->queryf("SELECT anonymized FROM frm_settings WHERE obj_id = %s",
302  array('integer'),array($a_obj_id));
303 
304  while($record = $ilDB->fetchAssoc($result))
305  {
306  return $record['anonymized'];
307  }
308 
309  return 0;
310  }
311 
312  public function setPostActivation($a_post_activation)
313  {
314  $this->post_activation_enabled = $a_post_activation;
315  }
316  public function isPostActivationEnabled()
317  {
319  }
320  public function setObjId($a_obj_id = 0)
321  {
322  $this->obj_id = $a_obj_id;
323  $this->read();
324  }
325  public function getObjId()
326  {
327  return $this->obj_id;
328  }
329 
330  public function setAdminForceNoti($a_admin_force)
331  {
332  $this->admin_force_noti = $a_admin_force;
333  }
334 
335  public function isAdminForceNoti()
336  {
338  }
339 
340  public function setUserToggleNoti($a_user_toggle)
341  {
342  $this->user_toggle_noti = $a_user_toggle;
343  }
344 
345  public function isUserToggleNoti()
346  {
348  }
349 
350  static function _isAdminForceNoti($a_obj_id)
351  {
352  global $ilDB;
353 
354  $res = $ilDB->queryF("SELECT admin_force_noti FROM frm_settings WHERE obj_id = %s",
355  array('integer'),
356  array($a_obj_id));
357  while($record = $ilDB->fetchAssoc($res))
358  {
359  return $record['admin_force_noti'];
360  }
361 
362  return 0;
363  }
364 
365  static function _isUserToggleNoti($a_obj_id)
366  {
367  global $ilDB;
368 
369  $res = $ilDB->queryF("SELECT user_toggle_noti FROM frm_settings WHERE obj_id = %s",
370  array('integer'),
371  array($a_obj_id));
372  while($record = $ilDB->fetchAssoc($res))
373  {
374  return $record['user_toggle_noti'];
375  }
376  return 0;
377  }
378 
379  public function setPresetSubject($a_preset_subject)
380  {
381  $this->preset_subject = $a_preset_subject;
382  }
383  public function getPresetSubject()
384  {
385  return $this->preset_subject;
386  }
387  public function setAddReSubject($a_add_re_subject)
388  {
389  $this->add_re_subject = $a_add_re_subject;
390  }
391  public function getAddReSubject()
392  {
393  return $this->add_re_subject;
394  }
395 
396  public function setNotificationType($a_notification_type)
397  {
398  if($a_notification_type == null)
399  $this->notification_type = 'default';
400  else
401  $this->notification_type = $a_notification_type;
402  }
403  public function getNotificationType()
404  {
406  }
407 
408  public function getSubjectSetting()
409  {
410  if($this->getPresetSubject() == 0
411  && $this->getAddReSubject() == 0)
412  {
413  return "empty_subject";
414  }
415  else if($this->getPresetSubject() == 1)
416  {
417  return "preset_subject";
418  }
419  else if($this->getAddReSubject() == 1)
420  {
421  return "add_re_to_subject";
422  }
423  else return "preset_subject";
424  }
425  public function setSubjectSetting($a_subject_setting)
426  {
427  if($a_subject_setting == 'empty_subject')
428  {
429  $this->setPresetSubject(0);
430  $this->setAddReSubject(0);
431  }
432  else if($a_subject_setting == 'preset_subject')
433  {
434  $this->setPresetSubject(1);
435  $this->setAddReSubject(0);
436  }
437  else if($a_subject_setting == 'add_re_to_subject')
438  {
439  $this->setPresetSubject(0);
440  $this->setAddReSubject(1);
441  }
442  }
443 
444  public function setMarkModeratorPosts($a_mod_post)
445  {
446  $this->mark_mod_posts = $a_mod_post;
447  }
448 
449  public function getMarkModeratorPosts()
450  {
451  return $this->mark_mod_posts;
452  }
453 
454  public function setThreadSorting($a_thread_sorting)
455  {
456  $this->thread_sorting = $a_thread_sorting;
457  }
458  public function getThreadSorting()
459  {
460  return $this->thread_sorting;
461  }
462 
466  public function getUserToggleNoti()
467  {
469  }
470 
474  public function getAdminForceNoti()
475  {
477  }
478 }
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 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)
$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)