ILIAS  release_4-4 Revision
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 
79  private $thread_ratings_allowed = false;
80 
87  private $preset_subject = 1;
88 
94  private $add_re_subject = 0;
95 
96  private $mark_mod_posts = 0;
97 
105  private $thread_sorting = 0;
106 
111  private $db = null;
112 
113  static private $instances = array();
114 
115  protected function __construct($a_obj_id = 0)
116  {
117  global $ilDB;
118 
119  $this->db = $ilDB;
120  $this->obj_id = $a_obj_id;
121  $this->read();
122  }
123 
124  private function __clone()
125  {
126  }
127 
128  static public function getInstance($a_obj_id = 0)
129  {
130  if (!self::$instances[$a_obj_id])
131  {
132  self::$instances[$a_obj_id] = new ilForumProperties($a_obj_id);
133  }
134 
135  return self::$instances[$a_obj_id];
136  }
137 
138  private function read()
139  {
140  if ($this->obj_id)
141  {
142  $res = $this->db->queryf('
143  SELECT * FROM frm_settings
144  WHERE obj_id = %s',
145  array('integer'), array($this->obj_id));
146 
147  $row = $this->db->fetchObject($res);
148 
149  if (is_object($row))
150  {
151  $this->default_view = $row->default_view;
152  $this->anonymized = $row->anonymized ;// == 1 ? true : false;
153  $this->statistics_enabled = $row->statistics_enabled ;// == 1 ? true : false;
154  $this->post_activation_enabled = $row->post_activation ;// == 1 ? true : false;
155  $this->admin_force_noti = $row->admin_force_noti == 1 ? true : false;
156  $this->user_toggle_noti = $row->user_toggle_noti == 1 ? true : false;
157  $this->preset_subject = $row->preset_subject;
158  $this->add_re_subject = $row->add_re_subject;
159 
160  $this->notification_type = $row->notification_type == null ? 'default': $row->notification_type;
161  $this->mark_mod_posts = $row->mark_mod_posts == 1 ? true : false;
162  $this->thread_sorting = $row->thread_sorting == 1? true : false;
163 
164  return true;
165  }
166 
167  return false;
168  }
169 
170  return false;
171  }
172 
173  public function insert()
174  {
175  if ($this->obj_id)
176  {
177  $this->db->insert('frm_settings',
178  array( 'obj_id' => array('integer', $this->obj_id),
179  'default_view' => array('integer', $this->default_view),
180  'anonymized' => array('integer', $this->anonymized),
181  'statistics_enabled'=> array('integer', $this->statistics_enabled),
182  'post_activation' => array('integer', $this->post_activation_enabled),
183  'admin_force_noti' => array('integer', $this->admin_force_noti),
184  'user_toggle_noti' => array('integer', $this->user_toggle_noti),
185  'preset_subject' => array('integer', $this->preset_subject),
186  'add_re_subject' => array('integer', $this->add_re_subject),
187  'notification_type' => array('text', $this->notification_type),
188  'mark_mod_posts' => array('integer', $this->mark_mod_posts),
189  'thread_sorting' => array('integer', $this->thread_sorting)
190  )
191  );
192 
193  return true;
194  }
195 
196  return false;
197  }
198 
199  public function update()
200  {
201  if ($this->obj_id)
202  {
203  $this->db->update('frm_settings',
204  array( 'default_view' => array('integer', $this->default_view),
205  'anonymized' => array('integer', $this->anonymized),
206  'statistics_enabled'=> array('integer', $this->statistics_enabled),
207  'post_activation' => array('integer', $this->post_activation_enabled),
208  'admin_force_noti' => array('integer', $this->admin_force_noti),
209  'user_toggle_noti' => array('integer', $this->user_toggle_noti),
210  'preset_subject' => array('integer', $this->preset_subject),
211  'add_re_subject' => array('integer', $this->add_re_subject),
212  'notification_type' => array('text', $this->notification_type),
213  'mark_mod_posts' => array('integer', $this->mark_mod_posts),
214  'thread_sorting' => array('integer', $this->thread_sorting)
215  ),
216  array( 'obj_id' => array('integer', $this->obj_id))
217  );
218  return true;
219  }
220  return false;
221  }
222 
223  public function copy($a_new_obj_id)
224  {
225  if ($a_new_obj_id)
226  {
227  $this->db->insert('frm_settings',
228  array( 'obj_id' => array('integer', $a_new_obj_id),
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  )
241  );
242  return true;
243  }
244 
245  return false;
246  }
247 
248  public function setDefaultView($a_default_view)
249  {
250  $this->default_view = $a_default_view;
251  }
252  public function getDefaultView()
253  {
254  return $this->default_view;
255  }
256  public function setStatisticsStatus($a_statistic_status)
257  {
258  $this->statistics_enabled = $a_statistic_status;
259  }
260  public function isStatisticEnabled()
261  {
263  }
264  public function setAnonymisation($a_anonymized)
265  {
266  $this->anonymized = $a_anonymized;
267  }
268  public function isAnonymized()
269  {
270  return $this->anonymized;
271  }
272  static function _isAnonymized($a_obj_id)
273  {
274  global $ilDB;
275 
276  $result = $ilDB->queryf("SELECT anonymized FROM frm_settings WHERE obj_id = %s",
277  array('integer'),array($a_obj_id));
278 
279  while($record = $ilDB->fetchAssoc($result))
280  {
281  return $record['anonymized'];
282  }
283 
284  return 0;
285  }
286 
287  public function setPostActivation($a_post_activation)
288  {
289  $this->post_activation_enabled = $a_post_activation;
290  }
291  public function isPostActivationEnabled()
292  {
294  }
295  public function setObjId($a_obj_id = 0)
296  {
297  $this->obj_id = $a_obj_id;
298  $this->read();
299  }
300  public function getObjId()
301  {
302  return $this->obj_id;
303  }
304 
305  public function setAdminForceNoti($a_admin_force)
306  {
307  $this->admin_force_noti = $a_admin_force;
308  }
309 
310  public function isAdminForceNoti()
311  {
313  }
314 
315  public function setUserToggleNoti($a_user_toggle)
316  {
317  $this->user_toggle_noti = $a_user_toggle;
318  }
319 
320  public function isUserToggleNoti()
321  {
323  }
324 
325  static function _isAdminForceNoti($a_obj_id)
326  {
327  global $ilDB;
328 
329  $res = $ilDB->queryF("SELECT admin_force_noti FROM frm_settings WHERE obj_id = %s",
330  array('integer'),
331  array($a_obj_id));
332  while($record = $ilDB->fetchAssoc($res))
333  {
334  return $record['admin_force_noti'];
335  }
336 
337  return 0;
338  }
339 
340  static function _isUserToggleNoti($a_obj_id)
341  {
342  global $ilDB;
343 
344  $res = $ilDB->queryF("SELECT user_toggle_noti FROM frm_settings WHERE obj_id = %s",
345  array('integer'),
346  array($a_obj_id));
347  while($record = $ilDB->fetchAssoc($res))
348  {
349  return $record['user_toggle_noti'];
350  }
351  return 0;
352  }
353 
354  public function isThreadRatingAllowed($a_allow_rating = null)
355  {
356  if(null === $a_allow_rating)
357  {
359  }
360 
361  $this->thread_ratings_allowed = $a_allow_rating;
362 
363  return $this;
364  }
365 
366  public function setPresetSubject($a_preset_subject)
367  {
368  $this->preset_subject = $a_preset_subject;
369  }
370  public function getPresetSubject()
371  {
372  return $this->preset_subject;
373  }
374  public function setAddReSubject($a_add_re_subject)
375  {
376  $this->add_re_subject = $a_add_re_subject;
377  }
378  public function getAddReSubject()
379  {
380  return $this->add_re_subject;
381  }
382 
383  public function setNotificationType($a_notification_type)
384  {
385  if($a_notification_type == null)
386  $this->notification_type = 'default';
387  else
388  $this->notification_type = $a_notification_type;
389  }
390  public function getNotificationType()
391  {
393  }
394 
395  public function getSubjectSetting()
396  {
397  if($this->getPresetSubject() == 0
398  && $this->getAddReSubject() == 0)
399  {
400  return "empty_subject";
401  }
402  else if($this->getPresetSubject() == 1)
403  {
404  return "preset_subject";
405  }
406  else if($this->getAddReSubject() == 1)
407  {
408  return "add_re_to_subject";
409  }
410  else return "preset_subject";
411  }
412  public function setSubjectSetting($a_subject_setting)
413  {
414  if($a_subject_setting == 'empty_subject')
415  {
416  $this->setPresetSubject(0);
417  $this->setAddReSubject(0);
418  }
419  else if($a_subject_setting == 'preset_subject')
420  {
421  $this->setPresetSubject(1);
422  $this->setAddReSubject(0);
423  }
424  else if($a_subject_setting == 'add_re_to_subject')
425  {
426  $this->setPresetSubject(0);
427  $this->setAddReSubject(1);
428  }
429  }
430 
431  public function setMarkModeratorPosts($a_mod_post)
432  {
433  $this->mark_mod_posts = $a_mod_post;
434  }
435 
436  public function getMarkModeratorPosts()
437  {
438  return $this->mark_mod_posts;
439  }
440 
441  public function setThreadSorting($a_thread_sorting)
442  {
443  $this->thread_sorting = $a_thread_sorting;
444  }
445  public function getThreadSorting()
446  {
447  return $this->thread_sorting;
448  }
449 
453  public function getUserToggleNoti()
454  {
456  }
457 
461  public function getAdminForceNoti()
462  {
464  }
465 
466 
467 }
468 ?>
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)
$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.
$anonymized
Defines if a forum is anonymized or not private.
$preset_subject
Preset subject on reply.
setSubjectSetting($a_subject_setting)
setNotificationType($a_notification_type)
isThreadRatingAllowed($a_allow_rating=null)
$notification_type
Global notification-type setting (CRS/GRP) possible values: &#39;all_users&#39;, &#39;per_user&#39;, null (default)