102    public function __construct($a_data, $a_id, $a_call_by_reference = 
true, $a_prepare_output = 
true)
 
  106        $this->ctrl = 
$DIC->ctrl();
 
  107        $this->ctrl->saveParameter($this, [
'ref_id', 
'cmdClass']);
 
  109        $this->tpl = 
$DIC->ui()->mainTemplate();
 
  110        $this->lng = 
$DIC->language();
 
  111        $this->httpRequest = 
$DIC->http()->request();
 
  112        $this->uiFactory = 
$DIC->ui()->factory();
 
  113        $this->uiRenderer = 
$DIC->ui()->renderer();
 
  114        $this->globalScreen = 
$DIC->globalScreen();
 
  116        $this->access = 
$DIC->access();
 
  117        $this->ilObjDataCache = 
$DIC[
'ilObjDataCache'];
 
  118        $this->tabs = 
$DIC->tabs();
 
  119        $this->
error = $DIC[
'ilErr'];
 
  121        $this->
user = $DIC->user();
 
  123        $this->toolbar = 
$DIC->toolbar();
 
  124        $this->repositoryTree = 
$DIC->repositoryTree();
 
  126        $this->rbac = 
$DIC->rbac();
 
  127        $this->locator = 
$DIC[
'ilLocator'];
 
  129        $this->tpl->addJavaScript(
'./Services/JavaScript/js/Basic.js');
 
  134        $this->lng->loadLanguageModule(
'forum');
 
  139        $this->is_moderator = $this->access->checkAccess(
'moderate_frm', 
'', 
$_GET[
'ref_id']);
 
  141        $this->objCurrentTopic = 
new ilForumTopic((
int) $this->httpRequest->getQueryParams()[
'thr_pk'] ?? 0, $this->is_moderator);
 
  142        $this->objCurrentPost = 
