ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
class.ilObjForumGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Object/classes/class.ilObjectGUI.php';
5 require_once 'Services/Table/classes/class.ilTable2GUI.php';
6 require_once 'Modules/Forum/classes/class.ilForumProperties.php';
7 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
8 require_once 'Modules/Forum/classes/class.ilForumPost.php';
9 require_once 'Modules/Forum/classes/class.ilForum.php';
10 require_once 'Modules/Forum/classes/class.ilForumTopic.php';
11 require_once 'Services/RTE/classes/class.ilRTE.php';
12 require_once 'Services/PersonalDesktop/interfaces/interface.ilDesktopItemHandling.php';
13 require_once 'Modules/Forum/classes/class.ilForumMailNotification.php';
14 require_once 'Services/UIComponent/SplitButton/classes/class.ilSplitButtonGUI.php';
15 
29 {
34 
39 
43  private $objCurrentPost;
44 
49 
53  private $is_moderator = false;
54 
59 
64 
68  private $replyEditForm;
69 
74 
78  private $hideToolbar = false;
79 
83  private $forum_overview_setting = null;
84 
88  public $object;
89 
93  public $ilias;
94 
98  private $forumObjects;
99 
104 
105  public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
106  {
112  global $ilCtrl, $ilAccess, $ilObjDataCache;
113 
114  $this->ctrl = $ilCtrl;
115  $this->ctrl->saveParameter($this, array('ref_id', 'cmdClass'));
116 
117  $this->type = 'frm';
118  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
119 
120  $this->lng->loadLanguageModule('forum');
121 
122  $this->initSessionStorage();
123 
124  // Forum properties
125  $this->objProperties = ilForumProperties::getInstance($ilObjDataCache->lookupObjId($_GET['ref_id']));
126 
127  // Stored due to performance issues
128  $this->is_moderator = $ilAccess->checkAccess('moderate_frm', '', $_GET['ref_id']);
129 
130  // Model of current topic/thread
131  $this->objCurrentTopic = new ilForumTopic((int) $_GET['thr_pk'], $this->is_moderator);
132 
133  // Model of current post
134  $this->objCurrentPost = new ilForumPost((int) $_GET['pos_pk'], $this->is_moderator);
135 
136  $frma_set = new ilSetting('frma');
137  $this->forum_overview_setting = $frma_set->get('forum_overview');
138  }
139 
140  protected function initSessionStorage()
141  {
142  $sess = ilSession::get('frm');
143  if(!is_array($sess))
144  {
145  $sess = array();
146  ilSession::set('frm', $sess);
147  }
148 
149  if(isset($_GET['thr_fk']) && !is_array($sess[(int)$_GET['thr_fk']]))
150  {
151  $sess[(int)$_GET['thr_fk']] = array();
152  ilSession::set('frm', $sess);
153  }
154  }
155 
159  private function isHierarchicalView()
160  {
161  return (
162  $_SESSION['viewmode'] == 'answers' ||
164  ) || !(
165  $_SESSION['viewmode'] == 'date' ||
167  );
168  }
169 
173  private function isTopLevelReplyCommand()
174  {
175  return in_array(
176  strtolower($this->ctrl->getCmd()),
177  array_map('strtolower', array('createToLevelPost', 'quoteTopLevelPost', 'saveTopLevelPost'))
178  );
179  }
180 
181  public function executeCommand()
182  {
191  global $ilNavigationHistory, $ilAccess, $ilCtrl, $ilTabs, $ilErr, $ilUser;
192 
193  $next_class = $this->ctrl->getNextClass($this);
194  $cmd = $this->ctrl->getCmd();
195 
196  $exclude_cmds = array(
197  'viewThread', 'markPostUnread','markPostRead', 'showThreadNotification',
198  'performPostActivation',
199  'askForPostActivation', 'askForPostDeactivation',
200  'toggleThreadNotification', 'toggleThreadNotificationTab',
201  'toggleStickiness', 'cancelPost', 'savePost', 'saveTopLevelPost', 'createToLevelPost', 'quoteTopLevelPost', 'quotePost', 'getQuotationHTMLAsynch',
202  'setTreeStateAsynch', 'fetchTreeChildrenAsync'
203  );
204 
205  if(!in_array($cmd, $exclude_cmds))
206  {
207  $this->prepareOutput();
208  }
209 
210  // add entry to navigation history
211  if(!$this->getCreationMode() && !$ilCtrl->isAsynch() && $ilAccess->checkAccess('read', '', $_GET['ref_id']))
212  {
213  $ilNavigationHistory->addItem($_GET['ref_id'],
214  'ilias.php?baseClass=ilRepositoryGUI&amp;cmd=showThreads&amp;ref_id='.$_GET['ref_id'], 'frm');
215  }
216 
217  switch ($next_class)
218  {
219  case 'ilrepositoryobjectsearchgui':
220  $this->addHeaderAction();
221  $this->setSideBlocks();
222  $ilTabs->setTabActive("forums_threads");
223  $ilCtrl->setReturn($this,'view');
224  include_once './Services/Search/classes/class.ilRepositoryObjectSearchGUI.php';
225  $search_gui = new ilRepositoryObjectSearchGUI(
226  $this->object->getRefId(),
227  $this,
228  'view'
229  );
230  $ilCtrl->forwardCommand($search_gui);
231  break;
232 
233  case 'ilpermissiongui':
234  require_once 'Services/AccessControl/classes/class.ilPermissionGUI.php';
235  $perm_gui = new ilPermissionGUI($this);
236  $this->ctrl->forwardCommand($perm_gui);
237  break;
238 
239  case 'ilforumexportgui':
240  require_once 'Modules/Forum/classes/class.ilForumExportGUI.php';
241  $fex_gui = new ilForumExportGUI($this);
242  $this->ctrl->forwardCommand($fex_gui);
243  exit();
244  break;
245 
246  case 'ilforummoderatorsgui':
247  require_once 'Modules/Forum/classes/class.ilForumModeratorsGUI.php';
248  $fm_gui = new ilForumModeratorsGUI($this);
249  $this->ctrl->forwardCommand($fm_gui);
250  break;
251 
252  case 'ilinfoscreengui':
253  $this->infoScreen();
254  break;
255 
256  case 'ilcolumngui':
257  $this->showThreadsObject();
258  break;
259 
260  case 'ilpublicuserprofilegui':
261  include_once 'Services/User/classes/class.ilPublicUserProfileGUI.php';
262  $profile_gui = new ilPublicUserProfileGUI((int)$_GET['user']);
263  $add = $this->getUserProfileAdditional((int)$_GET['ref_id'], (int)$_GET['user']);
264  $profile_gui->setAdditional($add);
265  $ret = $this->ctrl->forwardCommand($profile_gui);
266  $this->tpl->setContent($ret);
267  break;
268 
269  case 'ilobjectcopygui':
270  include_once 'Services/Object/classes/class.ilObjectCopyGUI.php';
271  $cp = new ilObjectCopyGUI($this);
272  $cp->setType('frm');
273  $this->ctrl->forwardCommand($cp);
274  break;
275 
276  case 'ilexportgui':
277  $ilTabs->setTabActive('export');
278  include_once 'Services/Export/classes/class.ilExportGUI.php';
279  $exp = new ilExportGUI($this);
280  $exp->addFormat('xml');
281  $this->ctrl->forwardCommand($exp);
282  break;
283 
284  case "ilratinggui":
285  if(!$this->objProperties->isIsThreadRatingEnabled() || $ilUser->isAnonymous())
286  {
287  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE);
288  }
289 
290  require_once 'Services/Rating/classes/class.ilRatingGUI.php';
291  $rating_gui = new ilRatingGUI();
292  $rating_gui->setObject($this->object->getId(), $this->object->getType(), $this->objCurrentTopic->getId(), 'thread');
293 
294  $ilCtrl->setParameter($this, 'thr_pk', (int)$_GET['thr_pk']);
295  $this->ctrl->forwardCommand($rating_gui);
296 
297  $avg = ilRating::getOverallRatingForObject($this->object->getId(), $this->object->getType(), (int)$_GET['thr_pk'], 'thread');
298  $this->objCurrentTopic->setAverageRating($avg['avg']);
299  $this->objCurrentTopic->update();
300 
301  $ilCtrl->redirect($this, "showThreads");
302  break;
303 
304  case 'ilcommonactiondispatchergui':
305  include_once 'Services/Object/classes/class.ilCommonActionDispatcherGUI.php';
307  $this->ctrl->forwardCommand($gui);
308  break;
309 
310  default:
311  // alex, 11 Jan 2011:
312  // I inserted this workaround due to bug report 6971.
313  // In general the command handling is quite obscure here.
314  // The form action of the table should be filled
315  // with $ilCtrl->getFormAction(..) not with $ilCtrl->getLinkTarget(..)
316  // Commands should be determined with $ilCtrl->getCmd() not
317  // with accessing $_POST['selected_cmd'], since this is internal
318  // of ilTable2GUI/ilCtrl and may change.
319  if(isset($_POST['select_cmd2']))
320  {
321  $_POST['selected_cmd'] = $_POST["selected_cmd2"];
322  }
323 
324  if(isset($_POST['selected_cmd']) && $_POST['selected_cmd'] != null)
325  {
326  $member_cmd = array('enableAdminForceNoti', 'disableAdminForceNoti', 'enableHideUserToggleNoti', 'disableHideUserToggleNoti');
327  in_array($_POST['selected_cmd'], $member_cmd) ? $cmd = $_POST['selected_cmd'] : $cmd = 'performThreadsAction';
328  }
329  else if(!$cmd && !$_POST['selected_cmd'] )
330  {
331  $cmd = 'showThreads';
332  }
333 
334  $cmd .= 'Object';
335  $this->$cmd();
336 
337  break;
338  }
339 
340  // suppress for topic level
341  if($cmd != 'viewThreadObject' && $cmd != 'showUserObject')
342  {
343  $this->addHeaderAction();
344  }
345  }
346 
347  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
348  {
352  global $ilSetting;
353 
354  $this->settingsTabs();
355 
356  //sorting for threads
357  $rg_thr = new ilRadioGroupInputGUI($this->lng->txt('frm_sorting_threads'), 'thread_sorting');
358  $rg_thr->addOption(new ilRadioOption($this->lng->txt('order_by').' '.$this->lng->txt('date'), '0'));
359  $rg_thr->addOption(new ilRadioOption($this->lng->txt('sorting_manual_sticky'), '1'));
360  $a_form->addItem($rg_thr);
361  $rg_thr->setInfo($this->lng->txt('sticky_threads_always_on_top'));
362 
363  // sorting for postings
364  $rg_pro = new ilRadioGroupInputGUI($this->lng->txt('frm_default_view'), 'default_view');
365 
366  $rg_pro->addOption(new ilRadioOption($this->lng->txt('sort_by_posts'), ilForumProperties::VIEW_TREE));
367  $rg_sort_by_date = new ilRadioOption($this->lng->txt('sort_by_date'), ilForumProperties::VIEW_DATE);
368  $rg_pro->addOption($rg_sort_by_date);
369 
370  $view_direction_group_gui = new ilRadioGroupInputGUI('', 'default_view_sort_dir');
371  $view_desc = new ilRadioOption($this->lng->txt('descending_order'), ilForumProperties::VIEW_DATE_DESC);
372  $view_asc = new ilRadioOption($this->lng->txt('ascending_order'), ilForumProperties::VIEW_DATE_ASC);
373  $view_direction_group_gui->addOption($view_desc);
374  $view_direction_group_gui->addOption($view_asc);
375 
376  $rg_sort_by_date->addSubItem($view_direction_group_gui);
377  $a_form->addItem($rg_pro);
378 
379  if($ilSetting->get('enable_anonymous_fora') || $this->objProperties->isAnonymized())
380  {
381  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('frm_anonymous_posting'), 'anonymized');
382  $cb_prop->setValue('1');
383  $cb_prop->setInfo($this->lng->txt('frm_anonymous_posting_desc'));
384  $a_form->addItem($cb_prop);
385  }
386 
387  if($ilSetting->get('enable_fora_statistics', false))
388  {
389  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('frm_statistics_enabled'), 'statistics_enabled');
390  $cb_prop->setValue('1');
391  $cb_prop->setInfo($this->lng->txt('frm_statistics_enabled_desc'));
392  $a_form->addItem($cb_prop);
393  }
394 
395  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('activate_new_posts'), 'post_activation');
396  $cb_prop->setValue('1');
397  $cb_prop->setInfo($this->lng->txt('post_activation_desc'));
398  $a_form->addItem($cb_prop);
399 
400  $frm_subject = new ilRadioGroupInputGUI($this->lng->txt('frm_subject_setting'), 'subject_setting');
401  $frm_subject->addOption(new ilRadioOption($this->lng->txt('preset_subject'), 'preset_subject'));
402  $frm_subject->addOption(new ilRadioOption($this->lng->txt('add_re_to_subject'), 'add_re_to_subject'));
403  $frm_subject->addOption(new ilRadioOption($this->lng->txt('empty_subject'), 'empty_subject'));
404 
405  $a_form->addItem($frm_subject);
406 
407  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('mark_moderator_posts'), 'mark_mod_posts');
408  $cb_prop->setValue('1');
409  $cb_prop->setInfo($this->lng->txt('mark_moderator_posts_desc'));
410  $a_form->addItem($cb_prop);
411 
412  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('enable_thread_ratings'), 'thread_rating');
413  $cb_prop->setValue(1);
414  $cb_prop->setInfo($this->lng->txt('enable_thread_ratings_info'));
415  $a_form->addItem($cb_prop);
416 
417  if(!ilForumProperties::isFileUploadGloballyAllowed())
418  {
419  $frm_upload = new ilCheckboxInputGUI($this->lng->txt('file_upload_allowed'), 'file_upload_allowed');
420  $frm_upload->setValue(1);
421  $frm_upload->setInfo($this->lng->txt('allow_file_upload_desc'));
422  $a_form->addItem($frm_upload);
423  }
424  }
425 
426  protected function getEditFormCustomValues(Array &$a_values)
427  {
428  $a_values["desc"] = $this->object->getLongDescription();
429  $a_values['default_view'] = $this->objProperties->getDefaultView();
430  $a_values['anonymized'] = $this->objProperties->isAnonymized();
431  $a_values['statistics_enabled'] = $this->objProperties->isStatisticEnabled();
432  $a_values['post_activation'] = $this->objProperties->isPostActivationEnabled();
433  $a_values['subject_setting'] = $this->objProperties->getSubjectSetting();
434  $a_values['mark_mod_posts'] = $this->objProperties->getMarkModeratorPosts();
435  $a_values['thread_sorting'] = $this->objProperties->getThreadSorting();
436  $a_values['thread_rating'] = $this->objProperties->isIsThreadRatingEnabled();
437 
438  $default_view =
439  in_array((int)$this->objProperties->getDefaultView(), array(ilForumProperties::VIEW_DATE_ASC, ilForumProperties::VIEW_DATE_DESC))
442  $a_values['default_view'] = $default_view;
443 
444  $default_view_sort_dir =
445  (int)$this->objProperties->getDefaultView() != (int)ilForumProperties::VIEW_TREE
446  ? (int)$this->objProperties->getDefaultView()
448 
449  $a_values['default_view_sort_dir'] = $default_view_sort_dir;
450  $a_values['file_upload_allowed'] = (bool)$this->objProperties->getFileUploadAllowed();
451  }
452 
453  protected function updateCustom(ilPropertyFormGUI $a_form)
454  {
458  global $ilSetting;
459 
460  $view = (int)$_POST['default_view'];
461  if($view == ilForumProperties::VIEW_DATE)
462  {
464  if((int)$_POST['default_view_sort_dir'] == ilForumProperties::VIEW_DATE_DESC)
465  {
467  }
468  }
469  $this->objProperties->setDefaultView($view);
470 
471  // BUGFIX FOR 11271
472  if(isset($_SESSION['viewmode']))
473  {
474  $_SESSION['viewmode'] = $view;
475  }
476 
477  if($ilSetting->get('enable_anonymous_fora') || $this->objProperties->isAnonymized())
478  {
479  $this->objProperties->setAnonymisation((int) $a_form->getInput('anonymized'));
480  }
481  if($ilSetting->get('enable_fora_statistics', false))
482  {
483  $this->objProperties->setStatisticsStatus((int) $a_form->getInput('statistics_enabled'));
484  }
485  $this->objProperties->setPostActivation((int) $a_form->getInput('post_activation'));
486  $this->objProperties->setSubjectSetting( $a_form->getInput('subject_setting'));
487  $this->objProperties->setMarkModeratorPosts((int) $a_form->getInput('mark_mod_posts'));
488  $this->objProperties->setThreadSorting((int)$a_form->getInput('thread_sorting'));
489  $this->objProperties->setIsThreadRatingEnabled((bool)$a_form->getInput('thread_rating'));
490  if(!ilForumProperties::isFileUploadGloballyAllowed())
491  {
492  $this->objProperties->setFileUploadAllowed((bool)$a_form->getInput('file_upload_allowed'));
493  }
494 
495  $this->objProperties->update();
496  }
497 
502  private function getThreadEditingForm($a_thread_id)
503  {
504  $form = new ilPropertyFormGUI();
505  $this->ctrl->setParameter($this, 'thr_pk', $a_thread_id);
506  $form->setFormAction($this->ctrl->getFormAction($this, 'updateThread'));
507 
508  $ti_prop = new ilTextInputGUI($this->lng->txt('title'), 'title');
509  $ti_prop->setRequired(true);
510  $ti_prop->setMaxLength(255);
511  $ti_prop->setSize(50);
512  $form->addItem($ti_prop);
513 
514  $form->addCommandButton('updateThread', $this->lng->txt('save'));
515  $form->addCommandButton('showThreads', $this->lng->txt('cancel'));
516 
517  return $form;
518  }
519 
524  public function editThreadObject($a_thread_id, ilPropertyFormGUI $form = null)
525  {
529  global $ilTabs;
530 
531  if(!$this->is_moderator)
532  {
533  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
534  }
535 
536  $ilTabs->setTabActive('forums_threads');
537 
538  if(!($form instanceof ilPropertyFormGUI))
539  {
540  $form = $this->getThreadEditingForm($a_thread_id);
541  $form->setValuesByArray(array(
542  'title' => ilForumTopic::_lookupTitle($a_thread_id)
543  ));
544  }
545 
546  $this->tpl->setContent($form->getHTML());
547  }
548 
552  public function updateThreadObject()
553  {
554  if(!$this->is_moderator)
555  {
556  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
557  }
558 
559  if(!$this->objCurrentTopic->getId())
560  {
561  $this->showThreadsObject();
562  return;
563  }
564 
565  $forum_id = ilObjForum::lookupForumIdByObjId($this->object->getId());
566  if($this->objCurrentTopic->getForumId() != $forum_id)
567  {
568  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
569  }
570 
571  $form = $this->getThreadEditingForm($this->objCurrentTopic->getId());
572  if(!$form->checkInput())
573  {
574  $form->setValuesByPost();
575  $this->editThreadObject($this->objCurrentTopic->getId(), $form);
576  return;
577  }
578 
579  $this->objCurrentTopic->setSubject($form->getInput('title'));
580  $this->objCurrentTopic->updateThreadTitle();
581 
582  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
583  $this->showThreadsObject();
584  }
585 
586  public function markAllReadObject()
587  {
591  global $ilUser;
592 
593  $this->object->markAllThreadsRead($ilUser->getId());
594 
595  ilUtil::sendInfo($this->lng->txt('forums_all_threads_marked_read'));
596 
597  $this->showThreadsObject();
598  }
599 
600  public function showThreadsObject()
601  {
602  $this->getSubTabs('showThreads');
603  $this->setSideBlocks();
604  $this->getCenterColumnHTML();
605  }
606  public function sortThreadsObject()
607  {
608  $this->getSubTabs('sortThreads');
609  $this->setSideBlocks();
610  $this->getCenterColumnHTML(true);
611  }
612 
613 
614  public function getSubTabs($subtab = 'showThreads')
615  {
616  global $ilTabs;
617 
618  if($this->objProperties->getThreadSorting() == 1 && $this->is_moderator)
619  {
620  $ilTabs->addSubTabTarget('show', $this->ctrl->getLinkTarget($this, 'showThreads'), 'showThreads', get_class($this), '', $subtab=='showThreads'? true : false );
621  $ilTabs->addSubTabTarget('sorting_header', $this->ctrl->getLinkTarget($this, 'sortThreads'), 'sortThreads', get_class($this), '', $subtab=='sortThreads'? true : false );
622  }
623  }
624  public function getContent()
625  {
632  global $ilUser, $ilAccess, $lng, $ilToolbar;
633 
634  if(!$ilAccess->checkAccess('read', '', $this->object->getRefId()))
635  {
636  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
637  }
638 
639  $cmd = $this->ctrl->getCmd();
640  $frm = $this->object->Forum;
641  $frm->setForumId($this->object->getId());
642  $frm->setForumRefId($this->object->getRefId());
643  $frm->setMDB2Wherecondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
644 
645  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_liste.html', 'Modules/Forum');
646 
647  if((int)strlen($this->confirmation_gui_html))
648  {
649  $this->tpl->setVariable('CONFIRMATION_GUI', $this->confirmation_gui_html);
650  }
651 
652  // Create topic button
653  if($ilAccess->checkAccess('add_thread', '', $this->object->getRefId()) && !$this->hideToolbar())
654  {
655  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
656  $btn = ilLinkButton::getInstance();
657  $btn->setUrl($this->ctrl->getLinkTarget($this, 'createThread'));
658  $btn->setCaption('forums_new_thread');
659  $ilToolbar->addStickyItem($btn);
660  }
661 
662  // Mark all topics as read button
663  include_once 'Services/Accessibility/classes/class.ilAccessKeyGUI.php';
664  if($ilUser->getId() != ANONYMOUS_USER_ID && !(int)strlen($this->confirmation_gui_html))
665  {
666  $ilToolbar->addButton(
667  $this->lng->txt('forums_mark_read'),
668  $this->ctrl->getLinkTarget($this, 'markAllRead'),
669  '',
671  );
672  $this->ctrl->clearParameters($this);
673  }
674 
675  // Import information: Topic (variable $topicData) means frm object, not thread
676  $topicData = $frm->getOneTopic();
677  if($topicData)
678  {
679  // Visit-Counter
680  $frm->setDbTable('frm_data');
681  $frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($topicData['top_pk']));
682  $frm->updateVisits($topicData['top_pk']);
683 
684  include_once 'Modules/Forum/classes/class.ilForumTopicTableGUI.php';
685  if(!in_array($cmd, array('showThreads', 'sortThreads') ))
686  {
687  $cmd = 'showThreads';
688  }
689  $tbl = new ilForumTopicTableGUI($this, $cmd, '', (int) $_GET['ref_id'], $topicData, $this->is_moderator, $this->forum_overview_setting);
690  $tbl->setMapper($frm)->fetchData();
691  $tbl->populate();
692  $this->tpl->setVariable('THREADS_TABLE', $tbl->getHTML());
693  }
694 
695  // Permanent link
696  include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
697  $permalink = new ilPermanentLinkGUI('frm', $this->object->getRefId());
698  $this->tpl->setVariable('PRMLINK', $permalink->getHTML());
699  }
700 
704  private function initForumCreateForm($object_type)
705  {
706  $this->create_form_gui = new ilPropertyFormGUI();
707  $this->create_form_gui->setTableWidth('600px');
708 
709  $this->create_form_gui->setTitle($this->lng->txt('frm_new'));
710  $this->create_form_gui->setTitleIcon(ilUtil::getImagePath('icon_frm.svg'));
711 
712  // form action
713  $this->ctrl->setParameter($this, 'new_type', $object_type);
714  $this->create_form_gui->setFormAction($this->ctrl->getFormAction($this, 'save'));
715 
716  // title
717  $title_gui = new ilTextInputGUI($this->lng->txt('title'), 'title');
718  $title_gui->setSize(min(40, ilObject::TITLE_LENGTH));
719  $title_gui->setMaxLength(ilObject::TITLE_LENGTH);
720  $this->create_form_gui->addItem($title_gui);
721 
722  // description
723  $description_gui = new ilTextAreaInputGUI($this->lng->txt('desc'), 'desc');
724  $description_gui->setCols(40);
725  $description_gui->setRows(2);
726  $this->create_form_gui->addItem($description_gui);
727 
728  // view sorting threads
729  $sorting_threads_gui = new ilRadioGroupInputGUI($this->lng->txt('frm_sorting_threads'), 'thread_sorting');
730  $sort_dat = new ilRadioOption($this->lng->txt('order_by').' '.$this->lng->txt('date'), 0);
731  $sorting_threads_gui->addOption($sort_dat);
732 
733  $sort_man = new ilRadioOption($this->lng->txt('sorting_manual_sticky'), 1);
734  $sorting_threads_gui->addOption($sort_man);
735  $sorting_threads_gui->setInfo($this->lng->txt('sticky_threads_always_on_top'));
736  $this->create_form_gui->addItem($sorting_threads_gui);
737 
738  // view
739  $view_group_gui = new ilRadioGroupInputGUI($this->lng->txt('frm_default_view'), 'sort');
740  $view_hir = new ilRadioOption($this->lng->txt('order_by').' '.$this->lng->txt('answers'), ilForumProperties::VIEW_TREE);
741  $view_group_gui->addOption($view_hir);
742  $view_dat = new ilRadioOption($this->lng->txt('order_by').' '.$this->lng->txt('date'), ilForumProperties::VIEW_DATE);
743  $view_group_gui->addOption($view_dat);
744  $this->create_form_gui->addItem($view_group_gui);
745  $view_direction_group_gui = new ilRadioGroupInputGUI('', 'default_view_sort_dir');
746  $view_desc = new ilRadioOption($this->lng->txt('frm_post_sort_desc'), ilForumProperties::VIEW_DATE_DESC);
747  $view_direction_group_gui->addOption($view_desc);
748  $view_asc = new ilRadioOption($this->lng->txt('frm_post_sort_asc'), ilForumProperties::VIEW_DATE_ASC);
749  $view_direction_group_gui->addOption($view_asc);
750  $view_dat->addSubItem($view_direction_group_gui);
751 
752  // anonymized or not
753  $anonymize_gui = new ilCheckboxInputGUI($this->lng->txt('frm_anonymous_posting'), 'anonymized');
754  $anonymize_gui->setInfo($this->lng->txt('frm_anonymous_posting_desc'));
755  $anonymize_gui->setValue(1);
756 
757  if($this->ilias->getSetting('enable_anonymous_fora', false))
758  $anonymize_gui->setDisabled(true);
759  $this->create_form_gui->addItem($anonymize_gui);
760 
761  // statistics enabled or not
762  $statistics_gui = new ilCheckboxInputGUI($this->lng->txt('frm_statistics_enabled'), 'statistics_enabled');
763  $statistics_gui->setInfo($this->lng->txt('frm_statistics_enabled_desc'));
764  $statistics_gui->setValue(1);
765  if(!$this->ilias->getSetting('enable_fora_statistics', false))
766  $statistics_gui->setDisabled(true);
767  $this->create_form_gui->addItem($statistics_gui);
768 
769  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('activate_new_posts'), 'post_activation');
770  $cb_prop->setValue('1');
771  $cb_prop->setInfo($this->lng->txt('post_activation_desc'));
772  $this->create_form_gui->addItem($cb_prop);
773 
774  $this->create_form_gui->addCommandButton('save', $this->lng->txt('save'));
775  $this->create_form_gui->addCommandButton('cancel', $this->lng->txt('cancel'));
776  }
777 
778  public function cancelObject($in_rep = false)
779  {
780  ilUtil::sendInfo($this->lng->txt('msg_cancel'), true);
781  ilUtil::redirect('ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&ref_id='.$_GET['ref_id']);
782  }
783 
787  protected function afterSave(ilObjForum $forumObj)
788  {
789  ilUtil::sendSuccess($this->lng->txt('frm_added'), true);
790  $this->ctrl->setParameter($this, 'ref_id', $forumObj->getRefId());
791  ilUtil::redirect($this->ctrl->getLinkTarget($this, 'createThread', '', false, false));
792  }
793 
794  public function getTabs(ilTabsGUI $tabs_gui)
795  {
801  global $ilAccess, $ilHelp, $ilCtrl;
802 
803  $ilHelp->setScreenIdComponent("frm");
804 
805  $this->ctrl->setParameter($this, 'ref_id', $this->ref_id);
806 
807  include_once 'Services/Repository/classes/class.ilRepositoryExplorer.php';
808  $active = array(
809  '', 'showThreads', 'view', 'markAllRead',
810  'enableForumNotification', 'disableForumNotification', 'moveThreads', 'performMoveThreads',
811  'cancelMoveThreads', 'performThreadsAction', 'createThread', 'addThread',
812  'showUser', 'confirmDeleteThreads',
813  'merge','mergeThreads', 'cancelMergeThreads', 'performMergeThreads'
814  );
815 
816  (in_array($ilCtrl->getCmd(), $active)) ? $force_active = true : $force_active = false;
817  $tabs_gui->addTarget('forums_threads', $this->ctrl->getLinkTarget($this,'showThreads'), $ilCtrl->getCmd(), get_class($this), '', $force_active);
818 
819  // info tab
820  if($ilAccess->checkAccess('visible', '', $this->ref_id))
821  {
822  $force_active = ($this->ctrl->getNextClass() == 'ilinfoscreengui' || strtolower($_GET['cmdClass']) == 'ilnotegui') ? true : false;
823  $tabs_gui->addTarget('info_short',
824  $this->ctrl->getLinkTargetByClass(
825  array('ilobjforumgui', 'ilinfoscreengui'), 'showSummary'),
826  array('showSummary', 'infoScreen'),
827  '', '', $force_active);
828  }
829 
830  if($ilAccess->checkAccess('write', '', $this->ref_id))
831  {
832  $force_active = ($ilCtrl->getCmd() == 'edit') ? true : false;
833  $tabs_gui->addTarget('settings', $this->ctrl->getLinkTarget($this, 'edit'), 'edit', get_class($this), '', $force_active);
834  }
835 
836  if($ilAccess->checkAccess('write', '', $this->ref_id))
837  {
838  $tabs_gui->addTarget('frm_moderators', $this->ctrl->getLinkTargetByClass('ilForumModeratorsGUI', 'showModerators'), 'showModerators', get_class($this));
839  }
840 
841  if($this->ilias->getSetting('enable_fora_statistics', false) &&
842  ($this->objProperties->isStatisticEnabled() || $ilAccess->checkAccess('write', '', $this->ref_id)))
843  {
844  $force_active = ($ilCtrl->getCmd() == 'showStatistics') ? true : false;
845  $tabs_gui->addTarget('frm_statistics', $this->ctrl->getLinkTarget($this, 'showStatistics'), 'showStatistics', get_class($this), '', $force_active); //false
846  }
847 
848  if($ilAccess->checkAccess('write', '', $this->object->getRefId()))
849  {
850  $tabs_gui->addTarget('export', $this->ctrl->getLinkTargetByClass('ilexportgui', ''), '', 'ilexportgui');
851  }
852 
853  if($ilAccess->checkAccess('edit_permission', '', $this->ref_id))
854  {
855  $tabs_gui->addTarget('perm_settings', $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), 'perm'), array('perm', 'info', 'owner'), 'ilpermissiongui');
856  }
857  }
858 
859  public function settingsTabs()
860  {
866  global $ilTabs, $ilAccess, $tree;
867 
868  $ilTabs->setTabActive('settings');
869  $ilTabs->addSubTabTarget('basic_settings', $this->ctrl->getLinkTarget($this, 'edit'), 'edit', get_class($this), '', $_GET['cmd']=='edit'? true : false );
870 
871  // notification tab
872  if($this->ilias->getSetting('forum_notification') > 0)
873  {
874  // check if there a parent-node is a grp or crs
875  $grp_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp');
876  $crs_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs');
877 
878  if((int)$grp_ref_id > 0 || (int)$crs_ref_id > 0 )
879  {
880  #show member-tab for notification if forum-notification is enabled in administration
881  if($ilAccess->checkAccess('write', '', $this->ref_id))
882  {
883  $mem_active = array('showMembers', 'forums_notification_settings');
884  (in_array($_GET['cmd'],$mem_active)) ? $force_mem_active = true : $force_mem_active = false;
885 
886  $ilTabs->addSubTabTarget('notifications', $this->ctrl->getLinkTarget($this, 'showMembers'), $_GET['cmd'], get_class($this), '', $force_mem_active);
887  }
888  }
889  }
890  return true;
891  }
892 
893  public function showStatisticsObject()
894  {
898  global $ilAccess;
899 
901  if(!$this->ilias->getSetting('enable_fora_statistics', false))
902  {
903  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
904  }
905 
906  // if no read access -> intrusion detected
907  if(!$ilAccess->checkAccess('read', '', $_GET['ref_id']))
908  {
909  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
910  }
911 
912  // if read access and statistics disabled -> intrusion detected
913  if(!$ilAccess->checkAccess('read', '', $_GET['ref_id']) && !$this->objProperties->isStatisticEnabled())
914  {
915  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
916  }
917 
918  // if write access and statistics disabled -> ok, for forum admin
919  if($ilAccess->checkAccess('write', '', $_GET['ref_id']) &&
920  !$this->objProperties->isStatisticEnabled())
921  {
922  ilUtil::sendInfo($this->lng->txt('frm_statistics_disabled_for_participants'));
923  }
924 
925  $this->object->Forum->setForumId($this->object->getId());
926 
927  require_once 'Modules/Forum/classes/class.ilForumStatisticsTableGUI.php';
928 
929  $tbl = new ilForumStatisticsTableGUI($this, 'showStatistics');
930  $tbl->setId('il_frm_statistic_table_'.(int) $_GET['ref_id']);
931  $tbl->setTitle($this->lng->txt('statistic'), 'icon_usr.svg', $this->lng->txt('obj_'.$this->object->getType()));
932 
933  $data = $this->object->Forum->getUserStatistic($this->is_moderator);
934  $result = array();
935  $counter = 0;
936  foreach($data as $row)
937  {
938  $result[$counter]['ranking'] = $row[0];
939  $result[$counter]['login'] = $row[1];
940  $result[$counter]['lastname'] = $row[2];
941  $result[$counter]['firstname'] = $row[3];
942 
943  ++$counter;
944  }
945  $tbl->setData($result);
946 
947  $this->tpl->setContent($tbl->getHTML());
948  }
949 
950  public static function _goto($a_target, $a_thread = 0, $a_posting = 0)
951  {
957  global $ilAccess, $ilErr, $lng;
958 
959  if($ilAccess->checkAccess('read', '', $a_target))
960  {
961  if($a_thread != 0)
962  {
963  $objTopic = new ilForumTopic($a_thread);
964  if ($objTopic->getFrmObjId() &&
965  $objTopic->getFrmObjId() != ilObject::_lookupObjectId($a_target))
966  {
967  $ref_ids = ilObject::_getAllReferences($objTopic->getFrmObjId());
968  foreach($ref_ids as $ref_id)
969  {
970  if($ilAccess->checkAccess('read', '', $ref_id))
971  {
972  $new_ref_id = $ref_id;
973  break;
974  }
975  }
976 
977  if (isset($new_ref_id) && $new_ref_id != $a_target)
978  {
979  ilUtil::redirect(ILIAS_HTTP_PATH."/goto.php?target=frm_".$new_ref_id."_".$a_thread."_".$a_posting);
980  }
981  }
982 
983  $_GET['ref_id'] = $a_target;
984  $_GET['pos_pk'] = $a_posting;
985  $_GET['thr_pk'] = $a_thread;
986  $_GET['anchor'] = $a_posting;
987  $_GET['cmdClass'] = 'ilObjForumGUI';
988  $_GET['cmd'] = 'viewThread';
989  $_GET['baseClass'] = 'ilRepositoryGUI';
990 
991  include_once('ilias.php');
992  exit();
993  }
994  else
995  {
996 
997  $_GET['ref_id'] = $a_target;
998  $_GET['baseClass'] = 'ilRepositoryGUI';
999  include_once('ilias.php');
1000  exit();
1001  }
1002  }
1003  else if($ilAccess->checkAccess('read', '', ROOT_FOLDER_ID))
1004  {
1005  $_GET['target'] = '';
1006  $_GET['ref_id'] = ROOT_FOLDER_ID;
1007  ilUtil::sendInfo(sprintf($lng->txt('msg_no_perm_read_item'),
1008  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1009  $_GET['baseClass'] = 'ilRepositoryGUI';
1010  include('ilias.php');
1011  exit();
1012  }
1013 
1014  $ilErr->raiseError($lng->txt('msg_no_perm_read'), $ilErr->FATAL);
1015  }
1016 
1017  public function performDeleteThreadsObject()
1018  {
1022  global $lng;
1023 
1024  if(!$this->is_moderator)
1025  {
1026  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
1027  return $this->showThreadsObject();
1028  }
1029 
1030  if(!isset($_POST['thread_ids']) || !is_array($_POST['thread_ids']))
1031  {
1032  ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'));
1033  return $this->showThreadsObject();
1034  }
1035 
1036  require_once 'Modules/Forum/classes/class.ilForum.php';
1037  require_once 'Modules/Forum/classes/class.ilObjForum.php';
1038 
1039  $forumObj = new ilObjForum($_GET['ref_id']);
1040 
1041  $this->objProperties->setObjId($forumObj->getId());
1042 
1043  $frm = new ilForum();
1044  if(count($_POST['thread_ids']) > 1 )
1045  {
1046  $success_message = 'forums_threads_deleted';
1047  }
1048  else
1049  {
1050  $success_message = 'forums_thread_deleted';
1051  }
1052 
1053  foreach($_POST['thread_ids'] as $topic_id)
1054  {
1055  $frm->setForumId($forumObj->getId());
1056  $frm->setForumRefId($forumObj->getRefId());
1057 
1058  $first_node = $frm->getFirstPostNode($topic_id);
1059  if((int)$first_node['pos_pk'])
1060  {
1061  $frm->deletePost($first_node['pos_pk']);
1062  ilUtil::sendInfo($lng->txt($success_message), true);
1063  }
1064  }
1065  $this->ctrl->redirect($this, 'showThreads');
1066  }
1067 
1068  public function confirmDeleteThreads()
1069  {
1073  global $lng;
1074 
1075  if(!isset($_POST['thread_ids']) || !is_array($_POST['thread_ids']))
1076  {
1077  ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'));
1078  return $this->showThreadsObject();
1079  }
1080 
1081  if(!$this->is_moderator)
1082  {
1083  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
1084  return $this->showThreadsObject();
1085  }
1086 
1087  include_once('Services/Utilities/classes/class.ilConfirmationGUI.php');
1088  $c_gui = new ilConfirmationGUI();
1089 
1090  $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performDeleteThreads'));
1091  $c_gui->setHeaderText($this->lng->txt('frm_sure_delete_threads'));
1092  $c_gui->setCancel($this->lng->txt('cancel'), 'showThreads');
1093  $c_gui->setConfirm($this->lng->txt('confirm'), 'performDeleteThreads');
1094 
1095  foreach((array)$_POST['thread_ids'] as $thread_id)
1096  {
1097  $c_gui->addItem('thread_ids[]', $thread_id, ilForumTopic::_lookupTitle($thread_id));
1098  }
1099 
1100  $this->confirmation_gui_html = $c_gui->getHTML();
1101 
1102  $this->hideToolbar(true);
1103 
1104  return $this->tpl->setContent($c_gui->getHTML());
1105  }
1106 
1107  public function prepareThreadScreen(ilObjForum $a_forum_obj)
1108  {
1115  global $tpl, $lng, $ilTabs, $ilHelp;
1116 
1117  $ilHelp->setScreenIdComponent("frm");
1118 
1119  $tpl->getStandardTemplate();
1120  ilUtil::sendInfo();
1122 
1123  $tpl->setTitleIcon(ilObject::_getIcon("", "big", "frm"));
1124 
1125  $ilTabs->setBackTarget($lng->txt('all_topics'),'ilias.php?baseClass=ilRepositoryGUI&amp;ref_id='.$_GET['ref_id']);
1126 
1127  // by answer view
1128  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
1129  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1130  $this->ctrl->setParameter($this, 'viewmode', ilForumProperties::VIEW_TREE);
1131  $ilTabs->addTarget('sort_by_posts', $this->ctrl->getLinkTarget($this, 'viewThread'));
1132 
1133  // by date view
1134  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
1135  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1136  $this->ctrl->setParameter($this, 'viewmode', ilForumProperties::VIEW_DATE);
1137  $ilTabs->addTarget('order_by_date', $this->ctrl->getLinkTarget($this, 'viewThread'));
1138 
1139  $this->ctrl->clearParameters($this);
1140 
1141  if($this->isHierarchicalView())
1142  {
1143  $ilTabs->setTabActive('sort_by_posts');
1144  }
1145  else
1146  {
1147  $ilTabs->setTabActive('order_by_date');
1148  }
1149 
1153  $frm = $a_forum_obj->Forum;
1154  $frm->setForumId($a_forum_obj->getId());
1155  }
1156 
1158  {
1159  if($this->is_moderator)
1160  {
1161  $this->objCurrentPost->activatePost();
1162  $GLOBALS['ilAppEventHandler']->raise(
1163  'Modules/Forum',
1164  'activatedPost',
1165  array(
1166  'ref_id' => $this->object->getRefId(),
1167  'post' => $this->objCurrentPost
1168  )
1169  );
1170  ilUtil::sendInfo($this->lng->txt('forums_post_was_activated'), true);
1171  }
1172 
1173  $this->viewThreadObject();
1174  }
1175 
1176  public function askForPostActivationObject()
1177  {
1178  if($this->is_moderator)
1179  {
1180  $this->setDisplayConfirmPostActivation(true);
1181  }
1182 
1183  $this->viewThreadObject();
1184  }
1185 
1186  public function setDisplayConfirmPostActivation($status = 0)
1187  {
1188  $this->display_confirm_post_activation = $status;
1189  }
1190 
1192  {
1194  }
1195 
1196  public function toggleThreadNotificationObject()
1197  {
1201  global $ilUser;
1202 
1203  if($this->objCurrentTopic->isNotificationEnabled($ilUser->getId()))
1204  {
1205  $this->objCurrentTopic->disableNotification($ilUser->getId());
1206  ilUtil::sendInfo($this->lng->txt('forums_notification_disabled'), true);
1207  }
1208  else
1209  {
1210  $this->objCurrentTopic->enableNotification($ilUser->getId());
1211  ilUtil::sendInfo($this->lng->txt('forums_notification_enabled'), true);
1212  }
1213 
1214  $this->viewThreadObject();
1215  }
1216 
1217  public function toggleStickinessObject()
1218  {
1219  if($this->is_moderator)
1220  {
1221  if($this->objCurrentTopic->isSticky())
1222  {
1223  $this->objCurrentTopic->unmakeSticky();
1224  }
1225  else
1226  {
1227  $this->objCurrentTopic->makeSticky();
1228  }
1229  }
1230 
1231  $this->viewThreadObject();
1232  }
1233 
1234  public function cancelPostObject()
1235  {
1236  $_GET['action'] = '';
1237  $this->viewThreadObject();
1238  }
1239 
1240  public function getDeleteFormHTML()
1241  {
1245  global $lng;
1246 
1248  $form_tpl = new ilTemplate('tpl.frm_delete_post_form.html', true, true, 'Modules/Forum');
1249 
1250  $form_tpl->setVariable('ANKER', $this->objCurrentPost->getId());
1251  $form_tpl->setVariable('SPACER', '<hr noshade="noshade" width="100%" size="1" align="center" />');
1252  $form_tpl->setVariable('TXT_DELETE', $lng->txt('forums_info_delete_post'));
1253  $this->ctrl->setParameter($this, 'action', 'ready_delete');
1254  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1255  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
1256  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
1257  $form_tpl->setVariable('FORM_ACTION', $this->ctrl->getLinkTarget($this, 'viewThread'));
1258  $this->ctrl->clearParameters($this);
1259  $form_tpl->setVariable('CANCEL_BUTTON', $lng->txt('cancel'));
1260  $form_tpl->setVariable('CONFIRM_BUTTON', $lng->txt('confirm'));
1261 
1262  return $form_tpl->get();
1263  }
1264 
1265  public function getActivationFormHTML()
1266  {
1270  global $lng;
1271 
1272  $form_tpl = new ilTemplate('tpl.frm_activation_post_form.html', true, true, 'Modules/Forum');
1273 
1274  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1275  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
1276  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
1277  $form_tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'performPostActivation'));
1278  $form_tpl->setVariable('SPACER', '<hr noshade="noshade" width="100%" size="1" align="center" />');
1279  $form_tpl->setVariable('ANCHOR', $this->objCurrentPost->getId());
1280  $form_tpl->setVariable('TXT_ACT', $lng->txt('activate_post_txt'));
1281  $form_tpl->setVariable('CONFIRM_BUTTON', $lng->txt('activate_only_current'));
1282  $form_tpl->setVariable('CMD_CONFIRM', 'performPostActivation');
1283  $form_tpl->setVariable('CANCEL_BUTTON', $lng->txt('cancel'));
1284  $form_tpl->setVariable('CMD_CANCEL', 'viewThread');
1285  $this->ctrl->clearParameters($this);
1286 
1287  return $form_tpl->get();
1288  }
1289 
1290  public function getCensorshipFormHTML()
1291  {
1296  global $lng, $frm;
1297 
1298  $form_tpl = new ilTemplate('tpl.frm_censorship_post_form.html', true, true, 'Modules/Forum');
1299 
1300  $form_tpl->setVariable('ANCHOR', $this->objCurrentPost->getId());
1301  $form_tpl->setVariable('SPACER', '<hr noshade="noshade" width="100%" size="1" align="center" />');
1302  $this->ctrl->setParameter($this, 'action', 'ready_censor');
1303  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1304  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
1305  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
1306  $form_tpl->setVariable('FORM_ACTION', $this->ctrl->getLinkTarget($this, 'viewThread'));
1307  $this->ctrl->clearParameters($this);
1308  $form_tpl->setVariable('TXT_CENS_MESSAGE', $lng->txt('forums_the_post'));
1309  $form_tpl->setVariable('TXT_CENS_COMMENT', $lng->txt('forums_censor_comment').':');
1310  $form_tpl->setVariable('CENS_MESSAGE', $frm->prepareText($this->objCurrentPost->getCensorshipComment(), 2));
1311 
1312  if($this->objCurrentPost->isCensored())
1313  {
1314  $form_tpl->setVariable('TXT_CENS', $lng->txt('forums_info_censor2_post'));
1315  $form_tpl->setVariable('YES_BUTTON', $lng->txt('confirm'));
1316  $form_tpl->setVariable('NO_BUTTON', $lng->txt('cancel'));
1317  }
1318  else
1319  {
1320  $form_tpl->setVariable('TXT_CENS', $lng->txt('forums_info_censor_post'));
1321  $form_tpl->setVariable('CANCEL_BUTTON', $lng->txt('cancel'));
1322  $form_tpl->setVariable('CONFIRM_BUTTON', $lng->txt('confirm'));
1323  }
1324 
1325  return $form_tpl->get();
1326  }
1327 
1331  private function initReplyEditForm()
1332  {
1339  global $ilUser, $rbacsystem;
1340 
1341  // init objects
1342  $oForumObjects = $this->getForumObjects();
1343  $frm = $oForumObjects['frm'];
1344  $oFDForum = $oForumObjects['file_obj'];
1345 
1346  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
1347  $this->replyEditForm = new ilPropertyFormGUI();
1348  $this->replyEditForm->setTableWidth('100%');
1349 
1350  if($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply')
1351  {
1352  $this->ctrl->setParameter($this, 'action', 'ready_showreply');
1353  }
1354  else
1355  {
1356  $this->ctrl->setParameter($this, 'action', 'ready_showedit');
1357  }
1358 
1359  $this->ctrl->setParameter($this, 'offset', (int)$_GET['offset']);
1360  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
1361  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1362  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
1363  if($this->isTopLevelReplyCommand())
1364  {
1365  $this->replyEditForm->setFormAction($this->ctrl->getFormAction($this, 'saveTopLevelPost'), 'frm_page_bottom');
1366  }
1367  else
1368  {
1369  $this->replyEditForm->setFormAction($this->ctrl->getFormAction($this, 'savePost'), $this->objCurrentPost->getId());
1370  }
1371  $this->ctrl->clearParameters($this);
1372 
1373  if($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply')
1374  {
1375  $this->replyEditForm->setTitle($this->lng->txt('forums_your_reply'));
1376  }
1377  else
1378  {
1379  $this->replyEditForm->setTitle($this->lng->txt('forums_edit_post'));
1380  }
1381 
1382  // alias
1383  if($this->objProperties->isAnonymized() &&
1384  in_array($_GET['action'], array('showreply', 'ready_showreply')))
1385  {
1386  $oAnonymousNameGUI = new ilTextInputGUI($this->lng->txt('forums_your_name'), 'alias');
1387  $oAnonymousNameGUI->setMaxLength(64);
1388  $oAnonymousNameGUI->setInfo($this->lng->txt('forums_use_alias'));
1389 
1390  $this->replyEditForm->addItem($oAnonymousNameGUI);
1391  }
1392 
1393  // subject
1394  $oSubjectGUI = new ilTextInputGUI($this->lng->txt('forums_subject'), 'subject');
1395  $oSubjectGUI->setMaxLength(64);
1396  $oSubjectGUI->setRequired(true);
1397 
1398  if($this->objProperties->getSubjectSetting() == 'empty_subject')
1399  $oSubjectGUI->setInfo($this->lng->txt('enter_new_subject'));
1400 
1401  $this->replyEditForm->addItem($oSubjectGUI);
1402 
1403  // post
1404  $oPostGUI = new ilTextAreaInputGUI(
1405  $_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply' ? $this->lng->txt('forums_your_reply') : $this->lng->txt('forums_edit_post'),
1406  'message'
1407  );
1408  $oPostGUI->setRequired(true);
1409  $oPostGUI->setCols(50);
1410  $oPostGUI->setRows(15);
1411  $oPostGUI->setUseRte(true);
1412  $oPostGUI->addPlugin('latex');
1413  $oPostGUI->addButton('latex');
1414  $oPostGUI->addButton('pastelatex');
1415  $oPostGUI->addPlugin('ilfrmquote');
1416 
1417  //$oPostGUI->addPlugin('code');
1418  if($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply')
1419  {
1420  $oPostGUI->addButton('ilFrmQuoteAjaxCall');
1421  }
1422  $oPostGUI->removePlugin('advlink');
1423  $oPostGUI->setRTERootBlockElement('');
1424  $oPostGUI->usePurifier(true);
1425  $oPostGUI->disableButtons(array(
1426  'charmap',
1427  'undo',
1428  'redo',
1429  'justifyleft',
1430  'justifycenter',
1431  'justifyright',
1432  'justifyfull',
1433  'anchor',
1434  'fullscreen',
1435  'cut',
1436  'copy',
1437  'paste',
1438  'pastetext',
1439  'formatselect'
1440  ));
1441 
1442  if($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply')
1443  {
1444  $oPostGUI->setRTESupport($ilUser->getId(), 'frm~', 'frm_post', 'tpl.tinymce_frm_post.html', false, '3.5.11');
1445  }
1446  else
1447  {
1448  $oPostGUI->setRTESupport($this->objCurrentPost->getId(), 'frm', 'frm_post', 'tpl.tinymce_frm_post.html', false, '3.5.11');
1449  }
1450  // purifier
1451  require_once 'Services/Html/classes/class.ilHtmlPurifierFactory.php';
1452  $oPostGUI->setPurifier(ilHtmlPurifierFactory::_getInstanceByType('frm_post'));
1453 
1454  $this->replyEditForm->addItem($oPostGUI);
1455 
1456  // notification only if gen. notification is disabled and forum isn't anonymous
1457  include_once 'Services/Mail/classes/class.ilMail.php';
1458  $umail = new ilMail($ilUser->getId());
1459  if($rbacsystem->checkAccess('internal_mail', $umail->getMailObjectReferenceId()) &&
1460  !$frm->isThreadNotificationEnabled($ilUser->getId(), $this->objCurrentPost->getThreadId()) &&
1461  !$this->objProperties->isAnonymized())
1462  {
1463  $oNotificationGUI = new ilCheckboxInputGUI('', 'notify');
1464  $oNotificationGUI->setInfo($this->lng->txt('forum_notify_me'));
1465 
1466  $this->replyEditForm->addItem($oNotificationGUI);
1467  }
1468 
1469  if($this->objProperties->isFileUploadAllowed())
1470  {
1471  $oFileUploadGUI = new ilFileWizardInputGUI($this->lng->txt('forums_attachments_add'), 'userfile');
1472  $oFileUploadGUI->setFilenames(array(0 => ''));
1473  $this->replyEditForm->addItem($oFileUploadGUI);
1474  }
1475 
1476  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
1477  if(
1478  $ilUser->isAnonymous() &&
1479  !$ilUser->isCaptchaVerified() &&
1480  ilCaptchaUtil::isActiveForForum()
1481  )
1482  {
1483  require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
1484  $captcha = new ilCaptchaInputGUI($this->lng->txt('cont_captcha_code'), 'captcha_code');
1485  $captcha->setRequired(true);
1486  $this->replyEditForm->addItem($captcha);
1487  }
1488 
1489  $attachments_of_node = $oFDForum->getFilesOfPost();
1490  if(count($attachments_of_node) && ($_GET['action'] == 'showedit' || $_GET['action'] == 'ready_showedit'))
1491  {
1492  $oExistingAttachmentsGUI = new ilCheckboxGroupInputGUI($this->lng->txt('forums_delete_file'), 'del_file');
1493  foreach($oFDForum->getFilesOfPost() as $file)
1494  {
1495  $oAttachmentGUI = new ilCheckboxInputGUI($file['name'], 'del_file');
1496  $oAttachmentGUI->setValue($file['md5']);
1497  $oExistingAttachmentsGUI->addOption($oAttachmentGUI);
1498  }
1499  $this->replyEditForm->addItem($oExistingAttachmentsGUI);
1500  }
1501 
1502  if($this->isTopLevelReplyCommand())
1503  {
1504  $this->replyEditForm->addCommandButton('saveTopLevelPost', $this->lng->txt('create'));
1505  }
1506  else
1507  {
1508  $this->replyEditForm->addCommandButton('savePost', $this->lng->txt('save'));
1509  }
1510 
1511  if($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply')
1512  {
1513  include_once 'Services/RTE/classes/class.ilRTE.php';
1514  $rtestring = ilRTE::_getRTEClassname();
1515 
1516  if(array_key_exists('show_rte', $_POST))
1517  {
1519  }
1520 
1521  if(strtolower($rtestring) != 'iltinymce' || !ilObjAdvancedEditing::_getRichTextEditorUserState())
1522  {
1523  if($this->isTopLevelReplyCommand())
1524  {
1525  $this->replyEditForm->addCommandButton('quoteTopLevelPost', $this->lng->txt('forum_add_quote'));
1526  }
1527  else
1528  {
1529  $this->replyEditForm->addCommandButton('quotePost', $this->lng->txt('forum_add_quote'));
1530  }
1531  }
1532  }
1533  $this->replyEditForm->addCommandButton('cancelPost', $this->lng->txt('cancel'));
1534  }
1535 
1539  private function getReplyEditForm()
1540  {
1541  if(null === $this->replyEditForm)
1542  {
1543  $this->initReplyEditForm();
1544  }
1545 
1546  return $this->replyEditForm;
1547  }
1548 
1552  public function createToLevelPostObject()
1553  {
1554  $this->viewThreadObject();
1555  return;
1556  }
1557 
1561  public function saveTopLevelPostObject()
1562  {
1563  $this->savePostObject();
1564  return;
1565  }
1566 
1570  public function quoteTopLevelPostObject()
1571  {
1572  $this->quotePostObject();
1573  return;
1574  }
1575 
1579  public function savePostObject()
1580  {
1586  global $ilUser, $ilAccess, $lng;
1587 
1588  if(!isset($_POST['del_file']) || !is_array($_POST['del_file'])) $_POST['del_file'] = array();
1589 
1590  if($this->objCurrentTopic->isClosed())
1591  {
1592  $_GET['action'] = '';
1593  return $this->viewThreadObject();
1594  }
1595 
1596  $oReplyEditForm = $this->getReplyEditForm();
1597  if($oReplyEditForm->checkInput())
1598  {
1599  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
1600  if(
1601  $ilUser->isAnonymous() &&
1602  !$ilUser->isCaptchaVerified() &&
1603  ilCaptchaUtil::isActiveForForum()
1604  )
1605  {
1606  $ilUser->setCaptchaVerified(true);
1607  }
1608 
1609  // init objects
1610  $oForumObjects = $this->getForumObjects();
1614  $forumObj = $oForumObjects['forumObj'];
1618  $frm = $oForumObjects['frm'];
1619  $frm->setMDB2WhereCondition(' top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
1620  $topicData = $frm->getOneTopic();
1621 
1622  // Generating new posting
1623  if($_GET['action'] == 'ready_showreply')
1624  {
1625  if(!$ilAccess->checkAccess('add_reply', '', (int)$_GET['ref_id']))
1626  {
1627  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
1628  }
1629 
1630  // reply: new post
1631  $status = 1;
1632  $send_activation_mail = 0;
1633 
1634  if($this->objProperties->isPostActivationEnabled())
1635  {
1636  if(!$this->is_moderator)
1637  {
1638  $status = 0;
1639  $send_activation_mail = 1;
1640  }
1641  else if($this->objCurrentPost->isAnyParentDeactivated())
1642  {
1643  $status = 0;
1644  }
1645  }
1646 
1647  if($this->objProperties->isAnonymized())
1648  {
1649  if(!strlen($oReplyEditForm->getInput('alias')))
1650  {
1651  $user_alias = $this->lng->txt('forums_anonymous');
1652  }
1653  else
1654  {
1655  $user_alias = $oReplyEditForm->getInput('alias');
1656  }
1657  }
1658  else
1659  {
1660  $user_alias = $ilUser->getLogin();
1661  }
1662 
1663  $newPost = $frm->generatePost(
1664  $topicData['top_pk'],
1665  $this->objCurrentTopic->getId(),
1666  $ilUser->getId(),
1667  ($this->objProperties->isAnonymized() ? 0 : $ilUser->getId()),
1668  ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message'), 0),
1669  $this->objCurrentPost->getId(),
1670  (int)$oReplyEditForm->getInput('notify'),
1671  $this->handleFormInput($oReplyEditForm->getInput('subject'), false),
1672  $user_alias,
1673  '',
1674  $status,
1675  $send_activation_mail
1676  );
1677 
1678  // mantis #8115: Mark parent as read
1679  $this->object->markPostRead($ilUser->getId(), (int) $this->objCurrentTopic->getId(), (int) $this->objCurrentPost->getId());
1680 
1681  // copy temporary media objects (frm~)
1682  include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
1683  $mediaObjects = ilRTE::_getMediaObjects($oReplyEditForm->getInput('message'), 0);
1684  $myMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId());
1685  foreach($mediaObjects as $mob)
1686  {
1687  foreach($myMediaObjects as $myMob)
1688  {
1689  if($mob == $myMob)
1690  {
1691  // change usage
1692  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
1693  break;
1694  }
1695  }
1696  ilObjMediaObject::_saveUsage($mob, 'frm:html', $newPost);
1697  }
1698 
1699  if($this->objProperties->isFileUploadAllowed())
1700  {
1701  $oFDForum = new ilFileDataForum($forumObj->getId(), $newPost);
1702  $file = $_FILES['userfile'];
1703  if(is_array($file) && !empty($file))
1704  {
1705  $oFDForum->storeUploadedFile($file);
1706  }
1707  }
1708 
1709  $GLOBALS['ilAppEventHandler']->raise(
1710  'Modules/Forum',
1711  'createdPost',
1712  array(
1713  'ref_id' => $this->object->getRefId(),
1714  'post' => new ilForumPost($newPost),
1715  'notify_moderators' => (bool)$send_activation_mail
1716  )
1717  );
1718 
1719  $message = '';
1720  if(!$this->is_moderator && !$status)
1721  {
1722  $message .= $lng->txt('forums_post_needs_to_be_activated');
1723  }
1724  else
1725  {
1726  $message .= $lng->txt('forums_post_new_entry');
1727  }
1728 
1729  $_SESSION['frm'][(int)$_GET['thr_pk']]['openTreeNodes'][] = (int)$this->objCurrentPost->getId();
1730 
1731  ilUtil::sendSuccess($message, true);
1732  $this->ctrl->setParameter($this, 'pos_pk', $newPost);
1733  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
1734  $this->ctrl->redirect($this, 'viewThread');
1735  }
1736  else
1737  {
1738  if((!$this->is_moderator &&
1739  !$this->objCurrentPost->isOwner($ilUser->getId())) || $this->objCurrentPost->isCensored() ||
1740  $ilUser->getId() == ANONYMOUS_USER_ID)
1741  {
1742  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
1743  }
1744 
1745  // remove usage of deleted media objects
1746  include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
1747  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm:html', $this->objCurrentPost->getId());
1748  $curMediaObjects = ilRTE::_getMediaObjects($oReplyEditForm->getInput('message'), 0);
1749  foreach($oldMediaObjects as $oldMob)
1750  {
1751  $found = false;
1752  foreach($curMediaObjects as $curMob)
1753  {
1754  if($oldMob == $curMob)
1755  {
1756  $found = true;
1757  break;
1758  }
1759  }
1760  if(!$found)
1761  {
1762  if(ilObjMediaObject::_exists($oldMob))
1763  {
1764  ilObjMediaObject::_removeUsage($oldMob, 'frm:html', $this->objCurrentPost->getId());
1765  $mob_obj = new ilObjMediaObject($oldMob);
1766  $mob_obj->delete();
1767  }
1768  }
1769  }
1770 
1771  // if post has been edited posting mus be activated again by moderator
1772  $status = 1;
1773  $send_activation_mail = 0;
1774 
1775  if($this->objProperties->isPostActivationEnabled())
1776  {
1777  if(!$this->is_moderator)
1778  {
1779  $status = 0;
1780  $send_activation_mail = 1;
1781  }
1782  else if($this->objCurrentPost->isAnyParentDeactivated())
1783  {
1784  $status = 0;
1785  }
1786  }
1787  $this->objCurrentPost->setStatus($status);
1788 
1789  $this->objCurrentPost->setSubject($this->handleFormInput($oReplyEditForm->getInput('subject'), false));
1790  $this->objCurrentPost->setMessage(ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message'), 0));
1791  $this->objCurrentPost->setNotification((int)$oReplyEditForm->getInput('notify'));
1792  $this->objCurrentPost->setChangeDate(date('Y-m-d H:i:s'));
1793  $this->objCurrentPost->setUpdateUserId($ilUser->getId());
1794 
1795  // edit: update post
1796  if($this->objCurrentPost->update())
1797  {
1798  $this->objCurrentPost->reload();
1799 
1800  // Change news item accordingly
1801  include_once 'Services/News/classes/class.ilNewsItem.php';
1802  // note: $this->objCurrentPost->getForumId() does not give us the forum ID here (why?)
1803  $news_id = ilNewsItem::getFirstNewsIdForContext($forumObj->getId(),
1804  'frm', $this->objCurrentPost->getId(), 'pos');
1805  if($news_id > 0)
1806  {
1807  $news_item = new ilNewsItem($news_id);
1808  $news_item->setTitle($this->objCurrentPost->getSubject());
1809  $news_item->setContent(ilRTE::_replaceMediaObjectImageSrc($frm->prepareText(
1810  $this->objCurrentPost->getMessage(), 0), 1)
1811  );
1812  $news_item->update();
1813  }
1814 
1815  $oFDForum = $oForumObjects['file_obj'];
1816 
1817  if($this->objProperties->isFileUploadAllowed())
1818  {
1819  $file = $_FILES['userfile'];
1820  if(is_array($file) && !empty($file))
1821  {
1822  $oFDForum->storeUploadedFile($file);
1823  }
1824  }
1825 
1826  $file2delete = $oReplyEditForm->getInput('del_file');
1827  if(is_array($file2delete) && count($file2delete))
1828  {
1829  $oFDForum->unlinkFilesByMD5Filenames($file2delete);
1830  }
1831 
1832  $GLOBALS['ilAppEventHandler']->raise(
1833  'Modules/Forum',
1834  'updatedPost',
1835  array(
1836  'ref_id' => $this->object->getRefId(),
1837  'post' => $this->objCurrentPost,
1838  'notify_moderators' => (bool)$send_activation_mail
1839  )
1840  );
1841 
1842  ilUtil::sendSuccess($lng->txt('forums_post_modified'), true);
1843  }
1844 
1845  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1846  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
1847  $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
1848  $this->ctrl->redirect($this, 'viewThread');
1849  }
1850  }
1851  else
1852  {
1853  $_GET['action'] = substr($_GET['action'], 6);
1854  }
1855  return $this->viewThreadObject();
1856  }
1857 
1858  private function hideToolbar($a_flag = null)
1859  {
1860  if(null === $a_flag)
1861  {
1862  return $this->hideToolbar;
1863  }
1864 
1865  $this->hideToolbar = $a_flag;
1866  return $this;
1867  }
1868 
1869  public function quotePostObject()
1870  {
1871  if(!is_array($_POST['del_file'])) $_POST['del_file'] = array();
1872 
1873  if($this->objCurrentTopic->isClosed())
1874  {
1875  $_GET['action'] = '';
1876  return $this->viewThreadObject();
1877  }
1878 
1879  $oReplyEditForm = $this->getReplyEditForm();
1880 
1881  // remove mandatory fields
1882  $oReplyEditForm->getItemByPostVar('subject')->setRequired(false);
1883  $oReplyEditForm->getItemByPostVar('message')->setRequired(false);
1884 
1885  $oReplyEditForm->checkInput();
1886 
1887  // add mandatory fields
1888  $oReplyEditForm->getItemByPostVar('subject')->setRequired(true);
1889  $oReplyEditForm->getItemByPostVar('message')->setRequired(true);
1890 
1891  $_GET['action'] = 'showreply';
1892 
1893  $this->viewThreadObject();
1894  }
1895 
1896  public function getQuotationHTMLAsynchObject()
1897  {
1898  $oForumObjects = $this->getForumObjects();
1902  $frm = $oForumObjects['frm'];
1903 
1904  require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
1905  $authorinfo = new ilForumAuthorInformation(
1906  $this->objCurrentPost->getPosAuthorId(),
1907  $this->objCurrentPost->getDisplayUserId(),
1908  $this->objCurrentPost->getUserAlias(),
1909  $this->objCurrentPost->getImportName()
1910  );
1911 
1912  $html = ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($this->objCurrentPost->getMessage(), 1, $authorinfo->getAuthorName()), 1);
1913  echo $html;
1914  exit();
1915  }
1916 
1917  private function getForumObjects()
1918  {
1919  if(null === $this->forumObjects)
1920  {
1921  $forumObj = $this->object;
1922  $file_obj = new ilFileDataForum($forumObj->getId(), $this->objCurrentPost->getId());
1923  $frm = $forumObj->Forum;
1924  $frm->setForumId($forumObj->getId());
1925  $frm->setForumRefId($forumObj->getRefId());
1926 
1927  $this->forumObjects['forumObj'] = $forumObj;
1928  $this->forumObjects['frm'] = $frm;
1929  $this->forumObjects['file_obj'] = $file_obj;
1930  }
1931 
1932  return $this->forumObjects;
1933  }
1934 
1935  public function getForumExplorer()
1936  {
1937  include_once 'Modules/Forum/classes/class.ilForumExplorer.php';
1938 
1939  $explorer = new ilForumExplorer(
1940  $this,
1941  $this->objCurrentTopic,
1942  $this->objProperties
1943  );
1944 
1945  return $explorer->render()->getHtml();
1946  }
1947 
1949  {
1950  include_once 'Services/JSON/classes/class.ilJsonUtil.php';
1951  include_once 'Modules/Forum/classes/class.ilForumExplorer.php';
1952 
1953  $response = new stdClass();
1954  $response->success = false;
1955 
1956  if( $_GET['nodeId'] )
1957  {
1958  $response->success = true;
1959  $response->children = array();
1960 
1961  $key = array_search((int)$_GET['nodeId'], (array)$_SESSION['frm'][(int)$_GET['thr_pk']]['openTreeNodes']);
1962  if( false === $key )
1963  {
1964  $_SESSION['frm'][(int)$_GET['thr_pk']]['openTreeNodes'][] = (int)$_GET['nodeId'];
1965  }
1966 
1967  $children = $this->objCurrentTopic->getNestedSetPostChildren(
1968  (int)$_GET['nodeId'],
1969  (array)$_SESSION['frm'][(int)$_GET['thr_pk']]['openTreeNodes']
1970  );
1971 
1972  $frm = new ilForum();
1973  $pageHits = $frm->getPageHits();
1974 
1975  $fetchedNodes = array();
1976 
1977  foreach( $children as $child )
1978  {
1979  if($child['parent_pos'] != (int)$_GET['nodeId'] &&
1980  !in_array($child['parent_pos'], $fetchedNodes))
1981  {
1982  continue;
1983  }
1984 
1985  $fetchedNodes[] = $child['pos_pk'];
1986 
1987  $this->ctrl->setParameter($this, 'thr_pk', (int)$_GET['thr_pk']);
1988 
1990  $child,
1991  $this,
1992  $pageHits
1993  );
1994 
1995  $responseChild = new stdClass();
1996  $responseChild->nodeId = $child['pos_pk'];
1997  $responseChild->parentId = $child['parent_pos'];
1998  $responseChild->hasChildren = ($child['children'] >= 1);
1999  $responseChild->fetchedWithChildren = in_array((int)$child['pos_pk'], (array)$_SESSION['frm'][(int)$_GET['thr_pk']]['openTreeNodes']);
2000  $responseChild->html = $html;
2001 
2002  $response->children[] = $responseChild;
2003  }
2004  }
2005 
2006  echo ilJsonUtil::encode($response);
2007  exit();
2008  }
2009 
2010  public function setTreeStateAsynchObject()
2011  {
2012  include_once 'Services/JSON/classes/class.ilJsonUtil.php';
2013 
2014  $response = new stdClass();
2015  $response->success = true;
2016 
2017  if( $_GET['nodeId'] )
2018  {
2019  if( $_GET['nodeId'] > 0 )
2020  {
2021  $key = array_search((int)$_GET['nodeId'], (array)$_SESSION['frm'][(int)$_GET['thr_pk']]['openTreeNodes']);
2022  if( false === $key )
2023  {
2024  $_SESSION['frm'][(int)$_GET['thr_pk']]['openTreeNodes'][] = (int)$_GET['nodeId'];
2025  }
2026  }
2027  else
2028  {
2029  $key = array_search((int)abs($_GET['nodeId']), (array)$_SESSION['frm'][(int)$_GET['thr_pk']]['openTreeNodes']);
2030  if( false !== $key )
2031  {
2032  unset($_SESSION['frm'][(int)$_GET['thr_pk']]['openTreeNodes'][$key]);
2033  }
2034  }
2035  }
2036 
2037  // Guarantee continuous keys
2038  shuffle($_SESSION['frm'][(int)$_GET['thr_pk']]['openTreeNodes']);
2039  exit();
2040  }
2041 
2042  public function viewThreadObject()
2043  {
2054  global $tpl, $lng, $ilUser, $ilAccess, $rbacreview, $ilNavigationHistory, $ilCtrl, $frm, $ilToolbar, $ilLocator;
2055 
2056  $bottom_toolbar = clone $ilToolbar;
2057  $bottom_toolbar_split_button_items = array();
2058 
2059  $tpl->addCss('./Modules/Forum/css/forum_tree.css');
2060  if(!isset($_SESSION['viewmode']))
2061  {
2062  $_SESSION['viewmode'] = $this->objProperties->getDefaultView();
2063  }
2064 
2065  // quick and dirty: check for treeview
2066  if(!isset($_SESSION['thread_control']['old']))
2067  {
2068  $_SESSION['thread_control']['old'] = $_GET['thr_pk'];
2069  $_SESSION['thread_control']['new'] = $_GET['thr_pk'];
2070  }
2071  else
2072  if(isset($_SESSION['thread_control']['old']) && $_GET['thr_pk'] != $_SESSION['thread_control']['old'])
2073  {
2074  $_SESSION['thread_control']['new'] = $_GET['thr_pk'];
2075  }
2076 
2077  if(isset($_GET['viewmode']) && $_GET['viewmode'] != $_SESSION['viewmode'])
2078  {
2079  $_SESSION['viewmode'] = $_GET['viewmode'];
2080  }
2081 
2082  if( (isset($_GET['action']) && $_SESSION['viewmode'] != ilForumProperties::VIEW_DATE)
2083  ||($_SESSION['viewmode'] == ilForumProperties::VIEW_TREE))
2084  {
2086  }
2087  else
2088  {
2090  }
2091 
2092  if(!$ilAccess->checkAccess('read', '', $this->object->getRefId()))
2093  {
2094  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
2095  }
2096 
2097  // init objects
2098  $oForumObjects = $this->getForumObjects();
2102  $forumObj = $oForumObjects['forumObj'];
2106  $frm = $oForumObjects['frm'];
2110  $file_obj = $oForumObjects['file_obj'];
2111 
2112  // download file
2113  if($_GET['file'])
2114  {
2115  if(!$path = $file_obj->getFileDataByMD5Filename($_GET['file']))
2116  {
2117  ilUtil::sendFailure($this->lng->txt('error_reading_file'));
2118  }
2119  else
2120  {
2121  ilUtil::deliverFile($path['path'], $path['clean_filename']);
2122  }
2123  }
2124 
2125  if(!$this->objCurrentTopic->getId())
2126  {
2127  $ilCtrl->redirect($this, 'showThreads');
2128  }
2129 
2130  // Set context for login
2131  $append = '_'.$this->objCurrentTopic->getId().
2132  ($this->objCurrentPost->getId() ? '_'.$this->objCurrentPost->getId() : '');
2133  $tpl->setLoginTargetPar('frm_'.$_GET['ref_id'].$append);
2134 
2135  // delete temporary media object (not in case a user adds media objects and wants to save an invalid form)
2136  if($_GET['action'] != 'showreply' && $_GET['action'] != 'showedit')
2137  {
2138  try
2139  {
2140  include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
2141  $mobs = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId());
2142  foreach($mobs as $mob)
2143  {
2144  if(ilObjMediaObject::_exists($mob))
2145  {
2146  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
2147  $mob_obj = new ilObjMediaObject($mob);
2148  $mob_obj->delete();
2149  }
2150  }
2151  }
2152  catch(Exception $e)
2153  {
2154  }
2155  }
2156 
2157  require_once './Modules/Forum/classes/class.ilObjForum.php';
2158  require_once './Modules/Forum/classes/class.ilFileDataForum.php';
2159 
2160  $lng->loadLanguageModule('forum');
2161 
2162  // add entry to navigation history
2163  if (!$this->getCreationMode() &&
2164  $ilAccess->checkAccess('read', '', $this->object->getRefId()))
2165  {
2166  $ilCtrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
2167  $ilNavigationHistory->addItem($this->object->getRefId(), $ilCtrl->getLinkTarget($this, 'showThreads'), 'frm');
2168  }
2169 
2170  // save last access
2171  $forumObj->updateLastAccess($ilUser->getId(), (int) $this->objCurrentTopic->getId());
2172 
2173  $this->prepareThreadScreen($forumObj);
2174 
2175  $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_view.html', 'Modules/Forum');
2176 
2177  if(isset($_GET['anchor']))
2178  {
2179  $tpl->setVariable('JUMP2ANCHOR_ID', (int)$_GET['anchor']);
2180  }
2181 
2182  if($this->isHierarchicalView())
2183  {
2184  $orderField = 'frm_posts_tree.rgt';
2185  $this->objCurrentTopic->setOrderDirection('DESC');
2186  }
2187  else
2188  {
2189  $orderField = 'frm_posts_tree.fpt_date';
2190  $this->objCurrentTopic->setOrderDirection(
2191  in_array($this->objProperties->getDefaultView(), array(ilForumProperties::VIEW_DATE_ASC, ilForumProperties::VIEW_TREE))
2192  ? 'ASC' : 'DESC'
2193  );
2194  }
2195 
2196  // get forum- and thread-data
2197  $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
2198 
2199  if(is_array($topicData = $frm->getOneTopic()))
2200  {
2201  // Visit-Counter for topic
2202  $this->objCurrentTopic->updateVisits();
2203 
2204  $tpl->setTitle($lng->txt('forums_thread')." \"".$this->objCurrentTopic->getSubject()."\"");
2205 
2206  // ********************************************************************************
2207  // build location-links
2208  $ilLocator->addRepositoryItems();
2209  $ilLocator->addItem($this->object->getTitle(), $ilCtrl->getLinkTarget($this, ""), "_top");
2210  $tpl->setLocator();
2211 
2212  // set tabs
2213  // menu template (contains linkbar)
2215  $menutpl = new ilTemplate('tpl.forums_threads_menu.html', true, true, 'Modules/Forum');
2216 
2217  include_once("./Services/Accessibility/classes/class.ilAccessKeyGUI.php");
2218 
2219  // mark all as read
2220  if(
2221  $ilUser->getId() != ANONYMOUS_USER_ID &&
2222  $forumObj->getCountUnread($ilUser->getId(), (int) $this->objCurrentTopic->getId())
2223  )
2224  {
2225  $this->ctrl->setParameter($this, 'mark_read', '1');
2226  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
2227 
2228  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
2229  $mark_thr_read_button = ilLinkButton::getInstance();
2230  $mark_thr_read_button->setCaption('forums_mark_read');
2231  $mark_thr_read_button->setUrl($this->ctrl->getLinkTarget($this, 'viewThread'));
2232  $mark_thr_read_button->setAccessKey(ilAccessKey::MARK_ALL_READ);
2233 
2234  $bottom_toolbar_split_button_items[] = $mark_thr_read_button;
2235 
2236  $this->ctrl->clearParameters($this);
2237  }
2238 
2239  // print thread
2240  $this->ctrl->setParameterByClass('ilforumexportgui', 'print_thread', $this->objCurrentTopic->getId());
2241  $this->ctrl->setParameterByClass('ilforumexportgui', 'thr_top_fk', $this->objCurrentTopic->getForumId());
2242 
2243  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
2244  $print_thr_button = ilLinkButton::getInstance();
2245  $print_thr_button->setCaption('forums_print_thread');
2246  $print_thr_button->setUrl($this->ctrl->getLinkTargetByClass('ilforumexportgui', 'printThread'));
2247 
2248  $bottom_toolbar_split_button_items[] = $print_thr_button;
2249 
2250  $this->ctrl->clearParametersByClass('ilforumexportgui');
2251 
2252  $this->addHeaderAction();
2253 
2254  if($_GET['mark_read'])
2255  {
2256  $forumObj->markThreadRead($ilUser->getId(), (int)$this->objCurrentTopic->getId());
2257  ilUtil::sendInfo($lng->txt('forums_thread_marked'), true);
2258  }
2259 
2260  // delete post and its sub-posts
2261  require_once './Modules/Forum/classes/class.ilForum.php';
2262 
2263  if ($_GET['action'] == 'ready_delete' && $_POST['confirm'] != '')
2264  {
2265  if(!$this->objCurrentTopic->isClosed() &&
2266  ($this->is_moderator ||
2267  ($this->objCurrentPost->isOwner($ilUser->getId()) && !$this->objCurrentPost->hasReplies())) &&
2268  $ilUser->getId() != ANONYMOUS_USER_ID)
2269  {
2270  $frm = new ilForum();
2271 
2272  $frm->setForumId($forumObj->getId());
2273  $frm->setForumRefId($forumObj->getRefId());
2274 
2275  $dead_thr = $frm->deletePost($this->objCurrentPost->getId());
2276 
2277  // if complete thread was deleted ...
2278  if ($dead_thr == $this->objCurrentTopic->getId())
2279  {
2280 
2281  $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($forumObj->getId()));
2282 
2283  $topicData = $frm->getOneTopic();
2284 
2285  ilUtil::sendInfo($lng->txt('forums_post_deleted'), true);
2286 
2287  if ($topicData['top_num_threads'] > 0)
2288  {
2289  $this->ctrl->redirect($this, 'showThreads');
2290  }
2291  else
2292  {
2293  $this->ctrl->redirect($this, 'createThread');
2294  }
2295  }
2296  ilUtil::sendInfo($lng->txt('forums_post_deleted'));
2297  }
2298  }
2299 
2300  // form processing (censor)
2301  if(!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'ready_censor')
2302  {
2303  $cens_message = $this->handleFormInput($_POST['formData']['cens_message']);
2304 
2305  if(($_POST['confirm'] != '' || $_POST['no_cs_change'] != '') && $_GET['action'] == 'ready_censor')
2306  {
2307  $frm->postCensorship($cens_message, $this->objCurrentPost->getId(), 1);
2308  ilUtil::sendSuccess($this->lng->txt('frm_censorship_applied'));
2309  }
2310  else if(($_POST['cancel'] != '' || $_POST['yes_cs_change'] != '') && $_GET['action'] == 'ready_censor')
2311  {
2312  $frm->postCensorship($cens_message, $this->objCurrentPost->getId());
2313  ilUtil::sendSuccess($this->lng->txt('frm_censorship_revoked'));
2314  }
2315  }
2316 
2317  // get complete tree of thread
2318  $first_node = $this->objCurrentTopic->getFirstPostNode();
2319  $this->objCurrentTopic->setOrderField($orderField);
2320  $subtree_nodes = $this->objCurrentTopic->getPostTree($first_node);
2321 
2322  if(
2323  !$this->isTopLevelReplyCommand() &&
2324  $first_node instanceof ilForumPost &&
2325  $first_node->isActivated() &&
2326  !$this->objCurrentTopic->isClosed() &&
2327  $ilAccess->checkAccess('add_reply', '', (int)$_GET['ref_id'])
2328  )
2329  {
2330  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
2331  $reply_button = ilLinkButton::getInstance();
2332  $reply_button->setPrimary(true);
2333  $reply_button->setCaption('add_new_answer');
2334  $this->ctrl->setParameter($this, 'action', 'showreply');
2335  $this->ctrl->setParameter($this, 'pos_pk', $first_node->getId());
2336  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
2337  $this->ctrl->setParameter($this, 'offset', (int)$_GET['offset']);
2338  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2339 
2340  $reply_button->setUrl($this->ctrl->getLinkTarget($this, 'createToLevelPost', 'frm_page_bottom'));
2341 
2342  $this->ctrl->clearParameters($this);
2343  array_unshift($bottom_toolbar_split_button_items, $reply_button);
2344  }
2345 
2346  // no posts
2347  if (!$posNum = count($subtree_nodes))
2348  {
2349  ilUtil::sendInfo($this->lng->txt('forums_no_posts_available'));
2350  }
2351 
2352  $pageHits = $frm->getPageHits();
2353 
2354  $z = 0;
2355 
2356  // navigation to browse
2357  if ($posNum > $pageHits)
2358  {
2359  $params = array(
2360  'ref_id' => $_GET['ref_id'],
2361  'thr_pk' => $this->objCurrentTopic->getId(),
2362  'orderby' => $_GET['orderby']
2363  );
2364 
2365  if (!$_GET['offset'])
2366  {
2367  $Start = 0;
2368  }
2369  else
2370  {
2371  $Start = $_GET['offset'];
2372  }
2373 
2374  $linkbar = ilUtil::Linkbar($ilCtrl->getLinkTarget($this, 'viewThread'), $posNum, $pageHits, $Start, $params);
2375 
2376  if($linkbar != '')
2377  {
2378  $menutpl->setCurrentBlock('linkbar');
2379  $menutpl->setVariable('LINKBAR', $linkbar);
2380  $menutpl->parseCurrentBlock();
2381  }
2382  }
2383 
2384  $tpl->setVariable('THREAD_MENU', $menutpl->get());
2385 
2386  // assistance val for anchor-links
2387  $jump = 0;
2388 
2389  // generate post-dates
2390  foreach($subtree_nodes as $node)
2391  {
2396  $this->ctrl->clearParameters($this);
2397 
2398  if($this->objCurrentPost->getId() && $this->objCurrentPost->getId() == $node->getId())
2399  {
2400  $jump++;
2401  }
2402 
2403  if ($posNum > $pageHits && $z >= ($Start + $pageHits))
2404  {
2405  // if anchor-link was not found ...
2406  if ($this->objCurrentPost->getId() && $jump < 1)
2407  {
2408  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
2409  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2410  $this->ctrl->setParameter($this, 'offset', ($Start + $pageHits));
2411  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2412  $this->ctrl->redirect($this, 'viewThread', $this->objCurrentPost->getId());
2413  }
2414  else
2415  {
2416  break;
2417  }
2418  }
2419 
2420  if(($posNum > $pageHits && $z >= $Start) || $posNum <= $pageHits)
2421  {
2422  $actions = array();
2423  if(!$this->isTopLevelReplyCommand() && $this->objCurrentPost->getId() == $node->getId())
2424  {
2425  # actions for "active" post
2426  if($this->is_moderator || $node->isActivated())
2427  {
2428  // reply/edit
2429  if(!$this->objCurrentTopic->isClosed() && ($_GET['action'] == 'showreply' || $_GET['action'] == 'showedit'))
2430  {
2431  if($_GET['action'] == 'showedit' &&
2432  ((!$this->is_moderator &&
2433  !$node->isOwner($ilUser->getId()) || $ilUser->getId() == ANONYMOUS_USER_ID) || $node->isCensored()))
2434  {
2435  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
2436  }
2437  else if($_GET['action'] == 'showreply' && !$ilAccess->checkAccess('add_reply', '', (int)$_GET['ref_id']))
2438  {
2439  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
2440  }
2441 
2442  $tpl->setVariable('REPLY_ANKER', $this->objCurrentPost->getId());
2443  $oEditReplyForm = $this->getReplyEditForm();
2444 
2445  switch($this->objProperties->getSubjectSetting())
2446  {
2447  case 'add_re_to_subject':
2448  $subject = $this->getModifiedReOnSubject(true);
2449  break;
2450 
2451  case 'preset_subject':
2452  $subject = $this->objCurrentPost->getSubject();
2453  break;
2454 
2455  case 'empty_subject':
2456  default:
2457  $subject = NULL;
2458  break;
2459  }
2460 
2461  switch($_GET['action'])
2462  {
2463  case 'showreply':
2464  if($this->ctrl->getCmd() == 'savePost')
2465  {
2466  $oEditReplyForm->setValuesByPost();
2467  }
2468  else if($this->ctrl->getCmd() == 'quotePost')
2469  {
2470  require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
2471  $authorinfo = new ilForumAuthorInformation(
2472  $node->getPosAuthorId(),
2473  $node->getDisplayUserId(),
2474  $node->getUserAlias(),
2475  $node->getImportName()
2476  );
2477 
2478  $oEditReplyForm->setValuesByPost();
2479  $oEditReplyForm->getItemByPostVar('message')->setValue(
2481  $frm->prepareText($node->getMessage(), 1, $authorinfo->getAuthorName())."\n".$oEditReplyForm->getInput('message'), 1
2482  )
2483  );
2484  }
2485  else
2486  {
2487  $oEditReplyForm->setValuesByArray(array(
2488  'alias' => '',
2489  'subject' => $subject,
2490  'message' => '',
2491  'notify' => 0,
2492  'userfile' => '',
2493  'del_file' => array()
2494  ));
2495  }
2496 
2497  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2498  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2499 
2500  $jsTpl = new ilTemplate('tpl.forum_post_quoation_ajax_handler.html', true, true, 'Modules/Forum');
2501  $jsTpl->setVariable('IL_FRM_QUOTE_CALLBACK_SRC',
2502  $this->ctrl->getLinkTarget($this, 'getQuotationHTMLAsynch', '', true));
2503  $this->ctrl->clearParameters($this);
2504  $this->tpl->setVariable('FORM_ADDITIONAL_JS', $jsTpl->get());
2505  break;
2506  case 'showedit':
2507  if($this->ctrl->getCmd() == 'savePost')
2508  {
2509  $oEditReplyForm->setValuesByPost();
2510  }
2511  else
2512  {
2513  $oEditReplyForm->setValuesByArray(array(
2514  'alias' => '',
2515  'subject' => $this->objCurrentPost->getSubject(),
2516  'message' => ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($this->objCurrentPost->getMessage(), 2), 1),
2517  'notify' => $this->objCurrentPost->isNotificationEnabled() ? true : false,
2518  'userfile' => '',
2519  'del_file' => array()
2520  ));
2521  }
2522  break;
2523  }
2524  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2525  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2526  $this->ctrl->setParameter($this, 'offset', (int)$_GET['offset']);
2527  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2528  $this->ctrl->setParameter($this, 'action', $_GET['action']);
2529  $tpl->setVariable('FORM', $oEditReplyForm->getHTML());
2530  $this->ctrl->clearParameters($this);
2531 
2532  } // if ($_GET['action'] == 'showreply' || $_GET['action'] == 'showedit')
2533  else if(!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'delete')
2534  {
2535  if($this->is_moderator ||
2536  ($node->isOwner($ilUser->getId()) && !$node->hasReplies()) &&
2537  $ilUser->getId() != ANONYMOUS_USER_ID)
2538  {
2539  // confirmation: delete
2540  $tpl->setVariable('FORM', $this->getDeleteFormHTML());
2541  }
2542  } // else if ($_GET['action'] == 'delete')
2543  else if(!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'censor')
2544  {
2545  if($this->is_moderator)
2546  {
2547  // confirmation: censor / remove censorship
2548  $tpl->setVariable('FORM', $this->getCensorshipFormHTML());
2549  }
2550  }
2551  else if (!$this->objCurrentTopic->isClosed() && $this->displayConfirmPostActivation())
2552  {
2553  if ($this->is_moderator)
2554  {
2555  // confirmation: activate
2556  $tpl->setVariable('FORM', $this->getActivationFormHTML());
2557  }
2558  }
2559  }
2560  } // if ($this->objCurrentPost->getId() == $node->getId())
2561 
2562  if ($this->objCurrentPost->getId() != $node->getId() ||
2563  ($_GET['action'] != 'showreply' &&
2564  $_GET['action'] != 'showedit' &&
2565  $_GET['action'] != 'censor' &&
2566  $_GET['action'] != 'delete' &&
2568  ))
2569  {
2570  if($this->is_moderator || $node->isActivated())
2571  {
2572  // button: reply
2573  if(!$this->objCurrentTopic->isClosed() && $node->isActivated() &&
2574  $ilAccess->checkAccess('add_reply', '', (int)$_GET['ref_id']) &&
2575  !$node->isCensored()
2576  )
2577  {
2578  $this->ctrl->setParameter($this, 'action', 'showreply');
2579  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
2580  $this->ctrl->setParameter($this, 'offset', $Start);
2581  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2582  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
2583 
2584  $actions['reply_to_postings'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
2585 
2586  $this->ctrl->clearParameters($this);
2587  }
2588 
2589  // button: edit article
2590  if (!$this->objCurrentTopic->isClosed() && $node->isActivated() &&
2591  ($node->isOwner($ilUser->getId()) || $this->is_moderator) &&
2592  !$node->isCensored() &&
2593  $ilUser->getId() != ANONYMOUS_USER_ID)
2594  {
2595  $this->ctrl->setParameter($this, 'action', 'showedit');
2596  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
2597  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
2598  $this->ctrl->setParameter($this, 'offset', $Start);
2599  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2600 
2601  $actions['edit'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
2602 
2603  $this->ctrl->clearParameters($this);
2604  }
2605 
2606  // button: mark read
2607  if ($ilUser->getId() != ANONYMOUS_USER_ID && !$node->isPostRead())
2608  {
2609  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
2610  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
2611  $this->ctrl->setParameter($this, 'offset', $Start);
2612  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2613  $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
2614 
2615  $actions['frm_mark_as_read'] = $this->ctrl->getLinkTarget($this, 'markPostRead', $node->getId());
2616 
2617  $this->ctrl->clearParameters($this);
2618  }
2619 
2620  // button: mark unread
2621  if ($ilUser->getId() != ANONYMOUS_USER_ID &&
2622  $node->isPostRead())
2623  {
2624  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
2625  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
2626  $this->ctrl->setParameter($this, 'offset', $Start);
2627  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2628  $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
2629 
2630  $actions['frm_mark_as_unread'] = $this->ctrl->getLinkTarget($this, 'markPostUnread', $node->getId());
2631 
2632  $this->ctrl->clearParameters($this);
2633  }
2634 
2635  // button: print
2636  if (!$node->isCensored())
2637  {
2638  $this->ctrl->setParameterByClass('ilforumexportgui', 'print_post', $node->getId());
2639  $this->ctrl->setParameterByClass('ilforumexportgui', 'top_pk', $node->getForumId());
2640  $this->ctrl->setParameterByClass('ilforumexportgui', 'thr_pk', $node->getThreadId());
2641 
2642  $actions['print'] = $this->ctrl->getLinkTargetByClass('ilforumexportgui', 'printPost');
2643 
2644  $this->ctrl->clearParameters($this);
2645  }
2646 
2647  # buttons for every post except the "active"
2648  if (!$this->objCurrentTopic->isClosed() &&
2649  ($this->is_moderator ||
2650  ($node->isOwner($ilUser->getId()) && !$node->hasReplies())) &&
2651  $ilUser->getId() != ANONYMOUS_USER_ID)
2652  {
2653  // button: delete
2654  $this->ctrl->setParameter($this, 'action', 'delete');
2655  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
2656  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
2657  $this->ctrl->setParameter($this, 'offset', $Start);
2658  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2659 
2660  $actions['delete'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
2661 
2662  $this->ctrl->clearParameters($this);
2663  }
2664 
2665  if (!$this->objCurrentTopic->isClosed() && $this->is_moderator)
2666  {
2667  // button: censor
2668  $this->ctrl->setParameter($this, 'action', 'censor');
2669  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
2670  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
2671  $this->ctrl->setParameter($this, 'offset', $Start);
2672  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2673  if($node->isCensored())
2674  {
2675  $actions['frm_revoke_censorship'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
2676  }
2677  else
2678  {
2679  $actions['frm_censorship'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
2680  }
2681 
2682  $this->ctrl->clearParameters($this);
2683 
2684  // button: activation/deactivation
2685  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
2686  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
2687  $this->ctrl->setParameter($this, 'offset', $Start);
2688  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2689 
2690  if (!$node->isActivated())
2691  {
2692  $actions['activate_post'] = $this->ctrl->getLinkTarget($this, 'askForPostActivation', $node->getId());
2693  }
2694 
2695  $this->ctrl->clearParameters($this);
2696  }
2697  }
2698  } // if ($this->objCurrentPost->getId() != $node->getId())
2699 
2700  // download post attachments
2701  $tmp_file_obj = new ilFileDataForum($forumObj->getId(), $node->getId());
2702  $attachments_of_node = $tmp_file_obj->getFilesOfPost();
2703  if(count($attachments_of_node))
2704  {
2705  if ($node->getId() != $this->objCurrentPost->getId() || $_GET['action'] != 'showedit')
2706  {
2707  foreach($attachments_of_node as $file)
2708  {
2709  $tpl->setCurrentBlock('attachment_download_row');
2710  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
2711  $this->ctrl->setParameter($this, 'file', $file['md5']);
2712  $tpl->setVariable('HREF_DOWNLOAD', $this->ctrl->getLinkTarget($this, 'viewThread'));
2713  $tpl->setVariable('TXT_FILENAME', $file['name']);
2714  $this->ctrl->clearParameters($this);
2715  $tpl->parseCurrentBlock();
2716  }
2717  $tpl->setCurrentBlock('attachments');
2718  $tpl->setVariable('TXT_ATTACHMENTS_DOWNLOAD',$lng->txt('forums_attachments'));
2719  include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
2720  $tpl->setVariable('DOWNLOAD_IMG', ilGlyphGUI::get(ilGlyphGUI::ATTACHMENT, $lng->txt('forums_download_attachment')));
2721  $tpl->parseCurrentBlock();
2722  }
2723  }
2724 
2725  $tpl->setCurrentBlock('posts_row');
2726  if(count($actions) > 0)
2727  {
2728  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
2729  $action_button = ilSplitButtonGUI::getInstance();
2730 
2731  $i = 0;
2732  foreach($actions as $lng_id => $url)
2733  {
2734  if($i == 0)
2735  {
2736  $sb_item = ilLinkButton::getInstance();
2737  $sb_item->setCaption($lng_id);
2738  $sb_item->setUrl($url);
2739 
2740  $action_button->setDefaultButton($sb_item);
2741  }
2742  else
2743  {
2744  $sb_item = ilLinkButton::getInstance();
2745  $sb_item->setCaption($lng_id);
2746  $sb_item->setUrl($url);
2747 
2748  $action_button->addMenuItem(new ilButtonToSplitButtonMenuItemAdapter($sb_item));
2749  }
2750 
2751  ++$i;
2752  }
2753 
2754  $tpl->setVariable('COMMANDS', $action_button->render());
2755  }
2756  // anker for every post
2757  $tpl->setVariable('POST_ANKER', $node->getId());
2758 
2759  //permanent link for every post
2760  // $tpl->setVariable('PERMA_LINK', ILIAS_HTTP_PATH."/goto.php?target="."frm"."_".$this->object->getRefId()."_".$node->getThreadId()."_".$node->getId()."&client_id=".CLIENT_ID);
2761  $tpl->setVariable('TXT_PERMA_LINK', $lng->txt('perma_link'));
2762  $tpl->setVariable('PERMA_TARGET', '_top');
2763 
2764  if(!$node->isActivated() && !$this->objCurrentTopic->isClosed() && $this->is_moderator)
2765  {
2766  $rowCol = 'ilPostingNeedsActivation';
2767  }
2768  else if($this->objProperties->getMarkModeratorPosts() == 1)
2769  {
2770  if($node->getIsAuthorModerator() === null && $is_moderator = ilForum::_isModerator($_GET['ref_id'], $node->getPosAuthorId()))
2771  {
2772  $rowCol = 'ilModeratorPosting';
2773  }
2774  elseif($node->getIsAuthorModerator())
2775  {
2776  $rowCol = 'ilModeratorPosting';
2777  }
2778  else $rowCol = ilUtil::switchColor($z, 'tblrow1', 'tblrow2');
2779  }
2780  else $rowCol = ilUtil::switchColor($z, 'tblrow1', 'tblrow2');
2781  if (( $_GET['action'] != 'delete' && $_GET['action'] != 'censor' &&
2783  )
2784  || $this->objCurrentPost->getId() != $node->getId())
2785  {
2786  $tpl->setVariable('ROWCOL', ' '.$rowCol);
2787  }
2788  else
2789  {
2790  // highlight censored posts
2791  $rowCol = 'tblrowmarked';
2792  }
2793 
2794  // post is censored
2795  if ($node->isCensored())
2796  {
2797  // display censorship advice
2798  if ($_GET['action'] != 'censor')
2799  {
2800  $tpl->setVariable('TXT_CENSORSHIP_ADVICE', $this->lng->txt('post_censored_comment_by_moderator'));
2801  }
2802 
2803  // highlight censored posts
2804  $rowCol = 'tblrowmarked';
2805  }
2806 
2807  // set row color
2808  $tpl->setVariable('ROWCOL', ' '.$rowCol);
2809  // if post is not activated display message for the owner
2810  if(!$node->isActivated() && $node->isOwner($ilUser->getId()))
2811  {
2812  $tpl->setVariable('POST_NOT_ACTIVATED_YET', $this->lng->txt('frm_post_not_activated_yet'));
2813  }
2814 
2815  // Author
2816  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
2817  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
2818  $backurl = urlencode($this->ctrl->getLinkTarget($this, 'viewThread', $node->getId()));
2819  $this->ctrl->clearParameters($this);
2820 
2821  $this->ctrl->setParameter($this, 'backurl', $backurl);
2822  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
2823  $this->ctrl->setParameter($this, 'user', $node->getDisplayUserId());
2824 
2825  require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
2826  $authorinfo = new ilForumAuthorInformation(
2827  $node->getPosAuthorId(),
2828  $node->getDisplayUserId(),
2829  $node->getUserAlias(),
2830  $node->getImportName(),
2831  array(
2832  'href' => $this->ctrl->getLinkTarget($this, 'showUser')
2833  )
2834  );
2835 
2836  $this->ctrl->clearParameters($this);
2837 
2838  if($authorinfo->hasSuffix())
2839  {
2840  $tpl->setVariable('AUTHOR', $authorinfo->getSuffix());
2841  $tpl->setVariable('USR_NAME', $node->getUserAlias());
2842  }
2843  else
2844  {
2845  $tpl->setVariable('AUTHOR', $authorinfo->getLinkedAuthorShortName());
2846  if($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized())
2847  {
2848  $tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true));
2849  }
2850  }
2851 
2852  $tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture());
2853  if($authorinfo->getAuthor()->getId() && ilForum::_isModerator((int)$_GET['ref_id'], $node->getPosAuthorId()))
2854  {
2855  if($authorinfo->getAuthor()->getGender() == 'f')
2856  {
2857  $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_f'));
2858  }
2859  else if($authorinfo->getAuthor()->getGender() == 'm')
2860  {
2861  $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_m'));
2862  }
2863  }
2864 
2865  // get create- and update-dates
2866  if ($node->getUpdateUserId() > 0)
2867  {
2868  $spanClass = '';
2869 
2870  // last update from moderator?
2871  $posMod = $frm->getModeratorFromPost($node->getId());
2872 
2873  if (is_array($posMod) && $posMod['top_mods'] > 0)
2874  {
2875  $MODS = $rbacreview->assignedUsers($posMod['top_mods']);
2876 
2877  if (is_array($MODS))
2878  {
2879  if (in_array($node->getUpdateUserId(), $MODS))
2880  $spanClass = 'moderator_small';
2881  }
2882  }
2883 
2884  $node->setChangeDate($node->getChangeDate());
2885 
2886  if ($spanClass == '') $spanClass = 'small';
2887 
2888  $this->ctrl->setParameter($this, 'backurl', $backurl);
2889  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
2890  $this->ctrl->setParameter($this, 'user', $node->getUpdateUserId());
2891 
2892  $update_user_id = $node->getUpdateUserId();
2893  if($node->getPosAuthorId() == $node->getUpdateUserId()
2894  && $node->getDisplayUserId() == 0)
2895  {
2896  $update_user_id = $node->getDisplayUserId();
2897  }
2898  require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
2899  $authorinfo = new ilForumAuthorInformation(
2900  $node->getPosAuthorId(),
2901  $update_user_id,
2902  $node->getUserAlias(),
2903  $node->getImportName(),
2904  array(
2905  'href' => $this->ctrl->getLinkTarget($this, 'showUser')
2906  )
2907  );
2908  $this->ctrl->clearParameters($this);
2909 
2910  $tpl->setVariable('POST_UPDATE_TXT', $lng->txt('edited_on').': '.$frm->convertDate($node->getChangeDate()).' - '.strtolower($lng->txt('by')));
2911  $tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
2912  if($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix())
2913  {
2914  $tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true));
2915  }
2916 
2917  } // if ($node->getUpdateUserId() > 0)*/
2918  // Author end
2919 
2920  // prepare post
2921  $node->setMessage($frm->prepareText($node->getMessage()));
2922 
2923  if($ilUser->getId() == ANONYMOUS_USER_ID ||
2924  $node->isPostRead())
2925  {
2926  $tpl->setVariable('SUBJECT', $node->getSubject());
2927  }
2928  else
2929  {
2930  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
2931  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
2932  $this->ctrl->setParameter($this, 'offset', $Start);
2933  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2934  $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
2935  $mark_post_target = $this->ctrl->getLinkTarget($this, 'markPostRead', $node->getId());
2936 
2937  $tpl->setVariable('SUBJECT',"<a href=\"".$mark_post_target."\"><b>".$node->getSubject()."</b></a>");
2938 
2939  }
2940 
2941  $tpl->setVariable('POST_DATE', $frm->convertDate($node->getCreateDate()));
2942 
2943  if (!$node->isCensored() ||
2944  ($this->objCurrentPost->getId() == $node->getId() && $_GET['action'] == 'censor'))
2945  {
2946  // post from moderator?
2947  $modAuthor = $frm->getModeratorFromPost($node->getId());
2948 
2949  $spanClass = "";
2950 
2951  if (is_array($modAuthor) && $modAuthor['top_mods'] > 0)
2952  {
2953  unset($MODS);
2954 
2955  $MODS = $rbacreview->assignedUsers($modAuthor['top_mods']);
2956 
2957  if (is_array($MODS))
2958  {
2959  if (in_array($node->getDisplayUserId(), $MODS))
2960  $spanClass = 'moderator';
2961  }
2962  }
2963 
2964  // possible bugfix for mantis #8223
2965  if($node->getMessage() == strip_tags($node->getMessage()))
2966  {
2967  // We can be sure, that there are not html tags
2968  $node->setMessage(nl2br($node->getMessage()));
2969  }
2970 
2971  if ($spanClass != "")
2972  {
2973  $tpl->setVariable('POST', "<span class=\"".$spanClass."\">".ilRTE::_replaceMediaObjectImageSrc($node->getMessage(), 1)."</span>");
2974  }
2975  else
2976  {
2977  $tpl->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($node->getMessage(), 1));
2978  }
2979  }
2980  else
2981  {
2982  $tpl->setVariable('POST', "<span class=\"moderator\">".nl2br($node->getCensorshipComment())."</span>");
2983  }
2984 
2985  $tpl->parseCurrentBlock();
2986 
2987  }
2988  $z++;
2989  }
2990 
2991  $first_node = $this->objCurrentTopic->getFirstPostNode();
2992  if(
2993  $first_node instanceof ilForumPost &&
2994  in_array($this->ctrl->getCmd(), array('createToLevelPost', 'saveTopLevelPost', 'quoteTopLevelPost')) &&
2995  !$this->objCurrentTopic->isClosed() &&
2996  $ilAccess->checkAccess('add_reply', '', (int)$_GET['ref_id']))
2997  {
2998  // Important: Don't separate the following two lines (very fragile code ...)
2999  $this->objCurrentPost->setId($first_node->getId());
3000  $form = $this->getReplyEditForm();
3001 
3002  if($this->ctrl->getCmd() == 'saveTopLevelPost')
3003  {
3004  $form->setValuesByPost();
3005  }
3006  else if($this->ctrl->getCmd() == 'quoteTopLevelPost')
3007  {
3008  require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
3009  $authorinfo = new ilForumAuthorInformation(
3010  $first_node->getPosAuthorId(),
3011  $first_node->getDisplayUserId(),
3012  $first_node->getUserAlias(),
3013  $first_node->getImportName()
3014  );
3015 
3016  $form->setValuesByPost();
3017  $form->getItemByPostVar('message')->setValue(
3019  $frm->prepareText($first_node->getMessage(), 1, $authorinfo->getAuthorName())."\n".$form->getInput('message'), 1
3020  )
3021  );
3022  }
3023  $this->ctrl->setParameter($this, 'pos_pk', $first_node->getId());
3024  $this->ctrl->setParameter($this, 'thr_pk', $first_node->getThreadId());
3025  $jsTpl = new ilTemplate('tpl.forum_post_quoation_ajax_handler.html', true, true, 'Modules/Forum');
3026  $jsTpl->setVariable('IL_FRM_QUOTE_CALLBACK_SRC',
3027  $this->ctrl->getLinkTarget($this, 'getQuotationHTMLAsynch', '', true));
3028  $this->ctrl->clearParameters($this);
3029  $tpl->setVariable('BOTTOM_FORM_ADDITIONAL_JS', $jsTpl->get());;
3030  $tpl->setVariable('BOTTOM_FORM', $form->getHTML());
3031  }
3032  }
3033  else
3034  {
3035  $tpl->setCurrentBlock('posts_no');
3036  $tpl->setVariable('TXT_MSG_NO_POSTS_AVAILABLE', $lng->txt('forums_posts_not_available'));
3037  $tpl->parseCurrentBlock();
3038  }
3039 
3040  if($bottom_toolbar_split_button_items)
3041  {
3042  $bottom_split_button = ilSplitButtonGUI::getInstance();
3043  $i = 0;
3044  foreach($bottom_toolbar_split_button_items as $item)
3045  {
3046  if($i == 0)
3047  {
3048  $bottom_split_button->setDefaultButton($item);
3049  }
3050  else
3051  {
3052  $bottom_split_button->addMenuItem(new ilButtonToSplitButtonMenuItemAdapter($item));
3053  }
3054 
3055  ++$i;
3056  }
3057  $bottom_toolbar->addStickyItem($bottom_split_button);
3058  }
3059 
3060  $ilToolbar = clone $bottom_toolbar;
3061 
3062  if($bottom_toolbar_split_button_items)
3063  {
3064  $bottom_toolbar->addSeparator();
3065  }
3066 
3067  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
3068  $to_top_button = ilLinkButton::getInstance();
3069  $to_top_button->setCaption('top_of_page');
3070  $to_top_button->setUrl('#frm_page_top');
3071  $bottom_toolbar->addButtonInstance($to_top_button);
3072  $tpl->setVariable('TOOLBAR_BOTTOM', $bottom_toolbar->getHTML());
3073 
3074  include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
3075  $permalink = new ilPermanentLinkGUI('frm', $this->object->getRefId(), '_'.$this->objCurrentTopic->getId());
3076  $this->tpl->setVariable('PRMLINK', $permalink->getHTML());
3077 
3078  if($this->isHierarchicalView())
3079  {
3080  $tpl->setLeftNavContent($this->getForumExplorer());
3081  }
3082 
3083  return true;
3084  }
3085 
3086  private function getModifiedReOnSubject($on_reply = false)
3087  {
3088  $subject = $this->objCurrentPost->getSubject();
3089  $re_txt = $this->lng->txt('post_reply');
3090 
3091  $re_txt_with_num = str_replace(':', '(',$re_txt);
3092  $search_length = strlen($re_txt_with_num);
3093  $comp = substr_compare($re_txt_with_num, substr($subject, 0 , $search_length), 0, $search_length);
3094 
3095  if($comp == 0)
3096  {
3097  $modified_subject = $subject;
3098  if($on_reply == true)
3099  {
3100  // i.e. $subject = "Re(12):"
3101  $str_pos_start = strpos($subject, '(');
3102  $str_pos_end = strpos($subject, ')');
3103 
3104  $length = ((int)$str_pos_end - (int)$str_pos_start);
3105  $str_pos_start++;
3106  $txt_number = substr($subject, $str_pos_start, $length - 1);
3107 
3108  if(is_numeric($txt_number))
3109  {
3110  $re_count = (int)$txt_number + 1;
3111  $modified_subject = substr($subject, 0, $str_pos_start) . $re_count . substr($subject, $str_pos_end);
3112  }
3113  }
3114  }
3115  else
3116  {
3117  $re_count = substr_count($subject, $re_txt);
3118  if($re_count >= 1 && $on_reply == true)
3119  {
3120  $subject = str_replace($re_txt, '', $subject);
3121 
3122  // i.e. $subject = "Re: Re: Re: ... " -> "Re(4):"
3123  $re_count++;
3124  $modified_subject = sprintf($this->lng->txt('post_reply_count'), $re_count).' '.trim($subject);
3125  }
3126  else if($re_count >= 1 && $on_reply == false)
3127  {
3128  // possibility to modify the subject only for output
3129  // i.e. $subject = "Re: Re: Re: ... " -> "Re(3):"
3130  $modified_subject = sprintf($this->lng->txt('post_reply_count'), $re_count).' '.trim($subject);
3131  }
3132  else if($re_count == 0)
3133  {
3134  // the first reply to a thread
3135  $modified_subject = $this->lng->txt('post_reply').' '. $this->objCurrentPost->getSubject();
3136  }
3137  }
3138  return $modified_subject;
3139  }
3140 
3141  public function showUserObject()
3142  {
3146  global $tpl;
3147 
3148  // we could actually call ilpublicuserprofilegui directly, this method
3149  // is not needed - but sadly used throughout the forum code
3150  // see above in execute command
3151 
3152  include_once 'Services/User/classes/class.ilPublicUserProfileGUI.php';
3153  $profile_gui = new ilPublicUserProfileGUI($_GET['user']);
3154  $add = $this->getUserProfileAdditional($_GET['ref_id'], $_GET['user']);
3155  $profile_gui->setAdditional($add);
3156  $profile_gui->setBackUrl($_GET['backurl']);
3157  $tpl->setContent($this->ctrl->getHTML($profile_gui));
3158  }
3159 
3160  protected function getUserProfileAdditional($a_forum_ref_id, $a_user_id)
3161  {
3166  global $lng, $ilAccess;
3167 
3168  if(!$ilAccess->checkAccess('read', '', $a_forum_ref_id))
3169  {
3170  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
3171  }
3172 
3173  require_once 'Modules/Forum/classes/class.ilForum.php';
3174 
3175  $lng->loadLanguageModule('forum');
3176 
3180  $ref_obj = ilObjectFactory::getInstanceByRefId($a_forum_ref_id);
3181  if($ref_obj->getType() == 'frm')
3182  {
3183  $forumObj = new ilObjForum($a_forum_ref_id);
3184  $frm = $forumObj->Forum;
3185  $frm->setForumId($forumObj->getId());
3186  $frm->setForumRefId($forumObj->getRefId());
3187  }
3188  else
3189  {
3190  $frm = new ilForum();
3191  }
3192 
3193  // count articles of user
3194  if($ilAccess->checkAccess('moderate_frm', '', $a_forum_ref_id))
3195  {
3196  $numPosts = $frm->countUserArticles(addslashes($a_user_id));
3197  }
3198  else
3199  {
3200  $numPosts = $frm->countActiveUserArticles(addslashes($a_user_id));
3201  }
3202 
3203  return array($lng->txt('forums_posts') => $numPosts);
3204  }
3205 
3206  public function performThreadsActionObject()
3207  {
3211  global $ilUser;
3212 
3213  unset($_SESSION['threads2move']);
3214 
3215  if(isset($_POST['thread_ids']) && is_array($_POST['thread_ids']))
3216  {
3217  if(isset($_POST['selected_cmd']) && $_POST['selected_cmd'] == 'move')
3218  {
3219  if($this->is_moderator)
3220  {
3221  $_SESSION['threads2move'] = $_POST['thread_ids'];
3222  $this->moveThreadsObject();
3223  }
3224  }
3225  else if($_POST['selected_cmd'] == 'enable_notifications' && $this->ilias->getSetting('forum_notification') != 0)
3226  {
3227  for($i = 0; $i < count($_POST['thread_ids']); $i++)
3228  {
3229  $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3230  $tmp_obj->enableNotification($ilUser->getId());
3231  unset($tmp_obj);
3232  }
3233 
3234  $this->ctrl->redirect($this, 'showThreads');
3235  }
3236  else if($_POST['selected_cmd'] == 'disable_notifications' && $this->ilias->getSetting('forum_notification') != 0)
3237  {
3238  for($i = 0; $i < count($_POST['thread_ids']); $i++)
3239  {
3240  $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3241  $tmp_obj->disableNotification($ilUser->getId());
3242  unset($tmp_obj);
3243  }
3244 
3245  $this->ctrl->redirect($this, 'showThreads');
3246  }
3247 
3248  else if($_POST['selected_cmd'] == 'close')
3249  {
3250  if($this->is_moderator)
3251  {
3252  for($i = 0; $i < count($_POST['thread_ids']); $i++)
3253  {
3254  $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3255  $tmp_obj->close();
3256  unset($tmp_obj);
3257  }
3258  }
3259  ilUtil::sendSuccess($this->lng->txt('selected_threads_closed'), true);
3260  $this->ctrl->redirect($this, 'showThreads');
3261  }
3262  else if($_POST['selected_cmd'] == 'reopen')
3263  {
3264  if($this->is_moderator)
3265  {
3266  for($i = 0; $i < count($_POST['thread_ids']); $i++)
3267  {
3268  $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3269  $tmp_obj->reopen();
3270  unset($tmp_obj);
3271  }
3272  }
3273 
3274  ilUtil::sendSuccess($this->lng->txt('selected_threads_reopened'), true);
3275  $this->ctrl->redirect($this, 'showThreads');
3276  }
3277  else if($_POST['selected_cmd'] == 'makesticky')
3278  {
3279  if($this->is_moderator)
3280  {
3281  $message = $this->lng->txt('sel_threads_make_sticky');
3282 
3283  for($i = 0; $i < count($_POST['thread_ids']); $i++)
3284  {
3285  $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3286  $makeSticky = $tmp_obj->makeSticky();
3287 
3288  if(!$makeSticky)
3289  {
3290  $message = $this->lng->txt('sel_threads_already_sticky');
3291  }
3292 
3293  unset($tmp_obj);
3294  }
3295  }
3296  if($message != null)
3297  {
3298  ilUtil::sendInfo($message,true);
3299  }
3300  $this->ctrl->redirect($this, 'showThreads');
3301  }
3302  else if($_POST['selected_cmd'] == 'unmakesticky')
3303  {
3304  if($this->is_moderator)
3305  {
3306  $message = $this->lng->txt('sel_threads_make_unsticky');
3307  for($i = 0; $i < count($_POST['thread_ids']); $i++)
3308  {
3309  $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3310  $unmakeSticky = $tmp_obj->unmakeSticky();
3311  if(!$unmakeSticky)
3312  {
3313  $message = $this->lng->txt('sel_threads_already_unsticky');
3314  }
3315 
3316  unset($tmp_obj);
3317  }
3318  }
3319 
3320  if($message != null)
3321  {
3322  ilUtil::sendInfo($message,true);
3323  }
3324  $this->ctrl->redirect($this, 'showThreads');
3325  }
3326  else if($_POST['selected_cmd'] == 'editThread')
3327  {
3328  if($this->is_moderator)
3329  {
3330  $count = count($_POST['thread_ids']);
3331  if($count != 1)
3332  {
3333  ilUtil::sendInfo($this->lng->txt('select_max_one_thread'), true);
3334  $this->ctrl->redirect($this, 'showThreads');
3335  }
3336  else
3337  {
3338  foreach($_POST['thread_ids'] as $thread_id)
3339  {
3340  return $this->editThreadObject($thread_id, null);
3341  }
3342  }
3343  }
3344 
3345  $this->ctrl->redirect($this, 'showThreads');
3346  }
3347  else if($_POST['selected_cmd'] == 'html')
3348  {
3349  $this->ctrl->setCmd('exportHTML');
3350  $this->ctrl->setCmdClass('ilForumExportGUI');
3351  $this->executeCommand();
3352  }
3353  else if($_POST['selected_cmd'] == 'confirmDeleteThreads')
3354  {
3355  $this->confirmDeleteThreads();
3356  }
3357  else if($_POST['selected_cmd'] == 'merge')
3358  {
3359  $this->mergeThreadsObject();
3360  }
3361  else
3362  {
3363  ilUtil::sendInfo($this->lng->txt('topics_please_select_one_action'), true);
3364  $this->ctrl->redirect($this, 'showThreads');
3365  }
3366  }
3367  else
3368  {
3369  ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'), true);
3370  $this->ctrl->redirect($this, 'showThreads');
3371  }
3372  }
3373 
3374  public function performMoveThreadsObject()
3375  {
3380  global $lng, $ilObjDataCache;
3381 
3382  if(!$this->is_moderator)
3383  {
3384  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
3385  }
3386 
3387  if(isset($_POST['frm_ref_id']) && (int) $_POST['frm_ref_id'])
3388  {
3389  $this->object->Forum->moveThreads((array) $_SESSION['threads2move'], $this->object->getRefId(), $ilObjDataCache->lookupObjId($_POST['frm_ref_id']));
3390 
3391  unset($_SESSION['threads2move']);
3392  ilUtil::sendInfo($lng->txt('threads_moved_successfully'), true);
3393  $this->ctrl->redirect($this, 'showThreads');
3394  }
3395  else
3396  {
3397  ilUtil::sendInfo($lng->txt('no_forum_selected'));
3398  $this->moveThreadsObject();
3399  }
3400  }
3401 
3402  public function cancelMoveThreadsObject()
3403  {
3407  global $lng;
3408 
3409  if(!$this->is_moderator)
3410  {
3411  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
3412  }
3413 
3414  unset($_SESSION['threads2move']);
3415 
3416  $this->ctrl->redirect($this, 'showThreads');
3417  }
3418 
3419  public function moveThreadsObject()
3420  {
3426  global $lng, $ilToolbar, $tree;
3427 
3428  if(!$this->is_moderator)
3429  {
3430  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
3431  }
3432 
3433  $threads2move = $_SESSION['threads2move'];
3434  if(!count($threads2move))
3435  {
3436  ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'), true);
3437  $this->ctrl->redirect($this, 'showThreads');
3438  }
3439 
3440  require_once 'Modules/Forum/classes/class.ilForumMoveTopicsExplorer.php';
3441  $exp = new ilForumMoveTopicsExplorer($this, 'moveThreads');
3442  $exp->setPathOpen($this->object->getRefId());
3443  $exp->setNodeSelected(isset($_POST['frm_ref_id']) && (int)$_POST['frm_ref_id'] ? (int)$_POST['frm_ref_id'] : 0);
3444  $exp->setCurrentFrmRefId($this->object->getRefId());
3445  $exp->setHighlightedNode($this->object->getRefId());
3446  if(!$exp->handleCommand())
3447  {
3448  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_move.html', 'Modules/Forum');
3449 
3450  if(!$this->hideToolbar())
3451  $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this));
3452 
3453  $tblThr = new ilTable2GUI($this);
3454  $tblThr->setId('il_frm_thread_move_table_'.$this->object->getRefId());
3455  $tblThr->setTitle($this->lng->txt('move_chosen_topics'));
3456  $tblThr->addColumn($this->lng->txt('subject'), 'top_name', '100%');
3457  $tblThr->disable('header');
3458  $tblThr->disable('footer');
3459  $tblThr->disable('linkbar');
3460  $tblThr->disable('sort');
3461  $tblThr->disable('linkbar');
3462  $tblThr->setLimit(PHP_INT_MAX);
3463  $tblThr->setRowTemplate('tpl.forums_threads_move_thr_row.html', 'Modules/Forum');
3464  $tblThr->setDefaultOrderField('is_sticky');
3465  $counter = 0;
3466  $result = array();
3467  foreach($threads2move as $thr_pk)
3468  {
3469  $objCurrentTopic = new ilForumTopic($thr_pk, $this->is_moderator);
3470 
3471  $result[$counter]['num'] = $counter + 1;
3472  $result[$counter]['thr_subject'] = $objCurrentTopic->getSubject();
3473 
3474  unset($objCurrentTopic);
3475  ++$counter;
3476  }
3477  $tblThr->setData($result);
3478  $this->tpl->setVariable('THREADS_TABLE', $tblThr->getHTML());
3479 
3480  $this->tpl->setVariable('FRM_SELECTION_TREE', $exp->getHTML());
3481  $this->tpl->setVariable('CMD_SUBMIT', 'performMoveThreads');
3482  $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('move'));
3483  $this->tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this, 'performMoveThreads'));
3484  }
3485 
3486  return true;
3487  }
3488 
3489  private function initTopicCreateForm()
3490  {
3497  global $ilUser, $rbacsystem, $ilias, $ilSetting;
3498 
3499  $this->create_topic_form_gui = new ilPropertyFormGUI();
3500 
3501  $this->create_topic_form_gui->setTitle($this->lng->txt('forums_new_thread'));
3502  $this->create_topic_form_gui->setTitleIcon(ilUtil::getImagePath('icon_frm.svg'));
3503  $this->create_topic_form_gui->setTableWidth('100%');
3504 
3505  // form action
3506  $this->create_topic_form_gui->setFormAction($this->ctrl->getFormAction($this, 'addThread'));
3507 
3508  if($this->objProperties->isAnonymized() == 1)
3509  {
3510  $alias_gui = new ilTextInputGUI($this->lng->txt('forums_your_name'), 'alias');
3511  $alias_gui->setInfo($this->lng->txt('forums_use_alias'));
3512  $alias_gui->setMaxLength(255);
3513  $alias_gui->setSize(50);
3514  $this->create_topic_form_gui->addItem($alias_gui);
3515  }
3516  else
3517  {
3518  $alias_gui = new ilNonEditableValueGUI($this->lng->txt('forums_your_name'), 'alias');
3519  $alias_gui->setValue($ilUser->getLogin());
3520  $this->create_topic_form_gui->addItem($alias_gui);
3521  }
3522 
3523  // topic
3524  $subject_gui = new ilTextInputGUI($this->lng->txt('forums_thread'), 'subject');
3525  $subject_gui->setMaxLength(255);
3526  $subject_gui->setSize(50);
3527  $subject_gui->setRequired(true);
3528  $this->create_topic_form_gui->addItem($subject_gui);
3529 
3530  // message
3531  $post_gui = new ilTextAreaInputGUI($this->lng->txt('forums_the_post'), 'message');
3532  $post_gui->setCols(50);
3533  $post_gui->setRows(15);
3534  $post_gui->setRequired(true);
3535  $post_gui->setUseRte(true);
3536  $post_gui->addPlugin('latex');
3537  $post_gui->addButton('latex');
3538  $post_gui->addButton('pastelatex');
3539  $post_gui->addPlugin('ilfrmquote');
3540  //$post_gui->addPlugin('code');
3541  $post_gui->removePlugin('advlink');
3542  $post_gui->usePurifier(true);
3543  $post_gui->setRTERootBlockElement('');
3544  $post_gui->setRTESupport($ilUser->getId(), 'frm~', 'frm_post', 'tpl.tinymce_frm_post.html', false, '3.5.11');
3545  $post_gui->disableButtons(array(
3546  'charmap',
3547  'undo',
3548  'redo',
3549  'justifyleft',
3550  'justifycenter',
3551  'justifyright',
3552  'justifyfull',
3553  'anchor',
3554  'fullscreen',
3555  'cut',
3556  'copy',
3557  'paste',
3558  'pastetext',
3559  'formatselect'
3560  ));
3561 
3562  // purifier
3563  require_once 'Services/Html/classes/class.ilHtmlPurifierFactory.php';
3564  $post_gui->setPurifier(ilHtmlPurifierFactory::_getInstanceByType('frm_post'));
3565  $this->create_topic_form_gui->addItem($post_gui);
3566 
3567  if($this->objProperties->isFileUploadAllowed())
3568  {
3569  $fi = new ilFileWizardInputGUI($this->lng->txt('forums_attachments_add'), 'userfile');
3570  $fi->setFilenames(array(0 => ''));
3571  $this->create_topic_form_gui->addItem($fi);
3572  }
3573 
3574  include_once 'Services/Mail/classes/class.ilMail.php';
3575  $umail = new ilMail($ilUser->getId());
3576  // catch hack attempts
3577  if($rbacsystem->checkAccess('internal_mail', $umail->getMailObjectReferenceId()) &&
3578  !$this->objProperties->isAnonymized())
3579  {
3580  // direct notification
3581  $dir_notification_gui = new ilCheckboxInputGUI($this->lng->txt('forum_direct_notification'), 'notify');
3582  $dir_notification_gui->setInfo($this->lng->txt('forum_notify_me_directly'));
3583  $dir_notification_gui->setValue(1);
3584  $this->create_topic_form_gui->addItem($dir_notification_gui);
3585 
3586  if($ilias->getSetting('forum_notification') != 0)
3587  {
3588  // gen. notification
3589  $gen_notification_gui = new ilCheckboxInputGUI($this->lng->txt('forum_general_notification'), 'notify_posts');
3590  $gen_notification_gui->setInfo($this->lng->txt('forum_notify_me_generally'));
3591  $gen_notification_gui->setValue(1);
3592  $this->create_topic_form_gui->addItem($gen_notification_gui);
3593  }
3594  }
3595 
3596  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
3597  if(
3598  $ilUser->isAnonymous() &&
3599  !$ilUser->isCaptchaVerified() &&
3600  ilCaptchaUtil::isActiveForForum()
3601  )
3602  {
3603  require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
3604  $captcha = new ilCaptchaInputGUI($this->lng->txt('cont_captcha_code'), 'captcha_code');
3605  $captcha->setRequired(true);
3606  $this->create_topic_form_gui->addItem($captcha);
3607  }
3608  $this->create_topic_form_gui->addCommandButton('addThread', $this->lng->txt('create'));
3609  $this->create_topic_form_gui->addCommandButton('showThreads', $this->lng->txt('cancel'));
3610  }
3611 
3612  private function setTopicCreateDefaultValues()
3613  {
3614  $this->create_topic_form_gui->setValuesByArray(array(
3615  'subject' => '',
3616  'message' => '',
3617  'userfile' => '',
3618  'notify' => 0,
3619  'notify_posts' => 0
3620  ));
3621  }
3622 
3623  public function createThreadObject()
3624  {
3629  global $ilAccess, $lng;
3630 
3631  if(!$ilAccess->checkAccess('add_thread', '', $this->object->getRefId()))
3632  {
3633  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
3634  }
3635 
3636  $this->initTopicCreateForm();
3637  $this->setTopicCreateDefaultValues();
3638 
3639  $create_form = new ilTemplate('tpl.create_thread_form.html', true, true, 'Modules/Forum');
3640  $create_form->setVariable('CREATE_FORM',$this->create_topic_form_gui->getHTML());
3641  $create_form->parseCurrentBlock();
3642 
3643  $this->tpl->setContent($create_form->get());
3644  }
3645 
3646  public function addThreadObject($a_prevent_redirect = false)
3647  {
3653  global $ilUser, $ilAccess, $lng;
3654 
3655  $frm = $this->object->Forum;
3656  $frm->setForumId($this->object->getId());
3657  $frm->setForumRefId($this->object->getRefId());
3658 
3659  if(!$ilAccess->checkAccess('add_thread', '', $this->object->getRefId()))
3660  {
3661  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
3662  }
3663 
3664  $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
3665 
3666  $topicData = $frm->getOneTopic();
3667 
3668  $this->initTopicCreateForm();
3669  if($this->create_topic_form_gui->checkInput())
3670  {
3671  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
3672  if(
3673  $ilUser->isAnonymous() &&
3674  !$ilUser->isCaptchaVerified() &&
3675  ilCaptchaUtil::isActiveForForum()
3676  )
3677  {
3678  $ilUser->setCaptchaVerified(true);
3679  }
3680 
3681  if($this->objProperties->isAnonymized())
3682  {
3683  if(!strlen($this->create_topic_form_gui->getInput('alias')))
3684  {
3685  $user_alias = $this->lng->txt('forums_anonymous');
3686  }
3687  else
3688  {
3689  $user_alias = $this->create_topic_form_gui->getInput('alias');
3690  }
3691  }
3692  else
3693  {
3694  $user_alias = $ilUser->getLogin();
3695  }
3696 
3697  $status = 1;
3698  if(
3699  $this->objProperties->isPostActivationEnabled() &&
3700  !$this->is_moderator || $this->objCurrentPost->isAnyParentDeactivated()
3701  )
3702  {
3703  $status = 0;
3704  }
3705 
3706  // build new thread
3707  $newPost = $frm->generateThread(
3708  $topicData['top_pk'],
3709  $ilUser->getId(),
3710  ($this->objProperties->isAnonymized() ? 0 : $ilUser->getId()),
3711  $this->handleFormInput($this->create_topic_form_gui->getInput('subject'), false),
3712  ilRTE::_replaceMediaObjectImageSrc($this->create_topic_form_gui->getInput('message'), 0),
3713  $this->create_topic_form_gui->getItemByPostVar('notify') ? (int)$this->create_topic_form_gui->getInput('notify') : 0,
3714  $this->create_topic_form_gui->getItemByPostVar('notify_posts') ? (int)$this->create_topic_form_gui->getInput('notify_posts') : 0,
3715  $user_alias,
3716  '',
3717  $status
3718  );
3719 
3720  if($this->objProperties->isFileUploadAllowed())
3721  {
3722  $file = $_FILES['userfile'];
3723  if(is_array($file) && !empty($file))
3724  {
3725  $tmp_file_obj = new ilFileDataForum($this->object->getId(), $newPost);
3726  $tmp_file_obj->storeUploadedFile($file);
3727  }
3728  }
3729 
3730  // Visit-Counter
3731  $frm->setDbTable('frm_data');
3732  $frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($topicData['top_pk']));
3733  $frm->updateVisits($topicData['top_pk']);
3734 
3735  $frm->setMDB2WhereCondition('thr_top_fk = %s AND thr_subject = %s AND thr_num_posts = 1 ',
3736  array('integer', 'text'), array($topicData['top_pk'], $this->create_topic_form_gui->getInput('subject')));
3737 
3738  // copy temporary media objects (frm~)
3739  include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
3740  $mediaObjects = ilRTE::_getMediaObjects($this->create_topic_form_gui->getInput('message'), 0);
3741  foreach($mediaObjects as $mob)
3742  {
3743  if(ilObjMediaObject::_exists($mob))
3744  {
3745  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
3746  ilObjMediaObject::_saveUsage($mob, 'frm:html', $newPost);
3747  }
3748  }
3749 
3750  $GLOBALS['ilAppEventHandler']->raise(
3751  'Modules/Forum',
3752  'createdPost',
3753  array(
3754  'ref_id' => $this->object->getRefId(),
3755  'post' => new ilForumPost($newPost),
3756  'notify_moderators' => !$status
3757  )
3758  );
3759 
3760  if(!$a_prevent_redirect)
3761  {
3762  ilUtil::sendSuccess($this->lng->txt('forums_thread_new_entry'), true);
3763  $this->ctrl->redirect($this);
3764  }
3765  else
3766  {
3767  return $newPost;
3768  }
3769  }
3770  else
3771  {
3772  $this->create_topic_form_gui->setValuesByPost();
3773 
3774  if(!$this->objProperties->isAnonymized())
3775  {
3776  $this->create_topic_form_gui->getItemByPostVar('alias')->setValue($ilUser->getLogin());
3777  }
3778 
3779  return $this->tpl->setContent($this->create_topic_form_gui->getHTML());
3780  }
3781  }
3782 
3783  public function enableForumNotificationObject()
3784  {
3788  global $ilUser;
3789 
3790  $frm = $this->object->Forum;
3791  $frm->setForumId($this->object->getId());
3792  $frm->enableForumNotification($ilUser->getId());
3793 
3794  if(!$this->objCurrentTopic->getId())
3795  {
3796  ilUtil::sendInfo($this->lng->txt('forums_forum_notification_enabled'));
3797  $this->showThreadsObject();
3798  }
3799  else
3800  {
3801  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3802  ilUtil::sendInfo($this->lng->txt('forums_forum_notification_enabled'), true);
3803  $this->ctrl->redirect($this, 'viewThread');
3804  }
3805  }
3806 
3807  public function disableForumNotificationObject()
3808  {
3812  global $ilUser;
3813 
3814  $frm = $this->object->Forum;
3815  $frm->setForumId($this->object->getId());
3816  $frm->disableForumNotification($ilUser->getId());
3817 
3818  if(!$this->objCurrentTopic->getId())
3819  {
3820  $this->showThreadsObject();
3821  ilUtil::sendInfo($this->lng->txt('forums_forum_notification_disabled'));
3822  }
3823  else
3824  {
3825  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3826  ilUtil::sendInfo($this->lng->txt('forums_forum_notification_disabled'), true);
3827  $this->ctrl->redirect($this, 'viewThread');
3828  }
3829  }
3830 
3831  public function checkEnableColumnEdit()
3832  {
3833  return false;
3834  }
3835 
3836  public function setColumnSettings(ilColumnGUI $column_gui)
3837  {
3842  global $lng, $ilAccess;
3843 
3844  $column_gui->setBlockProperty('news', 'title', $lng->txt('frm_latest_postings'));
3845  $column_gui->setBlockProperty('news', 'prevent_aggregation', true);
3846  $column_gui->setRepositoryMode(true);
3847 
3848  if($ilAccess->checkAccess('write', '', $this->object->getRefId()))
3849  {
3850  $news_set = new ilSetting('news');
3851  $enable_internal_rss = $news_set->get('enable_rss_for_internal');
3852  if($enable_internal_rss)
3853  {
3854  $column_gui->setBlockProperty('news', 'settings', true);
3855  $column_gui->setBlockProperty('news', 'public_notifications_option', true);
3856  }
3857  }
3858  }
3859 
3860 
3861  public function cloneWizardPageObject()
3862  {
3863  global $ilObjDataCache;
3864 
3865  if (!$_POST['clone_source'])
3866  {
3867  ilUtil::sendInfo($this->lng->txt('select_one'));
3868  if (isset($_SESSION['wizard_search_title']))
3869  {
3870  $this->searchCloneSourceObject();
3871  }
3872  else
3873  {
3874  $this->createObject();
3875  }
3876  return false;
3877  }
3878  $source_id = $_POST['clone_source'];
3879 
3880  $new_type = $_REQUEST['new_type'];
3881  $this->ctrl->setParameter($this, 'clone_source', (int) $_POST['clone_source']);
3882  $this->ctrl->setParameter($this, 'new_type', $new_type);
3883 
3884  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.frm_wizard_page.html', 'Modules/Forum');
3885  $this->tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this));
3886  $this->tpl->setVariable('TYPE_IMG', ilUtil::getImagePath('icon_'.$new_type.'.svg'));
3887  $this->tpl->setVariable('ALT_IMG', $this->lng->txt('obj_'.$new_type));
3888  $this->tpl->setVariable('TXT_DUPLICATE', $this->lng->txt('frm_wizard_page'));
3889  $this->tpl->setVariable('INFO_THREADS', $this->lng->txt('fmr_copy_threads_info'));
3890  $this->tpl->setVariable('THREADS', $this->lng->txt('forums_threads'));
3891 
3892  $forum_id = $ilObjDataCache->lookupObjId((int) $_POST['clone_source']);
3893  include_once('Modules/Forum/classes/class.ilForum.php');
3894  $threads = ilForum::_getThreads($forum_id, ilForum::SORT_TITLE);
3895  foreach ($threads as $thread_id => $title)
3896  {
3897  $this->tpl->setCurrentBlock('thread_row');
3898  $this->tpl->setVariable('CHECK_THREAD', ilUtil::formCheckbox(0, 'cp_options['.$source_id.'][threads][]', $thread_id));
3899  $this->tpl->setVariable('NAME_THREAD', $title);
3900  $this->tpl->parseCurrentBlock();
3901  }
3902  $this->tpl->setVariable('SELECT_ALL', $this->lng->txt('select_all'));
3903  $this->tpl->setVariable('JS_FIELD', 'cp_options['.$source_id.'][threads]');
3904  $this->tpl->setVariable('BTN_COPY', $this->lng->txt('obj_'.$new_type.'_duplicate'));
3905  if (isset($_SESSION['wizard_search_title']))
3906  {
3907  $this->tpl->setVariable('BACK_CMD', 'searchCloneSource');
3908  }
3909  else
3910  {
3911  $this->tpl->setVariable('BACK_CMD', 'create');
3912  }
3913  $this->tpl->setVariable('BTN_BACK', $this->lng->txt('btn_back'));
3914  }
3915 
3916  public function addLocatorItems()
3917  {
3920  global $ilLocator;
3921 
3922  if($this->object instanceof ilObject)
3923  {
3924  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ''), '', $this->object->getRefId());
3925  }
3926  }
3927 
3928  public function handleFormInput($a_text, $a_stripslashes = true)
3929  {
3930  $a_text = str_replace("<", "&lt;", $a_text);
3931  $a_text = str_replace(">", "&gt;", $a_text);
3932  if($a_stripslashes)
3933  $a_text = ilUtil::stripSlashes($a_text);
3934 
3935  return $a_text;
3936  }
3937 
3938  public function prepareFormOutput($a_text)
3939  {
3940  $a_text = str_replace("&lt;", "<", $a_text);
3941  $a_text = str_replace("&gt;", ">", $a_text);
3942  $a_text = ilUtil::prepareFormOutput($a_text);
3943  return $a_text;
3944  }
3945 
3951  public function infoScreenObject()
3952  {
3953  $this->ctrl->setCmd('showSummary');
3954  $this->ctrl->setCmdClass('ilinfoscreengui');
3955  $this->infoScreen();
3956  }
3957 
3958  public function infoScreen()
3959  {
3963  global $ilAccess;
3964 
3965  if(!$ilAccess->checkAccess('visible', '', $this->object->getRefId()))
3966  {
3967  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilias->error_obj->MESSAGE);
3968  }
3969 
3970  include_once 'Services/InfoScreen/classes/class.ilInfoScreenGUI.php';
3971  $info = new ilInfoScreenGUI($this);
3972 
3973  $info->enablePrivateNotes();
3974 
3975  // standard meta data
3976  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
3977 
3978  // forward the command
3979  $this->ctrl->forwardCommand($info);
3980  }
3981 
3982  public function updateNotificationSettingsObject()
3983  {
3988  global $ilAccess, $ilErr;
3989  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
3990  {
3991  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
3992  }
3993 
3994  // instantiate the property form
3996 
3997  // check input
3998  if($this->notificationSettingsForm->checkInput())
3999  {
4000  if(isset($_POST['notification_type']) && $_POST['notification_type']== 'all_users')
4001  {
4002  // set values and call update
4003  $this->objProperties->setAdminForceNoti(1);
4004  $this->objProperties->setUserToggleNoti((int) $this->notificationSettingsForm->getInput('usr_toggle'));
4005  $this->objProperties->setNotificationType('all_users');
4006  $this->updateUserNotifications(true);
4007  }
4008  else if($_POST['notification_type']== 'per_user')
4009  {
4010  $this->objProperties->setNotificationType('per_user');
4011  $this->objProperties->setAdminForceNoti(1);
4012  $this->objProperties->setUserToggleNoti(0);
4013  $this->updateUserNotifications();
4014  }
4015  else // if($_POST['notification_type'] == 'default')
4016  {
4017  $this->objProperties->setNotificationType('default');
4018  $this->objProperties->setAdminForceNoti(0);
4019  $this->objProperties->setUserToggleNoti(0);
4020  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
4021  $frm_noti = new ilForumNotification($this->object->getRefId());
4022  $frm_noti->deleteNotificationAllUsers();
4023  }
4024 
4025  $this->objProperties->update();
4026 
4027  // print success message
4028  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
4029  }
4030  $this->notificationSettingsForm->setValuesByPost();
4031 
4032  return $this->showMembersObject();
4033  }
4034 
4035  private function updateUserNotifications($update_all_users = false)
4036  {
4037  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
4038 
4039  $oParticipants = $this->getParticipantsObject();
4040 
4041  $frm_noti = new ilForumNotification($this->object->getRefId());
4042  $moderator_ids = $frm_noti->_getModerators($this->object->getRefId());
4043 
4044  $admin_ids = $oParticipants->getAdmins();
4045  $member_ids = $oParticipants->getMembers();
4046  $tutor_ids = $oParticipants->getTutors();
4047 
4048  $all_forum_users = array_merge($moderator_ids, $admin_ids, $member_ids, $tutor_ids);
4049  $all_forum_users= array_unique($all_forum_users);
4050 
4051  $all_notis = $frm_noti->read();
4052 
4053  foreach($all_forum_users as $user_id)
4054  {
4055  $frm_noti->setUserId($user_id);
4056 
4057  $frm_noti->setAdminForce(1);
4058  $frm_noti->setUserToggle($this->objProperties->isUserToggleNoti());
4059 
4060  if(array_key_exists($user_id, $all_notis) && $update_all_users)
4061  {
4062  $frm_noti->update();
4063  }
4064  else if($frm_noti->existsNotification() == false)
4065  {
4066  $frm_noti->insertAdminForce();
4067  }
4068  }
4069  }
4070 
4071  private function initNotificationSettingsForm()
4072  {
4073  if(null === $this->notificationSettingsForm)
4074  {
4075  $form = new ilPropertyFormGUI();
4076  $form->setFormAction($this->ctrl->getFormAction($this, 'updateNotificationSettings'));
4077  $form->setTitle($this->lng->txt('forums_notification_settings'));
4078 
4079  $radio_grp = new ilRadioGroupInputGUI('','notification_type');
4080  $radio_grp->setValue('default');
4081 
4082  $opt_default = new ilRadioOption($this->lng->txt("user_decides_notification"), 'default');
4083  $opt_0 = new ilRadioOption($this->lng->txt("settings_for_all_members"), 'all_users');
4084  $opt_1 = new ilRadioOption($this->lng->txt("settings_per_users"), 'per_user');
4085 
4086  $radio_grp->addOption($opt_default, 'default');
4087  $radio_grp->addOption($opt_0, 'all_users');
4088  $radio_grp->addOption($opt_1, 'per_user');
4089 
4090  $chb_2 = new ilCheckboxInputGUI($this->lng->txt('user_toggle_noti'), 'usr_toggle');
4091  $chb_2->setValue(1);
4092 
4093  $opt_0->addSubItem($chb_2);
4094  $form->addItem($radio_grp);
4095 
4096  $form->addCommandButton('updateNotificationSettings', $this->lng->txt('save'));
4097 
4098  $this->notificationSettingsForm = $form;
4099 
4100  return false;
4101  }
4102 
4103  return true;
4104  }
4105 
4106  public function getIcon($user_toggle_noti)
4107  {
4108  $icon = $user_toggle_noti
4109  ? "<img src=\"".ilUtil::getImagePath("icon_ok.svg")."\" alt=\"".$this->lng->txt("enabled")."\" title=\"".$this->lng->txt("enabled")."\" border=\"0\" vspace=\"0\"/>"
4110  : "<img src=\"".ilUtil::getImagePath("icon_not_ok.svg")."\" alt=\"".$this->lng->txt("disabled")."\" title=\"".$this->lng->txt("disabled")."\" border=\"0\" vspace=\"0\"/>";
4111  return $icon;
4112  }
4113 
4114  public function showMembersObject()
4115  {
4123  global $tree, $tpl, $ilTabs, $ilAccess, $ilErr;
4124 
4125  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
4126  {
4127  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
4128  }
4129 
4130  $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_members_list.html', 'Modules/Forum');
4131 
4132  $ilTabs->setTabActive('settings');
4133  $this->settingsTabs();
4134 
4135  // instantiate the property form
4136  if(!$this->initNotificationSettingsForm())
4137  {
4138  // if the form was just created set the values fetched from database
4139  $this->notificationSettingsForm->setValuesByArray(array(
4140  'notification_type' => $this->objProperties->getNotificationType(),
4141  'adm_force' => (bool) $this->objProperties->isAdminForceNoti(),
4142  'usr_toggle' => (bool) $this->objProperties->isUserToggleNoti()
4143  ));
4144  }
4145 
4146  // set form html into template
4147  $tpl->setVariable('NOTIFICATIONS_SETTINGS_FORM', $this->notificationSettingsForm->getHTML());
4148 
4149  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
4150  include_once 'Modules/Forum/classes/class.ilObjForum.php';
4151 
4152  $frm_noti = new ilForumNotification($this->object->getRefId());
4153  $oParticipants = $this->getParticipantsObject();
4154 
4155  $moderator_ids = $frm_noti->_getModerators($this->object->getRefId());
4156 
4157  $admin_ids = $oParticipants->getAdmins();
4158  $member_ids = $oParticipants->getMembers();
4159  $tutor_ids = $oParticipants->getTutors();
4160 
4161  if($this->objProperties->getNotificationType() == 'default')
4162  {
4163  // update forum_notification table
4164  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
4165  $forum_noti = new ilForumNotification($this->object->getRefId());
4166  $forum_noti->setAdminForce($this->objProperties->isAdminForceNoti());
4167  $forum_noti->setUserToggle($this->objProperties->isUserToggleNoti());
4168  $forum_noti->setForumId($this->objProperties->getObjId());
4169  }
4170  else if($this->objProperties->getNotificationType() == 'per_user')
4171  {
4172  $moderators = $this->getUserNotificationTableData($moderator_ids, $frm_noti);
4173  $admins = $this->getUserNotificationTableData($admin_ids, $frm_noti);
4174  $members = $this->getUserNotificationTableData($member_ids, $frm_noti);
4175  $tutors = $this->getUserNotificationTableData($tutor_ids, $frm_noti);
4176 
4177  $this->__showMembersTable($moderators, $admins, $members, $tutors);
4178  }
4179  }
4180 
4181  private function getUserNotificationTableData($user_ids, ilForumNotification $frm_noti)
4182  {
4183  $counter = 0;
4184  $users = array();
4185  foreach($user_ids as $user_id)
4186  {
4187  $frm_noti->setUserId($user_id);
4188  $user_toggle_noti = $frm_noti->isUserToggleNotification();
4189  $icon_ok = $this->getIcon(!$user_toggle_noti);
4190 
4191  $users[$counter]['user_id'] = ilUtil::formCheckbox(0, 'user_id[]', $user_id);
4192  $users[$counter]['login'] = ilObjUser::_lookupLogin($user_id);
4193  $name = ilObjUser::_lookupName($user_id);
4194  $users[$counter]['firstname'] = $name['firstname'];
4195  $users[$counter]['lastname'] = $name['lastname'];
4196  $users[$counter]['user_toggle_noti'] = $icon_ok;
4197  $counter++;
4198  }
4199  return $users;
4200  }
4201 
4202  private function __showMembersTable($moderators, $admins, $members, $tutors)
4203  {
4209  global $lng, $tpl, $ilCtrl;
4210 
4211  if($moderators)
4212  {
4213  $tbl_mod = new ilTable2GUI($this);
4214  $tbl_mod->setId('tbl_id_mod');
4215  $tbl_mod->setFormAction($ilCtrl->getFormAction($this, 'showMembers'));
4216  $tbl_mod->setTitle($lng->txt('moderators'));
4217 
4218  $tbl_mod->addColumn('', '', '1%', true);
4219  $tbl_mod->addColumn($lng->txt('login'), '', '10%');
4220  $tbl_mod->addColumn($lng->txt('firstname'), '', '10%');
4221  $tbl_mod->addColumn($lng->txt('lastname'), '', '10%');
4222  $tbl_mod->addColumn($lng->txt('allow_user_toggle_noti'), '', '10%');
4223  $tbl_mod->setSelectAllCheckbox('user_id');
4224 
4225  $tbl_mod->setRowTemplate('tpl.forums_members_row.html', 'Modules/Forum');
4226  $tbl_mod->setData($moderators);
4227 
4228  $tbl_mod->addMultiCommand('enableHideUserToggleNoti',$lng->txt('enable_hide_user_toggle'));
4229  $tbl_mod->addMultiCommand('disableHideUserToggleNoti',$lng->txt('disable_hide_user_toggle'));
4230 
4231  $tpl->setCurrentBlock('moderators_table');
4232  $tpl->setVariable('MODERATORS',$tbl_mod->getHTML());
4233  }
4234 
4235  if($admins)
4236  {
4237  $tbl_adm = new ilTable2GUI($this);
4238  $tbl_adm->setId('tbl_id_adm');
4239  $tbl_adm->setFormAction($ilCtrl->getFormAction($this, 'showMembers'));
4240  $tbl_adm->setTitle($lng->txt('administrator'));
4241 
4242  $tbl_adm->addColumn('', '', '1%', true);
4243  $tbl_adm->addColumn($lng->txt('login'), '', '10%');
4244  $tbl_adm->addColumn($lng->txt('firstname'), '', '10%');
4245  $tbl_adm->addColumn($lng->txt('lastname'), '', '10%');
4246  $tbl_adm->addColumn($lng->txt('allow_user_toggle_noti'), '', '10%');
4247  $tbl_adm->setSelectAllCheckbox('user_id');
4248  $tbl_adm->setRowTemplate('tpl.forums_members_row.html', 'Modules/Forum');
4249 
4250  $tbl_adm->setData($admins);
4251  $tbl_adm->addMultiCommand('enableHideUserToggleNoti',$lng->txt('enable_hide_user_toggle'));
4252  $tbl_adm->addMultiCommand('disableHideUserToggleNoti',$lng->txt('disable_hide_user_toggle'));
4253 
4254  $tpl->setCurrentBlock('admins_table');
4255  $tpl->setVariable('ADMINS',$tbl_adm->getHTML());
4256  }
4257 
4258  if($members)
4259  {
4260  $tbl_mem = new ilTable2GUI($this);
4261  $tbl_mem->setId('tbl_id_mem');
4262  $tbl_mem->setFormAction($ilCtrl->getFormAction($this, 'showMembers'));
4263  $tbl_mem->setTitle($lng->txt('members'));
4264 
4265  $tbl_mem->addColumn('', '', '1%', true);
4266  $tbl_mem->addColumn($lng->txt('login'), '', '10%');
4267  $tbl_mem->addColumn($lng->txt('firstname'), '', '10%');
4268  $tbl_mem->addColumn($lng->txt('lastname'), '', '10%');
4269  $tbl_mem->addColumn($lng->txt('allow_user_toggle_noti'), '', '10%');
4270  $tbl_mem->setSelectAllCheckbox('user_id');
4271  $tbl_mem->setRowTemplate('tpl.forums_members_row.html', 'Modules/Forum');
4272  $tbl_mem->setData($members);
4273 
4274  $tbl_mem->addMultiCommand('enableHideUserToggleNoti',$lng->txt('enable_hide_user_toggle'));
4275  $tbl_mem->addMultiCommand('disableHideUserToggleNoti',$lng->txt('disable_hide_user_toggle'));
4276 
4277  $tpl->setCurrentBlock('members_table');
4278  $tpl->setVariable('MEMBERS',$tbl_mem->getHTML());
4279  }
4280 
4281  if($tutors)
4282  {
4283  $tbl_tut = new ilTable2GUI($this);
4284  $tbl_tut->setId('tbl_id_tut');
4285  $tbl_tut->setFormAction($ilCtrl->getFormAction($this, 'showMembers'));
4286  $tbl_tut->setTitle($lng->txt('tutors'));
4287 
4288  $tbl_tut->addColumn('', '', '1%', true);
4289  $tbl_tut->addColumn($lng->txt('login'), '', '10%');
4290  $tbl_tut->addColumn($lng->txt('firstname'), '', '10%');
4291  $tbl_tut->addColumn($lng->txt('lastname'), '', '10%');
4292  $tbl_tut->addColumn($lng->txt('allow_user_toggle_noti'), '', '10%');
4293  $tbl_tut->setSelectAllCheckbox('user_id');
4294  $tbl_tut->setRowTemplate('tpl.forums_members_row.html', 'Modules/Forum');
4295  $tbl_tut->setData($tutors);
4296 
4297  $tbl_tut->addMultiCommand('enableHideUserToggleNoti',$lng->txt('enable_hide_user_toggle'));
4298  $tbl_tut->addMultiCommand('disableHideUserToggleNoti',$lng->txt('disable_hide_user_toggle'));
4299 
4300  $tpl->setCurrentBlock('tutors_table');
4301  $tpl->setVariable('TUTORS',$tbl_tut->getHTML());
4302  }
4303  }
4304 
4305  public function enableAdminForceNotiObject()
4306  {
4311  global $ilAccess, $ilErr;
4312  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
4313  {
4314  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
4315  }
4316 
4317  if(!isset($_POST['user_id']) || !is_array($_POST['user_id']))
4318  {
4319  ilUtil::sendInfo($this->lng->txt('time_limit_no_users_selected'), true);
4320  }
4321  else
4322  {
4323  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
4324  $frm_noti = new ilForumNotification($this->object->getRefId());
4325 
4326  foreach($_POST['user_id'] as $user_id)
4327  {
4328  $frm_noti->setUserId((int) $user_id);
4329  $is_enabled = $frm_noti->isAdminForceNotification();
4330 
4331  $frm_noti->setUserToggle(0);
4332  if(!$is_enabled)
4333  {
4334  $frm_noti->setAdminForce(1);
4335  $frm_noti->insertAdminForce();
4336  }
4337  }
4338 
4339  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
4340  }
4341 
4342  $this->showMembersObject();
4343  }
4344 
4345  public function disableAdminForceNotiObject()
4346  {
4351  global $ilAccess, $ilErr;
4352  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
4353  {
4354  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
4355  }
4356 
4357  if(!isset($_POST['user_id']) || !is_array($_POST['user_id']))
4358  {
4359  ilUtil::sendInfo($this->lng->txt('time_limit_no_users_selected'));
4360  }
4361  else
4362  {
4363  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
4364  $frm_noti = new ilForumNotification($this->object->getRefId());
4365 
4366  foreach($_POST['user_id'] as $user_id)
4367  {
4368  $frm_noti->setUserId((int) $user_id);
4369  $is_enabled = $frm_noti->isAdminForceNotification();
4370 
4371  if($is_enabled)
4372  {
4373  $frm_noti->deleteAdminForce();
4374  }
4375  }
4376 
4377  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
4378  }
4379 
4380  $this->showMembersObject();
4381  }
4382 
4383  public function enableHideUserToggleNotiObject()
4384  {
4389  global $ilAccess, $ilErr;
4390  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
4391  {
4392  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
4393  }
4394  if(!isset($_POST['user_id']) || !is_array($_POST['user_id']))
4395  {
4396  ilUtil::sendInfo($this->lng->txt('time_limit_no_users_selected'));
4397  }
4398  else
4399  {
4400  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
4401  $frm_noti = new ilForumNotification($this->object->getRefId());
4402 
4403  foreach($_POST['user_id'] as $user_id)
4404  {
4405  $frm_noti->setUserId((int) $user_id);
4406  $is_enabled = $frm_noti->isAdminForceNotification();
4407  $frm_noti->setUserToggle(1);
4408 
4409  if(!$is_enabled)
4410  {
4411  $frm_noti->setAdminForce(1);
4412  $frm_noti->insertAdminForce();
4413  }
4414  else
4415  {
4416  $frm_noti->updateUserToggle();
4417  }
4418  }
4419 
4420  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
4421  }
4422 
4423  $this->showMembersObject();
4424  }
4425 
4426  public function disableHideUserToggleNotiObject()
4427  {
4432  global $ilAccess, $ilErr;
4433  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
4434  {
4435  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
4436  }
4437 
4438  if(!isset($_POST['user_id']) || !is_array($_POST['user_id']))
4439  {
4440  ilUtil::sendInfo($this->lng->txt('time_limit_no_users_selected'));
4441  }
4442  else
4443  {
4444  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
4445  $frm_noti = new ilForumNotification($this->object->getRefId());
4446 
4447  foreach($_POST['user_id'] as $user_id)
4448  {
4449  $frm_noti->setUserId((int) $user_id);
4450  $is_enabled = $frm_noti->isAdminForceNotification();
4451  $frm_noti->setUserToggle(0);
4452  if($is_enabled)
4453  {
4454  $frm_noti->updateUserToggle();
4455  }
4456  else
4457  {
4458  $frm_noti->setAdminForce(1);
4459  $frm_noti->insertAdminForce();
4460  }
4461  }
4462 
4463  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
4464  }
4465 
4466  $this->showMembersObject();
4467  }
4468 
4469  public function markPostUnreadObject()
4470  {
4474  global $ilUser;
4475 
4476  if(isset($_GET['pos_pk']))
4477  {
4478  $this->object->markPostUnread($ilUser->getId(), (int) $_GET['pos_pk']);
4479  }
4480 
4481  $this->viewThreadObject();
4482  }
4483 
4484  public function markPostReadObject()
4485  {
4489  global $ilUser;
4490 
4491  $this->object->markPostRead($ilUser->getId(), (int) $this->objCurrentTopic->getId(), (int) $this->objCurrentPost->getId());
4492  $this->viewThreadObject();
4493  }
4494 
4495  protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
4496  {
4500  global $ilUser;
4501 
4502  $lg = parent::initHeaderAction();
4503 
4504  // Workaround: Do not show "desktop actions" in thread view
4505  if($this->objCurrentTopic->getId())
4506  {
4507  $container_obj = null;
4508  $lg->setContainerObject($container_obj);
4509  }
4510 
4511  if($lg instanceof ilObjForumListGUI)
4512  {
4513  if($ilUser->getId() != ANONYMOUS_USER_ID && $this->ilias->getSetting('forum_notification') != 0 )
4514  {
4515  $is_user_allowed_to_deactivate_notification = $this->isUserAllowedToDeactivateNotification();
4516 
4517  $frm = $this->object->Forum;
4518  $frm->setForumId($this->object->getId());
4519  $frm->setForumRefId($this->object->getRefId());
4520  $frm->setMDB2Wherecondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
4521  $frm_notificiation_enabled = $frm->isForumNotificationEnabled($ilUser->getId());
4522 
4523  if($this->objCurrentTopic->getId())
4524  {
4525  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4526  }
4527 
4528  if($this->isParentObjectCrsOrGrp())
4529  {
4530  // special behaviour for CRS/GRP-Forum notification!!
4531  if(
4532  $frm_notificiation_enabled &&
4533  $is_user_allowed_to_deactivate_notification
4534  )
4535  {
4536  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'disableForumNotification'), "forums_disable_forum_notification");
4537  }
4538  else
4539  {
4540  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'enableForumNotification'), "forums_enable_forum_notification");
4541  }
4542  }
4543  else
4544  {
4545  if($frm_notificiation_enabled)
4546  {
4547  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'disableForumNotification'), "forums_disable_forum_notification");
4548  }
4549  else
4550  {
4551  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'enableForumNotification'), "forums_enable_forum_notification");
4552  }
4553  }
4554 
4555  $topic_notification_enabled = false;
4556  if($this->objCurrentTopic->getId())
4557  {
4558  $topic_notification_enabled = $this->objCurrentTopic->isNotificationEnabled($ilUser->getId());
4559  if($topic_notification_enabled)
4560  {
4561  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'toggleThreadNotification'), "forums_disable_notification");
4562  }
4563  else
4564  {
4565  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'toggleThreadNotification'), "forums_enable_notification");
4566  }
4567  }
4568  $this->ctrl->setParameter($this, 'thr_pk', '');
4569 
4570  if($frm_notificiation_enabled || $topic_notification_enabled)
4571  {
4572  $lg->addHeaderIcon(
4573  "not_icon",
4574  ilUtil::getImagePath("notification_on.svg"),
4575  $this->lng->txt("frm_notification_activated")
4576  );
4577  }
4578  else
4579  {
4580  $lg->addHeaderIcon(
4581  "not_icon",
4582  ilUtil::getImagePath("notification_off.svg"),
4583  $this->lng->txt("frm_notification_deactivated")
4584  );
4585  }
4586  }
4587  }
4588 
4589  return $lg;
4590  }
4591 
4593  {
4594  if($this->objProperties->getNotificationType() == 'default')
4595  {
4596  return true;
4597  }
4598 
4599  if($this->objProperties->isUserToggleNoti() == 0)
4600  {
4601  return true;
4602  }
4603 
4604  if($this->isParentObjectCrsOrGrp());
4605  {
4606  global $ilUser;
4607 
4608  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
4609 
4610  $frm_noti = new ilForumNotification((int) $_GET['ref_id']);
4611  $frm_noti->setUserId($ilUser->getId());
4612 
4613  $user_toggle = (int)$frm_noti->isUserToggleNotification();
4614  if($user_toggle == 0)
4615  {
4616  return true;
4617  }
4618  }
4619 
4620  return false;
4621  }
4622 
4623  private function isParentObjectCrsOrGrp()
4624  {
4625  global $tree;
4626 
4627  // check if there a parent-node is a grp or crs
4628  $grp_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp');
4629  $crs_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs');
4630 
4631  if($grp_ref_id == 0 && $crs_ref_id == 0)
4632  {
4633  return false;
4634  }
4635  return true;
4636  }
4637 
4641  public function getParticipantsObject()
4642  {
4643  global $tree, $ilErr;
4644 
4645  $grp_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp');
4646  $crs_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs');
4647 
4648  if($this->isParentObjectCrsOrGrp() == false)
4649  {
4650  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE);
4651  }
4652 
4656  $oParticipants = null;
4657 
4658  if($grp_ref_id > 0)
4659  {
4660  $parent_obj = ilObjectFactory::getInstanceByRefId($grp_ref_id);
4661  include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
4662  $oParticipants = ilGroupParticipants::_getInstanceByObjId($parent_obj->getId());
4663  return $oParticipants;
4664  }
4665  else if($crs_ref_id > 0)
4666  {
4667  $parent_obj = ilObjectFactory::getInstanceByRefId($crs_ref_id);
4668 
4669  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
4670  $oParticipants = ilCourseParticipants::_getInstanceByObjId($parent_obj->getId());
4671  return $oParticipants;
4672  }
4673 
4674  return $oParticipants;
4675  }
4676 
4680  public function addToDeskObject()
4681  {
4686  global $ilSetting, $lng;
4687 
4688  if((int)$ilSetting->get('disable_my_offers'))
4689  {
4690  $this->showThreadsObject();
4691  return;
4692  }
4693 
4694  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
4696  ilUtil::sendSuccess($lng->txt("added_to_desktop"));
4697  $this->showThreadsObject();
4698  }
4699 
4703  public function removeFromDeskObject()
4704  {
4705  global $ilSetting, $lng;
4706 
4707  if((int)$ilSetting->get('disable_my_offers'))
4708  {
4709  $this->showThreadsObject();
4710  return;
4711  }
4712 
4713  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
4715  ilUtil::sendSuccess($lng->txt("removed_from_desktop"));
4716  $this->showThreadsObject();
4717  }
4718 
4719  public function saveThreadSortingObject()
4720  {
4721  $_POST['thread_sorting'] ? $thread_sorting = $_POST['thread_sorting'] :$thread_sorting = array();
4722 
4723  foreach($thread_sorting as $thr_pk=>$sorting_value)
4724  {
4725  $sorting_value = str_replace(',','.',$sorting_value);
4726  $sorting_value = (float)$sorting_value * 100;
4727  $this->object->setThreadSorting($thr_pk,$sorting_value);
4728  }
4729  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
4730  $this->showThreadsObject();
4731  return true;
4732  }
4733 
4737  public function mergeThreadsObject()
4738  {
4739  if(!$this->is_moderator)
4740  {
4741  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
4742  }
4743 
4744  $selected_thread_id = 0;
4745  if(isset($_GET['merge_thread_id']) && (int)$_GET['merge_thread_id'])
4746  {
4747  $selected_thread_id = (int)$_GET['merge_thread_id'];
4748  }
4749  else if(isset($_POST['thread_ids']) && count((array)$_POST['thread_ids']) == 1)
4750  {
4751  $selected_thread_id = (int)current($_POST['thread_ids']);
4752  }
4753  else
4754  {
4755  ilUtil::sendInfo($this->lng->txt('select_one'));
4756  $this->showThreadsObject();
4757  return;
4758  }
4759 
4760  if($selected_thread_id)
4761  {
4762  $frm = $this->object->Forum;
4763  $frm->setForumId($this->object->getId());
4764  $frm->setForumRefId($this->object->getRefId());
4765 
4766  $selected_thread_obj = new ilForumTopic($selected_thread_id);
4767 
4768  if(ilForum::_lookupObjIdForForumId($selected_thread_obj->getForumId()) != $frm->getForumId())
4769  {
4770  ilUtil::sendFailure($this->lng->txt('not_allowed_to_merge_into_another_forum'));
4771  $this->showThreadsObject();
4772  return;
4773  }
4774 
4775  $frm->setMDB2Wherecondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
4776 
4777  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_liste.html', 'Modules/Forum');
4778 
4779  $topicData = $frm->getOneTopic();
4780  if($topicData)
4781  {
4782  include_once 'Modules/Forum/classes/class.ilForumTopicTableGUI.php';
4783  $this->ctrl->setParameter($this, 'merge_thread_id', $selected_thread_id);
4784  $tbl = new ilForumTopicTableGUI($this, 'mergeThreads', '', (int)$_GET['ref_id'], $topicData, $this->is_moderator, $this->forum_overview_setting);
4785  $tbl->setSelectedThread($selected_thread_obj);
4786  $tbl->setMapper($frm)->fetchData();
4787  $tbl->populate();
4788  $this->tpl->setVariable('THREADS_TABLE', $tbl->getHTML());
4789  }
4790  else
4791  {
4792  ilUtil::sendFailure($this->lng->txt('select_one'));
4793  $this->showThreadsObject();
4794  return;
4795  }
4796  }
4797  }
4798 
4802  public function confirmMergeThreadsObject()
4803  {
4804  if(!$this->is_moderator)
4805  {
4806  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
4807  }
4808 
4809  if(!isset($_GET['merge_thread_id']) || !(int)$_GET['merge_thread_id'] || !is_array($_POST['thread_ids']) || count($_POST['thread_ids']) != 1)
4810  {
4811  ilUtil::sendFailure($this->lng->txt('select_one'));
4812  $this->mergeThreadsObject();
4813  return;
4814  }
4815 
4816  $source_thread_id = (int)$_GET['merge_thread_id'];
4817  $target_thread_id = (int)current($_POST['thread_ids']);
4818 
4819  if($source_thread_id == $target_thread_id)
4820  {
4821  ilUtil::sendFailure($this->lng->txt('error_same_thread_ids'));
4822  $this->showThreadsObject();
4823  return;
4824  }
4825 
4826  if(ilForumTopic::lookupForumIdByTopicId($source_thread_id) != ilForumTopic::lookupForumIdByTopicId($target_thread_id))
4827  {
4828  ilUtil::sendFailure($this->lng->txt('not_allowed_to_merge_into_another_forum'));
4829  $this->ctrl->clearParameters($this);
4830  $this->showThreadsObject();
4831  return;
4832  }
4833 
4834  if(ilForumTopic::_lookupDate($source_thread_id) < ilForumTopic::_lookupDate($target_thread_id))
4835  {
4836  ilUtil::sendInfo($this->lng->txt('switch_threads_for_merge'));
4837  }
4838 
4839  include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
4840  $c_gui = new ilConfirmationGUI();
4841 
4842  $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performMergeThreads'));
4843  $c_gui->setHeaderText($this->lng->txt('frm_sure_merge_threads'));
4844  $c_gui->setCancel($this->lng->txt('cancel'), 'showThreads');
4845  $c_gui->setConfirm($this->lng->txt('confirm'), 'performMergeThreads');
4846 
4847  $c_gui->addItem('thread_ids[]', $source_thread_id, sprintf($this->lng->txt('frm_merge_src'), ilForumTopic::_lookupTitle($source_thread_id)));
4848  $c_gui->addItem('thread_ids[]', $target_thread_id, sprintf($this->lng->txt('frm_merge_target'), ilForumTopic::_lookupTitle($target_thread_id)));
4849 
4850  $this->tpl->setContent($c_gui->getHTML());
4851  return;
4852  }
4853 
4857  public function performMergeThreadsObject()
4858  {
4862  global $lng;
4863 
4864  if(!$this->is_moderator)
4865  {
4866  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
4867  }
4868 
4869  if(!isset($_POST['thread_ids']) || !is_array($_POST['thread_ids']) || count($_POST['thread_ids']) != 2)
4870  {
4871  ilUtil::sendFailure($this->lng->txt('select_one'));
4872  $this->showThreadsObject();
4873  return;
4874  }
4875 
4876  if((int)$_POST['thread_ids'][0] == (int)$_POST['thread_ids'][1])
4877  {
4878  ilUtil::sendFailure($this->lng->txt('error_same_thread_ids'));
4879  $this->showThreadsObject();
4880  return;
4881  }
4882 
4883  try
4884  {
4885  ilForum::mergeThreads($this->object->id, (int)$_POST['thread_ids'][0], (int)$_POST['thread_ids'][1]);
4886  ilUtil::sendSuccess($this->lng->txt('merged_threads_successfully'));
4887  }
4888  catch(ilException $e)
4889  {
4890  return ilUtil::sendFailure($lng->txt($e->getMessage()));
4891  }
4892  $this->showThreadsObject();
4893  }
4894 
4898  public function cancelMergeThreads()
4899  {
4900  $this->showThreadsObject();
4901  }
4902 
4906  protected function setSideBlocks()
4907  {
4908  $rgt_content = '';
4909  if(!$GLOBALS['ilCtrl']->isAsynch())
4910  {
4911  require_once 'Services/Search/classes/class.ilRepositoryObjectSearchGUI.php';
4912  $rgt_content = ilRepositoryObjectSearchGUI::getSearchBlockHTML($this->lng->txt('frm_search'));
4913  }
4914  $this->tpl->setRightContent($rgt_content . $this->getRightColumnHTML());
4915  }
4916 }
Class ilForumStatisticsTableGUI.
static _getMediaObjects($a_text, $a_direction=0)
Returns all media objects found in the passed string.
static _getRTEClassname()
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _lookupLogin($a_user_id)
lookup login
static _lookupName($a_user_id)
lookup user name
static _isModerator($a_ref_id, $a_usr_id)
checks whether a user is moderator of a given forum object
afterSave(ilObjForum $forumObj)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static _lookupDate($thread_id)
This class represents an option in a radio group.
ILIAS Setting Class.
_getModerators($a_ref_id)
get all users assigned to local role il_frm_moderator_<frm_ref_id> (static)
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
print $file
$lg
Definition: example_018.php:62
const SORT_TITLE
static _lookupObjIdForForumId($a_for_id)
Class Forum core functions for forum.
static getTreeNodeHtml($object, ilObjForumGUI $gui, $pageHits)
Returns the html used for a single forum tree node public.
exit
Definition: login.php:54
Class ilForumExplorer class for explorer view of forum posts.
Base class for ILIAS Exception handling.
setBlockProperty($a_block_type, $a_property, $a_value)
This function is supposed to be used for block type specific properties, that should be passed to ilB...
Class ilInfoScreenGUI.
$_POST['username']
Definition: cron.php:12
setDisplayConfirmPostActivation($status=0)
Class for permanent links.
static lookupForumIdByObjId($obj_id)
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
$_SESSION["AccountId"]
$result
Tabs GUI.
static mergeThreads($obj_id, $source_id, $target_id)
This class represents a property form user interface.
GUI class for the workflow of copying objects.
This class represents a captcha input in a property form.
getIcon($user_toggle_noti)
const TITLE_LENGTH
max length of object title
static getFirstNewsIdForContext($a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id="", $a_context_sub_obj_type="")
Get first new id of news set related to a certain context.
$_GET["client_id"]
$tbl
Definition: example_048.php:81
Class ilObject Basic functions for all objects.
static Linkbar($AScript, $AHits, $ALimit, $AOffset, $AParams=array(), $ALayout=array(), $prefix='')
Linkbar Diese Funktion erzeugt einen typischen Navigationsbalken mit "Previous"- und "Next"-Links und...
initHeaderAction($a_sub_type=null, $a_sub_id=null)
Add header action menu.
Class ilObjForumListGUI.
This class represents a file wizard property in a property form.
$cmd
Definition: sahs_server.php:35
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
getSubTabs($subtab='showThreads')
static get($a_var)
Get a value.
static get($a_glyph, $a_text="")
Get glyph html.
static set($a_var, $a_val)
Set a value.
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
This class represents a checkbox property in a property form.
static _lookupTitle($a_id)
lookup object title
addItem($a_item)
Add Item (Property, SectionHeader).
$url
Definition: shib_logout.php:72
createObject()
create new object form
Class ilForumNotification.
addTarget($a_text, $a_link, $a_cmd="", $a_cmdClass="", $a_frame="", $a_activate=false, $a_dir_text=false)
DEPRECATED.
static addToDesktop()
Add desktop item public.
setInfo($a_info)
Set Info.
initForumCreateForm($object_type)
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static _setRichTextEditorUserState($a_state)
Sets the state of the rich text editor visibility for the current user.
static _getAllReferences($a_id)
get all reference ids of object
_removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Remove usage of mob in another container.
Class ilForumTopicTableGUI.
static _lookupObjectId($a_ref_id)
lookup object id
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
getCenterColumnHTML()
Get center column.
updateCustom(ilPropertyFormGUI $a_form)
Insert custom update form values into object.
Export User Interface Class.
$info
Definition: example_052.php:80
GUI class for public user profile presentation.
static getInstance($a_obj_id=0)
hideToolbar($a_flag=null)
_saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
This class represents a property in a property form.
addOption($a_option)
Add Option.
static encode($mixed, $suppress_native=false)
Class ilTable2GUI.
Class ilRatingGUI.
$mobs
& executeCommand()
execute command
getId()
get object id public
Class ilForumModeratorsGUI.
addSubItem($a_item)
Add Subitem.
Forum export to HTML and Print.
static _exists($a_id)
checks wether a lm content object with specified id exists or not
Column user interface class.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
Class Mail this class handles base functions for mail handling.
getTabs(&$tabs_gui)
get tabs abstract method.
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
Class ilObjForumGUI.
setRepositoryMode($a_repositorymode)
Set RepositoryMode.
setValue($a_value)
Set Value.
special template class to simplify handling of ITX/PEAR
setSize($a_size)
Set Size.
This class represents a text property in a property form.
static infoPanel($a_keep=true)
redirection script todo: (a better solution should control the processing via a xml file) ...
static getOverallRatingForObject($a_obj_id, $a_obj_type, $a_sub_obj_id=null, $a_sub_obj_type=null, $a_category_id=null)
Get overall rating for an object.
Class ilObjMediaObject.
setMaxLength($a_maxlength)
Set Max Length.
This class represents a property in a property form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
updateUserNotifications($update_all_users=false)
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static _getThreads($a_obj_id, $a_sort_mode=self::SORT_DATE)
Get thread infos of object.
prepareOutput()
prepare output
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
getModifiedReOnSubject($on_reply=false)
static getSearchBlockHTML($a_title)
Get standar search block html.
static removeFromDesktop()
Remove item from personal desktop public.
static _getInstanceByType($a_type)
Factory method for creating purifier instances.
getRightColumnHTML()
Display right column.
cancelObject($in_rep=false)
setColumnSettings($column_gui)
May be overwritten in subclasses.
This class represents a non editable value in a property form.
global $ilUser
Definition: imgupload.php:15
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
global $ilSetting
Definition: privfeed.php:40
setFilenames($a_filenames)
Set filenames.
static _getRichTextEditorUserState()
Gets the state of the rich text editor visibility for the current user.
$path
Definition: index.php:22
This class represents a text area property in a property form.
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows) ...
This class handles all operations on files for the forum object.
addToDeskObject()
Add desktop item public.
getCreationMode()
get creation mode
getRefId()
get reference id public
handleFormInput($a_text, $a_stripslashes=true)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
static _lookupTitle($a_topic_id)
Looks up the title/subject of a topic/thread.
Class ilObjForum.
getEditFormCustomValues(Array &$a_values)
static redirect($a_script)
http redirect to other script
addHeaderAction()
Add header action menu.
getThreadEditingForm($a_thread_id)
$html
Definition: example_001.php:87
$params
Definition: example_049.php:96
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
setRequired($a_required)
Set Required.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
storeUploadedFile($files)
Store uploaded files in filesystem.
static formCheckbox($checked, $varname, $value, $disabled=false)
??? public
getUserNotificationTableData($user_ids, ilForumNotification $frm_noti)
static lookupForumIdByTopicId($a_topic_id)
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded) ...
Confirmation screen class.