ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjForumGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Modules/Forum/classes/class.ilForumSettingsGUI.php';
5require_once 'Services/Object/classes/class.ilObjectGUI.php';
6require_once 'Services/Table/classes/class.ilTable2GUI.php';
7require_once 'Modules/Forum/classes/class.ilForumProperties.php';
8require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
9require_once 'Modules/Forum/classes/class.ilForumPost.php';
10require_once 'Modules/Forum/classes/class.ilForum.php';
11require_once 'Modules/Forum/classes/class.ilForumTopic.php';
12require_once 'Services/RTE/classes/class.ilRTE.php';
13require_once 'Services/PersonalDesktop/interfaces/interface.ilDesktopItemHandling.php';
14require_once 'Modules/Forum/classes/class.ilForumMailNotification.php';
15require_once 'Services/UIComponent/SplitButton/classes/class.ilSplitButtonGUI.php';
16require_once 'Modules/Forum/classes/class.ilForumPostDraft.php';
17require_once './Modules/Forum/classes/class.ilFileDataForumDrafts.php';
18require_once './Modules/Forum/classes/class.ilForumUtil.php';
19require_once './Modules/Forum/classes/class.ilForumDraftsHistory.php';
20require_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
21
37{
38 public $modal_history = '';
43
48
53
58
62 private $is_moderator = false;
63
68
73
78
82 private $hideToolbar = false;
83
88
92 public $object;
93
98
103
108
109 public $access;
111 public $tabs;
112 public $error;
114 public $user;
115 public $settings;
116 public $toolbar;
118 public $rbac;
119 public $locator;
120 public $ilHelp;
121
122 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
123 {
124 global $DIC;
125
126 $this->ctrl = $DIC->ctrl();
127 $this->ctrl->saveParameter($this, array('ref_id', 'cmdClass'));
128
129 $this->tpl = $DIC->ui()->mainTemplate();
130 $this->lng = $DIC->language();
131
132 $this->access = $DIC->access();
133 $this->ilObjDataCache = $DIC['ilObjDataCache'];
134 $this->tabs = $DIC->tabs();
135 $this->error = $DIC['ilErr'];
136 $this->ilNavigationHistory = $DIC['ilNavigationHistory'];
137 $this->user = $DIC->user();
138 $this->settings = $DIC->settings();
139 $this->toolbar = $DIC->toolbar();
140 $this->repositoryTree = $DIC->repositoryTree();
141 $this->ilHelp = $DIC['ilHelp'];
142 $this->rbac = $DIC->rbac();
143 $this->locator = $DIC['ilLocator'];
144
145 $this->type = 'frm';
146 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
147
148 $this->lng->loadLanguageModule('forum');
149
150 $this->initSessionStorage();
151
152 // Forum properties
153 $this->objProperties = ilForumProperties::getInstance($this->ilObjDataCache->lookupObjId($_GET['ref_id']));
154
155 // Stored due to performance issues
156 $this->is_moderator = $this->access->checkAccess('moderate_frm', '', $_GET['ref_id']);
157
158 // Model of current topic/thread
159 $this->objCurrentTopic = new ilForumTopic((int) $_GET['thr_pk'], $this->is_moderator);
160
161 // Model of current post
162 $this->objCurrentPost = new ilForumPost((int) $_GET['pos_pk'], $this->is_moderator);
163
164 $this->forum_overview_setting = $this->settings->get('forum_overview');
165 }
166
167 protected function initSessionStorage()
168 {
169 $sess = ilSession::get('frm');
170 if (!is_array($sess)) {
171 $sess = array();
172 ilSession::set('frm', $sess);
173 }
174
175 if (isset($_GET['thr_fk']) && !is_array($sess[(int) $_GET['thr_fk']])) {
176 $sess[(int) $_GET['thr_fk']] = array();
177 ilSession::set('frm', $sess);
178 }
179 }
180
185 public function ensureThreadBelongsToForum($objId, \ilForumTopic $thread)
186 {
187 $forumId = \ilObjForum::lookupForumIdByObjId($objId);
188 if ((int) $thread->getForumId() !== (int) $forumId) {
189 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
190 }
191 }
192
197 {
200
201 $this->tpl->addJavascript('./Modules/Forum/js/autosave.js');
202 $autosave_cmd = 'autosaveDraftAsync';
203 if ($this->objCurrentPost->getId() == 0 && $this->objCurrentPost->getThreadId() == 0) {
204 $autosave_cmd = 'autosaveThreadDraftAsync';
205 }
206 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
207 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
208 $draft_id = $_GET['draft_id'] > 0 ? $_GET['draft_id']: 0;
209 $this->ctrl->setParameter($this, 'draft_id', $draft_id);
210 $this->ctrl->setParameter($this, 'action', $_GET['action']);
211 $this->tpl->addOnLoadCode("il.Language.setLangVar('saving', " . json_encode($this->lng->txt('saving')) . ");");
212
213 $this->tpl->addOnLoadCode('il.ForumDraftsAutosave.init(' . json_encode(array(
214 'loading_img_src' => ilUtil::getImagePath('loader.svg'),
215 'draft_id' => $draft_id,
216 'interval' => $interval * 1000,
217 'url' => $this->ctrl->getFormAction($this, $autosave_cmd, '', true, false),
218 'selectors' => array(
219 'form' => '#form_' . $form->getId()
220 )
221 )) . ');');
222 }
223 }
224
228 private function isHierarchicalView()
229 {
230 return (
231 $_SESSION['viewmode'] == 'answers' ||
233 ) || !(
234 $_SESSION['viewmode'] == 'date' ||
236 );
237 }
238
242 private function isTopLevelReplyCommand()
243 {
244 return in_array(
245 strtolower($this->ctrl->getCmd()),
246 array_map('strtolower', array('createTopLevelPost', 'quoteTopLevelPost', 'saveTopLevelPost'))
247 );
248 }
249
250 public function executeCommand()
251 {
252 $next_class = $this->ctrl->getNextClass($this);
253 $cmd = $this->ctrl->getCmd();
254
255 $exclude_cmds = array(
256 'viewThread', 'markPostUnread','markPostRead', 'showThreadNotification',
257 'performPostActivation',
258 'askForPostActivation', 'askForPostDeactivation',
259 'toggleThreadNotification', 'toggleThreadNotificationTab',
260 'toggleStickiness', 'cancelPost', 'savePost', 'saveTopLevelPost', 'createTopLevelPost', 'quoteTopLevelPost', 'quotePost', 'getQuotationHTMLAsynch',
261 'autosaveDraftAsync', 'autosaveThreadDraftAsync',
262 'saveAsDraft', 'editDraft', 'updateDraft', 'deliverDraftZipFile', 'deliverZipFile', 'cancelDraft',
263 'publishThreadDraft', 'deleteThreadDrafts'
264 );
265
266 if (!in_array($cmd, $exclude_cmds)) {
267 $this->prepareOutput();
268 }
269
270 // add entry to navigation history
271 if (!$this->getCreationMode() && !$this->ctrl->isAsynch() && $this->access->checkAccess('read', '', $_GET['ref_id'])) {
273 $_GET['ref_id'],
274 'ilias.php?baseClass=ilRepositoryGUI&amp;cmd=showThreads&amp;ref_id=' . $_GET['ref_id'],
275 'frm'
276 );
277 }
278
279 switch ($next_class) {
280 case 'ilforumsettingsgui':
282 $this->ctrl->forwardCommand($forum_settings_gui);
283 break;
284
285 case 'ilrepositoryobjectsearchgui':
286 $this->addHeaderAction();
287 $this->setSideBlocks();
288 $this->tabs->activateTab("forums_threads");
289 $this->ctrl->setReturn($this, 'view');
290 include_once './Services/Search/classes/class.ilRepositoryObjectSearchGUI.php';
291 $search_gui = new ilRepositoryObjectSearchGUI(
292 $this->object->getRefId(),
293 $this,
294 'view'
295 );
296 $this->ctrl->forwardCommand($search_gui);
297 break;
298
299 case 'ilpermissiongui':
300 require_once 'Services/AccessControl/classes/class.ilPermissionGUI.php';
301 $perm_gui = new ilPermissionGUI($this);
302 $this->ctrl->forwardCommand($perm_gui);
303 break;
304
305 case 'ilforumexportgui':
306 require_once 'Modules/Forum/classes/class.ilForumExportGUI.php';
307 $fex_gui = new ilForumExportGUI();
308 $this->ctrl->forwardCommand($fex_gui);
309 exit();
310 break;
311
312 case 'ilforummoderatorsgui':
313 require_once 'Modules/Forum/classes/class.ilForumModeratorsGUI.php';
314 $fm_gui = new ilForumModeratorsGUI();
315 $this->ctrl->forwardCommand($fm_gui);
316 break;
317
318 case 'ilinfoscreengui':
319 $this->infoScreen();
320 break;
321
322 case 'ilcolumngui':
323 $this->showThreadsObject();
324 break;
325
326 case 'ilpublicuserprofilegui':
327 include_once 'Services/User/classes/class.ilPublicUserProfileGUI.php';
328 $profile_gui = new ilPublicUserProfileGUI((int) $_GET['user']);
329 $add = $this->getUserProfileAdditional((int) $_GET['ref_id'], (int) $_GET['user']);
330 $profile_gui->setAdditional($add);
331 $ret = $this->ctrl->forwardCommand($profile_gui);
332 $this->tpl->setContent($ret);
333 break;
334
335 case 'ilobjectcopygui':
336 include_once 'Services/Object/classes/class.ilObjectCopyGUI.php';
337 $cp = new ilObjectCopyGUI($this);
338 $cp->setType('frm');
339 $this->ctrl->forwardCommand($cp);
340 break;
341
342 case 'ilexportgui':
343 $this->tabs->activateTab('export');
344 include_once 'Services/Export/classes/class.ilExportGUI.php';
345 $exp = new ilExportGUI($this);
346 $exp->addFormat('xml');
347 $this->ctrl->forwardCommand($exp);
348 break;
349
350 case "ilratinggui":
351 if (!$this->objProperties->isIsThreadRatingEnabled() || $this->user->isAnonymous()) {
352 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
353 }
354
355 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
356 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
357 }
358
359 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $this->objCurrentTopic);
360
361 require_once 'Services/Rating/classes/class.ilRatingGUI.php';
362 $rating_gui = new ilRatingGUI();
363 $rating_gui->setObject($this->object->getId(), $this->object->getType(), $this->objCurrentTopic->getId(), 'thread');
364
365 $this->ctrl->setParameter($this, 'thr_pk', (int) $this->objCurrentTopic->getId());
366 $this->ctrl->forwardCommand($rating_gui);
367
368 $avg = ilRating::getOverallRatingForObject($this->object->getId(), $this->object->getType(), (int) $this->objCurrentTopic->getId(), 'thread');
369 $this->objCurrentTopic->setAverageRating($avg['avg']);
370 $this->objCurrentTopic->update();
371
372 $this->ctrl->redirect($this, "showThreads");
373 break;
374
375 case 'ilcommonactiondispatchergui':
376 include_once 'Services/Object/classes/class.ilCommonActionDispatcherGUI.php';
378 $this->ctrl->forwardCommand($gui);
379 break;
380
381 default:
382 // alex, 11 Jan 2011:
383 // I inserted this workaround due to bug report 6971.
384 // In general the command handling is quite obscure here.
385 // The form action of the table should be filled
386 // with $ilCtrl->getFormAction(..) not with $ilCtrl->getLinkTarget(..)
387 // Commands should be determined with $ilCtrl->getCmd() not
388 // with accessing $_POST['selected_cmd'], since this is internal
389 // of ilTable2GUI/ilCtrl and may change.
390 if (isset($_POST['select_cmd2'])) {
391 $_POST['selected_cmd'] = $_POST["selected_cmd2"];
392 }
393
394 if (isset($_POST['selected_cmd']) && $_POST['selected_cmd'] != null) {
395 $member_cmd = array('enableAdminForceNoti', 'disableAdminForceNoti', 'enableHideUserToggleNoti', 'disableHideUserToggleNoti');
396 in_array($_POST['selected_cmd'], $member_cmd) ? $cmd = $_POST['selected_cmd'] : $cmd = 'performThreadsAction';
397 } elseif (!$cmd && !$_POST['selected_cmd']) {
398 $cmd = 'showThreads';
399 }
400
401 $cmd .= 'Object';
402 $this->$cmd();
403
404 break;
405 }
406
407 // suppress for topic level
408 if ($cmd != 'viewThreadObject' && $cmd != 'showUserObject') {
409 $this->addHeaderAction();
410 }
411 }
412
416 public function infoScreenObject()
417 {
418 $this->ctrl->setCmd('showSummary');
419 $this->ctrl->setCmdClass('ilinfoscreengui');
420 $this->infoScreen();
421 }
422
426 protected function initEditCustomForm(ilPropertyFormGUI $a_form)
427 {
428 $this->forum_settings_gui = new ilForumSettingsGUI($this);
429 $this->forum_settings_gui->getCustomForm($a_form);
430 }
431
435 protected function getEditFormCustomValues(array &$a_values)
436 {
437 $this->forum_settings_gui->getCustomValues($a_values);
438 }
439
443 protected function updateCustom(ilPropertyFormGUI $a_form)
444 {
445 $this->forum_settings_gui->updateCustomValues($a_form);
446 }
447
452 private function getThreadEditingForm($a_thread_id)
453 {
454 $form = new ilPropertyFormGUI();
455 $this->ctrl->setParameter($this, 'thr_pk', $a_thread_id);
456 $form->setFormAction($this->ctrl->getFormAction($this, 'updateThread'));
457
458 $ti_prop = new ilTextInputGUI($this->lng->txt('title'), 'title');
459 $ti_prop->setRequired(true);
460 $ti_prop->setMaxLength(255);
461 $ti_prop->setSize(50);
462 $form->addItem($ti_prop);
463
464 $form->addCommandButton('updateThread', $this->lng->txt('save'));
465 $form->addCommandButton('showThreads', $this->lng->txt('cancel'));
466
467 return $form;
468 }
469
474 public function editThreadObject($a_thread_id, ilPropertyFormGUI $form = null)
475 {
476 if (!$this->is_moderator) {
477 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
478 }
479
480 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
481 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
482 }
483
484 $thread = new \ilForumTopic($a_thread_id);
485 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $thread);
486
487 $this->tabs->activateTab('forums_threads');
488
489 if (!($form instanceof ilPropertyFormGUI)) {
490 $form = $this->getThreadEditingForm($a_thread_id);
491 $form->setValuesByArray(array(
492 'title' => $thread->getSubject()
493 ));
494 }
495
496 $this->tpl->setContent($form->getHTML());
497 }
498
502 public function updateThreadObject()
503 {
504 if (!$this->is_moderator) {
505 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
506 }
507
508 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
509 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
510 }
511
512 if (!$this->objCurrentTopic->getId()) {
513 $this->showThreadsObject();
514 return;
515 }
516
517 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $this->objCurrentTopic);
518
519 $form = $this->getThreadEditingForm($this->objCurrentTopic->getId());
520 if (!$form->checkInput()) {
521 $form->setValuesByPost();
522 $this->editThreadObject($this->objCurrentTopic->getId(), $form);
523 return;
524 }
525
526 $this->objCurrentTopic->setSubject($form->getInput('title'));
527 $this->objCurrentTopic->updateThreadTitle();
528
529 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
530 $this->showThreadsObject();
531 }
532
533 public function markAllReadObject()
534 {
535 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
536 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
537 }
538
539 $this->object->markAllThreadsRead($this->user->getId());
540 ilUtil::sendInfo($this->lng->txt('forums_all_threads_marked_read'));
541 $this->showThreadsObject();
542 }
543
544 public function showThreadsObject()
545 {
546 $this->getSubTabs('showThreads');
547 $this->setSideBlocks();
548 $this->getCenterColumnHTML();
549 }
550
551 public function sortThreadsObject()
552 {
553 $this->getSubTabs('sortThreads');
554 $this->setSideBlocks();
555 $this->getCenterColumnHTML();
556 }
557
558 public function getSubTabs($subtab = 'showThreads')
559 {
560 if ($this->objProperties->getThreadSorting() == 1 && $this->is_moderator) {
561 $this->tabs->addSubTabTarget('show', $this->ctrl->getLinkTarget($this, 'showThreads'), 'showThreads', get_class($this), '', $subtab=='showThreads'? true : false);
562 $this->tabs->addSubTabTarget('sorting_header', $this->ctrl->getLinkTarget($this, 'sortThreads'), 'sortThreads', get_class($this), '', $subtab=='sortThreads'? true : false);
563 }
564 }
565
566 public function getContent()
567 {
568 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
569 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
570 }
571
572 $cmd = $this->ctrl->getCmd();
573 $frm = $this->object->Forum;
574 $frm->setForumId($this->object->getId());
575 $frm->setForumRefId($this->object->getRefId());
576 $frm->setMDB2Wherecondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
577
578 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_liste.html', 'Modules/Forum');
579
580 if ((int) strlen($this->confirmation_gui_html)) {
581 $this->tpl->setVariable('CONFIRMATION_GUI', $this->confirmation_gui_html);
582 }
583
584 // Create topic button
585 if ($this->access->checkAccess('add_thread', '', $this->object->getRefId()) && !$this->hideToolbar()) {
586 require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
588 $btn->setUrl($this->ctrl->getLinkTarget($this, 'createThread'));
589 $btn->setCaption('forums_new_thread');
590 $this->toolbar->addStickyItem($btn);
591 }
592
593 // Mark all topics as read button
594 include_once 'Services/Accessibility/classes/class.ilAccessKeyGUI.php';
595 if ($this->user->getId() != ANONYMOUS_USER_ID && !(int) strlen($this->confirmation_gui_html)) {
596 $this->toolbar->addButton(
597 $this->lng->txt('forums_mark_read'),
598 $this->ctrl->getLinkTarget($this, 'markAllRead'),
599 '',
601 );
602 $this->ctrl->clearParameters($this);
603 }
604
606 include_once './Modules/Forum/classes/class.ilForumDraftsTableGUI.php';
607 $drafts_tbl = new ilForumDraftsTableGUI($this, $cmd, '');
608 $draft_instances = ilForumPostDraft::getThreadDraftData($this->user->getId(), ilObjForum::lookupForumIdByObjId($this->object->getId()));
609 if (count($draft_instances)> 0) {
610 foreach ($draft_instances as $draft) {
611 $drafts_tbl->fillRow($draft);
612 }
613 $drafts_tbl->setData($draft_instances);
614 $this->tpl->setVariable('THREADS_DRAFTS_TABLE', $drafts_tbl->getHTML());
615 }
616 }
617
618 // Import information: Topic (variable $topicData) means frm object, not thread
619 $topicData = $frm->getOneTopic();
620 if ($topicData) {
621 // Visit-Counter
622 $frm->setDbTable('frm_data');
623 $frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($topicData['top_pk']));
624 $frm->updateVisits($topicData['top_pk']);
625
626 include_once 'Modules/Forum/classes/class.ilForumTopicTableGUI.php';
627 if (!in_array($cmd, array('showThreads', 'sortThreads'))) {
628 $cmd = 'showThreads';
629 }
630
631 $tbl = new ilForumTopicTableGUI($this, $cmd, '', (int) $_GET['ref_id'], $topicData, $this->is_moderator, $this->forum_overview_setting);
632 $tbl->init();
633 $tbl->setMapper($frm)->fetchData();
634 $this->tpl->setVariable('THREADS_TABLE', $tbl->getHTML());
635 }
636
637 // Permanent link
638 include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
639 $permalink = new ilPermanentLinkGUI('frm', $this->object->getRefId());
640 $this->tpl->setVariable('PRMLINK', $permalink->getHTML());
641 }
648 protected function renderDraftContent($render_drafts, $node, $edit_draft_id = null)
649 {
650 $frm = $this->object->Forum;
651
652 $draftsObjects = ilForumPostDraft::getInstancesByUserIdAndThreadId($this->user->getId(), $this->objCurrentTopic->getId());
653 $drafts = $draftsObjects[$node->getId()];
654
655 if ($render_drafts && is_array($drafts)) {
656 foreach ($drafts as $draft) {
657 if (!$draft instanceof ilForumPostDraft) {
658 continue 1;
659 }
660
661 if (isset($edit_draft_id) && $edit_draft_id == $node->getId()) {
662 // do not render a draft that is in 'edit'-mode
663 return false;
664 }
665
666 $tmp_file_obj = new ilFileDataForumDrafts($this->object->getId(), $draft->getDraftId());
667 $filesOfDraft = $tmp_file_obj->getFilesOfPost();
668 ksort($filesOfDraft);
669
670 if (count($filesOfDraft)) {
671 if ($_GET['action'] != 'showdraft' || $_GET['action'] == 'editdraft') {
672 foreach ($filesOfDraft as $file) {
673 $this->tpl->setCurrentBlock('attachment_download_row');
674 $this->ctrl->setParameter($this, 'draft_id', $tmp_file_obj->getDraftId());
675 $this->ctrl->setParameter($this, 'file', $file['md5']);
676 $this->tpl->setVariable('HREF_DOWNLOAD', $this->ctrl->getLinkTarget($this, 'viewThread'));
677 $this->tpl->setVariable('TXT_FILENAME', $file['name']);
678 $this->ctrl->setParameter($this, 'file', '');
679 $this->ctrl->setParameter($this, 'draft_id', '');
680 $this->ctrl->clearParameters($this);
681 $this->tpl->parseCurrentBlock();
682 }
683
684 $this->tpl->setCurrentBlock('attachments');
685 $this->tpl->setVariable('TXT_ATTACHMENTS_DOWNLOAD', $this->lng->txt('forums_attachments'));
686 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
687 $this->tpl->setVariable('DOWNLOAD_IMG', ilGlyphGUI::get(ilGlyphGUI::ATTACHMENT, $this->lng->txt('forums_download_attachment')));
688 if (count($filesOfDraft) > 1) {
689 $download_zip_button = ilLinkButton::getInstance();
690 $download_zip_button->setCaption($this->lng->txt('download'), false);
691 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
692 $download_zip_button->setUrl($this->ctrl->getLinkTarget($this, 'deliverDraftZipFile'));
693 $this->ctrl->setParameter($this, 'draft_id', '');
694 $this->tpl->setVariable('DOWNLOAD_ZIP', $download_zip_button->render());
695 }
696 $this->tpl->parseCurrentBlock();
697 }
698 }
699
700 // render splitButton for drafts
701 $this->renderSplitButton(false, $node, (int) $_GET['offset'], $draft);
702
703 // highlight drafts
704 //@todo change this...
705 // $rowCol = 'tblrowdraft';
706 $rowCol = 'tblrowmarked';
707 // set row color
708 $this->tpl->setVariable('ROWCOL', ' ' . $rowCol);
709
710 // Author
711 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
712 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
713 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
714
715 $backurl = urlencode($this->ctrl->getLinkTarget($this, 'viewThread', $node->getId()));
716
717 $this->ctrl->setParameter($this, 'backurl', $backurl);
718 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
719 $this->ctrl->setParameter($this, 'user', $draft->getPostDisplayUserId());
720
721 require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
722 $authorinfo = new ilForumAuthorInformation(
723 $draft->getPostAuthorId(),
724 $draft->getPostDisplayUserId(),
725 $draft->getPostUserAlias(),
726 '',
727 array(
728 'href' => $this->ctrl->getLinkTarget($this, 'showUser')
729 )
730 );
731
732 $this->ctrl->clearParameters($this);
733
734 if ($authorinfo->hasSuffix()) {
735 $this->tpl->setVariable('AUTHOR', $authorinfo->getSuffix());
736 $this->tpl->setVariable('USR_NAME', $draft->getPostUserAlias());
737 } else {
738 $this->tpl->setVariable('AUTHOR', $authorinfo->getLinkedAuthorShortName());
739 if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized()) {
740 $this->tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true));
741 }
742 }
743 $this->tpl->setVariable('DRAFT_ANCHOR', 'draft_' . $draft->getDraftId());
744
745 $this->tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture());
746 if ($authorinfo->getAuthor()->getId() && ilForum::_isModerator((int) $_GET['ref_id'], $draft->getPostAuthorId())) {
747 if ($authorinfo->getAuthor()->getGender() == 'f') {
748 $this->tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_f'));
749 } elseif ($authorinfo->getAuthor()->getGender() == 'm') {
750 $this->tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_m'));
751 } elseif ($authorinfo->getAuthor()->getGender() == 'n') {
752 $this->tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_n'));
753 }
754 }
755
756 // get create- and update-dates
757 if ($draft->getUpdateUserId() > 0) {
758 $spanClass = 'small';
759
760 if (ilForum::_isModerator($this->ref_id, $node->getUpdateUserId())) {
761 $spanClass = 'moderator_small';
762 }
763
764 $draft->setPostUpdate($draft->getPostUpdate());
765
766 $this->ctrl->setParameter($this, 'backurl', $backurl);
767 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
768 $this->ctrl->setParameter($this, 'user', $node->getUpdateUserId());
769 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
770 require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
771 $authorinfo = new ilForumAuthorInformation(
772 $draft->getPostAuthorId(),
773 $draft->getUpdateUserId(),
774 $draft->getPostUserAlias(),
775 '',
776 array(
777 'href' => $this->ctrl->getLinkTarget($this, 'showUser')
778 )
779 );
780
781 $this->ctrl->clearParameters($this);
782
783 $this->tpl->setVariable('POST_UPDATE_TXT', $this->lng->txt('edited_on') . ': ' . $frm->convertDate($draft->getPostUpdate()) . ' - ' . strtolower($this->lng->txt('by')));
784 $this->tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
785 if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
786 $this->tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true));
787 }
788 }
789 // Author end
790
791 // prepare post
792 $draft->setPostMessage($frm->prepareText($draft->getPostMessage()));
793
794 $this->tpl->setVariable('SUBJECT', $draft->getPostSubject());
795 $this->tpl->setVariable('POST_DATE', $frm->convertDate($draft->getPostDate()));
796
797 if (!$node->isCensored() ||
798 ($this->objCurrentPost->getId() == $node->getId() && $_GET['action'] == 'censor')
799 ) {
800 $spanClass = "";
801
802 if (ilForum::_isModerator($this->ref_id, $draft->getPostDisplayUserId())) {
803 $spanClass = 'moderator';
804 }
805
806 if ($draft->getPostMessage() == strip_tags($draft->getPostMessage())) {
807 // We can be sure, that there are not html tags
808 $draft->setPostMessage(nl2br($draft->getPostMessage()));
809 }
810
811 if ($spanClass != "") {
812 $this->tpl->setVariable('POST', "<span class=\"" . $spanClass . "\">" . ilRTE::_replaceMediaObjectImageSrc($draft->getPostMessage(), 1) . "</span>");
813 } else {
814 $this->tpl->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($draft->getPostMessage(), 1));
815 }
816 }
817 if (!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'deletedraft') {
818 if ($this->user->getId() != ANONYMOUS_USER_ID && $draft->getDraftId() == (int) $_GET['draft_id']) {
819 // confirmation: delete
820 $this->tpl->setVariable('FORM', $this->getDeleteDraftFormHTML());
821 }
822 } elseif ($_GET['action'] == 'editdraft' && $draft->getDraftId() == (int) $_GET['draft_id']) {
823 $oEditReplyForm = $this->getReplyEditForm();
824 $this->tpl->setVariable('EDIT_DRAFT_ANCHOR', 'draft_edit_' . $draft->getDraftId());
825 $this->tpl->setVariable('DRAFT_FORM', $oEditReplyForm->getHTML() . $this->modal_history);
826 }
827
828 $this->tpl->parseCurrentBlock();
829 }
830 return true;
831 }
832 return true;
833 }
834
840 protected function renderPostContent(ilForumPost $node, $Start, $z)
841 {
842 $forumObj = $this->object;
843 $frm = $this->object->Forum;
844
845 // download post attachments
846 $tmp_file_obj = new ilFileDataForum($forumObj->getId(), $node->getId());
847
848 $filesOfPost = $tmp_file_obj->getFilesOfPost();
849 ksort($filesOfPost);
850 if (count($filesOfPost)) {
851 if ($node->getId() != $this->objCurrentPost->getId() || $_GET['action'] != 'showedit') {
852 foreach ($filesOfPost as $file) {
853 $this->tpl->setCurrentBlock('attachment_download_row');
854 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
855 $this->ctrl->setParameter($this, 'file', $file['md5']);
856 $this->tpl->setVariable('HREF_DOWNLOAD', $this->ctrl->getLinkTarget($this, 'viewThread'));
857 $this->tpl->setVariable('TXT_FILENAME', $file['name']);
858 $this->ctrl->clearParameters($this);
859 $this->tpl->parseCurrentBlock();
860 }
861 $this->tpl->setCurrentBlock('attachments');
862 $this->tpl->setVariable('TXT_ATTACHMENTS_DOWNLOAD', $this->lng->txt('forums_attachments'));
863 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
864 $this->tpl->setVariable('DOWNLOAD_IMG', ilGlyphGUI::get(ilGlyphGUI::ATTACHMENT, $this->lng->txt('forums_download_attachment')));
865 if (count($filesOfPost) > 1) {
866 $download_zip_button = ilLinkButton::getInstance();
867 $download_zip_button->setCaption($this->lng->txt('download'), false);
868 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
869 $download_zip_button->setUrl($this->ctrl->getLinkTarget($this, 'deliverZipFile'));
870
871 $this->tpl->setVariable('DOWNLOAD_ZIP', $download_zip_button->render());
872 }
873
874 $this->tpl->parseCurrentBlock();
875 }
876 }
877 // render splitbutton for posts
878 $this->renderSplitButton(true, $node, $Start);
879
880 // anker for every post
881 $this->tpl->setVariable('POST_ANKER', $node->getId());
882
883 //permanent link for every post
884 $this->tpl->setVariable('TXT_PERMA_LINK', $this->lng->txt('perma_link'));
885 $this->tpl->setVariable('PERMA_TARGET', '_top');
886
887 if (!$node->isActivated() && !$this->objCurrentTopic->isClosed() && $this->is_moderator) {
888 $rowCol = 'ilPostingNeedsActivation';
889 } elseif ($this->objProperties->getMarkModeratorPosts() == 1) {
890 if ($node->getIsAuthorModerator() === null && $is_moderator = ilForum::_isModerator($_GET['ref_id'], $node->getPosAuthorId())) {
891 $rowCol = 'ilModeratorPosting';
892 } elseif ($node->getIsAuthorModerator()) {
893 $rowCol = 'ilModeratorPosting';
894 } else {
895 $rowCol = ilUtil::switchColor($z, 'tblrow1', 'tblrow2');
896 }
897 } else {
898 $rowCol = ilUtil::switchColor($z, 'tblrow1', 'tblrow2');
899 }
900 if ((
901 $_GET['action'] != 'delete' && $_GET['action'] != 'censor' &&
903 )
904 || $this->objCurrentPost->getId() != $node->getId()
905 ) {
906 $this->tpl->setVariable('ROWCOL', ' ' . $rowCol);
907 } else {
908 // highlight censored posts
909 $rowCol = 'tblrowmarked';
910 }
911
912 // post is censored
913 if ($node->isCensored()) {
914 // display censorship advice
915 if ($_GET['action'] != 'censor') {
916 $this->tpl->setVariable('TXT_CENSORSHIP_ADVICE', $this->lng->txt('post_censored_comment_by_moderator'));
917 }
918
919 // highlight censored posts
920 $rowCol = 'tblrowmarked';
921 }
922
923 // set row color
924 $this->tpl->setVariable('ROWCOL', ' ' . $rowCol);
925 // if post is not activated display message for the owner
926 if (!$node->isActivated() && $node->isOwner($this->user->getId())) {
927 $this->tpl->setVariable('POST_NOT_ACTIVATED_YET', $this->lng->txt('frm_post_not_activated_yet'));
928 }
929
930 // Author
931 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
932 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
933 $backurl = urlencode($this->ctrl->getLinkTarget($this, 'viewThread', $node->getId()));
934 $this->ctrl->clearParameters($this);
935
936 $this->ctrl->setParameter($this, 'backurl', $backurl);
937 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
938 $this->ctrl->setParameter($this, 'user', $node->getDisplayUserId());
939
940 require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
941 $authorinfo = new ilForumAuthorInformation(
942 $node->getPosAuthorId(),
943 $node->getDisplayUserId(),
944 $node->getUserAlias(),
945 $node->getImportName(),
946 array(
947 'href' => $this->ctrl->getLinkTarget($this, 'showUser')
948 )
949 );
950
951 $this->ctrl->clearParameters($this);
952
953 if ($authorinfo->hasSuffix()) {
954 $this->tpl->setVariable('AUTHOR', $authorinfo->getSuffix());
955 $this->tpl->setVariable('USR_NAME', $node->getUserAlias());
956 } else {
957 $this->tpl->setVariable('AUTHOR', $authorinfo->getLinkedAuthorShortName());
958 if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized()) {
959 $this->tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true));
960 }
961 }
962
963 $this->tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture());
964 if ($authorinfo->getAuthor()->getId() && ilForum::_isModerator((int) $_GET['ref_id'], $node->getPosAuthorId())) {
965 if ($authorinfo->getAuthor()->getGender() == 'f') {
966 $this->tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_f'));
967 } elseif ($authorinfo->getAuthor()->getGender() == 'm') {
968 $this->tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_m'));
969 }
970 }
971
972 // get create- and update-dates
973 if ($node->getUpdateUserId() > 0) {
974 $spanClass = 'small';
975
976 if (ilForum::_isModerator($this->ref_id, $node->getUpdateUserId())) {
977 $spanClass = 'moderator_small';
978 }
979
980 $node->setChangeDate($node->getChangeDate());
981
982 $this->ctrl->setParameter($this, 'backurl', $backurl);
983 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
984 $this->ctrl->setParameter($this, 'user', $node->getUpdateUserId());
985
986 $update_user_id = $node->getUpdateUserId();
987 if ($node->getPosAuthorId() == $node->getUpdateUserId()
988 && $node->getDisplayUserId() == 0) {
989 $update_user_id = $node->getDisplayUserId();
990 }
991 require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
992 $authorinfo = new ilForumAuthorInformation(
993 $node->getPosAuthorId(),
994 $update_user_id,
995 $node->getUserAlias(),
996 $node->getImportName(),
997 array(
998 'href' => $this->ctrl->getLinkTarget($this, 'showUser')
999 )
1000 );
1001
1002 $this->ctrl->clearParameters($this);
1003
1004 $this->tpl->setVariable('POST_UPDATE_TXT', $this->lng->txt('edited_on') . ': ' . $frm->convertDate($node->getChangeDate()) . ' - ' . strtolower($this->lng->txt('by')));
1005 $this->tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
1006 if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
1007 $this->tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true));
1008 }
1009 } // if ($node->getUpdateUserId() > 0)*/
1010 // Author end
1011
1012 // prepare post
1013 $node->setMessage($frm->prepareText($node->getMessage()));
1014
1015 if ($this->user->getId() == ANONYMOUS_USER_ID ||
1016 $node->isPostRead()
1017 ) {
1018 $this->tpl->setVariable('SUBJECT', $node->getSubject());
1019 } else {
1020 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
1021 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
1022 $this->ctrl->setParameter($this, 'offset', $Start);
1023 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
1024 $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
1025 $mark_post_target = $this->ctrl->getLinkTarget($this, 'markPostRead', $node->getId());
1026
1027 $this->tpl->setVariable('SUBJECT', "<a href=\"" . $mark_post_target . "\"><b>" . $node->getSubject() . "</b></a>");
1028 }
1029
1030 $this->tpl->setVariable('POST_DATE', $frm->convertDate($node->getCreateDate()));
1031
1032 if (!$node->isCensored() ||
1033 ($this->objCurrentPost->getId() == $node->getId() && $_GET['action'] == 'censor')
1034 ) {
1035 $spanClass = "";
1036 if (ilForum::_isModerator($this->ref_id, $node->getDisplayUserId())) {
1037 $spanClass = 'moderator';
1038 }
1039 // possible bugfix for mantis #8223
1040 if ($node->getMessage() == strip_tags($node->getMessage())) {
1041 // We can be sure, that there are not html tags
1042 $node->setMessage(nl2br($node->getMessage()));
1043 }
1044
1045 if ($spanClass != "") {
1046 $this->tpl->setVariable('POST', "<span class=\"" . $spanClass . "\">" . ilRTE::_replaceMediaObjectImageSrc($node->getMessage(), 1) . "</span>");
1047 } else {
1048 $this->tpl->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($node->getMessage(), 1));
1049 }
1050 } else {
1051 $this->tpl->setVariable('POST', "<span class=\"moderator\">" . nl2br($node->getCensorshipComment()) . "</span>");
1052 }
1053
1054 $this->tpl->parseCurrentBlock();
1055 return true;
1056 }
1057
1061 private function initForumCreateForm($object_type)
1062 {
1063 $this->create_form_gui = new ilPropertyFormGUI();
1064 $this->create_form_gui->setTableWidth('600px');
1065
1066 $this->create_form_gui->setTitle($this->lng->txt('frm_new'));
1067 $this->create_form_gui->setTitleIcon(ilUtil::getImagePath('icon_frm.svg'));
1068
1069 // form action
1070 $this->ctrl->setParameter($this, 'new_type', $object_type);
1071 $this->create_form_gui->setFormAction($this->ctrl->getFormAction($this, 'save'));
1072
1073 // title
1074 $title_gui = new ilTextInputGUI($this->lng->txt('title'), 'title');
1075 $title_gui->setSize(min(40, ilObject::TITLE_LENGTH));
1076 $title_gui->setMaxLength(ilObject::TITLE_LENGTH);
1077 $this->create_form_gui->addItem($title_gui);
1078
1079 // description
1080 $description_gui = new ilTextAreaInputGUI($this->lng->txt('desc'), 'desc');
1081 $description_gui->setCols(40);
1082 $description_gui->setRows(2);
1083 $this->create_form_gui->addItem($description_gui);
1084
1085 // custom properties
1086 $this->forum_settings_gui->getCustomForm($this->create_form_gui);
1087
1088 // view sorting threads
1089 $sort_man = new ilCheckboxInputGUI($this->lng->txt('sorting_manual_sticky'), 'thread_sorting');
1090 $sort_man->setInfo($this->lng->txt('sticky_threads_always_on_top'));
1091 $sort_man->setValue(1);
1092 $this->create_form_gui->addItem($sort_man);
1093
1094 // view
1095 $view_group_gui = new ilRadioGroupInputGUI($this->lng->txt('frm_default_view'), 'sort');
1096 $view_hir = new ilRadioOption($this->lng->txt('order_by') . ' ' . $this->lng->txt('answers'), ilForumProperties::VIEW_TREE);
1097 $view_group_gui->addOption($view_hir);
1098 $view_dat = new ilRadioOption($this->lng->txt('order_by') . ' ' . $this->lng->txt('date'), ilForumProperties::VIEW_DATE);
1099 $view_group_gui->addOption($view_dat);
1100 $this->create_form_gui->addItem($view_group_gui);
1101 $view_direction_group_gui = new ilRadioGroupInputGUI('', 'default_view_sort_dir');
1102 $view_desc = new ilRadioOption($this->lng->txt('frm_post_sort_desc'), ilForumProperties::VIEW_DATE_DESC);
1103 $view_direction_group_gui->addOption($view_desc);
1104 $view_asc = new ilRadioOption($this->lng->txt('frm_post_sort_asc'), ilForumProperties::VIEW_DATE_ASC);
1105 $view_direction_group_gui->addOption($view_asc);
1106 $view_dat->addSubItem($view_direction_group_gui);
1107
1108 // anonymized or not
1109 $anonymize_gui = new ilCheckboxInputGUI($this->lng->txt('frm_anonymous_posting'), 'anonymized');
1110 $anonymize_gui->setInfo($this->lng->txt('frm_anonymous_posting_desc'));
1111 $anonymize_gui->setValue(1);
1112
1113 if ($this->settings->get('enable_anonymous_fora', false)) {
1114 $anonymize_gui->setDisabled(true);
1115 }
1116 $this->create_form_gui->addItem($anonymize_gui);
1117
1118 // statistics enabled or not
1119 $statistics_gui = new ilCheckboxInputGUI($this->lng->txt('frm_statistics_enabled'), 'statistics_enabled');
1120 $statistics_gui->setInfo($this->lng->txt('frm_statistics_enabled_desc'));
1121 $statistics_gui->setValue(1);
1122 if (!$this->settings->get('enable_fora_statistics', false)) {
1123 $statistics_gui->setDisabled(true);
1124 }
1125 $this->create_form_gui->addItem($statistics_gui);
1126
1127 $cb_prop = new ilCheckboxInputGUI($this->lng->txt('activate_new_posts'), 'post_activation');
1128 $cb_prop->setValue('1');
1129 $cb_prop->setInfo($this->lng->txt('post_activation_desc'));
1130 $this->create_form_gui->addItem($cb_prop);
1131
1132 $this->create_form_gui->addCommandButton('save', $this->lng->txt('save'));
1133 $this->create_form_gui->addCommandButton('cancel', $this->lng->txt('cancel'));
1134 }
1135
1136 public function cancelObject()
1137 {
1138 ilUtil::sendInfo($this->lng->txt('msg_cancel'), true);
1139 ilUtil::redirect('ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&ref_id=' . $_GET['ref_id']);
1140 }
1141
1145 protected function afterSave(ilObject $forumObj)
1146 {
1147 ilUtil::sendSuccess($this->lng->txt('frm_added'), true);
1148 $this->ctrl->setParameter($this, 'ref_id', $forumObj->getRefId());
1149 ilUtil::redirect($this->ctrl->getLinkTarget($this, 'createThread', '', false, false));
1150 }
1151
1152 protected function getTabs()
1153 {
1154 $this->ilHelp->setScreenIdComponent("frm");
1155
1156 $this->ctrl->setParameter($this, 'ref_id', $this->ref_id);
1157
1158 $active = array(
1159 '', 'showThreads', 'view', 'markAllRead',
1160 'enableForumNotification', 'disableForumNotification', 'moveThreads', 'performMoveThreads',
1161 'cancelMoveThreads', 'performThreadsAction', 'createThread', 'addThread',
1162 'showUser', 'confirmDeleteThreads',
1163 'merge','mergeThreads', 'cancelMergeThreads', 'performMergeThreads'
1164 );
1165
1166 (in_array($this->ctrl->getCmd(), $active)) ? $force_active = true : $force_active = false;
1167 $this->tabs->addTarget('forums_threads', $this->ctrl->getLinkTarget($this, 'showThreads'), $this->ctrl->getCmd(), get_class($this), '', $force_active);
1168
1169 // info tab
1170 if ($this->access->checkAccess('visible', '', $this->ref_id) || $this->access->checkAccess('read', '', $this->ref_id)) {
1171 $force_active = ($this->ctrl->getNextClass() == 'ilinfoscreengui' || strtolower($_GET['cmdClass']) == 'ilnotegui') ? true : false;
1172 $this->tabs->addTarget(
1173 'info_short',
1174 $this->ctrl->getLinkTargetByClass(array('ilobjforumgui', 'ilinfoscreengui'), 'showSummary'),
1175 array('showSummary', 'infoScreen'),
1176 '',
1177 '',
1178 $force_active
1179 );
1180 }
1181
1182 if ($this->access->checkAccess('write', '', $this->ref_id)) {
1183 $force_active = ($this->ctrl->getCmd() == 'edit') ? true : false;
1184 $this->tabs->addTarget('settings', $this->ctrl->getLinkTarget($this, 'edit'), 'edit', get_class($this), '', $force_active);
1185 }
1186
1187 if ($this->access->checkAccess('write', '', $this->ref_id)) {
1188 $this->tabs->addTarget('frm_moderators', $this->ctrl->getLinkTargetByClass('ilForumModeratorsGUI', 'showModerators'), 'showModerators', get_class($this));
1189 }
1190
1191 if ($this->settings->get('enable_fora_statistics', false) &&
1192 ($this->objProperties->isStatisticEnabled() || $this->access->checkAccess('write', '', $this->ref_id))) {
1193 $force_active = ($this->ctrl->getCmd() == 'showStatistics') ? true : false;
1194 $this->tabs->addTarget('frm_statistics', $this->ctrl->getLinkTarget($this, 'showStatistics'), 'showStatistics', get_class($this), '', $force_active); //false
1195 }
1196
1197 if ($this->access->checkAccess('write', '', $this->object->getRefId())) {
1198 $this->tabs->addTarget('export', $this->ctrl->getLinkTargetByClass('ilexportgui', ''), '', 'ilexportgui');
1199 }
1200
1201 if ($this->access->checkAccess('edit_permission', '', $this->ref_id)) {
1202 $this->tabs->addTarget('perm_settings', $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), 'perm'), array('perm', 'info', 'owner'), 'ilpermissiongui');
1203 }
1204 }
1205
1206 public function showStatisticsObject()
1207 {
1209 if (!$this->settings->get('enable_fora_statistics', false)) {
1210 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1211 }
1212
1213 // if no read access -> intrusion detected
1214 if (!$this->access->checkAccess('read', '', (int) $_GET['ref_id'])) {
1215 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1216 }
1217
1218 // if read access and statistics disabled -> intrusion detected
1219 if (!$this->objProperties->isStatisticEnabled()) {
1220 // if write access and statistics disabled -> ok, for forum admin
1221 if ($this->access->checkAccess('write', '', (int) $_GET['ref_id'])) {
1222 ilUtil::sendInfo($this->lng->txt('frm_statistics_disabled_for_participants'));
1223 } else {
1224 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1225 }
1226 }
1227
1228 $this->object->Forum->setForumId($this->object->getId());
1229
1230 require_once 'Modules/Forum/classes/class.ilForumStatisticsTableGUI.php';
1231
1232 $tbl = new ilForumStatisticsTableGUI($this, 'showStatistics');
1233 $tbl->setId('il_frm_statistic_table_' . (int) (int) $_GET['ref_id']);
1234 $tbl->setTitle($this->lng->txt('statistic'), 'icon_usr.svg', $this->lng->txt('obj_' . $this->object->getType()));
1235
1236 $data = $this->object->Forum->getUserStatistic($this->is_moderator);
1237 $result = array();
1238 $counter = 0;
1239 foreach ($data as $row) {
1240 $result[$counter]['ranking'] = $row[0];
1241 $result[$counter]['login'] = $row[1];
1242 $result[$counter]['lastname'] = $row[2];
1243 $result[$counter]['firstname'] = $row[3];
1244
1245 ++$counter;
1246 }
1247 $tbl->setData($result);
1248
1249 $this->tpl->setContent($tbl->getHTML());
1250 }
1251
1252 public static function _goto($a_target, $a_thread = 0, $a_posting = 0)
1253 {
1254 global $DIC;
1255
1256 $ilAccess = $DIC->access();
1257 $lng = $DIC->language();
1258 $ilErr = $DIC['ilErr'];
1259
1260 if ($ilAccess->checkAccess('read', '', $a_target)) {
1261 if ($a_thread != 0) {
1262 $objTopic = new ilForumTopic($a_thread);
1263 if ($objTopic->getFrmObjId() &&
1264 $objTopic->getFrmObjId() != ilObject::_lookupObjectId($a_target)) {
1265 $ref_ids = ilObject::_getAllReferences($objTopic->getFrmObjId());
1266 foreach ($ref_ids as $ref_id) {
1267 if ($ilAccess->checkAccess('read', '', $ref_id)) {
1268 $new_ref_id = $ref_id;
1269 break;
1270 }
1271 }
1272
1273 if (isset($new_ref_id) && $new_ref_id != $a_target) {
1274 ilUtil::redirect(ILIAS_HTTP_PATH . "/goto.php?target=frm_" . $new_ref_id . "_" . $a_thread . "_" . $a_posting);
1275 }
1276 }
1277
1278 $_GET['ref_id'] = $a_target;
1279 $_GET['pos_pk'] = $a_posting;
1280 $_GET['thr_pk'] = $a_thread;
1281 $_GET['anchor'] = $a_posting;
1282 $_GET['cmdClass'] = 'ilObjForumGUI';
1283 $_GET['cmd'] = 'viewThread';
1284 $_GET['baseClass'] = 'ilRepositoryGUI';
1285
1286 include_once('ilias.php');
1287 exit();
1288 } else {
1289 $_GET['ref_id'] = $a_target;
1290 $_GET['baseClass'] = 'ilRepositoryGUI';
1291 include_once('ilias.php');
1292 exit();
1293 }
1294 } elseif ($ilAccess->checkAccess('read', '', ROOT_FOLDER_ID)) {
1295 $_GET['target'] = '';
1296 $_GET['ref_id'] = ROOT_FOLDER_ID;
1298 $lng->txt('msg_no_perm_read_item'),
1300 ), true);
1301 $_GET['baseClass'] = 'ilRepositoryGUI';
1302 include('ilias.php');
1303 exit();
1304 }
1305
1306 $ilErr->raiseError($lng->txt('msg_no_perm_read'), $ilErr->FATAL);
1307 }
1308
1310 {
1311 if (!$this->is_moderator) {
1312 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1313 }
1314
1315 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1316 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1317 }
1318
1319 if (!isset($_POST['thread_ids']) || !is_array($_POST['thread_ids'])) {
1320 ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'));
1321 return $this->showThreadsObject();
1322 }
1323
1324 require_once 'Modules/Forum/classes/class.ilObjForum.php';
1325 $forumObj = new ilObjForum($this->object->getRefId());
1326 $this->objProperties->setObjId($forumObj->getId());
1327
1328 $frm = new ilForum();
1329
1330 $success_message = "forums_thread_deleted";
1331 if (count($_POST['thread_ids']) > 1) {
1332 $success_message = "forums_threads_deleted";
1333 }
1334
1335 $threadIds = [];
1336 if (isset($_POST['thread_ids']) && is_array($_POST['thread_ids'])) {
1337 $threadIds = $_POST['thread_ids'];
1338 }
1339
1340 $threads = [];
1341 array_walk($threadIds, function ($threadId) use (&$threads) {
1342 $thread = new \ilForumTopic($threadId);
1343 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $thread);
1344
1345 $threads[] = $thread;
1346 });
1347
1348 foreach ($threads as $thread) {
1349 $frm->setForumId($forumObj->getId());
1350 $frm->setForumRefId($forumObj->getRefId());
1351
1352 $first_node = $frm->getFirstPostNode($thread->getId());
1353 if ((int) $first_node['pos_pk']) {
1354 $frm->deletePost($first_node['pos_pk']);
1355 ilUtil::sendInfo($this->lng->txt($success_message), true);
1356 }
1357 }
1358 $this->ctrl->redirect($this, 'showThreads');
1359 }
1360
1361 public function confirmDeleteThreads()
1362 {
1363 if (!isset($_POST['thread_ids']) || !is_array($_POST['thread_ids'])) {
1364 ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'));
1365 return $this->showThreadsObject();
1366 }
1367
1368 if (!$this->is_moderator) {
1369 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1370 }
1371
1372 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1373 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1374 }
1375
1376 $threads = [];
1377 array_walk($_POST['thread_ids'], function ($threadId) use (&$threads) {
1378 $thread = new \ilForumTopic($threadId);
1379 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $thread);
1380
1381 $threads[] = $thread;
1382 });
1383
1384 include_once('Services/Utilities/classes/class.ilConfirmationGUI.php');
1385 $c_gui = new ilConfirmationGUI();
1386
1387 $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performDeleteThreads'));
1388 $c_gui->setHeaderText($this->lng->txt('frm_sure_delete_threads'));
1389 $c_gui->setCancel($this->lng->txt('cancel'), 'showThreads');
1390 $c_gui->setConfirm($this->lng->txt('confirm'), 'performDeleteThreads');
1391
1392 foreach ($threads as $thread) {
1393 $c_gui->addItem('thread_ids[]', $thread->getId(), $thread->getSubject());
1394 }
1395
1396 $this->confirmation_gui_html = $c_gui->getHTML();
1397
1398 $this->hideToolbar(true);
1399
1400 return $this->tpl->setContent($c_gui->getHTML());
1401 }
1402
1404 {
1405 if (!isset($_POST['draft_ids']) || !is_array($_POST['draft_ids'])) {
1406 ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'));
1407 return $this->showThreadsObject();
1408 }
1409
1410 include_once('Services/Utilities/classes/class.ilConfirmationGUI.php');
1411 $c_gui = new ilConfirmationGUI();
1412
1413 $c_gui->setFormAction($this->ctrl->getFormAction($this, 'deleteThreadDrafts'));
1414 $c_gui->setHeaderText($this->lng->txt('sure_delete_drafts'));
1415 $c_gui->setCancel($this->lng->txt('cancel'), 'showThreads');
1416 $c_gui->setConfirm($this->lng->txt('confirm'), 'deleteThreadDrafts');
1417 $instances = ilForumPostDraft::getDraftInstancesByUserId($this->user->getId());
1418 foreach ($_POST['draft_ids'] as $draft_id) {
1419 if (array_key_exists($draft_id, $instances)) {
1420 $c_gui->addItem('draft_ids[]', $draft_id, $instances[$draft_id]->getPostSubject());
1421 }
1422 }
1423
1424 $this->confirmation_gui_html = $c_gui->getHTML();
1425
1426 $this->hideToolbar(true);
1427
1428 return $this->tpl->setContent($c_gui->getHTML());
1429 }
1430
1431 public function prepareThreadScreen(ilObjForum $a_forum_obj)
1432 {
1433 $this->ilHelp->setScreenIdComponent("frm");
1434
1435 $this->tpl->getStandardTemplate();
1438
1439 $this->tpl->setTitleIcon(ilObject::_getIcon("", "big", "frm"));
1440
1441 $this->tabs->setBackTarget($this->lng->txt('all_topics'), 'ilias.php?baseClass=ilRepositoryGUI&amp;ref_id=' . $_GET['ref_id']);
1442
1443 // by answer view
1444 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
1445 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1446 $this->ctrl->setParameter($this, 'viewmode', ilForumProperties::VIEW_TREE);
1447 $this->tabs->addTarget('sort_by_posts', $this->ctrl->getLinkTarget($this, 'viewThread'));
1448
1449 // by date view
1450 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
1451 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1452 $this->ctrl->setParameter($this, 'viewmode', ilForumProperties::VIEW_DATE);
1453 $this->tabs->addTarget('order_by_date', $this->ctrl->getLinkTarget($this, 'viewThread'));
1454
1455 $this->ctrl->clearParameters($this);
1456
1457 if ($this->isHierarchicalView()) {
1458 $this->tabs->activateTab('sort_by_posts');
1459 } else {
1460 $this->tabs->activateTab('order_by_date');
1461 }
1462
1466 $frm = $a_forum_obj->Forum;
1467 $frm->setForumId($a_forum_obj->getId());
1468 }
1469
1471 {
1472 if (!$this->is_moderator) {
1473 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1474 }
1475
1476 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1477 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1478 }
1479
1480 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $this->objCurrentPost->getThread());
1481
1482 $this->objCurrentPost->activatePost();
1483 $GLOBALS['ilAppEventHandler']->raise(
1484 'Modules/Forum',
1485 'activatedPost',
1486 array(
1487 'ref_id' => $this->object->getRefId(),
1488 'post' => $this->objCurrentPost
1489 )
1490 );
1491 ilUtil::sendInfo($this->lng->txt('forums_post_was_activated'), true);
1492
1493 $this->viewThreadObject();
1494 }
1495
1497 {
1498 if (!$this->is_moderator) {
1499 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1500 }
1501
1502 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1503 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1504 }
1505
1507
1508 $this->viewThreadObject();
1509 }
1510
1511 public function setDisplayConfirmPostActivation($status = 0)
1512 {
1513 $this->display_confirm_post_activation = $status;
1514 }
1515
1517 {
1519 }
1520
1522 {
1523 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1524 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1525 }
1526
1527 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $this->objCurrentTopic);
1528
1529 if ($this->objCurrentTopic->isNotificationEnabled($this->user->getId())) {
1530 $this->objCurrentTopic->disableNotification($this->user->getId());
1531 \ilUtil::sendInfo($this->lng->txt('forums_notification_disabled'));
1532 } else {
1533 $this->objCurrentTopic->enableNotification($this->user->getId());
1534 \ilUtil::sendInfo($this->lng->txt('forums_notification_enabled'));
1535 }
1536
1537 $this->viewThreadObject();
1538 }
1539
1540 public function toggleStickinessObject()
1541 {
1542 if (!$this->is_moderator) {
1543 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1544 }
1545
1546 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1547 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1548 }
1549
1550 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $this->objCurrentTopic);
1551
1552 if ($this->objCurrentTopic->isSticky()) {
1553 $this->objCurrentTopic->unmakeSticky();
1554 } else {
1555 $this->objCurrentTopic->makeSticky();
1556 }
1557
1558 $this->viewThreadObject();
1559 }
1560
1561 public function cancelPostObject()
1562 {
1563 $_GET['action'] = '';
1564 if (isset($_POST['draft_id']) && (int) $_POST['draft_id'] > 0) {
1565 $draft = ilForumPostDraft::newInstanceByDraftId((int) $_POST['draft_id']);
1566 $draft->deleteDraftsByDraftIds(array( (int) $_POST['draft_id']));
1567 }
1568
1569 $this->viewThreadObject();
1570 }
1571
1572 public function cancelDraftObject()
1573 {
1574 $_GET['action'] = '';
1575 if (isset($_GET['draft_id']) && (int) $_GET['draft_id'] > 0) {
1577 $history_obj = new ilForumDraftsHistory();
1578 $history_obj->getFirstAutosaveByDraftId((int) $_GET['draft_id']);
1579 $draft = ilForumPostDraft::newInstanceByDraftId((int) $_GET['draft_id']);
1580 $draft->setPostSubject($history_obj->getPostSubject());
1581 $draft->setPostMessage($history_obj->getPostMessage());
1582
1584 $history_obj->getPostMessage(),
1586 $history_obj->getHistoryId(),
1588 $draft->getDraftId()
1589 );
1590
1591 $draft->updateDraft();
1592
1593 $history_obj->deleteHistoryByDraftIds(array($draft->getDraftId()));
1594 }
1595 }
1596 $this->ctrl->clearParameters($this);
1597 $this->viewThreadObject();
1598 }
1599
1600 public function getDeleteFormHTML()
1601 {
1603 $form_tpl = new ilTemplate('tpl.frm_delete_post_form.html', true, true, 'Modules/Forum');
1604
1605 $form_tpl->setVariable('ANKER', $this->objCurrentPost->getId());
1606 $form_tpl->setVariable('SPACER', '<hr noshade="noshade" width="100%" size="1" align="center" />');
1607 $form_tpl->setVariable('TXT_DELETE', $this->lng->txt('forums_info_delete_post'));
1608 $this->ctrl->setParameter($this, 'action', 'ready_delete');
1609 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1610 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
1611 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
1612 $form_tpl->setVariable('FORM_ACTION', $this->ctrl->getLinkTarget($this, 'viewThread'));
1613 $this->ctrl->clearParameters($this);
1614 $form_tpl->setVariable('CANCEL_BUTTON', $this->lng->txt('cancel'));
1615 $form_tpl->setVariable('CONFIRM_BUTTON', $this->lng->txt('confirm'));
1616
1617 return $form_tpl->get();
1618 }
1619 public function getDeleteDraftFormHTML()
1620 {
1622 $form_tpl = new ilTemplate('tpl.frm_delete_post_form.html', true, true, 'Modules/Forum');
1623
1624 $form_tpl->setVariable('SPACER', '<hr noshade="noshade" width="100%" size="1" align="center" />');
1625 $form_tpl->setVariable('TXT_DELETE', $this->lng->txt('forums_info_delete_draft'));
1626 $this->ctrl->setParameter($this, 'action', 'ready_delete_draft');
1627 $this->ctrl->setParameter($this, 'draft_id', (int) $_GET['draft_id']);
1628 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1629 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
1630 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
1631 $form_tpl->setVariable('FORM_ACTION', $this->ctrl->getLinkTarget($this, 'viewThread'));
1632 $this->ctrl->clearParameters($this);
1633 $form_tpl->setVariable('CANCEL_BUTTON', $this->lng->txt('cancel'));
1634 $form_tpl->setVariable('CONFIRM_BUTTON', $this->lng->txt('confirm'));
1635
1636 return $form_tpl->get();
1637 }
1638
1639 public function getActivationFormHTML()
1640 {
1641 $form_tpl = new ilTemplate('tpl.frm_activation_post_form.html', true, true, 'Modules/Forum');
1642
1643 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1644 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
1645 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
1646 $form_tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'performPostActivation'));
1647 $form_tpl->setVariable('SPACER', '<hr noshade="noshade" width="100%" size="1" align="center" />');
1648 $form_tpl->setVariable('ANCHOR', $this->objCurrentPost->getId());
1649 $form_tpl->setVariable('TXT_ACT', $this->lng->txt('activate_post_txt'));
1650 $form_tpl->setVariable('CONFIRM_BUTTON', $this->lng->txt('activate_only_current'));
1651 $form_tpl->setVariable('CMD_CONFIRM', 'performPostActivation');
1652 $form_tpl->setVariable('CANCEL_BUTTON', $this->lng->txt('cancel'));
1653 $form_tpl->setVariable('CMD_CANCEL', 'viewThread');
1654 $this->ctrl->clearParameters($this);
1655
1656 return $form_tpl->get();
1657 }
1658
1659 public function getCensorshipFormHTML()
1660 {
1661 $frm = $this->object->Forum;
1662 $form_tpl = new ilTemplate('tpl.frm_censorship_post_form.html', true, true, 'Modules/Forum');
1663
1664 $form_tpl->setVariable('ANCHOR', $this->objCurrentPost->getId());
1665 $form_tpl->setVariable('SPACER', '<hr noshade="noshade" width="100%" size="1" align="center" />');
1666 $this->ctrl->setParameter($this, 'action', 'ready_censor');
1667 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1668 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
1669 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
1670 $form_tpl->setVariable('FORM_ACTION', $this->ctrl->getLinkTarget($this, 'viewThread'));
1671 $this->ctrl->clearParameters($this);
1672 $form_tpl->setVariable('TXT_CENS_MESSAGE', $this->lng->txt('forums_the_post'));
1673 $form_tpl->setVariable('TXT_CENS_COMMENT', $this->lng->txt('forums_censor_comment') . ':');
1674 $form_tpl->setVariable('CENS_MESSAGE', $frm->prepareText($this->objCurrentPost->getCensorshipComment(), 2));
1675
1676 if ($this->objCurrentPost->isCensored()) {
1677 $form_tpl->setVariable('TXT_CENS', $this->lng->txt('forums_info_censor2_post'));
1678 $form_tpl->setVariable('YES_BUTTON', $this->lng->txt('confirm'));
1679 $form_tpl->setVariable('NO_BUTTON', $this->lng->txt('cancel'));
1680 } else {
1681 $form_tpl->setVariable('TXT_CENS', $this->lng->txt('forums_info_censor_post'));
1682 $form_tpl->setVariable('CANCEL_BUTTON', $this->lng->txt('cancel'));
1683 $form_tpl->setVariable('CONFIRM_BUTTON', $this->lng->txt('confirm'));
1684 }
1685
1686 return $form_tpl->get();
1687 }
1688
1692 private function initReplyEditForm()
1693 {
1698 // init objects
1699 $oForumObjects = $this->getForumObjects();
1700 $frm = $oForumObjects['frm'];
1701 $oFDForum = $oForumObjects['file_obj'];
1702
1703 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
1704 $this->replyEditForm = new ilPropertyFormGUI();
1705 $this->replyEditForm->setId('id_showreply');
1706 $this->replyEditForm->setTableWidth('100%');
1707 $cancel_cmd = 'cancelPost';
1708 if ($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply') {
1709 $this->ctrl->setParameter($this, 'action', 'ready_showreply');
1710 } elseif ($_GET['action'] == 'showdraft' || $_GET['action'] == 'editdraft') {
1711 $this->ctrl->setParameter($this, 'action', $_GET['action']);
1712 $this->ctrl->setParameter($this, 'draft_id', (int) $_GET['draft_id']);
1713 } else {
1714 $this->ctrl->setParameter($this, 'action', 'ready_showedit');
1715 }
1716
1717 $this->ctrl->setParameter($this, 'offset', (int) $_GET['offset']);
1718 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
1719 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1720 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
1721 if ($this->isTopLevelReplyCommand()) {
1722 $this->replyEditForm->setFormAction($this->ctrl->getFormAction($this, 'saveTopLevelPost'), 'frm_page_bottom');
1723 } elseif ($_GET['action'] == 'publishDraft' || $_GET['action'] == 'editdraft') {
1724 $this->replyEditForm->setFormAction($this->ctrl->getFormAction($this, 'publishDraft'), $this->objCurrentPost->getId());
1725 } else {
1726 $this->replyEditForm->setFormAction($this->ctrl->getFormAction($this, 'savePost'), $this->objCurrentPost->getId());
1727 }
1728 $this->ctrl->clearParameters($this);
1729
1730 if ($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply') {
1731 $this->replyEditForm->setTitle($this->lng->txt('forums_your_reply'));
1732 } elseif ($_GET['action'] == 'showdraft' || $_GET['action'] == 'editdraft') {
1733 $this->replyEditForm->setTitle($this->lng->txt('forums_edit_draft'));
1734 } else {
1735 $this->replyEditForm->setTitle($this->lng->txt('forums_edit_post'));
1736 }
1737
1738 // alias
1740 && in_array($_GET['action'], array('showreply', 'ready_showreply'))) {
1741 $oAnonymousNameGUI = new ilTextInputGUI($this->lng->txt('forums_your_name'), 'alias');
1742 $oAnonymousNameGUI->setMaxLength(64);
1743 $oAnonymousNameGUI->setInfo($this->lng->txt('forums_use_alias'));
1744
1745 $this->replyEditForm->addItem($oAnonymousNameGUI);
1746 }
1747
1748 // subject
1749 $oSubjectGUI = new ilTextInputGUI($this->lng->txt('forums_subject'), 'subject');
1750 $oSubjectGUI->setMaxLength(255);
1751 $oSubjectGUI->setRequired(true);
1752
1753 if ($this->objProperties->getSubjectSetting() == 'empty_subject') {
1754 $oSubjectGUI->setInfo($this->lng->txt('enter_new_subject'));
1755 }
1756
1757 $this->replyEditForm->addItem($oSubjectGUI);
1758
1759 // post
1760 $oPostGUI = new ilTextAreaInputGUI(
1761 $_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply' ? $this->lng->txt('forums_your_reply') : $this->lng->txt('forums_edit_post'),
1762 'message'
1763 );
1764 $oPostGUI->setRequired(true);
1765 $oPostGUI->setRows(15);
1766 $oPostGUI->setUseRte(true);
1767 $oPostGUI->addPlugin('latex');
1768 $oPostGUI->addButton('latex');
1769 $oPostGUI->addButton('pastelatex');
1770 $oPostGUI->addPlugin('ilfrmquote');
1771
1772 //$oPostGUI->addPlugin('code');
1773 if ($_GET['action'] == 'showreply' || $_GET['action'] == 'showdraft') {
1774 $oPostGUI->addButton('ilFrmQuoteAjaxCall');
1775 }
1776 $oPostGUI->removePlugin('advlink');
1777 $oPostGUI->setRTERootBlockElement('');
1778 $oPostGUI->usePurifier(true);
1779 $oPostGUI->disableButtons(array(
1780 'charmap',
1781 'undo',
1782 'redo',
1783 'justifyleft',
1784 'justifycenter',
1785 'justifyright',
1786 'justifyfull',
1787 'anchor',
1788 'fullscreen',
1789 'cut',
1790 'copy',
1791 'paste',
1792 'pastetext',
1793 'formatselect'
1794 ));
1795
1796 if ($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply' || $_GET['action'] == 'showdraft' || $_GET['action'] == 'editdraft') {
1797 $oPostGUI->setRTESupport($this->user->getId(), 'frm~', 'frm_post', 'tpl.tinymce_frm_post.html', false, '3.5.11');
1798 } else {
1799 $oPostGUI->setRTESupport($this->objCurrentPost->getId(), 'frm', 'frm_post', 'tpl.tinymce_frm_post.html', false, '3.5.11');
1800 }
1801 // purifier
1802 require_once 'Services/Html/classes/class.ilHtmlPurifierFactory.php';
1803 $oPostGUI->setPurifier(ilHtmlPurifierFactory::_getInstanceByType('frm_post'));
1804
1805 $this->replyEditForm->addItem($oPostGUI);
1806
1807 // notification only if gen. notification is disabled and forum isn't anonymous
1808 include_once 'Services/Mail/classes/class.ilMail.php';
1809 $umail = new ilMail($this->user->getId());
1810 if ($this->rbac->system()->checkAccess('internal_mail', $umail->getMailObjectReferenceId()) &&
1811 !$frm->isThreadNotificationEnabled($this->user->getId(), $this->objCurrentPost->getThreadId()) &&
1812 !$this->objProperties->isAnonymized()) {
1813 $oNotificationGUI = new ilCheckboxInputGUI($this->lng->txt('forum_direct_notification'), 'notify');
1814 $oNotificationGUI->setInfo($this->lng->txt('forum_notify_me'));
1815
1816 $this->replyEditForm->addItem($oNotificationGUI);
1817 }
1818
1819 if ($this->objProperties->isFileUploadAllowed()) {
1820 $oFileUploadGUI = new ilFileWizardInputGUI($this->lng->txt('forums_attachments_add'), 'userfile');
1821 $oFileUploadGUI->setFilenames(array(0 => ''));
1822 $this->replyEditForm->addItem($oFileUploadGUI);
1823 }
1824
1825 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
1826 if (
1827 $this->user->isAnonymous() &&
1828 !$this->user->isCaptchaVerified() &&
1829 ilCaptchaUtil::isActiveForForum()
1830 ) {
1831 require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
1832 $captcha = new ilCaptchaInputGUI($this->lng->txt('cont_captcha_code'), 'captcha_code');
1833 $captcha->setRequired(true);
1834 $this->replyEditForm->addItem($captcha);
1835 }
1836
1837 $attachments_of_node = $oFDForum->getFilesOfPost();
1838 if (count($attachments_of_node) && ($_GET['action'] == 'showedit' || $_GET['action'] == 'ready_showedit')) {
1839 $oExistingAttachmentsGUI = new ilCheckboxGroupInputGUI($this->lng->txt('forums_delete_file'), 'del_file');
1840 foreach ($oFDForum->getFilesOfPost() as $file) {
1841 $oAttachmentGUI = new ilCheckboxInputGUI($file['name'], 'del_file');
1842 $oAttachmentGUI->setValue($file['md5']);
1843 $oExistingAttachmentsGUI->addOption($oAttachmentGUI);
1844 }
1845 $this->replyEditForm->addItem($oExistingAttachmentsGUI);
1846 }
1847
1849 if ($_GET['action'] == 'showdraft' || $_GET['action'] == 'editdraft') {
1850 $draftInfoGUI = new ilNonEditableValueGUI('', 'autosave_info', true);
1851 $draftInfoGUI->setValue(sprintf($this->lng->txt('autosave_draft_info'), ilForumPostDraft::lookupAutosaveInterval()));
1852 $this->replyEditForm->addItem($draftInfoGUI);
1853 } elseif ($_GET['action'] != 'showedit' && $_GET['action'] != 'ready_showedit') {
1854 $draftInfoGUI = new ilNonEditableValueGUI('', 'autosave_info', true);
1855 $draftInfoGUI->setValue(sprintf($this->lng->txt('autosave_post_draft_info'), ilForumPostDraft::lookupAutosaveInterval()));
1856 $this->replyEditForm->addItem($draftInfoGUI);
1857 }
1858
1859 $selected_draft_id = (int) $_GET['draft_id'];
1860 $draftObj = new ilForumPostDraft($this->user->getId(), $this->objCurrentPost->getId(), $selected_draft_id);
1861 if ($draftObj->getDraftId() > 0) {
1862 $oFDForumDrafts = new ilFileDataForumDrafts(0, $draftObj->getDraftId());
1863 if (count($oFDForumDrafts->getFilesOfPost())) {
1864 $oExistingAttachmentsGUI = new ilCheckboxGroupInputGUI($this->lng->txt('forums_delete_file'), 'del_file');
1865 foreach ($oFDForumDrafts->getFilesOfPost() as $file) {
1866 $oAttachmentGUI = new ilCheckboxInputGUI($file['name'], 'del_file');
1867 $oAttachmentGUI->setValue($file['md5']);
1868 $oExistingAttachmentsGUI->addOption($oAttachmentGUI);
1869 }
1870 $this->replyEditForm->addItem($oExistingAttachmentsGUI);
1871 }
1872 }
1873 }
1874
1875 if ($this->isTopLevelReplyCommand()) {
1876 $this->replyEditForm->addCommandButton('saveTopLevelPost', $this->lng->txt('create'));
1877 } elseif (ilForumPostDraft::isSavePostDraftAllowed() && $_GET['action'] == 'editdraft') {
1878 $this->replyEditForm->addCommandButton('publishDraft', $this->lng->txt('publish'));
1879 } else {
1880 $this->replyEditForm->addCommandButton('savePost', $this->lng->txt('save'));
1881 }
1882 $hidden_draft_id= new ilHiddenInputGUI('draft_id');
1883 if (isset($_GET['draft_id']) && (int) $_GET['draft_id']> 0) {
1884 $auto_save_draft_id = (int) $_GET['draft_id'];
1885 }
1886 $hidden_draft_id->setValue($auto_save_draft_id);
1887 $this->replyEditForm->addItem($hidden_draft_id);
1888
1889 if ($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply' || $_GET['action'] == 'editdraft') {
1890 include_once 'Services/RTE/classes/class.ilRTE.php';
1891 $rtestring = ilRTE::_getRTEClassname();
1892
1893 if (array_key_exists('show_rte', $_POST)) {
1895 }
1896
1897 if (strtolower($rtestring) != 'iltinymce' || !ilObjAdvancedEditing::_getRichTextEditorUserState()) {
1898 if ($this->isTopLevelReplyCommand()) {
1899 $this->replyEditForm->addCommandButton('quoteTopLevelPost', $this->lng->txt('forum_add_quote'));
1900 } else {
1901 $this->replyEditForm->addCommandButton('quotePost', $this->lng->txt('forum_add_quote'));
1902 }
1903 }
1904
1905 if (!$this->user->isAnonymous()
1906 && ($_GET['action'] == 'editdraft' || $_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply')
1908 ) {
1910 $this->addAutosave($this->replyEditForm);
1911 }
1912
1913 if ($_GET['action'] == 'editdraft') {
1914 $this->replyEditForm->addCommandButton('updateDraft', $this->lng->txt('save_message'));
1915 } else {
1916 $this->replyEditForm->addCommandButton('saveAsDraft', $this->lng->txt('save_message'));
1917 }
1918
1919 $cancel_cmd = 'cancelDraft';
1920 }
1921 }
1922 $this->replyEditForm->addCommandButton($cancel_cmd, $this->lng->txt('cancel'));
1923 }
1924
1928 private function getReplyEditForm()
1929 {
1930 if (null === $this->replyEditForm) {
1931 $this->initReplyEditForm();
1932 }
1933
1934 return $this->replyEditForm;
1935 }
1936
1941 {
1942 if (isset($_GET['draft_id']) && (int) $_GET['draft_id'] > 0 && !$this->user->isAnonymous()
1944 $draft_obj = new ilForumPostDraft($this->user->getId(), $this->objCurrentPost->getId(), (int) $_GET['draft_id']);
1945 }
1946
1947 if ($draft_obj instanceof ilForumPostDraft && $draft_obj->getDraftId() > 0) {
1948 $this->ctrl->setParameter($this, 'action', 'editdraft');
1949 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
1950 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
1951 $this->ctrl->setParameter($this, 'draft_id', $draft_obj->getDraftId());
1952 $this->ctrl->setParameter($this, 'offset', 0);
1953 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
1954 $this->ctrl->redirect($this, 'editDraft');
1955 } else {
1956 $this->viewThreadObject();
1957 }
1958 return;
1959 }
1960
1964 public function saveTopLevelPostObject()
1965 {
1966 $this->savePostObject();
1967 return;
1968 }
1969
1973 public function quoteTopLevelPostObject()
1974 {
1975 $this->quotePostObject();
1976 return;
1977 }
1978
1980 {
1981 if (isset($_GET['draft_id']) && (int) $_GET['draft_id'] > 0) {
1982 $this->publishDraftObject(false);
1983 }
1984 }
1985
1986 public function publishDraftObject($use_replyform = true)
1987 {
1988 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1989 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1990 }
1991
1992 if (!$this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
1993 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1994 }
1995
1996 if (!$this->objCurrentTopic->getId()) {
1997 \ilUtil::sendFailure($this->lng->txt('frm_action_not_possible_thr_deleted'), true);
1998 $this->ctrl->redirect($this);
1999 }
2000
2001 if ($this->objCurrentTopic->isClosed()) {
2002 \ilUtil::sendFailure($this->lng->txt('frm_action_not_possible_thr_closed'), true);
2003 $this->ctrl->redirect($this);
2004 }
2005
2006 if (!$this->objCurrentPost->getId()) {
2007 $_GET['action'] = '';
2008 \ilUtil::sendFailure($this->lng->txt('frm_action_not_possible_parent_deleted'));
2009 $this->viewThreadObject();
2010 return;
2011 }
2012
2013 $post_id = $this->objCurrentPost->getId();
2014
2015 $draft_obj = new ilForumPostDraft($this->user->getId(), $post_id, (int) $_GET['draft_id']);
2016
2017 if ($use_replyform) {
2018 $oReplyEditForm = $this->getReplyEditForm();
2019 if (!$oReplyEditForm->checkInput() && !$draft_obj instanceof ilForumPostDraft) {
2020 $oReplyEditForm->setValuesByPost();
2021 return $this->viewThreadObject();
2022 }
2023 $post_subject = $oReplyEditForm->getInput('subject');
2024 $post_message = $oReplyEditForm->getInput('message');
2025 $mob_direction = 0;
2026 } else {
2027 $post_subject = $draft_obj->getPostSubject();
2028 $post_message = $draft_obj->getPostMessage();
2029 $mob_direction = 1;
2030 }
2031
2032 if ($draft_obj->getDraftId() > 0) {
2033 // init objects
2034 $oForumObjects = $this->getForumObjects();
2035 $frm = $oForumObjects['frm'];
2036 $frm->setMDB2WhereCondition(' top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
2037
2038 // reply: new post
2039 $status = 1;
2040 $send_activation_mail = 0;
2041
2042 if ($this->objProperties->isPostActivationEnabled()) {
2043 if (!$this->is_moderator) {
2044 $status = 0;
2045 $send_activation_mail = 1;
2046 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2047 $status = 0;
2048 }
2049 }
2050
2051 $newPost = $frm->generatePost(
2052 $draft_obj->getForumId(),
2053 $draft_obj->getThreadId(),
2054 $this->user->getId(),
2055 $draft_obj->getPostDisplayUserId(),
2056 ilRTE::_replaceMediaObjectImageSrc($post_message, $mob_direction),
2057 $draft_obj->getPostId(),
2058 (int) $draft_obj->getNotify(),
2059 $this->handleFormInput($post_subject, false),
2060 $draft_obj->getPostUserAlias(),
2061 '',
2062 $status,
2063 $send_activation_mail
2064 );
2065
2066 $this->object->markPostRead($this->user->getId(), (int) $this->objCurrentTopic->getId(), (int) $this->objCurrentPost->getId());
2067
2068 $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
2069
2070 foreach ($uploadedObjects as $mob) {
2071 ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
2072 ilObjMediaObject::_saveUsage($mob, 'frm:html', $newPost);
2073 }
2074 ilForumUtil::saveMediaObjects($post_message, 'frm:html', $newPost, $mob_direction);
2075
2076 if ($this->objProperties->isFileUploadAllowed()) {
2077 $file = $_FILES['userfile'];
2078 if (is_array($file) && !empty($file)) {
2079 $tmp_file_obj = new ilFileDataForum($this->object->getId(), $newPost);
2080 $tmp_file_obj->storeUploadedFile($file);
2081 }
2082
2083 //move files of draft to posts directory
2084 $oFDForum = new ilFileDataForum($this->object->getId(), $newPost);
2085 $oFDForumDrafts = new ilFileDataForumDrafts($this->object->getId(), $draft_obj->getDraftId());
2086
2087 $oFDForumDrafts->moveFilesOfDraft($oFDForum->getForumPath(), $newPost);
2088 $oFDForumDrafts->delete();
2089 }
2090
2092 $GLOBALS['ilAppEventHandler']->raise(
2093 'Modules/Forum',
2094 'publishedDraft',
2095 array('draftObj' => $draft_obj,
2096 'obj_id' => $this->object->getId(),
2097 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed())
2098 );
2099 }
2100 $draft_obj->deleteDraft();
2101
2102 $GLOBALS['ilAppEventHandler']->raise(
2103 'Modules/Forum',
2104 'createdPost',
2105 array(
2106 'ref_id' => $this->object->getRefId(),
2107 'post' => new ilForumPost($newPost),
2108 'notify_moderators' => (bool) $send_activation_mail
2109 )
2110 );
2111
2112 $message = '';
2113 if (!$this->is_moderator && !$status) {
2114 $message .= $this->lng->txt('forums_post_needs_to_be_activated');
2115 } else {
2116 $message .= $this->lng->txt('forums_post_new_entry');
2117 }
2118
2119 $_SESSION['frm'][(int) $_GET['thr_pk']]['openTreeNodes'][] = (int) $this->objCurrentPost->getId();
2120
2121 $this->ctrl->clearParameters($this);
2123 $this->ctrl->setParameter($this, 'pos_pk', $newPost);
2124 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2125
2126 $this->ctrl->redirect($this, 'viewThread');
2127 }
2128 }
2129
2133 public function savePostObject()
2134 {
2135 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2136 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2137 }
2138
2139 if (!$this->objCurrentTopic->getId()) {
2140 \ilUtil::sendFailure($this->lng->txt('frm_action_not_possible_thr_deleted'), true);
2141 $this->ctrl->redirect($this);
2142 }
2143
2144 if ($this->objCurrentTopic->isClosed()) {
2145 \ilUtil::sendFailure($this->lng->txt('frm_action_not_possible_thr_closed'), true);
2146 $this->ctrl->redirect($this);
2147 }
2148
2149 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $this->objCurrentTopic);
2150
2151 if (!isset($_POST['del_file']) || !is_array($_POST['del_file'])) {
2152 $_POST['del_file'] = array();
2153 }
2154
2155 $oReplyEditForm = $this->getReplyEditForm();
2156 if ($oReplyEditForm->checkInput()) {
2157 if (!$this->objCurrentPost->getId()) {
2158 $_GET['action'] = '';
2159 \ilUtil::sendFailure($this->lng->txt('frm_action_not_possible_parent_deleted'));
2160 $this->viewThreadObject();
2161 return;
2162 }
2163
2164 $this->doCaptchaCheck();
2165
2166 // init objects
2167 $oForumObjects = $this->getForumObjects();
2171 $forumObj = $oForumObjects['forumObj'];
2175 $frm = $oForumObjects['frm'];
2176 $frm->setMDB2WhereCondition(' top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
2177 $topicData = $frm->getOneTopic();
2178
2179 // Generating new posting
2180 if ($_GET['action'] == 'ready_showreply') {
2181 if (!$this->access->checkAccess('add_reply', '', (int) $_GET['ref_id'])) {
2182 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2183 }
2184
2185 // reply: new post
2186 $status = 1;
2187 $send_activation_mail = 0;
2188
2189 if ($this->objProperties->isPostActivationEnabled()) {
2190 if (!$this->is_moderator) {
2191 $status = 0;
2192 $send_activation_mail = 1;
2193 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2194 $status = 0;
2195 }
2196 }
2197
2198 if ($this->isWritingWithPseudonymAllowed()) {
2199 if (!strlen($oReplyEditForm->getInput('alias'))) {
2200 $user_alias = $this->lng->txt('forums_anonymous');
2201 } else {
2202 $user_alias = $oReplyEditForm->getInput('alias');
2203 }
2204 $display_user_id = 0;
2205 } else {
2206 $user_alias = $this->user->getLogin();
2207 $display_user_id = $this->user->getId();
2208 }
2209
2210 $newPost = $frm->generatePost(
2211 $topicData['top_pk'],
2212 $this->objCurrentTopic->getId(),
2213 $this->user->getId(),
2214 $display_user_id,
2215 ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message'), 0),
2216 $this->objCurrentPost->getId(),
2217 (int) $oReplyEditForm->getInput('notify'),
2218 $this->handleFormInput($oReplyEditForm->getInput('subject'), false),
2219 $user_alias,
2220 '',
2221 $status,
2222 $send_activation_mail
2223 );
2224
2226 $draft_id = 0;
2228 $draft_id = $_POST['draft_id']; // info aus dem autosave?
2229 }
2230 $draft_obj = new ilForumPostDraft($this->user->getId(), $this->objCurrentPost->getId(), $draft_id);
2231 if ($draft_obj instanceof ilForumPostDraft) {
2232 $draft_obj->deleteDraft();
2233 }
2234 }
2235
2236 // mantis #8115: Mark parent as read
2237 $this->object->markPostRead($this->user->getId(), (int) $this->objCurrentTopic->getId(), (int) $this->objCurrentPost->getId());
2238
2239 // copy temporary media objects (frm~)
2240 ilForumUtil::moveMediaObjects($oReplyEditForm->getInput('message'), 'frm~:html', $this->user->getId(), 'frm:html', $newPost);
2241
2242 if ($this->objProperties->isFileUploadAllowed()) {
2243 $oFDForum = new ilFileDataForum($forumObj->getId(), $newPost);
2244 $file = $_FILES['userfile'];
2245 if (is_array($file) && !empty($file)) {
2246 $oFDForum->storeUploadedFile($file);
2247 }
2248 }
2249
2250 $GLOBALS['ilAppEventHandler']->raise(
2251 'Modules/Forum',
2252 'createdPost',
2253 array(
2254 'ref_id' => $this->object->getRefId(),
2255 'post' => new ilForumPost($newPost),
2256 'notify_moderators' => (bool) $send_activation_mail
2257 )
2258 );
2259
2260 $message = '';
2261 if (!$this->is_moderator && !$status) {
2262 $message .= $this->lng->txt('forums_post_needs_to_be_activated');
2263 } else {
2264 $message .= $this->lng->txt('forums_post_new_entry');
2265 }
2266
2268 $this->ctrl->clearParameters($this);
2269 $this->ctrl->setParameter($this, 'post_created_below', $this->objCurrentPost->getId());
2270 $this->ctrl->setParameter($this, 'pos_pk', $newPost);
2271 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2272 $this->ctrl->redirect($this, 'viewThread');
2273 } else {
2274 if ((!$this->is_moderator &&
2275 !$this->objCurrentPost->isOwner($this->user->getId())) || $this->objCurrentPost->isCensored() ||
2276 $this->user->getId() == ANONYMOUS_USER_ID) {
2277 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2278 }
2279
2280 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $this->objCurrentPost->getThread());
2281
2282 // remove usage of deleted media objects
2283 include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
2284 $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm:html', $this->objCurrentPost->getId());
2285 $curMediaObjects = ilRTE::_getMediaObjects($oReplyEditForm->getInput('message'), 0);
2286 foreach ($oldMediaObjects as $oldMob) {
2287 $found = false;
2288 foreach ($curMediaObjects as $curMob) {
2289 if ($oldMob == $curMob) {
2290 $found = true;
2291 break;
2292 }
2293 }
2294 if (!$found) {
2295 if (ilObjMediaObject::_exists($oldMob)) {
2296 ilObjMediaObject::_removeUsage($oldMob, 'frm:html', $this->objCurrentPost->getId());
2297 $mob_obj = new ilObjMediaObject($oldMob);
2298 $mob_obj->delete();
2299 }
2300 }
2301 }
2302
2303 // save old activation status for send_notification decision
2304 $old_status_was_active = $this->objCurrentPost->isActivated();
2305
2306 // if active post has been edited posting mus be activated again by moderator
2307 $status = 1;
2308 $send_activation_mail = 0;
2309
2310 if ($this->objProperties->isPostActivationEnabled()) {
2311 if (!$this->is_moderator) {
2312 $status = 0;
2313 $send_activation_mail = 1;
2314 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2315 $status = 0;
2316 }
2317 }
2318 $this->objCurrentPost->setStatus($status);
2319
2320 $this->objCurrentPost->setSubject($this->handleFormInput($oReplyEditForm->getInput('subject'), false));
2321 $this->objCurrentPost->setMessage(ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message'), 0));
2322 $this->objCurrentPost->setNotification((int) $oReplyEditForm->getInput('notify'));
2323 $this->objCurrentPost->setChangeDate(date('Y-m-d H:i:s'));
2324 $this->objCurrentPost->setUpdateUserId($this->user->getId());
2325
2326 // edit: update post
2327 if ($this->objCurrentPost->update()) {
2328 $this->objCurrentPost->reload();
2329
2330 // Change news item accordingly
2331 include_once 'Services/News/classes/class.ilNewsItem.php';
2332 // note: $this->objCurrentPost->getForumId() does not give us the forum ID here (why?)
2334 $forumObj->getId(),
2335 'frm',
2336 $this->objCurrentPost->getId(),
2337 'pos'
2338 );
2339 if ($news_id > 0) {
2340 $news_item = new ilNewsItem($news_id);
2341 $news_item->setTitle($this->objCurrentPost->getSubject());
2342 $news_item->setContent(
2343 ilRTE::_replaceMediaObjectImageSrc($frm->prepareText(
2344 $this->objCurrentPost->getMessage(),
2345 0
2346 ), 1)
2347 );
2348
2349 if ($this->objCurrentPost->getMessage() != strip_tags($this->objCurrentPost->getMessage())) {
2350 $news_item->setContentHtml(true);
2351 } else {
2352 $news_item->setContentHtml(false);
2353 }
2354 $news_item->update();
2355 }
2356
2357 $oFDForum = $oForumObjects['file_obj'];
2358
2359 if ($this->objProperties->isFileUploadAllowed()) {
2360 $file = $_FILES['userfile'];
2361 if (is_array($file) && !empty($file)) {
2362 $oFDForum->storeUploadedFile($file);
2363 }
2364 }
2365
2366 $file2delete = $oReplyEditForm->getInput('del_file');
2367 if (is_array($file2delete) && count($file2delete)) {
2368 $oFDForum->unlinkFilesByMD5Filenames($file2delete);
2369 }
2370
2371 $GLOBALS['ilAppEventHandler']->raise(
2372 'Modules/Forum',
2373 'updatedPost',
2374 array(
2375 'ref_id' => $this->object->getRefId(),
2376 'post' => $this->objCurrentPost,
2377 'notify_moderators' => (bool) $send_activation_mail,
2378 'old_status_was_active' => (bool) $old_status_was_active
2379 )
2380 );
2381
2382 ilUtil::sendSuccess($this->lng->txt('forums_post_modified'), true);
2383 }
2384
2385 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2386 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2387 $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
2388 $this->ctrl->redirect($this, 'viewThread');
2389 }
2390 } else {
2391 $_GET['action'] = substr($_GET['action'], 6);
2392 }
2393 return $this->viewThreadObject();
2394 }
2395
2396 private function hideToolbar($a_flag = null)
2397 {
2398 if (null === $a_flag) {
2399 return $this->hideToolbar;
2400 }
2401
2402 $this->hideToolbar = $a_flag;
2403 return $this;
2404 }
2405
2406 public function quotePostObject()
2407 {
2408 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2409 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2410 }
2411
2412 if (!is_array($_POST['del_file'])) {
2413 $_POST['del_file'] = array();
2414 }
2415
2416 if ($this->objCurrentTopic->isClosed()) {
2417 $_GET['action'] = '';
2418 return $this->viewThreadObject();
2419 }
2420
2421 $oReplyEditForm = $this->getReplyEditForm();
2422
2423 // remove mandatory fields
2424 $oReplyEditForm->getItemByPostVar('subject')->setRequired(false);
2425 $oReplyEditForm->getItemByPostVar('message')->setRequired(false);
2426
2427 $oReplyEditForm->checkInput();
2428
2429 // add mandatory fields
2430 $oReplyEditForm->getItemByPostVar('subject')->setRequired(true);
2431 $oReplyEditForm->getItemByPostVar('message')->setRequired(true);
2432
2433 $_GET['action'] = 'showreply';
2434
2435 $this->viewThreadObject();
2436 }
2437
2438 public function getQuotationHTMLAsynchObject()
2439 {
2440 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2441 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2442 }
2443
2444 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $this->objCurrentPost->getThread());
2445
2446 $oForumObjects = $this->getForumObjects();
2450 $frm = $oForumObjects['frm'];
2451
2452 require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
2453 $authorinfo = new ilForumAuthorInformation(
2454 $this->objCurrentPost->getPosAuthorId(),
2455 $this->objCurrentPost->getDisplayUserId(),
2456 $this->objCurrentPost->getUserAlias(),
2457 $this->objCurrentPost->getImportName()
2458 );
2459
2460 $html = ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($this->objCurrentPost->getMessage(), 1, $authorinfo->getAuthorName()), 1);
2461 echo $html;
2462 exit();
2463 }
2464
2465 private function getForumObjects()
2466 {
2467 if (null === $this->forumObjects) {
2468 $forumObj = $this->object;
2469 $file_obj = new ilFileDataForum($forumObj->getId(), $this->objCurrentPost->getId());
2470 $frm = $forumObj->Forum;
2471 $frm->setForumId($forumObj->getId());
2472 $frm->setForumRefId($forumObj->getRefId());
2473
2474 $this->forumObjects['forumObj'] = $forumObj;
2475 $this->forumObjects['frm'] = $frm;
2476 $this->forumObjects['file_obj'] = $file_obj;
2477 }
2478
2479 return $this->forumObjects;
2480 }
2481
2482 public function viewThreadObject()
2483 {
2484 $bottom_toolbar = clone $this->toolbar;
2485 $bottom_toolbar_split_button_items = array();
2486
2487 require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
2488 $this->tpl->addCss('./Modules/Forum/css/forum_tree.css');
2489 if (!isset($_SESSION['viewmode'])) {
2490 $_SESSION['viewmode'] = $this->objProperties->getDefaultView();
2491 }
2492
2493 // quick and dirty: check for treeview
2494 if (!isset($_SESSION['thread_control']['old'])) {
2495 $_SESSION['thread_control']['old'] = $_GET['thr_pk'];
2496 $_SESSION['thread_control']['new'] = $_GET['thr_pk'];
2497 } elseif (isset($_SESSION['thread_control']['old']) && $_GET['thr_pk'] != $_SESSION['thread_control']['old']) {
2498 $_SESSION['thread_control']['new'] = $_GET['thr_pk'];
2499 }
2500
2501 if (isset($_GET['viewmode']) && $_GET['viewmode'] != $_SESSION['viewmode']) {
2502 $_SESSION['viewmode'] = $_GET['viewmode'];
2503 }
2504
2505 if ((isset($_GET['action']) && $_SESSION['viewmode'] != ilForumProperties::VIEW_DATE)
2506 ||($_SESSION['viewmode'] == ilForumProperties::VIEW_TREE)) {
2508 } else {
2510 }
2511
2512 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2513 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2514 }
2515
2516 // init objects
2517 $oForumObjects = $this->getForumObjects();
2521 $forumObj = $oForumObjects['forumObj'];
2525 $frm = $oForumObjects['frm'];
2529 $file_obj = $oForumObjects['file_obj'];
2530
2531 // download file
2532 if (isset($_GET['file'])) {
2533 $file_obj_for_delivery = $file_obj;
2534 if (ilForumPostDraft::isSavePostDraftAllowed() && isset($_GET['draft_id']) && (int) $_GET['draft_id'] > 0) {
2535 $file_obj_for_delivery = new ilFileDataForumDrafts($forumObj->getId(), (int) $_GET['draft_id']);
2536 }
2537 $file_obj_for_delivery->deliverFile($_GET['file']);
2538 unset($file_obj_for_delivery);
2539 }
2540
2541 if (!$this->objCurrentTopic->getId()) {
2542 $this->ctrl->redirect($this, 'showThreads');
2543 }
2544
2545 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $this->objCurrentTopic);
2546
2547 // Set context for login
2548 $append = '_' . $this->objCurrentTopic->getId() .
2549 ($this->objCurrentPost->getId() ? '_' . $this->objCurrentPost->getId() : '');
2550 $this->tpl->setLoginTargetPar('frm_' . $_GET['ref_id'] . $append);
2551
2552 // delete temporary media object (not in case a user adds media objects and wants to save an invalid form)
2553 if ($_GET['action'] != 'showreply' && $_GET['action'] != 'showedit') {
2554 try {
2555 include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
2556 $mobs = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
2557 foreach ($mobs as $mob) {
2558 if (ilObjMediaObject::_exists($mob)) {
2559 ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
2560 $mob_obj = new ilObjMediaObject($mob);
2561 $mob_obj->delete();
2562 }
2563 }
2564 } catch (Exception $e) {
2565 }
2566 }
2567
2568 if ($this->isHierarchicalView()) {
2569 require_once 'Modules/Forum/classes/class.ilForumExplorerGUI.php';
2570 $exp = new ilForumExplorerGUI('frm_exp_' . $this->objCurrentTopic->getId(), $this, 'viewThread');
2571 $exp->setThread($this->objCurrentTopic);
2572 if (!$exp->handleCommand()) {
2573 $this->tpl->setLeftNavContent($exp->getHTML());
2574 }
2575 }
2576
2577 require_once './Modules/Forum/classes/class.ilObjForum.php';
2578 require_once './Modules/Forum/classes/class.ilFileDataForum.php';
2579
2580 $this->lng->loadLanguageModule('forum');
2581
2582 // add entry to navigation history
2583 if (!$this->getCreationMode() &&
2584 $this->access->checkAccess('read', '', $this->object->getRefId())) {
2585 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
2586 $this->ilNavigationHistory->addItem($this->object->getRefId(), $this->ctrl->getLinkTarget($this, 'showThreads'), 'frm');
2587 }
2588
2589 // save last access
2590 $forumObj->updateLastAccess($this->user->getId(), (int) $this->objCurrentTopic->getId());
2591
2592 $this->prepareThreadScreen($forumObj);
2593
2594 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_view.html', 'Modules/Forum');
2595
2596 if (isset($_GET['anchor'])) {
2597 $this->tpl->setVariable('JUMP2ANCHOR_ID', (int) $_GET['anchor']);
2598 }
2599
2600 if ($this->isHierarchicalView()) {
2601 $orderField = 'frm_posts_tree.rgt';
2602 $this->objCurrentTopic->setOrderDirection('DESC');
2603 } else {
2604 $orderField = 'frm_posts.pos_date';
2605 $this->objCurrentTopic->setOrderDirection(
2606 in_array($this->objProperties->getDefaultView(), array(ilForumProperties::VIEW_DATE_ASC, ilForumProperties::VIEW_TREE))
2607 ? 'ASC' : 'DESC'
2608 );
2609 }
2610
2611 // get forum- and thread-data
2612 $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
2613
2614 if (is_array($topicData = $frm->getOneTopic())) {
2615 // Visit-Counter for topic
2616 $this->objCurrentTopic->updateVisits();
2617
2618 $this->tpl->setTitle($this->lng->txt('forums_thread') . " \"" . $this->objCurrentTopic->getSubject() . "\"");
2619
2620 // build location-links
2621 $this->locator->addRepositoryItems();
2622 $this->locator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "_top");
2623 $this->tpl->setLocator();
2624
2625 // set tabs
2626 // menu template (contains linkbar)
2628 $menutpl = new ilTemplate('tpl.forums_threads_menu.html', true, true, 'Modules/Forum');
2629
2630 include_once("./Services/Accessibility/classes/class.ilAccessKeyGUI.php");
2631
2632 // mark all as read
2633 if ($this->user->getId() != ANONYMOUS_USER_ID &&
2634 $forumObj->getCountUnread($this->user->getId(), (int) $this->objCurrentTopic->getId())
2635 ) {
2636 $this->ctrl->setParameter($this, 'mark_read', '1');
2637 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
2638
2639 $mark_thr_read_button = ilLinkButton::getInstance();
2640 $mark_thr_read_button->setCaption('forums_mark_read');
2641 $mark_thr_read_button->setUrl($this->ctrl->getLinkTarget($this, 'viewThread'));
2642 $mark_thr_read_button->setAccessKey(ilAccessKey::MARK_ALL_READ);
2643
2644 $bottom_toolbar_split_button_items[] = $mark_thr_read_button;
2645
2646 $this->ctrl->clearParameters($this);
2647 }
2648
2649 // print thread
2650 $this->ctrl->setParameterByClass('ilforumexportgui', 'print_thread', $this->objCurrentTopic->getId());
2651 $this->ctrl->setParameterByClass('ilforumexportgui', 'thr_top_fk', $this->objCurrentTopic->getForumId());
2652
2653
2654 $print_thr_button = ilLinkButton::getInstance();
2655 $print_thr_button->setCaption('forums_print_thread');
2656 $print_thr_button->setUrl($this->ctrl->getLinkTargetByClass('ilforumexportgui', 'printThread'));
2657
2658 $bottom_toolbar_split_button_items[] = $print_thr_button;
2659
2660 $this->ctrl->clearParametersByClass('ilforumexportgui');
2661
2662 $this->addHeaderAction();
2663
2664 if ($_GET['mark_read']) {
2665 $forumObj->markThreadRead($this->user->getId(), (int) $this->objCurrentTopic->getId());
2666 ilUtil::sendInfo($this->lng->txt('forums_thread_marked'), true);
2667 }
2668
2669 // delete post and its sub-posts
2670 if ($_GET['action'] == 'ready_delete' && $_POST['confirm'] != '') {
2671 if (!$this->objCurrentTopic->isClosed() &&
2672 ($this->is_moderator ||
2673 ($this->objCurrentPost->isOwner($this->user->getId()) && !$this->objCurrentPost->hasReplies())) &&
2674 $this->user->getId() != ANONYMOUS_USER_ID) {
2675 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $this->objCurrentPost->getThread());
2676
2677 $frm = new ilForum();
2678
2679 $frm->setForumId($forumObj->getId());
2680 $frm->setForumRefId($forumObj->getRefId());
2681
2682 $dead_thr = $frm->deletePost($this->objCurrentPost->getId());
2683
2684 // if complete thread was deleted ...
2685 if ($dead_thr == $this->objCurrentTopic->getId()) {
2686 $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($forumObj->getId()));
2687
2688 $topicData = $frm->getOneTopic();
2689
2690 ilUtil::sendInfo($this->lng->txt('forums_post_deleted'), true);
2691
2692 if ($topicData['top_num_threads'] > 0) {
2693 $this->ctrl->redirect($this, 'showThreads');
2694 } else {
2695 $this->ctrl->redirect($this, 'createThread');
2696 }
2697 }
2698 ilUtil::sendInfo($this->lng->txt('forums_post_deleted'));
2699 }
2700 }
2701
2702 if ($_GET['action'] == 'ready_delete_draft' && $_POST['confirm'] != '') {
2703 $this->deleteSelectedDraft();
2704 ilUtil::sendInfo($this->lng->txt('forums_post_deleted'));
2705 }
2706
2707 // form processing (censor)
2708 if (!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'ready_censor') {
2709 $cens_message = $this->handleFormInput($_POST['formData']['cens_message']);
2710
2711 if (($_POST['confirm'] != '' || $_POST['no_cs_change'] != '') && $_GET['action'] == 'ready_censor') {
2712 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $this->objCurrentPost->getThread());
2713 $frm->postCensorship($cens_message, $this->objCurrentPost->getId(), 1);
2714 ilUtil::sendSuccess($this->lng->txt('frm_censorship_applied'));
2715 } elseif (($_POST['cancel'] != '' || $_POST['yes_cs_change'] != '') && $_GET['action'] == 'ready_censor') {
2716 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $this->objCurrentPost->getThread());
2717 $frm->postCensorship($cens_message, $this->objCurrentPost->getId());
2718 ilUtil::sendSuccess($this->lng->txt('frm_censorship_revoked'));
2719 }
2720 }
2721
2722 // get complete tree of thread
2723 $first_node = $this->objCurrentTopic->getFirstPostNode();
2724 $this->objCurrentTopic->setOrderField($orderField);
2725 $subtree_nodes = $this->objCurrentTopic->getPostTree($first_node);
2726
2727 if (!$this->isTopLevelReplyCommand() &&
2728 $first_node instanceof ilForumPost &&
2729 !$this->objCurrentTopic->isClosed() &&
2730 $this->access->checkAccess('add_reply', '', (int) $_GET['ref_id'])
2731 ) {
2732 $reply_button = ilLinkButton::getInstance();
2733 $reply_button->setPrimary(true);
2734 $reply_button->setCaption('add_new_answer');
2735 $this->ctrl->setParameter($this, 'action', 'showreply');
2736 $this->ctrl->setParameter($this, 'pos_pk', $first_node->getId());
2737 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
2738 $this->ctrl->setParameter($this, 'offset', (int) $_GET['offset']);
2739 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2740
2741 $reply_button->setUrl($this->ctrl->getLinkTarget($this, 'createTopLevelPost', 'frm_page_bottom'));
2742
2743 $this->ctrl->clearParameters($this);
2744 array_unshift($bottom_toolbar_split_button_items, $reply_button);
2745 }
2746
2747 // no posts
2748 if (!$posNum = count($subtree_nodes)) {
2749 ilUtil::sendInfo($this->lng->txt('forums_no_posts_available'));
2750 }
2751
2752 $pageHits = $frm->getPageHits();
2753
2754 $z = 0;
2755
2756 // navigation to browse
2757 if ($posNum > $pageHits) {
2758 $params = array(
2759 'ref_id' => $_GET['ref_id'],
2760 'thr_pk' => $this->objCurrentTopic->getId(),
2761 'orderby' => $_GET['orderby']
2762 );
2763
2764 if (!$_GET['offset']) {
2765 $Start = 0;
2766 } else {
2767 $Start = $_GET['offset'];
2768 }
2769
2770 $linkbar = ilUtil::Linkbar($this->ctrl->getLinkTarget($this, 'viewThread'), $posNum, $pageHits, $Start, $params);
2771
2772 if ($linkbar != '') {
2773 $menutpl->setCurrentBlock('linkbar');
2774 $menutpl->setVariable('LINKBAR', $linkbar);
2775 $menutpl->parseCurrentBlock();
2776 }
2777 }
2778
2779 $this->tpl->setVariable('THREAD_MENU', $menutpl->get());
2780
2781 // assistance val for anchor-links
2782 $jump = 0;
2783 $render_drafts = false;
2784 $draftsObjects = null;
2785
2786 if (ilForumPostDraft::isSavePostDraftAllowed() && !$this->user->isAnonymous()) {
2787 $draftsObjects = ilForumPostDraft::getInstancesByUserIdAndThreadId($this->user->getId(), $this->objCurrentTopic->getId());
2788 if (count($draftsObjects) > 0) {
2789 $render_drafts = true;
2790 }
2791 }
2792
2793 // generate post-dates
2794 foreach ($subtree_nodes as $node) {
2799 $this->ctrl->clearParameters($this);
2800
2801 if ($this->objCurrentPost->getId() && $this->objCurrentPost->getId() == $node->getId()) {
2802 $jump++;
2803 }
2804
2805 if ($posNum > $pageHits && $z >= ($Start + $pageHits)) {
2806 // if anchor-link was not found ...
2807 if ($this->objCurrentPost->getId() && $jump < 1) {
2808 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
2809 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2810 $this->ctrl->setParameter($this, 'offset', ($Start + $pageHits));
2811 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2812 $this->ctrl->redirect($this, 'viewThread', $this->objCurrentPost->getId());
2813 } else {
2814 break;
2815 }
2816 }
2817
2818 if (($posNum > $pageHits && $z >= $Start) || $posNum <= $pageHits) {
2819 $actions = array();
2820 if (!$this->isTopLevelReplyCommand() && $this->objCurrentPost->getId() == $node->getId()) {
2821 # actions for "active" post
2822 if ($this->is_moderator || $node->isActivated() || $node->isOwner($this->user->getId())) {
2823 // reply/edit
2824 if (
2825 !$this->objCurrentTopic->isClosed() && (
2826 $_GET['action'] == 'showreply' || $_GET['action'] == 'showedit' ||
2827 $_GET['action'] == 'showdraft'|| $_GET['action'] == 'editdraft'
2828 )) {
2829 if ($_GET['action'] == 'showedit' &&
2830 ((!$this->is_moderator &&
2831 !$node->isOwner($this->user->getId()) || $this->user->getId() == ANONYMOUS_USER_ID) || $node->isCensored())) {
2832 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->getMessage());
2833 } elseif ($_GET['action'] == 'showreply' && !$this->access->checkAccess('add_reply', '', (int) $_GET['ref_id'])) {
2834 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->getMessage());
2835 }
2836
2837 $this->tpl->setVariable('REPLY_ANKER', $this->objCurrentPost->getId());
2838 $oEditReplyForm = $this->getReplyEditForm();
2839 if ($_GET['action'] != 'editdraft') {
2840 switch ($this->objProperties->getSubjectSetting()) {
2841 case 'add_re_to_subject':
2842 $subject = $this->getModifiedReOnSubject(true);
2843 break;
2844
2845 case 'preset_subject':
2846 $subject = $this->objCurrentPost->getSubject();
2847 break;
2848
2849 case 'empty_subject':
2850 default:
2851 $subject = null;
2852 break;
2853 }
2854 }
2855 switch ($_GET['action']) {
2856 case 'showreply':
2857 if ($this->ctrl->getCmd() == 'savePost' || $this->ctrl->getCmd() == 'saveAsDraft') {
2858 $oEditReplyForm->setValuesByPost();
2859 } elseif ($this->ctrl->getCmd() == 'quotePost') {
2860 require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
2861 $authorinfo = new ilForumAuthorInformation(
2862 $node->getPosAuthorId(),
2863 $node->getDisplayUserId(),
2864 $node->getUserAlias(),
2865 $node->getImportName()
2866 );
2867
2868 $oEditReplyForm->setValuesByPost();
2869 $oEditReplyForm->getItemByPostVar('message')->setValue(
2871 $frm->prepareText($node->getMessage(), 1, $authorinfo->getAuthorName()) . "\n" . $oEditReplyForm->getInput('message'),
2872 1
2873 )
2874 );
2875 } else {
2876 $oEditReplyForm->setValuesByArray(array(
2877 'alias' => '',
2878 'subject' => $subject,
2879 'message' => '',
2880 'notify' => 0,
2881 'userfile' => '',
2882 'del_file' => array()
2883 ));
2884 }
2885
2886 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2887 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2888
2889 $jsTpl = new ilTemplate('tpl.forum_post_quoation_ajax_handler.html', true, true, 'Modules/Forum');
2890 $jsTpl->setVariable(
2891 'IL_FRM_QUOTE_CALLBACK_SRC',
2892 $this->ctrl->getLinkTarget($this, 'getQuotationHTMLAsynch', '', true)
2893 );
2894 $this->ctrl->clearParameters($this);
2895 $this->tpl->setVariable('FORM_ADDITIONAL_JS', $jsTpl->get());
2896 break;
2897
2898 case 'showedit':
2899 if ($this->ctrl->getCmd() == 'savePost') {
2900 $oEditReplyForm->setValuesByPost();
2901 } else {
2902 $oEditReplyForm->setValuesByArray(array(
2903 'alias' => '',
2904 'subject' => $this->objCurrentPost->getSubject(),
2905 'message' => ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($this->objCurrentPost->getMessage(), 2), 1),
2906 'notify' => $this->objCurrentPost->isNotificationEnabled() ? true : false,
2907 'userfile' => '',
2908 'del_file' => array()
2909 ));
2910 }
2911 break;
2912
2913 case 'editdraft':
2914 if (in_array($this->ctrl->getCmd(), array('saveDraft', 'updateDraft', 'publishDraft' ))) {
2915 $oEditReplyForm->setValuesByPost();
2916 } else {
2917 if (isset($_GET['draft_id']) && (int) $_GET['draft_id'] > 0) {
2921 $draftObject = new ilForumPostDraft($this->user->getId(), $this->objCurrentPost->getId(), (int) $_GET['draft_id']);
2922 $oEditReplyForm->setValuesByArray(array(
2923 'alias' => $draftObject->getPostUserAlias(),
2924 'subject' => $draftObject->getPostSubject(),
2925 'message' => ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($draftObject->getPostMessage(), 2), 1),
2926 'notify' => $draftObject->getNotify() ? true : false,
2927 'userfile' => '',
2928 'del_file' => array()
2929 ));
2930 // $edit_draft_id = $this->objCurrentPost->getId();
2931 $edit_draft_id = $draftObject->getDraftId();
2932 }
2933 }
2934 break;
2935 }
2936 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2937 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2938 $this->ctrl->setParameter($this, 'offset', (int) $_GET['offset']);
2939 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
2940 $this->ctrl->setParameter($this, 'action', $_GET['action']);
2941 if ($_GET['action'] != 'editdraft') {
2942 $this->tpl->setVariable('FORM', $oEditReplyForm->getHTML());
2943 }
2944 $this->ctrl->clearParameters($this);
2945 } // if ($_GET['action'] == 'showreply' || $_GET['action'] == 'showedit')
2946 elseif (!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'delete') {
2947 if ($this->is_moderator ||
2948 ($node->isOwner($this->user->getId()) && !$node->hasReplies()) &&
2949 $this->user->getId() != ANONYMOUS_USER_ID) {
2950 // confirmation: delete
2951 $this->tpl->setVariable('FORM', $this->getDeleteFormHTML());
2952 }
2953 }
2954 // else if ($_GET['action'] == 'delete')
2955 elseif (!$this->objCurrentTopic->isClosed() && $_GET['action'] == 'censor') {
2956 if ($this->is_moderator) {
2957 // confirmation: censor / remove censorship
2958 $this->tpl->setVariable('FORM', $this->getCensorshipFormHTML());
2959 }
2960 } elseif (!$this->objCurrentTopic->isClosed() && $this->displayConfirmPostActivation()) {
2961 if ($this->is_moderator) {
2962 // confirmation: activate
2963 $this->tpl->setVariable('FORM', $this->getActivationFormHTML());
2964 }
2965 }
2966 }
2967 }
2968 $this->renderPostContent($node, $Start, $z);
2969 $this->renderDraftContent($render_drafts, $node, $edit_draft_id);
2970 }
2971 $z++;
2972 }
2973
2974 $first_node = $this->objCurrentTopic->getFirstPostNode();
2975 if (
2976 $first_node instanceof ilForumPost &&
2977 in_array($this->ctrl->getCmd(), array('createTopLevelPost', 'saveTopLevelPost', 'quoteTopLevelPost')) &&
2978 !$this->objCurrentTopic->isClosed() &&
2979 $this->access->checkAccess('add_reply', '', (int) $_GET['ref_id'])) {
2980 // Important: Don't separate the following two lines (very fragile code ...)
2981 $this->objCurrentPost->setId($first_node->getId());
2982 $form = $this->getReplyEditForm();
2983
2984 if ($this->ctrl->getCmd() == 'saveTopLevelPost') {
2985 $form->setValuesByPost();
2986 } elseif ($this->ctrl->getCmd() == 'quoteTopLevelPost') {
2987 require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
2988 $authorinfo = new ilForumAuthorInformation(
2989 $first_node->getPosAuthorId(),
2990 $first_node->getDisplayUserId(),
2991 $first_node->getUserAlias(),
2992 $first_node->getImportName()
2993 );
2994
2995 $form->setValuesByPost();
2996 $form->getItemByPostVar('message')->setValue(
2998 $frm->prepareText($first_node->getMessage(), 1, $authorinfo->getAuthorName()) . "\n" . $form->getInput('message'),
2999 1
3000 )
3001 );
3002 }
3003 $this->ctrl->setParameter($this, 'pos_pk', $first_node->getId());
3004 $this->ctrl->setParameter($this, 'thr_pk', $first_node->getThreadId());
3005 $jsTpl = new ilTemplate('tpl.forum_post_quoation_ajax_handler.html', true, true, 'Modules/Forum');
3006 $jsTpl->setVariable('IL_FRM_QUOTE_CALLBACK_SRC', $this->ctrl->getLinkTarget($this, 'getQuotationHTMLAsynch', '', true));
3007 $this->ctrl->clearParameters($this);
3008 $this->tpl->setVariable('BOTTOM_FORM_ADDITIONAL_JS', $jsTpl->get());
3009 ;
3010 $this->tpl->setVariable('BOTTOM_FORM', $form->getHTML());
3011 }
3012 } else {
3013 $this->tpl->setCurrentBlock('posts_no');
3014 $this->tpl->setVariable('TXT_MSG_NO_POSTS_AVAILABLE', $this->lng->txt('forums_posts_not_available'));
3015 $this->tpl->parseCurrentBlock();
3016 }
3017
3018 if ($bottom_toolbar_split_button_items) {
3019 $bottom_split_button = ilSplitButtonGUI::getInstance();
3020 $i = 0;
3021 foreach ($bottom_toolbar_split_button_items as $item) {
3022 if ($i == 0) {
3023 $bottom_split_button->setDefaultButton($item);
3024 } else {
3025 $bottom_split_button->addMenuItem(new ilButtonToSplitButtonMenuItemAdapter($item));
3026 }
3027
3028 ++$i;
3029 }
3030 $bottom_toolbar->addStickyItem($bottom_split_button);
3031 $this->toolbar->addStickyItem($bottom_split_button);
3032 }
3033
3034 if ($bottom_toolbar_split_button_items) {
3035 $bottom_toolbar->addSeparator();
3036 }
3037
3038 $to_top_button = ilLinkButton::getInstance();
3039 $to_top_button->setCaption('top_of_page');
3040 $to_top_button->setUrl('#frm_page_top');
3041 $bottom_toolbar->addButtonInstance($to_top_button);
3042 $this->tpl->setVariable('TOOLBAR_BOTTOM', $bottom_toolbar->getHTML());
3043
3044 include_once 'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
3045 $permalink = new ilPermanentLinkGUI('frm', $this->object->getRefId(), '_' . $this->objCurrentTopic->getId());
3046 $this->tpl->setVariable('PRMLINK', $permalink->getHTML());
3047
3048 $this->tpl->addOnLoadCode('$(".ilFrmPostContent img").each(function() {
3049 var $elm = $(this);
3050 $elm.css({
3051 maxWidth: $elm.attr("width") + "px",
3052 maxHeight: $elm.attr("height") + "px"
3053 });
3054 $elm.removeAttr("width");
3055 $elm.removeAttr("height");
3056 });');
3057
3058 return true;
3059 }
3060
3061 private function getModifiedReOnSubject($on_reply = false)
3062 {
3063 $subject = $this->objCurrentPost->getSubject();
3064 $re_txt = $this->lng->txt('post_reply');
3065
3066 $re_txt_with_num = str_replace(':', '(', $re_txt);
3067 $search_length = strlen($re_txt_with_num);
3068 $comp = substr_compare($re_txt_with_num, substr($subject, 0, $search_length), 0, $search_length);
3069
3070 if ($comp == 0) {
3071 $modified_subject = $subject;
3072 if ($on_reply == true) {
3073 // i.e. $subject = "Re(12):"
3074 $str_pos_start = strpos($subject, '(');
3075 $str_pos_end = strpos($subject, ')');
3076
3077 $length = ((int) $str_pos_end - (int) $str_pos_start);
3078 $str_pos_start++;
3079 $txt_number = substr($subject, $str_pos_start, $length - 1);
3080
3081 if (is_numeric($txt_number)) {
3082 $re_count = (int) $txt_number + 1;
3083 $modified_subject = substr($subject, 0, $str_pos_start) . $re_count . substr($subject, $str_pos_end);
3084 }
3085 }
3086 } else {
3087 $re_count = substr_count($subject, $re_txt);
3088 if ($re_count >= 1 && $on_reply == true) {
3089 $subject = str_replace($re_txt, '', $subject);
3090
3091 // i.e. $subject = "Re: Re: Re: ... " -> "Re(4):"
3092 $re_count++;
3093 $modified_subject = sprintf($this->lng->txt('post_reply_count'), $re_count) . ' ' . trim($subject);
3094 } elseif ($re_count >= 1 && $on_reply == false) {
3095 // possibility to modify the subject only for output
3096 // i.e. $subject = "Re: Re: Re: ... " -> "Re(3):"
3097 $modified_subject = sprintf($this->lng->txt('post_reply_count'), $re_count) . ' ' . trim($subject);
3098 } elseif ($re_count == 0) {
3099 // the first reply to a thread
3100 $modified_subject = $this->lng->txt('post_reply') . ' ' . $this->objCurrentPost->getSubject();
3101 }
3102 }
3103 return $modified_subject;
3104 }
3105
3106 public function showUserObject()
3107 {
3108 include_once 'Services/User/classes/class.ilPublicUserProfileGUI.php';
3109 $profile_gui = new ilPublicUserProfileGUI((int) $_GET['user']);
3110 $add = $this->getUserProfileAdditional((int) $_GET['ref_id'], (int) $_GET['user']);
3111 $profile_gui->setAdditional($add);
3112 $profile_gui->setBackUrl(\ilUtil::stripSlashes($_GET['backurl']));
3113 $this->tpl->setContent($this->ctrl->getHTML($profile_gui));
3114 }
3115
3116 protected function getUserProfileAdditional($a_forum_ref_id, $a_user_id)
3117 {
3118 if (!$this->access->checkAccess('read', '', $a_forum_ref_id)) {
3119 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3120 }
3121
3122 $this->lng->loadLanguageModule('forum');
3123
3127 $ref_obj = ilObjectFactory::getInstanceByRefId($a_forum_ref_id);
3128 if ($ref_obj->getType() == 'frm') {
3129 $forumObj = new ilObjForum($a_forum_ref_id);
3130 $frm = $forumObj->Forum;
3131 $frm->setForumId($forumObj->getId());
3132 $frm->setForumRefId($forumObj->getRefId());
3133 } else {
3134 $frm = new ilForum();
3135 }
3136
3137 // count articles of user
3138 if ($this->access->checkAccess('moderate_frm', '', $a_forum_ref_id)) {
3139 $numPosts = $frm->countUserArticles(addslashes($a_user_id));
3140 } else {
3141 $numPosts = $frm->countActiveUserArticles(addslashes($a_user_id));
3142 }
3143
3144 return array($this->lng->txt('forums_posts') => $numPosts);
3145 }
3146
3148 {
3149 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3150 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3151 }
3152
3153 unset($_SESSION['threads2move']);
3154
3155 if (isset($_POST['thread_ids']) && is_array($_POST['thread_ids'])) {
3156 if (isset($_POST['selected_cmd']) && $_POST['selected_cmd'] == 'move') {
3157 if ($this->is_moderator) {
3158 $_SESSION['threads2move'] = $_POST['thread_ids'];
3159 $this->moveThreadsObject();
3160 }
3161 } elseif ($_POST['selected_cmd'] == 'enable_notifications' && $this->settings->get('forum_notification') != 0) {
3162 for ($i = 0; $i < count($_POST['thread_ids']); $i++) {
3163 $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3164 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $tmp_obj);
3165 $tmp_obj->enableNotification($this->user->getId());
3166 }
3167
3168 $this->ctrl->redirect($this, 'showThreads');
3169 } elseif ($_POST['selected_cmd'] == 'disable_notifications' && $this->settings->get('forum_notification') != 0) {
3170 for ($i = 0; $i < count($_POST['thread_ids']); $i++) {
3171 $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3172 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $tmp_obj);
3173 $tmp_obj->disableNotification($this->user->getId());
3174 }
3175
3176 $this->ctrl->redirect($this, 'showThreads');
3177 } elseif ($_POST['selected_cmd'] == 'close') {
3178 if ($this->is_moderator) {
3179 for ($i = 0; $i < count($_POST['thread_ids']); $i++) {
3180 $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3181 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $tmp_obj);
3182 $tmp_obj->close();
3183 }
3184 }
3185 ilUtil::sendSuccess($this->lng->txt('selected_threads_closed'), true);
3186 $this->ctrl->redirect($this, 'showThreads');
3187 } elseif ($_POST['selected_cmd'] == 'reopen') {
3188 if ($this->is_moderator) {
3189 for ($i = 0; $i < count($_POST['thread_ids']); $i++) {
3190 $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3191 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $tmp_obj);
3192 $tmp_obj->reopen();
3193 }
3194 }
3195
3196 ilUtil::sendSuccess($this->lng->txt('selected_threads_reopened'), true);
3197 $this->ctrl->redirect($this, 'showThreads');
3198 } elseif ($_POST['selected_cmd'] == 'makesticky') {
3199 if ($this->is_moderator) {
3200 $message = $this->lng->txt('sel_threads_make_sticky');
3201
3202 for ($i = 0; $i < count($_POST['thread_ids']); $i++) {
3203 $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3204 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $tmp_obj);
3205 $makeSticky = $tmp_obj->makeSticky();
3206
3207 if (!$makeSticky) {
3208 $message = $this->lng->txt('sel_threads_already_sticky');
3209 }
3210 }
3211 }
3212 if ($message != null) {
3214 }
3215 $this->ctrl->redirect($this, 'showThreads');
3216 } elseif ($_POST['selected_cmd'] == 'unmakesticky') {
3217 if ($this->is_moderator) {
3218 $message = $this->lng->txt('sel_threads_make_unsticky');
3219 for ($i = 0; $i < count($_POST['thread_ids']); $i++) {
3220 $tmp_obj = new ilForumTopic($_POST['thread_ids'][$i]);
3221 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $tmp_obj);
3222 $unmakeSticky = $tmp_obj->unmakeSticky();
3223 if (!$unmakeSticky) {
3224 $message = $this->lng->txt('sel_threads_already_unsticky');
3225 }
3226 }
3227 }
3228
3229 if ($message != null) {
3231 }
3232 $this->ctrl->redirect($this, 'showThreads');
3233 } elseif ($_POST['selected_cmd'] == 'editThread') {
3234 if ($this->is_moderator) {
3235 $count = count($_POST['thread_ids']);
3236 if ($count != 1) {
3237 ilUtil::sendInfo($this->lng->txt('select_max_one_thread'), true);
3238 $this->ctrl->redirect($this, 'showThreads');
3239 } else {
3240 foreach ($_POST['thread_ids'] as $thread_id) {
3241 return $this->editThreadObject($thread_id, null);
3242 }
3243 }
3244 }
3245
3246 $this->ctrl->redirect($this, 'showThreads');
3247 } elseif ($_POST['selected_cmd'] == 'html') {
3248 $this->ctrl->setCmd('exportHTML');
3249 $this->ctrl->setCmdClass('ilForumExportGUI');
3250 $this->executeCommand();
3251 } elseif ($_POST['selected_cmd'] == 'confirmDeleteThreads') {
3252 $this->confirmDeleteThreads();
3253 } elseif ($_POST['selected_cmd'] == 'merge') {
3254 $this->mergeThreadsObject();
3255 } else {
3256 ilUtil::sendInfo($this->lng->txt('topics_please_select_one_action'), true);
3257 $this->ctrl->redirect($this, 'showThreads');
3258 }
3259 } else {
3260 ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'), true);
3261 $this->ctrl->redirect($this, 'showThreads');
3262 }
3263 }
3264
3266 {
3267 if (!$this->is_moderator) {
3268 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3269 }
3270
3271 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3272 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3273 }
3274
3275 $threads2move = $_SESSION['threads2move'];
3276 if (!is_array($threads2move) || !count($threads2move)) {
3277 ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'), true);
3278 $this->ctrl->redirect($this, 'showThreads');
3279 }
3280
3281 if (!$this->access->checkAccess('read', '', (int) $_POST['frm_ref_id'])) {
3282 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3283 }
3284
3285 $threads = [];
3286 array_walk($threads2move, function ($threadId) use (&$threads) {
3287 $thread = new \ilForumTopic($threadId);
3288 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $thread);
3289
3290 $threads[] = $threadId;
3291 });
3292
3293 if (isset($_POST['frm_ref_id']) && (int) $_POST['frm_ref_id']) {
3294 $errorMessages = $this->object->Forum->moveThreads(
3295 (array) $_SESSION['threads2move'],
3296 $this->object->getRefId(),
3297 $this->ilObjDataCache->lookupObjId($_POST['frm_ref_id'])
3298 );
3299
3300 if (array() !== $errorMessages) {
3302 implode("<br><br>", $errorMessages),
3303 true
3304 );
3305 return $this->ctrl->redirectByClass('ilObjForumGUI', 'showThreads');
3306 }
3307
3308 unset($_SESSION['threads2move']);
3309 ilUtil::sendInfo($this->lng->txt('threads_moved_successfully'), true);
3310 $this->ctrl->redirect($this, 'showThreads');
3311 } else {
3312 ilUtil::sendInfo($this->lng->txt('no_forum_selected'));
3313 $this->moveThreadsObject();
3314 }
3315 }
3316
3317 public function cancelMoveThreadsObject()
3318 {
3319 unset($_SESSION['threads2move']);
3320 $this->ctrl->redirect($this, 'showThreads');
3321 }
3322
3323 public function moveThreadsObject()
3324 {
3325 if (!$this->is_moderator) {
3326 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3327 }
3328
3329 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3330 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3331 }
3332
3333 $threads2move = $_SESSION['threads2move'];
3334 if (!is_array($threads2move) || !count($threads2move)) {
3335 ilUtil::sendInfo($this->lng->txt('select_at_least_one_thread'), true);
3336 $this->ctrl->redirect($this, 'showThreads');
3337 }
3338
3339 require_once 'Modules/Forum/classes/class.ilForumMoveTopicsExplorer.php';
3340
3341 $threads = [];
3342 $isModerator = $this->is_moderator;
3343 array_walk($threads2move, function ($threadId) use (&$threads, $isModerator) {
3344 $thread = new \ilForumTopic($threadId, $isModerator);
3345 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $thread);
3346
3347 $threads[] = $thread;
3348 });
3349
3350 $exp = new ilForumMoveTopicsExplorer($this, 'moveThreads');
3351 $exp->setPathOpen($this->object->getRefId());
3352 $exp->setNodeSelected(isset($_POST['frm_ref_id']) && (int) $_POST['frm_ref_id'] ? (int) $_POST['frm_ref_id'] : 0);
3353 $exp->setCurrentFrmRefId($this->object->getRefId());
3354 $exp->setHighlightedNode($this->object->getRefId());
3355 if (!$exp->handleCommand()) {
3356 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_move.html', 'Modules/Forum');
3357
3358 if (!$this->hideToolbar()) {
3359 $this->toolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this));
3360 }
3361
3362 $tblThr = new ilTable2GUI($this);
3363 $tblThr->setId('il_frm_thread_move_table_' . $this->object->getRefId());
3364 $tblThr->setTitle($this->lng->txt('move_chosen_topics'));
3365 $tblThr->addColumn($this->lng->txt('subject'), 'top_name', '100%');
3366 $tblThr->disable('header');
3367 $tblThr->disable('footer');
3368 $tblThr->disable('linkbar');
3369 $tblThr->disable('sort');
3370 $tblThr->disable('linkbar');
3371 $tblThr->setLimit(PHP_INT_MAX);
3372 $tblThr->setRowTemplate('tpl.forums_threads_move_thr_row.html', 'Modules/Forum');
3373 $tblThr->setDefaultOrderField('is_sticky');
3374 $counter = 0;
3375 $result = array();
3376 foreach ($threads as $thread) {
3377 $result[$counter]['num'] = $counter + 1;
3378 $result[$counter]['thr_subject'] = $thread->getSubject();
3379 ++$counter;
3380 }
3381 $tblThr->setData($result);
3382 $this->tpl->setVariable('THREADS_TABLE', $tblThr->getHTML());
3383
3384 $this->tpl->setVariable('FRM_SELECTION_TREE', $exp->getHTML());
3385 $this->tpl->setVariable('CMD_SUBMIT', 'performMoveThreads');
3386 $this->tpl->setVariable('TXT_SUBMIT', $this->lng->txt('move'));
3387 $this->tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this, 'performMoveThreads'));
3388 }
3389
3390 return true;
3391 }
3392
3394 {
3395 if ($this->objProperties->isAnonymized()
3396 && (!$this->is_moderator || ($this->is_moderator && !$this->objProperties->getMarkModeratorPosts()))) {
3397 return true;
3398 }
3399 return false;
3400 }
3401
3402 private function initTopicCreateForm($edit_draft = false)
3403 {
3404 $this->create_topic_form_gui = new ilPropertyFormGUI();
3405 if ($edit_draft == true) {
3406 $this->create_topic_form_gui->setTitle($this->lng->txt('edit_thread_draft'));
3407 } else {
3408 $this->create_topic_form_gui->setTitle($this->lng->txt('forums_new_thread'));
3409 }
3410 $this->create_topic_form_gui->setTitleIcon(ilUtil::getImagePath('icon_frm.svg'));
3411 $this->create_topic_form_gui->setTableWidth('100%');
3412
3413 // form action
3414 $this->create_topic_form_gui->setFormAction($this->ctrl->getFormAction($this, 'addThread'));
3415
3416 if ($this->isWritingWithPseudonymAllowed()) {
3417 $alias_gui = new ilTextInputGUI($this->lng->txt('forums_your_name'), 'alias');
3418 $alias_gui->setInfo($this->lng->txt('forums_use_alias'));
3419 $alias_gui->setMaxLength(255);
3420 $alias_gui->setSize(50);
3421 $this->create_topic_form_gui->addItem($alias_gui);
3422 } else {
3423 $alias_gui = new ilNonEditableValueGUI($this->lng->txt('forums_your_name'), 'alias');
3424 $alias_gui->setValue($this->user->getLogin());
3425 $this->create_topic_form_gui->addItem($alias_gui);
3426 }
3427
3428 // topic
3429 $subject_gui = new ilTextInputGUI($this->lng->txt('forums_thread'), 'subject');
3430 $subject_gui->setMaxLength(255);
3431 $subject_gui->setSize(50);
3432 $subject_gui->setRequired(true);
3433 $this->create_topic_form_gui->addItem($subject_gui);
3434
3435 // message
3436 $post_gui = new ilTextAreaInputGUI($this->lng->txt('forums_the_post'), 'message');
3437 $post_gui->setCols(50);
3438 $post_gui->setRows(15);
3439 $post_gui->setRequired(true);
3440 $post_gui->setUseRte(true);
3441 $post_gui->addPlugin('latex');
3442 $post_gui->addButton('latex');
3443 $post_gui->addButton('pastelatex');
3444 $post_gui->addPlugin('ilfrmquote');
3445 //$post_gui->addPlugin('code');
3446
3447 $this->addAutosave($this->create_topic_form_gui);
3448
3449 $post_gui->removePlugin('advlink');
3450 $post_gui->usePurifier(true);
3451 $post_gui->setRTERootBlockElement('');
3452 $post_gui->setRTESupport($this->user->getId(), 'frm~', 'frm_post', 'tpl.tinymce_frm_post.html', false, '3.5.11');
3453 $post_gui->disableButtons(array(
3454 'charmap',
3455 'undo',
3456 'redo',
3457 'justifyleft',
3458 'justifycenter',
3459 'justifyright',
3460 'justifyfull',
3461 'anchor',
3462 'fullscreen',
3463 'cut',
3464 'copy',
3465 'paste',
3466 'pastetext',
3467 'formatselect'
3468 ));
3469
3470 // purifier
3471 require_once 'Services/Html/classes/class.ilHtmlPurifierFactory.php';
3472 $post_gui->setPurifier(ilHtmlPurifierFactory::_getInstanceByType('frm_post'));
3473 $this->create_topic_form_gui->addItem($post_gui);
3474
3475 if ($this->objProperties->isFileUploadAllowed()) {
3476 $fi = new ilFileWizardInputGUI($this->lng->txt('forums_attachments_add'), 'userfile');
3477 $fi->setFilenames(array(0 => ''));
3478 $this->create_topic_form_gui->addItem($fi);
3479 if ($edit_draft == true) {
3480 if (isset($_GET['draft_id']) && (int) $_GET['draft_id'] > 0) {
3481 $thread_draft = ilForumPostDraft::newInstanceByDraftId((int) $_GET['draft_id']);
3482
3483 if ($thread_draft->getDraftId() > 0) {
3484 $oFDForumDrafts = new ilFileDataForumDrafts(0, $thread_draft->getDraftId());
3485 if (count($oFDForumDrafts->getFilesOfPost())) {
3486 $oExistingAttachmentsGUI = new ilCheckboxGroupInputGUI($this->lng->txt('forums_delete_file'), 'del_file');
3487 foreach ($oFDForumDrafts->getFilesOfPost() as $file) {
3488 $oAttachmentGUI = new ilCheckboxInputGUI($file['name'], 'del_file');
3489 $oAttachmentGUI->setValue($file['md5']);
3490 $oExistingAttachmentsGUI->addOption($oAttachmentGUI);
3491 }
3492 $this->create_topic_form_gui->addItem($oExistingAttachmentsGUI);
3493 }
3494 }
3495 }
3496 }
3497 }
3498
3499 include_once 'Services/Mail/classes/class.ilMail.php';
3500 $umail = new ilMail($this->user->getId());
3501 // catch hack attempts
3502 if ($this->rbac->system()->checkAccess('internal_mail', $umail->getMailObjectReferenceId()) &&
3503 !$this->objProperties->isAnonymized()
3504 ) {
3505 // direct notification
3506 $dir_notification_gui = new ilCheckboxInputGUI($this->lng->txt('forum_direct_notification'), 'notify');
3507 $dir_notification_gui->setInfo($this->lng->txt('forum_notify_me'));
3508 $dir_notification_gui->setValue(1);
3509 $this->create_topic_form_gui->addItem($dir_notification_gui);
3510 }
3511
3512 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
3513 if (
3514 $this->user->isAnonymous() &&
3515 !$this->user->isCaptchaVerified() &&
3516 ilCaptchaUtil::isActiveForForum()
3517 ) {
3518 require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
3519 $captcha = new ilCaptchaInputGUI($this->lng->txt('cont_captcha_code'), 'captcha_code');
3520 $captcha->setRequired(true);
3521 $this->create_topic_form_gui->addItem($captcha);
3522 }
3523
3525 if ($this->ctrl->getCmd() == 'editThreadDraft') {
3526 $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
3527
3528 $this->create_topic_form_gui->setFormAction($this->ctrl->getFormAction($this, 'updateThreadDraft'));
3529 $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
3530 $this->create_topic_form_gui->addCommandButton('publishThreadDraft', $this->lng->txt('publish'));
3531 $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
3532 $this->create_topic_form_gui->addCommandButton('updateThreadDraft', $this->lng->txt('save_message'));
3533 } else {
3534 $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
3535 $this->create_topic_form_gui->setFormAction($this->ctrl->getFormAction($this, 'saveThreadAsDraft'));
3536 $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
3537 $this->create_topic_form_gui->addCommandButton('addThread', $this->lng->txt('create'));
3538 $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
3539 $this->create_topic_form_gui->addCommandButton('saveThreadAsDraft', $this->lng->txt('save_message'));
3540 }
3541 $this->create_topic_form_gui->addCommandButton('cancelDraft', $this->lng->txt('cancel'));
3542 } else {
3543 $this->create_topic_form_gui->addCommandButton('addThread', $this->lng->txt('create'));
3544 $this->create_topic_form_gui->addCommandButton('showThreads', $this->lng->txt('cancel'));
3545 }
3546 }
3547
3549 {
3550 $draft_ids = array();
3551 if (isset($_GET['draft_id']) && (int) $_GET['draft_id'] > 0) {
3552 $draft_ids = array((int) $_GET['draft_id']);
3553 } elseif (isset($_POST['draft_ids']) && is_array($_POST['draft_ids'])) {
3554 $draft_ids = $_POST['draft_ids'];
3555 }
3556 $instances = ilForumPostDraft::getDraftInstancesByUserId($this->user->getId());
3557 $checked_draft_ids = array();
3558 foreach ($draft_ids as $draft_id) {
3559 if (array_key_exists($draft_id, $instances)) {
3560 $checked_draft_ids[] = $draft_id;
3561 $draftObj = $instances[$draft_id];
3562
3563 $this->deleteMobsOfDraft($draftObj->getDraftId(), $draftObj->getPostMessage());
3564
3565 // delete attachments of draft
3566 $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draftObj->getDraftId());
3567 $objFileDataForumDrafts->delete();
3568
3570 $GLOBALS['ilAppEventHandler']->raise(
3571 'Modules/Forum',
3572 'deletedDraft',
3573 array('draftObj' => $draftObj,
3574 'obj_id' => $this->object->getId(),
3575 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed())
3576 );
3577 }
3578 // delete draft
3579 $draftObj->deleteDraft();
3580 }
3581 }
3582
3583 if (count($checked_draft_ids) > 1) {
3584 ilUtil::sendInfo($this->lng->txt('delete_drafts_successfully'), true);
3585 } else {
3586 ilUtil::sendInfo($this->lng->txt('delete_draft_successfully'), true);
3587 }
3588
3589 $this->ctrl->redirect($this, 'showThreads');
3590 }
3591
3593 {
3594 $this->create_topic_form_gui->setValuesByArray(array(
3595 'subject' => '',
3596 'message' => '',
3597 'userfile' => '',
3598 'notify' => 0
3599 ));
3600 }
3601
3602 public function createThreadObject()
3603 {
3604 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3605 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3606 }
3607
3608 if (!$this->access->checkAccess('add_thread', '', $this->object->getRefId())) {
3609 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3610 }
3611
3612 $this->initTopicCreateForm();
3614
3615 $create_form = new ilTemplate('tpl.create_thread_form.html', true, true, 'Modules/Forum');
3616 $create_form->setVariable('CREATE_FORM', $this->create_topic_form_gui->getHTML());
3617 $create_form->parseCurrentBlock();
3618
3619 $this->tpl->setContent($create_form->get());
3620 }
3621
3622 public function publishThreadDraftObject($a_prevent_redirect = false)
3623 {
3624 $frm = $this->object->Forum;
3625 $frm->setForumId($this->object->getId());
3626 $frm->setForumRefId($this->object->getRefId());
3627
3628 if (!$this->access->checkAccess('add_thread', '', $this->object->getRefId())) {
3629 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3630 }
3631
3632 $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
3633
3634 $topicData = $frm->getOneTopic();
3635
3636 $this->initTopicCreateForm();
3637 if ($this->create_topic_form_gui->checkInput()) {
3638 $this->doCaptchaCheck();
3639 $user_alias = ilForumUtil::getPublicUserAlias($this->create_topic_form_gui->getInput('alias'), $this->objProperties->isAnonymized());
3640
3641 $status = 1;
3642 if (
3643 $this->objProperties->isPostActivationEnabled() &&
3644 !$this->is_moderator || $this->objCurrentPost->isAnyParentDeactivated()
3645 ) {
3646 $status = 0;
3647 }
3648
3649 if (isset($_GET['draft_id'])) {
3650 $draft_id = (int) $_GET['draft_id'];
3651 $draft_obj = ilForumPostDraft::newInstanceByDraftId((int) $draft_id);
3652 }
3653
3654 $newThread = new ilForumTopic(0, true, true);
3655 $newThread->setForumId($topicData['top_pk']);
3656 $newThread->setThrAuthorId($draft_obj->getPostAuthorId());
3657 $newThread->setDisplayUserId($draft_obj->getPostDisplayUserId());
3658 $newThread->setSubject($this->handleFormInput($this->create_topic_form_gui->getInput('subject'), false));
3659 $newThread->setUserAlias($draft_obj->getPostUserAlias());
3660
3661 $newPostId = $frm->generateThread(
3662 $newThread,
3663 ilRTE::_replaceMediaObjectImageSrc($this->create_topic_form_gui->getInput('message'), 0),
3664 $draft_obj->getNotify(),
3665 $draft_obj->getPostNotify(),
3666 $status
3667 );
3668
3669 if ($this->objProperties->isFileUploadAllowed()) {
3670 $file = $_FILES['userfile'];
3671 if (is_array($file) && !empty($file)) {
3672 $tmp_file_obj = new ilFileDataForum($this->object->getId(), $newPostId);
3673 $tmp_file_obj->storeUploadedFile($file);
3674 }
3675 }
3676
3677 // Visit-Counter
3678 $frm->setDbTable('frm_data');
3679 $frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($topicData['top_pk']));
3680 $frm->updateVisits($topicData['top_pk']);
3681
3682 $frm->setMDB2WhereCondition(
3683 'thr_top_fk = %s AND thr_subject = %s AND thr_num_posts = 1 ',
3684 array('integer', 'text'),
3685 array($topicData['top_pk'], $this->create_topic_form_gui->getInput('subject'))
3686 );
3687
3688 $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
3689
3690 foreach ($uploadedObjects as $mob) {
3691 ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
3692 ilObjMediaObject::_saveUsage($mob, 'frm:html', $newPostId);
3693 }
3694
3695 if (ilForumPostDraft::isSavePostDraftAllowed() && $draft_obj instanceof ilForumPostDraft) {
3696 $history_obj = new ilForumDraftsHistory();
3697 $history_obj->deleteHistoryByDraftIds(array($draft_obj->getDraftId()));
3698
3699 if ($this->objProperties->isFileUploadAllowed()) {
3700 //move files of draft to posts directory
3701 $oFDForum = new ilFileDataForum($this->object->getId(), $newPostId);
3702 $oFDForumDrafts = new ilFileDataForumDrafts($this->object->getId(), $draft_obj->getDraftId());
3703
3704 $oFDForumDrafts->moveFilesOfDraft($oFDForum->getForumPath(), $newPostId);
3705 }
3706 $draft_obj->deleteDraft();
3707 }
3708
3709 $GLOBALS['ilAppEventHandler']->raise(
3710 'Modules/Forum',
3711 'createdPost',
3712 array(
3713 'ref_id' => $this->object->getRefId(),
3714 'post' => new ilForumPost($newPostId),
3715 'notify_moderators' => !$status
3716 )
3717 );
3718
3719 if (!$a_prevent_redirect) {
3720 ilUtil::sendSuccess($this->lng->txt('forums_thread_new_entry'), true);
3721 $this->ctrl->clearParameters($this);
3722 $this->ctrl->redirect($this);
3723 } else {
3724 return $newPostId;
3725 }
3726 } else {
3727 $this->create_topic_form_gui->setValuesByPost();
3728
3729 if (!$this->objProperties->isAnonymized()) {
3730 $this->create_topic_form_gui->getItemByPostVar('alias')->setValue($this->user->getLogin());
3731 }
3732
3733 return $this->tpl->setContent($this->create_topic_form_gui->getHTML());
3734 }
3735 }
3736 public function addThreadObject($a_prevent_redirect = false)
3737 {
3738 $frm = $this->object->Forum;
3739 $frm->setForumId($this->object->getId());
3740 $frm->setForumRefId($this->object->getRefId());
3741
3742 if (!$this->access->checkAccess('add_thread', '', $this->object->getRefId())) {
3743 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3744 }
3745
3746 $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
3747
3748 $topicData = $frm->getOneTopic();
3749
3750 $this->initTopicCreateForm();
3751 if ($this->create_topic_form_gui->checkInput()) {
3752 $this->doCaptchaCheck();
3753
3754 if ($this->isWritingWithPseudonymAllowed()) {
3755 if (!strlen($this->create_topic_form_gui->getInput('alias'))) {
3756 $user_alias = $this->lng->txt('forums_anonymous');
3757 } else {
3758 $user_alias = $this->create_topic_form_gui->getInput('alias');
3759 }
3760 $display_user_id = 0;
3761 } else {
3762 $user_alias = $this->user->getLogin();
3763 $display_user_id = $this->user->getId();
3764 }
3765 $user_alias = ilForumUtil::getPublicUserAlias($this->create_topic_form_gui->getInput('alias'), $this->objProperties->isAnonymized());
3766 $status = 1;
3767 if (
3768 $this->objProperties->isPostActivationEnabled() &&
3769 !$this->is_moderator || $this->objCurrentPost->isAnyParentDeactivated()
3770 ) {
3771 $status = 0;
3772 }
3773
3774 $newThread = new ilForumTopic(0, true, true);
3775 $newThread->setForumId($topicData['top_pk']);
3776 $newThread->setThrAuthorId($this->user->getId());
3777 $newThread->setDisplayUserId($display_user_id);
3778 $newThread->setSubject($this->handleFormInput($this->create_topic_form_gui->getInput('subject'), false));
3779 $newThread->setUserAlias($user_alias);
3780
3781 $newPost = $frm->generateThread(
3782 $newThread,
3783 ilRTE::_replaceMediaObjectImageSrc($this->create_topic_form_gui->getInput('message'), 0),
3784 $this->create_topic_form_gui->getItemByPostVar('notify') ? (int) $this->create_topic_form_gui->getInput('notify') : 0,
3785 0, // #19980
3786 $status
3787 );
3788
3789 if ($this->objProperties->isFileUploadAllowed()) {
3790 $file = $_FILES['userfile'];
3791 if (is_array($file) && !empty($file)) {
3792 $tmp_file_obj = new ilFileDataForum($this->object->getId(), $newPost);
3793 $tmp_file_obj->storeUploadedFile($file);
3794 }
3795 }
3796
3797 // Visit-Counter
3798 $frm->setDbTable('frm_data');
3799 $frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($topicData['top_pk']));
3800 $frm->updateVisits($topicData['top_pk']);
3801
3802 $frm->setMDB2WhereCondition(
3803 'thr_top_fk = %s AND thr_subject = %s AND thr_num_posts = 1 ',
3804 array('integer', 'text'),
3805 array($topicData['top_pk'], $this->create_topic_form_gui->getInput('subject'))
3806 );
3807
3808 // copy temporary media objects (frm~)
3809 include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
3810 $mediaObjects = ilRTE::_getMediaObjects($this->create_topic_form_gui->getInput('message'), 0);
3811 foreach ($mediaObjects as $mob) {
3812 if (ilObjMediaObject::_exists($mob)) {
3813 ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
3814 ilObjMediaObject::_saveUsage($mob, 'frm:html', $newPost);
3815 }
3816 }
3817
3819 if (isset($_POST['draft_id']) && $_POST['draft_id'] > 0) {
3820 $draft_obj = ilForumPostDraft::newInstanceByDraftId($_POST['draft_id']);
3821 //delete history
3822 $history_obj = new ilForumDraftsHistory();
3823 $history_obj->deleteHistoryByDraftIds(array($draft_obj->getDraftId()));
3824
3825 if ($this->objProperties->isFileUploadAllowed()) {
3826 //move files of draft to posts directory
3827 $oFDForum = new ilFileDataForum($this->object->getId(), $newPost);
3828 $oFDForumDrafts = new ilFileDataForumDrafts($this->object->getId(), $draft_obj->getDraftId());
3829
3830 $oFDForumDrafts->moveFilesOfDraft($oFDForum->getForumPath(), $newPost);
3831 }
3832 $draft_obj->deleteDraft();
3833 }
3834 }
3835 $GLOBALS['ilAppEventHandler']->raise(
3836 'Modules/Forum',
3837 'createdPost',
3838 array(
3839 'ref_id' => $this->object->getRefId(),
3840 'post' => new ilForumPost($newPost),
3841 'notify_moderators' => !$status
3842 )
3843 );
3844
3845 if (!$a_prevent_redirect) {
3846 ilUtil::sendSuccess($this->lng->txt('forums_thread_new_entry'), true);
3847 $this->ctrl->redirect($this);
3848 } else {
3849 return $newPost;
3850 }
3851 } else {
3852 $this->create_topic_form_gui->setValuesByPost();
3853
3854 if (!$this->objProperties->isAnonymized()) {
3855 $this->create_topic_form_gui->getItemByPostVar('alias')->setValue($this->user->getLogin());
3856 }
3857
3858 return $this->tpl->setContent($this->create_topic_form_gui->getHTML());
3859 }
3860 }
3861
3863 {
3864 $frm = $this->object->Forum;
3865 $frm->setForumId($this->object->getId());
3866 $frm->enableForumNotification($this->user->getId());
3867
3868 if (!$this->objCurrentTopic->getId()) {
3869 ilUtil::sendInfo($this->lng->txt('forums_forum_notification_enabled'));
3870 $this->showThreadsObject();
3871 } else {
3872 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3873 ilUtil::sendInfo($this->lng->txt('forums_forum_notification_enabled'), true);
3874 $this->ctrl->redirect($this, 'viewThread');
3875 }
3876 }
3877
3879 {
3880 $frm = $this->object->Forum;
3881 $frm->setForumId($this->object->getId());
3882 $frm->disableForumNotification($this->user->getId());
3883
3884 if (!$this->objCurrentTopic->getId()) {
3885 $this->showThreadsObject();
3886 ilUtil::sendInfo($this->lng->txt('forums_forum_notification_disabled'));
3887 } else {
3888 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3889 ilUtil::sendInfo($this->lng->txt('forums_forum_notification_disabled'), true);
3890 $this->ctrl->redirect($this, 'viewThread');
3891 }
3892 }
3893
3894 public function checkEnableColumnEdit()
3895 {
3896 return false;
3897 }
3898
3899 public function setColumnSettings(ilColumnGUI $column_gui)
3900 {
3901 $column_gui->setBlockProperty('news', 'title', $this->lng->txt('frm_latest_postings'));
3902 $column_gui->setBlockProperty('news', 'prevent_aggregation', true);
3903 $column_gui->setRepositoryMode(true);
3904
3905 if ($this->access->checkAccess('write', '', $this->object->getRefId())) {
3906 $news_set = new ilSetting('news');
3907 $enable_internal_rss = $news_set->get('enable_rss_for_internal');
3908 if ($enable_internal_rss) {
3909 $column_gui->setBlockProperty('news', 'settings', true);
3910 $column_gui->setBlockProperty('news', 'public_notifications_option', true);
3911 }
3912 }
3913 }
3914
3915
3916 public function cloneWizardPageObject()
3917 {
3918 if (!$_POST['clone_source']) {
3919 ilUtil::sendInfo($this->lng->txt('select_one'));
3920 if (isset($_SESSION['wizard_search_title'])) {
3921 $this->searchCloneSourceObject();
3922 } else {
3923 $this->createObject();
3924 }
3925 return false;
3926 }
3927 $source_id = $_POST['clone_source'];
3928
3929 $new_type = $_REQUEST['new_type'];
3930 $this->ctrl->setParameter($this, 'clone_source', (int) $_POST['clone_source']);
3931 $this->ctrl->setParameter($this, 'new_type', $new_type);
3932
3933 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.frm_wizard_page.html', 'Modules/Forum');
3934 $this->tpl->setVariable('FORMACTION', $this->ctrl->getFormAction($this));
3935 $this->tpl->setVariable('TYPE_IMG', ilUtil::getImagePath('icon_' . $new_type . '.svg'));
3936 $this->tpl->setVariable('ALT_IMG', $this->lng->txt('obj_' . $new_type));
3937 $this->tpl->setVariable('TXT_DUPLICATE', $this->lng->txt('frm_wizard_page'));
3938 $this->tpl->setVariable('INFO_THREADS', $this->lng->txt('fmr_copy_threads_info'));
3939 $this->tpl->setVariable('THREADS', $this->lng->txt('forums_threads'));
3940
3941 $forum_id = $this->ilObjDataCache->lookupObjId((int) $_POST['clone_source']);
3942 $threads = ilForum::_getThreads($forum_id, ilForum::SORT_TITLE);
3943 foreach ($threads as $thread_id => $title) {
3944 $this->tpl->setCurrentBlock('thread_row');
3945 $this->tpl->setVariable('CHECK_THREAD', ilUtil::formCheckbox(0, 'cp_options[' . $source_id . '][threads][]', $thread_id));
3946 $this->tpl->setVariable('NAME_THREAD', $title);
3947 $this->tpl->parseCurrentBlock();
3948 }
3949 $this->tpl->setVariable('SELECT_ALL', $this->lng->txt('select_all'));
3950 $this->tpl->setVariable('JS_FIELD', 'cp_options[' . $source_id . '][threads]');
3951 $this->tpl->setVariable('BTN_COPY', $this->lng->txt('obj_' . $new_type . '_duplicate'));
3952 if (isset($_SESSION['wizard_search_title'])) {
3953 $this->tpl->setVariable('BACK_CMD', 'searchCloneSource');
3954 } else {
3955 $this->tpl->setVariable('BACK_CMD', 'create');
3956 }
3957 $this->tpl->setVariable('BTN_BACK', $this->lng->txt('btn_back'));
3958 }
3959
3960 public function addLocatorItems()
3961 {
3962 if ($this->object instanceof ilObject) {
3963 $this->locator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ''), '', $this->object->getRefId());
3964 }
3965 }
3966
3967 public function handleFormInput($a_text, $a_stripslashes = true)
3968 {
3969 $a_text = str_replace("<", "&lt;", $a_text);
3970 $a_text = str_replace(">", "&gt;", $a_text);
3971 if ($a_stripslashes) {
3972 $a_text = ilUtil::stripSlashes($a_text);
3973 }
3974
3975 return $a_text;
3976 }
3977
3978 public function prepareFormOutput($a_text)
3979 {
3980 $a_text = str_replace("&lt;", "<", $a_text);
3981 $a_text = str_replace("&gt;", ">", $a_text);
3982 $a_text = ilUtil::prepareFormOutput($a_text);
3983 return $a_text;
3984 }
3985
3986 // /**
3987 // * this one is called from the info button in the repository
3988 // * not very nice to set cmdClass/Cmd manually, if everything
3989 // * works through ilCtrl in the future this may be changed
3990 // */
3991 // public function infoScreenObject()
3992 // {
3993 // $this->ctrl->setCmd('showSummary');
3994 // $this->ctrl->setCmdClass('ilinfoscreengui');
3995 // $this->infoScreen();
3996 // }
3997
3998 public function infoScreen()
3999 {
4000 if (
4001 !$this->access->checkAccess('visible', '', $this->object->getRefId()) &&
4002 !$this->access->checkAccess('read', '', $this->object->getRefId())
4003 ) {
4004 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
4005 }
4006
4007 include_once 'Services/InfoScreen/classes/class.ilInfoScreenGUI.php';
4008 $info = new ilInfoScreenGUI($this);
4009
4010 $info->enablePrivateNotes();
4011
4012 // standard meta data
4013 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
4014
4015 // forward the command
4016 $this->ctrl->forwardCommand($info);
4017 }
4018
4019 public function markPostUnreadObject()
4020 {
4021 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4022 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4023 }
4024
4025 if ((int) $this->objCurrentPost->getId() > 0) {
4026 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $this->objCurrentPost->getThread());
4027
4028 $this->object->markPostUnread($this->user->getId(), (int) $this->objCurrentPost->getId());
4029 }
4030 $this->viewThreadObject();
4031 }
4032
4033 public function markPostReadObject()
4034 {
4035 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4036 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4037 }
4038
4039 if ((int) $this->objCurrentTopic->getId() > 0 && (int) $this->objCurrentPost->getId() > 0) {
4040 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $this->objCurrentPost->getThread());
4041
4042 $this->object->markPostRead(
4043 $this->user->getId(),
4044 (int) $this->objCurrentTopic->getId(),
4045 (int) $this->objCurrentPost->getId()
4046 );
4047 }
4048 $this->viewThreadObject();
4049 }
4050
4051 protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
4052 {
4053 $lg = parent::initHeaderAction();
4054
4055 // Workaround: Do not show "desktop actions" in thread view
4056 if ($this->objCurrentTopic->getId()) {
4057 $container_obj = null;
4058 $lg->setContainerObject($container_obj);
4059 }
4060
4061 if ($lg instanceof ilObjForumListGUI) {
4062 if ($this->user->getId() != ANONYMOUS_USER_ID && $this->settings->get('forum_notification') != 0) {
4063 $is_user_allowed_to_deactivate_notification = $this->isUserAllowedToDeactivateNotification();
4064
4065 $frm = $this->object->Forum;
4066 $frm->setForumId($this->object->getId());
4067 $frm->setForumRefId($this->object->getRefId());
4068 $frm->setMDB2Wherecondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
4069 $frm_notificiation_enabled = $frm->isForumNotificationEnabled($this->user->getId());
4070
4071 if ($this->objCurrentTopic->getId()) {
4072 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4073 }
4074
4075 if ($this->isParentObjectCrsOrGrp()) {
4076 // special behaviour for CRS/GRP-Forum notification!!
4077 if (
4078 $frm_notificiation_enabled &&
4079 $is_user_allowed_to_deactivate_notification
4080 ) {
4081 $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'disableForumNotification'), "forums_disable_forum_notification");
4082 } elseif (!$frm_notificiation_enabled) {
4083 $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'enableForumNotification'), "forums_enable_forum_notification");
4084 }
4085 } else {
4086 if ($frm_notificiation_enabled) {
4087 $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'disableForumNotification'), "forums_disable_forum_notification");
4088 } else {
4089 $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'enableForumNotification'), "forums_enable_forum_notification");
4090 }
4091 }
4092
4093 $topic_notification_enabled = false;
4094 if ($this->objCurrentTopic->getId()) {
4095 $topic_notification_enabled = $this->objCurrentTopic->isNotificationEnabled($this->user->getId());
4096 if ($topic_notification_enabled) {
4097 $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'toggleThreadNotification'), "forums_disable_notification");
4098 } else {
4099 $lg->addCustomCommand($this->ctrl->getLinkTarget($this, 'toggleThreadNotification'), "forums_enable_notification");
4100 }
4101 }
4102 $this->ctrl->setParameter($this, 'thr_pk', '');
4103
4104 if ($frm_notificiation_enabled || $topic_notification_enabled) {
4105 $lg->addHeaderIcon(
4106 "not_icon",
4107 ilUtil::getImagePath("notification_on.svg"),
4108 $this->lng->txt("frm_notification_activated")
4109 );
4110 } else {
4111 $lg->addHeaderIcon(
4112 "not_icon",
4113 ilUtil::getImagePath("notification_off.svg"),
4114 $this->lng->txt("frm_notification_deactivated")
4115 );
4116 }
4117 }
4118 }
4119
4120 return $lg;
4121 }
4122
4124 {
4125 if ($this->objProperties->getNotificationType() == 'default') {
4126 return true;
4127 }
4128
4129 if ($this->objProperties->isUserToggleNoti() == 0) {
4130 return true;
4131 }
4132
4133 if ($this->isParentObjectCrsOrGrp()) {
4134 include_once 'Modules/Forum/classes/class.ilForumNotification.php';
4135
4136 $frm_noti = new ilForumNotification((int) $_GET['ref_id']);
4137 $frm_noti->setUserId($this->user->getId());
4138
4139 $user_toggle = (int) $frm_noti->isUserToggleNotification();
4140 if ($user_toggle == 0 && $this->objProperties->isUserToggleNoti() == 0) {
4141 return true;
4142 }
4143 }
4144
4145 return false;
4146 }
4147
4148 public function isParentObjectCrsOrGrp()
4149 {
4150 // check if there a parent-node is a grp or crs
4151 $grp_ref_id = $this->repositoryTree->checkForParentType($this->object->getRefId(), 'grp');
4152 $crs_ref_id = $this->repositoryTree->checkForParentType($this->object->getRefId(), 'crs');
4153
4154 if ($grp_ref_id == 0 && $crs_ref_id == 0) {
4155 return false;
4156 }
4157 return true;
4158 }
4159
4163 public function addToDeskObject()
4164 {
4165 if ((int) $this->settings->get('disable_my_offers')) {
4166 $this->showThreadsObject();
4167 return;
4168 }
4169
4170 include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
4172 ilUtil::sendSuccess($this->lng->txt("added_to_desktop"));
4173 $this->showThreadsObject();
4174 }
4175
4179 public function removeFromDeskObject()
4180 {
4181 if ((int) $this->settings->get('disable_my_offers')) {
4182 $this->showThreadsObject();
4183 return;
4184 }
4185
4186 include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
4188 ilUtil::sendSuccess($this->lng->txt("removed_from_desktop"));
4189 $this->showThreadsObject();
4190 }
4191
4192 public function saveThreadSortingObject()
4193 {
4194 $_POST['thread_sorting'] ? $thread_sorting = $_POST['thread_sorting'] :$thread_sorting = array();
4195
4196 if (!$this->is_moderator) {
4197 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4198 }
4199
4200 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4201 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4202 }
4203
4204 array_walk($thread_sorting, function ($sortValue, $threadId) {
4205 $this->ensureThreadBelongsToForum((int) $this->object->getId(), new \ilForumTopic($threadId));
4206 });
4207
4208 foreach ($thread_sorting as $thr_pk=>$sorting_value) {
4209 $sorting_value = str_replace(',', '.', $sorting_value);
4210 $sorting_value = (float) $sorting_value * 100;
4211 $this->object->setThreadSorting($thr_pk, $sorting_value);
4212 }
4213 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
4214 $this->showThreadsObject();
4215 return true;
4216 }
4217
4221 public function mergeThreadsObject()
4222 {
4223 if (!$this->is_moderator) {
4224 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4225 }
4226
4227 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4228 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4229 }
4230
4231 $selected_thread_id = 0;
4232 if (isset($_GET['merge_thread_id']) && (int) $_GET['merge_thread_id']) {
4233 $selected_thread_id = (int) $_GET['merge_thread_id'];
4234 } elseif (isset($_POST['thread_ids']) && count((array) $_POST['thread_ids']) == 1) {
4235 $selected_thread_id = (int) current($_POST['thread_ids']);
4236 } else {
4237 ilUtil::sendInfo($this->lng->txt('select_one'));
4238 $this->showThreadsObject();
4239 return;
4240 }
4241
4242 if ($selected_thread_id) {
4243 $frm = $this->object->Forum;
4244 $frm->setForumId($this->object->getId());
4245 $frm->setForumRefId($this->object->getRefId());
4246
4247 $selected_thread_obj = new ilForumTopic($selected_thread_id);
4248
4249 if (ilForum::_lookupObjIdForForumId($selected_thread_obj->getForumId()) != $frm->getForumId()) {
4250 ilUtil::sendFailure($this->lng->txt('not_allowed_to_merge_into_another_forum'));
4251 $this->showThreadsObject();
4252 return;
4253 }
4254
4255 $frm->setMDB2Wherecondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
4256
4257 $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_threads_liste.html', 'Modules/Forum');
4258
4259 $topicData = $frm->getOneTopic();
4260 if ($topicData) {
4261 include_once 'Modules/Forum/classes/class.ilForumTopicTableGUI.php';
4262 $this->ctrl->setParameter($this, 'merge_thread_id', $selected_thread_id);
4263 $tbl = new ilForumTopicTableGUI($this, 'mergeThreads', '', (int) $_GET['ref_id'], $topicData, $this->is_moderator, $this->forum_overview_setting);
4264 $tbl->setSelectedThread($selected_thread_obj);
4265 $tbl->setMapper($frm)->fetchData();
4266 $tbl->init();
4267 $this->tpl->setVariable('THREADS_TABLE', $tbl->getHTML());
4268 } else {
4269 ilUtil::sendFailure($this->lng->txt('select_one'));
4270 $this->showThreadsObject();
4271 return;
4272 }
4273 }
4274 }
4275
4280 {
4281 if (!$this->is_moderator) {
4282 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4283 }
4284
4285 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4286 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4287 }
4288
4289 if (!isset($_GET['merge_thread_id']) || !(int) $_GET['merge_thread_id'] || !is_array($_POST['thread_ids']) || count($_POST['thread_ids']) != 1) {
4290 ilUtil::sendFailure($this->lng->txt('select_one'));
4291 $this->mergeThreadsObject();
4292 return;
4293 }
4294
4295 $source_thread_id = (int) $_GET['merge_thread_id'];
4296 $target_thread_id = (int) current($_POST['thread_ids']);
4297
4298 if ($source_thread_id == $target_thread_id) {
4299 ilUtil::sendFailure($this->lng->txt('error_same_thread_ids'));
4300 $this->showThreadsObject();
4301 return;
4302 }
4303
4304 if (ilForumTopic::lookupForumIdByTopicId($source_thread_id) != ilForumTopic::lookupForumIdByTopicId($target_thread_id)) {
4305 ilUtil::sendFailure($this->lng->txt('not_allowed_to_merge_into_another_forum'));
4306 $this->ctrl->clearParameters($this);
4307 $this->showThreadsObject();
4308 return;
4309 }
4310
4311 if (ilForumTopic::_lookupDate($source_thread_id) < ilForumTopic::_lookupDate($target_thread_id)) {
4312 ilUtil::sendInfo($this->lng->txt('switch_threads_for_merge'));
4313 }
4314
4315 $this->ensureThreadBelongsToForum((int) $this->object->getId(), new \ilForumTopic((int) $source_thread_id));
4316 $this->ensureThreadBelongsToForum((int) $this->object->getId(), new \ilForumTopic((int) $target_thread_id));
4317
4318 include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
4319 $c_gui = new ilConfirmationGUI();
4320
4321 $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performMergeThreads'));
4322 $c_gui->setHeaderText($this->lng->txt('frm_sure_merge_threads'));
4323 $c_gui->setCancel($this->lng->txt('cancel'), 'showThreads');
4324 $c_gui->setConfirm($this->lng->txt('confirm'), 'performMergeThreads');
4325
4326 $c_gui->addItem('thread_ids[]', $source_thread_id, sprintf($this->lng->txt('frm_merge_src'), ilForumTopic::_lookupTitle($source_thread_id)));
4327 $c_gui->addItem('thread_ids[]', $target_thread_id, sprintf($this->lng->txt('frm_merge_target'), ilForumTopic::_lookupTitle($target_thread_id)));
4328
4329 $this->tpl->setContent($c_gui->getHTML());
4330 return;
4331 }
4332
4337 {
4338 if (!$this->is_moderator) {
4339 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4340 }
4341
4342 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4343 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4344 }
4345
4346 if (!isset($_POST['thread_ids']) || !is_array($_POST['thread_ids']) || count($_POST['thread_ids']) != 2) {
4347 ilUtil::sendFailure($this->lng->txt('select_one'));
4348 $this->showThreadsObject();
4349 return;
4350 }
4351
4352 if ((int) $_POST['thread_ids'][0] == (int) $_POST['thread_ids'][1]) {
4353 ilUtil::sendFailure($this->lng->txt('error_same_thread_ids'));
4354 $this->showThreadsObject();
4355 return;
4356 }
4357
4358 try {
4359 $this->ensureThreadBelongsToForum((int) $this->object->getId(), new \ilForumTopic((int) $_POST['thread_ids'][0]));
4360 $this->ensureThreadBelongsToForum((int) $this->object->getId(), new \ilForumTopic((int) $_POST['thread_ids'][1]));
4361 ilForum::mergeThreads($this->object->id, (int) $_POST['thread_ids'][0], (int) $_POST['thread_ids'][1]);
4362 ilUtil::sendSuccess($this->lng->txt('merged_threads_successfully'));
4363 } catch (ilException $e) {
4364 return ilUtil::sendFailure($this->lng->txt($e->getMessage()));
4365 }
4366 $this->showThreadsObject();
4367 }
4368
4372 public function cancelMergeThreads()
4373 {
4374 $this->showThreadsObject();
4375 }
4376
4380 protected function setSideBlocks()
4381 {
4382 $rgt_content = '';
4383 if (!$GLOBALS['ilCtrl']->isAsynch()) {
4384 require_once 'Services/Search/classes/class.ilRepositoryObjectSearchGUI.php';
4385 $rgt_content = ilRepositoryObjectSearchGUI::getSearchBlockHTML($this->lng->txt('frm_search'));
4386 }
4387 $this->tpl->setRightContent($rgt_content . $this->getRightColumnHTML());
4388 }
4389
4394 {
4395 $draftObj = ilForumPostDraft::newInstanceByDraftId((int) $_GET['draft_id']);
4396 if ($draftObj->getPostAuthorId() == $this->user->getId()) {
4397 $tmp_file_obj = new ilFileDataForumDrafts(0, $draftObj->getDraftId());
4398 if (!$tmp_file_obj->deliverZipFile()) {
4399 $this->ctrl->redirect($this);
4400 }
4401 }
4402 }
4403
4407 public function deliverZipFileObject()
4408 {
4409 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4410 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4411 }
4412
4413 $this->ensureThreadBelongsToForum((int) $this->object->getId(), $this->objCurrentPost->getThread());
4414
4415 $fileData = new \ilFileDataForum($this->object->getId(), $this->objCurrentPost->getId());
4416 if (!$fileData->deliverZipFile()) {
4417 $this->ctrl->redirect($this);
4418 }
4419 }
4420
4421 public function editThreadDraftObject($form = null)
4422 {
4423 $frm = $this->object->Forum;
4424 $frm->setForumId($this->object->getId());
4425 $frm->setForumRefId($this->object->getRefId());
4426
4427 if (!$this->access->checkAccess('add_thread', '', $this->object->getRefId())) {
4428 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4429 }
4430
4431 $thread_draft = new ilForumPostDraft();
4432 if (array_key_exists('draft_id', $_GET)) {
4433 $draft_id = (int) $_GET['draft_id'];
4434 $thread_draft = $thread_draft->newInstanceByDraftId($draft_id);
4435 }
4436
4437 if (!isset($_GET['hist_check']) || (int) $_GET['hist_check'] != 0) {
4438 $this->doHistoryCheck($thread_draft->getDraftId());
4439 }
4440
4441 if (!$form instanceof ilPropertyFormGUI) {
4442 $this->initTopicCreateForm(true);
4443
4444 $this->create_topic_form_gui->setValuesByArray(
4445 array(
4446 'alias' => $thread_draft->getPostUserAlias(),
4447 'subject' => $thread_draft->getPostSubject(),
4448 'message' => ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($thread_draft->getPostMessage(), 2), 1),
4449 'notify' =>$thread_draft->getNotify() ? true : false,
4450 'userfile' => '',
4451 'del_file' => array())
4452 );
4453 $this->tpl->setContent($this->create_topic_form_gui->getHTML() . $this->modal_history);
4454 } else {
4455 $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
4456 return $this->tpl->setContent($form->getHTML());
4457 }
4458 }
4459
4461 {
4462 $history_id = ((int) $_GET['history_id']);
4463 $history = new ilForumDraftsHistory($history_id);
4464
4465 $draft = $history->rollbackAutosave();
4466
4467 if ($draft->getThreadId() == 0 && $draft->getPostId() == 0) {
4468 $this->ctrl->setParameter($this, 'draft_id', $history->getDraftId());
4469 $this->ctrl->redirect($this, 'editThreadDraft');
4470 }
4471
4472 $this->ctrl->clearParameters($this);
4473 $this->ctrl->setParameter($this, 'pos_pk', $draft->getPostId());
4474 $this->ctrl->setParameter($this, 'thr_pk', $draft->getThreadId());
4475 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
4476 $this->ctrl->setParameter($this, 'action', 'editdraft');
4477
4478 // create draft backup before redirect!
4479 ilForumPostDraft::createDraftBackup((int) $draft->getDraftId());
4480
4481 $this->ctrl->redirect($this, 'viewThread');
4482 }
4483
4484 public function saveThreadAsDraftObject()
4485 {
4486 if (!isset($_POST['del_file']) || !is_array($_POST['del_file'])) {
4487 $_POST['del_file'] = array();
4488 }
4489 $autosave_draft_id = 0;
4490 if (ilForumPostDraft::isAutoSavePostDraftAllowed() && isset($_POST['draft_id']) && (int) $_POST['draft_id'] > 0) {
4491 $autosave_draft_id = (int) $_POST['draft_id'];
4492 } elseif (isset($_GET['draft_id']) && (int) $_GET['draft_id'] > 0) {
4493 $autosave_draft_id = (int) $_GET['draft_id'];
4494 }
4495
4496 $frm = $this->object->Forum;
4497 $frm->setForumId($this->object->getId());
4498 $frm->setForumRefId($this->object->getRefId());
4499
4500 if (!$this->access->checkAccess('add_thread', '', $this->object->getRefId())) {
4501 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4502 }
4503
4504 $frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
4505
4506 $topicData = $frm->getOneTopic();
4507
4508 $this->initTopicCreateForm();
4509 if ($this->create_topic_form_gui->checkInput()) {
4510 $this->doCaptchaCheck();
4511
4512 $user_alias = ilForumUtil::getPublicUserAlias($this->create_topic_form_gui->getInput('alias'), $this->objProperties->isAnonymized());
4513
4514 if ($autosave_draft_id == 0) {
4515 $draftObj = new ilForumPostDraft();
4516 } else {
4517 $draftObj = ilForumPostDraft::newInstanceByDraftId($autosave_draft_id);
4518 }
4519 $draftObj->setForumId($topicData['top_pk']);
4520 $draftObj->setThreadId(0);
4521 $draftObj->setPostId(0);
4522
4523 $draftObj->setPostSubject($this->handleFormInput($this->create_topic_form_gui->getInput('subject'), false));
4524 $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($this->create_topic_form_gui->getInput('message'), 0));
4525 $draftObj->setPostUserAlias($user_alias);
4526 $draftObj->setNotify((int) $this->create_topic_form_gui->getInput('notify'));
4527 $draftObj->setPostAuthorId($this->user->getId());
4528 $draftObj->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $this->user->getId()));
4529
4530 if ($autosave_draft_id == 0) {
4531 $draft_id = $draftObj->saveDraft();
4532 } else {
4533 $draftObj->updateDraft();
4534 $draft_id = $draftObj->getDraftId();
4535 }
4536
4538 $GLOBALS['ilAppEventHandler']->raise(
4539 'Modules/Forum',
4540 'savedAsDraft',
4541 array('draftObj' => $draftObj,
4542 'obj_id' => $this->object->getId(),
4543 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed())
4544 );
4545 }
4546 // copy temporary media objects (frm~)
4547 ilForumUtil::moveMediaObjects($this->create_topic_form_gui->getInput('message'), 'frm~d:html', $draft_id, 'frm~d:html', $draft_id);
4548
4549 if ($this->objProperties->isFileUploadAllowed()) {
4550 $oFDForumDrafts = new ilFileDataForumDrafts($this->object->getId(), $draft_id);
4551 $file = $_FILES['userfile'];
4552 if (is_array($file) && !empty($file)) {
4553 $oFDForumDrafts->storeUploadedFile($file);
4554 }
4555
4556 $file2delete = $this->create_topic_form_gui->getInput('del_file');
4557 if (is_array($file2delete) && count($file2delete)) {
4558 $oFDForumDrafts->unlinkFilesByMD5Filenames($file2delete);
4559 }
4560 }
4561 $this->ctrl->clearParameters($this);
4562 ilUtil::sendSuccess($this->lng->txt('save_draft_successfully'), true);
4563 $this->ctrl->redirect($this, 'showThreads');
4564 } else {
4565 $_GET['action'] = substr($_GET['action'], 6);
4566 $this->create_topic_form_gui->setValuesByPost();
4567 $this->ctrl->setParameter($this, 'draft_id', $autosave_draft_id);
4568 return $this->tpl->setContent($this->create_topic_form_gui->getHTML());
4569 }
4570 $this->ctrl->clearParameters($this);
4571 $this->ctrl->redirect($this, 'showThreads');
4572 }
4573
4574 public function updateThreadDraftObject()
4575 {
4576 if (!isset($_POST['del_file']) || !is_array($_POST['del_file'])) {
4577 $_POST['del_file'] = array();
4578 }
4579
4580 $frm = $this->object->Forum;
4581 $frm->setForumId($this->object->getId());
4582 $frm->setForumRefId($this->object->getRefId());
4583
4584 if (!$this->access->checkAccess('add_thread', '', $this->object->getRefId())
4585 || !isset($_GET['draft_id']) || (int) $_GET['draft_id'] <= 0) {
4586 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4587 }
4588 $this->initTopicCreateForm();
4589
4590 if ($this->create_topic_form_gui->checkInput()) {
4591 $this->doCaptchaCheck();
4592 $user_alias = ilForumUtil::getPublicUserAlias($this->create_topic_form_gui->getInput('alias'), $this->objProperties->isAnonymized());
4593
4594 $draftObj= ilForumPostDraft::newInstanceByDraftId((int) $_GET['draft_id']);
4595
4596 $draftObj->setPostSubject($this->handleFormInput($this->create_topic_form_gui->getInput('subject'), false));
4597 $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($this->create_topic_form_gui->getInput('message'), 0));
4598 $draftObj->setPostUserAlias($user_alias);
4599 $draftObj->setNotify((int) $this->create_topic_form_gui->getInput('notify'));
4600 $draftObj->setPostAuthorId($this->user->getId());
4601 $draftObj->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $this->user->getId()));
4602
4603 $draftObj->updateDraft();
4605 $GLOBALS['ilAppEventHandler']->raise(
4606 'Modules/Forum',
4607 'updatedDraft',
4608 array('draftObj' => $draftObj,
4609 'obj_id' => $this->object->getId(),
4610 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed())
4611 );
4612 }
4613
4614 // copy temporary media objects (frm~)
4615 ilForumUtil::moveMediaObjects($this->create_topic_form_gui->getInput('message'), 'frm~d:html', $draftObj->getDraftId(), 'frm~d:html', $draftObj->getDraftId());
4616
4617 if ($this->objProperties->isFileUploadAllowed()) {
4618 $oFDForumDrafts = new ilFileDataForumDrafts($this->object->getId(), $draftObj->getDraftId());
4619 $file = $_FILES['userfile'];
4620 if (is_array($file) && !empty($file)) {
4621 $oFDForumDrafts->storeUploadedFile($file);
4622 }
4623
4624 $file2delete = $this->create_topic_form_gui->getInput('del_file');
4625 if (is_array($file2delete) && count($file2delete)) {
4626 $oFDForumDrafts->unlinkFilesByMD5Filenames($file2delete);
4627 }
4628 }
4629
4630 ilUtil::sendSuccess($this->lng->txt('save_draft_successfully'), true);
4631 $this->ctrl->clearParameters($this);
4632 $this->ctrl->redirect($this, 'showThreads');
4633 } else {
4634 $this->create_topic_form_gui->setValuesByPost();
4635 $this->ctrl->setParameter($this, 'hist_check', 0);
4636 $this->ctrl->setParameter($this, 'draft_id', $_GET['draft_id']);
4637 return $this->editThreadDraftObject($this->create_topic_form_gui);
4638 }
4639 // return $this->viewThreadObject();
4640 $this->ctrl->clearParameters($this);
4641 $this->ctrl->redirect($this, 'showThreads');
4642 }
4643
4644 public function saveAsDraftObject()
4645 {
4646 if (!$this->objCurrentTopic->getId()) {
4647 \ilUtil::sendFailure($this->lng->txt('frm_action_not_possible_thr_deleted'), true);
4648 $this->ctrl->redirect($this);
4649 }
4650
4651 if ($this->objCurrentTopic->isClosed()) {
4652 \ilUtil::sendFailure($this->lng->txt('frm_action_not_possible_thr_closed'), true);
4653 $this->ctrl->redirect($this);
4654 }
4655
4656 if (!isset($_POST['del_file']) || !is_array($_POST['del_file'])) {
4657 $_POST['del_file'] = array();
4658 }
4659
4660 $autosave_draft_id = 0;
4661 if (ilForumPostDraft::isAutoSavePostDraftAllowed() && isset($_POST['draft_id'])) {
4662 $autosave_draft_id = (int) $_POST['draft_id'];
4663 }
4664 $oReplyEditForm = $this->getReplyEditForm();
4665 if ($oReplyEditForm->checkInput()) {
4666 if (!$this->objCurrentPost->getId()) {
4667 $_GET['action'] = '';
4668 \ilUtil::sendFailure($this->lng->txt('frm_action_not_possible_parent_deleted'));
4669 $this->viewThreadObject();
4670 return;
4671 }
4672
4673 $this->doCaptchaCheck();
4674
4675 // init objects
4676 $oForumObjects = $this->getForumObjects();
4680 $forumObj = $oForumObjects['forumObj'];
4684 $frm = $oForumObjects['frm'];
4685 $frm->setMDB2WhereCondition(' top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
4686 $topicData = $frm->getOneTopic();
4687
4688 // Generating new posting
4689 if ($_GET['action'] == 'ready_showreply') {
4690 if (!$this->access->checkAccess('add_reply', '', (int) $_GET['ref_id'])) {
4691 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4692 }
4693
4694 $user_alias = ilForumUtil::getPublicUserAlias($oReplyEditForm->getInput('alias'), $this->objProperties->isAnonymized());
4695
4696 if ($autosave_draft_id == 0) {
4697 $draftObj = new ilForumPostDraft();
4698 } else {
4699 $draftObj = ilForumPostDraft::newInstanceByDraftId($autosave_draft_id);
4700 }
4701 $draftObj->setForumId($topicData['top_pk']);
4702 $draftObj->setThreadId($this->objCurrentTopic->getId());
4703 $draftObj->setPostId($this->objCurrentPost->getId());
4704
4705 $draftObj->setPostSubject($this->handleFormInput($oReplyEditForm->getInput('subject'), false));
4706 $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message'), 0));
4707 $draftObj->setPostUserAlias($user_alias);
4708 $draftObj->setNotify((int) $oReplyEditForm->getInput('notify'));
4709 $draftObj->setPostNotify((int) $oReplyEditForm->getInput('notify_post'));
4710
4711 $draftObj->setPostAuthorId($this->user->getId());
4712 $draftObj->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $this->user->getId()));
4713
4714 if ($autosave_draft_id == 0) {
4715 $draft_id = $draftObj->saveDraft();
4716 } else {
4717 $draftObj->updateDraft();
4718 $draft_id = $draftObj->getDraftId();
4719 }
4720
4721
4723 $GLOBALS['ilAppEventHandler']->raise(
4724 'Modules/Forum',
4725 'savedAsDraft',
4726 array('draftObj' => $draftObj,
4727 'obj_id' => $this->object->getId(),
4728 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed())
4729 );
4730 }
4731
4732 if ($this->objProperties->isFileUploadAllowed()) {
4733 $file = $_FILES['userfile'];
4734 if (is_array($file) && !empty($file)) {
4735 $oFDForumDrafts = new ilFileDataForumDrafts($this->object->getId(), $draftObj->getDraftId());
4736 $oFDForumDrafts->storeUploadedFile($file);
4737 }
4738 }
4739
4740 // copy temporary media objects (frm~)
4741 ilForumUtil::moveMediaObjects($oReplyEditForm->getInput('message'), 'frm~d:html', $draft_id, 'frm~d:html', $draft_id);
4742
4743 $_SESSION['frm'][(int) $_GET['thr_pk']]['openTreeNodes'][] = (int) $this->objCurrentPost->getId();
4744
4745 ilUtil::sendSuccess($this->lng->txt('save_draft_successfully'), true);
4746 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
4747 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
4748 $this->ctrl->redirect($this, 'viewThread');
4749 }
4750 } else {
4751 $oReplyEditForm->setValuesByPost();
4752 $_GET['action'] = substr($_GET['action'], 6);
4753 }
4754 return $this->viewThreadObject();
4755 }
4756
4757 public function editDraftObject()
4758 {
4760 $draft_id = (int) $_GET['draft_id'];
4761 if ($this->checkDraftAccess($draft_id)) {
4762 $this->doHistoryCheck($draft_id);
4763 }
4764 }
4765
4766 $this->viewThreadObject();
4767 return true;
4768 }
4769
4773 public function updateDraftObject()
4774 {
4775 if (!$this->objCurrentTopic->getId()) {
4776 \ilUtil::sendFailure($this->lng->txt('frm_action_not_possible_thr_deleted'), true);
4777 $this->ctrl->redirect($this);
4778 }
4779
4780 if ($this->objCurrentTopic->isClosed()) {
4781 \ilUtil::sendFailure($this->lng->txt('frm_action_not_possible_thr_closed'), true);
4782 $this->ctrl->redirect($this);
4783 }
4784
4785 if (!$this->objCurrentPost->getId()) {
4786 $_GET['action'] = '';
4787 \ilUtil::sendFailure($this->lng->txt('frm_action_not_possible_parent_deleted'));
4788 $this->viewThreadObject();
4789 return;
4790 }
4791
4792 if (!isset($_POST['del_file']) || !is_array($_POST['del_file'])) {
4793 $_POST['del_file'] = array();
4794 }
4795
4796 $oReplyEditForm = $this->getReplyEditForm();
4797 if ($oReplyEditForm->checkInput()) {
4798 $this->doCaptchaCheck();
4799
4800 // init objects
4801 $oForumObjects = $this->getForumObjects();
4805 $forumObj = $oForumObjects['forumObj'];
4806
4807 if (!$this->user->isAnonymous() &&
4808 ($_GET['action'] == 'showdraft' || $_GET['action'] == 'editdraft')) {
4809 if (!$this->access->checkAccess('add_reply', '', (int) $_GET['ref_id'])) {
4810 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4811 }
4812
4813 $user_alias = ilForumUtil::getPublicUserAlias($oReplyEditForm->getInput('alias'), $this->objProperties->isAnonymized());
4814
4815 // generateDraft
4816 $update_draft = new ilForumPostDraft($this->user->getId(), $this->objCurrentPost->getId(), (int) $_GET['draft_id']);
4817
4818 $update_draft->setPostSubject($this->handleFormInput($oReplyEditForm->getInput('subject'), false));
4819 $update_draft->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message'), 0));
4820 $update_draft->setPostUserAlias($user_alias);
4821 $update_draft->setNotify((int) $oReplyEditForm->getInput('notify'));
4822 $update_draft->setUpdateUserId($this->user->getId());
4823 $update_draft->setPostAuthorId($this->user->getId());
4824 $update_draft->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $this->user->getId()));
4825
4826 $update_draft->updateDraft();
4827
4829 $GLOBALS['ilAppEventHandler']->raise(
4830 'Modules/Forum',
4831 'updatedDraft',
4832 array('draftObj' => $update_draft,
4833 'obj_id' => $this->object->getId(),
4834 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed())
4835 );
4836 }
4837
4838 $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
4839
4840 foreach ($uploadedObjects as $mob) {
4841 ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
4842 ilObjMediaObject::_saveUsage($mob, 'frm~d:html', $update_draft->getDraftId());
4843 }
4844 ilForumUtil::saveMediaObjects($oReplyEditForm->getInput('message'), 'frm~d:html', $update_draft->getDraftId());
4845
4846 if ($this->objProperties->isFileUploadAllowed()) {
4847 $oFDForumDrafts = new ilFileDataForumDrafts($forumObj->getId(), $update_draft->getDraftId());
4848 $file = $_FILES['userfile'];
4849 if (is_array($file) && !empty($file)) {
4850 $oFDForumDrafts->storeUploadedFile($file);
4851 }
4852 }
4853
4854 $file2delete = $oReplyEditForm->getInput('del_file');
4855 if (is_array($file2delete) && count($file2delete)) {
4856 $oFDForumDrafts->unlinkFilesByMD5Filenames($file2delete);
4857 }
4858
4859 $_SESSION['frm'][(int) $_GET['thr_pk']]['openTreeNodes'][] = (int) $this->objCurrentPost->getId();
4860 ilUtil::sendSuccess($this->lng->txt('save_draft_successfully'), true);
4861 }
4862 $this->ctrl->clearParameters($this);
4863 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
4864 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
4865 $this->ctrl->setParameter($this, 'draft_id', $update_draft->getDraftId());
4866 } else {
4867 $this->ctrl->clearParameters($this);
4868 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
4869 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
4870 $this->ctrl->setParameter($this, 'draft_id', (int) $_GET['draft_id']);
4871 $this->ctrl->setParameter($this, 'action', 'editdraft');
4872 $oReplyEditForm->setValuesByPost();
4873 return $this->viewThreadObject();
4874 }
4875 $this->ctrl->clearParameters($this);
4876 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
4877 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
4878 $this->ctrl->redirect($this, 'viewThread');
4879 }
4880
4886 protected function deleteMobsOfDraft($draft_id, $message)
4887 {
4888 // remove usage of deleted media objects
4889 include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
4890 $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draft_id);
4891 $curMediaObjects = ilRTE::_getMediaObjects($message, 0);
4892 foreach ($oldMediaObjects as $oldMob) {
4893 $found = false;
4894 foreach ($curMediaObjects as $curMob) {
4895 if ($oldMob == $curMob) {
4896 $found = true;
4897 break;
4898 }
4899 }
4900 if (!$found) {
4901 if (ilObjMediaObject::_exists($oldMob)) {
4902 ilObjMediaObject::_removeUsage($oldMob, 'frm~d:html', $draft_id);
4903 $mob_obj = new ilObjMediaObject($oldMob);
4904 $mob_obj->delete();
4905 }
4906 }
4907 }
4908 }
4909
4913 protected function deleteSelectedDraft(ilForumPostDraft $draft_obj = null)
4914 {
4915 if (
4916 !$this->access->checkAccess('add_reply', '', (int) $_GET['ref_id']) ||
4917 $this->user->isAnonymous() ||
4918 ($draft_obj instanceof ilForumPostDraft && $this->user->getId() != $draft_obj->getPostAuthorId())) {
4919 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4920 }
4921
4922 $post_id = $this->objCurrentPost->getId();
4923 if (!($draft_obj instanceof ilForumPostDraft)) {
4924 $draft_id_to_delete = (int) $_GET['draft_id'];
4925 $draft_obj = new ilForumPostDraft($this->user->getId(), $post_id, $draft_id_to_delete);
4926
4927 if (!$draft_obj->getDraftId() || ($draft_obj->getDraftId() != $draft_id_to_delete)) {
4928 $this->ctrl->clearParameters($this);
4929 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
4930 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
4931 $this->ctrl->redirect($this, 'viewThread');
4932 }
4933 }
4934
4935 $this->deleteMobsOfDraft($draft_obj->getDraftId(), $draft_obj->getPostMessage());
4936
4937 // delete attachments of draft
4938 $objFileDataForumDrafts = new ilFileDataForumDrafts(0, $draft_obj->getDraftId());
4939 $objFileDataForumDrafts->delete();
4940
4942 $GLOBALS['ilAppEventHandler']->raise(
4943 'Modules/Forum',
4944 'deletedDraft',
4945 array('draftObj' => $draft_obj,
4946 'obj_id' => $this->object->getId(),
4947 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed())
4948 );
4949 }
4950 // delete draft
4951 $draft_obj->deleteDraft();
4952
4953 ilUtil::sendSuccess($this->lng->txt('delete_draft_successfully'), true);
4954 $this->ctrl->clearParameters($this);
4955 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
4956 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
4957 $this->ctrl->redirect($this, 'viewThread');
4958 }
4959
4961 {
4962 if ($this->user->isAnonymous() || $_GET['action'] == 'ready_showreply') {
4963 exit();
4964 }
4965
4966 $reponse = new stdClass();
4967 $reponse->draft_id = 0;
4968
4970 $replyform = $this->getReplyEditForm();
4971 $current_post_id =$this->objCurrentPost->getId();
4972
4973 $replyform->checkInput();
4974
4975 $form_autosave_values['subject'] = $replyform->getInput('subject');
4976 $form_autosave_values['message'] = $replyform->getInput('message');
4977 $form_autosave_values['notify'] = $replyform->getInput('notify');
4978 $form_autosave_values['alias'] = $replyform->getInput('alias');
4979
4980 if (isset($_GET['draft_id']) && (int) $_GET['draft_id'] > 0) {
4981 $draft_id = (int) $_GET['draft_id'];
4982 } else {
4983 $draft_id = $replyform->getInput('draft_id');
4984 }
4985 $user_alias = ilForumUtil::getPublicUserAlias($form_autosave_values['alias'], $this->objProperties->isAnonymized());
4986
4987 if ((int) $draft_id > 0) {
4988 if ($_GET['action'] == 'showreply') {
4989 $draftObj = ilForumPostDraft::newInstanceByDraftId((int) $draft_id);
4990 $draftObj->setPostSubject($this->handleFormInput($form_autosave_values['subject'], false));
4991 $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form_autosave_values['message'], 0));
4992
4993 $draftObj->setPostUserAlias($user_alias);
4994 $draftObj->setNotify((int) $form_autosave_values['notify']);
4995 $draftObj->setUpdateUserId($this->user->getId());
4996 $draftObj->setPostAuthorId($this->user->getId());
4997 $draftObj->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $this->user->getId()));
4998
4999 $draftObj->updateDraft();
5000
5001 $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
5002 $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draftObj->getDraftId());
5003 $curMediaObjects = ilRTE::_getMediaObjects($form_autosave_values['message'], 0);
5004
5005 foreach ($uploadedObjects as $mob) {
5006 ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
5008 }
5009
5010 foreach ($oldMediaObjects as $mob) {
5012 }
5013
5014 foreach ($curMediaObjects as $mob) {
5016 }
5017 } else {
5018 $draftObj = new ilForumDraftsHistory();
5019 $draftObj->setDraftId((int) $draft_id);
5020 $draftObj->setPostSubject($this->handleFormInput($form_autosave_values['subject'], false));
5021 $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form_autosave_values['message'], 0));
5022 $draftObj->addDraftToHistory();
5023
5024 $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
5025 $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draftObj->getDraftId());
5026 $curMediaObjects = ilRTE::_getMediaObjects($form_autosave_values['message'], 0);
5027
5028 foreach ($uploadedObjects as $mob) {
5029 ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
5031 }
5032
5033 foreach ($oldMediaObjects as $mob) {
5035 }
5036
5037 foreach ($curMediaObjects as $mob) {
5039 }
5040 }
5041 } else {
5042 $draftObj = new ilForumPostDraft();
5043 $draftObj->setForumId(ilObjForum::lookupForumIdByRefId($this->ref_id));
5044 $draftObj->setThreadId($this->objCurrentTopic->getId());
5045 $draftObj->setPostId($current_post_id);
5046
5047 $draftObj->setPostSubject($this->handleFormInput($form_autosave_values['subject'], false));
5048 $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form_autosave_values['message'], 0));
5049
5050 $draftObj->setPostUserAlias($user_alias);
5051 $draftObj->setNotify((int) $form_autosave_values['notify']);
5052 $draftObj->setPostAuthorId($this->user->getId());
5053 $draftObj->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $this->user->getId()));
5054 $draftObj->saveDraft();
5055
5056 $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
5057 $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draftObj->getDraftId());
5058 $curMediaObjects = ilRTE::_getMediaObjects($form_autosave_values['message'], 0);
5059
5060 foreach ($uploadedObjects as $mob) {
5061 ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
5063 }
5064
5065 foreach ($oldMediaObjects as $mob) {
5067 }
5068
5069 foreach ($curMediaObjects as $mob) {
5071 }
5072 }
5073 }
5074
5075 $reponse->draft_id = $draftObj->getDraftId();
5076 echo json_encode($reponse);
5077 exit();
5078 }
5079
5081 {
5082 if ($this->user->isAnonymous() || $_GET['action'] == 'ready_showreply') {
5083 exit();
5084 }
5085
5086 $reponse = new stdClass();
5087 $reponse->draft_id = 0;
5088
5090 $this->initTopicCreateForm();
5091 $replyform = $this->create_topic_form_gui;
5092 $current_post_id = 0;
5093
5094
5095 $replyform->checkInput();
5096
5097 $form_autosave_values['subject'] = $replyform->getInput('subject');
5098 $form_autosave_values['message'] = $replyform->getInput('message');
5099 $form_autosave_values['notify'] = $replyform->getInput('notify');
5100 $form_autosave_values['alias'] = $replyform->getInput('alias');
5101
5102 if (isset($_GET['draft_id']) && (int) $_GET['draft_id'] > 0) {
5103 $draft_id = (int) $_GET['draft_id'];
5104 } else {
5105 $draft_id = $replyform->getInput('draft_id');
5106 }
5107 $user_alias = ilForumUtil::getPublicUserAlias($form_autosave_values['alias'], $this->objProperties->isAnonymized());
5108 if ((int) $draft_id > 0) {
5109 if ($_GET['action'] == 'showreply') {
5110 $draftObj = ilForumPostDraft::newInstanceByDraftId((int) $draft_id);
5111 $draftObj->setPostSubject($this->handleFormInput($form_autosave_values['subject'], false));
5112 $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form_autosave_values['message'], 0));
5113 $draftObj->setPostUserAlias($user_alias);
5114 $draftObj->setNotify((int) $form_autosave_values['notify']);
5115 $draftObj->setUpdateUserId($this->user->getId());
5116 $draftObj->setPostAuthorId($this->user->getId());
5117 $draftObj->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $this->user->getId()));
5118
5119 $draftObj->updateDraft();
5120
5121 $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
5122 $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draftObj->getDraftId());
5123 $curMediaObjects = ilRTE::_getMediaObjects($form_autosave_values['message'], 0);
5124
5125 foreach ($uploadedObjects as $mob) {
5126 ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
5128 }
5129
5130 foreach ($oldMediaObjects as $mob) {
5132 }
5133
5134 foreach ($curMediaObjects as $mob) {
5136 }
5137 } else {
5138 $draftObj = new ilForumDraftsHistory();
5139 $draftObj->setDraftId((int) $draft_id);
5140 $draftObj->setPostSubject($this->handleFormInput($form_autosave_values['subject'], false));
5141 $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form_autosave_values['message'], 0));
5142 $draftObj->addDraftToHistory();
5143
5144 $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
5145 $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draftObj->getDraftId());
5146 $curMediaObjects = ilRTE::_getMediaObjects($form_autosave_values['message'], 0);
5147
5148 foreach ($uploadedObjects as $mob) {
5149 ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
5151 }
5152
5153 foreach ($oldMediaObjects as $mob) {
5155 }
5156
5157 foreach ($curMediaObjects as $mob) {
5159 }
5160 }
5161 } else {
5162 $draftObj = new ilForumPostDraft();
5163 $draftObj->setForumId(ilObjForum::lookupForumIdByRefId($this->ref_id));
5164 $draftObj->setThreadId($this->objCurrentTopic->getId());
5165 $draftObj->setPostId($current_post_id);
5166
5167 $draftObj->setPostSubject($this->handleFormInput($form_autosave_values['subject'], false));
5168 $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form_autosave_values['message'], 0));
5169
5170 $draftObj->setPostUserAlias($user_alias);
5171 $draftObj->setNotify((int) $form_autosave_values['notify']);
5172 $draftObj->setPostAuthorId($this->user->getId());
5173 $draftObj->setPostDisplayUserId(($this->objProperties->isAnonymized() ? 0 : $this->user->getId()));
5174 $draftObj->saveDraft();
5175
5176 $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
5177 $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draftObj->getDraftId());
5178 $curMediaObjects = ilRTE::_getMediaObjects($form_autosave_values['message'], 0);
5179
5180 foreach ($uploadedObjects as $mob) {
5181 ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
5183 }
5184
5185 foreach ($oldMediaObjects as $mob) {
5187 }
5188
5189 foreach ($curMediaObjects as $mob) {
5191 }
5192 }
5193 }
5194
5195 $reponse->draft_id = $draftObj->getDraftId();
5196 echo json_encode($reponse);
5197 exit();
5198 }
5199
5207 private function renderSplitButton($is_post = true, ilForumPost $node, $Start = 0, ilForumPostDraft $draft = null)
5208 {
5209 $actions = array();
5210 if ($is_post) {
5211 if ($this->objCurrentPost->getId() != $node->getId()
5212 || ($_GET['action'] != 'showreply' &&
5213 $_GET['action'] != 'showedit' &&
5214 $_GET['action'] != 'censor' &&
5215 $_GET['action'] != 'delete' &&
5216 !$this->displayConfirmPostActivation())
5217 ) {
5218 if ($this->is_moderator || $node->isActivated() || $node->isOwner($this->user->getId())) {
5219 // button: reply
5220 if (!$this->objCurrentTopic->isClosed() && $node->isActivated() &&
5221 $this->access->checkAccess('add_reply', '', (int) $_GET['ref_id']) &&
5222 !$node->isCensored()
5223 ) {
5224 $this->ctrl->setParameter($this, 'action', 'showreply');
5225 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5226 $this->ctrl->setParameter($this, 'offset', $Start);
5227 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
5228 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5229
5230 if (!isset($draftsObjects[$node->getId()])) {
5231 $actions['reply_to_postings'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
5232 }
5233
5234 $this->ctrl->clearParameters($this);
5235 }
5236
5237 // button: edit article
5238 if (!$this->objCurrentTopic->isClosed() &&
5239 ($node->isOwner($this->user->getId()) || $this->is_moderator) &&
5240 !$node->isCensored() &&
5241 $this->user->getId() != ANONYMOUS_USER_ID
5242 ) {
5243 $this->ctrl->setParameter($this, 'action', 'showedit');
5244 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5245 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5246 $this->ctrl->setParameter($this, 'offset', $Start);
5247 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
5248
5249 $actions['edit'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
5250
5251 $this->ctrl->clearParameters($this);
5252 }
5253
5254 // button: mark read
5255 if ($this->user->getId() != ANONYMOUS_USER_ID && !$node->isPostRead()) {
5256 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5257 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5258 $this->ctrl->setParameter($this, 'offset', $Start);
5259 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
5260 $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
5261
5262 $actions['frm_mark_as_read'] = $this->ctrl->getLinkTarget($this, 'markPostRead', $node->getId());
5263
5264 $this->ctrl->clearParameters($this);
5265 }
5266
5267 // button: mark unread
5268 if ($this->user->getId() != ANONYMOUS_USER_ID &&
5269 $node->isPostRead()
5270 ) {
5271 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5272 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5273 $this->ctrl->setParameter($this, 'offset', $Start);
5274 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
5275 $this->ctrl->setParameter($this, 'viewmode', $_SESSION['viewmode']);
5276
5277 $actions['frm_mark_as_unread'] = $this->ctrl->getLinkTarget($this, 'markPostUnread', $node->getId());
5278
5279 $this->ctrl->clearParameters($this);
5280 }
5281
5282 // button: print
5283 if (!$node->isCensored()) {
5284 $this->ctrl->setParameterByClass('ilforumexportgui', 'print_post', $node->getId());
5285 $this->ctrl->setParameterByClass('ilforumexportgui', 'top_pk', $node->getForumId());
5286 $this->ctrl->setParameterByClass('ilforumexportgui', 'thr_pk', $node->getThreadId());
5287
5288 $actions['print'] = $this->ctrl->getLinkTargetByClass('ilforumexportgui', 'printPost');
5289
5290 $this->ctrl->clearParameters($this);
5291 }
5292
5293 # buttons for every post except the "active"
5294 if (!$this->objCurrentTopic->isClosed() &&
5295 ($this->is_moderator ||
5296 ($node->isOwner($this->user->getId()) && !$node->hasReplies())) &&
5297 $this->user->getId() != ANONYMOUS_USER_ID
5298 ) {
5299 // button: delete
5300 $this->ctrl->setParameter($this, 'action', 'delete');
5301 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5302 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5303 $this->ctrl->setParameter($this, 'offset', $Start);
5304 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
5305
5306 $actions['delete'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
5307
5308 $this->ctrl->clearParameters($this);
5309 }
5310
5311 if (!$this->objCurrentTopic->isClosed() && $this->is_moderator) {
5312 // button: censor
5313 $this->ctrl->setParameter($this, 'action', 'censor');
5314 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5315 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5316 $this->ctrl->setParameter($this, 'offset', $Start);
5317 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
5318 if ($node->isCensored()) {
5319 $actions['frm_revoke_censorship'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
5320 } else {
5321 $actions['frm_censorship'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
5322 }
5323
5324 $this->ctrl->clearParameters($this);
5325
5326 // button: activation/deactivation
5327 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5328 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5329 $this->ctrl->setParameter($this, 'offset', $Start);
5330 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
5331
5332 if (!$node->isActivated()) {
5333 $actions['activate_post'] = $this->ctrl->getLinkTarget($this, 'askForPostActivation', $node->getId());
5334 }
5335
5336 $this->ctrl->clearParameters($this);
5337 }
5338 }
5339 }
5340 } else {
5341 if (!isset($draft)) {
5342 $draftsObjects = ilForumPostDraft::getInstancesByUserIdAndThreadId($this->user->getId(), $this->objCurrentTopic->getId());
5343 $draft = $draftsObjects[$node->getId()];
5344 }
5345 // get actions for drafts
5346 $this->ctrl->setParameter($this, 'action', 'publishdraft');
5347 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5348 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
5349 $this->ctrl->setParameter($this, 'offset', (int) $_GET['offset']);
5350 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
5351 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
5352 $actions['publish'] = $this->ctrl->getLinkTarget($this, 'publishSelectedDraft', $node->getId());
5353 $this->ctrl->clearParameters($this);
5354
5355 $this->ctrl->setParameter($this, 'action', 'editdraft');
5356 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5357 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
5358 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
5359 $this->ctrl->setParameter($this, 'offset', (int) $_GET['offset']);
5360 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
5361 $actions['edit'] = $this->ctrl->getLinkTarget($this, 'editDraft', 'draft_edit_' . $draft->getDraftId());
5362 $this->ctrl->clearParameters($this);
5363
5364 $this->ctrl->setParameter($this, 'action', 'deletedraft');
5365 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5366 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
5367 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
5368 $this->ctrl->setParameter($this, 'offset', (int) $_GET['offset']);
5369 $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']);
5370 $actions['delete'] = $this->ctrl->getLinkTarget($this, 'viewThread', $node->getId());
5371 $this->ctrl->clearParameters($this);
5372
5373 if (isset($_GET['draft_id']) && $_GET['action'] == 'editdraft') {
5374 $actions = array();
5375 }
5376 }
5377
5378 $this->tpl->setCurrentBlock('posts_row');
5379 if (count($actions) > 0) {
5380 require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
5381 $action_button = ilSplitButtonGUI::getInstance();
5382
5383 $i = 0;
5384 foreach ($actions as $lng_id => $url) {
5385 if ($i == 0) {
5386 $sb_item = ilLinkButton::getInstance();
5387 $sb_item->setCaption($lng_id);
5388 $sb_item->setUrl($url);
5389
5390 $action_button->setDefaultButton($sb_item);
5391 ++$i;
5392 } else {
5393 $sb_item = ilLinkButton::getInstance();
5394 $sb_item->setCaption($lng_id);
5395 $sb_item->setUrl($url);
5396
5397 $action_button->addMenuItem(new ilButtonToSplitButtonMenuItemAdapter($sb_item));
5398 }
5399 }
5400
5401 if ($is_post) {
5402 $this->tpl->setVariable('COMMANDS', $action_button->render());
5403 } else {
5404 if ($_GET['action'] != 'deletedraft' && $_GET['action'] != 'editdraft' && !$this->objCurrentTopic->isClosed()) {
5405 $this->tpl->setVariable('COMMANDS', $action_button->render());
5406 }
5407 }
5408 }
5409 }
5410
5415 public function checkDraftAccess($draft_id)
5416 {
5417 $draft_obj = ilForumPostDraft::newInstanceByDraftId($draft_id);
5418
5419 if (!$this->access->checkAccess('add_reply', '', (int) $_GET['ref_id']) ||
5420 $this->user->isAnonymous() ||
5421 ($draft_obj instanceof ilForumPostDraft && $this->user->getId() != $draft_obj->getPostAuthorId())) {
5422 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5423 }
5424 return true;
5425 }
5426
5430 public function doHistoryCheck($draft_id)
5431 {
5432 require_once './Services/jQuery/classes/class.iljQueryUtil.php';
5434
5435 $modal = '';
5437 $history_instances = ilForumDraftsHistory::getInstancesByDraftId($draft_id);
5438 if (is_array($history_instances) && sizeof($history_instances) > 0) {
5439 require_once 'Services/UIComponent/Modal/classes/class.ilModalGUI.php';
5440 $modal = ilModalGUI::getInstance();
5441 $modal->setHeading($this->lng->txt('restore_draft_from_autosave'));
5442 $modal->setId('frm_autosave_restore');
5443 $form_tpl = new ilTemplate('tpl.restore_thread_draft.html', true, true, 'Modules/Forum');
5444 include_once './Services/Accordion/classes/class.ilAccordionGUI.php';
5445
5446 foreach ($history_instances as $key => $history_instance) {
5447 $acc_autosave = new ilAccordionGUI();
5448 $acc_autosave->setId('acc_' . $history_instance->getHistoryId());
5449
5450 $form_tpl->setCurrentBlock('list_item');
5451 $post_message = ilRTE::_replaceMediaObjectImageSrc($history_instance->getPostMessage(), 1);
5452
5453 $history_date = ilDatePresentation::formatDate(new ilDateTime($history_instance->getDraftDate(), IL_CAL_DATETIME));
5454 $restore_btn = ilLinkButton::getInstance();
5455 $restore_btn->addCSSClass('restore_btn');
5456 $this->ctrl->setParameter($this, 'history_id', $history_instance->getHistoryId());
5457 $restore_btn->setUrl($this->ctrl->getLinkTarget($this, 'restoreFromHistory'));
5458 $restore_btn->setCaption($this->lng->txt('restore'), false);
5459
5460 $acc_autosave->addItem($history_date . ' - ' . $history_instance->getPostSubject(), $post_message . $restore_btn->render());
5461
5462 $form_tpl->setVariable('ACC_AUTO_SAVE', $acc_autosave->getHtml());
5463 $form_tpl->parseCurrentBlock();
5464 }
5465
5466 $form_tpl->setVariable('RESTORE_DATA_EXISTS', 'found_threat_history_to_restore');
5467 $modal->setBody($form_tpl->get());
5468 $modal->initJS();
5469 $this->modal_history = $modal->getHTML();
5470 } else {
5472 }
5473 }
5474 }
5475
5476 public function doCaptchaCheck()
5477 {
5478 require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
5479 if ($this->user->isAnonymous()
5480 && !$this->user->isCaptchaVerified()
5481 && ilCaptchaUtil::isActiveForForum()) {
5482 $this->user->setCaptchaVerified(true);
5483 }
5484 }
5485}
sprintf('%.4f', $callTime)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$result
user()
Definition: user.php:4
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
error($a_errmsg)
set error message @access public
Accordion user interface class.
This class represents a captcha input in a property form.
This class represents a property in a property form.
This class represents a checkbox property in a property form.
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.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
@classDescription Date and time handling
static addToDesktop()
Add desktop item @access public.
static removeFromDesktop()
Remove item from personal desktop @access public.
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.
This class represents a file wizard property in a property form.
Class ilForumDraftHistory.
static getInstancesByDraftId($draft_id)
Class ilForumDraftsTableGUI.
Class ilForumExplorerGUI.
Forum export to HTML and Print.
Class ilForumModeratorsGUI.
Class ilForumNotification.
Class ilForumPostDraft.
static newInstanceByDraftId($draft_id)
static getInstancesByUserIdAndThreadId($user_id, $thread_id)
static getDraftInstancesByUserId($user_id)
static createDraftBackup($draft_id)
static getThreadDraftData($post_author_id, $forum_id)
isOwner($a_user_id=0)
setChangeDate($a_changedate)
setMessage($a_message)
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
const SORT_TITLE
static _getThreads($a_obj_id, $a_sort_mode=self::SORT_DATE)
Get thread infos of object.
static mergeThreads($obj_id, $source_id, $target_id)
static _lookupObjIdForForumId($a_for_id)
static get($a_glyph, $a_text="")
Get glyph html.
Online help application class.
This class represents a hidden form property in a property form.
static _getInstanceByType($a_type)
Factory method for creating purifier instances.
Class ilInfoScreenGUI.
static getInstance()
Factory.
This class handles base functions for mail handling.
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.
Class ilObjForumGUI.
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
renderSplitButton($is_post=true, ilForumPost $node, $Start=0, ilForumPostDraft $draft=null)
afterSave(ilObject $forumObj)
getThreadEditingForm($a_thread_id)
publishThreadDraftObject($a_prevent_redirect=false)
addAutosave(ilPropertyFormGUI $form)
publishDraftObject($use_replyform=true)
editThreadObject($a_thread_id, ilPropertyFormGUI $form=null)
initHeaderAction($a_sub_type=null, $a_sub_id=null)
Add header action menu.
getModifiedReOnSubject($on_reply=false)
executeCommand()
execute command
renderDraftContent($render_drafts, $node, $edit_draft_id=null)
getTabs()
get tabs abstract method.
getSubTabs($subtab='showThreads')
cancelObject()
cancel action and go back to previous page @access public
getEditFormCustomValues(array &$a_values)
static _goto($a_target, $a_thread=0, $a_posting=0)
ensureThreadBelongsToForum($objId, \ilForumTopic $thread)
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
renderPostContent(ilForumPost $node, $Start, $z)
hideToolbar($a_flag=null)
setColumnSettings(ilColumnGUI $column_gui)
May be overwritten in subclasses.
initForumCreateForm($object_type)
editThreadDraftObject($form=null)
addThreadObject($a_prevent_redirect=false)
checkDraftAccess($draft_id)
handleFormInput($a_text, $a_stripslashes=true)
updateCustom(ilPropertyFormGUI $a_form)
setDisplayConfirmPostActivation($status=0)
deleteSelectedDraft(ilForumPostDraft $draft_obj=null)
initEditCustomForm(ilPropertyFormGUI $a_form)
deleteMobsOfDraft($draft_id, $message)
todo: move to ilForumUtil
initTopicCreateForm($edit_draft=false)
Class ilObjForumListGUI.
Class ilObjForum.
static lookupForumIdByRefId($ref_id)
static lookupForumIdByObjId($obj_id)
Class ilObjMediaObject.
static _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Remove usage of mob in another container.
static _exists($a_id, $a_reference=false, $a_type=null)
checks wether a lm content object with specified id exists or not
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
getRightColumnHTML()
Display right column.
getCenterColumnHTML()
Get center column.
getCreationMode()
get creation mode
addHeaderAction()
Add header action menu.
createObject()
create new object form
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
const TITLE_LENGTH
max length of object title
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
getRefId()
get reference id @access public
static _getAllReferences($a_id)
get all reference ids of object
getId()
get object id @access public
Class for permanent links.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
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()
This class represents a property in a property form.
This class represents an option in a radio group.
Class ilRatingGUI.
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.
ILIAS Setting Class.
Class ilTable2GUI.
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 formCheckbox($checked, $varname, $value, $disabled=false)
??? @access public
static Linkbar($AScript, $AHits, $ALimit, $AOffset, $AParams=array(), $ALayout=array(), $prefix='')
Linkbar Diese Funktion erzeugt einen typischen Navigationsbalken mit "Previous"- und "Next"-Links und...
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static redirect($a_script)
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($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
$counter
$key
Definition: croninfo.php:18
$i
Definition: disco.tpl.php:19
$html
Definition: example_001.php:87
$lg
Definition: example_018.php:62
$tbl
Definition: example_048.php:81
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
catch(Exception $e) $message
$info
Definition: index.php:5
$ret
Definition: parser.php:6
$url
if(isset($_POST['submit'])) $form
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
$mobs
$params
Definition: disable.php:11