19 declare(strict_types=1);
61 private \ILIAS\HTTP\Services
$http;
72 public \ILIAS\DI\RBACServices
$rbac;
88 $this->httpRequest = $DIC->http()->request();
89 $this->
http = $DIC->http();
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');
131 if (!is_array($forumValues)) {
136 $threadId = $this->objCurrentTopic->getId();
137 if ($threadId > 0 && !isset($forumValues[$threadId])) {
138 $forumValues[(
int) $threadId] = [];
147 return $this->retrieveIntOrZeroFrom($this->
http->wrapper()->query(),
'thr_pk');
152 return $this->retrieveIntOrZeroFrom(
153 $from_post ? $this->
http->wrapper()->post() : $this->
http->wrapper()->query(),
161 'frm_exp_' . $this->objCurrentTopic->getId(),
171 array $subtree_nodes,
172 array $pagedPostings,
176 if ($firstForumPost->
getId() === $this->objCurrentPost->getId()) {
180 if ($subtree_nodes !== [] && $this->objCurrentPost->getId() > 0) {
181 $isCurrentPostingInPage = array_filter($pagedPostings, fn(
ilForumPost $posting):
bool => (
182 $posting->
getId() === $this->objCurrentPost->getId()
185 if ([] === $isCurrentPostingInPage) {
186 $pageOfCurrentPosting = 0;
188 foreach ($subtree_nodes as $node) {
189 if ($i > 0 && $i % $pageSize === 0) {
190 ++$pageOfCurrentPosting;
193 if ($node->getId() === $this->objCurrentPost->getId()) {
200 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
201 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
202 $this->
ctrl->setParameter($this,
'page', $pageOfCurrentPosting);
203 $this->
ctrl->setParameter(
208 $this->
ctrl->redirect($this,
'viewThread', (
string) $this->objCurrentPost->getId());
217 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
226 $this->tpl->addJavaScript(
'assets/js/autosave_forum.js');
227 $autosave_cmd =
'autosaveDraftAsync';
228 if ($this->objCurrentPost->getId() === 0 && $this->objCurrentPost->getThreadId() === 0) {
229 $autosave_cmd =
'autosaveThreadDraftAsync';
231 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
232 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
235 $this->tpl->addOnLoadCode(
236 "il.Language.setLangVar('saving', " . json_encode($this->
lng->txt(
'saving'), JSON_THROW_ON_ERROR) .
');' 239 $this->tpl->addOnLoadCode(
'il.ForumDraftsAutosave.init(' . json_encode([
242 'interval' => $interval * 1000,
243 'url' => $this->
ctrl->getFormAction($this, $autosave_cmd,
'',
true),
245 'form' =>
'#form_' . $form->
getId()
247 ], JSON_THROW_ON_ERROR) .
');');
254 strtolower($this->
ctrl->getCmd() ??
''),
255 array_map(
'strtolower', [
'createTopLevelPost',
'saveTopLevelPost',
'saveTopLevelDraft']),
263 'enableForumNotification',
264 'disableForumNotification',
265 'toggleThreadNotification',
266 'confirmDeleteThreadDrafts' 277 $next_class = $this->
ctrl->getNextClass($this) ??
'';
278 $cmd = $this->
ctrl->getCmd() ??
'';
284 'showThreadNotification',
285 'performPostActivation',
286 'askForPostActivation',
287 'askForPostDeactivation',
288 'toggleThreadNotification',
289 'toggleThreadNotificationTab',
294 'createTopLevelPost',
297 'autosaveDraftAsync',
298 'autosaveThreadDraftAsync',
302 'deliverDraftZipFile',
305 'deleteThreadDrafts',
307 'deletePostingDraft',
310 'confirmDeleteThreadsObject' 313 if (!in_array($cmd, $exclude_cmds,
true)) {
317 if (!$this->creation_mode) {
319 $pos_pk = $this->retrieveIntOrZeroFrom($this->
http->wrapper()->query(),
'pos_pk');
321 $this->selected_post_storage->get($this->objCurrentTopic->getId()) > 0) {
323 $this->selected_post_storage->get($this->objCurrentTopic->getId()) ?? 0,
326 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
328 $this->selected_post_storage->set($this->objCurrentTopic->getId(), 0);
342 $this->
object->getRefId(),
343 ilLink::_getLink($this->
object->getRefId(),
'frm'),
348 switch (strtolower($next_class)) {
349 case strtolower(ilForumPageGUI::class):
350 if (in_array(strtolower($cmd),
array_map(
'strtolower', [
351 self::UI_CMD_COPAGE_DOWNLOAD_FILE,
352 self::UI_CMD_COPAGE_DISPLAY_FULLSCREEN,
353 self::UI_CMD_COPAGE_DOWNLOAD_PARAGRAPH,
357 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
360 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
363 $this->content_style_gui->addCss($this->tpl, $this->ref_id);
364 $this->tpl->setCurrentBlock(
'SyntaxStyle');
366 $this->tpl->parseCurrentBlock();
378 $this->content_style_domain
381 $pageContent = $forwarder->forward();
382 if ($pageContent !==
'') {
383 $this->tpl->setContent($pageContent);
387 case strtolower(ilLearningProgressGUI::class):
389 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
392 $this->tabs_gui->activateTab(
'learning_progress');
394 $usrId = $this->
user->getId();
396 isset($this->request->getQueryParams()[
'user_id']) &&
397 is_numeric($this->request->getQueryParams()[
'user_id'])
399 $usrId = (
int) $this->request->getQueryParams()[
'user_id'];
404 $this->
object->getRefId(),
409 case strtolower(ilObjectContentStyleSettingsGUI::class):
412 if ($this->in_page_editor_style_context) {
413 $this->tabs_gui->setBackTarget(
414 $this->
lng->txt(
'back'),
422 $settings_gui = $this->content_style_gui
423 ->objectSettingsGUIForRefId(
427 $this->
ctrl->forwardCommand($settings_gui);
430 case strtolower(ilForumSettingsGUI::class):
432 $this->
ctrl->forwardCommand($forum_settings_gui);
435 case strtolower(ilRepositoryObjectSearchGUI::class):
438 $this->tabs_gui->activateTab(
'forums_threads');
439 $this->
ctrl->setReturn($this,
'view');
441 $this->
object->getRefId(),
445 $this->
ctrl->forwardCommand($search_gui);
448 case strtolower(ilPermissionGUI::class):
450 $this->
ctrl->forwardCommand($perm_gui);
453 case strtolower(ilForumExportGUI::class):
455 $this->
ctrl->forwardCommand($fex_gui);
456 $this->
http->close();
459 case strtolower(ilForumModeratorsGUI::class):
461 $this->
ctrl->forwardCommand($fm_gui);
464 case strtolower(ilInfoScreenGUI::class):
468 case strtolower(ilColumnGUI::class):
472 case strtolower(ilPublicUserProfileGUI::class):
473 $user = $this->retrieveIntOrZeroFrom($this->
http->wrapper()->query(),
'user');
475 $add = $this->getUserProfileAdditional($this->
object->getRefId(),
$user);
476 $profile_gui->setAdditional($add);
477 $ret = $this->
ctrl->forwardCommand($profile_gui);
478 $this->tpl->setContent($ret);
481 case strtolower(ilObjectCopyGUI::class):
484 $this->
ctrl->forwardCommand($cp);
487 case strtolower(ilExportGUI::class):
488 $this->tabs_gui->activateTab(
'export');
490 $this->
ctrl->forwardCommand($exp);
493 case strtolower(ilRatingGUI::class):
494 if (!$this->objProperties->isIsThreadRatingEnabled() || $this->
user->isAnonymous()) {
495 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
498 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
499 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
505 $rating_gui->setObject(
507 $this->
object->getType(),
508 $this->objCurrentTopic->getId(),
512 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
513 $this->
ctrl->forwardCommand($rating_gui);
517 $this->
object->getType(),
518 $this->objCurrentTopic->getId(),
521 $this->objCurrentTopic->setAverageRating($avg[
'avg']);
522 $this->objCurrentTopic->update();
524 $this->
ctrl->redirect($this,
'showThreads');
527 case strtolower(ilCommonActionDispatcherGUI::class):
529 $this->
ctrl->forwardCommand($gui);
532 case strtolower(ilContainerNewsSettingsGUI::class):
538 $this->
lng->loadLanguageModule(
'cont');
540 $news_set_gui->setNewsBlockForced(
true);
541 $news_set_gui->setPublicNotification(
true);
542 $this->
ctrl->forwardCommand($news_set_gui);
546 if (in_array($cmd, [
'close',
'reopen',
'make_topics_non_sticky',
'makesticky',
'editThread',
'move'])) {
547 $cmd =
'performThreadsAction';
550 $notificationCommands = [
551 'enableAdminForceNoti',
552 'disableAdminForceNoti',
553 'enableHideUserToggleNoti',
554 'disableHideUserToggleNoti' 557 if (!in_array($cmd, $notificationCommands,
true)) {
558 $cmd =
'performThreadsAction';
560 } elseif (($cmd === null || $cmd ===
'') && $this->
getTableCommands() === []) {
561 $cmd =
'showThreads';
570 if (!$this->in_page_editor_style_context &&
571 $cmd !==
'viewThreadObject' && $cmd !==
'showUserObject' && !in_array(
572 strtolower($next_class),
573 array_map(
'strtolower', [ilForumPageGUI::class]),
586 if ($this->
http->wrapper()->post()->has(
'selected_cmd')) {
587 $tableCommands[] = $this->
http->wrapper()->post()->retrieve(
589 $this->
refinery->kindlyTo()->string()
592 if ($this->
http->wrapper()->post()->has(
'selected_cmd2')) {
593 $tableCommands[] = $this->
http->wrapper()->post()->retrieve(
595 $this->
refinery->kindlyTo()->string()
599 return $tableCommands;
610 $this->forum_settings_gui->getCustomForm($a_form);
615 $this->forum_settings_gui->getCustomValues($a_values);
620 $this->forum_settings_gui->updateCustomValues($form);
625 if (!$this->is_moderator) {
626 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
629 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
630 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
633 if ($this->objCurrentTopic->getId() === 0) {
640 $title = $this->
getEditTitleModal($this->objCurrentTopic)->withRequest($this->
http->request())->getData();
641 if (array_key_exists(0, $title)) {
642 $new_subject = $title[0];
643 if ($new_subject !==
'') {
644 $this->objCurrentTopic->setSubject($new_subject);
645 $this->objCurrentTopic->updateThreadTitle();
646 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'));
655 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
656 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
659 $this->
object->markAllThreadsRead($this->
user->getId());
660 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_all_threads_marked_read'));
672 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
673 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
676 $cmd = $this->
ctrl->getCmd();
677 $frm = $this->
object->Forum;
678 $frm->setForumId($this->
object->getId());
679 $frm->setForumRefId($this->
object->getRefId());
680 $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', [
'integer'], [$frm->getForumId()]);
682 $frm_object = $frm->getOneTopic();
683 if ($frm_object->getTopPk() > 0) {
684 $frm->setDbTable(
'frm_data');
685 $frm->setMDB2WhereCondition(
'top_pk = %s ', [
'integer'], [$frm_object->getTopPk()]);
686 $frm->updateVisits($frm_object->getTopPk());
690 $this->
object->getRefId(),
691 $this->
object->getId(),
695 if ($cmd !==
'showThreads') {
696 $cmd =
'showThreads';
699 $this->tpl->setPermanentLink($this->
object->getType(), $this->
object->getRefId());
702 $btn = $this->uiFactory->button()
704 $this->
lng->txt(
'forums_new_thread'),
705 $this->
ctrl->getLinkTarget($this,
'createThread')
707 $this->
toolbar->addStickyItem($btn);
714 if ($this->confirmation_gui_html ===
'' && !$this->
user->isAnonymous()) {
716 $this->
lng->txt(
'forums_mark_read'),
717 $this->
ctrl->getLinkTarget($this,
'markAllRead')
719 $this->
ctrl->clearParameters($this);
722 if (!$this->
user->isAnonymous() && $this->
access->checkAccess(
'write',
'', $this->ref_id)) {
723 $this->
lng->loadLanguageModule(
'cntr');
725 $this->uiFactory->button()->standard(
726 $this->
lng->txt(
'cntr_text_media_editor'),
727 $this->
ctrl->getLinkTargetByClass(ilForumPageGUI::class,
'edit')
735 $this->
object->getRefId(),
743 $this->renderThreadOverview($tbl, $frm, $frm_object);
749 $data_objects = $tbl->
setMapper($frm)->fetchDataAnReturnObject();
751 $sticky_threads = [];
752 $regular_threads = [];
754 if (count($data_objects) > 0) {
755 foreach ($data_objects as $thread) {
756 if (array_key_exists(
'thread', $thread)) {
758 $current_thread = $thread[
'thread'];
759 $subject = $current_thread->getSubject();
760 if ($current_thread->isClosed()) {
761 $subject .=
' (' . $this->
lng->txt(
'forums_closed') .
')';
765 $this->
object->getRefId(),
768 $current_thread->getId()
772 $list_item = $this->factory
775 ->withActions($actions)
778 if ($current_thread->isSticky()) {
779 $sticky_threads[] = $list_item;
781 $regular_threads[] = $list_item;
787 $sticky_threads_item_group = null;
788 if (count($sticky_threads) > 0) {
789 $sticky_threads_item_group = $this->factory->item()->group(
790 count($regular_threads) > 0 ? $this->
lng->txt(
'top_thema') :
'',
795 $regular_threads_item_group = null;
796 if (count($regular_threads) > 0) {
797 $regular_threads_item_group = $this->factory->item()->group(
798 count($sticky_threads) > 0 ? $this->
lng->txt(
'thema') :
'',
803 $url = $this->
http->request()->getRequestTarget();
806 $current_page = $this->
http->wrapper()->query()->retrieve(
813 $view_controls[] = $this->factory
819 ->withMaxPaginationButtons(5)
820 ->withCurrentPage($current_page);
822 $item_groups = array_filter([$sticky_threads_item_group, $regular_threads_item_group]);
823 if ($item_groups === []) {
824 $vc_container = $this->factory->panel()->listing()->standard(
825 $this->
lng->txt(
'thread_overview'),
826 [$this->factory->item()->group($this->
lng->txt(
'frm_no_threads'), [])]
829 $vc_container = $this->factory->panel()->listing()->standard(
830 $this->
lng->txt(
'thread_overview'),
832 )->withViewControls($view_controls);
835 $default_html = $this->renderer->render($vc_container);
836 $modals = $this->renderer->render($this->modal_collection);
847 $this->content_style_domain
851 $this->tpl->setContent($forwarder->forward() . $default_html . $modals);
856 return $this->
http->wrapper()->query()->retrieve(
859 $this->refinery->kindlyTo()->int(),
867 return $this->
http->wrapper()->query()->retrieve(
870 $this->refinery->kindlyTo()->int(),
887 $sortation = ThreadSortation::tryFrom(
890 if ($sortation === null) {
891 $sortation = ThreadSortation::DEFAULT_SORTATION;
901 $this->
ctrl->setParameter($this,
'page', $offset);
904 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
905 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
906 $base_url = $this->
ctrl->getLinkTarget($this,
'showThreads');
908 $translationKeys = [];
909 foreach (ThreadSortation::cases() as $sortation) {
910 $this->
ctrl->setParameter($this,
'thread_sortation', $sortation->value);
911 $url = $this->
ctrl->getLinkTarget($this,
'showThreads');
913 $translationKeys[
$url] = $this->
lng->txt($sortation->languageId());
915 $this->
ctrl->clearParameters($this);
916 return $this->factory->viewControl()->sortation(
918 current(array_keys($translationKeys))
920 ->withTargetURL($base_url,
'thread_sortation');
929 $query = $this->
http->wrapper()->query()->has(
'thr_pk');
930 $post = $this->
http->wrapper()->post()->has(
'thread_ids');
932 $thread_ids = $this->
http->wrapper()->post()->retrieve(
937 $thread_ids = $this->
http->wrapper()->query()->retrieve(
951 $this->
ctrl->setParameter($this,
'thr_pk', $forum_topic->
getId());
953 $is_top_thread = $forum_topic->
isSticky();
955 if ($unread_counter === 0) {
958 $unread =
' (' . $unread_counter .
' ' . $this->
lng->txt(
'unread') .
')';
969 $this->
lng->txt(
'forums_created_by') => $authorinfo->getAuthorName(),
970 $this->
lng->txt(
'forums_articles') => $forum_topic->
getNumPosts() . $unread,
971 $this->
lng->txt(
'forums_last_post') => $this->
object->Forum->convertDate($forum_topic->
getLastPost()->getCreateDate()),
975 if ($is_top_thread ===
true) {
976 $is_top_thread = [$this->
lng->txt(
'relevance') => $this->
lng->txt(
'sticky')];
977 $properties = array_merge($properties, $is_top_thread);
980 $rating_property = [];
981 if ($this->objProperties->isIsThreadRatingEnabled()) {
985 $this->
object->getType(),
986 $forum_topic->
getId(),
989 $rating->setUserId($this->
user->getId());
990 $rating_property = [$this->
lng->txt(
'frm_rating') => $rating->getHTML()];
992 $this->
ctrl->setParameter($this,
'thr_pk', null);
994 return array_merge($properties, $rating_property);
1001 int $thread_id = null
1003 $this->
ctrl->setParameter($this,
'ref_id', $ref_id);
1004 $this->
ctrl->setParameter($this,
'thr_pk', $thread_id);
1005 $this->
ctrl->setParameter($this,
'page', 0);
1006 $url = $this->
ctrl->getLinkTarget($this, $cmd);
1007 $this->
ctrl->setParameter($this,
'ref_id', null);
1008 $this->
ctrl->setParameter($this,
'thr_pk', null);
1009 $this->
ctrl->setParameter($this,
'page', null);
1011 return $this->uiFactory->link()->standard($title,
$url);
1016 $actions = $this->uiFactory->dropdown()->standard([]);
1017 if ($this->is_moderator) {
1021 $this->modal_collection[] = $edit_title_modal;
1022 $edit_title = $this->factory->button()->shy($this->
lng->txt(
'frm_edit_title'),
'#')->withOnClick(
1023 $edit_title_modal->getShowSignal()
1028 $this->
lng->txt(
'move_thread_to_forum'),
1030 $forum_topic->
getId()
1034 $this->
lng->txt(
'merge_posts_into_thread'),
1036 $forum_topic->
getId()
1040 $this->
lng->txt(
'delete_thread'),
1041 'confirmDeleteThreads',
1042 $forum_topic->
getId()
1044 $actions = $this->uiFactory->dropdown()->standard([
1059 $topic_id = $this->
refinery->kindlyTo()->string()->transform($topic->
getId());
1060 $this->
ctrl->setParameter($this,
'thr_pk', (
string) $topic_id);
1061 $target = $this->
ctrl->getLinkTargetByClass(
1062 ilObjForumGUI::class,
1065 $this->
ctrl->setParameter($this,
'thread_id', null);
1067 return $this->factory->modal()->roundtrip(
1068 $this->
lng->txt(
'frm_edit_title'),
1071 $this->factory->input()->field()->text($this->
lng->txt(
'frm_edit_title'))->
withValue($topic->
getSubject()),
1080 $this->
user->getId(),
1083 if ($drafts === []) {
1096 $this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()),
1100 'tpl.forums_threads_liste.html',
1103 'components/ILIAS/Forum' 1105 $threadsTemplate->setVariable(
'THREADS_DRAFTS_TABLE', $this->uiRenderer->render($table->getComponent()));
1107 $draft_modal = $this->factory->modal()->roundtrip(
1108 $this->
lng->txt(
'drafts'),
1109 [$this->factory->legacy($threadsTemplate->get())]
1111 $this->modal_collection[] = $draft_modal;
1112 $edit_title = $this->factory->button()->standard($this->
lng->txt(
'drafts'),
'#')->withOnClick(
1113 $draft_modal->getShowSignal()
1115 $this->
toolbar->addComponent($edit_title);
1122 $this->
lng->txt($forum_topic->
isSticky() ?
'make_topics_non_sticky' :
'make_topics_sticky'),
1123 $forum_topic->
isSticky() ?
'make_topics_non_sticky' :
'makesticky',
1124 $forum_topic->
getId()
1132 $this->
lng->txt($forum_topic->
isClosed() ?
'reopen_topics' :
'close_topics'),
1133 $forum_topic->
isClosed() ?
'reopen' :
'close',
1134 $forum_topic->
getId()
1143 $df = new \ILIAS\Data\Factory();
1144 $list_item = $list_item->withColor($df->color(
'#B54F00'));
1152 $this->content_style_gui->addCss($this->tpl, $this->ref_id);
1153 $this->tpl->setCurrentBlock(
'SyntaxStyle');
1155 $this->tpl->parseCurrentBlock();
1160 $this->content_style_gui->redirectToObjectSettings();
1172 $frm = $this->
object->Forum;
1175 foreach ($drafts as $draft) {
1178 ksort($filesOfDraft);
1180 if ($action !==
'showdraft' && $filesOfDraft !== []) {
1181 foreach ($filesOfDraft as $file) {
1183 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1184 $this->
ctrl->setParameter($this,
'file', $file[
'md5']);
1185 $tpl->
setVariable(
'HREF_DOWNLOAD', $this->
ctrl->getLinkTarget($this,
'viewThread'));
1187 $this->
ctrl->setParameter($this,
'file',
'');
1188 $this->
ctrl->setParameter($this,
'draft_id',
'');
1189 $this->
ctrl->clearParameters($this);
1194 $tpl->
setVariable(
'TXT_ATTACHMENTS_DOWNLOAD', $this->
lng->txt(
'forums_attachments'));
1197 $this->uiRenderer->render(
1198 $this->uiFactory->symbol()->glyph()->attachment($this->
lng->txt(
'forums_download_attachment'))
1201 if (count($filesOfDraft) > 1) {
1202 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1203 $download_zip_button = $this->uiFactory->button()
1205 $this->
lng->txt(
'download'),
1206 $this->
ctrl->getLinkTarget($this,
'deliverDraftZipFile')
1208 $this->
ctrl->setParameter($this,
'draft_id',
'');
1209 $tpl->
setVariable(
'DOWNLOAD_ZIP', $this->uiRenderer->render($download_zip_button));
1214 $page = $this->
http->wrapper()->query()->retrieve(
1216 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->
refinery->always(0)])
1228 $rowCol =
'tblrowmarked';
1230 $depth = $referencePosting->
getDepth() - 1;
1236 $this->
ctrl->setParameter($this,
'pos_pk', $referencePosting->
getId());
1237 $this->
ctrl->setParameter($this,
'thr_pk', $referencePosting->
getThreadId());
1238 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1240 $backurl = urlencode($this->
ctrl->getLinkTarget($this,
'viewThread', (
string) $referencePosting->
getId()));
1242 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1243 $this->
ctrl->setParameter($this,
'thr_pk', $referencePosting->
getThreadId());
1244 $this->
ctrl->setParameter($this,
'user', $draft->getPostDisplayUserId());
1247 $draft->getPostAuthorId(),
1248 $draft->getPostDisplayUserId(),
1249 $draft->getPostUserAlias(),
1252 'href' => $this->
ctrl->getLinkTarget($this,
'showUser')
1256 $this->
ctrl->clearParameters($this);
1258 if ($authorinfo->hasSuffix()) {
1259 $tpl->
setVariable(
'AUTHOR', $authorinfo->getSuffix());
1260 $tpl->
setVariable(
'USR_NAME', $draft->getPostUserAlias());
1262 $tpl->
setVariable(
'AUTHOR', $authorinfo->getLinkedAuthorShortName());
1263 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized()) {
1264 $tpl->
setVariable(
'USR_NAME', $authorinfo->getAuthorName(
true));
1267 $tpl->
setVariable(
'DRAFT_ANCHOR',
'draft_' . $draft->getDraftId());
1269 $tpl->
setVariable(
'USR_IMAGE', $authorinfo->getProfilePicture());
1275 $this->
object->getRefId(),
1276 $draft->getPostAuthorId()
1278 if ($authorinfo->getAuthor()->getGender() ===
'f') {
1280 } elseif ($authorinfo->getAuthor()->getGender() ===
'm') {
1282 } elseif ($authorinfo->getAuthor()->getGender() ===
'n') {
1287 if ($draft->getUpdateUserId() > 0) {
1288 $draft->setPostUpdate($draft->getPostUpdate());
1290 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1291 $this->
ctrl->setParameter($this,
'thr_pk', $referencePosting->
getThreadId());
1293 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
1296 $draft->getPostAuthorId(),
1298 $draft->getPostDisplayUserId(),
1299 $draft->getPostUserAlias(),
1301 [
'href' => $this->
ctrl->getLinkTarget($this,
'showUser')]
1304 $this->
ctrl->clearParameters($this);
1308 $this->
lng->txt(
'edited_on') .
': ' . $frm->
convertDate($draft->getPostUpdate()) .
' - ' . strtolower($this->
lng->txt(
'by'))
1310 $tpl->
setVariable(
'UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
1311 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
1312 $tpl->
setVariable(
'UPDATE_USR_NAME', $authorinfo->getAuthorName(
true));
1316 $draft->setPostMessage($frm->
prepareText($draft->getPostMessage()));
1318 $tpl->
setVariable(
'SUBJECT', $draft->getPostSubject());
1321 $tpl->
setVariable(
'POST_DRAFT_TEXT', $this->
lng->txt(
'post_draft_info'));
1323 if (!$referencePosting->
isCensored() || ($this->objCurrentPost->getId() === $referencePosting->
getId() && $action ===
'censor')) {
1326 $spanClass =
'moderator';
1329 if ($draft->getPostMessage() === strip_tags($draft->getPostMessage())) {
1331 $draft->setPostMessage(nl2br($draft->getPostMessage()));
1334 if ($spanClass !==
'') {
1338 $draft->getPostMessage(),
1347 if ($action ===
'editdraft' && $draft->getDraftId() === $draft_id) {
1350 if (!$this->objCurrentTopic->isClosed() && in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
1354 $tpl->
setVariable(
'EDIT_DRAFT_ANCHOR',
'draft_edit_' . $draft->getDraftId());
1370 $frm = $this->
object->Forum;
1375 ksort($filesOfPost);
1376 if ($filesOfPost !== [] && ($action !==
'showedit' || $node->
getId() !== $this->objCurrentPost->getId())) {
1377 foreach ($filesOfPost as $file) {
1379 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1380 $this->
ctrl->setParameter($this,
'file', $file[
'md5']);
1381 $tpl->
setVariable(
'HREF_DOWNLOAD', $this->
ctrl->getLinkTarget($this,
'viewThread'));
1383 $this->
ctrl->clearParameters($this);
1387 $tpl->
setVariable(
'TXT_ATTACHMENTS_DOWNLOAD', $this->
lng->txt(
'forums_attachments'));
1390 $this->uiRenderer->render(
1391 $this->uiFactory->symbol()->glyph()->attachment($this->
lng->txt(
'forums_download_attachment'))
1394 if (count($filesOfPost) > 1) {
1395 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1396 $download_zip_button = $this->uiFactory->button()
1398 $this->
lng->txt(
'download'),
1399 $this->
ctrl->getLinkTarget($this,
'deliverZipFile')
1401 $tpl->
setVariable(
'DOWNLOAD_ZIP', $this->uiRenderer->render($download_zip_button));
1408 $tpl->
setVariable(
'TXT_PERMA_LINK', $this->
lng->txt(
'perma_link'));
1412 if (($this->is_moderator || $node->
isOwner($this->user->getId())) && !$node->
isActivated() && !$this->objCurrentTopic->isClosed()) {
1413 $rowCol =
'ilPostingNeedsActivation';
1414 } elseif ($this->objProperties->getMarkModeratorPosts()) {
1417 $rowCol =
'ilModeratorPosting';
1419 $rowCol =
'ilModeratorPosting';
1425 $this->objCurrentPost->getId() !== $node->
getId()
1429 $rowCol =
'tblrowmarked';
1433 if ($action !==
'censor') {
1434 $tpl->
setVariable(
'TXT_CENSORSHIP_ADVICE', $this->
lng->txt(
'post_censored_comment_by_moderator'));
1437 $rowCol =
'tblrowmarked';
1443 $tpl->
setVariable(
'POST_NOT_ACTIVATED_YET', $this->
lng->txt(
'frm_post_not_activated_yet'));
1446 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1448 $backurl = urlencode($this->
ctrl->getLinkTarget($this,
'viewThread', (
string) $node->
getId()));
1449 $this->
ctrl->clearParameters($this);
1451 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1460 'href' => $this->
ctrl->getLinkTarget($this,
'showUser')
1463 $this->
ctrl->clearParameters($this);
1465 if ($authorinfo->hasSuffix()) {
1466 if (!$authorinfo->isDeleted()) {
1467 $tpl->
setVariable(
'USR_NAME', $authorinfo->getAlias());
1469 $tpl->
setVariable(
'AUTHOR', $authorinfo->getSuffix());
1471 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized()) {
1472 $tpl->
setVariable(
'USR_NAME', $authorinfo->getAuthorName(
true));
1474 $tpl->
setVariable(
'AUTHOR', $authorinfo->getLinkedAuthorShortName());
1477 $tpl->
setVariable(
'USR_IMAGE', $authorinfo->getProfilePicture());
1483 if ($isModerator && $authorinfo->getAuthor()->getId()) {
1484 $authorRole = $this->
lng->txt(
'frm_moderator_n');
1485 if (is_string($authorinfo->getAuthor()->getGender()) && $authorinfo->getAuthor()->getGender() !==
'') {
1486 $authorRole = $this->
lng->txt(
'frm_moderator_' . $authorinfo->getAuthor()->getGender());
1494 $this->
ctrl->setParameter($this,
'backurl', $backurl);
1507 'href' => $this->
ctrl->getLinkTarget($this,
'showUser')
1510 $this->
ctrl->clearParameters($this);
1516 $tpl->
setVariable(
'UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
1517 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
1518 $tpl->
setVariable(
'UPDATE_USR_NAME', $authorinfo->getAuthorName(
true));
1523 && $node->
getId() !== $this->selected_post_storage->get($node->
getThreadId())) {
1524 $target = $this->uiFactory->symbol()->icon()->custom(
1526 $this->
lng->txt(
'target_select')
1529 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1534 $this->uiRenderer->render(
1535 $this->uiFactory->link()->bulky(
1537 $this->
lng->txt(
'select'),
1538 new \ILIAS\Data\URI(
1539 ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTarget($this,
'selectPost', (
string) $node->
getId())
1551 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
1553 $this->
ctrl->setParameter($this,
'page', $pageIndex);
1554 $this->
ctrl->setParameter(
1559 $this->
ctrl->setParameter($this,
'viewmode', $this->selectedSorting);
1560 $mark_post_target = $this->
ctrl->getLinkTarget($this,
'markPostRead', (
string) $node->
getId());
1564 '<a href="' . $mark_post_target .
'"><b>' . $node->
getSubject() .
'</b></a>' 1570 if (!$node->
isCensored() || ($this->objCurrentPost->getId() === $node->
getId() && $action ===
'censor')) {
1573 $spanClass =
'moderator';
1582 if ($spanClass !==
'') {
1585 '<span class="' . $spanClass .
'">' .
1604 $thr_pk = (
int) $this->httpRequest->getQueryParams()[
'thr_pk'];
1605 $pos_pk = (
int) $this->httpRequest->getQueryParams()[
'pos_pk'];
1607 $this->selected_post_storage->set(
1620 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_added'),
true);
1621 $this->
ctrl->setParameter($this,
'ref_id', $new_object->
getRefId());
1622 $this->
ctrl->redirect($this,
'createThread');
1627 if ($this->in_page_editor_style_context) {
1631 $this->
ilHelp->setScreenIdComponent(
'frm');
1633 $this->
ctrl->setParameter($this,
'ref_id', $this->ref_id);
1640 'enableForumNotification',
1641 'disableForumNotification',
1643 'performMoveThreads',
1644 'cancelMoveThreads',
1645 'performThreadsAction',
1649 'confirmDeleteThreads',
1652 'performMergeThreads' 1655 $force_active =
false;
1656 if (in_array($this->
ctrl->getCmd(), $active,
true)) {
1657 $force_active =
true;
1660 if ($this->
access->checkAccess(
1665 $this->tabs_gui->addTarget(
1666 self::UI_TAB_ID_THREADS,
1667 $this->
ctrl->getLinkTarget($this,
'showThreads'),
1668 $this->
ctrl->getCmd(),
1675 if ($this->
access->checkAccess(
'visible',
'', $this->ref_id) || $this->
access->checkAccess(
1680 $cmdClass = $this->
http->wrapper()->query()->retrieve(
1682 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->
refinery->always(
'')])
1685 $force_active = $this->
ctrl->getNextClass() ===
'ilinfoscreengui' || strtolower($cmdClass) ===
'ilnotegui';
1686 $this->tabs_gui->addTarget(
1687 self::UI_TAB_ID_INFO,
1688 $this->
ctrl->getLinkTargetByClass([self::class, ilInfoScreenGUI::class],
'showSummary'),
1689 [
'showSummary',
'infoScreen'],
1696 if ($this->
access->checkAccess(
'write',
'', $this->ref_id)) {
1697 $force_active = $this->
ctrl->getCmd() ===
'edit';
1698 $this->tabs_gui->addTarget(
1699 self::UI_TAB_ID_SETTINGS,
1700 $this->
ctrl->getLinkTarget($this,
'edit'),
1708 if ($this->
access->checkAccess(
'write',
'', $this->ref_id)) {
1709 $this->tabs_gui->addTarget(
1710 self::UI_TAB_ID_MODERATORS,
1711 $this->
ctrl->getLinkTargetByClass(ilForumModeratorsGUI::class,
'showModerators'),
1718 $this->tabs_gui->addTab(
1719 'learning_progress',
1720 $this->
lng->txt(
'learning_progress'),
1721 $this->
ctrl->getLinkTargetByClass(ilLearningProgressGUI::class)
1725 if ($this->
settings->get(
'enable_fora_statistics',
'0')) {
1726 $hasStatisticsAccess = $this->
access->checkAccess(
'write',
'', $this->ref_id);
1727 if (!$hasStatisticsAccess) {
1728 $hasStatisticsAccess = (
1729 $this->objProperties->isStatisticEnabled() &&
1730 $this->
access->checkAccess(
'read',
'', $this->ref_id)
1734 if ($hasStatisticsAccess) {
1735 $force_active = $this->
ctrl->getCmd() ===
'showStatistics';
1736 $this->tabs_gui->addTarget(
1737 self::UI_TAB_ID_STATS,
1738 $this->
ctrl->getLinkTarget($this,
'showStatistics'),
1747 if ($this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1748 $this->tabs_gui->addTarget(
1749 self::UI_TAB_ID_EXPORT,
1750 $this->
ctrl->getLinkTargetByClass(ilExportGUI::class,
''),
1756 if ($this->
access->checkAccess(
'edit_permission',
'', $this->ref_id)) {
1757 $this->tabs_gui->addTarget(
1758 self::UI_TAB_ID_PERMISSIONS,
1759 $this->
ctrl->getLinkTargetByClass([static::class, ilPermissionGUI::class],
'perm'),
1760 [
'perm',
'info',
'owner'],
1768 if (!$this->
settings->get(
'enable_fora_statistics',
'0')) {
1769 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1772 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1773 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1776 if (!$this->objProperties->isStatisticEnabled()) {
1777 if ($this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
1778 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'frm_statistics_disabled_for_participants'));
1780 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1784 $this->
object->Forum->setForumId($this->
object->getId());
1786 $tbl = new \ILIAS\Forum\Statistics\ForumStatisticsTable(
1788 $this->objProperties,
1790 $this->
access->checkRbacOrPositionPermissionAccess(
1791 'read_learning_progress',
1792 'read_learning_progress',
1793 $this->object->getRefId()
1800 $this->tpl->setContent($this->uiRenderer->render($tbl->getComponent()));
1803 public static function _goto($a_target, $a_thread = 0, $a_posting = 0): void
1806 $main_tpl = $DIC->ui()->mainTemplate();
1808 $ilAccess = $DIC->access();
1809 $lng = $DIC->language();
1812 $a_target = is_numeric($a_target) ? (
int) $a_target : 0;
1813 $a_thread = is_numeric($a_thread) ? (
int) $a_thread : 0;
1814 if ($ilAccess->checkAccess(
'read',
'', $a_target)) {
1815 if ($a_thread !== 0) {
1817 if ($objTopic->getFrmObjId() &&
1820 foreach ($ref_ids as
$ref_id) {
1821 if ($ilAccess->checkAccess(
'read',
'', $ref_id)) {
1827 if (isset($new_ref_id) && $new_ref_id !== $a_target) {
1828 $DIC->ctrl()->redirectToURL(
1829 ILIAS_HTTP_PATH .
'/goto.php?target=frm_' . $new_ref_id .
'_' . $a_thread .
'_' . $a_posting
1834 $DIC->ctrl()->setParameterByClass(self::class,
'ref_id', (
string) ((
int) $a_target));
1835 if (is_numeric($a_thread)) {
1836 $DIC->ctrl()->setParameterByClass(self::class,
'thr_pk', (
string) ((
int) $a_thread));
1838 if (is_numeric($a_posting)) {
1839 $DIC->ctrl()->setParameterByClass(self::class,
'pos_pk', (
string) ((
int) $a_posting));
1841 $DIC->ctrl()->redirectByClass(
1842 [ilRepositoryGUI::class, self::class],
1844 is_numeric($a_posting) ? (
string) ((
int) $a_posting) :
'' 1847 $DIC->ctrl()->setParameterByClass(self::class,
'ref_id', $a_target);
1848 $DIC->ctrl()->redirectByClass([ilRepositoryGUI::class, self::class,],
'');
1849 $DIC->http()->close();
1851 } elseif ($ilAccess->checkAccess(
'visible',
'', $a_target)) {
1852 $DIC->ctrl()->setParameterByClass(ilInfoScreenGUI::class,
'ref_id', $a_target);
1853 $DIC->ctrl()->redirectByClass(
1855 ilRepositoryGUI::class,
1857 ilInfoScreenGUI::class
1862 $main_tpl->setOnScreenMessage(
'info', sprintf(
1863 $lng->
txt(
'msg_no_perm_read_item'),
1866 $DIC->http()->close();
1875 if ($threadIds === []) {
1876 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
1877 $this->
ctrl->redirect($this,
'showThreads');
1880 if (!$this->is_moderator) {
1881 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1884 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1885 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1889 $this->objProperties->setObjId($forumObj->getId());
1893 $success_message =
'forums_thread_deleted';
1894 if (count($threadIds) > 1) {
1895 $success_message =
'forums_threads_deleted';
1899 array_walk($threadIds,
function (
int $threadId) use (&$threads):
void {
1903 $threads[] = $thread;
1908 foreach ($threads as $thread) {
1910 if (isset($first_node[
'pos_pk']) && (
int) $first_node[
'pos_pk']) {
1911 $frm->
deletePost((
int) $first_node[
'pos_pk']);
1912 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt($success_message),
true);
1915 $this->
ctrl->redirect($this,
'showThreads');
1918 public function confirmDeleteThreadsObject():
void 1921 if ($thread_ids === []) {
1922 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'));
1923 $this->
ctrl->redirect($this,
'showThreads');
1926 if (!$this->is_moderator) {
1927 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1930 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1931 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1936 array_walk($thread_ids,
function (
int $threadId) use (&$threads):
void {
1940 $threads[] = $thread;
1945 $c_gui->setFormAction($this->
ctrl->getFormAction($this,
'performDeleteThreads'));
1946 $c_gui->setHeaderText($this->
lng->txt(
'frm_sure_delete_threads'));
1947 $c_gui->setCancel($this->
lng->txt(
'cancel'),
'showThreads');
1948 $c_gui->setConfirm($this->
lng->txt(
'confirm'),
'performDeleteThreads');
1950 foreach ($threads as $thread) {
1951 $c_gui->addItem(
'thread_ids[]', (
string) $thread->getId(), $thread->getSubject());
1954 $this->confirmation_gui_html = $c_gui->getHTML();
1957 $this->tpl->setContent($c_gui->getHTML());
1962 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
1963 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
1966 $draft_ids = $this->
http->wrapper()->query()->retrieve(
1967 'forum_drafts_delete_draft_ids',
1969 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->int()),
1974 if ($draft_ids === []) {
1975 $draft_ids = $this->
http->wrapper()->query()->retrieve(
1976 'forum_drafts_delete_draft_ids',
1978 $this->refinery->kindlyTo()->listOf($this->
refinery->kindlyTo()->string()),
1983 if (!isset($draft_ids[0]) || $draft_ids[0] !==
'ALL_OBJECTS') {
1984 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'));
1990 static function (array $draft):
int {
1991 return $draft[
'draft_id'] ?? 0;
1994 $this->
user->getId(),
2001 $confirmation->setFormAction($this->
ctrl->getFormAction($this,
'deleteThreadDrafts'));
2002 $confirmation->setHeaderText($this->
lng->txt(
'sure_delete_drafts'));
2003 $confirmation->setCancel($this->
lng->txt(
'cancel'),
'showThreads');
2004 $confirmation->setConfirm($this->
lng->txt(
'confirm'),
'deleteThreadDrafts');
2006 foreach ($draft_ids as $draftId) {
2007 if (array_key_exists($draftId, $instances)) {
2008 $confirmation->addItem(
'draft_ids[]', (
string) $draftId, $instances[$draftId]->getPostSubject());
2012 $this->tpl->setContent($confirmation->getHTML());
2015 public function prepareThreadScreen(
ilObjForum $a_forum_obj):
void 2017 $this->
ilHelp->setScreenIdComponent(
'frm');
2019 $this->tpl->loadStandardTemplate();
2023 $this->tabs_gui->setBackTarget(
2024 $this->
lng->txt(
'frm_all_threads'),
2025 $this->
ctrl->getLinkTarget(
2032 $frm = $a_forum_obj->Forum;
2038 if (!$this->is_moderator) {
2039 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2042 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2043 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2048 $this->objCurrentPost->activatePost();
2049 $GLOBALS[
'ilAppEventHandler']->raise(
2050 'components/ILIAS/Forum',
2053 'object' => $this->
object,
2054 'ref_id' => $this->
object->getRefId(),
2058 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_post_was_activated'),
true);
2066 !$this->
user->isAnonymous() &&
2067 !$this->objCurrentTopic->isClosed() && (
2068 $this->is_moderator ||
2069 ($this->objCurrentPost->isOwner($this->
user->getId()) && !$this->objCurrentPost->hasReplies())
2075 $forumObj = $oForumObjects[
'forumObj'];
2080 $dead_thr = $frm->
deletePost($this->objCurrentPost->getId());
2083 if ($dead_thr === $this->objCurrentTopic->getId()) {
2086 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_post_deleted'),
true);
2087 if ($topicData->getTopNumThreads() > 0) {
2088 $this->
ctrl->redirect($this,
'showThreads');
2090 $this->
ctrl->redirect($this,
'createThread');
2093 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_post_deleted'),
true);
2094 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
2095 $this->
ctrl->redirect($this,
'viewThread');
2098 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2119 foreach ($this->modalActionsContainer as $modal) {
2120 $modalString .= $this->uiRenderer->render($modal);
2123 return $modalString;
2129 if ($this->is_moderator && !$this->objCurrentTopic->isClosed()) {
2130 if ($this->
http->wrapper()->post()->has(
'formData')) {
2131 $formData = $this->
http->wrapper()->post()->retrieve(
2138 if ($message ===
'' && $this->
http->wrapper()->post()->has(
'cens_message')) {
2139 $cens_message = $this->
http->wrapper()->post()->retrieve(
2141 $this->
refinery->kindlyTo()->string()
2148 $frm = $oForumObjects[
'frm'];
2151 $frm->
postCensorship($this->
object, $message, $this->objCurrentPost->getId());
2152 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_censorship_revoked'));
2154 $frm->
postCensorship($this->
object, $message, $this->objCurrentPost->getId(), 1);
2155 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'frm_censorship_applied'));
2162 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2167 if (!$this->is_moderator) {
2168 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2171 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2172 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2182 $this->display_confirm_post_activation = $status;
2192 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2193 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2198 if ($this->objCurrentTopic->isNotificationEnabled($this->user->getId())) {
2199 $this->objCurrentTopic->disableNotification($this->
user->getId());
2200 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_notification_disabled'),
true);
2202 $this->objCurrentTopic->enableNotification($this->
user->getId());
2203 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_notification_enabled'),
true);
2206 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
2207 $this->
ctrl->redirect($this,
'viewThread');
2212 if (!$this->is_moderator) {
2213 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2216 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2217 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2222 if ($this->objCurrentTopic->isSticky()) {
2223 $this->objCurrentTopic->unmakeSticky();
2225 $this->objCurrentTopic->makeSticky();
2233 $this->requestAction =
'';
2235 if ($draft_id > 0) {
2238 $draft->deleteDraftsByDraftIds([$draft_id]);
2247 $this->requestAction =
'';
2249 if ($draft_id > 0) {
2251 $history_entry->populateWithFirstAutosaveByDraftId($draft_id);
2254 $draft->setPostSubject($history_entry->getPostSubject());
2255 $draft->setPostMessage($history_entry->getPostMessage());
2258 $history_entry->getPostMessage(),
2260 $history_entry->getHistoryId(),
2262 $draft->getDraftId()
2265 $draft->updateDraft();
2267 $history_entry->deleteHistoryByDraftIds([$draft->getDraftId()]);
2271 $this->
ctrl->clearParameters($this);
2278 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
2280 $this->
ctrl->setParameter(
2285 $form->setFormAction($this->
ctrl->getFormAction($this,
'performPostActivation'));
2286 $this->
ctrl->clearParameters($this);
2287 $form->setId(
'frm_activate_post_' . $node->
getId());
2288 $form_id = $form->getId();
2289 $message = $this->uiFactory->messageBox()->confirmation($this->
lng->txt(
'activate_post_txt'));
2290 $submitBtn = $this->uiFactory->button()->primary(
2291 $this->
lng->txt(
'activate_only_current'),
2294 static function (
string $id) use ($form_id):
string {
2297 const button = document.getElementById('$id'); 2298 if (!button) return; 2300 const form = document.getElementById('form_$form_id'); 2303 button.addEventListener('click', (event) => { 2304 event.preventDefault(); 2311 $modal = $this->uiFactory->modal()->roundtrip(
2312 $this->
lng->txt(
'activate_only_current'),
2313 [$this->uiFactory->legacy($form->getHTML()), $message]
2314 )->withActionButtons([$submitBtn]);
2315 $action_button = $this->uiFactory->button()->standard($this->
lng->txt(
'activate_post'),
'#')->withOnClick(
2316 $modal->getShowSignal()
2318 $this->modalActionsContainer[] = $modal;
2319 $this->
ctrl->clearParameters($this);
2321 return $action_button;
2324 public function getCensorshipFormHTML():
string 2327 $frm = $this->
object->Forum;
2328 $form_tpl =
new ilTemplate(
'tpl.frm_censorship_post_form.html',
true,
true,
'components/ILIAS/Forum');
2330 $form_tpl->setVariable(
'ANCHOR', $this->objCurrentPost->getId());
2331 $form_tpl->setVariable(
'SPACER',
'<hr noshade="noshade" width="100%" size="1" align="center" />');
2332 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2333 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2334 $this->
ctrl->setParameter(
2339 $form_tpl->setVariable(
'FORM_ACTION', $this->
ctrl->getFormAction($this,
'viewThread'));
2340 $this->
ctrl->clearParameters($this);
2341 $form_tpl->setVariable(
'TXT_CENS_MESSAGE', $this->
lng->txt(
'forums_the_post'));
2342 $form_tpl->setVariable(
'TXT_CENS_COMMENT', $this->
lng->txt(
'forums_censor_comment') .
':');
2343 $form_tpl->setVariable(
'CENS_MESSAGE', $frm->
prepareText((
string) $this->objCurrentPost->getCensorshipComment(), 2));
2345 if ($this->objCurrentPost->isCensored()) {
2346 $form_tpl->setVariable(
'TXT_CENS', $this->
lng->txt(
'forums_info_censor2_post'));
2347 $form_tpl->setVariable(
'YES_BUTTON', $this->
lng->txt(
'confirm'));
2348 $form_tpl->setVariable(
'NO_BUTTON', $this->
lng->txt(
'cancel'));
2349 $form_tpl->setVariable(
'CMD_REVOKE_CENSORSHIP',
'revokeCensorship');
2350 $form_tpl->setVariable(
'CMD_CANCEL_REVOKE_CENSORSHIP',
'viewThread');
2352 $form_tpl->setVariable(
'TXT_CENS', $this->
lng->txt(
'forums_info_censor_post'));
2353 $form_tpl->setVariable(
'CANCEL_BUTTON', $this->
lng->txt(
'cancel'));
2354 $form_tpl->setVariable(
'CONFIRM_BUTTON', $this->
lng->txt(
'confirm'));
2355 $form_tpl->setVariable(
'CMD_ADD_CENSORSHIP',
'addCensorship');
2356 $form_tpl->setVariable(
'CMD_CANCEL_ADD_CENSORSHIP',
'viewThread');
2359 return $form_tpl->get();
2364 $isReply = in_array($this->requestAction, [
'showreply',
'ready_showreply']);
2365 $isDraft = in_array($this->requestAction, [
'publishDraft',
'editdraft']);
2371 $frm = $oForumObjects[
'frm'];
2372 $oFDForum = $oForumObjects[
'file_obj'];
2375 $this->replyEditForm->setId(
'id_showreply');
2376 $this->replyEditForm->setTableWidth(
'100%');
2377 $cancel_cmd =
'cancelPost';
2378 if (in_array($this->requestAction, [
'showreply',
'ready_showreply'])) {
2379 $this->
ctrl->setParameter($this,
'action',
'ready_showreply');
2380 } elseif (in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
2381 $this->
ctrl->setParameter($this,
'action', $this->requestAction);
2382 $this->
ctrl->setParameter($this,
'draft_id', $draft_id);
2384 $this->
ctrl->setParameter($this,
'action',
'ready_showedit');
2387 $this->
ctrl->setParameter($this,
'page', (
int) ($this->httpRequest->getQueryParams()[
'page'] ?? 0));
2388 $this->
ctrl->setParameter(
2393 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2394 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2396 $this->replyEditForm->setFormAction(
2397 $this->
ctrl->getFormAction($this,
'saveTopLevelPost',
'frm_page_bottom')
2399 } elseif (in_array($this->requestAction, [
'publishDraft',
'editdraft'])) {
2400 $this->replyEditForm->setFormAction(
2401 $this->
ctrl->getFormAction($this,
'publishDraft', (
string) $this->objCurrentPost->getId())
2404 $this->replyEditForm->setFormAction(
2405 $this->
ctrl->getFormAction($this,
'savePost', (
string) $this->objCurrentPost->getId())
2408 $this->
ctrl->clearParameters($this);
2411 $this->replyEditForm->setTitle($this->
lng->txt(
'forums_your_reply'));
2412 } elseif ($isDraft) {
2413 $this->replyEditForm->setTitle($this->
lng->txt(
'forums_edit_draft'));
2415 $this->replyEditForm->setTitle($this->
lng->txt(
'forums_edit_post'));
2420 in_array($this->requestAction, [
'showreply',
'ready_showreply',
'editdraft'])
2422 $oAnonymousNameGUI =
new ilTextInputGUI($this->
lng->txt(
'forums_your_name'),
'alias');
2423 $oAnonymousNameGUI->setMaxLength(64);
2424 $oAnonymousNameGUI->setInfo(sprintf($this->
lng->txt(
'forums_use_alias'), $this->
lng->txt(
'forums_anonymous')));
2426 $this->replyEditForm->addItem($oAnonymousNameGUI);
2429 $oSubjectGUI =
new ilTextInputGUI($this->
lng->txt(
'forums_subject'),
'subject');
2430 $oSubjectGUI->setMaxLength(255);
2431 $oSubjectGUI->setRequired(
true);
2433 if ($this->objProperties->getSubjectSetting() ===
'empty_subject') {
2434 $oSubjectGUI->setInfo($this->
lng->txt(
'enter_new_subject'));
2437 $this->replyEditForm->addItem($oSubjectGUI);
2440 $isReply ? $this->
lng->txt(
'forums_your_reply') : $this->
lng->txt(
'forums_edit_post'),
2444 $oPostGUI->setRows(15);
2445 $oPostGUI->setUseRte(
true);
2449 ($isReply && $this->objCurrentPost->getDepth() >= 2) ||
2450 (!$isDraft && !$isReply && $this->objCurrentPost->getDepth() > 2) ||
2451 ($isDraft && $this->objCurrentPost->getDepth() >= 2)
2455 $oPostGUI->removePlugin(
'advlink');
2456 $oPostGUI->setRTERootBlockElement(
'');
2457 $oPostGUI->usePurifier(
true);
2458 $oPostGUI->disableButtons([
2475 if (in_array($this->requestAction, [
'showreply',
'ready_showreply',
'showdraft',
'editdraft'])) {
2476 $oPostGUI->setRTESupport(
2477 $this->
user->getId(),
2480 'tpl.tinymce_frm_post.js',
2485 $oPostGUI->setRTESupport(
2486 $this->objCurrentPost->getId(),
2489 'tpl.tinymce_frm_post.js',
2497 $this->replyEditForm->addItem($oPostGUI);
2500 if (!$this->
user->isAnonymous() &&
2501 !$this->objProperties->isAnonymized() &&
2502 $this->
rbac->system()->checkAccess(
'internal_mail', $umail->getMailObjectReferenceId()) &&
2505 $oNotificationGUI->setInfo($this->
lng->txt(
'forum_notify_me'));
2506 $this->replyEditForm->addItem($oNotificationGUI);
2509 if ($this->objProperties->isFileUploadAllowed()) {
2512 $this->replyEditForm->addItem($oFileUploadGUI);
2515 $attachments_of_node = $oFDForum->getFilesOfPost();
2516 if (count($attachments_of_node) && in_array($this->requestAction, [
'showedit',
'ready_showedit'])) {
2518 foreach ($oFDForum->getFilesOfPost() as $file) {
2521 $this->replyEditForm->addItem($oExistingAttachmentsGUI);
2525 if (in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
2527 $draftInfoGUI->setValue(sprintf(
2528 $this->
lng->txt(
'autosave_draft_info'),
2531 $this->replyEditForm->addItem($draftInfoGUI);
2532 } elseif (!in_array($this->requestAction, [
'showedit',
'ready_showedit'])) {
2534 $draftInfoGUI->setValue(sprintf(
2535 $this->
lng->txt(
'autosave_post_draft_info'),
2538 $this->replyEditForm->addItem($draftInfoGUI);
2542 $selected_draft_id = $draft_id;
2544 $this->
user->getId(),
2545 $this->objCurrentPost->getId(),
2548 if ($draftObj->getDraftId() > 0) {
2552 if ($files_of_draft !== []) {
2554 $this->
lng->txt(
'forums_delete_file'),
2557 foreach ($files_of_draft as $file) {
2560 $this->replyEditForm->addItem($oExistingAttachmentsGUI);
2565 $this->replyEditForm->addCommandButton(
'saveTopLevelPost', $this->
lng->txt(
'create'));
2567 $this->replyEditForm->addCommandButton(
'publishDraft', $this->
lng->txt(
'publish'));
2569 $this->replyEditForm->addCommandButton(
'savePost', $this->
lng->txt(
'save'));
2574 $hidden_draft_id->setValue((
string) $auto_save_draft_id);
2575 $this->replyEditForm->addItem($hidden_draft_id);
2577 if (in_array($this->requestAction, [
'showreply',
'ready_showreply',
'editdraft'])) {
2578 $show_rte = $this->
http->wrapper()->post()->retrieve(
2580 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->
refinery->always(0)])
2587 if ($quotingAllowed) {
2588 $this->replyEditForm->addCommandButton(
'quotePost', $this->
lng->txt(
'forum_add_quote'));
2591 if (!$this->
user->isAnonymous() &&
2592 in_array($this->requestAction, [
'editdraft',
'showreply',
'ready_showreply']) &&
2598 if ($this->requestAction ===
'editdraft') {
2599 $this->replyEditForm->addCommandButton(
'updateDraft', $this->
lng->txt(
'save_message'));
2601 $this->replyEditForm->addCommandButton(
'saveTopLevelDraft', $this->
lng->txt(
'save_message'));
2603 $this->replyEditForm->addCommandButton(
'saveAsDraft', $this->
lng->txt(
'save_message'));
2606 $cancel_cmd =
'cancelDraft';
2609 $this->replyEditForm->addCommandButton($cancel_cmd, $this->
lng->txt(
'cancel'));
2614 if ($this->replyEditForm === null) {
2626 if ($draft_id > 0 && !$this->
user->isAnonymous()
2629 $this->
user->getId(),
2630 $this->objCurrentPost->getId(),
2635 if ($draft_obj instanceof
ilForumPostDraft && $draft_obj->getDraftId() > 0) {
2636 $this->
ctrl->setParameter($this,
'action',
'editdraft');
2637 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2638 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
2639 $this->
ctrl->setParameter($this,
'draft_id', $draft_obj->getDraftId());
2640 $this->
ctrl->setParameter($this,
'page', 0);
2641 $this->
ctrl->setParameter(
2646 $this->
ctrl->redirect($this,
'editDraft');
2660 if ($draft_id > 0) {
2668 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2669 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2672 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
2673 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2676 if ($this->objCurrentTopic->getId() === 0) {
2677 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
2678 $this->
ctrl->redirect($this);
2681 if ($this->objCurrentTopic->isClosed()) {
2682 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
2683 $this->
ctrl->redirect($this);
2686 if ($this->objCurrentPost->getId() === 0) {
2687 $this->requestAction =
'';
2688 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'));
2696 if ($use_replyform) {
2698 if (!$oReplyEditForm->checkInput()) {
2699 $oReplyEditForm->setValuesByPost();
2703 $post_subject = $oReplyEditForm->getInput(
'subject');
2704 $post_message = $oReplyEditForm->getInput(
'message');
2707 $post_subject = $draft->getPostSubject();
2708 $post_message = $draft->getPostMessage();
2713 $frm = $oForumObjects[
'frm'];
2718 $send_activation_mail =
false;
2720 if ($this->objProperties->isPostActivationEnabled()) {
2721 if (!$this->is_moderator) {
2723 $send_activation_mail =
true;
2724 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2729 $newPost = $frm->generatePost(
2730 $draft->getForumId(),
2731 $draft->getThreadId(),
2732 $this->
user->getId(),
2733 $draft->getPostDisplayUserId(),
2735 $draft->getPostId(),
2736 $draft->isNotificationEnabled(),
2738 $draft->getPostUserAlias(),
2741 $send_activation_mail
2744 $this->
object->markPostRead(
2745 $this->
user->getId(),
2746 $this->objCurrentTopic->getId(),
2747 $this->objCurrentPost->getId()
2752 foreach ($uploadedObjects as $mob) {
2759 if ($draft->getRCID() > 0) {
2760 $post_obj->setRCID($draft->getRCID());
2761 $post_obj->update();
2764 if ($this->objProperties->isFileUploadAllowed()) {
2765 $file = $_FILES[
'userfile'] ?? [];
2766 if (is_array($file) && !empty($file)) {
2772 $GLOBALS[
'ilAppEventHandler']->raise(
2773 'components/ILIAS/Forum',
2776 'draftObj' => $draft,
2777 'obj_id' => $this->
object->getId(),
2778 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
2781 $draft->deleteDraft();
2783 $GLOBALS[
'ilAppEventHandler']->raise(
2784 'components/ILIAS/Forum',
2787 'object' => $this->
object,
2788 'ref_id' => $this->
object->getRefId(),
2789 'post' => $post_obj,
2790 'notify_moderators' => $send_activation_mail
2795 if (!$this->is_moderator && !$status) {
2796 $message .= $this->
lng->txt(
'forums_post_needs_to_be_activated');
2798 $message .= $this->
lng->txt(
'forums_post_new_entry');
2802 if (is_array($frm_session_values)) {
2803 $frm_session_values[$this->objCurrentTopic->getId()][
'openTreeNodes'][] = $this->objCurrentPost->getId();
2807 $this->
ctrl->clearParameters($this);
2808 $this->tpl->setOnScreenMessage(
'success', $message,
true);
2809 $this->
ctrl->setParameter($this,
'pos_pk', $newPost);
2810 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2812 $this->
ctrl->redirect($this,
'viewThread');
2817 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
2818 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2821 if ($this->objCurrentTopic->getId() === 0) {
2822 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
2823 $this->
ctrl->redirect($this);
2826 if ($this->objCurrentTopic->isClosed()) {
2827 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
2828 $this->
ctrl->redirect($this);
2834 if ($oReplyEditForm->checkInput()) {
2835 if ($this->objCurrentPost->getId() === 0) {
2836 $this->requestAction =
'';
2837 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'),
true);
2843 $forumObj = $oForumObjects[
'forumObj'];
2844 $frm = $oForumObjects[
'frm'];
2848 $autosave_draft_id = $this->
http->wrapper()->post()->retrieve(
2850 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->
refinery->always(0)])
2853 if ($this->requestAction ===
'ready_showreply') {
2854 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
2855 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2859 $send_activation_mail =
false;
2861 if ($this->objProperties->isPostActivationEnabled()) {
2862 if (!$this->is_moderator) {
2864 $send_activation_mail =
true;
2865 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2871 if ((
string) $oReplyEditForm->getInput(
'alias') ===
'') {
2872 $user_alias = $this->
lng->txt(
'forums_anonymous');
2874 $user_alias = $oReplyEditForm->getInput(
'alias');
2876 $display_user_id = 0;
2878 $user_alias = $this->
user->getLogin();
2879 $display_user_id = $this->
user->getId();
2882 $newPost = $frm->generatePost(
2883 $topicData->getTopPk(),
2884 $this->objCurrentTopic->getId(),
2885 $this->
user->getId(),
2888 $this->objCurrentPost->getId(),
2889 $oReplyEditForm->getInput(
'notify') && !$this->
user->isAnonymous(),
2894 $send_activation_mail
2897 if ($autosave_draft_id > 0) {
2899 $this->
user->getId(),
2900 $this->objCurrentPost->getId(),
2904 $draft->deleteDraft();
2909 $this->
object->markPostRead(
2910 $this->
user->getId(),
2911 $this->objCurrentTopic->getId(),
2912 $this->objCurrentPost->getId()
2917 $oReplyEditForm->getInput(
'message'),
2919 $this->
user->getId(),
2924 if ($this->objProperties->isFileUploadAllowed()) {
2926 $file = $_FILES[
'userfile'];
2927 if (is_array($file) && !empty($file)) {
2932 $GLOBALS[
'ilAppEventHandler']->raise(
2933 'components/ILIAS/Forum',
2936 'object' => $this->
object,
2937 'ref_id' => $this->
object->getRefId(),
2939 'notify_moderators' => $send_activation_mail
2944 if (!$this->is_moderator && !$status) {
2945 $message .= $this->
lng->txt(
'forums_post_needs_to_be_activated');
2947 $message .= $this->
lng->txt(
'forums_post_new_entry');
2950 $this->tpl->setOnScreenMessage(
'success', $message,
true);
2951 $this->
ctrl->clearParameters($this);
2952 $this->
ctrl->setParameter($this,
'post_created_below', $this->objCurrentPost->getId());
2953 $this->
ctrl->setParameter($this,
'pos_pk', $newPost);
2954 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2956 if ((!$this->is_moderator &&
2957 !$this->objCurrentPost->isOwner($this->user->getId())) || $this->objCurrentPost->isCensored() ||
2958 $this->
user->isAnonymous()) {
2959 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
2966 foreach ($oldMediaObjects as $oldMob) {
2968 foreach ($curMediaObjects as $curMob) {
2969 if ($oldMob === $curMob) {
2982 $old_status_was_active = $this->objCurrentPost->isActivated();
2986 $send_activation_mail =
false;
2988 if ($this->objProperties->isPostActivationEnabled()) {
2989 if (!$this->is_moderator) {
2991 $send_activation_mail =
true;
2992 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2996 $this->objCurrentPost->setStatus($status);
2998 $this->objCurrentPost->setSubject($this->
handleFormInput($oReplyEditForm->getInput(
'subject'),
false));
3000 $oReplyEditForm->getInput(
'message')
3002 $this->objCurrentPost->setNotification($oReplyEditForm->getInput(
'notify') && !$this->
user->isAnonymous());
3003 $this->objCurrentPost->setChangeDate(date(
'Y-m-d H:i:s'));
3004 $this->objCurrentPost->setUpdateUserId($this->
user->getId());
3006 if ($this->objCurrentPost->update()) {
3007 $this->objCurrentPost->reload();
3014 $this->objCurrentPost->getId(),
3019 $news_item->setTitle($this->objCurrentPost->getSubject());
3020 $news_item->setContent(
3022 $this->objCurrentPost->getMessage()
3026 if ($this->objCurrentPost->getMessage() !== strip_tags($this->objCurrentPost->getMessage())) {
3027 $news_item->setContentHtml(
true);
3029 $news_item->setContentHtml(
false);
3031 $news_item->update();
3034 $oFDForum = $oForumObjects[
'file_obj'];
3036 $file2delete = $oReplyEditForm->getInput(
'del_file');
3037 if (is_array($file2delete) && count($file2delete)) {
3038 $oFDForum->unlinkFilesByMD5Filenames($file2delete);
3041 if ($this->objProperties->isFileUploadAllowed()) {
3042 $file = $_FILES[
'userfile'];
3043 if (is_array($file) && !empty($file)) {
3044 $oFDForum->storeUploadedFiles();
3048 $GLOBALS[
'ilAppEventHandler']->raise(
3049 'components/ILIAS/Forum',
3052 'ref_id' => $this->
object->getRefId(),
3054 'notify_moderators' => $send_activation_mail,
3055 'old_status_was_active' => $old_status_was_active
3059 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'forums_post_modified'),
true);
3062 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
3063 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
3064 $this->
ctrl->setParameter($this,
'viewmode', $this->selectedSorting);
3066 $this->
ctrl->redirect($this,
'viewThread');
3068 $this->requestAction = substr($this->requestAction, 6);
3075 if ($a_flag === null) {
3085 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3086 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3089 if ($this->objCurrentTopic->isClosed()) {
3090 $this->requestAction =
'';
3097 $oReplyEditForm->getItemByPostVar(
'subject')->setRequired(
false);
3098 $oReplyEditForm->getItemByPostVar(
'message')->setRequired(
false);
3100 $oReplyEditForm->checkInput();
3102 $oReplyEditForm->getItemByPostVar(
'subject')->setRequired(
true);
3103 $oReplyEditForm->getItemByPostVar(
'message')->setRequired(
true);
3105 $this->requestAction =
'showreply';
3115 if ($this->forumObjects === null) {
3117 $file_obj =
new ilFileDataForum($forumObj->getId(), $this->objCurrentPost->getId());
3118 $frm = $forumObj->Forum;
3119 $frm->setForumId($forumObj->getId());
3120 $frm->setForumRefId($forumObj->getRefId());
3122 $this->forumObjects[
'forumObj'] = $forumObj;
3123 $this->forumObjects[
'frm'] = $frm;
3124 $this->forumObjects[
'file_obj'] = $file_obj;
3132 $this->selectedSorting = $this->objProperties->getDefaultView();
3135 $view_mode =
'viewmode_' . $this->
getObject()->getId();
3145 isset($this->httpRequest->getQueryParams()[
'viewmode']) &&
3148 $this->selectedSorting = (
int) $this->httpRequest->getQueryParams()[
'viewmode'];
3151 if (!in_array($this->selectedSorting, [
3156 $this->selectedSorting = $this->objProperties->getDefaultView();
3165 $this->selected_post_storage->set($this->objCurrentTopic->getId(), 0);
3166 $this->
ctrl->redirect($this,
'viewThread');
3171 $thr_pk = $this->objCurrentTopic->getId();
3174 $toolbar_items = [];
3177 $thread_control_session_values =
ilSession::get(
'thread_control');
3178 if (is_array($thread_control_session_values)) {
3179 if (!isset($thread_control_session_values[
'old'])) {
3180 $thread_control_session_values[
'old'] = $thr_pk;
3181 $thread_control_session_values[
'new'] = $thr_pk;
3182 ilSession::set(
'thread_control', $thread_control_session_values);
3183 } elseif (isset($thread_control_session_values[
'old']) && $thr_pk !== $thread_control_session_values[
'old']) {
3184 $thread_control_session_values[
'new'] = $thr_pk;
3185 ilSession::set(
'thread_control', $thread_control_session_values);
3189 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3190 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3194 $forumObj = $oForumObjects[
'forumObj'];
3195 $frm = $oForumObjects[
'frm'];
3196 $file_obj = $oForumObjects[
'file_obj'];
3198 $selected_draft_id = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
3199 if (isset($this->httpRequest->getQueryParams()[
'file'])) {
3200 $file_obj_for_delivery = $file_obj;
3207 if ($this->objCurrentTopic->getId() === 0) {
3208 $this->
ctrl->redirect($this,
'showThreads');
3212 if (isset($this->httpRequest->getQueryParams()[
'page'])) {
3213 $pageIndex = max((
int) $this->httpRequest->getQueryParams()[
'page'], $pageIndex);
3216 if ($this->selected_post_storage->get($this->objCurrentTopic->getId()) > 0) {
3218 $this->selected_post_storage->get($this->objCurrentTopic->getId()),
3219 $this->is_moderator,
3223 $firstNodeInThread = $this->objCurrentTopic->getPostRootNode();
3234 'tpl.forums_threads_view.html',
3237 'components/ILIAS/Forum' 3242 $order_field =
'frm_posts_tree.rgt';
3243 $this->objCurrentTopic->setOrderDirection(
'DESC');
3244 $threadContentTemplate->setVariable(
'LIST_TYPE', $this->viewModeOptions[$this->selectedSorting]);
3246 $order_field =
'frm_posts.pos_date';
3247 $this->objCurrentTopic->setOrderDirection(
3250 $threadContentTemplate->setVariable(
'LIST_TYPE', $this->sortationOptions[$this->selectedSorting]);
3252 $this->objCurrentTopic->setOrderField($order_field);
3255 $subtree_nodes = $this->objCurrentTopic->getPostTree($firstNodeInThread);
3256 $numberOfPostings = count($subtree_nodes);
3267 $append =
'_' . $this->objCurrentTopic->getId() .
3268 ($this->objCurrentPost->getId() !== 0 ?
'_' . $this->objCurrentPost->getId() :
'');
3269 $this->tpl->setLoginTargetPar(
'frm_' . $this->
object->getRefId() . $append);
3272 if (!in_array($this->requestAction, [
'showreply',
'showedit'])) {
3275 foreach ($mobs as $mob) {
3286 if (!$this->
getCreationMode() && $this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3288 $this->
object->getRefId(),
3289 ilLink::_getLink($this->
object->getRefId(),
'frm'),
3294 $this->prepareThreadScreen($forumObj);
3297 if (isset($this->httpRequest->getQueryParams()[
'anchor'])) {
3298 $threadContentTemplate->setVariable(
'JUMP2ANCHOR_ID', (
int) $this->httpRequest->getQueryParams()[
'anchor']);
3303 $this->
object->getType(),
3304 $this->
object->getRefId(),
3305 $this->
object->getId(),
3306 $this->
user->getId()
3309 if ($firstNodeInThread) {
3310 $this->objCurrentTopic->updateVisits();
3312 $this->tpl->setTitle($this->
lng->txt(
'forums_thread') .
' "' . $this->objCurrentTopic->getSubject() .
'"');
3314 $this->
locator->addRepositoryItems();
3315 $this->
locator->addItem($this->
object->getTitle(), $this->
ctrl->getLinkTarget($this,
''),
'_top');
3316 $this->tpl->setLocator();
3318 if (!$this->
user->isAnonymous() &&
3319 $forumObj->getCountUnread($this->
user->getId(), $this->objCurrentTopic->getId(),
true)) {
3320 $this->
ctrl->setParameter($this,
'mark_read',
'1');
3321 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3323 $mark_thr_read_button = $this->uiFactory->button()->standard(
3324 $this->
lng->txt(
'forums_mark_read'),
3325 $this->
ctrl->getLinkTarget($this,
'viewThread')
3328 $toolbar_items[] = $mark_thr_read_button;
3330 $this->
ctrl->clearParameters($this);
3333 $this->
ctrl->setParameterByClass(ilForumExportGUI::class,
'print_thread', $this->objCurrentTopic->getId());
3334 $this->
ctrl->setParameterByClass(
3335 ilForumExportGUI::class,
3337 $this->objCurrentTopic->getForumId()
3340 if ($numberOfPostings > 0 && $this->
settings->get(
'forum_enable_print',
'0')) {
3341 $print_thr_button = $this->uiFactory->button()->standard(
3342 $this->
lng->txt(
'forums_print_thread'),
3343 $this->
ctrl->getLinkTargetByClass(ilForumExportGUI::class,
'printThread')
3345 $toolbar_items[] = $print_thr_button;
3349 $this->
ctrl->clearParametersByClass(ilForumExportGUI::class);
3353 if (isset($this->httpRequest->getQueryParams()[
'mark_read'])) {
3354 $forumObj->markThreadRead($this->
user->getId(), $this->objCurrentTopic->getId());
3355 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_thread_marked'),
true);
3360 !$this->objCurrentTopic->isClosed() &&
3361 $this->
access->checkAccess(
'add_reply',
'', $this->
object->getRefId())) {
3362 $this->
ctrl->setParameter($this,
'action',
'showreply');
3363 $this->
ctrl->setParameter($this,
'pos_pk', $firstNodeInThread->getId());
3364 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3365 $this->
ctrl->setParameter(
3368 (
int) ($this->httpRequest->getQueryParams()[
'page'] ?? 0)
3370 $this->
ctrl->setParameter(
3375 if ($numberOfPostings > 0) {
3376 $reply_button = $this->uiFactory->button()->standard(
3377 $this->
lng->txt(
'add_new_answer'),
3378 $this->
ctrl->getLinkTarget($this,
'createTopLevelPost',
'frm_page_bottom')
3381 $reply_button = $this->uiFactory->button()->primary(
3382 $this->
lng->txt(
'add_new_answer'),
3383 $this->
ctrl->getLinkTarget($this,
'createTopLevelPost',
'frm_page_bottom')
3386 $this->
ctrl->clearParameters($this);
3387 array_unshift($toolbar_items, $reply_button);
3391 if ($numberOfPostings === 0 && $firstNodeInThread->getId() === 0) {
3392 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_no_posts_available'));
3397 if ($numberOfPostings > $pageSize) {
3398 $this->
ctrl->setParameter($this,
'ref_id', $this->
object->getRefId());
3399 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3400 $this->
ctrl->setParameter(
3405 $paginationUrl = $this->
ctrl->getLinkTarget($this,
'viewThread',
'');
3406 $this->
ctrl->clearParameters($this);
3408 $pagination = $this->uiFactory->viewControl()
3410 ->withTargetURL($paginationUrl,
'page')
3411 ->withTotalEntries($numberOfPostings)
3412 ->withPageSize($pageSize)
3413 ->withMaxPaginationButtons(10)
3414 ->withCurrentPage($pageIndex);
3416 $threadContentTemplate->setVariable(
'THREAD_MENU', $this->uiRenderer->render(
3419 $threadContentTemplate->setVariable(
'THREAD_MENU_BOTTOM', $this->uiRenderer->render(
3425 $draftsObjects = [];
3426 if ($doRenderDrafts) {
3428 $this->
user->getId(),
3429 $this->objCurrentTopic->getId(),
3434 $pagedPostings = array_slice($subtree_nodes, $pageIndex * $pageSize, $pageSize);
3438 if ($doRenderDrafts && $pageIndex === 0 &&
3440 foreach ($draftsObjects as $draft) {
3441 $referencePosting = array_values(array_filter(
3444 return $draft->getPostId() === $post->
getId();
3446 ))[0] ?? $firstNodeInThread;
3449 $threadContentTemplate,
3450 $this->requestAction,
3457 foreach ($pagedPostings as $node) {
3458 $this->
ctrl->clearParameters($this);
3461 ($this->is_moderator || $node->isActivated() || $node->isOwner($this->
user->getId()))) {
3462 if (!$this->objCurrentTopic->isClosed() && in_array($this->requestAction, [
3466 $this->
renderPostingForm($threadContentTemplate, $frm, $node, $this->requestAction);
3467 } elseif ($this->requestAction ===
'censor' &&
3469 $threadContentTemplate->setVariable(
'FORM', $this->getCensorshipFormHTML());
3473 $this->
renderPostContent($threadContentTemplate, $node, $this->requestAction, $pageIndex, $postIndex);
3476 $threadContentTemplate,
3477 $this->requestAction,
3479 $draftsObjects[$node->getId()] ?? []
3488 $doRenderDrafts && $pageIndex === max(0, (
int) (ceil($numberOfPostings / $pageSize) - 1))
3490 foreach ($draftsObjects as $draft) {
3491 $referencePosting = array_values(array_filter(
3494 return $draft->getPostId() === $post->
getId();
3496 ))[0] ?? $firstNodeInThread;
3499 $threadContentTemplate,
3500 $this->requestAction,
3508 $firstNodeInThread instanceof
ilForumPost && $doRenderDrafts &&
3512 $threadContentTemplate,
3513 $this->requestAction,
3515 $draftsObjects[$firstNodeInThread->getId()] ?? []
3520 !$this->objCurrentTopic->isClosed() &&
3521 in_array($this->
ctrl->getCmd(), [
'createTopLevelPost',
'saveTopLevelPost',
'saveTopLevelDraft'],
true) &&
3522 $this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
3524 $this->objCurrentPost->setId($firstNodeInThread->getId());
3527 if (in_array($this->
ctrl->getCmd(), [
'saveTopLevelPost',
'saveTopLevelDraft'])) {
3528 $form->setValuesByPost();
3530 $threadContentTemplate->setVariable(
'BOTTOM_FORM', $form->getHTML());
3533 $threadContentTemplate->setCurrentBlock(
'posts_no');
3534 $threadContentTemplate->setVariable(
3535 'TXT_MSG_NO_POSTS_AVAILABLE',
3536 $this->
lng->txt(
'forums_posts_not_available')
3538 $threadContentTemplate->parseCurrentBlock();
3541 $to_top_button = $this->uiFactory->button()
3542 ->standard($this->
lng->txt(
'top_of_page'),
'#frm_page_top');
3543 $bottom_toolbar->addComponent($to_top_button);
3544 if ($numberOfPostings > 0) {
3545 $threadContentTemplate->setVariable(
'TOOLBAR_BOTTOM', $bottom_toolbar->getHTML());
3548 if ($toolbar_items !== []) {
3549 foreach ($toolbar_items as $component_index => $item) {
3550 $this->toolbar->addComponent($item);
3551 $bottom_toolbar->addComponent($item);
3552 if ($component_index === 0 && $numberOfPostings > 0) {
3561 $this->tpl->setPermanentLink(
3562 $this->
object->getType(),
3563 $this->
object->getRefId(),
3564 (string) $this->objCurrentTopic->getId()
3567 $this->tpl->addOnLoadCode(
3569 document.querySelectorAll(
'.ilFrmPostContent img').forEach((img) => {
3570 const maxWidth = img.getAttribute(
'width');
3571 const maxHeight = img.getAttribute(
'height');
3574 img.style.maxWidth = maxWidth +
'px';
3575 img.removeAttribute(
'width');
3579 img.style.maxHeight = maxHeight +
'px';
3580 img.removeAttribute(
'height');
3590 $this->tpl->setContent(($info ??
'') . $threadContentTemplate->get() . $this->
getModalActions());
3595 if ($currentViewMode === 3) {
3596 $currentViewMode = 2;
3598 $translationKeys = [];
3599 foreach ($this->viewModeOptions as $sortingConstantKey => $languageKey) {
3600 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3601 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
3602 $this->
ctrl->setParameter($this,
'viewmode', $sortingConstantKey);
3604 $translationKeys[$this->
lng->txt($languageKey)] = $this->
ctrl->getLinkTarget(
3610 $this->
ctrl->clearParameters($this);
3617 $sortViewControl = $this->uiFactory
3619 ->mode($translationKeys, $this->
lng->txt($this->viewModeOptions[$currentViewMode]))
3620 ->withActive($this->
lng->txt($this->viewModeOptions[$currentViewMode]));
3621 $this->
toolbar->addComponent($sortViewControl);
3626 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3627 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
3628 $target = $this->
ctrl->getLinkTarget(
3634 $translatedSortationOptions =
array_map(
function ($value):
string {
3635 return $this->
lng->txt($value);
3638 $sortingDirectionViewControl = $this->uiFactory
3640 ->sortation($translatedSortationOptions, (
string) $currentSorting)
3641 ->withTargetURL($target,
'viewmode');
3642 $this->
toolbar->addComponent($sortingDirectionViewControl);
3647 return (
new \
ILIAS\
components\Forum\Subject\PostingReplySubjectBuilder(
3648 $this->
lng->txt(
'post_reply'),
3649 $this->
lng->txt(
'post_reply_count')
3650 ))->build($this->objCurrentPost->getSubject());
3657 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->
refinery->always(0)])
3659 $backurl = $this->
http->wrapper()->query()->retrieve(
3661 $this->
refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->
refinery->always(
'')])
3665 $add = $this->getUserProfileAdditional($this->
object->getRefId(),
$user_id);
3666 $profile_gui->setAdditional($add);
3668 $this->tpl->setContent($this->
ctrl->getHTML($profile_gui));
3671 protected function getUserProfileAdditional(
int $a_forum_ref_id,
int $a_user_id): array
3673 if (!$this->
access->checkAccess(
'read',
'', $a_forum_ref_id)) {
3674 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3679 if ($ref_obj->getType() ===
'frm') {
3681 $frm = $forumObj->Forum;
3688 if ($this->
access->checkAccess(
'moderate_frm',
'', $a_forum_ref_id)) {
3694 return [$this->
lng->txt(
'forums_posts') => $numPosts];
3699 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3700 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3706 $cmd = $this->
ctrl->getCmd();
3709 if ($thread_ids !== []) {
3710 if ($cmd ===
'move') {
3711 if ($this->is_moderator) {
3715 } elseif ($cmd ===
'enable_notifications' && (
int) $this->
settings->get(
'forum_notification',
'0') !== 0) {
3716 foreach ($thread_ids as $thread_id) {
3719 $tmp_obj->enableNotification($this->
user->getId());
3722 $this->
ctrl->redirect($this,
'showThreads');
3723 } elseif ($cmd ===
'disable_notifications' && (
int) $this->
settings->get(
'forum_notification',
'0') !== 0) {
3724 foreach ($thread_ids as $thread_id) {
3727 $tmp_obj->disableNotification($this->
user->getId());
3730 $this->
ctrl->redirect($this,
'showThreads');
3731 } elseif ($cmd ===
'close') {
3732 if ($this->is_moderator) {
3733 foreach ($thread_ids as $thread_id) {
3739 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'selected_threads_closed'),
true);
3740 $this->
ctrl->redirect($this,
'showThreads');
3741 } elseif ($cmd ===
'reopen') {
3742 if ($this->is_moderator) {
3743 foreach ($thread_ids as $thread_id) {
3750 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'selected_threads_reopened'),
true);
3751 $this->
ctrl->redirect($this,
'showThreads');
3752 } elseif ($cmd ===
'makesticky') {
3753 if ($this->is_moderator) {
3754 $message = $this->
lng->txt(
'sel_threads_make_sticky');
3756 foreach ($thread_ids as $thread_id) {
3759 $makeSticky = $tmp_obj->makeSticky();
3761 $message = $this->
lng->txt(
'sel_threads_already_sticky');
3765 if ($message !== null) {
3766 $this->tpl->setOnScreenMessage(
'info', $message,
true);
3768 $this->
ctrl->redirect($this,
'showThreads');
3769 } elseif ($cmd ===
'unmakesticky' || $cmd ===
'make_topics_non_sticky') {
3770 if ($this->is_moderator) {
3771 $message = $this->
lng->txt(
'sel_threads_make_unsticky');
3772 foreach ($thread_ids as $thread_id) {
3775 $unmakeSticky = $tmp_obj->unmakeSticky();
3776 if (!$unmakeSticky) {
3777 $message = $this->
lng->txt(
'sel_threads_already_unsticky');
3782 if ($message !== null) {
3783 $this->tpl->setOnScreenMessage(
'info', $message,
true);
3785 $this->
ctrl->redirect($this,
'showThreads');
3786 } elseif ($cmd ===
'editThread') {
3787 if ($this->is_moderator) {
3788 $count = count($thread_ids);
3790 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_max_one_thread'),
true);
3791 $this->
ctrl->redirect($this,
'showThreads');
3798 $this->
ctrl->redirect($this,
'showThreads');
3799 } elseif ($cmd ===
'confirmDeleteThreads') {
3800 $this->confirmDeleteThreadsObject();
3801 } elseif ($cmd ===
'mergeThreads') {
3804 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'topics_please_select_one_action'),
true);
3805 $this->
ctrl->redirect($this,
'showThreads');
3808 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
3809 $this->
ctrl->redirect($this,
'showThreads');
3815 if (!$this->is_moderator) {
3816 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3819 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3820 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3824 if ($this->
http->wrapper()->post()->has(
'frm_ref_id')) {
3825 $frm_ref_id = $this->
http->wrapper()->post()->retrieve(
3830 $this->error->raiseError(
'Please select a forum', $this->error->MESSAGE);
3834 if (!is_array($threads2move) || $threads2move === []) {
3835 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
3836 $this->
ctrl->redirect($this,
'showThreads');
3839 if (!$this->
access->checkAccess(
'read',
'', (
int) $frm_ref_id)) {
3840 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3844 array_walk($threads2move,
function (
int $threadId) use (&$threads):
void {
3848 $threads[] = $threadId;
3851 if (isset($frm_ref_id) && (
int) $frm_ref_id) {
3852 $errorMessages = $this->
object->Forum->moveThreads(
3855 $this->ilObjDataCache->lookupObjId((
int) $frm_ref_id)
3858 if ([] !== $errorMessages) {
3859 $this->tpl->setOnScreenMessage(
'failure', implode(
'<br><br>', $errorMessages),
true);
3860 $this->
ctrl->redirect($this,
'showThreads');
3864 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'threads_moved_successfully'),
true);
3865 $this->
ctrl->redirect($this,
'showThreads');
3867 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'no_forum_selected'));
3875 $this->
ctrl->redirect($this,
'showThreads');
3880 if (!$this->is_moderator) {
3881 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3884 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3885 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3888 $frm_ref_id = $this->
http->wrapper()->post()->retrieve(
3890 $this->
refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->
refinery->always(null)])
3894 if (!is_array($threads2move) || $threads2move === []) {
3895 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_at_least_one_thread'),
true);
3896 $this->
ctrl->redirect($this,
'showThreads');
3901 array_walk($threads2move,
function (
int $threadId) use (&$threads, $isModerator):
void {
3905 $threads[] = $thread;
3909 $exp->setPathOpen($this->
object->getRefId());
3910 $exp->setNodeSelected(isset($frm_ref_id) && (
int) $frm_ref_id ? (
int) $frm_ref_id : 0);
3911 $exp->setCurrentFrmRefId($this->
object->getRefId());
3912 $exp->setHighlightedNode((
string) $this->
object->getRefId());
3913 if (!$exp->handleCommand()) {
3915 'tpl.forums_threads_move.html',
3918 'components/ILIAS/Forum' 3922 $this->
toolbar->addButton($this->
lng->txt(
'back'), $this->
ctrl->getLinkTarget($this));
3929 foreach ($threads as $thread) {
3930 $result[$counter][
'num'] = $counter + 1;
3931 $result[$counter][
'thr_subject'] = $thread->getSubject();
3935 $tblThr->setId(
'frmthrmv' . $this->
object->getRefId());
3936 $tblThr->setTitle(
'');
3937 $tblThr->addColumn($this->
lng->txt(
'subject'),
'top_name',
'100%');
3938 $tblThr->disable(
'header');
3939 $tblThr->disable(
'footer');
3940 $tblThr->disable(
'linkbar');
3941 $tblThr->disable(
'sort');
3942 $tblThr->disable(
'linkbar');
3943 $tblThr->setLimit(PHP_INT_MAX);
3944 $tblThr->setRowTemplate(
'tpl.forums_threads_move_thr_row.html',
'components/ILIAS/Forum');
3945 $tblThr->setDefaultOrderField(
'is_sticky');
3947 $tblThr->setData($result);
3948 $moveThreadTemplate->setVariable(
'THREAD_TITLE', sprintf($this->
lng->txt(
'move_chosen_topics'), $thread->getSubject()));
3949 $moveThreadTemplate->setVariable(
'THREADS_TABLE', $tblThr->getHTML());
3950 $moveThreadTemplate->setVariable(
'FRM_SELECTION_TREE', $exp->getHTML());
3951 $moveThreadTemplate->setVariable(
'CMD_SUBMIT',
'performMoveThreads');
3952 $moveThreadTemplate->setVariable(
'TXT_SUBMIT', $this->
lng->txt(
'move'));
3953 $moveThreadTemplate->setVariable(
'FORMACTION', $this->
ctrl->getFormAction($this,
'performMoveThreads'));
3955 $this->tpl->setContent($moveThreadTemplate->get());
3964 $this->objProperties->isAnonymized() &&
3965 (!$this->is_moderator || !$this->objProperties->getMarkModeratorPosts())
3971 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
3972 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
3975 $draftIds = array_filter((array) ($this->httpRequest->getParsedBody()[
'draft_ids'] ?? []));
3978 $checkedDraftIds = [];
3979 foreach ($draftIds as $draftId) {
3980 if (array_key_exists($draftId, $instances)) {
3981 $checkedDraftIds[] = $draftId;
3982 $draft = $instances[$draftId];
3986 $GLOBALS[
'ilAppEventHandler']->raise(
3987 'components/ILIAS/Forum',
3990 'draftObj' => $draft,
3991 'obj_id' => $this->
object->getId(),
3992 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
3997 $draftFileData->delete([$draft->getDraftId()]);
3999 $draft->deleteDraft();
4003 if (count($checkedDraftIds) > 1) {
4004 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'delete_drafts_successfully'),
true);
4006 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'delete_draft_successfully'),
true);
4008 $this->
ctrl->redirect($this,
'showThreads');
4013 $draftId = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
4014 $allowNotification = !$this->objProperties->isAnonymized() && !$this->
user->isAnonymous();
4017 if (!$this->
rbac->system()->checkAccess(
'internal_mail', $mail->getMailObjectReferenceId())) {
4018 $allowNotification =
false;
4023 $this->objProperties,
4036 $default_form->generateDefaultForm();
4040 return $default_form;
4045 $draftId = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
4046 $allowNotification = !$this->objProperties->isAnonymized() && !$this->
user->isAnonymous();
4049 if (!$this->
rbac->system()->checkAccess(
'internal_mail', $mail->getMailObjectReferenceId())) {
4050 $allowNotification =
false;
4055 $this->objProperties,
4065 $minimal_form->generateMinimalForm();
4067 return $minimal_form;
4072 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4073 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4076 if (!$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId())) {
4077 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4080 $tpl =
new ilTemplate(
'tpl.create_thread_form.html',
true,
true,
'components/ILIAS/Forum');
4083 $accordion->setId(
'acc_' . $this->obj_id);
4086 $accordion->addItem($this->
lng->txt(
'new_thread_with_post'), $this->
buildThreadForm()->getHTML());
4092 $this->tpl->setContent(
$tpl->
get());
4100 if (!$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4101 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4102 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4105 $frm = $this->
object->Forum;
4114 if ($form->checkInput()) {
4115 $userIdForDisplayPurposes = $this->
user->getId();
4117 $userIdForDisplayPurposes = 0;
4123 $this->objCurrentPost->isAnyParentDeactivated()
4128 if ($createFromDraft) {
4130 $newThread->setForumId($topicData->getTopPk());
4133 $newThread->setSubject($this->
handleFormInput($form->getInput(
'subject'),
false));
4145 $newThread->setForumId($topicData->getTopPk());
4146 $newThread->setThrAuthorId($this->
user->getId());
4147 $newThread->setDisplayUserId($userIdForDisplayPurposes);
4148 $newThread->setSubject($this->
handleFormInput($form->getInput(
'subject'),
false));
4150 $form->getInput(
'alias'),
4151 $this->objProperties->isAnonymized()
4157 $form->getItemByPostVar(
'notify') && $form->getInput(
'notify') && !$this->
user->isAnonymous(),
4165 $post_obj->setRCID($draft->
getRCID());
4166 $post_obj->update();
4169 if ($this->objProperties->isFileUploadAllowed()) {
4170 $file = $_FILES[
'userfile'];
4171 if (is_array($file) && !empty($file)) {
4181 if ($createFromDraft) {
4186 foreach ($mediaObjects as $mob) {
4195 $draftHistory->deleteHistoryByDraftIds([$draft->
getDraftId()]);
4199 $GLOBALS[
'ilAppEventHandler']->raise(
4200 'components/ILIAS/Forum',
4203 'object' => $this->
object,
4204 'ref_id' => $this->
object->getRefId(),
4205 'post' => $post_obj,
4206 'notify_moderators' => !$status
4210 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'forums_thread_new_entry'),
true);
4211 $this->
ctrl->redirect($this);
4214 $form->setValuesByPost();
4215 if (!$this->objProperties->isAnonymized()) {
4216 $form->getItemByPostVar(
'alias')->setValue($this->
user->getLogin());
4220 $accordion->setId(
'acc_' . $this->obj_id);
4222 $accordion->addItem($this->
lng->txt(
'new_thread_with_post'), $form->getHTML());
4223 $accordion->addItem($this->
lng->txt(
'empty_thread'), $minimal_form->getHTML());
4225 $this->tpl->setContent($accordion->getHTML());
4233 if (!$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4234 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4235 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4238 $frm = $this->
object->Forum;
4247 if ($minimal_form->checkInput()) {
4248 $userIdForDisplayPurposes = $this->
user->getId();
4250 $userIdForDisplayPurposes = 0;
4256 $this->objCurrentPost->isAnyParentDeactivated()
4262 $newThread->setForumId($topicData->getTopPk());
4263 $newThread->setThrAuthorId($this->
user->getId());
4264 $newThread->setDisplayUserId($userIdForDisplayPurposes);
4265 $newThread->setSubject($this->
handleFormInput($minimal_form->getInput(
'subject'),
false));
4267 $minimal_form->getInput(
'alias'),
4268 $this->objProperties->isAnonymized()
4284 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'forums_thread_new_entry'),
true);
4285 $this->
ctrl->redirect($this);
4288 $form->setValuesByPost();
4290 if (!$this->objProperties->isAnonymized()) {
4291 $form->getItemByPostVar(
'alias')->setValue($this->
user->getLogin());
4295 $accordion->setId(
'acc_' . $this->obj_id);
4297 $accordion->addItem($this->
lng->txt(
'new_thread_with_post'), $form->getHTML());
4298 $accordion->addItem($this->
lng->txt(
'empty_thread'), $minimal_form->getHTML());
4300 $this->tpl->setContent($accordion->getHTML());
4306 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4333 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId()) || $this->
user->isAnonymous()) {
4334 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4337 $frm = $this->
object->Forum;
4341 if ($this->objCurrentTopic->getId() > 0) {
4342 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4343 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_enabled'),
true);
4344 $this->
ctrl->redirect($this,
'viewThread');
4347 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_enabled'));
4353 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId()) || $this->
user->isAnonymous()) {
4354 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4357 $frm = $this->
object->Forum;
4361 if ($this->objCurrentTopic->getId() > 0) {
4362 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4363 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_disabled'),
true);
4364 $this->
ctrl->redirect($this,
'viewThread');
4367 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'forums_forum_notification_disabled'));
4377 if ($this->
access->checkAccess(
'write',
'', $this->object->getRefId())) {
4379 if ($news_set->get(
'enable_rss_for_internal')) {
4390 $this->
object->getTitle(),
4391 $this->
ctrl->getLinkTarget($this),
4393 $this->
object->getRefId()
4400 $a_text = str_replace([
'<',
'>'], [
'<',
'>'], $a_text);
4401 if ($a_stripslashes) {
4410 $a_text = str_replace([
'<',
'>'], [
'<',
'>'], $a_text);
4418 !$this->
access->checkAccess(
'visible',
'', $this->object->getRefId()) &&
4419 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())
4421 $this->error->raiseError($this->
lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
4424 if (strtolower($this->
ctrl->getCmd() ??
'') ===
'infoscreen') {
4425 $this->
ctrl->redirectByClass(ilInfoScreenGUI::class,
'showSummary');
4429 $info->enablePrivateNotes();
4430 $this->
ctrl->forwardCommand($info);
4435 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4436 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4439 if ($this->objCurrentPost->getId() > 0) {
4442 $this->
object->markPostUnread($this->
user->getId(), $this->objCurrentPost->getId());
4449 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4450 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4453 if ($this->objCurrentTopic->getId() > 0 && $this->objCurrentPost->getId() > 0) {
4456 $this->
object->markPostRead(
4457 $this->
user->getId(),
4458 $this->objCurrentTopic->getId(),
4459 $this->objCurrentPost->getId()
4463 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4464 $this->
ctrl->redirect($this,
'viewThread');
4469 $lg = parent::initHeaderAction();
4475 if ($this->
user->isAnonymous() || !$this->
access->checkAccess(
'read',
'', $this->
object->getRefId())) {
4479 $frm = $this->
object->Forum;
4482 $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', [
'integer'], [$frm->
getForumId()]);
4485 $has_membership_enabled_parent_container = $this->
object->isParentMembershipEnabledContainer();
4486 $user_may_disable_notifcations = (
4488 !$has_membership_enabled_parent_container
4491 if ($this->objCurrentTopic->getId() > 0) {
4492 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4495 if (!$this->
user->isAnonymous()) {
4496 if ($has_membership_enabled_parent_container) {
4497 if ($are_notifications_enabled && $user_may_disable_notifcations) {
4498 $lg->addCustomCommand(
4499 $this->
ctrl->getLinkTarget($this,
'disableForumNotification'),
4500 'forums_disable_forum_notification' 4502 } elseif (!$are_notifications_enabled) {
4503 $lg->addCustomCommand(
4504 $this->
ctrl->getLinkTarget($this,
'enableForumNotification'),
4505 'forums_enable_forum_notification' 4508 } elseif ($are_notifications_enabled) {
4509 $lg->addCustomCommand(
4510 $this->
ctrl->getLinkTarget($this,
'disableForumNotification'),
4511 'forums_disable_forum_notification' 4514 $lg->addCustomCommand(
4515 $this->
ctrl->getLinkTarget($this,
'enableForumNotification'),
4516 'forums_enable_forum_notification' 4521 if ($are_notifications_enabled && $user_may_disable_notifcations && !$this->
user->isAnonymous()) {
4524 $interested_events = $frm_noti->readInterestedEvents();
4527 'hidden_value' =>
'',
4535 $notificationsModal = $this->uiFactory->modal()->roundtrip(
4536 $this->
lng->txt(
'notification_settings'),
4537 [$events_form_builder->build()]
4538 )->withActionButtons([
4541 ->primary($this->
lng->txt(
'save'),
'#')
4545 const button = document.getElementById('$id'); 4546 if (!button) return; 4548 const modalDialog = button.closest('.modal-dialog'); 4549 if (!modalDialog) return; 4551 const form = modalDialog.querySelector('.modal-body form'); 4554 form.classList.add('ilForumNotificationSettingsForm'); 4555 button.addEventListener('click', (event) => { 4556 event.preventDefault(); 4566 $showNotificationSettingsBtn = $this->uiFactory->button()
4567 ->shy($this->
lng->txt(
'notification_settings'),
'#')
4569 $notificationsModal->getShowSignal()
4572 $lg->addCustomCommandButton($showNotificationSettingsBtn, $notificationsModal);
4575 $are_thread_notifications_enabled =
false;
4576 if (!$this->
user->isAnonymous() && $this->objCurrentTopic->getId() > 0) {
4577 $are_thread_notifications_enabled = $this->objCurrentTopic->isNotificationEnabled($this->
user->getId());
4578 if ($are_thread_notifications_enabled) {
4579 $lg->addCustomCommand(
4580 $this->
ctrl->getLinkTarget($this,
'toggleThreadNotification'),
4581 'forums_disable_notification' 4584 $lg->addCustomCommand(
4585 $this->
ctrl->getLinkTarget($this,
'toggleThreadNotification'),
4586 'forums_enable_notification' 4590 $this->
ctrl->setParameter($this,
'thr_pk',
'');
4592 if (!$this->
user->isAnonymous()) {
4593 if ($are_notifications_enabled || $are_thread_notifications_enabled) {
4597 $this->
lng->txt(
'frm_notification_activated')
4603 $this->
lng->txt(
'frm_notification_deactivated')
4617 if ($this->objCurrentTopic->getId() > 0) {
4618 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4622 $this->
ctrl->getFormAction($this,
'saveUserNotificationSettings'),
4633 if ($this->httpRequest->getMethod() ===
'POST') {
4634 $form = $events_form_builder->build()->withRequest($this->httpRequest);
4635 $formData = $form->getData();
4639 foreach ($events_form_builder->getValidEvents() as $event) {
4640 $interested_events += isset($formData[$event]) && $formData[$event] ? $events_form_builder->getValueForEvent(
4647 $frm_noti->setInterestedEvents($interested_events);
4648 $frm_noti->updateInterestedEvents();
4651 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
4653 if ($this->objCurrentTopic->getId() > 0) {
4654 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4655 $this->
ctrl->redirect($this,
'viewThread');
4658 $this->
ctrl->redirect($this,
'showThreads');
4667 if (!$this->objProperties->isUserToggleNoti() &&
4668 $this->objProperties->getNotificationType() === NotificationType::ALL_USERS) {
4672 if ($this->objProperties->getNotificationType() === NotificationType::PER_USER &&
4673 $this->
object->isParentMembershipEnabledContainer()) {
4677 return !$frm_noti->isUserToggleNotification();
4685 if (!$this->is_moderator) {
4686 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4689 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4690 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4693 $threadIdToMerge = $this->
http->wrapper()->query()->retrieve(
4696 $this->refinery->kindlyTo()->int(),
4700 if ($threadIdToMerge <= 0) {
4701 $threadIds = array_values(
4702 array_filter(
array_map(intval(...), (array) ($this->httpRequest->getParsedBody()[
'thread_ids'] ?? [])))
4704 if (count($threadIds) === 1) {
4705 $threadIdToMerge = current($threadIds);
4707 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'select_one'));
4713 $frm = $this->
object->Forum;
4720 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'not_allowed_to_merge_into_another_forum'));
4725 $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', [
'integer'], [$frm->
getForumId()]);
4728 'tpl.forums_threads_liste.html',
4731 'components/ILIAS/Forum' 4735 if ($topicData->getTopPk() > 0) {
4736 $this->
ctrl->setParameter($this,
'merge_thread_id', $threadIdToMerge);
4740 (
int) $this->httpRequest->getQueryParams()[
'ref_id'],
4744 $tbl->setSelectedThread($threadToMerge);
4747 $threadsTemplate->setVariable(
'THREADS_TABLE', $tbl->
getHTML());
4748 $this->tpl->setContent($threadsTemplate->get());
4750 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
4757 if (!$this->is_moderator) {
4758 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4761 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4762 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4765 $sourceThreadId = (
int) ($this->httpRequest->getQueryParams()[
'merge_thread_id'] ?? 0);
4766 $targetThreadIds = array_values(
4767 array_filter(
array_map(intval(...), (array) ($this->httpRequest->getParsedBody()[
'thread_ids'] ?? [])))
4770 if ($sourceThreadId <= 0 || count($targetThreadIds) !== 1) {
4771 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
4776 $targetThreadId = current($targetThreadIds);
4777 if ($sourceThreadId === $targetThreadId) {
4778 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'error_same_thread_ids'));
4784 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'not_allowed_to_merge_into_another_forum'));
4785 $this->
ctrl->clearParameters($this);
4791 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'switch_threads_for_merge'));
4799 $c_gui->setFormAction($this->
ctrl->getFormAction($this,
'performMergeThreads'));
4800 $c_gui->setHeaderText($this->
lng->txt(
'frm_sure_merge_threads'));
4801 $c_gui->setCancel($this->
lng->txt(
'cancel'),
'showThreads');
4802 $c_gui->setConfirm($this->
lng->txt(
'confirm'),
'performMergeThreads');
4806 (
string) $sourceThreadId,
4811 (
string) $targetThreadId,
4814 $this->tpl->setContent($c_gui->getHTML());
4819 if (!$this->is_moderator) {
4820 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4823 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4824 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4827 $threadIds = array_values(
4828 array_filter(
array_map(intval(...), (array) ($this->httpRequest->getParsedBody()[
'thread_ids'] ?? [])))
4830 if (count($threadIds) !== 2) {
4831 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
4836 if ((
int) $threadIds[0] === (
int) $threadIds[1]) {
4837 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'error_same_thread_ids'));
4850 $frm->
mergeThreads((
int) $threadIds[0], (
int) $threadIds[1]);
4851 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'merged_threads_successfully'));
4853 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt($e->getMessage()));
4862 if (!$this->
ctrl->isAsynch()) {
4863 $content = implode(
'', [
4868 $this->tpl->setRightContent($content);
4873 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4874 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4880 if (!$fileData->deliverZipFile()) {
4881 $this->
ctrl->redirect($this);
4887 if (!$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4888 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4894 if (!$fileData->deliverZipFile()) {
4895 $this->
ctrl->redirect($this);
4905 !$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4906 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4907 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4910 $frm = $this->
object->Forum;
4915 $draftId = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
4921 $do_history_check = (bool) ($this->httpRequest->getQueryParams()[
'hist_check'] ??
true);
4926 if ($form instanceof ilPropertyFormGUI) {
4927 $this->
ctrl->setParameter($this,
'draft_id', $draftId);
4930 $form->setValuesByArray([
4931 'alias' => $draft->getPostUserAlias(),
4932 'subject' => $draft->getPostSubject(),
4934 'notify' => $draft->isNotificationEnabled() && !$this->
user->isAnonymous(),
4937 'draft_id' => $draftId
4947 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4950 $historyId = (
int) ($this->httpRequest->getQueryParams()[
'history_id'] ?? 0);
4955 $draft = $history->rollbackAutosave();
4956 if ($draft->getThreadId() === 0 && $draft->getPostId() === 0) {
4957 $this->
ctrl->setParameter($this,
'draft_id', $history->getDraftId());
4958 $this->
ctrl->redirect($this,
'editThreadDraft');
4961 $this->
ctrl->clearParameters($this);
4962 $this->
ctrl->setParameter($this,
'pos_pk', $draft->getPostId());
4963 $this->
ctrl->setParameter($this,
'thr_pk', $draft->getThreadId());
4964 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
4965 $this->
ctrl->setParameter($this,
'action',
'editdraft');
4969 $this->
ctrl->redirect($this,
'viewThread');
4975 !$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
4976 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
4977 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
4980 $autosave_draft_id = (
int) ($this->httpRequest->getParsedBody()[
'draft_id'] ?? 0);
4981 if ($autosave_draft_id <= 0) {
4982 $autosave_draft_id = (
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
4985 $frm = $this->
object->Forum;
4992 if ($form->checkInput()) {
4993 if ($autosave_draft_id === 0) {
4995 $draft->setForumId($topicData->getTopPk());
4996 $draft->setThreadId(0);
4997 $draft->setPostId(0);
5003 $draft->setPostSubject($this->
handleFormInput($form->getInput(
'subject'),
false));
5006 $form->getInput(
'alias'),
5007 $this->objProperties->isAnonymized()
5009 $draft->setNotificationStatus($form->getInput(
'notify') && !$this->
user->isAnonymous());
5010 $draft->setPostAuthorId($this->
user->getId());
5013 if ($autosave_draft_id === 0) {
5014 $draftId = $draft->saveDraft();
5016 $draft->updateDraft();
5017 $draftId = $draft->getDraftId();
5020 $GLOBALS[
'ilAppEventHandler']->raise(
5021 'components/ILIAS/Forum',
5024 'draftObj' => $draft,
5025 'obj_id' => $this->
object->getId(),
5026 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
5034 $files2delete = $form->getInput(
'del_file');
5035 if (is_array($files2delete) && $files2delete !== []) {
5039 if ($this->objProperties->isFileUploadAllowed()) {
5040 $file = $_FILES[
'userfile'];
5041 if (is_array($file) && !empty($file)) {
5042 $draftFileData->storeUploadedFiles();
5046 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
5047 $this->
ctrl->clearParameters($this);
5048 $this->
ctrl->redirect($this,
'showThreads');
5051 $this->requestAction = substr($this->requestAction, 6);
5052 $form->setValuesByPost();
5053 $this->
ctrl->setParameter($this,
'draft_id', $autosave_draft_id);
5054 $this->tpl->setContent($form->getHTML());
5060 !$this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId()) ||
5061 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
5062 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5069 if ($form->checkInput()) {
5070 $draft->setPostSubject($this->
handleFormInput($form->getInput(
'subject'),
false));
5073 $form->getInput(
'alias'),
5074 $this->objProperties->isAnonymized()
5076 $draft->setNotificationStatus($form->getInput(
'notify') && !$this->
user->isAnonymous());
5077 $draft->setPostAuthorId($this->
user->getId());
5079 $draft->updateDraft();
5081 $GLOBALS[
'ilAppEventHandler']->raise(
5082 'components/ILIAS/Forum',
5085 'draftObj' => $draft,
5086 'obj_id' => $this->
object->getId(),
5087 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
5092 $form->getInput(
'message'),
5094 $draft->getDraftId(),
5096 $draft->getDraftId()
5101 $files2delete = $form->getInput(
'del_file');
5102 if (is_array($files2delete) && $files2delete !== []) {
5106 if ($this->objProperties->isFileUploadAllowed()) {
5107 $file = $_FILES[
'userfile'];
5108 if (is_array($file) && !empty($file) && isset($file[
'full_path'][0]) && !empty($file[
'full_path'][0])) {
5109 $draftFileData->storeUploadedFiles();
5113 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
5114 $this->
ctrl->clearParameters($this);
5115 $this->
ctrl->redirect($this,
'showThreads');
5118 $form->setValuesByPost();
5119 $this->
ctrl->setParameter($this,
'hist_check', 0);
5120 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5132 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
5133 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5136 $autosave_draft_id = $this->
http->wrapper()->post()->retrieve(
5139 $this->refinery->kindlyTo()->int(),
5144 if ($this->objCurrentTopic->getId() === 0) {
5145 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
5146 $this->
ctrl->redirect($this);
5149 if ($this->objCurrentTopic->isClosed()) {
5150 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
5151 $this->
ctrl->redirect($this);
5155 if ($oReplyEditForm->checkInput()) {
5156 if ($this->objCurrentPost->getId() === 0) {
5157 $this->requestAction =
'';
5158 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'),
true);
5164 $frm = $oForumObjects[
'frm'];
5168 if ($this->requestAction ===
'ready_showreply') {
5169 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5170 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5173 if ($autosave_draft_id > 0) {
5179 $draftObj->setForumId($topicData->getTopPk());
5180 $draftObj->setThreadId($this->objCurrentTopic->getId());
5181 $draftObj->setPostId($this->objCurrentPost->getId());
5184 $draftObj->setPostSubject($this->
handleFormInput($oReplyEditForm->getInput(
'subject'),
false));
5187 $oReplyEditForm->getInput(
'alias'),
5188 $this->objProperties->isAnonymized()
5190 $draftObj->setNotificationStatus($oReplyEditForm->getInput(
'notify') && !$this->
user->isAnonymous());
5191 $draftObj->setPostNotificationStatus($oReplyEditForm->getInput(
'notify_post') && !$this->
user->isAnonymous());
5193 $draftObj->setPostAuthorId($this->
user->getId());
5196 if ($autosave_draft_id === 0) {
5197 $draft_id = $draftObj->saveDraft();
5199 $draftObj->updateDraft();
5200 $draft_id = $draftObj->getDraftId();
5205 $oReplyEditForm->getInput(
'message'),
5212 if ($this->objProperties->isFileUploadAllowed()) {
5213 $file = $_FILES[
'userfile'];
5214 if (is_array($file) && !empty($file)) {
5220 $GLOBALS[
'ilAppEventHandler']->raise(
5221 'components/ILIAS/Forum',
5224 'draftObj' => $draftObj,
5225 'obj_id' => $this->
object->getId(),
5226 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5231 if (is_array($frm_session_values)) {
5232 $frm_session_values[$this->objCurrentPost->getThreadId()][
'openTreeNodes'][] = $this->objCurrentPost->getId();
5236 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
5237 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5238 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5239 $this->
ctrl->redirect($this,
'viewThread');
5242 $oReplyEditForm->setValuesByPost();
5243 $this->requestAction = substr($this->requestAction, 6);
5257 !$this->
access->checkAccess(
'read',
'', $this->object->getRefId())) {
5258 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5261 if ($this->objCurrentTopic->getId() === 0) {
5262 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_deleted'),
true);
5263 $this->
ctrl->redirect($this);
5266 if ($this->objCurrentTopic->isClosed()) {
5267 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_thr_closed'),
true);
5268 $this->
ctrl->redirect($this);
5271 if ($this->objCurrentPost->getId() === 0) {
5272 $this->requestAction =
'';
5273 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'frm_action_not_possible_parent_deleted'));
5279 if ($oReplyEditForm->checkInput()) {
5281 $forumObj = $oForumObjects[
'forumObj'];
5283 if (!$this->
user->isAnonymous() && in_array($this->requestAction, [
'showdraft',
'editdraft'])) {
5284 if (!$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5285 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5289 $this->
user->getId(),
5290 $this->objCurrentPost->getId(),
5296 $draft->setPostSubject($this->
handleFormInput($oReplyEditForm->getInput(
'subject'),
false));
5298 $oReplyEditForm->getInput(
'message')
5301 $oReplyEditForm->getInput(
'alias'),
5302 $this->objProperties->isAnonymized()
5304 $draft->setNotificationStatus($oReplyEditForm->getInput(
'notify') && !$this->
user->isAnonymous());
5305 $draft->setUpdateUserId($this->
user->getId());
5306 $draft->setPostAuthorId($this->
user->getId());
5309 $draft->updateDraft();
5311 $GLOBALS[
'ilAppEventHandler']->raise(
5312 'components/ILIAS/Forum',
5315 'draftObj' => $draft,
5316 'obj_id' => $this->
object->getId(),
5317 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5323 foreach ($uploadedObjects as $mob) {
5328 $oReplyEditForm->getInput(
'message'),
5330 $draft->getDraftId()
5335 $file2delete = $oReplyEditForm->getInput(
'del_file');
5336 if (is_array($file2delete) && count($file2delete)) {
5340 if ($this->objProperties->isFileUploadAllowed()) {
5341 $file = $_FILES[
'userfile'];
5342 if (is_array($file) && !empty($file)) {
5343 $oFDForumDrafts->storeUploadedFiles();
5348 if (is_array($frm_session_values)) {
5349 $frm_session_values[$this->objCurrentPost->getThreadId()][
'openTreeNodes'][] = $this->objCurrentPost->getId();
5352 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'save_draft_successfully'),
true);
5353 $this->
ctrl->clearParameters($this);
5354 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5355 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5356 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5359 $this->
ctrl->clearParameters($this);
5360 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5361 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5363 $this->
ctrl->setParameter($this,
'action',
'editdraft');
5364 $oReplyEditForm->setValuesByPost();
5368 $this->
ctrl->clearParameters($this);
5369 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5370 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5371 $this->
ctrl->redirect($this,
'viewThread');
5378 foreach ($oldMediaObjects as $oldMob) {
5380 foreach ($curMediaObjects as $curMob) {
5381 if ($oldMob === $curMob) {
5402 $objFileDataForumDrafts->
delete([$draft->getDraftId()]);
5404 $GLOBALS[
'ilAppEventHandler']->raise(
5405 'components/ILIAS/Forum',
5408 'draftObj' => $draft,
5409 'obj_id' => $this->
object->getId(),
5410 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5413 $draft->deleteDraft();
5415 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'delete_draft_successfully'),
true);
5416 $this->
ctrl->clearParameters($this);
5417 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5418 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5419 $this->
ctrl->redirect($this,
'viewThread');
5424 if ($this->requestAction !==
'ready_showreply' &&
5426 $this->
access->checkAccess(
'read',
'', $this->object->getRefId()) &&
5427 $this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5431 $this->objProperties,
5432 $this->objCurrentTopic,
5433 $this->objCurrentPost,
5434 function (
string $message):
string {
5442 $this->
http->saveResponse($this->
http->response()->withBody(
5444 $action->executeAndGetResponseObject(),
5450 $this->
http->sendResponse();
5451 $this->
http->close();
5456 if ($this->requestAction !==
'ready_showreply' &&
5458 $this->
access->checkAccess(
'read',
'', $this->object->getRefId()) &&
5459 $this->
access->checkAccess(
'add_thread',
'', $this->object->getRefId())) {
5463 $this->objProperties,
5464 $this->objCurrentTopic,
5465 $this->objCurrentPost,
5466 function (
string $message):
string {
5474 $this->
http->saveResponse($this->
http->response()->withBody(
5476 $action->executeAndGetResponseObject(),
5482 $this->
http->sendResponse();
5483 $this->
http->close();
5498 if (($this->objCurrentPost->getId() !== $node->
getId() || (
5499 !in_array($action, [
'showreply',
'showedit',
'censor',
'delete'],
true) &&
5502 if ($this->is_moderator && !$this->objCurrentTopic->isClosed() && !$node->
isActivated()) {
5503 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5505 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5506 $this->
ctrl->setParameter(
5511 $primary_action = $this->
ctrl->getLinkTarget(
5513 'askForPostActivation',
5514 (
string) $node->
getId()
5516 $primary_action_language_id =
'activate_post';
5517 $this->
ctrl->clearParameters($this);
5521 $this->
access->checkAccess(
'add_reply',
'', $this->
object->getRefId())
5523 $this->
ctrl->setParameter($this,
'action',
'showreply');
5524 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5525 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5526 $this->
ctrl->setParameter(
5532 $primary_action = $this->
ctrl->getLinkTarget(
5535 'reply_' . $node->
getId()
5537 $primary_action_language_id =
'reply_to_postings';
5538 $this->
ctrl->clearParameters($this);
5541 !$this->objCurrentTopic->isClosed() &&
5543 !$this->
user->isAnonymous() &&
5544 ($node->
isOwner($this->
user->getId()) || $this->is_moderator)
5546 $this->
ctrl->setParameter($this,
'action',
'showedit');
5547 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5549 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5550 $this->
ctrl->setParameter(
5555 $actions[
'edit'] = $this->
ctrl->getLinkTarget($this,
'viewThread', (
string) $node->
getId());
5556 $this->
ctrl->clearParameters($this);
5558 if (!$this->
user->isAnonymous()) {
5559 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5561 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5562 $this->
ctrl->setParameter(
5567 $this->
ctrl->setParameter($this,
'viewmode', $this->selectedSorting);
5569 $read_undread_txt =
'frm_mark_as_read';
5570 $read_undread_cmd =
'markPostRead';
5572 $read_undread_txt =
'frm_mark_as_unread';
5573 $read_undread_cmd =
'markPostUnread';
5575 $actions[$read_undread_txt] = $this->
ctrl->getLinkTarget(
5578 (
string) $node->
getId()
5581 $this->
ctrl->clearParameters($this);
5584 $this->
ctrl->setParameterByClass(ilForumExportGUI::class,
'top_pk', $node->
getForumId());
5585 $this->
ctrl->setParameterByClass(ilForumExportGUI::class,
'thr_pk', $node->
getThreadId());
5588 $this->
ctrl->clearParameters($this);
5591 !$this->objCurrentTopic->isClosed() &&
5592 !$this->
user->isAnonymous() &&
5595 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5597 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5598 $this->
ctrl->setParameter(
5603 $actions[
'delete'] = $this->
ctrl->getFormAction($this,
'deletePosting');
5604 $this->
ctrl->clearParameters($this);
5606 if ($this->is_moderator && !$this->objCurrentTopic->isClosed()) {
5607 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5609 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5610 $this->
ctrl->setParameter(
5616 $this->
ctrl->setParameter($this,
'action',
'viewThread');
5617 $actions[
'frm_revoke_censorship'] = $this->
ctrl->getFormAction($this,
'revokeCensorship');
5619 $actions[
'frm_censorship'] = $this->
ctrl->getFormAction($this,
'addCensorship');
5621 $this->
ctrl->clearParameters($this);
5624 } elseif ($draft_id !== $draft->getDraftId() || !in_array($action, [
'deletedraft',
'editdraft'])) {
5626 $this->
ctrl->setParameter($this,
'action',
'publishdraft');
5627 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5628 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5629 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5630 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5631 $this->
ctrl->setParameter(
5636 $primary_action = $this->
ctrl->getLinkTarget($this,
'publishSelectedDraft', (
string) $node->
getId());
5637 $primary_action_language_id =
'publish';
5638 $this->
ctrl->clearParameters($this);
5640 $this->
ctrl->setParameter($this,
'action',
'editdraft');
5641 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5642 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5643 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5644 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5645 $this->
ctrl->setParameter(
5650 $actions[
'edit'] = $this->
ctrl->getLinkTarget($this,
'editDraft',
'draft_edit_' . $draft->getDraftId());
5651 $this->
ctrl->clearParameters($this);
5653 $this->
ctrl->setParameter($this,
'pos_pk', $node->
getId());
5654 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5655 $this->
ctrl->setParameter($this,
'draft_id', $draft->getDraftId());
5656 $this->
ctrl->setParameter($this,
'page', $pageIndex);
5657 $this->
ctrl->setParameter(
5662 $actions[
'delete'] = $this->
ctrl->getFormAction($this,
'deletePostingDraft');
5663 $this->
ctrl->clearParameters($this);
5665 if ($draft_id !== 0 && $action ===
'editdraft') {
5671 if ($actions !== [] && !$this->objCurrentTopic->isClosed()) {
5673 foreach ($actions as $lng_id =>
$url) {
5674 if ($lng_id ===
'frm_revoke_censorship' || $lng_id ===
'frm_censorship') {
5675 $modalTemplate =
new ilTemplate(
'tpl.forums_censor_modal.html',
true,
true,
'components/ILIAS/Forum');
5676 $form_id = str_replace(
'.',
'_', uniqid(
'form',
true));
5677 $modalTemplate->setVariable(
'FORM_ID', $form_id);
5680 $modalTemplate->setVariable(
'BODY', $this->
lng->txt(
'forums_info_censor2_post'));
5682 $modalTemplate->setVariable(
'BODY', $this->
lng->txt(
'forums_info_censor_post'));
5683 $modalTemplate->touchBlock(
'message');
5686 $modalTemplate->setVariable(
'FORM_ACTION',
$url);
5688 $content = $this->uiFactory->legacy($modalTemplate->get());
5689 $submitBtn = $this->uiFactory->button()->primary(
5690 $this->
lng->txt(
'submit'),
5693 static function (
string $id) use ($form_id):
string {
5696 const button = document.getElementById('$id'); 5697 if (!button) return; 5699 const form = document.getElementById('$form_id'); 5702 button.addEventListener('click', (event) => { 5703 event.preventDefault(); 5710 $modal = $this->uiFactory->modal()->roundtrip(
5711 $this->
lng->txt($lng_id),
5713 )->withActionButtons([$submitBtn]);
5714 $items[] = $this->uiFactory->button()->shy($this->
lng->txt($lng_id),
'#')->withOnClick(
5715 $modal->getShowSignal()
5718 $this->modalActionsContainer[] = $modal;
5722 if ($lng_id ===
'delete') {
5723 $modal = $this->uiFactory->modal()->interruptive(
5724 $this->
lng->txt($lng_id),
5725 str_contains(
$url,
'deletePostingDraft') ?
5726 $this->
lng->txt(
'forums_info_delete_draft') :
5727 $this->
lng->txt(
'forums_info_delete_post'),
5729 )->withActionButtonLabel(
5730 $this->
lng->txt(str_contains(
$url,
'deletePostingDraft') ?
'deletePostingDraft' :
'deletePosting')
5733 $items[] = $this->uiFactory->button()->shy($this->
lng->txt($lng_id),
'#')->withOnClick(
5734 $modal->getShowSignal()
5737 $this->modalActionsContainer[] = $modal;
5743 $items[] = $this->uiFactory->button()->shy($this->
lng->txt($lng_id),
$url);
5746 $dropdown = $this->uiFactory->dropdown()->standard($items);
5747 $render_action_buttons = [$dropdown];
5748 if (isset($primary_action, $primary_action_language_id)) {
5749 if ($primary_action_language_id ===
'activate_post') {
5752 $action_button = $this->uiFactory->button()->standard(
5753 $this->
lng->txt($primary_action_language_id),
5757 $tpl->
setVariable(
'MAIN_ACTION', $this->uiRenderer->render($action_button));
5759 $tpl->
setVariable(
'DROPDOWN_ACTIONS', $this->uiRenderer->render($render_action_buttons));
5767 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5776 !$this->
user->isAnonymous() &&
5777 $this->
access->checkAccess(
'add_reply',
'', $this->
object->getRefId()) &&
5792 if ($draftsFromHistory !== []) {
5793 $form_tpl =
new ilTemplate(
'tpl.restore_thread_draft.html',
true,
true,
'components/ILIAS/Forum');
5796 foreach ($draftsFromHistory as $history_instance) {
5798 $accordion->setId(
'acc_' . $history_instance->getHistoryId());
5800 if ($first_open === null) {
5801 $first_open = $history_instance->getHistoryId();
5805 $form_tpl->setCurrentBlock(
'list_item');
5809 $history_instance->getDraftDate(),
5812 $this->
ctrl->setParameter($this,
'history_id', $history_instance->getHistoryId());
5813 $header = $history_date .
': ' . $history_instance->getPostSubject();
5816 'tpl.restore_thread_draft_accordion_content.html',
5819 'components/ILIAS/Forum' 5821 $accordion_tpl->setVariable(
'MESSAGE', $message);
5822 $accordion_tpl->setVariable(
5824 $this->uiRenderer->render(
5825 $this->uiFactory->button()->standard(
5826 $this->
lng->txt(
'restore'),
5827 $this->
ctrl->getLinkTarget($this,
'restoreFromHistory')
5831 $accordion->addItem($header, $accordion_tpl->get());
5833 $form_tpl->setVariable(
'ACC_AUTO_SAVE', $accordion->getHTML());
5834 $form_tpl->parseCurrentBlock();
5837 $form_tpl->setVariable(
'RESTORE_DATA_EXISTS',
'found_threat_history_to_restore');
5839 $modal = $this->ui_factory->modal()->interruptive(
5840 $this->
lng->txt(
'restore_draft_from_autosave'),
5844 return "document.getElementById('$id').dataset.modalId = 'frm_autosave_restore';";
5847 $this->modal_history = $this->ui_renderer->render($modal);
5856 if ($action ===
'showedit' && (
5857 (!$this->is_moderator && !$node->
isOwner($this->user->getId())) ||
5858 $this->
user->isAnonymous() ||
5861 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5862 } elseif ($action ===
'showreply' && !$this->
access->checkAccess(
'add_reply',
'', $this->object->getRefId())) {
5863 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
5866 $tpl->
setVariable(
'REPLY_ANKER',
'reply_' . $this->objCurrentPost->getId());
5869 if ($action !==
'editdraft') {
5870 switch ($this->objProperties->getSubjectSetting()) {
5871 case 'add_re_to_subject':
5875 case 'preset_subject':
5876 $subject = $this->objCurrentPost->getSubject();
5879 case 'empty_subject':
5887 if ($this->
ctrl->getCmd() ===
'savePost' || $this->
ctrl->getCmd() ===
'saveAsDraft') {
5888 $oEditReplyForm->setValuesByPost();
5889 } elseif ($this->
ctrl->getCmd() ===
'quotePost') {
5897 $oEditReplyForm->setValuesByPost();
5898 $oEditReplyForm->getItemByPostVar(
'message')->setValue(
5903 $authorinfo->getAuthorName()
5904 ) .
"\n" . $oEditReplyForm->getInput(
'message'),
5909 $oEditReplyForm->setValuesByArray([
5910 'draft_id' => $draft_id,
5912 'subject' => $subject,
5922 if ($this->
ctrl->getCmd() ===
'savePost') {
5923 $oEditReplyForm->setValuesByPost();
5925 $oEditReplyForm->setValuesByArray([
5927 'subject' => $this->objCurrentPost->getSubject(),
5929 $this->objCurrentPost->getMessage(),
5932 'notify' => $this->objCurrentPost->isNotificationEnabled() && !$this->
user->isAnonymous(),
5935 'draft_id' => $draft_id
5941 if (in_array($this->
ctrl->getCmd(), [
'saveDraft',
'updateDraft',
'publishDraft'])) {
5942 $oEditReplyForm->setValuesByPost();
5943 } elseif ($draft_id > 0) {
5945 $this->
user->getId(),
5946 $this->objCurrentPost->getId(),
5949 $oEditReplyForm->setValuesByArray([
5950 'alias' => $draftObject->getPostUserAlias(),
5951 'subject' => $draftObject->getPostSubject(),
5953 $draftObject->getPostMessage(),
5956 'notify' => $draftObject->isNotificationEnabled() && !$this->
user->isAnonymous(),
5959 'draft_id' => $draft_id
5965 $this->
ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
5966 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
5967 $this->
ctrl->setParameter($this,
'page', (
int) ($this->httpRequest->getQueryParams()[
'page'] ?? 0));
5968 $this->
ctrl->setParameter(
5973 $this->
ctrl->setParameter(
5978 if ($action !==
'editdraft') {
5979 $tpl->
setVariable(
'FORM', $oEditReplyForm->getHTML());
5981 $this->
ctrl->clearParameters($this);
5986 $this->
ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
5989 $this->uiFactory->button()->standard(
5990 $this->
lng->txt(
'reset_limited_view_button'),
5991 $this->
ctrl->getLinkTarget($this,
'resetLimitedView')
5995 return $this->uiRenderer->render(
5998 ->
info($this->
lng->txt(
'reset_limited_view_info'))
5999 ->withButtons($buttons)
6008 $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)
setOffset(int $a_offset)
set dataset offset
renderPostContent(ilTemplate $tpl, ilForumPost $node, string $action, int $pageIndex, int $postIndex)
setDisplayConfirmPostActivation(bool $status=false)
buildThreadForm(bool $isDraft=false)
ILIAS HTTP Services $http
getFirstPostNode(int $tree_id)
static get(string $a_var)
initEditCustomForm(ilPropertyFormGUI $a_form)
isForumNotificationEnabled(int $user_id)
button(string $caption, string $cmd)
performMergeThreadsObject()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilObjectDataCache $ilObjDataCache
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ilObjUser $user=null,)
bool $display_confirm_post_activation
Class Forum core functions for forum.
hasDraftAccess(int|ilForumPostDraft $draft)
static getInstancesByDraftId(int $draft_id)
initializeThreadOffsetAndLimit(ilForumThreadObjectTableGUI $tbl)
static moveMediaObjects(string $post_message, string $source_type, int $source_id, string $target_type, int $target_id, int $direction=0)
ilForumProperties $objProperties
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static lookupForumIdByObjId(int $obj_id)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
setUserId(?int $a_user_id)
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)
setMDB2WhereCondition(string $query_string, array $data_type, array $data_value)
autosaveDraftAsyncObject()
Interface Observer Contains several chained tasks and infos about them.
readonly bool $in_page_editor_style_context
getThreadProperties(ilForumTopic $forum_topic)
static _setRichTextEditorUserState(int $a_state)
Sets the state of the rich text editor visibility for the current user.
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
initializeThreadSortation(ilForumThreadObjectTableGUI $tbl)
Psr Http Message ServerRequestInterface $httpRequest
ILIAS Style Content GUIService $content_style_gui
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilForumTopic $objCurrentTopic
static lookupTitle(int $a_topic_id)
withAdditionalOnLoadCode(Closure $binder)
disableForumNotification(int $user_id)
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
getStickyActionForThread(ilForumTopic $forum_topic, int $ref_id)
publishThreadDraftObject()
addDraftButtonIfDraftsExists(string $cmd)
setDbTable(string $dbTable)
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.
getRequestedThreadSortation()
ensureValidPageForCurrentPosting(array $subtree_nodes, array $pagedPostings, int $pageSize, ilForumPost $firstForumPost)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
isOwner(int $a_user_id=0)
initHeaderAction(?string $sub_type=null, ?int $sub_id=null)
renderSplitButton(ilTemplate $tpl, string $action, bool $is_post, ilForumPost $node, int $pageIndex=0, ilForumPostDraft $draft=null)
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
Class ilForumNotification.
setForumRefId(int $a_ref_id)
setMapper(ilForum $mapper)
static lookupForumIdByRefId(int $ref_id)
addActivationFormModal(ilForumPost $node)
prepareFormOutput(string $a_text)
buildMinimalThreadForm(bool $isDraft=false)
static lookupCreationDate(int $thread_id)
confirmMergeThreadsObject()
convertDate(string $date)
isPostNotificationEnabled()
ilForumSettingsGUI $forum_settings_gui
static createDraftBackup(int $draft_id)
saveThreadAsDraftObject()
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)
info()
description: > Example for rendering a info message box.
mergeThreads(int $source_id, int $target_id)
getCenterColumnHTML()
Get center column.
getSortationViewControl()
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()
setOrderDirection(string $a_order_direction)
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...
getLinkActionForThread(int $ref_id, string $title, string $cmd, int $thread_id=null)
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.
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
countUserArticles(int $a_user_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()
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)
setOrderField(string $a_order_field)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
toggleThreadNotificationObject()
isUserAllowedToDeactivateNotification()
enableForumNotification(int $user_id)
generateThread(ilForumTopic $thread, string $message, bool $notify, bool $notify_posts, bool $status=true, bool $withFirstVisibleEntry=true)
static isSavePostDraftAllowed()
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
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)
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
countActiveUserArticles(int $a_user_id)
retrieveDraftId(bool $from_post=false)
editThreadDraftObject(ilPropertyFormGUI $form=null)
__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
deletePost($postIdOrRecord, bool $raiseEvents=true)
setLimit(int $a_limit=0, int $a_default_limit=0)
confirmDeleteThreadDraftsObject()
publishSelectedDraftObject()
createThread(ilForumPostDraft $draft, bool $createFromDraft=false)
Refactored thread creation to method, refactoring to a separate class should be done in next refactor...
postCensorship(ilObjForum $forum, string $message, int $pos_pk, int $cens=0)
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)
delete(array $posting_ids_to_delete=null)
This describes a Standard Dropdown.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getOverallRatingForObject(int $a_obj_id, string $a_obj_type, int $a_sub_obj_id=null, string $a_sub_obj_type=null, int $a_category_id=null)
Get overall rating for an object.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
static newInstanceByDraftId(int $draft_id)
setForumId(int $a_obj_id)
static getDraftInstancesByUserId(int $user_id)
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getRequestedThreadOffset()
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.
Interface ilCtrlSecurityInterface provides ilCtrl security information.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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()
isThreadNotificationEnabled(int $user_id, int $thread_id)
toggleExplorerNodeStateObject()
ilForumPageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI ilForumPageGUI: ilPublicUserProfi...