ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups 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 
21  private $obj_id;
22 
28 
33  private $anonymized = 0; //false;
34 
39  private $statistics_enabled = 0; //false;
40 
45  private $post_activation_enabled = 0; //false;
46 
55  private $notification_type = null;
56 
61  private $admin_force_noti = false;
66  private $user_toggle_noti = false;
67 
76  private $thread_ratings_allowed = false;
77 
84  private $preset_subject = 1;
85 
91  private $add_re_subject = 0;
92 
93  private $mark_mod_posts = 0;
94 
99  private $db = null;
100 
101  static private $instances = array();
102 
103  protected function __construct($a_obj_id = 0)
104  {
105  global $ilDB;
106 
107  $this->db = $ilDB;
108  $this->obj_id = $a_obj_id;
109  $this->read();
110  }
111 
112  private function __clone()
113  {
114  }
115 
116  static public function getInstance($a_obj_id = 0)
117  {
118  if (!self::$instances[$a_obj_id])
119  {
120  self::$instances[$a_obj_id] = new ilForumProperties($a_obj_id);
121  }
122 
123  return self::$instances[$a_obj_id];
124  }
125 
126  private function read()
127  {
128  if ($this->obj_id)
129  {
130  $res = $this->db->queryf('
131  SELECT * FROM frm_settings
132  WHERE obj_id = %s',
133  array('integer'), array($this->obj_id));
134 
135  $row = $this->db->fetchObject($res);
136 
137  if (is_object($row))
138  {
139  $this->default_view = $row->default_view;
140  $this->anonymized = $row->anonymized ;// == 1 ? true : false;
141  $this->statistics_enabled = $row->statistics_enabled ;// == 1 ? true : false;
142  $this->post_activation_enabled = $row->post_activation ;// == 1 ? true : false;
143  $this->admin_force_noti = $row->admin_force_noti == 1 ? true : false;
144  $this->user_toggle_noti = $row->user_toggle_noti == 1 ? true : false;
145  $this->preset_subject = $row->preset_subject;
146  $this->add_re_subject = $row->add_re_subject;
147 
148  $this->notification_type = $row->notification_type == null ? 'default': $row->notification_type;
149  $this->mark_mod_posts = $row->mark_mod_posts == 1 ? true : false;
150 
151  return true;
152  }
153 
154  return false;
155  }
156 
157  return false;
158  }
159 
160  public function insert()
161  {
162  if ($this->obj_id)
163  {
164  $this->db->insert('frm_settings',
165  array( 'obj_id' => array('integer', $this->obj_id),
166  'default_view' => array('integer', $this->default_view),
167  'anonymized' => array('integer', $this->anonymized),
168  'statistics_enabled'=> array('integer', $this->statistics_enabled),
169  'post_activation' => array('integer', $this->post_activation_enabled),
170  'admin_force_noti' => array('integer', $this->admin_force_noti),
171  'user_toggle_noti' => array('integer', $this->user_toggle_noti),
172  'preset_subject' => array('integer', $this->preset_subject),
173  'add_re_subject' => array('integer', $this->add_re_subject),
174  'notification_type' => array('text', $this->notification_type),
175  'mark_mod_posts' => array('integer', $this->mark_mod_posts))
176  );
177 
178  return true;
179  }
180 
181  return false;
182  }
183 
184  public function update()
185  {
186  if ($this->obj_id)
187  {
188  $this->db->update('frm_settings',
189  array( 'default_view' => array('integer', $this->default_view),
190  'anonymized' => array('integer', $this->anonymized),
191  'statistics_enabled'=> array('integer', $this->statistics_enabled),
192  'post_activation' => array('integer', $this->post_activation_enabled),
193  'admin_force_noti' => array('integer', $this->admin_force_noti),
194  'user_toggle_noti' => array('integer', $this->user_toggle_noti),
195  'preset_subject' => array('integer', $this->preset_subject),
196  'add_re_subject' => array('integer', $this->add_re_subject),
197  'notification_type' => array('text', $this->notification_type),
198  'mark_mod_posts' => array('integer', $this->mark_mod_posts)),
199  array( 'obj_id' => array('integer', $this->obj_id))
200  );
201  return true;
202  }
203  return false;
204  }
205 
206  public function copy($a_new_obj_id)
207  {
208  if ($a_new_obj_id)
209  {
210  $this->db->insert('frm_settings',
211  array( 'obj_id' => array('integer', $a_new_obj_id),
212  'default_view' => array('integer', $this->default_view),
213  'anonymized' => array('integer', $this->anonymized),
214  'statistics_enabled'=> array('integer', $this->statistics_enabled),
215  'post_activation' => array('integer', $this->post_activation_enabled),
216  'admin_force_noti' => array('integer', $this->admin_force_noti),
217  'user_toggle_noti' => array('integer', $this->user_toggle_noti),
218  'preset_subject' => array('integer', $this->preset_subject),
219  'add_re_subject' => array('integer', $this->add_re_subject),
220  'notification_type' => array('text', $this->notification_type),
221  'mark_mod_posts' => array('integer', $this->mark_mod_posts))
222  );
223  return true;
224  }
225 
226  return false;
227  }
228 
229  public function setDefaultView($a_default_view)
230  {
231  $this->default_view = $a_default_view;
232  }
233  public function getDefaultView()
234  {
235  return $this->default_view;
236  }
237  public function setStatisticsStatus($a_statistic_status)
238  {
239  $this->statistics_enabled = $a_statistic_status;
240  }
241  public function isStatisticEnabled()
242  {
244  }
245  public function setAnonymisation($a_anonymized)
246  {
247  $this->anonymized = $a_anonymized;
248  }
249  public function isAnonymized()
250  {
251  return $this->anonymized;
252  }
253  static function _isAnonymized($a_obj_id)
254  {
255  global $ilDB;
256 
257  $result = $ilDB->queryf("SELECT anonymized FROM frm_settings WHERE obj_id = %s",
258  array('integer'),array($a_obj_id));
259 
260  while($record = $ilDB->fetchAssoc($result))
261  {
262  return $record['anonymized'];
263  }
264 
265  return 0;
266  }
267 
268  public function setPostActivation($a_post_activation)
269  {
270  $this->post_activation_enabled = $a_post_activation;
271  }
272  public function isPostActivationEnabled()
273  {
275  }
276  public function setObjId($a_obj_id = 0)
277  {
278  $this->obj_id = $a_obj_id;
279  $this->read();
280  }
281  public function getObjId()
282  {
283  return $this->obj_id;
284  }
285 
286  public function setAdminForceNoti($a_admin_force)
287  {
288  $this->admin_force_noti = $a_admin_force;
289  }
290 
291  public function isAdminForceNoti()
292  {
294  }
295 
296  public function setUserToggleNoti($a_user_toggle)
297  {
298  $this->user_toggle_noti = $a_user_toggle;
299  }
300 
301  public function isUserToggleNoti()
302  {
304  }
305 
306  static function _isAdminForceNoti($a_obj_id)
307  {
308  global $ilDB;
309 
310  $res = $ilDB->queryF("SELECT admin_force_noti FROM frm_settings WHERE obj_id = %s",
311  array('integer'),
312  array($a_obj_id));
313  while($record = $ilDB->fetchAssoc($res))
314  {
315  return $record['admin_force_noti'];
316  }
317 
318  return 0;
319  }
320 
321  static function _isUserToggleNoti($a_obj_id)
322  {
323  global $ilDB;
324 
325  $res = $ilDB->queryF("SELECT user_toggle_noti FROM frm_settings WHERE obj_id = %s",
326  array('integer'),
327  array($a_obj_id));
328  while($record = $ilDB->fetchAssoc($res))
329  {
330  return $record['user_toggle_noti'];
331  }
332  return 0;
333  }
334 
335  public function isThreadRatingAllowed($a_allow_rating = null)
336  {
337  if(null === $a_allow_rating)
338  {
340  }
341 
342  $this->thread_ratings_allowed = $a_allow_rating;
343 
344  return $this;
345  }
346 
347  public function setPresetSubject($a_preset_subject)
348  {
349  $this->preset_subject = $a_preset_subject;
350  }
351  public function getPresetSubject()
352  {
353  return $this->preset_subject;
354  }
355  public function setAddReSubject($a_add_re_subject)
356  {
357  $this->add_re_subject = $a_add_re_subject;
358  }
359  public function getAddReSubject()
360  {
361  return $this->add_re_subject;
362  }
363 
364  public function setNotificationType($a_notification_type)
365  {
366  if($a_notification_type == null)
367  $this->notification_type = 'default';
368  else
369  $this->notification_type = $a_notification_type;
370  }
371  public function getNotificationType()
372  {
374  }
375 
376  public function getSubjectSetting()
377  {
378  if($this->getPresetSubject() == 0
379  && $this->getAddReSubject() == 0)
380  {
381  return "empty_subject";
382  }
383  else if($this->getPresetSubject() == 1)
384  {
385  return "preset_subject";
386  }
387  else if($this->getAddReSubject() == 1)
388  {
389  return "add_re_to_subject";
390  }
391  else return "preset_subject";
392  }
393  public function setSubjectSetting($a_subject_setting)
394  {
395  if($a_subject_setting == 'empty_subject')
396  {
397  $this->setPresetSubject(0);
398  $this->setAddReSubject(0);
399  }
400  else if($a_subject_setting == 'preset_subject')
401  {
402  $this->setPresetSubject(1);
403  $this->setAddReSubject(0);
404  }
405  else if($a_subject_setting == 'add_re_to_subject')
406  {
407  $this->setPresetSubject(0);
408  $this->setAddReSubject(1);
409  }
410  }
411 
412  public function setMarkModeratorPosts($a_mod_post)
413  {
414  $this->mark_mod_posts = $a_mod_post;
415  }
416 
417  public function getMarkModeratorPosts()
418  {
419  return $this->mark_mod_posts;
420  }
421 
425  public function getUserToggleNoti()
426  {
428  }
429 
433  public function getAdminForceNoti()
434  {
436  }
437 
438 }
439 ?>