4 require_once
'Services/Object/classes/class.ilObjectGUI.php';
5 require_once
'Services/Table/classes/class.ilTable2GUI.php';
6 require_once
'Modules/Forum/classes/class.ilForumProperties.php';
7 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
8 require_once
'Modules/Forum/classes/class.ilForumPost.php';
9 require_once
'Modules/Forum/classes/class.ilForum.php';
10 require_once
'Modules/Forum/classes/class.ilForumTopic.php';
11 require_once
'Services/RTE/classes/class.ilRTE.php';
12 require_once
'Services/PersonalDesktop/interfaces/interface.ilDesktopItemHandling.php';
104 public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output =
true)
111 global
$ilCtrl, $ilAccess, $ilObjDataCache;
114 $this->ctrl->saveParameter($this, array(
'ref_id',
'cmdClass'));
117 parent::__construct($a_data, $a_id, $a_call_by_reference,
false);
119 $this->lng->loadLanguageModule(
'forum');
127 $this->is_moderator = $ilAccess->checkAccess(
'moderate_frm',
'',
$_GET[
'ref_id']);
130 $this->objCurrentTopic =
new ilForumTopic((
int)
$_GET[
'thr_pk'], $this->is_moderator);
133 $this->objCurrentPost =
new ilForumPost((
int) $_GET[
'pos_pk'], $this->is_moderator);
136 $this->forum_overview_setting = $frma_set->get(
'forum_overview');
150 $sess[(int)$_GET[
'thr_fk']] = array();
163 global $ilNavigationHistory, $ilAccess,
$ilCtrl, $ilTabs;
165 $next_class = $this->ctrl->getNextClass($this);
166 $cmd = $this->ctrl->getCmd();
168 $exclude_cmds = array(
169 'viewThread',
'markPostUnread',
'markPostRead',
'showThreadNotification',
170 'cancelPostActivation',
'cancelPostDeactivation',
171 'performPostActivation',
'performPostDeactivation',
'performPostAndChildPostsActivation',
172 'askForPostActivation',
'askForPostDeactivation',
173 'toggleThreadNotification',
'toggleThreadNotificationTab',
174 'toggleStickiness',
'cancelPost',
'savePost',
'quotePost',
'getQuotationHTMLAsynch',
175 'setTreeStateAsynch',
'fetchTreeChildrenAsync'
178 if(!in_array(
$cmd, $exclude_cmds))
184 if(!$this->
getCreationMode() && !$ilCtrl->isAsynch() && $ilAccess->checkAccess(
'read',
'',
$_GET[
'ref_id']))
186 $ilNavigationHistory->addItem(
$_GET[
'ref_id'],
187 'ilias.php?baseClass=ilRepositoryGUI&cmd=showThreads&ref_id='.
$_GET[
'ref_id'],
'frm');
192 case 'ilpermissiongui':
193 require_once
'Services/AccessControl/classes/class.ilPermissionGUI.php';
195 $this->ctrl->forwardCommand($perm_gui);
198 case 'ilforumexportgui':
199 require_once
'Modules/Forum/classes/class.ilForumExportGUI.php';
201 $this->ctrl->forwardCommand($fex_gui);
205 case 'ilforummoderatorsgui':
206 require_once
'Modules/Forum/classes/class.ilForumModeratorsGUI.php';
208 $this->ctrl->forwardCommand($fm_gui);
211 case 'ilinfoscreengui':
219 case 'ilpublicuserprofilegui':
220 include_once
'Services/User/classes/class.ilPublicUserProfileGUI.php';
222 $add = $this->getUserProfileAdditional((
int)
$_GET[
'ref_id'], (
int)$_GET[
'user']);
223 $profile_gui->setAdditional($add);
224 $ret = $this->ctrl->forwardCommand($profile_gui);
225 $this->tpl->setContent(
$ret);
228 case 'ilobjectcopygui':
229 include_once
'Services/Object/classes/class.ilObjectCopyGUI.php';
232 $this->ctrl->forwardCommand($cp);
236 $ilTabs->setTabActive(
'export');
237 include_once
'Services/Export/classes/class.ilExportGUI.php';
239 $exp->addFormat(
'xml');
240 $this->ctrl->forwardCommand($exp);
243 case 'ilcommonactiondispatchergui':
244 include_once
'Services/Object/classes/class.ilCommonActionDispatcherGUI.php';
246 $this->ctrl->forwardCommand($gui);
258 if(isset(
$_POST[
'select_cmd2']))
263 if(isset(
$_POST[
'selected_cmd']) &&
$_POST[
'selected_cmd'] != null)
265 $member_cmd = array(
'enableAdminForceNoti',
'disableAdminForceNoti',
'enableHideUserToggleNoti',
'disableHideUserToggleNoti');
266 in_array(
$_POST[
'selected_cmd'], $member_cmd) ?
$cmd =
$_POST[
'selected_cmd'] :
$cmd =
'performThreadsAction';
270 $cmd =
'showThreads';
280 if(
$cmd !=
'viewThreadObject' &&
$cmd !=
'showUserObject')
293 $this->settingsTabs();
299 $rg_pro->addOption($rg_sort_by_date);
304 $view_direction_group_gui->addOption($view_desc);
305 $view_direction_group_gui->addOption($view_asc);
307 $rg_sort_by_date->
addSubItem($view_direction_group_gui);
310 if($ilSetting->get(
'enable_anonymous_fora') || $this->objProperties->isAnonymized())
312 $cb_prop =
new ilCheckboxInputGUI($this->lng->txt(
'frm_anonymous_posting'),
'anonymized');
314 $cb_prop->setInfo($this->lng->txt(
'frm_anonymous_posting_desc'));
318 if($ilSetting->get(
'enable_fora_statistics',
false))
320 $cb_prop =
new ilCheckboxInputGUI($this->lng->txt(
'frm_statistics_enabled'),
'statistics_enabled');
322 $cb_prop->setInfo($this->lng->txt(
'frm_statistics_enabled_desc'));
326 $cb_prop =
new ilCheckboxInputGUI($this->lng->txt(
'activate_new_posts'),
'post_activation');
328 $cb_prop->setInfo($this->lng->txt(
'post_activation_desc'));
331 $frm_subject =
new ilRadioGroupInputGUI($this->lng->txt(
'frm_subject_setting'),
'subject_setting');
333 $frm_subject->addOption(
new ilRadioOption($this->lng->txt(
'add_re_to_subject'),
'add_re_to_subject'));
334 $frm_subject->addOption(
new ilRadioOption($this->lng->txt(
'empty_subject'),
'empty_subject'));
336 $a_form->
addItem($frm_subject);
338 $cb_prop =
new ilCheckboxInputGUI($this->lng->txt(
'mark_moderator_posts'),
'mark_mod_posts');
340 $cb_prop->setInfo($this->lng->txt(
'mark_moderator_posts_desc'));
346 $a_values[
"desc"] = $this->
object->getLongDescription();
347 $a_values[
'default_view'] = $this->objProperties->getDefaultView();
348 $a_values[
'anonymized'] = $this->objProperties->isAnonymized();
349 $a_values[
'statistics_enabled'] = $this->objProperties->isStatisticEnabled();
350 $a_values[
'post_activation'] = $this->objProperties->isPostActivationEnabled();
351 $a_values[
'subject_setting'] = $this->objProperties->getSubjectSetting();
352 $a_values[
'mark_mod_posts'] = $this->objProperties->getMarkModeratorPosts();
358 $a_values[
'default_view'] = $default_view;
360 $default_view_sort_dir =
362 ? (
int)$this->objProperties->getDefaultView()
365 $a_values[
'default_view_sort_dir'] = $default_view_sort_dir;
375 $view = (int)
$_POST[
'default_view'];
384 $this->objProperties->setDefaultView($view);
392 if($ilSetting->get(
'enable_anonymous_fora') || $this->objProperties->isAnonymized())
394 $this->objProperties->setAnonymisation((
int) $a_form->
getInput(
'anonymized'));
396 if($ilSetting->get(
'enable_fora_statistics',
false))
398 $this->objProperties->setStatisticsStatus((
int) $a_form->
getInput(
'statistics_enabled'));
400 $this->objProperties->setPostActivation((
int) $a_form->
getInput(
'post_activation'));
401 $this->objProperties->setSubjectSetting( $a_form->
getInput(
'subject_setting'));
402 $this->objProperties->setMarkModeratorPosts((
int) $a_form->
getInput(
'mark_mod_posts'));
403 $this->objProperties->update();
413 $this->ctrl->setParameter($this,
'thr_pk', $a_thread_id);
414 $form->setFormAction($this->ctrl->getFormAction($this,
'updateThread'));
418 $ti_prop->setMaxLength(255);
419 $ti_prop->setSize(50);
420 $form->addItem($ti_prop);
422 $form->addCommandButton(
'updateThread', $this->lng->txt(
'save'));
423 $form->addCommandButton(
'showThreads', $this->lng->txt(
'cancel'));
439 if(!$this->is_moderator)
441 $this->ilias->raiseError($this->lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
444 $ilTabs->setTabActive(
'forums_threads');
449 $form->setValuesByArray(array(
454 $this->tpl->setContent($form->getHTML());
462 if(!$this->is_moderator)
464 $this->ilias->raiseError($this->lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
467 if(!$this->objCurrentTopic->getId())
474 if($this->objCurrentTopic->getForumId() != $forum_id)
476 $this->ilias->raiseError($this->lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
480 if(!$form->checkInput())
482 $form->setValuesByPost();
483 $this->editThreadObject($this->objCurrentTopic->getId(), $form);
487 $this->objCurrentTopic->setSubject($form->getInput(
'title'));
488 $this->objCurrentTopic->updateThreadTitle();
494 public function markAllReadObject()
501 $this->
object->markAllThreadsRead($ilUser->getId());
514 public function getContent()
524 if(!$ilAccess->checkAccess(
'read',
'', $this->object->getRefId()))
526 $this->ilias->raiseError($lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
529 $frm = $this->
object->Forum;
530 $frm->setForumId($this->object->getId());
531 $frm->setForumRefId($this->object->getRefId());
532 $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', array(
'integer'), array($frm->getForumId()));
534 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.forums_threads_liste.html',
'Modules/Forum');
536 if((
int)strlen($this->confirmation_gui_html))
538 $this->tpl->setVariable(
'CONFIRMATION_GUI', $this->confirmation_gui_html);
542 if($ilAccess->checkAccess(
'add_thread',
'', $this->object->getRefId()) && !$this->
hideToolbar())
544 $ilToolbar->addButton($this->lng->txt(
'forums_new_thread'), $this->ctrl->getLinkTarget($this,
'createThread'));
548 include_once
'Services/Accessibility/classes/class.ilAccessKeyGUI.php';
549 if($ilUser->getId() != ANONYMOUS_USER_ID && !(int)strlen($this->confirmation_gui_html))
551 $ilToolbar->addButton(
552 $this->lng->txt(
'forums_mark_read'),
553 $this->ctrl->getLinkTarget($this,
'markAllRead'),
557 $this->ctrl->clearParameters($this);
561 $topicData = $frm->getOneTopic();
565 $frm->setDbTable(
'frm_data');
566 $frm->setMDB2WhereCondition(
'top_pk = %s ', array(
'integer'), array($topicData[
'top_pk']));
567 $frm->updateVisits($topicData[
'top_pk']);
569 include_once
'Modules/Forum/classes/class.ilForumTopicTableGUI.php';
570 $tbl =
new ilForumTopicTableGUI($this,
'showThreads',
'', (
int) $_GET[
'ref_id'], $topicData, $this->is_moderator, $this->forum_overview_setting);
571 $tbl->setMapper($frm)->fetchData();
572 $this->tpl->setVariable(
'THREADS_TABLE', $tbl->getHTML());
576 include_once
'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
578 $this->tpl->setVariable(
'PRMLINK', $permalink->getHTML());
586 $this->create_form_gui =
new ilPropertyFormGUI();
587 $this->create_form_gui->setTableWidth(
'600px');
589 $this->create_form_gui->setTitle($this->lng->txt(
'frm_new'));
593 $this->ctrl->setParameter($this,
'new_type', $object_type);
594 $this->create_form_gui->setFormAction($this->ctrl->getFormAction($this,
'save'));
597 $title_gui =
new ilTextInputGUI($this->lng->txt(
'title'),
'title');
599 $this->create_form_gui->addItem($title_gui);
604 $description_gui->setRows(2);
605 $this->create_form_gui->addItem($description_gui);
610 $view_group_gui->addOption($view_hir);
612 $view_group_gui->addOption($view_dat);
613 $this->create_form_gui->addItem($view_group_gui);
616 $view_direction_group_gui->addOption($view_desc);
618 $view_direction_group_gui->addOption($view_asc);
619 $view_dat->
addSubItem($view_direction_group_gui);
622 $anonymize_gui =
new ilCheckboxInputGUI($this->lng->txt(
'frm_anonymous_posting'),
'anonymized');
623 $anonymize_gui->
setInfo($this->lng->txt(
'frm_anonymous_posting_desc'));
624 $anonymize_gui->setValue(1);
626 if($this->ilias->getSetting(
'enable_anonymous_fora',
false))
627 $anonymize_gui->setDisabled(
true);
628 $this->create_form_gui->addItem($anonymize_gui);
631 $statistics_gui =
new ilCheckboxInputGUI($this->lng->txt(
'frm_statistics_enabled'),
'statistics_enabled');
632 $statistics_gui->
setInfo($this->lng->txt(
'frm_statistics_enabled_desc'));
633 $statistics_gui->setValue(1);
634 if(!$this->ilias->getSetting(
'enable_fora_statistics',
false))
635 $statistics_gui->setDisabled(
true);
636 $this->create_form_gui->addItem($statistics_gui);
638 $cb_prop =
new ilCheckboxInputGUI($this->lng->txt(
'activate_new_posts'),
'post_activation');
640 $cb_prop->setInfo($this->lng->txt(
'post_activation_desc'));
641 $this->create_form_gui->addItem($cb_prop);
643 $this->create_form_gui->addCommandButton(
'save', $this->lng->txt(
'save'));
644 $this->create_form_gui->addCommandButton(
'cancel', $this->lng->txt(
'cancel'));
650 ilUtil::redirect(
'ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&ref_id='.$_GET[
'ref_id']);
661 $this->objProperties->setObjId($forumObj->
getId());
662 $this->objProperties->setDefaultView(1);
663 $this->objProperties->setAnonymisation(0);
664 $this->objProperties->setStatisticsStatus(0);
665 $this->objProperties->setPostActivation(0);
666 $this->objProperties->insert();
672 $roles[0] = ilObjForum::_lookupModeratorRole($forumObj->
getRefId());
674 $rbacadmin->assignUser($roles[0], $forumObj->
getOwner(),
'n');
677 $forumObj->saveData($roles);
682 $this->ctrl->setParameter($this,
'ref_id', $forumObj->
getRefId());
683 ilUtil::redirect($this->ctrl->getLinkTarget($this,
'createThread',
'',
false,
false));
693 global $ilAccess, $ilHelp,
$ilCtrl;
695 $ilHelp->setScreenIdComponent(
"frm");
697 $this->ctrl->setParameter($this,
'ref_id', $this->ref_id);
699 include_once
'Services/Repository/classes/class.ilRepositoryExplorer.php';
701 '',
'showThreads',
'view',
'markAllRead',
702 'enableForumNotification',
'disableForumNotification',
'moveThreads',
'performMoveThreads',
703 'cancelMoveThreads',
'performThreadsAction',
'createThread',
'addThread',
704 'showUser',
'confirmDeleteThreads'
707 (in_array($ilCtrl->getCmd(), $active)) ? $force_active =
true : $force_active =
false;
708 $tabs_gui->
addTarget(
'forums_threads', $this->ctrl->getLinkTarget($this,
'showThreads'), $ilCtrl->getCmd(), get_class($this),
'', $force_active);
711 if($ilAccess->checkAccess(
'visible',
'', $this->ref_id))
713 $force_active = ($this->ctrl->getNextClass() ==
'ilinfoscreengui' || strtolower($_GET[
'cmdClass']) ==
'ilnotegui') ?
true :
false;
715 $this->ctrl->getLinkTargetByClass(
716 array(
'ilobjforumgui',
'ilinfoscreengui'),
'showSummary'),
717 array(
'showSummary',
'infoScreen'),
718 '',
'', $force_active);
721 if($ilAccess->checkAccess(
'write',
'', $this->ref_id))
723 $force_active = ($ilCtrl->getCmd() ==
'edit') ?
true :
false;
724 $tabs_gui->
addTarget(
'settings', $this->ctrl->getLinkTarget($this,
'edit'),
'edit', get_class($this),
'', $force_active);
727 if($ilAccess->checkAccess(
'write',
'', $this->ref_id))
729 $tabs_gui->
addTarget(
'frm_moderators', $this->ctrl->getLinkTargetByClass(
'ilForumModeratorsGUI',
'showModerators'),
'showModerators', get_class($this));
732 if($this->ilias->getSetting(
'enable_fora_statistics',
false) &&
733 ($this->objProperties->isStatisticEnabled() || $ilAccess->checkAccess(
'write',
'', $this->ref_id)))
735 $force_active = ($ilCtrl->getCmd() ==
'showStatistics') ?
true :
false;
736 $tabs_gui->
addTarget(
'frm_statistics', $this->ctrl->getLinkTarget($this,
'showStatistics'),
'showStatistics', get_class($this),
'', $force_active);
739 if($ilAccess->checkAccess(
'write',
'', $this->object->getRefId()))
741 $tabs_gui->
addTarget(
'export', $this->ctrl->getLinkTargetByClass(
'ilexportgui',
''),
'',
'ilexportgui');
744 if($ilAccess->checkAccess(
'edit_permission',
'', $this->ref_id))
746 $tabs_gui->
addTarget(
'perm_settings', $this->ctrl->getLinkTargetByClass(array(get_class($this),
'ilpermissiongui'),
'perm'), array(
'perm',
'info',
'owner'),
'ilpermissiongui');
750 public function settingsTabs()
757 global $ilTabs, $ilAccess,
$tree;
759 $ilTabs->setTabActive(
'settings');
760 $ilTabs->addSubTabTarget(
'basic_settings', $this->ctrl->getLinkTarget($this,
'edit'),
'edit', get_class($this),
'', $_GET[
'cmd']==
'edit'?
true : false );
763 if($this->ilias->getSetting(
'forum_notification') > 0)
766 $grp_ref_id = $tree->checkForParentType($this->object->getRefId(),
'grp');
767 $crs_ref_id = $tree->checkForParentType($this->object->getRefId(),
'crs');
769 if((
int)$grp_ref_id > 0 || (int)$crs_ref_id > 0 )
771 #show member-tab for notification if forum-notification is enabled in administration
772 if($ilAccess->checkAccess(
'write',
'', $this->ref_id))
774 $mem_active = array(
'showMembers',
'forums_notification_settings');
775 (in_array($_GET[
'cmd'],$mem_active)) ? $force_mem_active =
true : $force_mem_active =
false;
777 $ilTabs->addSubTabTarget(
'notifications', $this->ctrl->getLinkTarget($this,
'showMembers'), $_GET[
'cmd'], get_class($this),
'', $force_mem_active);
784 public function showStatisticsObject()
792 if(!$this->ilias->getSetting(
'enable_fora_statistics',
false))
794 $this->ilias->raiseError($this->lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
798 if(!$ilAccess->checkAccess(
'read',
'', $_GET[
'ref_id']))
800 $this->ilias->raiseError($this->lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
804 if(!$ilAccess->checkAccess(
'read',
'', $_GET[
'ref_id']) && !$this->objProperties->isStatisticEnabled())
806 $this->ilias->raiseError($this->lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
810 if($ilAccess->checkAccess(
'write',
'', $_GET[
'ref_id']) &&
811 !$this->objProperties->isStatisticEnabled())
813 ilUtil::sendInfo($this->lng->txt(
'frm_statistics_disabled_for_participants'));
816 $this->
object->Forum->setForumId($this->object->getId());
818 require_once
'Modules/Forum/classes/class.ilForumStatisticsTableGUI.php';
821 $tbl->setId(
'il_frm_statistic_table_'.(
int) $_GET[
'ref_id']);
822 $tbl->setTitle($this->lng->txt(
'statistic'),
'icon_usr_b.png', $this->lng->txt(
'obj_'.$this->object->getType()));
824 $data = $this->
object->Forum->getUserStatistic($this->is_moderator);
829 $result[$counter][
'ranking'] = $row[0];
830 $result[$counter][
'login'] = $row[1];
831 $result[$counter][
'lastname'] = $row[2];
832 $result[$counter][
'firstname'] = $row[3];
838 $this->tpl->setContent($tbl->getHTML());
841 public static function _goto($a_target, $a_thread = 0, $a_posting = 0)
850 if($ilAccess->checkAccess(
'read',
'', $a_target))
855 if ($objTopic->getFrmObjId() &&
861 if($ilAccess->checkAccess(
'read',
'', $ref_id))
868 if (isset($new_ref_id) && $new_ref_id != $a_target)
870 ilUtil::redirect(ILIAS_HTTP_PATH.
"/goto.php?target=frm_".$new_ref_id.
"_".$a_thread.
"_".$a_posting);
874 $_GET[
'ref_id'] = $a_target;
875 $_GET[
'pos_pk'] = $a_posting;
876 $_GET[
'thr_pk'] = $a_thread;
877 $_GET[
'anchor'] = $a_posting;
878 $_GET[
'cmdClass'] =
'ilObjForumGUI';
879 $_GET[
'cmd'] =
'viewThread';
880 $_GET[
'baseClass'] =
'ilRepositoryGUI';
882 include_once(
'ilias.php');
888 $_GET[
'ref_id'] = $a_target;
889 $_GET[
'baseClass'] =
'ilRepositoryGUI';
890 include_once(
'ilias.php');
894 else if($ilAccess->checkAccess(
'read',
'', ROOT_FOLDER_ID))
896 $_GET[
'target'] =
'';
897 $_GET[
'ref_id'] = ROOT_FOLDER_ID;
900 $_GET[
'baseClass'] =
'ilRepositoryGUI';
901 include(
'ilias.php');
905 $ilErr->raiseError($lng->txt(
'msg_no_perm_read'), $ilErr->FATAL);
908 public function performDeleteThreadsObject()
915 if(!$this->is_moderator)
917 $this->ilias->raiseError($lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
921 if(!isset(
$_POST[
'thread_ids']) || !is_array(
$_POST[
'thread_ids']))
927 require_once
'Modules/Forum/classes/class.ilForum.php';
928 require_once
'Modules/Forum/classes/class.ilObjForum.php';
932 $this->objProperties->setObjId($forumObj->
getId());
935 foreach(
$_POST[
'thread_ids'] as $topic_id)
937 $frm->setForumId($forumObj->
getId());
938 $frm->setForumRefId($forumObj->
getRefId());
940 $first_node = $frm->getFirstPostNode($topic_id);
941 if((
int)$first_node[
'pos_pk'])
943 $frm->deletePost($first_node[
'pos_pk']);
948 $this->ctrl->redirect($this,
'showThreads');
951 public function confirmDeleteThreads()
958 if(!isset(
$_POST[
'thread_ids']) || !is_array(
$_POST[
'thread_ids']))
964 if(!$this->is_moderator)
966 $this->ilias->raiseError($lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
970 include_once(
'Services/Utilities/classes/class.ilConfirmationGUI.php');
973 $c_gui->setFormAction($this->ctrl->getFormAction($this,
'performDeleteThreads'));
974 $c_gui->setHeaderText($this->lng->txt(
'frm_sure_delete_threads'));
975 $c_gui->setCancel($this->lng->txt(
'cancel'),
'showThreads');
976 $c_gui->setConfirm($this->lng->txt(
'confirm'),
'performDeleteThreads');
978 foreach((array)
$_POST[
'thread_ids'] as $thread_id)
983 $this->confirmation_gui_html = $c_gui->getHTML();
987 return $this->tpl->setContent($c_gui->getHTML());
990 public function prepareThreadScreen(
ilObjForum $a_forum_obj)
998 global
$tpl,
$lng, $ilTabs, $ilHelp;
1000 $ilHelp->setScreenIdComponent(
"frm");
1002 $tpl->getStandardTemplate();
1008 $ilTabs->setBackTarget($lng->txt(
'all_topics'),
1009 'ilias.php?baseClass=ilRepositoryGUI&ref_id='.$_GET[
'ref_id']);
1012 $this->ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
1013 $this->ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
1016 $ilTabs->addTarget(
'sort_by_posts', $this->ctrl->getLinkTarget($this,
'viewThread'));
1021 $this->ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
1022 $this->ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
1023 $ilTabs->addTarget(
'order_by_date', $this->ctrl->getLinkTarget($this,
'viewThread'));
1024 $this->ctrl->clearParameters($this);
1029 $ilTabs->setTabActive(
'order_by_date');
1033 $ilTabs->setTabActive(
'sort_by_posts');
1039 $frm = $a_forum_obj->Forum;
1040 $frm->setForumId($a_forum_obj->
getId());
1045 if($this->is_moderator)
1047 $this->objCurrentPost->activatePostAndChildPosts();
1048 ilUtil::sendInfo($this->lng->txt(
'forums_post_and_children_were_activated'),
true);
1051 $this->viewThreadObject();
1056 if($this->is_moderator)
1058 $this->objCurrentPost->activatePost();
1062 $this->viewThreadObject();
1067 $this->viewThreadObject();
1072 if($this->is_moderator)
1077 $this->viewThreadObject();
1082 $this->display_confirm_post_activation = $status;
1090 public function toggleThreadNotificationObject()
1097 if($this->objCurrentTopic->isNotificationEnabled($ilUser->getId()))
1099 $this->objCurrentTopic->disableNotification($ilUser->getId());
1104 $this->objCurrentTopic->enableNotification($ilUser->getId());
1108 $this->viewThreadObject();
1113 if($this->is_moderator)
1115 if($this->objCurrentTopic->isSticky())
1117 $this->objCurrentTopic->unmakeSticky();
1121 $this->objCurrentTopic->makeSticky();
1125 $this->viewThreadObject();
1130 $_GET[
'action'] =
'';
1132 $this->viewThreadObject();
1135 public function getDeleteFormHTML()
1143 $form_tpl =
new ilTemplate(
'tpl.frm_delete_post_form.html',
true,
true,
'Modules/Forum');
1145 $form_tpl->setVariable(
'ANKER', $this->objCurrentPost->getId());
1146 $form_tpl->setVariable(
'SPACER',
'<hr noshade="noshade" width="100%" size="1" align="center" />');
1147 $form_tpl->setVariable(
'TXT_DELETE', $lng->txt(
'forums_info_delete_post'));
1148 $this->ctrl->setParameter($this,
'action',
'ready_delete');
1149 $this->ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
1150 $this->ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
1151 $this->ctrl->setParameter($this,
'orderby', $_GET[
'orderby']);
1152 $form_tpl->setVariable(
'FORM_ACTION', $this->ctrl->getLinkTarget($this,
'viewThread'));
1153 $this->ctrl->clearParameters($this);
1154 $form_tpl->setVariable(
'CANCEL_BUTTON', $lng->txt(
'cancel'));
1155 $form_tpl->setVariable(
'CONFIRM_BUTTON', $lng->txt(
'confirm'));
1157 return $form_tpl->get();
1160 public function getActivationFormHTML()
1167 $form_tpl =
new ilTemplate(
'tpl.frm_activation_post_form.html',
true,
true,
'Modules/Forum');
1169 $this->ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
1170 $this->ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
1171 $this->ctrl->setParameter($this,
'orderby', $_GET[
'orderby']);
1172 $form_tpl->setVariable(
'FORM_ACTION', $this->ctrl->getFormAction($this,
'performPostActivation'));
1173 $form_tpl->setVariable(
'SPACER',
'<hr noshade="noshade" width="100%" size="1" align="center" />');
1174 $form_tpl->setVariable(
'ANCHOR', $this->objCurrentPost->getId());
1175 $form_tpl->setVariable(
'TXT_ACT', $lng->txt(
'activate_post_txt'));
1176 $form_tpl->setVariable(
'CONFIRM_BUTTON', $lng->txt(
'activate_only_current'));
1177 $form_tpl->setVariable(
'CMD_CONFIRM',
'performPostActivation');
1178 $form_tpl->setVariable(
'CONFIRM_BRANCH_BUTTON', $lng->txt(
'activate_current_and_childs'));
1179 $form_tpl->setVariable(
'CMD_CONFIRM_BRANCH',
'performPostAndChildPostsActivation');
1180 $form_tpl->setVariable(
'CANCEL_BUTTON',$lng->txt(
'cancel'));
1181 $form_tpl->setVariable(
'CMD_CANCEL',
'cancelPostActivation');
1182 $this->ctrl->clearParameters($this);
1184 return $form_tpl->get();
1187 public function getDeactivationFormHTML()
1194 $form_tpl =
new ilTemplate(
'tpl.frm_deactivation_post_form.html',
true,
true,
'Modules/Forum');
1196 $this->ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
1197 $this->ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
1198 $this->ctrl->setParameter($this,
'orderby', $_GET[
'orderby']);
1199 $form_tpl->setVariable(
'FORM_ACTION', $this->ctrl->getFormAction($this,
'performPostDeactivation'));
1200 $form_tpl->setVariable(
'SPACER',
'<hr noshade="noshade" width="100%" size="1" align="center" />');
1201 $form_tpl->setVariable(
'ANCHOR', $this->objCurrentPost->getId());
1202 $form_tpl->setVariable(
'TXT_DEACT', $lng->txt(
'deactivate_post_txt'));
1203 $form_tpl->setVariable(
'CONFIRM_BUTTON', $lng->txt(
'deactivate_current_and_childs'));
1204 $form_tpl->setVariable(
'CMD_CONFIRM',
'performPostDeactivation');
1205 $form_tpl->setVariable(
'CANCEL_BUTTON',$lng->txt(
'cancel'));
1206 $form_tpl->setVariable(
'CMD_CANCEL',
'cancelPostDeactivation');
1207 $this->ctrl->clearParameters($this);
1209 return $form_tpl->get();
1212 public function getCensorshipFormHTML()
1220 $form_tpl =
new ilTemplate(
'tpl.frm_censorship_post_form.html',
true,
true,
'Modules/Forum');
1222 $form_tpl->setVariable(
'ANCHOR', $this->objCurrentPost->getId());
1223 $form_tpl->setVariable(
'SPACER',
'<hr noshade="noshade" width="100%" size="1" align="center" />');
1224 $this->ctrl->setParameter($this,
'action',
'ready_censor');
1225 $this->ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
1226 $this->ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
1227 $this->ctrl->setParameter($this,
'orderby', $_GET[
'orderby']);
1228 $form_tpl->setVariable(
'FORM_ACTION', $this->ctrl->getLinkTarget($this,
'viewThread'));
1229 $this->ctrl->clearParameters($this);
1230 $form_tpl->setVariable(
'TXT_CENS_MESSAGE', $lng->txt(
'forums_the_post'));
1231 $form_tpl->setVariable(
'TXT_CENS_COMMENT', $lng->txt(
'forums_censor_comment').
':');
1232 $form_tpl->setVariable(
'CENS_MESSAGE', $frm->prepareText($this->objCurrentPost->getCensorshipComment(), 2));
1235 if($this->objCurrentPost->isCensored())
1237 $form_tpl->setVariable(
'TXT_CENS', $lng->txt(
'forums_info_censor2_post'));
1238 $form_tpl->setVariable(
'YES_BUTTON', $lng->txt(
'yes'));
1239 $form_tpl->setVariable(
'NO_BUTTON', $lng->txt(
'no'));
1243 $form_tpl->setVariable(
'TXT_CENS', $lng->txt(
'forums_info_censor_post'));
1244 $form_tpl->setVariable(
'CANCEL_BUTTON', $lng->txt(
'cancel'));
1245 $form_tpl->setVariable(
'CONFIRM_BUTTON', $lng->txt(
'confirm'));
1248 return $form_tpl->get();
1251 private function initReplyEditForm()
1265 $frm = $oForumObjects[
'frm'];
1269 $oFDForum = $oForumObjects[
'file_obj'];
1271 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
1272 $this->replyEditForm =
new ilPropertyFormGUI();
1273 $this->replyEditForm->setTableWidth(
'100%');
1276 if($_GET[
'action'] ==
'showreply' || $_GET[
'action'] ==
'ready_showreply')
1278 $this->ctrl->setParameter($this,
'action',
'ready_showreply');
1282 $this->ctrl->setParameter($this,
'action',
'ready_showedit');
1286 $this->ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
1287 $this->ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
1288 $this->ctrl->setParameter($this,
'offset', (
int)$_GET[
'offset']);
1289 $this->ctrl->setParameter($this,
'orderby', $_GET[
'orderby']);
1290 $this->replyEditForm->setFormAction($this->ctrl->getFormAction($this,
'savePost', $this->objCurrentPost->getId()));
1291 $this->ctrl->clearParameters($this);
1293 if($_GET[
'action'] ==
'showreply' || $_GET[
'action'] ==
'ready_showreply')
1295 $this->replyEditForm->setTitle($this->lng->txt(
'forums_your_reply'));
1299 $this->replyEditForm->setTitle($this->lng->txt(
'forums_edit_post'));
1303 if($this->objProperties->isAnonymized() &&
1304 in_array($_GET[
'action'], array(
'showreply',
'ready_showreply')))
1306 $oAnonymousNameGUI =
new ilTextInputGUI($this->lng->txt(
'forums_your_name'),
'alias');
1308 $oAnonymousNameGUI->setInfo($this->lng->txt(
'forums_use_alias'));
1310 $this->replyEditForm->addItem($oAnonymousNameGUI);
1314 $oSubjectGUI =
new ilTextInputGUI($this->lng->txt(
'forums_subject'),
'subject');
1316 $oSubjectGUI->setRequired(
true);
1318 if($this->objProperties->getSubjectSetting() ==
'empty_subject')
1319 $oSubjectGUI->setInfo($this->lng->txt(
'enter_new_subject'));
1321 $this->replyEditForm->addItem($oSubjectGUI);
1325 $_GET[
'action'] ==
'showreply' || $_GET[
'action'] ==
'ready_showreply' ? $this->lng->txt(
'forums_your_reply') : $this->lng->txt(
'forums_edit_post'),
1329 $oPostGUI->setCols(50);
1330 $oPostGUI->setRows(15);
1331 $oPostGUI->setUseRte(
true);
1332 $oPostGUI->addPlugin(
'latex');
1333 $oPostGUI->addButton(
'latex');
1334 $oPostGUI->addButton(
'pastelatex');
1335 $oPostGUI->addPlugin(
'ilfrmquote');
1338 if($_GET[
'action'] ==
'showreply' || $_GET[
'action'] ==
'ready_showreply')
1340 $oPostGUI->addButton(
'ilFrmQuoteAjaxCall');
1342 $oPostGUI->removePlugin(
'advlink');
1343 $oPostGUI->setRTERootBlockElement(
'');
1344 $oPostGUI->usePurifier(
true);
1345 $oPostGUI->disableButtons(array(
1362 if($_GET[
'action'] ==
'showreply' || $_GET[
'action'] ==
'ready_showreply')
1364 $oPostGUI->setRTESupport($ilUser->getId(),
'frm~',
'frm_post',
'tpl.tinymce_frm_post.html',
false,
'3.4.7');
1368 $oPostGUI->setRTESupport($this->objCurrentPost->getId(),
'frm',
'frm_post',
'tpl.tinymce_frm_post.html',
false,
'3.4.7');
1371 require_once
'Services/Html/classes/class.ilHtmlPurifierFactory.php';
1374 $this->replyEditForm->addItem($oPostGUI);
1377 include_once
'Services/Mail/classes/class.ilMail.php';
1378 $umail =
new ilMail($ilUser->getId());
1379 if($rbacsystem->checkAccess(
'internal_mail', $umail->getMailObjectReferenceId()) &&
1380 !$frm->isThreadNotificationEnabled($ilUser->getId(), $this->objCurrentPost->getThreadId()) &&
1381 !$this->objProperties->isAnonymized())
1384 $oNotificationGUI->setInfo($this->lng->txt(
'forum_notify_me'));
1386 $this->replyEditForm->addItem($oNotificationGUI);
1390 $oFileUploadGUI =
new ilFileWizardInputGUI($this->lng->txt(
'forums_attachments_add'),
'userfile');
1392 $this->replyEditForm->addItem($oFileUploadGUI);
1394 if ($ilUser->getId() == ANONYMOUS_USER_ID &&
1395 $ilSetting->get(
'activate_captcha_anonym'))
1397 include_once(
"./Services/Captcha/classes/class.ilCaptchaInputGUI.php");
1398 $captcha =
new ilCaptchaInputGUI($this->lng->txt(
"cont_captcha_code"),
'captcha_code');
1400 $this->replyEditForm->addItem($captcha);
1404 if(count($oFDForum->getFilesOfPost()) && ($_GET[
'action'] ==
'showedit' || $_GET[
'action'] ==
'ready_showedit'))
1408 foreach($oFDForum->getFilesOfPost() as
$file)
1411 $oAttachmentGUI->setValue(
$file[
'md5']);
1412 $oExistingAttachmentsGUI->addOption($oAttachmentGUI);
1414 $this->replyEditForm->addItem($oExistingAttachmentsGUI);
1418 $this->replyEditForm->addCommandButton(
'savePost', $this->lng->txt(
'submit'));
1419 if($_GET[
'action'] ==
'showreply' || $_GET[
'action'] ==
'ready_showreply')
1421 include_once
'Services/RTE/classes/class.ilRTE.php';
1424 if(array_key_exists(
'show_rte',
$_POST))
1431 $this->replyEditForm->addCommandButton(
'quotePost', $this->lng->txt(
'forum_add_quote'));
1434 $this->replyEditForm->addCommandButton(
'cancelPost', $this->lng->txt(
'cancel'));
1439 if(null === $this->replyEditForm)
1441 $this->initReplyEditForm();
1447 public function savePostObject()
1456 if(!isset(
$_POST[
'del_file']) || !is_array(
$_POST[
'del_file']))
$_POST[
'del_file'] = array();
1458 if($this->objCurrentTopic->isClosed())
1460 $_GET[
'action'] =
'';
1461 return $this->viewThreadObject();
1465 if($oReplyEditForm->checkInput())
1472 $forumObj = $oForumObjects[
'forumObj'];
1476 $frm = $oForumObjects[
'frm'];
1477 $frm->setMDB2WhereCondition(
' top_frm_fk = %s ', array(
'integer'), array($frm->getForumId()));
1478 $topicData = $frm->getOneTopic();
1481 if($_GET[
'action'] ==
'ready_showreply')
1483 if(!$ilAccess->checkAccess(
'add_reply',
'', (
int)$_GET[
'ref_id']))
1485 $this->ilias->raiseError($lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
1490 $send_activation_mail = 0;
1492 if($this->objProperties->isPostActivationEnabled())
1494 if(!$this->is_moderator)
1497 $send_activation_mail = 1;
1499 else if($this->objCurrentPost->isAnyParentDeactivated())
1505 if($this->objProperties->isAnonymized())
1507 if(!strlen($oReplyEditForm->getInput(
'alias')))
1509 $user_alias = $this->lng->txt(
'forums_anonymous');
1513 $user_alias = $oReplyEditForm->getInput(
'alias');
1518 $user_alias = $ilUser->getLogin();
1521 $newPost = $frm->generatePost(
1522 $topicData[
'top_pk'],
1523 $this->objCurrentTopic->getId(),
1524 ($this->objProperties->isAnonymized() ? 0 : $ilUser->getId()),
1526 $this->objCurrentPost->getId(),
1527 (int)$oReplyEditForm->getInput(
'notify'),
1532 $send_activation_mail
1536 $this->
object->markPostRead($ilUser->getId(), (int) $this->objCurrentTopic->getId(), (int) $this->objCurrentPost->getId());
1539 include_once
'Services/MediaObjects/classes/class.ilObjMediaObject.php';
1542 foreach($mediaObjects as $mob)
1544 foreach($myMediaObjects as $myMob)
1557 $file = $_FILES[
'userfile'];
1558 if(is_array($file) && !empty($file))
1560 $oFDForum->storeUploadedFile($file);
1564 if ($this->ilias->getSetting(
"forum_notification") == 1 && (int)$status )
1566 $objPost =
new ilForumPost((
int)$newPost, $this->is_moderator);
1568 $post_data = array();
1569 $post_data = $objPost->getDataAsArray();
1571 $post_data[
"top_name"] = $titles[0];
1572 $post_data[
"ref_id"] = $this->
object->getRefId();
1574 $frm->__sendMessage($objPost->getParentId(), $post_data);
1576 $frm->sendForumNotifications($post_data);
1577 $frm->sendThreadNotifications($post_data);
1581 if(!$this->is_moderator && !$status)
1583 $message .= $lng->txt(
'forums_post_needs_to_be_activated');
1587 $message .= $lng->txt(
'forums_post_new_entry');
1590 $_SESSION[
'frm'][(int)$_GET[
'thr_pk']][
'openTreeNodes'][] = (
int)$this->objCurrentPost->getId();
1592 ilUtil::sendSuccess($message, true);
1593 $this->ctrl->setParameter($this, 'pos_pk', $newPost);
1594 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
1595 $this->ctrl->redirect($this, 'viewThread');
1599 if((!$this->is_moderator &&
1600 !$this->objCurrentPost->isOwner($ilUser->getId())) || $this->objCurrentPost->isCensored() ||
1601 $ilUser->getId() == ANONYMOUS_USER_ID)
1603 $this->ilias->raiseError($lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
1607 include_once
'Services/MediaObjects/classes/class.ilObjMediaObject.php';
1610 foreach($oldMediaObjects as $oldMob)
1613 foreach($curMediaObjects as $curMob)
1615 if($oldMob == $curMob)
1634 $send_activation_mail = 0;
1636 if($this->objProperties->isPostActivationEnabled())
1638 if(!$this->is_moderator)
1641 $send_activation_mail = 1;
1643 else if($this->objCurrentPost->isAnyParentDeactivated())
1648 $this->objCurrentPost->setStatus($status);
1650 $this->objCurrentPost->setSubject($this->
handleFormInput($oReplyEditForm->getInput(
'subject'),
false));
1652 $this->objCurrentPost->setNotification((
int)$oReplyEditForm->getInput(
'notify'));
1653 $this->objCurrentPost->setChangeDate(date(
'Y-m-d H:i:s'));
1654 $this->objCurrentPost->setUpdateUserId($ilUser->getId());
1657 if($this->objCurrentPost->update())
1659 $this->objCurrentPost->reload();
1662 include_once
'Services/News/classes/class.ilNewsItem.php';
1665 'frm', $this->objCurrentPost->getId(),
'pos');
1669 $news_item->setTitle($this->objCurrentPost->getSubject());
1671 $this->objCurrentPost->getMessage(), 0), 1)
1673 $news_item->update();
1677 $oFDForum = $oForumObjects[
'file_obj'];
1679 $file = $_FILES[
'userfile'];
1680 if(is_array($file) && !empty($file))
1685 $file2delete = $oReplyEditForm->getInput(
'del_file');
1686 if(is_array($file2delete) && count($file2delete))
1688 $oFDForum->unlinkFilesByMD5Filenames($file2delete);
1692 if (!$status && $send_activation_mail)
1694 $pos_data = $this->objCurrentPost->getDataAsArray();
1695 $pos_data[
"top_name"] = $this->
object->getTitle();
1696 $frm->sendPostActivationNotification($pos_data);
1700 $this->ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
1701 $this->ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
1702 $this->ctrl->setParameter($this,
'viewmode',
$_SESSION[
'viewmode']);
1703 $this->ctrl->redirect($this,
'viewThread');
1708 $_GET[
'action'] = substr($_GET[
'action'], 6);
1710 return $this->viewThreadObject();
1715 if(null === $a_flag)
1726 if(!is_array(
$_POST[
'del_file']))
$_POST[
'del_file'] = array();
1728 if($this->objCurrentTopic->isClosed())
1730 $_GET[
'action'] =
'';
1731 return $this->viewThreadObject();
1737 $oReplyEditForm->getItemByPostVar(
'subject')->setRequired(
false);
1738 $oReplyEditForm->getItemByPostVar(
'message')->setRequired(
false);
1740 $oReplyEditForm->checkInput();
1743 $oReplyEditForm->getItemByPostVar(
'subject')->setRequired(
true);
1744 $oReplyEditForm->getItemByPostVar(
'message')->setRequired(
true);
1746 $_GET[
'action'] =
'showreply';
1748 $this->viewThreadObject();
1751 public function getQuotationHTMLAsynchObject()
1757 $frm = $oForumObjects[
'frm'];
1759 require_once
'Modules/Forum/classes/class.ilForumAuthorInformation.php';
1761 $this->objCurrentPost->getUserId(),
1762 $this->objCurrentPost->getUserAlias(),
1763 $this->objCurrentPost->getImportName()
1773 if(null === $this->forumObjects)
1777 $frm = $forumObj->Forum;
1778 $frm->setForumId($forumObj->
getId());
1779 $frm->setForumRefId($forumObj->
getRefId());
1781 $this->forumObjects[
'forumObj'] = $forumObj;
1782 $this->forumObjects[
'frm'] = $frm;
1783 $this->forumObjects[
'file_obj'] = $file_obj;
1791 include_once
'Modules/Forum/classes/class.ilForumExplorer.php';
1795 $this->objCurrentTopic,
1796 $this->objProperties
1799 return $explorer->render()->getHtml();
1804 include_once
'Services/JSON/classes/class.ilJsonUtil.php';
1805 include_once
'Modules/Forum/classes/class.ilForumExplorer.php';
1807 $response =
new stdClass();
1808 $response->success =
false;
1810 if( $_GET[
'nodeId'] )
1812 $response->success =
true;
1813 $response->children = array();
1815 $key = array_search((
int)$_GET[
'nodeId'], (array)
$_SESSION[
'frm'][(
int)$_GET[
'thr_pk']][
'openTreeNodes']);
1816 if(
false === $key )
1818 $_SESSION[
'frm'][(int)$_GET[
'thr_pk']][
'openTreeNodes'][] = (
int)$_GET[
'nodeId'];
1821 $children = $this->objCurrentTopic->getNestedSetPostChildren(
1822 (
int)$_GET[
'nodeId'],
1823 (array)
$_SESSION[
'frm'][(
int)$_GET[
'thr_pk']][
'openTreeNodes']
1827 $pageHits = $frm->getPageHits();
1829 $fetchedNodes = array();
1831 foreach( $children as $child )
1833 if($child[
'parent_pos'] != (
int)$_GET[
'nodeId'] &&
1834 !in_array($child[
'parent_pos'], $fetchedNodes))
1839 $fetchedNodes[] = $child[
'pos_pk'];
1841 $this->ctrl->setParameter($this,
'thr_pk', (
int)$_GET[
'thr_pk']);
1849 $responseChild =
new stdClass();
1850 $responseChild->nodeId = $child[
'pos_pk'];
1851 $responseChild->parentId = $child[
'parent_pos'];
1852 $responseChild->hasChildren = ($child[
'children'] >= 1);
1853 $responseChild->fetchedWithChildren = in_array((
int)$child[
'pos_pk'], (array)
$_SESSION[
'frm'][(
int)$_GET[
'thr_pk']][
'openTreeNodes']);
1854 $responseChild->html = $html;
1856 $response->children[] = $responseChild;
1866 include_once
'Services/JSON/classes/class.ilJsonUtil.php';
1868 $response =
new stdClass();
1869 $response->success =
true;
1871 if( $_GET[
'nodeId'] )
1873 if( $_GET[
'nodeId'] > 0 )
1875 $key = array_search((
int)$_GET[
'nodeId'], (array)
$_SESSION[
'frm'][(
int)$_GET[
'thr_pk']][
'openTreeNodes']);
1876 if(
false === $key )
1878 $_SESSION[
'frm'][(int)$_GET[
'thr_pk']][
'openTreeNodes'][] = (
int)$_GET[
'nodeId'];
1883 $key = array_search((
int)abs($_GET[
'nodeId']), (array)
$_SESSION[
'frm'][(
int)$_GET[
'thr_pk']][
'openTreeNodes']);
1884 if(
false !== $key )
1886 unset(
$_SESSION[
'frm'][(
int)$_GET[
'thr_pk']][
'openTreeNodes'][$key]);
1892 shuffle(
$_SESSION[
'frm'][(
int)$_GET[
'thr_pk']][
'openTreeNodes']);
1896 public function viewThreadObject()
1908 global
$tpl,
$lng,
$ilUser, $ilAccess, $rbacreview, $ilNavigationHistory,
$ilCtrl, $frm, $ilToolbar, $ilLocator;
1910 $tpl->addCss(
'./Modules/Forum/css/forum_tree.css');
1913 $_SESSION[
'viewmode'] = $this->objProperties->getDefaultView();
1917 if(!isset(
$_SESSION[
'thread_control'][
'old']))
1919 $_SESSION[
'thread_control'][
'old'] = $_GET[
'thr_pk'];
1920 $_SESSION[
'thread_control'][
'new'] = $_GET[
'thr_pk'];
1923 if(isset(
$_SESSION[
'thread_control'][
'old']) && $_GET[
'thr_pk'] !=
$_SESSION[
'thread_control'][
'old'])
1925 $_SESSION[
'thread_control'][
'new'] = $_GET[
'thr_pk'];
1928 if(isset($_GET[
'viewmode']) && $_GET[
'viewmode'] !=
$_SESSION[
'viewmode'])
1930 $_SESSION[
'viewmode'] = $_GET[
'viewmode'];
1943 if(!$ilAccess->checkAccess(
'read',
'', $this->object->getRefId()))
1945 $this->ilias->raiseError($lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
1953 $forumObj = $oForumObjects[
'forumObj'];
1957 $frm = $oForumObjects[
'frm'];
1961 $file_obj = $oForumObjects[
'file_obj'];
1966 if(!
$path = $file_obj->getFileDataByMD5Filename($_GET[
'file']))
1976 if(!$this->objCurrentTopic->getId())
1978 $ilCtrl->redirect($this,
'showThreads');
1982 $append =
'_'.$this->objCurrentTopic->getId().
1983 ($this->objCurrentPost->getId() ?
'_'.$this->objCurrentPost->getId() :
'');
1984 $tpl->setLoginTargetPar(
'frm_'.$_GET[
'ref_id'].$append);
1987 if($_GET[
'action'] !=
'showreply' && $_GET[
'action'] !=
'showedit')
1991 include_once
'Services/MediaObjects/classes/class.ilObjMediaObject.php';
1993 foreach(
$mobs as $mob)
2008 require_once
'./Modules/Forum/classes/class.ilObjForum.php';
2009 require_once
'./Modules/Forum/classes/class.ilFileDataForum.php';
2011 $lng->loadLanguageModule(
'forum');
2015 $ilAccess->checkAccess(
'read',
'', $this->object->getRefId()))
2017 $ilCtrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
2018 $ilNavigationHistory->addItem($this->object->getRefId(), $ilCtrl->getLinkTarget($this,
'showThreads'),
'frm');
2022 $forumObj->updateLastAccess($ilUser->getId(), (int) $this->objCurrentTopic->getId());
2024 $this->prepareThreadScreen($forumObj);
2026 $tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.forums_threads_view.html',
'Modules/Forum');
2028 if(isset($_GET[
'anchor']))
2030 $tpl->setVariable(
'JUMP2ANCHOR_ID', (
int)$_GET[
'anchor']);
2036 $orderField =
'frm_posts_tree.fpt_date';
2037 $this->objCurrentTopic->setOrderDirection(
2044 $orderField =
'frm_posts_tree.rgt';
2045 $this->objCurrentTopic->setOrderDirection(
'DESC');
2049 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', array(
'integer'), array($frm->getForumId()));
2051 if(is_array($topicData = $frm->getOneTopic()))
2054 $this->objCurrentTopic->updateVisits();
2056 $tpl->setTitle($lng->txt(
'forums_thread').
" \"".$this->objCurrentTopic->getSubject().
"\"");
2060 $ilLocator->addRepositoryItems();
2061 $ilLocator->addItem($this->object->getTitle(), $ilCtrl->getLinkTarget($this,
""),
"_top");
2067 $menutpl =
new ilTemplate(
'tpl.forums_threads_menu.html',
true,
true,
'Modules/Forum');
2069 include_once(
"./Services/Accessibility/classes/class.ilAccessKeyGUI.php");
2072 if($ilUser->getId() != ANONYMOUS_USER_ID &&
2073 $forumObj->getCountUnread($ilUser->getId(), (int) $this->objCurrentTopic->getId()))
2075 $this->ctrl->setParameter($this,
'mark_read',
'1');
2076 $this->ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
2077 $ilToolbar->addButton(
2078 $this->lng->txt(
'forums_mark_read'),
2079 $this->ctrl->getLinkTarget($this,
'viewThread'),
2083 $this->ctrl->clearParameters($this);
2087 $this->ctrl->setParameterByClass(
'ilforumexportgui',
'print_thread', $this->objCurrentTopic->getId());
2088 $this->ctrl->setParameterByClass(
'ilforumexportgui',
'thr_top_fk', $this->objCurrentTopic->getForumId());
2089 $ilToolbar->addButton($this->lng->txt(
'forums_print_thread'),
2090 $this->ctrl->getLinkTargetByClass(
'ilforumexportgui',
'printThread')
2092 $this->ctrl->clearParametersByClass(
'ilforumexportgui');
2096 if($_GET[
'mark_read'])
2098 $forumObj->markThreadRead($ilUser->getId(), (int)$this->objCurrentTopic->getId());
2103 require_once
'./Modules/Forum/classes/class.ilForum.php';
2105 if ($_GET[
'action'] ==
'ready_delete' &&
$_POST[
'confirm'] !=
'')
2107 if(!$this->objCurrentTopic->isClosed() &&
2108 ($this->is_moderator ||
2109 ($this->objCurrentPost->isOwner($ilUser->getId()) && !$this->objCurrentPost->hasReplies())) &&
2110 $ilUser->getId() != ANONYMOUS_USER_ID)
2114 $frm->setForumId($forumObj->
getId());
2115 $frm->setForumRefId($forumObj->
getRefId());
2117 $dead_thr = $frm->deletePost($this->objCurrentPost->getId());
2120 if ($dead_thr == $this->objCurrentTopic->getId())
2123 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', array(
'integer'), array($forumObj->
getId()));
2125 $topicData = $frm->getOneTopic();
2129 if ($topicData[
'top_num_threads'] > 0)
2131 $this->ctrl->redirect($this,
'showThreads');
2135 $this->ctrl->redirect($this,
'createThread');
2143 if(!$this->objCurrentTopic->isClosed() && $_GET[
'action'] ==
'ready_censor')
2145 if((
$_POST[
'confirm'] !=
'' ||
$_POST[
'no_cs_change'] !=
'') && $_GET[
'action'] ==
'ready_censor')
2147 $frm->postCensorship($this->
handleFormInput(
$_POST[
'formData'][
'cens_message']), $this->objCurrentPost->getId(), 1);
2149 else if((
$_POST[
'cancel'] !=
'' ||
$_POST[
'yes_cs_change'] !=
'') && $_GET[
'action'] ==
'ready_censor')
2151 $frm->postCensorship($this->
handleFormInput(
$_POST[
'formData'][
'cens_message']), $this->objCurrentPost->getId());
2156 $first_node = $this->objCurrentTopic->getFirstPostNode();
2157 $this->objCurrentTopic->setOrderField($orderField);
2158 $subtree_nodes = $this->objCurrentTopic->getPostTree($first_node);
2161 if (!$posNum = count($subtree_nodes))
2166 $pageHits = $frm->getPageHits();
2171 if ($posNum > $pageHits)
2174 'ref_id' => $_GET[
'ref_id'],
2175 'thr_pk' => $this->objCurrentTopic->getId(),
2176 'orderby' => $_GET[
'orderby']
2179 if (!$_GET[
'offset'])
2185 $Start = $_GET[
'offset'];
2188 $linkbar =
ilUtil::Linkbar($ilCtrl->getLinkTarget($this,
'viewThread'), $posNum, $pageHits, $Start, $params);
2192 $menutpl->setCurrentBlock(
'linkbar');
2193 $menutpl->setVariable(
'LINKBAR', $linkbar);
2194 $menutpl->parseCurrentBlock();
2198 $tpl->setVariable(
'THREAD_MENU', $menutpl->get());
2204 foreach($subtree_nodes as $node)
2210 $this->ctrl->clearParameters($this);
2212 if($this->objCurrentPost->getId() && $this->objCurrentPost->getId() == $node->getId())
2217 if ($posNum > $pageHits && $z >= ($Start + $pageHits))
2220 if ($this->objCurrentPost->getId() && $jump < 1)
2222 $this->ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
2223 $this->ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2224 $this->ctrl->setParameter($this,
'offset', ($Start + $pageHits));
2225 $this->ctrl->setParameter($this,
'orderby', $_GET[
'orderby']);
2226 $this->ctrl->redirect($this,
'viewThread', $this->objCurrentPost->getId());
2235 if(($posNum > $pageHits && $z >= $Start) || $posNum <= $pageHits)
2237 if($this->objCurrentPost->getId() == $node->getId())
2239 # actions for "active" post
2240 if($this->is_moderator || $node->isActivated())
2243 if(!$this->objCurrentTopic->isClosed() && ($_GET[
'action'] ==
'showreply' || $_GET[
'action'] ==
'showedit'))
2245 if($_GET[
'action'] ==
'showedit' &&
2246 ((!$this->is_moderator &&
2247 !$node->isOwner($ilUser->getId()) || $ilUser->getId() == ANONYMOUS_USER_ID) || $node->isCensored()))
2249 $this->ilias->raiseError($lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
2251 else if($_GET[
'action'] ==
'showreply' && !$ilAccess->checkAccess(
'add_reply',
'', (
int)$_GET[
'ref_id']))
2253 $this->ilias->raiseError($lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
2256 $tpl->setVariable(
'REPLY_ANKER', $this->objCurrentPost->getId());
2259 switch($this->objProperties->getSubjectSetting())
2261 case 'add_re_to_subject':
2265 case 'preset_subject':
2266 $subject = $this->objCurrentPost->getSubject();
2269 case 'empty_subject':
2275 switch($_GET[
'action'])
2278 if($this->ctrl->getCmd() ==
'savePost')
2280 $oEditReplyForm->setValuesByPost();
2282 else if($this->ctrl->getCmd() ==
'quotePost')
2284 require_once
'Modules/Forum/classes/class.ilForumAuthorInformation.php';
2287 $node->getUserAlias(),
2288 $node->getImportName()
2291 $oEditReplyForm->setValuesByPost();
2292 $oEditReplyForm->getItemByPostVar(
'message')->setValue(
2294 $frm->prepareText($node->getMessage(), 1, $authorinfo->getAuthorName()).
"\n".$oEditReplyForm->getInput(
'message'), 1
2300 $oEditReplyForm->setValuesByArray(array(
2302 'subject' => $subject,
2306 'del_file' => array()
2310 $this->ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2311 $this->ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2313 $jsTpl =
new ilTemplate(
'tpl.forum_post_quoation_ajax_handler.html',
true,
true,
'Modules/Forum/');
2314 $jsTpl->setVariable(
'IL_FRM_QUOTE_CALLBACK_SRC',
2315 $this->ctrl->getLinkTarget($this,
'getQuotationHTMLAsynch',
'',
true));
2316 $this->ctrl->clearParameters($this);
2317 $this->tpl->setVariable(
'FORM_ADDITIONAL_JS', $jsTpl->get());
2320 if($this->ctrl->getCmd() ==
'savePost')
2322 $oEditReplyForm->setValuesByPost();
2326 $oEditReplyForm->setValuesByArray(array(
2328 'subject' => $this->objCurrentPost->getSubject(),
2330 'notify' => $this->objCurrentPost->isNotificationEnabled() ?
true :
false,
2332 'del_file' => array()
2337 $this->ctrl->setParameter($this,
'pos_pk', $this->objCurrentPost->getId());
2338 $this->ctrl->setParameter($this,
'thr_pk', $this->objCurrentPost->getThreadId());
2339 $this->ctrl->setParameter($this,
'offset', (
int)$_GET[
'offset']);
2340 $this->ctrl->setParameter($this,
'orderby', $_GET[
'orderby']);
2341 $this->ctrl->setParameter($this,
'action', $_GET[
'action']);
2342 $tpl->setVariable(
'FORM', $oEditReplyForm->getHTML());
2343 $this->ctrl->clearParameters($this);
2346 else if(!$this->objCurrentTopic->isClosed() && $_GET[
'action'] ==
'delete')
2348 if($this->is_moderator ||
2349 ($node->isOwner($ilUser->getId()) && !$node->hasReplies()) &&
2350 $ilUser->getId() != ANONYMOUS_USER_ID)
2353 $tpl->setVariable(
'FORM', $this->getDeleteFormHTML());
2356 else if(!$this->objCurrentTopic->isClosed() && $_GET[
'action'] ==
'censor')
2358 if($this->is_moderator)
2361 $tpl->setVariable(
'FORM', $this->getCensorshipFormHTML());
2366 if ($this->is_moderator)
2369 $tpl->setVariable(
'FORM', $this->getActivationFormHTML());
2375 if ($this->objCurrentPost->getId() != $node->getId() ||
2376 ($_GET[
'action'] !=
'showreply' &&
2377 $_GET[
'action'] !=
'showedit' &&
2378 $_GET[
'action'] !=
'censor' &&
2379 $_GET[
'action'] !=
'delete' &&
2380 #!$this->displayConfirmPostDeactivation() &&
2384 if($this->is_moderator || $node->isActivated())
2387 if(!$this->objCurrentTopic->isClosed() &&
2388 $ilAccess->checkAccess(
'add_reply',
'', (
int)$_GET[
'ref_id']) &&
2389 !$node->isCensored()
2392 $tpl->setCurrentBlock(
'commands');
2393 $this->ctrl->setParameter($this,
'action',
'showreply');
2394 $this->ctrl->setParameter($this,
'pos_pk', $node->getId());
2395 $this->ctrl->setParameter($this,
'offset', $Start);
2396 $this->ctrl->setParameter($this,
'orderby', $_GET[
'orderby']);
2397 $this->ctrl->setParameter($this,
'thr_pk', $node->getThreadId());
2398 $tpl->setVariable(
'COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this,
'viewThread', $node->getId()));
2399 $tpl->setVariable(
'COMMANDS_TXT', $lng->txt(
'reply'));
2400 $this->ctrl->clearParameters($this);
2401 $tpl->parseCurrentBlock();
2405 if (!$this->objCurrentTopic->isClosed() &&
2406 ($node->isOwner($ilUser->getId()) || $this->is_moderator) &&
2407 !$node->isCensored() &&
2408 $ilUser->getId() != ANONYMOUS_USER_ID)
2410 $tpl->setCurrentBlock(
'commands');
2411 $this->ctrl->setParameter($this,
'action',
'showedit');
2412 $this->ctrl->setParameter($this,
'pos_pk', $node->getId());
2413 $this->ctrl->setParameter($this,
'thr_pk', $node->getThreadId());
2414 $this->ctrl->setParameter($this,
'offset', $Start);
2415 $this->ctrl->setParameter($this,
'orderby', $_GET[
'orderby']);
2416 $tpl->setVariable(
'COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this,
'viewThread', $node->getId()));
2417 $tpl->setVariable(
'COMMANDS_TXT', $lng->txt(
'edit'));
2418 $this->ctrl->clearParameters($this);
2419 $tpl->parseCurrentBlock();
2423 if (!$node->isCensored())
2425 $tpl->setCurrentBlock(
'commands');
2426 $this->ctrl->setParameterByClass(
'ilforumexportgui',
'print_post', $node->getId());
2427 $this->ctrl->setParameterByClass(
'ilforumexportgui',
'top_pk', $node->getForumId());
2428 $this->ctrl->setParameterByClass(
'ilforumexportgui',
'thr_pk', $node->getThreadId());
2429 $tpl->setVariable(
'COMMANDS_COMMAND', $this->ctrl->getLinkTargetByClass(
'ilforumexportgui',
'printPost'));
2430 $tpl->setVariable(
'COMMANDS_TXT', $lng->txt(
'print'));
2431 $this->ctrl->clearParameters($this);
2432 $tpl->parseCurrentBlock();
2435 # buttons for every post except the "active"
2436 if (!$this->objCurrentTopic->isClosed() &&
2437 ($this->is_moderator ||
2438 ($node->isOwner($ilUser->getId()) && !$node->hasReplies())) &&
2439 $ilUser->getId() != ANONYMOUS_USER_ID)
2442 $tpl->setCurrentBlock(
'commands');
2443 $this->ctrl->setParameter($this,
'action',
'delete');
2444 $this->ctrl->setParameter($this,
'pos_pk', $node->getId());
2445 $this->ctrl->setParameter($this,
'thr_pk', $node->getThreadId());
2446 $this->ctrl->setParameter($this,
'offset', $Start);
2447 $this->ctrl->setParameter($this,
'orderby', $_GET[
'orderby']);
2448 $tpl->setVariable(
'COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this,
'viewThread', $node->getId()));
2449 $tpl->setVariable(
'COMMANDS_TXT', $lng->txt(
'delete'));
2450 $this->ctrl->clearParameters($this);
2451 $tpl->parseCurrentBlock();
2457 $tpl->setCurrentBlock(
'commands');
2458 $this->ctrl->setParameter($this,
'action',
'censor');
2459 $this->ctrl->setParameter($this,
'pos_pk', $node->getId());
2460 $this->ctrl->setParameter($this,
'thr_pk', $node->getThreadId());
2461 $this->ctrl->setParameter($this,
'offset', $Start);
2462 $this->ctrl->setParameter($this,
'orderby', $_GET[
'orderby']);
2463 $tpl->setVariable(
'COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this,
'viewThread', $node->getId()));
2464 $tpl->setVariable(
'COMMANDS_TXT', $lng->txt(
'censorship'));
2465 $this->ctrl->clearParameters($this);
2466 $tpl->parseCurrentBlock();
2469 $tpl->setCurrentBlock(
'commands');
2470 $this->ctrl->setParameter($this,
'pos_pk', $node->getId());
2471 $this->ctrl->setParameter($this,
'thr_pk', $node->getThreadId());
2472 $this->ctrl->setParameter($this,
'offset', $Start);
2473 $this->ctrl->setParameter($this,
'orderby', $_GET[
'orderby']);
2475 if (!$node->isActivated())
2477 $tpl->setVariable(
'COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this,
'askForPostActivation', $node->getId()));
2478 $tpl->setVariable(
'COMMANDS_TXT', $lng->txt(
'activate_post'));
2480 $this->ctrl->clearParameters($this);
2481 $tpl->parseCurrentBlock();
2485 if ($ilUser->getId() != ANONYMOUS_USER_ID &&
2486 !$node->isPostRead())
2488 $tpl->setCurrentBlock(
'commands');
2489 $this->ctrl->setParameter($this,
'pos_pk', $node->getId());
2490 $this->ctrl->setParameter($this,
'thr_pk', $node->getThreadId());
2491 $this->ctrl->setParameter($this,
'offset', $Start);
2492 $this->ctrl->setParameter($this,
'orderby', $_GET[
'orderby']);
2493 $this->ctrl->setParameter($this,
'viewmode',
$_SESSION[
'viewmode']);
2494 $tpl->setVariable(
'COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this,
'markPostRead', $node->getId()));
2495 $tpl->setVariable(
'COMMANDS_TXT', $lng->txt(
'is_read'));
2496 $this->ctrl->clearParameters($this);
2497 $tpl->parseCurrentBlock();
2501 if ($ilUser->getId() != ANONYMOUS_USER_ID &&
2502 $node->isPostRead())
2504 $tpl->setCurrentBlock(
'commands');
2505 $this->ctrl->setParameter($this,
'pos_pk', $node->getId());
2506 $this->ctrl->setParameter($this,
'thr_pk', $node->getThreadId());
2507 $this->ctrl->setParameter($this,
'offset', $Start);
2508 $this->ctrl->setParameter($this,
'orderby', $_GET[
'orderby']);
2509 $this->ctrl->setParameter($this,
'viewmode',
$_SESSION[
'viewmode']);
2510 $tpl->setVariable(
'COMMANDS_COMMAND', $this->ctrl->getLinkTarget($this,
'markPostUnread', $node->getId()));
2511 $tpl->setVariable(
'COMMANDS_TXT', $lng->txt(
'unread'));
2512 $this->ctrl->clearParameters($this);
2513 $tpl->parseCurrentBlock();
2520 if (count($tmp_file_obj->getFilesOfPost()))
2522 if ($node->getId() != $this->objCurrentPost->getId() || $_GET[
'action'] !=
'showedit')
2524 foreach ($tmp_file_obj->getFilesOfPost() as
$file)
2526 $tpl->setCurrentBlock(
'attachment_download_row');
2527 $this->ctrl->setParameter($this,
'pos_pk', $node->getId());
2528 $this->ctrl->setParameter($this,
'file', $file[
'md5']);
2529 $tpl->setVariable(
'HREF_DOWNLOAD', $this->ctrl->getLinkTarget($this,
'viewThread'));
2530 $tpl->setVariable(
'TXT_FILENAME', $file[
'name']);
2531 $this->ctrl->clearParameters($this);
2532 $tpl->parseCurrentBlock();
2534 $tpl->setCurrentBlock(
'attachments');
2535 $tpl->setVariable(
'TXT_ATTACHMENTS_DOWNLOAD',$lng->txt(
'forums_attachments'));
2537 $tpl->setVariable(
'TXT_DOWNLOAD_ATTACHMENT', $lng->txt(
'forums_download_attachment'));
2538 $tpl->parseCurrentBlock();
2542 $tpl->setCurrentBlock(
'posts_row');
2545 $tpl->setVariable(
'POST_ANKER', $node->getId());
2549 $tpl->setVariable(
'TXT_PERMA_LINK', $lng->txt(
'perma_link'));
2550 $tpl->setVariable(
'PERMA_TARGET',
'_top');
2552 if($this->objProperties->getMarkModeratorPosts() == 1)
2557 $rowCol =
'ilHighlighted';
2562 if (( $_GET[
'action'] !=
'delete' && $_GET[
'action'] !=
'censor' &&
2563 #!$this->displayConfirmPostDeactivation() &&
2566 || $this->objCurrentPost->getId() != $node->getId())
2568 $tpl->setVariable(
'ROWCOL',
' '.$rowCol);
2573 $rowCol =
'tblrowmarked';
2577 if ($node->isCensored())
2580 if ($_GET[
'action'] !=
'censor')
2582 $tpl->setVariable(
'TXT_CENSORSHIP_ADVICE', $this->lng->txt(
'post_censored_comment_by_moderator'));
2586 $rowCol =
'tblrowmarked';
2590 $tpl->setVariable(
'ROWCOL',
' '.$rowCol);
2592 if(!$node->isActivated() && $node->isOwner($ilUser->getId()))
2594 $tpl->setVariable(
'POST_NOT_ACTIVATED_YET', $this->lng->txt(
'frm_post_not_activated_yet'));
2599 $this->ctrl->setParameter($this,
'pos_pk', $node->getId());
2600 $this->ctrl->setParameter($this,
'thr_pk', $node->getThreadId());
2601 $backurl = urlencode($this->ctrl->getLinkTarget($this,
'viewThread', $node->getId()));
2602 $this->ctrl->clearParameters($this);
2604 $this->ctrl->setParameter($this,
'backurl', $backurl);
2605 $this->ctrl->setParameter($this,
'thr_pk', $node->getThreadId());
2606 $this->ctrl->setParameter($this,
'user', $node->getUserId());
2608 require_once
'Modules/Forum/classes/class.ilForumAuthorInformation.php';
2611 $node->getUserAlias(),
2612 $node->getImportName(),
2614 'href' => $this->ctrl->getLinkTarget($this,
'showUser')
2618 $this->ctrl->clearParameters($this);
2620 $tpl->setVariable(
'AUTHOR', $authorinfo->getLinkedAuthorShortName());
2621 if($authorinfo->getAuthorName(
true))
2623 $tpl->setVariable(
'USR_NAME', $authorinfo->getAuthorName(
true));
2626 $tpl->setVariable(
'USR_IMAGE', $authorinfo->getProfilePicture());
2627 if($authorinfo->getAuthor()->getId() &&
ilForum::_isModerator((
int)$_GET[
'ref_id'], $authorinfo->getAuthor()->getId()))
2629 if($authorinfo->getAuthor()->getGender() ==
'f')
2631 $tpl->setVariable(
'ROLE', $this->lng->txt(
'frm_moderator_f'));
2633 else if($authorinfo->getAuthor()->getGender() ==
'm')
2635 $tpl->setVariable(
'ROLE', $this->lng->txt(
'frm_moderator_m'));
2640 if ($node->getUpdateUserId() > 0)
2645 $posMod = $frm->getModeratorFromPost($node->getId());
2647 if (is_array($posMod) && $posMod[
'top_mods'] > 0)
2649 $MODS = $rbacreview->assignedUsers($posMod[
'top_mods']);
2651 if (is_array($MODS))
2653 if (in_array($node->getUpdateUserId(), $MODS))
2654 $spanClass =
'moderator_small';
2658 $node->setChangeDate($node->getChangeDate());
2660 if ($spanClass ==
'') $spanClass =
'small';
2662 $this->ctrl->setParameter($this,
'backurl', $backurl);
2663 $this->ctrl->setParameter($this,
'thr_pk', $node->getThreadId());
2664 $this->ctrl->setParameter($this,
'user', $node->getUpdateUserId());
2666 require_once
'Modules/Forum/classes/class.ilForumAuthorInformation.php';
2668 $node->getUpdateUserId(),
2672 'href' => $this->ctrl->getLinkTarget($this,
'showUser')
2676 $this->ctrl->clearParameters($this);
2678 $tpl->setVariable(
'POST_UPDATE_TXT', $lng->txt(
'edited_on').
': '.$frm->convertDate($node->getChangeDate()).
' - '.strtolower($lng->txt(
'by')));
2679 $tpl->setVariable(
'UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
2680 if($authorinfo->getAuthorName(
true))
2682 $tpl->setVariable(
'UPDATE_USR_NAME', $authorinfo->getAuthorName(
true));
2689 $node->setMessage($frm->prepareText($node->getMessage()));
2691 if($ilUser->getId() == ANONYMOUS_USER_ID ||
2692 $node->isPostRead())
2694 $tpl->setVariable(
'SUBJECT', $node->getSubject());
2698 $this->ctrl->setParameter($this,
'pos_pk', $node->getId());
2699 $this->ctrl->setParameter($this,
'thr_pk', $node->getThreadId());
2700 $this->ctrl->setParameter($this,
'offset', $Start);
2701 $this->ctrl->setParameter($this,
'orderby', $_GET[
'orderby']);
2702 $this->ctrl->setParameter($this,
'viewmode',
$_SESSION[
'viewmode']);
2703 $mark_post_target = $this->ctrl->getLinkTarget($this,
'markPostRead', $node->getId());
2705 $tpl->setVariable(
'SUBJECT',
"<a href=\"".$mark_post_target.
"\"><b>".$node->getSubject().
"</b></a>");
2709 $tpl->setVariable(
'POST_DATE', $frm->convertDate($node->getCreateDate()));
2711 if (!$node->isCensored() ||
2712 ($this->objCurrentPost->getId() == $node->getId() && $_GET[
'action'] ==
'censor'))
2715 $modAuthor = $frm->getModeratorFromPost($node->getId());
2719 if (is_array($modAuthor) && $modAuthor[
'top_mods'] > 0)
2723 $MODS = $rbacreview->assignedUsers($modAuthor[
'top_mods']);
2725 if (is_array($MODS))
2727 if (in_array($node->getUserId(), $MODS))
2728 $spanClass =
'moderator';
2733 if($node->getMessage() == strip_tags($node->getMessage()))
2736 $node->setMessage(nl2br($node->getMessage()));
2739 if ($spanClass !=
"")
2750 $tpl->setVariable(
'POST',
"<span class=\"moderator\">".nl2br($node->getCensorshipComment()).
"</span>");
2753 $tpl->parseCurrentBlock();
2761 $tpl->setCurrentBlock(
'posts_no');
2762 $tpl->setVariable(
'TXT_MSG_NO_POSTS_AVAILABLE', $lng->txt(
'forums_posts_not_available'));
2763 $tpl->parseCurrentBlock();
2766 $oThreadToolbar = clone $ilToolbar;
2767 $oThreadToolbar->addSeparator();
2768 $oThreadToolbar->addButton($this->lng->txt(
'top_of_page'),
'#frm_page_top');
2769 $tpl->setVariable(
'THREAD_TOOLBAR', $oThreadToolbar->getHTML());
2771 $tpl->setVariable(
'TPLPATH', $tpl->vars[
'TPLPATH']);
2774 include_once
'Services/PermanentLink/classes/class.ilPermanentLinkGUI.php';
2775 $permalink =
new ilPermanentLinkGUI(
'frm', $this->object->getRefId(),
'_'.$this->objCurrentTopic->getId());
2776 $this->tpl->setVariable(
'PRMLINK', $permalink->getHTML());
2790 $subject = $this->objCurrentPost->getSubject();
2791 $re_txt = $this->lng->txt(
'post_reply');
2793 $re_txt_with_num = str_replace(
':',
'(',$re_txt);
2794 $search_length = strlen($re_txt_with_num);
2795 $comp = substr_compare($re_txt_with_num, substr($subject, 0 , $search_length), 0, $search_length);
2799 $modified_subject = $subject;
2800 if($on_reply ==
true)
2803 $str_pos_start = strpos($subject,
'(');
2804 $str_pos_end = strpos($subject,
')');
2805 $length = ((int)$str_pos_end - (
int)$str_pos_start);
2807 $txt_number = substr($subject,$str_pos_start, $length-1);
2809 $re_count = (int)$txt_number + 1;
2811 $modified_subject = str_replace($txt_number, $re_count, $subject);
2816 $re_count = substr_count($subject, $re_txt);
2817 if($re_count >= 1 && $on_reply ==
true)
2819 $subject = str_replace($re_txt,
'', $subject);
2823 $modified_subject = sprintf($this->lng->txt(
'post_reply_count'), $re_count).
' '.trim($subject);
2825 else if($re_count >= 1 && $on_reply ==
false)
2829 $modified_subject = sprintf($this->lng->txt(
'post_reply_count'), $re_count).
' '.trim($subject);
2831 else if($re_count == 0)
2834 $modified_subject = $this->lng->txt(
'post_reply').
' '. $this->objCurrentPost->getSubject();
2837 return $modified_subject;
2840 public function showUserObject()
2851 include_once
'Services/User/classes/class.ilPublicUserProfileGUI.php';
2853 $add = $this->getUserProfileAdditional($_GET[
'ref_id'], $_GET[
'user']);
2854 $profile_gui->setAdditional($add);
2855 $profile_gui->setBackUrl($_GET[
'backurl']);
2856 $tpl->setContent($this->ctrl->getHTML($profile_gui));
2859 protected function getUserProfileAdditional($a_forum_ref_id, $a_user_id)
2865 global
$lng, $ilAccess;
2867 if(!$ilAccess->checkAccess(
'read',
'', $a_forum_ref_id))
2869 $this->ilias->raiseError($lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
2872 require_once
'Modules/Forum/classes/class.ilForum.php';
2874 $lng->loadLanguageModule(
'forum');
2880 if($ref_obj->getType() ==
'frm')
2883 $frm = $forumObj->Forum;
2884 $frm->setForumId($forumObj->
getId());
2885 $frm->setForumRefId($forumObj->
getRefId());
2893 if($ilAccess->checkAccess(
'moderate_frm',
'', $a_forum_ref_id))
2895 $numPosts = $frm->countUserArticles(addslashes($a_user_id));
2899 $numPosts = $frm->countActiveUserArticles(addslashes($a_user_id));
2902 return array($lng->txt(
'forums_posts') => $numPosts);
2905 public function performThreadsActionObject()
2913 unset(
$_SESSION[
'frm_topic_paste_expand']);
2915 if(isset(
$_POST[
'thread_ids']) && is_array(
$_POST[
'thread_ids']))
2917 if(isset(
$_POST[
'selected_cmd']) &&
$_POST[
'selected_cmd'] ==
'move')
2919 if($this->is_moderator)
2922 $this->moveThreadsObject();
2925 else if(
$_POST[
'selected_cmd'] ==
'enable_notifications' && $this->ilias->getSetting(
'forum_notification') != 0)
2927 for($i = 0; $i < count(
$_POST[
'thread_ids']); $i++)
2930 $tmp_obj->enableNotification($ilUser->getId());
2934 $this->ctrl->redirect($this,
'showThreads');
2936 else if(
$_POST[
'selected_cmd'] ==
'disable_notifications' && $this->ilias->getSetting(
'forum_notification') != 0)
2938 for($i = 0; $i < count(
$_POST[
'thread_ids']); $i++)
2941 $tmp_obj->disableNotification($ilUser->getId());
2945 $this->ctrl->redirect($this,
'showThreads');
2948 else if(
$_POST[
'selected_cmd'] ==
'close')
2950 if($this->is_moderator)
2952 for($i = 0; $i < count(
$_POST[
'thread_ids']); $i++)
2960 $this->ctrl->redirect($this,
'showThreads');
2962 else if(
$_POST[
'selected_cmd'] ==
'reopen')
2964 if($this->is_moderator)
2966 for($i = 0; $i < count(
$_POST[
'thread_ids']); $i++)
2974 $this->ctrl->redirect($this,
'showThreads');
2976 else if(
$_POST[
'selected_cmd'] ==
'makesticky')
2978 if($this->is_moderator)
2980 for($i = 0; $i < count(
$_POST[
'thread_ids']); $i++)
2983 $tmp_obj->makeSticky();
2988 $this->ctrl->redirect($this,
'showThreads');
2990 else if(
$_POST[
'selected_cmd'] ==
'unmakesticky')
2992 if($this->is_moderator)
2994 for($i = 0; $i < count(
$_POST[
'thread_ids']); $i++)
2997 $tmp_obj->unmakeSticky();
3002 $this->ctrl->redirect($this,
'showThreads');
3004 else if(
$_POST[
'selected_cmd'] ==
'editThread')
3006 if($this->is_moderator)
3008 $count = count(
$_POST[
'thread_ids']);
3012 $this->ctrl->redirect($this,
'showThreads');
3016 foreach(
$_POST[
'thread_ids'] as $thread_id)
3018 return $this->editThreadObject($thread_id, null);
3023 $this->ctrl->redirect($this,
'showThreads');
3025 else if(
$_POST[
'selected_cmd'] ==
'html')
3027 $this->ctrl->setCmd(
'exportHTML');
3028 $this->ctrl->setCmdClass(
'ilForumExportGUI');
3031 else if(
$_POST[
'selected_cmd'] ==
'confirmDeleteThreads')
3033 $this->confirmDeleteThreads();
3037 ilUtil::sendInfo($this->lng->txt(
'topics_please_select_one_action'),
true);
3038 $this->ctrl->redirect($this,
'showThreads');
3044 $this->ctrl->redirect($this,
'showThreads');
3048 public function performMoveThreadsObject()
3054 global
$lng, $ilObjDataCache;
3056 if(!$this->is_moderator)
3058 $this->ilias->raiseError($lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
3061 if(isset(
$_POST[
'frm_ref_id']) && (int)
$_POST[
'frm_ref_id'])
3063 $this->
object->Forum->moveThreads((array)
$_SESSION[
'threads2move'], $this->object->getRefId(), $ilObjDataCache->lookupObjId($_POST[
'frm_ref_id']));
3065 unset($_SESSION[
'threads2move']);
3066 unset($_SESSION[
'frm_topic_paste_expand']);
3068 $this->ctrl->redirect($this,
'showThreads');
3073 $this->moveThreadsObject();
3077 public function cancelMoveThreadsObject()
3084 if(!$this->is_moderator)
3086 $this->ilias->raiseError($lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
3089 unset($_SESSION[
'threads2move']);
3090 unset($_SESSION[
'frm_topic_paste_expand']);
3092 $this->ctrl->redirect($this,
'showThreads');
3095 public function moveThreadsObject()
3104 if(!$this->is_moderator)
3106 $this->ilias->raiseError($lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
3109 $threads2move = $_SESSION[
'threads2move'];
3111 if(empty($threads2move))
3114 $this->ctrl->redirect($this,
'showThreads');
3117 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.forums_threads_move.html',
'Modules/Forum');
3120 $ilToolbar->addButton($this->lng->txt(
'back'), $this->ctrl->getLinkTarget($this));
3123 $tblThr->setId(
'il_frm_thread_move_table_'.$this->object->getRefId());
3124 $tblThr->setTitle($this->lng->txt(
'move_chosen_topics'));
3125 $tblThr->addColumn($this->lng->txt(
'subject'),
'top_name',
'100%');
3126 $tblThr->disable(
'header');
3127 $tblThr->disable(
'footer');
3128 $tblThr->disable(
'linkbar');
3129 $tblThr->disable(
'sort');
3130 $tblThr->disable(
'linkbar');
3131 $tblThr->setLimit(0);
3132 $tblThr->setRowTemplate(
'tpl.forums_threads_move_thr_row.html',
'Modules/Forum');
3133 $tblThr->setDefaultOrderField(
'is_sticky');
3136 foreach($threads2move as $thr_pk)
3140 $result[$counter][
'num'] = $counter + 1;
3147 $this->tpl->setVariable(
'THREADS_TABLE', $tblThr->getHTML());
3150 require_once
'Modules/Forum/classes/class.ilForumMoveTopicsExplorer.php';
3152 $exp->
setExpandTarget($this->ctrl->getLinkTarget($this,
'moveThreads'));
3153 $exp->setTargetGet(
'ref_id');
3154 $exp->setPostVar(
'frm_ref_id');
3155 $exp->excludeObjIdFromSelection($this->object->getId());
3156 $exp->setCheckedItem(isset($_POST[
'frm_ref_id']) && (
int) $_POST[
'frm_ref_id'] ? (
int) $_POST[
'frm_ref_id'] : 0);
3159 if(!is_array($_SESSION[
'frm_topic_paste_expand']))
3161 $_SESSION[
'frm_topic_paste_expand'] = array();
3163 $path = $tree->getPathId($this->object->getRefId());
3164 foreach((array)
$path as $node_id)
3166 if(!in_array($node_id, $_SESSION[
'frm_topic_paste_expand']))
3167 $_SESSION[
'frm_topic_paste_expand'][] = $node_id;
3171 if(!isset($_GET[
'frm_topic_paste_expand']) || $_GET[
'frm_topic_paste_expand'] ==
'')
3173 $expanded = $tree->readRootId();
3177 $expanded = $_GET[
'frm_topic_paste_expand'];
3180 $exp->setExpand($expanded);
3183 $output = $exp->getOutput();
3184 $this->tpl->setVariable(
'FRM_SELECTION_TREE', $output);
3185 $this->tpl->setVariable(
'CMD_SUBMIT',
'performMoveThreads');
3186 $this->tpl->setVariable(
'TXT_SUBMIT', $this->lng->txt(
'move'));
3187 $this->tpl->setVariable(
'FORMACTION', $this->ctrl->getFormAction($this,
'performMoveThreads'));
3192 private function initTopicCreateForm()
3202 $this->create_topic_form_gui =
new ilPropertyFormGUI();
3204 $this->create_topic_form_gui->setTitle($this->lng->txt(
'forums_new_thread'));
3206 $this->create_topic_form_gui->setTableWidth(
'100%');
3209 $this->create_topic_form_gui->setFormAction($this->ctrl->getFormAction($this,
'addThread'));
3211 if($this->objProperties->isAnonymized() == 1)
3213 $alias_gui =
new ilTextInputGUI($this->lng->txt(
'forums_your_name'),
'alias');
3214 $alias_gui->
setInfo($this->lng->txt(
'forums_use_alias'));
3215 $alias_gui->setMaxLength(255);
3216 $alias_gui->setSize(50);
3217 $this->create_topic_form_gui->addItem($alias_gui);
3222 $alias_gui->
setValue($ilUser->getLogin());
3223 $this->create_topic_form_gui->addItem($alias_gui);
3227 $subject_gui =
new ilTextInputGUI($this->lng->txt(
'forums_thread'),
'subject');
3229 $subject_gui->setSize(50);
3230 $subject_gui->setRequired(
true);
3231 $this->create_topic_form_gui->addItem($subject_gui);
3236 $post_gui->setRows(15);
3237 $post_gui->setRequired(
true);
3238 $post_gui->setUseRte(
true);
3239 $post_gui->addPlugin(
'latex');
3240 $post_gui->addButton(
'latex');
3241 $post_gui->addButton(
'pastelatex');
3242 $post_gui->addPlugin(
'ilfrmquote');
3244 $post_gui->removePlugin(
'advlink');
3245 $post_gui->usePurifier(
true);
3246 $post_gui->setRTERootBlockElement(
'');
3247 $post_gui->setRTESupport($ilUser->getId(),
'frm~',
'frm_post',
'tpl.tinymce_frm_post.html',
false,
'3.4.7');
3248 $post_gui->disableButtons(array(
3266 require_once
'Services/Html/classes/class.ilHtmlPurifierFactory.php';
3268 $this->create_topic_form_gui->addItem($post_gui);
3273 $this->create_topic_form_gui->addItem($fi);
3275 include_once
'Services/Mail/classes/class.ilMail.php';
3276 $umail =
new ilMail($ilUser->getId());
3278 if($rbacsystem->checkAccess(
'internal_mail', $umail->getMailObjectReferenceId()) &&
3279 !$this->objProperties->isAnonymized())
3282 $dir_notification_gui =
new ilCheckboxInputGUI($this->lng->txt(
'forum_direct_notification'),
'notify');
3283 $dir_notification_gui->
setInfo($this->lng->txt(
'forum_notify_me_directly'));
3284 $dir_notification_gui->setValue(1);
3285 $this->create_topic_form_gui->addItem($dir_notification_gui);
3287 if($ilias->getSetting(
'forum_notification') != 0)
3290 $gen_notification_gui =
new ilCheckboxInputGUI($this->lng->txt(
'forum_general_notification'),
'notify_posts');
3291 $gen_notification_gui->
setInfo($this->lng->txt(
'forum_notify_me_generally'));
3292 $gen_notification_gui->setValue(1);
3293 $this->create_topic_form_gui->addItem($gen_notification_gui);
3297 if ($ilUser->getId() == ANONYMOUS_USER_ID &&
3298 $ilSetting->get(
'activate_captcha_anonym'))
3300 include_once(
"./Services/Captcha/classes/class.ilCaptchaInputGUI.php");
3301 $captcha =
new ilCaptchaInputGUI($this->lng->txt(
"cont_captcha_code"),
'captcha_code');
3303 $this->create_topic_form_gui->addItem($captcha);
3305 $this->create_topic_form_gui->addCommandButton(
'addThread', $this->lng->txt(
'submit'));
3306 $this->create_topic_form_gui->addCommandButton(
'showThreads', $this->lng->txt(
'cancel'));
3311 $this->create_topic_form_gui->setValuesByArray(array(
3320 public function createThreadObject()
3326 global $ilAccess,
$lng;
3328 if(!$ilAccess->checkAccess(
'add_thread',
'', $this->object->getRefId()))
3330 $this->ilias->raiseError($lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
3333 $this->initTopicCreateForm();
3336 $create_form =
new ilTemplate(
'tpl.create_thread_form.html',
true,
true,
'Modules/Forum');
3337 $create_form->setVariable(
'CREATE_FORM',$this->create_topic_form_gui->getHTML());
3338 $create_form->parseCurrentBlock();
3340 $this->tpl->setContent($create_form->get());
3343 public function addThreadObject($a_prevent_redirect =
false)
3352 $frm = $this->
object->Forum;
3353 $frm->setForumId($this->object->getId());
3354 $frm->setForumRefId($this->object->getRefId());
3356 if(!$ilAccess->checkAccess(
'add_thread',
'', $this->object->getRefId()))
3358 $this->ilias->raiseError($lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
3361 $frm->setMDB2WhereCondition(
'top_frm_fk = %s ', array(
'integer'), array($frm->getForumId()));
3363 $topicData = $frm->getOneTopic();
3365 $this->initTopicCreateForm();
3366 if($this->create_topic_form_gui->checkInput())
3368 if($this->objProperties->isAnonymized())
3370 if(!strlen($this->create_topic_form_gui->getInput(
'alias')))
3372 $user_alias = $this->lng->txt(
'forums_anonymous');
3376 $user_alias = $this->create_topic_form_gui->getInput(
'alias');
3381 $user_alias = $ilUser->getLogin();
3385 $newPost = $frm->generateThread(
3386 $topicData[
'top_pk'],
3387 ($this->objProperties->isAnonymized() ? 0 : $ilUser->getId()),
3388 $this->
handleFormInput($this->create_topic_form_gui->getInput(
'subject'),
false),
3390 $this->create_topic_form_gui->getItemByPostVar(
'notify') ? (int)$this->create_topic_form_gui->getInput(
'notify') : 0,
3391 $this->create_topic_form_gui->getItemByPostVar(
'notify_posts') ? (int)$this->create_topic_form_gui->getInput(
'notify_posts') : 0,
3395 $file = $_FILES[
'userfile'];
3398 if(is_array($file) && !empty($file))
3400 $tmp_file_obj =
new ilFileDataForum($this->object->getId(), $newPost);
3405 $frm->setDbTable(
'frm_data');
3406 $frm->setMDB2WhereCondition(
'top_pk = %s ', array(
'integer'), array($topicData[
'top_pk']));
3407 $frm->updateVisits($topicData[
'top_pk']);
3409 $frm->setMDB2WhereCondition(
'thr_top_fk = %s AND thr_subject = %s AND thr_num_posts = 1 ',
3410 array(
'integer',
'text'), array($topicData[
'top_pk'], $this->create_topic_form_gui->getInput(
'subject')));
3413 include_once
'Services/MediaObjects/classes/class.ilObjMediaObject.php';
3415 foreach($mediaObjects as $mob)
3424 if($this->ilias->getSetting(
'forum_notification') == 1)
3427 $objPost =
new ilForumPost((
int)$newPost, $this->is_moderator);
3428 $post_data = array();
3429 $post_data = $objPost->getDataAsArray();
3431 $post_data[
"top_name"] = $titles[0];
3432 $post_data[
"ref_id"] =$this->
object->getRefId();
3434 $frm->sendForumNotifications($post_data);
3436 if(!$a_prevent_redirect)
3439 $this->ctrl->redirect($this);
3448 $this->create_topic_form_gui->setValuesByPost();
3450 if(!$this->objProperties->isAnonymized())
3452 $this->create_topic_form_gui->getItemByPostVar(
'alias')->setValue($ilUser->getLogin());
3455 return $this->tpl->setContent($this->create_topic_form_gui->getHTML());
3459 public function enableForumNotificationObject()
3466 $frm = $this->
object->Forum;
3467 $frm->setForumId($this->object->getId());
3468 $frm->enableForumNotification($ilUser->getId());
3470 if(!$this->objCurrentTopic->getId())
3477 $this->ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3478 ilUtil::sendInfo($this->lng->txt(
'forums_forum_notification_enabled'),
true);
3479 $this->ctrl->redirect($this,
'viewThread');
3483 public function disableForumNotificationObject()
3490 $frm = $this->
object->Forum;
3491 $frm->setForumId($this->object->getId());
3492 $frm->disableForumNotification($ilUser->getId());
3494 if(!$this->objCurrentTopic->getId())
3501 $this->ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
3502 ilUtil::sendInfo($this->lng->txt(
'forums_forum_notification_disabled'),
true);
3503 $this->ctrl->redirect($this,
'viewThread');
3518 global
$lng, $ilAccess;
3520 $column_gui->
setBlockProperty(
'news',
'title', $lng->txt(
'frm_latest_postings'));
3524 if($ilAccess->checkAccess(
'write',
'', $this->object->getRefId()))
3527 $enable_internal_rss = $news_set->get(
'enable_rss_for_internal');
3528 if($enable_internal_rss)
3531 $column_gui->
setBlockProperty(
'news',
'public_notifications_option',
true);
3539 global $ilObjDataCache;
3541 if (!$_POST[
'clone_source'])
3544 if (isset($_SESSION[
'wizard_search_title']))
3546 $this->searchCloneSourceObject();
3554 $source_id = $_POST[
'clone_source'];
3557 $this->ctrl->setParameter($this,
'clone_source', (
int) $_POST[
'clone_source']);
3558 $this->ctrl->setParameter($this,
'new_type', $new_type);
3560 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.frm_wizard_page.html',
'Modules/Forum');
3561 $this->tpl->setVariable(
'FORMACTION', $this->ctrl->getFormAction($this));
3563 $this->tpl->setVariable(
'ALT_IMG', $this->lng->txt(
'obj_'.$new_type));
3564 $this->tpl->setVariable(
'TXT_DUPLICATE', $this->lng->txt(
'frm_wizard_page'));
3565 $this->tpl->setVariable(
'INFO_THREADS', $this->lng->txt(
'fmr_copy_threads_info'));
3566 $this->tpl->setVariable(
'THREADS', $this->lng->txt(
'forums_threads'));
3568 $forum_id = $ilObjDataCache->lookupObjId((
int) $_POST[
'clone_source']);
3569 include_once(
'Modules/Forum/classes/class.ilForum.php');
3571 foreach ($threads as $thread_id =>
$title)
3573 $this->tpl->setCurrentBlock(
'thread_row');
3574 $this->tpl->setVariable(
'CHECK_THREAD',
ilUtil::formCheckbox(0,
'cp_options['.$source_id.
'][threads][]', $thread_id));
3575 $this->tpl->setVariable(
'NAME_THREAD',
$title);
3576 $this->tpl->parseCurrentBlock();
3578 $this->tpl->setVariable(
'SELECT_ALL', $this->lng->txt(
'select_all'));
3579 $this->tpl->setVariable(
'JS_FIELD',
'cp_options['.$source_id.
'][threads]');
3580 $this->tpl->setVariable(
'BTN_COPY', $this->lng->txt(
'obj_'.$new_type.
'_duplicate'));
3581 if (isset($_SESSION[
'wizard_search_title']))
3583 $this->tpl->setVariable(
'BACK_CMD',
'searchCloneSource');
3587 $this->tpl->setVariable(
'BACK_CMD',
'create');
3589 $this->tpl->setVariable(
'BTN_BACK', $this->lng->txt(
'btn_back'));
3598 if($this->
object instanceof
ilObject)
3600 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this,
''),
'', $this->
object->getRefId());
3606 $a_text = str_replace(
"<",
"<", $a_text);
3607 $a_text = str_replace(
">",
">", $a_text);
3616 $a_text = str_replace(
"<",
"<", $a_text);
3617 $a_text = str_replace(
">",
">", $a_text);
3629 $this->ctrl->setCmd(
'showSummary');
3630 $this->ctrl->setCmdClass(
'ilinfoscreengui');
3631 $this->infoScreen();
3634 public function infoScreen()
3641 if(!$ilAccess->checkAccess(
'visible',
'', $this->object->getRefId()))
3643 $this->ilias->raiseError($this->lng->txt(
'msg_no_perm_read'), $this->ilias->error_obj->MESSAGE);
3646 include_once
'Services/InfoScreen/classes/class.ilInfoScreenGUI.php';
3649 $info->enablePrivateNotes();
3652 $info->addMetaDataSections($this->object->getId(), 0, $this->
object->getType());
3655 $this->ctrl->forwardCommand($info);
3658 public function updateNotificationSettingsObject()
3664 global $ilAccess,
$ilErr;
3665 if(!$ilAccess->checkAccess(
'write',
'', $this->ref_id))
3667 $ilErr->raiseError($this->lng->txt(
'msg_no_perm_read'),$ilErr->MESSAGE);
3674 if($this->notificationSettingsForm->checkInput())
3676 if(isset($_POST[
'notification_type']) && $_POST[
'notification_type']==
'all_users')
3679 $this->objProperties->setAdminForceNoti(1);
3680 $this->objProperties->setUserToggleNoti((
int) $this->notificationSettingsForm->getInput(
'usr_toggle'));
3681 $this->objProperties->setNotificationType(
'all_users');
3684 else if($_POST[
'notification_type']==
'per_user')
3686 $this->objProperties->setNotificationType(
'per_user');
3687 $this->objProperties->setAdminForceNoti(1);
3688 $this->objProperties->setUserToggleNoti(0);
3693 $this->objProperties->setNotificationType(
'default');
3694 $this->objProperties->setAdminForceNoti(0);
3695 $this->objProperties->setUserToggleNoti(0);
3696 include_once
'Modules/Forum/classes/class.ilForumNotification.php';
3701 $this->objProperties->update();
3706 $this->notificationSettingsForm->setValuesByPost();
3708 return $this->showMembersObject();
3713 include_once
'Modules/Forum/classes/class.ilForumNotification.php';
3715 $oParticipants = $this->getParticipantsObject();
3718 $moderator_ids = $frm_noti->
_getModerators($this->object->getRefId());
3720 $admin_ids = $oParticipants->getAdmins();
3721 $member_ids = $oParticipants->getMembers();
3722 $tutor_ids = $oParticipants->getTutors();
3724 $all_forum_users = array_merge($moderator_ids, $admin_ids, $member_ids, $tutor_ids);
3725 $all_forum_users= array_unique($all_forum_users);
3727 $all_notis = $frm_noti->read();
3729 foreach($all_forum_users as $user_id)
3731 $frm_noti->setUserId($user_id);
3733 $frm_noti->setAdminForce(1);
3734 $frm_noti->setUserToggle($this->objProperties->isUserToggleNoti());
3736 if(array_key_exists($user_id, $all_notis) && $update_all_users)
3738 $frm_noti->update();
3740 else if($frm_noti->existsNotification() ==
false)
3742 $frm_noti->insertAdminForce();
3749 if(null === $this->notificationSettingsForm)
3751 $form =
new ilPropertyFormGUI();
3752 $form->setFormAction($this->ctrl->getFormAction($this,
'updateNotificationSettings'));
3753 $form->setTitle($this->lng->txt(
'forums_notification_settings'));
3756 $radio_grp->setValue(
'default');
3758 $opt_default =
new ilRadioOption($this->lng->txt(
"user_decides_notification"),
'default');
3759 $opt_0 =
new ilRadioOption($this->lng->txt(
"settings_for_all_members"),
'all_users');
3760 $opt_1 =
new ilRadioOption($this->lng->txt(
"settings_per_users"),
'per_user');
3762 $radio_grp->addOption($opt_default,
'default');
3763 $radio_grp->addOption($opt_0,
'all_users');
3764 $radio_grp->addOption($opt_1,
'per_user');
3770 $form->addItem($radio_grp);
3772 $form->addCommandButton(
'updateNotificationSettings', $this->lng->txt(
'save'));
3774 $this->notificationSettingsForm = $form;
3784 $icon = $user_toggle_noti
3785 ?
"<img src=\"".ilUtil::getImagePath(
"icon_ok.png").
"\" alt=\"".$this->lng->txt(
"enabled").
"\" title=\"".$this->lng->txt(
"enabled").
"\" border=\"0\" vspace=\"0\"/>"
3786 :
"<img src=\"".ilUtil::getImagePath(
"icon_not_ok.png").
"\" alt=\"".$this->lng->txt(
"disabled").
"\" title=\"".$this->lng->txt(
"disabled").
"\" border=\"0\" vspace=\"0\"/>";
3790 public function showMembersObject()
3801 if(!$ilAccess->checkAccess(
'write',
'', $this->ref_id))
3803 $ilErr->raiseError($this->lng->txt(
'msg_no_perm_read'),$ilErr->MESSAGE);
3806 $tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.forums_members_list.html',
'Modules/Forum');
3808 $ilTabs->setTabActive(
'settings');
3809 $this->settingsTabs();
3815 $this->notificationSettingsForm->setValuesByArray(array(
3816 'notification_type' => $this->objProperties->getNotificationType(),
3817 'adm_force' => (bool) $this->objProperties->isAdminForceNoti(),
3818 'usr_toggle' => (bool) $this->objProperties->isUserToggleNoti()
3823 $tpl->setVariable(
'NOTIFICATIONS_SETTINGS_FORM', $this->notificationSettingsForm->getHTML());
3825 include_once
'Modules/Forum/classes/class.ilForumNotification.php';
3826 include_once
'Modules/Forum/classes/class.ilObjForum.php';
3829 $oParticipants = $this->getParticipantsObject();
3831 $moderator_ids = $frm_noti->_getModerators($this->object->getRefId());
3833 $admin_ids = $oParticipants->getAdmins();
3834 $member_ids = $oParticipants->getMembers();
3835 $tutor_ids = $oParticipants->getTutors();
3837 if($this->objProperties->getNotificationType() ==
'default')
3840 include_once
'Modules/Forum/classes/class.ilForumNotification.php';
3842 $forum_noti->
setAdminForce($this->objProperties->isAdminForceNoti());
3843 $forum_noti->setUserToggle($this->objProperties->isUserToggleNoti());
3844 $forum_noti->setForumId($this->objProperties->getObjId());
3846 else if($this->objProperties->getNotificationType() ==
'per_user')
3853 $this->__showMembersTable($moderators, $admins, $members, $tutors);
3861 foreach($user_ids as $user_id)
3865 $icon_ok = $this->
getIcon(!$user_toggle_noti);
3870 $users[$counter][
'firstname'] = $name[
'firstname'];
3871 $users[$counter][
'lastname'] = $name[
'lastname'];
3872 $users[$counter][
'user_toggle_noti'] = $icon_ok;
3878 private function __showMembersTable($moderators, $admins, $members, $tutors)
3890 $tbl_mod->setId(
'tbl_id_mod');
3891 $tbl_mod->setFormAction($ilCtrl->getFormAction($this,
'showMembers'));
3892 $tbl_mod->setTitle($lng->txt(
'moderators'));
3894 $tbl_mod->addColumn(
'',
'',
'1%',
true);
3895 $tbl_mod->addColumn($lng->txt(
'login'),
'',
'10%');
3896 $tbl_mod->addColumn($lng->txt(
'firstname'),
'',
'10%');
3897 $tbl_mod->addColumn($lng->txt(
'lastname'),
'',
'10%');
3898 $tbl_mod->addColumn($lng->txt(
'allow_user_toggle_noti'),
'',
'10%');
3899 $tbl_mod->setSelectAllCheckbox(
'user_id');
3901 $tbl_mod->setRowTemplate(
'tpl.forums_members_row.html',
'Modules/Forum');
3902 $tbl_mod->setData($moderators);
3904 $tbl_mod->addMultiCommand(
'enableHideUserToggleNoti',$lng->txt(
'enable_hide_user_toggle'));
3905 $tbl_mod->addMultiCommand(
'disableHideUserToggleNoti',$lng->txt(
'disable_hide_user_toggle'));
3907 $tpl->setCurrentBlock(
'moderators_table');
3908 $tpl->setVariable(
'MODERATORS',$tbl_mod->getHTML());
3914 $tbl_adm->setId(
'tbl_id_adm');
3915 $tbl_adm->setFormAction($ilCtrl->getFormAction($this,
'showMembers'));
3916 $tbl_adm->setTitle($lng->txt(
'administrator'));
3918 $tbl_adm->addColumn(
'',
'',
'1%',
true);
3919 $tbl_adm->addColumn($lng->txt(
'login'),
'',
'10%');
3920 $tbl_adm->addColumn($lng->txt(
'firstname'),
'',
'10%');
3921 $tbl_adm->addColumn($lng->txt(
'lastname'),
'',
'10%');
3922 $tbl_adm->addColumn($lng->txt(
'allow_user_toggle_noti'),
'',
'10%');
3923 $tbl_adm->setSelectAllCheckbox(
'user_id');
3924 $tbl_adm->setRowTemplate(
'tpl.forums_members_row.html',
'Modules/Forum');
3926 $tbl_adm->setData($admins);
3927 $tbl_adm->addMultiCommand(
'enableHideUserToggleNoti',$lng->txt(
'enable_hide_user_toggle'));
3928 $tbl_adm->addMultiCommand(
'disableHideUserToggleNoti',$lng->txt(
'disable_hide_user_toggle'));
3930 $tpl->setCurrentBlock(
'admins_table');
3931 $tpl->setVariable(
'ADMINS',$tbl_adm->getHTML());
3937 $tbl_mem->setId(
'tbl_id_mem');
3938 $tbl_mem->setFormAction($ilCtrl->getFormAction($this,
'showMembers'));
3939 $tbl_mem->setTitle($lng->txt(
'members'));
3941 $tbl_mem->addColumn(
'',
'',
'1%',
true);
3942 $tbl_mem->addColumn($lng->txt(
'login'),
'',
'10%');
3943 $tbl_mem->addColumn($lng->txt(
'firstname'),
'',
'10%');
3944 $tbl_mem->addColumn($lng->txt(
'lastname'),
'',
'10%');
3945 $tbl_mem->addColumn($lng->txt(
'allow_user_toggle_noti'),
'',
'10%');
3946 $tbl_mem->setSelectAllCheckbox(
'user_id');
3947 $tbl_mem->setRowTemplate(
'tpl.forums_members_row.html',
'Modules/Forum');
3948 $tbl_mem->setData($members);
3950 $tbl_mem->addMultiCommand(
'enableHideUserToggleNoti',$lng->txt(
'enable_hide_user_toggle'));
3951 $tbl_mem->addMultiCommand(
'disableHideUserToggleNoti',$lng->txt(
'disable_hide_user_toggle'));
3953 $tpl->setCurrentBlock(
'members_table');
3954 $tpl->setVariable(
'MEMBERS',$tbl_mem->getHTML());
3960 $tbl_tut->setId(
'tbl_id_tut');
3961 $tbl_tut->setFormAction($ilCtrl->getFormAction($this,
'showMembers'));
3962 $tbl_tut->setTitle($lng->txt(
'tutors'));
3964 $tbl_tut->addColumn(
'',
'',
'1%',
true);
3965 $tbl_tut->addColumn($lng->txt(
'login'),
'',
'10%');
3966 $tbl_tut->addColumn($lng->txt(
'firstname'),
'',
'10%');
3967 $tbl_tut->addColumn($lng->txt(
'lastname'),
'',
'10%');
3968 $tbl_tut->addColumn($lng->txt(
'allow_user_toggle_noti'),
'',
'10%');
3969 $tbl_tut->setSelectAllCheckbox(
'user_id');
3970 $tbl_tut->setRowTemplate(
'tpl.forums_members_row.html',
'Modules/Forum');
3971 $tbl_tut->setData($tutors);
3973 $tbl_tut->addMultiCommand(
'enableHideUserToggleNoti',$lng->txt(
'enable_hide_user_toggle'));
3974 $tbl_tut->addMultiCommand(
'disableHideUserToggleNoti',$lng->txt(
'disable_hide_user_toggle'));
3976 $tpl->setCurrentBlock(
'tutors_table');
3977 $tpl->setVariable(
'TUTORS',$tbl_tut->getHTML());
3981 public function enableAdminForceNotiObject()
3987 global $ilAccess,
$ilErr;
3988 if(!$ilAccess->checkAccess(
'write',
'', $this->ref_id))
3990 $ilErr->raiseError($this->lng->txt(
'msg_no_perm_read'),$ilErr->MESSAGE);
3993 if(!isset($_POST[
'user_id']) || !is_array($_POST[
'user_id']))
3999 include_once
'Modules/Forum/classes/class.ilForumNotification.php';
4002 foreach($_POST[
'user_id'] as $user_id)
4005 $is_enabled = $frm_noti->isAdminForceNotification();
4007 $frm_noti->setUserToggle(0);
4010 $frm_noti->setAdminForce(1);
4011 $frm_noti->insertAdminForce();
4018 $this->showMembersObject();
4021 public function disableAdminForceNotiObject()
4027 global $ilAccess,
$ilErr;
4028 if(!$ilAccess->checkAccess(
'write',
'', $this->ref_id))
4030 $ilErr->raiseError($this->lng->txt(
'msg_no_perm_read'),$ilErr->MESSAGE);
4033 if(!isset($_POST[
'user_id']) || !is_array($_POST[
'user_id']))
4039 include_once
'Modules/Forum/classes/class.ilForumNotification.php';
4042 foreach($_POST[
'user_id'] as $user_id)
4045 $is_enabled = $frm_noti->isAdminForceNotification();
4049 $frm_noti->deleteAdminForce();
4056 $this->showMembersObject();
4059 public function enableHideUserToggleNotiObject()
4065 global $ilAccess,
$ilErr;
4066 if(!$ilAccess->checkAccess(
'write',
'', $this->ref_id))
4068 $ilErr->raiseError($this->lng->txt(
'msg_no_perm_read'),$ilErr->MESSAGE);
4070 if(!isset($_POST[
'user_id']) || !is_array($_POST[
'user_id']))
4076 include_once
'Modules/Forum/classes/class.ilForumNotification.php';
4079 foreach($_POST[
'user_id'] as $user_id)
4082 $is_enabled = $frm_noti->isAdminForceNotification();
4083 $frm_noti->setUserToggle(1);
4087 $frm_noti->setAdminForce(1);
4088 $frm_noti->insertAdminForce();
4092 $frm_noti->updateUserToggle();
4099 $this->showMembersObject();
4102 public function disableHideUserToggleNotiObject()
4108 global $ilAccess,
$ilErr;
4109 if(!$ilAccess->checkAccess(
'write',
'', $this->ref_id))
4111 $ilErr->raiseError($this->lng->txt(
'msg_no_perm_read'),$ilErr->MESSAGE);
4114 if(!isset($_POST[
'user_id']) || !is_array($_POST[
'user_id']))
4120 include_once
'Modules/Forum/classes/class.ilForumNotification.php';
4123 foreach($_POST[
'user_id'] as $user_id)
4126 $is_enabled = $frm_noti->isAdminForceNotification();
4127 $frm_noti->setUserToggle(0);
4130 $frm_noti->updateUserToggle();
4134 $frm_noti->setAdminForce(1);
4135 $frm_noti->insertAdminForce();
4142 $this->showMembersObject();
4145 public function markPostUnreadObject()
4152 if(isset($_GET[
'pos_pk']))
4154 $this->
object->markPostUnread($ilUser->getId(), (int) $_GET[
'pos_pk']);
4157 $this->viewThreadObject();
4160 public function markPostReadObject()
4167 $this->
object->markPostRead($ilUser->getId(), (int) $this->objCurrentTopic->getId(), (int) $this->objCurrentPost->getId());
4168 $this->viewThreadObject();
4181 if($this->objCurrentTopic->getId())
4183 $container_obj = null;
4184 $lg->setContainerObject($container_obj);
4189 if($ilUser->getId() != ANONYMOUS_USER_ID && $this->ilias->getSetting(
'forum_notification') != 0 )
4193 $frm = $this->
object->Forum;
4194 $frm->setForumId($this->object->getId());
4195 $frm->setForumRefId($this->object->getRefId());
4196 $frm->setMDB2Wherecondition(
'top_frm_fk = %s ', array(
'integer'), array($frm->getForumId()));
4197 $frm_notificiation_enabled = $frm->isForumNotificationEnabled($ilUser->getId());
4199 if($this->objCurrentTopic->getId())
4201 $this->ctrl->setParameter($this,
'thr_pk', $this->objCurrentTopic->getId());
4208 $frm_notificiation_enabled &&
4209 $is_user_allowed_to_deactivate_notification
4212 $lg->addCustomCommand($this->ctrl->getLinkTarget($this,
'disableForumNotification'),
"forums_disable_forum_notification");
4216 $lg->addCustomCommand($this->ctrl->getLinkTarget($this,
'enableForumNotification'),
"forums_enable_forum_notification");
4221 if($frm_notificiation_enabled)
4223 $lg->addCustomCommand($this->ctrl->getLinkTarget($this,
'disableForumNotification'),
"forums_disable_forum_notification");
4227 $lg->addCustomCommand($this->ctrl->getLinkTarget($this,
'enableForumNotification'),
"forums_enable_forum_notification");
4231 $topic_notification_enabled =
false;
4232 if($this->objCurrentTopic->getId())
4234 $topic_notification_enabled = $this->objCurrentTopic->isNotificationEnabled($ilUser->getId());
4235 if($topic_notification_enabled)
4237 $lg->addCustomCommand($this->ctrl->getLinkTarget($this,
'toggleThreadNotification'),
"forums_disable_notification");
4241 $lg->addCustomCommand($this->ctrl->getLinkTarget($this,
'toggleThreadNotification'),
"forums_enable_notification");
4244 $this->ctrl->setParameter($this,
'thr_pk',
'');
4246 if($frm_notificiation_enabled || $topic_notification_enabled)
4251 $this->lng->txt(
"frm_notification_activated")
4259 $this->lng->txt(
"frm_notification_deactivated")
4270 if($this->objProperties->getNotificationType() ==
'default')
4275 if($this->objProperties->isUserToggleNoti() == 0)
4284 include_once
'Modules/Forum/classes/class.ilForumNotification.php';
4287 $frm_noti->setUserId($ilUser->getId());
4289 $user_toggle = (int)$frm_noti->isUserToggleNotification();
4290 if($user_toggle == 0)
4304 $grp_ref_id = $tree->checkForParentType($this->object->getRefId(),
'grp');
4305 $crs_ref_id = $tree->checkForParentType($this->object->getRefId(),
'crs');
4307 if($grp_ref_id == 0 && $crs_ref_id == 0)
4317 public function getParticipantsObject()
4321 $grp_ref_id = $tree->checkForParentType($this->object->getRefId(),
'grp');
4322 $crs_ref_id = $tree->checkForParentType($this->object->getRefId(),
'crs');
4326 $ilErr->raiseError($this->lng->txt(
'msg_no_perm_read'), $ilErr->MESSAGE);
4332 $oParticipants = null;
4337 include_once
'Modules/Group/classes/class.ilGroupParticipants.php';
4339 return $oParticipants;
4341 else if($crs_ref_id > 0)
4345 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
4347 return $oParticipants;
4350 return $oParticipants;
4364 if((
int)$ilSetting->get(
'disable_my_offers'))
4369 include_once
'./Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
4382 if((
int)$ilSetting->get(
'disable_my_offers'))
4387 include_once
'./Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';