19 declare(strict_types=1);
72 public \ILIAS\DI\RBACServices
$rbac;
89 $this->httpRequest = $DIC->http()->request();
91 $this->uiFactory = $DIC->ui()->factory();
92 $this->uiRenderer = $DIC->ui()->renderer();
95 $this->ilObjDataCache = $DIC[
'ilObjDataCache'];
97 $this->
ilHelp = $DIC[
'ilHelp'];
98 $this->
rbac = $DIC->rbac();
99 $this->
factory = $DIC->ui()->factory();
100 $this->
renderer = $DIC->ui()->renderer();
104 $this->
ctrl->saveParameter($this, [
'ref_id']);
105 $this->tpl->addJavaScript(
'assets/js/Basic.js');
107 $this->
lng->loadLanguageModule(
'forum');
108 $this->
lng->loadLanguageModule(
'content');
110 $ref_id = $this->retrieveIntOrZeroFrom($this->
http->wrapper()->query(),
'ref_id');
113 $this->is_moderator = $this->
access->checkAccess(
'moderate_frm',
'',
$ref_id);
116 $this->requestAction = (string) ($this->httpRequest->getQueryParams()[
'action'] ??
'');
117 $cs = $DIC->contentStyle();
118 $this->content_style_gui = $cs->gui();
119 if (is_object($this->
object)) {
120 $this->content_style_domain = $cs->domain()->styleForRefId($this->
object->getRefId());
122 $this->in_page_editor_style_context = $this->
http->wrapper()->query()->has(
'page_editor_style');
123 $this->
ctrl->saveParameterByClass(ilObjectContentStyleSettingsGUI::class,
'page_editor_style');
135 if (!is_array($forumValues)) {
140 $threadId = $this->objCurrentTopic->getId();
141 if ($threadId > 0 && !isset($forumValues[$threadId])) {
142 $forumValues[(
int) $threadId] = [];
151 return $this->retrieveIntOrZeroFrom($this->
http->wrapper()->query(),
'thr_pk');
156 return $this->retrieveIntOrZeroFrom(
157 $from_post ? $this->
http->wrapper()->post() : $this->
http->wrapper()->query(),
165 'frm_exp_' . $this->objCurrentTopic->getId(),
175 array $subtree_nodes,
176 array $pagedPostings,
180 if ($firstForumPost->
getId() === $this->objCurrentPost->getId()) {
184 if ($subtree_nodes !== [] && $this->objCurrentPost->getId() > 0) {
185 $isCurrentPostingInPage = array_filter($pagedPostings, fn(
ilForumPost $posting):
bool => (
186 $posting->
getId() === $this->objCurrentPost->getId()
189 if ([] === $isCurrentPostingInPage) {
190 $pageOfCurrentPosting = 0;
192 foreach ($subtree_nodes as $node) {
193 if ($i > 0 && $i % $pageSize === 0) {
194 ++$pageOfCurrentPosting;
197 if ($node->getId() === $this->objCurrentPost->getId()) {
204 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
205 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
206 $this->
ctrl->setParameter($this,
'page', $pageOfCurrentPosting);
207 $this->
ctrl->setParameter(
212 $this->
ctrl->redirect($this,
'viewThread', (
string) $this->objCurrentPost->getId());
221 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
230 $this->tpl->addJavaScript(
'assets/js/autosave_forum.js');
231 $autosave_cmd =
'autosaveDraftAsync';
232 if ($this->objCurrentPost->getId() === 0 && $this->objCurrentPost->getThreadId() === 0) {
233 $autosave_cmd =
'autosaveThreadDraftAsync';
235 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
236 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
239 $this->tpl->addOnLoadCode(
240 "il.Language.setLangVar('saving', " . json_encode($this->
lng->txt(
'saving'), JSON_THROW_ON_ERROR) .
');' 243 $this->tpl->addOnLoadCode(
'il.ForumDraftsAutosave.init(' . json_encode([
246 'interval' => $interval * 1000,
247 'url' => $this->
ctrl->getFormAction($this, $autosave_cmd,
'',
true),
249 'form' =>
'#form_' . $form->
getId()
251 ], JSON_THROW_ON_ERROR) .
');');
258 strtolower($this->
ctrl->getCmd() ??
''),
259 array_map(
'strtolower', [
'createTopLevelPost',
'saveTopLevelPost',
'saveTopLevelDraft']),
267 'enableForumNotification',
268 'disableForumNotification',
269 'toggleThreadNotification',
270 'confirmDeleteThreadDrafts' 281 $next_class = $this->
ctrl->getNextClass($this) ??
'';
282 $cmd = $this->
ctrl->getCmd() ??
'';
288 'showThreadNotification',
289 'performPostActivation',
290 'askForPostActivation',
291 'askForPostDeactivation',
292 'toggleThreadNotification',
293 'toggleThreadNotificationTab',
298 'createTopLevelPost',
301 'autosaveDraftAsync',
302 'autosaveThreadDraftAsync',
306 'deliverDraftZipFile',
309 'deleteThreadDrafts',
311 'deletePostingDraft',
314 'confirmDeleteThreadsObject' 317 if (!in_array($cmd, $exclude_cmds,
true)) {
321 if (!$this->creation_mode) {
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);
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,
361 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
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();
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):
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):
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):
476 case strtolower(ilPublicUserProfileGUI::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);
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):
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 $notificationCommands = [
555 'enableAdminForceNoti',
556 'disableAdminForceNoti',
557 'enableHideUserToggleNoti',
558 'disableHideUserToggleNoti' 561 if (!in_array($cmd, $notificationCommands,
true)) {
562 $cmd =
'performThreadsAction';
565 $cmd =
'showThreads';
574 if (!$this->in_page_editor_style_context &&
575 $cmd !==
'viewThreadObject' && $cmd !==
'showUserObject' && !in_array(
576 strtolower($next_class),
577 array_map(
'strtolower', [ilForumPageGUI::class]),
590 if ($this->
http->wrapper()->post()->has(
'selected_cmd')) {
591 $tableCommands[] = $this->
http->wrapper()->post()->retrieve(
593 $this->
refinery->kindlyTo()->string()
596 if ($this->
http->wrapper()->post()->has(
'selected_cmd2')) {
597 $tableCommands[] = $this->
http->wrapper()->post()->retrieve(
599 $this->
refinery->kindlyTo()->string()
603 return $tableCommands;
614 $this->forum_settings_gui->getCustomForm($a_form);
619 $this->forum_settings_gui->getCustomValues($a_values);
624 $this->forum_settings_gui->updateCustomValues($form);
629 if (!$this->is_moderator) {
630 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
633 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
634 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
637 if ($this->objCurrentTopic->getId() === 0) {
644 $title = $this->
getEditTitleModal($this->objCurrentTopic)->withRequest($this->
http->request())->getData();
645 if (array_key_exists(0, $title)) {
646 $new_subject = $title[0];
647 if ($new_subject !==
'') {
648 $this->objCurrentTopic->setSubject($new_subject);
649 $this->objCurrentTopic->updateThreadTitle();
650 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
659 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
660 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
663 $this->
object->markAllThreadsRead($this->
user->getId());
664 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_all_threads_marked_read'));
676 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
677 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
680 $cmd = $this->
ctrl->getCmd();
681 $frm = $this->
object->Forum;
682 $frm->setForumId($this->
object->getId());
683 $frm->setForumRefId($this->
object->getRefId());
684 $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
686 $frm_object = $frm->getOneTopic();
687 if ($frm_object->getTopPk() > 0) {
688 $frm->setDbTable(
'frm_data');
689 $frm->setMDB2WhereCondition(
'top_pk = %s ', [
'integer'], [$frm_object->getTopPk()]);
690 $frm->updateVisits($frm_object->getTopPk());
694 $this->
object->getRefId(),
695 $this->
object->getId(),
699 if ($cmd !==
'showThreads') {
700 $cmd =
'showThreads';
703 $this->tpl->setPermanentLink($this->
object->getType(), $this->
object->getRefId());
706 $btn = $this->uiFactory->button()
708 $this->
lng->txt(
'forums_new_thread'),
709 $this->
ctrl->getLinkTarget($this,
'createThread')
711 $this->
toolbar->addStickyItem($btn);
718 if ($this->confirmation_gui_html ===
'' && !$this->
user->isAnonymous()) {
720 $this->
lng->txt(
'forums_mark_read'),
721 $this->
ctrl->getLinkTarget($this,
'markAllRead')
723 $this->
ctrl->clearParameters($this);
726 if (!$this->
user->isAnonymous() && $this->
access->checkAccess(
'write',
'', $this->ref_id)) {
727 $this->
lng->loadLanguageModule(
'cntr');
729 $this->uiFactory->button()->standard(
730 $this->
lng->txt(
'cntr_text_media_editor'),
731 $this->
ctrl->getLinkTargetByClass(ilForumPageGUI::class,
'edit')
742 $threads_page = $this->forum_thread_table_session_storage->fetchData($frm, $frm_object);
744 $sticky_threads = [];
745 $regular_threads = [];
747 if (count($threads_page->getForumTopics()) > 0) {
748 foreach ($threads_page->getForumTopics() as $thread) {
749 $ref_id = $this->
object->getRefId();
750 $subject = $thread->getSubject();
751 if ($thread->isClosed()) {
752 $subject .=
' (' . $this->
lng->txt(
'forums_closed') .
')';
761 ->withActions($actions)
764 if ($thread->isSticky()) {
765 $sticky_threads[] = $list_item;
767 $regular_threads[] = $list_item;
772 $sticky_threads_item_group =
null;
773 if (count($sticky_threads) > 0) {
774 $sticky_threads_item_group = $this->
factory->item()->group(
775 count($regular_threads) > 0 ? $this->
lng->txt(
'top_thema') :
'',
780 $regular_threads_item_group =
null;
781 if (count($regular_threads) > 0) {
782 $regular_threads_item_group = $this->
factory->item()->group(
783 count($sticky_threads) > 0 ? $this->
lng->txt(
'thema') :
'',
788 $url = $this->
http->request()->getRequestTarget();
791 $current_page = $this->
http->wrapper()->query()->retrieve(
798 $view_controls[] = $this->
factory 804 ->withMaxPaginationButtons(5)
805 ->withCurrentPage($current_page);
807 $item_groups = array_filter([$sticky_threads_item_group, $regular_threads_item_group]);
808 if ($item_groups === []) {
809 $vc_container = $this->
factory->panel()->listing()->standard(
810 $this->
lng->txt(
'thread_overview'),
811 [$this->
factory->item()->group($this->
lng->txt(
'frm_no_threads'), [])]
814 $vc_container = $this->
factory->panel()->listing()->standard(
815 $this->
lng->txt(
'thread_overview'),
817 )->withViewControls($view_controls);
820 $default_html = $this->
renderer->render($vc_container);
821 $modals = $this->
renderer->render($this->modal_collection);
832 $this->content_style_domain
836 $this->tpl->setContent($forwarder->forward() . $default_html . $modals);
842 $this->
ctrl->setParameter($this,
'page', $offset);
845 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
846 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
847 $base_url = $this->
ctrl->getLinkTarget($this,
'showThreads');
849 $translationKeys = [];
850 foreach (ThreadSortation::cases() as $sortation) {
851 $this->
ctrl->setParameter($this,
'thread_sortation', $sortation->value);
852 $url = $this->
ctrl->getLinkTarget($this,
'showThreads');
854 $translationKeys[
$url] = $this->
lng->txt($sortation->languageId());
856 $this->
ctrl->clearParameters($this);
857 return $this->
factory->viewControl()->sortation(
859 current(array_keys($translationKeys))
861 ->withTargetURL($base_url,
'thread_sortation');
870 $query = $this->
http->wrapper()->query()->has(
'thr_pk');
871 $post = $this->
http->wrapper()->post()->has(
'thread_ids');
873 $thread_ids = $this->
http->wrapper()->post()->retrieve(
878 $thread_ids = $this->
http->wrapper()->query()->retrieve(
892 $this->
ctrl->setParameter($this,
'thr_pk', $forum_topic->
getId());
894 $is_top_thread = $forum_topic->
isSticky();
896 if ($unread_counter === 0) {
899 $unread =
' (' . $unread_counter .
' ' . $this->
lng->txt(
'unread') .
')';
910 $this->
lng->txt(
'forums_created_by') => $authorinfo->getAuthorName(),
911 $this->
lng->txt(
'forums_articles') => $forum_topic->
getNumPosts() . $unread,
912 $this->
lng->txt(
'forums_last_post') => $this->
object->Forum->convertDate($forum_topic->
getLastPost()->getCreateDate()),
916 if ($is_top_thread ===
true) {
917 $is_top_thread = [$this->
lng->txt(
'relevance') => $this->
lng->txt(
'sticky')];
918 $properties = array_merge($properties, $is_top_thread);
921 $rating_property = [];
922 if ($this->objProperties->isIsThreadRatingEnabled()) {
926 $this->
object->getType(),
927 $forum_topic->
getId(),
930 $rating->setUserId($this->
user->getId());
931 $rating_property = [$this->
lng->txt(
'frm_rating') => $rating->getHTML()];
933 $this->
ctrl->setParameter($this,
'thr_pk',
null);
935 return array_merge($properties, $rating_property);
942 ?
int $thread_id =
null 944 $this->
ctrl->setParameter($this,
'ref_id', $ref_id);
945 $this->
ctrl->setParameter($this,
'thr_pk', $thread_id);
946 $this->
ctrl->setParameter($this,
'page', 0);
947 $url = $this->
ctrl->getLinkTarget($this, $cmd);
948 $this->
ctrl->setParameter($this,
'ref_id',
null);
949 $this->
ctrl->setParameter($this,
'thr_pk',
null);
950 $this->
ctrl->setParameter($this,
'page',
null);
952 return $this->uiFactory->link()->standard($title,
$url);
957 $actions = $this->uiFactory->dropdown()->standard([]);
958 if ($this->is_moderator) {
962 $this->modal_collection[] = $edit_title_modal;
963 $edit_title = $this->
factory->button()->shy($this->
lng->txt(
'frm_edit_title'),
'#')->withOnClick(
964 $edit_title_modal->getShowSignal()
969 $this->
lng->txt(
'move_thread_to_forum'),
971 $forum_topic->
getId()
975 $this->
lng->txt(
'merge_posts_into_thread'),
977 $forum_topic->
getId()
981 $this->
lng->txt(
'delete_thread'),
982 'confirmDeleteThreads',
983 $forum_topic->
getId()
985 $actions = $this->uiFactory->dropdown()->standard([
1000 $topic_id = $this->
refinery->kindlyTo()->string()->transform($topic->
getId());
1001 $this->
ctrl->setParameter($this,
'thr_pk', (
string) $topic_id);
1002 $target = $this->
ctrl->getLinkTargetByClass(
1003 ilObjForumGUI::class,
1006 $this->
ctrl->setParameter($this,
'thread_id',
null);
1008 return $this->
factory->modal()->roundtrip(
1009 $this->
lng->txt(
'frm_edit_title'),
1021 $this->
user->getId(),
1024 if ($drafts === []) {
1037 $this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()),
1041 'tpl.forums_threads_liste.html',
1044 'components/ILIAS/Forum' 1046 $threadsTemplate->setVariable(
'THREADS_DRAFTS_TABLE', $this->uiRenderer->render($table->getComponent()));
1048 $draft_modal = $this->
factory->modal()->roundtrip(
1049 $this->
lng->txt(
'drafts'),
1050 [$this->
factory->legacy()->content($threadsTemplate->get())]
1052 $this->modal_collection[] = $draft_modal;
1053 $edit_title = $this->
factory->button()->standard($this->
lng->txt(
'drafts'),
'#')->withOnClick(
1054 $draft_modal->getShowSignal()
1056 $this->
toolbar->addComponent($edit_title);
1063 $this->
lng->txt($forum_topic->
isSticky() ?
'make_topics_non_sticky' :
'make_topics_sticky'),
1064 $forum_topic->
isSticky() ?
'make_topics_non_sticky' :
'makesticky',
1065 $forum_topic->
getId()
1073 $this->
lng->txt($forum_topic->
isClosed() ?
'reopen_topics' :
'close_topics'),
1074 $forum_topic->
isClosed() ?
'reopen' :
'close',
1075 $forum_topic->
getId()
1084 $df = new \ILIAS\Data\Factory();
1085 $list_item = $list_item->withColor($df->color(
'#B54F00'));
1093 $this->content_style_gui->addCss($this->tpl, $this->ref_id);
1094 $this->tpl->setCurrentBlock(
'SyntaxStyle');
1096 $this->tpl->parseCurrentBlock();
1101 $this->content_style_gui->redirectToObjectSettings();
1113 $frm = $this->
object->Forum;
1116 foreach ($drafts as $draft) {
1119 ksort($filesOfDraft);
1121 if ($action !==
'showdraft' && $filesOfDraft !== []) {
1122 foreach ($filesOfDraft as $file) {
1124 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1125 $this->
ctrl->setParameter($this,
'file', $file[
'md5']);
1126 $tpl->
setVariable(
'HREF_DOWNLOAD', $this->
ctrl->getLinkTarget($this,
'viewThread'));
1128 $this->
ctrl->setParameter($this,
'file',
'');
1129 $this->
ctrl->setParameter($this,
'draft_id',
'');
1130 $this->
ctrl->clearParameters($this);
1135 $tpl->
setVariable(
'TXT_ATTACHMENTS_DOWNLOAD', $this->
lng->txt(
'forums_attachments'));
1138 $this->uiRenderer->render(
1139 $this->uiFactory->symbol()->glyph()->attachment($this->
lng->txt(
'forums_download_attachment'))
1142 if (count($filesOfDraft) > 1) {
1143 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1144 $download_zip_button = $this->uiFactory->button()
1146 $this->
lng->txt(
'download'),
1147 $this->
ctrl->getLinkTarget($this,
'deliverDraftZipFile')
1149 $this->
ctrl->setParameter($this,
'draft_id',
'');
1150 $tpl->
setVariable(
'DOWNLOAD_ZIP', $this->uiRenderer->render($download_zip_button));
1155 $page = $this->
http->wrapper()->query()->retrieve(
1157 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->
refinery->always(0)])
1169 $rowCol =
'tblrowmarked';
1171 $depth = $referencePosting->
getDepth() - 1;
1177 $this->
ctrl->setParameter($this,
'pos_pk', $referencePosting->
getId());
1178 $this->
ctrl->setParameter($this,
'thr_pk', $referencePosting->
getThreadId());
1179 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1181 $backurl = urlencode($this->
ctrl->getLinkTarget($this,
'viewThread', (
string) $referencePosting->
getId()));
1183 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1184 $this->
ctrl->setParameter($this,
'thr_pk', $referencePosting->
getThreadId());
1185 $this->
ctrl->setParameter($this,
'user', $draft->getPostDisplayUserId());
1188 $draft->getPostAuthorId(),
1189 $draft->getPostDisplayUserId(),
1190 $draft->getPostUserAlias(),
1193 'href' => $this->
ctrl->getLinkTarget($this,
'showUser')
1197 $this->
ctrl->clearParameters($this);
1199 if ($authorinfo->hasSuffix()) {
1200 $tpl->
setVariable(
'AUTHOR', $authorinfo->getSuffix());
1201 $tpl->
setVariable(
'USR_NAME', $draft->getPostUserAlias());
1203 $tpl->
setVariable(
'AUTHOR', $authorinfo->getLinkedAuthorShortName());
1204 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized()) {
1205 $tpl->
setVariable(
'USR_NAME', $authorinfo->getAuthorName(
true));
1208 $tpl->
setVariable(
'DRAFT_ANCHOR',
'draft_' . $draft->getDraftId());
1210 $tpl->
setVariable(
'USR_IMAGE', $authorinfo->getProfilePicture());
1216 $this->
object->getRefId(),
1217 $draft->getPostAuthorId()
1219 if ($authorinfo->getAuthor()->getGender() ===
'f') {
1221 } elseif ($authorinfo->getAuthor()->getGender() ===
'm') {
1223 } elseif ($authorinfo->getAuthor()->getGender() ===
'n') {
1228 if ($draft->getUpdateUserId() > 0) {
1229 $draft->setPostUpdate($draft->getPostUpdate());
1231 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1232 $this->
ctrl->setParameter($this,
'thr_pk', $referencePosting->
getThreadId());
1234 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1237 $draft->getPostAuthorId(),
1239 $draft->getPostDisplayUserId(),
1240 $draft->getPostUserAlias(),
1242 [
'href' => $this->
ctrl->getLinkTarget($this,
'showUser')]
1245 $this->
ctrl->clearParameters($this);
1249 $this->
lng->txt(
'edited_on') .
': ' . $frm->convertDate($draft->getPostUpdate()) .
' - ' . strtolower($this->
lng->txt(
'by'))
1251 $tpl->
setVariable(
'UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
1252 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
1253 $tpl->
setVariable(
'UPDATE_USR_NAME', $authorinfo->getAuthorName(
true));
1257 $draft->setPostMessage($frm->prepareText($draft->getPostMessage()));
1259 $tpl->
setVariable(
'SUBJECT', $draft->getPostSubject());
1260 $tpl->
setVariable(
'POST_DATE', $frm->convertDate($draft->getPostDate()));
1262 $tpl->
setVariable(
'POST_DRAFT_TEXT', $this->
lng->txt(
'post_draft_info'));
1264 if (!$referencePosting->
isCensored() || ($this->objCurrentPost->getId() === $referencePosting->
getId() && $action ===
'censor')) {
1267 $spanClass =
'moderator';
1270 if ($draft->getPostMessage() === strip_tags($draft->getPostMessage())) {
1272 $draft->setPostMessage(nl2br($draft->getPostMessage()));
1275 if ($spanClass !==
'') {
1279 $draft->getPostMessage(),
1288 if ($action ===
'editdraft' && $draft->getDraftId() === $draft_id) {
1291 if (!$this->objCurrentTopic->isClosed() && in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
1295 $tpl->
setVariable(
'EDIT_DRAFT_ANCHOR',
'draft_edit_' . $draft->getDraftId());
1311 $frm = $this->
object->Forum;
1316 ksort($filesOfPost);
1317 if ($filesOfPost !== [] && ($action !==
'showedit' || $node->
getId() !== $this->objCurrentPost->getId())) {
1318 foreach ($filesOfPost as $file) {
1320 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1321 $this->
ctrl->setParameter($this,
'file', $file[
'md5']);
1322 $tpl->
setVariable(
'HREF_DOWNLOAD', $this->
ctrl->getLinkTarget($this,
'viewThread'));
1324 $this->
ctrl->clearParameters($this);
1328 $tpl->
setVariable(
'TXT_ATTACHMENTS_DOWNLOAD', $this->
lng->txt(
'forums_attachments'));
1331 $this->uiRenderer->render(
1332 $this->uiFactory->symbol()->glyph()->attachment($this->
lng->txt(
'forums_download_attachment'))
1335 if (count($filesOfPost) > 1) {
1336 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1337 $download_zip_button = $this->uiFactory->button()
1339 $this->
lng->txt(
'download'),
1340 $this->
ctrl->getLinkTarget($this,
'deliverZipFile')
1342 $tpl->
setVariable(
'DOWNLOAD_ZIP', $this->uiRenderer->render($download_zip_button));
1349 $tpl->
setVariable(
'TXT_PERMA_LINK', $this->
lng->txt(
'perma_link'));
1353 if (($this->is_moderator || $node->
isOwner($this->user->getId())) && !$node->
isActivated() && !$this->objCurrentTopic->isClosed()) {
1354 $rowCol =
'ilPostingNeedsActivation';
1355 } elseif ($this->objProperties->getMarkModeratorPosts()) {
1358 $rowCol =
'ilModeratorPosting';
1360 $rowCol =
'ilModeratorPosting';
1366 $this->objCurrentPost->getId() !== $node->
getId()
1370 $rowCol =
'tblrowmarked';
1374 if ($action !==
'censor') {
1375 $tpl->
setVariable(
'TXT_CENSORSHIP_ADVICE', $this->
lng->txt(
'post_censored_comment_by_moderator'));
1378 $rowCol =
'tblrowmarked';
1384 $tpl->
setVariable(
'POST_NOT_ACTIVATED_YET', $this->
lng->txt(
'frm_post_not_activated_yet'));
1387 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1389 $backurl = urlencode($this->
ctrl->getLinkTarget($this,
'viewThread', (
string) $node->
getId()));
1390 $this->
ctrl->clearParameters($this);
1392 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1401 'href' => $this->
ctrl->getLinkTarget($this,
'showUser')
1404 $this->
ctrl->clearParameters($this);
1406 if ($authorinfo->hasSuffix()) {
1407 if (!$authorinfo->isDeleted()) {
1408 $tpl->
setVariable(
'USR_NAME', $authorinfo->getAlias());
1410 $tpl->
setVariable(
'AUTHOR', $authorinfo->getSuffix());
1412 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized()) {
1413 $tpl->
setVariable(
'USR_NAME', $authorinfo->getAuthorName(
true));
1415 $tpl->
setVariable(
'AUTHOR', $authorinfo->getLinkedAuthorShortName());
1418 $tpl->
setVariable(
'USR_IMAGE', $authorinfo->getProfilePicture());
1424 if ($isModerator && $authorinfo->getAuthor()->getId()) {
1425 $authorRole = $this->
lng->txt(
'frm_moderator_n');
1426 if (is_string($authorinfo->getAuthor()->getGender()) && $authorinfo->getAuthor()->getGender() !==
'') {
1427 $authorRole = $this->
lng->txt(
'frm_moderator_' . $authorinfo->getAuthor()->getGender());
1435 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1448 'href' => $this->
ctrl->getLinkTarget($this,
'showUser')
1451 $this->
ctrl->clearParameters($this);
1455 $this->
lng->txt(
'edited_on') .
': ' . $frm->convertDate($node->
getChangeDate()) .
' - ' . strtolower($this->
lng->txt(
'by'))
1457 $tpl->
setVariable(
'UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
1458 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
1459 $tpl->
setVariable(
'UPDATE_USR_NAME', $authorinfo->getAuthorName(
true));
1464 && $node->
getId() !== $this->selected_post_storage->get($node->
getThreadId())) {
1465 $target = $this->uiFactory->symbol()->icon()->custom(
1467 $this->
lng->txt(
'target_select')
1470 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1475 $this->uiRenderer->render(
1476 $this->uiFactory->link()->bulky(
1478 $this->
lng->txt(
'select'),
1479 new \ILIAS\Data\URI(
1480 ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTarget($this,
'selectPost', (
string) $node->
getId())
1492 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1494 $this->
ctrl->setParameter($this,
'page', $pageIndex);
1495 $this->
ctrl->setParameter(
1500 $this->
ctrl->setParameter($this,
'viewmode', $this->selectedSorting);
1501 $mark_post_target = $this->
ctrl->getLinkTarget($this,
'markPostRead', (
string) $node->
getId());
1505 '<a href="' . $mark_post_target .
'"><b>' . $node->
getSubject() .
'</b></a>' 1511 if (!$node->
isCensored() || ($this->objCurrentPost->getId() === $node->
getId() && $action ===
'censor')) {
1514 $spanClass =
'moderator';
1523 if ($spanClass !==
'') {
1526 '<span class="' . $spanClass .
'">' .
1545 $thr_pk = (
int) $this->httpRequest->getQueryParams()[
'thr_pk'];
1546 $pos_pk = (
int) $this->httpRequest->getQueryParams()[
'pos_pk'];
1548 $this->selected_post_storage->set(
1561 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_added'),
true);
1562 $this->
ctrl->setParameter($this,
'ref_id', $new_object->
getRefId());
1563 $this->
ctrl->redirect($this,
'createThread');
1568 if ($this->in_page_editor_style_context) {
1572 $this->
ilHelp->setScreenIdComponent(
'frm');
1574 $this->
ctrl->setParameter($this,
'ref_id', $this->ref_id);
1581 'enableForumNotification',
1582 'disableForumNotification',
1584 'performMoveThreads',
1585 'cancelMoveThreads',
1586 'performThreadsAction',
1590 'confirmDeleteThreads',
1593 'performMergeThreads' 1596 $force_active =
false;
1597 if (in_array($this->
ctrl->getCmd(), $active,
true)) {
1598 $force_active =
true;
1601 if ($this->
access->checkAccess(
1606 $this->tabs_gui->addTarget(
1607 self::UI_TAB_ID_THREADS,
1608 $this->
ctrl->getLinkTarget($this,
'showThreads'),
1609 $this->
ctrl->getCmd(),
1616 if ($this->
access->checkAccess(
'visible',
'', $this->ref_id) || $this->
access->checkAccess(
1621 $cmdClass = $this->
http->wrapper()->query()->retrieve(
1623 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->
refinery->always(
'')])
1626 $force_active = $this->
ctrl->getNextClass() ===
'ilinfoscreengui' || strtolower($cmdClass) ===
'ilnotegui';
1627 $this->tabs_gui->addTarget(
1628 self::UI_TAB_ID_INFO,
1629 $this->
ctrl->getLinkTargetByClass([self::class, ilInfoScreenGUI::class],
'showSummary'),
1630 [
'showSummary',
'infoScreen'],
1637 if ($this->
access->checkAccess(
'write',
'', $this->ref_id)) {
1638 $force_active = $this->
ctrl->getCmd() ===
'edit';
1639 $this->tabs_gui->addTarget(
1640 self::UI_TAB_ID_SETTINGS,
1641 $this->
ctrl->getLinkTarget($this,
'edit'),
1649 if ($this->
access->checkAccess(
'write',
'', $this->ref_id)) {
1650 $this->tabs_gui->addTarget(
1651 self::UI_TAB_ID_MODERATORS,
1652 $this->
ctrl->getLinkTargetByClass(ilForumModeratorsGUI::class,
'showModerators'),
1659 $this->tabs_gui->addTab(
1660 'learning_progress',
1661 $this->
lng->txt(
'learning_progress'),
1662 $this->
ctrl->getLinkTargetByClass(ilLearningProgressGUI::class)
1666 if ($this->
settings->get(
'enable_fora_statistics',
'0')) {
1667 $hasStatisticsAccess = $this->
access->checkAccess(
'write',
'', $this->ref_id);
1668 if (!$hasStatisticsAccess) {
1669 $hasStatisticsAccess = (
1670 $this->objProperties->isStatisticEnabled() &&
1671 $this->
access->checkAccess(
'read',
'', $this->ref_id)
1675 if ($hasStatisticsAccess) {
1676 $force_active = $this->
ctrl->getCmd() ===
'showStatistics';
1677 $this->tabs_gui->addTarget(
1678 self::UI_TAB_ID_STATS,
1679 $this->
ctrl->getLinkTarget($this,
'showStatistics'),
1688 if ($this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1689 $this->tabs_gui->addTarget(
1690 self::UI_TAB_ID_EXPORT,
1691 $this->
ctrl->getLinkTargetByClass(ilExportGUI::class,
''),
1697 if ($this->
access->checkAccess(
'edit_permission',
'', $this->ref_id)) {
1698 $this->tabs_gui->addTarget(
1699 self::UI_TAB_ID_PERMISSIONS,
1700 $this->
ctrl->getLinkTargetByClass([static::class, ilPermissionGUI::class],
'perm'),
1701 [
'perm',
'info',
'owner'],
1709 if (!$this->
settings->get(
'enable_fora_statistics',
'0')) {
1710 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1713 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1714 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1717 if (!$this->objProperties->isStatisticEnabled()) {
1718 if ($this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1719 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'frm_statistics_disabled_for_participants'));
1721 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1725 $this->
object->Forum->setForumId($this->
object->getId());
1727 $tbl = new \ILIAS\Forum\Statistics\ForumStatisticsTable(
1729 $this->objProperties,
1731 $this->
access->checkRbacOrPositionPermissionAccess(
1732 'read_learning_progress',
1733 'read_learning_progress',
1734 $this->object->getRefId()
1741 $this->tpl->setContent($this->uiRenderer->render($tbl->getComponent()));
1744 public static function _goto($a_target, $a_thread = 0, $a_posting = 0): void
1747 $main_tpl = $DIC->ui()->mainTemplate();
1749 $ilAccess = $DIC->access();
1750 $lng = $DIC->language();
1753 $a_target = is_numeric($a_target) ? (
int) $a_target : 0;
1754 $a_thread = is_numeric($a_thread) ? (
int) $a_thread : 0;
1755 if ($ilAccess->checkAccess(
'read',
'', $a_target)) {
1756 if ($a_thread !== 0) {
1758 if ($objTopic->getFrmObjId() &&
1761 foreach ($ref_ids as
$ref_id) {
1762 if ($ilAccess->checkAccess(
'read',
'', $ref_id)) {
1768 if (isset($new_ref_id) && $new_ref_id !== $a_target) {
1769 $DIC->ctrl()->redirectToURL(
1770 ILIAS_HTTP_PATH .
'/goto.php?target=frm_' . $new_ref_id .
'_' . $a_thread .
'_' . $a_posting
1775 $DIC->ctrl()->setParameterByClass(self::class,
'ref_id', (
string) ((
int) $a_target));
1776 if (is_numeric($a_thread)) {
1777 $DIC->ctrl()->setParameterByClass(self::class,
'thr_pk', (
string) ((
int) $a_thread));
1779 if (is_numeric($a_posting)) {
1780 $DIC->ctrl()->setParameterByClass(self::class,
'pos_pk', (
string) ((
int) $a_posting));
1782 $DIC->ctrl()->redirectByClass(
1783 [ilRepositoryGUI::class, self::class],
1785 is_numeric($a_posting) ? (
string) ((
int) $a_posting) :
'' 1788 $DIC->ctrl()->setParameterByClass(self::class,
'ref_id', $a_target);
1789 $DIC->ctrl()->redirectByClass([ilRepositoryGUI::class, self::class,],
'');
1790 $DIC->http()->close();
1792 } elseif ($ilAccess->checkAccess(
'visible',
'', $a_target)) {
1793 $DIC->ctrl()->setParameterByClass(ilInfoScreenGUI::class,
'ref_id', $a_target);
1794 $DIC->ctrl()->redirectByClass(
1796 ilRepositoryGUI::class,
1798 ilInfoScreenGUI::class
1803 $main_tpl->setOnScreenMessage(
'info', sprintf(
1804 $lng->
txt(
'msg_no_perm_read_item'),
1807 $DIC->http()->close();
1816 if ($threadIds === []) {
1817 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
1818 $this->
ctrl->redirect($this,
'showThreads');
1821 if (!$this->is_moderator) {
1822 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1825 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1826 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1830 $this->objProperties->setObjId($forumObj->getId());
1834 $success_message =
'forums_thread_deleted';
1835 if (count($threadIds) > 1) {
1836 $success_message =
'forums_threads_deleted';
1840 array_walk($threadIds,
function (
int $threadId) use (&$threads):
void {
1844 $threads[] = $thread;
1847 $frm->setForumId($forumObj->getId());
1848 $frm->setForumRefId($forumObj->getRefId());
1849 foreach ($threads as $thread) {
1850 $first_node = $frm->getFirstPostNode($thread->getId());
1851 if (isset($first_node[
'pos_pk']) && (
int) $first_node[
'pos_pk']) {
1852 $frm->deletePost((
int) $first_node[
'pos_pk']);
1853 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt($success_message),
true);
1856 $this->
ctrl->redirect($this,
'showThreads');
1859 public function confirmDeleteThreadsObject():
void 1862 if ($thread_ids === []) {
1863 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'));
1864 $this->
ctrl->redirect($this,
'showThreads');
1867 if (!$this->is_moderator) {
1868 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1871 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1872 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1877 array_walk($thread_ids,
function (
int $threadId) use (&$threads):
void {
1881 $threads[] = $thread;
1886 $c_gui->setFormAction($this->
ctrl->getFormAction($this,
'performDeleteThreads'));
1887 $c_gui->setHeaderText($this->
lng->txt(
'frm_sure_delete_threads'));
1888 $c_gui->setCancel($this->
lng->txt(
'cancel'),
'showThreads');
1889 $c_gui->setConfirm($this->
lng->txt(
'confirm'),
'performDeleteThreads');
1891 foreach ($threads as $thread) {
1892 $c_gui->addItem(
'thread_ids[]', (
string) $thread->getId(), $thread->getSubject());
1895 $this->confirmation_gui_html = $c_gui->getHTML();
1898 $this->tpl->setContent($c_gui->getHTML());
1903 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1904 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1907 $draft_ids = $this->
http->wrapper()->query()->retrieve(
1908 'forum_drafts_delete_draft_ids',
1910 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->int()),
1915 if ($draft_ids === []) {
1916 $draft_ids = $this->
http->wrapper()->query()->retrieve(
1917 'forum_drafts_delete_draft_ids',
1919 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->string()),
1924 if (!isset($draft_ids[0]) || $draft_ids[0] !==
'ALL_OBJECTS') {
1925 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'));
1931 static fn(array $draft):
int => $draft[
'draft_id'] ?? 0,
1933 $this->
user->getId(),
1940 $confirmation->setFormAction($this->
ctrl->getFormAction($this,
'deleteThreadDrafts'));
1941 $confirmation->setHeaderText($this->
lng->txt(
'sure_delete_drafts'));
1942 $confirmation->setCancel($this->
lng->txt(
'cancel'),
'showThreads');
1943 $confirmation->setConfirm($this->
lng->txt(
'confirm'),
'deleteThreadDrafts');
1945 foreach ($draft_ids as $draftId) {
1946 if (array_key_exists($draftId, $instances)) {
1947 $confirmation->addItem(
'draft_ids[]', (
string) $draftId, $instances[$draftId]->getPostSubject());
1951 $this->tpl->setContent($confirmation->getHTML());
1954 public function prepareThreadScreen(
ilObjForum $a_forum_obj):
void 1956 $this->
ilHelp->setScreenIdComponent(
'frm');
1958 $this->tpl->loadStandardTemplate();
1962 $this->tabs_gui->setBackTarget(
1963 $this->
lng->txt(
'frm_all_threads'),
1964 $this->
ctrl->getLinkTarget(
1971 $frm = $a_forum_obj->Forum;
1972 $frm->setForumId($a_forum_obj->
getId());
1977 if (!$this->is_moderator) {
1978 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1981 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1982 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1987 $this->objCurrentPost->activatePost();
1988 $GLOBALS[
'ilAppEventHandler']->raise(
1989 'components/ILIAS/Forum',
1992 'object' => $this->
object,
1993 'ref_id' => $this->
object->getRefId(),
1997 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_post_was_activated'),
true);
2005 !$this->
user->isAnonymous() &&
2006 !$this->objCurrentTopic->isClosed() && (
2007 $this->is_moderator ||
2008 ($this->objCurrentPost->isOwner($this->
user->getId()) && !$this->objCurrentPost->hasReplies())
2014 $forumObj = $oForumObjects[
'forumObj'];
2017 $frm->setForumId($forumObj->getId());
2018 $frm->setForumRefId($forumObj->getRefId());
2019 $dead_thr = $frm->deletePost($this->objCurrentPost->getId());
2022 if ($dead_thr === $this->objCurrentTopic->getId()) {
2023 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', [
'integer'], [$forumObj->getId()]);
2024 $topicData = $frm->getOneTopic();
2025 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_post_deleted'),
true);
2026 if ($topicData->getTopNumThreads() > 0) {
2027 $this->
ctrl->redirect($this,
'showThreads');
2029 $this->
ctrl->redirect($this,
'createThread');
2032 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_post_deleted'),
true);
2033 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
2034 $this->
ctrl->redirect($this,
'viewThread');
2037 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2058 foreach ($this->modalActionsContainer as $modal) {
2059 $modalString .= $this->uiRenderer->render($modal);
2062 return $modalString;
2068 if ($this->is_moderator && !$this->objCurrentTopic->isClosed()) {
2069 if ($this->
http->wrapper()->post()->has(
'formData')) {
2070 $formData = $this->
http->wrapper()->post()->retrieve(
2077 if (
$message ===
'' && $this->
http->wrapper()->post()->has(
'cens_message')) {
2078 $cens_message = $this->
http->wrapper()->post()->retrieve(
2080 $this->
refinery->kindlyTo()->string()
2087 $frm = $oForumObjects[
'frm'];
2090 $frm->postCensorship($this->
object,
$message, $this->objCurrentPost->getId());
2091 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_censorship_revoked'));
2093 $frm->postCensorship($this->
object,
$message, $this->objCurrentPost->getId(), 1);
2094 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_censorship_applied'));
2101 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2106 if (!$this->is_moderator) {
2107 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2110 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2111 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2121 $this->display_confirm_post_activation = $status;
2131 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2132 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2137 if ($this->objCurrentTopic->isNotificationEnabled($this->user->getId())) {
2138 $this->objCurrentTopic->disableNotification($this->
user->getId());
2139 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_notification_disabled'),
true);
2141 $this->objCurrentTopic->enableNotification($this->
user->getId());
2142 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_notification_enabled'),
true);
2145 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
2146 $this->
ctrl->redirect($this,
'viewThread');
2151 if (!$this->is_moderator) {
2152 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2155 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2156 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2161 if ($this->objCurrentTopic->isSticky()) {
2162 $this->objCurrentTopic->unmakeSticky();
2164 $this->objCurrentTopic->makeSticky();
2172 $this->requestAction =
'';
2174 if ($draft_id > 0) {
2177 $draft->deleteDraftsByDraftIds([$draft_id]);
2186 $this->requestAction =
'';
2188 if ($draft_id > 0) {
2190 $history_entry->populateWithFirstAutosaveByDraftId($draft_id);
2193 $draft->setPostSubject($history_entry->getPostSubject());
2194 $draft->setPostMessage($history_entry->getPostMessage());
2197 $history_entry->getPostMessage(),
2199 $history_entry->getHistoryId(),
2201 $draft->getDraftId()
2204 $draft->updateDraft();
2206 $history_entry->deleteHistoryByDraftIds([$draft->getDraftId()]);
2210 $this->
ctrl->clearParameters($this);
2217 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
2219 $this->
ctrl->setParameter(
2224 $form->setFormAction($this->
ctrl->getFormAction($this,
'performPostActivation'));
2225 $this->
ctrl->clearParameters($this);
2226 $form->setId(
'frm_activate_post_' . $node->
getId());
2227 $form_id = $form->getId();
2228 $message = $this->uiFactory->messageBox()->confirmation($this->
lng->txt(
'activate_post_txt'));
2229 $submitBtn = $this->uiFactory->button()->primary(
2230 $this->
lng->txt(
'activate_only_current'),
2233 static function (
string $id) use ($form_id):
string {
2236 const button = document.getElementById('$id'); 2237 if (!button) return; 2239 const form = document.getElementById('form_$form_id'); 2242 button.addEventListener('click', (event) => { 2243 event.preventDefault(); 2250 $modal = $this->uiFactory->modal()->roundtrip(
2251 $this->
lng->txt(
'activate_only_current'),
2252 [$this->uiFactory->legacy()->content($form->getHTML()),
$message]
2253 )->withActionButtons([$submitBtn]);
2254 $action_button = $this->uiFactory->button()->standard($this->
lng->txt(
'activate_post'),
'#')->withOnClick(
2255 $modal->getShowSignal()
2257 $this->modalActionsContainer[] = $modal;
2258 $this->
ctrl->clearParameters($this);
2260 return $action_button;
2263 public function getCensorshipFormHTML():
string 2266 $frm = $this->
object->Forum;
2267 $form_tpl =
new ilTemplate(
'tpl.frm_censorship_post_form.html',
true,
true,
'components/ILIAS/Forum');
2269 $form_tpl->setVariable(
'ANCHOR', $this->objCurrentPost->getId());
2270 $form_tpl->setVariable(
'SPACER',
'<hr noshade="noshade" width="100%" size="1" align="center" />');
2271 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2272 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2273 $this->
ctrl->setParameter(
2278 $form_tpl->setVariable(
'FORM_ACTION', $this->
ctrl->getFormAction($this,
'viewThread'));
2279 $this->
ctrl->clearParameters($this);
2280 $form_tpl->setVariable(
'TXT_CENS_MESSAGE', $this->
lng->txt(
'forums_the_post'));
2281 $form_tpl->setVariable(
'TXT_CENS_COMMENT', $this->
lng->txt(
'forums_censor_comment') .
':');
2282 $form_tpl->setVariable(
'CENS_MESSAGE', $frm->prepareText((
string) $this->objCurrentPost->getCensorshipComment(), 2));
2284 if ($this->objCurrentPost->isCensored()) {
2285 $form_tpl->setVariable(
'TXT_CENS', $this->
lng->txt(
'forums_info_censor2_post'));
2286 $form_tpl->setVariable(
'YES_BUTTON', $this->
lng->txt(
'confirm'));
2287 $form_tpl->setVariable(
'NO_BUTTON', $this->
lng->txt(
'cancel'));
2288 $form_tpl->setVariable(
'CMD_REVOKE_CENSORSHIP',
'revokeCensorship');
2289 $form_tpl->setVariable(
'CMD_CANCEL_REVOKE_CENSORSHIP',
'viewThread');
2291 $form_tpl->setVariable(
'TXT_CENS', $this->
lng->txt(
'forums_info_censor_post'));
2292 $form_tpl->setVariable(
'CANCEL_BUTTON', $this->
lng->txt(
'cancel'));
2293 $form_tpl->setVariable(
'CONFIRM_BUTTON', $this->
lng->txt(
'confirm'));
2294 $form_tpl->setVariable(
'CMD_ADD_CENSORSHIP',
'addCensorship');
2295 $form_tpl->setVariable(
'CMD_CANCEL_ADD_CENSORSHIP',
'viewThread');
2298 return $form_tpl->get();
2303 $isReply = in_array($this->requestAction, [
'showreply',
'ready_showreply']);
2304 $isDraft = in_array($this->requestAction, [
'publishDraft',
'editdraft']);
2310 $frm = $oForumObjects[
'frm'];
2311 $oFDForum = $oForumObjects[
'file_obj'];
2314 $this->replyEditForm->setId(
'id_showreply');
2315 $this->replyEditForm->setTableWidth(
'100%');
2316 $cancel_cmd =
'cancelPost';
2317 if (in_array($this->requestAction, [
'showreply',
'ready_showreply'])) {
2318 $this->
ctrl->setParameter($this,
'action',
'ready_showreply');
2319 } elseif (in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
2320 $this->
ctrl->setParameter($this,
'action', $this->requestAction);
2321 $this->
ctrl->setParameter($this,
'draft_id', $draft_id);
2323 $this->
ctrl->setParameter($this,
'action',
'ready_showedit');
2326 $this->
ctrl->setParameter($this,
'page', (
int) ($this->httpRequest->getQueryParams()[
'page'] ?? 0));
2327 $this->
ctrl->setParameter(
2332 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2333 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2335 $this->replyEditForm->setFormAction(
2336 $this->
ctrl->getFormAction($this,
'saveTopLevelPost',
'frm_page_bottom')
2338 } elseif (in_array($this->requestAction, [
'publishDraft',
'editdraft'])) {
2339 $this->replyEditForm->setFormAction(
2340 $this->
ctrl->getFormAction($this,
'publishDraft', (
string) $this->objCurrentPost->getId())
2343 $this->replyEditForm->setFormAction(
2344 $this->
ctrl->getFormAction($this,
'savePost', (
string) $this->objCurrentPost->getId())
2347 $this->
ctrl->clearParameters($this);
2350 $this->replyEditForm->setTitle($this->
lng->txt(
'forums_your_reply'));
2351 } elseif ($isDraft) {
2352 $this->replyEditForm->setTitle($this->
lng->txt(
'forums_edit_draft'));
2354 $this->replyEditForm->setTitle($this->
lng->txt(
'forums_edit_post'));
2359 in_array($this->requestAction, [
'showreply',
'ready_showreply',
'editdraft'])
2361 $oAnonymousNameGUI =
new ilTextInputGUI($this->
lng->txt(
'forums_your_name'),
'alias');
2362 $oAnonymousNameGUI->setMaxLength(64);
2363 $oAnonymousNameGUI->setInfo(sprintf($this->
lng->txt(
'forums_use_alias'), $this->
lng->txt(
'forums_anonymous')));
2365 $this->replyEditForm->addItem($oAnonymousNameGUI);
2368 $oSubjectGUI =
new ilTextInputGUI($this->
lng->txt(
'forums_subject'),
'subject');
2369 $oSubjectGUI->setMaxLength(255);
2370 $oSubjectGUI->setRequired(
true);
2372 if ($this->objProperties->getSubjectSetting() ===
'empty_subject') {
2373 $oSubjectGUI->setInfo($this->
lng->txt(
'enter_new_subject'));
2376 $this->replyEditForm->addItem($oSubjectGUI);
2379 $isReply ? $this->
lng->txt(
'forums_your_reply') : $this->
lng->txt(
'forums_edit_post'),
2383 $oPostGUI->setRows(15);
2384 $oPostGUI->setUseRte(
true);
2388 ($isReply && $this->objCurrentPost->getDepth() >= 2) ||
2389 (!$isDraft && !$isReply && $this->objCurrentPost->getDepth() > 2) ||
2390 ($isDraft && $this->objCurrentPost->getDepth() >= 2)
2394 $oPostGUI->removePlugin(
'advlink');
2395 $oPostGUI->setRTERootBlockElement(
'');
2396 $oPostGUI->usePurifier(
true);
2397 $oPostGUI->disableButtons([
2414 if (in_array($this->requestAction, [
'showreply',
'ready_showreply',
'showdraft',
'editdraft'])) {
2415 $oPostGUI->setRTESupport(
2416 $this->
user->getId(),
2419 'tpl.tinymce_frm_post.js',
2424 $oPostGUI->setRTESupport(
2425 $this->objCurrentPost->getId(),
2428 'tpl.tinymce_frm_post.js',
2435 $oPostGUI->setInfo($this->
lng->txt(
'latex_edit_info'));
2437 $this->replyEditForm->addItem($oPostGUI);
2440 if (!$this->
user->isAnonymous() &&
2441 !$this->objProperties->isAnonymized() &&
2442 $this->
rbac->system()->checkAccess(
'internal_mail', $umail->getMailObjectReferenceId()) &&
2443 !$frm->isThreadNotificationEnabled($this->user->getId(), $this->objCurrentPost->getThreadId())) {
2445 $oNotificationGUI->setInfo($this->
lng->txt(
'forum_notify_me'));
2446 $this->replyEditForm->addItem($oNotificationGUI);
2449 if ($this->objProperties->isFileUploadAllowed()) {
2452 $this->replyEditForm->addItem($oFileUploadGUI);
2455 $attachments_of_node = $oFDForum->getFilesOfPost();
2456 if (count($attachments_of_node) && in_array($this->requestAction, [
'showedit',
'ready_showedit'])) {
2458 foreach ($oFDForum->getFilesOfPost() as $file) {
2461 $this->replyEditForm->addItem($oExistingAttachmentsGUI);
2465 if (in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
2467 $draftInfoGUI->setValue(sprintf(
2468 $this->
lng->txt(
'autosave_draft_info'),
2471 $this->replyEditForm->addItem($draftInfoGUI);
2472 } elseif (!in_array($this->requestAction, [
'showedit',
'ready_showedit'])) {
2474 $draftInfoGUI->setValue(sprintf(
2475 $this->
lng->txt(
'autosave_post_draft_info'),
2478 $this->replyEditForm->addItem($draftInfoGUI);
2482 $selected_draft_id = $draft_id;
2484 $this->
user->getId(),
2485 $this->objCurrentPost->getId(),
2488 if ($draftObj->getDraftId() > 0) {
2492 if ($files_of_draft !== []) {
2494 $this->
lng->txt(
'forums_delete_file'),
2497 foreach ($files_of_draft as $file) {
2500 $this->replyEditForm->addItem($oExistingAttachmentsGUI);
2505 $this->replyEditForm->addCommandButton(
'saveTopLevelPost', $this->
lng->txt(
'create'));
2507 $this->replyEditForm->addCommandButton(
'publishDraft', $this->
lng->txt(
'publish'));
2509 $this->replyEditForm->addCommandButton(
'savePost', $this->
lng->txt(
'save'));
2514 $hidden_draft_id->setValue((
string) $auto_save_draft_id);
2515 $this->replyEditForm->addItem($hidden_draft_id);
2517 if (in_array($this->requestAction, [
'showreply',
'ready_showreply',
'editdraft'])) {
2518 $show_rte = $this->
http->wrapper()->post()->retrieve(
2520 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->
refinery->always(0)])
2527 if ($quotingAllowed) {
2528 $this->replyEditForm->addCommandButton(
'quotePost', $this->
lng->txt(
'forum_add_quote'));
2531 if (!$this->
user->isAnonymous() &&
2532 in_array($this->requestAction, [
'editdraft',
'showreply',
'ready_showreply']) &&
2538 if ($this->requestAction ===
'editdraft') {
2539 $this->replyEditForm->addCommandButton(
'updateDraft', $this->
lng->txt(
'save_message'));
2541 $this->replyEditForm->addCommandButton(
'saveTopLevelDraft', $this->
lng->txt(
'save_message'));
2543 $this->replyEditForm->addCommandButton(
'saveAsDraft', $this->
lng->txt(
'save_message'));
2546 $cancel_cmd =
'cancelDraft';
2549 $this->replyEditForm->addCommandButton($cancel_cmd, $this->
lng->txt(
'cancel'));
2554 if ($this->replyEditForm ===
null) {
2566 if ($draft_id > 0 && !$this->
user->isAnonymous()
2569 $this->
user->getId(),
2570 $this->objCurrentPost->getId(),
2575 if ($draft_obj instanceof
ilForumPostDraft && $draft_obj->getDraftId() > 0) {
2576 $this->
ctrl->setParameter($this,
'action',
'editdraft');
2577 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2578 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
2579 $this->
ctrl->setParameter($this,
'draft_id', $draft_obj->getDraftId());
2580 $this->
ctrl->setParameter($this,
'page', 0);
2581 $this->
ctrl->setParameter(
2586 $this->
ctrl->redirect($this,
'editDraft');
2600 if ($draft_id > 0) {
2608 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2609 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2612 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
2613 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2616 if ($this->objCurrentTopic->getId() === 0) {
2617 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
2618 $this->
ctrl->redirect($this);
2621 if ($this->objCurrentTopic->isClosed()) {
2622 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
2623 $this->
ctrl->redirect($this);
2626 if ($this->objCurrentPost->getId() === 0) {
2627 $this->requestAction =
'';
2628 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'));
2636 if ($use_replyform) {
2638 if (!$oReplyEditForm->checkInput()) {
2639 $oReplyEditForm->setValuesByPost();
2643 $post_subject = $oReplyEditForm->getInput(
'subject');
2644 $post_message = $oReplyEditForm->getInput(
'message');
2647 $post_subject = $draft->getPostSubject();
2648 $post_message = $draft->getPostMessage();
2653 $frm = $oForumObjects[
'frm'];
2654 $frm->setMDB2WhereCondition(
' top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
2658 $send_activation_mail =
false;
2660 if ($this->objProperties->isPostActivationEnabled()) {
2661 if (!$this->is_moderator) {
2663 $send_activation_mail =
true;
2664 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2669 $newPost = $frm->generatePost(
2670 $draft->getForumId(),
2671 $draft->getThreadId(),
2672 $this->
user->getId(),
2673 $draft->getPostDisplayUserId(),
2675 $draft->getPostId(),
2676 $draft->isNotificationEnabled(),
2678 $draft->getPostUserAlias(),
2681 $send_activation_mail
2684 $this->
object->markPostRead(
2685 $this->
user->getId(),
2686 $this->objCurrentTopic->getId(),
2687 $this->objCurrentPost->getId()
2692 foreach ($uploadedObjects as $mob) {
2699 if ($draft->getRCID() > 0) {
2700 $post_obj->setRCID($draft->getRCID());
2701 $post_obj->update();
2704 if ($this->objProperties->isFileUploadAllowed()) {
2705 $file = $_FILES[
'userfile'] ?? [];
2706 if (is_array($file) && !empty($file)) {
2712 $GLOBALS[
'ilAppEventHandler']->raise(
2713 'components/ILIAS/Forum',
2716 'draftObj' => $draft,
2717 'obj_id' => $this->
object->getId(),
2718 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
2721 $draft->deleteDraft();
2723 $GLOBALS[
'ilAppEventHandler']->raise(
2724 'components/ILIAS/Forum',
2727 'object' => $this->
object,
2728 'ref_id' => $this->
object->getRefId(),
2729 'post' => $post_obj,
2730 'notify_moderators' => $send_activation_mail
2735 if (!$this->is_moderator && !$status) {
2736 $message .= $this->
lng->txt(
'forums_post_needs_to_be_activated');
2738 $message .= $this->
lng->txt(
'forums_post_new_entry');
2742 if (is_array($frm_session_values)) {
2743 $frm_session_values[$this->objCurrentTopic->getId()][
'openTreeNodes'][] = $this->objCurrentPost->getId();
2747 $this->
ctrl->clearParameters($this);
2748 $this->tpl->setOnScreenMessage(
'success',
$message,
true);
2749 $this->
ctrl->setParameter($this,
'pos_pk', $newPost);
2750 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2752 $this->
ctrl->redirect($this,
'viewThread');
2757 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2758 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2761 if ($this->objCurrentTopic->getId() === 0) {
2762 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
2763 $this->
ctrl->redirect($this);
2766 if ($this->objCurrentTopic->isClosed()) {
2767 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
2768 $this->
ctrl->redirect($this);
2774 if ($oReplyEditForm->checkInput()) {
2775 if ($this->objCurrentPost->getId() === 0) {
2776 $this->requestAction =
'';
2777 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'),
true);
2783 $forumObj = $oForumObjects[
'forumObj'];
2784 $frm = $oForumObjects[
'frm'];
2785 $frm->setMDB2WhereCondition(
' top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
2786 $topicData = $frm->getOneTopic();
2788 $autosave_draft_id = $this->
http->wrapper()->post()->retrieve(
2790 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->
refinery->always(0)])
2793 if ($this->requestAction ===
'ready_showreply') {
2794 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
2795 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2799 $send_activation_mail =
false;
2801 if ($this->objProperties->isPostActivationEnabled()) {
2802 if (!$this->is_moderator) {
2804 $send_activation_mail =
true;
2805 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2811 if ((
string) $oReplyEditForm->getInput(
'alias') ===
'') {
2812 $user_alias = $this->
lng->txt(
'forums_anonymous');
2814 $user_alias = $oReplyEditForm->getInput(
'alias');
2816 $display_user_id = 0;
2818 $user_alias = $this->
user->getLogin();
2819 $display_user_id = $this->
user->getId();
2822 $newPost = $frm->generatePost(
2823 $topicData->getTopPk(),
2824 $this->objCurrentTopic->getId(),
2825 $this->
user->getId(),
2828 $this->objCurrentPost->getId(),
2829 $oReplyEditForm->getInput(
'notify') && !$this->
user->isAnonymous(),
2834 $send_activation_mail
2837 if ($autosave_draft_id > 0) {
2839 $this->
user->getId(),
2840 $this->objCurrentPost->getId(),
2844 $draft->deleteDraft();
2849 $this->
object->markPostRead(
2850 $this->
user->getId(),
2851 $this->objCurrentTopic->getId(),
2852 $this->objCurrentPost->getId()
2857 $oReplyEditForm->getInput(
'message'),
2859 $this->
user->getId(),
2864 if ($this->objProperties->isFileUploadAllowed()) {
2866 $file = $_FILES[
'userfile'];
2867 if (is_array($file) && !empty($file)) {
2872 $GLOBALS[
'ilAppEventHandler']->raise(
2873 'components/ILIAS/Forum',
2876 'object' => $this->
object,
2877 'ref_id' => $this->
object->getRefId(),
2879 'notify_moderators' => $send_activation_mail
2884 if (!$this->is_moderator && !$status) {
2885 $message .= $this->
lng->txt(
'forums_post_needs_to_be_activated');
2887 $message .= $this->
lng->txt(
'forums_post_new_entry');
2890 $this->tpl->setOnScreenMessage(
'success',
$message,
true);
2891 $this->
ctrl->clearParameters($this);
2892 $this->
ctrl->setParameter($this,
'post_created_below', $this->objCurrentPost->getId());
2893 $this->
ctrl->setParameter($this,
'pos_pk', $newPost);
2894 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2896 if ((!$this->is_moderator &&
2897 !$this->objCurrentPost->isOwner($this->user->getId())) || $this->objCurrentPost->isCensored() ||
2898 $this->
user->isAnonymous()) {
2899 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2906 foreach ($oldMediaObjects as $oldMob) {
2908 foreach ($curMediaObjects as $curMob) {
2909 if ($oldMob === $curMob) {
2922 $old_status_was_active = $this->objCurrentPost->isActivated();
2926 $send_activation_mail =
false;
2928 if ($this->objProperties->isPostActivationEnabled()) {
2929 if (!$this->is_moderator) {
2931 $send_activation_mail =
true;
2932 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2936 $this->objCurrentPost->setStatus($status);
2938 $this->objCurrentPost->setSubject($this->
handleFormInput($oReplyEditForm->getInput(
'subject'),
false));
2940 $oReplyEditForm->getInput(
'message')
2942 $this->objCurrentPost->setNotification($oReplyEditForm->getInput(
'notify') && !$this->
user->isAnonymous());
2943 $this->objCurrentPost->setChangeDate(date(
'Y-m-d H:i:s'));
2944 $this->objCurrentPost->setUpdateUserId($this->
user->getId());
2946 if ($this->objCurrentPost->update()) {
2947 $this->objCurrentPost->reload();
2954 $this->objCurrentPost->getId(),
2959 $news_item->setTitle($this->objCurrentPost->getSubject());
2960 $news_item->setContent(
2962 $this->objCurrentPost->getMessage()
2966 if ($this->objCurrentPost->getMessage() !== strip_tags($this->objCurrentPost->getMessage())) {
2967 $news_item->setContentHtml(
true);
2969 $news_item->setContentHtml(
false);
2971 $news_item->update();
2974 $oFDForum = $oForumObjects[
'file_obj'];
2976 $file2delete = $oReplyEditForm->getInput(
'del_file');
2977 if (is_array($file2delete) && count($file2delete)) {
2978 $oFDForum->unlinkFilesByMD5Filenames($file2delete);
2981 if ($this->objProperties->isFileUploadAllowed()) {
2982 $file = $_FILES[
'userfile'];
2983 if (is_array($file) && !empty($file)) {
2984 $oFDForum->storeUploadedFiles();
2988 $GLOBALS[
'ilAppEventHandler']->raise(
2989 'components/ILIAS/Forum',
2992 'ref_id' => $this->
object->getRefId(),
2994 'notify_moderators' => $send_activation_mail,
2995 'old_status_was_active' => $old_status_was_active
2999 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'forums_post_modified'),
true);
3002 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
3003 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
3004 $this->
ctrl->setParameter($this,
'viewmode', $this->selectedSorting);
3006 $this->
ctrl->redirect($this,
'viewThread');
3008 $this->requestAction = substr($this->requestAction, 6);
3015 if ($a_flag ===
null) {
3025 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3026 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3029 if ($this->objCurrentTopic->isClosed()) {
3030 $this->requestAction =
'';
3037 $oReplyEditForm->getItemByPostVar(
'subject')->setRequired(
false);
3038 $oReplyEditForm->getItemByPostVar(
'message')->setRequired(
false);
3040 $oReplyEditForm->checkInput();
3042 $oReplyEditForm->getItemByPostVar(
'subject')->setRequired(
true);
3043 $oReplyEditForm->getItemByPostVar(
'message')->setRequired(
true);
3045 $this->requestAction =
'showreply';
3055 if ($this->forumObjects ===
null) {
3057 $file_obj =
new ilFileDataForum($forumObj->getId(), $this->objCurrentPost->getId());
3058 $frm = $forumObj->Forum;
3059 $frm->setForumId($forumObj->getId());
3060 $frm->setForumRefId($forumObj->getRefId());
3062 $this->forumObjects[
'forumObj'] = $forumObj;
3063 $this->forumObjects[
'frm'] = $frm;
3064 $this->forumObjects[
'file_obj'] = $file_obj;
3072 $this->selectedSorting = $this->objProperties->getDefaultView();
3075 $view_mode =
'viewmode_' . $this->
getObject()->getId();
3085 isset($this->httpRequest->getQueryParams()[
'viewmode']) &&
3088 $this->selectedSorting = (
int) $this->httpRequest->getQueryParams()[
'viewmode'];
3091 if (!in_array($this->selectedSorting, [
3096 $this->selectedSorting = $this->objProperties->getDefaultView();
3105 $this->selected_post_storage->set($this->objCurrentTopic->getId(), 0);
3106 $this->
ctrl->redirect($this,
'viewThread');
3111 $thr_pk = $this->objCurrentTopic->getId();
3114 $toolbar_items = [];
3117 $thread_control_session_values =
ilSession::get(
'thread_control');
3118 if (is_array($thread_control_session_values)) {
3119 if (!isset($thread_control_session_values[
'old'])) {
3120 $thread_control_session_values[
'old'] = $thr_pk;
3121 $thread_control_session_values[
'new'] = $thr_pk;
3122 ilSession::set(
'thread_control', $thread_control_session_values);
3123 } elseif (isset($thread_control_session_values[
'old']) && $thr_pk !== $thread_control_session_values[
'old']) {
3124 $thread_control_session_values[
'new'] = $thr_pk;
3125 ilSession::set(
'thread_control', $thread_control_session_values);
3129 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3130 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3134 $forumObj = $oForumObjects[
'forumObj'];
3135 $frm = $oForumObjects[
'frm'];
3136 $file_obj = $oForumObjects[
'file_obj'];
3138 $selected_draft_id = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
3139 if (isset($this->httpRequest->getQueryParams()[
'file'])) {
3140 $file_obj_for_delivery = $file_obj;
3147 if ($this->objCurrentTopic->getId() === 0) {
3148 $this->
ctrl->redirect($this,
'showThreads');
3152 if (isset($this->httpRequest->getQueryParams()[
'page'])) {
3153 $pageIndex = max((
int) $this->httpRequest->getQueryParams()[
'page'], $pageIndex);
3156 if ($this->selected_post_storage->get($this->objCurrentTopic->getId()) > 0) {
3158 $this->selected_post_storage->get($this->objCurrentTopic->getId()),
3159 $this->is_moderator,
3163 $firstNodeInThread = $this->objCurrentTopic->getPostRootNode();
3174 'tpl.forums_threads_view.html',
3177 'components/ILIAS/Forum' 3182 $order_field =
'frm_posts_tree.rgt';
3183 $this->objCurrentTopic->setOrderDirection(
'DESC');
3184 $threadContentTemplate->setVariable(
'LIST_TYPE', $this->viewModeOptions[$this->selectedSorting]);
3186 $order_field =
'frm_posts.pos_date';
3187 $this->objCurrentTopic->setOrderDirection(
3190 $threadContentTemplate->setVariable(
'LIST_TYPE', $this->sortationOptions[$this->selectedSorting]);
3192 $this->objCurrentTopic->setOrderField($order_field);
3195 $subtree_nodes = $this->objCurrentTopic->getPostTree($firstNodeInThread);
3196 $numberOfPostings = count($subtree_nodes);
3207 $append =
'_' . $this->objCurrentTopic->getId() .
3208 ($this->objCurrentPost->getId() !== 0 ?
'_' . $this->objCurrentPost->getId() :
'');
3209 $this->tpl->setLoginTargetPar(
'frm_' . $this->
object->getRefId() . $append);
3212 if (!in_array($this->requestAction, [
'showreply',
'showedit'])) {
3215 foreach ($mobs as $mob) {
3226 if (!$this->
getCreationMode() && $this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3228 $this->
object->getRefId(),
3229 ilLink::_getLink($this->
object->getRefId(),
'frm'),
3234 $this->prepareThreadScreen($forumObj);
3237 if (isset($this->httpRequest->getQueryParams()[
'anchor'])) {
3238 $threadContentTemplate->setVariable(
'JUMP2ANCHOR_ID', (
int) $this->httpRequest->getQueryParams()[
'anchor']);
3240 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
3243 $this->
object->getType(),
3244 $this->
object->getRefId(),
3245 $this->
object->getId(),
3246 $this->
user->getId()
3249 if ($firstNodeInThread) {
3250 $this->objCurrentTopic->updateVisits();
3252 $this->tpl->setTitle($this->
lng->txt(
'forums_thread') .
' "' . $this->objCurrentTopic->getSubject() .
'"');
3254 $this->
locator->addRepositoryItems();
3255 $this->
locator->addItem($this->
object->getTitle(), $this->
ctrl->getLinkTarget($this,
''),
'_top');
3256 $this->tpl->setLocator();
3258 if (!$this->
user->isAnonymous() &&
3259 $forumObj->getCountUnread($this->
user->getId(), $this->objCurrentTopic->getId(),
true)) {
3260 $this->
ctrl->setParameter($this,
'mark_read',
'1');
3261 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3263 $mark_thr_read_button = $this->uiFactory->button()->standard(
3264 $this->
lng->txt(
'forums_mark_read'),
3265 $this->
ctrl->getLinkTarget($this,
'viewThread')
3268 $toolbar_items[] = $mark_thr_read_button;
3270 $this->
ctrl->clearParameters($this);
3273 $this->
ctrl->setParameterByClass(ilForumExportGUI::class,
'print_thread', $this->objCurrentTopic->getId());
3274 $this->
ctrl->setParameterByClass(
3275 ilForumExportGUI::class,
3277 $this->objCurrentTopic->getForumId()
3280 if ($numberOfPostings > 0 && $this->
settings->get(
'forum_enable_print',
'0')) {
3281 $print_thr_button = $this->uiFactory->button()->standard(
3282 $this->
lng->txt(
'forums_print_thread'),
3283 $this->
ctrl->getLinkTargetByClass(ilForumExportGUI::class,
'printThread')
3285 $toolbar_items[] = $print_thr_button;
3289 $this->
ctrl->clearParametersByClass(ilForumExportGUI::class);
3293 if (isset($this->httpRequest->getQueryParams()[
'mark_read'])) {
3294 $forumObj->markThreadRead($this->
user->getId(), $this->objCurrentTopic->getId());
3295 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_thread_marked'),
true);
3300 !$this->objCurrentTopic->isClosed() &&
3301 $this->
access->checkAccess(
'add_reply',
'', $this->
object->getRefId())) {
3302 $this->
ctrl->setParameter($this,
'action',
'showreply');
3303 $this->
ctrl->setParameter($this,
'pos_pk', $firstNodeInThread->getId());
3304 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3305 $this->
ctrl->setParameter(
3308 (
int) ($this->httpRequest->getQueryParams()[
'page'] ?? 0)
3310 $this->
ctrl->setParameter(
3315 if ($numberOfPostings > 0) {
3316 $reply_button = $this->uiFactory->button()->standard(
3317 $this->
lng->txt(
'add_new_answer'),
3318 $this->
ctrl->getLinkTarget($this,
'createTopLevelPost',
'frm_page_bottom')
3321 $reply_button = $this->uiFactory->button()->primary(
3322 $this->
lng->txt(
'add_new_answer'),
3323 $this->
ctrl->getLinkTarget($this,
'createTopLevelPost',
'frm_page_bottom')
3326 $this->
ctrl->clearParameters($this);
3327 array_unshift($toolbar_items, $reply_button);
3331 if ($numberOfPostings === 0 && $firstNodeInThread->getId() === 0) {
3332 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_no_posts_available'));
3335 $pageSize = $frm->getPageHits();
3337 if ($numberOfPostings > $pageSize) {
3338 $this->
ctrl->setParameter($this,
'ref_id', $this->
object->getRefId());
3339 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3340 $this->
ctrl->setParameter(
3345 $paginationUrl = $this->
ctrl->getLinkTarget($this,
'viewThread',
'');
3346 $this->
ctrl->clearParameters($this);
3348 $pagination = $this->uiFactory->viewControl()
3350 ->withTargetURL($paginationUrl,
'page')
3351 ->withTotalEntries($numberOfPostings)
3352 ->withPageSize($pageSize)
3353 ->withMaxPaginationButtons(10)
3354 ->withCurrentPage($pageIndex);
3356 $threadContentTemplate->setVariable(
'THREAD_MENU', $this->uiRenderer->render(
3359 $threadContentTemplate->setVariable(
'THREAD_MENU_BOTTOM', $this->uiRenderer->render(
3365 $draftsObjects = [];
3366 if ($doRenderDrafts) {
3368 $this->
user->getId(),
3369 $this->objCurrentTopic->getId(),
3374 $pagedPostings = array_slice($subtree_nodes, $pageIndex * $pageSize, $pageSize);
3378 if ($doRenderDrafts && $pageIndex === 0 &&
3380 foreach ($draftsObjects as $draft) {
3381 $referencePosting = array_values(array_filter(
3384 ))[0] ?? $firstNodeInThread;
3387 $threadContentTemplate,
3388 $this->requestAction,
3395 foreach ($pagedPostings as $node) {
3396 $this->
ctrl->clearParameters($this);
3399 ($this->is_moderator || $node->isActivated() || $node->isOwner($this->
user->getId()))) {
3400 if (!$this->objCurrentTopic->isClosed() && in_array($this->requestAction, [
3404 $this->
renderPostingForm($threadContentTemplate, $frm, $node, $this->requestAction);
3405 } elseif ($this->requestAction ===
'censor' &&
3407 $threadContentTemplate->setVariable(
'FORM', $this->getCensorshipFormHTML());
3411 $this->
renderPostContent($threadContentTemplate, $node, $this->requestAction, $pageIndex, $postIndex);
3414 $threadContentTemplate,
3415 $this->requestAction,
3417 $draftsObjects[$node->getId()] ?? []
3426 $doRenderDrafts && $pageIndex === max(0, (
int) (ceil($numberOfPostings / $pageSize) - 1))
3428 foreach ($draftsObjects as $draft) {
3429 $referencePosting = array_values(array_filter(
3432 ))[0] ?? $firstNodeInThread;
3435 $threadContentTemplate,
3436 $this->requestAction,
3444 $firstNodeInThread instanceof
ilForumPost && $doRenderDrafts &&
3448 $threadContentTemplate,
3449 $this->requestAction,
3451 $draftsObjects[$firstNodeInThread->getId()] ?? []
3456 !$this->objCurrentTopic->isClosed() &&
3457 in_array($this->
ctrl->getCmd(), [
'createTopLevelPost',
'saveTopLevelPost',
'saveTopLevelDraft'],
true) &&
3458 $this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
3460 $this->objCurrentPost->setId($firstNodeInThread->getId());
3463 if (in_array($this->
ctrl->getCmd(), [
'saveTopLevelPost',
'saveTopLevelDraft'])) {
3464 $form->setValuesByPost();
3466 $threadContentTemplate->setVariable(
'BOTTOM_FORM', $form->getHTML());
3469 $threadContentTemplate->setCurrentBlock(
'posts_no');
3470 $threadContentTemplate->setVariable(
3471 'TXT_MSG_NO_POSTS_AVAILABLE',
3472 $this->
lng->txt(
'forums_posts_not_available')
3474 $threadContentTemplate->parseCurrentBlock();
3477 $to_top_button = $this->uiFactory->button()
3478 ->standard($this->
lng->txt(
'top_of_page'),
'#frm_page_top');
3479 $bottom_toolbar->addComponent($to_top_button);
3480 if ($numberOfPostings > 0) {
3481 $threadContentTemplate->setVariable(
'TOOLBAR_BOTTOM', $bottom_toolbar->getHTML());
3484 if ($toolbar_items !== []) {
3485 foreach ($toolbar_items as $component_index => $item) {
3486 $this->toolbar->addComponent($item);
3487 $bottom_toolbar->addComponent($item);
3488 if ($component_index === 0 && $numberOfPostings > 0) {
3497 $this->tpl->setPermanentLink(
3498 $this->
object->getType(),
3499 $this->
object->getRefId(),
3500 (string) $this->objCurrentTopic->getId()
3503 $this->tpl->addOnLoadCode(
3505 document.querySelectorAll(
'.ilFrmPostContent img').forEach((img) => {
3506 const maxWidth = img.getAttribute(
'width');
3507 const maxHeight = img.getAttribute(
'height');
3510 img.style.maxWidth = maxWidth +
'px';
3511 img.removeAttribute(
'width');
3515 img.style.maxHeight = maxHeight +
'px';
3516 img.removeAttribute(
'height');
3526 $this->tpl->setContent((
$info ??
'') . $threadContentTemplate->get() . $this->
getModalActions());
3531 if ($currentViewMode === 3) {
3532 $currentViewMode = 2;
3534 $translationKeys = [];
3535 foreach ($this->viewModeOptions as $sortingConstantKey => $languageKey) {
3536 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3537 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
3538 $this->
ctrl->setParameter($this,
'viewmode', $sortingConstantKey);
3540 $translationKeys[$this->
lng->txt($languageKey)] = $this->
ctrl->getLinkTarget(
3546 $this->
ctrl->clearParameters($this);
3553 $sortViewControl = $this->uiFactory
3555 ->mode($translationKeys, $this->
lng->txt($this->viewModeOptions[$currentViewMode]))
3556 ->withActive($this->
lng->txt($this->viewModeOptions[$currentViewMode]));
3557 $this->
toolbar->addComponent($sortViewControl);
3562 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3563 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
3564 $target = $this->
ctrl->getLinkTarget(
3572 $sortingDirectionViewControl = $this->uiFactory
3574 ->sortation($translatedSortationOptions, (
string) $currentSorting)
3575 ->withTargetURL($target,
'viewmode');
3576 $this->
toolbar->addComponent($sortingDirectionViewControl);
3581 return (
new \
ILIAS\
components\Forum\Subject\PostingReplySubjectBuilder(
3582 $this->
lng->txt(
'post_reply'),
3583 $this->
lng->txt(
'post_reply_count')
3584 ))->build($this->objCurrentPost->getSubject());
3591 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->
refinery->always(0)])
3593 $backurl = $this->
http->wrapper()->query()->retrieve(
3595 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->
refinery->always(
'')])
3599 $add = $this->getUserProfileAdditional($this->
object->getRefId(),
$user_id);
3600 $profile_gui->setAdditional($add);
3602 $this->tpl->setContent($this->
ctrl->getHTML($profile_gui));
3605 protected function getUserProfileAdditional(
int $a_forum_ref_id,
int $a_user_id): array
3607 if (!$this->
access->checkAccess(
'read',
'', $a_forum_ref_id)) {
3608 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3613 if ($ref_obj->getType() ===
'frm') {
3615 $frm = $forumObj->Forum;
3616 $frm->setForumId($forumObj->getId());
3617 $frm->setForumRefId($forumObj->getRefId());
3622 if ($this->
access->checkAccess(
'moderate_frm',
'', $a_forum_ref_id)) {
3623 $numPosts = $frm->countUserArticles($a_user_id);
3625 $numPosts = $frm->countActiveUserArticles($a_user_id);
3628 return [$this->
lng->txt(
'forums_posts') => $numPosts];
3633 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3634 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3640 $cmd = $this->
ctrl->getCmd();
3643 if ($thread_ids !== []) {
3644 if ($cmd ===
'move') {
3645 if ($this->is_moderator) {
3649 } elseif ($cmd ===
'enable_notifications' && (
int) $this->
settings->get(
'forum_notification',
'0') !== 0) {
3650 foreach ($thread_ids as $thread_id) {
3653 $tmp_obj->enableNotification($this->
user->getId());
3656 $this->
ctrl->redirect($this,
'showThreads');
3657 } elseif ($cmd ===
'disable_notifications' && (
int) $this->
settings->get(
'forum_notification',
'0') !== 0) {
3658 foreach ($thread_ids as $thread_id) {
3661 $tmp_obj->disableNotification($this->
user->getId());
3664 $this->
ctrl->redirect($this,
'showThreads');
3665 } elseif ($cmd ===
'close') {
3666 if ($this->is_moderator) {
3667 foreach ($thread_ids as $thread_id) {
3673 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'selected_threads_closed'),
true);
3674 $this->
ctrl->redirect($this,
'showThreads');
3675 } elseif ($cmd ===
'reopen') {
3676 if ($this->is_moderator) {
3677 foreach ($thread_ids as $thread_id) {
3684 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'selected_threads_reopened'),
true);
3685 $this->
ctrl->redirect($this,
'showThreads');
3686 } elseif ($cmd ===
'makesticky') {
3687 if ($this->is_moderator) {
3688 $message = $this->
lng->txt(
'sel_threads_make_sticky');
3690 foreach ($thread_ids as $thread_id) {
3693 $makeSticky = $tmp_obj->makeSticky();
3695 $message = $this->
lng->txt(
'sel_threads_already_sticky');
3700 $this->tpl->setOnScreenMessage(
'info',
$message,
true);
3702 $this->
ctrl->redirect($this,
'showThreads');
3703 } elseif ($cmd ===
'unmakesticky' || $cmd ===
'make_topics_non_sticky') {
3704 if ($this->is_moderator) {
3705 $message = $this->
lng->txt(
'sel_threads_make_unsticky');
3706 foreach ($thread_ids as $thread_id) {
3709 $unmakeSticky = $tmp_obj->unmakeSticky();
3710 if (!$unmakeSticky) {
3711 $message = $this->
lng->txt(
'sel_threads_already_unsticky');
3717 $this->tpl->setOnScreenMessage(
'info',
$message,
true);
3719 $this->
ctrl->redirect($this,
'showThreads');
3720 } elseif ($cmd ===
'editThread') {
3721 if ($this->is_moderator) {
3722 $count = count($thread_ids);
3724 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_max_one_thread'),
true);
3725 $this->
ctrl->redirect($this,
'showThreads');
3732 $this->
ctrl->redirect($this,
'showThreads');
3733 } elseif ($cmd ===
'confirmDeleteThreads') {
3734 $this->confirmDeleteThreadsObject();
3735 } elseif ($cmd ===
'mergeThreads') {
3738 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'topics_please_select_one_action'),
true);
3739 $this->
ctrl->redirect($this,
'showThreads');
3742 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
3743 $this->
ctrl->redirect($this,
'showThreads');
3749 if (!$this->is_moderator) {
3750 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3753 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3754 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3758 if ($this->
http->wrapper()->post()->has(
'frm_ref_id')) {
3759 $frm_ref_id = $this->
http->wrapper()->post()->retrieve(
3764 $this->error->raiseError(
'Please select a forum', $this->error->MESSAGE);
3768 if (!is_array($threads2move) || $threads2move === []) {
3769 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
3770 $this->
ctrl->redirect($this,
'showThreads');
3773 if (!$this->
access->checkAccess(
'read',
'', (
int) $frm_ref_id)) {
3774 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3778 array_walk($threads2move,
function (
int $threadId) use (&$threads):
void {
3782 $threads[] = $threadId;
3785 if (isset($frm_ref_id) && (
int) $frm_ref_id) {
3786 $errorMessages = $this->
object->Forum->moveThreads(
3789 $this->ilObjDataCache->lookupObjId((
int) $frm_ref_id)
3792 if ([] !== $errorMessages) {
3793 $this->tpl->setOnScreenMessage(
'failure', implode(
'<br><br>', $errorMessages),
true);
3794 $this->
ctrl->redirect($this,
'showThreads');
3798 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'threads_moved_successfully'),
true);
3799 $this->
ctrl->redirect($this,
'showThreads');
3801 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'no_forum_selected'));
3809 $this->
ctrl->redirect($this,
'showThreads');
3814 if (!$this->is_moderator) {
3815 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3818 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3819 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3822 $frm_ref_id = $this->
http->wrapper()->post()->retrieve(
3828 if (!is_array($threads2move) || $threads2move === []) {
3829 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
3830 $this->
ctrl->redirect($this,
'showThreads');
3835 array_walk($threads2move,
function (
int $threadId) use (&$threads, $isModerator):
void {
3839 $threads[] = $thread;
3843 $exp->setPathOpen($this->
object->getRefId());
3844 $exp->setNodeSelected(isset($frm_ref_id) && (
int) $frm_ref_id ? (
int) $frm_ref_id : 0);
3845 $exp->setCurrentFrmRefId($this->
object->getRefId());
3846 $exp->setHighlightedNode((
string) $this->
object->getRefId());
3847 if (!$exp->handleCommand()) {
3849 'tpl.forums_threads_move.html',
3852 'components/ILIAS/Forum' 3856 $this->
toolbar->addButton($this->
lng->txt(
'back'), $this->
ctrl->getLinkTarget($this));
3860 foreach ($threads as $thread) {
3861 $messages[] = $this->ui_factory->messageBox()->info(
3862 sprintf($this->
lng->txt(
'move_chosen_topics'), $thread->getSubject())
3865 $moveThreadTemplate->setVariable(
'THREAD_MESSAGE', $this->uiRenderer->render(
$messages));
3866 $moveThreadTemplate->setVariable(
'FRM_SELECTION_TREE', $exp->getHTML());
3867 $moveThreadTemplate->setVariable(
'CMD_SUBMIT',
'performMoveThreads');
3868 $moveThreadTemplate->setVariable(
'TXT_SUBMIT', $this->
lng->txt(
'move'));
3869 $moveThreadTemplate->setVariable(
'FORMACTION', $this->
ctrl->getFormAction($this,
'performMoveThreads'));
3871 $this->tpl->setContent($moveThreadTemplate->get());
3880 $this->objProperties->isAnonymized() &&
3881 (!$this->is_moderator || !$this->objProperties->getMarkModeratorPosts())
3887 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3888 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3891 $draftIds = array_filter((array) ($this->httpRequest->getParsedBody()[
'draft_ids'] ?? []));
3894 $checkedDraftIds = [];
3895 foreach ($draftIds as $draftId) {
3896 if (array_key_exists($draftId, $instances)) {
3897 $checkedDraftIds[] = $draftId;
3898 $draft = $instances[$draftId];
3902 $GLOBALS[
'ilAppEventHandler']->raise(
3903 'components/ILIAS/Forum',
3906 'draftObj' => $draft,
3907 'obj_id' => $this->
object->getId(),
3908 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
3913 $draftFileData->delete([$draft->getDraftId()]);
3915 $draft->deleteDraft();
3919 if (count($checkedDraftIds) > 1) {
3920 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'delete_drafts_successfully'),
true);
3922 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'delete_draft_successfully'),
true);
3924 $this->
ctrl->redirect($this,
'showThreads');
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,
3952 $default_form->generateDefaultForm();
3956 return $default_form;
3961 $draftId = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
3962 $allowNotification = !$this->objProperties->isAnonymized() && !$this->
user->isAnonymous();
3965 if (!$this->
rbac->system()->checkAccess(
'internal_mail', $mail->getMailObjectReferenceId())) {
3966 $allowNotification =
false;
3971 $this->objProperties,
3981 $minimal_form->generateMinimalForm();
3983 return $minimal_form;
3988 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3989 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3992 if (!$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId())) {
3993 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3996 $tpl =
new ilTemplate(
'tpl.create_thread_form.html',
true,
true,
'components/ILIAS/Forum');
3999 $accordion->setId(
'acc_' . $this->obj_id);
4002 $accordion->addItem($this->
lng->txt(
'new_thread_with_post'), $this->
buildThreadForm()->getHTML());
4008 $this->tpl->setContent(
$tpl->
get());
4016 if (!$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4017 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4018 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4021 $frm = $this->
object->Forum;
4022 $frm->setForumId($this->
object->getId());
4023 $frm->setForumRefId($this->
object->getRefId());
4024 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
4025 $topicData = $frm->getOneTopic();
4030 if ($form->checkInput()) {
4031 $userIdForDisplayPurposes = $this->
user->getId();
4033 $userIdForDisplayPurposes = 0;
4039 $this->objCurrentPost->isAnyParentDeactivated()
4044 if ($createFromDraft) {
4046 $newThread->setForumId($topicData->getTopPk());
4049 $newThread->setSubject($this->
handleFormInput($form->getInput(
'subject'),
false));
4052 $newPost = $frm->generateThread(
4061 $newThread->setForumId($topicData->getTopPk());
4062 $newThread->setThrAuthorId($this->
user->getId());
4063 $newThread->setDisplayUserId($userIdForDisplayPurposes);
4064 $newThread->setSubject($this->
handleFormInput($form->getInput(
'subject'),
false));
4066 $form->getInput(
'alias'),
4067 $this->objProperties->isAnonymized()
4070 $newPost = $frm->generateThread(
4073 $form->getItemByPostVar(
'notify') && $form->getInput(
'notify') && !$this->
user->isAnonymous(),
4081 $post_obj->setRCID($draft->
getRCID());
4082 $post_obj->update();
4085 if ($this->objProperties->isFileUploadAllowed()) {
4086 $file = $_FILES[
'userfile'];
4087 if (is_array($file) && !empty($file)) {
4093 $frm->setDbTable(
'frm_data');
4094 $frm->setMDB2WhereCondition(
'top_pk = %s ', [
'integer'], [$topicData->getTopPk()]);
4095 $frm->updateVisits($topicData->getTopPk());
4097 if ($createFromDraft) {
4102 foreach ($mediaObjects as $mob) {
4111 $draftHistory->deleteHistoryByDraftIds([$draft->
getDraftId()]);
4115 $GLOBALS[
'ilAppEventHandler']->raise(
4116 'components/ILIAS/Forum',
4119 'object' => $this->
object,
4120 'ref_id' => $this->
object->getRefId(),
4121 'post' => $post_obj,
4122 'notify_moderators' => !$status
4126 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'forums_thread_new_entry'),
true);
4127 $this->
ctrl->redirect($this);
4130 $form->setValuesByPost();
4131 if (!$this->objProperties->isAnonymized()) {
4132 $form->getItemByPostVar(
'alias')->setValue($this->
user->getLogin());
4136 $accordion->setId(
'acc_' . $this->obj_id);
4138 $accordion->addItem($this->
lng->txt(
'new_thread_with_post'), $form->getHTML());
4139 $accordion->addItem($this->
lng->txt(
'empty_thread'), $minimal_form->getHTML());
4141 $this->tpl->setContent($accordion->getHTML());
4149 if (!$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4150 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4151 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4154 $frm = $this->
object->Forum;
4155 $frm->setForumId($this->
object->getId());
4156 $frm->setForumRefId($this->
object->getRefId());
4157 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
4158 $topicData = $frm->getOneTopic();
4163 if ($minimal_form->checkInput()) {
4164 $userIdForDisplayPurposes = $this->
user->getId();
4166 $userIdForDisplayPurposes = 0;
4172 $this->objCurrentPost->isAnyParentDeactivated()
4178 $newThread->setForumId($topicData->getTopPk());
4179 $newThread->setThrAuthorId($this->
user->getId());
4180 $newThread->setDisplayUserId($userIdForDisplayPurposes);
4181 $newThread->setSubject($this->
handleFormInput($minimal_form->getInput(
'subject'),
false));
4183 $minimal_form->getInput(
'alias'),
4184 $this->objProperties->isAnonymized()
4187 $frm->generateThread(
4196 $frm->setDbTable(
'frm_data');
4197 $frm->setMDB2WhereCondition(
'top_pk = %s ', [
'integer'], [$topicData->getTopPk()]);
4198 $frm->updateVisits($topicData->getTopPk());
4200 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'forums_thread_new_entry'),
true);
4201 $this->
ctrl->redirect($this);
4204 $form->setValuesByPost();
4206 if (!$this->objProperties->isAnonymized()) {
4207 $form->getItemByPostVar(
'alias')->setValue($this->
user->getLogin());
4211 $accordion->setId(
'acc_' . $this->obj_id);
4213 $accordion->addItem($this->
lng->txt(
'new_thread_with_post'), $form->getHTML());
4214 $accordion->addItem($this->
lng->txt(
'empty_thread'), $minimal_form->getHTML());
4216 $this->tpl->setContent($accordion->getHTML());
4222 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4249 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId()) || $this->
user->isAnonymous()) {
4250 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4253 $frm = $this->
object->Forum;
4254 $frm->setForumId($this->
object->getId());
4255 $frm->enableForumNotification($this->
user->getId());
4257 if ($this->objCurrentTopic->getId() > 0) {
4258 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4259 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_enabled'),
true);
4260 $this->
ctrl->redirect($this,
'viewThread');
4263 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_enabled'));
4269 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId()) || $this->
user->isAnonymous()) {
4270 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4273 $frm = $this->
object->Forum;
4274 $frm->setForumId($this->
object->getId());
4275 $frm->disableForumNotification($this->
user->getId());
4277 if ($this->objCurrentTopic->getId() > 0) {
4278 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4279 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_disabled'),
true);
4280 $this->
ctrl->redirect($this,
'viewThread');
4283 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_disabled'));
4293 if ($this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
4295 if ($news_set->get(
'enable_rss_for_internal')) {
4306 $this->
object->getTitle(),
4307 $this->
ctrl->getLinkTarget($this),
4309 $this->
object->getRefId()
4316 $a_text = str_replace([
'<',
'>'], [
'<',
'>'], $a_text);
4317 if ($a_stripslashes) {
4326 $a_text = str_replace([
'<',
'>'], [
'<',
'>'], $a_text);
4334 !$this->
access->checkAccess(
'visible',
'', $this->object->getRefId()) &&
4335 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())
4337 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
4340 if (strtolower($this->
ctrl->getCmd() ??
'') ===
'infoscreen') {
4341 $this->
ctrl->redirectByClass(ilInfoScreenGUI::class,
'showSummary');
4345 $info->enablePrivateNotes();
4351 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4352 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4355 if ($this->objCurrentPost->getId() > 0) {
4358 $this->
object->markPostUnread($this->
user->getId(), $this->objCurrentPost->getId());
4365 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4366 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4369 if ($this->objCurrentTopic->getId() > 0 && $this->objCurrentPost->getId() > 0) {
4372 $this->
object->markPostRead(
4373 $this->
user->getId(),
4374 $this->objCurrentTopic->getId(),
4375 $this->objCurrentPost->getId()
4379 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4380 $this->
ctrl->redirect($this,
'viewThread');
4385 $lg = parent::initHeaderAction();
4391 if ($this->
user->isAnonymous() || !$this->
access->checkAccess(
'read',
'', $this->
object->getRefId())) {
4395 $frm = $this->
object->Forum;
4396 $frm->setForumId($this->
object->getId());
4397 $frm->setForumRefId($this->
object->getRefId());
4398 $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
4400 $are_notifications_enabled = $frm->isForumNotificationEnabled($this->
user->getId());
4401 $has_membership_enabled_parent_container = $this->
object->isParentMembershipEnabledContainer();
4402 $user_may_disable_notifcations = (
4404 !$has_membership_enabled_parent_container
4407 if ($this->objCurrentTopic->getId() > 0) {
4408 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4411 if (!$this->
user->isAnonymous()) {
4412 if ($has_membership_enabled_parent_container) {
4413 if ($are_notifications_enabled && $user_may_disable_notifcations) {
4414 $lg->addCustomCommand(
4415 $this->
ctrl->getLinkTarget($this,
'disableForumNotification'),
4416 'forums_disable_forum_notification' 4418 } elseif (!$are_notifications_enabled) {
4419 $lg->addCustomCommand(
4420 $this->
ctrl->getLinkTarget($this,
'enableForumNotification'),
4421 'forums_enable_forum_notification' 4424 } elseif ($are_notifications_enabled) {
4425 $lg->addCustomCommand(
4426 $this->
ctrl->getLinkTarget($this,
'disableForumNotification'),
4427 'forums_disable_forum_notification' 4430 $lg->addCustomCommand(
4431 $this->
ctrl->getLinkTarget($this,
'enableForumNotification'),
4432 'forums_enable_forum_notification' 4437 if ($are_notifications_enabled && $user_may_disable_notifcations && !$this->
user->isAnonymous()) {
4439 $frm_noti->setUserId($this->
user->getId());
4440 $interested_events = $frm_noti->readInterestedEvents();
4443 'hidden_value' =>
'',
4451 $notificationsModal = $this->uiFactory->modal()->roundtrip(
4452 $this->
lng->txt(
'notification_settings'),
4453 [$events_form_builder->build()]
4454 )->withActionButtons([
4457 ->primary($this->
lng->txt(
'save'),
'#')
4461 const button = document.getElementById('$id'); 4462 if (!button) return; 4464 const modalDialog = button.closest('.modal-dialog'); 4465 if (!modalDialog) return; 4467 const form = modalDialog.querySelector('.modal-body form'); 4470 form.classList.add('ilForumNotificationSettingsForm'); 4471 button.addEventListener('click', (event) => { 4472 event.preventDefault(); 4482 $showNotificationSettingsBtn = $this->uiFactory->button()
4483 ->shy($this->
lng->txt(
'notification_settings'),
'#')
4485 $notificationsModal->getShowSignal()
4488 $lg->addCustomCommandButton($showNotificationSettingsBtn, $notificationsModal);
4491 $are_thread_notifications_enabled =
false;
4492 if (!$this->
user->isAnonymous() && $this->objCurrentTopic->getId() > 0) {
4493 $are_thread_notifications_enabled = $this->objCurrentTopic->isNotificationEnabled($this->
user->getId());
4494 if ($are_thread_notifications_enabled) {
4495 $lg->addCustomCommand(
4496 $this->
ctrl->getLinkTarget($this,
'toggleThreadNotification'),
4497 'forums_disable_notification' 4500 $lg->addCustomCommand(
4501 $this->
ctrl->getLinkTarget($this,
'toggleThreadNotification'),
4502 'forums_enable_notification' 4506 $this->
ctrl->setParameter($this,
'thr_pk',
'');
4508 if (!$this->
user->isAnonymous()) {
4509 if ($are_notifications_enabled || $are_thread_notifications_enabled) {
4513 $this->
lng->txt(
'frm_notification_activated')
4519 $this->
lng->txt(
'frm_notification_deactivated')
4533 if ($this->objCurrentTopic->getId() > 0) {
4534 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4538 $this->
ctrl->getFormAction($this,
'saveUserNotificationSettings'),
4549 if ($this->httpRequest->getMethod() ===
'POST') {
4550 $form = $events_form_builder->build()->withRequest($this->httpRequest);
4551 $formData = $form->getData();
4555 foreach ($events_form_builder->getValidEvents() as $event) {
4556 $interested_events += isset($formData[$event]) && $formData[$event] ? $events_form_builder->getValueForEvent(
4562 $frm_noti->setUserId($this->
user->getId());
4563 $frm_noti->setInterestedEvents($interested_events);
4564 $frm_noti->updateInterestedEvents();
4567 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
4569 if ($this->objCurrentTopic->getId() > 0) {
4570 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4571 $this->
ctrl->redirect($this,
'viewThread');
4574 $this->
ctrl->redirect($this,
'showThreads');
4583 if (!$this->objProperties->isUserToggleNoti() &&
4584 $this->objProperties->getNotificationType() === NotificationType::ALL_USERS) {
4588 if ($this->objProperties->getNotificationType() === NotificationType::PER_USER &&
4589 $this->
object->isParentMembershipEnabledContainer()) {
4591 $frm_noti->setUserId($this->
user->getId());
4593 return !$frm_noti->isUserToggleNotification();
4601 if (!$this->is_moderator) {
4602 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4605 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4606 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4609 $threadIdToMerge = $this->
http->wrapper()->query()->retrieve(
4612 $this->refinery->kindlyTo()->int(),
4616 if ($threadIdToMerge <= 0) {
4617 $threadIds = array_values(
4618 array_filter(
array_map(intval(...), (array) ($this->httpRequest->getParsedBody()[
'thread_ids'] ?? [])))
4620 if (count($threadIds) === 1) {
4621 $threadIdToMerge = current($threadIds);
4623 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'));
4629 $frm = $this->
object->Forum;
4630 $frm->setForumId($this->
object->getId());
4631 $frm->setForumRefId($this->
object->getRefId());
4636 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'not_allowed_to_merge_into_another_forum'));
4641 $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
4644 'tpl.forums_threads_liste.html',
4647 'components/ILIAS/Forum' 4650 $topicData = $frm->getOneTopic();
4651 if ($topicData->getTopPk() > 0) {
4652 $this->
ctrl->setParameter($this,
'merge_thread_id', $threadIdToMerge);
4656 (
int) $this->httpRequest->getQueryParams()[
'ref_id'],
4661 $tbl->setMapper($frm)->fetchData();
4663 $threadsTemplate->setVariable(
'THREADS_TABLE', $tbl->getHTML());
4664 $this->tpl->setContent($threadsTemplate->get());
4666 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
4673 if (!$this->is_moderator) {
4674 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4677 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4678 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4681 $sourceThreadId = (
int) ($this->httpRequest->getQueryParams()[
'merge_thread_id'] ?? 0);
4682 $targetThreadIds = array_values(
4683 array_filter(
array_map(intval(...), (array) ($this->httpRequest->getParsedBody()[
'thread_ids'] ?? [])))
4686 if ($sourceThreadId <= 0 || count($targetThreadIds) !== 1) {
4687 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
4692 $targetThreadId = current($targetThreadIds);
4693 if ($sourceThreadId === $targetThreadId) {
4694 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'error_same_thread_ids'));
4700 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'not_allowed_to_merge_into_another_forum'));
4701 $this->
ctrl->clearParameters($this);
4707 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'switch_threads_for_merge'));
4715 $c_gui->setFormAction($this->
ctrl->getFormAction($this,
'performMergeThreads'));
4716 $c_gui->setHeaderText($this->
lng->txt(
'frm_sure_merge_threads'));
4717 $c_gui->setCancel($this->
lng->txt(
'cancel'),
'showThreads');
4718 $c_gui->setConfirm($this->
lng->txt(
'confirm'),
'performMergeThreads');
4722 (
string) $sourceThreadId,
4727 (
string) $targetThreadId,
4730 $this->tpl->setContent($c_gui->getHTML());
4735 if (!$this->is_moderator) {
4736 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4739 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4740 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4743 $threadIds = array_values(
4744 array_filter(
array_map(intval(...), (array) ($this->httpRequest->getParsedBody()[
'thread_ids'] ?? [])))
4746 if (count($threadIds) !== 2) {
4747 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
4752 if ((
int) $threadIds[0] === (
int) $threadIds[1]) {
4753 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'error_same_thread_ids'));
4760 $frm->setForumId($this->
object->getId());
4761 $frm->setForumRefId($this->
object->getRefId());
4766 $frm->mergeThreads((
int) $threadIds[0], (
int) $threadIds[1]);
4767 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'merged_threads_successfully'));
4769 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt($e->getMessage()));
4778 if (!$this->
ctrl->isAsynch()) {
4779 $content = implode(
'', [
4784 $this->tpl->setRightContent($content);
4789 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4790 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4796 if (!$fileData->deliverZipFile()) {
4797 $this->
ctrl->redirect($this);
4803 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4804 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4810 if (!$fileData->deliverZipFile()) {
4811 $this->
ctrl->redirect($this);
4818 !$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4819 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4820 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4823 $frm = $this->
object->Forum;
4824 $frm->setForumId($this->
object->getId());
4825 $frm->setForumRefId($this->
object->getRefId());
4828 $draftId = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
4834 $do_history_check = (bool) ($this->httpRequest->getQueryParams()[
'hist_check'] ??
true);
4839 if ($form instanceof ilPropertyFormGUI) {
4840 $this->
ctrl->setParameter($this,
'draft_id', $draftId);
4843 $form->setValuesByArray([
4844 'alias' => $draft->getPostUserAlias(),
4845 'subject' => $draft->getPostSubject(),
4847 'notify' => $draft->isNotificationEnabled() && !$this->
user->isAnonymous(),
4850 'draft_id' => $draftId
4860 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4863 $historyId = (
int) ($this->httpRequest->getQueryParams()[
'history_id'] ?? 0);
4868 $draft = $history->rollbackAutosave();
4869 if ($draft->getThreadId() === 0 && $draft->getPostId() === 0) {
4870 $this->
ctrl->setParameter($this,
'draft_id', $history->getDraftId());
4871 $this->
ctrl->redirect($this,
'editThreadDraft');
4874 $this->
ctrl->clearParameters($this);
4875 $this->
ctrl->setParameter($this,
'pos_pk', $draft->getPostId());
4876 $this->
ctrl->setParameter($this,
'thr_pk', $draft->getThreadId());
4877 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
4878 $this->
ctrl->setParameter($this,
'action',
'editdraft');
4882 $this->
ctrl->redirect($this,
'viewThread');
4888 !$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4889 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4890 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4893 $autosave_draft_id = (
int) ($this->httpRequest->getParsedBody()[
'draft_id'] ?? 0);
4894 if ($autosave_draft_id <= 0) {
4895 $autosave_draft_id = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
4898 $frm = $this->
object->Forum;
4899 $frm->setForumId($this->
object->getId());
4900 $frm->setForumRefId($this->
object->getRefId());
4901 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
4902 $topicData = $frm->getOneTopic();
4905 if ($form->checkInput()) {
4906 if ($autosave_draft_id === 0) {
4908 $draft->setForumId($topicData->getTopPk());
4909 $draft->setThreadId(0);
4910 $draft->setPostId(0);
4916 $draft->setPostSubject($this->
handleFormInput($form->getInput(
'subject'),
false));
4919 $form->getInput(
'alias'),
4920 $this->objProperties->isAnonymized()
4922 $draft->setNotificationStatus($form->getInput(
'notify') && !$this->
user->isAnonymous());
4923 $draft->setPostAuthorId($this->
user->getId());
4926 if ($autosave_draft_id === 0) {
4927 $draftId = $draft->saveDraft();
4929 $draft->updateDraft();
4930 $draftId = $draft->getDraftId();
4933 $GLOBALS[
'ilAppEventHandler']->raise(
4934 'components/ILIAS/Forum',
4937 'draftObj' => $draft,
4938 'obj_id' => $this->
object->getId(),
4939 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
4947 $files2delete = $form->getInput(
'del_file');
4948 if (is_array($files2delete) && $files2delete !== []) {
4952 if ($this->objProperties->isFileUploadAllowed()) {
4953 $file = $_FILES[
'userfile'];
4954 if (is_array($file) && !empty($file)) {
4955 $draftFileData->storeUploadedFiles();
4959 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
4960 $this->
ctrl->clearParameters($this);
4961 $this->
ctrl->redirect($this,
'showThreads');
4964 $this->requestAction = substr($this->requestAction, 6);
4965 $form->setValuesByPost();
4966 $this->
ctrl->setParameter($this,
'draft_id', $autosave_draft_id);
4967 $this->tpl->setContent($form->getHTML());
4973 !$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4974 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4975 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4982 if ($form->checkInput()) {
4983 $draft->setPostSubject($this->
handleFormInput($form->getInput(
'subject'),
false));
4986 $form->getInput(
'alias'),
4987 $this->objProperties->isAnonymized()
4989 $draft->setNotificationStatus($form->getInput(
'notify') && !$this->
user->isAnonymous());
4990 $draft->setPostAuthorId($this->
user->getId());
4992 $draft->updateDraft();
4994 $GLOBALS[
'ilAppEventHandler']->raise(
4995 'components/ILIAS/Forum',
4998 'draftObj' => $draft,
4999 'obj_id' => $this->
object->getId(),
5000 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
5005 $form->getInput(
'message'),
5007 $draft->getDraftId(),
5009 $draft->getDraftId()
5014 $files2delete = $form->getInput(
'del_file');
5015 if (is_array($files2delete) && $files2delete !== []) {
5019 if ($this->objProperties->isFileUploadAllowed()) {
5020 $file = $_FILES[
'userfile'];
5021 if (is_array($file) && !empty($file) && isset($file[
'full_path'][0]) && !empty($file[
'full_path'][0])) {
5022 $draftFileData->storeUploadedFiles();
5026 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
5027 $this->
ctrl->clearParameters($this);
5028 $this->
ctrl->redirect($this,
'showThreads');
5031 $form->setValuesByPost();
5032 $this->
ctrl->setParameter($this,
'hist_check', 0);
5033 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5045 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
5046 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5049 $autosave_draft_id = $this->
http->wrapper()->post()->retrieve(
5052 $this->refinery->kindlyTo()->int(),
5057 if ($this->objCurrentTopic->getId() === 0) {
5058 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
5059 $this->
ctrl->redirect($this);
5062 if ($this->objCurrentTopic->isClosed()) {
5063 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
5064 $this->
ctrl->redirect($this);
5068 if ($oReplyEditForm->checkInput()) {
5069 if ($this->objCurrentPost->getId() === 0) {
5070 $this->requestAction =
'';
5071 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'),
true);
5077 $frm = $oForumObjects[
'frm'];
5078 $frm->setMDB2WhereCondition(
' top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
5079 $topicData = $frm->getOneTopic();
5081 if ($this->requestAction ===
'ready_showreply') {
5082 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5083 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5086 if ($autosave_draft_id > 0) {
5092 $draftObj->setForumId($topicData->getTopPk());
5093 $draftObj->setThreadId($this->objCurrentTopic->getId());
5094 $draftObj->setPostId($this->objCurrentPost->getId());
5097 $draftObj->setPostSubject($this->
handleFormInput($oReplyEditForm->getInput(
'subject'),
false));
5100 $oReplyEditForm->getInput(
'alias'),
5101 $this->objProperties->isAnonymized()
5103 $draftObj->setNotificationStatus($oReplyEditForm->getInput(
'notify') && !$this->
user->isAnonymous());
5104 $draftObj->setPostNotificationStatus($oReplyEditForm->getInput(
'notify_post') && !$this->
user->isAnonymous());
5106 $draftObj->setPostAuthorId($this->
user->getId());
5109 if ($autosave_draft_id === 0) {
5110 $draft_id = $draftObj->saveDraft();
5112 $draftObj->updateDraft();
5113 $draft_id = $draftObj->getDraftId();
5118 $oReplyEditForm->getInput(
'message'),
5125 if ($this->objProperties->isFileUploadAllowed()) {
5126 $file = $_FILES[
'userfile'];
5127 if (is_array($file) && !empty($file)) {
5133 $GLOBALS[
'ilAppEventHandler']->raise(
5134 'components/ILIAS/Forum',
5137 'draftObj' => $draftObj,
5138 'obj_id' => $this->
object->getId(),
5139 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5144 if (is_array($frm_session_values)) {
5145 $frm_session_values[$this->objCurrentPost->getThreadId()][
'openTreeNodes'][] = $this->objCurrentPost->getId();
5149 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
5150 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5151 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5152 $this->
ctrl->redirect($this,
'viewThread');
5155 $oReplyEditForm->setValuesByPost();
5156 $this->requestAction = substr($this->requestAction, 6);
5170 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
5171 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5174 if ($this->objCurrentTopic->getId() === 0) {
5175 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
5176 $this->
ctrl->redirect($this);
5179 if ($this->objCurrentTopic->isClosed()) {
5180 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
5181 $this->
ctrl->redirect($this);
5184 if ($this->objCurrentPost->getId() === 0) {
5185 $this->requestAction =
'';
5186 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'));
5192 if ($oReplyEditForm->checkInput()) {
5194 $forumObj = $oForumObjects[
'forumObj'];
5196 if (!$this->
user->isAnonymous() && in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
5197 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5198 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5202 $this->
user->getId(),
5203 $this->objCurrentPost->getId(),
5209 $draft->setPostSubject($this->
handleFormInput($oReplyEditForm->getInput(
'subject'),
false));
5211 $oReplyEditForm->getInput(
'message')
5214 $oReplyEditForm->getInput(
'alias'),
5215 $this->objProperties->isAnonymized()
5217 $draft->setNotificationStatus($oReplyEditForm->getInput(
'notify') && !$this->
user->isAnonymous());
5218 $draft->setUpdateUserId($this->
user->getId());
5219 $draft->setPostAuthorId($this->
user->getId());
5222 $draft->updateDraft();
5224 $GLOBALS[
'ilAppEventHandler']->raise(
5225 'components/ILIAS/Forum',
5228 'draftObj' => $draft,
5229 'obj_id' => $this->
object->getId(),
5230 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5236 foreach ($uploadedObjects as $mob) {
5241 $oReplyEditForm->getInput(
'message'),
5243 $draft->getDraftId()
5248 $file2delete = $oReplyEditForm->getInput(
'del_file');
5249 if (is_array($file2delete) && count($file2delete)) {
5253 if ($this->objProperties->isFileUploadAllowed()) {
5254 $file = $_FILES[
'userfile'];
5255 if (is_array($file) && !empty($file)) {
5256 $oFDForumDrafts->storeUploadedFiles();
5261 if (is_array($frm_session_values)) {
5262 $frm_session_values[$this->objCurrentPost->getThreadId()][
'openTreeNodes'][] = $this->objCurrentPost->getId();
5265 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
5266 $this->
ctrl->clearParameters($this);
5267 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5268 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5269 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5272 $this->
ctrl->clearParameters($this);
5273 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5274 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5276 $this->
ctrl->setParameter($this,
'action',
'editdraft');
5277 $oReplyEditForm->setValuesByPost();
5281 $this->
ctrl->clearParameters($this);
5282 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5283 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5284 $this->
ctrl->redirect($this,
'viewThread');
5291 foreach ($oldMediaObjects as $oldMob) {
5293 foreach ($curMediaObjects as $curMob) {
5294 if ($oldMob === $curMob) {
5315 $objFileDataForumDrafts->
delete([$draft->getDraftId()]);
5317 $GLOBALS[
'ilAppEventHandler']->raise(
5318 'components/ILIAS/Forum',
5321 'draftObj' => $draft,
5322 'obj_id' => $this->
object->getId(),
5323 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5326 $draft->deleteDraft();
5328 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'delete_draft_successfully'),
true);
5329 $this->
ctrl->clearParameters($this);
5330 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5331 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5332 $this->
ctrl->redirect($this,
'viewThread');
5337 if ($this->requestAction !==
'ready_showreply' &&
5339 $this->
access->checkAccess(
'read',
'', $this->object->getRefId()) &&
5340 $this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5344 $this->objProperties,
5345 $this->objCurrentTopic,
5346 $this->objCurrentPost,
5353 $this->
http->saveResponse($this->
http->response()->withBody(
5355 $action->executeAndGetResponseObject(),
5361 $this->
http->sendResponse();
5362 $this->
http->close();
5367 if ($this->requestAction !==
'ready_showreply' &&
5369 $this->
access->checkAccess(
'read',
'', $this->object->getRefId()) &&
5370 $this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId())) {
5374 $this->objProperties,
5375 $this->objCurrentTopic,
5376 $this->objCurrentPost,
5383 $this->
http->saveResponse($this->
http->response()->withBody(
5385 $action->executeAndGetResponseObject(),
5391 $this->
http->sendResponse();
5392 $this->
http->close();
5407 if (($this->objCurrentPost->getId() !== $node->
getId() || (
5408 !in_array($action, [
'showreply',
'showedit',
'censor',
'delete'],
true) &&
5411 if ($this->is_moderator && !$this->objCurrentTopic->isClosed() && !$node->
isActivated()) {
5412 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5414 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5415 $this->
ctrl->setParameter(
5420 $primary_action = $this->
ctrl->getLinkTarget(
5422 'askForPostActivation',
5423 (
string) $node->
getId()
5425 $primary_action_language_id =
'activate_post';
5426 $this->
ctrl->clearParameters($this);
5430 $this->
access->checkAccess(
'add_reply',
'', $this->
object->getRefId())
5432 $this->
ctrl->setParameter($this,
'action',
'showreply');
5433 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5434 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5435 $this->
ctrl->setParameter(
5441 $primary_action = $this->
ctrl->getLinkTarget(
5444 'reply_' . $node->
getId()
5446 $primary_action_language_id =
'reply_to_postings';
5447 $this->
ctrl->clearParameters($this);
5450 !$this->objCurrentTopic->isClosed() &&
5452 !$this->
user->isAnonymous() &&
5453 ($node->
isOwner($this->
user->getId()) || $this->is_moderator)
5455 $this->
ctrl->setParameter($this,
'action',
'showedit');
5456 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5458 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5459 $this->
ctrl->setParameter(
5464 $actions[
'edit'] = $this->
ctrl->getLinkTarget($this,
'viewThread', (
string) $node->
getId());
5465 $this->
ctrl->clearParameters($this);
5467 if (!$this->
user->isAnonymous()) {
5468 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5470 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5471 $this->
ctrl->setParameter(
5476 $this->
ctrl->setParameter($this,
'viewmode', $this->selectedSorting);
5478 $read_undread_txt =
'frm_mark_as_read';
5479 $read_undread_cmd =
'markPostRead';
5481 $read_undread_txt =
'frm_mark_as_unread';
5482 $read_undread_cmd =
'markPostUnread';
5484 $actions[$read_undread_txt] = $this->
ctrl->getLinkTarget(
5487 (
string) $node->
getId()
5490 $this->
ctrl->clearParameters($this);
5493 $this->
ctrl->setParameterByClass(ilForumExportGUI::class,
'top_pk', $node->
getForumId());
5494 $this->
ctrl->setParameterByClass(ilForumExportGUI::class,
'thr_pk', $node->
getThreadId());
5497 $this->
ctrl->clearParameters($this);
5500 !$this->objCurrentTopic->isClosed() &&
5501 !$this->
user->isAnonymous() &&
5504 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5506 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5507 $this->
ctrl->setParameter(
5512 $actions[
'delete'] = $this->
ctrl->getFormAction($this,
'deletePosting');
5513 $this->
ctrl->clearParameters($this);
5515 if ($this->is_moderator && !$this->objCurrentTopic->isClosed()) {
5516 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5518 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5519 $this->
ctrl->setParameter(
5525 $this->
ctrl->setParameter($this,
'action',
'viewThread');
5526 $actions[
'frm_revoke_censorship'] = $this->
ctrl->getFormAction($this,
'revokeCensorship');
5528 $actions[
'frm_censorship'] = $this->
ctrl->getFormAction($this,
'addCensorship');
5530 $this->
ctrl->clearParameters($this);
5533 } elseif ($draft_id !== $draft->getDraftId() || !in_array($action, [
'deletedraft',
'editdraft'])) {
5535 $this->
ctrl->setParameter($this,
'action',
'publishdraft');
5536 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5537 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5538 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5539 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5540 $this->
ctrl->setParameter(
5545 $primary_action = $this->
ctrl->getLinkTarget($this,
'publishSelectedDraft', (
string) $node->
getId());
5546 $primary_action_language_id =
'publish';
5547 $this->
ctrl->clearParameters($this);
5549 $this->
ctrl->setParameter($this,
'action',
'editdraft');
5550 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5551 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5552 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5553 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5554 $this->
ctrl->setParameter(
5559 $actions[
'edit'] = $this->
ctrl->getLinkTarget($this,
'editDraft',
'draft_edit_' . $draft->getDraftId());
5560 $this->
ctrl->clearParameters($this);
5562 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5563 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5564 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5565 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5566 $this->
ctrl->setParameter(
5571 $actions[
'delete'] = $this->
ctrl->getFormAction($this,
'deletePostingDraft');
5572 $this->
ctrl->clearParameters($this);
5574 if ($draft_id !== 0 && $action ===
'editdraft') {
5580 if ($actions !== [] && !$this->objCurrentTopic->isClosed()) {
5582 foreach ($actions as $lng_id =>
$url) {
5583 if ($lng_id ===
'frm_revoke_censorship' || $lng_id ===
'frm_censorship') {
5584 $modalTemplate =
new ilTemplate(
'tpl.forums_censor_modal.html',
true,
true,
'components/ILIAS/Forum');
5585 $form_id = str_replace(
'.',
'_', uniqid(
'form',
true));
5586 $modalTemplate->setVariable(
'FORM_ID', $form_id);
5589 $modalTemplate->setVariable(
'BODY', $this->
lng->txt(
'forums_info_censor2_post'));
5591 $modalTemplate->setVariable(
'BODY', $this->
lng->txt(
'forums_info_censor_post'));
5592 $modalTemplate->touchBlock(
'message');
5595 $modalTemplate->setVariable(
'FORM_ACTION',
$url);
5597 $content = $this->uiFactory->legacy()->content($modalTemplate->get());
5598 $submitBtn = $this->uiFactory->button()->primary(
5599 $this->
lng->txt(
'submit'),
5602 static function (
string $id) use ($form_id):
string {
5605 const button = document.getElementById('$id'); 5606 if (!button) return; 5608 const form = document.getElementById('$form_id'); 5611 button.addEventListener('click', (event) => { 5612 event.preventDefault(); 5619 $modal = $this->uiFactory->modal()->roundtrip(
5620 $this->
lng->txt($lng_id),
5622 )->withActionButtons([$submitBtn]);
5623 $items[] = $this->uiFactory->button()->shy($this->
lng->txt($lng_id),
'#')->withOnClick(
5624 $modal->getShowSignal()
5627 $this->modalActionsContainer[] = $modal;
5631 if ($lng_id ===
'delete') {
5632 $modal = $this->uiFactory->modal()->interruptive(
5633 $this->
lng->txt($lng_id),
5634 str_contains(
$url,
'deletePostingDraft') ?
5635 $this->
lng->txt(
'forums_info_delete_draft') :
5636 $this->
lng->txt(
'forums_info_delete_post'),
5638 )->withActionButtonLabel(
5639 $this->
lng->txt(str_contains(
$url,
'deletePostingDraft') ?
'deletePostingDraft' :
'deletePosting')
5642 $items[] = $this->uiFactory->button()->shy($this->
lng->txt($lng_id),
'#')->withOnClick(
5643 $modal->getShowSignal()
5646 $this->modalActionsContainer[] = $modal;
5652 $items[] = $this->uiFactory->button()->shy($this->
lng->txt($lng_id),
$url);
5655 $dropdown = $this->uiFactory->dropdown()->standard($items);
5656 $render_action_buttons = [$dropdown];
5657 if (isset($primary_action, $primary_action_language_id)) {
5658 if ($primary_action_language_id ===
'activate_post') {
5661 $action_button = $this->uiFactory->button()->standard(
5662 $this->
lng->txt($primary_action_language_id),
5666 $tpl->
setVariable(
'MAIN_ACTION', $this->uiRenderer->render($action_button));
5668 $tpl->
setVariable(
'DROPDOWN_ACTIONS', $this->uiRenderer->render($render_action_buttons));
5676 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5685 !$this->
user->isAnonymous() &&
5686 $this->
access->checkAccess(
'add_reply',
'', $this->
object->getRefId()) &&
5701 if ($draftsFromHistory !== []) {
5702 $form_tpl =
new ilTemplate(
'tpl.restore_thread_draft.html',
true,
true,
'components/ILIAS/Forum');
5705 foreach ($draftsFromHistory as $history_instance) {
5707 $accordion->setId(
'acc_' . $history_instance->getHistoryId());
5709 if ($first_open ===
null) {
5710 $first_open = $history_instance->getHistoryId();
5714 $form_tpl->setCurrentBlock(
'list_item');
5718 $history_instance->getDraftDate(),
5721 $this->
ctrl->setParameter($this,
'history_id', $history_instance->getHistoryId());
5722 $header = $history_date .
': ' . $history_instance->getPostSubject();
5725 'tpl.restore_thread_draft_accordion_content.html',
5728 'components/ILIAS/Forum' 5730 $accordion_tpl->setVariable(
'MESSAGE',
$message);
5731 $accordion_tpl->setVariable(
5733 $this->uiRenderer->render(
5734 $this->uiFactory->button()->standard(
5735 $this->
lng->txt(
'restore'),
5736 $this->
ctrl->getLinkTarget($this,
'restoreFromHistory')
5740 $accordion->addItem($header, $accordion_tpl->get());
5742 $form_tpl->setVariable(
'ACC_AUTO_SAVE', $accordion->getHTML());
5743 $form_tpl->parseCurrentBlock();
5746 $form_tpl->setVariable(
'RESTORE_DATA_EXISTS',
'found_threat_history_to_restore');
5748 $modal = $this->ui_factory->modal()->interruptive(
5749 $this->
lng->txt(
'restore_draft_from_autosave'),
5753 return "document.getElementById('$id').dataset.modalId = 'frm_autosave_restore';";
5756 $this->modal_history = $this->ui_renderer->render($modal);
5765 if ($action ===
'showedit' && (
5766 (!$this->is_moderator && !$node->
isOwner($this->user->getId())) ||
5767 $this->
user->isAnonymous() ||
5770 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5771 } elseif ($action ===
'showreply' && !$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5772 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5775 $tpl->
setVariable(
'REPLY_ANKER',
'reply_' . $this->objCurrentPost->getId());
5778 if ($action !==
'editdraft') {
5779 switch ($this->objProperties->getSubjectSetting()) {
5780 case 'add_re_to_subject':
5784 case 'preset_subject':
5785 $subject = $this->objCurrentPost->getSubject();
5788 case 'empty_subject':
5796 if ($this->
ctrl->getCmd() ===
'savePost' || $this->
ctrl->getCmd() ===
'saveAsDraft') {
5797 $oEditReplyForm->setValuesByPost();
5798 } elseif ($this->
ctrl->getCmd() ===
'quotePost') {
5806 $oEditReplyForm->setValuesByPost();
5807 $oEditReplyForm->getItemByPostVar(
'message')->setValue(
5812 $authorinfo->getAuthorName()
5813 ) .
"\n" . $oEditReplyForm->getInput(
'message'),
5818 $oEditReplyForm->setValuesByArray([
5819 'draft_id' => $draft_id,
5821 'subject' => $subject,
5831 if ($this->
ctrl->getCmd() ===
'savePost') {
5832 $oEditReplyForm->setValuesByPost();
5834 $oEditReplyForm->setValuesByArray([
5836 'subject' => $this->objCurrentPost->getSubject(),
5838 $this->objCurrentPost->getMessage(),
5841 'notify' => $this->objCurrentPost->isNotificationEnabled() && !$this->
user->isAnonymous(),
5844 'draft_id' => $draft_id
5850 if (in_array($this->
ctrl->getCmd(), [
'saveDraft',
'updateDraft',
'publishDraft'])) {
5851 $oEditReplyForm->setValuesByPost();
5852 } elseif ($draft_id > 0) {
5854 $this->
user->getId(),
5855 $this->objCurrentPost->getId(),
5858 $oEditReplyForm->setValuesByArray([
5859 'alias' => $draftObject->getPostUserAlias(),
5860 'subject' => $draftObject->getPostSubject(),
5862 $draftObject->getPostMessage(),
5865 'notify' => $draftObject->isNotificationEnabled() && !$this->
user->isAnonymous(),
5868 'draft_id' => $draft_id
5874 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5875 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5876 $this->
ctrl->setParameter($this,
'page', (
int) ($this->httpRequest->getQueryParams()[
'page'] ?? 0));
5877 $this->
ctrl->setParameter(
5882 $this->
ctrl->setParameter(
5887 if ($action !==
'editdraft') {
5888 $tpl->
setVariable(
'FORM', $oEditReplyForm->getHTML());
5890 $this->
ctrl->clearParameters($this);
5895 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5898 $this->uiFactory->button()->standard(
5899 $this->
lng->txt(
'reset_limited_view_button'),
5900 $this->
ctrl->getLinkTarget($this,
'resetLimitedView')
5904 return $this->uiRenderer->render(
5907 ->
info($this->
lng->txt(
'reset_limited_view_info'))
5908 ->withButtons($buttons)
5917 $this->refinery->kindlyTo()->string(),
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.
const PAGE_NAME_THREAD_OVERVIEW
array $modalActionsContainer
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
renderPostContent(ilTemplate $tpl, ilForumPost $node, string $action, int $pageIndex, int $postIndex)
setDisplayConfirmPostActivation(bool $status=false)
buildThreadForm(bool $isDraft=false)
delete(?array $posting_ids_to_delete=null)
static get(string $a_var)
initEditCustomForm(ilPropertyFormGUI $a_form)
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
button(string $caption, string $cmd)
performMergeThreadsObject()
ilObjectDataCache $ilObjDataCache
bool $display_confirm_post_activation
hasDraftAccess(int|ilForumPostDraft $draft)
static getInstancesByDraftId(int $draft_id)
static moveMediaObjects(string $post_message, string $source_type, int $source_id, string $target_type, int $target_id, int $direction=0)
ilForumProperties $objProperties
This class represents an option in a checkbox group.
static lookupForumIdByObjId(int $obj_id)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
Class ilForumExplorerGUI.
getResetLimitedViewInfo()
ILIAS DI RBACServices $rbac
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
deliverFile(string $file)
GUI class for the workflow of copying objects.
getEditTitleModal(ilForumTopic $topic)
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) ...
ILIAS GlobalScreen Services $globalScreen
renderSortationControl(int $currentSorting)
setMessage(string $a_message)
static _goto($a_target, $a_thread=0, $a_posting=0)
disableForumNotificationObject()
ilNavigationHistory $ilNavigationHistory
prepareOutput(bool $show_sub_objects=true)
autosaveDraftAsyncObject()
Interface Observer Contains several chained tasks and infos about them.
readonly bool $in_page_editor_style_context
getThreadProperties(ilForumTopic $forum_topic)
renderPostingForm(ilTemplate $tpl, ilForum $frm, ilForumPost $node, string $action)
doHistoryCheck(int $draftId)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
markTopThreadInOverview(ilForumTopic $current_thread, Item $list_item)
static _getAllReferences(int $id)
get all reference ids for object ID
Psr Http Message ServerRequestInterface $httpRequest
ILIAS Style Content GUIService $content_style_gui
ilForumTopic $objCurrentTopic
static lookupTitle(int $a_topic_id)
withAdditionalOnLoadCode(Closure $binder)
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.
getStickyActionForThread(ilForumTopic $forum_topic, int $ref_id)
publishThreadDraftObject()
renderSplitButton(ilTemplate $tpl, string $action, bool $is_post, ilForumPost $node, int $pageIndex=0, ?ilForumPostDraft $draft=null)
addDraftButtonIfDraftsExists(string $cmd)
ForumThreadTableSessionStorage $forum_thread_table_session_storage
setRepositoryMode(bool $a_repositorymode)
createEmptyThread()
Refactored thread creation to method, refactoring to a separate class should be done in next refactor...
handleCensorship(bool $wasRevoked=false)
static lookupAutosaveInterval()
Class ilForumSettingsGUI.
ensureValidPageForCurrentPosting(array $subtree_nodes, array $pagedPostings, int $pageSize, ilForumPost $firstForumPost)
isOwner(int $a_user_id=0)
initHeaderAction(?string $sub_type=null, ?int $sub_id=null)
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static lookupForumIdByRefId(int $ref_id)
addActivationFormModal(ilForumPost $node)
prepareFormOutput(string $a_text)
buildMinimalThreadForm(bool $isDraft=false)
static lookupCreationDate(int $thread_id)
confirmMergeThreadsObject()
isPostNotificationEnabled()
ilForumSettingsGUI $forum_settings_gui
static createDraftBackup(int $draft_id)
saveThreadAsDraftObject()
setSelectedThread(ilForumTopic $thread_obj)
getPostRootNode(bool $isModerator=false, bool $preventImplicitRead=false)
renderDraftContent(ilTemplate $tpl, string $action, ilForumPost $referencePosting, array $drafts)
Class ilForumTopicTableGUI.
Class ilForumDraftHistory.
setColumnSettings(ilColumnGUI $column_gui)
withOnLoadCode(Closure $binder)
static _lookupObjId(int $ref_id)
getActionsForThreadOverview(int $ref_id, ilForumTopic $forum_topic)
static getInstance(int $a_obj_id=0)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
info()
description: > Example for rendering a info message box.
getLinkActionForThread(int $ref_id, string $title, string $cmd, ?int $thread_id=null)
getCenterColumnHTML()
Get center column.
publishDraftObject(bool $use_replyform=true)
afterSave(ilObject $new_object)
ilForumPost $objCurrentPost
GUI class for public user profile presentation.
string $confirmation_gui_html
hideToolbar($a_flag=null)
static http()
Fetches the global http state from ILIAS.
setVariable($variable, $value='')
Sets a variable value.
updateCustom(ilPropertyFormGUI $form)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilGlobalTemplateInterface $tpl
static _lookupTitle(int $obj_id)
saveUserNotificationSettingsObject()
deletePostingDraftObject()
renderViewModeControl(int $currentViewMode)
static getPublicUserAlias(string $user_alias, bool $is_anonymized)
handleFormInput(string $a_text, bool $a_stripslashes=true)
performThreadsActionObject()
This is how the factory for UI elements looks.
static saveMediaObjects(string $post_message, string $target_type, int $target_id, int $direction=0)
Forum export to HTML and Print.
static isAutoSavePostDraftAllowed()
setChangeDate(?string $a_changedate)
Column user interface class.
saveTopLevelDraftObject()
enableForumNotificationObject()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getEditFormCustomValues(array &$a_values)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
prepareText(string $text, int $edit=0, string $quote_user='', string $type='')
static _lookupObjIdForForumId(int $a_for_id)
Class ilObjectGUI Basic methods of all Output classes.
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
Common interface to all items.
const PAGE_SIZE_THREAD_OVERVIEW
cancelMoveThreadsObject()
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)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
performMoveThreadsObject()
isWritingWithPseudonymAllowed()
ilForumThreadSettingsSessionStorage $selected_post_storage
__construct($data, int $id=0, bool $call_by_reference=true, bool $prepare_output=true)
static getThreadDraftData(int $post_author_id, int $forum_id)
askForPostActivationObject()
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 _lookupObjectId(int $ref_id)
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
restoreFromHistoryObject()
static getInstanceByType(string $type)
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...
getOpenCloseActionForThread(ilForumTopic $forum_topic, int $ref_id)
static getSyntaxStylePath()
editStylePropertiesObject()
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
deleteThreadDraftsObject()
performDeleteThreadsObject()
ILIAS Style Content Object ObjectFacade $content_style_domain
Last visited history for repository items.
checkDraftAccess(int|ilForumPostDraft $draft)
createTopLevelPostObject()
unlinkFilesByMD5Filenames($hashed_filename_or_filenames)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
toggleThreadNotificationObject()
isUserAllowedToDeactivateNotification()
static isSavePostDraftAllowed()
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
getSortationViewControl(int $offset)
deliverDraftZipFileObject()
updateThreadDraftObject()
displayConfirmPostActivation()
static _isModerator(int $a_ref_id, int $a_usr_id)
A news item can be created by different sources.
static getSortedDrafts(int $usrId, int $threadId, int $sorting=ilForumProperties::VIEW_DATE_ASC)
ilForumMoveTopicsExplorer
getRightColumnHTML()
Display right column.
getSafePostCommands()
This method must return a list of safe POST commands.
deleteMobsOfDraft(int $draft_id, string $message)
retrieveDraftId(bool $from_post=false)
__construct(Container $dic, ilPlugin $plugin)
autosaveThreadDraftAsyncObject()
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.
const LP_CONTEXT_REPOSITORY
This class represents a text area property in a property form.
const PRESENTATION_MODE_PRESENTATION
presentation mode for requesting
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
confirmDeleteThreadDraftsObject()
publishSelectedDraftObject()
createThread(ilForumPostDraft $draft, bool $createFromDraft=false)
Refactored thread creation to method, refactoring to a separate class should be done in next refactor...
toggleExplorerNodeState()
Should be called by an ilCtrl-enabled command class if a tree node toggle action should be processed...
ilPropertyFormGUI $replyEditForm
static lookupForumIdByTopicId(int $a_topic_id)
decorateWithAutosave(ilPropertyFormGUI $form)
renderThreadOverview(ilForum $frm, ForumDto $frm_object)
This describes a Standard Dropdown.
Class ilChatroomConfigFileHandler .
static newInstanceByDraftId(int $draft_id)
static getDraftInstancesByUserId(int $user_id)
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
editThreadDraftObject(?ilPropertyFormGUI $form=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getSearchBlockHTML(string $a_title)
eventsFormBuilder(?array $predefined_values=null)
addHeaderAction()
Add header action menu.
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjUserTrackingGUI.
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
static set(string $a_var, $a_val)
Set a value.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
performPostActivationObject()
toggleExplorerNodeStateObject()
ilForumPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI ilForumPageGUI: ilPublicUserProfi...