19declare(strict_types=1);
42 use ilForumRequestTrait;
74 public \ILIAS\DI\RBACServices
$rbac;
92 $this->httpRequest =
$DIC->http()->request();
94 $this->uiFactory =
$DIC->ui()->factory();
95 $this->uiRenderer =
$DIC->ui()->renderer();
98 $this->irss =
$DIC->resourceStorage();
100 $this->ilObjDataCache =
$DIC[
'ilObjDataCache'];
103 $this->
rbac = $DIC->rbac();
104 $this->
factory = $DIC->ui()->factory();
105 $this->
renderer = $DIC->ui()->renderer();
109 $this->
ctrl->saveParameter($this, [
'ref_id']);
110 $this->tpl->addJavaScript(
'assets/js/Basic.js');
112 $this->
lng->loadLanguageModule(
'forum');
113 $this->
lng->loadLanguageModule(
'content');
115 $ref_id = $this->retrieveIntOrZeroFrom($this->
http->wrapper()->query(),
'ref_id');
118 $this->is_moderator = $this->
access->checkAccess(
'moderate_frm',
'',
$ref_id);
121 $this->requestAction = (string) ($this->httpRequest->getQueryParams()[
'action'] ??
'');
122 $cs =
$DIC->contentStyle();
123 $this->content_style_gui = $cs->gui();
124 if (is_object($this->
object)) {
125 $this->content_style_domain = $cs->domain()->styleForRefId($this->
object->getRefId());
127 $this->in_page_editor_style_context = $this->
http->wrapper()->query()->has(
'page_editor_style');
128 $this->
ctrl->saveParameterByClass(ilObjectContentStyleSettingsGUI::class,
'page_editor_style');
140 if (!is_array($forumValues)) {
145 $threadId = $this->objCurrentTopic->getId();
146 if ($threadId > 0 && !isset($forumValues[$threadId])) {
147 $forumValues[(
int) $threadId] = [];
156 return $this->retrieveIntOrZeroFrom($this->
http->wrapper()->query(),
'thr_pk');
161 return $this->retrieveIntOrZeroFrom(
162 $from_post ? $this->
http->wrapper()->post() : $this->http->wrapper()->query(),
170 'frm_exp_' . $this->objCurrentTopic->getId(),
173 $this->objCurrentTopic,
174 $this->objCurrentTopic->getPostRootNode($this->is_moderator)
176 $exp->toggleExplorerNodeState();
180 array $subtree_nodes,
181 array $pagedPostings,
185 if ($firstForumPost->
getId() === $this->objCurrentPost->
getId()) {
189 if ($subtree_nodes !== [] && $this->objCurrentPost->getId() > 0) {
190 $isCurrentPostingInPage = array_filter($pagedPostings, fn(
ilForumPost $posting):
bool => (
191 $posting->
getId() === $this->objCurrentPost->getId()
194 if ([] === $isCurrentPostingInPage) {
195 $pageOfCurrentPosting = 0;
197 foreach ($subtree_nodes as $node) {
198 if ($i > 0 && $i % $pageSize === 0) {
199 ++$pageOfCurrentPosting;
202 if ($node->getId() === $this->objCurrentPost->getId()) {
209 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
210 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
211 $this->
ctrl->setParameter($this,
'page', $pageOfCurrentPosting);
212 $this->
ctrl->setParameter(
217 $this->
ctrl->redirect($this,
'viewThread', (
string) $this->objCurrentPost->getId());
226 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
235 $this->tpl->addJavaScript(
'assets/js/autosave_forum.js');
236 $autosave_cmd =
'autosaveDraftAsync';
237 if ($this->objCurrentPost->getId() === 0 && $this->objCurrentPost->getThreadId() === 0) {
238 $autosave_cmd =
'autosaveThreadDraftAsync';
240 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
241 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
242 $this->
ctrl->setParameter($this,
'draft_id', $this->retrieveDraftId());
244 $this->tpl->addOnLoadCode(
245 "il.Language.setLangVar('saving', " . json_encode($this->
lng->txt(
'saving'), JSON_THROW_ON_ERROR) .
');'
248 $this->tpl->addOnLoadCode(
'il.ForumDraftsAutosave.init(' . json_encode([
250 'draftId' => $this->retrieveDraftId(),
251 'interval' => $interval * 1000,
252 'url' => $this->
ctrl->getFormAction($this, $autosave_cmd,
'',
true),
254 'form' =>
'#form_' . $form->
getId()
256 ], JSON_THROW_ON_ERROR) .
');');
263 strtolower($this->
ctrl->getCmd() ??
''),
264 array_map(
'strtolower', [
'createTopLevelPost',
'saveTopLevelPost',
'saveTopLevelDraft']),
272 'enableForumNotification',
273 'disableForumNotification',
274 'toggleThreadNotification',
275 'confirmDeleteThreadDrafts'
284 public function executeCommand(): void
286 $next_class = $this->
ctrl->getNextClass($this) ??
'';
287 $cmd = $this->
ctrl->getCmd() ??
'';
293 'showThreadNotification',
294 'performPostActivation',
295 'askForPostActivation',
296 'askForPostDeactivation',
297 'toggleThreadNotification',
302 'createTopLevelPost',
305 'autosaveDraftAsync',
306 'autosaveThreadDraftAsync',
310 'deliverDraftZipFile',
313 'deleteThreadDrafts',
315 'deletePostingDraft',
318 'confirmDeleteThreadsObject'
321 if (!in_array($cmd, $exclude_cmds,
true)) {
322 $this->prepareOutput();
325 if (!$this->creation_mode) {
326 $this->checkUsersViewMode();
327 $pos_pk = $this->retrieveIntOrZeroFrom($this->
http->wrapper()->query(),
'pos_pk');
329 $this->selected_post_storage->get($this->objCurrentTopic->getId()) > 0) {
331 $this->selected_post_storage->get($this->objCurrentTopic->getId()) ?? 0,
334 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
336 $this->selected_post_storage->set($this->objCurrentTopic->getId(), 0);
344 if (!$this->getCreationMode() && !$this->
ctrl->isAsynch() && $this->access->checkAccess(
347 $this->object->getRefId()
350 $this->
object->getRefId(),
351 ilLink::_getLink($this->object->getRefId(),
'frm'),
356 switch (strtolower($next_class)) {
357 case strtolower(ilForumPageGUI::class):
358 if (in_array(strtolower($cmd), array_map(
'strtolower', [
359 self::UI_CMD_COPAGE_DOWNLOAD_FILE,
360 self::UI_CMD_COPAGE_DISPLAY_FULLSCREEN,
361 self::UI_CMD_COPAGE_DOWNLOAD_PARAGRAPH,
364 if (!$this->checkPermissionBool(
'read')) {
365 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
367 } elseif (!$this->checkPermissionBool(
'write') || $this->
user->isAnonymous()) {
368 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
371 $this->content_style_gui->addCss($this->tpl, $this->ref_id);
372 $this->tpl->setCurrentBlock(
'SyntaxStyle');
374 $this->tpl->parseCurrentBlock();
377 $obj = $this->object;
386 $this->content_style_domain
389 $pageContent = $forwarder->forward();
390 if ($pageContent !==
'') {
391 $this->tpl->setContent($pageContent);
395 case strtolower(ilLearningProgressGUI::class):
397 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
400 $this->tabs_gui->activateTab(
'learning_progress');
402 $usrId = $this->
user->getId();
404 isset($this->request->getQueryParams()[
'user_id']) &&
405 is_numeric($this->request->getQueryParams()[
'user_id'])
407 $usrId = (
int) $this->request->getQueryParams()[
'user_id'];
412 $this->
object->getRefId(),
417 case strtolower(ilObjectContentStyleSettingsGUI::class):
418 $this->checkPermission(
'write');
420 if ($this->in_page_editor_style_context) {
421 $this->tabs_gui->setBackTarget(
422 $this->
lng->txt(
'back'),
430 $settings_gui = $this->content_style_gui
431 ->objectSettingsGUIForRefId(
435 $this->
ctrl->forwardCommand($settings_gui);
438 case strtolower(ilForumSettingsGUI::class):
440 $this->
ctrl->forwardCommand($forum_settings_gui);
443 case strtolower(ilRepositoryObjectSearchGUI::class):
444 $this->addHeaderAction();
445 $this->setSideBlocks();
446 $this->tabs_gui->activateTab(
'forums_threads');
447 $this->
ctrl->setReturn($this,
'view');
449 $this->
object->getRefId(),
453 $this->
ctrl->forwardCommand($search_gui);
456 case strtolower(ilPermissionGUI::class):
458 $this->
ctrl->forwardCommand($perm_gui);
461 case strtolower(ilForumExportGUI::class):
463 $this->
ctrl->forwardCommand($fex_gui);
464 $this->
http->close();
467 case strtolower(ilForumModeratorsGUI::class):
469 $this->
ctrl->forwardCommand($fm_gui);
472 case strtolower(ilInfoScreenGUI::class):
476 case strtolower(ilColumnGUI::class):
477 $this->showThreadsObject();
480 case strtolower(PublicProfileGUI::class):
481 $user = $this->retrieveIntOrZeroFrom($this->
http->wrapper()->query(),
'user');
483 $add = $this->getUserProfileAdditional($this->
object->getRefId(), $user);
484 $profile_gui->setAdditional($add);
485 $ret = $this->
ctrl->forwardCommand($profile_gui);
486 $this->tpl->setContent($ret);
489 case strtolower(ilObjectCopyGUI::class):
492 $this->
ctrl->forwardCommand($cp);
495 case strtolower(ilExportGUI::class):
496 $this->tabs_gui->activateTab(
'export');
498 $this->
ctrl->forwardCommand($exp);
501 case strtolower(ilRatingGUI::class):
502 if (!$this->objProperties->isIsThreadRatingEnabled() || $this->
user->isAnonymous()) {
503 $this->
error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
506 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
507 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
510 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentTopic);
513 $rating_gui->setObject(
515 $this->object->getType(),
516 $this->objCurrentTopic->getId(),
520 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
521 $this->
ctrl->forwardCommand($rating_gui);
525 $this->object->getType(),
526 $this->objCurrentTopic->getId(),
529 $this->objCurrentTopic->setAverageRating($avg[
'avg']);
530 $this->objCurrentTopic->update();
532 $this->
ctrl->redirect($this,
'showThreads');
535 case strtolower(ilCommonActionDispatcherGUI::class):
537 $this->
ctrl->forwardCommand($gui);
540 case strtolower(ilContainerNewsSettingsGUI::class):
541 $this->checkPermission(
'write');
546 $this->
lng->loadLanguageModule(
'cont');
548 $news_set_gui->setNewsBlockForced(
true);
549 $news_set_gui->setPublicNotification(
true);
550 $this->
ctrl->forwardCommand($news_set_gui);
554 if (in_array($cmd, [
'close',
'reopen',
'make_topics_non_sticky',
'makesticky',
'editThread',
'move'])) {
555 $cmd =
'performThreadsAction';
558 if ($cmd ===
null || $cmd ===
'') {
559 $cmd =
'showThreads';
568 if (!$this->in_page_editor_style_context &&
569 $cmd !==
'viewThreadObject' && $cmd !==
'showUserObject' && !in_array(
570 strtolower($next_class),
571 array_map(
'strtolower', [ilForumPageGUI::class]),
574 $this->addHeaderAction();
586 $this->forum_settings_gui->getCustomForm($a_form);
591 $this->forum_settings_gui->getCustomValues($a_values);
596 $this->forum_settings_gui->updateCustomValues($form);
601 if (!$this->is_moderator) {
602 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
605 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
606 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
609 if ($this->objCurrentTopic->getId() === 0) {
610 $this->showThreadsObject();
614 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentTopic);
616 $title = $this->getEditTitleModal($this->objCurrentTopic)->withRequest($this->
http->request())->getData();
617 if (array_key_exists(0, $title)) {
618 $new_subject = $title[0];
619 if ($new_subject !==
'') {
620 $this->objCurrentTopic->setSubject($new_subject);
621 $this->objCurrentTopic->updateThreadTitle();
622 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
625 $this->
ctrl->redirect($this,
'showThreads');
631 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
632 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
635 $this->
object->markAllThreadsRead($this->
user->getId());
636 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_all_threads_marked_read'));
637 $this->showThreadsObject();
642 $this->setSideBlocks();
643 $this->getCenterColumnHTML();
648 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
649 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
652 $cmd = $this->
ctrl->getCmd();
653 $frm = $this->
object->Forum;
654 $frm->setForumId($this->
object->getId());
655 $frm->setForumRefId($this->
object->getRefId());
656 $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
658 $frm_object = $frm->getOneTopic();
659 if ($frm_object->getTopPk() > 0) {
660 $frm->setDbTable(
'frm_data');
661 $frm->setMDB2WhereCondition(
'top_pk = %s ', [
'integer'], [$frm_object->getTopPk()]);
662 $frm->updateVisits($frm_object->getTopPk());
666 $this->object->getRefId(),
667 $this->object->getId(),
671 if ($cmd !==
'showThreads') {
672 $cmd =
'showThreads';
675 $this->tpl->setPermanentLink($this->
object->getType(), $this->object->getRefId());
677 if (!$this->hideToolbar() && $this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId())) {
678 $btn = $this->uiFactory->button()
680 $this->
lng->txt(
'forums_new_thread'),
681 $this->ctrl->getLinkTarget($this,
'createThread')
683 $this->
toolbar->addStickyItem($btn);
687 $this->addDraftButtonIfDraftsExists($cmd);
690 if ($this->confirmation_gui_html ===
'' && !$this->
user->isAnonymous()) {
692 $this->
lng->txt(
'forums_mark_read'),
693 $this->ctrl->getLinkTarget($this,
'markAllRead')
695 $this->
ctrl->clearParameters($this);
698 if (!$this->
user->isAnonymous() && $this->access->checkAccess(
'write',
'', $this->ref_id)) {
699 $this->
lng->loadLanguageModule(
'cntr');
701 $this->uiFactory->button()->standard(
702 $this->lng->txt(
'cntr_text_media_editor'),
703 $this->ctrl->getLinkTargetByClass(ilForumPageGUI::class,
'edit')
708 $this->renderThreadOverview($frm, $frm_object);
714 $threads_page = $this->forum_thread_table_session_storage->fetchData($frm, $frm_object);
716 $sticky_threads = [];
717 $regular_threads = [];
719 if (count($threads_page->getForumTopics()) > 0) {
720 foreach ($threads_page->getForumTopics() as $thread) {
721 $ref_id = $this->
object->getRefId();
722 $subject = $thread->getSubject();
723 if ($thread->isClosed()) {
724 $subject .=
' (' . $this->
lng->txt(
'forums_closed') .
')';
727 $link = $this->getLinkActionForThread(
$ref_id, $subject,
'viewThread', $thread->getId());
728 $actions = $this->getActionsForThreadOverview(
$ref_id, $thread);
733 ->withActions($actions)
734 ->withProperties($this->getThreadProperties($thread));
735 $list_item = $this->markTopThreadInOverview($thread, $list_item);
736 if ($thread->isSticky()) {
737 $sticky_threads[] = $list_item;
739 $regular_threads[] = $list_item;
744 $sticky_threads_item_group =
null;
745 if (count($sticky_threads) > 0) {
746 $sticky_threads_item_group = $this->
factory->item()->group(
747 count($regular_threads) > 0 ? $this->
lng->txt(
'top_thema') :
'',
752 $regular_threads_item_group =
null;
753 if (count($regular_threads) > 0) {
754 $regular_threads_item_group = $this->
factory->item()->group(
755 count($sticky_threads) > 0 ? $this->
lng->txt(
'thema') :
'',
760 $url = $this->
http->request()->getRequestTarget();
763 $current_page = $this->
http->wrapper()->query()->retrieve(
769 $view_controls[] = $this->getSortationViewControl(
770 $this->forum_thread_table_session_storage->getThreadPage(),
771 $this->forum_thread_table_session_storage->getThreadSortation()
773 $view_controls[] = $this->
factory
779 ->withMaxPaginationButtons(5)
780 ->withCurrentPage($current_page);
782 $item_groups = array_filter([$sticky_threads_item_group, $regular_threads_item_group]);
783 if ($item_groups === []) {
784 $vc_container = $this->
factory->panel()->listing()->standard(
785 $this->
lng->txt(
'thread_overview'),
786 [$this->factory->item()->group($this->lng->txt(
'frm_no_threads'), [])]
789 $vc_container = $this->
factory->panel()->listing()->standard(
790 $this->
lng->txt(
'thread_overview'),
792 )->withViewControls($view_controls);
795 $default_html = $this->
renderer->render($vc_container);
796 $modals = $this->
renderer->render($this->modal_collection);
798 $this->initStyleSheets();
807 $this->content_style_domain
811 $this->tpl->setContent($forwarder->forward() . $default_html . $modals);
819 $this->
ctrl->setParameter($this,
'page', $offset);
822 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
823 $base_url = $this->
ctrl->getLinkTarget($this,
'showThreads');
825 $translation_keys = [];
826 foreach (ThreadSortation::cases() as $sortation) {
827 $translation_keys[$sortation->value] = $this->
lng->txt($sortation->languageId());
829 $this->
ctrl->clearParameters($this);
831 return $this->
factory->viewControl()->sortation(
833 (
string) $effective_sortation->value
834 )->withTargetURL($base_url, ForumThreadTableSessionStorage::KEY_THREAD_SORTATION);
843 $query = $this->
http->wrapper()->query()->has(
'thr_pk');
844 $post = $this->
http->wrapper()->post()->has(
'thread_ids');
846 $thread_ids = $this->
http->wrapper()->post()->retrieve(
848 $this->
refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
851 $thread_ids = $this->
http->wrapper()->query()->retrieve(
853 $this->
refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
865 $this->
ctrl->setParameter($this,
'thr_pk', $forum_topic->
getId());
867 $is_top_thread = $forum_topic->
isSticky();
869 if ($unread_counter === 0) {
872 $unread =
' (' . $unread_counter .
' ' . $this->
lng->txt(
'unread') .
')';
883 $this->
lng->txt(
'forums_created_by') => $authorinfo->getAuthorName(),
884 $this->
lng->txt(
'forums_articles') => $forum_topic->
getNumPosts() . $unread,
885 $this->
lng->txt(
'forums_last_post') => $this->
object->Forum->convertDate($forum_topic->
getLastPost()->getCreateDate()),
889 if ($is_top_thread ===
true) {
890 $is_top_thread = [$this->
lng->txt(
'relevance') => $this->
lng->txt(
'sticky')];
891 $properties = array_merge($properties, $is_top_thread);
894 $rating_property = [];
895 if ($this->objProperties->isIsThreadRatingEnabled()) {
899 $this->object->getType(),
900 $forum_topic->
getId(),
903 $rating->setUserId($this->
user->getId());
904 $rating_property = [$this->
lng->txt(
'frm_rating') => $rating->getHTML()];
906 $this->
ctrl->setParameter($this,
'thr_pk',
null);
908 return array_merge($properties, $rating_property);
915 ?
int $thread_id =
null
917 $this->
ctrl->setParameter($this,
'ref_id',
$ref_id);
918 $this->
ctrl->setParameter($this,
'thr_pk', $thread_id);
919 $this->
ctrl->setParameter($this,
'page', 0);
920 $url = $this->
ctrl->getLinkTarget($this, $cmd);
921 $this->
ctrl->setParameter($this,
'ref_id',
null);
922 $this->
ctrl->setParameter($this,
'thr_pk',
null);
923 $this->
ctrl->setParameter($this,
'page',
null);
925 return $this->uiFactory->link()->standard($title,
$url);
930 $actions = $this->uiFactory->dropdown()->standard([]);
931 if ($this->is_moderator) {
932 $open_close = $this->getOpenCloseActionForThread($forum_topic,
$ref_id);
933 $stick_or_no_stick = $this->getStickyActionForThread($forum_topic,
$ref_id);
934 $edit_title_modal = $this->getEditTitleModal($forum_topic);
935 $this->modal_collection[] = $edit_title_modal;
936 $edit_title = $this->
factory->button()->shy($this->
lng->txt(
'frm_edit_title'),
'#')->withOnClick(
937 $edit_title_modal->getShowSignal()
940 $move = $this->getLinkActionForThread(
942 $this->
lng->txt(
'move_thread_to_forum'),
944 $forum_topic->
getId()
946 $merge = $this->getLinkActionForThread(
948 $this->
lng->txt(
'merge_posts_into_thread'),
950 $forum_topic->
getId()
952 $delete = $this->getLinkActionForThread(
954 $this->
lng->txt(
'delete_thread'),
955 'confirmDeleteThreads',
956 $forum_topic->
getId()
958 $actions = $this->uiFactory->dropdown()->standard([
973 $topic_id = $this->
refinery->kindlyTo()->string()->transform($topic->
getId());
974 $this->
ctrl->setParameter($this,
'thr_pk', (
string) $topic_id);
975 $target = $this->
ctrl->getLinkTargetByClass(
976 ilObjForumGUI::class,
979 $this->
ctrl->setParameter($this,
'thread_id',
null);
981 return $this->
factory->modal()->roundtrip(
982 $this->
lng->txt(
'frm_edit_title'),
985 $this->factory->input()->field()->text($this->lng->txt(
'frm_edit_title'))->withValue($topic->
getSubject()),
994 $this->
user->getId(),
997 if ($drafts === []) {
1010 $this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()),
1014 'tpl.forums_threads_liste.html',
1017 'components/ILIAS/Forum'
1019 $threadsTemplate->setVariable(
'THREADS_DRAFTS_TABLE', $this->uiRenderer->render($table->getComponent()));
1021 $draft_modal = $this->
factory->modal()->roundtrip(
1022 $this->
lng->txt(
'drafts'),
1023 [$this->factory->legacy()->content($threadsTemplate->get())]
1025 $this->modal_collection[] = $draft_modal;
1026 $edit_title = $this->
factory->button()->standard($this->
lng->txt(
'drafts'),
'#')->withOnClick(
1027 $draft_modal->getShowSignal()
1029 $this->
toolbar->addComponent($edit_title);
1034 return $this->getLinkActionForThread(
1036 $this->
lng->txt($forum_topic->
isSticky() ?
'make_topics_non_sticky' :
'make_topics_sticky'),
1037 $forum_topic->
isSticky() ?
'make_topics_non_sticky' :
'makesticky',
1038 $forum_topic->
getId()
1044 return $this->getLinkActionForThread(
1046 $this->
lng->txt($forum_topic->
isClosed() ?
'reopen_topics' :
'close_topics'),
1047 $forum_topic->
isClosed() ?
'reopen' :
'close',
1048 $forum_topic->
getId()
1056 if ($current_thread->isSticky()) {
1057 $df = new \ILIAS\Data\Factory();
1058 $list_item = $list_item->withColor($df->color(
'#B54F00'));
1066 $this->content_style_gui->addCss($this->tpl, $this->ref_id);
1067 $this->tpl->setCurrentBlock(
'SyntaxStyle');
1069 $this->tpl->parseCurrentBlock();
1074 $this->content_style_gui->redirectToObjectSettings();
1086 $frm = $this->
object->Forum;
1088 $draft_id = $this->retrieveDraftId();
1089 foreach ($drafts as $draft) {
1091 $filesOfDraft = $tmp_file_obj->getFilesOfPost();
1092 ksort($filesOfDraft);
1094 if ($action !==
'showdraft' && $filesOfDraft !== []) {
1095 foreach ($filesOfDraft as $file) {
1097 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1098 $this->
ctrl->setParameter($this,
'file', $file[
'md5']);
1099 $tpl->
setVariable(
'HREF_DOWNLOAD', $this->
ctrl->getLinkTarget($this,
'viewThread'));
1101 $this->
ctrl->setParameter($this,
'file',
'');
1102 $this->
ctrl->setParameter($this,
'draft_id',
'');
1103 $this->
ctrl->clearParameters($this);
1108 $tpl->
setVariable(
'TXT_ATTACHMENTS_DOWNLOAD', $this->
lng->txt(
'forums_attachments'));
1111 $this->uiRenderer->render(
1112 $this->uiFactory->symbol()->glyph()->attachment()
1115 if (count($filesOfDraft) > 1) {
1116 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1117 $download_zip_button = $this->uiFactory->button()
1119 $this->
lng->txt(
'download'),
1120 $this->ctrl->getLinkTarget($this,
'deliverDraftZipFile')
1122 $this->
ctrl->setParameter($this,
'draft_id',
'');
1123 $tpl->
setVariable(
'DOWNLOAD_ZIP', $this->uiRenderer->render($download_zip_button));
1128 $page = $this->
http->wrapper()->query()->retrieve(
1130 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
1133 $this->renderSplitButton(
1142 $rowCol =
'tblrowmarked';
1144 $depth = $referencePosting->
getDepth() - 1;
1150 $this->
ctrl->setParameter($this,
'pos_pk', $referencePosting->
getId());
1151 $this->
ctrl->setParameter($this,
'thr_pk', $referencePosting->
getThreadId());
1152 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1154 $backurl = urlencode($this->
ctrl->getLinkTarget($this,
'viewThread', (
string) $referencePosting->
getId()));
1156 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1157 $this->
ctrl->setParameter($this,
'thr_pk', $referencePosting->
getThreadId());
1158 $this->
ctrl->setParameter($this,
'user', $draft->getPostDisplayUserId());
1161 $draft->getPostAuthorId(),
1162 $draft->getPostDisplayUserId(),
1163 $draft->getPostUserAlias(),
1166 'href' => $this->ctrl->getLinkTarget($this,
'showUser')
1170 $this->
ctrl->clearParameters($this);
1172 if ($authorinfo->hasSuffix()) {
1173 $tpl->
setVariable(
'AUTHOR', $authorinfo->getSuffix());
1174 $tpl->
setVariable(
'USR_NAME', $draft->getPostUserAlias());
1176 $tpl->
setVariable(
'AUTHOR', $authorinfo->getLinkedAuthorShortName());
1177 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized()) {
1178 $tpl->
setVariable(
'USR_NAME', $authorinfo->getAuthorName(
true));
1181 $tpl->
setVariable(
'DRAFT_ANCHOR',
'draft_' . $draft->getDraftId());
1183 $tpl->
setVariable(
'USR_IMAGE', $authorinfo->getProfilePicture());
1189 $this->object->getRefId(),
1190 $draft->getPostAuthorId()
1192 if ($authorinfo->getAuthor()->getGender() ===
'f') {
1194 } elseif ($authorinfo->getAuthor()->getGender() ===
'm') {
1196 } elseif ($authorinfo->getAuthor()->getGender() ===
'n') {
1201 if ($draft->getUpdateUserId() > 0) {
1202 $draft->setPostUpdate($draft->getPostUpdate());
1204 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1205 $this->
ctrl->setParameter($this,
'thr_pk', $referencePosting->
getThreadId());
1207 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1210 $draft->getPostAuthorId(),
1212 $draft->getPostDisplayUserId(),
1213 $draft->getPostUserAlias(),
1215 [
'href' => $this->ctrl->getLinkTarget($this,
'showUser')]
1218 $this->
ctrl->clearParameters($this);
1222 $this->
lng->txt(
'edited_on') .
': ' . $frm->convertDate($draft->getPostUpdate()) .
' - ' . strtolower($this->
lng->txt(
'by'))
1224 $tpl->
setVariable(
'UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
1225 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
1226 $tpl->
setVariable(
'UPDATE_USR_NAME', $authorinfo->getAuthorName(
true));
1230 $draft->setPostMessage($frm->prepareText($draft->getPostMessage()));
1232 $tpl->
setVariable(
'SUBJECT', $draft->getPostSubject());
1233 $tpl->
setVariable(
'POST_DATE', $frm->convertDate($draft->getPostDate()));
1235 $tpl->
setVariable(
'POST_DRAFT_TEXT', $this->
lng->txt(
'post_draft_info'));
1237 if (!$referencePosting->
isCensored() || ($this->objCurrentPost->getId() === $referencePosting->
getId() && $action ===
'censor')) {
1240 $spanClass =
'moderator';
1243 if ($draft->getPostMessage() === strip_tags($draft->getPostMessage())) {
1245 $draft->setPostMessage(nl2br($draft->getPostMessage()));
1248 if ($spanClass !==
'') {
1252 $draft->getPostMessage(),
1261 if ($action ===
'editdraft' && $draft->getDraftId() === $draft_id) {
1262 $oEditReplyForm = $this->getReplyEditForm();
1264 if (!$this->objCurrentTopic->isClosed() && in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
1265 $this->renderPostingForm($tpl, $frm, $referencePosting, $this->requestAction);
1268 $tpl->
setVariable(
'EDIT_DRAFT_ANCHOR',
'draft_edit_' . $draft->getDraftId());
1269 $tpl->
setVariable(
'DRAFT_FORM', $oEditReplyForm->getHTML() . $this->modal_history);
1283 $forumObj = $this->
object;
1284 $frm = $this->
object->Forum;
1288 $filesOfPost = $fileDataOfForum->getFilesOfPost();
1289 ksort($filesOfPost);
1290 if ($filesOfPost !== [] && ($action !==
'showedit' || $node->
getId() !== $this->objCurrentPost->getId())) {
1291 foreach ($filesOfPost as $file) {
1293 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1294 $this->
ctrl->setParameter($this,
'file', $file[
'md5']);
1295 $tpl->
setVariable(
'HREF_DOWNLOAD', $this->
ctrl->getLinkTarget($this,
'viewThread'));
1297 $this->
ctrl->clearParameters($this);
1301 $tpl->
setVariable(
'TXT_ATTACHMENTS_DOWNLOAD', $this->
lng->txt(
'forums_attachments'));
1304 $this->uiRenderer->render(
1305 $this->uiFactory->symbol()->glyph()->attachment()
1308 if (count($filesOfPost) > 1) {
1309 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1310 $download_zip_button = $this->uiFactory->button()
1312 $this->
lng->txt(
'download'),
1313 $this->ctrl->getLinkTarget($this,
'deliverZipFile')
1315 $tpl->
setVariable(
'DOWNLOAD_ZIP', $this->uiRenderer->render($download_zip_button));
1319 $this->renderSplitButton($tpl, $action,
true, $node, $pageIndex);
1322 $tpl->
setVariable(
'TXT_PERMA_LINK', $this->
lng->txt(
'perma_link'));
1326 if (($this->is_moderator || $node->
isOwner($this->user->getId())) && !$node->
isActivated() && !$this->objCurrentTopic->isClosed()) {
1327 $rowCol =
'ilPostingNeedsActivation';
1328 } elseif ($this->objProperties->getMarkModeratorPosts()) {
1331 $rowCol =
'ilModeratorPosting';
1333 $rowCol =
'ilModeratorPosting';
1338 (!in_array($action, [
'delete',
'censor']) && !$this->displayConfirmPostActivation()) ||
1339 $this->objCurrentPost->getId() !== $node->
getId()
1343 $rowCol =
'tblrowmarked';
1347 if ($action !==
'censor') {
1348 $tpl->
setVariable(
'TXT_CENSORSHIP_ADVICE', $this->
lng->txt(
'post_censored_comment_by_moderator'));
1351 $rowCol =
'tblrowmarked';
1356 if (!$node->
isActivated() && ($node->
isOwner($this->user->getId()) || $this->is_moderator)) {
1357 $tpl->
setVariable(
'POST_NOT_ACTIVATED_YET', $this->
lng->txt(
'frm_post_not_activated_yet'));
1360 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1362 $backurl = urlencode($this->
ctrl->getLinkTarget($this,
'viewThread', (
string) $node->
getId()));
1363 $this->
ctrl->clearParameters($this);
1365 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1374 'href' => $this->ctrl->getLinkTarget($this,
'showUser')
1377 $this->
ctrl->clearParameters($this);
1379 if ($authorinfo->hasSuffix()) {
1380 if (!$authorinfo->isDeleted()) {
1381 $tpl->
setVariable(
'USR_NAME', $authorinfo->getAlias());
1383 $tpl->
setVariable(
'AUTHOR', $authorinfo->getSuffix());
1385 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized()) {
1386 $tpl->
setVariable(
'USR_NAME', $authorinfo->getAuthorName(
true));
1388 $tpl->
setVariable(
'AUTHOR', $authorinfo->getLinkedAuthorShortName());
1391 $tpl->
setVariable(
'USR_IMAGE', $authorinfo->getProfilePicture());
1397 if ($isModerator && $authorinfo->getAuthor()->getId()) {
1398 $authorRole = $this->
lng->txt(
'frm_moderator_n');
1399 if (is_string($authorinfo->getAuthor()->getGender()) && $authorinfo->getAuthor()->getGender() !==
'') {
1400 $authorRole = $this->
lng->txt(
'frm_moderator_' . $authorinfo->getAuthor()->getGender());
1408 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1421 'href' => $this->ctrl->getLinkTarget($this,
'showUser')
1424 $this->
ctrl->clearParameters($this);
1428 $this->
lng->txt(
'edited_on') .
': ' . $frm->convertDate($node->
getChangeDate()) .
' - ' . strtolower($this->
lng->txt(
'by'))
1430 $tpl->
setVariable(
'UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
1431 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
1432 $tpl->
setVariable(
'UPDATE_USR_NAME', $authorinfo->getAuthorName(
true));
1437 && $node->
getId() !== $this->selected_post_storage->get($node->
getThreadId())) {
1438 $target = $this->uiFactory->symbol()->icon()->custom(
1440 $this->
lng->txt(
'target_select')
1443 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1448 $this->uiRenderer->render(
1449 $this->uiFactory->link()->bulky(
1451 $this->lng->txt(
'select'),
1452 new \
ILIAS\Data\URI(
1453 ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTarget($this,
'selectPost', (
string) $node->
getId())
1465 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1467 $this->
ctrl->setParameter($this,
'page', $pageIndex);
1468 $this->
ctrl->setParameter(
1471 $this->getOrderByParam()
1473 $this->
ctrl->setParameter($this,
'viewmode', $this->selectedSorting);
1474 $mark_post_target = $this->
ctrl->getLinkTarget($this,
'markPostRead', (
string) $node->
getId());
1478 '<a href="' . $mark_post_target .
'"><b>' . $node->
getSubject() .
'</b></a>'
1484 if (!$node->
isCensored() || ($this->objCurrentPost->getId() === $node->
getId() && $action ===
'censor')) {
1487 $spanClass =
'moderator';
1496 if ($spanClass !==
'') {
1499 '<span class="' . $spanClass .
'">' .
1518 $thr_pk = (
int) $this->httpRequest->getQueryParams()[
'thr_pk'];
1519 $pos_pk = (
int) $this->httpRequest->getQueryParams()[
'pos_pk'];
1521 $this->selected_post_storage->set(
1526 $this->viewThreadObject();
1534 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_added'),
true);
1535 $this->
ctrl->setParameter($this,
'ref_id', $new_object->
getRefId());
1536 $this->
ctrl->redirect($this,
'createThread');
1541 if ($this->in_page_editor_style_context) {
1545 $this->
ilHelp->setScreenIdComponent(
'frm');
1547 $this->
ctrl->setParameter($this,
'ref_id', $this->ref_id);
1554 'enableForumNotification',
1555 'disableForumNotification',
1557 'performMoveThreads',
1558 'cancelMoveThreads',
1559 'performThreadsAction',
1563 'confirmDeleteThreads',
1566 'performMergeThreads'
1569 $force_active =
false;
1570 if (in_array($this->
ctrl->getCmd(), $active,
true)) {
1571 $force_active =
true;
1574 if ($this->
access->checkAccess(
1579 $this->tabs_gui->addTarget(
1580 self::UI_TAB_ID_THREADS,
1581 $this->
ctrl->getLinkTarget($this,
'showThreads'),
1582 $this->ctrl->getCmd(),
1589 if ($this->
access->checkAccess(
'visible',
'', $this->ref_id) || $this->access->checkAccess(
1594 $cmdClass = $this->
http->wrapper()->query()->retrieve(
1596 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always(
'')])
1599 $force_active = $this->
ctrl->getNextClass() ===
'ilinfoscreengui' || strtolower($cmdClass) ===
'ilnotegui';
1600 $this->tabs_gui->addTarget(
1601 self::UI_TAB_ID_INFO,
1602 $this->
ctrl->getLinkTargetByClass([self::class, ilInfoScreenGUI::class],
'showSummary'),
1603 [
'showSummary',
'infoScreen'],
1610 if ($this->
access->checkAccess(
'write',
'', $this->ref_id)) {
1611 $force_active = $this->
ctrl->getCmd() ===
'edit';
1612 $this->tabs_gui->addTarget(
1613 self::UI_TAB_ID_SETTINGS,
1614 $this->
ctrl->getLinkTarget($this,
'edit'),
1622 if ($this->
access->checkAccess(
'write',
'', $this->ref_id)) {
1623 $this->tabs_gui->addTarget(
1624 self::UI_TAB_ID_MODERATORS,
1625 $this->
ctrl->getLinkTargetByClass(ilForumModeratorsGUI::class,
'showModerators'),
1632 $this->tabs_gui->addTab(
1633 'learning_progress',
1634 $this->
lng->txt(
'learning_progress'),
1635 $this->ctrl->getLinkTargetByClass(ilLearningProgressGUI::class)
1639 if ($this->
settings->get(
'enable_fora_statistics',
'0')) {
1640 $hasStatisticsAccess = $this->
access->checkAccess(
'write',
'', $this->ref_id);
1641 if (!$hasStatisticsAccess) {
1642 $hasStatisticsAccess = (
1643 $this->objProperties->isStatisticEnabled() &&
1644 $this->
access->checkAccess(
'read',
'', $this->ref_id)
1648 if ($hasStatisticsAccess) {
1649 $force_active = $this->
ctrl->getCmd() ===
'showStatistics';
1650 $this->tabs_gui->addTarget(
1651 self::UI_TAB_ID_STATS,
1652 $this->
ctrl->getLinkTarget($this,
'showStatistics'),
1661 if ($this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1662 $this->tabs_gui->addTarget(
1663 self::UI_TAB_ID_EXPORT,
1664 $this->
ctrl->getLinkTargetByClass(ilExportGUI::class,
''),
1670 if ($this->
access->checkAccess(
'edit_permission',
'', $this->ref_id)) {
1671 $this->tabs_gui->addTarget(
1672 self::UI_TAB_ID_PERMISSIONS,
1673 $this->
ctrl->getLinkTargetByClass([static::class, ilPermissionGUI::class],
'perm'),
1674 [
'perm',
'info',
'owner'],
1682 if (!$this->
settings->get(
'enable_fora_statistics',
'0')) {
1683 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1686 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1687 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1690 if (!$this->objProperties->isStatisticEnabled()) {
1691 if ($this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1692 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'frm_statistics_disabled_for_participants'));
1694 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1698 $this->
object->Forum->setForumId($this->
object->getId());
1700 $tbl = new \ILIAS\Forum\Statistics\ForumStatisticsTable(
1702 $this->objProperties,
1704 $this->access->checkRbacOrPositionPermissionAccess(
1705 'read_learning_progress',
1706 'read_learning_progress',
1707 $this->object->getRefId()
1714 $this->tpl->setContent($this->uiRenderer->render($tbl->getComponent()));
1717 public static function _goto($a_target, $a_thread = 0, $a_posting = 0): void
1720 $main_tpl =
$DIC->ui()->mainTemplate();
1722 $ilAccess =
$DIC->access();
1726 $a_target = is_numeric($a_target) ? (
int) $a_target : 0;
1727 $a_thread = is_numeric($a_thread) ? (
int) $a_thread : 0;
1728 if ($ilAccess->checkAccess(
'read',
'', $a_target)) {
1729 if ($a_thread !== 0) {
1731 if ($objTopic->getFrmObjId() &&
1734 foreach ($ref_ids as
$ref_id) {
1735 if ($ilAccess->checkAccess(
'read',
'',
$ref_id)) {
1741 if (isset($new_ref_id) && $new_ref_id !== $a_target) {
1742 $DIC->ctrl()->redirectToURL(
1743 ILIAS_HTTP_PATH .
'/goto.php?target=frm_' . $new_ref_id .
'_' . $a_thread .
'_' . $a_posting
1748 $DIC->ctrl()->setParameterByClass(self::class,
'ref_id', (
string) ((
int) $a_target));
1749 if (is_numeric($a_thread)) {
1750 $DIC->ctrl()->setParameterByClass(self::class,
'thr_pk', (
string) ((
int) $a_thread));
1752 if (is_numeric($a_posting)) {
1753 $DIC->ctrl()->setParameterByClass(self::class,
'pos_pk', (
string) ((
int) $a_posting));
1755 $DIC->ctrl()->redirectByClass(
1756 [ilRepositoryGUI::class, self::class],
1758 is_numeric($a_posting) ? (
string) ((
int) $a_posting) :
''
1761 $DIC->ctrl()->setParameterByClass(self::class,
'ref_id', $a_target);
1762 $DIC->ctrl()->redirectByClass([ilRepositoryGUI::class, self::class,],
'');
1763 $DIC->http()->close();
1765 } elseif ($ilAccess->checkAccess(
'visible',
'', $a_target)) {
1766 $DIC->ctrl()->setParameterByClass(ilInfoScreenGUI::class,
'ref_id', $a_target);
1767 $DIC->ctrl()->redirectByClass(
1769 ilRepositoryGUI::class,
1771 ilInfoScreenGUI::class
1776 $main_tpl->setOnScreenMessage(
'info', sprintf(
1777 $lng->txt(
'msg_no_perm_read_item'),
1780 $DIC->http()->close();
1788 $threadIds = $this->retrieveThreadIds();
1789 if ($threadIds === []) {
1790 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
1791 $this->
ctrl->redirect($this,
'showThreads');
1794 if (!$this->is_moderator) {
1795 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1798 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1799 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1803 $this->objProperties->setObjId($forumObj->getId());
1807 $success_message =
'forums_thread_deleted';
1808 if (count($threadIds) > 1) {
1809 $success_message =
'forums_threads_deleted';
1813 array_walk($threadIds,
function (
int $threadId) use (&$threads):
void {
1815 $this->ensureThreadBelongsToForum($this->
object->getId(), $thread);
1817 $threads[] = $thread;
1820 $frm->setForumId($forumObj->getId());
1821 $frm->setForumRefId($forumObj->getRefId());
1822 foreach ($threads as $thread) {
1823 $first_node = $frm->getFirstPostNode($thread->getId());
1824 if (isset($first_node[
'pos_pk']) && (
int) $first_node[
'pos_pk']) {
1825 $frm->deletePost((
int) $first_node[
'pos_pk']);
1826 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt($success_message),
true);
1829 $this->
ctrl->redirect($this,
'showThreads');
1832 public function confirmDeleteThreadsObject(): void
1834 $thread_ids = $this->retrieveThreadIds();
1835 if ($thread_ids === []) {
1836 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'));
1837 $this->
ctrl->redirect($this,
'showThreads');
1840 if (!$this->is_moderator) {
1841 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1844 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1845 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1850 array_walk($thread_ids,
function (
int $threadId) use (&$threads):
void {
1852 $this->ensureThreadBelongsToForum($this->
object->getId(), $thread);
1854 $threads[] = $thread;
1859 $c_gui->setFormAction($this->
ctrl->getFormAction($this,
'performDeleteThreads'));
1860 $c_gui->setHeaderText($this->
lng->txt(
'frm_sure_delete_threads'));
1861 $c_gui->setCancel($this->
lng->txt(
'cancel'),
'showThreads');
1862 $c_gui->setConfirm($this->
lng->txt(
'confirm'),
'performDeleteThreads');
1864 foreach ($threads as $thread) {
1865 $c_gui->addItem(
'thread_ids[]', (
string) $thread->getId(), $thread->getSubject());
1868 $this->confirmation_gui_html = $c_gui->getHTML();
1870 $this->hideToolbar(
true);
1871 $this->tpl->setContent($c_gui->getHTML());
1876 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1877 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1880 $draft_ids = $this->
http->wrapper()->query()->retrieve(
1881 'forum_drafts_delete_draft_ids',
1883 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
1884 $this->refinery->always([])
1888 if ($draft_ids === []) {
1889 $draft_ids = $this->
http->wrapper()->query()->retrieve(
1890 'forum_drafts_delete_draft_ids',
1892 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string()),
1893 $this->refinery->always([])
1897 if (!isset($draft_ids[0]) || $draft_ids[0] !==
'ALL_OBJECTS') {
1898 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'));
1899 $this->showThreadsObject();
1903 $draft_ids = array_filter(array_map(
1904 static fn(array $draft):
int => $draft[
'draft_id'] ?? 0,
1906 $this->
user->getId(),
1913 $confirmation->setFormAction($this->
ctrl->getFormAction($this,
'deleteThreadDrafts'));
1914 $confirmation->setHeaderText($this->
lng->txt(
'sure_delete_drafts'));
1915 $confirmation->setCancel($this->
lng->txt(
'cancel'),
'showThreads');
1916 $confirmation->setConfirm($this->
lng->txt(
'confirm'),
'deleteThreadDrafts');
1918 foreach ($draft_ids as $draftId) {
1919 if (array_key_exists($draftId, $instances)) {
1920 $confirmation->addItem(
'draft_ids[]', (
string) $draftId, $instances[$draftId]->getPostSubject());
1924 $this->tpl->setContent($confirmation->getHTML());
1927 public function prepareThreadScreen(
ilObjForum $a_forum_obj): void
1929 $this->
ilHelp->setScreenIdComponent(
'frm');
1931 $this->tpl->loadStandardTemplate();
1935 $this->tabs_gui->setBackTarget(
1936 $this->
lng->txt(
'frm_all_threads'),
1937 $this->ctrl->getLinkTarget(
1944 $frm = $a_forum_obj->Forum;
1945 $frm->setForumId($a_forum_obj->
getId());
1950 if (!$this->is_moderator) {
1951 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1954 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1955 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1958 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
1960 $this->objCurrentPost->activatePost();
1961 $GLOBALS[
'ilAppEventHandler']->raise(
1962 'components/ILIAS/Forum',
1965 'object' => $this->
object,
1966 'ref_id' => $this->
object->getRefId(),
1967 'post' => $this->objCurrentPost
1970 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_post_was_activated'),
true);
1972 $this->viewThreadObject();
1978 !$this->
user->isAnonymous() &&
1979 !$this->objCurrentTopic->isClosed() && (
1980 $this->is_moderator ||
1981 ($this->objCurrentPost->isOwner($this->user->getId()) && !$this->objCurrentPost->hasReplies())
1984 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
1986 $oForumObjects = $this->getForumObjects();
1987 $forumObj = $oForumObjects[
'forumObj'];
1990 $frm->setForumId($forumObj->getId());
1991 $frm->setForumRefId($forumObj->getRefId());
1992 $dead_thr = $frm->deletePost($this->objCurrentPost->getId());
1995 if ($dead_thr === $this->objCurrentTopic->getId()) {
1996 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', [
'integer'], [$forumObj->getId()]);
1997 $topicData = $frm->getOneTopic();
1998 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_post_deleted'),
true);
1999 if ($topicData->getTopNumThreads() > 0) {
2000 $this->
ctrl->redirect($this,
'showThreads');
2002 $this->
ctrl->redirect($this,
'createThread');
2005 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_post_deleted'),
true);
2006 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
2007 $this->
ctrl->redirect($this,
'viewThread');
2010 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2015 $this->deleteSelectedDraft();
2020 $this->handleCensorship(
true);
2025 $this->handleCensorship();
2031 foreach ($this->modalActionsContainer as $modal) {
2032 $modalString .= $this->uiRenderer->render($modal);
2035 return $modalString;
2041 if ($this->is_moderator && !$this->objCurrentTopic->isClosed()) {
2042 if ($this->
http->wrapper()->post()->has(
'formData')) {
2043 $formData = $this->
http->wrapper()->post()->retrieve(
2045 $this->
refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string())
2047 $message = $this->handleFormInput($formData[
'cens_message']);
2050 if ($message ===
'' && $this->
http->wrapper()->post()->has(
'cens_message')) {
2051 $cens_message = $this->
http->wrapper()->post()->retrieve(
2053 $this->
refinery->kindlyTo()->string()
2055 $message = $this->handleFormInput($cens_message);
2057 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
2059 $oForumObjects = $this->getForumObjects();
2060 $frm = $oForumObjects[
'frm'];
2063 $frm->postCensorship($this->
object, $message, $this->objCurrentPost->getId());
2064 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_censorship_revoked'));
2066 $frm->postCensorship($this->
object, $message, $this->objCurrentPost->getId(), 1);
2067 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_censorship_applied'));
2070 $this->viewThreadObject();
2074 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2079 if (!$this->is_moderator) {
2080 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2083 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2084 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2087 $this->setDisplayConfirmPostActivation(
true);
2089 $this->viewThreadObject();
2094 $this->display_confirm_post_activation = $status;
2099 return $this->display_confirm_post_activation;
2104 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2105 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2108 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentTopic);
2110 if ($this->objCurrentTopic->isNotificationEnabled($this->user->getId())) {
2111 $this->objCurrentTopic->disableNotification($this->
user->getId());
2112 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_notification_disabled'),
true);
2114 $this->objCurrentTopic->enableNotification($this->
user->getId());
2115 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_notification_enabled'),
true);
2118 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
2119 $this->
ctrl->redirect($this,
'viewThread');
2124 if (!$this->is_moderator) {
2125 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2128 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2129 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2132 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentTopic);
2134 if ($this->objCurrentTopic->isSticky()) {
2135 $this->objCurrentTopic->unmakeSticky();
2137 $this->objCurrentTopic->makeSticky();
2140 $this->viewThreadObject();
2145 $this->requestAction =
'';
2146 $draft_id = $this->retrieveDraftId(
true);
2147 if ($draft_id > 0) {
2149 if ($this->hasDraftAccess($draft)) {
2150 $draft->deleteDraftsByDraftIds([$draft_id]);
2154 $this->viewThreadObject();
2159 $this->requestAction =
'';
2160 $draft_id = $this->retrieveDraftId();
2161 if ($draft_id > 0) {
2163 $history_entry->populateWithFirstAutosaveByDraftId($draft_id);
2165 if ($this->hasDraftAccess($draft)) {
2166 $draft->setPostSubject($history_entry->getPostSubject());
2167 $draft->setPostMessage($history_entry->getPostMessage());
2170 $history_entry->getPostMessage(),
2172 $history_entry->getHistoryId(),
2174 $draft->getDraftId()
2177 $draft->updateDraft();
2179 $history_entry->deleteHistoryByDraftIds([$draft->getDraftId()]);
2183 $this->
ctrl->clearParameters($this);
2184 $this->viewThreadObject();
2190 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
2192 $this->
ctrl->setParameter(
2195 $this->getOrderByParam()
2197 $form->setFormAction($this->
ctrl->getFormAction($this,
'performPostActivation'));
2198 $this->
ctrl->clearParameters($this);
2199 $form->setId(
'frm_activate_post_' . $node->
getId());
2200 $form_id = $form->getId();
2201 $message = $this->uiFactory->messageBox()->confirmation($this->
lng->txt(
'activate_post_txt'));
2202 $submitBtn = $this->uiFactory->button()->primary(
2203 $this->
lng->txt(
'activate_only_current'),
2206 static function (
string $id) use ($form_id):
string {
2209 const button = document.getElementById('$id');
2210 if (!button) return;
2212 const form = document.getElementById('form_$form_id');
2215 button.addEventListener('click', (event) => {
2216 event.preventDefault();
2223 $modal = $this->uiFactory->modal()->roundtrip(
2224 $this->
lng->txt(
'activate_only_current'),
2225 [$this->uiFactory->legacy()->content($form->getHTML()), $message]
2226 )->withActionButtons([$submitBtn]);
2227 $action_button = $this->uiFactory->button()->standard($this->
lng->txt(
'activate_post'),
'#')->withOnClick(
2228 $modal->getShowSignal()
2230 $this->modalActionsContainer[] = $modal;
2231 $this->
ctrl->clearParameters($this);
2233 return $action_button;
2236 public function getCensorshipFormHTML(): string
2239 $frm = $this->
object->Forum;
2240 $form_tpl =
new ilTemplate(
'tpl.frm_censorship_post_form.html',
true,
true,
'components/ILIAS/Forum');
2242 $form_tpl->setVariable(
'ANCHOR', $this->objCurrentPost->getId());
2243 $form_tpl->setVariable(
'SPACER',
'<hr noshade="noshade" width="100%" size="1" align="center" />');
2244 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2245 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2246 $this->
ctrl->setParameter(
2249 $this->getOrderByParam()
2251 $form_tpl->setVariable(
'FORM_ACTION', $this->
ctrl->getFormAction($this,
'viewThread'));
2252 $this->
ctrl->clearParameters($this);
2253 $form_tpl->setVariable(
'TXT_CENS_MESSAGE', $this->
lng->txt(
'forums_the_post'));
2254 $form_tpl->setVariable(
'TXT_CENS_COMMENT', $this->
lng->txt(
'forums_censor_comment') .
':');
2255 $form_tpl->setVariable(
'CENS_MESSAGE', $frm->prepareText((
string) $this->objCurrentPost->getCensorshipComment(), 2));
2257 if ($this->objCurrentPost->isCensored()) {
2258 $form_tpl->setVariable(
'TXT_CENS', $this->
lng->txt(
'forums_info_censor2_post'));
2259 $form_tpl->setVariable(
'YES_BUTTON', $this->
lng->txt(
'confirm'));
2260 $form_tpl->setVariable(
'NO_BUTTON', $this->
lng->txt(
'cancel'));
2261 $form_tpl->setVariable(
'CMD_REVOKE_CENSORSHIP',
'revokeCensorship');
2262 $form_tpl->setVariable(
'CMD_CANCEL_REVOKE_CENSORSHIP',
'viewThread');
2264 $form_tpl->setVariable(
'TXT_CENS', $this->
lng->txt(
'forums_info_censor_post'));
2265 $form_tpl->setVariable(
'CANCEL_BUTTON', $this->
lng->txt(
'cancel'));
2266 $form_tpl->setVariable(
'CONFIRM_BUTTON', $this->
lng->txt(
'confirm'));
2267 $form_tpl->setVariable(
'CMD_ADD_CENSORSHIP',
'addCensorship');
2268 $form_tpl->setVariable(
'CMD_CANCEL_ADD_CENSORSHIP',
'viewThread');
2271 return $form_tpl->get();
2276 $isReply = in_array($this->requestAction, [
'showreply',
'ready_showreply']);
2277 $isDraft = in_array($this->requestAction, [
'publishDraft',
'editdraft']);
2279 $draft_id = $this->retrieveDraftId();
2282 $oForumObjects = $this->getForumObjects();
2283 $frm = $oForumObjects[
'frm'];
2284 $oFDForum = $oForumObjects[
'file_obj'];
2287 $this->replyEditForm->setId(
'id_showreply');
2288 $this->replyEditForm->setTableWidth(
'100%');
2289 $cancel_cmd =
'cancelPost';
2290 if (in_array($this->requestAction, [
'showreply',
'ready_showreply'])) {
2291 $this->
ctrl->setParameter($this,
'action',
'ready_showreply');
2292 } elseif (in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
2293 $this->
ctrl->setParameter($this,
'action', $this->requestAction);
2294 $this->
ctrl->setParameter($this,
'draft_id', $draft_id);
2296 $this->
ctrl->setParameter($this,
'action',
'ready_showedit');
2299 $this->
ctrl->setParameter($this,
'page', (
int) ($this->httpRequest->getQueryParams()[
'page'] ?? 0));
2300 $this->
ctrl->setParameter(
2303 $this->getOrderByParam()
2305 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2306 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2307 if ($this->isTopLevelReplyCommand()) {
2308 $this->replyEditForm->setFormAction(
2309 $this->
ctrl->getFormAction($this,
'saveTopLevelPost',
'frm_page_bottom')
2311 } elseif (in_array($this->requestAction, [
'publishDraft',
'editdraft'])) {
2312 $this->replyEditForm->setFormAction(
2313 $this->
ctrl->getFormAction($this,
'publishDraft', (
string) $this->objCurrentPost->getId())
2316 $this->replyEditForm->setFormAction(
2317 $this->
ctrl->getFormAction($this,
'savePost', (
string) $this->objCurrentPost->getId())
2320 $this->
ctrl->clearParameters($this);
2323 $this->replyEditForm->setTitle($this->
lng->txt(
'forums_your_reply'));
2324 } elseif ($isDraft) {
2325 $this->replyEditForm->setTitle($this->
lng->txt(
'forums_edit_draft'));
2327 $this->replyEditForm->setTitle($this->
lng->txt(
'forums_edit_post'));
2331 $this->isWritingWithPseudonymAllowed() &&
2332 in_array($this->requestAction, [
'showreply',
'ready_showreply',
'editdraft'])
2334 $oAnonymousNameGUI =
new ilTextInputGUI($this->
lng->txt(
'forums_your_name'),
'alias');
2335 $oAnonymousNameGUI->setMaxLength(64);
2336 $oAnonymousNameGUI->setInfo(sprintf($this->
lng->txt(
'forums_use_alias'), $this->lng->txt(
'forums_anonymous')));
2338 $this->replyEditForm->addItem($oAnonymousNameGUI);
2341 $oSubjectGUI =
new ilTextInputGUI($this->
lng->txt(
'forums_subject'),
'subject');
2342 $oSubjectGUI->setMaxLength(255);
2343 $oSubjectGUI->setRequired(
true);
2345 if ($this->objProperties->getSubjectSetting() ===
'empty_subject') {
2346 $oSubjectGUI->setInfo($this->
lng->txt(
'enter_new_subject'));
2349 $this->replyEditForm->addItem($oSubjectGUI);
2352 $isReply ? $this->
lng->txt(
'forums_your_reply') : $this->lng->txt(
'forums_edit_post'),
2355 $oPostGUI->setRequired(
true);
2356 $oPostGUI->setRows(15);
2357 $oPostGUI->setUseRte(
true);
2360 !$this->isTopLevelReplyCommand() && (
2361 ($isReply && $this->objCurrentPost->getDepth() >= 2) ||
2362 (!$isDraft && !$isReply && $this->objCurrentPost->getDepth() > 2) ||
2363 ($isDraft && $this->objCurrentPost->getDepth() >= 2)
2367 $oPostGUI->removePlugin(
'advlink');
2368 $oPostGUI->setRTERootBlockElement(
'');
2369 $oPostGUI->usePurifier(
true);
2370 $oPostGUI->disableButtons([
2387 if (in_array($this->requestAction, [
'showreply',
'ready_showreply',
'showdraft',
'editdraft'])) {
2388 $oPostGUI->setRTESupport(
2389 $this->
user->getId(),
2392 'tpl.tinymce_frm_post.js',
2397 $oPostGUI->setRTESupport(
2398 $this->objCurrentPost->getId(),
2401 'tpl.tinymce_frm_post.js',
2408 $oPostGUI->setInfo($this->
lng->txt(
'latex_edit_info'));
2410 $this->replyEditForm->addItem($oPostGUI);
2413 if (!$this->
user->isAnonymous() &&
2414 !$this->objProperties->isAnonymized() &&
2415 $this->rbac->system()->checkAccess(
'internal_mail', $umail->getMailObjectReferenceId()) &&
2416 !$frm->isThreadNotificationEnabled($this->user->getId(), $this->objCurrentPost->getThreadId())) {
2418 $oNotificationGUI->setInfo($this->
lng->txt(
'forum_notify_me'));
2419 $this->replyEditForm->addItem($oNotificationGUI);
2422 if ($this->objProperties->isFileUploadAllowed()) {
2424 $oFileUploadGUI->setFilenames([0 =>
'']);
2425 $this->replyEditForm->addItem($oFileUploadGUI);
2428 $attachments_of_node = $oFDForum->getFilesOfPost();
2429 if (count($attachments_of_node) && in_array($this->requestAction, [
'showedit',
'ready_showedit'])) {
2431 foreach ($oFDForum->getFilesOfPost() as $file) {
2432 $oExistingAttachmentsGUI->addOption(
new ilCheckboxOption($file[
'name'], $file[
'md5']));
2434 $this->replyEditForm->addItem($oExistingAttachmentsGUI);
2438 if (in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
2440 $draftInfoGUI->setValue(sprintf(
2441 $this->
lng->txt(
'autosave_draft_info'),
2444 $this->replyEditForm->addItem($draftInfoGUI);
2445 } elseif (!in_array($this->requestAction, [
'showedit',
'ready_showedit'])) {
2447 $draftInfoGUI->setValue(sprintf(
2448 $this->
lng->txt(
'autosave_post_draft_info'),
2451 $this->replyEditForm->addItem($draftInfoGUI);
2455 $selected_draft_id = $draft_id;
2457 $this->
user->getId(),
2458 $this->objCurrentPost->getId(),
2461 if ($draftObj->getDraftId() > 0) {
2463 $files_of_draft = $oFDForumDrafts->getFilesOfPost();
2465 if ($files_of_draft !== []) {
2467 $this->
lng->txt(
'forums_delete_file'),
2470 foreach ($files_of_draft as $file) {
2471 $oExistingAttachmentsGUI->addOption(
new ilCheckboxOption($file[
'name'], $file[
'md5']));
2473 $this->replyEditForm->addItem($oExistingAttachmentsGUI);
2477 if ($this->isTopLevelReplyCommand()) {
2478 $this->replyEditForm->addCommandButton(
'saveTopLevelPost', $this->
lng->txt(
'create'));
2480 $this->replyEditForm->addCommandButton(
'publishDraft', $this->
lng->txt(
'publish'));
2482 $this->replyEditForm->addCommandButton(
'savePost', $this->
lng->txt(
'save'));
2485 $auto_save_draft_id = $this->retrieveDraftId();
2487 $hidden_draft_id->setValue((
string) $auto_save_draft_id);
2488 $this->replyEditForm->addItem($hidden_draft_id);
2490 if (in_array($this->requestAction, [
'showreply',
'ready_showreply',
'editdraft'])) {
2491 $show_rte = $this->
http->wrapper()->post()->retrieve(
2493 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
2500 if ($quotingAllowed) {
2501 $this->replyEditForm->addCommandButton(
'quotePost', $this->
lng->txt(
'forum_add_quote'));
2504 if (!$this->
user->isAnonymous() &&
2505 in_array($this->requestAction, [
'editdraft',
'showreply',
'ready_showreply']) &&
2508 $this->decorateWithAutosave($this->replyEditForm);
2511 if ($this->requestAction ===
'editdraft') {
2512 $this->replyEditForm->addCommandButton(
'updateDraft', $this->
lng->txt(
'save_message'));
2513 } elseif ($this->isTopLevelReplyCommand()) {
2514 $this->replyEditForm->addCommandButton(
'saveTopLevelDraft', $this->
lng->txt(
'save_message'));
2516 $this->replyEditForm->addCommandButton(
'saveAsDraft', $this->
lng->txt(
'save_message'));
2519 $cancel_cmd =
'cancelDraft';
2522 $this->replyEditForm->addCommandButton($cancel_cmd, $this->
lng->txt(
'cancel'));
2527 if ($this->replyEditForm ===
null) {
2528 $this->initReplyEditForm();
2531 return $this->replyEditForm;
2537 $draft_id = $this->retrieveDraftId();
2539 if ($draft_id > 0 && !$this->
user->isAnonymous()
2542 $this->
user->getId(),
2543 $this->objCurrentPost->getId(),
2549 $this->
ctrl->setParameter($this,
'action',
'editdraft');
2550 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2551 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
2552 $this->
ctrl->setParameter($this,
'draft_id', $draft_obj->getDraftId());
2553 $this->
ctrl->setParameter($this,
'page', 0);
2554 $this->
ctrl->setParameter(
2557 $this->getOrderByParam()
2559 $this->
ctrl->redirect($this,
'editDraft');
2561 $this->viewThreadObject();
2567 $this->savePostObject();
2572 $draft_id = $this->retrieveDraftId();
2573 if ($draft_id > 0) {
2574 $this->publishDraftObject(
false);
2581 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2582 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2585 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
2586 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2589 if ($this->objCurrentTopic->getId() === 0) {
2590 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
2591 $this->
ctrl->redirect($this);
2594 if ($this->objCurrentTopic->isClosed()) {
2595 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
2596 $this->
ctrl->redirect($this);
2599 if ($this->objCurrentPost->getId() === 0) {
2600 $this->requestAction =
'';
2601 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'));
2602 $this->viewThreadObject();
2606 $draft =
new ilForumPostDraft($this->
user->getId(), $this->objCurrentPost->getId(), $this->retrieveDraftId());
2607 $this->checkDraftAccess($draft->getDraftId());
2609 if ($use_replyform) {
2610 $oReplyEditForm = $this->getReplyEditForm();
2611 if (!$oReplyEditForm->checkInput()) {
2612 $oReplyEditForm->setValuesByPost();
2613 $this->viewThreadObject();
2616 $post_subject = $oReplyEditForm->getInput(
'subject');
2617 $post_message = $oReplyEditForm->getInput(
'message');
2620 $post_subject = $draft->getPostSubject();
2621 $post_message = $draft->getPostMessage();
2625 $oForumObjects = $this->getForumObjects();
2626 $frm = $oForumObjects[
'frm'];
2627 $frm->setMDB2WhereCondition(
' top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
2631 $send_activation_mail =
false;
2633 if ($this->objProperties->isPostActivationEnabled()) {
2634 if (!$this->is_moderator) {
2636 $send_activation_mail =
true;
2637 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2642 $newPost = $frm->generatePost(
2643 $draft->getForumId(),
2644 $draft->getThreadId(),
2645 $this->user->getId(),
2646 $draft->getPostDisplayUserId(),
2648 $draft->getPostId(),
2649 $draft->isNotificationEnabled(),
2650 $this->handleFormInput($post_subject,
false),
2651 $draft->getPostUserAlias(),
2654 $send_activation_mail
2657 $this->
object->markPostRead(
2658 $this->
user->getId(),
2659 $this->objCurrentTopic->getId(),
2660 $this->objCurrentPost->getId()
2665 foreach ($uploadedObjects as $mob) {
2672 if ($draft->getRCID() > 0) {
2673 $post_obj->setRCID($draft->getRCID());
2674 $post_obj->update();
2677 if ($this->objProperties->isFileUploadAllowed()) {
2678 $file = $_FILES[
'userfile'] ?? [];
2679 if (is_array($file) && !empty($file)) {
2681 $tmp_file_obj->storeUploadedFiles();
2685 $GLOBALS[
'ilAppEventHandler']->raise(
2686 'components/ILIAS/Forum',
2689 'draftObj' => $draft,
2690 'obj_id' => $this->
object->getId(),
2691 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
2694 $draft->deleteDraft();
2696 $GLOBALS[
'ilAppEventHandler']->raise(
2697 'components/ILIAS/Forum',
2700 'object' => $this->
object,
2701 'ref_id' => $this->
object->getRefId(),
2702 'post' => $post_obj,
2703 'notify_moderators' => $send_activation_mail
2708 if (!$this->is_moderator && !$status) {
2709 $message .= $this->
lng->txt(
'forums_post_needs_to_be_activated');
2711 $message .= $this->
lng->txt(
'forums_post_new_entry');
2715 if (is_array($frm_session_values)) {
2716 $frm_session_values[$this->objCurrentTopic->getId()][
'openTreeNodes'][] = $this->objCurrentPost->getId();
2720 $this->
ctrl->clearParameters($this);
2721 $this->tpl->setOnScreenMessage(
'success', $message,
true);
2722 $this->
ctrl->setParameter($this,
'pos_pk', $newPost);
2723 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2725 $this->
ctrl->redirect($this,
'viewThread');
2730 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2731 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2734 if ($this->objCurrentTopic->getId() === 0) {
2735 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
2736 $this->
ctrl->redirect($this);
2739 if ($this->objCurrentTopic->isClosed()) {
2740 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
2741 $this->
ctrl->redirect($this);
2744 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentTopic);
2746 $oReplyEditForm = $this->getReplyEditForm();
2747 if ($oReplyEditForm->checkInput()) {
2748 if ($this->objCurrentPost->getId() === 0) {
2749 $this->requestAction =
'';
2750 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'),
true);
2751 $this->viewThreadObject();
2755 $oForumObjects = $this->getForumObjects();
2756 $forumObj = $oForumObjects[
'forumObj'];
2757 $frm = $oForumObjects[
'frm'];
2758 $frm->setMDB2WhereCondition(
' top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
2759 $topicData = $frm->getOneTopic();
2761 $autosave_draft_id = $this->
http->wrapper()->post()->retrieve(
2763 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
2766 if ($this->requestAction ===
'ready_showreply') {
2767 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
2768 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2772 $send_activation_mail =
false;
2774 if ($this->objProperties->isPostActivationEnabled()) {
2775 if (!$this->is_moderator) {
2777 $send_activation_mail =
true;
2778 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2783 if ($this->isWritingWithPseudonymAllowed()) {
2784 if ((
string) $oReplyEditForm->getInput(
'alias') ===
'') {
2785 $user_alias = $this->
lng->txt(
'forums_anonymous');
2787 $user_alias = $oReplyEditForm->getInput(
'alias');
2789 $display_user_id = 0;
2791 $user_alias = $this->
user->getLogin();
2792 $display_user_id = $this->
user->getId();
2795 $newPost = $frm->generatePost(
2796 $topicData->getTopPk(),
2797 $this->objCurrentTopic->getId(),
2798 $this->user->getId(),
2801 $this->objCurrentPost->getId(),
2802 $oReplyEditForm->getInput(
'notify') && !$this->user->isAnonymous(),
2803 $this->handleFormInput($oReplyEditForm->getInput(
'subject'),
false),
2807 $send_activation_mail
2810 if ($autosave_draft_id > 0) {
2812 $this->
user->getId(),
2813 $this->objCurrentPost->getId(),
2816 if ($this->hasDraftAccess($draft)) {
2817 $draft->deleteDraft();
2822 $this->
object->markPostRead(
2823 $this->
user->getId(),
2824 $this->objCurrentTopic->getId(),
2825 $this->objCurrentPost->getId()
2830 $oReplyEditForm->getInput(
'message'),
2832 $this->user->getId(),
2837 if ($this->objProperties->isFileUploadAllowed()) {
2839 $file = $_FILES[
'userfile'];
2840 if (is_array($file) && !empty($file)) {
2841 $oFDForum->storeUploadedFiles();
2845 $GLOBALS[
'ilAppEventHandler']->raise(
2846 'components/ILIAS/Forum',
2849 'object' => $this->
object,
2850 'ref_id' => $this->
object->getRefId(),
2852 'notify_moderators' => $send_activation_mail
2857 if (!$this->is_moderator && !$status) {
2858 $message .= $this->
lng->txt(
'forums_post_needs_to_be_activated');
2860 $message .= $this->
lng->txt(
'forums_post_new_entry');
2863 $this->tpl->setOnScreenMessage(
'success', $message,
true);
2864 $this->
ctrl->clearParameters($this);
2865 $this->
ctrl->setParameter($this,
'post_created_below', $this->objCurrentPost->getId());
2866 $this->
ctrl->setParameter($this,
'pos_pk', $newPost);
2867 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2869 if ((!$this->is_moderator &&
2870 !$this->objCurrentPost->isOwner($this->user->getId())) || $this->objCurrentPost->isCensored() ||
2871 $this->user->isAnonymous()) {
2872 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2875 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
2879 foreach ($oldMediaObjects as $oldMob) {
2881 foreach ($curMediaObjects as $curMob) {
2882 if ($oldMob === $curMob) {
2895 $old_status_was_active = $this->objCurrentPost->isActivated();
2899 $send_activation_mail =
false;
2901 if ($this->objProperties->isPostActivationEnabled()) {
2902 if (!$this->is_moderator) {
2904 $send_activation_mail =
true;
2905 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2909 $this->objCurrentPost->setStatus($status);
2911 $this->objCurrentPost->setSubject($this->handleFormInput($oReplyEditForm->getInput(
'subject'),
false));
2913 $oReplyEditForm->getInput(
'message')
2915 $this->objCurrentPost->setNotification($oReplyEditForm->getInput(
'notify') && !$this->user->isAnonymous());
2916 $this->objCurrentPost->setChangeDate(date(
'Y-m-d H:i:s'));
2917 $this->objCurrentPost->setUpdateUserId($this->
user->getId());
2919 if ($this->objCurrentPost->update()) {
2920 $this->objCurrentPost->reload();
2927 $this->objCurrentPost->getId(),
2932 $news_item->setTitle($this->objCurrentPost->getSubject());
2933 $news_item->setContent(
2935 $this->objCurrentPost->getMessage()
2939 if ($this->objCurrentPost->getMessage() !== strip_tags($this->objCurrentPost->getMessage())) {
2940 $news_item->setContentHtml(
true);
2942 $news_item->setContentHtml(
false);
2944 $news_item->update();
2947 $oFDForum = $oForumObjects[
'file_obj'];
2949 $file2delete = $oReplyEditForm->getInput(
'del_file');
2950 if (is_array($file2delete) && count($file2delete)) {
2951 $oFDForum->unlinkFilesByMD5Filenames($file2delete);
2954 if ($this->objProperties->isFileUploadAllowed()) {
2955 $file = $_FILES[
'userfile'];
2956 if (is_array($file) && !empty($file)) {
2957 $oFDForum->storeUploadedFiles();
2961 $GLOBALS[
'ilAppEventHandler']->raise(
2962 'components/ILIAS/Forum',
2965 'ref_id' => $this->
object->getRefId(),
2966 'post' => $this->objCurrentPost,
2967 'notify_moderators' => $send_activation_mail,
2968 'old_status_was_active' => $old_status_was_active
2972 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'forums_post_modified'),
true);
2975 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2976 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2977 $this->
ctrl->setParameter($this,
'viewmode', $this->selectedSorting);
2979 $this->
ctrl->redirect($this,
'viewThread');
2981 $this->requestAction = substr($this->requestAction, 6);
2983 $this->viewThreadObject();
2988 if ($a_flag ===
null) {
2989 return $this->hideToolbar;
2992 $this->hideToolbar = $a_flag;
2998 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2999 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3002 if ($this->objCurrentTopic->isClosed()) {
3003 $this->requestAction =
'';
3004 $this->viewThreadObject();
3008 $oReplyEditForm = $this->getReplyEditForm();
3010 $oReplyEditForm->getItemByPostVar(
'subject')->setRequired(
false);
3011 $oReplyEditForm->getItemByPostVar(
'message')->setRequired(
false);
3013 $oReplyEditForm->checkInput();
3015 $oReplyEditForm->getItemByPostVar(
'subject')->setRequired(
true);
3016 $oReplyEditForm->getItemByPostVar(
'message')->setRequired(
true);
3018 $this->requestAction =
'showreply';
3020 $this->viewThreadObject();
3028 if ($this->forumObjects ===
null) {
3029 $forumObj = $this->object;
3030 $file_obj =
new ilFileDataForum($forumObj->getId(), $this->objCurrentPost->getId());
3031 $frm = $forumObj->Forum;
3032 $frm->setForumId($forumObj->getId());
3033 $frm->setForumRefId($forumObj->getRefId());
3035 $this->forumObjects[
'forumObj'] = $forumObj;
3036 $this->forumObjects[
'frm'] = $frm;
3037 $this->forumObjects[
'file_obj'] = $file_obj;
3040 return $this->forumObjects;
3045 $this->selectedSorting = $this->objProperties->getDefaultView();
3047 if ($this->getObject() !==
null) {
3048 $view_mode =
'viewmode_' . $this->getObject()->getId();
3058 isset($this->httpRequest->getQueryParams()[
'viewmode']) &&
3059 (
int) $this->httpRequest->getQueryParams()[
'viewmode'] !== $this->selectedSorting
3061 $this->selectedSorting = (
int) $this->httpRequest->getQueryParams()[
'viewmode'];
3064 if (!in_array($this->selectedSorting, [
3069 $this->selectedSorting = $this->objProperties->getDefaultView();
3078 $this->selected_post_storage->set($this->objCurrentTopic->getId(), 0);
3079 $this->
ctrl->redirect($this,
'viewThread');
3084 $thr_pk = $this->objCurrentTopic->getId();
3086 $bottom_toolbar = clone $this->toolbar;
3087 $toolbar_items = [];
3090 $thread_control_session_values =
ilSession::get(
'thread_control');
3091 if (is_array($thread_control_session_values)) {
3092 if (!isset($thread_control_session_values[
'old'])) {
3093 $thread_control_session_values[
'old'] = $thr_pk;
3094 $thread_control_session_values[
'new'] = $thr_pk;
3095 ilSession::set(
'thread_control', $thread_control_session_values);
3096 } elseif (isset($thread_control_session_values[
'old']) && $thr_pk !== $thread_control_session_values[
'old']) {
3097 $thread_control_session_values[
'new'] = $thr_pk;
3098 ilSession::set(
'thread_control', $thread_control_session_values);
3102 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3103 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3106 $oForumObjects = $this->getForumObjects();
3107 $forumObj = $oForumObjects[
'forumObj'];
3108 $frm = $oForumObjects[
'frm'];
3109 $file_obj = $oForumObjects[
'file_obj'];
3111 $selected_draft_id = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
3112 if (isset($this->httpRequest->getQueryParams()[
'file'])) {
3113 $file_obj_for_delivery = $file_obj;
3117 $file_obj_for_delivery->deliverFile(
ilUtil::stripSlashes($this->httpRequest->getQueryParams()[
'file']));
3120 if ($this->objCurrentTopic->getId() === 0) {
3121 $this->
ctrl->redirect($this,
'showThreads');
3125 if (isset($this->httpRequest->getQueryParams()[
'page'])) {
3126 $pageIndex = max((
int) $this->httpRequest->getQueryParams()[
'page'], $pageIndex);
3129 if ($this->selected_post_storage->get($this->objCurrentTopic->getId()) > 0) {
3131 $this->selected_post_storage->get($this->objCurrentTopic->getId()),
3132 $this->is_moderator,
3136 $firstNodeInThread = $this->objCurrentTopic->getPostRootNode();
3144 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentTopic);
3147 'tpl.forums_threads_view.html',
3150 'components/ILIAS/Forum'
3155 $order_field =
'frm_posts_tree.rgt';
3156 $this->objCurrentTopic->setOrderDirection(
'DESC');
3157 $threadContentTemplate->setVariable(
'LIST_TYPE', $this->viewModeOptions[$this->selectedSorting]);
3159 $order_field =
'frm_posts.pos_date';
3160 $this->objCurrentTopic->setOrderDirection(
3163 $threadContentTemplate->setVariable(
'LIST_TYPE', $this->sortationOptions[$this->selectedSorting]);
3165 $this->objCurrentTopic->setOrderField($order_field);
3168 $subtree_nodes = $this->objCurrentTopic->getPostTree($firstNodeInThread);
3169 $numberOfPostings = count($subtree_nodes);
3180 $append =
'_' . $this->objCurrentTopic->getId() .
3181 ($this->objCurrentPost->getId() !== 0 ?
'_' . $this->objCurrentPost->getId() :
'');
3182 $this->tpl->setLoginTargetPar(
'frm_' . $this->
object->getRefId() . $append);
3185 if (!in_array($this->requestAction, [
'showreply',
'showedit'])) {
3188 foreach ($mobs as $mob) {
3195 }
catch (Exception) {
3199 if (!$this->getCreationMode() && $this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3201 $this->
object->getRefId(),
3202 ilLink::_getLink($this->object->getRefId(),
'frm'),
3207 $this->prepareThreadScreen($forumObj);
3210 if (isset($this->httpRequest->getQueryParams()[
'anchor'])) {
3211 $threadContentTemplate->setVariable(
'JUMP2ANCHOR_ID', (
int) $this->httpRequest->getQueryParams()[
'anchor']);
3213 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
3216 $this->
object->getType(),
3217 $this->object->getRefId(),
3218 $this->object->getId(),
3219 $this->user->getId()
3222 if ($firstNodeInThread) {
3223 $this->objCurrentTopic->updateVisits();
3225 $this->tpl->setTitle($this->
lng->txt(
'forums_thread') .
' "' . $this->objCurrentTopic->getSubject() .
'"');
3227 $this->
locator->addRepositoryItems();
3228 $this->
locator->addItem($this->
object->getTitle(), $this->ctrl->getLinkTarget($this,
''),
'_top');
3229 $this->tpl->setLocator();
3231 if (!$this->
user->isAnonymous() &&
3232 $forumObj->getCountUnread($this->user->getId(), $this->objCurrentTopic->getId(),
true)) {
3233 $this->
ctrl->setParameter($this,
'mark_read',
'1');
3234 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3236 $mark_thr_read_button = $this->uiFactory->button()->standard(
3237 $this->
lng->txt(
'forums_mark_read'),
3238 $this->ctrl->getLinkTarget($this,
'viewThread')
3241 $toolbar_items[] = $mark_thr_read_button;
3243 $this->
ctrl->clearParameters($this);
3246 $this->
ctrl->setParameterByClass(ilForumExportGUI::class,
'print_thread', $this->objCurrentTopic->getId());
3247 $this->
ctrl->setParameterByClass(
3248 ilForumExportGUI::class,
3250 $this->objCurrentTopic->getForumId()
3253 if ($numberOfPostings > 0 && $this->
settings->get(
'forum_enable_print',
'0')) {
3254 $print_thr_button = $this->uiFactory->button()->standard(
3255 $this->
lng->txt(
'forums_print_thread'),
3256 $this->ctrl->getLinkTargetByClass(ilForumExportGUI::class,
'printThread')
3258 $toolbar_items[] = $print_thr_button;
3262 $this->
ctrl->clearParametersByClass(ilForumExportGUI::class);
3264 $this->addHeaderAction();
3266 if (isset($this->httpRequest->getQueryParams()[
'mark_read'])) {
3267 $forumObj->markThreadRead($this->
user->getId(), $this->objCurrentTopic->getId());
3268 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_thread_marked'),
true);
3272 !$this->isTopLevelReplyCommand() &&
3273 !$this->objCurrentTopic->isClosed() &&
3274 $this->access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
3275 $this->
ctrl->setParameter($this,
'action',
'showreply');
3276 $this->
ctrl->setParameter($this,
'pos_pk', $firstNodeInThread->getId());
3277 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3278 $this->
ctrl->setParameter(
3281 (
int) ($this->httpRequest->getQueryParams()[
'page'] ?? 0)
3283 $this->
ctrl->setParameter(
3286 $this->getOrderByParam()
3288 if ($numberOfPostings > 0) {
3289 $reply_button = $this->uiFactory->button()->standard(
3290 $this->
lng->txt(
'add_new_answer'),
3291 $this->ctrl->getLinkTarget($this,
'createTopLevelPost',
'frm_page_bottom')
3294 $reply_button = $this->uiFactory->button()->primary(
3295 $this->
lng->txt(
'add_new_answer'),
3296 $this->ctrl->getLinkTarget($this,
'createTopLevelPost',
'frm_page_bottom')
3299 $this->
ctrl->clearParameters($this);
3300 array_unshift($toolbar_items, $reply_button);
3304 if ($numberOfPostings === 0 && $firstNodeInThread->getId() === 0) {
3305 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_no_posts_available'));
3308 $pageSize = $frm->getPageHits();
3310 if ($numberOfPostings > $pageSize) {
3311 $this->
ctrl->setParameter($this,
'ref_id', $this->
object->getRefId());
3312 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3313 $this->
ctrl->setParameter(
3316 $this->getOrderByParam()
3318 $paginationUrl = $this->
ctrl->getLinkTarget($this,
'viewThread',
'');
3319 $this->
ctrl->clearParameters($this);
3321 $pagination = $this->uiFactory->viewControl()
3323 ->withTargetURL($paginationUrl,
'page')
3324 ->withTotalEntries($numberOfPostings)
3325 ->withPageSize($pageSize)
3326 ->withMaxPaginationButtons(10)
3327 ->withCurrentPage($pageIndex);
3329 $threadContentTemplate->setVariable(
'THREAD_MENU', $this->uiRenderer->render(
3332 $threadContentTemplate->setVariable(
'THREAD_MENU_BOTTOM', $this->uiRenderer->render(
3338 $draftsObjects = [];
3339 if ($doRenderDrafts) {
3341 $this->
user->getId(),
3342 $this->objCurrentTopic->getId(),
3343 $this->selectedSorting
3347 $pagedPostings = array_slice($subtree_nodes, $pageIndex * $pageSize, $pageSize);
3349 $this->ensureValidPageForCurrentPosting($subtree_nodes, $pagedPostings, $pageSize, $firstNodeInThread);
3351 $this->preloadPostingFileResources($pagedPostings, $draftsObjects);
3352 if ($doRenderDrafts && $pageIndex === 0 &&
3354 foreach ($draftsObjects as $draft) {
3355 $referencePosting = array_values(array_filter(
3358 ))[0] ?? $firstNodeInThread;
3360 $this->renderDraftContent(
3361 $threadContentTemplate,
3362 $this->requestAction,
3369 foreach ($pagedPostings as $node) {
3370 $this->
ctrl->clearParameters($this);
3372 if (!$this->isTopLevelReplyCommand() && $this->objCurrentPost->getId() === $node->getId() &&
3373 ($this->is_moderator || $node->isActivated() || $node->isOwner($this->user->getId()))) {
3374 if (!$this->objCurrentTopic->isClosed() && in_array($this->requestAction, [
3378 $this->renderPostingForm($threadContentTemplate, $frm, $node, $this->requestAction);
3379 } elseif ($this->requestAction ===
'censor' &&
3380 !$this->objCurrentTopic->isClosed() && $this->is_moderator) {
3381 $threadContentTemplate->setVariable(
'FORM', $this->getCensorshipFormHTML());
3385 $this->renderPostContent($threadContentTemplate, $node, $this->requestAction, $pageIndex, $postIndex);
3387 $this->renderDraftContent(
3388 $threadContentTemplate,
3389 $this->requestAction,
3391 $draftsObjects[$node->getId()] ?? []
3400 $doRenderDrafts && $pageIndex === max(0, (
int) (ceil($numberOfPostings / $pageSize) - 1))
3402 foreach ($draftsObjects as $draft) {
3403 $referencePosting = array_values(array_filter(
3406 ))[0] ?? $firstNodeInThread;
3408 $this->renderDraftContent(
3409 $threadContentTemplate,
3410 $this->requestAction,
3418 $firstNodeInThread instanceof
ilForumPost && $doRenderDrafts &&
3421 $this->renderDraftContent(
3422 $threadContentTemplate,
3423 $this->requestAction,
3425 $draftsObjects[$firstNodeInThread->getId()] ?? []
3430 !$this->objCurrentTopic->isClosed() &&
3431 in_array($this->
ctrl->getCmd(), [
'createTopLevelPost',
'saveTopLevelPost',
'saveTopLevelDraft'],
true) &&
3432 $this->access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
3434 $this->objCurrentPost->setId($firstNodeInThread->getId());
3435 $form = $this->getReplyEditForm();
3437 if (in_array($this->
ctrl->getCmd(), [
'saveTopLevelPost',
'saveTopLevelDraft'])) {
3438 $form->setValuesByPost();
3440 $threadContentTemplate->setVariable(
'BOTTOM_FORM', $form->getHTML());
3443 $threadContentTemplate->setCurrentBlock(
'posts_no');
3444 $threadContentTemplate->setVariable(
3445 'TXT_MSG_NO_POSTS_AVAILABLE',
3446 $this->
lng->txt(
'forums_posts_not_available')
3448 $threadContentTemplate->parseCurrentBlock();
3451 $to_top_button = $this->uiFactory->button()
3452 ->standard($this->
lng->txt(
'top_of_page'),
'#frm_page_top');
3453 $bottom_toolbar->addComponent($to_top_button);
3454 if ($numberOfPostings > 0) {
3455 $threadContentTemplate->setVariable(
'TOOLBAR_BOTTOM', $bottom_toolbar->getHTML());
3458 if ($toolbar_items !== []) {
3459 foreach ($toolbar_items as $component_index => $item) {
3460 $this->toolbar->addComponent($item);
3461 $bottom_toolbar->addComponent($item);
3462 if ($component_index === 0 && $numberOfPostings > 0) {
3463 $this->renderViewModeControl($this->selectedSorting);
3465 $this->renderSortationControl($this->selectedSorting);
3471 $this->tpl->setPermanentLink(
3472 $this->
object->getType(),
3473 $this->object->getRefId(),
3474 (
string) $this->objCurrentTopic->getId()
3477 $this->tpl->addOnLoadCode(
3479 document.querySelectorAll(
'.ilFrmPostContent img').forEach((img) => {
3480 const maxWidth = img.getAttribute(
'width');
3481 const maxHeight = img.getAttribute(
'height');
3484 img.style.maxWidth = maxWidth +
'px';
3485 img.removeAttribute(
'width');
3489 img.style.maxHeight = maxHeight +
'px';
3490 img.removeAttribute(
'height');
3497 $info = $this->getResetLimitedViewInfo();
3500 $this->tpl->setContent((
$info ??
'') . $threadContentTemplate->get() . $this->getModalActions());
3505 if ($currentViewMode === 3) {
3506 $currentViewMode = 2;
3508 $translationKeys = [];
3509 foreach ($this->viewModeOptions as $sortingConstantKey => $languageKey) {
3510 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3511 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
3512 $this->
ctrl->setParameter($this,
'viewmode', $sortingConstantKey);
3514 $translationKeys[$this->
lng->txt($languageKey)] = $this->
ctrl->getLinkTarget(
3520 $this->
ctrl->clearParameters($this);
3527 $sortViewControl = $this->uiFactory
3529 ->mode($translationKeys, $this->
lng->txt($this->viewModeOptions[$currentViewMode]))
3530 ->withActive($this->
lng->txt($this->viewModeOptions[$currentViewMode]));
3531 $this->
toolbar->addComponent($sortViewControl);
3536 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3537 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
3538 $target = $this->
ctrl->getLinkTarget(
3544 $translatedSortationOptions = array_map(fn($value):
string => $this->
lng->txt($value), $this->sortationOptions);
3546 $sortingDirectionViewControl = $this->uiFactory
3548 ->sortation($translatedSortationOptions, (
string) $currentSorting)
3549 ->withTargetURL($target,
'viewmode');
3550 $this->
toolbar->addComponent($sortingDirectionViewControl);
3555 return (
new \
ILIAS\
components\Forum\Subject\PostingReplySubjectBuilder(
3556 $this->
lng->txt(
'post_reply'),
3557 $this->lng->txt(
'post_reply_count')
3558 ))->build($this->objCurrentPost->getSubject());
3565 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
3567 $backurl = $this->
http->wrapper()->query()->retrieve(
3569 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always(
'')])
3573 $add = $this->getUserProfileAdditional($this->
object->getRefId(),
$user_id);
3574 $profile_gui->setAdditional($add);
3576 $this->tpl->setContent($this->
ctrl->getHTML($profile_gui));
3579 protected function getUserProfileAdditional(
int $a_forum_ref_id,
int $a_user_id): array
3581 if (!$this->
access->checkAccess(
'read',
'', $a_forum_ref_id)) {
3582 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3587 if ($ref_obj->getType() ===
'frm') {
3589 $frm = $forumObj->Forum;
3590 $frm->setForumId($forumObj->getId());
3591 $frm->setForumRefId($forumObj->getRefId());
3596 if ($this->
access->checkAccess(
'moderate_frm',
'', $a_forum_ref_id)) {
3597 $numPosts = $frm->countUserArticles($a_user_id);
3599 $numPosts = $frm->countActiveUserArticles($a_user_id);
3602 return [$this->
lng->txt(
'forums_posts') => $numPosts];
3607 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3608 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3613 $thread_ids = $this->retrieveThreadIds();
3614 $cmd = $this->
ctrl->getCmd();
3617 if ($thread_ids !== []) {
3618 if ($cmd ===
'move') {
3619 if ($this->is_moderator) {
3621 $this->moveThreadsObject();
3623 } elseif ($cmd ===
'enable_notifications' && (
int) $this->
settings->get(
'forum_notification',
'0') !== 0) {
3624 foreach ($thread_ids as $thread_id) {
3626 $this->ensureThreadBelongsToForum($this->
object->getId(), $tmp_obj);
3627 $tmp_obj->enableNotification($this->
user->getId());
3630 $this->
ctrl->redirect($this,
'showThreads');
3631 } elseif ($cmd ===
'disable_notifications' && (
int) $this->
settings->get(
'forum_notification',
'0') !== 0) {
3632 foreach ($thread_ids as $thread_id) {
3634 $this->ensureThreadBelongsToForum($this->
object->getId(), $tmp_obj);
3635 $tmp_obj->disableNotification($this->
user->getId());
3638 $this->
ctrl->redirect($this,
'showThreads');
3639 } elseif ($cmd ===
'close') {
3640 if ($this->is_moderator) {
3641 foreach ($thread_ids as $thread_id) {
3643 $this->ensureThreadBelongsToForum($this->
object->getId(), $tmp_obj);
3647 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'selected_threads_closed'),
true);
3648 $this->
ctrl->redirect($this,
'showThreads');
3649 } elseif ($cmd ===
'reopen') {
3650 if ($this->is_moderator) {
3651 foreach ($thread_ids as $thread_id) {
3653 $this->ensureThreadBelongsToForum($this->
object->getId(), $tmp_obj);
3658 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'selected_threads_reopened'),
true);
3659 $this->
ctrl->redirect($this,
'showThreads');
3660 } elseif ($cmd ===
'makesticky') {
3661 if ($this->is_moderator) {
3662 $message = $this->
lng->txt(
'sel_threads_make_sticky');
3664 foreach ($thread_ids as $thread_id) {
3666 $this->ensureThreadBelongsToForum($this->
object->getId(), $tmp_obj);
3667 $makeSticky = $tmp_obj->makeSticky();
3669 $message = $this->
lng->txt(
'sel_threads_already_sticky');
3673 if ($message !==
null) {
3674 $this->tpl->setOnScreenMessage(
'info', $message,
true);
3676 $this->
ctrl->redirect($this,
'showThreads');
3677 } elseif ($cmd ===
'unmakesticky' || $cmd ===
'make_topics_non_sticky') {
3678 if ($this->is_moderator) {
3679 $message = $this->
lng->txt(
'sel_threads_make_unsticky');
3680 foreach ($thread_ids as $thread_id) {
3682 $this->ensureThreadBelongsToForum($this->
object->getId(), $tmp_obj);
3683 $unmakeSticky = $tmp_obj->unmakeSticky();
3684 if (!$unmakeSticky) {
3685 $message = $this->
lng->txt(
'sel_threads_already_unsticky');
3690 if ($message !==
null) {
3691 $this->tpl->setOnScreenMessage(
'info', $message,
true);
3693 $this->
ctrl->redirect($this,
'showThreads');
3694 } elseif ($cmd ===
'editThread') {
3695 if ($this->is_moderator) {
3696 $count = count($thread_ids);
3698 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_max_one_thread'),
true);
3699 $this->
ctrl->redirect($this,
'showThreads');
3701 $this->updateThreadObject();
3706 $this->
ctrl->redirect($this,
'showThreads');
3707 } elseif ($cmd ===
'confirmDeleteThreads') {
3708 $this->confirmDeleteThreadsObject();
3709 } elseif ($cmd ===
'mergeThreads') {
3710 $this->mergeThreadsObject();
3712 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'topics_please_select_one_action'),
true);
3713 $this->
ctrl->redirect($this,
'showThreads');
3716 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
3717 $this->
ctrl->redirect($this,
'showThreads');
3723 if (!$this->is_moderator) {
3724 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3727 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3728 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3732 if ($this->
http->wrapper()->post()->has(
'frm_ref_id')) {
3733 $frm_ref_id = $this->
http->wrapper()->post()->retrieve(
3738 $this->
error->raiseError(
'Please select a forum', $this->
error->MESSAGE);
3742 if (!is_array($threads2move) || $threads2move === []) {
3743 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
3744 $this->
ctrl->redirect($this,
'showThreads');
3747 if (!$this->
access->checkAccess(
'read',
'', (
int) $frm_ref_id)) {
3748 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3752 array_walk($threads2move,
function (
int $threadId) use (&$threads):
void {
3754 $this->ensureThreadBelongsToForum($this->
object->getId(), $thread);
3756 $threads[] = $threadId;
3759 if (isset($frm_ref_id) && (
int) $frm_ref_id) {
3760 $errorMessages = $this->
object->Forum->moveThreads(
3763 $this->ilObjDataCache->lookupObjId((
int) $frm_ref_id)
3766 if ([] !== $errorMessages) {
3767 $this->tpl->setOnScreenMessage(
'failure', implode(
'<br><br>', $errorMessages),
true);
3768 $this->
ctrl->redirect($this,
'showThreads');
3772 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'threads_moved_successfully'),
true);
3773 $this->
ctrl->redirect($this,
'showThreads');
3775 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'no_forum_selected'));
3776 $this->moveThreadsObject();
3783 $this->
ctrl->redirect($this,
'showThreads');
3788 if (!$this->is_moderator) {
3789 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3792 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3793 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3796 $frm_ref_id = $this->
http->wrapper()->post()->retrieve(
3798 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(
null)])
3802 if (!is_array($threads2move) || $threads2move === []) {
3803 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
3804 $this->
ctrl->redirect($this,
'showThreads');
3808 $isModerator = $this->is_moderator;
3809 array_walk($threads2move,
function (
int $threadId) use (&$threads, $isModerator):
void {
3811 $this->ensureThreadBelongsToForum($this->
object->getId(), $thread);
3813 $threads[] = $thread;
3817 $exp->setPathOpen($this->
object->getRefId());
3818 $exp->setNodeSelected(isset($frm_ref_id) && (
int) $frm_ref_id ? (
int) $frm_ref_id : 0);
3819 $exp->setCurrentFrmRefId($this->
object->getRefId());
3820 $exp->setHighlightedNode((
string) $this->
object->getRefId());
3821 if (!$exp->handleCommand()) {
3823 'tpl.forums_threads_move.html',
3826 'components/ILIAS/Forum'
3829 if (!$this->hideToolbar()) {
3830 $this->
toolbar->addButton($this->
lng->txt(
'back'), $this->ctrl->getLinkTarget($this));
3834 foreach ($threads as $thread) {
3835 $messages[] = $this->ui_factory->messageBox()->info(
3836 sprintf($this->
lng->txt(
'move_chosen_topics'), $thread->getSubject())
3839 $moveThreadTemplate->setVariable(
'THREAD_MESSAGE', $this->uiRenderer->render($messages));
3840 $moveThreadTemplate->setVariable(
'FRM_SELECTION_TREE', $exp->getHTML());
3841 $moveThreadTemplate->setVariable(
'CMD_SUBMIT',
'performMoveThreads');
3842 $moveThreadTemplate->setVariable(
'TXT_SUBMIT', $this->
lng->txt(
'move'));
3843 $moveThreadTemplate->setVariable(
'FORMACTION', $this->
ctrl->getFormAction($this,
'performMoveThreads'));
3845 $this->tpl->setContent($moveThreadTemplate->get());
3854 $this->objProperties->isAnonymized() &&
3855 (!$this->is_moderator || !$this->objProperties->getMarkModeratorPosts())
3861 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3862 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3865 $draftIds = array_filter((array) ($this->httpRequest->getParsedBody()[
'draft_ids'] ?? []));
3868 $checkedDraftIds = [];
3869 foreach ($draftIds as $draftId) {
3870 if (array_key_exists($draftId, $instances)) {
3871 $checkedDraftIds[] = $draftId;
3872 $draft = $instances[$draftId];
3874 $this->deleteMobsOfDraft($draft->getDraftId(), $draft->getPostMessage());
3876 $GLOBALS[
'ilAppEventHandler']->raise(
3877 'components/ILIAS/Forum',
3880 'draftObj' => $draft,
3881 'obj_id' => $this->
object->getId(),
3882 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
3887 $draftFileData->delete([$draft->getDraftId()]);
3889 $draft->deleteDraft();
3893 if (count($checkedDraftIds) > 1) {
3894 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'delete_drafts_successfully'),
true);
3896 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'delete_draft_successfully'),
true);
3898 $this->
ctrl->redirect($this,
'showThreads');
3903 $draftId = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
3904 $allowNotification = !$this->objProperties->isAnonymized() && !$this->
user->isAnonymous();
3907 if (!$this->
rbac->system()->checkAccess(
'internal_mail', $mail->getMailObjectReferenceId())) {
3908 $allowNotification =
false;
3913 $this->objProperties,
3914 $this->isWritingWithPseudonymAllowed(),
3926 $default_form->generateDefaultForm();
3928 $this->decorateWithAutosave($default_form);
3930 return $default_form;
3935 $draftId = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
3936 $allowNotification = !$this->objProperties->isAnonymized() && !$this->
user->isAnonymous();
3939 if (!$this->
rbac->system()->checkAccess(
'internal_mail', $mail->getMailObjectReferenceId())) {
3940 $allowNotification =
false;
3945 $this->objProperties,
3946 $this->isWritingWithPseudonymAllowed(),
3955 $minimal_form->generateMinimalForm();
3957 return $minimal_form;
3962 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3963 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3966 if (!$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId())) {
3967 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3970 $tpl =
new ilTemplate(
'tpl.create_thread_form.html',
true,
true,
'components/ILIAS/Forum');
3973 $accordion->setId(
'acc_' . $this->obj_id);
3976 $accordion->addItem($this->
lng->txt(
'new_thread_with_post'), $this->buildThreadForm()->getHTML());
3977 $accordion->addItem($this->
lng->txt(
'empty_thread'), $this->buildMinimalThreadForm()->getHTML());
3979 $tpl->
setVariable(
'CREATE_FORM', $accordion->getHTML());
3982 $this->tpl->setContent($tpl->
get());
3990 if (!$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
3991 !$this->access->checkAccess(
'read',
'', $this->object->getRefId())) {
3992 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3995 $frm = $this->
object->Forum;
3996 $frm->setForumId($this->
object->getId());
3997 $frm->setForumRefId($this->
object->getRefId());
3998 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
3999 $topicData = $frm->getOneTopic();
4001 $form = $this->buildThreadForm($createFromDraft);
4002 $minimal_form = $this->buildMinimalThreadForm($createFromDraft);
4004 if ($form->checkInput()) {
4005 $userIdForDisplayPurposes = $this->
user->getId();
4006 if ($this->isWritingWithPseudonymAllowed()) {
4007 $userIdForDisplayPurposes = 0;
4012 ($this->objProperties->isPostActivationEnabled() && !$this->is_moderator) ||
4013 $this->objCurrentPost->isAnyParentDeactivated()
4018 if ($createFromDraft) {
4020 $newThread->setForumId($topicData->getTopPk());
4023 $newThread->setSubject($this->handleFormInput($form->getInput(
'subject'),
false));
4026 $newPost = $frm->generateThread(
4035 $newThread->setForumId($topicData->getTopPk());
4036 $newThread->setThrAuthorId($this->
user->getId());
4037 $newThread->setDisplayUserId($userIdForDisplayPurposes);
4038 $newThread->setSubject($this->handleFormInput($form->getInput(
'subject'),
false));
4040 $form->getInput(
'alias'),
4041 $this->objProperties->isAnonymized()
4044 $newPost = $frm->generateThread(
4047 $form->getItemByPostVar(
'notify') && $form->getInput(
'notify') && !$this->user->isAnonymous(),
4055 $post_obj->setRCID($draft->
getRCID());
4056 $post_obj->update();
4059 if ($this->objProperties->isFileUploadAllowed()) {
4060 $file = $_FILES[
'userfile'];
4061 if (is_array($file) && !empty($file)) {
4063 $fileData->storeUploadedFiles();
4067 $frm->setDbTable(
'frm_data');
4068 $frm->setMDB2WhereCondition(
'top_pk = %s ', [
'integer'], [$topicData->getTopPk()]);
4069 $frm->updateVisits($topicData->getTopPk());
4071 if ($createFromDraft) {
4076 foreach ($mediaObjects as $mob) {
4085 $draftHistory->deleteHistoryByDraftIds([$draft->
getDraftId()]);
4089 $GLOBALS[
'ilAppEventHandler']->raise(
4090 'components/ILIAS/Forum',
4093 'object' => $this->
object,
4094 'ref_id' => $this->
object->getRefId(),
4095 'post' => $post_obj,
4096 'notify_moderators' => !$status
4100 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'forums_thread_new_entry'),
true);
4101 $this->
ctrl->redirect($this);
4104 $form->setValuesByPost();
4105 if (!$this->objProperties->isAnonymized()) {
4106 $form->getItemByPostVar(
'alias')->setValue($this->
user->getLogin());
4110 $accordion->setId(
'acc_' . $this->obj_id);
4112 $accordion->addItem($this->
lng->txt(
'new_thread_with_post'), $form->getHTML());
4113 $accordion->addItem($this->
lng->txt(
'empty_thread'), $minimal_form->getHTML());
4115 $this->tpl->setContent($accordion->getHTML());
4123 if (!$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4124 !$this->access->checkAccess(
'read',
'', $this->object->getRefId())) {
4125 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4128 $frm = $this->
object->Forum;
4129 $frm->setForumId($this->
object->getId());
4130 $frm->setForumRefId($this->
object->getRefId());
4131 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
4132 $topicData = $frm->getOneTopic();
4134 $form = $this->buildThreadForm();
4135 $minimal_form = $this->buildMinimalThreadForm();
4137 if ($minimal_form->checkInput()) {
4138 $userIdForDisplayPurposes = $this->
user->getId();
4139 if ($this->isWritingWithPseudonymAllowed()) {
4140 $userIdForDisplayPurposes = 0;
4145 ($this->objProperties->isPostActivationEnabled() && !$this->is_moderator) ||
4146 $this->objCurrentPost->isAnyParentDeactivated()
4152 $newThread->setForumId($topicData->getTopPk());
4153 $newThread->setThrAuthorId($this->
user->getId());
4154 $newThread->setDisplayUserId($userIdForDisplayPurposes);
4155 $newThread->setSubject($this->handleFormInput($minimal_form->getInput(
'subject'),
false));
4157 $minimal_form->getInput(
'alias'),
4158 $this->objProperties->isAnonymized()
4161 $frm->generateThread(
4170 $frm->setDbTable(
'frm_data');
4171 $frm->setMDB2WhereCondition(
'top_pk = %s ', [
'integer'], [$topicData->getTopPk()]);
4172 $frm->updateVisits($topicData->getTopPk());
4174 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'forums_thread_new_entry'),
true);
4175 $this->
ctrl->redirect($this);
4178 $form->setValuesByPost();
4180 if (!$this->objProperties->isAnonymized()) {
4181 $form->getItemByPostVar(
'alias')->setValue($this->
user->getLogin());
4185 $accordion->setId(
'acc_' . $this->obj_id);
4187 $accordion->addItem($this->
lng->txt(
'new_thread_with_post'), $form->getHTML());
4188 $accordion->addItem($this->
lng->txt(
'empty_thread'), $minimal_form->getHTML());
4190 $this->tpl->setContent($accordion->getHTML());
4196 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4200 $this->checkDraftAccess($draft);
4202 $this->createThread($draft,
true);
4210 $this->checkDraftAccess($draft);
4213 $this->createThread($draft);
4218 $this->createEmptyThread();
4223 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId()) || $this->user->isAnonymous()) {
4224 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4227 $frm = $this->
object->Forum;
4228 $frm->setForumId($this->
object->getId());
4229 $frm->enableForumNotification($this->
user->getId());
4231 if ($this->objCurrentTopic->getId() > 0) {
4232 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4233 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_enabled'),
true);
4234 $this->
ctrl->redirect($this,
'viewThread');
4237 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_enabled'));
4238 $this->showThreadsObject();
4243 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId()) || $this->user->isAnonymous()) {
4244 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4247 $frm = $this->
object->Forum;
4248 $frm->setForumId($this->
object->getId());
4249 $frm->disableForumNotification($this->
user->getId());
4251 if ($this->objCurrentTopic->getId() > 0) {
4252 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4253 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_disabled'),
true);
4254 $this->
ctrl->redirect($this,
'viewThread');
4257 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_disabled'));
4258 $this->showThreadsObject();
4267 if ($this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
4269 if ($news_set->get(
'enable_rss_for_internal')) {
4280 $this->
object->getTitle(),
4281 $this->ctrl->getLinkTarget($this),
4283 $this->object->getRefId()
4290 $a_text = str_replace([
'<',
'>'], [
'<',
'>'], $a_text);
4291 if ($a_stripslashes) {
4300 $a_text = str_replace([
'<',
'>'], [
'<',
'>'], $a_text);
4308 !$this->
access->checkAccess(
'visible',
'', $this->object->getRefId()) &&
4309 !$this->access->checkAccess(
'read',
'', $this->object->getRefId())
4311 $this->
error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
4314 if (strtolower($this->
ctrl->getCmd() ??
'') ===
'infoscreen') {
4315 $this->
ctrl->redirectByClass(ilInfoScreenGUI::class,
'showSummary');
4319 $info->enablePrivateNotes();
4325 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4326 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4329 if ($this->objCurrentPost->getId() > 0) {
4330 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
4332 $this->
object->markPostUnread($this->
user->getId(), $this->objCurrentPost->getId());
4334 $this->viewThreadObject();
4339 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4340 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4343 if ($this->objCurrentTopic->getId() > 0 && $this->objCurrentPost->getId() > 0) {
4344 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
4346 $this->
object->markPostRead(
4347 $this->
user->getId(),
4348 $this->objCurrentTopic->getId(),
4349 $this->objCurrentPost->getId()
4353 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4354 $this->
ctrl->redirect($this,
'viewThread');
4359 $lg = parent::initHeaderAction();
4365 if ($this->
user->isAnonymous() || !$this->access->checkAccess(
'read',
'', $this->object->getRefId())) {
4369 $frm = $this->
object->Forum;
4370 $frm->setForumId($this->
object->getId());
4371 $frm->setForumRefId($this->
object->getRefId());
4372 $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
4374 $are_notifications_enabled = $frm->isForumNotificationEnabled($this->
user->getId());
4375 $has_membership_enabled_parent_container = $this->
object->isParentMembershipEnabledContainer();
4376 $user_may_disable_notifcations = (
4377 $this->isUserAllowedToDeactivateNotification() ||
4378 !$has_membership_enabled_parent_container
4381 if ($this->objCurrentTopic->getId() > 0) {
4382 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4385 if (!$this->
user->isAnonymous()) {
4386 if ($has_membership_enabled_parent_container) {
4387 if ($are_notifications_enabled && $user_may_disable_notifcations) {
4388 $lg->addCustomCommand(
4389 $this->
ctrl->getLinkTarget($this,
'disableForumNotification'),
4390 'forums_disable_forum_notification'
4392 } elseif (!$are_notifications_enabled) {
4393 $lg->addCustomCommand(
4394 $this->
ctrl->getLinkTarget($this,
'enableForumNotification'),
4395 'forums_enable_forum_notification'
4398 } elseif ($are_notifications_enabled) {
4399 $lg->addCustomCommand(
4400 $this->
ctrl->getLinkTarget($this,
'disableForumNotification'),
4401 'forums_disable_forum_notification'
4404 $lg->addCustomCommand(
4405 $this->
ctrl->getLinkTarget($this,
'enableForumNotification'),
4406 'forums_enable_forum_notification'
4411 if ($are_notifications_enabled && $user_may_disable_notifcations && !$this->
user->isAnonymous()) {
4413 $frm_noti->setUserId($this->
user->getId());
4414 $interested_events = $frm_noti->readInterestedEvents();
4416 $events_form_builder = $this->eventsFormBuilder([
4417 'hidden_value' =>
'',
4425 $notificationsModal = $this->uiFactory->modal()->roundtrip(
4426 $this->
lng->txt(
'notification_settings'),
4427 [$events_form_builder->build()]
4428 )->withActionButtons([
4431 ->primary($this->
lng->txt(
'save'),
'#')
4432 ->withOnLoadCode(function (
string $id):
string {
4435 const button = document.getElementById('$id');
4436 if (!button) return;
4438 const modalDialog = button.closest('.modal-dialog');
4439 if (!modalDialog) return;
4441 const form = modalDialog.querySelector('.modal-body form');
4444 form.classList.add('ilForumNotificationSettingsForm');
4445 button.addEventListener('click', (event) => {
4446 event.preventDefault();
4456 $showNotificationSettingsBtn = $this->uiFactory->button()
4457 ->shy($this->
lng->txt(
'notification_settings'),
'#')
4459 $notificationsModal->getShowSignal()
4462 $lg->addCustomCommandButton($showNotificationSettingsBtn, $notificationsModal);
4465 $are_thread_notifications_enabled =
false;
4466 if (!$this->
user->isAnonymous() && $this->objCurrentTopic->getId() > 0) {
4467 $are_thread_notifications_enabled = $this->objCurrentTopic->isNotificationEnabled($this->
user->getId());
4468 if ($are_thread_notifications_enabled) {
4469 $lg->addCustomCommand(
4470 $this->
ctrl->getLinkTarget($this,
'toggleThreadNotification'),
4471 'forums_disable_notification'
4474 $lg->addCustomCommand(
4475 $this->
ctrl->getLinkTarget($this,
'toggleThreadNotification'),
4476 'forums_enable_notification'
4480 $this->
ctrl->setParameter($this,
'thr_pk',
'');
4482 if (!$this->
user->isAnonymous()) {
4483 if ($are_notifications_enabled || $are_thread_notifications_enabled) {
4487 $this->
lng->txt(
'frm_notification_activated')
4493 $this->
lng->txt(
'frm_notification_deactivated')
4507 if ($this->objCurrentTopic->getId() > 0) {
4508 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4512 $this->
ctrl->getFormAction($this,
'saveUserNotificationSettings'),
4521 $events_form_builder = $this->eventsFormBuilder();
4523 if ($this->httpRequest->getMethod() ===
'POST') {
4524 $form = $events_form_builder->build()->withRequest($this->httpRequest);
4525 $formData = $form->getData();
4529 foreach ($events_form_builder->getValidEvents() as $event) {
4530 $interested_events += isset($formData[$event]) && $formData[$event] ? $events_form_builder->getValueForEvent(
4536 $frm_noti->setUserId($this->
user->getId());
4537 $frm_noti->setInterestedEvents($interested_events);
4538 $frm_noti->updateInterestedEvents();
4541 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
4543 if ($this->objCurrentTopic->getId() > 0) {
4544 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4545 $this->
ctrl->redirect($this,
'viewThread');
4548 $this->
ctrl->redirect($this,
'showThreads');
4557 if (!$this->objProperties->isUserToggleNoti() &&
4558 $this->objProperties->getNotificationType() === NotificationType::ALL_USERS) {
4562 if ($this->objProperties->getNotificationType() === NotificationType::PER_USER &&
4563 $this->object->isParentMembershipEnabledContainer()) {
4565 $frm_noti->setUserId($this->
user->getId());
4567 return !$frm_noti->isUserToggleNotification();
4575 if (!$this->is_moderator) {
4576 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4579 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4580 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4583 $threadIdToMerge = $this->
http->wrapper()->query()->retrieve(
4586 $this->refinery->kindlyTo()->int(),
4587 $this->refinery->always(0)
4590 if ($threadIdToMerge <= 0) {
4591 $threadIds = array_values(
4592 array_filter(array_map(intval(...), (array) ($this->httpRequest->getParsedBody()[
'thread_ids'] ?? [])))
4594 if (count($threadIds) === 1) {
4595 $threadIdToMerge = current($threadIds);
4597 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'));
4598 $this->showThreadsObject();
4603 $frm = $this->
object->Forum;
4604 $frm->setForumId($this->
object->getId());
4605 $frm->setForumRefId($this->
object->getRefId());
4610 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'not_allowed_to_merge_into_another_forum'));
4611 $this->showThreadsObject();
4615 $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
4618 'tpl.forums_threads_liste.html',
4621 'components/ILIAS/Forum'
4624 $topicData = $frm->getOneTopic();
4625 if ($topicData->getTopPk() > 0) {
4626 $this->
ctrl->setParameter($this,
'merge_thread_id', $threadIdToMerge);
4630 (
int) $this->httpRequest->getQueryParams()[
'ref_id'],
4634 $tbl->setSelectedThread($threadToMerge);
4635 $tbl->setMapper($frm)->fetchData();
4637 $threadsTemplate->setVariable(
'THREADS_TABLE', $tbl->getHTML());
4638 $this->tpl->setContent($threadsTemplate->get());
4640 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
4641 $this->showThreadsObject();
4647 if (!$this->is_moderator) {
4648 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4651 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4652 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4655 $sourceThreadId = (
int) ($this->httpRequest->getQueryParams()[
'merge_thread_id'] ?? 0);
4656 $targetThreadIds = array_values(
4657 array_filter(array_map(intval(...), (array) ($this->httpRequest->getParsedBody()[
'thread_ids'] ?? [])))
4660 if ($sourceThreadId <= 0 || count($targetThreadIds) !== 1) {
4661 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
4662 $this->mergeThreadsObject();
4666 $targetThreadId = current($targetThreadIds);
4667 if ($sourceThreadId === $targetThreadId) {
4668 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'error_same_thread_ids'));
4669 $this->showThreadsObject();
4674 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'not_allowed_to_merge_into_another_forum'));
4675 $this->
ctrl->clearParameters($this);
4676 $this->showThreadsObject();
4681 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'switch_threads_for_merge'));
4684 $this->ensureThreadBelongsToForum($this->
object->getId(),
new ilForumTopic($sourceThreadId));
4685 $this->ensureThreadBelongsToForum($this->
object->getId(),
new ilForumTopic($targetThreadId));
4689 $c_gui->setFormAction($this->
ctrl->getFormAction($this,
'performMergeThreads'));
4690 $c_gui->setHeaderText($this->
lng->txt(
'frm_sure_merge_threads'));
4691 $c_gui->setCancel($this->
lng->txt(
'cancel'),
'showThreads');
4692 $c_gui->setConfirm($this->
lng->txt(
'confirm'),
'performMergeThreads');
4696 (
string) $sourceThreadId,
4701 (
string) $targetThreadId,
4704 $this->tpl->setContent($c_gui->getHTML());
4709 if (!$this->is_moderator) {
4710 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4713 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4714 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4717 $threadIds = array_values(
4718 array_filter(array_map(intval(...), (array) ($this->httpRequest->getParsedBody()[
'thread_ids'] ?? [])))
4720 if (count($threadIds) !== 2) {
4721 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
4722 $this->showThreadsObject();
4726 if ((
int) $threadIds[0] === (
int) $threadIds[1]) {
4727 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'error_same_thread_ids'));
4728 $this->showThreadsObject();
4734 $frm->setForumId($this->
object->getId());
4735 $frm->setForumRefId($this->
object->getRefId());
4737 $this->ensureThreadBelongsToForum($this->
object->getId(),
new ilForumTopic((
int) $threadIds[0]));
4738 $this->ensureThreadBelongsToForum($this->
object->getId(),
new ilForumTopic((
int) $threadIds[1]));
4740 $frm->mergeThreads((
int) $threadIds[0], (
int) $threadIds[1]);
4741 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'merged_threads_successfully'));
4743 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt($e->getMessage()));
4746 $this->showThreadsObject();
4751 $content = $this->getRightColumnHTML();
4752 if (!$this->
ctrl->isAsynch()) {
4753 $content = implode(
'', [
4758 $this->tpl->setRightContent($content);
4763 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4764 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4768 $this->checkDraftAccess($draft);
4770 if (!$fileData->deliverZipFile()) {
4771 $this->
ctrl->redirect($this);
4777 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4778 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4781 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
4784 if (!$fileData->deliverZipFile()) {
4785 $this->
ctrl->redirect($this);
4792 !$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4793 !$this->access->checkAccess(
'read',
'', $this->object->getRefId())) {
4794 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4797 $frm = $this->
object->Forum;
4798 $frm->setForumId($this->
object->getId());
4799 $frm->setForumRefId($this->
object->getRefId());
4802 $draftId = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
4805 $this->checkDraftAccess($draft);
4808 $do_history_check = (bool) ($this->httpRequest->getQueryParams()[
'hist_check'] ??
true);
4810 $this->doHistoryCheck($draft->getDraftId());
4814 $this->
ctrl->setParameter($this,
'draft_id', $draftId);
4816 $form = $this->buildThreadForm(
true);
4817 $form->setValuesByArray([
4818 'alias' => $draft->getPostUserAlias(),
4819 'subject' => $draft->getPostSubject(),
4821 'notify' => $draft->isNotificationEnabled() && !$this->user->isAnonymous(),
4824 'draft_id' => $draftId
4828 $this->tpl->setContent($form->getHTML() . $this->modal_history);
4834 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4837 $historyId = (
int) ($this->httpRequest->getQueryParams()[
'history_id'] ?? 0);
4840 $this->checkDraftAccess($history->getDraftId());
4842 $draft = $history->rollbackAutosave();
4843 if ($draft->getThreadId() === 0 && $draft->getPostId() === 0) {
4844 $this->
ctrl->setParameter($this,
'draft_id', $history->getDraftId());
4845 $this->
ctrl->redirect($this,
'editThreadDraft');
4848 $this->
ctrl->clearParameters($this);
4849 $this->
ctrl->setParameter($this,
'pos_pk', $draft->getPostId());
4850 $this->
ctrl->setParameter($this,
'thr_pk', $draft->getThreadId());
4851 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
4852 $this->
ctrl->setParameter($this,
'action',
'editdraft');
4856 $this->
ctrl->redirect($this,
'viewThread');
4862 !$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4863 !$this->access->checkAccess(
'read',
'', $this->object->getRefId())) {
4864 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4867 $autosave_draft_id = (
int) ($this->httpRequest->getParsedBody()[
'draft_id'] ?? 0);
4868 if ($autosave_draft_id <= 0) {
4869 $autosave_draft_id = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
4872 $frm = $this->
object->Forum;
4873 $frm->setForumId($this->
object->getId());
4874 $frm->setForumRefId($this->
object->getRefId());
4875 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
4876 $topicData = $frm->getOneTopic();
4878 $form = $this->buildThreadForm();
4879 if ($form->checkInput()) {
4880 if ($autosave_draft_id === 0) {
4882 $draft->setForumId($topicData->getTopPk());
4883 $draft->setThreadId(0);
4884 $draft->setPostId(0);
4887 $this->checkDraftAccess($draft);
4890 $draft->setPostSubject($this->handleFormInput($form->getInput(
'subject'),
false));
4893 $form->getInput(
'alias'),
4894 $this->objProperties->isAnonymized()
4896 $draft->setNotificationStatus($form->getInput(
'notify') && !$this->user->isAnonymous());
4897 $draft->setPostAuthorId($this->
user->getId());
4898 $draft->setPostDisplayUserId($this->isWritingWithPseudonymAllowed() ? 0 : $this->
user->getId());
4900 if ($autosave_draft_id === 0) {
4901 $draftId = $draft->saveDraft();
4903 $draft->updateDraft();
4904 $draftId = $draft->getDraftId();
4907 $GLOBALS[
'ilAppEventHandler']->raise(
4908 'components/ILIAS/Forum',
4911 'draftObj' => $draft,
4912 'obj_id' => $this->
object->getId(),
4913 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
4921 $files2delete = $form->getInput(
'del_file');
4922 if (is_array($files2delete) && $files2delete !== []) {
4923 $draftFileData->unlinkFilesByMD5Filenames($files2delete);
4926 if ($this->objProperties->isFileUploadAllowed()) {
4927 $file = $_FILES[
'userfile'];
4928 if (is_array($file) && !empty($file)) {
4929 $draftFileData->storeUploadedFiles();
4933 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
4934 $this->
ctrl->clearParameters($this);
4935 $this->
ctrl->redirect($this,
'showThreads');
4938 $this->requestAction = substr($this->requestAction, 6);
4939 $form->setValuesByPost();
4940 $this->
ctrl->setParameter($this,
'draft_id', $autosave_draft_id);
4941 $this->tpl->setContent($form->getHTML());
4947 !$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4948 !$this->access->checkAccess(
'read',
'', $this->object->getRefId())) {
4949 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4953 $this->checkDraftAccess($draft);
4955 $form = $this->buildThreadForm(
true);
4956 if ($form->checkInput()) {
4957 $draft->setPostSubject($this->handleFormInput($form->getInput(
'subject'),
false));
4960 $form->getInput(
'alias'),
4961 $this->objProperties->isAnonymized()
4963 $draft->setNotificationStatus($form->getInput(
'notify') && !$this->user->isAnonymous());
4964 $draft->setPostAuthorId($this->
user->getId());
4965 $draft->setPostDisplayUserId($this->isWritingWithPseudonymAllowed() ? 0 : $this->
user->getId());
4966 $draft->updateDraft();
4968 $GLOBALS[
'ilAppEventHandler']->raise(
4969 'components/ILIAS/Forum',
4972 'draftObj' => $draft,
4973 'obj_id' => $this->
object->getId(),
4974 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
4979 $form->getInput(
'message'),
4981 $draft->getDraftId(),
4983 $draft->getDraftId()
4988 $files2delete = $form->getInput(
'del_file');
4989 if (is_array($files2delete) && $files2delete !== []) {
4990 $draftFileData->unlinkFilesByMD5Filenames($files2delete);
4993 if ($this->objProperties->isFileUploadAllowed()) {
4994 $file = $_FILES[
'userfile'];
4995 if (is_array($file) && !empty($file) && isset($file[
'full_path'][0]) && !empty($file[
'full_path'][0])) {
4996 $draftFileData->storeUploadedFiles();
5000 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
5001 $this->
ctrl->clearParameters($this);
5002 $this->
ctrl->redirect($this,
'showThreads');
5005 $form->setValuesByPost();
5006 $this->
ctrl->setParameter($this,
'hist_check', 0);
5007 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5008 $this->editThreadDraftObject($form);
5013 $this->saveAsDraftObject();
5019 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
5020 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5023 $autosave_draft_id = $this->
http->wrapper()->post()->retrieve(
5026 $this->refinery->kindlyTo()->int(),
5027 $this->refinery->always(
null)
5031 if ($this->objCurrentTopic->getId() === 0) {
5032 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
5033 $this->
ctrl->redirect($this);
5036 if ($this->objCurrentTopic->isClosed()) {
5037 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
5038 $this->
ctrl->redirect($this);
5041 $oReplyEditForm = $this->getReplyEditForm();
5042 if ($oReplyEditForm->checkInput()) {
5043 if ($this->objCurrentPost->getId() === 0) {
5044 $this->requestAction =
'';
5045 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'),
true);
5046 $this->viewThreadObject();
5050 $oForumObjects = $this->getForumObjects();
5051 $frm = $oForumObjects[
'frm'];
5052 $frm->setMDB2WhereCondition(
' top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
5053 $topicData = $frm->getOneTopic();
5055 if ($this->requestAction ===
'ready_showreply') {
5056 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5057 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5060 if ($autosave_draft_id > 0) {
5062 $this->checkDraftAccess($draftObj->getDraftId());
5065 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
5066 $draftObj->setForumId($topicData->getTopPk());
5067 $draftObj->setThreadId($this->objCurrentTopic->getId());
5068 $draftObj->setPostId($this->objCurrentPost->getId());
5071 $draftObj->setPostSubject($this->handleFormInput($oReplyEditForm->getInput(
'subject'),
false));
5074 $oReplyEditForm->getInput(
'alias'),
5075 $this->objProperties->isAnonymized()
5077 $draftObj->setNotificationStatus($oReplyEditForm->getInput(
'notify') && !$this->user->isAnonymous());
5078 $draftObj->setPostNotificationStatus($oReplyEditForm->getInput(
'notify_post') && !$this->user->isAnonymous());
5080 $draftObj->setPostAuthorId($this->
user->getId());
5081 $draftObj->setPostDisplayUserId(($this->isWritingWithPseudonymAllowed() ? 0 : $this->
user->getId()));
5083 if ($autosave_draft_id === 0) {
5084 $draft_id = $draftObj->saveDraft();
5086 $draftObj->updateDraft();
5087 $draft_id = $draftObj->getDraftId();
5092 $oReplyEditForm->getInput(
'message'),
5099 if ($this->objProperties->isFileUploadAllowed()) {
5100 $file = $_FILES[
'userfile'];
5101 if (is_array($file) && !empty($file)) {
5103 $oFDForumDrafts->storeUploadedFiles();
5107 $GLOBALS[
'ilAppEventHandler']->raise(
5108 'components/ILIAS/Forum',
5111 'draftObj' => $draftObj,
5112 'obj_id' => $this->
object->getId(),
5113 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5118 if (is_array($frm_session_values)) {
5119 $frm_session_values[$this->objCurrentPost->getThreadId()][
'openTreeNodes'][] = $this->objCurrentPost->getId();
5123 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
5124 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5125 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5126 $this->
ctrl->redirect($this,
'viewThread');
5129 $oReplyEditForm->setValuesByPost();
5130 $this->requestAction = substr($this->requestAction, 6);
5132 $this->viewThreadObject();
5137 $this->doHistoryCheck($this->retrieveDraftId());
5138 $this->viewThreadObject();
5144 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
5145 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5148 if ($this->objCurrentTopic->getId() === 0) {
5149 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
5150 $this->
ctrl->redirect($this);
5153 if ($this->objCurrentTopic->isClosed()) {
5154 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
5155 $this->
ctrl->redirect($this);
5158 if ($this->objCurrentPost->getId() === 0) {
5159 $this->requestAction =
'';
5160 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'));
5161 $this->viewThreadObject();
5165 $oReplyEditForm = $this->getReplyEditForm();
5166 if ($oReplyEditForm->checkInput()) {
5167 $oForumObjects = $this->getForumObjects();
5168 $forumObj = $oForumObjects[
'forumObj'];
5170 if (!$this->
user->isAnonymous() && in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
5171 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5172 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5176 $this->
user->getId(),
5177 $this->objCurrentPost->getId(),
5178 $this->retrieveDraftId()
5181 $this->checkDraftAccess($draft);
5183 $draft->setPostSubject($this->handleFormInput($oReplyEditForm->getInput(
'subject'),
false));
5185 $oReplyEditForm->getInput(
'message')
5188 $oReplyEditForm->getInput(
'alias'),
5189 $this->objProperties->isAnonymized()
5191 $draft->setNotificationStatus($oReplyEditForm->getInput(
'notify') && !$this->user->isAnonymous());
5192 $draft->setUpdateUserId($this->
user->getId());
5193 $draft->setPostAuthorId($this->
user->getId());
5194 $draft->setPostDisplayUserId($this->isWritingWithPseudonymAllowed() ? 0 : $this->
user->getId());
5196 $draft->updateDraft();
5198 $GLOBALS[
'ilAppEventHandler']->raise(
5199 'components/ILIAS/Forum',
5202 'draftObj' => $draft,
5203 'obj_id' => $this->
object->getId(),
5204 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5210 foreach ($uploadedObjects as $mob) {
5215 $oReplyEditForm->getInput(
'message'),
5217 $draft->getDraftId()
5222 $file2delete = $oReplyEditForm->getInput(
'del_file');
5223 if (is_array($file2delete) && count($file2delete)) {
5224 $oFDForumDrafts->unlinkFilesByMD5Filenames($file2delete);
5227 if ($this->objProperties->isFileUploadAllowed()) {
5228 $file = $_FILES[
'userfile'];
5229 if (is_array($file) && !empty($file)) {
5230 $oFDForumDrafts->storeUploadedFiles();
5235 if (is_array($frm_session_values)) {
5236 $frm_session_values[$this->objCurrentPost->getThreadId()][
'openTreeNodes'][] = $this->objCurrentPost->getId();
5239 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
5240 $this->
ctrl->clearParameters($this);
5241 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5242 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5243 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5246 $this->
ctrl->clearParameters($this);
5247 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5248 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5249 $this->
ctrl->setParameter($this,
'draft_id', $this->retrieveDraftId());
5250 $this->
ctrl->setParameter($this,
'action',
'editdraft');
5251 $oReplyEditForm->setValuesByPost();
5252 $this->viewThreadObject();
5255 $this->
ctrl->clearParameters($this);
5256 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5257 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5258 $this->
ctrl->redirect($this,
'viewThread');
5265 foreach ($oldMediaObjects as $oldMob) {
5267 foreach ($curMediaObjects as $curMob) {
5268 if ($oldMob === $curMob) {
5283 $draft =
new ilForumPostDraft($this->
user->getId(), $this->objCurrentPost->getId(), $this->retrieveDraftId());
5284 $this->checkDraftAccess($draft);
5286 $this->deleteMobsOfDraft($draft->getDraftId(), $draft->getPostMessage());
5289 $objFileDataForumDrafts->delete([$draft->getDraftId()]);
5291 $GLOBALS[
'ilAppEventHandler']->raise(
5292 'components/ILIAS/Forum',
5295 'draftObj' => $draft,
5296 'obj_id' => $this->
object->getId(),
5297 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5300 $draft->deleteDraft();
5302 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'delete_draft_successfully'),
true);
5303 $this->
ctrl->clearParameters($this);
5304 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5305 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5306 $this->
ctrl->redirect($this,
'viewThread');
5311 if ($this->requestAction !==
'ready_showreply' &&
5313 $this->
access->checkAccess(
'read',
'', $this->object->getRefId()) &&
5314 $this->access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5317 $this->getReplyEditForm(),
5318 $this->objProperties,
5319 $this->objCurrentTopic,
5320 $this->objCurrentPost,
5321 fn(
string $message):
string => $this->handleFormInput($message),
5322 $this->retrieveDraftId(),
5327 $this->
http->saveResponse($this->
http->response()->withBody(
5328 \
ILIAS\Filesystem\Stream\Streams::ofString(json_encode(
5329 $action->executeAndGetResponseObject(),
5335 $this->
http->sendResponse();
5336 $this->
http->close();
5341 if ($this->requestAction !==
'ready_showreply' &&
5343 $this->
access->checkAccess(
'read',
'', $this->object->getRefId()) &&
5344 $this->access->checkAccess(
'add_thread',
'', $this->object->getRefId())) {
5347 $this->buildThreadForm(),
5348 $this->objProperties,
5349 $this->objCurrentTopic,
5350 $this->objCurrentPost,
5351 fn(
string $message):
string => $this->handleFormInput($message,
false),
5352 $this->retrieveDraftId(),
5357 $this->
http->saveResponse($this->
http->response()->withBody(
5358 \
ILIAS\Filesystem\Stream\Streams::ofString(json_encode(
5359 $action->executeAndGetResponseObject(),
5365 $this->
http->sendResponse();
5366 $this->
http->close();
5377 $draft_id = $this->retrieveDraftId();
5381 if (($this->objCurrentPost->getId() !== $node->
getId() || (
5382 !in_array($action, [
'showreply',
'showedit',
'censor',
'delete'],
true) &&
5383 !$this->displayConfirmPostActivation()
5384 )) && ($this->is_moderator || $node->
isActivated() || $node->
isOwner($this->user->getId()))) {
5385 if ($this->is_moderator && !$this->objCurrentTopic->isClosed() && !$node->
isActivated()) {
5386 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5388 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5389 $this->
ctrl->setParameter(
5392 $this->getOrderByParam()
5394 $primary_action = $this->
ctrl->getLinkTarget(
5396 'askForPostActivation',
5397 (
string) $node->
getId()
5399 $primary_action_language_id =
'activate_post';
5400 $this->
ctrl->clearParameters($this);
5404 $this->access->checkAccess(
'add_reply',
'', $this->object->getRefId())
5406 $this->
ctrl->setParameter($this,
'action',
'showreply');
5407 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5408 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5409 $this->
ctrl->setParameter(
5412 $this->getOrderByParam()
5415 $primary_action = $this->
ctrl->getLinkTarget(
5418 'reply_' . $node->
getId()
5420 $primary_action_language_id =
'reply_to_postings';
5421 $this->
ctrl->clearParameters($this);
5424 !$this->objCurrentTopic->isClosed() &&
5426 !$this->user->isAnonymous() &&
5427 ($node->
isOwner($this->user->getId()) || $this->is_moderator)
5429 $this->
ctrl->setParameter($this,
'action',
'showedit');
5430 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5432 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5433 $this->
ctrl->setParameter(
5436 $this->getOrderByParam()
5438 $actions[
'edit'] = $this->
ctrl->getLinkTarget($this,
'viewThread', (
string) $node->
getId());
5439 $this->
ctrl->clearParameters($this);
5441 if (!$this->
user->isAnonymous()) {
5442 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5444 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5445 $this->
ctrl->setParameter(
5448 $this->getOrderByParam()
5450 $this->
ctrl->setParameter($this,
'viewmode', $this->selectedSorting);
5452 $read_undread_txt =
'frm_mark_as_read';
5453 $read_undread_cmd =
'markPostRead';
5455 $read_undread_txt =
'frm_mark_as_unread';
5456 $read_undread_cmd =
'markPostUnread';
5458 $actions[$read_undread_txt] = $this->
ctrl->getLinkTarget(
5461 (
string) $node->
getId()
5464 $this->
ctrl->clearParameters($this);
5467 $this->
ctrl->setParameterByClass(ilForumExportGUI::class,
'top_pk', $node->
getForumId());
5468 $this->
ctrl->setParameterByClass(ilForumExportGUI::class,
'thr_pk', $node->
getThreadId());
5471 $this->
ctrl->clearParameters($this);
5474 !$this->objCurrentTopic->isClosed() &&
5475 !$this->user->isAnonymous() &&
5476 ($this->is_moderator || ($node->
isOwner($this->user->getId()) && !$node->
hasReplies()))
5478 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5480 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5481 $this->
ctrl->setParameter(
5484 $this->getOrderByParam()
5486 $actions[
'delete'] = $this->
ctrl->getFormAction($this,
'deletePosting');
5487 $this->
ctrl->clearParameters($this);
5489 if ($this->is_moderator && !$this->objCurrentTopic->isClosed()) {
5490 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5492 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5493 $this->
ctrl->setParameter(
5496 $this->getOrderByParam()
5499 $this->
ctrl->setParameter($this,
'action',
'viewThread');
5500 $actions[
'frm_revoke_censorship'] = $this->
ctrl->getFormAction($this,
'revokeCensorship');
5502 $actions[
'frm_censorship'] = $this->
ctrl->getFormAction($this,
'addCensorship');
5504 $this->
ctrl->clearParameters($this);
5507 } elseif ($draft_id !== $draft->getDraftId() || !in_array($action, [
'deletedraft',
'editdraft'])) {
5509 $this->
ctrl->setParameter($this,
'action',
'publishdraft');
5510 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5511 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5512 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5513 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5514 $this->
ctrl->setParameter(
5517 $this->getOrderByParam()
5519 $primary_action = $this->
ctrl->getLinkTarget($this,
'publishSelectedDraft', (
string) $node->
getId());
5520 $primary_action_language_id =
'publish';
5521 $this->
ctrl->clearParameters($this);
5523 $this->
ctrl->setParameter($this,
'action',
'editdraft');
5524 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5525 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5526 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5527 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5528 $this->
ctrl->setParameter(
5531 $this->getOrderByParam()
5533 $actions[
'edit'] = $this->
ctrl->getLinkTarget($this,
'editDraft',
'draft_edit_' . $draft->getDraftId());
5534 $this->
ctrl->clearParameters($this);
5536 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5537 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5538 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5539 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5540 $this->
ctrl->setParameter(
5543 $this->getOrderByParam()
5545 $actions[
'delete'] = $this->
ctrl->getFormAction($this,
'deletePostingDraft');
5546 $this->
ctrl->clearParameters($this);
5548 if ($draft_id !== 0 && $action ===
'editdraft') {
5554 if ($actions !== [] && !$this->objCurrentTopic->isClosed()) {
5556 foreach ($actions as $lng_id =>
$url) {
5557 if ($lng_id ===
'frm_revoke_censorship' || $lng_id ===
'frm_censorship') {
5558 $modalTemplate =
new ilTemplate(
'tpl.forums_censor_modal.html',
true,
true,
'components/ILIAS/Forum');
5559 $form_id = str_replace(
'.',
'_', uniqid(
'form',
true));
5560 $modalTemplate->setVariable(
'FORM_ID', $form_id);
5563 $modalTemplate->setVariable(
'BODY', $this->
lng->txt(
'forums_info_censor2_post'));
5565 $modalTemplate->setVariable(
'BODY', $this->
lng->txt(
'forums_info_censor_post'));
5566 $modalTemplate->touchBlock(
'message');
5569 $modalTemplate->setVariable(
'FORM_ACTION',
$url);
5571 $content = $this->uiFactory->legacy()->content($modalTemplate->get());
5572 $submitBtn = $this->uiFactory->button()->primary(
5573 $this->
lng->txt(
'submit'),
5576 static function (
string $id) use ($form_id):
string {
5579 const button = document.getElementById('$id');
5580 if (!button) return;
5582 const form = document.getElementById('$form_id');
5585 button.addEventListener('click', (event) => {
5586 event.preventDefault();
5593 $modal = $this->uiFactory->modal()->roundtrip(
5594 $this->
lng->txt($lng_id),
5596 )->withActionButtons([$submitBtn]);
5597 $items[] = $this->uiFactory->button()->shy($this->
lng->txt($lng_id),
'#')->withOnClick(
5598 $modal->getShowSignal()
5601 $this->modalActionsContainer[] = $modal;
5605 if ($lng_id ===
'delete') {
5606 $modal = $this->uiFactory->modal()->interruptive(
5607 $this->
lng->txt($lng_id),
5608 str_contains(
$url,
'deletePostingDraft') ?
5609 $this->
lng->txt(
'forums_info_delete_draft') :
5610 $this->lng->txt(
'forums_info_delete_post'),
5612 )->withActionButtonLabel(
5613 $this->
lng->txt(str_contains(
$url,
'deletePostingDraft') ?
'deletePostingDraft' :
'deletePosting')
5616 $items[] = $this->uiFactory->button()->shy($this->
lng->txt($lng_id),
'#')->withOnClick(
5617 $modal->getShowSignal()
5620 $this->modalActionsContainer[] = $modal;
5626 $items[] = $this->uiFactory->button()->shy($this->
lng->txt($lng_id),
$url);
5629 $dropdown = $this->uiFactory->dropdown()->standard($items);
5630 $render_action_buttons = [$dropdown];
5631 if (isset($primary_action, $primary_action_language_id)) {
5632 if ($primary_action_language_id ===
'activate_post') {
5633 $action_button = $this->addActivationFormModal($node);
5635 $action_button = $this->uiFactory->button()->standard(
5636 $this->
lng->txt($primary_action_language_id),
5640 $tpl->
setVariable(
'MAIN_ACTION', $this->uiRenderer->render($action_button));
5642 $tpl->
setVariable(
'DROPDOWN_ACTIONS', $this->uiRenderer->render($render_action_buttons));
5649 if (!$this->hasDraftAccess($draft)) {
5650 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5659 !$this->user->isAnonymous() &&
5660 $this->access->checkAccess(
'add_reply',
'', $this->object->getRefId()) &&
5671 $this->checkDraftAccess($draftId);
5675 if ($draftsFromHistory !== []) {
5676 $form_tpl =
new ilTemplate(
'tpl.restore_thread_draft.html',
true,
true,
'components/ILIAS/Forum');
5679 foreach ($draftsFromHistory as $history_instance) {
5681 $accordion->setId(
'acc_' . $history_instance->getHistoryId());
5683 if ($first_open ===
null) {
5684 $first_open = $history_instance->getHistoryId();
5688 $form_tpl->setCurrentBlock(
'list_item');
5692 $history_instance->getDraftDate(),
5695 $this->
ctrl->setParameter($this,
'history_id', $history_instance->getHistoryId());
5696 $header = $history_date .
': ' . $history_instance->getPostSubject();
5699 'tpl.restore_thread_draft_accordion_content.html',
5702 'components/ILIAS/Forum'
5704 $accordion_tpl->setVariable(
'MESSAGE', $message);
5705 $accordion_tpl->setVariable(
5707 $this->uiRenderer->render(
5708 $this->uiFactory->button()->standard(
5709 $this->lng->txt(
'restore'),
5710 $this->ctrl->getLinkTarget($this,
'restoreFromHistory')
5714 $accordion->addItem($header, $accordion_tpl->get());
5716 $form_tpl->setVariable(
'ACC_AUTO_SAVE', $accordion->getHTML());
5717 $form_tpl->parseCurrentBlock();
5720 $form_tpl->setVariable(
'RESTORE_DATA_EXISTS',
'found_threat_history_to_restore');
5722 $modal = $this->ui_factory->modal()->interruptive(
5723 $this->
lng->txt(
'restore_draft_from_autosave'),
5726 )->withAdditionalOnLoadCode(
function (
string $id):
string {
5727 return "document.getElementById('$id').dataset.modalId = 'frm_autosave_restore';";
5730 $this->modal_history = $this->ui_renderer->render($modal);
5738 $draft_id = $this->retrieveDraftId();
5739 if ($action ===
'showedit' && (
5740 (!$this->is_moderator && !$node->
isOwner($this->user->getId())) ||
5741 $this->user->isAnonymous() ||
5744 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5745 } elseif ($action ===
'showreply' && !$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5746 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5749 $tpl->
setVariable(
'REPLY_ANKER',
'reply_' . $this->objCurrentPost->getId());
5750 $oEditReplyForm = $this->getReplyEditForm();
5752 if ($action !==
'editdraft') {
5753 switch ($this->objProperties->getSubjectSetting()) {
5754 case 'add_re_to_subject':
5755 $subject = $this->getModifiedReOnSubject();
5758 case 'preset_subject':
5759 $subject = $this->objCurrentPost->getSubject();
5762 case 'empty_subject':
5770 if ($this->
ctrl->getCmd() ===
'savePost' || $this->ctrl->getCmd() ===
'saveAsDraft') {
5771 $oEditReplyForm->setValuesByPost();
5772 } elseif ($this->
ctrl->getCmd() ===
'quotePost') {
5780 $oEditReplyForm->setValuesByPost();
5781 $oEditReplyForm->getItemByPostVar(
'message')->setValue(
5786 $authorinfo->getAuthorName()
5787 ) .
"\n" . $oEditReplyForm->getInput(
'message'),
5792 $oEditReplyForm->setValuesByArray([
5793 'draft_id' => $draft_id,
5795 'subject' => $subject,
5805 if ($this->
ctrl->getCmd() ===
'savePost') {
5806 $oEditReplyForm->setValuesByPost();
5808 $oEditReplyForm->setValuesByArray([
5810 'subject' => $this->objCurrentPost->getSubject(),
5812 $this->objCurrentPost->getMessage(),
5815 'notify' => $this->objCurrentPost->isNotificationEnabled() && !$this->user->isAnonymous(),
5818 'draft_id' => $draft_id
5824 if (in_array($this->
ctrl->getCmd(), [
'saveDraft',
'updateDraft',
'publishDraft'])) {
5825 $oEditReplyForm->setValuesByPost();
5826 } elseif ($draft_id > 0) {
5828 $this->
user->getId(),
5829 $this->objCurrentPost->getId(),
5832 $oEditReplyForm->setValuesByArray([
5833 'alias' => $draftObject->getPostUserAlias(),
5834 'subject' => $draftObject->getPostSubject(),
5836 $draftObject->getPostMessage(),
5839 'notify' => $draftObject->isNotificationEnabled() && !$this->user->isAnonymous(),
5842 'draft_id' => $draft_id
5848 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5849 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5850 $this->
ctrl->setParameter($this,
'page', (
int) ($this->httpRequest->getQueryParams()[
'page'] ?? 0));
5851 $this->
ctrl->setParameter(
5854 $this->getOrderByParam()
5856 $this->
ctrl->setParameter(
5861 if ($action !==
'editdraft') {
5862 $tpl->
setVariable(
'FORM', $oEditReplyForm->getHTML());
5864 $this->
ctrl->clearParameters($this);
5869 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5872 $this->uiFactory->button()->standard(
5873 $this->
lng->txt(
'reset_limited_view_button'),
5874 $this->ctrl->getLinkTarget($this,
'resetLimitedView')
5878 return $this->uiRenderer->render(
5881 ->
info($this->
lng->txt(
'reset_limited_view_info'))
5882 ->withButtons($buttons)
5890 $this->refinery->byTrying([
5891 $this->refinery->kindlyTo()->string(),
5892 $this->refinery->always(
'')
5903 $collectionIds = [];
5905 foreach ($postings as $posting) {
5906 $rcid = $posting->getRCID();
5908 $collection_ids[] = $rcid;
5912 foreach ($draftsObjects as $draft) {
5913 $rcid = $draft->getRCID();
5915 $collection_ids[] = $rcid;
5919 if (!empty($collection_ids)) {
5920 $this->irss->preloadCollections(array_unique($collection_ids));
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
setVariable($variable, $value='')
Sets a variable value.
Builds a Color from either hex- or rgb values.
GUI class for public user profile presentation.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, $a_ext_rc=null, $a_ext_time=null)
This class represents an option in a checkbox group.
Column user interface class.
setRepositoryMode(bool $a_repositorymode)
setBlockProperty(string $a_block_type, string $a_property, string $a_value)
This function is supposed to be used for block type specific properties, that should be passed to ilB...
Class ilCommonActionDispatcherGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
Base class for ILIAS Exception handling.
Export User Interface Class.
Class ilForumDraftHistory.
static getInstancesByDraftId(int $draft_id)
Class ilForumExplorerGUI.
Forum export to HTML and Print.
@ilCtrl_Calls ilForumModeratorsGUI: ilRepositorySearchGUI
ilForumMoveTopicsExplorer
Class ilForumNotification.
const PRESENTATION_MODE_PRESENTATION
presentation mode for requesting
@ilCtrl_Calls ilForumPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI @ilCtrl_Calls ilForu...
static getThreadDraftData(int $post_author_id, int $forum_id)
static lookupAutosaveInterval()
static createDraftBackup(int $draft_id)
static isAutoSavePostDraftAllowed()
static isSavePostDraftAllowed()
static newInstanceByDraftId(int $draft_id)
isPostNotificationEnabled()
static getDraftInstancesByUserId(int $user_id)
static getSortedDrafts(int $usrId, int $threadId, int $sorting=ilForumProperties::VIEW_DATE_ASC)
setMessage(string $a_message)
isOwner(int $a_user_id=0)
setChangeDate(?string $a_changedate)
const PAGE_NAME_THREAD_OVERVIEW
static getInstance(int $a_obj_id=0)
const PAGE_SIZE_THREAD_OVERVIEW
@ilCtrl_Calls ilForumSettingsGUI: ilObjectContentStyleSettingsGUI
Class ilForumTopicTableGUI.
static lookupTitle(int $a_topic_id)
static lookupCreationDate(int $thread_id)
static lookupForumIdByTopicId(int $a_topic_id)
static getPublicUserAlias(string $user_alias, bool $is_anonymized)
static saveMediaObjects(string $post_message, string $target_type, int $target_id, int $direction=0)
static moveMediaObjects(string $post_message, string $source_type, int $source_id, string $target_type, int $target_id, int $direction=0)
Class Forum core functions for forum.
static _lookupObjIdForForumId(int $a_for_id)
prepareText(string $text, int $edit=0, string $quote_user='', string $type='')
static _isModerator(int $a_ref_id, int $a_usr_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByType(string $type)
Learning progress access checks.
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
const LP_CONTEXT_REPOSITORY
Class ilObjUserTrackingGUI.
Last visited history for repository items.
addItem(int $a_ref_id, string $a_link, string $a_type, string $a_title="", ?int $a_sub_obj_id=null, string $a_goto_link="")
Add an item to the stack.
A news item can be created by different sources.
static getFirstNewsIdForContext(int $a_context_obj_id, string $a_context_obj_type, int $a_context_sub_obj_id=0, string $a_context_sub_obj_type="")
Get first new id of news set related to a certain context.
This class represents a non editable value in a property form.
@ilCtrl_Calls ilObjForumGUI: ilPermissionGUI, ilForumExportGUI, ilInfoScreenGUI @ilCtrl_Calls ilObjFo...
setDisplayConfirmPostActivation(bool $status=false)
toggleExplorerNodeStateObject()
renderPostingForm(ilTemplate $tpl, ilForum $frm, ilForumPost $node, string $action)
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
afterSave(ilObject $new_object)
ForumThreadTableSessionStorage $forum_thread_table_session_storage
getOpenCloseActionForThread(ilForumTopic $forum_topic, int $ref_id)
getThreadProperties(ilForumTopic $forum_topic)
saveTopLevelDraftObject()
ilForumProperties $objProperties
ilForumPost $objCurrentPost
ilPropertyFormGUI $replyEditForm
renderSplitButton(ilTemplate $tpl, string $action, bool $is_post, ilForumPost $node, int $pageIndex=0, ?ilForumPostDraft $draft=null)
getResetLimitedViewInfo()
saveThreadAsDraftObject()
disableForumNotificationObject()
getStickyActionForThread(ilForumTopic $forum_topic, int $ref_id)
cancelMoveThreadsObject()
string $confirmation_gui_html
readonly bool $in_page_editor_style_context
checkDraftAccess(int|ilForumPostDraft $draft)
displayConfirmPostActivation()
toggleThreadNotificationObject()
getTabs()
@abstract overwrite in derived GUI class of your object type
isUserAllowedToDeactivateNotification()
markTopThreadInOverview(ilForumTopic $current_thread, Item $list_item)
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
static _goto($a_target, $a_thread=0, $a_posting=0)
renderDraftContent(ilTemplate $tpl, string $action, ilForumPost $referencePosting, array $drafts)
autosaveDraftAsyncObject()
decorateWithAutosave(ilPropertyFormGUI $form)
initHeaderAction(?string $sub_type=null, ?int $sub_id=null)
Add header action menu.
addDraftButtonIfDraftsExists(string $cmd)
getEditTitleModal(ilForumTopic $topic)
ILIAS GlobalScreen Services $globalScreen
publishSelectedDraftObject()
ilForumSettingsGUI $forum_settings_gui
autosaveThreadDraftAsyncObject()
addActivationFormModal(ilForumPost $node)
performMergeThreadsObject()
getSortationViewControl(int $offset, ThreadSortation $effective_sortation)
hideToolbar($a_flag=null)
setColumnSettings(ilColumnGUI $column_gui)
handleCensorship(bool $wasRevoked=false)
eventsFormBuilder(?array $predefined_values=null)
createThread(ilForumPostDraft $draft, bool $createFromDraft=false)
Refactored thread creation to method, refactoring to a separate class should be done in next refactor...
buildMinimalThreadForm(bool $isDraft=false)
updateCustom(ilPropertyFormGUI $form)
Insert custom update form values into object.
getSafePostCommands()
This method must return a list of safe POST commands.
hasDraftAccess(int|ilForumPostDraft $draft)
deliverDraftZipFileObject()
restoreFromHistoryObject()
renderThreadOverview(ilForum $frm, ForumDto $frm_object)
confirmMergeThreadsObject()
isWritingWithPseudonymAllowed()
editThreadDraftObject(?ilPropertyFormGUI $form=null)
ILIAS DI RBACServices $rbac
ilForumThreadSettingsSessionStorage $selected_post_storage
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
bool $display_confirm_post_activation
deletePostingDraftObject()
doHistoryCheck(int $draftId)
createTopLevelPostObject()
performDeleteThreadsObject()
confirmDeleteThreadDraftsObject()
prepareFormOutput(string $a_text)
publishThreadDraftObject()
deleteMobsOfDraft(int $draft_id, string $message)
ILIAS Style Content Object ObjectFacade $content_style_domain
ilObjectDataCache $ilObjDataCache
performThreadsActionObject()
askForPostActivationObject()
enableForumNotificationObject()
getLinkActionForThread(int $ref_id, string $title, string $cmd, ?int $thread_id=null)
performPostActivationObject()
retrieveDraftId(bool $from_post=false)
editStylePropertiesObject()
ilForumTopic $objCurrentTopic
renderPostContent(ilTemplate $tpl, ilForumPost $node, string $action, int $pageIndex, int $postIndex)
handleFormInput(string $a_text, bool $a_stripslashes=true)
performMoveThreadsObject()
ilNavigationHistory $ilNavigationHistory
ensureValidPageForCurrentPosting(array $subtree_nodes, array $pagedPostings, int $pageSize, ilForumPost $firstForumPost)
array $modalActionsContainer
publishDraftObject(bool $use_replyform=true)
buildThreadForm(bool $isDraft=false)
createEmptyThread()
Refactored thread creation to method, refactoring to a separate class should be done in next refactor...
deleteThreadDraftsObject()
saveUserNotificationSettingsObject()
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
preloadPostingFileResources(array $postings, array $draftsObjects)
updateThreadDraftObject()
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
renderSortationControl(int $currentSorting)
renderViewModeControl(int $currentViewMode)
ILIAS Style Content GUIService $content_style_gui
Psr Http Message ServerRequestInterface $httpRequest
__construct($data, int $id=0, bool $call_by_reference=true, bool $prepare_output=true)
getActionsForThreadOverview(int $ref_id, ilForumTopic $forum_topic)
static lookupForumIdByRefId(int $ref_id)
static lookupForumIdByObjId(int $obj_id)
static getSyntaxStylePath()
GUI class for the workflow of copying objects.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObjectGUI Basic methods of all Output classes.
Class ilObject Basic functions for all objects.
static _lookupObjectId(int $ref_id)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static _getMediaObjects(string $a_text, int $a_direction=0)
Returns all media objects found in the passed string.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getOverallRatingForObject(int $a_obj_id, string $a_obj_type, ?int $a_sub_obj_id=null, ?string $a_sub_obj_type=null, ?int $a_category_id=null)
Get overall rating for an object.
static getSearchBlockHTML(string $a_title)
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
get(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
Returns a block with all replacements done.
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This class represents a text area property in a property form.
This class represents a text property in a property form.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static switchColor(int $a_num, string $a_css1, string $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows)
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
This describes a Standard Dropdown.
Common interface to all items.
This is how the factory for UI elements looks.
An entity that renders components to a string output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
button(string $caption, string $cmd)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
Class ilChatroomConfigFileHandler \ILIAS\Chatroom\classes.
if(!file_exists('../ilias.ini.php'))