new ilForumPost((
int) $this->httpRequest->getQueryParams()[
'pos_pk'] ?? 0, $this->is_moderator);
 
  144        $this->requestAction = (string) ($this->httpRequest->getQueryParams()[
'action'] ?? 
'');
 
  150        if (!is_array($forumValues)) {
 
  155        $threadId = $this->httpRequest->getQueryParams()[
'thr_pk'] ?? 0;
 
  156        if ((
int) $threadId > 0 && !is_array($forumValues[(
int) $threadId])) {
 
  157            $forumValues[(int) $threadId] = [];
 
  168            'frm_exp_' . $this->objCurrentTopic->getId(),
 
  171            $this->objCurrentTopic,
 
  172            $this->objCurrentTopic->getFirstPostNode($this->is_moderator)
 
  174        $exp->toggleExplorerNodeState();
 
  185        array $subtree_nodes,
 
  186        array $pagedPostings,
 
  190        if ($firstForumPost->
getId() == $this->objCurrentPost->getId()) {
 
  194        if (count($subtree_nodes) > 0 && $this->objCurrentPost->getId() > 0) {
 
  195            $isCurrentPostingInPage = array_filter($pagedPostings, 
function (
ilForumPost $posting) {
 
  196                return $posting->
getId() == $this->objCurrentPost->getId();
 
  199            if (0 === count($isCurrentPostingInPage)) {
 
  200                $pageOfCurrentPosting = 0;
 
  202                foreach ($subtree_nodes as $node) {
 
  203                    if (
$i > 0 && 0 === 
$i % $pageSize) {
 
  204                        ++$pageOfCurrentPosting;
 
  207                    if ($node->getId() == $this->objCurrentPost->getId()) {
 
  214                $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentTopic->getId());
 
  215                $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
  216                $this->ctrl->setParameter($this, 
'page', $pageOfCurrentPosting);
 
  217                $this->ctrl->setParameter(
 
  222                $this->ctrl->redirect($this, 
'viewThread', $this->objCurrentPost->getId());
 
  234        if ((
int) $thread->
getForumId() !== (
int) $forumId) {
 
  235            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  247            $this->tpl->addJavascript(
'./Modules/Forum/js/autosave.js');
 
  248            $autosave_cmd = 
'autosaveDraftAsync';
 
  249            if ($this->objCurrentPost->getId() == 0 && $this->objCurrentPost->getThreadId() == 0) {
 
  250                $autosave_cmd = 
'autosaveThreadDraftAsync';
 
  252            $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
  253            $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
  254            $draft_id = (int) 
$_GET[
'draft_id'] > 0 ? (
int) 
$_GET[
'draft_id'] : 0;
 
  255            $this->ctrl->setParameter($this, 
'draft_id', $draft_id);
 
  257            $this->tpl->addOnLoadCode(
 
  258                "il.Language.setLangVar('saving', " . json_encode($this->lng->txt(
'saving')) . 
");" 
  261            $this->tpl->addOnLoadCode(
'il.ForumDraftsAutosave.init(' . json_encode(array(
 
  263                    'draft_id' => $draft_id,
 
  264                    'interval' => $interval * 1000,
 
  265                    'url' => $this->ctrl->getFormAction($this, $autosave_cmd, 
'', 
true, 
false),
 
  266                    'selectors' => array(
 
  267                        'form' => 
'#form_' . $form->
getId()
 
  294            strtolower($this->ctrl->getCmd()),
 
  295            array_map(
'strtolower', array(
'createTopLevelPost', 
'saveTopLevelPost', 
'saveTopLevelDraft'))
 
  301        $next_class = $this->ctrl->getNextClass($this);
 
  302        $cmd = $this->ctrl->getCmd();
 
  304        $exclude_cmds = array(
 
  308            'showThreadNotification',
 
  309            'performPostActivation',
 
  310            'askForPostActivation',
 
  311            'askForPostDeactivation',
 
  312            'toggleThreadNotification',
 
  313            'toggleThreadNotificationTab',
 
  318            'createTopLevelPost',
 
  321            'getQuotationHTMLAsynch',
 
  322            'autosaveDraftAsync',
 
  323            'autosaveThreadDraftAsync',
 
  327            'deliverDraftZipFile',
 
  330            'deleteThreadDrafts',
 
  332            'deletePostingDraft',
 
  337        if (!in_array($cmd, $exclude_cmds)) {
 
  341        if (!$this->
getCreationMode() && !$this->ctrl->isAsynch() && $this->access->checkAccess(
 
  347                (
int) 
$_GET[
'ref_id'],
 
  353        switch ($next_class) {
 
  354            case 'ilforumsettingsgui':
 
  359            case 'ilrepositoryobjectsearchgui':
 
  362                $this->tabs->activateTab(
"forums_threads");
 
  363                $this->ctrl->setReturn($this, 
'view');
 
  365                    $this->object->getRefId(),
 
  369                $this->ctrl->forwardCommand($search_gui);
 
  372            case 'ilpermissiongui':
 
  374                $this->ctrl->forwardCommand($perm_gui);
 
  377            case 'ilforumexportgui':
 
  379                $this->ctrl->forwardCommand($fex_gui);
 
  383            case 'ilforummoderatorsgui':
 
  385                $this->ctrl->forwardCommand($fm_gui);
 
  388            case 'ilinfoscreengui':
 
  396            case 'ilpublicuserprofilegui':
 
  398                $add = $this->getUserProfileAdditional((
int) 
$_GET[
'ref_id'], (
int) 
$_GET[
'user']);
 
  399                $profile_gui->setAdditional($add);
 
  400                $ret = $this->ctrl->forwardCommand($profile_gui);
 
  401                $this->tpl->setContent(
$ret);
 
  404            case 'ilobjectcopygui':
 
  407                $this->ctrl->forwardCommand($cp);
 
  411                $this->tabs->activateTab(
'export');
 
  413                $exp->addFormat(
'xml');
 
  414                $this->ctrl->forwardCommand($exp);
 
  418                if (!$this->objProperties->isIsThreadRatingEnabled() || $this->user->isAnonymous()) {
 
  419                    $this->
error->raiseError($this->lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
 
  422                if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
  423                    $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  429                $rating_gui->setObject(
 
  430                    $this->object->getId(),
 
  431                    $this->object->getType(),
 
  432                    $this->objCurrentTopic->getId(),
 
  436                $this->ctrl->setParameter($this, 
'thr_pk', (
int) $this->objCurrentTopic->getId());
 
  437                $this->ctrl->forwardCommand($rating_gui);
 
  440                    $this->object->getId(),
 
  441                    $this->object->getType(),
 
  442                    (
int) $this->objCurrentTopic->getId(),
 
  445                $this->objCurrentTopic->setAverageRating($avg[
'avg']);
 
  446                $this->objCurrentTopic->update();
 
  448                $this->ctrl->redirect($this, 
"showThreads");
 
  451            case 'ilcommonactiondispatchergui':
 
  453                $this->ctrl->forwardCommand($gui);
 
  456            case "ilcontainernewssettingsgui":
 
  460                $this->lng->loadLanguageModule(
'cont');
 
  462                $news_set_gui->setNewsBlockForced(
true);
 
  463                $news_set_gui->setPublicNotification(
true);
 
  464                $this->ctrl->forwardCommand($news_set_gui);
 
  476                if (isset(
$_POST[
'select_cmd2'])) {
 
  480                if (isset(
$_POST[
'selected_cmd']) && 
$_POST[
'selected_cmd'] != 
null) {
 
  482                        'enableAdminForceNoti',
 
  483                        'disableAdminForceNoti',
 
  484                        'enableHideUserToggleNoti',
 
  485                        'disableHideUserToggleNoti' 
  490                    ) ? $cmd = 
$_POST[
'selected_cmd'] : $cmd = 
'performThreadsAction';
 
  491                } elseif (!$cmd && !
$_POST[
'selected_cmd']) {
 
  492                    $cmd = 
'showThreads';
 
  502        if ($cmd != 
'viewThreadObject' && $cmd != 
'showUserObject') {
 
  512        $this->ctrl->setCmd(
'showSummary');
 
  513        $this->ctrl->setCmdClass(
'ilinfoscreengui');
 
  523        $this->forum_settings_gui->getCustomForm($a_form);
 
  531        $this->forum_settings_gui->getCustomValues($a_values);
 
  539        $this->forum_settings_gui->updateCustomValues($a_form);
 
  549        $this->ctrl->setParameter($this, 
'thr_pk', $a_thread_id);
 
  550        $form->setFormAction($this->ctrl->getFormAction($this, 
'updateThread'));
 
  553        $ti_prop->setRequired(
true);
 
  554        $ti_prop->setMaxLength(255);
 
  555        $ti_prop->setSize(50);
 
  556        $form->addItem($ti_prop);
 
  558        $form->addCommandButton(
'updateThread', $this->lng->txt(
'save'));
 
  559        $form->addCommandButton(
'showThreads', $this->lng->txt(
'cancel'));
 
  570        if (!$this->is_moderator) {
 
  571            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  574        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
  575            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  578        $thread = new \ilForumTopic($threadId);
 
  581        $this->tabs->activateTab(
'forums_threads');
 
  585            $form->setValuesByArray(array(
 
  586                'title' => $thread->getSubject()
 
  590        $this->tpl->setContent($form->getHTML());
 
  598        if (!$this->is_moderator) {
 
  599            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  602        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
  603            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  606        if (!$this->objCurrentTopic->getId()) {
 
  614        if (!$form->checkInput()) {
 
  615            $form->setValuesByPost();
 
  620        $this->objCurrentTopic->setSubject($form->getInput(
'title'));
 
  621        $this->objCurrentTopic->updateThreadTitle();
 
  623        ilUtil::sendSuccess($this->lng->txt(
'saved_successfully'));
 
  629        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
  630            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  633        $this->
object->markAllThreadsRead($this->
user->getId());
 
  654        if ($this->objProperties->getThreadSorting() == 1 && $this->is_moderator) {
 
  655            $this->tabs->addSubTabTarget(
 
  657                $this->ctrl->getLinkTarget($this, 
'showThreads'),
 
  661                $subtab == 
'showThreads' ? 
true : 
false 
  663            $this->tabs->addSubTabTarget(
 
  665                $this->ctrl->getLinkTarget($this, 
'sortThreads'),
 
  669                $subtab == 
'sortThreads' ? 
true : 
false 
  676        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
  677            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
  680        $cmd = $this->ctrl->getCmd();
 
  681        $frm = $this->
object->Forum;
 
  682        $frm->setForumId($this->object->getId());
 
  683        $frm->setForumRefId($this->object->getRefId());
 
  684        $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', array(
'integer'), array($frm->getForumId()));
 
  686        $threadsTemplate = new \ilTemplate(
 
  687            'tpl.forums_threads_liste.html',
 
  693        if ((
int) strlen($this->confirmation_gui_html)) {
 
  694            $threadsTemplate->setVariable(
'CONFIRMATION_GUI', $this->confirmation_gui_html);
 
  698        if ($this->access->checkAccess(
'add_thread', 
'', $this->object->getRefId()) && !$this->hideToolbar()) {
 
  700            $btn->setUrl($this->ctrl->getLinkTarget($this, 
'createThread'));
 
  701            $btn->setCaption(
'forums_new_thread');
 
  702            $this->toolbar->addStickyItem($btn);
 
  706        if (!$this->
user->isAnonymous() && !(
int) strlen($this->confirmation_gui_html)) {
 
  707            $this->toolbar->addButton(
 
  708                $this->lng->txt(
'forums_mark_read'),
 
  709                $this->ctrl->getLinkTarget($this, 
'markAllRead'),
 
  713            $this->ctrl->clearParameters($this);
 
  718                $this->
user->getId(),
 
  721            if (count($drafts) > 0) {
 
  725                    $this->access->checkAccess(
'add_thread', 
'', $this->object->getRefId())
 
  727                $draftsTable->setData($drafts);
 
  728                $threadsTemplate->setVariable(
'THREADS_DRAFTS_TABLE', $draftsTable->getHTML());
 
  733        $topicData = $frm->getOneTopic();
 
  736            $frm->setDbTable(
'frm_data');
 
  737            $frm->setMDB2WhereCondition(
'top_pk = %s ', array(
'integer'), array($topicData[
'top_pk']));
 
  738            $frm->updateVisits($topicData[
'top_pk']);
 
  740            if (!in_array($cmd, array(
'showThreads', 
'sortThreads'))) {
 
  741                $cmd = 
'showThreads';
 
  748                (
int) 
$_GET[
'ref_id'],
 
  751                $this->
settings->get(
'forum_overview')
 
  754            $tbl->setMapper($frm)->fetchData();
 
  755            $threadsTemplate->setVariable(
'THREADS_TABLE', $tbl->getHTML());
 
  758        $this->tpl->setPermanentLink($this->object->getType(), $this->object->getRefId(), 
'', 
'_top');
 
  760        $this->tpl->setContent($threadsTemplate->get());
 
  776        $frm = $this->object->Forum;
 
  778        foreach ($drafts as $draft) {
 
  780            $filesOfDraft = $tmp_file_obj->getFilesOfPost();
 
  781            ksort($filesOfDraft);
 
  783            if (count($filesOfDraft)) {
 
  784                if ($action !== 
'showdraft') {
 
  785                    foreach ($filesOfDraft as $file) {
 
  786                        $tpl->setCurrentBlock(
'attachment_download_row');
 
  787                        $this->ctrl->setParameter($this, 
'draft_id', $tmp_file_obj->getDraftId());
 
  788                        $this->ctrl->setParameter($this, 
'file', $file[
'md5']);
 
  789                        $tpl->setVariable(
'HREF_DOWNLOAD', $this->ctrl->getLinkTarget($this, 
'viewThread'));
 
  790                        $tpl->setVariable(
'TXT_FILENAME', $file[
'name']);
 
  791                        $this->ctrl->setParameter($this, 
'file', 
'');
 
  792                        $this->ctrl->setParameter($this, 
'draft_id', 
'');
 
  793                        $this->ctrl->clearParameters($this);
 
  794                        $tpl->parseCurrentBlock();
 
  797                    $tpl->setCurrentBlock(
'attachments');
 
  798                    $tpl->setVariable(
'TXT_ATTACHMENTS_DOWNLOAD', $this->lng->txt(
'forums_attachments'));
 
  803                    if (count($filesOfDraft) > 1) {
 
  805                        $download_zip_button->setCaption($this->lng->txt(
'download'), 
false);
 
  806                        $this->ctrl->setParameter($this, 
'draft_id', $draft->getDraftId());
 
  807                        $download_zip_button->setUrl($this->ctrl->getLinkTarget($this, 
'deliverDraftZipFile'));
 
  808                        $this->ctrl->setParameter($this, 
'draft_id', 
'');
 
  809                        $tpl->setVariable(
'DOWNLOAD_ZIP', $download_zip_button->render());
 
  811                    $tpl->parseCurrentBlock();
 
  820                (
int) $this->httpRequest->getQueryParams()[
'page'],
 
  824            $rowCol = 
'tblrowmarked';
 
  825            $tpl->setVariable(
'ROWCOL', 
' ' . $rowCol);
 
  826            $tpl->setVariable(
'DEPTH', (
int) ($referencePosting->
getDepth() - 1));
 
  828            $this->ctrl->setParameter($this, 
'pos_pk', $referencePosting->
getId());
 
  829            $this->ctrl->setParameter($this, 
'thr_pk', $referencePosting->
getThreadId());
 
  830            $this->ctrl->setParameter($this, 
'draft_id', $draft->getDraftId());
 
  832            $backurl = urlencode($this->ctrl->getLinkTarget($this, 
'viewThread', $referencePosting->
getId()));
 
  834            $this->ctrl->setParameter($this, 
'backurl', $backurl);
 
  835            $this->ctrl->setParameter($this, 
'thr_pk', $referencePosting->
getThreadId());
 
  836            $this->ctrl->setParameter($this, 
'user', $draft->getPostDisplayUserId());
 
  839                $draft->getPostAuthorId(),
 
  840                $draft->getPostDisplayUserId(),
 
  841                $draft->getPostUserAlias(),
 
  844                    'href' => $this->ctrl->getLinkTarget($this, 
'showUser')
 
  848            $this->ctrl->clearParameters($this);
 
  850            if ($authorinfo->hasSuffix()) {
 
  851                $tpl->setVariable(
'AUTHOR', $authorinfo->getSuffix());
 
  852                $tpl->setVariable(
'USR_NAME', $draft->getPostUserAlias());
 
  854                $tpl->setVariable(
'AUTHOR', $authorinfo->getLinkedAuthorShortName());
 
  855                if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized()) {
 
  856                    $tpl->setVariable(
'USR_NAME', $authorinfo->getAuthorName(
true));
 
  859            $tpl->setVariable(
'DRAFT_ANCHOR', 
'draft_' . $draft->getDraftId());
 
  861            $tpl->setVariable(
'USR_IMAGE', $authorinfo->getProfilePicture());
 
  864                (
int) 
$_GET[
'ref_id'],
 
  865                $draft->getPostAuthorId()
 
  867                if ($authorinfo->getAuthor()->getGender() == 
'f') {
 
  868                    $tpl->setVariable(
'ROLE', $this->lng->txt(
'frm_moderator_f'));
 
  869                } elseif ($authorinfo->getAuthor()->getGender() == 
'm') {
 
  870                    $tpl->setVariable(
'ROLE', $this->lng->txt(
'frm_moderator_m'));
 
  871                } elseif ($authorinfo->getAuthor()->getGender() == 
'n') {
 
  872                    $tpl->setVariable(
'ROLE', $this->lng->txt(
'frm_moderator_n'));
 
  876            if ($draft->getUpdateUserId() > 0) {
 
  877                $draft->setPostUpdate($draft->getPostUpdate());
 
  879                $this->ctrl->setParameter($this, 
'backurl', $backurl);
 
  880                $this->ctrl->setParameter($this, 
'thr_pk', $referencePosting->
getThreadId());
 
  881                $this->ctrl->setParameter($this, 
'user', $referencePosting->
getUpdateUserId());
 
  882                $this->ctrl->setParameter($this, 
'draft_id', $draft->getDraftId());
 
  885                    $draft->getPostAuthorId(),
 
  886                    $draft->getUpdateUserId(),
 
  887                    $draft->getPostUserAlias(),
 
  890                        'href' => $this->ctrl->getLinkTarget($this, 
'showUser')
 
  894                $this->ctrl->clearParameters($this);
 
  898                    $this->lng->txt(
'edited_on') . 
': ' . $frm->convertDate($draft->getPostUpdate()) . 
' - ' . strtolower($this->lng->txt(
'by'))
 
  900                $tpl->setVariable(
'UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
 
  901                if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
 
  902                    $tpl->setVariable(
'UPDATE_USR_NAME', $authorinfo->getAuthorName(
true));
 
  906            $draft->setPostMessage($frm->prepareText($draft->getPostMessage()));
 
  908            $tpl->setVariable(
'SUBJECT', $draft->getPostSubject());
 
  909            $tpl->setVariable(
'POST_DATE', $frm->convertDate($draft->getPostDate()));
 
  911            if (!$referencePosting->
isCensored() || ($this->objCurrentPost->getId() == $referencePosting->
getId() && $action === 
'censor')) {
 
  914                    $spanClass = 
'moderator';
 
  917                if ($draft->getPostMessage() == strip_tags($draft->getPostMessage())) {
 
  919                    $draft->setPostMessage(nl2br($draft->getPostMessage()));
 
  922                if ($spanClass != 
"") {
 
  926                            $draft->getPostMessage(),
 
  935            if (!$this->objCurrentTopic->isClosed() && $action === 
'deletedraft') {
 
  936                if (!$this->
user->isAnonymous() && (
int) $draft->getDraftId() === (
int) 
$_GET[
'draft_id']) {
 
  938                    $tpl->setVariable(
'FORM', $this->getDeleteDraftFormHTML());
 
  940            } elseif ($action === 
'editdraft' && (
int) $draft->getDraftId() === (
int) 
$_GET[
'draft_id']) {
 
  943                if (!$this->objCurrentTopic->isClosed() && in_array($this->requestAction, [
'showdraft', 
'editdraft'])) {
 
  944                    $this->renderPostingForm(
$tpl, $frm, $referencePosting, $this->requestAction);
 
  947                $tpl->setVariable(
'EDIT_DRAFT_ANCHOR', 
'draft_edit_' . $draft->getDraftId());
 
  948                $tpl->setVariable(
'DRAFT_FORM', $oEditReplyForm->getHTML() . $this->modal_history);
 
  951            $tpl->parseCurrentBlock();
 
  970        $forumObj = $this->object;
 
  971        $frm = $this->
object->Forum;
 
  975        $filesOfPost = $fileDataOfForum->getFilesOfPost();
 
  977        if (count($filesOfPost) > 0) {
 
  978            if ($node->
getId() != $this->objCurrentPost->getId() || $action !== 
'showedit') {
 
  979                foreach ($filesOfPost as $file) {
 
  980                    $tpl->setCurrentBlock(
'attachment_download_row');
 
  981                    $this->ctrl->setParameter($this, 
'pos_pk', $node->
getId());
 
  982                    $this->ctrl->setParameter($this, 
'file', $file[
'md5']);
 
  983                    $tpl->setVariable(
'HREF_DOWNLOAD', $this->ctrl->getLinkTarget($this, 
'viewThread'));
 
  984                    $tpl->setVariable(
'TXT_FILENAME', $file[
'name']);
 
  985                    $this->ctrl->clearParameters($this);
 
  986                    $tpl->parseCurrentBlock();
 
  989                $tpl->setCurrentBlock(
'attachments');
 
  990                $tpl->setVariable(
'TXT_ATTACHMENTS_DOWNLOAD', $this->lng->txt(
'forums_attachments'));
 
  995                if (count($filesOfPost) > 1) {
 
  997                    $download_zip_button->setCaption($this->lng->txt(
'download'), 
false);
 
  998                    $this->ctrl->setParameter($this, 
'pos_pk', $node->
getId());
 
  999                    $download_zip_button->setUrl($this->ctrl->getLinkTarget($this, 
'deliverZipFile'));
 
 1001                    $tpl->setVariable(
'DOWNLOAD_ZIP', $download_zip_button->render());
 
 1004                $tpl->parseCurrentBlock();
 
 1007        $this->renderSplitButton(
$tpl, $action, 
true, $node, $pageIndex);
 
 1009        $tpl->setVariable(
'POST_ANKER', $node->
getId());
 
 1010        $tpl->setVariable(
'TXT_PERMA_LINK', $this->lng->txt(
'perma_link'));
 
 1011        $tpl->setVariable(
'PERMA_TARGET', 
'_top');
 
 1014        if (!$node->
isActivated() && !$this->objCurrentTopic->isClosed() && $this->is_moderator) {
 
 1015            $rowCol = 
'ilPostingNeedsActivation';
 
 1016        } elseif ($this->objProperties->getMarkModeratorPosts() == 1) {
 
 1019                $rowCol = 
'ilModeratorPosting';
 
 1021                $rowCol = 
'ilModeratorPosting';
 
 1026            (!in_array($action, [
'delete', 
'censor']) && !$this->displayConfirmPostActivation()) ||
 
 1027            $this->objCurrentPost->getId() != $node->
getId()
 
 1029            $tpl->setVariable(
'ROWCOL', 
' ' . $rowCol);
 
 1031            $rowCol = 
'tblrowmarked';
 
 1035            if ($action !== 
'censor') {
 
 1036                $tpl->setVariable(
'TXT_CENSORSHIP_ADVICE', $this->lng->txt(
'post_censored_comment_by_moderator'));
 
 1039            $rowCol = 
'tblrowmarked';
 
 1042        $tpl->setVariable(
'ROWCOL', 
' ' . $rowCol);
 
 1043        $tpl->setVariable(
'DEPTH', (
int) ($node->
getDepth() - 1));
 
 1045            $tpl->setVariable(
'POST_NOT_ACTIVATED_YET', $this->lng->txt(
'frm_post_not_activated_yet'));
 
 1048        $this->ctrl->setParameter($this, 
'pos_pk', $node->
getId());
 
 1049        $this->ctrl->setParameter($this, 
'thr_pk', $node->
getThreadId());
 
 1050        $backurl = urlencode($this->ctrl->getLinkTarget($this, 
'viewThread', $node->
getId()));
 
 1051        $this->ctrl->clearParameters($this);
 
 1053        $this->ctrl->setParameter($this, 
'backurl', $backurl);
 
 1054        $this->ctrl->setParameter($this, 
'thr_pk', $node->
getThreadId());
 
 1062                'href' => $this->ctrl->getLinkTarget($this, 
'showUser')
 
 1065        $this->ctrl->clearParameters($this);
 
 1067        if ($authorinfo->hasSuffix()) {
 
 1068            if (!$authorinfo->isDeleted()) {
 
 1069                $tpl->setVariable(
'USR_NAME', $authorinfo->getAlias());
 
 1071            $tpl->setVariable(
'AUTHOR', $authorinfo->getSuffix());
 
 1073            if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized()) {
 
 1074                $tpl->setVariable(
'USR_NAME', $authorinfo->getAuthorName(
true));
 
 1076            $tpl->setVariable(
'AUTHOR', $authorinfo->getLinkedAuthorShortName());
 
 1079        $tpl->setVariable(
'USR_IMAGE', $authorinfo->getProfilePicture());
 
 1082        if ($authorinfo->getAuthor()->getId() && $isModerator) {
 
 1083            $authorRole = $this->lng->txt(
'frm_moderator_n');
 
 1084            if (is_string($authorinfo->getAuthor()->getGender()) && strlen($authorinfo->getAuthor()->getGender()) > 0) {
 
 1085                $authorRole = $this->lng->txt(
'frm_moderator_' . $authorinfo->getAuthor()->getGender());
 
 1087            $tpl->setVariable(
'ROLE', $authorRole);
 
 1093            $this->ctrl->setParameter($this, 
'backurl', $backurl);
 
 1094            $this->ctrl->setParameter($this, 
'thr_pk', $node->
getThreadId());
 
 1106                    'href' => $this->ctrl->getLinkTarget($this, 
'showUser')
 
 1109            $this->ctrl->clearParameters($this);
 
 1113                $this->lng->txt(
'edited_on') . 
': ' . $frm->convertDate($node->
getChangeDate()) . 
' - ' . strtolower($this->lng->txt(
'by'))
 
 1115            $tpl->setVariable(
'UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
 
 1116            if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
 
 1117                $tpl->setVariable(
'UPDATE_USR_NAME', $authorinfo->getAuthorName(
true));
 
 1126            $this->ctrl->setParameter($this, 
'pos_pk', $node->
getId());
 
 1127            $this->ctrl->setParameter($this, 
'thr_pk', $node->
getThreadId());
 
 1128            $this->ctrl->setParameter($this, 
'page', $pageIndex);
 
 1129            $this->ctrl->setParameter(
 
 1135            $mark_post_target = $this->ctrl->getLinkTarget($this, 
'markPostRead', $node->
getId());
 
 1139                "<a href=\"" . $mark_post_target . 
"\"><b>" . $node->
getSubject() . 
"</b></a>" 
 1145        if (!$node->
isCensored() || ($this->objCurrentPost->getId() == $node->
getId() && $action === 
'censor')) {
 
 1148                $spanClass = 
'moderator';
 
 1157            if ($spanClass !== 
'') {
 
 1160                    "<span class=\"" . $spanClass . 
"\">" .
 
 1171        $tpl->parseCurrentBlock();
 
 1179        \ilUtil::sendSuccess($this->lng->txt(
'frm_added'), 
true);
 
 1180        $this->ctrl->setParameter($this, 
'ref_id', $a_new_object->
getRefId());
 
 1181        $this->ctrl->redirect($this, 
'createThread');
 
 1186        $this->
ilHelp->setScreenIdComponent(
"frm");
 
 1188        $this->ctrl->setParameter($this, 
'ref_id', $this->ref_id);
 
 1195            'enableForumNotification',
 
 1196            'disableForumNotification',
 
 1198            'performMoveThreads',
 
 1199            'cancelMoveThreads',
 
 1200            'performThreadsAction',
 
 1204            'confirmDeleteThreads',
 
 1207            'performMergeThreads' 
 1210        (in_array($this->ctrl->getCmd(), $active)) ? $force_active = 
true : $force_active = 
false;
 
 1212        if ($this->access->checkAccess(
 
 1217            $this->tabs->addTarget(
 
 1219                $this->ctrl->getLinkTarget($this, 
'showThreads'),
 
 1220                $this->ctrl->getCmd(),
 
 1228        if ($this->access->checkAccess(
'visible', 
'', $this->ref_id) || $this->access->checkAccess(
 
 1233            $force_active = ($this->ctrl->getNextClass() == 
'ilinfoscreengui' || strtolower(
$_GET[
'cmdClass']) == 
'ilnotegui') ? 
true : 
false;
 
 1234            $this->tabs->addTarget(
 
 1236                $this->ctrl->getLinkTargetByClass(array(
'ilobjforumgui', 
'ilinfoscreengui'), 
'showSummary'),
 
 1237                array(
'showSummary', 
'infoScreen'),
 
 1244        if ($this->access->checkAccess(
'write', 
'', $this->ref_id)) {
 
 1245            $force_active = ($this->ctrl->getCmd() == 
'edit') ? 
true : 
false;
 
 1246            $this->tabs->addTarget(
 
 1248                $this->ctrl->getLinkTarget($this, 
'edit'),
 
 1256        if ($this->access->checkAccess(
'write', 
'', $this->ref_id)) {
 
 1257            $this->tabs->addTarget(
 
 1259                $this->ctrl->getLinkTargetByClass(
'ilForumModeratorsGUI', 
'showModerators'),
 
 1265        if ($this->
settings->get(
'enable_fora_statistics', 
false)) {
 
 1266            $hasStatisticsAccess = $this->access->checkAccess(
'write', 
'', $this->ref_id);
 
 1267            if (!$hasStatisticsAccess) {
 
 1268                $hasStatisticsAccess = (
 
 1269                    $this->objProperties->isStatisticEnabled() &&
 
 1270                    $this->access->checkAccess(
'read', 
'', $this->ref_id)
 
 1274            if ($hasStatisticsAccess) {
 
 1275                $force_active = ($this->ctrl->getCmd() == 
'showStatistics') ? 
true : 
false;
 
 1276                $this->tabs->addTarget(
 
 1278                    $this->ctrl->getLinkTarget($this, 
'showStatistics'),
 
 1287        if ($this->access->checkAccess(
'write', 
'', $this->object->getRefId())) {
 
 1288            $this->tabs->addTarget(
'export', $this->ctrl->getLinkTargetByClass(
'ilexportgui', 
''), 
'', 
'ilexportgui');
 
 1291        if ($this->access->checkAccess(
'edit_permission', 
'', $this->ref_id)) {
 
 1292            $this->tabs->addTarget(
 
 1294                $this->ctrl->getLinkTargetByClass(array(get_class($this), 
'ilpermissiongui'), 
'perm'),
 
 1295                array(
'perm', 
'info', 
'owner'),
 
 1304        if (!$this->
settings->get(
'enable_fora_statistics', 
false)) {
 
 1305            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1309        if (!$this->access->checkAccess(
'read', 
'', (
int) 
$_GET[
'ref_id'])) {
 
 1310            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1314        if (!$this->objProperties->isStatisticEnabled()) {
 
 1316            if ($this->access->checkAccess(
'write', 
'', (
int) 
$_GET[
'ref_id'])) {
 
 1317                ilUtil::sendInfo($this->lng->txt(
'frm_statistics_disabled_for_participants'));
 
 1319                $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1323        $this->
object->Forum->setForumId($this->object->getId());
 
 1326        $tbl->setId(
'il_frm_statistic_table_' . (
int) 
$_GET[
'ref_id']);
 
 1328            $this->lng->txt(
'statistic'),
 
 1330            $this->lng->txt(
'obj_' . $this->object->getType())
 
 1333        $data = $this->
object->Forum->getUserStatistic($this->is_moderator);
 
 1336        foreach (
$data as $row) {
 
 1337            $result[$counter][
'ranking'] = $row[0];
 
 1338            $result[$counter][
'login'] = $row[1];
 
 1339            $result[$counter][
'lastname'] = $row[2];
 
 1340            $result[$counter][
'firstname'] = $row[3];
 
 1346        $this->tpl->setContent($tbl->getHTML());
 
 1349    public static function _goto($a_target, $a_thread = 0, $a_posting = 0)
 
 1353        $ilAccess = 
$DIC->access();
 
 1357        if ($ilAccess->checkAccess(
'read', 
'', $a_target)) {
 
 1358            if ($a_thread != 0) {
 
 1360                if ($objTopic->getFrmObjId() &&
 
 1363                    foreach ($ref_ids as $ref_id) {
 
 1364                        if ($ilAccess->checkAccess(
'read', 
'', $ref_id)) {
 
 1365                            $new_ref_id = $ref_id;
 
 1370                    if (isset($new_ref_id) && $new_ref_id != $a_target) {
 
 1371                        $DIC->ctrl()->redirectToURL(
 
 1372                            ILIAS_HTTP_PATH . 
'/goto.php?target=frm_' . $new_ref_id . 
'_' . $a_thread . 
'_' . $a_posting
 
 1377                $DIC->ctrl()->setParameterByClass(ilObjForumGUI::class, 
'ref_id', (
int) $a_target);
 
 1378                if (is_numeric($a_thread)) {
 
 1379                    $DIC->ctrl()->setParameterByClass(ilObjForumGUI::class, 
'thr_pk', (
int) $a_thread);
 
 1381                if (is_numeric($a_posting)) {
 
 1382                    $DIC->ctrl()->setParameterByClass(ilObjForumGUI::class, 
'pos_pk', (
int) $a_posting);
 
 1384                $DIC->ctrl()->redirectByClass(
 
 1385                    [ilRepositoryGUI::class, self::class],
 
 1387                    is_numeric($a_posting) ? (
int) $a_posting : 
'' 
 1390                $_GET[
'ref_id'] = $a_target;
 
 1391                $_GET[
'baseClass'] = 
'ilRepositoryGUI';
 
 1392                include_once(
'ilias.php');
 
 1395        } elseif ($ilAccess->checkAccess(
'visible', 
'', $a_target)) {
 
 1396            $DIC->ctrl()->setParameterByClass(ilInfoScreenGUI::class, 
'ref_id', $a_target);
 
 1397            $DIC->ctrl()->redirectByClass(
 
 1399                    ilRepositoryGUI::class,
 
 1401                    ilInfoScreenGUI::class
 
 1405        } elseif ($ilAccess->checkAccess(
'read', 
'', ROOT_FOLDER_ID)) {
 
 1406            $_GET[
'target'] = 
'';
 
 1407            $_GET[
'ref_id'] = ROOT_FOLDER_ID;
 
 1409                $lng->txt(
'msg_no_perm_read_item'),
 
 1412            $_GET[
'baseClass'] = 
'ilRepositoryGUI';
 
 1413            include_once(
'ilias.php');
 
 1422        if (!$this->is_moderator) {
 
 1423            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1426        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 1427            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1430        if (!isset(
$_POST[
'thread_ids']) || !is_array(
$_POST[
'thread_ids'])) {
 
 1432            return $this->showThreadsObject();
 
 1435        $forumObj = 
new ilObjForum($this->object->getRefId());
 
 1436        $this->objProperties->setObjId($forumObj->getId());
 
 1440        $success_message = 
"forums_thread_deleted";
 
 1441        if (count(
$_POST[
'thread_ids']) > 1) {
 
 1442            $success_message = 
"forums_threads_deleted";
 
 1446        if (isset(
$_POST[
'thread_ids']) && is_array(
$_POST[
'thread_ids'])) {
 
 1447            $threadIds = 
$_POST[
'thread_ids'];
 
 1451        array_walk($threadIds, 
function ($threadId) use (&$threads) {
 
 1452            $thread = new \ilForumTopic($threadId);
 
 1453            $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $thread);
 
 1455            $threads[] = $thread;
 
 1458        foreach ($threads as $thread) {
 
 1459            $frm->setForumId($forumObj->getId());
 
 1460            $frm->setForumRefId($forumObj->getRefId());
 
 1462            $first_node = $frm->getFirstPostNode($thread->getId());
 
 1463            if ((
int) $first_node[
'pos_pk']) {
 
 1464                $frm->deletePost($first_node[
'pos_pk']);
 
 1468        $this->ctrl->redirect($this, 
'showThreads');
 
 1473        if (!isset(
$_POST[
'thread_ids']) || !is_array(
$_POST[
'thread_ids'])) {
 
 1475            return $this->showThreadsObject();
 
 1478        if (!$this->is_moderator) {
 
 1479            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1482        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 1483            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1487        array_walk(
$_POST[
'thread_ids'], 
function ($threadId) use (&$threads) {
 
 1488            $thread = new \ilForumTopic($threadId);
 
 1489            $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $thread);
 
 1491            $threads[] = $thread;
 
 1496        $c_gui->setFormAction($this->ctrl->getFormAction($this, 
'performDeleteThreads'));
 
 1497        $c_gui->setHeaderText($this->lng->txt(
'frm_sure_delete_threads'));
 
 1498        $c_gui->setCancel($this->lng->txt(
'cancel'), 
'showThreads');
 
 1499        $c_gui->setConfirm($this->lng->txt(
'confirm'), 
'performDeleteThreads');
 
 1501        foreach ($threads as $thread) {
 
 1502            $c_gui->addItem(
'thread_ids[]', $thread->getId(), $thread->getSubject());
 
 1505        $this->confirmation_gui_html = $c_gui->getHTML();
 
 1507        $this->hideToolbar(
true);
 
 1509        return $this->tpl->setContent($c_gui->getHTML());
 
 1514        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 1515            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1518        $draftIds = array_filter((array) ($this->httpRequest->getParsedBody()[
'draft_ids'] ?? []));
 
 1519        if (0 === count($draftIds)) {
 
 1521            $this->showThreadsObject();
 
 1526        $confirmation->setFormAction($this->ctrl->getFormAction($this, 
'deleteThreadDrafts'));
 
 1527        $confirmation->setHeaderText($this->lng->txt(
'sure_delete_drafts'));
 
 1528        $confirmation->setCancel($this->lng->txt(
'cancel'), 
'showThreads');
 
 1529        $confirmation->setConfirm($this->lng->txt(
'confirm'), 
'deleteThreadDrafts');
 
 1531        foreach ($draftIds as $draftId) {
 
 1532            if (array_key_exists($draftId, $instances)) {
 
 1533                $confirmation->addItem(
'draft_ids[]', $draftId, $instances[$draftId]->getPostSubject());
 
 1537        $this->tpl->setContent($confirmation->getHTML());
 
 1540    public function prepareThreadScreen(
ilObjForum $a_forum_obj)
 
 1542        $this->
ilHelp->setScreenIdComponent(
"frm");
 
 1544        $this->tpl->loadStandardTemplate();
 
 1548        $this->tpl->setTitleIcon(ilObject::_getIcon(
"", 
"big", 
"frm"));
 
 1550        $this->tabs->setBackTarget(
 
 1551            $this->lng->txt(
'all_topics'),
 
 1552            'ilias.php?baseClass=ilRepositoryGUI&ref_id=' . 
$_GET[
'ref_id']
 
 1558        $frm = $a_forum_obj->Forum;
 
 1559        $frm->setForumId($a_forum_obj->
getId());
 
 1564        if (!$this->is_moderator) {
 
 1565            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1568        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 1569            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1572        $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $this->objCurrentPost->getThread());
 
 1574        $this->objCurrentPost->activatePost();
 
 1575        $GLOBALS[
'ilAppEventHandler']->raise(
 
 1579                'ref_id' => $this->object->getRefId(),
 
 1580                'post' => $this->objCurrentPost
 
 1585        $this->viewThreadObject();
 
 1588    private function deletePostingObject()
 
 1591            !$this->objCurrentTopic->isClosed() && (
 
 1592                $this->is_moderator ||
 
 1593                ($this->objCurrentPost->isOwner($this->user->getId()) && !$this->objCurrentPost->hasReplies())
 
 1595            !$this->user->isAnonymous()
 
 1597            $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $this->objCurrentPost->getThread());
 
 1599            $oForumObjects = $this->getForumObjects();
 
 1601            $forumObj = $oForumObjects[
'forumObj'];
 
 1604            $frm->setForumId($forumObj->getId());
 
 1605            $frm->setForumRefId($forumObj->getRefId());
 
 1606            $dead_thr = $frm->deletePost($this->objCurrentPost->getId());
 
 1609            if ($dead_thr == $this->objCurrentTopic->getId()) {
 
 1610                $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', array(
'integer'), array($forumObj->getId()));
 
 1611                $topicData = $frm->getOneTopic();
 
 1613                if ($topicData[
'top_num_threads'] > 0) {
 
 1614                    $this->ctrl->redirect($this, 
'showThreads');
 
 1616                    $this->ctrl->redirect($this, 
'createThread');
 
 1620            $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentTopic->getId());
 
 1621            $this->ctrl->redirect($this, 
'viewThread');
 
 1624        $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1629        $this->deleteSelectedDraft();
 
 1634        $this->handleCensorship(
true);
 
 1639        $this->handleCensorship();
 
 1642    private function handleCensorship($wasRevoked = 
false)
 
 1644        if (!$this->objCurrentTopic->isClosed() && $this->is_moderator) {
 
 1645            $message = $this->handleFormInput(
$_POST[
'formData'][
'cens_message']);
 
 1646            $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $this->objCurrentPost->getThread());
 
 1648            $oForumObjects = $this->getForumObjects();
 
 1650            $frm = $oForumObjects[
'frm'];
 
 1653                $frm->postCensorship(
$message, $this->objCurrentPost->getId());
 
 1654                ilUtil::sendSuccess($this->lng->txt(
'frm_censorship_revoked'));
 
 1656                $frm->postCensorship(
$message, $this->objCurrentPost->getId(), 1);
 
 1657                ilUtil::sendSuccess($this->lng->txt(
'frm_censorship_applied'));
 
 1660            $this->viewThreadObject();
 
 1664        $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1669        if (!$this->is_moderator) {
 
 1670            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1673        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 1674            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1677        $this->setDisplayConfirmPostActivation(
true);
 
 1679        $this->viewThreadObject();
 
 1684        $this->display_confirm_post_activation = $status;
 
 1689        return $this->display_confirm_post_activation;
 
 1694        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 1695            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1698        $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $this->objCurrentTopic);
 
 1700        if ($this->objCurrentTopic->isNotificationEnabled($this->user->getId())) {
 
 1701            $this->objCurrentTopic->disableNotification($this->
user->getId());
 
 1704            $this->objCurrentTopic->enableNotification($this->
user->getId());
 
 1708        $this->viewThreadObject();
 
 1713        if (!$this->is_moderator) {
 
 1714            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1717        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 1718            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 1721        $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $this->objCurrentTopic);
 
 1723        if ($this->objCurrentTopic->isSticky()) {
 
 1724            $this->objCurrentTopic->unmakeSticky();
 
 1726            $this->objCurrentTopic->makeSticky();
 
 1729        $this->viewThreadObject();
 
 1734        $this->requestAction = 
'';
 
 1735        if (isset(
$_POST[
'draft_id']) && (
int) 
$_POST[
'draft_id'] > 0) {
 
 1737            $draft->deleteDraftsByDraftIds(array((
int) 
$_POST[
'draft_id']));
 
 1740        $this->viewThreadObject();
 
 1745        $this->requestAction = 
'';
 
 1746        if (isset(
$_GET[
'draft_id']) && (
int) 
$_GET[
'draft_id'] > 0) {
 
 1749                $history_obj->getFirstAutosaveByDraftId((
int) 
$_GET[
'draft_id']);
 
 1751                $draft->setPostSubject($history_obj->getPostSubject());
 
 1752                $draft->setPostMessage($history_obj->getPostMessage());
 
 1755                    $history_obj->getPostMessage(),
 
 1757                    $history_obj->getHistoryId(),
 
 1759                    $draft->getDraftId()
 
 1762                $draft->updateDraft();
 
 1764                $history_obj->deleteHistoryByDraftIds(array($draft->getDraftId()));
 
 1767        $this->ctrl->clearParameters($this);
 
 1768        $this->viewThreadObject();
 
 1771    public function getDeleteFormHTML()
 
 1774        $form_tpl = 
new ilTemplate(
'tpl.frm_delete_post_form.html', 
true, 
true, 
'Modules/Forum');
 
 1775        $form_tpl->setVariable(
'ANKER', $this->objCurrentPost->getId());
 
 1776        $form_tpl->setVariable(
'SPACER', 
'<hr noshade="noshade" width="100%" size="1" align="center" />');
 
 1777        $form_tpl->setVariable(
'TXT_DELETE', $this->lng->txt(
'forums_info_delete_post'));
 
 1778        $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 1779        $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 1780        $this->ctrl->setParameter(
 
 1785        $form_tpl->setVariable(
'FORM_ACTION', $this->ctrl->getFormAction($this, 
'viewThread'));
 
 1786        $this->ctrl->clearParameters($this);
 
 1787        $form_tpl->setVariable(
'CMD_CONFIRM', 
'deletePosting');
 
 1788        $form_tpl->setVariable(
'CMD_CANCEL', 
'viewThread');
 
 1789        $form_tpl->setVariable(
'CANCEL_BUTTON', $this->lng->txt(
'cancel'));
 
 1790        $form_tpl->setVariable(
'CONFIRM_BUTTON', $this->lng->txt(
'confirm'));
 
 1792        return $form_tpl->get();
 
 1795    public function getDeleteDraftFormHTML()
 
 1798        $form_tpl = 
new ilTemplate(
'tpl.frm_delete_post_form.html', 
true, 
true, 
'Modules/Forum');
 
 1799        $form_tpl->setVariable(
'SPACER', 
'<hr noshade="noshade" width="100%" size="1" align="center" />');
 
 1800        $form_tpl->setVariable(
'TXT_DELETE', $this->lng->txt(
'forums_info_delete_draft'));
 
 1801        $this->ctrl->setParameter($this, 
'draft_id', (
int) 
$_GET[
'draft_id']);
 
 1802        $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 1803        $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 1804        $this->ctrl->setParameter(
 
 1809        $form_tpl->setVariable(
'FORM_ACTION', $this->ctrl->getFormAction($this, 
'viewThread'));
 
 1810        $this->ctrl->clearParameters($this);
 
 1811        $form_tpl->setVariable(
'CMD_CONFIRM', 
'deletePostingDraft');
 
 1812        $form_tpl->setVariable(
'CMD_CANCEL', 
'viewThread');
 
 1813        $form_tpl->setVariable(
'CANCEL_BUTTON', $this->lng->txt(
'cancel'));
 
 1814        $form_tpl->setVariable(
'CONFIRM_BUTTON', $this->lng->txt(
'confirm'));
 
 1816        return $form_tpl->get();
 
 1821        $form_tpl = 
new ilTemplate(
'tpl.frm_activation_post_form.html', 
true, 
true, 
'Modules/Forum');
 
 1822        $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 1823        $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 1824        $this->ctrl->setParameter(
 
 1829        $form_tpl->setVariable(
'FORM_ACTION', $this->ctrl->getFormAction($this, 
'performPostActivation'));
 
 1830        $form_tpl->setVariable(
'SPACER', 
'<hr noshade="noshade" width="100%" size="1" align="center" />');
 
 1831        $form_tpl->setVariable(
'ANCHOR', $this->objCurrentPost->getId());
 
 1832        $form_tpl->setVariable(
'TXT_ACT', $this->lng->txt(
'activate_post_txt'));
 
 1833        $form_tpl->setVariable(
'CONFIRM_BUTTON', $this->lng->txt(
'activate_only_current'));
 
 1834        $form_tpl->setVariable(
'CMD_CONFIRM', 
'performPostActivation');
 
 1835        $form_tpl->setVariable(
'CANCEL_BUTTON', $this->lng->txt(
'cancel'));
 
 1836        $form_tpl->setVariable(
'CMD_CANCEL', 
'viewThread');
 
 1837        $this->ctrl->clearParameters($this);
 
 1839        return $form_tpl->get();
 
 1844        $frm = $this->
object->Forum;
 
 1845        $form_tpl = 
new ilTemplate(
'tpl.frm_censorship_post_form.html', 
true, 
true, 
'Modules/Forum');
 
 1847        $form_tpl->setVariable(
'ANCHOR', $this->objCurrentPost->getId());
 
 1848        $form_tpl->setVariable(
'SPACER', 
'<hr noshade="noshade" width="100%" size="1" align="center" />');
 
 1849        $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 1850        $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 1851        $this->ctrl->setParameter(
 
 1856        $form_tpl->setVariable(
'FORM_ACTION', $this->ctrl->getFormAction($this, 
'viewThread'));
 
 1857        $this->ctrl->clearParameters($this);
 
 1858        $form_tpl->setVariable(
'TXT_CENS_MESSAGE', $this->lng->txt(
'forums_the_post'));
 
 1859        $form_tpl->setVariable(
'TXT_CENS_COMMENT', $this->lng->txt(
'forums_censor_comment') . 
':');
 
 1860        $form_tpl->setVariable(
'CENS_MESSAGE', $frm->prepareText($this->objCurrentPost->getCensorshipComment(), 2));
 
 1862        if ($this->objCurrentPost->isCensored()) {
 
 1863            $form_tpl->setVariable(
'TXT_CENS', $this->lng->txt(
'forums_info_censor2_post'));
 
 1864            $form_tpl->setVariable(
'YES_BUTTON', $this->lng->txt(
'confirm'));
 
 1865            $form_tpl->setVariable(
'NO_BUTTON', $this->lng->txt(
'cancel'));
 
 1866            $form_tpl->setVariable(
'CMD_REVOKE_CENSORSHIP', 
'revokeCensorship');
 
 1867            $form_tpl->setVariable(
'CMD_CANCEL_REVOKE_CENSORSHIP', 
'viewThread');
 
 1869            $form_tpl->setVariable(
'TXT_CENS', $this->lng->txt(
'forums_info_censor_post'));
 
 1870            $form_tpl->setVariable(
'CANCEL_BUTTON', $this->lng->txt(
'cancel'));
 
 1871            $form_tpl->setVariable(
'CONFIRM_BUTTON', $this->lng->txt(
'confirm'));
 
 1872            $form_tpl->setVariable(
'CMD_ADD_CENSORSHIP', 
'addCensorship');
 
 1873            $form_tpl->setVariable(
'CMD_CANCEL_ADD_CENSORSHIP', 
'viewThread');
 
 1876        return $form_tpl->get();
 
 1882    private function initReplyEditForm()
 
 1887        $isReply = in_array($this->requestAction, [
'showreply', 
'ready_showreply']);
 
 1888        $isDraft = in_array($this->requestAction, [
'publishDraft', 
'editdraft']);
 
 1891        $oForumObjects = $this->getForumObjects();
 
 1892        $frm = $oForumObjects[
'frm'];
 
 1893        $oFDForum = $oForumObjects[
'file_obj'];
 
 1896        $this->replyEditForm->setId(
'id_showreply');
 
 1897        $this->replyEditForm->setTableWidth(
'100%');
 
 1898        $cancel_cmd = 
'cancelPost';
 
 1899        if (in_array($this->requestAction, [
'showreply', 
'ready_showreply'])) {
 
 1900            $this->ctrl->setParameter($this, 
'action', 
'ready_showreply');
 
 1901        } elseif (in_array($this->requestAction, [
'showdraft', 
'editdraft'])) {
 
 1902            $this->ctrl->setParameter($this, 
'action', $this->requestAction);
 
 1903            $this->ctrl->setParameter($this, 
'draft_id', (
int) 
$_GET[
'draft_id']);
 
 1905            $this->ctrl->setParameter($this, 
'action', 
'ready_showedit');
 
 1908        $this->ctrl->setParameter($this, 
'page', (
int) $this->httpRequest->getQueryParams()[
'page']);
 
 1909        $this->ctrl->setParameter(
 
 1914        $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 1915        $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 1916        if ($this->isTopLevelReplyCommand()) {
 
 1917            $this->replyEditForm->setFormAction(
 
 1918                $this->ctrl->getFormAction($this, 
'saveTopLevelPost'),
 
 1921        } elseif (in_array($this->requestAction, [
'publishDraft', 
'editdraft'])) {
 
 1922            $this->replyEditForm->setFormAction(
 
 1923                $this->ctrl->getFormAction($this, 
'publishDraft'),
 
 1924                $this->objCurrentPost->getId()
 
 1927            $this->replyEditForm->setFormAction(
 
 1928                $this->ctrl->getFormAction($this, 
'savePost'),
 
 1929                $this->objCurrentPost->getId()
 
 1932        $this->ctrl->clearParameters($this);
 
 1935            $this->replyEditForm->setTitle($this->lng->txt(
'forums_your_reply'));
 
 1936        } elseif ($isDraft) {
 
 1937            $this->replyEditForm->setTitle($this->lng->txt(
'forums_edit_draft'));
 
 1939            $this->replyEditForm->setTitle($this->lng->txt(
'forums_edit_post'));
 
 1943            $this->isWritingWithPseudonymAllowed() &&
 
 1944            in_array($this->requestAction, [
'showreply', 
'ready_showreply', 
'editdraft'])
 
 1946            $oAnonymousNameGUI = 
new ilTextInputGUI($this->lng->txt(
'forums_your_name'), 
'alias');
 
 1947            $oAnonymousNameGUI->setMaxLength(64);
 
 1948            $oAnonymousNameGUI->setInfo($this->lng->txt(
'forums_use_alias'));
 
 1950            $this->replyEditForm->addItem($oAnonymousNameGUI);
 
 1953        $oSubjectGUI = 
new ilTextInputGUI($this->lng->txt(
'forums_subject'), 
'subject');
 
 1954        $oSubjectGUI->setMaxLength(255);
 
 1955        $oSubjectGUI->setRequired(
true);
 
 1957        if ($this->objProperties->getSubjectSetting() == 
'empty_subject') {
 
 1958            $oSubjectGUI->setInfo($this->lng->txt(
'enter_new_subject'));
 
 1961        $this->replyEditForm->addItem($oSubjectGUI);
 
 1964            $isReply ? $this->lng->txt(
'forums_your_reply') : $this->lng->txt(
'forums_edit_post'),
 
 1967        $oPostGUI->setRequired(
true);
 
 1968        $oPostGUI->setRows(15);
 
 1969        $oPostGUI->setUseRte(
true);
 
 1970        $oPostGUI->addPlugin(
'latex');
 
 1971        $oPostGUI->addButton(
'latex');
 
 1972        $oPostGUI->addButton(
'pastelatex');
 
 1975            !$this->isTopLevelReplyCommand() && (
 
 1976                ($isReply && $this->objCurrentPost->getDepth() >= 2) ||
 
 1977                (!$isDraft && !$isReply && $this->objCurrentPost->getDepth() > 2) ||
 
 1978                ($isDraft && $this->objCurrentPost->getDepth() >= 2)
 
 1981        if ($quotingAllowed) {
 
 1982            $oPostGUI->addPlugin(
'ilfrmquote');
 
 1983            $oPostGUI->addButton(
'ilFrmQuoteAjaxCall');
 
 1986        $oPostGUI->removePlugin(
'advlink');
 
 1987        $oPostGUI->setRTERootBlockElement(
'');
 
 1988        $oPostGUI->usePurifier(
true);
 
 1989        $oPostGUI->disableButtons(array(
 
 2006        if (in_array($this->requestAction, [
'showreply', 
'ready_showreply', 
'showdraft', 
'editdraft'])) {
 
 2007            $oPostGUI->setRTESupport(
 
 2008                $this->
user->getId(),
 
 2011                'tpl.tinymce_frm_post.js',
 
 2016            $oPostGUI->setRTESupport(
 
 2017                $this->objCurrentPost->getId(),
 
 2020                'tpl.tinymce_frm_post.js',
 
 2028        $this->replyEditForm->addItem($oPostGUI);
 
 2032        if ($this->rbac->system()->checkAccess(
'internal_mail', $umail->getMailObjectReferenceId()) &&
 
 2033            !$frm->isThreadNotificationEnabled($this->user->getId(), $this->objCurrentPost->getThreadId()) &&
 
 2034            !$this->objProperties->isAnonymized()) {
 
 2035            $oNotificationGUI = 
new ilCheckboxInputGUI($this->lng->txt(
'forum_direct_notification'), 
'notify');
 
 2036            $oNotificationGUI->setInfo($this->lng->txt(
'forum_notify_me'));
 
 2038            $this->replyEditForm->addItem($oNotificationGUI);
 
 2041        if ($this->objProperties->isFileUploadAllowed()) {
 
 2042            $oFileUploadGUI = 
new ilFileWizardInputGUI($this->lng->txt(
'forums_attachments_add'), 
'userfile');
 
 2043            $oFileUploadGUI->setFilenames(array(0 => 
''));
 
 2044            $this->replyEditForm->addItem($oFileUploadGUI);
 
 2048            $this->
user->isAnonymous() &&
 
 2049            !$this->user->isCaptchaVerified() &&
 
 2050            ilCaptchaUtil::isActiveForForum()
 
 2052            $captcha = 
new ilCaptchaInputGUI($this->lng->txt(
'cont_captcha_code'), 
'captcha_code');
 
 2053            $captcha->setRequired(
true);
 
 2054            $this->replyEditForm->addItem($captcha);
 
 2057        $attachments_of_node = $oFDForum->getFilesOfPost();
 
 2058        if (count($attachments_of_node) && in_array($this->requestAction, [
'showedit', 
'ready_showedit'])) {
 
 2060            foreach ($oFDForum->getFilesOfPost() as $file) {
 
 2062                $oAttachmentGUI->setValue($file[
'md5']);
 
 2063                $oExistingAttachmentsGUI->addOption($oAttachmentGUI);
 
 2065            $this->replyEditForm->addItem($oExistingAttachmentsGUI);
 
 2069            if (in_array($this->requestAction, [
'showdraft', 
'editdraft'])) {
 
 2071                $draftInfoGUI->setValue(sprintf(
 
 2072                    $this->lng->txt(
'autosave_draft_info'),
 
 2075                $this->replyEditForm->addItem($draftInfoGUI);
 
 2076            } elseif (!in_array($this->requestAction, [
'showedit', 
'ready_showedit'])) {
 
 2078                $draftInfoGUI->setValue(sprintf(
 
 2079                    $this->lng->txt(
'autosave_post_draft_info'),
 
 2082                $this->replyEditForm->addItem($draftInfoGUI);
 
 2085        $selected_draft_id = (int) 
$_GET[
'draft_id'];
 
 2087            $this->
user->getId(),
 
 2088            $this->objCurrentPost->getId(),
 
 2091        if ($draftObj->getDraftId() > 0) {
 
 2093            if (count($oFDForumDrafts->getFilesOfPost())) {
 
 2095                    $this->lng->txt(
'forums_delete_file'),
 
 2098                foreach ($oFDForumDrafts->getFilesOfPost() as $file) {
 
 2100                    $oAttachmentGUI->setValue($file[
'md5']);
 
 2101                    $oExistingAttachmentsGUI->addOption($oAttachmentGUI);
 
 2103                $this->replyEditForm->addItem($oExistingAttachmentsGUI);
 
 2107        if ($this->isTopLevelReplyCommand()) {
 
 2108            $this->replyEditForm->addCommandButton(
'saveTopLevelPost', $this->lng->txt(
'create'));
 
 2110            $this->replyEditForm->addCommandButton(
'publishDraft', $this->lng->txt(
'publish'));
 
 2112            $this->replyEditForm->addCommandButton(
'savePost', $this->lng->txt(
'save'));
 
 2115        if (isset(
$_GET[
'draft_id']) && (
int) 
$_GET[
'draft_id'] > 0) {
 
 2116            $auto_save_draft_id = (int) 
$_GET[
'draft_id'];
 
 2118        $hidden_draft_id->setValue($auto_save_draft_id);
 
 2119        $this->replyEditForm->addItem($hidden_draft_id);
 
 2121        if (in_array($this->requestAction, [
'showreply', 
'ready_showreply', 
'editdraft'])) {
 
 2124            if (array_key_exists(
'show_rte', 
$_POST)) {
 
 2129                if ($quotingAllowed) {
 
 2130                    $this->replyEditForm->addCommandButton(
'quotePost', $this->lng->txt(
'forum_add_quote'));
 
 2135                !$this->
user->isAnonymous() &&
 
 2136                in_array($this->requestAction, [
'editdraft', 
'showreply', 
'ready_showreply']) &&
 
 2140                    $this->decorateWithAutosave($this->replyEditForm);
 
 2143                if ($this->requestAction == 
'editdraft') {
 
 2144                    $this->replyEditForm->addCommandButton(
'updateDraft', $this->lng->txt(
'save_message'));
 
 2145                } elseif ($this->isTopLevelReplyCommand()) {
 
 2146                    $this->replyEditForm->addCommandButton(
'saveTopLevelDraft', $this->lng->txt(
'save_message'));
 
 2148                    $this->replyEditForm->addCommandButton(
'saveAsDraft', $this->lng->txt(
'save_message'));
 
 2151                $cancel_cmd = 
'cancelDraft';
 
 2154        $this->replyEditForm->addCommandButton($cancel_cmd, $this->lng->txt(
'cancel'));
 
 2162        if (
null === $this->replyEditForm) {
 
 2163            $this->initReplyEditForm();
 
 2166        return $this->replyEditForm;
 
 2174        if (isset(
$_GET[
'draft_id']) && (
int) 
$_GET[
'draft_id'] > 0 && !$this->
user->isAnonymous()
 
 2177                $this->
user->getId(),
 
 2178                $this->objCurrentPost->getId(),
 
 2179                (
int) 
$_GET[
'draft_id']
 
 2184            $this->ctrl->setParameter($this, 
'action', 
'editdraft');
 
 2185            $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 2186            $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentTopic->getId());
 
 2187            $this->ctrl->setParameter($this, 
'draft_id', $draft_obj->getDraftId());
 
 2188            $this->ctrl->setParameter($this, 
'page', 1);
 
 2189            $this->ctrl->setParameter(
 
 2194            $this->ctrl->redirect($this, 
'editDraft');
 
 2196            $this->viewThreadObject();
 
 2206        $this->savePostObject();
 
 2212        if (isset(
$_GET[
'draft_id']) && (
int) 
$_GET[
'draft_id'] > 0) {
 
 2213            $this->publishDraftObject(
false);
 
 2219        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 2220            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 2223        if (!$this->access->checkAccess(
'add_reply', 
'', $this->object->getRefId())) {
 
 2224            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 2227        if (!$this->objCurrentTopic->getId()) {
 
 2229            $this->ctrl->redirect($this);
 
 2232        if ($this->objCurrentTopic->isClosed()) {
 
 2234            $this->ctrl->redirect($this);
 
 2237        if (!$this->objCurrentPost->getId()) {
 
 2238            $this->requestAction = 
'';
 
 2240            $this->viewThreadObject();
 
 2244        $post_id = $this->objCurrentPost->getId();
 
 2248        if ($use_replyform) {
 
 2249            $oReplyEditForm = $this->getReplyEditForm();
 
 2250            if (!$oReplyEditForm->checkInput()) {
 
 2251                $oReplyEditForm->setValuesByPost();
 
 2252                return $this->viewThreadObject();
 
 2254            $post_subject = $oReplyEditForm->getInput(
'subject');
 
 2255            $post_message = $oReplyEditForm->getInput(
'message');
 
 2258            $post_subject = $draft_obj->getPostSubject();
 
 2259            $post_message = $draft_obj->getPostMessage();
 
 2263        if ($draft_obj->getDraftId() > 0) {
 
 2265            $oForumObjects = $this->getForumObjects();
 
 2266            $frm = $oForumObjects[
'frm'];
 
 2267            $frm->setMDB2WhereCondition(
' top_frm_fk = %s ', array(
'integer'), array($frm->getForumId()));
 
 2271            $send_activation_mail = 0;
 
 2273            if ($this->objProperties->isPostActivationEnabled()) {
 
 2274                if (!$this->is_moderator) {
 
 2276                    $send_activation_mail = 1;
 
 2277                } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
 
 2282            $newPost = $frm->generatePost(
 
 2283                $draft_obj->getForumId(),
 
 2284                $draft_obj->getThreadId(),
 
 2285                $this->user->getId(),
 
 2286                $draft_obj->getPostDisplayUserId(),
 
 2288                $draft_obj->getPostId(),
 
 2289                (
int) $draft_obj->getNotify(),
 
 2290                $this->handleFormInput($post_subject, 
false),
 
 2291                $draft_obj->getPostUserAlias(),
 
 2294                $send_activation_mail
 
 2297            $this->
object->markPostRead(
 
 2298                $this->
user->getId(),
 
 2299                (
int) $this->objCurrentTopic->getId(),
 
 2300                (
int) $this->objCurrentPost->getId()
 
 2305            foreach ($uploadedObjects as $mob) {
 
 2311            if ($this->objProperties->isFileUploadAllowed()) {
 
 2312                $file = $_FILES[
'userfile'];
 
 2313                if (is_array($file) && !empty($file)) {
 
 2314                    $tmp_file_obj = 
new ilFileDataForum($this->object->getId(), $newPost);
 
 2315                    $tmp_file_obj->storeUploadedFile($file);
 
 2322                $oFDForumDrafts->moveFilesOfDraft($oFDForum->getForumPath(), $newPost);
 
 2323                $oFDForumDrafts->delete();
 
 2327                $GLOBALS[
'ilAppEventHandler']->raise(
 
 2331                        'draftObj' => $draft_obj,
 
 2332                        'obj_id' => $this->object->getId(),
 
 2333                        'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
 
 2337            $draft_obj->deleteDraft();
 
 2339            $GLOBALS[
'ilAppEventHandler']->raise(
 
 2343                    'ref_id' => $this->object->getRefId(),
 
 2345                    'notify_moderators' => (
bool) $send_activation_mail
 
 2350            if (!$this->is_moderator && !$status) {
 
 2351                $message .= $this->lng->txt(
'forums_post_needs_to_be_activated');
 
 2353                $message .= $this->lng->txt(
'forums_post_new_entry');
 
 2356            $_SESSION[
'frm'][(int) 
$_GET[
'thr_pk']][
'openTreeNodes'][] = (
int) $this->objCurrentPost->getId();
 
 2358            $this->ctrl->clearParameters($this);
 
 2359            ilUtil::sendSuccess(
$message, 
true);
 
 2360            $this->ctrl->setParameter($this, 
'pos_pk', $newPost);
 
 2361            $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 2363            $this->ctrl->redirect($this, 
'viewThread');
 
 2370    public function savePostObject()
 
 2372        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 2373            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 2376        if (!$this->objCurrentTopic->getId()) {
 
 2378            $this->ctrl->redirect($this);
 
 2381        if ($this->objCurrentTopic->isClosed()) {
 
 2383            $this->ctrl->redirect($this);
 
 2386        $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $this->objCurrentTopic);
 
 2388        if (!isset(
$_POST[
'del_file']) || !is_array(
$_POST[
'del_file'])) {
 
 2389            $_POST[
'del_file'] = array();
 
 2392        $oReplyEditForm = $this->getReplyEditForm();
 
 2393        if ($oReplyEditForm->checkInput()) {
 
 2394            if (!$this->objCurrentPost->getId()) {
 
 2395                $this->requestAction = 
'';
 
 2397                $this->viewThreadObject();
 
 2401            $this->doCaptchaCheck();
 
 2404            $oForumObjects = $this->getForumObjects();
 
 2408            $forumObj = $oForumObjects[
'forumObj'];
 
 2412            $frm = $oForumObjects[
'frm'];
 
 2413            $frm->setMDB2WhereCondition(
' top_frm_fk = %s ', array(
'integer'), array($frm->getForumId()));
 
 2414            $topicData = $frm->getOneTopic();
 
 2417            if ($this->requestAction == 
'ready_showreply') {
 
 2418                if (!$this->access->checkAccess(
'add_reply', 
'', (
int) 
$_GET[
'ref_id'])) {
 
 2419                    $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 2424                $send_activation_mail = 0;
 
 2426                if ($this->objProperties->isPostActivationEnabled()) {
 
 2427                    if (!$this->is_moderator) {
 
 2429                        $send_activation_mail = 1;
 
 2430                    } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
 
 2435                if ($this->isWritingWithPseudonymAllowed()) {
 
 2436                    if (!strlen($oReplyEditForm->getInput(
'alias'))) {
 
 2437                        $user_alias = $this->lng->txt(
'forums_anonymous');
 
 2439                        $user_alias = $oReplyEditForm->getInput(
'alias');
 
 2441                    $display_user_id = 0;
 
 2443                    $user_alias = $this->
user->getLogin();
 
 2444                    $display_user_id = $this->
user->getId();
 
 2447                $newPost = $frm->generatePost(
 
 2448                    $topicData[
'top_pk'],
 
 2449                    $this->objCurrentTopic->getId(),
 
 2450                    $this->user->getId(),
 
 2453                    $this->objCurrentPost->getId(),
 
 2454                    (
int) $oReplyEditForm->getInput(
'notify'),
 
 2455                    $this->handleFormInput($oReplyEditForm->getInput(
'subject'), 
false),
 
 2459                    $send_activation_mail
 
 2465                        $draft_id = 
$_POST[
'draft_id']; 
 
 2467                    $draft_obj = 
new ilForumPostDraft($this->
user->getId(), $this->objCurrentPost->getId(), $draft_id);
 
 2469                        $draft_obj->deleteDraft();
 
 2474                $this->
object->markPostRead(
 
 2475                    $this->
user->getId(),
 
 2476                    (
int) $this->objCurrentTopic->getId(),
 
 2477                    (
int) $this->objCurrentPost->getId()
 
 2482                    $oReplyEditForm->getInput(
'message'),
 
 2484                    $this->user->getId(),
 
 2489                if ($this->objProperties->isFileUploadAllowed()) {
 
 2491                    $file = $_FILES[
'userfile'];
 
 2492                    if (is_array($file) && !empty($file)) {
 
 2493                        $oFDForum->storeUploadedFile($file);
 
 2497                $GLOBALS[
'ilAppEventHandler']->raise(
 
 2501                        'ref_id' => $this->object->getRefId(),
 
 2503                        'notify_moderators' => (
bool) $send_activation_mail
 
 2508                if (!$this->is_moderator && !$status) {
 
 2509                    $message .= $this->lng->txt(
'forums_post_needs_to_be_activated');
 
 2511                    $message .= $this->lng->txt(
'forums_post_new_entry');
 
 2514                ilUtil::sendSuccess(
$message, 
true);
 
 2515                $this->ctrl->clearParameters($this);
 
 2516                $this->ctrl->setParameter($this, 
'post_created_below', $this->objCurrentPost->getId());
 
 2517                $this->ctrl->setParameter($this, 
'pos_pk', $newPost);
 
 2518                $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 2519                $this->ctrl->redirect($this, 
'viewThread');
 
 2521                if ((!$this->is_moderator &&
 
 2522                        !$this->objCurrentPost->isOwner($this->user->getId())) || $this->objCurrentPost->isCensored() ||
 
 2523                    $this->user->isAnonymous()) {
 
 2524                    $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 2527                $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $this->objCurrentPost->getThread());
 
 2532                foreach ($oldMediaObjects as $oldMob) {
 
 2534                    foreach ($curMediaObjects as $curMob) {
 
 2535                        if ($oldMob == $curMob) {
 
 2550                $old_status_was_active = $this->objCurrentPost->isActivated();
 
 2554                $send_activation_mail = 0;
 
 2556                if ($this->objProperties->isPostActivationEnabled()) {
 
 2557                    if (!$this->is_moderator) {
 
 2559                        $send_activation_mail = 1;
 
 2560                    } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
 
 2564                $this->objCurrentPost->setStatus($status);
 
 2566                $this->objCurrentPost->setSubject($this->handleFormInput($oReplyEditForm->getInput(
'subject'), 
false));
 
 2568                    $oReplyEditForm->getInput(
'message'),
 
 2571                $this->objCurrentPost->setNotification((
int) $oReplyEditForm->getInput(
'notify'));
 
 2572                $this->objCurrentPost->setChangeDate(date(
'Y-m-d H:i:s'));
 
 2573                $this->objCurrentPost->setUpdateUserId($this->
user->getId());
 
 2576                if ($this->objCurrentPost->update()) {
 
 2577                    $this->objCurrentPost->reload();
 
 2584                        $this->objCurrentPost->getId(),
 
 2589                        $news_item->setTitle($this->objCurrentPost->getSubject());
 
 2590                        $news_item->setContent(
 
 2592                                $this->objCurrentPost->getMessage(),
 
 2597                        if ($this->objCurrentPost->getMessage() != strip_tags($this->objCurrentPost->getMessage())) {
 
 2598                            $news_item->setContentHtml(
true);
 
 2600                            $news_item->setContentHtml(
false);
 
 2602                        $news_item->update();
 
 2605                    $oFDForum = $oForumObjects[
'file_obj'];
 
 2607                    $file2delete = $oReplyEditForm->getInput(
'del_file');
 
 2608                    if (is_array($file2delete) && count($file2delete)) {
 
 2609                        $oFDForum->unlinkFilesByMD5Filenames($file2delete);
 
 2612                    if ($this->objProperties->isFileUploadAllowed()) {
 
 2613                        $file = $_FILES[
'userfile'];
 
 2614                        if (is_array($file) && !empty($file)) {
 
 2615                            $oFDForum->storeUploadedFile($file);
 
 2619                    $GLOBALS[
'ilAppEventHandler']->raise(
 
 2623                            'ref_id' => $this->object->getRefId(),
 
 2624                            'post' => $this->objCurrentPost,
 
 2625                            'notify_moderators' => (
bool) $send_activation_mail,
 
 2626                            'old_status_was_active' => (
bool) $old_status_was_active
 
 2630                    ilUtil::sendSuccess($this->lng->txt(
'forums_post_modified'), 
true);
 
 2633                $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 2634                $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 2635                $this->ctrl->setParameter($this, 
'viewmode', 
$_SESSION[
'viewmode']);
 
 2636                $this->ctrl->redirect($this, 
'viewThread');
 
 2639            $this->requestAction = substr($this->requestAction, 6);
 
 2641        return $this->viewThreadObject();
 
 2646        if (
null === $a_flag) {
 
 2647            return $this->hideToolbar;
 
 2650        $this->hideToolbar = $a_flag;
 
 2656        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 2657            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 2660        if (!is_array(
$_POST[
'del_file'])) {
 
 2661            $_POST[
'del_file'] = array();
 
 2664        if ($this->objCurrentTopic->isClosed()) {
 
 2665            $this->requestAction = 
'';
 
 2666            return $this->viewThreadObject();
 
 2669        $oReplyEditForm = $this->getReplyEditForm();
 
 2672        $oReplyEditForm->getItemByPostVar(
'subject')->setRequired(
false);
 
 2673        $oReplyEditForm->getItemByPostVar(
'message')->setRequired(
false);
 
 2675        $oReplyEditForm->checkInput();
 
 2678        $oReplyEditForm->getItemByPostVar(
'subject')->setRequired(
true);
 
 2679        $oReplyEditForm->getItemByPostVar(
'message')->setRequired(
true);
 
 2681        $this->requestAction = 
'showreply';
 
 2683        $this->viewThreadObject();
 
 2686    public function getQuotationHTMLAsynchObject()
 
 2688        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 2689            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 2692        $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $this->objCurrentPost->getThread());
 
 2694        $oForumObjects = $this->getForumObjects();
 
 2698        $frm = $oForumObjects[
'frm'];
 
 2701            $this->objCurrentPost->getPosAuthorId(),
 
 2702            $this->objCurrentPost->getDisplayUserId(),
 
 2703            $this->objCurrentPost->getUserAlias(),
 
 2704            $this->objCurrentPost->getImportName()
 
 2708            $this->objCurrentPost->getMessage(),
 
 2710            $authorinfo->getAuthorName()
 
 2718        if (
null === $this->forumObjects) {
 
 2719            $forumObj = $this->object;
 
 2720            $file_obj = 
new ilFileDataForum($forumObj->getId(), $this->objCurrentPost->getId());
 
 2721            $frm = $forumObj->Forum;
 
 2722            $frm->setForumId($forumObj->getId());
 
 2723            $frm->setForumRefId($forumObj->getRefId());
 
 2725            $this->forumObjects[
'forumObj'] = $forumObj;
 
 2726            $this->forumObjects[
'frm'] = $frm;
 
 2727            $this->forumObjects[
'file_obj'] = $file_obj;
 
 2730        return $this->forumObjects;
 
 2736            $_SESSION[
'viewmode'] = $this->objProperties->getDefaultView();
 
 2739        if (isset(
$_GET[
'viewmode']) && (
int) 
$_GET[
'viewmode'] !== (
int) 
$_SESSION[
'viewmode']) {
 
 2748            $_SESSION[
'viewmode'] = $this->objProperties->getDefaultView();
 
 2752    public function viewThreadObject()
 
 2754        $this->checkUsersViewMode();
 
 2756        $bottom_toolbar = clone $this->toolbar;
 
 2757        $bottom_toolbar_split_button_items = [];
 
 2760        if (!isset(
$_SESSION[
'thread_control'][
'old'])) {
 
 2769        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 2770            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 2774        if (isset($this->httpRequest->getQueryParams()[
'page'])) {
 
 2775            $pageIndex = max((
int) $this->httpRequest->getQueryParams()[
'page'], $pageIndex);
 
 2778        $firstNodeInThread = $this->objCurrentTopic->getFirstPostNode();
 
 2780        $toolContext = $this->globalScreen
 
 2796        $oForumObjects = $this->getForumObjects();
 
 2798        $forumObj = $oForumObjects[
'forumObj'];
 
 2800        $frm = $oForumObjects[
'frm'];
 
 2802        $file_obj = $oForumObjects[
'file_obj'];
 
 2804        $selected_draft_id = (int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
 
 2806        if (isset($this->httpRequest->getQueryParams()[
'file'])) {
 
 2807            $file_obj_for_delivery = $file_obj;
 
 2811            $file_obj_for_delivery->deliverFile(\
ilUtil::stripSlashes($this->httpRequest->getQueryParams()[
'file']));
 
 2814        if (!$this->objCurrentTopic->getId()) {
 
 2815            $this->ctrl->redirect($this, 
'showThreads');
 
 2818        $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $this->objCurrentTopic);
 
 2821        $append = 
'_' . $this->objCurrentTopic->getId() .
 
 2822            ($this->objCurrentPost->getId() ? 
'_' . $this->objCurrentPost->getId() : 
'');
 
 2823        $this->tpl->setLoginTargetPar(
'frm_' . 
$_GET[
'ref_id'] . $append);
 
 2826        if (!in_array($this->requestAction, [
'showreply', 
'showedit'])) {
 
 2829                foreach (
$mobs as $mob) {
 
 2836            } 
catch (Exception 
$e) {
 
 2840        if (!$this->getCreationMode() && $this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 2842                (
int) $this->object->getRefId(),
 
 2849        $forumObj->updateLastAccess($this->
user->getId(), (
int) $this->objCurrentTopic->getId());
 
 2851        $this->prepareThreadScreen($forumObj);
 
 2853        $threadContentTemplate = new \ilTemplate(
 
 2854            'tpl.forums_threads_view.html',
 
 2860        if (isset($this->httpRequest->getQueryParams()[
'anchor'])) {
 
 2861            $threadContentTemplate->setVariable(
'JUMP2ANCHOR_ID', (
int) $this->httpRequest->getQueryParams()[
'anchor']);
 
 2865        if ($this->isHierarchicalView()) {
 
 2866            $orderField = 
'frm_posts_tree.rgt';
 
 2867            $this->objCurrentTopic->setOrderDirection(
'DESC');
 
 2870                $currentSortation = (in_array(
$_SESSION[
'viewmode'], [
 
 2873                ]) ? 
$_SESSION[
'viewmode'] : $currentSortation);
 
 2876            $orderField = 
'frm_posts.pos_date';
 
 2877            $this->objCurrentTopic->setOrderDirection(
 
 2882        $currentViewMode = $this->objProperties->getDefaultView();
 
 2884            $currentViewMode = (in_array(
$_SESSION[
'viewmode'], [
 
 2889        $threadContentTemplate->setVariable(
'LIST_TYPE', $this->viewModeOptions[$currentViewMode]);
 
 2891        $numberOfPostings = 0;
 
 2894        $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', array(
'integer'), array($frm->getForumId()));
 
 2896        if ($firstNodeInThread) {
 
 2897            $this->objCurrentTopic->updateVisits();
 
 2899            $this->tpl->setTitle($this->lng->txt(
'forums_thread') . 
" \"" . $this->objCurrentTopic->getSubject() . 
"\"");
 
 2901            $this->locator->addRepositoryItems();
 
 2902            $this->locator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, 
""), 
"_top");
 
 2903            $this->tpl->setLocator();
 
 2906                !$this->
user->isAnonymous() &&
 
 2907                $forumObj->getCountUnread($this->
user->getId(), (
int) $this->objCurrentTopic->getId(), 
true)
 
 2909                $this->ctrl->setParameter($this, 
'mark_read', 
'1');
 
 2910                $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentTopic->getId());
 
 2913                $mark_thr_read_button->setCaption(
'forums_mark_read');
 
 2914                $mark_thr_read_button->setUrl($this->ctrl->getLinkTarget($this, 
'viewThread'));
 
 2917                $bottom_toolbar_split_button_items[] = $mark_thr_read_button;
 
 2919                $this->ctrl->clearParameters($this);
 
 2923            $this->ctrl->setParameterByClass(
'ilforumexportgui', 
'print_thread', $this->objCurrentTopic->getId());
 
 2924            $this->ctrl->setParameterByClass(
'ilforumexportgui', 
'thr_top_fk', $this->objCurrentTopic->getForumId());
 
 2927            $print_thr_button->setCaption(
'forums_print_thread');
 
 2928            $print_thr_button->setUrl($this->ctrl->getLinkTargetByClass(
'ilforumexportgui', 
'printThread'));
 
 2930            $bottom_toolbar_split_button_items[] = $print_thr_button;
 
 2932            $this->ctrl->clearParametersByClass(
'ilforumexportgui');
 
 2934            $this->addHeaderAction();
 
 2936            if (isset($this->httpRequest->getQueryParams()[
'mark_read'])) {
 
 2937                $forumObj->markThreadRead($this->
user->getId(), (
int) $this->objCurrentTopic->getId());
 
 2941            $this->objCurrentTopic->setOrderField($orderField);
 
 2942            $subtree_nodes = $this->objCurrentTopic->getPostTree($firstNodeInThread);
 
 2944            if (!$this->isTopLevelReplyCommand() &&
 
 2946                !$this->objCurrentTopic->isClosed() &&
 
 2947                $this->access->checkAccess(
'add_reply', 
'', (
int) 
$_GET[
'ref_id'])
 
 2950                $reply_button->setPrimary(
true);
 
 2951                $reply_button->setCaption(
'add_new_answer');
 
 2952                $this->ctrl->setParameter($this, 
'action', 
'showreply');
 
 2953                $this->ctrl->setParameter($this, 
'pos_pk', $firstNodeInThread->getId());
 
 2954                $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentTopic->getId());
 
 2955                $this->ctrl->setParameter($this, 
'page', (
int) $this->httpRequest->getQueryParams()[
'page']);
 
 2956                $this->ctrl->setParameter(
 
 2962                $reply_button->setUrl($this->ctrl->getLinkTarget($this, 
'createTopLevelPost', 
'frm_page_bottom'));
 
 2964                $this->ctrl->clearParameters($this);
 
 2965                array_unshift($bottom_toolbar_split_button_items, $reply_button);
 
 2969            if (!$numberOfPostings = count($subtree_nodes)) {
 
 2973            $pageSize = $frm->getPageHits();
 
 2975            if ($numberOfPostings > $pageSize) {
 
 2976                $this->ctrl->setParameter($this, 
'ref_id', (
int) $this->object->getRefId());
 
 2977                $this->ctrl->setParameter($this, 
'thr_pk', (
int) $this->objCurrentTopic->getId());
 
 2978                $this->ctrl->setParameter(
 
 2983                $paginationUrl = $this->ctrl->getLinkTarget($this, 
'viewThread', 
'', 
false, 
false);
 
 2984                $this->ctrl->clearParameters($this);
 
 2986                $pagination = $this->uiFactory->viewControl()
 
 2988                    ->withTargetURL($paginationUrl, 
'page')
 
 2989                    ->withTotalEntries($numberOfPostings)
 
 2990                    ->withPageSize($pageSize)
 
 2991                    ->withMaxPaginationButtons(10)
 
 2992                    ->withCurrentPage($pageIndex);
 
 2994                $threadContentTemplate->setVariable(
'THREAD_MENU', $this->uiRenderer->render(
 
 2997                $threadContentTemplate->setVariable(
'THREAD_MENU_BOTTOM', $this->uiRenderer->render(
 
 3003            $draftsObjects = [];
 
 3004            if ($doRenderDrafts) {
 
 3006                    (
int) $this->
user->getId(),
 
 3007                    (
int) $this->objCurrentTopic->getId(),
 
 3008                    (
int) $currentViewMode
 
 3012            $pagedPostings = array_slice($subtree_nodes, $pageIndex * $pageSize, $pageSize);
 
 3014            $this->ensureValidPageForCurrentPosting($subtree_nodes, $pagedPostings, $pageSize, $firstNodeInThread);
 
 3017                $doRenderDrafts && 0 === $pageIndex &&
 
 3021                foreach ($draftsObjects as $draft) {
 
 3022                    $referencePosting = array_values(array_filter(
 
 3024                        static function (
ilForumPost $post) use ($draft) : 
bool {
 
 3025                            return $draft->getPostId() == $post->
getId();
 
 3027                    ))[0] ?? $firstNodeInThread;
 
 3029                    $this->renderDraftContent(
 
 3030                        $threadContentTemplate,
 
 3031                        $this->requestAction,
 
 3038            foreach ($pagedPostings as $node) {
 
 3039                $this->ctrl->clearParameters($this);
 
 3041                if (!$this->isTopLevelReplyCommand() && $this->objCurrentPost->getId() == $node->getId()) {
 
 3042                    if ($this->is_moderator || $node->isActivated() || $node->isOwner($this->user->getId())) {
 
 3043                        if (!$this->objCurrentTopic->isClosed() && in_array($this->requestAction, [
 
 3047                            $this->renderPostingForm($threadContentTemplate, $frm, $node, $this->requestAction);
 
 3048                        } elseif (!$this->objCurrentTopic->isClosed() && $this->requestAction === 
'delete') {
 
 3050                                $this->is_moderator ||
 
 3051                                ($node->isOwner($this->user->getId()) && !$node->hasReplies()) &&
 
 3052                                !$this->user->isAnonymous()
 
 3054                                $threadContentTemplate->setVariable(
'FORM', $this->getDeleteFormHTML());
 
 3056                        } elseif (!$this->objCurrentTopic->isClosed() && $this->requestAction === 
'censor') {
 
 3057                            if ($this->is_moderator) {
 
 3058                                $threadContentTemplate->setVariable(
'FORM', $this->getCensorshipFormHTML());
 
 3060                        } elseif (!$this->objCurrentTopic->isClosed() && $this->displayConfirmPostActivation()) {
 
 3061                            if ($this->is_moderator) {
 
 3062                                $threadContentTemplate->setVariable(
'FORM', $this->getActivationFormHTML());
 
 3068                $this->renderPostContent($threadContentTemplate, $node, $this->requestAction, $pageIndex, $postIndex);
 
 3070                    $this->renderDraftContent(
 
 3071                        $threadContentTemplate,
 
 3072                        $this->requestAction,
 
 3074                        $draftsObjects[$node->getId()] ?? []
 
 3082                $doRenderDrafts && $pageIndex === max(0, (
int) (ceil($numberOfPostings / $pageSize) - 1)) &&
 
 3086                foreach ($draftsObjects as $draft) {
 
 3087                    $referencePosting = array_values(array_filter(
 
 3089                        static function (
ilForumPost $post) use ($draft) : 
bool {
 
 3090                            return $draft->getPostId() == $post->
getId();
 
 3092                    ))[0] ?? $firstNodeInThread;
 
 3094                    $this->renderDraftContent(
 
 3095                        $threadContentTemplate,
 
 3096                        $this->requestAction,
 
 3104                $firstNodeInThread instanceof 
ilForumPost && $doRenderDrafts &&
 
 3107                $this->renderDraftContent(
 
 3108                    $threadContentTemplate,
 
 3109                    $this->requestAction,
 
 3111                    $draftsObjects[$firstNodeInThread->getId()] ?? []
 
 3117                in_array($this->ctrl->getCmd(), array(
'createTopLevelPost', 
'saveTopLevelPost', 
'saveTopLevelDraft')) &&
 
 3118                !$this->objCurrentTopic->isClosed() &&
 
 3119                $this->access->checkAccess(
'add_reply', 
'', (
int) 
$_GET[
'ref_id'])) {
 
 3121                $this->objCurrentPost->setId($firstNodeInThread->getId());
 
 3122                $form = $this->getReplyEditForm();
 
 3124                if (in_array($this->ctrl->getCmd(), [
'saveTopLevelPost', 
'saveTopLevelDraft'])) {
 
 3125                    $form->setValuesByPost();
 
 3127                $this->ctrl->setParameter($this, 
'pos_pk', $firstNodeInThread->getId());
 
 3128                $this->ctrl->setParameter($this, 
'thr_pk', $firstNodeInThread->getThreadId());
 
 3129                $jsTpl = 
new ilTemplate(
'tpl.forum_post_quoation_ajax_handler.html', 
true, 
true, 
'Modules/Forum');
 
 3130                $jsTpl->setVariable(
 
 3131                    'IL_FRM_QUOTE_CALLBACK_SRC',
 
 3132                    $this->ctrl->getLinkTarget($this, 
'getQuotationHTMLAsynch', 
'', 
true)
 
 3134                $this->ctrl->clearParameters($this);
 
 3135                $threadContentTemplate->setVariable(
'BOTTOM_FORM_ADDITIONAL_JS', $jsTpl->get());
 
 3136                $threadContentTemplate->setVariable(
'BOTTOM_FORM', $form->getHTML());
 
 3139            $threadContentTemplate->setCurrentBlock(
'posts_no');
 
 3140            $threadContentTemplate->setVariable(
 
 3141                'TXT_MSG_NO_POSTS_AVAILABLE',
 
 3142                $this->lng->txt(
'forums_posts_not_available')
 
 3144            $threadContentTemplate->parseCurrentBlock();
 
 3147        if ($bottom_toolbar_split_button_items) {
 
 3150            foreach ($bottom_toolbar_split_button_items as $item) {
 
 3152                    $bottom_split_button->setDefaultButton($item);
 
 3159            $bottom_toolbar->addStickyItem($bottom_split_button);
 
 3160            $this->toolbar->addStickyItem($bottom_split_button);
 
 3163        if ($bottom_toolbar_split_button_items) {
 
 3164            $bottom_toolbar->addSeparator();
 
 3168        $to_top_button->setCaption(
'top_of_page');
 
 3169        $to_top_button->setUrl(
'#frm_page_top');
 
 3170        $bottom_toolbar->addButtonInstance($to_top_button);
 
 3171        if ($numberOfPostings > 0) {
 
 3172            $threadContentTemplate->setVariable(
'TOOLBAR_BOTTOM', $bottom_toolbar->getHTML());
 
 3175        $this->renderViewModeControl($currentViewMode);
 
 3177            $this->renderSortationControl($currentSortation);
 
 3180        $this->tpl->setPermanentLink(
 
 3181            $this->object->getType(),
 
 3182            $this->object->getRefId(),
 
 3183            '_' . $this->objCurrentTopic->getId(),
 
 3187        $this->tpl->addOnLoadCode(
'$(".ilFrmPostContent img").each(function() { 
 3190                                maxWidth: $elm.attr("width") + "px",  
 3191                                maxHeight: $elm.attr("height")  + "px" 
 3193                        $elm.removeAttr("width"); 
 3194                        $elm.removeAttr("height"); 
 3197        $this->tpl->setContent($threadContentTemplate->get());
 
 3204        $translationKeys = [];
 
 3205        foreach ($this->viewModeOptions as $sortingConstantKey => $languageKey) {
 
 3206            $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentTopic->getId());
 
 3207            $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 3208            $this->ctrl->setParameter($this, 
'viewmode', $sortingConstantKey);
 
 3210            $translationKeys[$this->lng->txt($languageKey)] = $this->ctrl->getLinkTarget(
 
 3218            $this->ctrl->clearParameters($this);
 
 3221        $sortViewControl = $this->uiFactory
 
 3223            ->mode($translationKeys, $this->lng->txt($this->viewModeOptions[$currentViewMode]))
 
 3224            ->withActive($this->lng->txt($this->viewModeOptions[$currentViewMode]));
 
 3225        $this->toolbar->addComponent($sortViewControl);
 
 3230        $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentTopic->getId());
 
 3231        $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 3232        $target = $this->ctrl->getLinkTarget(
 
 3240        $translatedSortationOptions = array_map(
function ($value) {
 
 3241            return $this->lng->txt($value);
 
 3242        }, $this->sortationOptions);
 
 3244        $sortingDirectionViewControl = $this->uiFactory
 
 3246            ->sortation($translatedSortationOptions)
 
 3247            ->withLabel($this->lng->txt($this->sortationOptions[$currentSorting]))
 
 3248            ->withTargetURL($target, 
'viewmode');
 
 3249        $this->toolbar->addComponent($sortingDirectionViewControl);
 
 3254        $subject = $this->objCurrentPost->getSubject();
 
 3255        $re_txt = $this->lng->txt(
'post_reply');
 
 3257        $re_txt_with_num = str_replace(
':', 
'(', $re_txt);
 
 3258        $search_length = strlen($re_txt_with_num);
 
 3259        $comp = substr_compare($re_txt_with_num, substr($subject, 0, $search_length), 0, $search_length);
 
 3262            $modified_subject = $subject;
 
 3263            if ($on_reply == 
true) {
 
 3265                $str_pos_start = strpos($subject, 
'(');
 
 3266                $str_pos_end = strpos($subject, 
')');
 
 3268                $length = ((int) $str_pos_end - (
int) $str_pos_start);
 
 3270                $txt_number = substr($subject, $str_pos_start, $length - 1);
 
 3272                if (is_numeric($txt_number)) {
 
 3273                    $re_count = (int) $txt_number + 1;
 
 3274                    $modified_subject = substr($subject, 0, $str_pos_start) . $re_count . substr(
 
 3281            $re_count = substr_count($subject, $re_txt);
 
 3282            if ($re_count >= 1 && $on_reply == 
true) {
 
 3283                $subject = str_replace($re_txt, 
'', $subject);
 
 3287                $modified_subject = sprintf($this->lng->txt(
'post_reply_count'), $re_count) . 
' ' . trim($subject);
 
 3288            } elseif ($re_count >= 1 && $on_reply == 
false) {
 
 3291                $modified_subject = sprintf($this->lng->txt(
'post_reply_count'), $re_count) . 
' ' . trim($subject);
 
 3292            } elseif ($re_count == 0) {
 
 3294                $modified_subject = $this->lng->txt(
'post_reply') . 
' ' . $this->objCurrentPost->getSubject();
 
 3297        return $modified_subject;
 
 3303        $add = $this->getUserProfileAdditional((
int) 
$_GET[
'ref_id'], (
int) 
$_GET[
'user']);
 
 3304        $profile_gui->setAdditional($add);
 
 3306        $this->tpl->setContent($this->ctrl->getHTML($profile_gui));
 
 3309    protected function getUserProfileAdditional($a_forum_ref_id, $a_user_id)
 
 3311        if (!$this->access->checkAccess(
'read', 
'', $a_forum_ref_id)) {
 
 3312            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3319        if ($ref_obj->getType() == 
'frm') {
 
 3321            $frm = $forumObj->Forum;
 
 3322            $frm->setForumId($forumObj->getId());
 
 3323            $frm->setForumRefId($forumObj->getRefId());
 
 3329        if ($this->access->checkAccess(
'moderate_frm', 
'', $a_forum_ref_id)) {
 
 3330            $numPosts = $frm->countUserArticles(addslashes($a_user_id));
 
 3332            $numPosts = $frm->countActiveUserArticles(addslashes($a_user_id));
 
 3335        return array($this->lng->txt(
'forums_posts') => $numPosts);
 
 3340        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 3341            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3346        if (isset(
$_POST[
'thread_ids']) && is_array(
$_POST[
'thread_ids'])) {
 
 3347            if (isset(
$_POST[
'selected_cmd']) && 
$_POST[
'selected_cmd'] == 
'move') {
 
 3348                if ($this->is_moderator) {
 
 3350                    $this->moveThreadsObject();
 
 3352            } elseif (
$_POST[
'selected_cmd'] == 
'enable_notifications' && $this->
settings->get(
'forum_notification') != 0) {
 
 3355                    $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $tmp_obj);
 
 3356                    $tmp_obj->enableNotification($this->
user->getId());
 
 3359                $this->ctrl->redirect($this, 
'showThreads');
 
 3360            } elseif (
$_POST[
'selected_cmd'] == 
'disable_notifications' && $this->
settings->get(
'forum_notification') != 0) {
 
 3363                    $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $tmp_obj);
 
 3364                    $tmp_obj->disableNotification($this->
user->getId());
 
 3367                $this->ctrl->redirect($this, 
'showThreads');
 
 3368            } elseif (
$_POST[
'selected_cmd'] == 
'close') {
 
 3369                if ($this->is_moderator) {
 
 3372                        $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $tmp_obj);
 
 3376                ilUtil::sendSuccess($this->lng->txt(
'selected_threads_closed'), 
true);
 
 3377                $this->ctrl->redirect($this, 
'showThreads');
 
 3378            } elseif (
$_POST[
'selected_cmd'] == 
'reopen') {
 
 3379                if ($this->is_moderator) {
 
 3382                        $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $tmp_obj);
 
 3387                ilUtil::sendSuccess($this->lng->txt(
'selected_threads_reopened'), 
true);
 
 3388                $this->ctrl->redirect($this, 
'showThreads');
 
 3389            } elseif (
$_POST[
'selected_cmd'] == 
'makesticky') {
 
 3390                if ($this->is_moderator) {
 
 3391                    $message = $this->lng->txt(
'sel_threads_make_sticky');
 
 3395                        $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $tmp_obj);
 
 3396                        $makeSticky = $tmp_obj->makeSticky();
 
 3399                            $message = $this->lng->txt(
'sel_threads_already_sticky');
 
 3406                $this->ctrl->redirect($this, 
'showThreads');
 
 3407            } elseif (
$_POST[
'selected_cmd'] == 
'unmakesticky') {
 
 3408                if ($this->is_moderator) {
 
 3409                    $message = $this->lng->txt(
'sel_threads_make_unsticky');
 
 3412                        $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $tmp_obj);
 
 3413                        $unmakeSticky = $tmp_obj->unmakeSticky();
 
 3414                        if (!$unmakeSticky) {
 
 3415                            $message = $this->lng->txt(
'sel_threads_already_unsticky');
 
 3423                $this->ctrl->redirect($this, 
'showThreads');
 
 3424            } elseif (
$_POST[
'selected_cmd'] == 
'editThread') {
 
 3425                if ($this->is_moderator) {
 
 3426                    $count = count(
$_POST[
'thread_ids']);
 
 3429                        $this->ctrl->redirect($this, 
'showThreads');
 
 3431                        foreach (
$_POST[
'thread_ids'] as $thread_id) {
 
 3432                            return $this->editThreadObject($thread_id, 
null);
 
 3437                $this->ctrl->redirect($this, 
'showThreads');
 
 3438            } elseif (
$_POST[
'selected_cmd'] == 
'html') {
 
 3439                $this->ctrl->setCmd(
'exportHTML');
 
 3440                $this->ctrl->setCmdClass(
'ilForumExportGUI');
 
 3441                $this->executeCommand();
 
 3442            } elseif (
$_POST[
'selected_cmd'] == 
'confirmDeleteThreads') {
 
 3443                $this->confirmDeleteThreads();
 
 3444            } elseif (
$_POST[
'selected_cmd'] == 
'merge') {
 
 3445                $this->mergeThreadsObject();
 
 3447                ilUtil::sendInfo($this->lng->txt(
'topics_please_select_one_action'), 
true);
 
 3448                $this->ctrl->redirect($this, 
'showThreads');
 
 3452            $this->ctrl->redirect($this, 
'showThreads');
 
 3458        if (!$this->is_moderator) {
 
 3459            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3462        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 3463            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3467        $threads2move = 
$_SESSION[
'threads2move'];
 
 3468        if (!is_array($threads2move) || !count($threads2move)) {
 
 3470            $this->ctrl->redirect($this, 
'showThreads');
 
 3473        if (!$this->access->checkAccess(
'read', 
'', (
int) 
$_POST[
'frm_ref_id'])) {
 
 3474            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3478        array_walk($threads2move, 
function ($threadId) use (&$threads) {
 
 3479            $thread = new \ilForumTopic($threadId);
 
 3480            $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $thread);
 
 3482            $threads[] = $threadId;
 
 3485        if (isset(
$_POST[
'frm_ref_id']) && (int) 
$_POST[
'frm_ref_id']) {
 
 3486            $errorMessages = $this->
object->Forum->moveThreads(
 
 3488                $this->
object->getRefId(),
 
 3489                $this->ilObjDataCache->lookupObjId(
$_POST[
'frm_ref_id'])
 
 3492            if (array() !== $errorMessages) {
 
 3494                    implode(
"<br><br>", $errorMessages),
 
 3497                return $this->ctrl->redirectByClass(
'ilObjForumGUI', 
'showThreads');
 
 3502            $this->ctrl->redirect($this, 
'showThreads');
 
 3505            $this->moveThreadsObject();
 
 3512        $this->ctrl->redirect($this, 
'showThreads');
 
 3517        if (!$this->is_moderator) {
 
 3518            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3521        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 3522            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3525        $threads2move = 
$_SESSION[
'threads2move'];
 
 3526        if (!is_array($threads2move) || !count($threads2move)) {
 
 3528            $this->ctrl->redirect($this, 
'showThreads');
 
 3532        $isModerator = $this->is_moderator;
 
 3533        array_walk($threads2move, 
function ($threadId) use (&$threads, $isModerator) {
 
 3534            $thread = new \ilForumTopic($threadId, $isModerator);
 
 3535            $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $thread);
 
 3537            $threads[] = $thread;
 
 3541        $exp->setPathOpen($this->object->getRefId());
 
 3542        $exp->setNodeSelected(isset(
$_POST[
'frm_ref_id']) && (
int) 
$_POST[
'frm_ref_id'] ? (
int) 
$_POST[
'frm_ref_id'] : 0);
 
 3543        $exp->setCurrentFrmRefId($this->object->getRefId());
 
 3544        $exp->setHighlightedNode($this->object->getRefId());
 
 3545        if (!$exp->handleCommand()) {
 
 3547                'tpl.forums_threads_move.html',
 
 3553            if (!$this->hideToolbar()) {
 
 3554                $this->toolbar->addButton($this->lng->txt(
'back'), $this->ctrl->getLinkTarget($this));
 
 3558            $tblThr->setId(
'il_frm_thread_move_table_' . $this->object->getRefId());
 
 3559            $tblThr->setTitle($this->lng->txt(
'move_chosen_topics'));
 
 3560            $tblThr->addColumn($this->lng->txt(
'subject'), 
'top_name', 
'100%');
 
 3561            $tblThr->disable(
'header');
 
 3562            $tblThr->disable(
'footer');
 
 3563            $tblThr->disable(
'linkbar');
 
 3564            $tblThr->disable(
'sort');
 
 3565            $tblThr->disable(
'linkbar');
 
 3566            $tblThr->setLimit(PHP_INT_MAX);
 
 3567            $tblThr->setRowTemplate(
'tpl.forums_threads_move_thr_row.html', 
'Modules/Forum');
 
 3568            $tblThr->setDefaultOrderField(
'is_sticky');
 
 3571            foreach ($threads as $thread) {
 
 3572                $result[$counter][
'num'] = $counter + 1;
 
 3573                $result[$counter][
'thr_subject'] = $thread->getSubject();
 
 3577            $moveThreadTemplate->setVariable(
'THREADS_TABLE', $tblThr->getHTML());
 
 3579            $moveThreadTemplate->setVariable(
'FRM_SELECTION_TREE', $exp->getHTML());
 
 3580            $moveThreadTemplate->setVariable(
'CMD_SUBMIT', 
'performMoveThreads');
 
 3581            $moveThreadTemplate->setVariable(
'TXT_SUBMIT', $this->lng->txt(
'move'));
 
 3582            $moveThreadTemplate->setVariable(
'FORMACTION', $this->ctrl->getFormAction($this, 
'performMoveThreads'));
 
 3584            $this->tpl->setContent($moveThreadTemplate->get());
 
 3592        if ($this->objProperties->isAnonymized() && (!$this->is_moderator || !$this->objProperties->getMarkModeratorPosts())) {
 
 3600        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 3601            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3604        $draftIds = array_filter((array) ($this->httpRequest->getParsedBody()[
'draft_ids'] ?? []));
 
 3605        if (0 === count($draftIds)) {
 
 3606            $draftIds = array_filter([(
int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0)]);
 
 3610        $checkedDraftIds = [];
 
 3611        foreach ($draftIds as $draftId) {
 
 3612            if (array_key_exists($draftId, $instances)) {
 
 3613                $checkedDraftIds[] = $draftId;
 
 3614                $draft = $instances[$draftId];
 
 3616                $this->deleteMobsOfDraft($draft->getDraftId(), $draft->getPostMessage());
 
 3618                $draftFileData = new \ilFileDataForumDrafts(0, $draft->getDraftId());
 
 3619                $draftFileData->delete();
 
 3621                $GLOBALS[
'ilAppEventHandler']->raise(
 
 3625                    'draftObj' => $draft,
 
 3626                    'obj_id' => $this->object->getId(),
 
 3627                    'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
 
 3631                $draft->deleteDraft();
 
 3635        if (count($checkedDraftIds) > 1) {
 
 3640        $this->ctrl->redirect($this, 
'showThreads');
 
 3649        $draftId = (int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
 
 3650        $allowNotification = !$this->objProperties->isAnonymized();
 
 3652        $mail = new \ilMail($this->
user->getId());
 
 3653        if (!$this->rbac->system()->checkAccess(
'internal_mail', $mail->getMailObjectReferenceId())) {
 
 3654            $allowNotification = 
false;
 
 3657        $form = new \ilForumThreadFormGUI(
 
 3659            $this->objProperties,
 
 3660            $this->isWritingWithPseudonymAllowed(),
 
 3666        $this->decorateWithAutosave($form);
 
 3673        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 3674            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3677        if (!$this->access->checkAccess(
'add_thread', 
'', $this->object->getRefId())) {
 
 3678            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3681        $templateForWidthHandling = new \ilTemplate(
'tpl.create_thread_form.html', 
true, 
true, 
'Modules/Forum');
 
 3682        $templateForWidthHandling->setVariable(
'CREATE_FORM', $this->buildThreadForm()->getHTML());
 
 3683        $templateForWidthHandling->parseCurrentBlock();
 
 3685        $this->tpl->setContent($templateForWidthHandling->get());
 
 3696            !$this->access->checkAccess(
'add_thread', 
'', $this->object->getRefId()) ||
 
 3697            !$this->access->checkAccess(
'read', 
'', $this->object->getRefId())
 
 3699            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3702        $frm = $this->
object->Forum;
 
 3703        $frm->setForumId($this->object->getId());
 
 3704        $frm->setForumRefId($this->object->getRefId());
 
 3705        $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', array(
'integer'), array($frm->getForumId()));
 
 3706        $topicData = $frm->getOneTopic();
 
 3708        $form = $this->buildThreadForm($createFromDraft);
 
 3709        if ($form->checkInput()) {
 
 3710            $this->doCaptchaCheck();
 
 3712            $userIdForDisplayPurposes = $this->
user->getId();
 
 3713            if ($this->isWritingWithPseudonymAllowed()) {
 
 3714                $userIdForDisplayPurposes = 0;
 
 3719                ($this->objProperties->isPostActivationEnabled() && !$this->is_moderator) ||
 
 3720                $this->objCurrentPost->isAnyParentDeactivated()
 
 3725            if ($createFromDraft) {
 
 3726                $newThread = new \ilForumTopic(0, 
true, 
true);
 
 3727                $newThread->setForumId($topicData[
'top_pk']);
 
 3730                $newThread->setSubject($this->handleFormInput($form->getInput(
'subject'), 
false));
 
 3733                $newPost = $frm->generateThread(
 
 3742                    $form->getInput(
'alias'),
 
 3743                    $this->objProperties->isAnonymized()
 
 3745                $newThread = new \ilForumTopic(0, 
true, 
true);
 
 3746                $newThread->setForumId($topicData[
'top_pk']);
 
 3747                $newThread->setThrAuthorId($this->
user->getId());
 
 3748                $newThread->setDisplayUserId($userIdForDisplayPurposes);
 
 3749                $newThread->setSubject($this->handleFormInput($form->getInput(
'subject'), 
false));
 
 3750                $newThread->setUserAlias($userAlias);
 
 3752                $newPost = $frm->generateThread(
 
 3755                    $form->getItemByPostVar(
'notify') ? (
int) $form->getInput(
'notify') : 0,
 
 3761            if ($this->objProperties->isFileUploadAllowed()) {
 
 3762                $file = $_FILES[
'userfile'];
 
 3763                if (is_array($file) && !empty($file)) {
 
 3764                    $fileData = new \ilFileDataForum($this->object->getId(), $newPost);
 
 3765                    $fileData->storeUploadedFile($file);
 
 3769            $frm->setDbTable(
'frm_data');
 
 3770            $frm->setMDB2WhereCondition(
'top_pk = %s ', array(
'integer'), array($topicData[
'top_pk']));
 
 3771            $frm->updateVisits($topicData[
'top_pk']);
 
 3773            if ($createFromDraft) {
 
 3778            foreach ($mediaObjects as $mob) {
 
 3786                $draftHistory = new \ilForumDraftsHistory();
 
 3787                $draftHistory->deleteHistoryByDraftIds([$draft->
getDraftId()]);
 
 3788                if ($this->objProperties->isFileUploadAllowed()) {
 
 3789                    $forumFileData = new \ilFileDataForum($this->object->getId(), $newPost);
 
 3790                    $draftFileData = new \ilFileDataForumDrafts($this->object->getId(), $draft->
getDraftId());
 
 3791                    $draftFileData->moveFilesOfDraft($forumFileData->getForumPath(), $newPost);
 
 3796            $GLOBALS[
'ilAppEventHandler']->raise(
 
 3800                'ref_id' => $this->object->getRefId(),
 
 3802                'notify_moderators' => !$status
 
 3806            \ilUtil::sendSuccess($this->lng->txt(
'forums_thread_new_entry'), 
true);
 
 3807            $this->ctrl->redirect($this);
 
 3810        $form->setValuesByPost();
 
 3811        if (!$this->objProperties->isAnonymized()) {
 
 3812            $form->getItemByPostVar(
'alias')->setValue($this->
user->getLogin());
 
 3815        $this->tpl->setContent($form->getHTML());
 
 3821            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3824        $draftId = (int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
 
 3827        if ((
int) $draft->getDraftId() <= 0) {
 
 3828            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3831        $this->createThread($draft, 
true);
 
 3836        $draft = new \ilForumPostDraft();
 
 3838            $draftId = (int) ($this->httpRequest->getParsedBody()[
'draft_id'] ?? 0);
 
 3844        $this->createThread($draft, 
false);
 
 3849        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 3850            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3853        $frm = $this->
object->Forum;
 
 3854        $frm->setForumId($this->object->getId());
 
 3855        $frm->enableForumNotification($this->
user->getId());
 
 3857        if ((
int) $this->objCurrentTopic->getId() > 0) {
 
 3858            $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentTopic->getId());
 
 3860            $this->ctrl->redirect($this, 
'viewThread');
 
 3864        $this->showThreadsObject();
 
 3869        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 3870            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3873        $frm = $this->
object->Forum;
 
 3874        $frm->setForumId($this->object->getId());
 
 3875        $frm->disableForumNotification($this->
user->getId());
 
 3877        if ((
int) $this->objCurrentTopic->getId() > 0) {
 
 3878            $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentTopic->getId());
 
 3880            $this->ctrl->redirect($this, 
'viewThread');
 
 3884        $this->showThreadsObject();
 
 3892        $column_gui->
setBlockProperty(
'news', 
'title', $this->lng->txt(
'frm_latest_postings'));
 
 3896        if ($this->access->checkAccess(
'write', 
'', $this->object->getRefId())) {
 
 3897            $news_set = new \ilSetting(
'news');
 
 3898            if ($news_set->get(
'enable_rss_for_internal')) {
 
 3900                $column_gui->
setBlockProperty(
'news', 
'public_notifications_option', 
true);
 
 3911            $this->locator->addItem(
 
 3912                $this->object->getTitle(),
 
 3913                $this->ctrl->getLinkTarget($this),
 
 3915                $this->object->getRefId()
 
 3922        $a_text = str_replace(
"<", 
"<", $a_text);
 
 3923        $a_text = str_replace(
">", 
">", $a_text);
 
 3924        if ($a_stripslashes) {
 
 3933        $a_text = str_replace(
"<", 
"<", $a_text);
 
 3934        $a_text = str_replace(
">", 
">", $a_text);
 
 3942            !$this->access->checkAccess(
'visible', 
'', $this->object->getRefId()) &&
 
 3943            !$this->access->checkAccess(
'read', 
'', $this->object->getRefId())
 
 3945            $this->
error->raiseError($this->lng->txt(
'msg_no_perm_read'), $this->error->MESSAGE);
 
 3948        $info = new \ilInfoScreenGUI($this);
 
 3949        $info->enablePrivateNotes();
 
 3950        $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
 
 3951        $this->ctrl->forwardCommand($info);
 
 3959        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 3960            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3963        if ((
int) $this->objCurrentPost->getId() > 0) {
 
 3964            $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $this->objCurrentPost->getThread());
 
 3966            $this->
object->markPostUnread($this->
user->getId(), (
int) $this->objCurrentPost->getId());
 
 3968        $this->viewThreadObject();
 
 3976        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 3977            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 3980        if ((
int) $this->objCurrentTopic->getId() > 0 && (
int) $this->objCurrentPost->getId() > 0) {
 
 3981            $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $this->objCurrentPost->getThread());
 
 3983            $this->
object->markPostRead(
 
 3984                $this->
user->getId(),
 
 3985                (
int) $this->objCurrentTopic->getId(),
 
 3986                (
int) $this->objCurrentPost->getId()
 
 3989        $this->viewThreadObject();
 
 3997        $lg = parent::initHeaderAction();
 
 3999        if ((
int) $this->objCurrentTopic->getId() > 0) {
 
 4000            $container_obj = 
null; 
 
 4001            $lg->setContainerObject($container_obj);
 
 4008        if ($this->
user->isAnonymous() || !$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 4012        $frm = $this->
object->Forum;
 
 4013        $frm->setForumId($this->object->getId());
 
 4014        $frm->setForumRefId($this->object->getRefId());
 
 4015        $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', array(
'integer'), array($frm->getForumId()));
 
 4017        $isForumNotificationEnabled = $frm->isForumNotificationEnabled($this->
user->getId());
 
 4018        $userMayDisableNotifications = $this->isUserAllowedToDeactivateNotification();
 
 4020        if ((
int) $this->objCurrentTopic->getId() > 0) {
 
 4021            $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentTopic->getId());
 
 4024        if ($this->isParentObjectCrsOrGrp()) {
 
 4026            if ($isForumNotificationEnabled && $userMayDisableNotifications) {
 
 4027                $lg->addCustomCommand(
 
 4028                    $this->ctrl->getLinkTarget($this, 
'disableForumNotification'),
 
 4029                    'forums_disable_forum_notification' 
 4031            } elseif (!$isForumNotificationEnabled) {
 
 4032                $lg->addCustomCommand(
 
 4033                    $this->ctrl->getLinkTarget($this, 
'enableForumNotification'),
 
 4034                    'forums_enable_forum_notification' 
 4037        } elseif ($isForumNotificationEnabled) {
 
 4038            $lg->addCustomCommand(
 
 4039                $this->ctrl->getLinkTarget($this, 
'disableForumNotification'),
 
 4040                'forums_disable_forum_notification' 
 4043            $lg->addCustomCommand(
 
 4044                $this->ctrl->getLinkTarget($this, 
'enableForumNotification'),
 
 4045                'forums_enable_forum_notification' 
 4049        $isThreadNotificationEnabled = 
false;
 
 4050        if ((
int) $this->objCurrentTopic->getId() > 0) {
 
 4051            $isThreadNotificationEnabled = $this->objCurrentTopic->isNotificationEnabled($this->
user->getId());
 
 4052            if ($isThreadNotificationEnabled) {
 
 4053                $lg->addCustomCommand(
 
 4054                    $this->ctrl->getLinkTarget($this, 
'toggleThreadNotification'),
 
 4055                    'forums_disable_notification' 
 4058                $lg->addCustomCommand(
 
 4059                    $this->ctrl->getLinkTarget($this, 
'toggleThreadNotification'),
 
 4060                    'forums_enable_notification' 
 4064        $this->ctrl->setParameter($this, 
'thr_pk', 
'');
 
 4066        if ($isForumNotificationEnabled || $isThreadNotificationEnabled) {
 
 4070                $this->lng->txt(
'frm_notification_activated')
 
 4076                $this->lng->txt(
'frm_notification_deactivated')
 
 4085        if ($this->objProperties->getNotificationType() == 
'default') {
 
 4089        if ($this->objProperties->isUserToggleNoti() == 0) {
 
 4093        if ($this->isParentObjectCrsOrGrp()) {
 
 4095            $frm_noti->setUserId($this->
user->getId());
 
 4097            $user_toggle = (int) $frm_noti->isUserToggleNotification();
 
 4098            if ($user_toggle == 0 && $this->objProperties->isUserToggleNoti() == 0) {
 
 4108        $grpRefId = $this->repositoryTree->checkForParentType($this->object->getRefId(), 
'grp');
 
 4109        $crsRefId = $this->repositoryTree->checkForParentType($this->object->getRefId(), 
'crs');
 
 4111        return ($grpRefId > 0 || $crsRefId > 0);
 
 4116        if (!$this->is_moderator) {
 
 4117            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4120        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 4121            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4124        $threadIdToSortValueMap = (array) ($this->httpRequest->getParsedBody()[
'thread_sorting'] ?? []);
 
 4126        array_walk($threadIdToSortValueMap, 
function ($sortValue, $threadId) {
 
 4127            $this->ensureThreadBelongsToForum((
int) $this->object->getId(), 
new \
ilForumTopic($threadId));
 
 4130        foreach ($threadIdToSortValueMap as $threadId => $sortValue) {
 
 4131            $sortValue = str_replace(
',', 
'.', $sortValue);
 
 4132            $sortValue = (float) $sortValue * 100;
 
 4133            $this->
object->setThreadSorting((
int) $threadId, $sortValue);
 
 4136        \ilUtil::sendSuccess($this->lng->txt(
'saved_successfully'), 
true);
 
 4137        $this->ctrl->redirect($this, 
'showThreads');
 
 4145        if (!$this->is_moderator) {
 
 4146            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4149        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 4150            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4153        $threadIdToMerge = (int) ($this->httpRequest->getQueryParams()[
'merge_thread_id'] ?? 0);
 
 4154        if (!($threadIdToMerge > 0)) {
 
 4155            $threadIds = array_values(
 
 4156                array_filter(array_map(
'intval', (array) $this->httpRequest->getParsedBody()[
'thread_ids'] ?? []))
 
 4158            if (1 === count($threadIds)) {
 
 4159                $threadIdToMerge = current($threadIds);
 
 4162                $this->showThreadsObject();
 
 4167        $frm = $this->
object->Forum;
 
 4168        $frm->setForumId($this->object->getId());
 
 4169        $frm->setForumRefId($this->object->getRefId());
 
 4175            $this->showThreadsObject();
 
 4179        $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', array(
'integer'), array($frm->getForumId()));
 
 4181        $threadsTemplate = new \ilTemplate(
 
 4182            'tpl.forums_threads_liste.html',
 
 4188        $topicData = $frm->getOneTopic();
 
 4190            $this->ctrl->setParameter($this, 
'merge_thread_id', $threadIdToMerge);
 
 4191            $tbl = new \ilForumTopicTableGUI(
 
 4195                (
int) $this->httpRequest->getQueryParams()[
'ref_id'],
 
 4197                $this->is_moderator,
 
 4198                $this->settings->get(
'forum_overview')
 
 4200            $tbl->setSelectedThread($threadToMerge);
 
 4201            $tbl->setMapper($frm)->fetchData();
 
 4203            $threadsTemplate->setVariable(
'THREADS_TABLE', $tbl->getHTML());
 
 4204            $this->tpl->setContent($threadsTemplate->get());
 
 4207            $this->showThreadsObject();
 
 4216        if (!$this->is_moderator) {
 
 4217            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4220        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 4221            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4224        $sourceThreadId = (int) ($this->httpRequest->getQueryParams()[
'merge_thread_id'] ?? 0);
 
 4225        $targetThreadIds = array_values(
 
 4226            array_filter(array_map(
'intval', (array) $this->httpRequest->getParsedBody()[
'thread_ids'] ?? []))
 
 4229        if (!($sourceThreadId > 0) || 1 !== count($targetThreadIds)) {
 
 4231            $this->mergeThreadsObject();
 
 4235        $targetThreadId = current($targetThreadIds);
 
 4236        if ($sourceThreadId == $targetThreadId) {
 
 4238            $this->showThreadsObject();
 
 4244            $this->ctrl->clearParameters($this);
 
 4245            $this->showThreadsObject();
 
 4253        $this->ensureThreadBelongsToForum((
int) $this->object->getId(), 
new \
ilForumTopic((
int) $sourceThreadId));
 
 4254        $this->ensureThreadBelongsToForum((
int) $this->object->getId(), 
new \
ilForumTopic((
int) $targetThreadId));
 
 4258        $c_gui->setFormAction($this->ctrl->getFormAction($this, 
'performMergeThreads'));
 
 4259        $c_gui->setHeaderText($this->lng->txt(
'frm_sure_merge_threads'));
 
 4260        $c_gui->setCancel($this->lng->txt(
'cancel'), 
'showThreads');
 
 4261        $c_gui->setConfirm($this->lng->txt(
'confirm'), 
'performMergeThreads');
 
 4273        $this->tpl->setContent($c_gui->getHTML());
 
 4281        if (!$this->is_moderator) {
 
 4282            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4285        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 4286            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4289        $threadIds = array_values(
 
 4290            array_filter(array_map(
'intval', (array) $this->httpRequest->getParsedBody()[
'thread_ids'] ?? []))
 
 4292        if (2 !== count($threadIds)) {
 
 4294            $this->showThreadsObject();
 
 4298        if ((
int) $threadIds[0] === (
int) $threadIds[1]) {
 
 4300            $this->showThreadsObject();
 
 4305            $frm = new \ilForum();
 
 4306            $frm->setForumId($this->object->getId());
 
 4307            $frm->setForumRefId($this->object->getRefId());
 
 4309            $this->ensureThreadBelongsToForum((
int) $this->object->getId(), 
new \
ilForumTopic((
int) $threadIds[0]));
 
 4310            $this->ensureThreadBelongsToForum((
int) $this->object->getId(), 
new \
ilForumTopic((
int) $threadIds[1]));
 
 4312            $frm->mergeThreads((
int) $threadIds[0], (
int) $threadIds[1]);
 
 4313            \ilUtil::sendSuccess($this->lng->txt(
'merged_threads_successfully'));
 
 4318        $this->showThreadsObject();
 
 4326        $content = $this->getRightColumnHTML();
 
 4327        if (!$this->ctrl->isAsynch()) {
 
 4328            $content = implode(
'', [
 
 4333        $this->tpl->setRightContent($content);
 
 4341        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 4342            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4345        $draftId = $this->httpRequest->getQueryParams()[
'draft_id'] ?? 0;
 
 4347        if ($draft->getPostAuthorId() == $this->user->getId()) {
 
 4348            $fileData = new \ilFileDataForumDrafts(0, $draft->getDraftId());
 
 4349            if (!$fileData->deliverZipFile()) {
 
 4350                $this->ctrl->redirect($this);
 
 4360        if (!$this->access->checkAccess(
'read', 
'', $this->object->getRefId())) {
 
 4361            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4364        $this->ensureThreadBelongsToForum((
int) $this->object->getId(), $this->objCurrentPost->getThread());
 
 4366        $fileData = new \ilFileDataForum($this->object->getId(), $this->objCurrentPost->getId());
 
 4367        if (!$fileData->deliverZipFile()) {
 
 4368            $this->ctrl->redirect($this);
 
 4378            !$this->access->checkAccess(
'add_thread', 
'', $this->object->getRefId()) ||
 
 4379            !$this->access->checkAccess(
'read', 
'', $this->object->getRefId()) ||
 
 4382            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4385        $frm = $this->
object->Forum;
 
 4386        $frm->setForumId($this->object->getId());
 
 4387        $frm->setForumRefId($this->object->getRefId());
 
 4389        $draft = new \ilForumPostDraft();
 
 4390        $draftId = (int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
 
 4392            $draft = $draft->newInstanceByDraftId($draftId);
 
 4395        $historyCheck = (int) ($this->httpRequest->getQueryParams()[
'hist_check'] ?? 1);
 
 4397            $this->doHistoryCheck($draft->getDraftId());
 
 4401            $form = $this->buildThreadForm(
true);
 
 4402            $form->setValuesByArray([
 
 4403                'alias' => $draft->getPostUserAlias(),
 
 4404                'subject' => $draft->getPostSubject(),
 
 4406                'notify' => $draft->getNotify() ? 
true : 
false,
 
 4411            $this->ctrl->setParameter($this, 
'draft_id', $draftId);
 
 4414        $this->tpl->setContent($form->getHTML() . $this->modal_history);
 
 4419        $historyId = (int) ($this->httpRequest->getQueryParams()[
'history_id'] ?? 0);
 
 4420        $history = new \ilForumDraftsHistory($historyId);
 
 4422        $draft = $history->rollbackAutosave();
 
 4423        if ($draft->getThreadId() == 0 && $draft->getPostId() == 0) {
 
 4424            $this->ctrl->setParameter($this, 
'draft_id', $history->getDraftId());
 
 4425            $this->ctrl->redirect($this, 
'editThreadDraft');
 
 4428        $this->ctrl->clearParameters($this);
 
 4429        $this->ctrl->setParameter($this, 
'pos_pk', $draft->getPostId());
 
 4430        $this->ctrl->setParameter($this, 
'thr_pk', $draft->getThreadId());
 
 4431        $this->ctrl->setParameter($this, 
'draft_id', $draft->getDraftId());
 
 4432        $this->ctrl->setParameter($this, 
'action', 
'editdraft');
 
 4437        $this->ctrl->redirect($this, 
'viewThread');
 
 4443            !$this->access->checkAccess(
'add_thread', 
'', $this->object->getRefId()) ||
 
 4444            !$this->access->checkAccess(
'read', 
'', $this->object->getRefId()) ||
 
 4447            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4450        $autoSavedDraftId = (int) ($this->httpRequest->getParsedBody()[
'draft_id'] ?? 0);
 
 4451        if ($autoSavedDraftId <= 0) {
 
 4452            $autoSavedDraftId = (int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
 
 4455        $frm = $this->
object->Forum;
 
 4456        $frm->setForumId($this->object->getId());
 
 4457        $frm->setForumRefId($this->object->getRefId());
 
 4458        $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', array(
'integer'), array($frm->getForumId()));
 
 4459        $topicData = $frm->getOneTopic();
 
 4461        $form = $this->buildThreadForm();
 
 4462        if ($form->checkInput()) {
 
 4463            $this->doCaptchaCheck();
 
 4465            if (0 === $autoSavedDraftId) {
 
 4466                $draft = new \ilForumPostDraft();
 
 4471            $draft->setForumId($topicData[
'top_pk']);
 
 4472            $draft->setThreadId(0);
 
 4473            $draft->setPostId(0);
 
 4474            $draft->setPostSubject($this->handleFormInput($form->getInput(
'subject'), 
false));
 
 4477                $form->getInput(
'alias'),
 
 4478                $this->objProperties->isAnonymized()
 
 4480            $draft->setPostUserAlias($userAlias);
 
 4481            $draft->setNotify((
int) $form->getInput(
'notify'));
 
 4482            $draft->setPostAuthorId($this->
user->getId());
 
 4483            $draft->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $this->user->getId()));
 
 4485            if (0 === $autoSavedDraftId) {
 
 4486                $draftId = $draft->saveDraft();
 
 4488                $draft->updateDraft();
 
 4489                $draftId = $draft->getDraftId();
 
 4492            $GLOBALS[
'ilAppEventHandler']->raise(
 
 4496                'draftObj' => $draft,
 
 4497                'obj_id' => $this->object->getId(),
 
 4498                'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
 
 4504            $draftFileData = new \ilFileDataForumDrafts($this->object->getId(), $draftId);
 
 4506            $files2delete = $form->getInput(
'del_file');
 
 4507            if (is_array($files2delete) && count($files2delete) > 0) {
 
 4508                $draftFileData->unlinkFilesByMD5Filenames($files2delete);
 
 4511            if ($this->objProperties->isFileUploadAllowed()) {
 
 4512                $file = $_FILES[
'userfile'];
 
 4513                if (is_array($file) && !empty($file)) {
 
 4514                    $draftFileData->storeUploadedFile($file);
 
 4518            \ilUtil::sendSuccess($this->lng->txt(
'save_draft_successfully'), 
true);
 
 4519            $this->ctrl->clearParameters($this);
 
 4520            $this->ctrl->redirect($this, 
'showThreads');
 
 4523        $this->requestAction = substr($this->requestAction, 6); 
 
 4524        $form->setValuesByPost();
 
 4525        $this->ctrl->setParameter($this, 
'draft_id', $autoSavedDraftId);
 
 4526        $this->tpl->setContent($form->getHTML());
 
 4532            !$this->access->checkAccess(
'add_thread', 
'', $this->object->getRefId()) ||
 
 4533            !$this->access->checkAccess(
'read', 
'', $this->object->getRefId()) ||
 
 4536            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4539        $draftId = (int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
 
 4540        if ($draftId <= 0 || !$this->checkDraftAccess($draftId)) {
 
 4541            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->
error->MESSAGE);
 
 4544        $form = $this->buildThreadForm(
true);
 
 4545        if ($form->checkInput()) {
 
 4546            $this->doCaptchaCheck();
 
 4549                $form->getInput(
'alias'),
 
 4550                $this->objProperties->isAnonymized()
 
 4554            $draft->setPostSubject($this->handleFormInput($form->getInput(
'subject'), 
false));
 
 4556            $draft->setPostUserAlias($userAlias);
 
 4557            $draft->setNotify((
int) $form->getInput(
'notify'));
 
 4558            $draft->setPostAuthorId($this->
user->getId());
 
 4559            $draft->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $this->user->getId()));
 
 4560            $draft->updateDraft();
 
 4562            $GLOBALS[
'ilAppEventHandler']->raise(
 
 4566                'draftObj' => $draft,
 
 4567                'obj_id' => $this->object->getId(),
 
 4568                'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
 
 4573                $form->getInput(
'message'),
 
 4575                $draft->getDraftId(),
 
 4577                $draft->getDraftId()
 
 4580            $draftFileData = new \ilFileDataForumDrafts($this->object->getId(), $draft->getDraftId());
 
 4582            $files2delete = $form->getInput(
'del_file');
 
 4583            if (is_array($files2delete) && count($files2delete) > 0) {
 
 4584                $draftFileData->unlinkFilesByMD5Filenames($files2delete);
 
 4587            if ($this->objProperties->isFileUploadAllowed()) {
 
 4588                $file = $_FILES[
'userfile'];
 
 4589                if (is_array($file) && !empty($file)) {
 
 4590                    $draftFileData->storeUploadedFile($file);
 
 4594            \ilUtil::sendSuccess($this->lng->txt(
'save_draft_successfully'), 
true);
 
 4595            $this->ctrl->clearParameters($this);
 
 4596            $this->ctrl->redirect($this, 
'showThreads');
 
 4599        $form->setValuesByPost();
 
 4600        $this->ctrl->setParameter($this, 
'hist_check', 0);
 
 4601        $this->ctrl->setParameter($this, 
'draft_id', $draftId);
 
 4602        $this->editThreadDraftObject($form);
 
 4607        $this->saveAsDraftObject();
 
 4610    public function saveAsDraftObject()
 
 4612        if (!$this->objCurrentTopic->getId()) {
 
 4614            $this->ctrl->redirect($this);
 
 4617        if ($this->objCurrentTopic->isClosed()) {
 
 4619            $this->ctrl->redirect($this);
 
 4622        if (!isset(
$_POST[
'del_file']) || !is_array(
$_POST[
'del_file'])) {
 
 4623            $_POST[
'del_file'] = array();
 
 4626        $autosave_draft_id = 0;
 
 4628            $autosave_draft_id = (int) 
$_POST[
'draft_id'];
 
 4630        $oReplyEditForm = $this->getReplyEditForm();
 
 4631        if ($oReplyEditForm->checkInput()) {
 
 4632            if (!$this->objCurrentPost->getId()) {
 
 4633                $this->requestAction = 
'';
 
 4635                $this->viewThreadObject();
 
 4639            $this->doCaptchaCheck();
 
 4642            $oForumObjects = $this->getForumObjects();
 
 4646            $forumObj = $oForumObjects[
'forumObj'];
 
 4650            $frm = $oForumObjects[
'frm'];
 
 4651            $frm->setMDB2WhereCondition(
' top_frm_fk = %s ', array(
'integer'), array($frm->getForumId()));
 
 4652            $topicData = $frm->getOneTopic();
 
 4655            if ($this->requestAction == 
'ready_showreply') {
 
 4656                if (!$this->access->checkAccess(
'add_reply', 
'', (
int) 
$_GET[
'ref_id'])) {
 
 4657                    $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4661                    $oReplyEditForm->getInput(
'alias'),
 
 4662                    $this->objProperties->isAnonymized()
 
 4665                if ($autosave_draft_id == 0) {
 
 4670                $draftObj->setForumId($topicData[
'top_pk']);
 
 4671                $draftObj->setThreadId($this->objCurrentTopic->getId());
 
 4672                $draftObj->setPostId($this->objCurrentPost->getId());
 
 4674                $draftObj->setPostSubject($this->handleFormInput($oReplyEditForm->getInput(
'subject'), 
false));
 
 4676                $draftObj->setPostUserAlias($user_alias);
 
 4677                $draftObj->setNotify((
int) $oReplyEditForm->getInput(
'notify'));
 
 4678                $draftObj->setPostNotify((
int) $oReplyEditForm->getInput(
'notify_post'));
 
 4680                $draftObj->setPostAuthorId($this->
user->getId());
 
 4681                $draftObj->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $this->user->getId()));
 
 4683                if ($autosave_draft_id == 0) {
 
 4684                    $draft_id = $draftObj->saveDraft();
 
 4686                    $draftObj->updateDraft();
 
 4687                    $draft_id = $draftObj->getDraftId();
 
 4691                    $GLOBALS[
'ilAppEventHandler']->raise(
 
 4695                            'draftObj' => $draftObj,
 
 4696                            'obj_id' => $this->object->getId(),
 
 4697                            'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
 
 4702                if ($this->objProperties->isFileUploadAllowed()) {
 
 4703                    $file = $_FILES[
'userfile'];
 
 4704                    if (is_array($file) && !empty($file)) {
 
 4706                        $oFDForumDrafts->storeUploadedFile($file);
 
 4712                    $oReplyEditForm->getInput(
'message'),
 
 4719                $_SESSION[
'frm'][(int) 
$_GET[
'thr_pk']][
'openTreeNodes'][] = (
int) $this->objCurrentPost->getId();
 
 4721                ilUtil::sendSuccess($this->lng->txt(
'save_draft_successfully'), 
true);
 
 4722                $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 4723                $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 4724                $this->ctrl->redirect($this, 
'viewThread');
 
 4727            $oReplyEditForm->setValuesByPost();
 
 4728            $this->requestAction = substr($this->requestAction, 6);
 
 4730        return $this->viewThreadObject();
 
 4736            $draftId = (int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
 
 4737            if ($this->checkDraftAccess($draftId)) {
 
 4738                $this->doHistoryCheck($draftId);
 
 4742        $this->viewThreadObject();
 
 4748    public function updateDraftObject()
 
 4750        if (!$this->objCurrentTopic->getId()) {
 
 4752            $this->ctrl->redirect($this);
 
 4755        if ($this->objCurrentTopic->isClosed()) {
 
 4757            $this->ctrl->redirect($this);
 
 4760        if (!$this->objCurrentPost->getId()) {
 
 4761            $this->requestAction = 
'';
 
 4763            $this->viewThreadObject();
 
 4767        if (!isset(
$_POST[
'del_file']) || !is_array(
$_POST[
'del_file'])) {
 
 4768            $_POST[
'del_file'] = array();
 
 4771        $oReplyEditForm = $this->getReplyEditForm();
 
 4772        if ($oReplyEditForm->checkInput()) {
 
 4773            $this->doCaptchaCheck();
 
 4776            $oForumObjects = $this->getForumObjects();
 
 4780            $forumObj = $oForumObjects[
'forumObj'];
 
 4782            if (!$this->
user->isAnonymous() && in_array($this->requestAction, [
'showdraft', 
'editdraft'])) {
 
 4783                if (!$this->access->checkAccess(
'add_reply', 
'', (
int) 
$_GET[
'ref_id'])) {
 
 4784                    $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4786                if (!$this->checkDraftAccess((
int) 
$_GET[
'draft_id'])) {
 
 4787                    $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4791                    $oReplyEditForm->getInput(
'alias'),
 
 4792                    $this->objProperties->isAnonymized()
 
 4797                    $this->
user->getId(),
 
 4798                    $this->objCurrentPost->getId(),
 
 4799                    (
int) 
$_GET[
'draft_id']
 
 4802                $update_draft->setPostSubject($this->handleFormInput($oReplyEditForm->getInput(
'subject'), 
false));
 
 4804                    $oReplyEditForm->getInput(
'message'),
 
 4807                $update_draft->setPostUserAlias($user_alias);
 
 4808                $update_draft->setNotify((
int) $oReplyEditForm->getInput(
'notify'));
 
 4809                $update_draft->setUpdateUserId($this->
user->getId());
 
 4810                $update_draft->setPostAuthorId($this->
user->getId());
 
 4811                $update_draft->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $this->user->getId()));
 
 4813                $update_draft->updateDraft();
 
 4816                    $GLOBALS[
'ilAppEventHandler']->raise(
 
 4820                            'draftObj' => $update_draft,
 
 4821                            'obj_id' => $this->object->getId(),
 
 4822                            'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
 
 4829                foreach ($uploadedObjects as $mob) {
 
 4834                    $oReplyEditForm->getInput(
'message'),
 
 4836                    $update_draft->getDraftId()
 
 4841                $file2delete = $oReplyEditForm->getInput(
'del_file');
 
 4842                if (is_array($file2delete) && count($file2delete)) {
 
 4843                    $oFDForumDrafts->unlinkFilesByMD5Filenames($file2delete);
 
 4846                if ($this->objProperties->isFileUploadAllowed()) {
 
 4847                    $file = $_FILES[
'userfile'];
 
 4848                    if (is_array($file) && !empty($file)) {
 
 4849                        $oFDForumDrafts->storeUploadedFile($file);
 
 4853                $_SESSION[
'frm'][(int) 
$_GET[
'thr_pk']][
'openTreeNodes'][] = (
int) $this->objCurrentPost->getId();
 
 4854                ilUtil::sendSuccess($this->lng->txt(
'save_draft_successfully'), 
true);
 
 4856            $this->ctrl->clearParameters($this);
 
 4857            $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 4858            $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 4859            $this->ctrl->setParameter($this, 
'draft_id', $update_draft->getDraftId());
 
 4861            $this->ctrl->clearParameters($this);
 
 4862            $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 4863            $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 4864            $this->ctrl->setParameter($this, 
'draft_id', (
int) 
$_GET[
'draft_id']);
 
 4865            $this->ctrl->setParameter($this, 
'action', 
'editdraft');
 
 4866            $oReplyEditForm->setValuesByPost();
 
 4867            return $this->viewThreadObject();
 
 4869        $this->ctrl->clearParameters($this);
 
 4870        $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 4871        $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 4872        $this->ctrl->redirect($this, 
'viewThread');
 
 4885        foreach ($oldMediaObjects as $oldMob) {
 
 4887            foreach ($curMediaObjects as $curMob) {
 
 4888                if ($oldMob == $curMob) {
 
 4909            !$this->access->checkAccess(
'add_reply', 
'', (
int) 
$_GET[
'ref_id']) ||
 
 4910            $this->user->isAnonymous() ||
 
 4912            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 4915        $post_id = $this->objCurrentPost->getId();
 
 4917            $draft_id_to_delete = (int) 
$_GET[
'draft_id'];
 
 4920            if (!$draft_obj->getDraftId() || ($draft_obj->getDraftId() != $draft_id_to_delete)) {
 
 4921                $this->ctrl->clearParameters($this);
 
 4922                $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 4923                $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 4924                $this->ctrl->redirect($this, 
'viewThread');
 
 4928        $this->deleteMobsOfDraft($draft_obj->getDraftId(), $draft_obj->getPostMessage());
 
 4931        $objFileDataForumDrafts->delete();
 
 4934            $GLOBALS[
'ilAppEventHandler']->raise(
 
 4938                    'draftObj' => $draft_obj,
 
 4939                    'obj_id' => $this->object->getId(),
 
 4940                    'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
 
 4944        $draft_obj->deleteDraft();
 
 4946        ilUtil::sendSuccess($this->lng->txt(
'delete_draft_successfully'), 
true);
 
 4947        $this->ctrl->clearParameters($this);
 
 4948        $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 4949        $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 4950        $this->ctrl->redirect($this, 
'viewThread');
 
 4955        $draftId = (int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
 
 4957            $this->requestAction !== 
'ready_showreply' &&
 
 4958            $this->access->checkAccess(
'read', 
'', $this->object->getRefId()) &&
 
 4959            $this->access->checkAccess(
'add_reply', 
'', $this->object->getRefId())
 
 4961            $action = new \ilForumAutoSaveAsyncDraftAction(
 
 4963                $this->getReplyEditForm(),
 
 4964                $this->objProperties,
 
 4965                $this->objCurrentTopic,
 
 4966                $this->objCurrentPost,
 
 4967                function (
string $message) : 
string {
 
 4968                    return $this->handleFormInput(
$message);
 
 4975            echo json_encode($action->executeAndGetResponseObject());
 
 4983        $draftId = (int) ($this->httpRequest->getQueryParams()[
'draft_id'] ?? 0);
 
 4985            $this->requestAction !== 
'ready_showreply' &&
 
 4986            $this->access->checkAccess(
'read', 
'', $this->object->getRefId()) &&
 
 4987            $this->access->checkAccess(
'add_thread', 
'', $this->object->getRefId())
 
 4989            $action = new \ilForumAutoSaveAsyncDraftAction(
 
 4991                $this->buildThreadForm(),
 
 4992                $this->objProperties,
 
 4993                $this->objCurrentTopic,
 
 4994                $this->objCurrentPost,
 
 4995                function (
string $message) : 
string {
 
 4996                    return $this->handleFormInput(
$message, 
false);
 
 5003            echo json_encode($action->executeAndGetResponseObject());
 
 5028            if ($this->objCurrentPost->getId() != $node->
getId() || (
 
 5031                    [
'showreply', 
'showedit', 
'censor', 
'delete']
 
 5032                ) && !$this->displayConfirmPostActivation()
 
 5034                if ($this->is_moderator || $node->
isActivated() || $node->
isOwner($this->user->getId())) {
 
 5035                    if (!$this->objCurrentTopic->isClosed() && $node->
isActivated() &&
 
 5036                        $this->access->checkAccess(
'add_reply', 
'', (
int) $this->object->getRefId()) &&
 
 5039                        $this->ctrl->setParameter($this, 
'action', 
'showreply');
 
 5040                        $this->ctrl->setParameter($this, 
'pos_pk', $node->
getId());
 
 5041                        $this->ctrl->setParameter($this, 
'page', $pageIndex);
 
 5042                        $this->ctrl->setParameter(
 
 5047                        $this->ctrl->setParameter($this, 
'thr_pk', $node->
getThreadId());
 
 5049                        if (!isset($draftsObjects[$node->
getId()])) {
 
 5050                            $actions[
'reply_to_postings'] = $this->ctrl->getLinkTarget(
 
 5053                                'reply_' . $node->
getId()
 
 5057                        $this->ctrl->clearParameters($this);
 
 5060                    if (!$this->objCurrentTopic->isClosed() &&
 
 5061                        ($node->
isOwner($this->user->getId()) || $this->is_moderator) &&
 
 5063                        !$this->user->isAnonymous()
 
 5065                        $this->ctrl->setParameter($this, 
'action', 
'showedit');
 
 5066                        $this->ctrl->setParameter($this, 
'pos_pk', $node->
getId());
 
 5067                        $this->ctrl->setParameter($this, 
'thr_pk', $node->
getThreadId());
 
 5068                        $this->ctrl->setParameter($this, 
'page', $pageIndex);
 
 5069                        $this->ctrl->setParameter(
 
 5075                        $actions[
'edit'] = $this->ctrl->getLinkTarget($this, 
'viewThread', $node->
getId());
 
 5077                        $this->ctrl->clearParameters($this);
 
 5081                        $this->ctrl->setParameter($this, 
'pos_pk', $node->
getId());
 
 5082                        $this->ctrl->setParameter($this, 
'thr_pk', $node->
getThreadId());
 
 5083                        $this->ctrl->setParameter($this, 
'page', $pageIndex);
 
 5084                        $this->ctrl->setParameter(
 
 5089                        $this->ctrl->setParameter($this, 
'viewmode', 
$_SESSION[
'viewmode']);
 
 5091                        $actions[
'frm_mark_as_read'] = $this->ctrl->getLinkTarget(
 
 5097                        $this->ctrl->clearParameters($this);
 
 5102                        $this->ctrl->setParameter($this, 
'pos_pk', $node->
getId());
 
 5103                        $this->ctrl->setParameter($this, 
'thr_pk', $node->
getThreadId());
 
 5104                        $this->ctrl->setParameter($this, 
'page', $pageIndex);
 
 5105                        $this->ctrl->setParameter(
 
 5110                        $this->ctrl->setParameter($this, 
'viewmode', 
$_SESSION[
'viewmode']);
 
 5112                        $actions[
'frm_mark_as_unread'] = $this->ctrl->getLinkTarget(
 
 5118                        $this->ctrl->clearParameters($this);
 
 5122                        $this->ctrl->setParameterByClass(
'ilforumexportgui', 
'print_post', $node->
getId());
 
 5123                        $this->ctrl->setParameterByClass(
'ilforumexportgui', 
'top_pk', $node->
getForumId());
 
 5124                        $this->ctrl->setParameterByClass(
'ilforumexportgui', 
'thr_pk', $node->
getThreadId());
 
 5126                        $actions[
'print'] = $this->ctrl->getLinkTargetByClass(
'ilforumexportgui', 
'printPost');
 
 5128                        $this->ctrl->clearParameters($this);
 
 5131                    if (!$this->objCurrentTopic->isClosed() &&
 
 5132                        ($this->is_moderator ||
 
 5134                        !$this->user->isAnonymous()
 
 5136                        $this->ctrl->setParameter($this, 
'action', 
'delete');
 
 5137                        $this->ctrl->setParameter($this, 
'pos_pk', $node->
getId());
 
 5138                        $this->ctrl->setParameter($this, 
'thr_pk', $node->
getThreadId());
 
 5139                        $this->ctrl->setParameter($this, 
'page', $pageIndex);
 
 5140                        $this->ctrl->setParameter(
 
 5146                        $actions[
'delete'] = $this->ctrl->getLinkTarget($this, 
'viewThread', $node->
getId());
 
 5148                        $this->ctrl->clearParameters($this);
 
 5151                    if (!$this->objCurrentTopic->isClosed() && $this->is_moderator) {
 
 5152                        $this->ctrl->setParameter($this, 
'action', 
'censor');
 
 5153                        $this->ctrl->setParameter($this, 
'pos_pk', $node->
getId());
 
 5154                        $this->ctrl->setParameter($this, 
'thr_pk', $node->
getThreadId());
 
 5155                        $this->ctrl->setParameter($this, 
'page', $pageIndex);
 
 5156                        $this->ctrl->setParameter(
 
 5162                            $actions[
'frm_revoke_censorship'] = $this->ctrl->getLinkTarget(
 
 5168                            $actions[
'frm_censorship'] = $this->ctrl->getLinkTarget(
 
 5175                        $this->ctrl->clearParameters($this);
 
 5177                        $this->ctrl->setParameter($this, 
'pos_pk', $node->
getId());
 
 5178                        $this->ctrl->setParameter($this, 
'thr_pk', $node->
getThreadId());
 
 5179                        $this->ctrl->setParameter($this, 
'page', $pageIndex);
 
 5180                        $this->ctrl->setParameter(
 
 5187                            $actions[
'activate_post'] = $this->ctrl->getLinkTarget(
 
 5189                                'askForPostActivation',
 
 5194                        $this->ctrl->clearParameters($this);
 
 5198        } elseif (
$_GET[
'draft_id'] != $draft->getDraftId() || !in_array($action, [
'deletedraft', 
'editdraft'])) {
 
 5200            $this->ctrl->setParameter($this, 
'action', 
'publishdraft');
 
 5201            $this->ctrl->setParameter($this, 
'pos_pk', $node->
getId());
 
 5202            $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentTopic->getId());
 
 5203            $this->ctrl->setParameter($this, 
'page', (
int) $this->httpRequest->getQueryParams()[
'page']);
 
 5204            $this->ctrl->setParameter($this, 
'draft_id', $draft->getDraftId());
 
 5205            $this->ctrl->setParameter(
 
 5210            $actions[
'publish'] = $this->ctrl->getLinkTarget($this, 
'publishSelectedDraft', $node->
getId());
 
 5211            $this->ctrl->clearParameters($this);
 
 5213            $this->ctrl->setParameter($this, 
'action', 
'editdraft');
 
 5214            $this->ctrl->setParameter($this, 
'pos_pk', $node->
getId());
 
 5215            $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentTopic->getId());
 
 5216            $this->ctrl->setParameter($this, 
'draft_id', $draft->getDraftId());
 
 5217            $this->ctrl->setParameter($this, 
'page', (
int) $this->httpRequest->getQueryParams()[
'page']);
 
 5218            $this->ctrl->setParameter(
 
 5223            $actions[
'edit'] = $this->ctrl->getLinkTarget($this, 
'editDraft', 
'draft_edit_' . $draft->getDraftId());
 
 5224            $this->ctrl->clearParameters($this);
 
 5226            $this->ctrl->setParameter($this, 
'action', 
'deletedraft');
 
 5227            $this->ctrl->setParameter($this, 
'pos_pk', $node->
getId());
 
 5228            $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentTopic->getId());
 
 5229            $this->ctrl->setParameter($this, 
'draft_id', $draft->getDraftId());
 
 5230            $this->ctrl->setParameter($this, 
'page', (
int) $this->httpRequest->getQueryParams()[
'page']);
 
 5231            $this->ctrl->setParameter(
 
 5236            $actions[
'delete'] = $this->ctrl->getLinkTarget($this, 
'viewThread', $node->
getId());
 
 5237            $this->ctrl->clearParameters($this);
 
 5240        $tpl->setCurrentBlock(
'posts_row');
 
 5241        if (count($actions) > 0 && !$this->objCurrentTopic->isClosed()) {
 
 5245            foreach ($actions as $lng_id => 
$url) {
 
 5248                    $sb_item->setCaption($lng_id);
 
 5249                    $sb_item->setUrl(
$url);
 
 5251                    $action_button->setDefaultButton($sb_item);
 
 5255                    $sb_item->setCaption($lng_id);
 
 5256                    $sb_item->setUrl(
$url);
 
 5262            $tpl->setVariable(
'COMMANDS', $action_button->render());
 
 5274            !$this->access->checkAccess(
'add_reply', 
'', $this->object->getRefId()) || $this->user->isAnonymous() ||
 
 5277            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 5288        if (!$this->checkDraftAccess($draftId)) {
 
 5289            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->MESSAGE);
 
 5298        if (is_array($draftsFromHistory) && 
sizeof($draftsFromHistory) > 0) {
 
 5300            $modal->setHeading($this->lng->txt(
'restore_draft_from_autosave'));
 
 5301            $modal->setId(
'frm_autosave_restore');
 
 5302            $form_tpl = new \ilTemplate(
'tpl.restore_thread_draft.html', 
true, 
true, 
'Modules/Forum');
 
 5304            foreach ($draftsFromHistory as $key => $history_instance) {
 
 5306                $accordion->setId(
'acc_' . $history_instance->getHistoryId());
 
 5308                $form_tpl->setCurrentBlock(
'list_item');
 
 5312                    $history_instance->getDraftDate(),
 
 5315                $this->ctrl->setParameter($this, 
'history_id', $history_instance->getHistoryId());
 
 5316                $header = $history_date . 
' - ' . $history_instance->getPostSubject();
 
 5317                $accordion->addItem($header, 
$message . $this->uiRenderer->render(
 
 5318                    $this->uiFactory->button()->standard(
 
 5319                        $this->lng->txt(
'restore'),
 
 5320                        $this->ctrl->getLinkTarget($this, 
'restoreFromHistory')
 
 5324                $form_tpl->setVariable(
'ACC_AUTO_SAVE', $accordion->getHtml());
 
 5325                $form_tpl->parseCurrentBlock();
 
 5328            $form_tpl->setVariable(
'RESTORE_DATA_EXISTS', 
'found_threat_history_to_restore');
 
 5329            $modal->setBody($form_tpl->get());
 
 5331            $this->modal_history = $modal->getHTML();
 
 5342        if ($this->
user->isAnonymous() && !$this->user->isCaptchaVerified() && \ilCaptchaUtil::isActiveForForum()) {
 
 5343            $this->
user->setCaptchaVerified(
true);
 
 5357            $action == 
'showedit' && (
 
 5358                (!$this->is_moderator && !$node->
isOwner($this->user->getId()) || $this->user->isAnonymous()) || $node->
isCensored()
 
 5361            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->getMessage());
 
 5362        } elseif ($action == 
'showreply' && !$this->access->checkAccess(
'add_reply', 
'', (
int) 
$_GET[
'ref_id'])) {
 
 5363            $this->
error->raiseError($this->lng->txt(
'permission_denied'), $this->error->getMessage());
 
 5366        $tpl->setVariable(
'REPLY_ANKER', 
'reply_' . $this->objCurrentPost->getId());
 
 5367        $oEditReplyForm = $this->getReplyEditForm();
 
 5368        if ($action !== 
'editdraft') {
 
 5369            switch ($this->objProperties->getSubjectSetting()) {
 
 5370                case 'add_re_to_subject':
 
 5371                    $subject = $this->getModifiedReOnSubject(
true);
 
 5374                case 'preset_subject':
 
 5375                    $subject = $this->objCurrentPost->getSubject();
 
 5378                case 'empty_subject':
 
 5387                if ($this->ctrl->getCmd() == 
'savePost' || $this->ctrl->getCmd() == 
'saveAsDraft') {
 
 5388                    $oEditReplyForm->setValuesByPost();
 
 5389                } elseif ($this->ctrl->getCmd() == 
'quotePost') {
 
 5397                    $oEditReplyForm->setValuesByPost();
 
 5398                    $oEditReplyForm->getItemByPostVar(
'message')->setValue(
 
 5403                                $authorinfo->getAuthorName()
 
 5404                            ) . 
"\n" . $oEditReplyForm->getInput(
'message'),
 
 5409                    $oEditReplyForm->setValuesByArray(array(
 
 5411                        'subject' => $subject,
 
 5415                        'del_file' => array()
 
 5419                $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 5420                $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 5422                $jsTpl = 
new ilTemplate(
'tpl.forum_post_quoation_ajax_handler.html', 
true, 
true, 
'Modules/Forum');
 
 5423                $jsTpl->setVariable(
 
 5424                    'IL_FRM_QUOTE_CALLBACK_SRC',
 
 5425                    $this->ctrl->getLinkTarget($this, 
'getQuotationHTMLAsynch', 
'', 
true)
 
 5427                $this->ctrl->clearParameters($this);
 
 5428                $tpl->setVariable(
'FORM_ADDITIONAL_JS', $jsTpl->get());
 
 5432                if ($this->ctrl->getCmd() == 
'savePost') {
 
 5433                    $oEditReplyForm->setValuesByPost();
 
 5435                    $oEditReplyForm->setValuesByArray(array(
 
 5437                        'subject' => $this->objCurrentPost->getSubject(),
 
 5439                            $this->objCurrentPost->getMessage(),
 
 5442                        'notify' => $this->objCurrentPost->isNotificationEnabled() ? 
true : 
false,
 
 5444                        'del_file' => array()
 
 5448                $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getParentId());
 
 5449                $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 5450                $jsTpl = 
new ilTemplate(
'tpl.forum_post_quoation_ajax_handler.html', 
true, 
true, 
'Modules/Forum');
 
 5451                $jsTpl->setVariable(
 
 5452                    'IL_FRM_QUOTE_CALLBACK_SRC',
 
 5453                    $this->ctrl->getLinkTarget($this, 
'getQuotationHTMLAsynch', 
'', 
true)
 
 5455                $this->ctrl->clearParameters($this);
 
 5456                $tpl->setVariable(
'FORM_ADDITIONAL_JS', $jsTpl->get());
 
 5460                if (in_array($this->ctrl->getCmd(), array(
'saveDraft', 
'updateDraft', 
'publishDraft'))) {
 
 5461                    $oEditReplyForm->setValuesByPost();
 
 5462                } elseif (isset(
$_GET[
'draft_id']) && (
int) 
$_GET[
'draft_id'] > 0) {
 
 5467                        $this->
user->getId(),
 
 5468                        $this->objCurrentPost->getId(),
 
 5469                        (
int) 
$_GET[
'draft_id']
 
 5471                    $oEditReplyForm->setValuesByArray(array(
 
 5472                        'alias' => $draftObject->getPostUserAlias(),
 
 5473                        'subject' => $draftObject->getPostSubject(),
 
 5475                            $draftObject->getPostMessage(),
 
 5478                        'notify' => $draftObject->getNotify() ? 
true : 
false,
 
 5484                $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 5485                $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 5487                $jsTpl = 
new ilTemplate(
'tpl.forum_post_quoation_ajax_handler.html', 
true, 
true, 
'Modules/Forum');
 
 5488                $jsTpl->setVariable(
 
 5489                    'IL_FRM_QUOTE_CALLBACK_SRC',
 
 5490                    $this->ctrl->getLinkTarget($this, 
'getQuotationHTMLAsynch', 
'', 
true)
 
 5492                $this->ctrl->clearParameters($this);
 
 5493                $tpl->setVariable(
'FORM_ADDITIONAL_JS', $jsTpl->get());
 
 5497        $this->ctrl->setParameter($this, 
'pos_pk', $this->objCurrentPost->getId());
 
 5498        $this->ctrl->setParameter($this, 
'thr_pk', $this->objCurrentPost->getThreadId());
 
 5499        $this->ctrl->setParameter($this, 
'page', (
int) $this->httpRequest->getQueryParams()[
'page']);
 
 5500        $this->ctrl->setParameter(
 
 5505        $this->ctrl->setParameter(
 
 5510        if ($action !== 
'editdraft') {
 
 5511            $tpl->setVariable(
'FORM', $oEditReplyForm->getHTML());
 
 5513        $this->ctrl->clearParameters($this);
 
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
Accordion user interface class.
Column user interface class.
setBlockProperty($a_block_type, $a_property, $a_value)
This function is supposed to be used for block type specific properties, that should be passed to ilB...
setRepositoryMode($a_repositorymode)
Set RepositoryMode.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Confirmation screen class.
News settings for containers.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
Base class for ILIAS Exception handling.
Export User Interface Class.
This class handles all operations on files for the drafts of a forum object.
This class handles all operations on files for the forum object.
Class ilForumDraftHistory.
static getInstancesByDraftId($draft_id)
Class ilForumDraftsTableGUI.
Class ilForumExplorerGUI.
Forum export to HTML and Print.
Class ilForumModeratorsGUI.
ilForumMoveTopicsExplorer
Class ilForumNotification.
static lookupAutosaveInterval()
static isAutoSavePostDraftAllowed()
static newInstanceByDraftId($draft_id)
static isSavePostDraftAllowed()
static getDraftInstancesByUserId($user_id)
static createDraftBackup($draft_id)
static getThreadDraftData($post_author_id, $forum_id)
static getSortedDrafts(int $usrId, int $threadId, int $sorting=ilForumProperties::VIEW_DATE_ASC)
setChangeDate($a_changedate)
static getInstance($a_obj_id=0)
Class ilForumSettingsGUI.
Class ilForumStatisticsTableGUI.
Class ilForumTopicTableGUI.
static lookupForumIdByTopicId($a_topic_id)
static _lookupDate($thread_id)
static _lookupTitle($a_topic_id)
Looks up the title/subject of a topic/thread.
static getPublicUserAlias($user_alias, $is_anonymized=false)
static moveMediaObjects($post_message, $source_type, $source_id, $target_type, $target_id, $direction=0)
static saveMediaObjects($post_message, $target_type, $target_id, $direction=0)
Class Forum core functions for forum.
static _isModerator($a_ref_id, $a_usr_id)
checks whether a user is moderator of a given forum object
prepareText($text, $edit=0, $quote_user='', $type='')
prepares given string @access public
static _lookupObjIdForForumId($a_for_id)
static get($a_glyph, $a_text="")
Get glyph html.
Online help application class.
static _getInstanceByType(string $type)
Factory method for creating purifier instances.
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
static getInstance()
Get instance.
Navigation History of Repository Items.
addItem( $a_ref_id, $a_link, $a_type, $a_title="", $a_sub_obj_id="", $a_goto_link="")
Add an item to the stack.
static getFirstNewsIdForContext( $a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id="", $a_context_sub_obj_type="")
Get first new id of news set related to a certain context.
This class represents a non editable value in a property form.
static _getRichTextEditorUserState()
Gets the state of the rich text editor visibility for the current user.
static _setRichTextEditorUserState($a_state)
Sets the state of the rich text editor visibility for the current user.
toggleExplorerNodeStateObject()
Toggle explorer node.
ensureThreadBelongsToForum(int $objId, \ilForumTopic $thread)
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
saveTopLevelDraftObject()
getThreadEditingForm($a_thread_id)
doCaptchaCheck()
Performs a CAPTCHA check for anonymous users if the CAPTCHA should be used for forums in the public a...
publishDraftObject($use_replyform=true)
saveThreadAsDraftObject()
disableForumNotificationObject()
cancelMoveThreadsObject()
initHeaderAction($a_sub_type=null, $a_sub_id=null)
Add header action menu.ilObjectListGUI
getModifiedReOnSubject($on_reply=false)
displayConfirmPostActivation()
$display_confirm_post_activation
toggleThreadNotificationObject()
executeCommand()
execute command
buildThreadForm($isDraft=false)
getTabs()
get tabs abstract method.
getSubTabs($subtab='showThreads')
isUserAllowedToDeactivateNotification()
getEditFormCustomValues(array &$a_values)
static _goto($a_target, $a_thread=0, $a_posting=0)
renderDraftContent(ilTemplate $tpl, string $action, ilForumPost $referencePosting, array $drafts)
autosaveDraftAsyncObject()
renderSplitButton(ilTemplate $tpl, string $action, bool $is_post, ilForumPost $node, int $pageIndex=0, ilForumPostDraft $draft=null)
publishSelectedDraftObject()
editThreadDraftObject(\ilPropertyFormGUI $form=null)
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
autosaveThreadDraftAsyncObject()
performMergeThreadsObject()
hideToolbar($a_flag=null)
setColumnSettings(ilColumnGUI $column_gui)
May be overwritten in subclasses.
deliverDraftZipFileObject()
restoreFromHistoryObject()
confirmMergeThreadsObject()
isWritingWithPseudonymAllowed()
handleFormInput($a_text, $a_stripslashes=true)
updateCustom(ilPropertyFormGUI $a_form)
createThread(\ilForumPostDraft $draft, bool $createFromDraft=false)
Refactored thread creation to method, refactoring to a separate class should be done in next refactor...
deletePostingDraftObject()
createTopLevelPostObject()
performDeleteThreadsObject()
confirmDeleteThreadDraftsObject()
publishThreadDraftObject()
decorateWithAutosave(\ilPropertyFormGUI $form)
afterSave(ilObject $a_new_object)
editThreadObject($threadId, ilPropertyFormGUI $form=null)
performThreadsActionObject()
askForPostActivationObject()
enableForumNotificationObject()
performPostActivationObject()
setDisplayConfirmPostActivation($status=0)
deleteSelectedDraft(ilForumPostDraft $draft_obj=null)
renderPostContent(ilTemplate $tpl, ilForumPost $node, string $action, int $pageIndex, int $postIndex)
performMoveThreadsObject()
ensureValidPageForCurrentPosting(array $subtree_nodes, array $pagedPostings, int $pageSize, ilForumPost $firstForumPost)
deleteThreadDraftsObject()
saveThreadSortingObject()
updateThreadDraftObject()
initEditCustomForm(ilPropertyFormGUI $a_form)
renderSortationControl(int $currentSorting)
renderViewModeControl(int $currentViewMode)
prepareFormOutput($a_text)
deleteMobsOfDraft($draft_id, $message)
todo: move to ilForumUtil
checkDraftAccess(int $draftId)
static lookupForumIdByRefId($ref_id)
static lookupForumIdByObjId($obj_id)
GUI class for the workflow of copying objects.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput($a_show_subobjects=true)
prepare output
getCenterColumnHTML()
Get center column.
getCreationMode()
get creation mode
addHeaderAction()
Add header action menu.
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
getRefId()
get reference id @access public
static _getAllReferences($a_id)
get all reference ids of object
getId()
get object id @access public
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
GUI class for public user profile presentation.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static _getMediaObjects($a_text, $a_direction=0)
Returns all media objects found in the passed string.
static _getRTEClassname()
static getOverallRatingForObject($a_obj_id, $a_obj_type, $a_sub_obj_id=null, $a_sub_obj_type=null, $a_category_id=null)
Get overall rating for an object.
static getSearchBlockHTML($a_title)
Get standar search block html.
static set($a_var, $a_val)
Set a value.
static get($a_var)
Get a value.
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
This class represents a text property in a property form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static infoPanel($a_keep=true)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
This is how the factory for UI elements looks.
An entity that renders components to a string output.
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl