19declare(strict_types=1);
41 use ilForumRequestTrait;
73 public \ILIAS\DI\RBACServices
$rbac;
90 $this->httpRequest =
$DIC->http()->request();
92 $this->uiFactory =
$DIC->ui()->factory();
93 $this->uiRenderer =
$DIC->ui()->renderer();
96 $this->ilObjDataCache =
$DIC[
'ilObjDataCache'];
99 $this->
rbac = $DIC->rbac();
100 $this->
factory = $DIC->ui()->factory();
101 $this->
renderer = $DIC->ui()->renderer();
105 $this->
ctrl->saveParameter($this, [
'ref_id']);
106 $this->tpl->addJavaScript(
'assets/js/Basic.js');
108 $this->
lng->loadLanguageModule(
'forum');
109 $this->
lng->loadLanguageModule(
'content');
111 $ref_id = $this->retrieveIntOrZeroFrom($this->
http->wrapper()->query(),
'ref_id');
114 $this->is_moderator = $this->
access->checkAccess(
'moderate_frm',
'',
$ref_id);
117 $this->requestAction = (string) ($this->httpRequest->getQueryParams()[
'action'] ??
'');
118 $cs =
$DIC->contentStyle();
119 $this->content_style_gui = $cs->gui();
120 if (is_object($this->
object)) {
121 $this->content_style_domain = $cs->domain()->styleForRefId($this->
object->getRefId());
123 $this->in_page_editor_style_context = $this->
http->wrapper()->query()->has(
'page_editor_style');
124 $this->
ctrl->saveParameterByClass(ilObjectContentStyleSettingsGUI::class,
'page_editor_style');
136 if (!is_array($forumValues)) {
141 $threadId = $this->objCurrentTopic->getId();
142 if ($threadId > 0 && !isset($forumValues[$threadId])) {
143 $forumValues[(
int) $threadId] = [];
152 return $this->retrieveIntOrZeroFrom($this->
http->wrapper()->query(),
'thr_pk');
157 return $this->retrieveIntOrZeroFrom(
158 $from_post ? $this->
http->wrapper()->post() : $this->http->wrapper()->query(),
166 'frm_exp_' . $this->objCurrentTopic->getId(),
169 $this->objCurrentTopic,
170 $this->objCurrentTopic->getPostRootNode($this->is_moderator)
172 $exp->toggleExplorerNodeState();
176 array $subtree_nodes,
177 array $pagedPostings,
181 if ($firstForumPost->
getId() === $this->objCurrentPost->
getId()) {
185 if ($subtree_nodes !== [] && $this->objCurrentPost->getId() > 0) {
186 $isCurrentPostingInPage = array_filter($pagedPostings, fn(
ilForumPost $posting):
bool => (
187 $posting->
getId() === $this->objCurrentPost->getId()
190 if ([] === $isCurrentPostingInPage) {
191 $pageOfCurrentPosting = 0;
193 foreach ($subtree_nodes as $node) {
194 if ($i > 0 && $i % $pageSize === 0) {
195 ++$pageOfCurrentPosting;
198 if ($node->getId() === $this->objCurrentPost->getId()) {
205 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
206 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
207 $this->
ctrl->setParameter($this,
'page', $pageOfCurrentPosting);
208 $this->
ctrl->setParameter(
213 $this->
ctrl->redirect($this,
'viewThread', (
string) $this->objCurrentPost->getId());
222 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
231 $this->tpl->addJavaScript(
'assets/js/autosave_forum.js');
232 $autosave_cmd =
'autosaveDraftAsync';
233 if ($this->objCurrentPost->getId() === 0 && $this->objCurrentPost->getThreadId() === 0) {
234 $autosave_cmd =
'autosaveThreadDraftAsync';
236 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
237 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
238 $this->
ctrl->setParameter($this,
'draft_id', $this->retrieveDraftId());
240 $this->tpl->addOnLoadCode(
241 "il.Language.setLangVar('saving', " . json_encode($this->
lng->txt(
'saving'), JSON_THROW_ON_ERROR) .
');'
244 $this->tpl->addOnLoadCode(
'il.ForumDraftsAutosave.init(' . json_encode([
246 'draft_id' => $this->retrieveDraftId(),
247 'interval' => $interval * 1000,
248 'url' => $this->
ctrl->getFormAction($this, $autosave_cmd,
'',
true),
250 'form' =>
'#form_' . $form->
getId()
252 ], JSON_THROW_ON_ERROR) .
');');
259 strtolower($this->
ctrl->getCmd() ??
''),
260 array_map(
'strtolower', [
'createTopLevelPost',
'saveTopLevelPost',
'saveTopLevelDraft']),
268 'enableForumNotification',
269 'disableForumNotification',
270 'toggleThreadNotification',
271 'confirmDeleteThreadDrafts'
280 public function executeCommand(): void
282 $next_class = $this->
ctrl->getNextClass($this) ??
'';
283 $cmd = $this->
ctrl->getCmd() ??
'';
289 'showThreadNotification',
290 'performPostActivation',
291 'askForPostActivation',
292 'askForPostDeactivation',
293 'toggleThreadNotification',
298 'createTopLevelPost',
301 'autosaveDraftAsync',
302 'autosaveThreadDraftAsync',
306 'deliverDraftZipFile',
309 'deleteThreadDrafts',
311 'deletePostingDraft',
314 'confirmDeleteThreadsObject'
317 if (!in_array($cmd, $exclude_cmds,
true)) {
318 $this->prepareOutput();
321 if (!$this->creation_mode) {
322 $this->checkUsersViewMode();
323 $pos_pk = $this->retrieveIntOrZeroFrom($this->
http->wrapper()->query(),
'pos_pk');
325 $this->selected_post_storage->get($this->objCurrentTopic->getId()) > 0) {
327 $this->selected_post_storage->get($this->objCurrentTopic->getId()) ?? 0,
330 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
332 $this->selected_post_storage->set($this->objCurrentTopic->getId(), 0);
340 if (!$this->getCreationMode() && !$this->
ctrl->isAsynch() && $this->access->checkAccess(
343 $this->object->getRefId()
346 $this->
object->getRefId(),
347 ilLink::_getLink($this->object->getRefId(),
'frm'),
352 switch (strtolower($next_class)) {
353 case strtolower(ilForumPageGUI::class):
354 if (in_array(strtolower($cmd), array_map(
'strtolower', [
355 self::UI_CMD_COPAGE_DOWNLOAD_FILE,
356 self::UI_CMD_COPAGE_DISPLAY_FULLSCREEN,
357 self::UI_CMD_COPAGE_DOWNLOAD_PARAGRAPH,
360 if (!$this->checkPermissionBool(
'read')) {
361 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
363 } elseif (!$this->checkPermissionBool(
'write') || $this->
user->isAnonymous()) {
364 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
367 $this->content_style_gui->addCss($this->tpl, $this->ref_id);
368 $this->tpl->setCurrentBlock(
'SyntaxStyle');
370 $this->tpl->parseCurrentBlock();
373 $obj = $this->object;
382 $this->content_style_domain
385 $pageContent = $forwarder->forward();
386 if ($pageContent !==
'') {
387 $this->tpl->setContent($pageContent);
391 case strtolower(ilLearningProgressGUI::class):
393 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
396 $this->tabs_gui->activateTab(
'learning_progress');
398 $usrId = $this->
user->getId();
400 isset($this->request->getQueryParams()[
'user_id']) &&
401 is_numeric($this->request->getQueryParams()[
'user_id'])
403 $usrId = (
int) $this->request->getQueryParams()[
'user_id'];
408 $this->
object->getRefId(),
413 case strtolower(ilObjectContentStyleSettingsGUI::class):
414 $this->checkPermission(
'write');
416 if ($this->in_page_editor_style_context) {
417 $this->tabs_gui->setBackTarget(
418 $this->
lng->txt(
'back'),
426 $settings_gui = $this->content_style_gui
427 ->objectSettingsGUIForRefId(
431 $this->
ctrl->forwardCommand($settings_gui);
434 case strtolower(ilForumSettingsGUI::class):
436 $this->
ctrl->forwardCommand($forum_settings_gui);
439 case strtolower(ilRepositoryObjectSearchGUI::class):
440 $this->addHeaderAction();
441 $this->setSideBlocks();
442 $this->tabs_gui->activateTab(
'forums_threads');
443 $this->
ctrl->setReturn($this,
'view');
445 $this->
object->getRefId(),
449 $this->
ctrl->forwardCommand($search_gui);
452 case strtolower(ilPermissionGUI::class):
454 $this->
ctrl->forwardCommand($perm_gui);
457 case strtolower(ilForumExportGUI::class):
459 $this->
ctrl->forwardCommand($fex_gui);
460 $this->
http->close();
463 case strtolower(ilForumModeratorsGUI::class):
465 $this->
ctrl->forwardCommand($fm_gui);
468 case strtolower(ilInfoScreenGUI::class):
472 case strtolower(ilColumnGUI::class):
473 $this->showThreadsObject();
476 case strtolower(PublicProfileGUI::class):
477 $user = $this->retrieveIntOrZeroFrom($this->
http->wrapper()->query(),
'user');
479 $add = $this->getUserProfileAdditional($this->
object->getRefId(), $user);
480 $profile_gui->setAdditional($add);
481 $ret = $this->
ctrl->forwardCommand($profile_gui);
482 $this->tpl->setContent($ret);
485 case strtolower(ilObjectCopyGUI::class):
488 $this->
ctrl->forwardCommand($cp);
491 case strtolower(ilExportGUI::class):
492 $this->tabs_gui->activateTab(
'export');
494 $this->
ctrl->forwardCommand($exp);
497 case strtolower(ilRatingGUI::class):
498 if (!$this->objProperties->isIsThreadRatingEnabled() || $this->
user->isAnonymous()) {
499 $this->
error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
502 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
503 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
506 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentTopic);
509 $rating_gui->setObject(
511 $this->object->getType(),
512 $this->objCurrentTopic->getId(),
516 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
517 $this->
ctrl->forwardCommand($rating_gui);
521 $this->object->getType(),
522 $this->objCurrentTopic->getId(),
525 $this->objCurrentTopic->setAverageRating($avg[
'avg']);
526 $this->objCurrentTopic->update();
528 $this->
ctrl->redirect($this,
'showThreads');
531 case strtolower(ilCommonActionDispatcherGUI::class):
533 $this->
ctrl->forwardCommand($gui);
536 case strtolower(ilContainerNewsSettingsGUI::class):
537 $this->checkPermission(
'write');
542 $this->
lng->loadLanguageModule(
'cont');
544 $news_set_gui->setNewsBlockForced(
true);
545 $news_set_gui->setPublicNotification(
true);
546 $this->
ctrl->forwardCommand($news_set_gui);
550 if (in_array($cmd, [
'close',
'reopen',
'make_topics_non_sticky',
'makesticky',
'editThread',
'move'])) {
551 $cmd =
'performThreadsAction';
554 if ($cmd ===
null || $cmd ===
'') {
555 $cmd =
'showThreads';
564 if (!$this->in_page_editor_style_context &&
565 $cmd !==
'viewThreadObject' && $cmd !==
'showUserObject' && !in_array(
566 strtolower($next_class),
567 array_map(
'strtolower', [ilForumPageGUI::class]),
570 $this->addHeaderAction();
582 $this->forum_settings_gui->getCustomForm($a_form);
587 $this->forum_settings_gui->getCustomValues($a_values);
592 $this->forum_settings_gui->updateCustomValues($form);
597 if (!$this->is_moderator) {
598 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
601 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
602 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
605 if ($this->objCurrentTopic->getId() === 0) {
606 $this->showThreadsObject();
610 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentTopic);
612 $title = $this->getEditTitleModal($this->objCurrentTopic)->withRequest($this->
http->request())->getData();
613 if (array_key_exists(0, $title)) {
614 $new_subject = $title[0];
615 if ($new_subject !==
'') {
616 $this->objCurrentTopic->setSubject($new_subject);
617 $this->objCurrentTopic->updateThreadTitle();
618 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
621 $this->showThreadsObject();
627 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
628 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
631 $this->
object->markAllThreadsRead($this->
user->getId());
632 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_all_threads_marked_read'));
633 $this->showThreadsObject();
638 $this->setSideBlocks();
639 $this->getCenterColumnHTML();
644 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
645 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
648 $cmd = $this->
ctrl->getCmd();
649 $frm = $this->
object->Forum;
650 $frm->setForumId($this->
object->getId());
651 $frm->setForumRefId($this->
object->getRefId());
652 $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
654 $frm_object = $frm->getOneTopic();
655 if ($frm_object->getTopPk() > 0) {
656 $frm->setDbTable(
'frm_data');
657 $frm->setMDB2WhereCondition(
'top_pk = %s ', [
'integer'], [$frm_object->getTopPk()]);
658 $frm->updateVisits($frm_object->getTopPk());
662 $this->object->getRefId(),
663 $this->object->getId(),
667 if ($cmd !==
'showThreads') {
668 $cmd =
'showThreads';
671 $this->tpl->setPermanentLink($this->
object->getType(), $this->object->getRefId());
673 if (!$this->hideToolbar() && $this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId())) {
674 $btn = $this->uiFactory->button()
676 $this->
lng->txt(
'forums_new_thread'),
677 $this->ctrl->getLinkTarget($this,
'createThread')
679 $this->
toolbar->addStickyItem($btn);
683 $this->addDraftButtonIfDraftsExists($cmd);
686 if ($this->confirmation_gui_html ===
'' && !$this->
user->isAnonymous()) {
688 $this->
lng->txt(
'forums_mark_read'),
689 $this->ctrl->getLinkTarget($this,
'markAllRead')
691 $this->
ctrl->clearParameters($this);
694 if (!$this->
user->isAnonymous() && $this->access->checkAccess(
'write',
'', $this->ref_id)) {
695 $this->
lng->loadLanguageModule(
'cntr');
697 $this->uiFactory->button()->standard(
698 $this->lng->txt(
'cntr_text_media_editor'),
699 $this->ctrl->getLinkTargetByClass(ilForumPageGUI::class,
'edit')
704 $this->renderThreadOverview($frm, $frm_object);
710 $threads_page = $this->forum_thread_table_session_storage->fetchData($frm, $frm_object);
712 $sticky_threads = [];
713 $regular_threads = [];
715 if (count($threads_page->getForumTopics()) > 0) {
716 foreach ($threads_page->getForumTopics() as $thread) {
717 $ref_id = $this->
object->getRefId();
718 $subject = $thread->getSubject();
719 if ($thread->isClosed()) {
720 $subject .=
' (' . $this->
lng->txt(
'forums_closed') .
')';
723 $link = $this->getLinkActionForThread(
$ref_id, $subject,
'viewThread', $thread->getId());
724 $actions = $this->getActionsForThreadOverview(
$ref_id, $thread);
729 ->withActions($actions)
730 ->withProperties($this->getThreadProperties($thread));
731 $list_item = $this->markTopThreadInOverview($thread, $list_item);
732 if ($thread->isSticky()) {
733 $sticky_threads[] = $list_item;
735 $regular_threads[] = $list_item;
740 $sticky_threads_item_group =
null;
741 if (count($sticky_threads) > 0) {
742 $sticky_threads_item_group = $this->
factory->item()->group(
743 count($regular_threads) > 0 ? $this->
lng->txt(
'top_thema') :
'',
748 $regular_threads_item_group =
null;
749 if (count($regular_threads) > 0) {
750 $regular_threads_item_group = $this->
factory->item()->group(
751 count($sticky_threads) > 0 ? $this->
lng->txt(
'thema') :
'',
756 $url = $this->
http->request()->getRequestTarget();
759 $current_page = $this->
http->wrapper()->query()->retrieve(
765 $view_controls[] = $this->getSortationViewControl($this->forum_thread_table_session_storage->getThreadPage());
766 $view_controls[] = $this->
factory
772 ->withMaxPaginationButtons(5)
773 ->withCurrentPage($current_page);
775 $item_groups = array_filter([$sticky_threads_item_group, $regular_threads_item_group]);
776 if ($item_groups === []) {
777 $vc_container = $this->
factory->panel()->listing()->standard(
778 $this->
lng->txt(
'thread_overview'),
779 [$this->factory->item()->group($this->lng->txt(
'frm_no_threads'), [])]
782 $vc_container = $this->
factory->panel()->listing()->standard(
783 $this->
lng->txt(
'thread_overview'),
785 )->withViewControls($view_controls);
788 $default_html = $this->
renderer->render($vc_container);
789 $modals = $this->
renderer->render($this->modal_collection);
791 $this->initStyleSheets();
800 $this->content_style_domain
804 $this->tpl->setContent($forwarder->forward() . $default_html . $modals);
810 $this->
ctrl->setParameter($this,
'page', $offset);
813 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
814 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
815 $base_url = $this->
ctrl->getLinkTarget($this,
'showThreads');
817 $translationKeys = [];
818 foreach (ThreadSortation::cases() as $sortation) {
819 $this->
ctrl->setParameter($this,
'thread_sortation', $sortation->value);
820 $url = $this->
ctrl->getLinkTarget($this,
'showThreads');
822 $translationKeys[
$url] = $this->
lng->txt($sortation->languageId());
824 $this->
ctrl->clearParameters($this);
825 return $this->
factory->viewControl()->sortation(
827 current(array_keys($translationKeys))
829 ->withTargetURL($base_url,
'thread_sortation');
838 $query = $this->
http->wrapper()->query()->has(
'thr_pk');
839 $post = $this->
http->wrapper()->post()->has(
'thread_ids');
841 $thread_ids = $this->
http->wrapper()->post()->retrieve(
843 $this->
refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
846 $thread_ids = $this->
http->wrapper()->query()->retrieve(
848 $this->
refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
860 $this->
ctrl->setParameter($this,
'thr_pk', $forum_topic->
getId());
862 $is_top_thread = $forum_topic->
isSticky();
864 if ($unread_counter === 0) {
867 $unread =
' (' . $unread_counter .
' ' . $this->
lng->txt(
'unread') .
')';
878 $this->
lng->txt(
'forums_created_by') => $authorinfo->getAuthorName(),
879 $this->
lng->txt(
'forums_articles') => $forum_topic->
getNumPosts() . $unread,
880 $this->
lng->txt(
'forums_last_post') => $this->
object->Forum->convertDate($forum_topic->
getLastPost()->getCreateDate()),
884 if ($is_top_thread ===
true) {
885 $is_top_thread = [$this->
lng->txt(
'relevance') => $this->
lng->txt(
'sticky')];
886 $properties = array_merge($properties, $is_top_thread);
889 $rating_property = [];
890 if ($this->objProperties->isIsThreadRatingEnabled()) {
894 $this->object->getType(),
895 $forum_topic->
getId(),
898 $rating->setUserId($this->
user->getId());
899 $rating_property = [$this->
lng->txt(
'frm_rating') => $rating->getHTML()];
901 $this->
ctrl->setParameter($this,
'thr_pk',
null);
903 return array_merge($properties, $rating_property);
910 ?
int $thread_id =
null
912 $this->
ctrl->setParameter($this,
'ref_id',
$ref_id);
913 $this->
ctrl->setParameter($this,
'thr_pk', $thread_id);
914 $this->
ctrl->setParameter($this,
'page', 0);
915 $url = $this->
ctrl->getLinkTarget($this, $cmd);
916 $this->
ctrl->setParameter($this,
'ref_id',
null);
917 $this->
ctrl->setParameter($this,
'thr_pk',
null);
918 $this->
ctrl->setParameter($this,
'page',
null);
920 return $this->uiFactory->link()->standard($title,
$url);
925 $actions = $this->uiFactory->dropdown()->standard([]);
926 if ($this->is_moderator) {
927 $open_close = $this->getOpenCloseActionForThread($forum_topic,
$ref_id);
928 $stick_or_no_stick = $this->getStickyActionForThread($forum_topic,
$ref_id);
929 $edit_title_modal = $this->getEditTitleModal($forum_topic);
930 $this->modal_collection[] = $edit_title_modal;
931 $edit_title = $this->
factory->button()->shy($this->
lng->txt(
'frm_edit_title'),
'#')->withOnClick(
932 $edit_title_modal->getShowSignal()
935 $move = $this->getLinkActionForThread(
937 $this->
lng->txt(
'move_thread_to_forum'),
939 $forum_topic->
getId()
941 $merge = $this->getLinkActionForThread(
943 $this->
lng->txt(
'merge_posts_into_thread'),
945 $forum_topic->
getId()
947 $delete = $this->getLinkActionForThread(
949 $this->
lng->txt(
'delete_thread'),
950 'confirmDeleteThreads',
951 $forum_topic->
getId()
953 $actions = $this->uiFactory->dropdown()->standard([
968 $topic_id = $this->
refinery->kindlyTo()->string()->transform($topic->
getId());
969 $this->
ctrl->setParameter($this,
'thr_pk', (
string) $topic_id);
970 $target = $this->
ctrl->getLinkTargetByClass(
971 ilObjForumGUI::class,
974 $this->
ctrl->setParameter($this,
'thread_id',
null);
976 return $this->
factory->modal()->roundtrip(
977 $this->
lng->txt(
'frm_edit_title'),
980 $this->factory->input()->field()->text($this->lng->txt(
'frm_edit_title'))->withValue($topic->
getSubject()),
989 $this->
user->getId(),
992 if ($drafts === []) {
1005 $this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()),
1009 'tpl.forums_threads_liste.html',
1012 'components/ILIAS/Forum'
1014 $threadsTemplate->setVariable(
'THREADS_DRAFTS_TABLE', $this->uiRenderer->render($table->getComponent()));
1016 $draft_modal = $this->
factory->modal()->roundtrip(
1017 $this->
lng->txt(
'drafts'),
1018 [$this->factory->legacy()->content($threadsTemplate->get())]
1020 $this->modal_collection[] = $draft_modal;
1021 $edit_title = $this->
factory->button()->standard($this->
lng->txt(
'drafts'),
'#')->withOnClick(
1022 $draft_modal->getShowSignal()
1024 $this->
toolbar->addComponent($edit_title);
1029 return $this->getLinkActionForThread(
1031 $this->
lng->txt($forum_topic->
isSticky() ?
'make_topics_non_sticky' :
'make_topics_sticky'),
1032 $forum_topic->
isSticky() ?
'make_topics_non_sticky' :
'makesticky',
1033 $forum_topic->
getId()
1039 return $this->getLinkActionForThread(
1041 $this->
lng->txt($forum_topic->
isClosed() ?
'reopen_topics' :
'close_topics'),
1042 $forum_topic->
isClosed() ?
'reopen' :
'close',
1043 $forum_topic->
getId()
1051 if ($current_thread->isSticky()) {
1052 $df = new \ILIAS\Data\Factory();
1053 $list_item = $list_item->withColor($df->color(
'#B54F00'));
1061 $this->content_style_gui->addCss($this->tpl, $this->ref_id);
1062 $this->tpl->setCurrentBlock(
'SyntaxStyle');
1064 $this->tpl->parseCurrentBlock();
1069 $this->content_style_gui->redirectToObjectSettings();
1081 $frm = $this->
object->Forum;
1083 $draft_id = $this->retrieveDraftId();
1084 foreach ($drafts as $draft) {
1086 $filesOfDraft = $tmp_file_obj->getFilesOfPost();
1087 ksort($filesOfDraft);
1089 if ($action !==
'showdraft' && $filesOfDraft !== []) {
1090 foreach ($filesOfDraft as $file) {
1092 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1093 $this->
ctrl->setParameter($this,
'file', $file[
'md5']);
1094 $tpl->
setVariable(
'HREF_DOWNLOAD', $this->
ctrl->getLinkTarget($this,
'viewThread'));
1096 $this->
ctrl->setParameter($this,
'file',
'');
1097 $this->
ctrl->setParameter($this,
'draft_id',
'');
1098 $this->
ctrl->clearParameters($this);
1103 $tpl->
setVariable(
'TXT_ATTACHMENTS_DOWNLOAD', $this->
lng->txt(
'forums_attachments'));
1106 $this->uiRenderer->render(
1107 $this->uiFactory->symbol()->glyph()->attachment($this->lng->txt(
'forums_download_attachment'))
1110 if (count($filesOfDraft) > 1) {
1111 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1112 $download_zip_button = $this->uiFactory->button()
1114 $this->
lng->txt(
'download'),
1115 $this->ctrl->getLinkTarget($this,
'deliverDraftZipFile')
1117 $this->
ctrl->setParameter($this,
'draft_id',
'');
1118 $tpl->
setVariable(
'DOWNLOAD_ZIP', $this->uiRenderer->render($download_zip_button));
1123 $page = $this->
http->wrapper()->query()->retrieve(
1125 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
1128 $this->renderSplitButton(
1137 $rowCol =
'tblrowmarked';
1139 $depth = $referencePosting->
getDepth() - 1;
1145 $this->
ctrl->setParameter($this,
'pos_pk', $referencePosting->
getId());
1146 $this->
ctrl->setParameter($this,
'thr_pk', $referencePosting->
getThreadId());
1147 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1149 $backurl = urlencode($this->
ctrl->getLinkTarget($this,
'viewThread', (
string) $referencePosting->
getId()));
1151 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1152 $this->
ctrl->setParameter($this,
'thr_pk', $referencePosting->
getThreadId());
1153 $this->
ctrl->setParameter($this,
'user', $draft->getPostDisplayUserId());
1156 $draft->getPostAuthorId(),
1157 $draft->getPostDisplayUserId(),
1158 $draft->getPostUserAlias(),
1161 'href' => $this->ctrl->getLinkTarget($this,
'showUser')
1165 $this->
ctrl->clearParameters($this);
1167 if ($authorinfo->hasSuffix()) {
1168 $tpl->
setVariable(
'AUTHOR', $authorinfo->getSuffix());
1169 $tpl->
setVariable(
'USR_NAME', $draft->getPostUserAlias());
1171 $tpl->
setVariable(
'AUTHOR', $authorinfo->getLinkedAuthorShortName());
1172 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized()) {
1173 $tpl->
setVariable(
'USR_NAME', $authorinfo->getAuthorName(
true));
1176 $tpl->
setVariable(
'DRAFT_ANCHOR',
'draft_' . $draft->getDraftId());
1178 $tpl->
setVariable(
'USR_IMAGE', $authorinfo->getProfilePicture());
1184 $this->object->getRefId(),
1185 $draft->getPostAuthorId()
1187 if ($authorinfo->getAuthor()->getGender() ===
'f') {
1189 } elseif ($authorinfo->getAuthor()->getGender() ===
'm') {
1191 } elseif ($authorinfo->getAuthor()->getGender() ===
'n') {
1196 if ($draft->getUpdateUserId() > 0) {
1197 $draft->setPostUpdate($draft->getPostUpdate());
1199 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1200 $this->
ctrl->setParameter($this,
'thr_pk', $referencePosting->
getThreadId());
1202 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1205 $draft->getPostAuthorId(),
1207 $draft->getPostDisplayUserId(),
1208 $draft->getPostUserAlias(),
1210 [
'href' => $this->ctrl->getLinkTarget($this,
'showUser')]
1213 $this->
ctrl->clearParameters($this);
1217 $this->
lng->txt(
'edited_on') .
': ' . $frm->convertDate($draft->getPostUpdate()) .
' - ' . strtolower($this->
lng->txt(
'by'))
1219 $tpl->
setVariable(
'UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
1220 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
1221 $tpl->
setVariable(
'UPDATE_USR_NAME', $authorinfo->getAuthorName(
true));
1225 $draft->setPostMessage($frm->prepareText($draft->getPostMessage()));
1227 $tpl->
setVariable(
'SUBJECT', $draft->getPostSubject());
1228 $tpl->
setVariable(
'POST_DATE', $frm->convertDate($draft->getPostDate()));
1230 $tpl->
setVariable(
'POST_DRAFT_TEXT', $this->
lng->txt(
'post_draft_info'));
1232 if (!$referencePosting->
isCensored() || ($this->objCurrentPost->getId() === $referencePosting->
getId() && $action ===
'censor')) {
1235 $spanClass =
'moderator';
1238 if ($draft->getPostMessage() === strip_tags($draft->getPostMessage())) {
1240 $draft->setPostMessage(nl2br($draft->getPostMessage()));
1243 if ($spanClass !==
'') {
1247 $draft->getPostMessage(),
1256 if ($action ===
'editdraft' && $draft->getDraftId() === $draft_id) {
1257 $oEditReplyForm = $this->getReplyEditForm();
1259 if (!$this->objCurrentTopic->isClosed() && in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
1260 $this->renderPostingForm($tpl, $frm, $referencePosting, $this->requestAction);
1263 $tpl->
setVariable(
'EDIT_DRAFT_ANCHOR',
'draft_edit_' . $draft->getDraftId());
1264 $tpl->
setVariable(
'DRAFT_FORM', $oEditReplyForm->getHTML() . $this->modal_history);
1278 $forumObj = $this->
object;
1279 $frm = $this->
object->Forum;
1283 $filesOfPost = $fileDataOfForum->getFilesOfPost();
1284 ksort($filesOfPost);
1285 if ($filesOfPost !== [] && ($action !==
'showedit' || $node->
getId() !== $this->objCurrentPost->getId())) {
1286 foreach ($filesOfPost as $file) {
1288 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1289 $this->
ctrl->setParameter($this,
'file', $file[
'md5']);
1290 $tpl->
setVariable(
'HREF_DOWNLOAD', $this->
ctrl->getLinkTarget($this,
'viewThread'));
1292 $this->
ctrl->clearParameters($this);
1296 $tpl->
setVariable(
'TXT_ATTACHMENTS_DOWNLOAD', $this->
lng->txt(
'forums_attachments'));
1299 $this->uiRenderer->render(
1300 $this->uiFactory->symbol()->glyph()->attachment($this->lng->txt(
'forums_download_attachment'))
1303 if (count($filesOfPost) > 1) {
1304 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1305 $download_zip_button = $this->uiFactory->button()
1307 $this->
lng->txt(
'download'),
1308 $this->ctrl->getLinkTarget($this,
'deliverZipFile')
1310 $tpl->
setVariable(
'DOWNLOAD_ZIP', $this->uiRenderer->render($download_zip_button));
1314 $this->renderSplitButton($tpl, $action,
true, $node, $pageIndex);
1317 $tpl->
setVariable(
'TXT_PERMA_LINK', $this->
lng->txt(
'perma_link'));
1321 if (($this->is_moderator || $node->
isOwner($this->user->getId())) && !$node->
isActivated() && !$this->objCurrentTopic->isClosed()) {
1322 $rowCol =
'ilPostingNeedsActivation';
1323 } elseif ($this->objProperties->getMarkModeratorPosts()) {
1326 $rowCol =
'ilModeratorPosting';
1328 $rowCol =
'ilModeratorPosting';
1333 (!in_array($action, [
'delete',
'censor']) && !$this->displayConfirmPostActivation()) ||
1334 $this->objCurrentPost->getId() !== $node->
getId()
1338 $rowCol =
'tblrowmarked';
1342 if ($action !==
'censor') {
1343 $tpl->
setVariable(
'TXT_CENSORSHIP_ADVICE', $this->
lng->txt(
'post_censored_comment_by_moderator'));
1346 $rowCol =
'tblrowmarked';
1351 if (!$node->
isActivated() && ($node->
isOwner($this->user->getId()) || $this->is_moderator)) {
1352 $tpl->
setVariable(
'POST_NOT_ACTIVATED_YET', $this->
lng->txt(
'frm_post_not_activated_yet'));
1355 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1357 $backurl = urlencode($this->
ctrl->getLinkTarget($this,
'viewThread', (
string) $node->
getId()));
1358 $this->
ctrl->clearParameters($this);
1360 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1369 'href' => $this->ctrl->getLinkTarget($this,
'showUser')
1372 $this->
ctrl->clearParameters($this);
1374 if ($authorinfo->hasSuffix()) {
1375 if (!$authorinfo->isDeleted()) {
1376 $tpl->
setVariable(
'USR_NAME', $authorinfo->getAlias());
1378 $tpl->
setVariable(
'AUTHOR', $authorinfo->getSuffix());
1380 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized()) {
1381 $tpl->
setVariable(
'USR_NAME', $authorinfo->getAuthorName(
true));
1383 $tpl->
setVariable(
'AUTHOR', $authorinfo->getLinkedAuthorShortName());
1386 $tpl->
setVariable(
'USR_IMAGE', $authorinfo->getProfilePicture());
1392 if ($isModerator && $authorinfo->getAuthor()->getId()) {
1393 $authorRole = $this->
lng->txt(
'frm_moderator_n');
1394 if (is_string($authorinfo->getAuthor()->getGender()) && $authorinfo->getAuthor()->getGender() !==
'') {
1395 $authorRole = $this->
lng->txt(
'frm_moderator_' . $authorinfo->getAuthor()->getGender());
1403 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1416 'href' => $this->ctrl->getLinkTarget($this,
'showUser')
1419 $this->
ctrl->clearParameters($this);
1423 $this->
lng->txt(
'edited_on') .
': ' . $frm->convertDate($node->
getChangeDate()) .
' - ' . strtolower($this->
lng->txt(
'by'))
1425 $tpl->
setVariable(
'UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
1426 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
1427 $tpl->
setVariable(
'UPDATE_USR_NAME', $authorinfo->getAuthorName(
true));
1432 && $node->
getId() !== $this->selected_post_storage->get($node->
getThreadId())) {
1433 $target = $this->uiFactory->symbol()->icon()->custom(
1435 $this->
lng->txt(
'target_select')
1438 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1443 $this->uiRenderer->render(
1444 $this->uiFactory->link()->bulky(
1446 $this->lng->txt(
'select'),
1447 new \
ILIAS\Data\URI(
1448 ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTarget($this,
'selectPost', (
string) $node->
getId())
1460 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1462 $this->
ctrl->setParameter($this,
'page', $pageIndex);
1463 $this->
ctrl->setParameter(
1466 $this->getOrderByParam()
1468 $this->
ctrl->setParameter($this,
'viewmode', $this->selectedSorting);
1469 $mark_post_target = $this->
ctrl->getLinkTarget($this,
'markPostRead', (
string) $node->
getId());
1473 '<a href="' . $mark_post_target .
'"><b>' . $node->
getSubject() .
'</b></a>'
1479 if (!$node->
isCensored() || ($this->objCurrentPost->getId() === $node->
getId() && $action ===
'censor')) {
1482 $spanClass =
'moderator';
1491 if ($spanClass !==
'') {
1494 '<span class="' . $spanClass .
'">' .
1513 $thr_pk = (
int) $this->httpRequest->getQueryParams()[
'thr_pk'];
1514 $pos_pk = (
int) $this->httpRequest->getQueryParams()[
'pos_pk'];
1516 $this->selected_post_storage->set(
1521 $this->viewThreadObject();
1529 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_added'),
true);
1530 $this->
ctrl->setParameter($this,
'ref_id', $new_object->
getRefId());
1531 $this->
ctrl->redirect($this,
'createThread');
1536 if ($this->in_page_editor_style_context) {
1540 $this->
ilHelp->setScreenIdComponent(
'frm');
1542 $this->
ctrl->setParameter($this,
'ref_id', $this->ref_id);
1549 'enableForumNotification',
1550 'disableForumNotification',
1552 'performMoveThreads',
1553 'cancelMoveThreads',
1554 'performThreadsAction',
1558 'confirmDeleteThreads',
1561 'performMergeThreads'
1564 $force_active =
false;
1565 if (in_array($this->
ctrl->getCmd(), $active,
true)) {
1566 $force_active =
true;
1569 if ($this->
access->checkAccess(
1574 $this->tabs_gui->addTarget(
1575 self::UI_TAB_ID_THREADS,
1576 $this->
ctrl->getLinkTarget($this,
'showThreads'),
1577 $this->ctrl->getCmd(),
1584 if ($this->
access->checkAccess(
'visible',
'', $this->ref_id) || $this->access->checkAccess(
1589 $cmdClass = $this->
http->wrapper()->query()->retrieve(
1591 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always(
'')])
1594 $force_active = $this->
ctrl->getNextClass() ===
'ilinfoscreengui' || strtolower($cmdClass) ===
'ilnotegui';
1595 $this->tabs_gui->addTarget(
1596 self::UI_TAB_ID_INFO,
1597 $this->
ctrl->getLinkTargetByClass([self::class, ilInfoScreenGUI::class],
'showSummary'),
1598 [
'showSummary',
'infoScreen'],
1605 if ($this->
access->checkAccess(
'write',
'', $this->ref_id)) {
1606 $force_active = $this->
ctrl->getCmd() ===
'edit';
1607 $this->tabs_gui->addTarget(
1608 self::UI_TAB_ID_SETTINGS,
1609 $this->
ctrl->getLinkTarget($this,
'edit'),
1617 if ($this->
access->checkAccess(
'write',
'', $this->ref_id)) {
1618 $this->tabs_gui->addTarget(
1619 self::UI_TAB_ID_MODERATORS,
1620 $this->
ctrl->getLinkTargetByClass(ilForumModeratorsGUI::class,
'showModerators'),
1627 $this->tabs_gui->addTab(
1628 'learning_progress',
1629 $this->
lng->txt(
'learning_progress'),
1630 $this->ctrl->getLinkTargetByClass(ilLearningProgressGUI::class)
1634 if ($this->
settings->get(
'enable_fora_statistics',
'0')) {
1635 $hasStatisticsAccess = $this->
access->checkAccess(
'write',
'', $this->ref_id);
1636 if (!$hasStatisticsAccess) {
1637 $hasStatisticsAccess = (
1638 $this->objProperties->isStatisticEnabled() &&
1639 $this->
access->checkAccess(
'read',
'', $this->ref_id)
1643 if ($hasStatisticsAccess) {
1644 $force_active = $this->
ctrl->getCmd() ===
'showStatistics';
1645 $this->tabs_gui->addTarget(
1646 self::UI_TAB_ID_STATS,
1647 $this->
ctrl->getLinkTarget($this,
'showStatistics'),
1656 if ($this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1657 $this->tabs_gui->addTarget(
1658 self::UI_TAB_ID_EXPORT,
1659 $this->
ctrl->getLinkTargetByClass(ilExportGUI::class,
''),
1665 if ($this->
access->checkAccess(
'edit_permission',
'', $this->ref_id)) {
1666 $this->tabs_gui->addTarget(
1667 self::UI_TAB_ID_PERMISSIONS,
1668 $this->
ctrl->getLinkTargetByClass([static::class, ilPermissionGUI::class],
'perm'),
1669 [
'perm',
'info',
'owner'],
1677 if (!$this->
settings->get(
'enable_fora_statistics',
'0')) {
1678 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1681 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1682 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1685 if (!$this->objProperties->isStatisticEnabled()) {
1686 if ($this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1687 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'frm_statistics_disabled_for_participants'));
1689 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1693 $this->
object->Forum->setForumId($this->
object->getId());
1695 $tbl = new \ILIAS\Forum\Statistics\ForumStatisticsTable(
1697 $this->objProperties,
1699 $this->access->checkRbacOrPositionPermissionAccess(
1700 'read_learning_progress',
1701 'read_learning_progress',
1702 $this->object->getRefId()
1709 $this->tpl->setContent($this->uiRenderer->render($tbl->getComponent()));
1712 public static function _goto($a_target, $a_thread = 0, $a_posting = 0): void
1715 $main_tpl =
$DIC->ui()->mainTemplate();
1717 $ilAccess =
$DIC->access();
1721 $a_target = is_numeric($a_target) ? (
int) $a_target : 0;
1722 $a_thread = is_numeric($a_thread) ? (
int) $a_thread : 0;
1723 if ($ilAccess->checkAccess(
'read',
'', $a_target)) {
1724 if ($a_thread !== 0) {
1726 if ($objTopic->getFrmObjId() &&
1729 foreach ($ref_ids as
$ref_id) {
1730 if ($ilAccess->checkAccess(
'read',
'',
$ref_id)) {
1736 if (isset($new_ref_id) && $new_ref_id !== $a_target) {
1737 $DIC->ctrl()->redirectToURL(
1738 ILIAS_HTTP_PATH .
'/goto.php?target=frm_' . $new_ref_id .
'_' . $a_thread .
'_' . $a_posting
1743 $DIC->ctrl()->setParameterByClass(self::class,
'ref_id', (
string) ((
int) $a_target));
1744 if (is_numeric($a_thread)) {
1745 $DIC->ctrl()->setParameterByClass(self::class,
'thr_pk', (
string) ((
int) $a_thread));
1747 if (is_numeric($a_posting)) {
1748 $DIC->ctrl()->setParameterByClass(self::class,
'pos_pk', (
string) ((
int) $a_posting));
1750 $DIC->ctrl()->redirectByClass(
1751 [ilRepositoryGUI::class, self::class],
1753 is_numeric($a_posting) ? (
string) ((
int) $a_posting) :
''
1756 $DIC->ctrl()->setParameterByClass(self::class,
'ref_id', $a_target);
1757 $DIC->ctrl()->redirectByClass([ilRepositoryGUI::class, self::class,],
'');
1758 $DIC->http()->close();
1760 } elseif ($ilAccess->checkAccess(
'visible',
'', $a_target)) {
1761 $DIC->ctrl()->setParameterByClass(ilInfoScreenGUI::class,
'ref_id', $a_target);
1762 $DIC->ctrl()->redirectByClass(
1764 ilRepositoryGUI::class,
1766 ilInfoScreenGUI::class
1771 $main_tpl->setOnScreenMessage(
'info', sprintf(
1772 $lng->txt(
'msg_no_perm_read_item'),
1775 $DIC->http()->close();
1783 $threadIds = $this->retrieveThreadIds();
1784 if ($threadIds === []) {
1785 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
1786 $this->
ctrl->redirect($this,
'showThreads');
1789 if (!$this->is_moderator) {
1790 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1793 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1794 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1798 $this->objProperties->setObjId($forumObj->getId());
1802 $success_message =
'forums_thread_deleted';
1803 if (count($threadIds) > 1) {
1804 $success_message =
'forums_threads_deleted';
1808 array_walk($threadIds,
function (
int $threadId) use (&$threads):
void {
1810 $this->ensureThreadBelongsToForum($this->
object->getId(), $thread);
1812 $threads[] = $thread;
1815 $frm->setForumId($forumObj->getId());
1816 $frm->setForumRefId($forumObj->getRefId());
1817 foreach ($threads as $thread) {
1818 $first_node = $frm->getFirstPostNode($thread->getId());
1819 if (isset($first_node[
'pos_pk']) && (
int) $first_node[
'pos_pk']) {
1820 $frm->deletePost((
int) $first_node[
'pos_pk']);
1821 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt($success_message),
true);
1824 $this->
ctrl->redirect($this,
'showThreads');
1827 public function confirmDeleteThreadsObject(): void
1829 $thread_ids = $this->retrieveThreadIds();
1830 if ($thread_ids === []) {
1831 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'));
1832 $this->
ctrl->redirect($this,
'showThreads');
1835 if (!$this->is_moderator) {
1836 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1839 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1840 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1845 array_walk($thread_ids,
function (
int $threadId) use (&$threads):
void {
1847 $this->ensureThreadBelongsToForum($this->
object->getId(), $thread);
1849 $threads[] = $thread;
1854 $c_gui->setFormAction($this->
ctrl->getFormAction($this,
'performDeleteThreads'));
1855 $c_gui->setHeaderText($this->
lng->txt(
'frm_sure_delete_threads'));
1856 $c_gui->setCancel($this->
lng->txt(
'cancel'),
'showThreads');
1857 $c_gui->setConfirm($this->
lng->txt(
'confirm'),
'performDeleteThreads');
1859 foreach ($threads as $thread) {
1860 $c_gui->addItem(
'thread_ids[]', (
string) $thread->getId(), $thread->getSubject());
1863 $this->confirmation_gui_html = $c_gui->getHTML();
1865 $this->hideToolbar(
true);
1866 $this->tpl->setContent($c_gui->getHTML());
1871 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1872 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1875 $draft_ids = $this->
http->wrapper()->query()->retrieve(
1876 'forum_drafts_delete_draft_ids',
1878 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
1879 $this->refinery->always([])
1883 if ($draft_ids === []) {
1884 $draft_ids = $this->
http->wrapper()->query()->retrieve(
1885 'forum_drafts_delete_draft_ids',
1887 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string()),
1888 $this->refinery->always([])
1892 if (!isset($draft_ids[0]) || $draft_ids[0] !==
'ALL_OBJECTS') {
1893 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'));
1894 $this->showThreadsObject();
1898 $draft_ids = array_filter(array_map(
1899 static fn(array $draft):
int => $draft[
'draft_id'] ?? 0,
1901 $this->
user->getId(),
1908 $confirmation->setFormAction($this->
ctrl->getFormAction($this,
'deleteThreadDrafts'));
1909 $confirmation->setHeaderText($this->
lng->txt(
'sure_delete_drafts'));
1910 $confirmation->setCancel($this->
lng->txt(
'cancel'),
'showThreads');
1911 $confirmation->setConfirm($this->
lng->txt(
'confirm'),
'deleteThreadDrafts');
1913 foreach ($draft_ids as $draftId) {
1914 if (array_key_exists($draftId, $instances)) {
1915 $confirmation->addItem(
'draft_ids[]', (
string) $draftId, $instances[$draftId]->getPostSubject());
1919 $this->tpl->setContent($confirmation->getHTML());
1922 public function prepareThreadScreen(
ilObjForum $a_forum_obj): void
1924 $this->
ilHelp->setScreenIdComponent(
'frm');
1926 $this->tpl->loadStandardTemplate();
1930 $this->tabs_gui->setBackTarget(
1931 $this->
lng->txt(
'frm_all_threads'),
1932 $this->ctrl->getLinkTarget(
1939 $frm = $a_forum_obj->Forum;
1940 $frm->setForumId($a_forum_obj->
getId());
1945 if (!$this->is_moderator) {
1946 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1949 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1950 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1953 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
1955 $this->objCurrentPost->activatePost();
1956 $GLOBALS[
'ilAppEventHandler']->raise(
1957 'components/ILIAS/Forum',
1960 'object' => $this->
object,
1961 'ref_id' => $this->
object->getRefId(),
1962 'post' => $this->objCurrentPost
1965 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_post_was_activated'),
true);
1967 $this->viewThreadObject();
1973 !$this->
user->isAnonymous() &&
1974 !$this->objCurrentTopic->isClosed() && (
1975 $this->is_moderator ||
1976 ($this->objCurrentPost->isOwner($this->user->getId()) && !$this->objCurrentPost->hasReplies())
1979 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
1981 $oForumObjects = $this->getForumObjects();
1982 $forumObj = $oForumObjects[
'forumObj'];
1985 $frm->setForumId($forumObj->getId());
1986 $frm->setForumRefId($forumObj->getRefId());
1987 $dead_thr = $frm->deletePost($this->objCurrentPost->getId());
1990 if ($dead_thr === $this->objCurrentTopic->getId()) {
1991 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', [
'integer'], [$forumObj->getId()]);
1992 $topicData = $frm->getOneTopic();
1993 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_post_deleted'),
true);
1994 if ($topicData->getTopNumThreads() > 0) {
1995 $this->
ctrl->redirect($this,
'showThreads');
1997 $this->
ctrl->redirect($this,
'createThread');
2000 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_post_deleted'),
true);
2001 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
2002 $this->
ctrl->redirect($this,
'viewThread');
2005 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2010 $this->deleteSelectedDraft();
2015 $this->handleCensorship(
true);
2020 $this->handleCensorship();
2026 foreach ($this->modalActionsContainer as $modal) {
2027 $modalString .= $this->uiRenderer->render($modal);
2030 return $modalString;
2036 if ($this->is_moderator && !$this->objCurrentTopic->isClosed()) {
2037 if ($this->
http->wrapper()->post()->has(
'formData')) {
2038 $formData = $this->
http->wrapper()->post()->retrieve(
2040 $this->
refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string())
2042 $message = $this->handleFormInput($formData[
'cens_message']);
2045 if (
$message ===
'' && $this->
http->wrapper()->post()->has(
'cens_message')) {
2046 $cens_message = $this->
http->wrapper()->post()->retrieve(
2048 $this->
refinery->kindlyTo()->string()
2050 $message = $this->handleFormInput($cens_message);
2052 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
2054 $oForumObjects = $this->getForumObjects();
2055 $frm = $oForumObjects[
'frm'];
2058 $frm->postCensorship($this->
object,
$message, $this->objCurrentPost->getId());
2059 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_censorship_revoked'));
2061 $frm->postCensorship($this->
object,
$message, $this->objCurrentPost->getId(), 1);
2062 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_censorship_applied'));
2065 $this->viewThreadObject();
2069 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2074 if (!$this->is_moderator) {
2075 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2078 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2079 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2082 $this->setDisplayConfirmPostActivation(
true);
2084 $this->viewThreadObject();
2089 $this->display_confirm_post_activation = $status;
2094 return $this->display_confirm_post_activation;
2099 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2100 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2103 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentTopic);
2105 if ($this->objCurrentTopic->isNotificationEnabled($this->user->getId())) {
2106 $this->objCurrentTopic->disableNotification($this->
user->getId());
2107 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_notification_disabled'),
true);
2109 $this->objCurrentTopic->enableNotification($this->
user->getId());
2110 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_notification_enabled'),
true);
2113 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
2114 $this->
ctrl->redirect($this,
'viewThread');
2119 if (!$this->is_moderator) {
2120 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2123 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2124 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2127 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentTopic);
2129 if ($this->objCurrentTopic->isSticky()) {
2130 $this->objCurrentTopic->unmakeSticky();
2132 $this->objCurrentTopic->makeSticky();
2135 $this->viewThreadObject();
2140 $this->requestAction =
'';
2141 $draft_id = $this->retrieveDraftId(
true);
2142 if ($draft_id > 0) {
2144 if ($this->hasDraftAccess($draft)) {
2145 $draft->deleteDraftsByDraftIds([$draft_id]);
2149 $this->viewThreadObject();
2154 $this->requestAction =
'';
2155 $draft_id = $this->retrieveDraftId();
2156 if ($draft_id > 0) {
2158 $history_entry->populateWithFirstAutosaveByDraftId($draft_id);
2160 if ($this->hasDraftAccess($draft)) {
2161 $draft->setPostSubject($history_entry->getPostSubject());
2162 $draft->setPostMessage($history_entry->getPostMessage());
2165 $history_entry->getPostMessage(),
2167 $history_entry->getHistoryId(),
2169 $draft->getDraftId()
2172 $draft->updateDraft();
2174 $history_entry->deleteHistoryByDraftIds([$draft->getDraftId()]);
2178 $this->
ctrl->clearParameters($this);
2179 $this->viewThreadObject();
2185 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
2187 $this->
ctrl->setParameter(
2190 $this->getOrderByParam()
2192 $form->setFormAction($this->
ctrl->getFormAction($this,
'performPostActivation'));
2193 $this->
ctrl->clearParameters($this);
2194 $form->setId(
'frm_activate_post_' . $node->
getId());
2195 $form_id = $form->getId();
2196 $message = $this->uiFactory->messageBox()->confirmation($this->
lng->txt(
'activate_post_txt'));
2197 $submitBtn = $this->uiFactory->button()->primary(
2198 $this->
lng->txt(
'activate_only_current'),
2201 static function (
string $id) use ($form_id):
string {
2204 const button = document.getElementById('$id');
2205 if (!button) return;
2207 const form = document.getElementById('form_$form_id');
2210 button.addEventListener('click', (event) => {
2211 event.preventDefault();
2218 $modal = $this->uiFactory->modal()->roundtrip(
2219 $this->
lng->txt(
'activate_only_current'),
2220 [$this->uiFactory->legacy()->content($form->getHTML()),
$message]
2221 )->withActionButtons([$submitBtn]);
2222 $action_button = $this->uiFactory->button()->standard($this->
lng->txt(
'activate_post'),
'#')->withOnClick(
2223 $modal->getShowSignal()
2225 $this->modalActionsContainer[] = $modal;
2226 $this->
ctrl->clearParameters($this);
2228 return $action_button;
2231 public function getCensorshipFormHTML(): string
2234 $frm = $this->
object->Forum;
2235 $form_tpl =
new ilTemplate(
'tpl.frm_censorship_post_form.html',
true,
true,
'components/ILIAS/Forum');
2237 $form_tpl->setVariable(
'ANCHOR', $this->objCurrentPost->getId());
2238 $form_tpl->setVariable(
'SPACER',
'<hr noshade="noshade" width="100%" size="1" align="center" />');
2239 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2240 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2241 $this->
ctrl->setParameter(
2244 $this->getOrderByParam()
2246 $form_tpl->setVariable(
'FORM_ACTION', $this->
ctrl->getFormAction($this,
'viewThread'));
2247 $this->
ctrl->clearParameters($this);
2248 $form_tpl->setVariable(
'TXT_CENS_MESSAGE', $this->
lng->txt(
'forums_the_post'));
2249 $form_tpl->setVariable(
'TXT_CENS_COMMENT', $this->
lng->txt(
'forums_censor_comment') .
':');
2250 $form_tpl->setVariable(
'CENS_MESSAGE', $frm->prepareText((
string) $this->objCurrentPost->getCensorshipComment(), 2));
2252 if ($this->objCurrentPost->isCensored()) {
2253 $form_tpl->setVariable(
'TXT_CENS', $this->
lng->txt(
'forums_info_censor2_post'));
2254 $form_tpl->setVariable(
'YES_BUTTON', $this->
lng->txt(
'confirm'));
2255 $form_tpl->setVariable(
'NO_BUTTON', $this->
lng->txt(
'cancel'));
2256 $form_tpl->setVariable(
'CMD_REVOKE_CENSORSHIP',
'revokeCensorship');
2257 $form_tpl->setVariable(
'CMD_CANCEL_REVOKE_CENSORSHIP',
'viewThread');
2259 $form_tpl->setVariable(
'TXT_CENS', $this->
lng->txt(
'forums_info_censor_post'));
2260 $form_tpl->setVariable(
'CANCEL_BUTTON', $this->
lng->txt(
'cancel'));
2261 $form_tpl->setVariable(
'CONFIRM_BUTTON', $this->
lng->txt(
'confirm'));
2262 $form_tpl->setVariable(
'CMD_ADD_CENSORSHIP',
'addCensorship');
2263 $form_tpl->setVariable(
'CMD_CANCEL_ADD_CENSORSHIP',
'viewThread');
2266 return $form_tpl->get();
2271 $isReply = in_array($this->requestAction, [
'showreply',
'ready_showreply']);
2272 $isDraft = in_array($this->requestAction, [
'publishDraft',
'editdraft']);
2274 $draft_id = $this->retrieveDraftId();
2277 $oForumObjects = $this->getForumObjects();
2278 $frm = $oForumObjects[
'frm'];
2279 $oFDForum = $oForumObjects[
'file_obj'];
2282 $this->replyEditForm->setId(
'id_showreply');
2283 $this->replyEditForm->setTableWidth(
'100%');
2284 $cancel_cmd =
'cancelPost';
2285 if (in_array($this->requestAction, [
'showreply',
'ready_showreply'])) {
2286 $this->
ctrl->setParameter($this,
'action',
'ready_showreply');
2287 } elseif (in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
2288 $this->
ctrl->setParameter($this,
'action', $this->requestAction);
2289 $this->
ctrl->setParameter($this,
'draft_id', $draft_id);
2291 $this->
ctrl->setParameter($this,
'action',
'ready_showedit');
2294 $this->
ctrl->setParameter($this,
'page', (
int) ($this->httpRequest->getQueryParams()[
'page'] ?? 0));
2295 $this->
ctrl->setParameter(
2298 $this->getOrderByParam()
2300 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2301 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2302 if ($this->isTopLevelReplyCommand()) {
2303 $this->replyEditForm->setFormAction(
2304 $this->
ctrl->getFormAction($this,
'saveTopLevelPost',
'frm_page_bottom')
2306 } elseif (in_array($this->requestAction, [
'publishDraft',
'editdraft'])) {
2307 $this->replyEditForm->setFormAction(
2308 $this->
ctrl->getFormAction($this,
'publishDraft', (
string) $this->objCurrentPost->getId())
2311 $this->replyEditForm->setFormAction(
2312 $this->
ctrl->getFormAction($this,
'savePost', (
string) $this->objCurrentPost->getId())
2315 $this->
ctrl->clearParameters($this);
2318 $this->replyEditForm->setTitle($this->
lng->txt(
'forums_your_reply'));
2319 } elseif ($isDraft) {
2320 $this->replyEditForm->setTitle($this->
lng->txt(
'forums_edit_draft'));
2322 $this->replyEditForm->setTitle($this->
lng->txt(
'forums_edit_post'));
2326 $this->isWritingWithPseudonymAllowed() &&
2327 in_array($this->requestAction, [
'showreply',
'ready_showreply',
'editdraft'])
2329 $oAnonymousNameGUI =
new ilTextInputGUI($this->
lng->txt(
'forums_your_name'),
'alias');
2330 $oAnonymousNameGUI->setMaxLength(64);
2331 $oAnonymousNameGUI->setInfo(sprintf($this->
lng->txt(
'forums_use_alias'), $this->lng->txt(
'forums_anonymous')));
2333 $this->replyEditForm->addItem($oAnonymousNameGUI);
2336 $oSubjectGUI =
new ilTextInputGUI($this->
lng->txt(
'forums_subject'),
'subject');
2337 $oSubjectGUI->setMaxLength(255);
2338 $oSubjectGUI->setRequired(
true);
2340 if ($this->objProperties->getSubjectSetting() ===
'empty_subject') {
2341 $oSubjectGUI->setInfo($this->
lng->txt(
'enter_new_subject'));
2344 $this->replyEditForm->addItem($oSubjectGUI);
2347 $isReply ? $this->
lng->txt(
'forums_your_reply') : $this->lng->txt(
'forums_edit_post'),
2350 $oPostGUI->setRequired(
true);
2351 $oPostGUI->setRows(15);
2352 $oPostGUI->setUseRte(
true);
2355 !$this->isTopLevelReplyCommand() && (
2356 ($isReply && $this->objCurrentPost->getDepth() >= 2) ||
2357 (!$isDraft && !$isReply && $this->objCurrentPost->getDepth() > 2) ||
2358 ($isDraft && $this->objCurrentPost->getDepth() >= 2)
2362 $oPostGUI->removePlugin(
'advlink');
2363 $oPostGUI->setRTERootBlockElement(
'');
2364 $oPostGUI->usePurifier(
true);
2365 $oPostGUI->disableButtons([
2382 if (in_array($this->requestAction, [
'showreply',
'ready_showreply',
'showdraft',
'editdraft'])) {
2383 $oPostGUI->setRTESupport(
2384 $this->
user->getId(),
2387 'tpl.tinymce_frm_post.js',
2392 $oPostGUI->setRTESupport(
2393 $this->objCurrentPost->getId(),
2396 'tpl.tinymce_frm_post.js',
2403 $oPostGUI->setInfo($this->
lng->txt(
'latex_edit_info'));
2405 $this->replyEditForm->addItem($oPostGUI);
2408 if (!$this->
user->isAnonymous() &&
2409 !$this->objProperties->isAnonymized() &&
2410 $this->rbac->system()->checkAccess(
'internal_mail', $umail->getMailObjectReferenceId()) &&
2411 !$frm->isThreadNotificationEnabled($this->user->getId(), $this->objCurrentPost->getThreadId())) {
2413 $oNotificationGUI->setInfo($this->
lng->txt(
'forum_notify_me'));
2414 $this->replyEditForm->addItem($oNotificationGUI);
2417 if ($this->objProperties->isFileUploadAllowed()) {
2419 $oFileUploadGUI->setFilenames([0 =>
'']);
2420 $this->replyEditForm->addItem($oFileUploadGUI);
2423 $attachments_of_node = $oFDForum->getFilesOfPost();
2424 if (count($attachments_of_node) && in_array($this->requestAction, [
'showedit',
'ready_showedit'])) {
2426 foreach ($oFDForum->getFilesOfPost() as $file) {
2427 $oExistingAttachmentsGUI->addOption(
new ilCheckboxOption($file[
'name'], $file[
'md5']));
2429 $this->replyEditForm->addItem($oExistingAttachmentsGUI);
2433 if (in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
2435 $draftInfoGUI->setValue(sprintf(
2436 $this->
lng->txt(
'autosave_draft_info'),
2439 $this->replyEditForm->addItem($draftInfoGUI);
2440 } elseif (!in_array($this->requestAction, [
'showedit',
'ready_showedit'])) {
2442 $draftInfoGUI->setValue(sprintf(
2443 $this->
lng->txt(
'autosave_post_draft_info'),
2446 $this->replyEditForm->addItem($draftInfoGUI);
2450 $selected_draft_id = $draft_id;
2452 $this->
user->getId(),
2453 $this->objCurrentPost->getId(),
2456 if ($draftObj->getDraftId() > 0) {
2458 $files_of_draft = $oFDForumDrafts->getFilesOfPost();
2460 if ($files_of_draft !== []) {
2462 $this->
lng->txt(
'forums_delete_file'),
2465 foreach ($files_of_draft as $file) {
2466 $oExistingAttachmentsGUI->addOption(
new ilCheckboxOption($file[
'name'], $file[
'md5']));
2468 $this->replyEditForm->addItem($oExistingAttachmentsGUI);
2472 if ($this->isTopLevelReplyCommand()) {
2473 $this->replyEditForm->addCommandButton(
'saveTopLevelPost', $this->
lng->txt(
'create'));
2475 $this->replyEditForm->addCommandButton(
'publishDraft', $this->
lng->txt(
'publish'));
2477 $this->replyEditForm->addCommandButton(
'savePost', $this->
lng->txt(
'save'));
2480 $auto_save_draft_id = $this->retrieveDraftId();
2482 $hidden_draft_id->setValue((
string) $auto_save_draft_id);
2483 $this->replyEditForm->addItem($hidden_draft_id);
2485 if (in_array($this->requestAction, [
'showreply',
'ready_showreply',
'editdraft'])) {
2486 $show_rte = $this->
http->wrapper()->post()->retrieve(
2488 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
2495 if ($quotingAllowed) {
2496 $this->replyEditForm->addCommandButton(
'quotePost', $this->
lng->txt(
'forum_add_quote'));
2499 if (!$this->
user->isAnonymous() &&
2500 in_array($this->requestAction, [
'editdraft',
'showreply',
'ready_showreply']) &&
2503 $this->decorateWithAutosave($this->replyEditForm);
2506 if ($this->requestAction ===
'editdraft') {
2507 $this->replyEditForm->addCommandButton(
'updateDraft', $this->
lng->txt(
'save_message'));
2508 } elseif ($this->isTopLevelReplyCommand()) {
2509 $this->replyEditForm->addCommandButton(
'saveTopLevelDraft', $this->
lng->txt(
'save_message'));
2511 $this->replyEditForm->addCommandButton(
'saveAsDraft', $this->
lng->txt(
'save_message'));
2514 $cancel_cmd =
'cancelDraft';
2517 $this->replyEditForm->addCommandButton($cancel_cmd, $this->
lng->txt(
'cancel'));
2522 if ($this->replyEditForm ===
null) {
2523 $this->initReplyEditForm();
2526 return $this->replyEditForm;
2532 $draft_id = $this->retrieveDraftId();
2534 if ($draft_id > 0 && !$this->
user->isAnonymous()
2537 $this->
user->getId(),
2538 $this->objCurrentPost->getId(),
2544 $this->
ctrl->setParameter($this,
'action',
'editdraft');
2545 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2546 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
2547 $this->
ctrl->setParameter($this,
'draft_id', $draft_obj->getDraftId());
2548 $this->
ctrl->setParameter($this,
'page', 0);
2549 $this->
ctrl->setParameter(
2552 $this->getOrderByParam()
2554 $this->
ctrl->redirect($this,
'editDraft');
2556 $this->viewThreadObject();
2562 $this->savePostObject();
2567 $draft_id = $this->retrieveDraftId();
2568 if ($draft_id > 0) {
2569 $this->publishDraftObject(
false);
2576 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2577 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2580 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
2581 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2584 if ($this->objCurrentTopic->getId() === 0) {
2585 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
2586 $this->
ctrl->redirect($this);
2589 if ($this->objCurrentTopic->isClosed()) {
2590 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
2591 $this->
ctrl->redirect($this);
2594 if ($this->objCurrentPost->getId() === 0) {
2595 $this->requestAction =
'';
2596 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'));
2597 $this->viewThreadObject();
2601 $draft =
new ilForumPostDraft($this->
user->getId(), $this->objCurrentPost->getId(), $this->retrieveDraftId());
2602 $this->checkDraftAccess($draft->getDraftId());
2604 if ($use_replyform) {
2605 $oReplyEditForm = $this->getReplyEditForm();
2606 if (!$oReplyEditForm->checkInput()) {
2607 $oReplyEditForm->setValuesByPost();
2608 $this->viewThreadObject();
2611 $post_subject = $oReplyEditForm->getInput(
'subject');
2612 $post_message = $oReplyEditForm->getInput(
'message');
2615 $post_subject = $draft->getPostSubject();
2616 $post_message = $draft->getPostMessage();
2620 $oForumObjects = $this->getForumObjects();
2621 $frm = $oForumObjects[
'frm'];
2622 $frm->setMDB2WhereCondition(
' top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
2626 $send_activation_mail =
false;
2628 if ($this->objProperties->isPostActivationEnabled()) {
2629 if (!$this->is_moderator) {
2631 $send_activation_mail =
true;
2632 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2637 $newPost = $frm->generatePost(
2638 $draft->getForumId(),
2639 $draft->getThreadId(),
2640 $this->user->getId(),
2641 $draft->getPostDisplayUserId(),
2643 $draft->getPostId(),
2644 $draft->isNotificationEnabled(),
2645 $this->handleFormInput($post_subject,
false),
2646 $draft->getPostUserAlias(),
2649 $send_activation_mail
2652 $this->
object->markPostRead(
2653 $this->
user->getId(),
2654 $this->objCurrentTopic->getId(),
2655 $this->objCurrentPost->getId()
2660 foreach ($uploadedObjects as $mob) {
2667 if ($draft->getRCID() > 0) {
2668 $post_obj->setRCID($draft->getRCID());
2669 $post_obj->update();
2672 if ($this->objProperties->isFileUploadAllowed()) {
2673 $file = $_FILES[
'userfile'] ?? [];
2674 if (is_array($file) && !empty($file)) {
2676 $tmp_file_obj->storeUploadedFiles();
2680 $GLOBALS[
'ilAppEventHandler']->raise(
2681 'components/ILIAS/Forum',
2684 'draftObj' => $draft,
2685 'obj_id' => $this->
object->getId(),
2686 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
2689 $draft->deleteDraft();
2691 $GLOBALS[
'ilAppEventHandler']->raise(
2692 'components/ILIAS/Forum',
2695 'object' => $this->
object,
2696 'ref_id' => $this->
object->getRefId(),
2697 'post' => $post_obj,
2698 'notify_moderators' => $send_activation_mail
2703 if (!$this->is_moderator && !$status) {
2704 $message .= $this->
lng->txt(
'forums_post_needs_to_be_activated');
2706 $message .= $this->
lng->txt(
'forums_post_new_entry');
2710 if (is_array($frm_session_values)) {
2711 $frm_session_values[$this->objCurrentTopic->getId()][
'openTreeNodes'][] = $this->objCurrentPost->getId();
2715 $this->
ctrl->clearParameters($this);
2716 $this->tpl->setOnScreenMessage(
'success',
$message,
true);
2717 $this->
ctrl->setParameter($this,
'pos_pk', $newPost);
2718 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2720 $this->
ctrl->redirect($this,
'viewThread');
2725 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2726 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2729 if ($this->objCurrentTopic->getId() === 0) {
2730 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
2731 $this->
ctrl->redirect($this);
2734 if ($this->objCurrentTopic->isClosed()) {
2735 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
2736 $this->
ctrl->redirect($this);
2739 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentTopic);
2741 $oReplyEditForm = $this->getReplyEditForm();
2742 if ($oReplyEditForm->checkInput()) {
2743 if ($this->objCurrentPost->getId() === 0) {
2744 $this->requestAction =
'';
2745 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'),
true);
2746 $this->viewThreadObject();
2750 $oForumObjects = $this->getForumObjects();
2751 $forumObj = $oForumObjects[
'forumObj'];
2752 $frm = $oForumObjects[
'frm'];
2753 $frm->setMDB2WhereCondition(
' top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
2754 $topicData = $frm->getOneTopic();
2756 $autosave_draft_id = $this->
http->wrapper()->post()->retrieve(
2758 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
2761 if ($this->requestAction ===
'ready_showreply') {
2762 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
2763 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2767 $send_activation_mail =
false;
2769 if ($this->objProperties->isPostActivationEnabled()) {
2770 if (!$this->is_moderator) {
2772 $send_activation_mail =
true;
2773 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2778 if ($this->isWritingWithPseudonymAllowed()) {
2779 if ((
string) $oReplyEditForm->getInput(
'alias') ===
'') {
2780 $user_alias = $this->
lng->txt(
'forums_anonymous');
2782 $user_alias = $oReplyEditForm->getInput(
'alias');
2784 $display_user_id = 0;
2786 $user_alias = $this->
user->getLogin();
2787 $display_user_id = $this->
user->getId();
2790 $newPost = $frm->generatePost(
2791 $topicData->getTopPk(),
2792 $this->objCurrentTopic->getId(),
2793 $this->user->getId(),
2796 $this->objCurrentPost->getId(),
2797 $oReplyEditForm->getInput(
'notify') && !$this->user->isAnonymous(),
2798 $this->handleFormInput($oReplyEditForm->getInput(
'subject'),
false),
2802 $send_activation_mail
2805 if ($autosave_draft_id > 0) {
2807 $this->
user->getId(),
2808 $this->objCurrentPost->getId(),
2811 if ($this->hasDraftAccess($draft)) {
2812 $draft->deleteDraft();
2817 $this->
object->markPostRead(
2818 $this->
user->getId(),
2819 $this->objCurrentTopic->getId(),
2820 $this->objCurrentPost->getId()
2825 $oReplyEditForm->getInput(
'message'),
2827 $this->user->getId(),
2832 if ($this->objProperties->isFileUploadAllowed()) {
2834 $file = $_FILES[
'userfile'];
2835 if (is_array($file) && !empty($file)) {
2836 $oFDForum->storeUploadedFiles();
2840 $GLOBALS[
'ilAppEventHandler']->raise(
2841 'components/ILIAS/Forum',
2844 'object' => $this->
object,
2845 'ref_id' => $this->
object->getRefId(),
2847 'notify_moderators' => $send_activation_mail
2852 if (!$this->is_moderator && !$status) {
2853 $message .= $this->
lng->txt(
'forums_post_needs_to_be_activated');
2855 $message .= $this->
lng->txt(
'forums_post_new_entry');
2858 $this->tpl->setOnScreenMessage(
'success',
$message,
true);
2859 $this->
ctrl->clearParameters($this);
2860 $this->
ctrl->setParameter($this,
'post_created_below', $this->objCurrentPost->getId());
2861 $this->
ctrl->setParameter($this,
'pos_pk', $newPost);
2862 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2864 if ((!$this->is_moderator &&
2865 !$this->objCurrentPost->isOwner($this->user->getId())) || $this->objCurrentPost->isCensored() ||
2866 $this->user->isAnonymous()) {
2867 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2870 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
2874 foreach ($oldMediaObjects as $oldMob) {
2876 foreach ($curMediaObjects as $curMob) {
2877 if ($oldMob === $curMob) {
2890 $old_status_was_active = $this->objCurrentPost->isActivated();
2894 $send_activation_mail =
false;
2896 if ($this->objProperties->isPostActivationEnabled()) {
2897 if (!$this->is_moderator) {
2899 $send_activation_mail =
true;
2900 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2904 $this->objCurrentPost->setStatus($status);
2906 $this->objCurrentPost->setSubject($this->handleFormInput($oReplyEditForm->getInput(
'subject'),
false));
2908 $oReplyEditForm->getInput(
'message')
2910 $this->objCurrentPost->setNotification($oReplyEditForm->getInput(
'notify') && !$this->user->isAnonymous());
2911 $this->objCurrentPost->setChangeDate(date(
'Y-m-d H:i:s'));
2912 $this->objCurrentPost->setUpdateUserId($this->
user->getId());
2914 if ($this->objCurrentPost->update()) {
2915 $this->objCurrentPost->reload();
2922 $this->objCurrentPost->getId(),
2927 $news_item->setTitle($this->objCurrentPost->getSubject());
2928 $news_item->setContent(
2930 $this->objCurrentPost->getMessage()
2934 if ($this->objCurrentPost->getMessage() !== strip_tags($this->objCurrentPost->getMessage())) {
2935 $news_item->setContentHtml(
true);
2937 $news_item->setContentHtml(
false);
2939 $news_item->update();
2942 $oFDForum = $oForumObjects[
'file_obj'];
2944 $file2delete = $oReplyEditForm->getInput(
'del_file');
2945 if (is_array($file2delete) && count($file2delete)) {
2946 $oFDForum->unlinkFilesByMD5Filenames($file2delete);
2949 if ($this->objProperties->isFileUploadAllowed()) {
2950 $file = $_FILES[
'userfile'];
2951 if (is_array($file) && !empty($file)) {
2952 $oFDForum->storeUploadedFiles();
2956 $GLOBALS[
'ilAppEventHandler']->raise(
2957 'components/ILIAS/Forum',
2960 'ref_id' => $this->
object->getRefId(),
2961 'post' => $this->objCurrentPost,
2962 'notify_moderators' => $send_activation_mail,
2963 'old_status_was_active' => $old_status_was_active
2967 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'forums_post_modified'),
true);
2970 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2971 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2972 $this->
ctrl->setParameter($this,
'viewmode', $this->selectedSorting);
2974 $this->
ctrl->redirect($this,
'viewThread');
2976 $this->requestAction = substr($this->requestAction, 6);
2978 $this->viewThreadObject();
2983 if ($a_flag ===
null) {
2984 return $this->hideToolbar;
2987 $this->hideToolbar = $a_flag;
2993 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2994 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2997 if ($this->objCurrentTopic->isClosed()) {
2998 $this->requestAction =
'';
2999 $this->viewThreadObject();
3003 $oReplyEditForm = $this->getReplyEditForm();
3005 $oReplyEditForm->getItemByPostVar(
'subject')->setRequired(
false);
3006 $oReplyEditForm->getItemByPostVar(
'message')->setRequired(
false);
3008 $oReplyEditForm->checkInput();
3010 $oReplyEditForm->getItemByPostVar(
'subject')->setRequired(
true);
3011 $oReplyEditForm->getItemByPostVar(
'message')->setRequired(
true);
3013 $this->requestAction =
'showreply';
3015 $this->viewThreadObject();
3023 if ($this->forumObjects ===
null) {
3024 $forumObj = $this->object;
3025 $file_obj =
new ilFileDataForum($forumObj->getId(), $this->objCurrentPost->getId());
3026 $frm = $forumObj->Forum;
3027 $frm->setForumId($forumObj->getId());
3028 $frm->setForumRefId($forumObj->getRefId());
3030 $this->forumObjects[
'forumObj'] = $forumObj;
3031 $this->forumObjects[
'frm'] = $frm;
3032 $this->forumObjects[
'file_obj'] = $file_obj;
3035 return $this->forumObjects;
3040 $this->selectedSorting = $this->objProperties->getDefaultView();
3042 if ($this->getObject() !==
null) {
3043 $view_mode =
'viewmode_' . $this->getObject()->getId();
3053 isset($this->httpRequest->getQueryParams()[
'viewmode']) &&
3054 (
int) $this->httpRequest->getQueryParams()[
'viewmode'] !== $this->selectedSorting
3056 $this->selectedSorting = (
int) $this->httpRequest->getQueryParams()[
'viewmode'];
3059 if (!in_array($this->selectedSorting, [
3064 $this->selectedSorting = $this->objProperties->getDefaultView();
3073 $this->selected_post_storage->set($this->objCurrentTopic->getId(), 0);
3074 $this->
ctrl->redirect($this,
'viewThread');
3079 $thr_pk = $this->objCurrentTopic->getId();
3081 $bottom_toolbar = clone $this->toolbar;
3082 $toolbar_items = [];
3085 $thread_control_session_values =
ilSession::get(
'thread_control');
3086 if (is_array($thread_control_session_values)) {
3087 if (!isset($thread_control_session_values[
'old'])) {
3088 $thread_control_session_values[
'old'] = $thr_pk;
3089 $thread_control_session_values[
'new'] = $thr_pk;
3090 ilSession::set(
'thread_control', $thread_control_session_values);
3091 } elseif (isset($thread_control_session_values[
'old']) && $thr_pk !== $thread_control_session_values[
'old']) {
3092 $thread_control_session_values[
'new'] = $thr_pk;
3093 ilSession::set(
'thread_control', $thread_control_session_values);
3097 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3098 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3101 $oForumObjects = $this->getForumObjects();
3102 $forumObj = $oForumObjects[
'forumObj'];
3103 $frm = $oForumObjects[
'frm'];
3104 $file_obj = $oForumObjects[
'file_obj'];
3106 $selected_draft_id = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
3107 if (isset($this->httpRequest->getQueryParams()[
'file'])) {
3108 $file_obj_for_delivery = $file_obj;
3112 $file_obj_for_delivery->deliverFile(
ilUtil::stripSlashes($this->httpRequest->getQueryParams()[
'file']));
3115 if ($this->objCurrentTopic->getId() === 0) {
3116 $this->
ctrl->redirect($this,
'showThreads');
3120 if (isset($this->httpRequest->getQueryParams()[
'page'])) {
3121 $pageIndex = max((
int) $this->httpRequest->getQueryParams()[
'page'], $pageIndex);
3124 if ($this->selected_post_storage->get($this->objCurrentTopic->getId()) > 0) {
3126 $this->selected_post_storage->get($this->objCurrentTopic->getId()),
3127 $this->is_moderator,
3131 $firstNodeInThread = $this->objCurrentTopic->getPostRootNode();
3139 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentTopic);
3142 'tpl.forums_threads_view.html',
3145 'components/ILIAS/Forum'
3150 $order_field =
'frm_posts_tree.rgt';
3151 $this->objCurrentTopic->setOrderDirection(
'DESC');
3152 $threadContentTemplate->setVariable(
'LIST_TYPE', $this->viewModeOptions[$this->selectedSorting]);
3154 $order_field =
'frm_posts.pos_date';
3155 $this->objCurrentTopic->setOrderDirection(
3158 $threadContentTemplate->setVariable(
'LIST_TYPE', $this->sortationOptions[$this->selectedSorting]);
3160 $this->objCurrentTopic->setOrderField($order_field);
3163 $subtree_nodes = $this->objCurrentTopic->getPostTree($firstNodeInThread);
3164 $numberOfPostings = count($subtree_nodes);
3175 $append =
'_' . $this->objCurrentTopic->getId() .
3176 ($this->objCurrentPost->getId() !== 0 ?
'_' . $this->objCurrentPost->getId() :
'');
3177 $this->tpl->setLoginTargetPar(
'frm_' . $this->
object->getRefId() . $append);
3180 if (!in_array($this->requestAction, [
'showreply',
'showedit'])) {
3183 foreach ($mobs as $mob) {
3190 }
catch (Exception) {
3194 if (!$this->getCreationMode() && $this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3196 $this->
object->getRefId(),
3197 ilLink::_getLink($this->object->getRefId(),
'frm'),
3202 $this->prepareThreadScreen($forumObj);
3205 if (isset($this->httpRequest->getQueryParams()[
'anchor'])) {
3206 $threadContentTemplate->setVariable(
'JUMP2ANCHOR_ID', (
int) $this->httpRequest->getQueryParams()[
'anchor']);
3208 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
3211 $this->
object->getType(),
3212 $this->object->getRefId(),
3213 $this->object->getId(),
3214 $this->user->getId()
3217 if ($firstNodeInThread) {
3218 $this->objCurrentTopic->updateVisits();
3220 $this->tpl->setTitle($this->
lng->txt(
'forums_thread') .
' "' . $this->objCurrentTopic->getSubject() .
'"');
3222 $this->
locator->addRepositoryItems();
3223 $this->
locator->addItem($this->
object->getTitle(), $this->ctrl->getLinkTarget($this,
''),
'_top');
3224 $this->tpl->setLocator();
3226 if (!$this->
user->isAnonymous() &&
3227 $forumObj->getCountUnread($this->user->getId(), $this->objCurrentTopic->getId(),
true)) {
3228 $this->
ctrl->setParameter($this,
'mark_read',
'1');
3229 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3231 $mark_thr_read_button = $this->uiFactory->button()->standard(
3232 $this->
lng->txt(
'forums_mark_read'),
3233 $this->ctrl->getLinkTarget($this,
'viewThread')
3236 $toolbar_items[] = $mark_thr_read_button;
3238 $this->
ctrl->clearParameters($this);
3241 $this->
ctrl->setParameterByClass(ilForumExportGUI::class,
'print_thread', $this->objCurrentTopic->getId());
3242 $this->
ctrl->setParameterByClass(
3243 ilForumExportGUI::class,
3245 $this->objCurrentTopic->getForumId()
3248 if ($numberOfPostings > 0 && $this->
settings->get(
'forum_enable_print',
'0')) {
3249 $print_thr_button = $this->uiFactory->button()->standard(
3250 $this->
lng->txt(
'forums_print_thread'),
3251 $this->ctrl->getLinkTargetByClass(ilForumExportGUI::class,
'printThread')
3253 $toolbar_items[] = $print_thr_button;
3257 $this->
ctrl->clearParametersByClass(ilForumExportGUI::class);
3259 $this->addHeaderAction();
3261 if (isset($this->httpRequest->getQueryParams()[
'mark_read'])) {
3262 $forumObj->markThreadRead($this->
user->getId(), $this->objCurrentTopic->getId());
3263 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_thread_marked'),
true);
3267 !$this->isTopLevelReplyCommand() &&
3268 !$this->objCurrentTopic->isClosed() &&
3269 $this->access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
3270 $this->
ctrl->setParameter($this,
'action',
'showreply');
3271 $this->
ctrl->setParameter($this,
'pos_pk', $firstNodeInThread->getId());
3272 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3273 $this->
ctrl->setParameter(
3276 (
int) ($this->httpRequest->getQueryParams()[
'page'] ?? 0)
3278 $this->
ctrl->setParameter(
3281 $this->getOrderByParam()
3283 if ($numberOfPostings > 0) {
3284 $reply_button = $this->uiFactory->button()->standard(
3285 $this->
lng->txt(
'add_new_answer'),
3286 $this->ctrl->getLinkTarget($this,
'createTopLevelPost',
'frm_page_bottom')
3289 $reply_button = $this->uiFactory->button()->primary(
3290 $this->
lng->txt(
'add_new_answer'),
3291 $this->ctrl->getLinkTarget($this,
'createTopLevelPost',
'frm_page_bottom')
3294 $this->
ctrl->clearParameters($this);
3295 array_unshift($toolbar_items, $reply_button);
3299 if ($numberOfPostings === 0 && $firstNodeInThread->getId() === 0) {
3300 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_no_posts_available'));
3303 $pageSize = $frm->getPageHits();
3305 if ($numberOfPostings > $pageSize) {
3306 $this->
ctrl->setParameter($this,
'ref_id', $this->
object->getRefId());
3307 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3308 $this->
ctrl->setParameter(
3311 $this->getOrderByParam()
3313 $paginationUrl = $this->
ctrl->getLinkTarget($this,
'viewThread',
'');
3314 $this->
ctrl->clearParameters($this);
3316 $pagination = $this->uiFactory->viewControl()
3318 ->withTargetURL($paginationUrl,
'page')
3319 ->withTotalEntries($numberOfPostings)
3320 ->withPageSize($pageSize)
3321 ->withMaxPaginationButtons(10)
3322 ->withCurrentPage($pageIndex);
3324 $threadContentTemplate->setVariable(
'THREAD_MENU', $this->uiRenderer->render(
3327 $threadContentTemplate->setVariable(
'THREAD_MENU_BOTTOM', $this->uiRenderer->render(
3333 $draftsObjects = [];
3334 if ($doRenderDrafts) {
3336 $this->
user->getId(),
3337 $this->objCurrentTopic->getId(),
3338 $this->selectedSorting
3342 $pagedPostings = array_slice($subtree_nodes, $pageIndex * $pageSize, $pageSize);
3344 $this->ensureValidPageForCurrentPosting($subtree_nodes, $pagedPostings, $pageSize, $firstNodeInThread);
3346 if ($doRenderDrafts && $pageIndex === 0 &&
3348 foreach ($draftsObjects as $draft) {
3349 $referencePosting = array_values(array_filter(
3352 ))[0] ?? $firstNodeInThread;
3354 $this->renderDraftContent(
3355 $threadContentTemplate,
3356 $this->requestAction,
3363 foreach ($pagedPostings as $node) {
3364 $this->
ctrl->clearParameters($this);
3366 if (!$this->isTopLevelReplyCommand() && $this->objCurrentPost->getId() === $node->getId() &&
3367 ($this->is_moderator || $node->isActivated() || $node->isOwner($this->user->getId()))) {
3368 if (!$this->objCurrentTopic->isClosed() && in_array($this->requestAction, [
3372 $this->renderPostingForm($threadContentTemplate, $frm, $node, $this->requestAction);
3373 } elseif ($this->requestAction ===
'censor' &&
3374 !$this->objCurrentTopic->isClosed() && $this->is_moderator) {
3375 $threadContentTemplate->setVariable(
'FORM', $this->getCensorshipFormHTML());
3379 $this->renderPostContent($threadContentTemplate, $node, $this->requestAction, $pageIndex, $postIndex);
3381 $this->renderDraftContent(
3382 $threadContentTemplate,
3383 $this->requestAction,
3385 $draftsObjects[$node->getId()] ?? []
3394 $doRenderDrafts && $pageIndex === max(0, (
int) (ceil($numberOfPostings / $pageSize) - 1))
3396 foreach ($draftsObjects as $draft) {
3397 $referencePosting = array_values(array_filter(
3400 ))[0] ?? $firstNodeInThread;
3402 $this->renderDraftContent(
3403 $threadContentTemplate,
3404 $this->requestAction,
3412 $firstNodeInThread instanceof
ilForumPost && $doRenderDrafts &&
3415 $this->renderDraftContent(
3416 $threadContentTemplate,
3417 $this->requestAction,
3419 $draftsObjects[$firstNodeInThread->getId()] ?? []
3424 !$this->objCurrentTopic->isClosed() &&
3425 in_array($this->
ctrl->getCmd(), [
'createTopLevelPost',
'saveTopLevelPost',
'saveTopLevelDraft'],
true) &&
3426 $this->access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
3428 $this->objCurrentPost->setId($firstNodeInThread->getId());
3429 $form = $this->getReplyEditForm();
3431 if (in_array($this->
ctrl->getCmd(), [
'saveTopLevelPost',
'saveTopLevelDraft'])) {
3432 $form->setValuesByPost();
3434 $threadContentTemplate->setVariable(
'BOTTOM_FORM', $form->getHTML());
3437 $threadContentTemplate->setCurrentBlock(
'posts_no');
3438 $threadContentTemplate->setVariable(
3439 'TXT_MSG_NO_POSTS_AVAILABLE',
3440 $this->
lng->txt(
'forums_posts_not_available')
3442 $threadContentTemplate->parseCurrentBlock();
3445 $to_top_button = $this->uiFactory->button()
3446 ->standard($this->
lng->txt(
'top_of_page'),
'#frm_page_top');
3447 $bottom_toolbar->addComponent($to_top_button);
3448 if ($numberOfPostings > 0) {
3449 $threadContentTemplate->setVariable(
'TOOLBAR_BOTTOM', $bottom_toolbar->getHTML());
3452 if ($toolbar_items !== []) {
3453 foreach ($toolbar_items as $component_index => $item) {
3454 $this->toolbar->addComponent($item);
3455 $bottom_toolbar->addComponent($item);
3456 if ($component_index === 0 && $numberOfPostings > 0) {
3457 $this->renderViewModeControl($this->selectedSorting);
3459 $this->renderSortationControl($this->selectedSorting);
3465 $this->tpl->setPermanentLink(
3466 $this->
object->getType(),
3467 $this->object->getRefId(),
3468 (
string) $this->objCurrentTopic->getId()
3471 $this->tpl->addOnLoadCode(
3473 document.querySelectorAll(
'.ilFrmPostContent img').forEach((img) => {
3474 const maxWidth = img.getAttribute(
'width');
3475 const maxHeight = img.getAttribute(
'height');
3478 img.style.maxWidth = maxWidth +
'px';
3479 img.removeAttribute(
'width');
3483 img.style.maxHeight = maxHeight +
'px';
3484 img.removeAttribute(
'height');
3491 $info = $this->getResetLimitedViewInfo();
3494 $this->tpl->setContent((
$info ??
'') . $threadContentTemplate->get() . $this->getModalActions());
3499 if ($currentViewMode === 3) {
3500 $currentViewMode = 2;
3502 $translationKeys = [];
3503 foreach ($this->viewModeOptions as $sortingConstantKey => $languageKey) {
3504 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3505 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
3506 $this->
ctrl->setParameter($this,
'viewmode', $sortingConstantKey);
3508 $translationKeys[$this->
lng->txt($languageKey)] = $this->
ctrl->getLinkTarget(
3514 $this->
ctrl->clearParameters($this);
3521 $sortViewControl = $this->uiFactory
3523 ->mode($translationKeys, $this->
lng->txt($this->viewModeOptions[$currentViewMode]))
3524 ->withActive($this->
lng->txt($this->viewModeOptions[$currentViewMode]));
3525 $this->
toolbar->addComponent($sortViewControl);
3530 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3531 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
3532 $target = $this->
ctrl->getLinkTarget(
3538 $translatedSortationOptions = array_map(fn($value):
string => $this->
lng->txt($value), $this->sortationOptions);
3540 $sortingDirectionViewControl = $this->uiFactory
3542 ->sortation($translatedSortationOptions, (
string) $currentSorting)
3543 ->withTargetURL($target,
'viewmode');
3544 $this->
toolbar->addComponent($sortingDirectionViewControl);
3549 return (
new \
ILIAS\
components\Forum\Subject\PostingReplySubjectBuilder(
3550 $this->
lng->txt(
'post_reply'),
3551 $this->lng->txt(
'post_reply_count')
3552 ))->build($this->objCurrentPost->getSubject());
3559 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
3561 $backurl = $this->
http->wrapper()->query()->retrieve(
3563 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always(
'')])
3567 $add = $this->getUserProfileAdditional($this->
object->getRefId(),
$user_id);
3568 $profile_gui->setAdditional($add);
3570 $this->tpl->setContent($this->
ctrl->getHTML($profile_gui));
3573 protected function getUserProfileAdditional(
int $a_forum_ref_id,
int $a_user_id): array
3575 if (!$this->
access->checkAccess(
'read',
'', $a_forum_ref_id)) {
3576 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3581 if ($ref_obj->getType() ===
'frm') {
3583 $frm = $forumObj->Forum;
3584 $frm->setForumId($forumObj->getId());
3585 $frm->setForumRefId($forumObj->getRefId());
3590 if ($this->
access->checkAccess(
'moderate_frm',
'', $a_forum_ref_id)) {
3591 $numPosts = $frm->countUserArticles($a_user_id);
3593 $numPosts = $frm->countActiveUserArticles($a_user_id);
3596 return [$this->
lng->txt(
'forums_posts') => $numPosts];
3601 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3602 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3607 $thread_ids = $this->retrieveThreadIds();
3608 $cmd = $this->
ctrl->getCmd();
3611 if ($thread_ids !== []) {
3612 if ($cmd ===
'move') {
3613 if ($this->is_moderator) {
3615 $this->moveThreadsObject();
3617 } elseif ($cmd ===
'enable_notifications' && (
int) $this->
settings->get(
'forum_notification',
'0') !== 0) {
3618 foreach ($thread_ids as $thread_id) {
3620 $this->ensureThreadBelongsToForum($this->
object->getId(), $tmp_obj);
3621 $tmp_obj->enableNotification($this->
user->getId());
3624 $this->
ctrl->redirect($this,
'showThreads');
3625 } elseif ($cmd ===
'disable_notifications' && (
int) $this->
settings->get(
'forum_notification',
'0') !== 0) {
3626 foreach ($thread_ids as $thread_id) {
3628 $this->ensureThreadBelongsToForum($this->
object->getId(), $tmp_obj);
3629 $tmp_obj->disableNotification($this->
user->getId());
3632 $this->
ctrl->redirect($this,
'showThreads');
3633 } elseif ($cmd ===
'close') {
3634 if ($this->is_moderator) {
3635 foreach ($thread_ids as $thread_id) {
3637 $this->ensureThreadBelongsToForum($this->
object->getId(), $tmp_obj);
3641 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'selected_threads_closed'),
true);
3642 $this->
ctrl->redirect($this,
'showThreads');
3643 } elseif ($cmd ===
'reopen') {
3644 if ($this->is_moderator) {
3645 foreach ($thread_ids as $thread_id) {
3647 $this->ensureThreadBelongsToForum($this->
object->getId(), $tmp_obj);
3652 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'selected_threads_reopened'),
true);
3653 $this->
ctrl->redirect($this,
'showThreads');
3654 } elseif ($cmd ===
'makesticky') {
3655 if ($this->is_moderator) {
3656 $message = $this->
lng->txt(
'sel_threads_make_sticky');
3658 foreach ($thread_ids as $thread_id) {
3660 $this->ensureThreadBelongsToForum($this->
object->getId(), $tmp_obj);
3661 $makeSticky = $tmp_obj->makeSticky();
3663 $message = $this->
lng->txt(
'sel_threads_already_sticky');
3668 $this->tpl->setOnScreenMessage(
'info',
$message,
true);
3670 $this->
ctrl->redirect($this,
'showThreads');
3671 } elseif ($cmd ===
'unmakesticky' || $cmd ===
'make_topics_non_sticky') {
3672 if ($this->is_moderator) {
3673 $message = $this->
lng->txt(
'sel_threads_make_unsticky');
3674 foreach ($thread_ids as $thread_id) {
3676 $this->ensureThreadBelongsToForum($this->
object->getId(), $tmp_obj);
3677 $unmakeSticky = $tmp_obj->unmakeSticky();
3678 if (!$unmakeSticky) {
3679 $message = $this->
lng->txt(
'sel_threads_already_unsticky');
3685 $this->tpl->setOnScreenMessage(
'info',
$message,
true);
3687 $this->
ctrl->redirect($this,
'showThreads');
3688 } elseif ($cmd ===
'editThread') {
3689 if ($this->is_moderator) {
3690 $count = count($thread_ids);
3692 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_max_one_thread'),
true);
3693 $this->
ctrl->redirect($this,
'showThreads');
3695 $this->updateThreadObject();
3700 $this->
ctrl->redirect($this,
'showThreads');
3701 } elseif ($cmd ===
'confirmDeleteThreads') {
3702 $this->confirmDeleteThreadsObject();
3703 } elseif ($cmd ===
'mergeThreads') {
3704 $this->mergeThreadsObject();
3706 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'topics_please_select_one_action'),
true);
3707 $this->
ctrl->redirect($this,
'showThreads');
3710 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
3711 $this->
ctrl->redirect($this,
'showThreads');
3717 if (!$this->is_moderator) {
3718 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3721 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3722 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3726 if ($this->
http->wrapper()->post()->has(
'frm_ref_id')) {
3727 $frm_ref_id = $this->
http->wrapper()->post()->retrieve(
3732 $this->
error->raiseError(
'Please select a forum', $this->
error->MESSAGE);
3736 if (!is_array($threads2move) || $threads2move === []) {
3737 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
3738 $this->
ctrl->redirect($this,
'showThreads');
3741 if (!$this->
access->checkAccess(
'read',
'', (
int) $frm_ref_id)) {
3742 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3746 array_walk($threads2move,
function (
int $threadId) use (&$threads):
void {
3748 $this->ensureThreadBelongsToForum($this->
object->getId(), $thread);
3750 $threads[] = $threadId;
3753 if (isset($frm_ref_id) && (
int) $frm_ref_id) {
3754 $errorMessages = $this->
object->Forum->moveThreads(
3757 $this->ilObjDataCache->lookupObjId((
int) $frm_ref_id)
3760 if ([] !== $errorMessages) {
3761 $this->tpl->setOnScreenMessage(
'failure', implode(
'<br><br>', $errorMessages),
true);
3762 $this->
ctrl->redirect($this,
'showThreads');
3766 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'threads_moved_successfully'),
true);
3767 $this->
ctrl->redirect($this,
'showThreads');
3769 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'no_forum_selected'));
3770 $this->moveThreadsObject();
3777 $this->
ctrl->redirect($this,
'showThreads');
3782 if (!$this->is_moderator) {
3783 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3786 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3787 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3790 $frm_ref_id = $this->
http->wrapper()->post()->retrieve(
3792 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(
null)])
3796 if (!is_array($threads2move) || $threads2move === []) {
3797 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
3798 $this->
ctrl->redirect($this,
'showThreads');
3802 $isModerator = $this->is_moderator;
3803 array_walk($threads2move,
function (
int $threadId) use (&$threads, $isModerator):
void {
3805 $this->ensureThreadBelongsToForum($this->
object->getId(), $thread);
3807 $threads[] = $thread;
3811 $exp->setPathOpen($this->
object->getRefId());
3812 $exp->setNodeSelected(isset($frm_ref_id) && (
int) $frm_ref_id ? (
int) $frm_ref_id : 0);
3813 $exp->setCurrentFrmRefId($this->
object->getRefId());
3814 $exp->setHighlightedNode((
string) $this->
object->getRefId());
3815 if (!$exp->handleCommand()) {
3817 'tpl.forums_threads_move.html',
3820 'components/ILIAS/Forum'
3823 if (!$this->hideToolbar()) {
3824 $this->
toolbar->addButton($this->
lng->txt(
'back'), $this->ctrl->getLinkTarget($this));
3828 foreach ($threads as $thread) {
3829 $messages[] = $this->ui_factory->messageBox()->info(
3830 sprintf($this->
lng->txt(
'move_chosen_topics'), $thread->getSubject())
3833 $moveThreadTemplate->setVariable(
'THREAD_MESSAGE', $this->uiRenderer->render(
$messages));
3834 $moveThreadTemplate->setVariable(
'FRM_SELECTION_TREE', $exp->getHTML());
3835 $moveThreadTemplate->setVariable(
'CMD_SUBMIT',
'performMoveThreads');
3836 $moveThreadTemplate->setVariable(
'TXT_SUBMIT', $this->
lng->txt(
'move'));
3837 $moveThreadTemplate->setVariable(
'FORMACTION', $this->
ctrl->getFormAction($this,
'performMoveThreads'));
3839 $this->tpl->setContent($moveThreadTemplate->get());
3848 $this->objProperties->isAnonymized() &&
3849 (!$this->is_moderator || !$this->objProperties->getMarkModeratorPosts())
3855 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3856 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3859 $draftIds = array_filter((array) ($this->httpRequest->getParsedBody()[
'draft_ids'] ?? []));
3862 $checkedDraftIds = [];
3863 foreach ($draftIds as $draftId) {
3864 if (array_key_exists($draftId, $instances)) {
3865 $checkedDraftIds[] = $draftId;
3866 $draft = $instances[$draftId];
3868 $this->deleteMobsOfDraft($draft->getDraftId(), $draft->getPostMessage());
3870 $GLOBALS[
'ilAppEventHandler']->raise(
3871 'components/ILIAS/Forum',
3874 'draftObj' => $draft,
3875 'obj_id' => $this->
object->getId(),
3876 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
3881 $draftFileData->delete([$draft->getDraftId()]);
3883 $draft->deleteDraft();
3887 if (count($checkedDraftIds) > 1) {
3888 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'delete_drafts_successfully'),
true);
3890 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'delete_draft_successfully'),
true);
3892 $this->
ctrl->redirect($this,
'showThreads');
3897 $draftId = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
3898 $allowNotification = !$this->objProperties->isAnonymized() && !$this->
user->isAnonymous();
3901 if (!$this->
rbac->system()->checkAccess(
'internal_mail', $mail->getMailObjectReferenceId())) {
3902 $allowNotification =
false;
3907 $this->objProperties,
3908 $this->isWritingWithPseudonymAllowed(),
3920 $default_form->generateDefaultForm();
3922 $this->decorateWithAutosave($default_form);
3924 return $default_form;
3929 $draftId = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
3930 $allowNotification = !$this->objProperties->isAnonymized() && !$this->
user->isAnonymous();
3933 if (!$this->
rbac->system()->checkAccess(
'internal_mail', $mail->getMailObjectReferenceId())) {
3934 $allowNotification =
false;
3939 $this->objProperties,
3940 $this->isWritingWithPseudonymAllowed(),
3949 $minimal_form->generateMinimalForm();
3951 return $minimal_form;
3956 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3957 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3960 if (!$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId())) {
3961 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3964 $tpl =
new ilTemplate(
'tpl.create_thread_form.html',
true,
true,
'components/ILIAS/Forum');
3967 $accordion->setId(
'acc_' . $this->obj_id);
3970 $accordion->addItem($this->
lng->txt(
'new_thread_with_post'), $this->buildThreadForm()->getHTML());
3971 $accordion->addItem($this->
lng->txt(
'empty_thread'), $this->buildMinimalThreadForm()->getHTML());
3973 $tpl->
setVariable(
'CREATE_FORM', $accordion->getHTML());
3976 $this->tpl->setContent($tpl->
get());
3984 if (!$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
3985 !$this->access->checkAccess(
'read',
'', $this->object->getRefId())) {
3986 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3989 $frm = $this->
object->Forum;
3990 $frm->setForumId($this->
object->getId());
3991 $frm->setForumRefId($this->
object->getRefId());
3992 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
3993 $topicData = $frm->getOneTopic();
3995 $form = $this->buildThreadForm($createFromDraft);
3996 $minimal_form = $this->buildMinimalThreadForm($createFromDraft);
3998 if ($form->checkInput()) {
3999 $userIdForDisplayPurposes = $this->
user->getId();
4000 if ($this->isWritingWithPseudonymAllowed()) {
4001 $userIdForDisplayPurposes = 0;
4006 ($this->objProperties->isPostActivationEnabled() && !$this->is_moderator) ||
4007 $this->objCurrentPost->isAnyParentDeactivated()
4012 if ($createFromDraft) {
4014 $newThread->setForumId($topicData->getTopPk());
4017 $newThread->setSubject($this->handleFormInput($form->getInput(
'subject'),
false));
4020 $newPost = $frm->generateThread(
4029 $newThread->setForumId($topicData->getTopPk());
4030 $newThread->setThrAuthorId($this->
user->getId());
4031 $newThread->setDisplayUserId($userIdForDisplayPurposes);
4032 $newThread->setSubject($this->handleFormInput($form->getInput(
'subject'),
false));
4034 $form->getInput(
'alias'),
4035 $this->objProperties->isAnonymized()
4038 $newPost = $frm->generateThread(
4041 $form->getItemByPostVar(
'notify') && $form->getInput(
'notify') && !$this->user->isAnonymous(),
4049 $post_obj->setRCID($draft->
getRCID());
4050 $post_obj->update();
4053 if ($this->objProperties->isFileUploadAllowed()) {
4054 $file = $_FILES[
'userfile'];
4055 if (is_array($file) && !empty($file)) {
4057 $fileData->storeUploadedFiles();
4061 $frm->setDbTable(
'frm_data');
4062 $frm->setMDB2WhereCondition(
'top_pk = %s ', [
'integer'], [$topicData->getTopPk()]);
4063 $frm->updateVisits($topicData->getTopPk());
4065 if ($createFromDraft) {
4070 foreach ($mediaObjects as $mob) {
4079 $draftHistory->deleteHistoryByDraftIds([$draft->
getDraftId()]);
4083 $GLOBALS[
'ilAppEventHandler']->raise(
4084 'components/ILIAS/Forum',
4087 'object' => $this->
object,
4088 'ref_id' => $this->
object->getRefId(),
4089 'post' => $post_obj,
4090 'notify_moderators' => !$status
4094 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'forums_thread_new_entry'),
true);
4095 $this->
ctrl->redirect($this);
4098 $form->setValuesByPost();
4099 if (!$this->objProperties->isAnonymized()) {
4100 $form->getItemByPostVar(
'alias')->setValue($this->
user->getLogin());
4104 $accordion->setId(
'acc_' . $this->obj_id);
4106 $accordion->addItem($this->
lng->txt(
'new_thread_with_post'), $form->getHTML());
4107 $accordion->addItem($this->
lng->txt(
'empty_thread'), $minimal_form->getHTML());
4109 $this->tpl->setContent($accordion->getHTML());
4117 if (!$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4118 !$this->access->checkAccess(
'read',
'', $this->object->getRefId())) {
4119 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4122 $frm = $this->
object->Forum;
4123 $frm->setForumId($this->
object->getId());
4124 $frm->setForumRefId($this->
object->getRefId());
4125 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
4126 $topicData = $frm->getOneTopic();
4128 $form = $this->buildThreadForm();
4129 $minimal_form = $this->buildMinimalThreadForm();
4131 if ($minimal_form->checkInput()) {
4132 $userIdForDisplayPurposes = $this->
user->getId();
4133 if ($this->isWritingWithPseudonymAllowed()) {
4134 $userIdForDisplayPurposes = 0;
4139 ($this->objProperties->isPostActivationEnabled() && !$this->is_moderator) ||
4140 $this->objCurrentPost->isAnyParentDeactivated()
4146 $newThread->setForumId($topicData->getTopPk());
4147 $newThread->setThrAuthorId($this->
user->getId());
4148 $newThread->setDisplayUserId($userIdForDisplayPurposes);
4149 $newThread->setSubject($this->handleFormInput($minimal_form->getInput(
'subject'),
false));
4151 $minimal_form->getInput(
'alias'),
4152 $this->objProperties->isAnonymized()
4155 $frm->generateThread(
4164 $frm->setDbTable(
'frm_data');
4165 $frm->setMDB2WhereCondition(
'top_pk = %s ', [
'integer'], [$topicData->getTopPk()]);
4166 $frm->updateVisits($topicData->getTopPk());
4168 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'forums_thread_new_entry'),
true);
4169 $this->
ctrl->redirect($this);
4172 $form->setValuesByPost();
4174 if (!$this->objProperties->isAnonymized()) {
4175 $form->getItemByPostVar(
'alias')->setValue($this->
user->getLogin());
4179 $accordion->setId(
'acc_' . $this->obj_id);
4181 $accordion->addItem($this->
lng->txt(
'new_thread_with_post'), $form->getHTML());
4182 $accordion->addItem($this->
lng->txt(
'empty_thread'), $minimal_form->getHTML());
4184 $this->tpl->setContent($accordion->getHTML());
4190 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4194 $this->checkDraftAccess($draft);
4196 $this->createThread($draft,
true);
4204 $this->checkDraftAccess($draft);
4207 $this->createThread($draft);
4212 $this->createEmptyThread();
4217 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId()) || $this->user->isAnonymous()) {
4218 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4221 $frm = $this->
object->Forum;
4222 $frm->setForumId($this->
object->getId());
4223 $frm->enableForumNotification($this->
user->getId());
4225 if ($this->objCurrentTopic->getId() > 0) {
4226 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4227 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_enabled'),
true);
4228 $this->
ctrl->redirect($this,
'viewThread');
4231 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_enabled'));
4232 $this->showThreadsObject();
4237 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId()) || $this->user->isAnonymous()) {
4238 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4241 $frm = $this->
object->Forum;
4242 $frm->setForumId($this->
object->getId());
4243 $frm->disableForumNotification($this->
user->getId());
4245 if ($this->objCurrentTopic->getId() > 0) {
4246 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4247 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_disabled'),
true);
4248 $this->
ctrl->redirect($this,
'viewThread');
4251 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_disabled'));
4252 $this->showThreadsObject();
4261 if ($this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
4263 if ($news_set->get(
'enable_rss_for_internal')) {
4274 $this->
object->getTitle(),
4275 $this->ctrl->getLinkTarget($this),
4277 $this->object->getRefId()
4284 $a_text = str_replace([
'<',
'>'], [
'<',
'>'], $a_text);
4285 if ($a_stripslashes) {
4294 $a_text = str_replace([
'<',
'>'], [
'<',
'>'], $a_text);
4302 !$this->
access->checkAccess(
'visible',
'', $this->object->getRefId()) &&
4303 !$this->access->checkAccess(
'read',
'', $this->object->getRefId())
4305 $this->
error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
4308 if (strtolower($this->
ctrl->getCmd() ??
'') ===
'infoscreen') {
4309 $this->
ctrl->redirectByClass(ilInfoScreenGUI::class,
'showSummary');
4313 $info->enablePrivateNotes();
4319 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4320 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4323 if ($this->objCurrentPost->getId() > 0) {
4324 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
4326 $this->
object->markPostUnread($this->
user->getId(), $this->objCurrentPost->getId());
4328 $this->viewThreadObject();
4333 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4334 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4337 if ($this->objCurrentTopic->getId() > 0 && $this->objCurrentPost->getId() > 0) {
4338 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
4340 $this->
object->markPostRead(
4341 $this->
user->getId(),
4342 $this->objCurrentTopic->getId(),
4343 $this->objCurrentPost->getId()
4347 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4348 $this->
ctrl->redirect($this,
'viewThread');
4353 $lg = parent::initHeaderAction();
4359 if ($this->
user->isAnonymous() || !$this->access->checkAccess(
'read',
'', $this->object->getRefId())) {
4363 $frm = $this->
object->Forum;
4364 $frm->setForumId($this->
object->getId());
4365 $frm->setForumRefId($this->
object->getRefId());
4366 $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
4368 $are_notifications_enabled = $frm->isForumNotificationEnabled($this->
user->getId());
4369 $has_membership_enabled_parent_container = $this->
object->isParentMembershipEnabledContainer();
4370 $user_may_disable_notifcations = (
4371 $this->isUserAllowedToDeactivateNotification() ||
4372 !$has_membership_enabled_parent_container
4375 if ($this->objCurrentTopic->getId() > 0) {
4376 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4379 if (!$this->
user->isAnonymous()) {
4380 if ($has_membership_enabled_parent_container) {
4381 if ($are_notifications_enabled && $user_may_disable_notifcations) {
4382 $lg->addCustomCommand(
4383 $this->
ctrl->getLinkTarget($this,
'disableForumNotification'),
4384 'forums_disable_forum_notification'
4386 } elseif (!$are_notifications_enabled) {
4387 $lg->addCustomCommand(
4388 $this->
ctrl->getLinkTarget($this,
'enableForumNotification'),
4389 'forums_enable_forum_notification'
4392 } elseif ($are_notifications_enabled) {
4393 $lg->addCustomCommand(
4394 $this->
ctrl->getLinkTarget($this,
'disableForumNotification'),
4395 'forums_disable_forum_notification'
4398 $lg->addCustomCommand(
4399 $this->
ctrl->getLinkTarget($this,
'enableForumNotification'),
4400 'forums_enable_forum_notification'
4405 if ($are_notifications_enabled && $user_may_disable_notifcations && !$this->
user->isAnonymous()) {
4407 $frm_noti->setUserId($this->
user->getId());
4408 $interested_events = $frm_noti->readInterestedEvents();
4410 $events_form_builder = $this->eventsFormBuilder([
4411 'hidden_value' =>
'',
4419 $notificationsModal = $this->uiFactory->modal()->roundtrip(
4420 $this->
lng->txt(
'notification_settings'),
4421 [$events_form_builder->build()]
4422 )->withActionButtons([
4425 ->primary($this->
lng->txt(
'save'),
'#')
4426 ->withOnLoadCode(function (
string $id):
string {
4429 const button = document.getElementById('$id');
4430 if (!button) return;
4432 const modalDialog = button.closest('.modal-dialog');
4433 if (!modalDialog) return;
4435 const form = modalDialog.querySelector('.modal-body form');
4438 form.classList.add('ilForumNotificationSettingsForm');
4439 button.addEventListener('click', (event) => {
4440 event.preventDefault();
4450 $showNotificationSettingsBtn = $this->uiFactory->button()
4451 ->shy($this->
lng->txt(
'notification_settings'),
'#')
4453 $notificationsModal->getShowSignal()
4456 $lg->addCustomCommandButton($showNotificationSettingsBtn, $notificationsModal);
4459 $are_thread_notifications_enabled =
false;
4460 if (!$this->
user->isAnonymous() && $this->objCurrentTopic->getId() > 0) {
4461 $are_thread_notifications_enabled = $this->objCurrentTopic->isNotificationEnabled($this->
user->getId());
4462 if ($are_thread_notifications_enabled) {
4463 $lg->addCustomCommand(
4464 $this->
ctrl->getLinkTarget($this,
'toggleThreadNotification'),
4465 'forums_disable_notification'
4468 $lg->addCustomCommand(
4469 $this->
ctrl->getLinkTarget($this,
'toggleThreadNotification'),
4470 'forums_enable_notification'
4474 $this->
ctrl->setParameter($this,
'thr_pk',
'');
4476 if (!$this->
user->isAnonymous()) {
4477 if ($are_notifications_enabled || $are_thread_notifications_enabled) {
4481 $this->
lng->txt(
'frm_notification_activated')
4487 $this->
lng->txt(
'frm_notification_deactivated')
4501 if ($this->objCurrentTopic->getId() > 0) {
4502 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4506 $this->
ctrl->getFormAction($this,
'saveUserNotificationSettings'),
4515 $events_form_builder = $this->eventsFormBuilder();
4517 if ($this->httpRequest->getMethod() ===
'POST') {
4518 $form = $events_form_builder->build()->withRequest($this->httpRequest);
4519 $formData = $form->getData();
4523 foreach ($events_form_builder->getValidEvents() as $event) {
4524 $interested_events += isset($formData[$event]) && $formData[$event] ? $events_form_builder->getValueForEvent(
4530 $frm_noti->setUserId($this->
user->getId());
4531 $frm_noti->setInterestedEvents($interested_events);
4532 $frm_noti->updateInterestedEvents();
4535 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
4537 if ($this->objCurrentTopic->getId() > 0) {
4538 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4539 $this->
ctrl->redirect($this,
'viewThread');
4542 $this->
ctrl->redirect($this,
'showThreads');
4551 if (!$this->objProperties->isUserToggleNoti() &&
4552 $this->objProperties->getNotificationType() === NotificationType::ALL_USERS) {
4556 if ($this->objProperties->getNotificationType() === NotificationType::PER_USER &&
4557 $this->object->isParentMembershipEnabledContainer()) {
4559 $frm_noti->setUserId($this->
user->getId());
4561 return !$frm_noti->isUserToggleNotification();
4569 if (!$this->is_moderator) {
4570 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4573 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4574 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4577 $threadIdToMerge = $this->
http->wrapper()->query()->retrieve(
4580 $this->refinery->kindlyTo()->int(),
4581 $this->refinery->always(0)
4584 if ($threadIdToMerge <= 0) {
4585 $threadIds = array_values(
4586 array_filter(array_map(intval(...), (array) ($this->httpRequest->getParsedBody()[
'thread_ids'] ?? [])))
4588 if (count($threadIds) === 1) {
4589 $threadIdToMerge = current($threadIds);
4591 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'));
4592 $this->showThreadsObject();
4597 $frm = $this->
object->Forum;
4598 $frm->setForumId($this->
object->getId());
4599 $frm->setForumRefId($this->
object->getRefId());
4604 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'not_allowed_to_merge_into_another_forum'));
4605 $this->showThreadsObject();
4609 $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
4612 'tpl.forums_threads_liste.html',
4615 'components/ILIAS/Forum'
4618 $topicData = $frm->getOneTopic();
4619 if ($topicData->getTopPk() > 0) {
4620 $this->
ctrl->setParameter($this,
'merge_thread_id', $threadIdToMerge);
4624 (
int) $this->httpRequest->getQueryParams()[
'ref_id'],
4628 $tbl->setSelectedThread($threadToMerge);
4629 $tbl->setMapper($frm)->fetchData();
4631 $threadsTemplate->setVariable(
'THREADS_TABLE', $tbl->getHTML());
4632 $this->tpl->setContent($threadsTemplate->get());
4634 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
4635 $this->showThreadsObject();
4641 if (!$this->is_moderator) {
4642 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4645 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4646 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4649 $sourceThreadId = (
int) ($this->httpRequest->getQueryParams()[
'merge_thread_id'] ?? 0);
4650 $targetThreadIds = array_values(
4651 array_filter(array_map(intval(...), (array) ($this->httpRequest->getParsedBody()[
'thread_ids'] ?? [])))
4654 if ($sourceThreadId <= 0 || count($targetThreadIds) !== 1) {
4655 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
4656 $this->mergeThreadsObject();
4660 $targetThreadId = current($targetThreadIds);
4661 if ($sourceThreadId === $targetThreadId) {
4662 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'error_same_thread_ids'));
4663 $this->showThreadsObject();
4668 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'not_allowed_to_merge_into_another_forum'));
4669 $this->
ctrl->clearParameters($this);
4670 $this->showThreadsObject();
4675 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'switch_threads_for_merge'));
4678 $this->ensureThreadBelongsToForum($this->
object->getId(),
new ilForumTopic($sourceThreadId));
4679 $this->ensureThreadBelongsToForum($this->
object->getId(),
new ilForumTopic($targetThreadId));
4683 $c_gui->setFormAction($this->
ctrl->getFormAction($this,
'performMergeThreads'));
4684 $c_gui->setHeaderText($this->
lng->txt(
'frm_sure_merge_threads'));
4685 $c_gui->setCancel($this->
lng->txt(
'cancel'),
'showThreads');
4686 $c_gui->setConfirm($this->
lng->txt(
'confirm'),
'performMergeThreads');
4690 (
string) $sourceThreadId,
4695 (
string) $targetThreadId,
4698 $this->tpl->setContent($c_gui->getHTML());
4703 if (!$this->is_moderator) {
4704 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4707 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4708 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4711 $threadIds = array_values(
4712 array_filter(array_map(intval(...), (array) ($this->httpRequest->getParsedBody()[
'thread_ids'] ?? [])))
4714 if (count($threadIds) !== 2) {
4715 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
4716 $this->showThreadsObject();
4720 if ((
int) $threadIds[0] === (
int) $threadIds[1]) {
4721 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'error_same_thread_ids'));
4722 $this->showThreadsObject();
4728 $frm->setForumId($this->
object->getId());
4729 $frm->setForumRefId($this->
object->getRefId());
4731 $this->ensureThreadBelongsToForum($this->
object->getId(),
new ilForumTopic((
int) $threadIds[0]));
4732 $this->ensureThreadBelongsToForum($this->
object->getId(),
new ilForumTopic((
int) $threadIds[1]));
4734 $frm->mergeThreads((
int) $threadIds[0], (
int) $threadIds[1]);
4735 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'merged_threads_successfully'));
4737 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt($e->getMessage()));
4740 $this->showThreadsObject();
4745 $content = $this->getRightColumnHTML();
4746 if (!$this->
ctrl->isAsynch()) {
4747 $content = implode(
'', [
4752 $this->tpl->setRightContent($content);
4757 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4758 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4762 $this->checkDraftAccess($draft);
4764 if (!$fileData->deliverZipFile()) {
4765 $this->
ctrl->redirect($this);
4771 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4772 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4775 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
4778 if (!$fileData->deliverZipFile()) {
4779 $this->
ctrl->redirect($this);
4786 !$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4787 !$this->access->checkAccess(
'read',
'', $this->object->getRefId())) {
4788 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4791 $frm = $this->
object->Forum;
4792 $frm->setForumId($this->
object->getId());
4793 $frm->setForumRefId($this->
object->getRefId());
4796 $draftId = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
4799 $this->checkDraftAccess($draft);
4802 $do_history_check = (bool) ($this->httpRequest->getQueryParams()[
'hist_check'] ??
true);
4804 $this->doHistoryCheck($draft->getDraftId());
4808 $this->
ctrl->setParameter($this,
'draft_id', $draftId);
4810 $form = $this->buildThreadForm(
true);
4811 $form->setValuesByArray([
4812 'alias' => $draft->getPostUserAlias(),
4813 'subject' => $draft->getPostSubject(),
4815 'notify' => $draft->isNotificationEnabled() && !$this->user->isAnonymous(),
4818 'draft_id' => $draftId
4822 $this->tpl->setContent($form->getHTML() . $this->modal_history);
4828 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4831 $historyId = (
int) ($this->httpRequest->getQueryParams()[
'history_id'] ?? 0);
4834 $this->checkDraftAccess($history->getDraftId());
4836 $draft = $history->rollbackAutosave();
4837 if ($draft->getThreadId() === 0 && $draft->getPostId() === 0) {
4838 $this->
ctrl->setParameter($this,
'draft_id', $history->getDraftId());
4839 $this->
ctrl->redirect($this,
'editThreadDraft');
4842 $this->
ctrl->clearParameters($this);
4843 $this->
ctrl->setParameter($this,
'pos_pk', $draft->getPostId());
4844 $this->
ctrl->setParameter($this,
'thr_pk', $draft->getThreadId());
4845 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
4846 $this->
ctrl->setParameter($this,
'action',
'editdraft');
4850 $this->
ctrl->redirect($this,
'viewThread');
4856 !$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4857 !$this->access->checkAccess(
'read',
'', $this->object->getRefId())) {
4858 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4861 $autosave_draft_id = (
int) ($this->httpRequest->getParsedBody()[
'draft_id'] ?? 0);
4862 if ($autosave_draft_id <= 0) {
4863 $autosave_draft_id = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
4866 $frm = $this->
object->Forum;
4867 $frm->setForumId($this->
object->getId());
4868 $frm->setForumRefId($this->
object->getRefId());
4869 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
4870 $topicData = $frm->getOneTopic();
4872 $form = $this->buildThreadForm();
4873 if ($form->checkInput()) {
4874 if ($autosave_draft_id === 0) {
4876 $draft->setForumId($topicData->getTopPk());
4877 $draft->setThreadId(0);
4878 $draft->setPostId(0);
4881 $this->checkDraftAccess($draft);
4884 $draft->setPostSubject($this->handleFormInput($form->getInput(
'subject'),
false));
4887 $form->getInput(
'alias'),
4888 $this->objProperties->isAnonymized()
4890 $draft->setNotificationStatus($form->getInput(
'notify') && !$this->user->isAnonymous());
4891 $draft->setPostAuthorId($this->
user->getId());
4892 $draft->setPostDisplayUserId($this->isWritingWithPseudonymAllowed() ? 0 : $this->
user->getId());
4894 if ($autosave_draft_id === 0) {
4895 $draftId = $draft->saveDraft();
4897 $draft->updateDraft();
4898 $draftId = $draft->getDraftId();
4901 $GLOBALS[
'ilAppEventHandler']->raise(
4902 'components/ILIAS/Forum',
4905 'draftObj' => $draft,
4906 'obj_id' => $this->
object->getId(),
4907 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
4915 $files2delete = $form->getInput(
'del_file');
4916 if (is_array($files2delete) && $files2delete !== []) {
4917 $draftFileData->unlinkFilesByMD5Filenames($files2delete);
4920 if ($this->objProperties->isFileUploadAllowed()) {
4921 $file = $_FILES[
'userfile'];
4922 if (is_array($file) && !empty($file)) {
4923 $draftFileData->storeUploadedFiles();
4927 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
4928 $this->
ctrl->clearParameters($this);
4929 $this->
ctrl->redirect($this,
'showThreads');
4932 $this->requestAction = substr($this->requestAction, 6);
4933 $form->setValuesByPost();
4934 $this->
ctrl->setParameter($this,
'draft_id', $autosave_draft_id);
4935 $this->tpl->setContent($form->getHTML());
4941 !$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4942 !$this->access->checkAccess(
'read',
'', $this->object->getRefId())) {
4943 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4947 $this->checkDraftAccess($draft);
4949 $form = $this->buildThreadForm(
true);
4950 if ($form->checkInput()) {
4951 $draft->setPostSubject($this->handleFormInput($form->getInput(
'subject'),
false));
4954 $form->getInput(
'alias'),
4955 $this->objProperties->isAnonymized()
4957 $draft->setNotificationStatus($form->getInput(
'notify') && !$this->user->isAnonymous());
4958 $draft->setPostAuthorId($this->
user->getId());
4959 $draft->setPostDisplayUserId($this->isWritingWithPseudonymAllowed() ? 0 : $this->
user->getId());
4960 $draft->updateDraft();
4962 $GLOBALS[
'ilAppEventHandler']->raise(
4963 'components/ILIAS/Forum',
4966 'draftObj' => $draft,
4967 'obj_id' => $this->
object->getId(),
4968 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
4973 $form->getInput(
'message'),
4975 $draft->getDraftId(),
4977 $draft->getDraftId()
4982 $files2delete = $form->getInput(
'del_file');
4983 if (is_array($files2delete) && $files2delete !== []) {
4984 $draftFileData->unlinkFilesByMD5Filenames($files2delete);
4987 if ($this->objProperties->isFileUploadAllowed()) {
4988 $file = $_FILES[
'userfile'];
4989 if (is_array($file) && !empty($file) && isset($file[
'full_path'][0]) && !empty($file[
'full_path'][0])) {
4990 $draftFileData->storeUploadedFiles();
4994 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
4995 $this->
ctrl->clearParameters($this);
4996 $this->
ctrl->redirect($this,
'showThreads');
4999 $form->setValuesByPost();
5000 $this->
ctrl->setParameter($this,
'hist_check', 0);
5001 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5002 $this->editThreadDraftObject($form);
5007 $this->saveAsDraftObject();
5013 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
5014 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5017 $autosave_draft_id = $this->
http->wrapper()->post()->retrieve(
5020 $this->refinery->kindlyTo()->int(),
5021 $this->refinery->always(
null)
5025 if ($this->objCurrentTopic->getId() === 0) {
5026 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
5027 $this->
ctrl->redirect($this);
5030 if ($this->objCurrentTopic->isClosed()) {
5031 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
5032 $this->
ctrl->redirect($this);
5035 $oReplyEditForm = $this->getReplyEditForm();
5036 if ($oReplyEditForm->checkInput()) {
5037 if ($this->objCurrentPost->getId() === 0) {
5038 $this->requestAction =
'';
5039 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'),
true);
5040 $this->viewThreadObject();
5044 $oForumObjects = $this->getForumObjects();
5045 $frm = $oForumObjects[
'frm'];
5046 $frm->setMDB2WhereCondition(
' top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
5047 $topicData = $frm->getOneTopic();
5049 if ($this->requestAction ===
'ready_showreply') {
5050 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5051 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5054 if ($autosave_draft_id > 0) {
5056 $this->checkDraftAccess($draftObj->getDraftId());
5059 $this->ensureThreadBelongsToForum($this->
object->getId(), $this->objCurrentPost->getThread());
5060 $draftObj->setForumId($topicData->getTopPk());
5061 $draftObj->setThreadId($this->objCurrentTopic->getId());
5062 $draftObj->setPostId($this->objCurrentPost->getId());
5065 $draftObj->setPostSubject($this->handleFormInput($oReplyEditForm->getInput(
'subject'),
false));
5068 $oReplyEditForm->getInput(
'alias'),
5069 $this->objProperties->isAnonymized()
5071 $draftObj->setNotificationStatus($oReplyEditForm->getInput(
'notify') && !$this->user->isAnonymous());
5072 $draftObj->setPostNotificationStatus($oReplyEditForm->getInput(
'notify_post') && !$this->user->isAnonymous());
5074 $draftObj->setPostAuthorId($this->
user->getId());
5075 $draftObj->setPostDisplayUserId(($this->isWritingWithPseudonymAllowed() ? 0 : $this->
user->getId()));
5077 if ($autosave_draft_id === 0) {
5078 $draft_id = $draftObj->saveDraft();
5080 $draftObj->updateDraft();
5081 $draft_id = $draftObj->getDraftId();
5086 $oReplyEditForm->getInput(
'message'),
5093 if ($this->objProperties->isFileUploadAllowed()) {
5094 $file = $_FILES[
'userfile'];
5095 if (is_array($file) && !empty($file)) {
5097 $oFDForumDrafts->storeUploadedFiles();
5101 $GLOBALS[
'ilAppEventHandler']->raise(
5102 'components/ILIAS/Forum',
5105 'draftObj' => $draftObj,
5106 'obj_id' => $this->
object->getId(),
5107 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5112 if (is_array($frm_session_values)) {
5113 $frm_session_values[$this->objCurrentPost->getThreadId()][
'openTreeNodes'][] = $this->objCurrentPost->getId();
5117 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
5118 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5119 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5120 $this->
ctrl->redirect($this,
'viewThread');
5123 $oReplyEditForm->setValuesByPost();
5124 $this->requestAction = substr($this->requestAction, 6);
5126 $this->viewThreadObject();
5131 $this->doHistoryCheck($this->retrieveDraftId());
5132 $this->viewThreadObject();
5138 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
5139 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5142 if ($this->objCurrentTopic->getId() === 0) {
5143 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
5144 $this->
ctrl->redirect($this);
5147 if ($this->objCurrentTopic->isClosed()) {
5148 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
5149 $this->
ctrl->redirect($this);
5152 if ($this->objCurrentPost->getId() === 0) {
5153 $this->requestAction =
'';
5154 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'));
5155 $this->viewThreadObject();
5159 $oReplyEditForm = $this->getReplyEditForm();
5160 if ($oReplyEditForm->checkInput()) {
5161 $oForumObjects = $this->getForumObjects();
5162 $forumObj = $oForumObjects[
'forumObj'];
5164 if (!$this->
user->isAnonymous() && in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
5165 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5166 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5170 $this->
user->getId(),
5171 $this->objCurrentPost->getId(),
5172 $this->retrieveDraftId()
5175 $this->checkDraftAccess($draft);
5177 $draft->setPostSubject($this->handleFormInput($oReplyEditForm->getInput(
'subject'),
false));
5179 $oReplyEditForm->getInput(
'message')
5182 $oReplyEditForm->getInput(
'alias'),
5183 $this->objProperties->isAnonymized()
5185 $draft->setNotificationStatus($oReplyEditForm->getInput(
'notify') && !$this->user->isAnonymous());
5186 $draft->setUpdateUserId($this->
user->getId());
5187 $draft->setPostAuthorId($this->
user->getId());
5188 $draft->setPostDisplayUserId($this->isWritingWithPseudonymAllowed() ? 0 : $this->
user->getId());
5190 $draft->updateDraft();
5192 $GLOBALS[
'ilAppEventHandler']->raise(
5193 'components/ILIAS/Forum',
5196 'draftObj' => $draft,
5197 'obj_id' => $this->
object->getId(),
5198 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5204 foreach ($uploadedObjects as $mob) {
5209 $oReplyEditForm->getInput(
'message'),
5211 $draft->getDraftId()
5216 $file2delete = $oReplyEditForm->getInput(
'del_file');
5217 if (is_array($file2delete) && count($file2delete)) {
5218 $oFDForumDrafts->unlinkFilesByMD5Filenames($file2delete);
5221 if ($this->objProperties->isFileUploadAllowed()) {
5222 $file = $_FILES[
'userfile'];
5223 if (is_array($file) && !empty($file)) {
5224 $oFDForumDrafts->storeUploadedFiles();
5229 if (is_array($frm_session_values)) {
5230 $frm_session_values[$this->objCurrentPost->getThreadId()][
'openTreeNodes'][] = $this->objCurrentPost->getId();
5233 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
5234 $this->
ctrl->clearParameters($this);
5235 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5236 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5237 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
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', $this->retrieveDraftId());
5244 $this->
ctrl->setParameter($this,
'action',
'editdraft');
5245 $oReplyEditForm->setValuesByPost();
5246 $this->viewThreadObject();
5249 $this->
ctrl->clearParameters($this);
5250 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5251 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5252 $this->
ctrl->redirect($this,
'viewThread');
5259 foreach ($oldMediaObjects as $oldMob) {
5261 foreach ($curMediaObjects as $curMob) {
5262 if ($oldMob === $curMob) {
5277 $draft =
new ilForumPostDraft($this->
user->getId(), $this->objCurrentPost->getId(), $this->retrieveDraftId());
5278 $this->checkDraftAccess($draft);
5280 $this->deleteMobsOfDraft($draft->getDraftId(), $draft->getPostMessage());
5283 $objFileDataForumDrafts->delete([$draft->getDraftId()]);
5285 $GLOBALS[
'ilAppEventHandler']->raise(
5286 'components/ILIAS/Forum',
5289 'draftObj' => $draft,
5290 'obj_id' => $this->
object->getId(),
5291 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5294 $draft->deleteDraft();
5296 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'delete_draft_successfully'),
true);
5297 $this->
ctrl->clearParameters($this);
5298 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5299 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5300 $this->
ctrl->redirect($this,
'viewThread');
5305 if ($this->requestAction !==
'ready_showreply' &&
5307 $this->
access->checkAccess(
'read',
'', $this->object->getRefId()) &&
5308 $this->access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5311 $this->getReplyEditForm(),
5312 $this->objProperties,
5313 $this->objCurrentTopic,
5314 $this->objCurrentPost,
5316 $this->retrieveDraftId(),
5321 $this->
http->saveResponse($this->
http->response()->withBody(
5322 \
ILIAS\Filesystem\Stream\Streams::ofString(json_encode(
5323 $action->executeAndGetResponseObject(),
5329 $this->
http->sendResponse();
5330 $this->
http->close();
5335 if ($this->requestAction !==
'ready_showreply' &&
5337 $this->
access->checkAccess(
'read',
'', $this->object->getRefId()) &&
5338 $this->access->checkAccess(
'add_thread',
'', $this->object->getRefId())) {
5341 $this->buildThreadForm(),
5342 $this->objProperties,
5343 $this->objCurrentTopic,
5344 $this->objCurrentPost,
5346 $this->retrieveDraftId(),
5351 $this->
http->saveResponse($this->
http->response()->withBody(
5352 \
ILIAS\Filesystem\Stream\Streams::ofString(json_encode(
5353 $action->executeAndGetResponseObject(),
5359 $this->
http->sendResponse();
5360 $this->
http->close();
5371 $draft_id = $this->retrieveDraftId();
5375 if (($this->objCurrentPost->getId() !== $node->
getId() || (
5376 !in_array($action, [
'showreply',
'showedit',
'censor',
'delete'],
true) &&
5377 !$this->displayConfirmPostActivation()
5378 )) && ($this->is_moderator || $node->
isActivated() || $node->
isOwner($this->user->getId()))) {
5379 if ($this->is_moderator && !$this->objCurrentTopic->isClosed() && !$node->
isActivated()) {
5380 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5382 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5383 $this->
ctrl->setParameter(
5386 $this->getOrderByParam()
5388 $primary_action = $this->
ctrl->getLinkTarget(
5390 'askForPostActivation',
5391 (
string) $node->
getId()
5393 $primary_action_language_id =
'activate_post';
5394 $this->
ctrl->clearParameters($this);
5398 $this->access->checkAccess(
'add_reply',
'', $this->object->getRefId())
5400 $this->
ctrl->setParameter($this,
'action',
'showreply');
5401 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5402 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5403 $this->
ctrl->setParameter(
5406 $this->getOrderByParam()
5409 $primary_action = $this->
ctrl->getLinkTarget(
5412 'reply_' . $node->
getId()
5414 $primary_action_language_id =
'reply_to_postings';
5415 $this->
ctrl->clearParameters($this);
5418 !$this->objCurrentTopic->isClosed() &&
5420 !$this->user->isAnonymous() &&
5421 ($node->
isOwner($this->user->getId()) || $this->is_moderator)
5423 $this->
ctrl->setParameter($this,
'action',
'showedit');
5424 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5426 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5427 $this->
ctrl->setParameter(
5430 $this->getOrderByParam()
5432 $actions[
'edit'] = $this->
ctrl->getLinkTarget($this,
'viewThread', (
string) $node->
getId());
5433 $this->
ctrl->clearParameters($this);
5435 if (!$this->
user->isAnonymous()) {
5436 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5438 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5439 $this->
ctrl->setParameter(
5442 $this->getOrderByParam()
5444 $this->
ctrl->setParameter($this,
'viewmode', $this->selectedSorting);
5446 $read_undread_txt =
'frm_mark_as_read';
5447 $read_undread_cmd =
'markPostRead';
5449 $read_undread_txt =
'frm_mark_as_unread';
5450 $read_undread_cmd =
'markPostUnread';
5452 $actions[$read_undread_txt] = $this->
ctrl->getLinkTarget(
5455 (
string) $node->
getId()
5458 $this->
ctrl->clearParameters($this);
5461 $this->
ctrl->setParameterByClass(ilForumExportGUI::class,
'top_pk', $node->
getForumId());
5462 $this->
ctrl->setParameterByClass(ilForumExportGUI::class,
'thr_pk', $node->
getThreadId());
5465 $this->
ctrl->clearParameters($this);
5468 !$this->objCurrentTopic->isClosed() &&
5469 !$this->user->isAnonymous() &&
5470 ($this->is_moderator || ($node->
isOwner($this->user->getId()) && !$node->
hasReplies()))
5472 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5474 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5475 $this->
ctrl->setParameter(
5478 $this->getOrderByParam()
5480 $actions[
'delete'] = $this->
ctrl->getFormAction($this,
'deletePosting');
5481 $this->
ctrl->clearParameters($this);
5483 if ($this->is_moderator && !$this->objCurrentTopic->isClosed()) {
5484 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5486 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5487 $this->
ctrl->setParameter(
5490 $this->getOrderByParam()
5493 $this->
ctrl->setParameter($this,
'action',
'viewThread');
5494 $actions[
'frm_revoke_censorship'] = $this->
ctrl->getFormAction($this,
'revokeCensorship');
5496 $actions[
'frm_censorship'] = $this->
ctrl->getFormAction($this,
'addCensorship');
5498 $this->
ctrl->clearParameters($this);
5501 } elseif ($draft_id !== $draft->getDraftId() || !in_array($action, [
'deletedraft',
'editdraft'])) {
5503 $this->
ctrl->setParameter($this,
'action',
'publishdraft');
5504 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5505 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5506 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5507 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5508 $this->
ctrl->setParameter(
5511 $this->getOrderByParam()
5513 $primary_action = $this->
ctrl->getLinkTarget($this,
'publishSelectedDraft', (
string) $node->
getId());
5514 $primary_action_language_id =
'publish';
5515 $this->
ctrl->clearParameters($this);
5517 $this->
ctrl->setParameter($this,
'action',
'editdraft');
5518 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5519 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5520 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5521 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5522 $this->
ctrl->setParameter(
5525 $this->getOrderByParam()
5527 $actions[
'edit'] = $this->
ctrl->getLinkTarget($this,
'editDraft',
'draft_edit_' . $draft->getDraftId());
5528 $this->
ctrl->clearParameters($this);
5530 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5531 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5532 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5533 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5534 $this->
ctrl->setParameter(
5537 $this->getOrderByParam()
5539 $actions[
'delete'] = $this->
ctrl->getFormAction($this,
'deletePostingDraft');
5540 $this->
ctrl->clearParameters($this);
5542 if ($draft_id !== 0 && $action ===
'editdraft') {
5548 if ($actions !== [] && !$this->objCurrentTopic->isClosed()) {
5550 foreach ($actions as $lng_id =>
$url) {
5551 if ($lng_id ===
'frm_revoke_censorship' || $lng_id ===
'frm_censorship') {
5552 $modalTemplate =
new ilTemplate(
'tpl.forums_censor_modal.html',
true,
true,
'components/ILIAS/Forum');
5553 $form_id = str_replace(
'.',
'_', uniqid(
'form',
true));
5554 $modalTemplate->setVariable(
'FORM_ID', $form_id);
5557 $modalTemplate->setVariable(
'BODY', $this->
lng->txt(
'forums_info_censor2_post'));
5559 $modalTemplate->setVariable(
'BODY', $this->
lng->txt(
'forums_info_censor_post'));
5560 $modalTemplate->touchBlock(
'message');
5563 $modalTemplate->setVariable(
'FORM_ACTION',
$url);
5565 $content = $this->uiFactory->legacy()->content($modalTemplate->get());
5566 $submitBtn = $this->uiFactory->button()->primary(
5567 $this->
lng->txt(
'submit'),
5570 static function (
string $id) use ($form_id):
string {
5573 const button = document.getElementById('$id');
5574 if (!button) return;
5576 const form = document.getElementById('$form_id');
5579 button.addEventListener('click', (event) => {
5580 event.preventDefault();
5587 $modal = $this->uiFactory->modal()->roundtrip(
5588 $this->
lng->txt($lng_id),
5590 )->withActionButtons([$submitBtn]);
5591 $items[] = $this->uiFactory->button()->shy($this->
lng->txt($lng_id),
'#')->withOnClick(
5592 $modal->getShowSignal()
5595 $this->modalActionsContainer[] = $modal;
5599 if ($lng_id ===
'delete') {
5600 $modal = $this->uiFactory->modal()->interruptive(
5601 $this->
lng->txt($lng_id),
5602 str_contains(
$url,
'deletePostingDraft') ?
5603 $this->
lng->txt(
'forums_info_delete_draft') :
5604 $this->lng->txt(
'forums_info_delete_post'),
5606 )->withActionButtonLabel(
5607 $this->
lng->txt(str_contains(
$url,
'deletePostingDraft') ?
'deletePostingDraft' :
'deletePosting')
5610 $items[] = $this->uiFactory->button()->shy($this->
lng->txt($lng_id),
'#')->withOnClick(
5611 $modal->getShowSignal()
5614 $this->modalActionsContainer[] = $modal;
5620 $items[] = $this->uiFactory->button()->shy($this->
lng->txt($lng_id),
$url);
5623 $dropdown = $this->uiFactory->dropdown()->standard($items);
5624 $render_action_buttons = [$dropdown];
5625 if (isset($primary_action, $primary_action_language_id)) {
5626 if ($primary_action_language_id ===
'activate_post') {
5627 $action_button = $this->addActivationFormModal($node);
5629 $action_button = $this->uiFactory->button()->standard(
5630 $this->
lng->txt($primary_action_language_id),
5634 $tpl->
setVariable(
'MAIN_ACTION', $this->uiRenderer->render($action_button));
5636 $tpl->
setVariable(
'DROPDOWN_ACTIONS', $this->uiRenderer->render($render_action_buttons));
5643 if (!$this->hasDraftAccess($draft)) {
5644 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5653 !$this->user->isAnonymous() &&
5654 $this->access->checkAccess(
'add_reply',
'', $this->object->getRefId()) &&
5665 $this->checkDraftAccess($draftId);
5669 if ($draftsFromHistory !== []) {
5670 $form_tpl =
new ilTemplate(
'tpl.restore_thread_draft.html',
true,
true,
'components/ILIAS/Forum');
5673 foreach ($draftsFromHistory as $history_instance) {
5675 $accordion->setId(
'acc_' . $history_instance->getHistoryId());
5677 if ($first_open ===
null) {
5678 $first_open = $history_instance->getHistoryId();
5682 $form_tpl->setCurrentBlock(
'list_item');
5686 $history_instance->getDraftDate(),
5689 $this->
ctrl->setParameter($this,
'history_id', $history_instance->getHistoryId());
5690 $header = $history_date .
': ' . $history_instance->getPostSubject();
5693 'tpl.restore_thread_draft_accordion_content.html',
5696 'components/ILIAS/Forum'
5698 $accordion_tpl->setVariable(
'MESSAGE',
$message);
5699 $accordion_tpl->setVariable(
5701 $this->uiRenderer->render(
5702 $this->uiFactory->button()->standard(
5703 $this->lng->txt(
'restore'),
5704 $this->ctrl->getLinkTarget($this,
'restoreFromHistory')
5708 $accordion->addItem($header, $accordion_tpl->get());
5710 $form_tpl->setVariable(
'ACC_AUTO_SAVE', $accordion->getHTML());
5711 $form_tpl->parseCurrentBlock();
5714 $form_tpl->setVariable(
'RESTORE_DATA_EXISTS',
'found_threat_history_to_restore');
5716 $modal = $this->ui_factory->modal()->interruptive(
5717 $this->
lng->txt(
'restore_draft_from_autosave'),
5720 )->withAdditionalOnLoadCode(
function (
string $id):
string {
5721 return "document.getElementById('$id').dataset.modalId = 'frm_autosave_restore';";
5724 $this->modal_history = $this->ui_renderer->render($modal);
5732 $draft_id = $this->retrieveDraftId();
5733 if ($action ===
'showedit' && (
5734 (!$this->is_moderator && !$node->
isOwner($this->user->getId())) ||
5735 $this->user->isAnonymous() ||
5738 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5739 } elseif ($action ===
'showreply' && !$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5740 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5743 $tpl->
setVariable(
'REPLY_ANKER',
'reply_' . $this->objCurrentPost->getId());
5744 $oEditReplyForm = $this->getReplyEditForm();
5746 if ($action !==
'editdraft') {
5747 switch ($this->objProperties->getSubjectSetting()) {
5748 case 'add_re_to_subject':
5749 $subject = $this->getModifiedReOnSubject();
5752 case 'preset_subject':
5753 $subject = $this->objCurrentPost->getSubject();
5756 case 'empty_subject':
5764 if ($this->
ctrl->getCmd() ===
'savePost' || $this->ctrl->getCmd() ===
'saveAsDraft') {
5765 $oEditReplyForm->setValuesByPost();
5766 } elseif ($this->
ctrl->getCmd() ===
'quotePost') {
5774 $oEditReplyForm->setValuesByPost();
5775 $oEditReplyForm->getItemByPostVar(
'message')->setValue(
5780 $authorinfo->getAuthorName()
5781 ) .
"\n" . $oEditReplyForm->getInput(
'message'),
5786 $oEditReplyForm->setValuesByArray([
5787 'draft_id' => $draft_id,
5789 'subject' => $subject,
5799 if ($this->
ctrl->getCmd() ===
'savePost') {
5800 $oEditReplyForm->setValuesByPost();
5802 $oEditReplyForm->setValuesByArray([
5804 'subject' => $this->objCurrentPost->getSubject(),
5806 $this->objCurrentPost->getMessage(),
5809 'notify' => $this->objCurrentPost->isNotificationEnabled() && !$this->user->isAnonymous(),
5812 'draft_id' => $draft_id
5818 if (in_array($this->
ctrl->getCmd(), [
'saveDraft',
'updateDraft',
'publishDraft'])) {
5819 $oEditReplyForm->setValuesByPost();
5820 } elseif ($draft_id > 0) {
5822 $this->
user->getId(),
5823 $this->objCurrentPost->getId(),
5826 $oEditReplyForm->setValuesByArray([
5827 'alias' => $draftObject->getPostUserAlias(),
5828 'subject' => $draftObject->getPostSubject(),
5830 $draftObject->getPostMessage(),
5833 'notify' => $draftObject->isNotificationEnabled() && !$this->user->isAnonymous(),
5836 'draft_id' => $draft_id
5842 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5843 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5844 $this->
ctrl->setParameter($this,
'page', (
int) ($this->httpRequest->getQueryParams()[
'page'] ?? 0));
5845 $this->
ctrl->setParameter(
5848 $this->getOrderByParam()
5850 $this->
ctrl->setParameter(
5855 if ($action !==
'editdraft') {
5856 $tpl->
setVariable(
'FORM', $oEditReplyForm->getHTML());
5858 $this->
ctrl->clearParameters($this);
5863 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5866 $this->uiFactory->button()->standard(
5867 $this->
lng->txt(
'reset_limited_view_button'),
5868 $this->ctrl->getLinkTarget($this,
'resetLimitedView')
5872 return $this->uiRenderer->render(
5875 ->
info($this->
lng->txt(
'reset_limited_view_info'))
5876 ->withButtons($buttons)
5884 $this->refinery->byTrying([
5885 $this->refinery->kindlyTo()->string(),
5886 $this->refinery->always(
'')
$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, bool $isCatchupWriteEvents=true, $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()
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)
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)
getSortationViewControl(int $offset)
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'))