ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 require_once 'Modules/Forum/classes/class.ilForumPostDraft.php';
16 require_once './Modules/Forum/classes/class.ilFileDataForumDrafts.php';
17 require_once './Modules/Forum/classes/class.ilForumUtil.php';
18 require_once './Modules/Forum/classes/class.ilForumDraftsHistory.php';
19 require_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
20 
34 {
35 
36  public $modal_history = '';
41 
46 
50  private $objCurrentPost;
51 
56 
60  private $is_moderator = false;
61 
66 
71 
75  private $replyEditForm;
76 
81 
85  private $hideToolbar = false;
86 
90  private $forum_overview_setting = null;
91 
95  public $object;
96 
100  public $ilias;
101 
105  private $forumObjects;
106 
107  public $access;
108  public $error;
109  public $settings;
110  public $user;
112 
117 
118  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
119  {
125  global $ilCtrl, $ilAccess, $ilObjDataCache, $ilErr, $ilSetting, $ilUser;
126 
127  $this->ctrl = $ilCtrl;
128  $this->ctrl->saveParameter($this, array('ref_id', 'cmdClass'));
129 
130  $this->type = 'frm';
131  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
132 
133  $this->lng->loadLanguageModule('forum');
134 
135  $this->initSessionStorage();
136 
137  // Forum properties
138  $this->objProperties = ilForumProperties::getInstance($ilObjDataCache->lookupObjId($_GET['ref_id']));
139 
140  // Stored due to performance issues
141  $this->is_moderator = $ilAccess->checkAccess('moderate_frm', '', $_GET['ref_id']);
142  $this->access = $ilAccess;
143  $this->error = $ilErr;
144  $this->settings = $ilSetting;
145  $this->user = $ilUser;
146  $this->ilObjDataCache = $ilObjDataCache;
147  // Model of current topic/thread
148  $this->objCurrentTopic = new ilForumTopic((int) $_GET['thr_pk'], $this->is_moderator);
149 
150  // Model of current post
151  $this->objCurrentPost = new ilForumPost((int) $_GET['pos_pk'], $this->is_moderator);
152 
153  $frma_set = new ilSetting('frma');
154  $this->forum_overview_setting = $frma_set->get('forum_overview');
155  }
156 
157  protected function initSessionStorage()
158  {
159  $sess = ilSession::get('frm');
160  if(!is_array($sess))
161  {
162  $sess = array();
163  ilSession::set('frm', $sess);
164  }
165 
166  if(isset($_GET['thr_fk']) && !is_array($sess[(int)$_GET['thr_fk']]))
167  {
168  $sess[(int)$_GET['thr_fk']] = array();
169  ilSession::set('frm', $sess);
170  }
171  }
172 
177  public function ensureThreadBelongsToForum($objId, \ilForumTopic $thread)
178  {
179  $forumId = \ilObjForum::lookupForumIdByObjId($objId);
180  if ((int)$thread->getForumId() !== (int)$forumId) {
181  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
182  }
183  }
184 
188  protected function addAutosave(ilPropertyFormGUI $form)
189  {
191  {
193 
194  $this->tpl->addJavascript('./Modules/Forum/js/autosave.js');
195  $autosave_cmd = 'autosaveDraftAsync';
196  if($this->objCurrentPost->getId() == 0 && $this->objCurrentPost->getThreadId() == 0)
197  {
198  $autosave_cmd = 'autosaveThreadDraftAsync';
199  }
200  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
201  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
202  $draft_id = $_GET['draft_id'] > 0 ? $_GET['draft_id']: 0;
203  $this->ctrl->setParameter($this, 'draft_id', $draft_id );
204  $this->ctrl->setParameter($this, 'action', $_GET['action']);
205  $this->tpl->addOnLoadCode("il.Language.setLangVar('saving', " . json_encode($this->lng->txt('saving')) . ");");
206 
207  $this->tpl->addOnLoadCode('il.ForumDraftsAutosave.init(' . json_encode(array(
208  'loading_img_src' => ilUtil::getImagePath('loader.svg'),
209  'draft_id' => $draft_id,
210  'interval' => $interval * 1000,
211  'url' => $this->ctrl->getFormAction($this, $autosave_cmd, '', true, false),
212  'selectors' => array(
213  'form' => '#form_' . $form->getId()
214  )
215  )) . ');');
216  }
217  }
218 
222  private function isHierarchicalView()
223  {
224  return (
225  $_SESSION['viewmode'] == 'answers' ||
227  ) || !(
228  $_SESSION['viewmode'] == 'date' ||
230  );
231  }
232 
236  private function isTopLevelReplyCommand()
237  {
238  return in_array(
239  strtolower($this->ctrl->getCmd()),
240  array_map('strtolower', array('createTopLevelPost', 'quoteTopLevelPost', 'saveTopLevelPost'))
241  );
242  }
243 
244  public function executeCommand()
245  {
254  global $ilNavigationHistory, $ilAccess, $ilCtrl, $ilTabs, $ilErr, $ilUser;
255 
256  $next_class = $this->ctrl->getNextClass($this);
257  $cmd = $this->ctrl->getCmd();
258 
259  $exclude_cmds = array(
260  'viewThread', 'markPostUnread','markPostRead', 'showThreadNotification',
261  'performPostActivation',
262  'askForPostActivation', 'askForPostDeactivation',
263  'toggleThreadNotification', 'toggleThreadNotificationTab',
264  'toggleStickiness', 'cancelPost', 'savePost', 'saveTopLevelPost', 'createTopLevelPost', 'quoteTopLevelPost', 'quotePost', 'getQuotationHTMLAsynch',
265  'autosaveDraftAsync', 'autosaveThreadDraftAsync',
266  'saveAsDraft', 'editDraft', 'updateDraft', 'deliverDraftZipFile', 'deliverZipFile', 'cancelDraft',
267  'publishThreadDraft', 'deleteThreadDrafts'
268  );
269 
270  if(!in_array($cmd, $exclude_cmds))
271  {
272  $this->prepareOutput();
273  }
274 
275  // add entry to navigation history
276  if(!$this->getCreationMode() && !$ilCtrl->isAsynch() && $ilAccess->checkAccess('read', '', $_GET['ref_id']))
277  {
278  $ilNavigationHistory->addItem($_GET['ref_id'],
279  'ilias.php?baseClass=ilRepositoryGUI&amp;cmd=showThreads&amp;ref_id='.$_GET['ref_id'], 'frm');
280  }
281 
282  switch ($next_class)
283  {
284  case 'ilrepositoryobjectsearchgui':
285  $this->addHeaderAction();
286  $this->setSideBlocks();
287  $ilTabs->setTabActive("forums_threads");
288  $ilCtrl->setReturn($this,'view');
289  include_once './Services/Search/classes/class.ilRepositoryObjectSearchGUI.php';
290  $search_gui = new ilRepositoryObjectSearchGUI(
291  $this->object->getRefId(),
292  $this,
293  'view'
294  );
295  $ilCtrl->forwardCommand($search_gui);
296  break;
297 
298  case 'ilpermissiongui':
299  require_once 'Services/AccessControl/classes/class.ilPermissionGUI.php';
300  $perm_gui = new ilPermissionGUI($this);
301  $this->ctrl->forwardCommand($perm_gui);
302  break;
303 
304  case 'ilforumexportgui':
305  require_once 'Modules/Forum/classes/class.ilForumExportGUI.php';
306  $fex_gui = new ilForumExportGUI($this);
307  $this->ctrl->forwardCommand($fex_gui);
308  exit();
309  break;
310 
311  case 'ilforummoderatorsgui':
312  require_once 'Modules/Forum/classes/class.ilForumModeratorsGUI.php';
313  $fm_gui = new ilForumModeratorsGUI($this);
314  $this->ctrl->forwardCommand($fm_gui);
315  break;
316 
317  case 'ilinfoscreengui':
318  $this->infoScreen();
319  break;
320 
321  case 'ilcolumngui':
322  $this->showThreadsObject();
323  break;
324 
325  case 'ilpublicuserprofilegui':
326  include_once 'Services/User/classes/class.ilPublicUserProfileGUI.php';
327  $profile_gui = new ilPublicUserProfileGUI((int)$_GET['user']);
328  $add = $this->getUserProfileAdditional((int)$_GET['ref_id'], (int)$_GET['user']);
329  $profile_gui->setAdditional($add);
330  $ret = $this->ctrl->forwardCommand($profile_gui);
331  $this->tpl->setContent($ret);
332  break;
333 
334  case 'ilobjectcopygui':
335  include_once 'Services/Object/classes/class.ilObjectCopyGUI.php';
336  $cp = new ilObjectCopyGUI($this);
337  $cp->setType('frm');
338  $this->ctrl->forwardCommand($cp);
339  break;
340 
341  case 'ilexportgui':
342  $ilTabs->setTabActive('export');
343  include_once 'Services/Export/classes/class.ilExportGUI.php';
344  $exp = new ilExportGUI($this);
345  $exp->addFormat('xml');
346  $this->ctrl->forwardCommand($exp);
347  break;
348 
349  case "ilratinggui":
350  if(!$this->objProperties->isIsThreadRatingEnabled() || $ilUser->isAnonymous())
351  {
352  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE);
353  }
354 
355  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
356  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
357  }
358 
359  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $this->objCurrentTopic);
360 
361  require_once 'Services/Rating/classes/class.ilRatingGUI.php';
362  $rating_gui = new ilRatingGUI();
363  $rating_gui->setObject($this->object->getId(), $this->object->getType(), $this->objCurrentTopic->getId(), 'thread');
364 
365  $this->ctrl->setParameter($this, 'thr_pk', (int)$this->objCurrentTopic->getId());
366  $this->ctrl->forwardCommand($rating_gui);
367 
368  $avg = ilRating::getOverallRatingForObject($this->object->getId(), $this->object->getType(), (int)$this->objCurrentTopic->getId(), 'thread');
369  $this->objCurrentTopic->setAverageRating($avg['avg']);
370  $this->objCurrentTopic->update();
371 
372  $ilCtrl->redirect($this, "showThreads");
373  break;
374 
375  case 'ilcommonactiondispatchergui':
376  include_once 'Services/Object/classes/class.ilCommonActionDispatcherGUI.php';
378  $this->ctrl->forwardCommand($gui);
379  break;
380 
381  default:
382  // alex, 11 Jan 2011:
383  // I inserted this workaround due to bug report 6971.
384  // In general the command handling is quite obscure here.
385  // The form action of the table should be filled
386  // with $ilCtrl->getFormAction(..) not with $ilCtrl->getLinkTarget(..)
387  // Commands should be determined with $ilCtrl->getCmd() not
388  // with accessing $_POST['selected_cmd'], since this is internal
389  // of ilTable2GUI/ilCtrl and may change.
390  if(isset($_POST['select_cmd2']))
391  {
392  $_POST['selected_cmd'] = $_POST["selected_cmd2"];
393  }
394 
395  if(isset($_POST['selected_cmd']) && $_POST['selected_cmd'] != null)
396  {
397  $member_cmd = array('enableAdminForceNoti', 'disableAdminForceNoti', 'enableHideUserToggleNoti', 'disableHideUserToggleNoti');
398  in_array($_POST['selected_cmd'], $member_cmd) ? $cmd = $_POST['selected_cmd'] : $cmd = 'performThreadsAction';
399  }
400  else if(!$cmd && !$_POST['selected_cmd'] )
401  {
402  $cmd = 'showThreads';
403  }
404 
405  $cmd .= 'Object';
406  $this->$cmd();
407 
408  break;
409  }
410 
411  // suppress for topic level
412  if($cmd != 'viewThreadObject' && $cmd != 'showUserObject')
413  {
414  $this->addHeaderAction();
415  }
416  }
417 
418  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
419  {
423  global $ilSetting;
424 
425  $this->settingsTabs();
426 
427  //sorting for threads
428  $cb_sort = new ilCheckboxInputGUI($this->lng->txt('sorting_manual_sticky'), 'thread_sorting');
429  $cb_sort->setValue('1');
430  $cb_sort->setInfo($this->lng->txt('sticky_threads_always_on_top'));
431  $a_form->addItem($cb_sort);
432 
433  // sorting for postings
434  $rg_pro = new ilRadioGroupInputGUI($this->lng->txt('frm_default_view'), 'default_view');
435 
436  $rg_pro->addOption(new ilRadioOption($this->lng->txt('sort_by_posts'), ilForumProperties::VIEW_TREE));
437  $rg_sort_by_date = new ilRadioOption($this->lng->txt('sort_by_date'), ilForumProperties::VIEW_DATE);
438  $rg_pro->addOption($rg_sort_by_date);
439 
440  $view_direction_group_gui = new ilRadioGroupInputGUI('', 'default_view_sort_dir');
441  $view_desc = new ilRadioOption($this->lng->txt('descending_order'), ilForumProperties::VIEW_DATE_DESC);
442  $view_asc = new ilRadioOption($this->lng->txt('ascending_order'), ilForumProperties::VIEW_DATE_ASC);
443  $view_direction_group_gui->addOption($view_desc);
444  $view_direction_group_gui->addOption($view_asc);
445 
446  $rg_sort_by_date->addSubItem($view_direction_group_gui);
447  $a_form->addItem($rg_pro);
448 
449  if($ilSetting->get('enable_anonymous_fora') || $this->objProperties->isAnonymized())
450  {
451  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('frm_anonymous_posting'), 'anonymized');
452  $cb_prop->setValue('1');
453  $cb_prop->setInfo($this->lng->txt('frm_anonymous_posting_desc'));
454  $a_form->addItem($cb_prop);
455  }
456  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('mark_moderator_posts'), 'mark_mod_posts');
457  $cb_prop->setValue('1');
458  $cb_prop->setInfo($this->lng->txt('mark_moderator_posts_desc'));
459  $a_form->addItem($cb_prop);
460 
461  if($ilSetting->get('enable_fora_statistics', false))
462  {
463  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('frm_statistics_enabled'), 'statistics_enabled');
464  $cb_prop->setValue('1');
465  $cb_prop->setInfo($this->lng->txt('frm_statistics_enabled_desc'));
466  $a_form->addItem($cb_prop);
467  }
468 
469  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('activate_new_posts'), 'post_activation');
470  $cb_prop->setValue('1');
471  $cb_prop->setInfo($this->lng->txt('post_activation_desc'));
472  $a_form->addItem($cb_prop);
473 
474  $frm_subject = new ilRadioGroupInputGUI($this->lng->txt('frm_subject_setting'), 'subject_setting');
475  $frm_subject->addOption(new ilRadioOption($this->lng->txt('preset_subject'), 'preset_subject'));
476  $frm_subject->addOption(new ilRadioOption($this->lng->txt('add_re_to_subject'), 'add_re_to_subject'));
477  $frm_subject->addOption(new ilRadioOption($this->lng->txt('empty_subject'), 'empty_subject'));
478 
479  $a_form->addItem($frm_subject);
480 
481  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('enable_thread_ratings'), 'thread_rating');
482  $cb_prop->setValue(1);
483  $cb_prop->setInfo($this->lng->txt('enable_thread_ratings_info'));
484  $a_form->addItem($cb_prop);
485 
486  if(!ilForumProperties::isFileUploadGloballyAllowed())
487  {
488  $frm_upload = new ilCheckboxInputGUI($this->lng->txt('file_upload_allowed'), 'file_upload_allowed');
489  $frm_upload->setValue(1);
490  $frm_upload->setInfo($this->lng->txt('allow_file_upload_desc'));
491  $a_form->addItem($frm_upload);
492  }
493  }
494 
495  protected function getEditFormCustomValues(Array &$a_values)
496  {
497  $a_values["desc"] = $this->object->getLongDescription();
498  $a_values['default_view'] = $this->objProperties->getDefaultView();
499  $a_values['anonymized'] = $this->objProperties->isAnonymized();
500  $a_values['statistics_enabled'] = $this->objProperties->isStatisticEnabled();
501  $a_values['post_activation'] = $this->objProperties->isPostActivationEnabled();
502  $a_values['subject_setting'] = $this->objProperties->getSubjectSetting();
503  $a_values['mark_mod_posts'] = $this->objProperties->getMarkModeratorPosts();
504  $a_values['thread_sorting'] = $this->objProperties->getThreadSorting();
505  $a_values['thread_rating'] = $this->objProperties->isIsThreadRatingEnabled();
506 
507  $default_view =
508  in_array((int)$this->objProperties->getDefaultView(), array(ilForumProperties::VIEW_DATE_ASC, ilForumProperties::VIEW_DATE_DESC))
511  $a_values['default_view'] = $default_view;
512 
513  $default_view_sort_dir =
514  (int)$this->objProperties->getDefaultView() != (int)ilForumProperties::VIEW_TREE
515  ? (int)$this->objProperties->getDefaultView()
517 
518  $a_values['default_view_sort_dir'] = $default_view_sort_dir;
519  $a_values['file_upload_allowed'] = (bool)$this->objProperties->getFileUploadAllowed();
520  }
521 
522  protected function updateCustom(ilPropertyFormGUI $a_form)
523  {
527  global $ilSetting;
528 
529  $view = (int)$_POST['default_view'];
530  if($view == ilForumProperties::VIEW_DATE)
531  {
533  if((int)$_POST['default_view_sort_dir'] == ilForumProperties::VIEW_DATE_DESC)
534  {
536  }
537  }
538  $this->objProperties->setDefaultView($view);
539 
540  // BUGFIX FOR 11271
541  if(isset($_SESSION['viewmode']))
542  {
543  $_SESSION['viewmode'] = $view;
544  }
545 
546  if($ilSetting->get('enable_anonymous_fora') || $this->objProperties->isAnonymized())
547  {
548  $this->objProperties->setAnonymisation((int) $a_form->getInput('anonymized'));
549  }
550  if($ilSetting->get('enable_fora_statistics', false))
551  {
552  $this->objProperties->setStatisticsStatus((int) $a_form->getInput('statistics_enabled'));
553  }
554  $this->objProperties->setPostActivation((int) $a_form->getInput('post_activation'));
555  $this->objProperties->setSubjectSetting( $a_form->getInput('subject_setting'));
556  $this->objProperties->setMarkModeratorPosts((int) $a_form->getInput('mark_mod_posts'));
557  $this->objProperties->setThreadSorting((int)$a_form->getInput('thread_sorting'));
558  $this->objProperties->setIsThreadRatingEnabled((bool)$a_form->getInput('thread_rating'));
559  if(!ilForumProperties::isFileUploadGloballyAllowed())
560  {
561  $this->objProperties->setFileUploadAllowed((bool)$a_form->getInput('file_upload_allowed'));
562  }
563 
564  $this->objProperties->update();
565  }
566 
571  private function getThreadEditingForm($a_thread_id)
572  {
573  $form = new ilPropertyFormGUI();
574  $this->ctrl->setParameter($this, 'thr_pk', $a_thread_id);
575  $form->setFormAction($this->ctrl->getFormAction($this, 'updateThread'));
576 
577  $ti_prop = new ilTextInputGUI($this->lng->txt('title'), 'title');
578  $ti_prop->setRequired(true);
579  $ti_prop->setMaxLength(255);
580  $ti_prop->setSize(50);
581  $form->addItem($ti_prop);
582 
583  $form->addCommandButton('updateThread', $this->lng->txt('save'));
584  $form->addCommandButton('showThreads', $this->lng->txt('cancel'));
585 
586  return $form;
587  }
588 
593  public function editThreadObject($a_thread_id, ilPropertyFormGUI $form = null)
594  {
598  global $ilTabs;
599 
600  if(!$this->is_moderator)
601  {
602  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
603  }
604 
605  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
606  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
607  }
608 
609  $thread = new \ilForumTopic($a_thread_id);
610  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $thread);
611 
612  $ilTabs->setTabActive('forums_threads');
613 
614  if(!($form instanceof ilPropertyFormGUI))
615  {
616  $form = $this->getThreadEditingForm($a_thread_id);
617  $form->setValuesByArray(array(
618  'title' => $thread->getSubject()
619  ));
620  }
621 
622  $this->tpl->setContent($form->getHTML());
623  }
624 
628  public function updateThreadObject()
629  {
630  if(!$this->is_moderator)
631  {
632  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
633  }
634 
635  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
636  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
637  }
638 
639  if (!$this->objCurrentTopic->getId()) {
640  $this->showThreadsObject();
641  return;
642  }
643 
644  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $this->objCurrentTopic);
645 
646  $form = $this->getThreadEditingForm($this->objCurrentTopic->getId());
647  if(!$form->checkInput())
648  {
649  $form->setValuesByPost();
650  $this->editThreadObject($this->objCurrentTopic->getId(), $form);
651  return;
652  }
653 
654  $this->objCurrentTopic->setSubject($form->getInput('title'));
655  $this->objCurrentTopic->updateThreadTitle();
656 
657  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
658  $this->showThreadsObject();
659  }
660 
661  public function markAllReadObject()
662  {
666  global $ilUser;
667 
668  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
669  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
670  }
671 
672  $this->object->markAllThreadsRead($ilUser->getId());
673  ilUtil::sendInfo($this->lng->txt('forums_all_threads_marked_read'));
674 
675  $this->showThreadsObject();
676  }
677 
678  public function showThreadsObject()
679  {
680  $this->getSubTabs('showThreads');
681  $this->setSideBlocks();
682  $this->getCenterColumnHTML();
683  }
684  public function sortThreadsObject()
685  {
686  $this->getSubTabs('sortThreads');
687  $this->setSideBlocks();
688  $this->getCenterColumnHTML(true);
689  }
690 
691 
692  public function getSubTabs($subtab = 'showThreads')
693  {
694  global $ilTabs;
695 
696  if($this->objProperties->getThreadSorting() == 1 && $this->is_moderator)
697  {
698  $ilTabs->addSubTabTarget('show', $this->ctrl->getLinkTarget($this, 'showThreads'), 'showThreads', get_class($this), '', $subtab=='showThreads'? true : false );
699  $ilTabs->addSubTabTarget('sorting_header', $this->ctrl->getLinkTarget($this, 'sortThreads'), 'sortThreads', get_class($this), '', $subtab=='sortThreads'? true : false );
700  }
701  }
702  public function getContent()
703  {
710  global $ilUser, $ilAccess, $lng, $ilToolbar;
711 
712  if(!$ilAccess->checkAccess('read', '', $this->object->getRefId()))
713  {
714  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
715  }
716 
717  $cmd = $this->ctrl->getCmd();
718  $frm = $this->object->Forum;
719  $frm->setForumId($this->object->getId());
720  $frm->setForumRefId($this->object->getRefId());
721  $frm->setMDB2Wherecondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
722 
723  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_liste.html', 'Modules/Forum');
724 
725  if((int)strlen($this->confirmation_gui_html))
726  {
727  $this->tpl->setVariable('CONFIRMATION_GUI', $this->confirmation_gui_html);
728  }
729 
730  // Create topic button
731  if($ilAccess->checkAccess('add_thread', '', $this->object->getRefId()) && !$this->hideToolbar())
732  {
733  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
734  $btn = ilLinkButton::getInstance();
735  $btn->setUrl($this->ctrl->getLinkTarget($this, 'createThread'));
736  $btn->setCaption('forums_new_thread');
737  $ilToolbar->addStickyItem($btn);
738  }
739 
740  // Mark all topics as read button
741  include_once 'Services/Accessibility/classes/class.ilAccessKeyGUI.php';
742  if($ilUser->getId() != ANONYMOUS_USER_ID && !(int)strlen($this->confirmation_gui_html))
743  {
744  $ilToolbar->addButton(
745  $this->lng->txt('forums_mark_read'),
746  $this->ctrl->getLinkTarget($this, 'markAllRead'),
747  '',
749  );
750  $this->ctrl->clearParameters($this);
751  }
752 
754  {
755  include_once './Modules/Forum/classes/class.ilForumDraftsTableGUI.php';
756  $drafts_tbl = new ilForumDraftsTableGUI($this, $cmd, '');
757  $draft_instances = ilForumPostDraft::getThreadDraftData($ilUser->getId(), ilObjForum::lookupForumIdByObjId($this->object->getId()));
758  if(count($draft_instances)> 0)
759  {
760  foreach($draft_instances as $draft)
761  {
762  $drafts_tbl->fillRow($draft);
763  }
764  $drafts_tbl->setData($draft_instances);
765  $this->tpl->setVariable('THREADS_DRAFTS_TABLE', $drafts_tbl->getHTML());
766  }
767  }
768 
769  // Import information: Topic (variable $topicData) means frm object, not thread
770  $topicData = $frm->getOneTopic();
771  if($topicData)
772  {
773  // Visit-Counter
774  $frm->setDbTable('frm_data');
775  $frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($topicData['top_pk']));
776  $frm->updateVisits($topicData['top_pk']);
777 
778  include_once 'Modules/Forum/classes/class.ilForumTopicTableGUI.php';
779  if(!in_array($cmd, array('showThreads', 'sortThreads') ))
780  {
781  $cmd = 'showThreads';
782  }
783 
784  $tbl = new ilForumTopicTableGUI($this, $cmd, '', (int) $_GET['ref_id'], $topicData, $this->is_moderator, $this->forum_overview_setting);
785  $tbl->init();
786  $tbl->setMapper($frm)->fetchData();
787  $this->tpl->setVariable('THREADS_TABLE', $tbl->getHTML());
788  }
789 
790  // Permanent link
791  include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
792  $permalink = new ilPermanentLinkGUI('frm', $this->object->getRefId());
793  $this->tpl->setVariable('PRMLINK', $permalink->getHTML());
794  }
801  protected function renderDraftContent($render_drafts, $node, $edit_draft_id = NULL)
802  {
809  global $tpl, $lng, $rbacreview, $ilUser;
810 
811  $frm = $this->object->Forum;
812 
813  $draftsObjects = ilForumPostDraft::getInstancesByUserIdAndThreadId($ilUser->getId(), $this->objCurrentTopic->getId());
814  $drafts = $draftsObjects[$node->getId()];
815 
816  if($render_drafts && is_array($drafts))
817  {
818  foreach($drafts as $draft)
819  {
820  if(!$draft instanceof ilForumPostDraft)
821  {
822  continue 1;
823  }
824 
825  if(isset($edit_draft_id) && $edit_draft_id == $node->getId())
826  {
827  // do not render a draft that is in 'edit'-mode
828  return false;
829  }
830 
831  $tmp_file_obj = new ilFileDataForumDrafts($this->object->getId(), $draft->getDraftId());
832  $filesOfDraft = $tmp_file_obj->getFilesOfPost();
833  ksort($filesOfDraft);
834 
835  if(count($filesOfDraft))
836  {
837  if($_GET['action'] != 'showdraft' || $_GET['action'] == 'editdraft')
838  {
839  foreach($filesOfDraft as $file)
840  {
841  $tpl->setCurrentBlock('attachment_download_row');
842  $this->ctrl->setParameter($this, 'draft_id', $tmp_file_obj->getDraftId());
843  $this->ctrl->setParameter($this, 'file', $file['md5']);
844  $tpl->setVariable('HREF_DOWNLOAD', $this->ctrl->getLinkTarget($this, 'viewThread'));
845  $tpl->setVariable('TXT_FILENAME', $file['name']);
846  $this->ctrl->setParameter($this, 'file', '');
847  $this->ctrl->setParameter($this, 'draft_id', '');
848  $this->ctrl->clearParameters($this);
849  $tpl->parseCurrentBlock();
850  }
851 
852  $tpl->setCurrentBlock('attachments');
853  $tpl->setVariable('TXT_ATTACHMENTS_DOWNLOAD', $lng->txt('forums_attachments'));
854  include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
855  $tpl->setVariable('DOWNLOAD_IMG', ilGlyphGUI::get(ilGlyphGUI::ATTACHMENT, $lng->txt('forums_download_attachment')));
856  if(count($filesOfDraft) > 1)
857  {
858  $download_zip_button = ilLinkButton::getInstance();
859  $download_zip_button->setCaption($lng->txt('download'), false);
860  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
861  $download_zip_button->setUrl($this->ctrl->getLinkTarget($this, 'deliverDraftZipFile'));
862  $this->ctrl->setParameter($this, 'draft_id', '');
863  $tpl->setVariable('DOWNLOAD_ZIP', $download_zip_button->render());
864  }
865  $tpl->parseCurrentBlock();
866  }
867  }
868 
869  // render splitButton for drafts
870  $this->renderSplitButton(false, $node, (int)$_GET['offset'], $draft);
871 
872  // highlight drafts
873  //@todo change this...
874  // $rowCol = 'tblrowdraft';
875  $rowCol = 'tblrowmarked';
876  // set row color
877  $tpl->setVariable('ROWCOL', ' ' . $rowCol);
878 
879  // Author
880  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
881  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
882  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
883 
884  $backurl = urlencode($this->ctrl->getLinkTarget($this, 'viewThread', $node->getId()));
885 
886  $this->ctrl->setParameter($this, 'backurl', $backurl);
887  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
888  $this->ctrl->setParameter($this, 'user', $draft->getPostDisplayUserId());
889 
890  require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
891  $authorinfo = new ilForumAuthorInformation(
892  $draft->getPostAuthorId(),
893  $draft->getPostDisplayUserId(),
894  $draft->getPostUserAlias(),
895  '',
896  array(
897  'href' => $this->ctrl->getLinkTarget($this, 'showUser')
898  )
899  );
900 
901  $this->ctrl->clearParameters($this);
902 
903  if($authorinfo->hasSuffix())
904  {
905  $tpl->setVariable('AUTHOR', $authorinfo->getSuffix());
906  $tpl->setVariable('USR_NAME', $draft->getPostUserAlias());
907  }
908  else
909  {
910  $tpl->setVariable('AUTHOR', $authorinfo->getLinkedAuthorShortName());
911  if($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized())
912  {
913  $tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true));
914  }
915  }
916  $tpl->setVariable('DRAFT_ANCHOR', 'draft_' . $draft->getDraftId());
917 
918  $tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture());
919  if($authorinfo->getAuthor()->getId() && ilForum::_isModerator((int)$_GET['ref_id'], $draft->getPostAuthorId()))
920  {
921  if($authorinfo->getAuthor()->getGender() == 'f')
922  {
923  $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_f'));
924  }
925  else if($authorinfo->getAuthor()->getGender() == 'm')
926  {
927  $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_m'));
928  }
929  }
930 
931  // get create- and update-dates
932  if($draft->getUpdateUserId() > 0)
933  {
934  $spanClass = '';
935 
936  // last update from moderator?
937  $posMod = $frm->getModeratorFromPost($node->getId());
938 
939  if(is_array($posMod) && $posMod['top_mods'] > 0)
940  {
941  $MODS = $rbacreview->assignedUsers($posMod['top_mods']);
942 
943  if(is_array($MODS))
944  {
945  if(in_array($node->getUpdateUserId(), $MODS))
946  $spanClass = 'moderator_small';
947  }
948  }
949 
950  $draft->setPostUpdate($draft->getPostUpdate());
951 
952  if($spanClass == '') $spanClass = 'small';
953 
954  $this->ctrl->setParameter($this, 'backurl', $backurl);
955  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
956  $this->ctrl->setParameter($this, 'user', $node->getUpdateUserId());
957  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
958  require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
959  $authorinfo = new ilForumAuthorInformation(
960  $draft->getPostAuthorId(),
961  $draft->getUpdateUserId(),
962  $draft->getPostUserAlias(),
963  '',
964  array(
965  'href' => $this->ctrl->getLinkTarget($this, 'showUser')
966  )
967  );
968 
969  $this->ctrl->clearParameters($this);
970 
971  $tpl->setVariable('POST_UPDATE_TXT', $lng->txt('edited_on') . ': ' . $frm->convertDate($draft->getPostUpdate()) . ' - ' . strtolower($lng->txt('by')));
972  $tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
973  if($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix())
974  {
975  $tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true));
976  }
977  }
978  // Author end
979 
980  // prepare post
981  $draft->setPostMessage($frm->prepareText($draft->getPostMessage()));
982 
983  $tpl->setVariable('SUBJECT', $draft->getPostSubject());
984  $tpl->setVariable('POST_DATE', $frm->convertDate($draft->getPostDate()));
985 
986  if(!$node->isCensored() ||
987  ($this->objCurrentPost->getId() == $node->getId() && $_GET['action'] == 'censor')
988  )
989  {
990  // post from moderator?
991  $modAuthor = $frm->getModeratorFromPost($node->getId());
992 
993  $spanClass = "";
994 
995  if(is_array($modAuthor) && $modAuthor['top_mods'] > 0)
996  {
997  unset($MODS);
998 
999  $MODS = $rbacreview->assignedUsers($modAuthor['top_mods']);
1000 
1001  if(is_array($MODS))
1002  {
1003  if(in_array($draft->getPostDisplayUserId(), $MODS))
1004  $spanClass = 'moderator';
1005  }
1006  }
1007 
1008  if($draft->getPostMessage() == strip_tags($draft->getPostMessage()))
1009  {
1010  // We can be sure, that there are not html tags
1011  $draft->setPostMessage(nl2br($draft->getPostMessage()));
1012  }
1013 
1014  if($spanClass != "")
1015  {
1016  $tpl->setVariable('POST', "<span class=\"" . $spanClass . "\">" . ilRTE::_replaceMediaObjectImageSrc($draft->getPostMessage(), 1) . "</span>");
1017  }
1018  else
1019  {
1020  $tpl->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($draft->getPostMessage(), 1));
1021  }
1022  }
1023  if(!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'deletedraft')
1024  {
1025  if($ilUser->getId() != ANONYMOUS_USER_ID && $draft->getDraftId() == (int)$_GET['draft_id'])
1026  {
1027  // confirmation: delete
1028  $tpl->setVariable('FORM', $this->getDeleteDraftFormHTML());
1029  }
1030  }
1031  else if($_GET['action'] == 'editdraft' && $draft->getDraftId() == (int)$_GET['draft_id'])
1032  {
1033  $oEditReplyForm = $this->getReplyEditForm();
1034  $tpl->setVariable('EDIT_DRAFT_ANCHOR', 'draft_edit_' . $draft->getDraftId());
1035  $tpl->setVariable('DRAFT_FORM', $oEditReplyForm->getHTML(). $this->modal_history);
1036  }
1037 
1038  $tpl->parseCurrentBlock();
1039  }
1040  return true;
1041  }
1042  return true;
1043  }
1044 
1050  protected function renderPostContent(ilForumPost $node, $Start, $z)
1051  {
1058  global $tpl, $lng, $rbacreview, $ilUser;
1059 
1060  $forumObj = $this->object;
1061  $frm = $this->object->Forum;
1062 
1063  // download post attachments
1064  $tmp_file_obj = new ilFileDataForum($forumObj->getId(), $node->getId());
1065 
1066  $filesOfPost = $tmp_file_obj->getFilesOfPost();
1067  ksort($filesOfPost);
1068  if(count($filesOfPost))
1069  {
1070  if($node->getId() != $this->objCurrentPost->getId() || $_GET['action'] != 'showedit')
1071  {
1072  foreach($filesOfPost as $file)
1073  {
1074  $tpl->setCurrentBlock('attachment_download_row');
1075  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
1076  $this->ctrl->setParameter($this, 'file', $file['md5']);
1077  $tpl->setVariable('HREF_DOWNLOAD', $this->ctrl->getLinkTarget($this, 'viewThread'));
1078  $tpl->setVariable('TXT_FILENAME', $file['name']);
1079  $this->ctrl->clearParameters($this);
1080  $tpl->parseCurrentBlock();
1081  }
1082  $tpl->setCurrentBlock('attachments');
1083  $tpl->setVariable('TXT_ATTACHMENTS_DOWNLOAD', $lng->txt('forums_attachments'));
1084  include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
1085  $tpl->setVariable('DOWNLOAD_IMG', ilGlyphGUI::get(ilGlyphGUI::ATTACHMENT, $lng->txt('forums_download_attachment')));
1086  if(count($filesOfPost) > 1)
1087  {
1088  $download_zip_button = ilLinkButton::getInstance();
1089  $download_zip_button->setCaption($lng->txt('download'), false);
1090  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
1091  $download_zip_button->setUrl($this->ctrl->getLinkTarget($this, 'deliverZipFile'));
1092 
1093  $tpl->setVariable('DOWNLOAD_ZIP', $download_zip_button->render());
1094  }
1095 
1096  $tpl->parseCurrentBlock();
1097  }
1098  }
1099  // render splitbutton for posts
1100  $this->renderSplitButton(true, $node, $Start);
1101 
1102  // anker for every post
1103  $tpl->setVariable('POST_ANKER', $node->getId());
1104 
1105  //permanent link for every post
1106  $tpl->setVariable('TXT_PERMA_LINK', $lng->txt('perma_link'));
1107  $tpl->setVariable('PERMA_TARGET', '_top');
1108 
1109  if(!$node->isActivated() && !$this->objCurrentTopic->isClosed() && $this->is_moderator)
1110  {
1111  $rowCol = 'ilPostingNeedsActivation';
1112  }
1113  else if($this->objProperties->getMarkModeratorPosts() == 1)
1114  {
1115  if($node->getIsAuthorModerator() === null && $is_moderator = ilForum::_isModerator($_GET['ref_id'], $node->getPosAuthorId()))
1116  {
1117  $rowCol = 'ilModeratorPosting';
1118  }
1119  elseif($node->getIsAuthorModerator())
1120  {
1121  $rowCol = 'ilModeratorPosting';
1122  }
1123  else $rowCol = ilUtil::switchColor($z, 'tblrow1', 'tblrow2');
1124  }
1125  else $rowCol = ilUtil::switchColor($z, 'tblrow1', 'tblrow2');
1126  if(($_GET['action'] != 'delete' && $_GET['action'] != 'censor' &&
1128  )
1129  || $this->objCurrentPost->getId() != $node->getId()
1130  )
1131  {
1132  $tpl->setVariable('ROWCOL', ' ' . $rowCol);
1133  }
1134  else
1135  {
1136  // highlight censored posts
1137  $rowCol = 'tblrowmarked';
1138  }
1139 
1140  // post is censored
1141  if($node->isCensored())
1142  {
1143  // display censorship advice
1144  if($_GET['action'] != 'censor')
1145  {
1146  $tpl->setVariable('TXT_CENSORSHIP_ADVICE', $this->lng->txt('post_censored_comment_by_moderator'));
1147  }
1148 
1149  // highlight censored posts
1150  $rowCol = 'tblrowmarked';
1151  }
1152 
1153  // set row color
1154  $tpl->setVariable('ROWCOL', ' ' . $rowCol);
1155  // if post is not activated display message for the owner
1156  if(!$node->isActivated() && $node->isOwner($ilUser->getId()))
1157  {
1158  $tpl->setVariable('POST_NOT_ACTIVATED_YET', $this->lng->txt('frm_post_not_activated_yet'));
1159  }
1160 
1161  // Author
1162  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
1163  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
1164  $backurl = urlencode($this->ctrl->getLinkTarget($this, 'viewThread', $node->getId()));
1165  $this->ctrl->clearParameters($this);
1166 
1167  $this->ctrl->setParameter($this, 'backurl', $backurl);
1168  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
1169  $this->ctrl->setParameter($this, 'user', $node->getDisplayUserId());
1170 
1171  require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
1172  $authorinfo = new ilForumAuthorInformation(
1173  $node->getPosAuthorId(),
1174  $node->getDisplayUserId(),
1175  $node->getUserAlias(),
1176  $node->getImportName(),
1177  array(
1178  'href' => $this->ctrl->getLinkTarget($this, 'showUser')
1179  )
1180  );
1181 
1182  $this->ctrl->clearParameters($this);
1183 
1184  if($authorinfo->hasSuffix())
1185  {
1186  $tpl->setVariable('AUTHOR', $authorinfo->getSuffix());
1187  $tpl->setVariable('USR_NAME', $node->getUserAlias());
1188  }
1189  else
1190  {
1191  $tpl->setVariable('AUTHOR', $authorinfo->getLinkedAuthorShortName());
1192  if($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized())
1193  {
1194  $tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true));
1195  }
1196  }
1197 
1198  $tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture());
1199  if($authorinfo->getAuthor()->getId() && ilForum::_isModerator((int)$_GET['ref_id'], $node->getPosAuthorId()))
1200  {
1201  if($authorinfo->getAuthor()->getGender() == 'f')
1202  {
1203  $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_f'));
1204  }
1205  else if($authorinfo->getAuthor()->getGender() == 'm')
1206  {
1207  $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_m'));
1208  }
1209  }
1210 
1211  // get create- and update-dates
1212  if($node->getUpdateUserId() > 0)
1213  {
1214  $spanClass = '';
1215 
1216  // last update from moderator?
1217  $posMod = $frm->getModeratorFromPost($node->getId());
1218 
1219  if(is_array($posMod) && $posMod['top_mods'] > 0)
1220  {
1221  $MODS = $rbacreview->assignedUsers($posMod['top_mods']);
1222 
1223  if(is_array($MODS))
1224  {
1225  if(in_array($node->getUpdateUserId(), $MODS))
1226  $spanClass = 'moderator_small';
1227  }
1228  }
1229 
1230  $node->setChangeDate($node->getChangeDate());
1231 
1232  if($spanClass == '') $spanClass = 'small';
1233 
1234  $this->ctrl->setParameter($this, 'backurl', $backurl);
1235  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
1236  $this->ctrl->setParameter($this, 'user', $node->getUpdateUserId());
1237 
1238  $update_user_id = $node->getUpdateUserId();
1239  if($node->getPosAuthorId() == $node->getUpdateUserId()
1240  && $node->getDisplayUserId() == 0)
1241  {
1242  $update_user_id = $node->getDisplayUserId();
1243  }
1244  require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
1245  $authorinfo = new ilForumAuthorInformation(
1246  $node->getPosAuthorId(),
1247  $update_user_id,
1248  $node->getUserAlias(),
1249  $node->getImportName(),
1250  array(
1251  'href' => $this->ctrl->getLinkTarget($this, 'showUser')
1252  )
1253  );
1254 
1255  $this->ctrl->clearParameters($this);
1256 
1257  $tpl->setVariable('POST_UPDATE_TXT', $lng->txt('edited_on') . ': ' . $frm->convertDate($node->getChangeDate()) . ' - ' . strtolower($lng->txt('by')));
1258  $tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
1259  if($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix())
1260  {
1261  $tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true));
1262  }
1263 
1264  } // if ($node->getUpdateUserId() > 0)*/
1265  // Author end
1266 
1267  // prepare post
1268  $node->setMessage($frm->prepareText($node->getMessage()));
1269 
1270  if($ilUser->getId() == ANONYMOUS_USER_ID ||
1271  $node->isPostRead()
1272  )
1273  {
1274  $tpl->setVariable('SUBJECT', $node->getSubject());
1275  }
1276  else
1277  {
1278  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
1279  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
1280  $this->ctrl->setParameter($this, 'offset', $Start);
1281  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
1282  $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
1283  $mark_post_target = $this->ctrl->getLinkTarget($this, 'markPostRead', $node->getId());
1284 
1285  $tpl->setVariable('SUBJECT', "<a href=\"" . $mark_post_target . "\"><b>" . $node->getSubject() . "</b></a>");
1286  }
1287 
1288  $tpl->setVariable('POST_DATE', $frm->convertDate($node->getCreateDate()));
1289 
1290  if(!$node->isCensored() ||
1291  ($this->objCurrentPost->getId() == $node->getId() && $_GET['action'] == 'censor')
1292  )
1293  {
1294  // post from moderator?
1295  $modAuthor = $frm->getModeratorFromPost($node->getId());
1296 
1297  $spanClass = "";
1298 
1299  if(is_array($modAuthor) && $modAuthor['top_mods'] > 0)
1300  {
1301  unset($MODS);
1302 
1303  $MODS = $rbacreview->assignedUsers($modAuthor['top_mods']);
1304 
1305  if(is_array($MODS))
1306  {
1307  if(in_array($node->getDisplayUserId(), $MODS))
1308  $spanClass = 'moderator';
1309  }
1310  }
1311 
1312  // possible bugfix for mantis #8223
1313  if($node->getMessage() == strip_tags($node->getMessage()))
1314  {
1315  // We can be sure, that there are not html tags
1316  $node->setMessage(nl2br($node->getMessage()));
1317  }
1318 
1319  if($spanClass != "")
1320  {
1321  $tpl->setVariable('POST', "<span class=\"" . $spanClass . "\">" . ilRTE::_replaceMediaObjectImageSrc($node->getMessage(), 1) . "</span>");
1322  }
1323  else
1324  {
1325  $tpl->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($node->getMessage(), 1));
1326  }
1327  }
1328  else
1329  {
1330  $tpl->setVariable('POST', "<span class=\"moderator\">" . nl2br($node->getCensorshipComment()) . "</span>");
1331  }
1332 
1333  $tpl->parseCurrentBlock();
1334  return true;
1335  }
1336 
1340  private function initForumCreateForm($object_type)
1341  {
1342  $this->create_form_gui = new ilPropertyFormGUI();
1343  $this->create_form_gui->setTableWidth('600px');
1344 
1345  $this->create_form_gui->setTitle($this->lng->txt('frm_new'));
1346  $this->create_form_gui->setTitleIcon(ilUtil::getImagePath('icon_frm.svg'));
1347 
1348  // form action
1349  $this->ctrl->setParameter($this, 'new_type', $object_type);
1350  $this->create_form_gui->setFormAction($this->ctrl->getFormAction($this, 'save'));
1351 
1352  // title
1353  $title_gui = new ilTextInputGUI($this->lng->txt('title'), 'title');
1354  $title_gui->setSize(min(40, ilObject::TITLE_LENGTH));
1355  $title_gui->setMaxLength(ilObject::TITLE_LENGTH);
1356  $this->create_form_gui->addItem($title_gui);
1357 
1358  // description
1359  $description_gui = new ilTextAreaInputGUI($this->lng->txt('desc'), 'desc');
1360  $description_gui->setCols(40);
1361  $description_gui->setRows(2);
1362  $this->create_form_gui->addItem($description_gui);
1363 
1364  // view sorting threads
1365  $sort_man = new ilCheckboxInputGUI($this->lng->txt('sorting_manual_sticky'), 'thread_sorting');
1366  $sort_man->setInfo($this->lng->txt('sticky_threads_always_on_top'));
1367  $sort_man->setValue(1);
1368  $this->create_form_gui->addItem($sort_man);
1369 
1370  // view
1371  $view_group_gui = new ilRadioGroupInputGUI($this->lng->txt('frm_default_view'), 'sort');
1372  $view_hir = new ilRadioOption($this->lng->txt('order_by').' '.$this->lng->txt('answers'), ilForumProperties::VIEW_TREE);
1373  $view_group_gui->addOption($view_hir);
1374  $view_dat = new ilRadioOption($this->lng->txt('order_by').' '.$this->lng->txt('date'), ilForumProperties::VIEW_DATE);
1375  $view_group_gui->addOption($view_dat);
1376  $this->create_form_gui->addItem($view_group_gui);
1377  $view_direction_group_gui = new ilRadioGroupInputGUI('', 'default_view_sort_dir');
1378  $view_desc = new ilRadioOption($this->lng->txt('frm_post_sort_desc'), ilForumProperties::VIEW_DATE_DESC);
1379  $view_direction_group_gui->addOption($view_desc);
1380  $view_asc = new ilRadioOption($this->lng->txt('frm_post_sort_asc'), ilForumProperties::VIEW_DATE_ASC);
1381  $view_direction_group_gui->addOption($view_asc);
1382  $view_dat->addSubItem($view_direction_group_gui);
1383 
1384  // anonymized or not
1385  $anonymize_gui = new ilCheckboxInputGUI($this->lng->txt('frm_anonymous_posting'), 'anonymized');
1386  $anonymize_gui->setInfo($this->lng->txt('frm_anonymous_posting_desc'));
1387  $anonymize_gui->setValue(1);
1388 
1389  if($this->ilias->getSetting('enable_anonymous_fora', false))
1390  $anonymize_gui->setDisabled(true);
1391  $this->create_form_gui->addItem($anonymize_gui);
1392 
1393  // statistics enabled or not
1394  $statistics_gui = new ilCheckboxInputGUI($this->lng->txt('frm_statistics_enabled'), 'statistics_enabled');
1395  $statistics_gui->setInfo($this->lng->txt('frm_statistics_enabled_desc'));
1396  $statistics_gui->setValue(1);
1397  if(!$this->ilias->getSetting('enable_fora_statistics', false))
1398  $statistics_gui->setDisabled(true);
1399  $this->create_form_gui->addItem($statistics_gui);
1400 
1401  $cb_prop = new ilCheckboxInputGUI($this->lng->txt('activate_new_posts'), 'post_activation');
1402  $cb_prop->setValue('1');
1403  $cb_prop->setInfo($this->lng->txt('post_activation_desc'));
1404  $this->create_form_gui->addItem($cb_prop);
1405 
1406  $this->create_form_gui->addCommandButton('save', $this->lng->txt('save'));
1407  $this->create_form_gui->addCommandButton('cancel', $this->lng->txt('cancel'));
1408  }
1409 
1410  public function cancelObject()
1411  {
1412  ilUtil::sendInfo($this->lng->txt('msg_cancel'), true);
1413  ilUtil::redirect('ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&ref_id='.$_GET['ref_id']);
1414  }
1415 
1419  protected function afterSave(ilObject $forumObj)
1420  {
1421  ilUtil::sendSuccess($this->lng->txt('frm_added'), true);
1422  $this->ctrl->setParameter($this, 'ref_id', $forumObj->getRefId());
1423  ilUtil::redirect($this->ctrl->getLinkTarget($this, 'createThread', '', false, false));
1424  }
1425 
1426  protected function getTabs()
1427  {
1433  global $ilAccess, $ilHelp, $ilCtrl;
1434 
1435  $ilHelp->setScreenIdComponent("frm");
1436 
1437  $this->ctrl->setParameter($this, 'ref_id', $this->ref_id);
1438 
1439  $active = array(
1440  '', 'showThreads', 'view', 'markAllRead',
1441  'enableForumNotification', 'disableForumNotification', 'moveThreads', 'performMoveThreads',
1442  'cancelMoveThreads', 'performThreadsAction', 'createThread', 'addThread',
1443  'showUser', 'confirmDeleteThreads',
1444  'merge','mergeThreads', 'cancelMergeThreads', 'performMergeThreads'
1445  );
1446 
1447  (in_array($ilCtrl->getCmd(), $active)) ? $force_active = true : $force_active = false;
1448  $this->tabs_gui->addTarget('forums_threads', $this->ctrl->getLinkTarget($this,'showThreads'), $ilCtrl->getCmd(), get_class($this), '', $force_active);
1449 
1450  // info tab
1451  if($ilAccess->checkAccess('visible', '', $this->ref_id))
1452  {
1453  $force_active = ($this->ctrl->getNextClass() == 'ilinfoscreengui' || strtolower($_GET['cmdClass']) == 'ilnotegui') ? true : false;
1454  $this->tabs_gui->addTarget('info_short',
1455  $this->ctrl->getLinkTargetByClass(
1456  array('ilobjforumgui', 'ilinfoscreengui'), 'showSummary'),
1457  array('showSummary', 'infoScreen'),
1458  '', '', $force_active);
1459  }
1460 
1461  if($ilAccess->checkAccess('write', '', $this->ref_id))
1462  {
1463  $force_active = ($ilCtrl->getCmd() == 'edit') ? true : false;
1464  $this->tabs_gui->addTarget('settings', $this->ctrl->getLinkTarget($this, 'edit'), 'edit', get_class($this), '', $force_active);
1465  }
1466 
1467  if($ilAccess->checkAccess('write', '', $this->ref_id))
1468  {
1469  $this->tabs_gui->addTarget('frm_moderators', $this->ctrl->getLinkTargetByClass('ilForumModeratorsGUI', 'showModerators'), 'showModerators', get_class($this));
1470  }
1471 
1472  if($this->ilias->getSetting('enable_fora_statistics', false) &&
1473  ($this->objProperties->isStatisticEnabled() || $ilAccess->checkAccess('write', '', $this->ref_id)))
1474  {
1475  $force_active = ($ilCtrl->getCmd() == 'showStatistics') ? true : false;
1476  $this->tabs_gui->addTarget('frm_statistics', $this->ctrl->getLinkTarget($this, 'showStatistics'), 'showStatistics', get_class($this), '', $force_active); //false
1477  }
1478 
1479  if($ilAccess->checkAccess('write', '', $this->object->getRefId()))
1480  {
1481  $this->tabs_gui->addTarget('export', $this->ctrl->getLinkTargetByClass('ilexportgui', ''), '', 'ilexportgui');
1482  }
1483 
1484  if($ilAccess->checkAccess('edit_permission', '', $this->ref_id))
1485  {
1486  $this->tabs_gui->addTarget('perm_settings', $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), 'perm'), array('perm', 'info', 'owner'), 'ilpermissiongui');
1487  }
1488  }
1489 
1490  public function settingsTabs()
1491  {
1497  global $ilTabs, $ilAccess, $tree;
1498 
1499  $ilTabs->setTabActive('settings');
1500  $ilTabs->addSubTabTarget('basic_settings', $this->ctrl->getLinkTarget($this, 'edit'), 'edit', get_class($this), '', $_GET['cmd']=='edit'? true : false );
1501 
1502  // notification tab
1503  if($this->ilias->getSetting('forum_notification') > 0)
1504  {
1505  // check if there a parent-node is a grp or crs
1506  $grp_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp');
1507  $crs_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs');
1508 
1509  if((int)$grp_ref_id > 0 || (int)$crs_ref_id > 0 )
1510  {
1511  #show member-tab for notification if forum-notification is enabled in administration
1512  if($ilAccess->checkAccess('write', '', $this->ref_id))
1513  {
1514  $mem_active = array('showMembers', 'forums_notification_settings');
1515  (in_array($_GET['cmd'],$mem_active)) ? $force_mem_active = true : $force_mem_active = false;
1516 
1517  $ilTabs->addSubTabTarget('notifications', $this->ctrl->getLinkTarget($this, 'showMembers'), $_GET['cmd'], get_class($this), '', $force_mem_active);
1518  }
1519  }
1520  }
1521  return true;
1522  }
1523 
1524  public function showStatisticsObject()
1525  {
1527  if (!$this->settings->get('enable_fora_statistics', false)) {
1528  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1529  }
1530 
1531  // if no read access -> intrusion detected
1532  if (!$this->access->checkAccess('read', '', (int)$_GET['ref_id'])) {
1533  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1534  }
1535 
1536  // if read access and statistics disabled -> intrusion detected
1537  if (!$this->objProperties->isStatisticEnabled()) {
1538  // if write access and statistics disabled -> ok, for forum admin
1539  if ($this->access->checkAccess('write', '', (int)$_GET['ref_id'])) {
1540  ilUtil::sendInfo($this->lng->txt('frm_statistics_disabled_for_participants'));
1541  } else {
1542  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1543  }
1544  }
1545 
1546  $this->object->Forum->setForumId($this->object->getId());
1547 
1548  require_once 'Modules/Forum/classes/class.ilForumStatisticsTableGUI.php';
1549 
1550  $tbl = new ilForumStatisticsTableGUI($this, 'showStatistics');
1551  $tbl->setId('il_frm_statistic_table_'. (int)$_GET['ref_id']);
1552  $tbl->setTitle($this->lng->txt('statistic'), 'icon_usr.svg', $this->lng->txt('obj_'.$this->object->getType()));
1553 
1554  $data = $this->object->Forum->getUserStatistic($this->is_moderator);
1555  $result = array();
1556  $counter = 0;
1557  foreach($data as $row)
1558  {
1559  $result[$counter]['ranking'] = $row[0];
1560  $result[$counter]['login'] = $row[1];
1561  $result[$counter]['lastname'] = $row[2];
1562  $result[$counter]['firstname'] = $row[3];
1563 
1564  ++$counter;
1565  }
1566  $tbl->setData($result);
1567 
1568  $this->tpl->setContent($tbl->getHTML());
1569  }
1570 
1571  public static function _goto($a_target, $a_thread = 0, $a_posting = 0)
1572  {
1578  global $ilAccess, $ilErr, $lng;
1579 
1580  if($ilAccess->checkAccess('read', '', $a_target))
1581  {
1582  if($a_thread != 0)
1583  {
1584  $objTopic = new ilForumTopic($a_thread);
1585  if ($objTopic->getFrmObjId() &&
1586  $objTopic->getFrmObjId() != ilObject::_lookupObjectId($a_target))
1587  {
1588  $ref_ids = ilObject::_getAllReferences($objTopic->getFrmObjId());
1589  foreach($ref_ids as $ref_id)
1590  {
1591  if($ilAccess->checkAccess('read', '', $ref_id))
1592  {
1593  $new_ref_id = $ref_id;
1594  break;
1595  }
1596  }
1597 
1598  if (isset($new_ref_id) && $new_ref_id != $a_target)
1599  {
1600  ilUtil::redirect(ILIAS_HTTP_PATH."/goto.php?target=frm_".$new_ref_id."_".$a_thread."_".$a_posting);
1601  }
1602  }
1603 
1604  $_GET['ref_id'] = $a_target;
1605  $_GET['pos_pk'] = $a_posting;
1606  $_GET['thr_pk'] = $a_thread;
1607  $_GET['anchor'] = $a_posting;
1608  $_GET['cmdClass'] = 'ilObjForumGUI';
1609  $_GET['cmd'] = 'viewThread';
1610  $_GET['baseClass'] = 'ilRepositoryGUI';
1611 
1612  include_once('ilias.php');
1613  exit();
1614  }
1615  else
1616  {
1617 
1618  $_GET['ref_id'] = $a_target;
1619  $_GET['baseClass'] = 'ilRepositoryGUI';
1620  include_once('ilias.php');
1621  exit();
1622  }
1623  }
1624  else if($ilAccess->checkAccess('read', '', ROOT_FOLDER_ID))
1625  {
1626  $_GET['target'] = '';
1627  $_GET['ref_id'] = ROOT_FOLDER_ID;
1628  ilUtil::sendInfo(sprintf($lng->txt('msg_no_perm_read_item'),
1629  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
1630  $_GET['baseClass'] = 'ilRepositoryGUI';
1631  include('ilias.php');
1632  exit();
1633  }
1634 
1635  $ilErr->raiseError($lng->txt('msg_no_perm_read'), $ilErr->FATAL);
1636  }
1637 
1638  public function performDeleteThreadsObject()
1639  {
1640  if (!$this->is_moderator) {
1641  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1642  }
1643 
1644  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1645  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1646  }
1647 
1648  if (!isset($_POST['thread_ids']) || !is_array($_POST['thread_ids'])) {
1649  ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'));
1650  return $this->showThreadsObject();
1651  }
1652 
1653  require_once 'Modules/Forum/classes/class.ilForum.php';
1654  require_once 'Modules/Forum/classes/class.ilObjForum.php';
1655  $forumObj = new ilObjForum($this->object->getRefId());
1656  $this->objProperties->setObjId($forumObj->getId());
1657 
1658  $frm = new ilForum();
1659 
1660  $success_message = "forums_thread_deleted";
1661  if (count($_POST['thread_ids']) > 1) {
1662  $success_message = "forums_threads_deleted";
1663  }
1664 
1665  $threadIds = [];
1666  if (isset($_POST['thread_ids']) && is_array($_POST['thread_ids'] )) {
1667  $threadIds = $_POST['thread_ids'];
1668  }
1669 
1670  $threads = [];
1671  array_walk($threadIds, function($threadId) use (&$threads) {
1672  $thread = new \ilForumTopic($threadId);
1673  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $thread);
1674 
1675  $threads[] = $thread;
1676  });
1677 
1678  foreach ($threads as $thread) {
1679  $frm->setForumId($forumObj->getId());
1680  $frm->setForumRefId($forumObj->getRefId());
1681 
1682  $first_node = $frm->getFirstPostNode($thread->getId());
1683  if ((int)$first_node['pos_pk']) {
1684  $frm->deletePost($first_node['pos_pk']);
1685  ilUtil::sendInfo($this->lng->txt($success_message), true);
1686  }
1687  }
1688  $this->ctrl->redirect($this, 'showThreads');
1689  }
1690 
1691  public function confirmDeleteThreads()
1692  {
1693  if (!isset($_POST['thread_ids']) || !is_array($_POST['thread_ids'])) {
1694  ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'));
1695  return $this->showThreadsObject();
1696  }
1697 
1698  if (!$this->is_moderator) {
1699  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1700  }
1701 
1702  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1703  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1704  }
1705 
1706  $threads = [];
1707  array_walk($_POST['thread_ids'], function($threadId) use (&$threads) {
1708  $thread = new \ilForumTopic($threadId);
1709  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $thread);
1710 
1711  $threads[] = $thread;
1712  });
1713 
1714  include_once('Services/Utilities/classes/class.ilConfirmationGUI.php');
1715  $c_gui = new ilConfirmationGUI();
1716 
1717  $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performDeleteThreads'));
1718  $c_gui->setHeaderText($this->lng->txt('frm_sure_delete_threads'));
1719  $c_gui->setCancel($this->lng->txt('cancel'), 'showThreads');
1720  $c_gui->setConfirm($this->lng->txt('confirm'), 'performDeleteThreads');
1721 
1722  foreach ($threads as $thread) {
1723  $c_gui->addItem('thread_ids[]', $thread->getId(), $thread->getSubject());
1724  }
1725 
1726  $this->confirmation_gui_html = $c_gui->getHTML();
1727 
1728  $this->hideToolbar(true);
1729 
1730  return $this->tpl->setContent($c_gui->getHTML());
1731  }
1732 
1734  {
1735  global $ilUser;
1736 
1737  if(!isset($_POST['draft_ids']) || !is_array($_POST['draft_ids']))
1738  {
1739  ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'));
1740  return $this->showThreadsObject();
1741  }
1742 
1743  include_once('Services/Utilities/classes/class.ilConfirmationGUI.php');
1744  $c_gui = new ilConfirmationGUI();
1745 
1746  $c_gui->setFormAction($this->ctrl->getFormAction($this, 'deleteThreadDrafts'));
1747  $c_gui->setHeaderText($this->lng->txt('sure_delete_drafts'));
1748  $c_gui->setCancel($this->lng->txt('cancel'), 'showThreads');
1749  $c_gui->setConfirm($this->lng->txt('confirm'), 'deleteThreadDrafts');
1750  $instances = ilForumPostDraft::getDraftInstancesByUserId($ilUser->getId());
1751  foreach($_POST['draft_ids'] as $draft_id)
1752  {
1753  if(array_key_exists($draft_id, $instances))
1754  {
1755  $c_gui->addItem('draft_ids[]', $draft_id, $instances[$draft_id]->getPostSubject());
1756  }
1757  }
1758 
1759  $this->confirmation_gui_html = $c_gui->getHTML();
1760 
1761  $this->hideToolbar(true);
1762 
1763  return $this->tpl->setContent($c_gui->getHTML());
1764  }
1765 
1766  public function prepareThreadScreen(ilObjForum $a_forum_obj)
1767  {
1774  global $tpl, $lng, $ilTabs, $ilHelp;
1775 
1776  $ilHelp->setScreenIdComponent("frm");
1777 
1778  $tpl->getStandardTemplate();
1779  ilUtil::sendInfo();
1781 
1782  $tpl->setTitleIcon(ilObject::_getIcon("", "big", "frm"));
1783 
1784  $ilTabs->setBackTarget($lng->txt('all_topics'),'ilias.php?baseClass=ilRepositoryGUI&amp;ref_id='.$_GET['ref_id']);
1785 
1786  // by answer view
1787  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
1788  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1789  $this->ctrl->setParameter($this, 'viewmode', ilForumProperties::VIEW_TREE);
1790  $ilTabs->addTarget('sort_by_posts', $this->ctrl->getLinkTarget($this, 'viewThread'));
1791 
1792  // by date view
1793  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
1794  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1795  $this->ctrl->setParameter($this, 'viewmode', ilForumProperties::VIEW_DATE);
1796  $ilTabs->addTarget('order_by_date', $this->ctrl->getLinkTarget($this, 'viewThread'));
1797 
1798  $this->ctrl->clearParameters($this);
1799 
1800  if($this->isHierarchicalView())
1801  {
1802  $ilTabs->setTabActive('sort_by_posts');
1803  }
1804  else
1805  {
1806  $ilTabs->setTabActive('order_by_date');
1807  }
1808 
1812  $frm = $a_forum_obj->Forum;
1813  $frm->setForumId($a_forum_obj->getId());
1814  }
1815 
1817  {
1818  if (!$this->is_moderator) {
1819  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1820  }
1821 
1822  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1823  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1824  }
1825 
1826  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $this->objCurrentPost->getThread());
1827 
1828  $this->objCurrentPost->activatePost();
1829  $GLOBALS['ilAppEventHandler']->raise(
1830  'Modules/Forum',
1831  'activatedPost',
1832  array(
1833  'ref_id' => $this->object->getRefId(),
1834  'post' => $this->objCurrentPost
1835  )
1836  );
1837  ilUtil::sendInfo($this->lng->txt('forums_post_was_activated'), true);
1838 
1839  $this->viewThreadObject();
1840  }
1841 
1842  public function askForPostActivationObject()
1843  {
1844  if (!$this->is_moderator) {
1845  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1846  }
1847 
1848  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1849  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1850  }
1851 
1852  $this->setDisplayConfirmPostActivation(true);
1853 
1854  $this->viewThreadObject();
1855  }
1856 
1857  public function setDisplayConfirmPostActivation($status = 0)
1858  {
1859  $this->display_confirm_post_activation = $status;
1860  }
1861 
1863  {
1865  }
1866 
1867  public function toggleThreadNotificationObject()
1868  {
1872  global $ilUser;
1873 
1874  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1875  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1876  }
1877 
1878  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $this->objCurrentTopic);
1879 
1880  if ($this->objCurrentTopic->isNotificationEnabled($ilUser->getId())) {
1881  $this->objCurrentTopic->disableNotification($ilUser->getId());
1882  \ilUtil::sendInfo($this->lng->txt('forums_notification_disabled'));
1883  } else {
1884  $this->objCurrentTopic->enableNotification($ilUser->getId());
1885  \ilUtil::sendInfo($this->lng->txt('forums_notification_enabled'));
1886  }
1887 
1888  $this->viewThreadObject();
1889  }
1890 
1891  public function toggleStickinessObject()
1892  {
1893  if (!$this->is_moderator) {
1894  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1895  }
1896 
1897  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1898  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1899  }
1900 
1901  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $this->objCurrentTopic);
1902 
1903  if ($this->objCurrentTopic->isSticky()) {
1904  $this->objCurrentTopic->unmakeSticky();
1905  } else {
1906  $this->objCurrentTopic->makeSticky();
1907  }
1908 
1909  $this->viewThreadObject();
1910  }
1911 
1912  public function cancelPostObject()
1913  {
1914  $_GET['action'] = '';
1915  if(isset($_POST['draft_id']) && (int)$_POST['draft_id'] > 0)
1916  {
1917  $draft = ilForumPostDraft::newInstanceByDraftId((int)$_POST['draft_id']);
1918  $draft->deleteDraftsByDraftIds(array( (int)$_POST['draft_id']));
1919  }
1920 
1921  $this->viewThreadObject();
1922  }
1923 
1924  public function cancelDraftObject()
1925  {
1926  $_GET['action'] = '';
1927  if(isset($_GET['draft_id']) && (int)$_GET['draft_id'] > 0)
1928  {
1930  {
1931  $history_obj = new ilForumDraftsHistory();
1932  $history_obj->getFirstAutosaveByDraftId((int)$_GET['draft_id']);
1933  $draft = ilForumPostDraft::newInstanceByDraftId((int)$_GET['draft_id']);
1934  $draft->setPostSubject($history_obj->getPostSubject());
1935  $draft->setPostMessage($history_obj->getPostMessage());
1936 
1937  ilForumUtil::moveMediaObjects($history_obj->getPostMessage(),
1938  ilForumDraftsHistory::MEDIAOBJECT_TYPE, $history_obj->getHistoryId(),
1939  ilForumPostDraft::MEDIAOBJECT_TYPE, $draft->getDraftId());
1940 
1941  $draft->updateDraft();
1942 
1943  $history_obj->deleteHistoryByDraftIds(array($draft->getDraftId()));
1944  }
1945  }
1946  $this->ctrl->clearParameters($this);
1947  $this->viewThreadObject();
1948  }
1949 
1950  public function getDeleteFormHTML()
1951  {
1955  global $lng;
1956 
1958  $form_tpl = new ilTemplate('tpl.frm_delete_post_form.html', true, true, 'Modules/Forum');
1959 
1960  $form_tpl->setVariable('ANKER', $this->objCurrentPost->getId());
1961  $form_tpl->setVariable('SPACER', '<hr noshade="noshade" width="100%" size="1" align="center" />');
1962  $form_tpl->setVariable('TXT_DELETE', $lng->txt('forums_info_delete_post'));
1963  $this->ctrl->setParameter($this, 'action', 'ready_delete');
1964  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1965  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
1966  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
1967  $form_tpl->setVariable('FORM_ACTION', $this->ctrl->getLinkTarget($this, 'viewThread'));
1968  $this->ctrl->clearParameters($this);
1969  $form_tpl->setVariable('CANCEL_BUTTON', $lng->txt('cancel'));
1970  $form_tpl->setVariable('CONFIRM_BUTTON', $lng->txt('confirm'));
1971 
1972  return $form_tpl->get();
1973  }
1974  public function getDeleteDraftFormHTML()
1975  {
1979  global $lng;
1980 
1982  $form_tpl = new ilTemplate('tpl.frm_delete_post_form.html', true, true, 'Modules/Forum');
1983 
1984  $form_tpl->setVariable('SPACER', '<hr noshade="noshade" width="100%" size="1" align="center" />');
1985  $form_tpl->setVariable('TXT_DELETE', $lng->txt('forums_info_delete_draft'));
1986  $this->ctrl->setParameter($this, 'action', 'ready_delete_draft');
1987  $this->ctrl->setParameter($this, 'draft_id', (int)$_GET['draft_id']);
1988  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1989  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
1990  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
1991  $form_tpl->setVariable('FORM_ACTION', $this->ctrl->getLinkTarget($this, 'viewThread'));
1992  $this->ctrl->clearParameters($this);
1993  $form_tpl->setVariable('CANCEL_BUTTON', $lng->txt('cancel'));
1994  $form_tpl->setVariable('CONFIRM_BUTTON', $lng->txt('confirm'));
1995 
1996  return $form_tpl->get();
1997  }
1998 
1999  public function getActivationFormHTML()
2000  {
2004  global $lng;
2005 
2006  $form_tpl = new ilTemplate('tpl.frm_activation_post_form.html', true, true, 'Modules/Forum');
2007 
2008  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2009  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2010  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2011  $form_tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'performPostActivation'));
2012  $form_tpl->setVariable('SPACER', '<hr noshade="noshade" width="100%" size="1" align="center" />');
2013  $form_tpl->setVariable('ANCHOR', $this->objCurrentPost->getId());
2014  $form_tpl->setVariable('TXT_ACT', $lng->txt('activate_post_txt'));
2015  $form_tpl->setVariable('CONFIRM_BUTTON', $lng->txt('activate_only_current'));
2016  $form_tpl->setVariable('CMD_CONFIRM', 'performPostActivation');
2017  $form_tpl->setVariable('CANCEL_BUTTON', $lng->txt('cancel'));
2018  $form_tpl->setVariable('CMD_CANCEL', 'viewThread');
2019  $this->ctrl->clearParameters($this);
2020 
2021  return $form_tpl->get();
2022  }
2023 
2024  public function getCensorshipFormHTML()
2025  {
2030  global $lng, $frm;
2031 
2032  $form_tpl = new ilTemplate('tpl.frm_censorship_post_form.html', true, true, 'Modules/Forum');
2033 
2034  $form_tpl->setVariable('ANCHOR', $this->objCurrentPost->getId());
2035  $form_tpl->setVariable('SPACER', '<hr noshade="noshade" width="100%" size="1" align="center" />');
2036  $this->ctrl->setParameter($this, 'action', 'ready_censor');
2037  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2038  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2039  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2040  $form_tpl->setVariable('FORM_ACTION', $this->ctrl->getLinkTarget($this, 'viewThread'));
2041  $this->ctrl->clearParameters($this);
2042  $form_tpl->setVariable('TXT_CENS_MESSAGE', $lng->txt('forums_the_post'));
2043  $form_tpl->setVariable('TXT_CENS_COMMENT', $lng->txt('forums_censor_comment').':');
2044  $form_tpl->setVariable('CENS_MESSAGE', $frm->prepareText($this->objCurrentPost->getCensorshipComment(), 2));
2045 
2046  if($this->objCurrentPost->isCensored())
2047  {
2048  $form_tpl->setVariable('TXT_CENS', $lng->txt('forums_info_censor2_post'));
2049  $form_tpl->setVariable('YES_BUTTON', $lng->txt('confirm'));
2050  $form_tpl->setVariable('NO_BUTTON', $lng->txt('cancel'));
2051  }
2052  else
2053  {
2054  $form_tpl->setVariable('TXT_CENS', $lng->txt('forums_info_censor_post'));
2055  $form_tpl->setVariable('CANCEL_BUTTON', $lng->txt('cancel'));
2056  $form_tpl->setVariable('CONFIRM_BUTTON', $lng->txt('confirm'));
2057  }
2058 
2059  return $form_tpl->get();
2060  }
2061 
2065  private function initReplyEditForm()
2066  {
2073  global $ilUser, $rbacsystem;
2074 
2075  // init objects
2076  $oForumObjects = $this->getForumObjects();
2077  $frm = $oForumObjects['frm'];
2078  $oFDForum = $oForumObjects['file_obj'];
2079 
2080  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
2081  $this->replyEditForm = new ilPropertyFormGUI();
2082  $this->replyEditForm->setId('id_showreply');
2083  $this->replyEditForm->setTableWidth('100%');
2084  $cancel_cmd = 'cancelPost';
2085  if($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply')
2086  {
2087  $this->ctrl->setParameter($this, 'action', 'ready_showreply');
2088  }
2089  else if($_GET['action'] == 'showdraft' || $_GET['action'] == 'editdraft')
2090  {
2091  $this->ctrl->setParameter($this, 'action', $_GET['action']);
2092  $this->ctrl->setParameter($this, 'draft_id', (int)$_GET['draft_id']);
2093  }
2094  else
2095  {
2096  $this->ctrl->setParameter($this, 'action', 'ready_showedit');
2097  }
2098 
2099  $this->ctrl->setParameter($this, 'offset', (int)$_GET['offset']);
2100  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2101  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2102  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2103  if($this->isTopLevelReplyCommand())
2104  {
2105  $this->replyEditForm->setFormAction($this->ctrl->getFormAction($this, 'saveTopLevelPost'), 'frm_page_bottom');
2106  }
2107  else if($_GET['action'] == 'publishDraft' || $_GET['action'] == 'editdraft')
2108  {
2109  $this->replyEditForm->setFormAction($this->ctrl->getFormAction($this, 'publishDraft'), $this->objCurrentPost->getId());
2110  }
2111  else
2112  {
2113  $this->replyEditForm->setFormAction($this->ctrl->getFormAction($this, 'savePost'), $this->objCurrentPost->getId());
2114  }
2115  $this->ctrl->clearParameters($this);
2116 
2117  if($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply')
2118  {
2119  $this->replyEditForm->setTitle($this->lng->txt('forums_your_reply'));
2120  }
2121  elseif($_GET['action'] == 'showdraft' || $_GET['action'] == 'editdraft')
2122  {
2123  $this->replyEditForm->setTitle($this->lng->txt('forums_edit_draft'));
2124  }
2125  else
2126  {
2127  $this->replyEditForm->setTitle($this->lng->txt('forums_edit_post'));
2128  }
2129 
2130  // alias
2131  if($this->isWritingWithPseudonymAllowed()
2132  && in_array($_GET['action'], array('showreply', 'ready_showreply')))
2133  {
2134  $oAnonymousNameGUI = new ilTextInputGUI($this->lng->txt('forums_your_name'), 'alias');
2135  $oAnonymousNameGUI->setMaxLength(64);
2136  $oAnonymousNameGUI->setInfo($this->lng->txt('forums_use_alias'));
2137 
2138  $this->replyEditForm->addItem($oAnonymousNameGUI);
2139  }
2140 
2141  // subject
2142  $oSubjectGUI = new ilTextInputGUI($this->lng->txt('forums_subject'), 'subject');
2143  $oSubjectGUI->setMaxLength(64);
2144  $oSubjectGUI->setRequired(true);
2145 
2146  if($this->objProperties->getSubjectSetting() == 'empty_subject')
2147  $oSubjectGUI->setInfo($this->lng->txt('enter_new_subject'));
2148 
2149  $this->replyEditForm->addItem($oSubjectGUI);
2150 
2151  // post
2152  $oPostGUI = new ilTextAreaInputGUI(
2153  $_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply' ? $this->lng->txt('forums_your_reply') : $this->lng->txt('forums_edit_post'),
2154  'message'
2155  );
2156  $oPostGUI->setRequired(true);
2157  $oPostGUI->setCols(50);
2158  $oPostGUI->setRows(15);
2159  $oPostGUI->setUseRte(true);
2160  $oPostGUI->addPlugin('latex');
2161  $oPostGUI->addButton('latex');
2162  $oPostGUI->addButton('pastelatex');
2163  $oPostGUI->addPlugin('ilfrmquote');
2164 
2165  //$oPostGUI->addPlugin('code');
2166  if($_GET['action'] == 'showreply' || $_GET['action'] == 'showdraft')
2167  {
2168  $oPostGUI->addButton('ilFrmQuoteAjaxCall');
2169  }
2170  $oPostGUI->removePlugin('advlink');
2171  $oPostGUI->setRTERootBlockElement('');
2172  $oPostGUI->usePurifier(true);
2173  $oPostGUI->disableButtons(array(
2174  'charmap',
2175  'undo',
2176  'redo',
2177  'justifyleft',
2178  'justifycenter',
2179  'justifyright',
2180  'justifyfull',
2181  'anchor',
2182  'fullscreen',
2183  'cut',
2184  'copy',
2185  'paste',
2186  'pastetext',
2187  'formatselect'
2188  ));
2189 
2190  if($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply' || $_GET['action'] == 'showdraft' || $_GET['action'] == 'editdraft')
2191  {
2192  $oPostGUI->setRTESupport($ilUser->getId(), 'frm~', 'frm_post', 'tpl.tinymce_frm_post.html', false, '3.5.11');
2193  }
2194  else
2195  {
2196  $oPostGUI->setRTESupport($this->objCurrentPost->getId(), 'frm', 'frm_post', 'tpl.tinymce_frm_post.html', false, '3.5.11');
2197  }
2198  // purifier
2199  require_once 'Services/Html/classes/class.ilHtmlPurifierFactory.php';
2200  $oPostGUI->setPurifier(ilHtmlPurifierFactory::_getInstanceByType('frm_post'));
2201 
2202  $this->replyEditForm->addItem($oPostGUI);
2203 
2204  // notification only if gen. notification is disabled and forum isn't anonymous
2205  include_once 'Services/Mail/classes/class.ilMail.php';
2206  $umail = new ilMail($ilUser->getId());
2207  if($rbacsystem->checkAccess('internal_mail', $umail->getMailObjectReferenceId()) &&
2208  !$frm->isThreadNotificationEnabled($ilUser->getId(), $this->objCurrentPost->getThreadId()) &&
2209  !$this->objProperties->isAnonymized())
2210  {
2211  $oNotificationGUI = new ilCheckboxInputGUI($this->lng->txt('forum_direct_notification'), 'notify');
2212  $oNotificationGUI->setInfo($this->lng->txt('forum_notify_me'));
2213 
2214  $this->replyEditForm->addItem($oNotificationGUI);
2215  }
2216 
2217  if($this->objProperties->isFileUploadAllowed())
2218  {
2219  $oFileUploadGUI = new ilFileWizardInputGUI($this->lng->txt('forums_attachments_add'), 'userfile');
2220  $oFileUploadGUI->setFilenames(array(0 => ''));
2221  $this->replyEditForm->addItem($oFileUploadGUI);
2222  }
2223 
2224  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
2225  if(
2226  $ilUser->isAnonymous() &&
2227  !$ilUser->isCaptchaVerified() &&
2228  ilCaptchaUtil::isActiveForForum()
2229  )
2230  {
2231  require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
2232  $captcha = new ilCaptchaInputGUI($this->lng->txt('cont_captcha_code'), 'captcha_code');
2233  $captcha->setRequired(true);
2234  $this->replyEditForm->addItem($captcha);
2235  }
2236 
2237  $attachments_of_node = $oFDForum->getFilesOfPost();
2238  if(count($attachments_of_node) && ($_GET['action'] == 'showedit' || $_GET['action'] == 'ready_showedit'))
2239  {
2240  $oExistingAttachmentsGUI = new ilCheckboxGroupInputGUI($this->lng->txt('forums_delete_file'), 'del_file');
2241  foreach($oFDForum->getFilesOfPost() as $file)
2242  {
2243  $oAttachmentGUI = new ilCheckboxInputGUI($file['name'], 'del_file');
2244  $oAttachmentGUI->setValue($file['md5']);
2245  $oExistingAttachmentsGUI->addOption($oAttachmentGUI);
2246  }
2247  $this->replyEditForm->addItem($oExistingAttachmentsGUI);
2248  }
2249 
2251  {
2252  if($_GET['action'] == 'showdraft' || $_GET['action'] == 'editdraft')
2253  {
2254  $draftInfoGUI = new ilNonEditableValueGUI('','autosave_info', true);
2255  $draftInfoGUI->setValue(sprintf($this->lng->txt('autosave_draft_info'), ilForumPostDraft::lookupAutosaveInterval()));
2256  $this->replyEditForm->addItem($draftInfoGUI);
2257  }
2258  else if($_GET['action'] != 'showedit' && $_GET['action'] != 'ready_showedit')
2259  {
2260  $draftInfoGUI = new ilNonEditableValueGUI('','autosave_info', true);
2261  $draftInfoGUI->setValue(sprintf($this->lng->txt('autosave_post_draft_info'), ilForumPostDraft::lookupAutosaveInterval()));
2262  $this->replyEditForm->addItem($draftInfoGUI);
2263  }
2264 
2265  $selected_draft_id = (int)$_GET['draft_id'];
2266  $draftObj = new ilForumPostDraft($ilUser->getId(), $this->objCurrentPost->getId(), $selected_draft_id);
2267  if($draftObj->getDraftId() > 0)
2268  {
2269  $oFDForumDrafts = new ilFileDataForumDrafts(0, $draftObj->getDraftId());
2270  if(count($oFDForumDrafts->getFilesOfPost()))
2271  {
2272  $oExistingAttachmentsGUI = new ilCheckboxGroupInputGUI($this->lng->txt('forums_delete_file'), 'del_file');
2273  foreach($oFDForumDrafts->getFilesOfPost() as $file)
2274  {
2275  $oAttachmentGUI = new ilCheckboxInputGUI($file['name'], 'del_file');
2276  $oAttachmentGUI->setValue($file['md5']);
2277  $oExistingAttachmentsGUI->addOption($oAttachmentGUI);
2278  }
2279  $this->replyEditForm->addItem($oExistingAttachmentsGUI);
2280  }
2281  }
2282  }
2283 
2284  if($this->isTopLevelReplyCommand())
2285  {
2286  $this->replyEditForm->addCommandButton('saveTopLevelPost', $this->lng->txt('create'));
2287  }
2288  else if(ilForumPostDraft::isSavePostDraftAllowed() && $_GET['action'] == 'editdraft')
2289  {
2290  $this->replyEditForm->addCommandButton('publishDraft', $this->lng->txt('publish'));
2291  }
2292  else
2293  {
2294  $this->replyEditForm->addCommandButton('savePost', $this->lng->txt('save'));
2295  }
2296  $hidden_draft_id= new ilHiddenInputGUI('draft_id');
2297  if(isset($_GET['draft_id']) && (int)$_GET['draft_id']> 0)
2298  {
2299  $auto_save_draft_id = (int)$_GET['draft_id'];
2300  }
2301  $hidden_draft_id->setValue($auto_save_draft_id);
2302  $this->replyEditForm->addItem($hidden_draft_id);
2303 
2304  if($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply' || $_GET['action'] == 'editdraft')
2305  {
2306  include_once 'Services/RTE/classes/class.ilRTE.php';
2307  $rtestring = ilRTE::_getRTEClassname();
2308 
2309  if(array_key_exists('show_rte', $_POST))
2310  {
2312  }
2313 
2314  if(strtolower($rtestring) != 'iltinymce' || !ilObjAdvancedEditing::_getRichTextEditorUserState())
2315  {
2316  if($this->isTopLevelReplyCommand())
2317  {
2318  $this->replyEditForm->addCommandButton('quoteTopLevelPost', $this->lng->txt('forum_add_quote'));
2319  }
2320  else
2321  {
2322  $this->replyEditForm->addCommandButton('quotePost', $this->lng->txt('forum_add_quote'));
2323  }
2324  }
2325 
2326  if(!$ilUser->isAnonymous()
2327  && ($_GET['action'] == 'editdraft' || $_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply')
2329  )
2330  {
2332  {
2333  $this->addAutosave($this->replyEditForm);
2334  }
2335 
2336  if($_GET['action'] == 'editdraft')
2337  {
2338  $this->replyEditForm->addCommandButton('updateDraft', $this->lng->txt('save_message'));
2339  }
2340  else
2341  {
2342  $this->replyEditForm->addCommandButton('saveAsDraft', $this->lng->txt('save_message'));
2343  }
2344 
2345  $cancel_cmd = 'cancelDraft';
2346  }
2347  }
2348  $this->replyEditForm->addCommandButton($cancel_cmd, $this->lng->txt('cancel'));
2349 
2350  }
2351 
2355  private function getReplyEditForm()
2356  {
2357  if(null === $this->replyEditForm)
2358  {
2359  $this->initReplyEditForm();
2360  }
2361 
2362  return $this->replyEditForm;
2363  }
2364 
2368  public function createTopLevelPostObject()
2369  {
2370  global $ilUser;
2371 
2372  if(isset($_GET['draft_id']) && (int)$_GET['draft_id'] > 0 && !$ilUser->isAnonymous()
2374  {
2375  $draft_obj = new ilForumPostDraft($ilUser->getId(), $this->objCurrentPost->getId(), (int)$_GET['draft_id']);
2376  }
2377 
2378  if($draft_obj instanceof ilForumPostDraft && $draft_obj->getDraftId() > 0)
2379  {
2380  $this->ctrl->setParameter($this, 'action', 'editdraft');
2381  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2382  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
2383  $this->ctrl->setParameter($this, 'draft_id', $draft_obj->getDraftId());
2384  $this->ctrl->setParameter($this, 'offset', 0);
2385  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2386  $this->ctrl->redirect($this, 'editDraft');
2387  }
2388  else
2389  {
2390  $this->viewThreadObject();
2391  }
2392  return;
2393  }
2394 
2398  public function saveTopLevelPostObject()
2399  {
2400  $this->savePostObject();
2401  return;
2402  }
2403 
2407  public function quoteTopLevelPostObject()
2408  {
2409  $this->quotePostObject();
2410  return;
2411  }
2412 
2413  public function publishSelectedDraftObject()
2414  {
2415  if(isset($_GET['draft_id']) && (int)$_GET['draft_id'] > 0)
2416  {
2417  $this->publishDraftObject(false);
2418  }
2419  }
2420 
2421  public function publishDraftObject($use_replyform = true)
2422  {
2423  global $ilUser, $lng;
2424 
2425  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2426  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2427  }
2428 
2429  if (!$this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
2430  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2431  }
2432 
2433  if($this->objCurrentTopic->isClosed())
2434  {
2435  $_GET['action'] = '';
2436  return $this->viewThreadObject();
2437  }
2438 
2439  $post_id = $this->objCurrentPost->getId();
2440 
2441  $draft_obj = new ilForumPostDraft($ilUser->getId(), $post_id, (int)$_GET['draft_id']);
2442 
2443  if($use_replyform)
2444  {
2445  $oReplyEditForm = $this->getReplyEditForm();
2446  if(!$oReplyEditForm->checkInput() && !$draft_obj instanceof ilForumPostDraft)
2447  {
2448  $oReplyEditForm->setValuesByPost();
2449  return $this->viewThreadObject();
2450  }
2451  $post_subject = $oReplyEditForm->getInput('subject');
2452  $post_message = $oReplyEditForm->getInput('message');
2453  $mob_direction = 0;
2454  }
2455  else
2456  {
2457  $post_subject = $draft_obj->getPostSubject();
2458  $post_message = $draft_obj->getPostMessage();
2459  $mob_direction = 1;
2460  }
2461 
2462  if($draft_obj->getDraftId() > 0)
2463  {
2464  // init objects
2465  $oForumObjects = $this->getForumObjects();
2466  $frm = $oForumObjects['frm'];
2467  $frm->setMDB2WhereCondition(' top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
2468 
2469  // reply: new post
2470  $status = 1;
2471  $send_activation_mail = 0;
2472 
2473  if($this->objProperties->isPostActivationEnabled())
2474  {
2475  if(!$this->is_moderator)
2476  {
2477  $status = 0;
2478  $send_activation_mail = 1;
2479  }
2480  else if($this->objCurrentPost->isAnyParentDeactivated())
2481  {
2482  $status = 0;
2483  }
2484  }
2485 
2486  $newPost = $frm->generatePost(
2487  $draft_obj->getForumId(),
2488  $draft_obj->getThreadId(),
2489  $ilUser->getId(),
2490  $draft_obj->getPostDisplayUserId(),
2491  ilRTE::_replaceMediaObjectImageSrc($post_message, $mob_direction),
2492  $draft_obj->getPostId(),
2493  (int)$draft_obj->getNotify(),
2494  $this->handleFormInput($post_subject , false),
2495  $draft_obj->getPostUserAlias(),
2496  '',
2497  $status,
2498  $send_activation_mail
2499  );
2500 
2501  $this->object->markPostRead($ilUser->getId(), (int) $this->objCurrentTopic->getId(), (int) $this->objCurrentPost->getId());
2502 
2503  $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId());
2504 
2505  foreach($uploadedObjects as $mob)
2506  {
2507  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
2508  ilObjMediaObject::_saveUsage($mob,'frm:html', $newPost);
2509  }
2510  ilForumUtil::saveMediaObjects($post_message, 'frm:html', $newPost, $mob_direction);
2511 
2512  if($this->objProperties->isFileUploadAllowed())
2513  {
2514  $file = $_FILES['userfile'];
2515  if(is_array($file) && !empty($file))
2516  {
2517  $tmp_file_obj = new ilFileDataForum($this->object->getId(), $newPost);
2518  $tmp_file_obj->storeUploadedFile($file);
2519  }
2520 
2521  //move files of draft to posts directory
2522  $oFDForum = new ilFileDataForum($this->object->getId(), $newPost);
2523  $oFDForumDrafts = new ilFileDataForumDrafts($this->object->getId(), $draft_obj->getDraftId());
2524 
2525  $oFDForumDrafts->moveFilesOfDraft($oFDForum->getForumPath(), $newPost);
2526  $oFDForumDrafts->delete();
2527  }
2528 
2530  {
2531  $GLOBALS['ilAppEventHandler']->raise(
2532  'Modules/Forum',
2533  'publishedDraft',
2534  array('draftObj' => $draft_obj,
2535  'obj_id' => $this->object->getId(),
2536  'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed())
2537  );
2538  }
2539  $draft_obj->deleteDraft();
2540 
2541  $GLOBALS['ilAppEventHandler']->raise(
2542  'Modules/Forum',
2543  'createdPost',
2544  array(
2545  'ref_id' => $this->object->getRefId(),
2546  'post' => new ilForumPost($newPost),
2547  'notify_moderators' => (bool)$send_activation_mail
2548  )
2549  );
2550 
2551  $message = '';
2552  if(!$this->is_moderator && !$status)
2553  {
2554  $message .= $lng->txt('forums_post_needs_to_be_activated');
2555  }
2556  else
2557  {
2558  $message .= $lng->txt('forums_post_new_entry');
2559  }
2560 
2561  $_SESSION['frm'][(int)$_GET['thr_pk']]['openTreeNodes'][] = (int)$this->objCurrentPost->getId();
2562 
2563  $this->ctrl->clearParameters($this);
2564  ilUtil::sendSuccess($message, true);
2565  $this->ctrl->setParameter($this, 'pos_pk', $newPost);
2566  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2567 
2568  $this->ctrl->redirect($this, 'viewThread');
2569  }
2570  }
2571 
2575  public function savePostObject()
2576  {
2581  global $ilUser, $lng;
2582 
2583  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2584  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2585  }
2586 
2587  if (!$this->objCurrentTopic->getId()) {
2588  \ilUtil::sendFailure($this->lng->txt('frm_action_not_possible_thr_deleted'), true);
2589  $this->ctrl->redirect($this);
2590  }
2591 
2592  if ($this->objCurrentTopic->isClosed()) {
2593  \ilUtil::sendFailure($this->lng->txt('frm_action_not_possible_thr_closed'), true);
2594  $this->ctrl->redirect($this);
2595  }
2596 
2597  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $this->objCurrentTopic);
2598 
2599  if(!isset($_POST['del_file']) || !is_array($_POST['del_file'])) $_POST['del_file'] = array();
2600 
2601  if($this->objCurrentTopic->isClosed())
2602  {
2603  $_GET['action'] = '';
2604  return $this->viewThreadObject();
2605  }
2606 
2607  $oReplyEditForm = $this->getReplyEditForm();
2608  if($oReplyEditForm->checkInput())
2609  {
2610  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
2611  if(
2612  $ilUser->isAnonymous() &&
2613  !$ilUser->isCaptchaVerified() &&
2614  ilCaptchaUtil::isActiveForForum()
2615  )
2616  {
2617  $ilUser->setCaptchaVerified(true);
2618  }
2619 
2620  // init objects
2621  $oForumObjects = $this->getForumObjects();
2625  $forumObj = $oForumObjects['forumObj'];
2629  $frm = $oForumObjects['frm'];
2630  $frm->setMDB2WhereCondition(' top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
2631  $topicData = $frm->getOneTopic();
2632 
2633  // Generating new posting
2634  if($_GET['action'] == 'ready_showreply')
2635  {
2636  if (!$this->access->checkAccess('add_reply', '', (int)$_GET['ref_id'])) {
2637  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2638  }
2639 
2640  // reply: new post
2641  $status = 1;
2642  $send_activation_mail = 0;
2643 
2644  if($this->objProperties->isPostActivationEnabled())
2645  {
2646  if(!$this->is_moderator)
2647  {
2648  $status = 0;
2649  $send_activation_mail = 1;
2650  }
2651  else if($this->objCurrentPost->isAnyParentDeactivated())
2652  {
2653  $status = 0;
2654  }
2655  }
2656 
2657  if($this->isWritingWithPseudonymAllowed())
2658  {
2659  if(!strlen($oReplyEditForm->getInput('alias')))
2660  {
2661  $user_alias = $this->lng->txt('forums_anonymous');
2662  }
2663  else
2664  {
2665  $user_alias = $oReplyEditForm->getInput('alias');
2666  }
2667  $display_user_id = 0;
2668  }
2669  else
2670  {
2671  $user_alias = $ilUser->getLogin();
2672  $display_user_id = $ilUser->getId();
2673  }
2674 
2675 
2676  $newPost = $frm->generatePost(
2677  $topicData['top_pk'],
2678  $this->objCurrentTopic->getId(),
2679  $ilUser->getId(),
2680  $display_user_id,
2681  ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message'), 0),
2682  $this->objCurrentPost->getId(),
2683  (int)$oReplyEditForm->getInput('notify'),
2684  $this->handleFormInput($oReplyEditForm->getInput('subject'), false),
2685  $user_alias,
2686  '',
2687  $status,
2688  $send_activation_mail
2689  );
2690 
2692  {
2693  $draft_id = 0;
2695  {
2696  $draft_id = $_POST['draft_id']; // info aus dem autosave?
2697  }
2698  $draft_obj = new ilForumPostDraft($ilUser->getId(), $this->objCurrentPost->getId(), $draft_id);
2699  if($draft_obj instanceof ilForumPostDraft)
2700  {
2701  $draft_obj->deleteDraft();
2702  }
2703  }
2704 
2705  // mantis #8115: Mark parent as read
2706  $this->object->markPostRead($ilUser->getId(), (int) $this->objCurrentTopic->getId(), (int) $this->objCurrentPost->getId());
2707 
2708  // copy temporary media objects (frm~)
2709  ilForumUtil::moveMediaObjects($oReplyEditForm->getInput('message'), 'frm~:html', $ilUser->getId(), 'frm:html', $newPost);
2710 
2711  if($this->objProperties->isFileUploadAllowed())
2712  {
2713  $oFDForum = new ilFileDataForum($forumObj->getId(), $newPost);
2714  $file = $_FILES['userfile'];
2715  if(is_array($file) && !empty($file))
2716  {
2717  $oFDForum->storeUploadedFile($file);
2718  }
2719  }
2720 
2721  $GLOBALS['ilAppEventHandler']->raise(
2722  'Modules/Forum',
2723  'createdPost',
2724  array(
2725  'ref_id' => $this->object->getRefId(),
2726  'post' => new ilForumPost($newPost),
2727  'notify_moderators' => (bool)$send_activation_mail
2728  )
2729  );
2730 
2731  $message = '';
2732  if(!$this->is_moderator && !$status)
2733  {
2734  $message .= $lng->txt('forums_post_needs_to_be_activated');
2735  }
2736  else
2737  {
2738  $message .= $lng->txt('forums_post_new_entry');
2739  }
2740 
2741  ilUtil::sendSuccess($message, true);
2742  $this->ctrl->clearParameters($this);
2743  $this->ctrl->setParameter($this, 'post_created_below', $this->objCurrentPost->getId());
2744  $this->ctrl->setParameter($this, 'pos_pk', $newPost);
2745  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2746  $this->ctrl->redirect($this, 'viewThread');
2747  }
2748  else
2749  {
2750  if((!$this->is_moderator &&
2751  !$this->objCurrentPost->isOwner($ilUser->getId())) || $this->objCurrentPost->isCensored() ||
2752  $ilUser->getId() == ANONYMOUS_USER_ID)
2753  {
2754  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2755  }
2756 
2757  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $this->objCurrentPost->getThread());
2758 
2759  // remove usage of deleted media objects
2760  include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
2761  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm:html', $this->objCurrentPost->getId());
2762  $curMediaObjects = ilRTE::_getMediaObjects($oReplyEditForm->getInput('message'), 0);
2763  foreach($oldMediaObjects as $oldMob)
2764  {
2765  $found = false;
2766  foreach($curMediaObjects as $curMob)
2767  {
2768  if($oldMob == $curMob)
2769  {
2770  $found = true;
2771  break;
2772  }
2773  }
2774  if(!$found)
2775  {
2776  if(ilObjMediaObject::_exists($oldMob))
2777  {
2778  ilObjMediaObject::_removeUsage($oldMob, 'frm:html', $this->objCurrentPost->getId());
2779  $mob_obj = new ilObjMediaObject($oldMob);
2780  $mob_obj->delete();
2781  }
2782  }
2783  }
2784 
2785  // save old activation status for send_notification decision
2786  $old_status_was_active = $this->objCurrentPost->isActivated();
2787 
2788  // if post has been edited posting mus be activated again by moderator
2789  $status = 1;
2790  $send_activation_mail = 0;
2791 
2792  if($this->objProperties->isPostActivationEnabled())
2793  {
2794  if(!$this->is_moderator)
2795  {
2796  $status = 0;
2797  $send_activation_mail = 1;
2798  }
2799  else if($this->objCurrentPost->isAnyParentDeactivated())
2800  {
2801  $status = 0;
2802  }
2803  }
2804  $this->objCurrentPost->setStatus($status);
2805 
2806  $this->objCurrentPost->setSubject($this->handleFormInput($oReplyEditForm->getInput('subject'), false));
2807  $this->objCurrentPost->setMessage(ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message'), 0));
2808  $this->objCurrentPost->setNotification((int)$oReplyEditForm->getInput('notify'));
2809  $this->objCurrentPost->setChangeDate(date('Y-m-d H:i:s'));
2810  $this->objCurrentPost->setUpdateUserId($ilUser->getId());
2811 
2812  // edit: update post
2813  if($this->objCurrentPost->update())
2814  {
2815  $this->objCurrentPost->reload();
2816 
2817  // Change news item accordingly
2818  include_once 'Services/News/classes/class.ilNewsItem.php';
2819  // note: $this->objCurrentPost->getForumId() does not give us the forum ID here (why?)
2820  $news_id = ilNewsItem::getFirstNewsIdForContext($forumObj->getId(),
2821  'frm', $this->objCurrentPost->getId(), 'pos');
2822  if($news_id > 0)
2823  {
2824  $news_item = new ilNewsItem($news_id);
2825  $news_item->setTitle($this->objCurrentPost->getSubject());
2826  $news_item->setContent(ilRTE::_replaceMediaObjectImageSrc($frm->prepareText(
2827  $this->objCurrentPost->getMessage(), 0), 1)
2828  );
2829 
2830  if($this->objCurrentPost->getMessage() != strip_tags($this->objCurrentPost->getMessage()))
2831  {
2832  $news_item->setContentHtml(true);
2833  }
2834  else
2835  {
2836  $news_item->setContentHtml(false);
2837  }
2838  $news_item->update();
2839  }
2840 
2841  $oFDForum = $oForumObjects['file_obj'];
2842 
2843  if($this->objProperties->isFileUploadAllowed())
2844  {
2845  $file = $_FILES['userfile'];
2846  if(is_array($file) && !empty($file))
2847  {
2848  $oFDForum->storeUploadedFile($file);
2849  }
2850  }
2851 
2852  $file2delete = $oReplyEditForm->getInput('del_file');
2853  if(is_array($file2delete) && count($file2delete))
2854  {
2855  $oFDForum->unlinkFilesByMD5Filenames($file2delete);
2856  }
2857 
2858  $GLOBALS['ilAppEventHandler']->raise(
2859  'Modules/Forum',
2860  'updatedPost',
2861  array(
2862  'ref_id' => $this->object->getRefId(),
2863  'post' => $this->objCurrentPost,
2864  'notify_moderators' => (bool)$send_activation_mail,
2865  'old_status_was_active' => (bool)$old_status_was_active
2866  )
2867  );
2868 
2869  ilUtil::sendSuccess($lng->txt('forums_post_modified'), true);
2870  }
2871 
2872  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2873  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2874  $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
2875  $this->ctrl->redirect($this, 'viewThread');
2876  }
2877  }
2878  else
2879  {
2880  $_GET['action'] = substr($_GET['action'], 6);
2881  }
2882  return $this->viewThreadObject();
2883  }
2884 
2885  private function hideToolbar($a_flag = null)
2886  {
2887  if(null === $a_flag)
2888  {
2889  return $this->hideToolbar;
2890  }
2891 
2892  $this->hideToolbar = $a_flag;
2893  return $this;
2894  }
2895 
2896  public function quotePostObject()
2897  {
2898  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2899  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2900  }
2901 
2902  if(!is_array($_POST['del_file'])) $_POST['del_file'] = array();
2903 
2904  if($this->objCurrentTopic->isClosed())
2905  {
2906  $_GET['action'] = '';
2907  return $this->viewThreadObject();
2908  }
2909 
2910  $oReplyEditForm = $this->getReplyEditForm();
2911 
2912  // remove mandatory fields
2913  $oReplyEditForm->getItemByPostVar('subject')->setRequired(false);
2914  $oReplyEditForm->getItemByPostVar('message')->setRequired(false);
2915 
2916  $oReplyEditForm->checkInput();
2917 
2918  // add mandatory fields
2919  $oReplyEditForm->getItemByPostVar('subject')->setRequired(true);
2920  $oReplyEditForm->getItemByPostVar('message')->setRequired(true);
2921 
2922  $_GET['action'] = 'showreply';
2923 
2924  $this->viewThreadObject();
2925  }
2926 
2927  public function getQuotationHTMLAsynchObject()
2928  {
2929  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2930  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2931  }
2932 
2933  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $this->objCurrentPost->getThread());
2934 
2935  $oForumObjects = $this->getForumObjects();
2939  $frm = $oForumObjects['frm'];
2940 
2941  require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
2942  $authorinfo = new ilForumAuthorInformation(
2943  $this->objCurrentPost->getPosAuthorId(),
2944  $this->objCurrentPost->getDisplayUserId(),
2945  $this->objCurrentPost->getUserAlias(),
2946  $this->objCurrentPost->getImportName()
2947  );
2948 
2949  $html = ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($this->objCurrentPost->getMessage(), 1, $authorinfo->getAuthorName()), 1);
2950  echo $html;
2951  exit();
2952  }
2953 
2954  private function getForumObjects()
2955  {
2956  if(null === $this->forumObjects)
2957  {
2958  $forumObj = $this->object;
2959  $file_obj = new ilFileDataForum($forumObj->getId(), $this->objCurrentPost->getId());
2960  $frm = $forumObj->Forum;
2961  $frm->setForumId($forumObj->getId());
2962  $frm->setForumRefId($forumObj->getRefId());
2963 
2964  $this->forumObjects['forumObj'] = $forumObj;
2965  $this->forumObjects['frm'] = $frm;
2966  $this->forumObjects['file_obj'] = $file_obj;
2967  }
2968 
2969  return $this->forumObjects;
2970  }
2971 
2972  public function viewThreadObject()
2973  {
2984  global $tpl, $lng, $ilUser, $ilAccess, $rbacreview, $ilNavigationHistory, $ilCtrl, $frm, $ilToolbar, $ilLocator;
2985 
2986  $bottom_toolbar = clone $ilToolbar;
2987  $bottom_toolbar_split_button_items = array();
2988 
2989  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
2990  $tpl->addCss('./Modules/Forum/css/forum_tree.css');
2991  if(!isset($_SESSION['viewmode']))
2992  {
2993  $_SESSION['viewmode'] = $this->objProperties->getDefaultView();
2994  }
2995 
2996  // quick and dirty: check for treeview
2997  if(!isset($_SESSION['thread_control']['old']))
2998  {
2999  $_SESSION['thread_control']['old'] = $_GET['thr_pk'];
3000  $_SESSION['thread_control']['new'] = $_GET['thr_pk'];
3001  }
3002  else
3003  if(isset($_SESSION['thread_control']['old']) && $_GET['thr_pk'] != $_SESSION['thread_control']['old'])
3004  {
3005  $_SESSION['thread_control']['new'] = $_GET['thr_pk'];
3006  }
3007 
3008  if(isset($_GET['viewmode']) && $_GET['viewmode'] != $_SESSION['viewmode'])
3009  {
3010  $_SESSION['viewmode'] = $_GET['viewmode'];
3011  }
3012 
3013  if( (isset($_GET['action']) && $_SESSION['viewmode'] != ilForumProperties::VIEW_DATE)
3014  ||($_SESSION['viewmode'] == ilForumProperties::VIEW_TREE))
3015  {
3017  }
3018  else
3019  {
3021  }
3022 
3023  if(!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3024  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3025  }
3026 
3027  // init objects
3028  $oForumObjects = $this->getForumObjects();
3032  $forumObj = $oForumObjects['forumObj'];
3036  $frm = $oForumObjects['frm'];
3040  $file_obj = $oForumObjects['file_obj'];
3041 
3042  // download file
3043  if(isset($_GET['file']))
3044  {
3045  $file_obj_for_delivery = $file_obj;
3046  if(ilForumPostDraft::isSavePostDraftAllowed() && isset($_GET['draft_id']) && (int)$_GET['draft_id'] > 0)
3047  {
3048  $file_obj_for_delivery = new ilFileDataForumDrafts($forumObj->getId(), (int)$_GET['draft_id']);
3049  }
3050  $file_obj_for_delivery->deliverFile($_GET['file']);
3051  unset($file_obj_for_delivery);
3052  }
3053 
3054  if(!$this->objCurrentTopic->getId())
3055  {
3056  $ilCtrl->redirect($this, 'showThreads');
3057  }
3058 
3059  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $this->objCurrentTopic);
3060 
3061  // Set context for login
3062  $append = '_'.$this->objCurrentTopic->getId().
3063  ($this->objCurrentPost->getId() ? '_'.$this->objCurrentPost->getId() : '');
3064  $tpl->setLoginTargetPar('frm_'.$_GET['ref_id'].$append);
3065 
3066  // delete temporary media object (not in case a user adds media objects and wants to save an invalid form)
3067  if($_GET['action'] != 'showreply' && $_GET['action'] != 'showedit')
3068  {
3069  try
3070  {
3071  include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
3072  $mobs = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId());
3073  foreach($mobs as $mob)
3074  {
3075  if(ilObjMediaObject::_exists($mob))
3076  {
3077  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
3078  $mob_obj = new ilObjMediaObject($mob);
3079  $mob_obj->delete();
3080  }
3081  }
3082  }
3083  catch(Exception $e)
3084  {
3085  }
3086  }
3087 
3088  if($this->isHierarchicalView())
3089  {
3090  require_once 'Modules/Forum/classes/class.ilForumExplorerGUI.php';
3091  $exp = new ilForumExplorerGUI('frm_exp_' . $this->objCurrentTopic->getId(), $this, 'viewThread');
3092  $exp->setThread($this->objCurrentTopic);
3093  if(!$exp->handleCommand())
3094  {
3095  $this->tpl->setLeftNavContent($exp->getHTML());
3096  }
3097  }
3098 
3099  require_once './Modules/Forum/classes/class.ilObjForum.php';
3100  require_once './Modules/Forum/classes/class.ilFileDataForum.php';
3101 
3102  $lng->loadLanguageModule('forum');
3103 
3104  // add entry to navigation history
3105  if (!$this->getCreationMode() &&
3106  $ilAccess->checkAccess('read', '', $this->object->getRefId()))
3107  {
3108  $ilCtrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3109  $ilNavigationHistory->addItem($this->object->getRefId(), $ilCtrl->getLinkTarget($this, 'showThreads'), 'frm');
3110  }
3111 
3112  // save last access
3113  $forumObj->updateLastAccess($ilUser->getId(), (int) $this->objCurrentTopic->getId());
3114 
3115  $this->prepareThreadScreen($forumObj);
3116 
3117  $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_view.html', 'Modules/Forum');
3118 
3119  if(isset($_GET['anchor']))
3120  {
3121  $tpl->setVariable('JUMP2ANCHOR_ID', (int)$_GET['anchor']);
3122  }
3123 
3124  if($this->isHierarchicalView())
3125  {
3126  $orderField = 'frm_posts_tree.rgt';
3127  $this->objCurrentTopic->setOrderDirection('DESC');
3128  }
3129  else
3130  {
3131  $orderField = 'frm_posts.pos_date';
3132  $this->objCurrentTopic->setOrderDirection(
3133  in_array($this->objProperties->getDefaultView(), array(ilForumProperties::VIEW_DATE_ASC, ilForumProperties::VIEW_TREE))
3134  ? 'ASC' : 'DESC'
3135  );
3136  }
3137 
3138  // get forum- and thread-data
3139  $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
3140 
3141  if(is_array($topicData = $frm->getOneTopic()))
3142  {
3143  // Visit-Counter for topic
3144  $this->objCurrentTopic->updateVisits();
3145 
3146  $tpl->setTitle($lng->txt('forums_thread')." \"".$this->objCurrentTopic->getSubject()."\"");
3147 
3148  // ********************************************************************************
3149  // build location-links
3150  $ilLocator->addRepositoryItems();
3151  $ilLocator->addItem($this->object->getTitle(), $ilCtrl->getLinkTarget($this, ""), "_top");
3152  $tpl->setLocator();
3153 
3154  // set tabs
3155  // menu template (contains linkbar)
3157  $menutpl = new ilTemplate('tpl.forums_threads_menu.html', true, true, 'Modules/Forum');
3158 
3159  include_once("./Services/Accessibility/classes/class.ilAccessKeyGUI.php");
3160 
3161  // mark all as read
3162  if(
3163  $ilUser->getId() != ANONYMOUS_USER_ID &&
3164  $forumObj->getCountUnread($ilUser->getId(), (int) $this->objCurrentTopic->getId())
3165  )
3166  {
3167  $this->ctrl->setParameter($this, 'mark_read', '1');
3168  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3169 
3170  $mark_thr_read_button = ilLinkButton::getInstance();
3171  $mark_thr_read_button->setCaption('forums_mark_read');
3172  $mark_thr_read_button->setUrl($this->ctrl->getLinkTarget($this, 'viewThread'));
3173  $mark_thr_read_button->setAccessKey(ilAccessKey::MARK_ALL_READ);
3174 
3175  $bottom_toolbar_split_button_items[] = $mark_thr_read_button;
3176 
3177  $this->ctrl->clearParameters($this);
3178  }
3179 
3180  // print thread
3181  $this->ctrl->setParameterByClass('ilforumexportgui', 'print_thread', $this->objCurrentTopic->getId());
3182  $this->ctrl->setParameterByClass('ilforumexportgui', 'thr_top_fk', $this->objCurrentTopic->getForumId());
3183 
3184 
3185  $print_thr_button = ilLinkButton::getInstance();
3186  $print_thr_button->setCaption('forums_print_thread');
3187  $print_thr_button->setUrl($this->ctrl->getLinkTargetByClass('ilforumexportgui', 'printThread'));
3188 
3189  $bottom_toolbar_split_button_items[] = $print_thr_button;
3190 
3191  $this->ctrl->clearParametersByClass('ilforumexportgui');
3192 
3193  $this->addHeaderAction();
3194 
3195  if($_GET['mark_read'])
3196  {
3197  $forumObj->markThreadRead($ilUser->getId(), (int)$this->objCurrentTopic->getId());
3198  ilUtil::sendInfo($lng->txt('forums_thread_marked'), true);
3199  }
3200 
3201  // delete post and its sub-posts
3202  require_once './Modules/Forum/classes/class.ilForum.php';
3203 
3204  if ($_GET['action'] == 'ready_delete' && $_POST['confirm'] != '')
3205  {
3206  if(!$this->objCurrentTopic->isClosed() &&
3207  ($this->is_moderator ||
3208  ($this->objCurrentPost->isOwner($ilUser->getId()) && !$this->objCurrentPost->hasReplies())) &&
3209  $ilUser->getId() != ANONYMOUS_USER_ID)
3210  {
3211  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $this->objCurrentPost->getThread());
3212 
3213  $frm = new ilForum();
3214 
3215  $frm->setForumId($forumObj->getId());
3216  $frm->setForumRefId($forumObj->getRefId());
3217 
3218  $dead_thr = $frm->deletePost($this->objCurrentPost->getId());
3219 
3220  // if complete thread was deleted ...
3221  if ($dead_thr == $this->objCurrentTopic->getId())
3222  {
3223 
3224  $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($forumObj->getId()));
3225 
3226  $topicData = $frm->getOneTopic();
3227 
3228  ilUtil::sendInfo($lng->txt('forums_post_deleted'), true);
3229 
3230  if ($topicData['top_num_threads'] > 0)
3231  {
3232  $this->ctrl->redirect($this, 'showThreads');
3233  }
3234  else
3235  {
3236  $this->ctrl->redirect($this, 'createThread');
3237  }
3238  }
3239  ilUtil::sendInfo($lng->txt('forums_post_deleted'));
3240  }
3241 
3242  }
3243 
3244  if ($_GET['action'] == 'ready_delete_draft' && $_POST['confirm'] != '')
3245  {
3246  $this->deleteSelectedDraft();
3247  ilUtil::sendInfo($lng->txt('forums_post_deleted'));
3248  }
3249 
3250  // form processing (censor)
3251  if(!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'ready_censor')
3252  {
3253  $cens_message = $this->handleFormInput($_POST['formData']['cens_message']);
3254 
3255  if(($_POST['confirm'] != '' || $_POST['no_cs_change'] != '') && $_GET['action'] == 'ready_censor') {
3256  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $this->objCurrentPost->getThread());
3257  $frm->postCensorship($cens_message, $this->objCurrentPost->getId(), 1);
3258  ilUtil::sendSuccess($this->lng->txt('frm_censorship_applied'));
3259  } elseif (($_POST['cancel'] != '' || $_POST['yes_cs_change'] != '') && $_GET['action'] == 'ready_censor') {
3260  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $this->objCurrentPost->getThread());
3261  $frm->postCensorship($cens_message, $this->objCurrentPost->getId());
3262  ilUtil::sendSuccess($this->lng->txt('frm_censorship_revoked'));
3263  }
3264  }
3265 
3266  // get complete tree of thread
3267  $first_node = $this->objCurrentTopic->getFirstPostNode();
3268  $this->objCurrentTopic->setOrderField($orderField);
3269  $subtree_nodes = $this->objCurrentTopic->getPostTree($first_node);
3270 
3271  if(
3272  !$this->isTopLevelReplyCommand() &&
3273  $first_node instanceof ilForumPost &&
3274  !$this->objCurrentTopic->isClosed() &&
3275  $ilAccess->checkAccess('add_reply', '', (int)$_GET['ref_id'])
3276  )
3277  {
3278  $reply_button = ilLinkButton::getInstance();
3279  $reply_button->setPrimary(true);
3280  $reply_button->setCaption('add_new_answer');
3281  $this->ctrl->setParameter($this, 'action', 'showreply');
3282  $this->ctrl->setParameter($this, 'pos_pk', $first_node->getId());
3283  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3284  $this->ctrl->setParameter($this, 'offset', (int)$_GET['offset']);
3285  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
3286 
3287  $reply_button->setUrl($this->ctrl->getLinkTarget($this, 'createTopLevelPost', 'frm_page_bottom'));
3288 
3289  $this->ctrl->clearParameters($this);
3290  array_unshift($bottom_toolbar_split_button_items, $reply_button);
3291  }
3292 
3293  // no posts
3294  if (!$posNum = count($subtree_nodes))
3295  {
3296  ilUtil::sendInfo($this->lng->txt('forums_no_posts_available'));
3297  }
3298 
3299  $pageHits = $frm->getPageHits();
3300 
3301  $z = 0;
3302 
3303  // navigation to browse
3304  if ($posNum > $pageHits)
3305  {
3306  $params = array(
3307  'ref_id' => $_GET['ref_id'],
3308  'thr_pk' => $this->objCurrentTopic->getId(),
3309  'orderby' => $_GET['orderby']
3310  );
3311 
3312  if (!$_GET['offset'])
3313  {
3314  $Start = 0;
3315  }
3316  else
3317  {
3318  $Start = $_GET['offset'];
3319  }
3320 
3321  $linkbar = ilUtil::Linkbar($ilCtrl->getLinkTarget($this, 'viewThread'), $posNum, $pageHits, $Start, $params);
3322 
3323  if($linkbar != '')
3324  {
3325  $menutpl->setCurrentBlock('linkbar');
3326  $menutpl->setVariable('LINKBAR', $linkbar);
3327  $menutpl->parseCurrentBlock();
3328  }
3329  }
3330 
3331  $tpl->setVariable('THREAD_MENU', $menutpl->get());
3332 
3333  // assistance val for anchor-links
3334  $jump = 0;
3335  $render_drafts = false;
3336  $draftsObjects = NULL;
3337 
3338  if(ilForumPostDraft::isSavePostDraftAllowed() && !$ilUser->isAnonymous())
3339  {
3340  $draftsObjects = ilForumPostDraft::getInstancesByUserIdAndThreadId($ilUser->getId(), $this->objCurrentTopic->getId());
3341  if(count($draftsObjects) > 0)
3342  {
3343  $render_drafts = true;
3344  }
3345  }
3346 
3347  // generate post-dates
3348  foreach($subtree_nodes as $node)
3349  {
3354  $this->ctrl->clearParameters($this);
3355 
3356  if($this->objCurrentPost->getId() && $this->objCurrentPost->getId() == $node->getId())
3357  {
3358  $jump++;
3359  }
3360 
3361  if ($posNum > $pageHits && $z >= ($Start + $pageHits))
3362  {
3363  // if anchor-link was not found ...
3364  if ($this->objCurrentPost->getId() && $jump < 1)
3365  {
3366  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3367  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
3368  $this->ctrl->setParameter($this, 'offset', ($Start + $pageHits));
3369  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
3370  $this->ctrl->redirect($this, 'viewThread', $this->objCurrentPost->getId());
3371  }
3372  else
3373  {
3374  break;
3375  }
3376  }
3377 
3378  if(($posNum > $pageHits && $z >= $Start) || $posNum <= $pageHits)
3379  {
3380  $actions = array();
3381  if(!$this->isTopLevelReplyCommand() && $this->objCurrentPost->getId() == $node->getId())
3382  {
3383  # actions for "active" post
3384  if($this->is_moderator || $node->isActivated() || $node->isOwner($ilUser->getId()))
3385  {
3386  // reply/edit
3387  if(
3388  !$this->objCurrentTopic->isClosed() && (
3389  $_GET['action'] == 'showreply' || $_GET['action'] == 'showedit' ||
3390  $_GET['action'] == 'showdraft'|| $_GET['action'] == 'editdraft'
3391  ))
3392  {
3393  if($_GET['action'] == 'showedit' &&
3394  ((!$this->is_moderator &&
3395  !$node->isOwner($ilUser->getId()) || $ilUser->getId() == ANONYMOUS_USER_ID) || $node->isCensored()))
3396  {
3397  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
3398  }
3399  else if($_GET['action'] == 'showreply' && !$ilAccess->checkAccess('add_reply', '', (int)$_GET['ref_id']))
3400  {
3401  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
3402  }
3403 
3404  $tpl->setVariable('REPLY_ANKER', $this->objCurrentPost->getId());
3405  $oEditReplyForm = $this->getReplyEditForm();
3406  if($_GET['action'] != 'editdraft')
3407  {
3408  switch($this->objProperties->getSubjectSetting())
3409  {
3410  case 'add_re_to_subject':
3411  $subject = $this->getModifiedReOnSubject(true);
3412  break;
3413 
3414  case 'preset_subject':
3415  $subject = $this->objCurrentPost->getSubject();
3416  break;
3417 
3418  case 'empty_subject':
3419  default:
3420  $subject = NULL;
3421  break;
3422  }
3423  }
3424  switch($_GET['action'])
3425  {
3426  case 'showreply':
3427  if($this->ctrl->getCmd() == 'savePost' || $this->ctrl->getCmd() == 'saveAsDraft')
3428  {
3429  $oEditReplyForm->setValuesByPost();
3430  }
3431  else if($this->ctrl->getCmd() == 'quotePost')
3432  {
3433  require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
3434  $authorinfo = new ilForumAuthorInformation(
3435  $node->getPosAuthorId(),
3436  $node->getDisplayUserId(),
3437  $node->getUserAlias(),
3438  $node->getImportName()
3439  );
3440 
3441  $oEditReplyForm->setValuesByPost();
3442  $oEditReplyForm->getItemByPostVar('message')->setValue(
3444  $frm->prepareText($node->getMessage(), 1, $authorinfo->getAuthorName())."\n".$oEditReplyForm->getInput('message'), 1
3445  )
3446  );
3447  }
3448  else
3449  {
3450  $oEditReplyForm->setValuesByArray(array(
3451  'alias' => '',
3452  'subject' => $subject,
3453  'message' => '',
3454  'notify' => 0,
3455  'userfile' => '',
3456  'del_file' => array()
3457  ));
3458  }
3459 
3460  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
3461  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
3462 
3463  $jsTpl = new ilTemplate('tpl.forum_post_quoation_ajax_handler.html', true, true, 'Modules/Forum');
3464  $jsTpl->setVariable('IL_FRM_QUOTE_CALLBACK_SRC',
3465  $this->ctrl->getLinkTarget($this, 'getQuotationHTMLAsynch', '', true));
3466  $this->ctrl->clearParameters($this);
3467  $this->tpl->setVariable('FORM_ADDITIONAL_JS', $jsTpl->get());
3468  break;
3469 
3470  case 'showedit':
3471  if($this->ctrl->getCmd() == 'savePost')
3472  {
3473  $oEditReplyForm->setValuesByPost();
3474  }
3475  else
3476  {
3477  $oEditReplyForm->setValuesByArray(array(
3478  'alias' => '',
3479  'subject' => $this->objCurrentPost->getSubject(),
3480  'message' => ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($this->objCurrentPost->getMessage(), 2), 1),
3481  'notify' => $this->objCurrentPost->isNotificationEnabled() ? true : false,
3482  'userfile' => '',
3483  'del_file' => array()
3484  ));
3485  }
3486  break;
3487 
3488  case 'editdraft':
3489  if(in_array($this->ctrl->getCmd(), array('saveDraft', 'updateDraft', 'publishDraft' )))
3490  {
3491  $oEditReplyForm->setValuesByPost();
3492  }
3493  else
3494  {
3495 
3496  if(isset($_GET['draft_id']) && (int)$_GET['draft_id'] > 0)
3497  {
3501  $draftObject = new ilForumPostDraft($ilUser->getId(), $this->objCurrentPost->getId(), (int)$_GET['draft_id']);
3502  $oEditReplyForm->setValuesByArray(array(
3503  'alias' => $draftObject->getPostUserAlias(),
3504  'subject' => $draftObject->getPostSubject(),
3505  'message' => ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($draftObject->getPostMessage(), 2), 1),
3506  'notify' => $draftObject->getNotify() ? true : false,
3507  'userfile' => '',
3508  'del_file' => array()
3509  ));
3510  // $edit_draft_id = $this->objCurrentPost->getId();
3511  $edit_draft_id = $draftObject->getDraftId();
3512  }
3513  }
3514  break;
3515  }
3516  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
3517  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
3518  $this->ctrl->setParameter($this, 'offset', (int)$_GET['offset']);
3519  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
3520  $this->ctrl->setParameter($this, 'action', $_GET['action']);
3521  if($_GET['action'] != 'editdraft')
3522  {
3523  $tpl->setVariable('FORM', $oEditReplyForm->getHTML());
3524  }
3525  $this->ctrl->clearParameters($this);
3526 
3527  } // if ($_GET['action'] == 'showreply' || $_GET['action'] == 'showedit')
3528  else if(!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'delete')
3529  {
3530  if($this->is_moderator ||
3531  ($node->isOwner($ilUser->getId()) && !$node->hasReplies()) &&
3532  $ilUser->getId() != ANONYMOUS_USER_ID)
3533  {
3534  // confirmation: delete
3535  $tpl->setVariable('FORM', $this->getDeleteFormHTML());
3536  }
3537  }
3538 // else if ($_GET['action'] == 'delete')
3539  else if(!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'censor')
3540  {
3541  if($this->is_moderator)
3542  {
3543  // confirmation: censor / remove censorship
3544  $tpl->setVariable('FORM', $this->getCensorshipFormHTML());
3545  }
3546  }
3547  else if (!$this->objCurrentTopic->isClosed() && $this->displayConfirmPostActivation())
3548  {
3549  if ($this->is_moderator)
3550  {
3551  // confirmation: activate
3552  $tpl->setVariable('FORM', $this->getActivationFormHTML());
3553  }
3554  }
3555 
3556  }
3557  }
3558  $this->renderPostContent($node, $Start, $z);
3559  $this->renderDraftContent($render_drafts, $node, $edit_draft_id);
3560  }
3561  $z++;
3562  }
3563 
3564  $first_node = $this->objCurrentTopic->getFirstPostNode();
3565  if(
3566  $first_node instanceof ilForumPost &&
3567  in_array($this->ctrl->getCmd(), array('createTopLevelPost', 'saveTopLevelPost', 'quoteTopLevelPost')) &&
3568  !$this->objCurrentTopic->isClosed() &&
3569  $ilAccess->checkAccess('add_reply', '', (int)$_GET['ref_id']))
3570  {
3571  // Important: Don't separate the following two lines (very fragile code ...)
3572  $this->objCurrentPost->setId($first_node->getId());
3573  $form = $this->getReplyEditForm();
3574 
3575  if($this->ctrl->getCmd() == 'saveTopLevelPost')
3576  {
3577  $form->setValuesByPost();
3578  }
3579  else if($this->ctrl->getCmd() == 'quoteTopLevelPost')
3580  {
3581  require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
3582  $authorinfo = new ilForumAuthorInformation(
3583  $first_node->getPosAuthorId(),
3584  $first_node->getDisplayUserId(),
3585  $first_node->getUserAlias(),
3586  $first_node->getImportName()
3587  );
3588 
3589  $form->setValuesByPost();
3590  $form->getItemByPostVar('message')->setValue(
3592  $frm->prepareText($first_node->getMessage(), 1, $authorinfo->getAuthorName())."\n".$form->getInput('message'), 1
3593  )
3594  );
3595  }
3596  $this->ctrl->setParameter($this, 'pos_pk', $first_node->getId());
3597  $this->ctrl->setParameter($this, 'thr_pk', $first_node->getThreadId());
3598  $jsTpl = new ilTemplate('tpl.forum_post_quoation_ajax_handler.html', true, true, 'Modules/Forum');
3599  $jsTpl->setVariable('IL_FRM_QUOTE_CALLBACK_SRC', $this->ctrl->getLinkTarget($this, 'getQuotationHTMLAsynch', '', true));
3600  $this->ctrl->clearParameters($this);
3601  $tpl->setVariable('BOTTOM_FORM_ADDITIONAL_JS', $jsTpl->get());;
3602  $tpl->setVariable('BOTTOM_FORM', $form->getHTML());
3603  }
3604  }
3605  else
3606  {
3607  $tpl->setCurrentBlock('posts_no');
3608  $tpl->setVariable('TXT_MSG_NO_POSTS_AVAILABLE', $lng->txt('forums_posts_not_available'));
3609  $tpl->parseCurrentBlock();
3610  }
3611 
3612  if($bottom_toolbar_split_button_items)
3613  {
3614  $bottom_split_button = ilSplitButtonGUI::getInstance();
3615  $i = 0;
3616  foreach($bottom_toolbar_split_button_items as $item)
3617  {
3618  if($i == 0)
3619  {
3620  $bottom_split_button->setDefaultButton($item);
3621  }
3622  else
3623  {
3624  $bottom_split_button->addMenuItem(new ilButtonToSplitButtonMenuItemAdapter($item));
3625  }
3626 
3627  ++$i;
3628  }
3629  $bottom_toolbar->addStickyItem($bottom_split_button);
3630  }
3631 
3632  $ilToolbar = clone $bottom_toolbar;
3633 
3634  if($bottom_toolbar_split_button_items)
3635  {
3636  $bottom_toolbar->addSeparator();
3637  }
3638 
3639  $to_top_button = ilLinkButton::getInstance();
3640  $to_top_button->setCaption('top_of_page');
3641  $to_top_button->setUrl('#frm_page_top');
3642  $bottom_toolbar->addButtonInstance($to_top_button);
3643  $tpl->setVariable('TOOLBAR_BOTTOM', $bottom_toolbar->getHTML());
3644 
3645  include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
3646  $permalink = new ilPermanentLinkGUI('frm', $this->object->getRefId(), '_'.$this->objCurrentTopic->getId());
3647  $this->tpl->setVariable('PRMLINK', $permalink->getHTML());
3648 
3649  return true;
3650  }
3651 
3652  private function getModifiedReOnSubject($on_reply = false)
3653  {
3654  $subject = $this->objCurrentPost->getSubject();
3655  $re_txt = $this->lng->txt('post_reply');
3656 
3657  $re_txt_with_num = str_replace(':', '(',$re_txt);
3658  $search_length = strlen($re_txt_with_num);
3659  $comp = substr_compare($re_txt_with_num, substr($subject, 0 , $search_length), 0, $search_length);
3660 
3661  if($comp == 0)
3662  {
3663  $modified_subject = $subject;
3664  if($on_reply == true)
3665  {
3666  // i.e. $subject = "Re(12):"
3667  $str_pos_start = strpos($subject, '(');
3668  $str_pos_end = strpos($subject, ')');
3669 
3670  $length = ((int)$str_pos_end - (int)$str_pos_start);
3671  $str_pos_start++;
3672  $txt_number = substr($subject, $str_pos_start, $length - 1);
3673 
3674  if(is_numeric($txt_number))
3675  {
3676  $re_count = (int)$txt_number + 1;
3677  $modified_subject = substr($subject, 0, $str_pos_start) . $re_count . substr($subject, $str_pos_end);
3678  }
3679  }
3680  }
3681  else
3682  {
3683  $re_count = substr_count($subject, $re_txt);
3684  if($re_count >= 1 && $on_reply == true)
3685  {
3686  $subject = str_replace($re_txt, '', $subject);
3687 
3688  // i.e. $subject = "Re: Re: Re: ... " -> "Re(4):"
3689  $re_count++;
3690  $modified_subject = sprintf($this->lng->txt('post_reply_count'), $re_count).' '.trim($subject);
3691  }
3692  else if($re_count >= 1 && $on_reply == false)
3693  {
3694  // possibility to modify the subject only for output
3695  // i.e. $subject = "Re: Re: Re: ... " -> "Re(3):"
3696  $modified_subject = sprintf($this->lng->txt('post_reply_count'), $re_count).' '.trim($subject);
3697  }
3698  else if($re_count == 0)
3699  {
3700  // the first reply to a thread
3701  $modified_subject = $this->lng->txt('post_reply').' '. $this->objCurrentPost->getSubject();
3702  }
3703  }
3704  return $modified_subject;
3705  }
3706 
3707  public function showUserObject()
3708  {
3709  // we could actually call ilpublicuserprofilegui directly, this method
3710  // is not needed - but sadly used throughout the forum code
3711  // see above in execute command
3712 
3713  include_once 'Services/User/classes/class.ilPublicUserProfileGUI.php';
3714  $profile_gui = new ilPublicUserProfileGUI((int)$_GET['user']);
3715  $add = $this->getUserProfileAdditional((int)$_GET['ref_id'], (int)$_GET['user']);
3716  $profile_gui->setAdditional($add);
3717  $profile_gui->setBackUrl(\ilUtil::stripSlashes($_GET['backurl']));
3718  $this->tpl->setContent($this->ctrl->getHTML($profile_gui));
3719  }
3720 
3721  protected function getUserProfileAdditional($a_forum_ref_id, $a_user_id)
3722  {
3727  global $lng, $ilAccess;
3728 
3729  if(!$ilAccess->checkAccess('read', '', $a_forum_ref_id))
3730  {
3731  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
3732  }
3733 
3734  require_once 'Modules/Forum/classes/class.ilForum.php';
3735 
3736  $lng->loadLanguageModule('forum');
3737 
3741  $ref_obj = ilObjectFactory::getInstanceByRefId($a_forum_ref_id);
3742  if($ref_obj->getType() == 'frm')
3743  {
3744  $forumObj = new ilObjForum($a_forum_ref_id);
3745  $frm = $forumObj->Forum;
3746  $frm->setForumId($forumObj->getId());
3747  $frm->setForumRefId($forumObj->getRefId());
3748  }
3749  else
3750  {
3751  $frm = new ilForum();
3752  }
3753 
3754  // count articles of user
3755  if($ilAccess->checkAccess('moderate_frm', '', $a_forum_ref_id))
3756  {
3757  $numPosts = $frm->countUserArticles(addslashes($a_user_id));
3758  }
3759  else
3760  {
3761  $numPosts = $frm->countActiveUserArticles(addslashes($a_user_id));
3762  }
3763 
3764  return array($lng->txt('forums_posts') => $numPosts);
3765  }
3766 
3767  public function performThreadsActionObject()
3768  {
3772  global $ilUser;
3773 
3774  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3775  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3776  }
3777 
3778  unset($_SESSION['threads2move']);
3779 
3780  if(isset($_POST['thread_ids']) && is_array($_POST['thread_ids']))
3781  {
3782  if(isset($_POST['selected_cmd']) && $_POST['selected_cmd'] == 'move')
3783  {
3784  if($this->is_moderator)
3785  {
3786  $_SESSION['threads2move'] = $_POST['thread_ids'];
3787  $this->moveThreadsObject();
3788  }
3789  }
3790  else if($_POST['selected_cmd'] == 'enable_notifications' && $this->ilias->getSetting('forum_notification') != 0)
3791  {
3792  for($i = 0; $i < count($_POST['thread_ids']); $i++)
3793  {
3794  $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3795  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $tmp_obj);
3796  $tmp_obj->enableNotification($ilUser->getId());
3797  }
3798 
3799  $this->ctrl->redirect($this, 'showThreads');
3800  }
3801  else if($_POST['selected_cmd'] == 'disable_notifications' && $this->ilias->getSetting('forum_notification') != 0)
3802  {
3803  for($i = 0; $i < count($_POST['thread_ids']); $i++)
3804  {
3805  $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3806  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $tmp_obj);
3807  $tmp_obj->disableNotification($ilUser->getId());
3808  }
3809 
3810  $this->ctrl->redirect($this, 'showThreads');
3811  }
3812 
3813  else if($_POST['selected_cmd'] == 'close')
3814  {
3815  if($this->is_moderator)
3816  {
3817  for($i = 0; $i < count($_POST['thread_ids']); $i++)
3818  {
3819  $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3820  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $tmp_obj);
3821  $tmp_obj->close();
3822  }
3823  }
3824  ilUtil::sendSuccess($this->lng->txt('selected_threads_closed'), true);
3825  $this->ctrl->redirect($this, 'showThreads');
3826  }
3827  else if($_POST['selected_cmd'] == 'reopen')
3828  {
3829  if($this->is_moderator)
3830  {
3831  for($i = 0; $i < count($_POST['thread_ids']); $i++)
3832  {
3833  $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3834  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $tmp_obj);
3835  $tmp_obj->reopen();
3836  }
3837  }
3838 
3839  ilUtil::sendSuccess($this->lng->txt('selected_threads_reopened'), true);
3840  $this->ctrl->redirect($this, 'showThreads');
3841  }
3842  else if($_POST['selected_cmd'] == 'makesticky')
3843  {
3844  if($this->is_moderator)
3845  {
3846  $message = $this->lng->txt('sel_threads_make_sticky');
3847 
3848  for($i = 0; $i < count($_POST['thread_ids']); $i++)
3849  {
3850  $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3851  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $tmp_obj);
3852  $makeSticky = $tmp_obj->makeSticky();
3853 
3854  if(!$makeSticky)
3855  {
3856  $message = $this->lng->txt('sel_threads_already_sticky');
3857  }
3858  }
3859  }
3860  if($message != null)
3861  {
3862  ilUtil::sendInfo($message,true);
3863  }
3864  $this->ctrl->redirect($this, 'showThreads');
3865  }
3866  else if($_POST['selected_cmd'] == 'unmakesticky')
3867  {
3868  if($this->is_moderator)
3869  {
3870  $message = $this->lng->txt('sel_threads_make_unsticky');
3871  for($i = 0; $i < count($_POST['thread_ids']); $i++)
3872  {
3873  $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3874  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $tmp_obj);
3875  $unmakeSticky = $tmp_obj->unmakeSticky();
3876  if(!$unmakeSticky)
3877  {
3878  $message = $this->lng->txt('sel_threads_already_unsticky');
3879  }
3880  }
3881  }
3882 
3883  if($message != null)
3884  {
3885  ilUtil::sendInfo($message,true);
3886  }
3887  $this->ctrl->redirect($this, 'showThreads');
3888  }
3889  else if($_POST['selected_cmd'] == 'editThread')
3890  {
3891  if($this->is_moderator)
3892  {
3893  $count = count($_POST['thread_ids']);
3894  if($count != 1)
3895  {
3896  ilUtil::sendInfo($this->lng->txt('select_max_one_thread'), true);
3897  $this->ctrl->redirect($this, 'showThreads');
3898  }
3899  else
3900  {
3901  foreach($_POST['thread_ids'] as $thread_id)
3902  {
3903  return $this->editThreadObject($thread_id, null);
3904  }
3905  }
3906  }
3907 
3908  $this->ctrl->redirect($this, 'showThreads');
3909  }
3910  else if($_POST['selected_cmd'] == 'html')
3911  {
3912  $this->ctrl->setCmd('exportHTML');
3913  $this->ctrl->setCmdClass('ilForumExportGUI');
3914  $this->executeCommand();
3915  }
3916  else if($_POST['selected_cmd'] == 'confirmDeleteThreads')
3917  {
3918  $this->confirmDeleteThreads();
3919  }
3920  else if($_POST['selected_cmd'] == 'merge')
3921  {
3922  $this->mergeThreadsObject();
3923  }
3924  else
3925  {
3926  ilUtil::sendInfo($this->lng->txt('topics_please_select_one_action'), true);
3927  $this->ctrl->redirect($this, 'showThreads');
3928  }
3929  }
3930  else
3931  {
3932  ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'), true);
3933  $this->ctrl->redirect($this, 'showThreads');
3934  }
3935  }
3936 
3937  public function performMoveThreadsObject()
3938  {
3939  if (!$this->is_moderator) {
3940  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3941  }
3942 
3943  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3944  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3945  }
3946 
3947  $threads2move = $_SESSION['threads2move'];
3948  if (!is_array($threads2move) || !count($threads2move)) {
3949  ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'), true);
3950  $this->ctrl->redirect($this, 'showThreads');
3951  }
3952 
3953  if (!$this->access->checkAccess('read', '', (int)$_POST['frm_ref_id'])) {
3954  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3955  }
3956 
3957  $threads = [];
3958  array_walk($threads2move, function($threadId) use (&$threads) {
3959  $thread = new \ilForumTopic($threadId);
3960  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $thread);
3961 
3962  $threads[] = $threadId;
3963  });
3964 
3965  if (isset($_POST['frm_ref_id']) && (int)$_POST['frm_ref_id']) {
3966  $this->object->Forum->moveThreads(
3967  $threads, $this->object->getRefId(),
3968  $this->ilObjDataCache->lookupObjId((int)$_POST['frm_ref_id'])
3969  );
3970 
3971  unset($_SESSION['threads2move']);
3972  ilUtil::sendInfo($this->lng->txt('threads_moved_successfully'), true);
3973  $this->ctrl->redirect($this, 'showThreads');
3974  } else {
3975  ilUtil::sendInfo($this->lng->txt('no_forum_selected'));
3976  $this->moveThreadsObject();
3977  }
3978  }
3979 
3980  public function cancelMoveThreadsObject()
3981  {
3982  unset($_SESSION['threads2move']);
3983 
3984  $this->ctrl->redirect($this, 'showThreads');
3985  }
3986 
3987  public function moveThreadsObject()
3988  {
3994  global $lng, $ilToolbar, $tree;
3995 
3996  if (!$this->is_moderator) {
3997  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3998  }
3999 
4000  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4001  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4002  }
4003 
4004  $threads2move = $_SESSION['threads2move'];
4005  if(!is_array($threads2move) || !count($threads2move))
4006  {
4007  ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'), true);
4008  $this->ctrl->redirect($this, 'showThreads');
4009  }
4010 
4011  require_once 'Modules/Forum/classes/class.ilForumMoveTopicsExplorer.php';
4012 
4013  $threads = [];
4014  $isModerator = $this->is_moderator;
4015  array_walk($threads2move, function($threadId) use (&$threads, $isModerator) {
4016  $thread = new \ilForumTopic($threadId, $isModerator);
4017  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $thread);
4018 
4019  $threads[] = $thread;
4020  });
4021 
4022  $exp = new ilForumMoveTopicsExplorer($this, 'moveThreads');
4023  $exp->setPathOpen($this->object->getRefId());
4024  $exp->setNodeSelected(isset($_POST['frm_ref_id']) && (int)$_POST['frm_ref_id'] ? (int)$_POST['frm_ref_id'] : 0);
4025  $exp->setCurrentFrmRefId($this->object->getRefId());
4026  $exp->setHighlightedNode($this->object->getRefId());
4027  if(!$exp->handleCommand())
4028  {
4029  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_move.html', 'Modules/Forum');
4030 
4031  if(!$this->hideToolbar())
4032  $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this));
4033 
4034  $tblThr = new ilTable2GUI($this);
4035  $tblThr->setId('il_frm_thread_move_table_'.$this->object->getRefId());
4036  $tblThr->setTitle($this->lng->txt('move_chosen_topics'));
4037  $tblThr->addColumn($this->lng->txt('subject'), 'top_name', '100%');
4038  $tblThr->disable('header');
4039  $tblThr->disable('footer');
4040  $tblThr->disable('linkbar');
4041  $tblThr->disable('sort');
4042  $tblThr->disable('linkbar');
4043  $tblThr->setLimit(PHP_INT_MAX);
4044  $tblThr->setRowTemplate('tpl.forums_threads_move_thr_row.html', 'Modules/Forum');
4045  $tblThr->setDefaultOrderField('is_sticky');
4046  $counter = 0;
4047  $result = array();
4048  foreach ($threads as $thread) {
4049  $result[$counter]['num'] = $counter + 1;
4050  $result[$counter]['thr_subject'] = $thread->getSubject();
4051  ++$counter;
4052  }
4053  $tblThr->setData($result);
4054  $this->tpl->setVariable('THREADS_TABLE', $tblThr->getHTML());
4055 
4056  $this->tpl->setVariable('FRM_SELECTION_TREE', $exp->getHTML());
4057  $this->tpl->setVariable('CMD_SUBMIT', 'performMoveThreads');
4058  $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('move'));
4059  $this->tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this, 'performMoveThreads'));
4060  }
4061 
4062  return true;
4063  }
4064 
4066  {
4067  if($this->objProperties->isAnonymized()
4068  && (!$this->is_moderator || ($this->is_moderator && !$this->objProperties->getMarkModeratorPosts())))
4069  {
4070  return true;
4071  }
4072  return false;
4073  }
4074 
4075  private function initTopicCreateForm($edit_draft = false)
4076  {
4083  global $ilUser, $rbacsystem, $ilias, $ilSetting;
4084 
4085  $this->create_topic_form_gui = new ilPropertyFormGUI();
4086  if($edit_draft == true)
4087  {
4088  $this->create_topic_form_gui->setTitle($this->lng->txt('edit_thread_draft'));
4089  }
4090  else
4091  {
4092  $this->create_topic_form_gui->setTitle($this->lng->txt('forums_new_thread'));
4093  }
4094  $this->create_topic_form_gui->setTitleIcon(ilUtil::getImagePath('icon_frm.svg'));
4095  $this->create_topic_form_gui->setTableWidth('100%');
4096 
4097  // form action
4098  $this->create_topic_form_gui->setFormAction($this->ctrl->getFormAction($this, 'addThread'));
4099 
4100  if($this->isWritingWithPseudonymAllowed())
4101  {
4102  $alias_gui = new ilTextInputGUI($this->lng->txt('forums_your_name'), 'alias');
4103  $alias_gui->setInfo($this->lng->txt('forums_use_alias'));
4104  $alias_gui->setMaxLength(255);
4105  $alias_gui->setSize(50);
4106  $this->create_topic_form_gui->addItem($alias_gui);
4107  }
4108  else
4109  {
4110  $alias_gui = new ilNonEditableValueGUI($this->lng->txt('forums_your_name'), 'alias');
4111  $alias_gui->setValue($ilUser->getLogin());
4112  $this->create_topic_form_gui->addItem($alias_gui);
4113  }
4114 
4115  // topic
4116  $subject_gui = new ilTextInputGUI($this->lng->txt('forums_thread'), 'subject');
4117  $subject_gui->setMaxLength(255);
4118  $subject_gui->setSize(50);
4119  $subject_gui->setRequired(true);
4120  $this->create_topic_form_gui->addItem($subject_gui);
4121 
4122  // message
4123  $post_gui = new ilTextAreaInputGUI($this->lng->txt('forums_the_post'), 'message');
4124  $post_gui->setCols(50);
4125  $post_gui->setRows(15);
4126  $post_gui->setRequired(true);
4127  $post_gui->setUseRte(true);
4128  $post_gui->addPlugin('latex');
4129  $post_gui->addButton('latex');
4130  $post_gui->addButton('pastelatex');
4131  $post_gui->addPlugin('ilfrmquote');
4132  //$post_gui->addPlugin('code');
4133 
4134  $this->addAutosave($this->create_topic_form_gui);
4135 
4136  $post_gui->removePlugin('advlink');
4137  $post_gui->usePurifier(true);
4138  $post_gui->setRTERootBlockElement('');
4139  $post_gui->setRTESupport($ilUser->getId(), 'frm~', 'frm_post', 'tpl.tinymce_frm_post.html', false, '3.5.11');
4140  $post_gui->disableButtons(array(
4141  'charmap',
4142  'undo',
4143  'redo',
4144  'justifyleft',
4145  'justifycenter',
4146  'justifyright',
4147  'justifyfull',
4148  'anchor',
4149  'fullscreen',
4150  'cut',
4151  'copy',
4152  'paste',
4153  'pastetext',
4154  'formatselect'
4155  ));
4156 
4157  // purifier
4158  require_once 'Services/Html/classes/class.ilHtmlPurifierFactory.php';
4159  $post_gui->setPurifier(ilHtmlPurifierFactory::_getInstanceByType('frm_post'));
4160  $this->create_topic_form_gui->addItem($post_gui);
4161 
4162  if($this->objProperties->isFileUploadAllowed())
4163  {
4164  $fi = new ilFileWizardInputGUI($this->lng->txt('forums_attachments_add'), 'userfile');
4165  $fi->setFilenames(array(0 => ''));
4166  $this->create_topic_form_gui->addItem($fi);
4167  if($edit_draft == true)
4168  {
4169  if(isset($_GET['draft_id']) && (int)$_GET['draft_id'] > 0)
4170  {
4171  $thread_draft = ilForumPostDraft::newInstanceByDraftId((int)$_GET['draft_id']);
4172 
4173  if($thread_draft->getDraftId() > 0)
4174  {
4175  $oFDForumDrafts = new ilFileDataForumDrafts(0, $thread_draft->getDraftId());
4176  if(count($oFDForumDrafts->getFilesOfPost()))
4177  {
4178  $oExistingAttachmentsGUI = new ilCheckboxGroupInputGUI($this->lng->txt('forums_delete_file'), 'del_file');
4179  foreach($oFDForumDrafts->getFilesOfPost() as $file)
4180  {
4181  $oAttachmentGUI = new ilCheckboxInputGUI($file['name'], 'del_file');
4182  $oAttachmentGUI->setValue($file['md5']);
4183  $oExistingAttachmentsGUI->addOption($oAttachmentGUI);
4184  }
4185  $this->create_topic_form_gui->addItem($oExistingAttachmentsGUI);
4186  }
4187  }
4188  }
4189  }
4190  }
4191 
4192  include_once 'Services/Mail/classes/class.ilMail.php';
4193  $umail = new ilMail($ilUser->getId());
4194  // catch hack attempts
4195  if($rbacsystem->checkAccess('internal_mail', $umail->getMailObjectReferenceId()) &&
4196  !$this->objProperties->isAnonymized()
4197  )
4198  {
4199  // direct notification
4200  $dir_notification_gui = new ilCheckboxInputGUI($this->lng->txt('forum_direct_notification'), 'notify');
4201  $dir_notification_gui->setInfo($this->lng->txt('forum_notify_me'));
4202  $dir_notification_gui->setValue(1);
4203  $this->create_topic_form_gui->addItem($dir_notification_gui);
4204  }
4205 
4206  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
4207  if(
4208  $ilUser->isAnonymous() &&
4209  !$ilUser->isCaptchaVerified() &&
4210  ilCaptchaUtil::isActiveForForum()
4211  )
4212  {
4213  require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
4214  $captcha = new ilCaptchaInputGUI($this->lng->txt('cont_captcha_code'), 'captcha_code');
4215  $captcha->setRequired(true);
4216  $this->create_topic_form_gui->addItem($captcha);
4217  }
4218 
4220  {
4221 
4222  if($this->ctrl->getCmd() == 'editThreadDraft')
4223  {
4224  $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
4225 
4226  $this->create_topic_form_gui->setFormAction($this->ctrl->getFormAction($this, 'updateThreadDraft'));
4227  $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
4228  $this->create_topic_form_gui->addCommandButton('publishThreadDraft', $this->lng->txt('publish'));
4229  $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
4230  $this->create_topic_form_gui->addCommandButton('updateThreadDraft', $this->lng->txt('save_message'));
4231  }
4232  else
4233  {
4234  $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
4235  $this->create_topic_form_gui->setFormAction($this->ctrl->getFormAction($this, 'saveThreadAsDraft'));
4236  $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
4237  $this->create_topic_form_gui->addCommandButton('addThread', $this->lng->txt('create'));
4238  $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
4239  $this->create_topic_form_gui->addCommandButton('saveThreadAsDraft', $this->lng->txt('save_message'));
4240  }
4241  $this->create_topic_form_gui->addCommandButton('cancelDraft', $this->lng->txt('cancel'));
4242  }
4243  else
4244  {
4245  $this->create_topic_form_gui->addCommandButton('addThread', $this->lng->txt('create'));
4246  $this->create_topic_form_gui->addCommandButton('showThreads', $this->lng->txt('cancel'));
4247  }
4248  }
4249 
4250  public function deleteThreadDraftsObject()
4251  {
4252  global $ilUser;
4253 
4254  $draft_ids = array();
4255  if(isset($_GET['draft_id']) && (int)$_GET['draft_id'] > 0)
4256  {
4257  $draft_ids = array((int)$_GET['draft_id']);
4258  }
4259  elseif(isset($_POST['draft_ids']) && is_array($_POST['draft_ids']))
4260  {
4261  $draft_ids = $_POST['draft_ids'];
4262  }
4263  $instances = ilForumPostDraft::getDraftInstancesByUserId($ilUser->getId());
4264  $checked_draft_ids = array();
4265  foreach($draft_ids as $draft_id)
4266  {
4267  if(array_key_exists($draft_id, $instances))
4268  {
4269  $checked_draft_ids[] = $draft_id;
4270  $draftObj = $instances[$draft_id];
4271 
4272  $this->deleteMobsOfDraft($draftObj->getDraftId(), $draftObj->getPostMessage());
4273 
4274  // delete attachments of draft
4275  $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draftObj->getDraftId());
4276  $objFileDataForumDrafts->delete();
4277 
4279  {
4280  $GLOBALS['ilAppEventHandler']->raise(
4281  'Modules/Forum',
4282  'deletedDraft',
4283  array('draftObj' => $draftObj,
4284  'obj_id' => $this->object->getId(),
4285  'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed())
4286  );
4287  }
4288  // delete draft
4289  $draftObj->deleteDraft();
4290  }
4291  }
4292 
4293  if(count($checked_draft_ids) > 1)
4294  {
4295  ilUtil::sendInfo($this->lng->txt('delete_drafts_successfully'), true);
4296  }
4297  else
4298  {
4299  ilUtil::sendInfo($this->lng->txt('delete_draft_successfully'), true);
4300  }
4301 
4302  $this->ctrl->redirect($this, 'showThreads');
4303  }
4304 
4305  private function setTopicCreateDefaultValues()
4306  {
4307  $this->create_topic_form_gui->setValuesByArray(array(
4308  'subject' => '',
4309  'message' => '',
4310  'userfile' => '',
4311  'notify' => 0
4312  ));
4313  }
4314 
4315  public function createThreadObject()
4316  {
4317  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4318  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4319  }
4320 
4321  if (!$this->access->checkAccess('add_thread', '', $this->object->getRefId())) {
4322  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4323  }
4324 
4325  $this->initTopicCreateForm();
4326  $this->setTopicCreateDefaultValues();
4327 
4328  $create_form = new ilTemplate('tpl.create_thread_form.html', true, true, 'Modules/Forum');
4329  $create_form->setVariable('CREATE_FORM',$this->create_topic_form_gui->getHTML());
4330  $create_form->parseCurrentBlock();
4331 
4332  $this->tpl->setContent($create_form->get());
4333  }
4334 
4335  public function publishThreadDraftObject($a_prevent_redirect = false)
4336  {
4342  global $ilUser, $ilAccess, $lng;
4343 
4344  $frm = $this->object->Forum;
4345  $frm->setForumId($this->object->getId());
4346  $frm->setForumRefId($this->object->getRefId());
4347 
4348  if(!$ilAccess->checkAccess('add_thread', '', $this->object->getRefId()))
4349  {
4350  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
4351  }
4352 
4353  $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
4354 
4355  $topicData = $frm->getOneTopic();
4356 
4357  $this->initTopicCreateForm();
4358  if($this->create_topic_form_gui->checkInput())
4359  {
4360  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
4361  if(
4362  $ilUser->isAnonymous() &&
4363  !$ilUser->isCaptchaVerified() &&
4364  ilCaptchaUtil::isActiveForForum()
4365  )
4366  {
4367  $ilUser->setCaptchaVerified(true);
4368  }
4369  $user_alias = ilForumUtil::getPublicUserAlias($this->create_topic_form_gui->getInput('alias'), $this->objProperties->isAnonymized());
4370 
4371  $status = 1;
4372  if(
4373  $this->objProperties->isPostActivationEnabled() &&
4374  !$this->is_moderator || $this->objCurrentPost->isAnyParentDeactivated()
4375  )
4376  {
4377  $status = 0;
4378  }
4379 
4380  if(isset($_GET['draft_id']))
4381  {
4382  $draft_id = (int)$_GET['draft_id'];
4383  $draft_obj = ilForumPostDraft::newInstanceByDraftId((int)$draft_id);
4384 
4385  }
4386 
4387  $newThread = new ilForumTopic(0, true, true);
4388  $newThread->setForumId($topicData['top_pk']);
4389  $newThread->setThrAuthorId($draft_obj->getPostAuthorId());
4390  $newThread->setDisplayUserId($draft_obj->getPostDisplayUserId());
4391  $newThread->setSubject($this->handleFormInput($this->create_topic_form_gui->getInput('subject'), false));
4392  $newThread->setUserAlias($draft_obj->getPostUserAlias());
4393 
4394  $newPostId = $frm->generateThread(
4395  $newThread,
4396  ilRTE::_replaceMediaObjectImageSrc($this->create_topic_form_gui->getInput('message'), 0),
4397  $draft_obj->getNotify(),
4398  $draft_obj->getPostNotify(),
4399  $status
4400  );
4401 
4402  if($this->objProperties->isFileUploadAllowed())
4403  {
4404  $file = $_FILES['userfile'];
4405  if(is_array($file) && !empty($file))
4406  {
4407  $tmp_file_obj = new ilFileDataForum($this->object->getId(), $newPostId);
4408  $tmp_file_obj->storeUploadedFile($file);
4409  }
4410  }
4411 
4412  // Visit-Counter
4413  $frm->setDbTable('frm_data');
4414  $frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($topicData['top_pk']));
4415  $frm->updateVisits($topicData['top_pk']);
4416 
4417  $frm->setMDB2WhereCondition('thr_top_fk = %s AND thr_subject = %s AND thr_num_posts = 1 ',
4418  array('integer', 'text'), array($topicData['top_pk'], $this->create_topic_form_gui->getInput('subject')));
4419 
4420  $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId());
4421 
4422  foreach($uploadedObjects as $mob)
4423  {
4424  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
4425  ilObjMediaObject::_saveUsage($mob,'frm:html', $newPostId);
4426  }
4427 
4428  if(ilForumPostDraft::isSavePostDraftAllowed() && $draft_obj instanceof ilForumPostDraft)
4429  {
4430  $history_obj = new ilForumDraftsHistory();
4431  $history_obj->deleteHistoryByDraftIds(array($draft_obj->getDraftId()));
4432 
4433  if($this->objProperties->isFileUploadAllowed())
4434  {
4435  //move files of draft to posts directory
4436  $oFDForum = new ilFileDataForum($this->object->getId(), $newPostId);
4437  $oFDForumDrafts = new ilFileDataForumDrafts($this->object->getId(), $draft_obj->getDraftId());
4438 
4439  $oFDForumDrafts->moveFilesOfDraft($oFDForum->getForumPath(), $newPostId);
4440  }
4441  $draft_obj->deleteDraft();
4442  }
4443 
4444  $GLOBALS['ilAppEventHandler']->raise(
4445  'Modules/Forum',
4446  'createdPost',
4447  array(
4448  'ref_id' => $this->object->getRefId(),
4449  'post' => new ilForumPost($newPostId),
4450  'notify_moderators' => !$status
4451  )
4452  );
4453 
4454  if(!$a_prevent_redirect)
4455  {
4456  ilUtil::sendSuccess($this->lng->txt('forums_thread_new_entry'), true);
4457  $this->ctrl->clearParameters($this);
4458  $this->ctrl->redirect($this);
4459  }
4460  else
4461  {
4462  return $newPostId;
4463  }
4464  }
4465  else
4466  {
4467  $this->create_topic_form_gui->setValuesByPost();
4468 
4469  if(!$this->objProperties->isAnonymized())
4470  {
4471  $this->create_topic_form_gui->getItemByPostVar('alias')->setValue($ilUser->getLogin());
4472  }
4473 
4474  return $this->tpl->setContent($this->create_topic_form_gui->getHTML());
4475  }
4476 
4477  }
4478  public function addThreadObject($a_prevent_redirect = false)
4479  {
4485  global $ilUser, $ilAccess, $lng;
4486 
4487  $frm = $this->object->Forum;
4488  $frm->setForumId($this->object->getId());
4489  $frm->setForumRefId($this->object->getRefId());
4490 
4491  if(!$ilAccess->checkAccess('add_thread', '', $this->object->getRefId()))
4492  {
4493  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
4494  }
4495 
4496  $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
4497 
4498  $topicData = $frm->getOneTopic();
4499 
4500  $this->initTopicCreateForm();
4501  if($this->create_topic_form_gui->checkInput())
4502  {
4503  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
4504  if(
4505  $ilUser->isAnonymous() &&
4506  !$ilUser->isCaptchaVerified() &&
4507  ilCaptchaUtil::isActiveForForum()
4508  )
4509  {
4510  $ilUser->setCaptchaVerified(true);
4511  }
4512 
4513  if($this->isWritingWithPseudonymAllowed())
4514  {
4515  if(!strlen($this->create_topic_form_gui->getInput('alias')))
4516  {
4517  $user_alias = $this->lng->txt('forums_anonymous');
4518  }
4519  else
4520  {
4521  $user_alias = $this->create_topic_form_gui->getInput('alias');
4522  }
4523  $display_user_id = 0;
4524  }
4525  else
4526  {
4527  $user_alias = $ilUser->getLogin();
4528  $display_user_id = $ilUser->getId();
4529  }
4530  $user_alias = ilForumUtil::getPublicUserAlias($this->create_topic_form_gui->getInput('alias'), $this->objProperties->isAnonymized());
4531  $status = 1;
4532  if(
4533  $this->objProperties->isPostActivationEnabled() &&
4534  !$this->is_moderator || $this->objCurrentPost->isAnyParentDeactivated()
4535  )
4536  {
4537  $status = 0;
4538  }
4539 
4540  $newThread = new ilForumTopic(0, true, true);
4541  $newThread->setForumId($topicData['top_pk']);
4542  $newThread->setThrAuthorId($ilUser->getId());
4543  $newThread->setDisplayUserId($display_user_id);
4544  $newThread->setSubject($this->handleFormInput($this->create_topic_form_gui->getInput('subject'), false));
4545  $newThread->setUserAlias($user_alias);
4546 
4547  $newPost = $frm->generateThread(
4548  $newThread,
4549  ilRTE::_replaceMediaObjectImageSrc($this->create_topic_form_gui->getInput('message'), 0),
4550  $this->create_topic_form_gui->getItemByPostVar('notify') ? (int)$this->create_topic_form_gui->getInput('notify') : 0,
4551  0, // #19980
4552  $status
4553  );
4554 
4555  if($this->objProperties->isFileUploadAllowed())
4556  {
4557  $file = $_FILES['userfile'];
4558  if(is_array($file) && !empty($file))
4559  {
4560  $tmp_file_obj = new ilFileDataForum($this->object->getId(), $newPost);
4561  $tmp_file_obj->storeUploadedFile($file);
4562  }
4563  }
4564 
4565  // Visit-Counter
4566  $frm->setDbTable('frm_data');
4567  $frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($topicData['top_pk']));
4568  $frm->updateVisits($topicData['top_pk']);
4569 
4570  $frm->setMDB2WhereCondition('thr_top_fk = %s AND thr_subject = %s AND thr_num_posts = 1 ',
4571  array('integer', 'text'), array($topicData['top_pk'], $this->create_topic_form_gui->getInput('subject')));
4572 
4573  // copy temporary media objects (frm~)
4574  include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
4575  $mediaObjects = ilRTE::_getMediaObjects($this->create_topic_form_gui->getInput('message'), 0);
4576  foreach($mediaObjects as $mob)
4577  {
4578  if(ilObjMediaObject::_exists($mob))
4579  {
4580  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
4581  ilObjMediaObject::_saveUsage($mob, 'frm:html', $newPost);
4582  }
4583  }
4584 
4586  {
4587  if(isset($_POST['draft_id']) && $_POST['draft_id'] > 0)
4588  {
4589  $draft_obj = ilForumPostDraft::newInstanceByDraftId($_POST['draft_id']);
4590  //delete history
4591  $history_obj = new ilForumDraftsHistory();
4592  $history_obj->deleteHistoryByDraftIds(array($draft_obj->getDraftId()));
4593 
4594  if($this->objProperties->isFileUploadAllowed())
4595  {
4596  //move files of draft to posts directory
4597  $oFDForum = new ilFileDataForum($this->object->getId(), $newPost);
4598  $oFDForumDrafts = new ilFileDataForumDrafts($this->object->getId(), $draft_obj->getDraftId());
4599 
4600  $oFDForumDrafts->moveFilesOfDraft($oFDForum->getForumPath(), $newPost);
4601  }
4602  $draft_obj->deleteDraft();
4603  }
4604  }
4605  $GLOBALS['ilAppEventHandler']->raise(
4606  'Modules/Forum',
4607  'createdPost',
4608  array(
4609  'ref_id' => $this->object->getRefId(),
4610  'post' => new ilForumPost($newPost),
4611  'notify_moderators' => !$status
4612  )
4613  );
4614 
4615  if(!$a_prevent_redirect)
4616  {
4617  ilUtil::sendSuccess($this->lng->txt('forums_thread_new_entry'), true);
4618  $this->ctrl->redirect($this);
4619  }
4620  else
4621  {
4622  return $newPost;
4623  }
4624  }
4625  else
4626  {
4627  $this->create_topic_form_gui->setValuesByPost();
4628 
4629  if(!$this->objProperties->isAnonymized())
4630  {
4631  $this->create_topic_form_gui->getItemByPostVar('alias')->setValue($ilUser->getLogin());
4632  }
4633 
4634  return $this->tpl->setContent($this->create_topic_form_gui->getHTML());
4635  }
4636  }
4637 
4638  public function enableForumNotificationObject()
4639  {
4643  global $ilUser;
4644 
4645  $frm = $this->object->Forum;
4646  $frm->setForumId($this->object->getId());
4647  $frm->enableForumNotification($ilUser->getId());
4648 
4649  if(!$this->objCurrentTopic->getId())
4650  {
4651  ilUtil::sendInfo($this->lng->txt('forums_forum_notification_enabled'));
4652  $this->showThreadsObject();
4653  }
4654  else
4655  {
4656  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4657  ilUtil::sendInfo($this->lng->txt('forums_forum_notification_enabled'), true);
4658  $this->ctrl->redirect($this, 'viewThread');
4659  }
4660  }
4661 
4662  public function disableForumNotificationObject()
4663  {
4667  global $ilUser;
4668 
4669  $frm = $this->object->Forum;
4670  $frm->setForumId($this->object->getId());
4671  $frm->disableForumNotification($ilUser->getId());
4672 
4673  if(!$this->objCurrentTopic->getId())
4674  {
4675  $this->showThreadsObject();
4676  ilUtil::sendInfo($this->lng->txt('forums_forum_notification_disabled'));
4677  }
4678  else
4679  {
4680  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4681  ilUtil::sendInfo($this->lng->txt('forums_forum_notification_disabled'), true);
4682  $this->ctrl->redirect($this, 'viewThread');
4683  }
4684  }
4685 
4686  public function checkEnableColumnEdit()
4687  {
4688  return false;
4689  }
4690 
4691  public function setColumnSettings(ilColumnGUI $column_gui)
4692  {
4697  global $lng, $ilAccess;
4698 
4699  $column_gui->setBlockProperty('news', 'title', $lng->txt('frm_latest_postings'));
4700  $column_gui->setBlockProperty('news', 'prevent_aggregation', true);
4701  $column_gui->setRepositoryMode(true);
4702 
4703  if($ilAccess->checkAccess('write', '', $this->object->getRefId()))
4704  {
4705  $news_set = new ilSetting('news');
4706  $enable_internal_rss = $news_set->get('enable_rss_for_internal');
4707  if($enable_internal_rss)
4708  {
4709  $column_gui->setBlockProperty('news', 'settings', true);
4710  $column_gui->setBlockProperty('news', 'public_notifications_option', true);
4711  }
4712  }
4713  }
4714 
4715 
4716  public function cloneWizardPageObject()
4717  {
4718  global $ilObjDataCache;
4719 
4720  if (!$_POST['clone_source'])
4721  {
4722  ilUtil::sendInfo($this->lng->txt('select_one'));
4723  if (isset($_SESSION['wizard_search_title']))
4724  {
4725  $this->searchCloneSourceObject();
4726  }
4727  else
4728  {
4729  $this->createObject();
4730  }
4731  return false;
4732  }
4733  $source_id = $_POST['clone_source'];
4734 
4735  $new_type = $_REQUEST['new_type'];
4736  $this->ctrl->setParameter($this, 'clone_source', (int) $_POST['clone_source']);
4737  $this->ctrl->setParameter($this, 'new_type', $new_type);
4738 
4739  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.frm_wizard_page.html', 'Modules/Forum');
4740  $this->tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this));
4741  $this->tpl->setVariable('TYPE_IMG', ilUtil::getImagePath('icon_'.$new_type.'.svg'));
4742  $this->tpl->setVariable('ALT_IMG', $this->lng->txt('obj_'.$new_type));
4743  $this->tpl->setVariable('TXT_DUPLICATE', $this->lng->txt('frm_wizard_page'));
4744  $this->tpl->setVariable('INFO_THREADS', $this->lng->txt('fmr_copy_threads_info'));
4745  $this->tpl->setVariable('THREADS', $this->lng->txt('forums_threads'));
4746 
4747  $forum_id = $ilObjDataCache->lookupObjId((int) $_POST['clone_source']);
4748  include_once('Modules/Forum/classes/class.ilForum.php');
4749  $threads = ilForum::_getThreads($forum_id, ilForum::SORT_TITLE);
4750  foreach ($threads as $thread_id => $title)
4751  {
4752  $this->tpl->setCurrentBlock('thread_row');
4753  $this->tpl->setVariable('CHECK_THREAD', ilUtil::formCheckbox(0, 'cp_options['.$source_id.'][threads][]', $thread_id));
4754  $this->tpl->setVariable('NAME_THREAD', $title);
4755  $this->tpl->parseCurrentBlock();
4756  }
4757  $this->tpl->setVariable('SELECT_ALL', $this->lng->txt('select_all'));
4758  $this->tpl->setVariable('JS_FIELD', 'cp_options['.$source_id.'][threads]');
4759  $this->tpl->setVariable('BTN_COPY', $this->lng->txt('obj_'.$new_type.'_duplicate'));
4760  if (isset($_SESSION['wizard_search_title']))
4761  {
4762  $this->tpl->setVariable('BACK_CMD', 'searchCloneSource');
4763  }
4764  else
4765  {
4766  $this->tpl->setVariable('BACK_CMD', 'create');
4767  }
4768  $this->tpl->setVariable('BTN_BACK', $this->lng->txt('btn_back'));
4769  }
4770 
4771  public function addLocatorItems()
4772  {
4775  global $ilLocator;
4776 
4777  if($this->object instanceof ilObject)
4778  {
4779  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ''), '', $this->object->getRefId());
4780  }
4781  }
4782 
4783  public function handleFormInput($a_text, $a_stripslashes = true)
4784  {
4785  $a_text = str_replace("<", "&lt;", $a_text);
4786  $a_text = str_replace(">", "&gt;", $a_text);
4787  if($a_stripslashes)
4788  $a_text = ilUtil::stripSlashes($a_text);
4789 
4790  return $a_text;
4791  }
4792 
4793  public function prepareFormOutput($a_text)
4794  {
4795  $a_text = str_replace("&lt;", "<", $a_text);
4796  $a_text = str_replace("&gt;", ">", $a_text);
4797  $a_text = ilUtil::prepareFormOutput($a_text);
4798  return $a_text;
4799  }
4800 
4806  public function infoScreenObject()
4807  {
4808  $this->ctrl->setCmd('showSummary');
4809  $this->ctrl->setCmdClass('ilinfoscreengui');
4810  $this->infoScreen();
4811  }
4812 
4813  public function infoScreen()
4814  {
4818  global $ilAccess;
4819 
4820  if(!$ilAccess->checkAccess('visible', '', $this->object->getRefId()))
4821  {
4822  $this->ilias->raiseError($this->lng->txt('msg_no_perm_read'), $this->ilias->error_obj->MESSAGE);
4823  }
4824 
4825  include_once 'Services/InfoScreen/classes/class.ilInfoScreenGUI.php';
4826  $info = new ilInfoScreenGUI($this);
4827 
4828  $info->enablePrivateNotes();
4829 
4830  // standard meta data
4831  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
4832 
4833  // forward the command
4834  $this->ctrl->forwardCommand($info);
4835  }
4836 
4837  public function updateNotificationSettingsObject()
4838  {
4843  global $ilAccess, $ilErr;
4844  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
4845  {
4846  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
4847  }
4848 
4849  // instantiate the property form
4851 
4852  // check input
4853  if($this->notificationSettingsForm->checkInput())
4854  {
4855  if(isset($_POST['notification_type']) && $_POST['notification_type']== 'all_users')
4856  {
4857  // set values and call update
4858  $this->objProperties->setAdminForceNoti(1);
4859  $this->objProperties->setUserToggleNoti((int) $this->notificationSettingsForm->getInput('usr_toggle'));
4860  $this->objProperties->setNotificationType('all_users');
4861  $this->updateUserNotifications(true);
4862  }
4863  else if($_POST['notification_type']== 'per_user')
4864  {
4865  $this->objProperties->setNotificationType('per_user');
4866  $this->objProperties->setAdminForceNoti(1);
4867  $this->objProperties->setUserToggleNoti(0);
4868  $this->updateUserNotifications();
4869  }
4870  else // if($_POST['notification_type'] == 'default')
4871  {
4872  $this->objProperties->setNotificationType('default');
4873  $this->objProperties->setAdminForceNoti(0);
4874  $this->objProperties->setUserToggleNoti(0);
4875  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
4876  $frm_noti = new ilForumNotification($this->object->getRefId());
4877  $frm_noti->deleteNotificationAllUsers();
4878  }
4879 
4880  $this->objProperties->update();
4881 
4882  // print success message
4883  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
4884  }
4885  $this->notificationSettingsForm->setValuesByPost();
4886 
4887  return $this->showMembersObject();
4888  }
4889 
4890  private function updateUserNotifications($update_all_users = false)
4891  {
4892  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
4893 
4894  $oParticipants = $this->getParticipantsObject();
4895 
4896  $frm_noti = new ilForumNotification($this->object->getRefId());
4897  $moderator_ids = ilForum::_getModerators($this->object->getRefId());
4898 
4899  $admin_ids = $oParticipants->getAdmins();
4900  $member_ids = $oParticipants->getMembers();
4901  $tutor_ids = $oParticipants->getTutors();
4902 
4903  $all_forum_users = array_merge($moderator_ids, $admin_ids, $member_ids, $tutor_ids);
4904  $all_forum_users= array_unique($all_forum_users);
4905 
4906  $all_notis = $frm_noti->read();
4907 
4908  foreach($all_forum_users as $user_id)
4909  {
4910  $frm_noti->setUserId($user_id);
4911 
4912  $frm_noti->setAdminForce(1);
4913  $frm_noti->setUserToggle($this->objProperties->isUserToggleNoti());
4914 
4915  if(array_key_exists($user_id, $all_notis) && $update_all_users)
4916  {
4917  $frm_noti->update();
4918  }
4919  else if($frm_noti->existsNotification() == false)
4920  {
4921  $frm_noti->insertAdminForce();
4922  }
4923  }
4924  }
4925 
4926  private function initNotificationSettingsForm()
4927  {
4928  if(null === $this->notificationSettingsForm)
4929  {
4930  $form = new ilPropertyFormGUI();
4931  $form->setFormAction($this->ctrl->getFormAction($this, 'updateNotificationSettings'));
4932  $form->setTitle($this->lng->txt('forums_notification_settings'));
4933 
4934  $radio_grp = new ilRadioGroupInputGUI('','notification_type');
4935  $radio_grp->setValue('default');
4936 
4937  $opt_default = new ilRadioOption($this->lng->txt("user_decides_notification"), 'default');
4938  $opt_0 = new ilRadioOption($this->lng->txt("settings_for_all_members"), 'all_users');
4939  $opt_1 = new ilRadioOption($this->lng->txt("settings_per_users"), 'per_user');
4940 
4941  $radio_grp->addOption($opt_default, 'default');
4942  $radio_grp->addOption($opt_0, 'all_users');
4943  $radio_grp->addOption($opt_1, 'per_user');
4944 
4945  $chb_2 = new ilCheckboxInputGUI($this->lng->txt('user_toggle_noti'), 'usr_toggle');
4946  $chb_2->setValue(1);
4947 
4948  $opt_0->addSubItem($chb_2);
4949  $form->addItem($radio_grp);
4950 
4951  $form->addCommandButton('updateNotificationSettings', $this->lng->txt('save'));
4952 
4953  $this->notificationSettingsForm = $form;
4954 
4955  return false;
4956  }
4957 
4958  return true;
4959  }
4960 
4961  public function getIcon($user_toggle_noti)
4962  {
4963  $icon = $user_toggle_noti
4964  ? "<img src=\"".ilUtil::getImagePath("icon_ok.svg")."\" alt=\"".$this->lng->txt("enabled")."\" title=\"".$this->lng->txt("enabled")."\" border=\"0\" vspace=\"0\"/>"
4965  : "<img src=\"".ilUtil::getImagePath("icon_not_ok.svg")."\" alt=\"".$this->lng->txt("disabled")."\" title=\"".$this->lng->txt("disabled")."\" border=\"0\" vspace=\"0\"/>";
4966  return $icon;
4967  }
4968 
4969  public function showMembersObject()
4970  {
4978  global $tree, $tpl, $ilTabs, $ilAccess, $ilErr;
4979 
4980  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
4981  {
4982  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
4983  }
4984 
4985  $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_members_list.html', 'Modules/Forum');
4986 
4987  $ilTabs->setTabActive('settings');
4988  $this->settingsTabs();
4989 
4990  // instantiate the property form
4991  if(!$this->initNotificationSettingsForm())
4992  {
4993  // if the form was just created set the values fetched from database
4994  $this->notificationSettingsForm->setValuesByArray(array(
4995  'notification_type' => $this->objProperties->getNotificationType(),
4996  'adm_force' => (bool) $this->objProperties->isAdminForceNoti(),
4997  'usr_toggle' => (bool) $this->objProperties->isUserToggleNoti()
4998  ));
4999  }
5000 
5001  // set form html into template
5002  $tpl->setVariable('NOTIFICATIONS_SETTINGS_FORM', $this->notificationSettingsForm->getHTML());
5003 
5004  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
5005  include_once 'Modules/Forum/classes/class.ilObjForum.php';
5006 
5007  $frm_noti = new ilForumNotification($this->object->getRefId());
5008  $oParticipants = $this->getParticipantsObject();
5009 
5010  $moderator_ids = ilForum::_getModerators($this->object->getRefId());
5011 
5012  $admin_ids = $oParticipants->getAdmins();
5013  $member_ids = $oParticipants->getMembers();
5014  $tutor_ids = $oParticipants->getTutors();
5015 
5016  if($this->objProperties->getNotificationType() == 'default')
5017  {
5018  // update forum_notification table
5019  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
5020  $forum_noti = new ilForumNotification($this->object->getRefId());
5021  $forum_noti->setAdminForce($this->objProperties->isAdminForceNoti());
5022  $forum_noti->setUserToggle($this->objProperties->isUserToggleNoti());
5023  $forum_noti->setForumId($this->objProperties->getObjId());
5024  }
5025  else if($this->objProperties->getNotificationType() == 'per_user')
5026  {
5027  $moderators = $this->getUserNotificationTableData($moderator_ids, $frm_noti);
5028  $admins = $this->getUserNotificationTableData($admin_ids, $frm_noti);
5029  $members = $this->getUserNotificationTableData($member_ids, $frm_noti);
5030  $tutors = $this->getUserNotificationTableData($tutor_ids, $frm_noti);
5031 
5032  $this->__showMembersTable($moderators, $admins, $members, $tutors);
5033  }
5034  }
5035 
5036  private function getUserNotificationTableData($user_ids, ilForumNotification $frm_noti)
5037  {
5038  $counter = 0;
5039  $users = array();
5040  foreach($user_ids as $user_id)
5041  {
5042  $frm_noti->setUserId($user_id);
5043  $user_toggle_noti = $frm_noti->isUserToggleNotification();
5044  $icon_ok = $this->getIcon(!$user_toggle_noti);
5045 
5046  $users[$counter]['user_id'] = ilUtil::formCheckbox(0, 'user_id[]', $user_id);
5047  $users[$counter]['login'] = ilObjUser::_lookupLogin($user_id);
5048  $name = ilObjUser::_lookupName($user_id);
5049  $users[$counter]['firstname'] = $name['firstname'];
5050  $users[$counter]['lastname'] = $name['lastname'];
5051  $users[$counter]['user_toggle_noti'] = $icon_ok;
5052  $counter++;
5053  }
5054  return $users;
5055  }
5056 
5057  private function __showMembersTable($moderators, $admins, $members, $tutors)
5058  {
5064  global $lng, $tpl, $ilCtrl;
5065 
5066  if($moderators)
5067  {
5068  $tbl_mod = new ilTable2GUI($this);
5069  $tbl_mod->setId('tbl_id_mod');
5070  $tbl_mod->setFormAction($ilCtrl->getFormAction($this, 'showMembers'));
5071  $tbl_mod->setTitle($lng->txt('moderators'));
5072 
5073  $tbl_mod->addColumn('', '', '1%', true);
5074  $tbl_mod->addColumn($lng->txt('login'), '', '10%');
5075  $tbl_mod->addColumn($lng->txt('firstname'), '', '10%');
5076  $tbl_mod->addColumn($lng->txt('lastname'), '', '10%');
5077  $tbl_mod->addColumn($lng->txt('allow_user_toggle_noti'), '', '10%');
5078  $tbl_mod->setSelectAllCheckbox('user_id');
5079 
5080  $tbl_mod->setRowTemplate('tpl.forums_members_row.html', 'Modules/Forum');
5081  $tbl_mod->setData($moderators);
5082 
5083  $tbl_mod->addMultiCommand('enableHideUserToggleNoti',$lng->txt('enable_hide_user_toggle'));
5084  $tbl_mod->addMultiCommand('disableHideUserToggleNoti',$lng->txt('disable_hide_user_toggle'));
5085 
5086  $tpl->setCurrentBlock('moderators_table');
5087  $tpl->setVariable('MODERATORS',$tbl_mod->getHTML());
5088  }
5089 
5090  if($admins)
5091  {
5092  $tbl_adm = new ilTable2GUI($this);
5093  $tbl_adm->setId('tbl_id_adm');
5094  $tbl_adm->setFormAction($ilCtrl->getFormAction($this, 'showMembers'));
5095  $tbl_adm->setTitle($lng->txt('administrator'));
5096 
5097  $tbl_adm->addColumn('', '', '1%', true);
5098  $tbl_adm->addColumn($lng->txt('login'), '', '10%');
5099  $tbl_adm->addColumn($lng->txt('firstname'), '', '10%');
5100  $tbl_adm->addColumn($lng->txt('lastname'), '', '10%');
5101  $tbl_adm->addColumn($lng->txt('allow_user_toggle_noti'), '', '10%');
5102  $tbl_adm->setSelectAllCheckbox('user_id');
5103  $tbl_adm->setRowTemplate('tpl.forums_members_row.html', 'Modules/Forum');
5104 
5105  $tbl_adm->setData($admins);
5106  $tbl_adm->addMultiCommand('enableHideUserToggleNoti',$lng->txt('enable_hide_user_toggle'));
5107  $tbl_adm->addMultiCommand('disableHideUserToggleNoti',$lng->txt('disable_hide_user_toggle'));
5108 
5109  $tpl->setCurrentBlock('admins_table');
5110  $tpl->setVariable('ADMINS',$tbl_adm->getHTML());
5111  }
5112 
5113  if($members)
5114  {
5115  $tbl_mem = new ilTable2GUI($this);
5116  $tbl_mem->setId('tbl_id_mem');
5117  $tbl_mem->setFormAction($ilCtrl->getFormAction($this, 'showMembers'));
5118  $tbl_mem->setTitle($lng->txt('members'));
5119 
5120  $tbl_mem->addColumn('', '', '1%', true);
5121  $tbl_mem->addColumn($lng->txt('login'), '', '10%');
5122  $tbl_mem->addColumn($lng->txt('firstname'), '', '10%');
5123  $tbl_mem->addColumn($lng->txt('lastname'), '', '10%');
5124  $tbl_mem->addColumn($lng->txt('allow_user_toggle_noti'), '', '10%');
5125  $tbl_mem->setSelectAllCheckbox('user_id');
5126  $tbl_mem->setRowTemplate('tpl.forums_members_row.html', 'Modules/Forum');
5127  $tbl_mem->setData($members);
5128 
5129  $tbl_mem->addMultiCommand('enableHideUserToggleNoti',$lng->txt('enable_hide_user_toggle'));
5130  $tbl_mem->addMultiCommand('disableHideUserToggleNoti',$lng->txt('disable_hide_user_toggle'));
5131 
5132  $tpl->setCurrentBlock('members_table');
5133  $tpl->setVariable('MEMBERS',$tbl_mem->getHTML());
5134  }
5135 
5136  if($tutors)
5137  {
5138  $tbl_tut = new ilTable2GUI($this);
5139  $tbl_tut->setId('tbl_id_tut');
5140  $tbl_tut->setFormAction($ilCtrl->getFormAction($this, 'showMembers'));
5141  $tbl_tut->setTitle($lng->txt('tutors'));
5142 
5143  $tbl_tut->addColumn('', '', '1%', true);
5144  $tbl_tut->addColumn($lng->txt('login'), '', '10%');
5145  $tbl_tut->addColumn($lng->txt('firstname'), '', '10%');
5146  $tbl_tut->addColumn($lng->txt('lastname'), '', '10%');
5147  $tbl_tut->addColumn($lng->txt('allow_user_toggle_noti'), '', '10%');
5148  $tbl_tut->setSelectAllCheckbox('user_id');
5149  $tbl_tut->setRowTemplate('tpl.forums_members_row.html', 'Modules/Forum');
5150  $tbl_tut->setData($tutors);
5151 
5152  $tbl_tut->addMultiCommand('enableHideUserToggleNoti',$lng->txt('enable_hide_user_toggle'));
5153  $tbl_tut->addMultiCommand('disableHideUserToggleNoti',$lng->txt('disable_hide_user_toggle'));
5154 
5155  $tpl->setCurrentBlock('tutors_table');
5156  $tpl->setVariable('TUTORS',$tbl_tut->getHTML());
5157  }
5158  }
5159 
5160  public function enableAdminForceNotiObject()
5161  {
5166  global $ilAccess, $ilErr;
5167  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
5168  {
5169  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
5170  }
5171 
5172  if(!isset($_POST['user_id']) || !is_array($_POST['user_id']))
5173  {
5174  ilUtil::sendInfo($this->lng->txt('time_limit_no_users_selected'), true);
5175  }
5176  else
5177  {
5178  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
5179  $frm_noti = new ilForumNotification($this->object->getRefId());
5180 
5181  foreach($_POST['user_id'] as $user_id)
5182  {
5183  $frm_noti->setUserId((int) $user_id);
5184  $is_enabled = $frm_noti->isAdminForceNotification();
5185 
5186  $frm_noti->setUserToggle(0);
5187  if(!$is_enabled)
5188  {
5189  $frm_noti->setAdminForce(1);
5190  $frm_noti->insertAdminForce();
5191  }
5192  }
5193 
5194  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
5195  }
5196 
5197  $this->showMembersObject();
5198  }
5199 
5200  public function disableAdminForceNotiObject()
5201  {
5206  global $ilAccess, $ilErr;
5207  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
5208  {
5209  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
5210  }
5211 
5212  if(!isset($_POST['user_id']) || !is_array($_POST['user_id']))
5213  {
5214  ilUtil::sendInfo($this->lng->txt('time_limit_no_users_selected'));
5215  }
5216  else
5217  {
5218  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
5219  $frm_noti = new ilForumNotification($this->object->getRefId());
5220 
5221  foreach($_POST['user_id'] as $user_id)
5222  {
5223  $frm_noti->setUserId((int) $user_id);
5224  $is_enabled = $frm_noti->isAdminForceNotification();
5225 
5226  if($is_enabled)
5227  {
5228  $frm_noti->deleteAdminForce();
5229  }
5230  }
5231 
5232  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
5233  }
5234 
5235  $this->showMembersObject();
5236  }
5237 
5238  public function enableHideUserToggleNotiObject()
5239  {
5244  global $ilAccess, $ilErr;
5245  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
5246  {
5247  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
5248  }
5249  if(!isset($_POST['user_id']) || !is_array($_POST['user_id']))
5250  {
5251  ilUtil::sendInfo($this->lng->txt('time_limit_no_users_selected'));
5252  }
5253  else
5254  {
5255  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
5256  $frm_noti = new ilForumNotification($this->object->getRefId());
5257 
5258  foreach($_POST['user_id'] as $user_id)
5259  {
5260  $frm_noti->setUserId((int) $user_id);
5261  $is_enabled = $frm_noti->isAdminForceNotification();
5262  $frm_noti->setUserToggle(1);
5263 
5264  if(!$is_enabled)
5265  {
5266  $frm_noti->setAdminForce(1);
5267  $frm_noti->insertAdminForce();
5268  }
5269  else
5270  {
5271  $frm_noti->updateUserToggle();
5272  }
5273  }
5274 
5275  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
5276  }
5277 
5278  $this->showMembersObject();
5279  }
5280 
5281  public function disableHideUserToggleNotiObject()
5282  {
5287  global $ilAccess, $ilErr;
5288  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
5289  {
5290  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
5291  }
5292 
5293  if(!isset($_POST['user_id']) || !is_array($_POST['user_id']))
5294  {
5295  ilUtil::sendInfo($this->lng->txt('time_limit_no_users_selected'));
5296  }
5297  else
5298  {
5299  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
5300  $frm_noti = new ilForumNotification($this->object->getRefId());
5301 
5302  foreach($_POST['user_id'] as $user_id)
5303  {
5304  $frm_noti->setUserId((int) $user_id);
5305  $is_enabled = $frm_noti->isAdminForceNotification();
5306  $frm_noti->setUserToggle(0);
5307  if($is_enabled)
5308  {
5309  $frm_noti->updateUserToggle();
5310  }
5311  else
5312  {
5313  $frm_noti->setAdminForce(1);
5314  $frm_noti->insertAdminForce();
5315  }
5316  }
5317 
5318  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
5319  }
5320 
5321  $this->showMembersObject();
5322  }
5323 
5324  public function markPostUnreadObject()
5325  {
5326  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
5327  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5328  }
5329 
5330  if ((int)$this->objCurrentPost->getId() > 0) {
5331  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $this->objCurrentPost->getThread());
5332 
5333  $this->object->markPostUnread($this->user->getId(), (int)$this->objCurrentPost->getId());
5334  }
5335  $this->viewThreadObject();
5336  }
5337 
5338  public function markPostReadObject()
5339  {
5340  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
5341  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5342  }
5343 
5344  if ((int)$this->objCurrentTopic->getId() > 0 && (int)$this->objCurrentPost->getId() > 0) {
5345  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $this->objCurrentPost->getThread());
5346 
5347  $this->object->markPostRead(
5348  $this->user->getId(), (int)$this->objCurrentTopic->getId(), (int)$this->objCurrentPost->getId()
5349  );
5350  }
5351  $this->viewThreadObject();
5352  }
5353 
5354  protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
5355  {
5359  global $ilUser;
5360 
5361  $lg = parent::initHeaderAction();
5362 
5363  // Workaround: Do not show "desktop actions" in thread view
5364  if($this->objCurrentTopic->getId())
5365  {
5366  $container_obj = null;
5367  $lg->setContainerObject($container_obj);
5368  }
5369 
5370  if($lg instanceof ilObjForumListGUI)
5371  {
5372  if($ilUser->getId() != ANONYMOUS_USER_ID && $this->ilias->getSetting('forum_notification') != 0 )
5373  {
5374  $is_user_allowed_to_deactivate_notification = $this->isUserAllowedToDeactivateNotification();
5375 
5376  $frm = $this->object->Forum;
5377  $frm->setForumId($this->object->getId());
5378  $frm->setForumRefId($this->object->getRefId());
5379  $frm->setMDB2Wherecondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
5380  $frm_notificiation_enabled = $frm->isForumNotificationEnabled($ilUser->getId());
5381 
5382  if($this->objCurrentTopic->getId())
5383  {
5384  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
5385  }
5386 
5387  if($this->isParentObjectCrsOrGrp())
5388  {
5389  // special behaviour for CRS/GRP-Forum notification!!
5390  if(
5391  $frm_notificiation_enabled &&
5392  $is_user_allowed_to_deactivate_notification
5393  )
5394  {
5395  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'disableForumNotification'), "forums_disable_forum_notification");
5396  }
5397  else
5398  {
5399  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'enableForumNotification'), "forums_enable_forum_notification");
5400  }
5401  }
5402  else
5403  {
5404  if($frm_notificiation_enabled)
5405  {
5406  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'disableForumNotification'), "forums_disable_forum_notification");
5407  }
5408  else
5409  {
5410  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'enableForumNotification'), "forums_enable_forum_notification");
5411  }
5412  }
5413 
5414  $topic_notification_enabled = false;
5415  if($this->objCurrentTopic->getId())
5416  {
5417  $topic_notification_enabled = $this->objCurrentTopic->isNotificationEnabled($ilUser->getId());
5418  if($topic_notification_enabled)
5419  {
5420  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'toggleThreadNotification'), "forums_disable_notification");
5421  }
5422  else
5423  {
5424  $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'toggleThreadNotification'), "forums_enable_notification");
5425  }
5426  }
5427  $this->ctrl->setParameter($this, 'thr_pk', '');
5428 
5429  if($frm_notificiation_enabled || $topic_notification_enabled)
5430  {
5431  $lg->addHeaderIcon(
5432  "not_icon",
5433  ilUtil::getImagePath("notification_on.svg"),
5434  $this->lng->txt("frm_notification_activated")
5435  );
5436  }
5437  else
5438  {
5439  $lg->addHeaderIcon(
5440  "not_icon",
5441  ilUtil::getImagePath("notification_off.svg"),
5442  $this->lng->txt("frm_notification_deactivated")
5443  );
5444  }
5445  }
5446  }
5447 
5448  return $lg;
5449  }
5450 
5452  {
5453  if($this->objProperties->getNotificationType() == 'default')
5454  {
5455  return true;
5456  }
5457 
5458  if($this->objProperties->isUserToggleNoti() == 0)
5459  {
5460  return true;
5461  }
5462 
5463  if($this->isParentObjectCrsOrGrp())
5464  {
5465  global $ilUser;
5466 
5467  include_once 'Modules/Forum/classes/class.ilForumNotification.php';
5468 
5469  $frm_noti = new ilForumNotification((int) $_GET['ref_id']);
5470  $frm_noti->setUserId($ilUser->getId());
5471 
5472  $user_toggle = (int)$frm_noti->isUserToggleNotification();
5473  if($user_toggle == 0)
5474  {
5475  return true;
5476  }
5477  }
5478 
5479  return false;
5480  }
5481 
5482  private function isParentObjectCrsOrGrp()
5483  {
5484  global $tree;
5485 
5486  // check if there a parent-node is a grp or crs
5487  $grp_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp');
5488  $crs_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs');
5489 
5490  if($grp_ref_id == 0 && $crs_ref_id == 0)
5491  {
5492  return false;
5493  }
5494  return true;
5495  }
5496 
5500  public function getParticipantsObject()
5501  {
5502  global $tree, $ilErr;
5503 
5504  $grp_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp');
5505  $crs_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs');
5506 
5507  if($this->isParentObjectCrsOrGrp() == false)
5508  {
5509  $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE);
5510  }
5511 
5515  $oParticipants = null;
5516 
5517  if($grp_ref_id > 0)
5518  {
5519  $parent_obj = ilObjectFactory::getInstanceByRefId($grp_ref_id);
5520  include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
5521  $oParticipants = ilGroupParticipants::_getInstanceByObjId($parent_obj->getId());
5522  return $oParticipants;
5523  }
5524  else if($crs_ref_id > 0)
5525  {
5526  $parent_obj = ilObjectFactory::getInstanceByRefId($crs_ref_id);
5527 
5528  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
5529  $oParticipants = ilCourseParticipants::_getInstanceByObjId($parent_obj->getId());
5530  return $oParticipants;
5531  }
5532 
5533  return $oParticipants;
5534  }
5535 
5539  public function addToDeskObject()
5540  {
5545  global $ilSetting, $lng;
5546 
5547  if((int)$ilSetting->get('disable_my_offers'))
5548  {
5549  $this->showThreadsObject();
5550  return;
5551  }
5552 
5553  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
5555  ilUtil::sendSuccess($lng->txt("added_to_desktop"));
5556  $this->showThreadsObject();
5557  }
5558 
5562  public function removeFromDeskObject()
5563  {
5564  global $ilSetting, $lng;
5565 
5566  if((int)$ilSetting->get('disable_my_offers'))
5567  {
5568  $this->showThreadsObject();
5569  return;
5570  }
5571 
5572  include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
5574  ilUtil::sendSuccess($lng->txt("removed_from_desktop"));
5575  $this->showThreadsObject();
5576  }
5577 
5578  public function saveThreadSortingObject()
5579  {
5580  $_POST['thread_sorting'] ? $thread_sorting = $_POST['thread_sorting'] :$thread_sorting = array();
5581 
5582  if (!$this->is_moderator) {
5583  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5584  }
5585 
5586  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
5587  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5588  }
5589 
5590  array_walk($thread_sorting, function($sortValue, $threadId) {
5591  $this->ensureThreadBelongsToForum((int)$this->object->getId(), new \ilForumTopic($threadId));
5592  });
5593 
5594  foreach($thread_sorting as $thr_pk=>$sorting_value)
5595  {
5596  $sorting_value = str_replace(',','.',$sorting_value);
5597  $sorting_value = (float)$sorting_value * 100;
5598  $this->object->setThreadSorting($thr_pk,$sorting_value);
5599  }
5600  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
5601  $this->showThreadsObject();
5602  return true;
5603  }
5604 
5608  public function mergeThreadsObject()
5609  {
5610  if(!$this->is_moderator)
5611  {
5612  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
5613  }
5614 
5615  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
5616  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5617  }
5618 
5619  $selected_thread_id = 0;
5620  if(isset($_GET['merge_thread_id']) && (int)$_GET['merge_thread_id'])
5621  {
5622  $selected_thread_id = (int)$_GET['merge_thread_id'];
5623  }
5624  else if(isset($_POST['thread_ids']) && count((array)$_POST['thread_ids']) == 1)
5625  {
5626  $selected_thread_id = (int)current($_POST['thread_ids']);
5627  }
5628  else
5629  {
5630  ilUtil::sendInfo($this->lng->txt('select_one'));
5631  $this->showThreadsObject();
5632  return;
5633  }
5634 
5635  if($selected_thread_id)
5636  {
5637  $frm = $this->object->Forum;
5638  $frm->setForumId($this->object->getId());
5639  $frm->setForumRefId($this->object->getRefId());
5640 
5641  $selected_thread_obj = new ilForumTopic($selected_thread_id);
5642 
5643  if(ilForum::_lookupObjIdForForumId($selected_thread_obj->getForumId()) != $frm->getForumId())
5644  {
5645  ilUtil::sendFailure($this->lng->txt('not_allowed_to_merge_into_another_forum'));
5646  $this->showThreadsObject();
5647  return;
5648  }
5649 
5650  $frm->setMDB2Wherecondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
5651 
5652  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_liste.html', 'Modules/Forum');
5653 
5654  $topicData = $frm->getOneTopic();
5655  if($topicData)
5656  {
5657  include_once 'Modules/Forum/classes/class.ilForumTopicTableGUI.php';
5658  $this->ctrl->setParameter($this, 'merge_thread_id', $selected_thread_id);
5659  $tbl = new ilForumTopicTableGUI($this, 'mergeThreads', '', (int)$_GET['ref_id'], $topicData, $this->is_moderator, $this->forum_overview_setting);
5660  $tbl->setSelectedThread($selected_thread_obj);
5661  $tbl->setMapper($frm)->fetchData();
5662  $tbl->init();
5663  $this->tpl->setVariable('THREADS_TABLE', $tbl->getHTML());
5664  }
5665  else
5666  {
5667  ilUtil::sendFailure($this->lng->txt('select_one'));
5668  $this->showThreadsObject();
5669  return;
5670  }
5671  }
5672  }
5673 
5677  public function confirmMergeThreadsObject()
5678  {
5679  if(!$this->is_moderator)
5680  {
5681  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
5682  }
5683 
5684  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
5685  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5686  }
5687 
5688  if(!isset($_GET['merge_thread_id']) || !(int)$_GET['merge_thread_id'] || !is_array($_POST['thread_ids']) || count($_POST['thread_ids']) != 1)
5689  {
5690  ilUtil::sendFailure($this->lng->txt('select_one'));
5691  $this->mergeThreadsObject();
5692  return;
5693  }
5694 
5695  $source_thread_id = (int)$_GET['merge_thread_id'];
5696  $target_thread_id = (int)current($_POST['thread_ids']);
5697 
5698  if($source_thread_id == $target_thread_id)
5699  {
5700  ilUtil::sendFailure($this->lng->txt('error_same_thread_ids'));
5701  $this->showThreadsObject();
5702  return;
5703  }
5704 
5705  if(ilForumTopic::lookupForumIdByTopicId($source_thread_id) != ilForumTopic::lookupForumIdByTopicId($target_thread_id))
5706  {
5707  ilUtil::sendFailure($this->lng->txt('not_allowed_to_merge_into_another_forum'));
5708  $this->ctrl->clearParameters($this);
5709  $this->showThreadsObject();
5710  return;
5711  }
5712 
5713  if(ilForumTopic::_lookupDate($source_thread_id) < ilForumTopic::_lookupDate($target_thread_id))
5714  {
5715  ilUtil::sendInfo($this->lng->txt('switch_threads_for_merge'));
5716  }
5717 
5718  $this->ensureThreadBelongsToForum((int)$this->object->getId(), new \ilForumTopic((int)$source_thread_id));
5719  $this->ensureThreadBelongsToForum((int)$this->object->getId(), new \ilForumTopic((int)$target_thread_id));
5720 
5721  include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
5722  $c_gui = new ilConfirmationGUI();
5723 
5724  $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performMergeThreads'));
5725  $c_gui->setHeaderText($this->lng->txt('frm_sure_merge_threads'));
5726  $c_gui->setCancel($this->lng->txt('cancel'), 'showThreads');
5727  $c_gui->setConfirm($this->lng->txt('confirm'), 'performMergeThreads');
5728 
5729  $c_gui->addItem('thread_ids[]', $source_thread_id, sprintf($this->lng->txt('frm_merge_src'), ilForumTopic::_lookupTitle($source_thread_id)));
5730  $c_gui->addItem('thread_ids[]', $target_thread_id, sprintf($this->lng->txt('frm_merge_target'), ilForumTopic::_lookupTitle($target_thread_id)));
5731 
5732  $this->tpl->setContent($c_gui->getHTML());
5733  return;
5734  }
5735 
5739  public function performMergeThreadsObject()
5740  {
5744  global $lng;
5745 
5746  if(!$this->is_moderator)
5747  {
5748  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
5749  }
5750 
5751  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
5752  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5753  }
5754 
5755  if(!isset($_POST['thread_ids']) || !is_array($_POST['thread_ids']) || count($_POST['thread_ids']) != 2)
5756  {
5757  ilUtil::sendFailure($this->lng->txt('select_one'));
5758  $this->showThreadsObject();
5759  return;
5760  }
5761 
5762  if((int)$_POST['thread_ids'][0] == (int)$_POST['thread_ids'][1])
5763  {
5764  ilUtil::sendFailure($this->lng->txt('error_same_thread_ids'));
5765  $this->showThreadsObject();
5766  return;
5767  }
5768 
5769  try
5770  {
5771  $this->ensureThreadBelongsToForum((int)$this->object->getId(), new \ilForumTopic((int)$_POST['thread_ids'][0]));
5772  $this->ensureThreadBelongsToForum((int)$this->object->getId(), new \ilForumTopic((int)$_POST['thread_ids'][1]));
5773  ilForum::mergeThreads($this->object->id, (int)$_POST['thread_ids'][0], (int)$_POST['thread_ids'][1]);
5774  ilUtil::sendSuccess($this->lng->txt('merged_threads_successfully'));
5775  }
5776  catch(ilException $e)
5777  {
5778  return ilUtil::sendFailure($lng->txt($e->getMessage()));
5779  }
5780  $this->showThreadsObject();
5781  }
5782 
5786  public function cancelMergeThreads()
5787  {
5788  $this->showThreadsObject();
5789  }
5790 
5794  protected function setSideBlocks()
5795  {
5796  $rgt_content = '';
5797  if(!$GLOBALS['ilCtrl']->isAsynch())
5798  {
5799  require_once 'Services/Search/classes/class.ilRepositoryObjectSearchGUI.php';
5800  $rgt_content = ilRepositoryObjectSearchGUI::getSearchBlockHTML($this->lng->txt('frm_search'));
5801  }
5802  $this->tpl->setRightContent($rgt_content . $this->getRightColumnHTML());
5803  }
5804 
5808  public function deliverDraftZipFileObject()
5809  {
5811  global $ilUser;
5812 
5813  $draftObj = ilForumPostDraft::newInstanceByDraftId((int)$_GET['draft_id']);
5814  if($draftObj->getPostAuthorId() == $ilUser->getId())
5815  {
5816  $tmp_file_obj = new ilFileDataForumDrafts(0, $draftObj->getDraftId());
5817  if(!$tmp_file_obj->deliverZipFile())
5818  {
5819  $this->ctrl->redirect($this);
5820  }
5821  }
5822  }
5823 
5827  public function deliverZipFileObject()
5828  {
5829  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
5830  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5831  }
5832 
5833  $this->ensureThreadBelongsToForum((int)$this->object->getId(), $this->objCurrentPost->getThread());
5834 
5835  $fileData = new \ilFileDataForum($this->object->getId(), $this->objCurrentPost->getId());
5836  if (!$fileData->deliverZipFile()) {
5837  $this->ctrl->redirect($this);
5838  }
5839  }
5840 
5841  public function editThreadDraftObject($form = NULL)
5842  {
5848  global $ilUser, $ilAccess, $lng, $tpl;
5849 
5850  $frm = $this->object->Forum;
5851  $frm->setForumId($this->object->getId());
5852  $frm->setForumRefId($this->object->getRefId());
5853 
5854  if(!$ilAccess->checkAccess('add_thread', '', $this->object->getRefId()))
5855  {
5856  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
5857  }
5858 
5859  $thread_draft = new ilForumPostDraft();
5860  if(array_key_exists('draft_id', $_GET))
5861  {
5862  $draft_id = (int)$_GET['draft_id'];
5863  $thread_draft = $thread_draft->newInstanceByDraftId($draft_id);
5864  }
5865 
5866  if(!isset($_GET['hist_check']) || (int)$_GET['hist_check'] != 0)
5867  {
5868  $this->doHistoryCheck($thread_draft->getDraftId());
5869  }
5870 
5871  if(!$form instanceof ilPropertyFormGUI)
5872  {
5873  $this->initTopicCreateForm(true);
5874 
5875  $this->create_topic_form_gui->setValuesByArray(array(
5876  'alias' => $thread_draft->getPostUserAlias(),
5877  'subject' => $thread_draft->getPostSubject(),
5878  'message' => ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($thread_draft->getPostMessage(), 2), 1),
5879  'notify' =>$thread_draft->getNotify() ? true : false,
5880  'userfile' => '',
5881  'del_file' => array())
5882  );
5883  $tpl->setContent($this->create_topic_form_gui->getHTML() . $this->modal_history);
5884  }
5885  else
5886  {
5887  $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
5888  return $tpl->setContent($form->getHTML());
5889  }
5890  }
5891 
5892  public function restoreFromHistoryObject()
5893  {
5894  $history_id = ((int)$_GET['history_id']);
5895  $history = new ilForumDraftsHistory($history_id);
5896 
5897  $draft = $history->rollbackAutosave();
5898 
5899  if($draft->getThreadId() == 0 && $draft->getPostId() == 0)
5900  {
5901  $this->ctrl->setParameter($this, 'draft_id', $history->getDraftId());
5902  $this->ctrl->redirect($this, 'editThreadDraft');
5903  }
5904 
5905  $this->ctrl->clearParameters($this);
5906  $this->ctrl->setParameter($this, 'pos_pk', $draft->getPostId());
5907  $this->ctrl->setParameter($this, 'thr_pk', $draft->getThreadId());
5908  $this->ctrl->setParameter($this, 'draft_id',$draft->getDraftId());
5909  $this->ctrl->setParameter($this, 'action', 'editdraft');
5910 
5911  // create draft backup before redirect!
5912  ilForumPostDraft::createDraftBackup((int)$draft->getDraftId());
5913 
5914  $this->ctrl->redirect($this, 'viewThread');
5915  }
5916 
5917  public function saveThreadAsDraftObject()
5918  {
5924  global $ilUser, $ilAccess, $lng;
5925 
5926  if(!isset($_POST['del_file']) || !is_array($_POST['del_file'])) $_POST['del_file'] = array();
5927  $autosave_draft_id = 0;
5928  if(ilForumPostDraft::isAutoSavePostDraftAllowed() && isset($_POST['draft_id']) && (int)$_POST['draft_id'] > 0)
5929  {
5930  $autosave_draft_id = (int)$_POST['draft_id'];
5931  }
5932  else if(isset($_GET['draft_id']) && (int)$_GET['draft_id'] > 0)
5933  {
5934  $autosave_draft_id = (int)$_GET['draft_id'];
5935  }
5936 
5937  $frm = $this->object->Forum;
5938  $frm->setForumId($this->object->getId());
5939  $frm->setForumRefId($this->object->getRefId());
5940 
5941  if(!$ilAccess->checkAccess('add_thread', '', $this->object->getRefId()))
5942  {
5943  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
5944  }
5945 
5946  $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
5947 
5948  $topicData = $frm->getOneTopic();
5949 
5950  $this->initTopicCreateForm();
5951  if($this->create_topic_form_gui->checkInput())
5952  {
5953  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
5954  if(
5955  $ilUser->isAnonymous() &&
5956  !$ilUser->isCaptchaVerified() &&
5957  ilCaptchaUtil::isActiveForForum()
5958  )
5959  {
5960  $ilUser->setCaptchaVerified(true);
5961  }
5962 
5963  $user_alias = ilForumUtil::getPublicUserAlias($this->create_topic_form_gui->getInput('alias'), $this->objProperties->isAnonymized());
5964 
5965  if($autosave_draft_id == 0)
5966  {
5967  $draftObj = new ilForumPostDraft();
5968  }
5969  else
5970  {
5971  $draftObj = ilForumPostDraft::newInstanceByDraftId($autosave_draft_id);
5972  }
5973  $draftObj->setForumId($topicData['top_pk']);
5974  $draftObj->setThreadId(0);
5975  $draftObj->setPostId(0);
5976 
5977  $draftObj->setPostSubject($this->handleFormInput($this->create_topic_form_gui->getInput('subject'), false));
5978  $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($this->create_topic_form_gui->getInput('message'), 0));
5979  $draftObj->setPostUserAlias($user_alias);
5980  $draftObj->setNotify((int)$this->create_topic_form_gui->getInput('notify'));
5981  $draftObj->setPostAuthorId($ilUser->getId());
5982  $draftObj->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $ilUser->getId()));
5983 
5984  if($autosave_draft_id == 0)
5985  {
5986  $draft_id = $draftObj->saveDraft();
5987  }
5988  else
5989  {
5990  $draftObj->updateDraft();
5991  $draft_id = $draftObj->getDraftId();
5992  }
5993 
5995  {
5996  $GLOBALS['ilAppEventHandler']->raise(
5997  'Modules/Forum',
5998  'savedAsDraft',
5999  array('draftObj' => $draftObj,
6000  'obj_id' => $this->object->getId(),
6001  'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed())
6002  );
6003  }
6004  // copy temporary media objects (frm~)
6005  ilForumUtil::moveMediaObjects($this->create_topic_form_gui->getInput('message'), 'frm~d:html', $draft_id, 'frm~d:html', $draft_id);
6006 
6007  if($this->objProperties->isFileUploadAllowed())
6008  {
6009  $oFDForumDrafts = new ilFileDataForumDrafts($this->object->getId(), $draft_id);
6010  $file = $_FILES['userfile'];
6011  if(is_array($file) && !empty($file))
6012  {
6013  $oFDForumDrafts->storeUploadedFile($file);
6014  }
6015 
6016  $file2delete = $this->create_topic_form_gui->getInput('del_file');
6017  if(is_array($file2delete) && count($file2delete))
6018  {
6019  $oFDForumDrafts->unlinkFilesByMD5Filenames($file2delete);
6020  }
6021  }
6022  $this->ctrl->clearParameters($this);
6023  ilUtil::sendSuccess($lng->txt('save_draft_successfully'), true);
6024  $this->ctrl->redirect($this, 'showThreads');
6025  }
6026  else
6027  {
6028  $_GET['action'] = substr($_GET['action'], 6);
6029  $this->create_topic_form_gui->setValuesByPost();
6030  $this->ctrl->setParameter($this, 'draft_id', $autosave_draft_id );
6031  return $this->tpl->setContent($this->create_topic_form_gui->getHTML());
6032  }
6033  $this->ctrl->clearParameters($this);
6034  $this->ctrl->redirect($this, 'showThreads');
6035  }
6036 
6037  public function updateThreadDraftObject()
6038  {
6044  global $ilUser, $ilAccess, $lng;
6045 
6046  if(!isset($_POST['del_file']) || !is_array($_POST['del_file'])) $_POST['del_file'] = array();
6047 
6048  $frm = $this->object->Forum;
6049  $frm->setForumId($this->object->getId());
6050  $frm->setForumRefId($this->object->getRefId());
6051 
6052  if(!$ilAccess->checkAccess('add_thread', '', $this->object->getRefId())
6053  || !isset($_GET['draft_id']) || (int)$_GET['draft_id'] <= 0)
6054  {
6055  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
6056  }
6057  $this->initTopicCreateForm();
6058 
6059  if($this->create_topic_form_gui->checkInput())
6060  {
6061  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
6062  if(
6063  $ilUser->isAnonymous() &&
6064  !$ilUser->isCaptchaVerified() &&
6065  ilCaptchaUtil::isActiveForForum()
6066  )
6067  {
6068  $ilUser->setCaptchaVerified(true);
6069  }
6070  $user_alias = ilForumUtil::getPublicUserAlias($this->create_topic_form_gui->getInput('alias'), $this->objProperties->isAnonymized());
6071 
6072  $draftObj= ilForumPostDraft::newInstanceByDraftId((int)$_GET['draft_id']);
6073 
6074  $draftObj->setPostSubject($this->handleFormInput($this->create_topic_form_gui->getInput('subject'), false));
6075  $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($this->create_topic_form_gui->getInput('message'), 0));
6076  $draftObj->setPostUserAlias($user_alias);
6077  $draftObj->setNotify((int)$this->create_topic_form_gui->getInput('notify'));
6078  $draftObj->setPostAuthorId($ilUser->getId());
6079  $draftObj->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $ilUser->getId()));
6080 
6081  $draftObj->updateDraft();
6083  {
6084  $GLOBALS['ilAppEventHandler']->raise(
6085  'Modules/Forum',
6086  'updatedDraft',
6087  array('draftObj' => $draftObj,
6088  'obj_id' => $this->object->getId(),
6089  'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed())
6090  );
6091  }
6092 
6093  // copy temporary media objects (frm~)
6094  ilForumUtil::moveMediaObjects($this->create_topic_form_gui->getInput('message'), 'frm~d:html', $draftObj->getDraftId(), 'frm~d:html', $draftObj->getDraftId());
6095 
6096  if($this->objProperties->isFileUploadAllowed())
6097  {
6098  $oFDForumDrafts = new ilFileDataForumDrafts($this->object->getId(), $draftObj->getDraftId());
6099  $file = $_FILES['userfile'];
6100  if(is_array($file) && !empty($file))
6101  {
6102  $oFDForumDrafts->storeUploadedFile($file);
6103  }
6104 
6105  $file2delete = $this->create_topic_form_gui->getInput('del_file');
6106  if(is_array($file2delete) && count($file2delete))
6107  {
6108  $oFDForumDrafts->unlinkFilesByMD5Filenames($file2delete);
6109  }
6110  }
6111 
6112  ilUtil::sendSuccess($lng->txt('save_draft_successfully'), true);
6113  $this->ctrl->clearParameters($this);
6114  $this->ctrl->redirect($this, 'showThreads');
6115  }
6116  else
6117  {
6118  $this->create_topic_form_gui->setValuesByPost();
6119  $this->ctrl->setParameter($this, 'hist_check', 0);
6120  $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
6121  return $this->editThreadDraftObject($this->create_topic_form_gui);
6122  }
6123  // return $this->viewThreadObject();
6124  $this->ctrl->clearParameters($this);
6125  $this->ctrl->redirect($this, 'showThreads');
6126  }
6127 
6128  public function saveAsDraftObject()
6129  {
6135  global $ilUser, $ilAccess, $lng;
6136 
6137  if(!isset($_POST['del_file']) || !is_array($_POST['del_file'])) $_POST['del_file'] = array();
6138  $autosave_draft_id = 0;
6139  if(ilForumPostDraft::isAutoSavePostDraftAllowed() && isset($_POST['draft_id']))
6140  {
6141  $autosave_draft_id = (int)$_POST['draft_id'];
6142  }
6143  $oReplyEditForm = $this->getReplyEditForm();
6144  if($oReplyEditForm->checkInput())
6145  {
6146  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
6147  if(
6148  $ilUser->isAnonymous() &&
6149  !$ilUser->isCaptchaVerified() &&
6150  ilCaptchaUtil::isActiveForForum()
6151  )
6152  {
6153  $ilUser->setCaptchaVerified(true);
6154  }
6155 
6156  // init objects
6157  $oForumObjects = $this->getForumObjects();
6161  $forumObj = $oForumObjects['forumObj'];
6165  $frm = $oForumObjects['frm'];
6166  $frm->setMDB2WhereCondition(' top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
6167  $topicData = $frm->getOneTopic();
6168 
6169  // Generating new posting
6170  if($_GET['action'] == 'ready_showreply')
6171  {
6172  if(!$ilAccess->checkAccess('add_reply', '', (int)$_GET['ref_id']))
6173  {
6174  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
6175  }
6176 
6177  $user_alias = ilForumUtil::getPublicUserAlias($oReplyEditForm->getInput('alias'), $this->objProperties->isAnonymized());
6178 
6179  if($autosave_draft_id == 0)
6180  {
6181  $draftObj = new ilForumPostDraft();
6182  }
6183  else
6184  {
6185  $draftObj = ilForumPostDraft::newInstanceByDraftId($autosave_draft_id);
6186  }
6187  $draftObj->setForumId($topicData['top_pk']);
6188  $draftObj->setThreadId($this->objCurrentTopic->getId());
6189  $draftObj->setPostId($this->objCurrentPost->getId());
6190 
6191  $draftObj->setPostSubject($this->handleFormInput($oReplyEditForm->getInput('subject'), false));
6192  $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message'), 0));
6193  $draftObj->setPostUserAlias($user_alias);
6194  $draftObj->setNotify((int)$oReplyEditForm->getInput('notify'));
6195  $draftObj->setPostNotify((int)$oReplyEditForm->getInput('notify_post'));
6196 
6197  $draftObj->setPostAuthorId($ilUser->getId());
6198  $draftObj->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $ilUser->getId()));
6199 
6200  if($autosave_draft_id == 0)
6201  {
6202  $draft_id = $draftObj->saveDraft();
6203  }
6204  else
6205  {
6206  $draftObj->updateDraft();
6207  $draft_id = $draftObj->getDraftId();
6208  }
6209 
6210 
6212  {
6213  $GLOBALS['ilAppEventHandler']->raise(
6214  'Modules/Forum',
6215  'savedAsDraft',
6216  array('draftObj' => $draftObj,
6217  'obj_id' => $this->object->getId(),
6218  'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed())
6219  );
6220  }
6221 
6222  if($this->objProperties->isFileUploadAllowed())
6223  {
6224  $file = $_FILES['userfile'];
6225  if(is_array($file) && !empty($file))
6226  {
6227  $oFDForumDrafts = new ilFileDataForumDrafts($this->object->getId(), $draftObj->getDraftId());
6228  $oFDForumDrafts->storeUploadedFile($file);
6229  }
6230  }
6231 
6232  // copy temporary media objects (frm~)
6233  ilForumUtil::moveMediaObjects($oReplyEditForm->getInput('message'),'frm~d:html', $draft_id, 'frm~d:html', $draft_id);
6234 
6235  $_SESSION['frm'][(int)$_GET['thr_pk']]['openTreeNodes'][] = (int)$this->objCurrentPost->getId();
6236 
6237  ilUtil::sendSuccess($lng->txt('save_draft_successfully'), true);
6238  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
6239  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
6240  $this->ctrl->redirect($this, 'viewThread');
6241  }
6242  }
6243  else
6244  {
6245  $oReplyEditForm->setValuesByPost();
6246  $_GET['action'] = substr($_GET['action'], 6);
6247  }
6248  return $this->viewThreadObject();
6249  }
6250 
6251  public function editDraftObject()
6252  {
6254  {
6255  $draft_id = (int)$_GET['draft_id'];
6256  if($this->checkDraftAccess($draft_id))
6257  {
6258  $this->doHistoryCheck($draft_id);
6259  }
6260  }
6261 
6262  $this->viewThreadObject();
6263  return true;
6264  }
6265 
6269  public function updateDraftObject()
6270  {
6276  global $ilUser, $ilAccess, $lng;
6277 
6278  if(!isset($_POST['del_file']) || !is_array($_POST['del_file'])) $_POST['del_file'] = array();
6279 
6280  $oReplyEditForm = $this->getReplyEditForm();
6281  if($oReplyEditForm->checkInput())
6282  {
6283  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
6284  if(
6285  $ilUser->isAnonymous() &&
6286  !$ilUser->isCaptchaVerified() &&
6287  ilCaptchaUtil::isActiveForForum()
6288  )
6289  {
6290  $ilUser->setCaptchaVerified(true);
6291  }
6292 
6293  // init objects
6294  $oForumObjects = $this->getForumObjects();
6298  $forumObj = $oForumObjects['forumObj'];
6299 
6300  if( !$ilUser->isAnonymous() &&
6301  ($_GET['action'] == 'showdraft' || $_GET['action'] == 'editdraft'))
6302  {
6303  if(!$ilAccess->checkAccess('add_reply', '', (int)$_GET['ref_id']))
6304  {
6305  $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
6306  }
6307 
6308  $user_alias = ilForumUtil::getPublicUserAlias($oReplyEditForm->getInput('alias'), $this->objProperties->isAnonymized());
6309 
6310  // generateDraft
6311  $update_draft = new ilForumPostDraft($ilUser->getId(),$this->objCurrentPost->getId(), (int)$_GET['draft_id']);
6312 
6313  $update_draft->setPostSubject($this->handleFormInput($oReplyEditForm->getInput('subject'), false));
6314  $update_draft->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message'), 0));
6315  $update_draft->setPostUserAlias($user_alias);
6316  $update_draft->setNotify((int)$oReplyEditForm->getInput('notify'));
6317  $update_draft->setUpdateUserId($ilUser->getId());
6318  $update_draft->setPostAuthorId($ilUser->getId());
6319  $update_draft->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $ilUser->getId()));
6320 
6321  $update_draft->updateDraft();
6322 
6324  {
6325  $GLOBALS['ilAppEventHandler']->raise(
6326  'Modules/Forum',
6327  'updatedDraft',
6328  array('draftObj' => $update_draft,
6329  'obj_id' => $this->object->getId(),
6330  'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed())
6331  );
6332  }
6333 
6334  $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId());
6335 
6336  foreach($uploadedObjects as $mob)
6337  {
6338  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
6339  ilObjMediaObject::_saveUsage($mob,'frm~d:html', $update_draft->getDraftId());
6340  }
6341  ilForumUtil::saveMediaObjects($oReplyEditForm->getInput('message'), 'frm~d:html', $update_draft->getDraftId());
6342 
6343  if($this->objProperties->isFileUploadAllowed())
6344  {
6345  $oFDForumDrafts = new ilFileDataForumDrafts($forumObj->getId(), $update_draft->getDraftId());
6346  $file = $_FILES['userfile'];
6347  if(is_array($file) && !empty($file))
6348  {
6349  $oFDForumDrafts->storeUploadedFile($file);
6350  }
6351  }
6352 
6353  $file2delete = $oReplyEditForm->getInput('del_file');
6354  if(is_array($file2delete) && count($file2delete))
6355  {
6356  $oFDForumDrafts->unlinkFilesByMD5Filenames($file2delete);
6357  }
6358 
6359  $_SESSION['frm'][(int)$_GET['thr_pk']]['openTreeNodes'][] = (int)$this->objCurrentPost->getId();
6360  ilUtil::sendSuccess($lng->txt('save_draft_successfully'), true);
6361  }
6362  $this->ctrl->clearParameters($this);
6363  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
6364  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
6365  $this->ctrl->setParameter($this, 'draft_id', $update_draft->getDraftId());
6366  }
6367  else
6368  {
6369  $this->ctrl->clearParameters($this);
6370  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
6371  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
6372  $this->ctrl->setParameter($this, 'draft_id',(int)$_GET['draft_id']);
6373  $this->ctrl->setParameter($this, 'action', 'editdraft');
6374  $oReplyEditForm->setValuesByPost();
6375  return $this->viewThreadObject();
6376  }
6377  $this->ctrl->clearParameters($this);
6378  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
6379  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
6380  $this->ctrl->redirect($this, 'viewThread');
6381  }
6382 
6388  protected function deleteMobsOfDraft($draft_id, $message)
6389  {
6390  // remove usage of deleted media objects
6391  include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
6392  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draft_id);
6393  $curMediaObjects = ilRTE::_getMediaObjects($message, 0);
6394  foreach($oldMediaObjects as $oldMob)
6395  {
6396  $found = false;
6397  foreach($curMediaObjects as $curMob)
6398  {
6399  if($oldMob == $curMob)
6400  {
6401  $found = true;
6402  break;
6403  }
6404  }
6405  if(!$found)
6406  {
6407  if(ilObjMediaObject::_exists($oldMob))
6408  {
6409  ilObjMediaObject::_removeUsage($oldMob,'frm~d:html', $draft_id);
6410  $mob_obj = new ilObjMediaObject($oldMob);
6411  $mob_obj->delete();
6412  }
6413  }
6414  }
6415  }
6416 
6420  protected function deleteSelectedDraft(ilForumPostDraft $draft_obj = null)
6421  {
6422  global $ilUser, $ilAccess, $ilErr, $lng;
6423 
6424  if(
6425  !$ilAccess->checkAccess('add_reply', '', (int)$_GET['ref_id']) ||
6426  $ilUser->isAnonymous() ||
6427  ($draft_obj instanceof ilForumPostDraft && $ilUser->getId() != $draft_obj->getPostAuthorId()))
6428  {
6429  $ilErr->raiseError($lng->txt('permission_denied'), $ilErr->getMessage());
6430  }
6431 
6432  $post_id = $this->objCurrentPost->getId();
6433  if(!($draft_obj instanceof ilForumPostDraft))
6434  {
6435  $draft_id_to_delete = (int)$_GET['draft_id'];
6436  $draft_obj = new ilForumPostDraft($ilUser->getId(), $post_id, $draft_id_to_delete);
6437 
6438  if(!$draft_obj->getDraftId() || ($draft_obj->getDraftId() != $draft_id_to_delete))
6439  {
6440  $this->ctrl->clearParameters($this);
6441  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
6442  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
6443  $this->ctrl->redirect($this, 'viewThread');
6444  }
6445  }
6446 
6447  $this->deleteMobsOfDraft($draft_obj->getDraftId(), $draft_obj->getPostMessage());
6448 
6449  // delete attachments of draft
6450  $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draft_obj->getDraftId());
6451  $objFileDataForumDrafts->delete();
6452 
6454  {
6455  $GLOBALS['ilAppEventHandler']->raise(
6456  'Modules/Forum',
6457  'deletedDraft',
6458  array('draftObj' => $draft_obj,
6459  'obj_id' => $this->object->getId(),
6460  'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed())
6461  );
6462  }
6463  // delete draft
6464  $draft_obj->deleteDraft();
6465 
6466  ilUtil::sendSuccess($this->lng->txt('delete_draft_successfully'), true);
6467  $this->ctrl->clearParameters($this);
6468  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
6469  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
6470  $this->ctrl->redirect($this, 'viewThread');
6471  }
6472 
6473  public function autosaveDraftAsyncObject()
6474  {
6475  global $ilUser;
6476 
6477  if($ilUser->isAnonymous() || $_GET['action'] == 'ready_showreply')
6478  {
6479  exit();
6480  }
6481 
6482  $reponse = new stdClass();
6483  $reponse->draft_id = 0;
6484 
6486  {
6487  $replyform = $this->getReplyEditForm();
6488  $current_post_id =$this->objCurrentPost->getId();
6489 
6490  $replyform->checkInput();
6491 
6492  $form_autosave_values['subject'] = $replyform->getInput('subject');
6493  $form_autosave_values['message'] = $replyform->getInput('message');
6494  $form_autosave_values['notify'] = $replyform->getInput('notify');
6495  $form_autosave_values['alias'] = $replyform->getInput('alias');
6496 
6497  if(isset($_GET['draft_id']) && (int)$_GET['draft_id'] > 0)
6498  {
6499  $draft_id = (int)$_GET['draft_id'];
6500  }
6501  else
6502  {
6503  $draft_id = $replyform->getInput('draft_id');
6504  }
6505  $user_alias = ilForumUtil::getPublicUserAlias($form_autosave_values['alias'], $this->objProperties->isAnonymized());
6506 
6507  if((int)$draft_id > 0)
6508  {
6509  if($_GET['action'] == 'showreply')
6510  {
6511  $draftObj = ilForumPostDraft::newInstanceByDraftId((int)$draft_id);
6512  $draftObj->setPostSubject($this->handleFormInput($form_autosave_values['subject'], false));
6513  $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form_autosave_values['message'], 0));
6514 
6515  $draftObj->setPostUserAlias($user_alias);
6516  $draftObj->setNotify((int)$form_autosave_values['notify']);
6517  $draftObj->setUpdateUserId($ilUser->getId());
6518  $draftObj->setPostAuthorId($ilUser->getId());
6519  $draftObj->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $ilUser->getId()));
6520 
6521  $draftObj->updateDraft();
6522 
6523  $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId());
6524  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draftObj->getDraftId());
6525  $curMediaObjects = ilRTE::_getMediaObjects($form_autosave_values['message'], 0);
6526 
6527  foreach($uploadedObjects as $mob)
6528  {
6529  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
6530  ilObjMediaObject::_saveUsage($mob, ilForumPostDraft::MEDIAOBJECT_TYPE, $draftObj->getDraftId());
6531  }
6532 
6533  foreach($oldMediaObjects as $mob)
6534  {
6535  ilObjMediaObject::_saveUsage($mob, ilForumPostDraft::MEDIAOBJECT_TYPE, $draftObj->getDraftId());
6536  }
6537 
6538  foreach($curMediaObjects as $mob)
6539  {
6540  ilObjMediaObject::_saveUsage($mob, ilForumPostDraft::MEDIAOBJECT_TYPE, $draftObj->getDraftId());
6541  }
6542  }
6543  else
6544  {
6545  $draftObj = new ilForumDraftsHistory();
6546  $draftObj->setDraftId((int)$draft_id);
6547  $draftObj->setPostSubject($this->handleFormInput($form_autosave_values['subject'], false));
6548  $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form_autosave_values['message'], 0));
6549  $draftObj->addDraftToHistory();
6550 
6551  $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId());
6552  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draftObj->getDraftId());
6553  $curMediaObjects = ilRTE::_getMediaObjects($form_autosave_values['message'], 0);
6554 
6555  foreach($uploadedObjects as $mob)
6556  {
6557  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
6558  ilObjMediaObject::_saveUsage($mob, ilForumDraftsHistory::MEDIAOBJECT_TYPE, $draftObj->getHistoryId());
6559  }
6560 
6561  foreach($oldMediaObjects as $mob)
6562  {
6563  ilObjMediaObject::_saveUsage($mob, ilForumDraftsHistory::MEDIAOBJECT_TYPE, $draftObj->getHistoryId());
6564  }
6565 
6566  foreach($curMediaObjects as $mob)
6567  {
6568  ilObjMediaObject::_saveUsage($mob, ilForumDraftsHistory::MEDIAOBJECT_TYPE, $draftObj->getHistoryId());
6569  }
6570  }
6571  }
6572  else
6573  {
6574  $draftObj = new ilForumPostDraft();
6575  $draftObj->setForumId(ilObjForum::lookupForumIdByRefId($this->ref_id));
6576  $draftObj->setThreadId($this->objCurrentTopic->getId());
6577  $draftObj->setPostId($current_post_id);
6578 
6579  $draftObj->setPostSubject($this->handleFormInput($form_autosave_values['subject'], false));
6580  $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form_autosave_values['message'], 0));
6581 
6582  $draftObj->setPostUserAlias($user_alias);
6583  $draftObj->setNotify((int)$form_autosave_values['notify']);
6584  $draftObj->setPostAuthorId($ilUser->getId());
6585  $draftObj->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $ilUser->getId()));
6586  $draftObj->saveDraft();
6587 
6588  $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId());
6589  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draftObj->getDraftId());
6590  $curMediaObjects = ilRTE::_getMediaObjects($form_autosave_values['message'], 0);
6591 
6592  foreach($uploadedObjects as $mob)
6593  {
6594  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
6595  ilObjMediaObject::_saveUsage($mob, ilForumPostDraft::MEDIAOBJECT_TYPE, $draftObj->getDraftId());
6596  }
6597 
6598  foreach($oldMediaObjects as $mob)
6599  {
6600  ilObjMediaObject::_saveUsage($mob, ilForumPostDraft::MEDIAOBJECT_TYPE, $draftObj->getDraftId());
6601  }
6602 
6603  foreach($curMediaObjects as $mob)
6604  {
6605  ilObjMediaObject::_saveUsage($mob, ilForumPostDraft::MEDIAOBJECT_TYPE, $draftObj->getDraftId());
6606  }
6607  }
6608  }
6609 
6610  $reponse->draft_id = $draftObj->getDraftId();
6611  echo json_encode($reponse);
6612  exit();
6613  }
6614 
6616  {
6617  global $ilUser;
6618 
6619  if($ilUser->isAnonymous() || $_GET['action'] == 'ready_showreply')
6620  {
6621  exit();
6622  }
6623 
6624  $reponse = new stdClass();
6625  $reponse->draft_id = 0;
6626 
6628  {
6629  $this->initTopicCreateForm();
6630  $replyform = $this->create_topic_form_gui;
6631  $current_post_id = 0;
6632 
6633 
6634  $replyform->checkInput();
6635 
6636  $form_autosave_values['subject'] = $replyform->getInput('subject');
6637  $form_autosave_values['message'] = $replyform->getInput('message');
6638  $form_autosave_values['notify'] = $replyform->getInput('notify');
6639  $form_autosave_values['alias'] = $replyform->getInput('alias');
6640 
6641  if(isset($_GET['draft_id']) && (int)$_GET['draft_id'] > 0)
6642  {
6643  $draft_id = (int)$_GET['draft_id'];
6644  }
6645  else
6646  {
6647  $draft_id = $replyform->getInput('draft_id');
6648  }
6649  $user_alias = ilForumUtil::getPublicUserAlias($form_autosave_values['alias'], $this->objProperties->isAnonymized());
6650  if((int)$draft_id > 0)
6651  {
6652  if($_GET['action'] == 'showreply')
6653  {
6654  $draftObj = ilForumPostDraft::newInstanceByDraftId((int)$draft_id);
6655  $draftObj->setPostSubject($this->handleFormInput($form_autosave_values['subject'], false));
6656  $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form_autosave_values['message'], 0));
6657  $draftObj->setPostUserAlias($user_alias);
6658  $draftObj->setNotify((int)$form_autosave_values['notify']);
6659  $draftObj->setUpdateUserId($ilUser->getId());
6660  $draftObj->setPostAuthorId($ilUser->getId());
6661  $draftObj->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $ilUser->getId()));
6662 
6663  $draftObj->updateDraft();
6664 
6665  $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId());
6666  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draftObj->getDraftId());
6667  $curMediaObjects = ilRTE::_getMediaObjects($form_autosave_values['message'], 0);
6668 
6669  foreach($uploadedObjects as $mob)
6670  {
6671  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
6672  ilObjMediaObject::_saveUsage($mob, ilForumPostDraft::MEDIAOBJECT_TYPE, $draftObj->getDraftId());
6673  }
6674 
6675  foreach($oldMediaObjects as $mob)
6676  {
6677  ilObjMediaObject::_saveUsage($mob, ilForumPostDraft::MEDIAOBJECT_TYPE, $draftObj->getDraftId());
6678  }
6679 
6680  foreach($curMediaObjects as $mob)
6681  {
6682  ilObjMediaObject::_saveUsage($mob, ilForumPostDraft::MEDIAOBJECT_TYPE, $draftObj->getDraftId());
6683  }
6684 
6685  }
6686  else
6687  {
6688  $draftObj = new ilForumDraftsHistory();
6689  $draftObj->setDraftId((int)$draft_id);
6690  $draftObj->setPostSubject($this->handleFormInput($form_autosave_values['subject'], false));
6691  $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form_autosave_values['message'], 0));
6692  $draftObj->addDraftToHistory();
6693 
6694  $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId());
6695  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draftObj->getDraftId());
6696  $curMediaObjects = ilRTE::_getMediaObjects($form_autosave_values['message'], 0);
6697 
6698  foreach($uploadedObjects as $mob)
6699  {
6700  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
6701  ilObjMediaObject::_saveUsage($mob, ilForumDraftsHistory::MEDIAOBJECT_TYPE, $draftObj->getHistoryId());
6702  }
6703 
6704  foreach($oldMediaObjects as $mob)
6705  {
6706  ilObjMediaObject::_saveUsage($mob, ilForumDraftsHistory::MEDIAOBJECT_TYPE, $draftObj->getHistoryId());
6707  }
6708 
6709  foreach($curMediaObjects as $mob)
6710  {
6711  ilObjMediaObject::_saveUsage($mob, ilForumDraftsHistory::MEDIAOBJECT_TYPE, $draftObj->getHistoryId());
6712  }
6713 
6714  }
6715  }
6716  else
6717  {
6718  $draftObj = new ilForumPostDraft();
6719  $draftObj->setForumId(ilObjForum::lookupForumIdByRefId($this->ref_id));
6720  $draftObj->setThreadId($this->objCurrentTopic->getId());
6721  $draftObj->setPostId($current_post_id);
6722 
6723  $draftObj->setPostSubject($this->handleFormInput($form_autosave_values['subject'], false));
6724  $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form_autosave_values['message'], 0));
6725 
6726  $draftObj->setPostUserAlias($user_alias);
6727  $draftObj->setNotify((int)$form_autosave_values['notify']);
6728  $draftObj->setPostAuthorId($ilUser->getId());
6729  $draftObj->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $ilUser->getId()));
6730  $draftObj->saveDraft();
6731 
6732  $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $ilUser->getId());
6733  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draftObj->getDraftId());
6734  $curMediaObjects = ilRTE::_getMediaObjects($form_autosave_values['message'], 0);
6735 
6736  foreach($uploadedObjects as $mob)
6737  {
6738  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
6739  ilObjMediaObject::_saveUsage($mob, ilForumPostDraft::MEDIAOBJECT_TYPE, $draftObj->getDraftId());
6740  }
6741 
6742  foreach($oldMediaObjects as $mob)
6743  {
6744  ilObjMediaObject::_saveUsage($mob, ilForumPostDraft::MEDIAOBJECT_TYPE, $draftObj->getDraftId());
6745  }
6746 
6747  foreach($curMediaObjects as $mob)
6748  {
6749  ilObjMediaObject::_saveUsage($mob, ilForumPostDraft::MEDIAOBJECT_TYPE, $draftObj->getDraftId());
6750  }
6751 
6752  }
6753  }
6754 
6755  $reponse->draft_id = $draftObj->getDraftId();
6756  echo json_encode($reponse);
6757  exit();
6758  }
6759 
6767  private function renderSplitButton($is_post = true, ilForumPost $node, $Start = 0, ilForumPostDraft $draft = NULL)
6768  {
6774  global $tpl, $ilAccess, $ilUser;
6775 
6776  $actions = array();
6777  if($is_post)
6778  {
6779  if($this->objCurrentPost->getId() != $node->getId()
6780  || ($_GET['action'] != 'showreply' &&
6781  $_GET['action'] != 'showedit' &&
6782  $_GET['action'] != 'censor' &&
6783  $_GET['action'] != 'delete' &&
6784  !$this->displayConfirmPostActivation())
6785  )
6786  {
6787  if($this->is_moderator || $node->isActivated() || $node->isOwner($ilUser->getId()))
6788  {
6789  // button: reply
6790  if(!$this->objCurrentTopic->isClosed() && $node->isActivated() &&
6791  $ilAccess->checkAccess('add_reply', '', (int)$_GET['ref_id']) &&
6792  !$node->isCensored()
6793  )
6794  {
6795  $this->ctrl->setParameter($this, 'action', 'showreply');
6796  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
6797  $this->ctrl->setParameter($this, 'offset', $Start);
6798  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
6799  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
6800 
6801  if(!isset($draftsObjects[$node->getId()]))
6802  {
6803  $actions['reply_to_postings'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
6804  }
6805 
6806  $this->ctrl->clearParameters($this);
6807  }
6808 
6809  // button: edit article
6810  if(!$this->objCurrentTopic->isClosed() &&
6811  ($node->isOwner($ilUser->getId()) || $this->is_moderator) &&
6812  !$node->isCensored() &&
6813  $ilUser->getId() != ANONYMOUS_USER_ID
6814  )
6815  {
6816  $this->ctrl->setParameter($this, 'action', 'showedit');
6817  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
6818  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
6819  $this->ctrl->setParameter($this, 'offset', $Start);
6820  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
6821 
6822  $actions['edit'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
6823 
6824  $this->ctrl->clearParameters($this);
6825  }
6826 
6827  // button: mark read
6828  if($ilUser->getId() != ANONYMOUS_USER_ID && !$node->isPostRead())
6829  {
6830  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
6831  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
6832  $this->ctrl->setParameter($this, 'offset', $Start);
6833  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
6834  $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
6835 
6836  $actions['frm_mark_as_read'] = $this->ctrl->getLinkTarget($this, 'markPostRead', $node->getId());
6837 
6838  $this->ctrl->clearParameters($this);
6839  }
6840 
6841  // button: mark unread
6842  if($ilUser->getId() != ANONYMOUS_USER_ID &&
6843  $node->isPostRead()
6844  )
6845  {
6846  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
6847  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
6848  $this->ctrl->setParameter($this, 'offset', $Start);
6849  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
6850  $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
6851 
6852  $actions['frm_mark_as_unread'] = $this->ctrl->getLinkTarget($this, 'markPostUnread', $node->getId());
6853 
6854  $this->ctrl->clearParameters($this);
6855  }
6856 
6857  // button: print
6858  if(!$node->isCensored())
6859  {
6860  $this->ctrl->setParameterByClass('ilforumexportgui', 'print_post', $node->getId());
6861  $this->ctrl->setParameterByClass('ilforumexportgui', 'top_pk', $node->getForumId());
6862  $this->ctrl->setParameterByClass('ilforumexportgui', 'thr_pk', $node->getThreadId());
6863 
6864  $actions['print'] = $this->ctrl->getLinkTargetByClass('ilforumexportgui', 'printPost');
6865 
6866  $this->ctrl->clearParameters($this);
6867  }
6868 
6869  # buttons for every post except the "active"
6870  if(!$this->objCurrentTopic->isClosed() &&
6871  ($this->is_moderator ||
6872  ($node->isOwner($ilUser->getId()) && !$node->hasReplies())) &&
6873  $ilUser->getId() != ANONYMOUS_USER_ID
6874  )
6875  {
6876  // button: delete
6877  $this->ctrl->setParameter($this, 'action', 'delete');
6878  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
6879  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
6880  $this->ctrl->setParameter($this, 'offset', $Start);
6881  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
6882 
6883  $actions['delete'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
6884 
6885  $this->ctrl->clearParameters($this);
6886  }
6887 
6888  if(!$this->objCurrentTopic->isClosed() && $this->is_moderator)
6889  {
6890  // button: censor
6891  $this->ctrl->setParameter($this, 'action', 'censor');
6892  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
6893  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
6894  $this->ctrl->setParameter($this, 'offset', $Start);
6895  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
6896  if($node->isCensored())
6897  {
6898  $actions['frm_revoke_censorship'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
6899  }
6900  else
6901  {
6902  $actions['frm_censorship'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
6903  }
6904 
6905  $this->ctrl->clearParameters($this);
6906 
6907  // button: activation/deactivation
6908  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
6909  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
6910  $this->ctrl->setParameter($this, 'offset', $Start);
6911  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
6912 
6913  if(!$node->isActivated())
6914  {
6915  $actions['activate_post'] = $this->ctrl->getLinkTarget($this, 'askForPostActivation', $node->getId());
6916  }
6917 
6918  $this->ctrl->clearParameters($this);
6919  }
6920  }
6921  }
6922  }
6923  else
6924  {
6925  if(!isset($draft))
6926  {
6927  $draftsObjects = ilForumPostDraft::getInstancesByUserIdAndThreadId($ilUser->getId(), $this->objCurrentTopic->getId());
6928  $draft = $draftsObjects[$node->getId()];
6929  }
6930  // get actions for drafts
6931  $this->ctrl->setParameter($this, 'action', 'publishdraft');
6932  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
6933  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
6934  $this->ctrl->setParameter($this, 'offset', (int)$_GET['offset']);
6935  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
6936  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
6937  $actions['publish'] = $this->ctrl->getLinkTarget($this, 'publishSelectedDraft', $node->getId());
6938  $this->ctrl->clearParameters($this);
6939 
6940  $this->ctrl->setParameter($this, 'action', 'editdraft');
6941  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
6942  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
6943  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
6944  $this->ctrl->setParameter($this, 'offset', (int)$_GET['offset']);
6945  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
6946  $actions['edit'] = $this->ctrl->getLinkTarget($this, 'editDraft', 'draft_edit_' . $draft->getDraftId());
6947  $this->ctrl->clearParameters($this);
6948 
6949  $this->ctrl->setParameter($this, 'action', 'deletedraft');
6950  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
6951  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
6952  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
6953  $this->ctrl->setParameter($this, 'offset', (int)$_GET['offset']);
6954  $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
6955  $actions['delete'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
6956  $this->ctrl->clearParameters($this);
6957 
6958  if(isset($_GET['draft_id']) && $_GET['action'] == 'editdraft')
6959  {
6960  $actions = array();
6961  }
6962  }
6963 
6964  $tpl->setCurrentBlock('posts_row');
6965  if(count($actions) > 0)
6966  {
6967  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
6968  $action_button = ilSplitButtonGUI::getInstance();
6969 
6970  $i = 0;
6971  foreach($actions as $lng_id => $url)
6972  {
6973  if($i == 0)
6974  {
6975  $sb_item = ilLinkButton::getInstance();
6976  $sb_item->setCaption($lng_id);
6977  $sb_item->setUrl($url);
6978 
6979  $action_button->setDefaultButton($sb_item);
6980  ++$i;
6981  }
6982  else
6983  {
6984  $sb_item = ilLinkButton::getInstance();
6985  $sb_item->setCaption($lng_id);
6986  $sb_item->setUrl($url);
6987 
6988  $action_button->addMenuItem(new ilButtonToSplitButtonMenuItemAdapter($sb_item));
6989  }
6990  }
6991 
6992  if($is_post )
6993  {
6994  $tpl->setVariable('COMMANDS', $action_button->render());
6995  }
6996  else
6997  {
6998  if($_GET['action'] != 'deletedraft' && $_GET['action'] != 'editdraft' && !$this->objCurrentTopic->isClosed())
6999  {
7000  $tpl->setVariable('COMMANDS', $action_button->render());
7001  }
7002  }
7003  }
7004  }
7005 
7010  public function checkDraftAccess($draft_id)
7011  {
7012  global $ilUser, $ilAccess, $ilErr, $lng;
7013 
7014  $draft_obj = ilForumPostDraft::newInstanceByDraftId($draft_id);
7015 
7016  if(!$ilAccess->checkAccess('add_reply', '', (int)$_GET['ref_id']) ||
7017  $ilUser->isAnonymous() ||
7018  ($draft_obj instanceof ilForumPostDraft && $ilUser->getId() != $draft_obj->getPostAuthorId()))
7019  {
7020  $ilErr->raiseError($lng->txt('permission_denied'), $ilErr->getMessage());
7021  }
7022  return true;
7023  }
7024 
7028  public function doHistoryCheck($draft_id)
7029  {
7030 
7031  require_once './Services/jQuery/classes/class.iljQueryUtil.php';
7033 
7034  $modal = '';
7036  {
7037  $history_instances = ilForumDraftsHistory::getInstancesByDraftId($draft_id);
7038  if(is_array($history_instances) && sizeof($history_instances) > 0)
7039  {
7040  require_once 'Services/UIComponent/Modal/classes/class.ilModalGUI.php';
7041  $modal = ilModalGUI::getInstance();
7042  $modal->setHeading($this->lng->txt('restore_draft_from_autosave'));
7043  $modal->setId('frm_autosave_restore');
7044  $form_tpl = new ilTemplate('tpl.restore_thread_draft.html', true, true, 'Modules/Forum');
7045  include_once './Services/Accordion/classes/class.ilAccordionGUI.php';
7046 
7047  foreach($history_instances as $key => $history_instance)
7048  {
7049  $acc_autosave = new ilAccordionGUI();
7050  $acc_autosave->setId('acc_'.$history_instance->getHistoryId());
7051 
7052  $form_tpl->setCurrentBlock('list_item');
7053  $post_message = ilRTE::_replaceMediaObjectImageSrc($history_instance->getPostMessage(), 1);
7054 
7055  $history_date = ilDatePresentation::formatDate(new ilDateTime($history_instance->getDraftDate(), IL_CAL_DATETIME));
7056  $restore_btn = ilLinkButton::getInstance();
7057  $restore_btn->addCSSClass('restore_btn');
7058  $this->ctrl->setParameter($this, 'history_id', $history_instance->getHistoryId());
7059  $restore_btn->setUrl($this->ctrl->getLinkTarget($this, 'restoreFromHistory'));
7060  $restore_btn->setCaption($this->lng->txt('restore'), false);
7061 
7062  $acc_autosave->addItem($history_date.' - '. $history_instance->getPostSubject(), $post_message . $restore_btn->render());
7063 
7064  $form_tpl->setVariable('ACC_AUTO_SAVE', $acc_autosave->getHtml());
7065  $form_tpl->parseCurrentBlock();
7066  }
7067 
7068  $form_tpl->setVariable('RESTORE_DATA_EXISTS', 'found_threat_history_to_restore');
7069  $modal->setBody($form_tpl->get());
7070  $modal->initJS();
7071  $this->modal_history = $modal->getHTML();
7072  }
7073  else
7074  {
7076  }
7077  }
7078  }
7079 }
Class ilForumStatisticsTableGUI.
static _getMediaObjects($a_text, $a_direction=0)
Returns all media objects found in the passed string.
static _getRTEClassname()
static getDraftInstancesByUserId($user_id)
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 getThreadDraftData($post_author_id, $forum_id)
Class ilForumPostDraft.
static _isModerator($a_ref_id, $a_usr_id)
checks whether a user is moderator of a given forum object
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static _lookupDate($thread_id)
global $ilErr
Definition: raiseError.php:16
This class represents an option in a radio group.
ILIAS Setting Class.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
$lg
Definition: example_018.php:62
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
const SORT_TITLE
static _lookupObjIdForForumId($a_for_id)
Class Forum core functions for forum.
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.
getTabs()
get tabs abstract method.
const IL_CAL_DATETIME
setDisplayConfirmPostActivation($status=0)
Class for permanent links.
static lookupForumIdByObjId($obj_id)
$_SESSION["AccountId"]
$result
Class ilForumExplorerGUI.
static _exists($a_id, $a_reference=false, $a_type=NULL)
checks wether a lm content object with specified id exists or not
static getPublicUserAlias($user_alias, $is_anonymized=false)
static mergeThreads($obj_id, $source_id, $target_id)
storeUploadedFile($files)
Store uploaded files in filesystem.
This class represents a property form user interface.
GUI class for the workflow of copying objects.
deleteMobsOfDraft($draft_id, $message)
todo: move to ilForumUtil
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
isOwner($a_user_id=0)
Class ilObject Basic functions for all objects.
static getInstancesByUserIdAndThreadId($user_id, $thread_id)
static Linkbar($AScript, $AHits, $ALimit, $AOffset, $AParams=array(), $ALayout=array(), $prefix='')
Linkbar Diese Funktion erzeugt einen typischen Navigationsbalken mit "Previous"- und "Next"-Links und...
static lookupForumIdByRefId($ref_id)
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.
static saveMediaObjects($post_message, $target_type, $target_id, $direction=0)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$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.
Class ilForumDraftsTableGUI.
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
static moveMediaObjects($post_message, $source_type, $source_id, $target_type, $target_id, $direction=0)
createObject()
create new object form
This class handles all operations on files for the drafts of a forum object.
Class ilForumNotification.
static _removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Remove usage of mob in another container.
static addToDesktop()
Add desktop item public.
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.
user()
Definition: user.php:4
static _getAllReferences($a_id)
get all reference ids of object
Class ilForumTopicTableGUI.
Class ilForumDraftHistory.
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.
$counter
deleteSelectedDraft(ilForumPostDraft $draft_obj=null)
getCenterColumnHTML()
Get center column.
updateCustom(ilPropertyFormGUI $a_form)
Insert custom update form values into object.
Export User Interface Class.
This class represents a hidden form property in a property form.
$info
Definition: example_052.php:80
prepareOutput($a_show_subobjects=true)
prepare output
GUI class for public user profile presentation.
static getInstance($a_obj_id=0)
publishDraftObject($use_replyform=true)
hideToolbar($a_flag=null)
This class represents a property in a property form.
addOption($a_option)
Add Option.
Class ilTable2GUI.
Class ilRatingGUI.
static createDraftBackup($draft_id)
$mobs
getId()
get object id public
Class ilForumModeratorsGUI.
addSubItem($a_item)
Add Subitem.
Forum export to HTML and Print.
Column user interface class.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class handles base functions for mail handling.
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
Class ilObjForumGUI.
setRepositoryMode($a_repositorymode)
Set RepositoryMode.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
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 formatDate(ilDateTime $date)
Format a date public.
static infoPanel($a_keep=true)
Date and time handling
$ilUser
Definition: imgupload.php:18
static getInstancesByDraftId($draft_id)
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.
checkDraftAccess($draft_id)
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.
getId()
Get Id.
static _getThreads($a_obj_id, $a_sort_mode=self::SORT_DATE)
Get thread infos of object.
ensureThreadBelongsToForum($objId, \ilForumTopic $thread)
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Create styles array
The data for the language used.
setMessage($a_message)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
getModifiedReOnSubject($on_reply=false)
static getSearchBlockHTML($a_title)
Get standar search block html.
static removeFromDesktop()
Remove item from personal desktop public.
static getInstance()
Get instance.
static _getInstanceByType($a_type)
Factory method for creating purifier instances.
settings()
Definition: settings.php:2
getRightColumnHTML()
Display right column.
This class represents a non editable value in a property form.
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
Create new PHPExcel object
obj_idprivate
global $ilSetting
Definition: privfeed.php:17
setFilenames($a_filenames)
Set filenames.
static _getRichTextEditorUserState()
Gets the state of the rich text editor visibility for the current user.
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.
$ret
Definition: parser.php:6
setColumnSettings(ilColumnGUI $column_gui)
May be overwritten in subclasses.
addToDeskObject()
Add desktop item public.
getCreationMode()
get creation mode
getRefId()
get reference id public
handleFormInput($a_text, $a_stripslashes=true)
afterSave(ilObject $forumObj)
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static initjQuery($a_tpl=null)
Init jQuery.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static _getModerators($a_ref_id)
get all users assigned to local role il_frm_moderator_<frm_ref_id> (static)
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
setChangeDate($a_changedate)
static _lookupTitle($a_topic_id)
Looks up the title/subject of a topic/thread.
addAutosave(ilPropertyFormGUI $form)
Class ilObjForum.
getEditFormCustomValues(Array &$a_values)
static redirect($a_script)
http redirect to other script
Accordion user interface class.
addHeaderAction()
Add header action menu.
static _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
getThreadEditingForm($a_thread_id)
$_POST["username"]
$html
Definition: example_001.php:87
$params
Definition: example_049.php:96
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
executeCommand()
execute command
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.