ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilObjForumGUI Class Reference

ilObjForumGUI: ilPermissionGUI, ilForumExportGUI, ilInfoScreenGUI ilObjForumGUI: ilColumnGUI, ilPublicUserProfileGUI, ilForumModeratorsGUI, ilRepositoryObjectSearchGUI ilObjForumGUI: ilObjectCopyGUI, ilExportGUI, ilCommonActionDispatcherGUI, ilRatingGUI ilObjForumGUI: ilForumSettingsGUI, ilContainerNewsSettingsGUI, ilLearningProgressGUI, ilForumPageGUI ilObjForumGUI: ilObjectContentStyleSettingsGUI More...

+ Inheritance diagram for ilObjForumGUI:
+ Collaboration diagram for ilObjForumGUI:

Public Member Functions

 __construct ($data, int $id=0, bool $call_by_reference=true, bool $prepare_output=true)
 
 ensureThreadBelongsToForum (int $objId, ilForumTopic $thread)
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 
 infoScreenObject ()
 
 updateThreadObject ()
 
 markAllReadObject ()
 
 showThreadsObject ()
 
 getContent ()
 
 showStatisticsObject ()
 
 performDeleteThreadsObject ()
 
 performPostActivationObject ()
 
 askForPostActivationObject ()
 
 setDisplayConfirmPostActivation (bool $status=false)
 
 displayConfirmPostActivation ()
 
 cancelPostObject ()
 
 cancelDraftObject ()
 
 addActivationFormModal (ilForumPost $node)
 
 createTopLevelPostObject ()
 
 saveTopLevelPostObject ()
 
 publishSelectedDraftObject ()
 
 publishDraftObject (bool $use_replyform=true)
 
 savePostObject ()
 
 quotePostObject ()
 
 checkUsersViewMode ()
 
 resetLimitedViewObject ()
 
 viewThreadObject ()
 
 showUserObject ()
 
 performThreadsActionObject ()
 
 performMoveThreadsObject ()
 
 cancelMoveThreadsObject ()
 
 moveThreadsObject ()
 
 setColumnSettings (ilColumnGUI $column_gui)
 
 handleFormInput (string $a_text, bool $a_stripslashes=true)
 
 prepareFormOutput (string $a_text)
 
 saveUserNotificationSettingsObject ()
 
 isUserAllowedToDeactivateNotification ()
 
 isParentObjectCrsOrGrp ()
 
 mergeThreadsObject ()
 
 confirmMergeThreadsObject ()
 
 performMergeThreadsObject ()
 
 saveTopLevelDraftObject ()
 
 saveAsDraftObject ()
 
 updateDraftObject ()
 
- Public Member Functions inherited from ilObjectGUI
 getRefId ()
 
 setAdminMode (string $mode)
 
 getAdminMode ()
 
 getObject ()
 
 executeCommand ()
 
 withReferences ()
 determines whether objects are referenced or not (got ref ids or not) More...
 
 setCreationMode (bool $mode=true)
 If true, a creation screen is displayed the current [ref_id] does belong to the parent class The mode is determined in ilRepositoryGUI. More...
 
 getCreationMode ()
 
 prepareOutput (bool $show_sub_objects=true)
 
 getAdminTabs ()
 administration tabs show only permissions and trash folder More...
 
 getHTML ()
 
 confirmedDeleteObject ()
 confirmed deletion of object -> objects are moved to trash or deleted immediately, if trash is disabled More...
 
 cancelObject ()
 cancel action and go back to previous page More...
 
 createObject ()
 create new object form More...
 
 editAvailabilityPeriodObject ()
 
 saveAvailabilityPeriodObject ()
 
 cancelCreation ()
 cancel create action and go back to repository parent More...
 
 saveObject ()
 
 getDidacticTemplateVar (string $type)
 Get didactic template setting from creation screen. More...
 
 putObjectInTree (ilObject $obj, ?int $parent_node_id=null)
 Add object to tree at given position. More...
 
 editObject ()
 
 addExternalEditFormCustom (ilPropertyFormGUI $form)
 
 updateObject ()
 updates object entry in object_data More...
 
 getFormAction (string $cmd, string $default_form_action="")
 Get form action for command (command is method name without "Object", e.g. More...
 
 isVisible (int $ref_id, string $type)
 
 viewObject ()
 viewObject container presentation for "administration -> repository, trash, permissions" More...
 
 deleteObject (bool $error=false)
 Display deletion confirmation screen. More...
 
 setColumnSettings (ilColumnGUI $column_gui)
 
 addToDeskObject ()
 
 removeFromDeskObject ()
 
- Public Member Functions inherited from ILIAS\Object\ImplementsCreationCallback
 callCreationCallback (\ilObject $object, \ilObjectDefinition $obj_definition, int $requested_crtcb)
 
- Public Member Functions inherited from ilDesktopItemHandling
 addToDeskObject ()
 
 removeFromDeskObject ()
 

Static Public Member Functions

static _goto ($a_target, $a_thread=0, $a_posting=0)
 
- Static Public Member Functions inherited from ilObjectGUI
static _gotoRepositoryRoot (bool $raise_error=false)
 Goto repository root. More...
 
static _gotoRepositoryNode (int $ref_id, string $cmd="")
 
static _gotoSharedWorkspaceNode (int $wsp_id)
 

Data Fields

string $modal_history = ''
 
ilForumProperties $objProperties
 
ilNavigationHistory $ilNavigationHistory
 
ilObjectDataCache $ilObjDataCache
 
ILIAS DI RBACServices $rbac
 
ilHelpGUI $ilHelp
 
- Data Fields inherited from ilObjectGUI
const ADMIN_MODE_NONE = ""
 
const ADMIN_MODE_SETTINGS = "settings"
 
const ADMIN_MODE_REPOSITORY = "repository"
 
const UPLOAD_TYPE_LOCAL = 1
 
const UPLOAD_TYPE_UPLOAD_DIRECTORY = 2
 
const CFORM_NEW = 1
 
const CFORM_IMPORT = 2
 
const CFORM_CLONE = 3
 
const SUPPORTED_IMPORT_MIME_TYPES = [MimeType::APPLICATION__ZIP, MimeType::APPLICATION__X_ZIP_COMPRESSED]
 
- Data Fields inherited from ilForumObjectConstants
const OBJ_TYPE = 'frm'
 
const UI_TAB_ID_INFO = 'info_short'
 
const UI_TAB_ID_SETTINGS = 'settings'
 
const UI_TAB_ID_MODERATORS = 'frm_moderators'
 
const UI_TAB_ID_THREADS = 'forums_threads'
 
const UI_TAB_ID_STATS = 'frm_statistics'
 
const UI_TAB_ID_EXPORT = 'export'
 
const UI_TAB_ID_PERMISSIONS = 'perm_settings'
 
const UI_SUB_TAB_ID_BASIC_SETTINGS = 'general'
 
const UI_SUB_TAB_ID_NOTIFICATIONS = 'notifications'
 
const UI_SUB_TAB_ID_NEWS = 'cont_news_settings'
 
const UI_SUB_TAB_ID_STYLE = 'cont_style'
 
const UI_CMD_COPAGE_DOWNLOAD_FILE = 'downloadFile'
 
const UI_CMD_COPAGE_DISPLAY_FULLSCREEN = 'displayMediaFullscreen'
 
const UI_CMD_COPAGE_DOWNLOAD_PARAGRAPH = 'download_paragraph'
 

Protected Member Functions

 initSessionStorage ()
 
 toggleExplorerNodeStateObject ()
 
 ensureValidPageForCurrentPosting (array $subtree_nodes, array $pagedPostings, int $pageSize, ilForumPost $firstForumPost)
 
 initEditCustomForm (ilPropertyFormGUI $a_form)
 
 getEditFormCustomValues (array &$a_values)
 
 updateCustom (ilPropertyFormGUI $form)
 
 renderPostContent (ilTemplate $tpl, ilForumPost $node, string $action, int $pageIndex, int $postIndex)
 
 selectPostObject ()
 
 afterSave (ilObject $new_object)
 
 getTabs ()
 
 confirmDeleteThreadDraftsObject ()
 
 toggleThreadNotificationObject ()
 
 toggleStickinessObject ()
 
 deleteThreadDraftsObject ()
 
 publishThreadDraftObject ()
 
 addThreadObject ()
 
 addEmptyThreadObject ()
 
 enableForumNotificationObject ()
 
 disableForumNotificationObject ()
 
 addLocatorItems ()
 
 infoScreen ()
 
 markPostUnreadObject ()
 
 markPostReadObject ()
 
 initHeaderAction (?string $sub_type=null, ?int $sub_id=null)
 
 setSideBlocks ()
 
 deliverDraftZipFileObject ()
 
 deliverZipFileObject ()
 
 editThreadDraftObject (?ilPropertyFormGUI $form=null)
 
 restoreFromHistoryObject ()
 
 saveThreadAsDraftObject ()
 
 updateThreadDraftObject ()
 
 editDraftObject ()
 
 deleteMobsOfDraft (int $draft_id, string $message)
 
 deleteSelectedDraft ()
 
 autosaveDraftAsyncObject ()
 
 autosaveThreadDraftAsyncObject ()
 
- Protected Member Functions inherited from ilObjectGUI
 getObjectService ()
 
 assignObject ()
 
 setTitleAndDescription ()
 
 createActionDispatcherGUI ()
 
 initHeaderAction (?string $sub_type=null, ?int $sub_id=null)
 Add header action menu. More...
 
 insertHeaderAction (?ilObjectListGUI $list_gui=null)
 Insert header action into main template. More...
 
 addHeaderAction ()
 Add header action menu. More...
 
 redrawHeaderActionObject ()
 Ajax call: redraw action header only. More...
 
 setTabs ()
 set admin tabs More...
 
 setAdminTabs ()
 set admin tabs More...
 
 setLocator ()
 
 addLocatorItems ()
 should be overwritten to add object specific items (repository items are preloaded) More...
 
 omitLocator (bool $omit=true)
 
 addAdminLocatorItems (bool $do_not_add_object=false)
 should be overwritten to add object specific items (repository items are preloaded) More...
 
 getCreationFormsHTML (StandardForm|ilPropertyFormGUI|array $form)
 
 getTitleForCreationFormPage ()
 
 getCreationFormTitle ()
 
 initCreateForm (string $new_type)
 
 didacticTemplatesToForm ()
 
 initDidacticTemplate (ilPropertyFormGUI $form)
 
 retrieveAdditionalDidacticTemplateOptions ()
 
 addAdoptContentLinkToToolbar ()
 
 addImportButtonToToolbar ()
 
 addAvailabilityPeriodButtonToToolbar (ilToolbarGUI $toolbar)
 
 parseDidacticTemplateVar (string $var, string $type)
 
 afterSave (ilObject $new_object)
 Post (successful) object creation hook. More...
 
 initEditForm ()
 
 initEditCustomForm (ilPropertyFormGUI $a_form)
 Add custom fields to update form. More...
 
 getEditFormValues ()
 
 getEditFormCustomValues (array &$a_values)
 Add values to custom edit fields. More...
 
 validateCustom (ilPropertyFormGUI $form)
 Validate custom values (if not possible with checkInput()) More...
 
 updateCustom (ilPropertyFormGUI $form)
 Insert custom update form values into object. More...
 
 afterUpdate ()
 Post (successful) object update hook. More...
 
 routeImportCmdObject ()
 
 importFile (string $file_to_import, string $path_to_uploaded_file_in_temp_dir)
 
 deleteUploadedImportFile (string $path_to_uploaded_file_in_temp_dir)
 
 afterImport (ilObject $new_object)
 Post (successful) object import hook. More...
 
 setFormAction (string $cmd, string $form_action)
 
 getReturnLocation (string $cmd, string $default_location="")
 Get return location for command (command is method name without "Object", e.g. More...
 
 setReturnLocation (string $cmd, string $location)
 set specific return location for command More...
 
 getTargetFrame (string $cmd, string $default_target_frame="")
 get target frame for command (command is method name without "Object", e.g. More...
 
 setTargetFrame (string $cmd, string $target_frame)
 Set specific target frame for command. More...
 
 showPossibleSubObjects ()
 show possible sub objects (pull down menu) More...
 
 getTabs ()
 overwrite in derived GUI class of your object type More...
 
 redirectToRefId (int $ref_id, string $cmd="")
 redirects to (repository) view per ref id usually to a container and usually used at the end of a save/import method where the object gui type (of the new object) doesn't match with the type of the current ["ref_id"] value of the request More...
 
 getCenterColumnHTML ()
 Get center column. More...
 
 getRightColumnHTML ()
 Display right column. More...
 
 checkPermission (string $perm, string $cmd="", string $type="", ?int $ref_id=null)
 
 checkPermissionBool (string $perm, string $cmd="", string $type="", ?int $ref_id=null)
 
 enableDragDropFileUpload ()
 Enables the file upload into this object by dropping files. More...
 
 getCreatableObjectTypes ()
 
 buildAddNewItemElements (array $subtypes, string $create_target_class=ilRepositoryGUI::class, ?int $redirect_target_ref_id=null,)
 
 buildGroup (string $create_target_class, array $obj_types_in_group, string $title, array $subtypes)
 

Protected Attributes

ILIAS Style Content Object ObjectFacade $content_style_domain
 
ILIAS Style Content GUIService $content_style_gui
 
- Protected Attributes inherited from ilObjectGUI
ILIAS Notes Service $notes_service
 
ServerRequestInterface $request
 
ilLocatorGUI $locator
 
ilObjUser $user
 
ilAccessHandler $access
 
ilSetting $settings
 
ilToolbarGUI $toolbar
 
ilRbacAdmin $rbac_admin
 
ilRbacSystem $rbac_system
 
ilRbacReview $rbac_review
 
ilObjectService $object_service
 
ilObjectDefinition $obj_definition
 
ilGlobalTemplateInterface $tpl
 
ilTree $tree
 
ilCtrl $ctrl
 
ilErrorHandling $error
 
ilLanguage $lng
 
ilTabsGUI $tabs_gui
 
ILIAS $ilias
 
ArrayBasedRequestWrapper $post_wrapper
 
RequestWrapper $request_wrapper
 
Refinery $refinery
 
ilFavouritesManager $favourites
 
ilObjectCustomIconFactory $custom_icon_factory
 
UIFactory $ui_factory
 
UIRenderer $ui_renderer
 
Filesystem $temp_file_system
 
ilObject $object = null
 
bool $creation_mode = false
 
 $data
 
int $id
 
bool $call_by_reference = false
 
bool $prepare_output
 
int $ref_id
 
int $obj_id
 
int $maxcount
 
array $form_action = []
 
array $return_location = []
 
array $target_frame = []
 
string $tmp_import_dir
 
string $sub_objects = ""
 
bool $omit_locator = false
 
string $type = ""
 
string $admin_mode = self::ADMIN_MODE_NONE
 
int $requested_ref_id = 0
 
int $requested_crtptrefid = 0
 
int $requested_crtcb = 0
 
string $requested_new_type = ""
 
string $link_params
 
string $html = ""
 

Private Member Functions

 retrieveThrPk ()
 
 retrieveDraftId (bool $from_post=false)
 
 decorateWithAutosave (ilPropertyFormGUI $form)
 
 isTopLevelReplyCommand ()
 
 getTableCommands ()
 
 renderThreadOverview (ilForum $frm, ForumDto $frm_object)
 
 getSortationViewControl (int $offset)
 
 retrieveThreadIds ()
 
 getThreadProperties (ilForumTopic $forum_topic)
 
 getLinkActionForThread (int $ref_id, string $title, string $cmd, ?int $thread_id=null)
 
 getActionsForThreadOverview (int $ref_id, ilForumTopic $forum_topic)
 
 getEditTitleModal (ilForumTopic $topic)
 
 addDraftButtonIfDraftsExists (string $cmd)
 
 getStickyActionForThread (ilForumTopic $forum_topic, int $ref_id)
 
 getOpenCloseActionForThread (ilForumTopic $forum_topic, int $ref_id)
 
 markTopThreadInOverview (ilForumTopic $current_thread, Item $list_item)
 
 initStyleSheets ()
 
 editStylePropertiesObject ()
 
 renderDraftContent (ilTemplate $tpl, string $action, ilForumPost $referencePosting, array $drafts)
 
 deletePostingObject ()
 
 deletePostingDraftObject ()
 
 revokeCensorshipObject ()
 
 addCensorshipObject ()
 
 getModalActions ()
 
 handleCensorship (bool $wasRevoked=false)
 
 initReplyEditForm ()
 
 getReplyEditForm ()
 
 hideToolbar ($a_flag=null)
 
 getForumObjects ()
 
 renderViewModeControl (int $currentViewMode)
 
 renderSortationControl (int $currentSorting)
 
 getModifiedReOnSubject ()
 
 isWritingWithPseudonymAllowed ()
 
 buildThreadForm (bool $isDraft=false)
 
 buildMinimalThreadForm (bool $isDraft=false)
 
 createThreadObject ()
 
 createThread (ilForumPostDraft $draft, bool $createFromDraft=false)
 Refactored thread creation to method, refactoring to a separate class should be done in next refactoring steps. More...
 
 createEmptyThread ()
 Refactored thread creation to method, refactoring to a separate class should be done in next refactoring steps. More...
 
 eventsFormBuilder (?array $predefined_values=null)
 
 renderSplitButton (ilTemplate $tpl, string $action, bool $is_post, ilForumPost $node, int $pageIndex=0, ?ilForumPostDraft $draft=null)
 
 checkDraftAccess (int|ilForumPostDraft $draft)
 
 hasDraftAccess (int|ilForumPostDraft $draft)
 
 doHistoryCheck (int $draftId)
 
 renderPostingForm (ilTemplate $tpl, ilForum $frm, ilForumPost $node, string $action)
 
 getResetLimitedViewInfo ()
 
 getOrderByParam ()
 

Private Attributes

array $viewModeOptions
 
array $sortationOptions
 
ILIAS GlobalScreen Services $globalScreen
 
ilForumTopic $objCurrentTopic
 
ilForumPost $objCurrentPost
 
bool $display_confirm_post_activation = false
 
bool $is_moderator
 
ilPropertyFormGUI $replyEditForm = null
 
bool $hideToolbar = false
 
Psr Http Message ServerRequestInterface $httpRequest
 
ILIAS HTTP Services $http
 
Factory $uiFactory
 
Renderer $uiRenderer
 
array $forumObjects = null
 
string $confirmation_gui_html = ''
 
ilForumSettingsGUI $forum_settings_gui
 
string $requestAction
 
array $modalActionsContainer = []
 
Factory $factory
 
Renderer $renderer
 
int $selectedSorting
 
ilForumThreadSettingsSessionStorage $selected_post_storage
 
array $modal_collection = []
 
readonly bool $in_page_editor_style_context
 
ForumThreadTableSessionStorage $forum_thread_table_session_storage
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjForumGUI::__construct (   $data,
int  $id = 0,
bool  $call_by_reference = true,
bool  $prepare_output = true 
)

Definition at line 85 of file class.ilObjForumGUI.php.

References ilObjectGUI\$call_by_reference, ilObjectGUI\$data, $DIC, ilObjectGUI\$id, ilObjectGUI\$ref_id, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), factory(), ilForumProperties\getInstance(), ILIAS\Repository\globalScreen(), ILIAS\FileDelivery\http(), initSessionStorage(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ILIAS\Repository\rbac(), renderer(), and retrieveThrPk().

86  {
87  global $DIC;
88 
89  $this->httpRequest = $DIC->http()->request();
90  $this->http = $DIC->http();
91 
92  $this->uiFactory = $DIC->ui()->factory();
93  $this->uiRenderer = $DIC->ui()->renderer();
94  $this->globalScreen = $DIC->globalScreen();
95 
96  $this->ilObjDataCache = $DIC['ilObjDataCache'];
97  $this->ilNavigationHistory = $DIC['ilNavigationHistory'];
98  $this->ilHelp = $DIC['ilHelp'];
99  $this->rbac = $DIC->rbac();
100  $this->factory = $DIC->ui()->factory();
101  $this->renderer = $DIC->ui()->renderer();
102 
103  $this->type = 'frm';
105  $this->ctrl->saveParameter($this, ['ref_id']);
106  $this->tpl->addJavaScript('assets/js/Basic.js');
107 
108  $this->lng->loadLanguageModule('forum');
109  $this->lng->loadLanguageModule('content');
110 
111  $ref_id = $this->retrieveIntOrZeroFrom($this->http->wrapper()->query(), 'ref_id');
112 
113  $this->objProperties = ilForumProperties::getInstance($this->ilObjDataCache->lookupObjId($ref_id));
114  $this->is_moderator = $this->access->checkAccess('moderate_frm', '', $ref_id);
115 
116  $this->objCurrentTopic = new ilForumTopic($this->retrieveThrPk(), $this->is_moderator);
117  $this->requestAction = (string) ($this->httpRequest->getQueryParams()['action'] ?? '');
118  $cs = $DIC->contentStyle();
119  $this->content_style_gui = $cs->gui();
120  if (is_object($this->object)) {
121  $this->content_style_domain = $cs->domain()->styleForRefId($this->object->getRefId());
122  }
123  $this->in_page_editor_style_context = $this->http->wrapper()->query()->has('page_editor_style');
124  $this->ctrl->saveParameterByClass(ilObjectContentStyleSettingsGUI::class, 'page_editor_style');
125 
126  $this->initSessionStorage();
127  $this->forum_thread_table_session_storage = new ForumThreadTableSessionStorage(
128  $this->ref_id,
129  $this->is_moderator
130  );
131  }
factory()
renderer()
static getInstance(int $a_obj_id=0)
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:22
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Last visited history for repository items.
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ _goto()

static ilObjForumGUI::_goto (   $a_target,
  $a_thread = 0,
  $a_posting = 0 
)
static

Definition at line 1742 of file class.ilObjForumGUI.php.

References $DIC, $ilErr, ilObjectGUI\$lng, ilObjectGUI\$ref_id, ilObject\_getAllReferences(), ilObject\_lookupObjectId(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ILIAS\Repository\int(), ROOT_FOLDER_ID, and ilLanguage\txt().

Referenced by ILIAS\StaticURL\Handler\LegacyGotoHandler\handle().

1742  : void
1743  {
1744  global $DIC;
1745  $main_tpl = $DIC->ui()->mainTemplate();
1746 
1747  $ilAccess = $DIC->access();
1748  $lng = $DIC->language();
1749  $ilErr = $DIC['ilErr'];
1750 
1751  $a_target = is_numeric($a_target) ? (int) $a_target : 0;
1752  $a_thread = is_numeric($a_thread) ? (int) $a_thread : 0;
1753  if ($ilAccess->checkAccess('read', '', $a_target)) {
1754  if ($a_thread !== 0) {
1755  $objTopic = new ilForumTopic($a_thread);
1756  if ($objTopic->getFrmObjId() &&
1757  $objTopic->getFrmObjId() !== ilObject::_lookupObjectId($a_target)) {
1758  $ref_ids = ilObject::_getAllReferences($objTopic->getFrmObjId());
1759  foreach ($ref_ids as $ref_id) {
1760  if ($ilAccess->checkAccess('read', '', $ref_id)) {
1761  $new_ref_id = $ref_id;
1762  break;
1763  }
1764  }
1765 
1766  if (isset($new_ref_id) && $new_ref_id !== $a_target) {
1767  $DIC->ctrl()->redirectToURL(
1768  ILIAS_HTTP_PATH . '/goto.php?target=frm_' . $new_ref_id . '_' . $a_thread . '_' . $a_posting
1769  );
1770  }
1771  }
1772 
1773  $DIC->ctrl()->setParameterByClass(self::class, 'ref_id', (string) ((int) $a_target));
1774  if (is_numeric($a_thread)) {
1775  $DIC->ctrl()->setParameterByClass(self::class, 'thr_pk', (string) ((int) $a_thread));
1776  }
1777  if (is_numeric($a_posting)) {
1778  $DIC->ctrl()->setParameterByClass(self::class, 'pos_pk', (string) ((int) $a_posting));
1779  }
1780  $DIC->ctrl()->redirectByClass(
1781  [ilRepositoryGUI::class, self::class],
1782  'viewThread',
1783  is_numeric($a_posting) ? (string) ((int) $a_posting) : ''
1784  );
1785  } else {
1786  $DIC->ctrl()->setParameterByClass(self::class, 'ref_id', $a_target);
1787  $DIC->ctrl()->redirectByClass([ilRepositoryGUI::class, self::class,], '');
1788  $DIC->http()->close();
1789  }
1790  } elseif ($ilAccess->checkAccess('visible', '', $a_target)) {
1791  $DIC->ctrl()->setParameterByClass(ilInfoScreenGUI::class, 'ref_id', $a_target);
1792  $DIC->ctrl()->redirectByClass(
1793  [
1794  ilRepositoryGUI::class,
1795  self::class,
1796  ilInfoScreenGUI::class
1797  ],
1798  'showSummary'
1799  );
1800  } elseif ($ilAccess->checkAccess('read', '', ROOT_FOLDER_ID)) {
1801  $main_tpl->setOnScreenMessage('info', sprintf(
1802  $lng->txt('msg_no_perm_read_item'),
1804  ), true);
1805  $DIC->http()->close();
1806  }
1807 
1808  $ilErr->raiseError($lng->txt('msg_no_perm_read'), $ilErr->FATAL);
1809  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
const ROOT_FOLDER_ID
Definition: constants.php:32
static _getAllReferences(int $id)
get all reference ids for object ID
$ilErr
Definition: raiseError.php:33
static _lookupObjId(int $ref_id)
ilLanguage $lng
static _lookupTitle(int $obj_id)
global $DIC
Definition: shib_login.php:22
static _lookupObjectId(int $ref_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addActivationFormModal()

ilObjForumGUI::addActivationFormModal ( ilForumPost  $node)

Definition at line 2214 of file class.ilObjForumGUI.php.

References ilObjectGUI\$id, $message, ILIAS\Repository\ctrl(), ilForumPost\getId(), getOrderByParam(), ilForumPost\getThreadId(), ILIAS\Repository\lng(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

Referenced by renderSplitButton().

2215  {
2216  $form = new ilPropertyFormGUI();
2217  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
2218  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
2219  $this->ctrl->setParameter(
2220  $this,
2221  'orderby',
2222  $this->getOrderByParam()
2223  );
2224  $form->setFormAction($this->ctrl->getFormAction($this, 'performPostActivation'));
2225  $this->ctrl->clearParameters($this);
2226  $form->setId('frm_activate_post_' . $node->getId());
2227  $form_id = $form->getId();
2228  $message = $this->uiFactory->messageBox()->confirmation($this->lng->txt('activate_post_txt'));
2229  $submitBtn = $this->uiFactory->button()->primary(
2230  $this->lng->txt('activate_only_current'),
2231  '#'
2232  )->withOnLoadCode(
2233  static function (string $id) use ($form_id): string {
2234  return "
2235  (function () {
2236  const button = document.getElementById('$id');
2237  if (!button) return;
2238 
2239  const form = document.getElementById('form_$form_id');
2240  if (!form) return;
2241 
2242  button.addEventListener('click', (event) => {
2243  event.preventDefault();
2244  form.submit();
2245  }, true);
2246  }());
2247  ";
2248  }
2249  );
2250  $modal = $this->uiFactory->modal()->roundtrip(
2251  $this->lng->txt('activate_only_current'),
2252  [$this->uifactory->legacy()->content($form->getHTML()), $message]
2253  )->withActionButtons([$submitBtn]);
2254  $action_button = $this->uiFactory->button()->standard($this->lng->txt('activate_post'), '#')->withOnClick(
2255  $modal->getShowSignal()
2256  );
2257  $this->modalActionsContainer[] = $modal;
2258  $this->ctrl->clearParameters($this);
2259 
2260  return $action_button;
2261  }
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addCensorshipObject()

ilObjForumGUI::addCensorshipObject ( )
private

Definition at line 2050 of file class.ilObjForumGUI.php.

References handleCensorship().

2050  : void
2051  {
2052  $this->handleCensorship();
2053  }
handleCensorship(bool $wasRevoked=false)
+ Here is the call graph for this function:

◆ addDraftButtonIfDraftsExists()

ilObjForumGUI::addDraftButtonIfDraftsExists ( string  $cmd)
private

Definition at line 1016 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), factory(), ilForumPostDraft\getThreadDraftData(), ILIAS\Repository\lng(), ilObjForum\lookupForumIdByObjId(), ILIAS\Repository\object(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

Referenced by getContent().

1016  : void
1017  {
1019  $this->user->getId(),
1020  ilObjForum::lookupForumIdByObjId($this->object->getId())
1021  );
1022  if ($drafts === []) {
1023  return;
1024  }
1025 
1026  $table = new ForumDraftsTable(
1027  $this->object,
1028  $this->ui_factory,
1029  $this->httpRequest,
1030  $this->lng,
1031  $cmd,
1032  $this->ctrl,
1033  new DataFactory(),
1034  $this->user,
1035  $this->access->checkAccess('add_thread', '', $this->object->getRefId()),
1036  $this
1037  );
1038  $threadsTemplate = new ilTemplate(
1039  'tpl.forums_threads_liste.html',
1040  true,
1041  true,
1042  'components/ILIAS/Forum'
1043  );
1044  $threadsTemplate->setVariable('THREADS_DRAFTS_TABLE', $this->uiRenderer->render($table->getComponent()));
1045 
1046  $draft_modal = $this->factory->modal()->roundtrip(
1047  $this->lng->txt('drafts'),
1048  [$this->factory->legacy()->content($threadsTemplate->get())]
1049  );
1050  $this->modal_collection[] = $draft_modal;
1051  $edit_title = $this->factory->button()->standard($this->lng->txt('drafts'), '#')->withOnClick(
1052  $draft_modal->getShowSignal()
1053  );
1054  $this->toolbar->addComponent($edit_title);
1055  }
static lookupForumIdByObjId(int $obj_id)
factory()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getThreadDraftData(int $post_author_id, int $forum_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addEmptyThreadObject()

ilObjForumGUI::addEmptyThreadObject ( )
protected

Definition at line 4268 of file class.ilObjForumGUI.php.

References createEmptyThread().

4268  : void
4269  {
4270  $this->createEmptyThread();
4271  }
createEmptyThread()
Refactored thread creation to method, refactoring to a separate class should be done in next refactor...
+ Here is the call graph for this function:

◆ addLocatorItems()

ilObjForumGUI::addLocatorItems ( )
protected

Definition at line 4328 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\locator(), and ILIAS\Repository\object().

4328  : void
4329  {
4330  if ($this->object instanceof ilObjForum) {
4331  $this->locator->addItem(
4332  $this->object->getTitle(),
4333  $this->ctrl->getLinkTarget($this),
4334  '',
4335  $this->object->getRefId()
4336  );
4337  }
4338  }
+ Here is the call graph for this function:

◆ addThreadObject()

ilObjForumGUI::addThreadObject ( )
protected

Definition at line 4257 of file class.ilObjForumGUI.php.

References checkDraftAccess(), createThread(), ilForumPostDraft\isSavePostDraftAllowed(), ilForumPostDraft\newInstanceByDraftId(), and retrieveDraftId().

4257  : void
4258  {
4259  $draft = new ilForumPostDraft();
4262  $this->checkDraftAccess($draft);
4263  }
4264 
4265  $this->createThread($draft);
4266  }
checkDraftAccess(int|ilForumPostDraft $draft)
retrieveDraftId(bool $from_post=false)
createThread(ilForumPostDraft $draft, bool $createFromDraft=false)
Refactored thread creation to method, refactoring to a separate class should be done in next refactor...
static newInstanceByDraftId(int $draft_id)
+ Here is the call graph for this function:

◆ afterSave()

ilObjForumGUI::afterSave ( ilObject  $new_object)
protected
Parameters
ilObject | ilObjForum$new_object

Definition at line 1557 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl(), ilObject\getRefId(), and ILIAS\Repository\lng().

1557  : void
1558  {
1559  $this->tpl->setOnScreenMessage('success', $this->lng->txt('frm_added'), true);
1560  $this->ctrl->setParameter($this, 'ref_id', $new_object->getRefId());
1561  $this->ctrl->redirect($this, 'createThread');
1562  }
+ Here is the call graph for this function:

◆ askForPostActivationObject()

ilObjForumGUI::askForPostActivationObject ( )

Definition at line 2104 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\lng(), setDisplayConfirmPostActivation(), and viewThreadObject().

2104  : void
2105  {
2106  if (!$this->is_moderator) {
2107  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2108  }
2109 
2110  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2111  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2112  }
2113 
2114  $this->setDisplayConfirmPostActivation(true);
2115 
2116  $this->viewThreadObject();
2117  }
setDisplayConfirmPostActivation(bool $status=false)
+ Here is the call graph for this function:

◆ autosaveDraftAsyncObject()

ilObjForumGUI::autosaveDraftAsyncObject ( )
protected

Definition at line 5365 of file class.ilObjForumGUI.php.

References $message, ILIAS\Repository\access(), getReplyEditForm(), handleFormInput(), ILIAS\FileDelivery\http(), ilForumPostDraft\isSavePostDraftAllowed(), ilObjForum\lookupForumIdByRefId(), retrieveDraftId(), ilUtil\stripSlashes(), and ILIAS\Repository\user().

5365  : void
5366  {
5367  if ($this->requestAction !== 'ready_showreply' &&
5369  $this->access->checkAccess('read', '', $this->object->getRefId()) &&
5370  $this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
5371  $action = new ilForumAutoSaveAsyncDraftAction(
5372  $this->user,
5373  $this->getReplyEditForm(),
5374  $this->objProperties,
5375  $this->objCurrentTopic,
5376  $this->objCurrentPost,
5377  function (string $message): string {
5378  return $this->handleFormInput($message);
5379  },
5380  $this->retrieveDraftId(),
5381  ilObjForum::lookupForumIdByRefId($this->ref_id),
5382  ilUtil::stripSlashes($this->requestAction)
5383  );
5384 
5385  $this->http->saveResponse($this->http->response()->withBody(
5386  \ILIAS\Filesystem\Stream\Streams::ofString(json_encode(
5387  $action->executeAndGetResponseObject(),
5388  JSON_THROW_ON_ERROR
5389  ))
5390  ));
5391  }
5392 
5393  $this->http->sendResponse();
5394  $this->http->close();
5395  }
Interface Observer Contains several chained tasks and infos about them.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static lookupForumIdByRefId(int $ref_id)
static http()
Fetches the global http state from ILIAS.
handleFormInput(string $a_text, bool $a_stripslashes=true)
retrieveDraftId(bool $from_post=false)
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:

◆ autosaveThreadDraftAsyncObject()

ilObjForumGUI::autosaveThreadDraftAsyncObject ( )
protected

Definition at line 5397 of file class.ilObjForumGUI.php.

References $message, ILIAS\Repository\access(), buildThreadForm(), handleFormInput(), ILIAS\FileDelivery\http(), ilForumPostDraft\isSavePostDraftAllowed(), ilObjForum\lookupForumIdByRefId(), retrieveDraftId(), ilUtil\stripSlashes(), and ILIAS\Repository\user().

5397  : void
5398  {
5399  if ($this->requestAction !== 'ready_showreply' &&
5401  $this->access->checkAccess('read', '', $this->object->getRefId()) &&
5402  $this->access->checkAccess('add_thread', '', $this->object->getRefId())) {
5403  $action = new ilForumAutoSaveAsyncDraftAction(
5404  $this->user,
5405  $this->buildThreadForm(),
5406  $this->objProperties,
5407  $this->objCurrentTopic,
5408  $this->objCurrentPost,
5409  function (string $message): string {
5410  return $this->handleFormInput($message, false);
5411  },
5412  $this->retrieveDraftId(),
5413  ilObjForum::lookupForumIdByRefId($this->ref_id),
5414  ilUtil::stripSlashes($this->requestAction)
5415  );
5416 
5417  $this->http->saveResponse($this->http->response()->withBody(
5418  \ILIAS\Filesystem\Stream\Streams::ofString(json_encode(
5419  $action->executeAndGetResponseObject(),
5420  JSON_THROW_ON_ERROR
5421  ))
5422  ));
5423  }
5424 
5425  $this->http->sendResponse();
5426  $this->http->close();
5427  }
buildThreadForm(bool $isDraft=false)
Interface Observer Contains several chained tasks and infos about them.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static lookupForumIdByRefId(int $ref_id)
static http()
Fetches the global http state from ILIAS.
handleFormInput(string $a_text, bool $a_stripslashes=true)
retrieveDraftId(bool $from_post=false)
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:

◆ buildMinimalThreadForm()

ilObjForumGUI::buildMinimalThreadForm ( bool  $isDraft = false)
private

Definition at line 3985 of file class.ilObjForumGUI.php.

References ilForumThreadFormGUI\ALIAS_INPUT, ILIAS\Repository\int(), isWritingWithPseudonymAllowed(), ILIAS\Repository\rbac(), ilForumThreadFormGUI\SUBJECT_INPUT, and ILIAS\Repository\user().

Referenced by createEmptyThread(), createThread(), and createThreadObject().

3986  {
3987  $draftId = (int) ($this->httpRequest->getQueryParams()['draft_id'] ?? 0);
3988  $allowNotification = !$this->objProperties->isAnonymized() && !$this->user->isAnonymous();
3989 
3990  $mail = new ilMail($this->user->getId());
3991  if (!$this->rbac->system()->checkAccess('internal_mail', $mail->getMailObjectReferenceId())) {
3992  $allowNotification = false;
3993  }
3994 
3995  $minimal_form = new ilForumThreadFormGUI(
3996  $this,
3997  $this->objProperties,
3999  $allowNotification,
4000  $isDraft,
4001  $draftId
4002  );
4003 
4004  $minimal_form->addInputItem(ilForumThreadFormGUI::ALIAS_INPUT);
4005  $minimal_form->addInputItem(ilForumThreadFormGUI::SUBJECT_INPUT);
4006 
4007  $minimal_form->generateMinimalForm();
4008 
4009  return $minimal_form;
4010  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildThreadForm()

ilObjForumGUI::buildThreadForm ( bool  $isDraft = false)
private

Definition at line 3953 of file class.ilObjForumGUI.php.

References ilForumThreadFormGUI\ALIAS_INPUT, ilForumThreadFormGUI\ALLOW_NOTIFICATION_INPUT, decorateWithAutosave(), ilForumThreadFormGUI\FILE_UPLOAD_INPUT, ILIAS\Repository\int(), isWritingWithPseudonymAllowed(), ilForumThreadFormGUI\MESSAGE_INPUT, ILIAS\Repository\rbac(), ilForumThreadFormGUI\SUBJECT_INPUT, and ILIAS\Repository\user().

Referenced by autosaveThreadDraftAsyncObject(), createEmptyThread(), createThread(), createThreadObject(), editThreadDraftObject(), saveThreadAsDraftObject(), and updateThreadDraftObject().

3954  {
3955  $draftId = (int) ($this->httpRequest->getQueryParams()['draft_id'] ?? 0);
3956  $allowNotification = !$this->objProperties->isAnonymized() && !$this->user->isAnonymous();
3957 
3958  $mail = new ilMail($this->user->getId());
3959  if (!$this->rbac->system()->checkAccess('internal_mail', $mail->getMailObjectReferenceId())) {
3960  $allowNotification = false;
3961  }
3962 
3963  $default_form = new ilForumThreadFormGUI(
3964  $this,
3965  $this->objProperties,
3967  $allowNotification,
3968  $isDraft,
3969  $draftId
3970  );
3971 
3972  $default_form->addInputItem(ilForumThreadFormGUI::ALIAS_INPUT);
3973  $default_form->addInputItem(ilForumThreadFormGUI::SUBJECT_INPUT);
3974  $default_form->addInputItem(ilForumThreadFormGUI::MESSAGE_INPUT);
3975  $default_form->addInputItem(ilForumThreadFormGUI::FILE_UPLOAD_INPUT);
3976  $default_form->addInputItem(ilForumThreadFormGUI::ALLOW_NOTIFICATION_INPUT);
3977 
3978  $default_form->generateDefaultForm();
3979 
3980  $this->decorateWithAutosave($default_form);
3981 
3982  return $default_form;
3983  }
decorateWithAutosave(ilPropertyFormGUI $form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancelDraftObject()

ilObjForumGUI::cancelDraftObject ( )

Definition at line 2184 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl(), hasDraftAccess(), ilForumDraftsHistory\MEDIAOBJECT_TYPE, ilForumPostDraft\MEDIAOBJECT_TYPE, ilForumUtil\moveMediaObjects(), ilForumPostDraft\newInstanceByDraftId(), retrieveDraftId(), and viewThreadObject().

2184  : void
2185  {
2186  $this->requestAction = '';
2187  $draft_id = $this->retrieveDraftId();
2188  if ($draft_id > 0) {
2189  $history_entry = new ilForumDraftsHistory();
2190  $history_entry->populateWithFirstAutosaveByDraftId($draft_id);
2191  $draft = ilForumPostDraft::newInstanceByDraftId($history_entry->getDraftId());
2192  if ($this->hasDraftAccess($draft)) {
2193  $draft->setPostSubject($history_entry->getPostSubject());
2194  $draft->setPostMessage($history_entry->getPostMessage());
2195 
2197  $history_entry->getPostMessage(),
2199  $history_entry->getHistoryId(),
2201  $draft->getDraftId()
2202  );
2203 
2204  $draft->updateDraft();
2205 
2206  $history_entry->deleteHistoryByDraftIds([$draft->getDraftId()]);
2207  }
2208  }
2209 
2210  $this->ctrl->clearParameters($this);
2211  $this->viewThreadObject();
2212  }
hasDraftAccess(int|ilForumPostDraft $draft)
static moveMediaObjects(string $post_message, string $source_type, int $source_id, string $target_type, int $target_id, int $direction=0)
Class ilForumDraftHistory.
retrieveDraftId(bool $from_post=false)
static newInstanceByDraftId(int $draft_id)
+ Here is the call graph for this function:

◆ cancelMoveThreadsObject()

ilObjForumGUI::cancelMoveThreadsObject ( )

Definition at line 3811 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl(), and ilSession\set().

3811  : void
3812  {
3813  ilSession::set('threads2move', []);
3814  $this->ctrl->redirect($this, 'showThreads');
3815  }
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

◆ cancelPostObject()

ilObjForumGUI::cancelPostObject ( )

Definition at line 2170 of file class.ilObjForumGUI.php.

References hasDraftAccess(), ilForumPostDraft\newInstanceByDraftId(), retrieveDraftId(), and viewThreadObject().

2170  : void
2171  {
2172  $this->requestAction = '';
2173  $draft_id = $this->retrieveDraftId(true);
2174  if ($draft_id > 0) {
2175  $draft = ilForumPostDraft::newInstanceByDraftId($draft_id);
2176  if ($this->hasDraftAccess($draft)) {
2177  $draft->deleteDraftsByDraftIds([$draft_id]);
2178  }
2179  }
2180 
2181  $this->viewThreadObject();
2182  }
hasDraftAccess(int|ilForumPostDraft $draft)
retrieveDraftId(bool $from_post=false)
static newInstanceByDraftId(int $draft_id)
+ Here is the call graph for this function:

◆ checkDraftAccess()

ilObjForumGUI::checkDraftAccess ( int|ilForumPostDraft  $draft)
private

Definition at line 5706 of file class.ilObjForumGUI.php.

References hasDraftAccess(), ILIAS\Repository\lng(), and ilForumPostDraft\newInstanceByDraftId().

Referenced by addThreadObject(), deleteSelectedDraft(), deliverDraftZipFileObject(), doHistoryCheck(), editThreadDraftObject(), publishDraftObject(), publishThreadDraftObject(), restoreFromHistoryObject(), saveAsDraftObject(), saveThreadAsDraftObject(), updateDraftObject(), and updateThreadDraftObject().

5706  : void
5707  {
5708  $draft = is_int($draft) ? ilForumPostDraft::newInstanceByDraftId($draft) : $draft;
5709  if (!$this->hasDraftAccess($draft)) {
5710  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5711  }
5712  }
hasDraftAccess(int|ilForumPostDraft $draft)
static newInstanceByDraftId(int $draft_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkUsersViewMode()

ilObjForumGUI::checkUsersViewMode ( )

Definition at line 3069 of file class.ilObjForumGUI.php.

References $selectedSorting, ilSession\get(), ilObjectGUI\getObject(), ILIAS\Repository\int(), null, ilSession\set(), ilForumProperties\VIEW_DATE_ASC, ilForumProperties\VIEW_DATE_DESC, and ilForumProperties\VIEW_TREE.

Referenced by getSafePostCommands().

3069  : void
3070  {
3071  $this->selectedSorting = $this->objProperties->getDefaultView();
3072 
3073  if ($this->getObject() !== null) {
3074  $view_mode = 'viewmode_' . $this->getObject()->getId();
3075  if (in_array((int) ilSession::get($view_mode), [
3079  ], true)) {
3080  $this->selectedSorting = ilSession::get($view_mode);
3081  }
3082 
3083  if (
3084  isset($this->httpRequest->getQueryParams()['viewmode']) &&
3085  (int) $this->httpRequest->getQueryParams()['viewmode'] !== $this->selectedSorting
3086  ) {
3087  $this->selectedSorting = (int) $this->httpRequest->getQueryParams()['viewmode'];
3088  }
3089 
3090  if (!in_array($this->selectedSorting, [
3094  ], true)) {
3095  $this->selectedSorting = $this->objProperties->getDefaultView();
3096  }
3097 
3098  ilSession::set($view_mode, $this->selectedSorting);
3099  }
3100  }
static get(string $a_var)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDeleteThreadDraftsObject()

ilObjForumGUI::confirmDeleteThreadDraftsObject ( )
protected

Definition at line 1899 of file class.ilObjForumGUI.php.

References ilObject\_getIcon(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilForumPostDraft\getDraftInstancesByUserId(), ilObject\getId(), ilForumPostDraft\getThreadDraftData(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ilObjForum\lookupForumIdByObjId(), ILIAS\Repository\object(), ILIAS\Repository\refinery(), showThreadsObject(), and ILIAS\Repository\user().

1899  : void
1900  {
1901  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1902  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1903  }
1904 
1905  $draft_ids = $this->http->wrapper()->query()->retrieve(
1906  'forum_drafts_delete_draft_ids',
1907  $this->refinery->byTrying([
1908  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
1909  $this->refinery->always([])
1910  ])
1911  );
1912 
1913  if ($draft_ids === []) {
1914  $draft_ids = $this->http->wrapper()->query()->retrieve(
1915  'forum_drafts_delete_draft_ids',
1916  $this->refinery->byTrying([
1917  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string()),
1918  $this->refinery->always([])
1919  ])
1920  );
1921 
1922  if (!isset($draft_ids[0]) || $draft_ids[0] !== 'ALL_OBJECTS') {
1923  $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_at_least_one_thread'));
1924  $this->showThreadsObject();
1925  return;
1926  }
1927 
1928  $draft_ids = array_filter(array_map(
1929  static function (array $draft): int {
1930  return $draft['draft_id'] ?? 0;
1931  },
1933  $this->user->getId(),
1934  ilObjForum::lookupForumIdByObjId($this->object->getId())
1935  )
1936  ));
1937  }
1938 
1939  $confirmation = new ilConfirmationGUI();
1940  $confirmation->setFormAction($this->ctrl->getFormAction($this, 'deleteThreadDrafts'));
1941  $confirmation->setHeaderText($this->lng->txt('sure_delete_drafts'));
1942  $confirmation->setCancel($this->lng->txt('cancel'), 'showThreads');
1943  $confirmation->setConfirm($this->lng->txt('confirm'), 'deleteThreadDrafts');
1944  $instances = ilForumPostDraft::getDraftInstancesByUserId($this->user->getId());
1945  foreach ($draft_ids as $draftId) {
1946  if (array_key_exists($draftId, $instances)) {
1947  $confirmation->addItem('draft_ids[]', (string) $draftId, $instances[$draftId]->getPostSubject());
1948  }
1949  }
1950 
1951  $this->tpl->setContent($confirmation->getHTML());
1952  }
static lookupForumIdByObjId(int $obj_id)
static http()
Fetches the global http state from ILIAS.
static getThreadDraftData(int $post_author_id, int $forum_id)
static getDraftInstancesByUserId(int $user_id)
+ Here is the call graph for this function:

◆ confirmMergeThreadsObject()

ilObjForumGUI::confirmMergeThreadsObject ( )

Definition at line 4701 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ensureThreadBelongsToForum(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ilForumTopic\lookupCreationDate(), ilForumTopic\lookupForumIdByTopicId(), ilForumTopic\lookupTitle(), mergeThreadsObject(), ILIAS\Repository\object(), and showThreadsObject().

4701  : void
4702  {
4703  if (!$this->is_moderator) {
4704  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4705  }
4706 
4707  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4708  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4709  }
4710 
4711  $sourceThreadId = (int) ($this->httpRequest->getQueryParams()['merge_thread_id'] ?? 0);
4712  $targetThreadIds = array_values(
4713  array_filter(array_map(intval(...), (array) ($this->httpRequest->getParsedBody()['thread_ids'] ?? [])))
4714  );
4715 
4716  if ($sourceThreadId <= 0 || count($targetThreadIds) !== 1) {
4717  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
4718  $this->mergeThreadsObject();
4719  return;
4720  }
4721 
4722  $targetThreadId = current($targetThreadIds);
4723  if ($sourceThreadId === $targetThreadId) {
4724  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('error_same_thread_ids'));
4725  $this->showThreadsObject();
4726  return;
4727  }
4728 
4729  if (ilForumTopic::lookupForumIdByTopicId($sourceThreadId) !== ilForumTopic::lookupForumIdByTopicId($targetThreadId)) {
4730  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('not_allowed_to_merge_into_another_forum'));
4731  $this->ctrl->clearParameters($this);
4732  $this->showThreadsObject();
4733  return;
4734  }
4735 
4736  if (ilForumTopic::lookupCreationDate($sourceThreadId) < ilForumTopic::lookupCreationDate($targetThreadId)) {
4737  $this->tpl->setOnScreenMessage('info', $this->lng->txt('switch_threads_for_merge'));
4738  }
4739 
4740  $this->ensureThreadBelongsToForum($this->object->getId(), new ilForumTopic($sourceThreadId));
4741  $this->ensureThreadBelongsToForum($this->object->getId(), new ilForumTopic($targetThreadId));
4742 
4743  $c_gui = new ilConfirmationGUI();
4744 
4745  $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performMergeThreads'));
4746  $c_gui->setHeaderText($this->lng->txt('frm_sure_merge_threads'));
4747  $c_gui->setCancel($this->lng->txt('cancel'), 'showThreads');
4748  $c_gui->setConfirm($this->lng->txt('confirm'), 'performMergeThreads');
4749 
4750  $c_gui->addItem(
4751  'thread_ids[]',
4752  (string) $sourceThreadId,
4753  sprintf($this->lng->txt('frm_merge_src'), ilForumTopic::lookupTitle($sourceThreadId))
4754  );
4755  $c_gui->addItem(
4756  'thread_ids[]',
4757  (string) $targetThreadId,
4758  sprintf($this->lng->txt('frm_merge_target'), ilForumTopic::lookupTitle($targetThreadId))
4759  );
4760  $this->tpl->setContent($c_gui->getHTML());
4761  }
static lookupTitle(int $a_topic_id)
static lookupCreationDate(int $thread_id)
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
static lookupForumIdByTopicId(int $a_topic_id)
+ Here is the call graph for this function:

◆ createEmptyThread()

ilObjForumGUI::createEmptyThread ( )
private

Refactored thread creation to method, refactoring to a separate class should be done in next refactoring steps.

Definition at line 4173 of file class.ilObjForumGUI.php.

References $is_moderator, ILIAS\Repository\access(), buildMinimalThreadForm(), buildThreadForm(), ILIAS\Repository\ctrl(), ilAccordionGUI\FIRST_OPEN, ilForumUtil\getPublicUserAlias(), handleFormInput(), isWritingWithPseudonymAllowed(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ILIAS\Repository\user().

Referenced by addEmptyThreadObject().

4173  : void
4174  {
4175  if (!$this->access->checkAccess('add_thread', '', $this->object->getRefId()) ||
4176  !$this->access->checkAccess('read', '', $this->object->getRefId())) {
4177  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4178  }
4179 
4180  $frm = $this->object->Forum;
4181  $frm->setForumId($this->object->getId());
4182  $frm->setForumRefId($this->object->getRefId());
4183  $frm->setMDB2WhereCondition('top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
4184  $topicData = $frm->getOneTopic();
4185 
4186  $form = $this->buildThreadForm();
4187  $minimal_form = $this->buildMinimalThreadForm();
4188 
4189  if ($minimal_form->checkInput()) {
4190  $userIdForDisplayPurposes = $this->user->getId();
4191  if ($this->isWritingWithPseudonymAllowed()) {
4192  $userIdForDisplayPurposes = 0;
4193  }
4194 
4195  $status = true;
4196  if (
4197  ($this->objProperties->isPostActivationEnabled() && !$this->is_moderator) ||
4198  $this->objCurrentPost->isAnyParentDeactivated()
4199  ) {
4200  $status = false;
4201  }
4202 
4203  $newThread = new ilForumTopic(0, true, true);
4204  $newThread->setForumId($topicData->getTopPk());
4205  $newThread->setThrAuthorId($this->user->getId());
4206  $newThread->setDisplayUserId($userIdForDisplayPurposes);
4207  $newThread->setSubject($this->handleFormInput($minimal_form->getInput('subject'), false));
4208  $newThread->setUserAlias(ilForumUtil::getPublicUserAlias(
4209  $minimal_form->getInput('alias'),
4210  $this->objProperties->isAnonymized()
4211  ));
4212 
4213  $frm->generateThread(
4214  $newThread,
4215  '',
4216  false,
4217  false, // #19980
4218  $status,
4219  false
4220  );
4221 
4222  $frm->setDbTable('frm_data');
4223  $frm->setMDB2WhereCondition('top_pk = %s ', ['integer'], [$topicData->getTopPk()]);
4224  $frm->updateVisits($topicData->getTopPk());
4225 
4226  $this->tpl->setOnScreenMessage('success', $this->lng->txt('forums_thread_new_entry'), true);
4227  $this->ctrl->redirect($this);
4228  }
4229 
4230  $form->setValuesByPost();
4231 
4232  if (!$this->objProperties->isAnonymized()) {
4233  $form->getItemByPostVar('alias')->setValue($this->user->getLogin());
4234  }
4235 
4236  $accordion = new ilAccordionGUI();
4237  $accordion->setId('acc_' . $this->obj_id);
4238  $accordion->setBehaviour(ilAccordionGUI::FIRST_OPEN);
4239  $accordion->addItem($this->lng->txt('new_thread_with_post'), $form->getHTML());
4240  $accordion->addItem($this->lng->txt('empty_thread'), $minimal_form->getHTML());
4241 
4242  $this->tpl->setContent($accordion->getHTML());
4243  }
buildThreadForm(bool $isDraft=false)
buildMinimalThreadForm(bool $isDraft=false)
static getPublicUserAlias(string $user_alias, bool $is_anonymized)
handleFormInput(string $a_text, bool $a_stripslashes=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createThread()

ilObjForumGUI::createThread ( ilForumPostDraft  $draft,
bool  $createFromDraft = false 
)
private

Refactored thread creation to method, refactoring to a separate class should be done in next refactoring steps.

Definition at line 4040 of file class.ilObjForumGUI.php.

References $GLOBALS, $is_moderator, ilObjMediaObject\_exists(), ilRTE\_getMediaObjects(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), ilRTE\_replaceMediaObjectImageSrc(), ilObjMediaObject\_saveUsage(), ILIAS\Repository\access(), buildMinimalThreadForm(), buildThreadForm(), ILIAS\Repository\ctrl(), ilForumPostDraft\deleteDraft(), ilAccordionGUI\FIRST_OPEN, ilForumPostDraft\getDraftId(), ilForumPostDraft\getPostAuthorId(), ilForumPostDraft\getPostDisplayUserId(), ilForumPostDraft\getPostUserAlias(), ilForumUtil\getPublicUserAlias(), ilForumPostDraft\getRCID(), handleFormInput(), ilForumPostDraft\isNotificationEnabled(), ilForumPostDraft\isPostNotificationEnabled(), isWritingWithPseudonymAllowed(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilFileDataForum\storeUploadedFiles(), and ILIAS\Repository\user().

Referenced by addThreadObject(), and publishThreadDraftObject().

4040  : void
4041  {
4042  if (!$this->access->checkAccess('add_thread', '', $this->object->getRefId()) ||
4043  !$this->access->checkAccess('read', '', $this->object->getRefId())) {
4044  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4045  }
4046 
4047  $frm = $this->object->Forum;
4048  $frm->setForumId($this->object->getId());
4049  $frm->setForumRefId($this->object->getRefId());
4050  $frm->setMDB2WhereCondition('top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
4051  $topicData = $frm->getOneTopic();
4052 
4053  $form = $this->buildThreadForm($createFromDraft);
4054  $minimal_form = $this->buildMinimalThreadForm($createFromDraft);
4055 
4056  if ($form->checkInput()) {
4057  $userIdForDisplayPurposes = $this->user->getId();
4058  if ($this->isWritingWithPseudonymAllowed()) {
4059  $userIdForDisplayPurposes = 0;
4060  }
4061 
4062  $status = true;
4063  if (
4064  ($this->objProperties->isPostActivationEnabled() && !$this->is_moderator) ||
4065  $this->objCurrentPost->isAnyParentDeactivated()
4066  ) {
4067  $status = false;
4068  }
4069 
4070  if ($createFromDraft) {
4071  $newThread = new ilForumTopic(0, true, true);
4072  $newThread->setForumId($topicData->getTopPk());
4073  $newThread->setThrAuthorId($draft->getPostAuthorId());
4074  $newThread->setDisplayUserId($draft->getPostDisplayUserId());
4075  $newThread->setSubject($this->handleFormInput($form->getInput('subject'), false));
4076  $newThread->setUserAlias($draft->getPostUserAlias());
4077 
4078  $newPost = $frm->generateThread(
4079  $newThread,
4080  ilRTE::_replaceMediaObjectImageSrc($form->getInput('message')),
4081  $draft->isNotificationEnabled() && !$this->user->isAnonymous(),
4082  $draft->isPostNotificationEnabled() && !$this->user->isAnonymous(),
4083  $status
4084  );
4085  } else {
4086  $newThread = new ilForumTopic(0, true, true);
4087  $newThread->setForumId($topicData->getTopPk());
4088  $newThread->setThrAuthorId($this->user->getId());
4089  $newThread->setDisplayUserId($userIdForDisplayPurposes);
4090  $newThread->setSubject($this->handleFormInput($form->getInput('subject'), false));
4091  $newThread->setUserAlias(ilForumUtil::getPublicUserAlias(
4092  $form->getInput('alias'),
4093  $this->objProperties->isAnonymized()
4094  ));
4095 
4096  $newPost = $frm->generateThread(
4097  $newThread,
4098  ilRTE::_replaceMediaObjectImageSrc($form->getInput('message')),
4099  $form->getItemByPostVar('notify') && $form->getInput('notify') && !$this->user->isAnonymous(),
4100  false, // #19980
4101  $status
4102  );
4103  }
4104 
4105  $post_obj = new ilForumPost($newPost);
4106  if ($draft->getRCID() > 0) {
4107  $post_obj->setRCID($draft->getRCID());
4108  $post_obj->update();
4109  }
4110 
4111  if ($this->objProperties->isFileUploadAllowed()) {
4112  $file = $_FILES['userfile'];
4113  if (is_array($file) && !empty($file)) {
4114  $fileData = new ilFileDataForum($this->object->getId(), $newPost);
4115  $fileData->storeUploadedFiles();
4116  }
4117  }
4118 
4119  $frm->setDbTable('frm_data');
4120  $frm->setMDB2WhereCondition('top_pk = %s ', ['integer'], [$topicData->getTopPk()]);
4121  $frm->updateVisits($topicData->getTopPk());
4122 
4123  if ($createFromDraft) {
4124  $mediaObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
4125  } else {
4126  $mediaObjects = ilRTE::_getMediaObjects($form->getInput('message'));
4127  }
4128  foreach ($mediaObjects as $mob) {
4129  if (ilObjMediaObject::_exists($mob)) {
4130  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
4131  ilObjMediaObject::_saveUsage($mob, 'frm:html', $newPost);
4132  }
4133  }
4134 
4135  if ($draft->getDraftId() > 0) {
4136  $draftHistory = new ilForumDraftsHistory();
4137  $draftHistory->deleteHistoryByDraftIds([$draft->getDraftId()]);
4138  $draft->deleteDraft();
4139  }
4140 
4141  $GLOBALS['ilAppEventHandler']->raise(
4142  'components/ILIAS/Forum',
4143  'createdPost',
4144  [
4145  'object' => $this->object,
4146  'ref_id' => $this->object->getRefId(),
4147  'post' => $post_obj,
4148  'notify_moderators' => !$status
4149  ]
4150  );
4151 
4152  $this->tpl->setOnScreenMessage('success', $this->lng->txt('forums_thread_new_entry'), true);
4153  $this->ctrl->redirect($this);
4154  }
4155 
4156  $form->setValuesByPost();
4157  if (!$this->objProperties->isAnonymized()) {
4158  $form->getItemByPostVar('alias')->setValue($this->user->getLogin());
4159  }
4160 
4161  $accordion = new ilAccordionGUI();
4162  $accordion->setId('acc_' . $this->obj_id);
4163  $accordion->setBehaviour(ilAccordionGUI::FIRST_OPEN);
4164  $accordion->addItem($this->lng->txt('new_thread_with_post'), $form->getHTML());
4165  $accordion->addItem($this->lng->txt('empty_thread'), $minimal_form->getHTML());
4166 
4167  $this->tpl->setContent($accordion->getHTML());
4168  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static _getMediaObjects(string $a_text, int $a_direction=0)
Returns all media objects found in the passed string.
buildThreadForm(bool $isDraft=false)
static _saveUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Save usage of mob within another container (e.g.
buildMinimalThreadForm(bool $isDraft=false)
Class ilForumDraftHistory.
$GLOBALS["DIC"]
Definition: wac.php:53
static getPublicUserAlias(string $user_alias, bool $is_anonymized)
handleFormInput(string $a_text, bool $a_stripslashes=true)
static _exists(int $id, bool $reference=false, ?string $type=null)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
static _removeUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Remove usage of mob in another container.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createThreadObject()

ilObjForumGUI::createThreadObject ( )
private

Definition at line 4012 of file class.ilObjForumGUI.php.

References ilObjectGUI\$tpl, ILIAS\Repository\access(), buildMinimalThreadForm(), buildThreadForm(), ilAccordionGUI\FIRST_OPEN, ILIAS\UICore\GlobalTemplate\get(), ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), and ILIAS\UICore\GlobalTemplate\setVariable().

4012  : void
4013  {
4014  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4015  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4016  }
4017 
4018  if (!$this->access->checkAccess('add_thread', '', $this->object->getRefId())) {
4019  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4020  }
4021 
4022  $tpl = new ilTemplate('tpl.create_thread_form.html', true, true, 'components/ILIAS/Forum');
4023 
4024  $accordion = new ilAccordionGUI();
4025  $accordion->setId('acc_' . $this->obj_id);
4026  $accordion->setBehaviour(ilAccordionGUI::FIRST_OPEN);
4027 
4028  $accordion->addItem($this->lng->txt('new_thread_with_post'), $this->buildThreadForm()->getHTML());
4029  $accordion->addItem($this->lng->txt('empty_thread'), $this->buildMinimalThreadForm()->getHTML());
4030 
4031  $tpl->setVariable('CREATE_FORM', $accordion->getHTML());
4033 
4034  $this->tpl->setContent($tpl->get());
4035  }
buildThreadForm(bool $isDraft=false)
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
buildMinimalThreadForm(bool $isDraft=false)
ilGlobalTemplateInterface $tpl
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ createTopLevelPostObject()

ilObjForumGUI::createTopLevelPostObject ( )

Definition at line 2560 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl(), getOrderByParam(), ilForumPostDraft\isSavePostDraftAllowed(), null, retrieveDraftId(), ILIAS\Repository\user(), and viewThreadObject().

2560  : void
2561  {
2562  $draft_obj = null;
2563  $draft_id = $this->retrieveDraftId();
2564 
2565  if ($draft_id > 0 && !$this->user->isAnonymous()
2567  $draft_obj = new ilForumPostDraft(
2568  $this->user->getId(),
2569  $this->objCurrentPost->getId(),
2570  $draft_id
2571  );
2572  }
2573 
2574  if ($draft_obj instanceof ilForumPostDraft && $draft_obj->getDraftId() > 0) {
2575  $this->ctrl->setParameter($this, 'action', 'editdraft');
2576  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2577  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
2578  $this->ctrl->setParameter($this, 'draft_id', $draft_obj->getDraftId());
2579  $this->ctrl->setParameter($this, 'page', 0);
2580  $this->ctrl->setParameter(
2581  $this,
2582  'orderby',
2583  $this->getOrderByParam()
2584  );
2585  $this->ctrl->redirect($this, 'editDraft');
2586  } else {
2587  $this->viewThreadObject();
2588  }
2589  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
retrieveDraftId(bool $from_post=false)
+ Here is the call graph for this function:

◆ decorateWithAutosave()

ilObjForumGUI::decorateWithAutosave ( ilPropertyFormGUI  $form)
private

Definition at line 226 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl(), ilFormGUI\getId(), ilUtil\getImagePath(), ilForumPostDraft\isAutoSavePostDraftAllowed(), ILIAS\Repository\lng(), ilForumPostDraft\lookupAutosaveInterval(), retrieveDraftId(), and ilUtil\stripSlashes().

Referenced by buildThreadForm(), and initReplyEditForm().

226  : void
227  {
230 
231  $this->tpl->addJavaScript('assets/js/autosave_forum.js');
232  $autosave_cmd = 'autosaveDraftAsync';
233  if ($this->objCurrentPost->getId() === 0 && $this->objCurrentPost->getThreadId() === 0) {
234  $autosave_cmd = 'autosaveThreadDraftAsync';
235  }
236  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
237  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
238  $this->ctrl->setParameter($this, 'draft_id', $this->retrieveDraftId());
239  $this->ctrl->setParameter($this, 'action', ilUtil::stripSlashes($this->requestAction));
240  $this->tpl->addOnLoadCode(
241  "il.Language.setLangVar('saving', " . json_encode($this->lng->txt('saving'), JSON_THROW_ON_ERROR) . ');'
242  );
243 
244  $this->tpl->addOnLoadCode('il.ForumDraftsAutosave.init(' . json_encode([
245  'loading_img_src' => ilUtil::getImagePath('media/loader.svg'),
246  'draft_id' => $this->retrieveDraftId(),
247  'interval' => $interval * 1000,
248  'url' => $this->ctrl->getFormAction($this, $autosave_cmd, '', true),
249  'selectors' => [
250  'form' => '#form_' . $form->getId()
251  ]
252  ], JSON_THROW_ON_ERROR) . ');');
253  }
254  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
retrieveDraftId(bool $from_post=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteMobsOfDraft()

ilObjForumGUI::deleteMobsOfDraft ( int  $draft_id,
string  $message 
)
protected

Definition at line 5317 of file class.ilObjForumGUI.php.

References ilObjMediaObject\_exists(), ilRTE\_getMediaObjects(), ilObjMediaObject\_getMobsOfObject(), and ilObjMediaObject\_removeUsage().

Referenced by deleteSelectedDraft(), and deleteThreadDraftsObject().

5317  : void
5318  {
5319  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draft_id);
5320  $curMediaObjects = ilRTE::_getMediaObjects($message);
5321  foreach ($oldMediaObjects as $oldMob) {
5322  $found = false;
5323  foreach ($curMediaObjects as $curMob) {
5324  if ($oldMob === $curMob) {
5325  $found = true;
5326  break;
5327  }
5328  }
5329  if (!$found && ilObjMediaObject::_exists($oldMob)) {
5330  ilObjMediaObject::_removeUsage($oldMob, 'frm~d:html', $draft_id);
5331  $mob_obj = new ilObjMediaObject($oldMob);
5332  $mob_obj->delete();
5333  }
5334  }
5335  }
static _getMediaObjects(string $a_text, int $a_direction=0)
Returns all media objects found in the passed string.
static _exists(int $id, bool $reference=false, ?string $type=null)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
static _removeUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Remove usage of mob in another container.
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deletePostingDraftObject()

ilObjForumGUI::deletePostingDraftObject ( )
private

Definition at line 2040 of file class.ilObjForumGUI.php.

References deleteSelectedDraft().

2040  : void
2041  {
2042  $this->deleteSelectedDraft();
2043  }
+ Here is the call graph for this function:

◆ deletePostingObject()

ilObjForumGUI::deletePostingObject ( )
private

Definition at line 2002 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl(), ensureThreadBelongsToForum(), getForumObjects(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ILIAS\Repository\user().

2002  : void
2003  {
2004  if (
2005  !$this->user->isAnonymous() &&
2006  !$this->objCurrentTopic->isClosed() && (
2007  $this->is_moderator ||
2008  ($this->objCurrentPost->isOwner($this->user->getId()) && !$this->objCurrentPost->hasReplies())
2009  )
2010  ) {
2011  $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentPost->getThread());
2012 
2013  $oForumObjects = $this->getForumObjects();
2014  $forumObj = $oForumObjects['forumObj'];
2015 
2016  $frm = new ilForum();
2017  $frm->setForumId($forumObj->getId());
2018  $frm->setForumRefId($forumObj->getRefId());
2019  $dead_thr = $frm->deletePost($this->objCurrentPost->getId());
2020 
2021  // if complete thread was deleted ...
2022  if ($dead_thr === $this->objCurrentTopic->getId()) {
2023  $frm->setMDB2WhereCondition('top_frm_fk = %s ', ['integer'], [$forumObj->getId()]);
2024  $topicData = $frm->getOneTopic();
2025  $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_post_deleted'), true);
2026  if ($topicData->getTopNumThreads() > 0) {
2027  $this->ctrl->redirect($this, 'showThreads');
2028  } else {
2029  $this->ctrl->redirect($this, 'createThread');
2030  }
2031  }
2032  $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_post_deleted'), true);
2033  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
2034  $this->ctrl->redirect($this, 'viewThread');
2035  }
2036 
2037  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2038  }
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
+ Here is the call graph for this function:

◆ deleteSelectedDraft()

ilObjForumGUI::deleteSelectedDraft ( )
protected

Definition at line 5337 of file class.ilObjForumGUI.php.

References $GLOBALS, checkDraftAccess(), ILIAS\Repository\ctrl(), ilFileDataForumDrafts\delete(), deleteMobsOfDraft(), ILIAS\Repository\lng(), ILIAS\Repository\object(), retrieveDraftId(), and ILIAS\Repository\user().

Referenced by deletePostingDraftObject().

5337  : void
5338  {
5339  $draft = new ilForumPostDraft($this->user->getId(), $this->objCurrentPost->getId(), $this->retrieveDraftId());
5340  $this->checkDraftAccess($draft);
5341 
5342  $this->deleteMobsOfDraft($draft->getDraftId(), $draft->getPostMessage());
5343 
5344  $objFileDataForumDrafts = new ilFileDataForumDrafts($this->object->getId());
5345  $objFileDataForumDrafts->delete([$draft->getDraftId()]);
5346 
5347  $GLOBALS['ilAppEventHandler']->raise(
5348  'components/ILIAS/Forum',
5349  'deletedDraft',
5350  [
5351  'draftObj' => $draft,
5352  'obj_id' => $this->object->getId(),
5353  'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5354  ]
5355  );
5356  $draft->deleteDraft();
5357 
5358  $this->tpl->setOnScreenMessage('success', $this->lng->txt('delete_draft_successfully'), true);
5359  $this->ctrl->clearParameters($this);
5360  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
5361  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
5362  $this->ctrl->redirect($this, 'viewThread');
5363  }
delete(?array $posting_ids_to_delete=null)
$GLOBALS["DIC"]
Definition: wac.php:53
checkDraftAccess(int|ilForumPostDraft $draft)
deleteMobsOfDraft(int $draft_id, string $message)
retrieveDraftId(bool $from_post=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteThreadDraftsObject()

ilObjForumGUI::deleteThreadDraftsObject ( )
protected

Definition at line 3908 of file class.ilObjForumGUI.php.

References $GLOBALS, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), deleteMobsOfDraft(), ilForumPostDraft\getDraftInstancesByUserId(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ILIAS\Repository\user().

3908  : void
3909  {
3910  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3911  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3912  }
3913 
3914  $draftIds = array_filter((array) ($this->httpRequest->getParsedBody()['draft_ids'] ?? []));
3915  if ([] === $draftIds) {
3916  $draftIds = array_filter([(int) ($this->httpRequest->getQueryParams()['draft_id'] ?? 0)]);
3917  }
3918 
3919  $instances = ilForumPostDraft::getDraftInstancesByUserId($this->user->getId());
3920  $checkedDraftIds = [];
3921  foreach ($draftIds as $draftId) {
3922  if (array_key_exists($draftId, $instances)) {
3923  $checkedDraftIds[] = $draftId;
3924  $draft = $instances[$draftId];
3925 
3926  $this->deleteMobsOfDraft($draft->getDraftId(), $draft->getPostMessage());
3927 
3928  $GLOBALS['ilAppEventHandler']->raise(
3929  'components/ILIAS/Forum',
3930  'deletedDraft',
3931  [
3932  'draftObj' => $draft,
3933  'obj_id' => $this->object->getId(),
3934  'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
3935  ]
3936  );
3937 
3938  $draftFileData = new ilFileDataForumDrafts();
3939  $draftFileData->delete([$draft->getDraftId()]);
3940 
3941  $draft->deleteDraft();
3942  }
3943  }
3944 
3945  if (count($checkedDraftIds) > 1) {
3946  $this->tpl->setOnScreenMessage('info', $this->lng->txt('delete_drafts_successfully'), true);
3947  } else {
3948  $this->tpl->setOnScreenMessage('info', $this->lng->txt('delete_draft_successfully'), true);
3949  }
3950  $this->ctrl->redirect($this, 'showThreads');
3951  }
$GLOBALS["DIC"]
Definition: wac.php:53
deleteMobsOfDraft(int $draft_id, string $message)
static getDraftInstancesByUserId(int $user_id)
+ Here is the call graph for this function:

◆ deliverDraftZipFileObject()

ilObjForumGUI::deliverDraftZipFileObject ( )
protected

Definition at line 4817 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), checkDraftAccess(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ilForumPostDraft\newInstanceByDraftId(), and retrieveDraftId().

4817  : void
4818  {
4819  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4820  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4821  }
4822 
4824  $this->checkDraftAccess($draft);
4825  $fileData = new ilFileDataForumDrafts(0, $draft->getDraftId());
4826  if (!$fileData->deliverZipFile()) {
4827  $this->ctrl->redirect($this);
4828  }
4829  }
checkDraftAccess(int|ilForumPostDraft $draft)
retrieveDraftId(bool $from_post=false)
static newInstanceByDraftId(int $draft_id)
+ Here is the call graph for this function:

◆ deliverZipFileObject()

ilObjForumGUI::deliverZipFileObject ( )
protected

Definition at line 4831 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ensureThreadBelongsToForum(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

4831  : void
4832  {
4833  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4834  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4835  }
4836 
4837  $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentPost->getThread());
4838 
4839  $fileData = new ilFileDataForum($this->object->getId(), $this->objCurrentPost->getId());
4840  if (!$fileData->deliverZipFile()) {
4841  $this->ctrl->redirect($this);
4842  }
4843  }
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
+ Here is the call graph for this function:

◆ disableForumNotificationObject()

ilObjForumGUI::disableForumNotificationObject ( )
protected

Definition at line 4293 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\object(), showThreadsObject(), and ILIAS\Repository\user().

4293  : void
4294  {
4295  if (!$this->access->checkAccess('read', '', $this->object->getRefId()) || $this->user->isAnonymous()) {
4296  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4297  }
4298 
4299  $frm = $this->object->Forum;
4300  $frm->setForumId($this->object->getId());
4301  $frm->disableForumNotification($this->user->getId());
4302 
4303  if ($this->objCurrentTopic->getId() > 0) {
4304  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4305  $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_forum_notification_disabled'), true);
4306  $this->ctrl->redirect($this, 'viewThread');
4307  }
4308 
4309  $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_forum_notification_disabled'));
4310  $this->showThreadsObject();
4311  }
+ Here is the call graph for this function:

◆ displayConfirmPostActivation()

ilObjForumGUI::displayConfirmPostActivation ( )

Definition at line 2124 of file class.ilObjForumGUI.php.

References $display_confirm_post_activation.

Referenced by renderPostContent(), and renderSplitButton().

2124  : bool
2125  {
2127  }
bool $display_confirm_post_activation
+ Here is the caller graph for this function:

◆ doHistoryCheck()

ilObjForumGUI::doHistoryCheck ( int  $draftId)
private

Definition at line 5725 of file class.ilObjForumGUI.php.

References ilObjectGUI\$id, $message, ilRTE\_replaceMediaObjectImageSrc(), ilAccordionGUI\ALL_CLOSED, checkDraftAccess(), ilForumPostDraft\createDraftBackup(), ILIAS\Repository\ctrl(), ilAccordionGUI\FIRST_OPEN, ilDatePresentation\formatDate(), ilForumDraftsHistory\getInstancesByDraftId(), IL_CAL_DATETIME, iljQueryUtil\initjQuery(), ilForumPostDraft\isAutoSavePostDraftAllowed(), ILIAS\Repository\lng(), null, and ILIAS\UI\Implementation\Component\withAdditionalOnLoadCode().

Referenced by editDraftObject(), and editThreadDraftObject().

5725  : void
5726  {
5728  return;
5729  }
5730 
5731  $this->checkDraftAccess($draftId);
5732 
5734  $draftsFromHistory = ilForumDraftsHistory::getInstancesByDraftId($draftId);
5735  if ($draftsFromHistory !== []) {
5736  $form_tpl = new ilTemplate('tpl.restore_thread_draft.html', true, true, 'components/ILIAS/Forum');
5737 
5738  $first_open = null;
5739  foreach ($draftsFromHistory as $history_instance) {
5740  $accordion = new ilAccordionGUI();
5741  $accordion->setId('acc_' . $history_instance->getHistoryId());
5742  $accordion->setBehaviour(ilAccordionGUI::ALL_CLOSED);
5743  if ($first_open === null) {
5744  $first_open = $history_instance->getHistoryId();
5745  $accordion->setBehaviour(ilAccordionGUI::FIRST_OPEN);
5746  }
5747 
5748  $form_tpl->setCurrentBlock('list_item');
5749  $message = ilRTE::_replaceMediaObjectImageSrc($history_instance->getPostMessage(), 1);
5750 
5751  $history_date = ilDatePresentation::formatDate(new ilDateTime(
5752  $history_instance->getDraftDate(),
5754  ));
5755  $this->ctrl->setParameter($this, 'history_id', $history_instance->getHistoryId());
5756  $header = $history_date . ': ' . $history_instance->getPostSubject();
5757 
5758  $accordion_tpl = new ilTemplate(
5759  'tpl.restore_thread_draft_accordion_content.html',
5760  true,
5761  true,
5762  'components/ILIAS/Forum'
5763  );
5764  $accordion_tpl->setVariable('MESSAGE', $message);
5765  $accordion_tpl->setVariable(
5766  'BUTTON',
5767  $this->uiRenderer->render(
5768  $this->uiFactory->button()->standard(
5769  $this->lng->txt('restore'),
5770  $this->ctrl->getLinkTarget($this, 'restoreFromHistory')
5771  )
5772  )
5773  );
5774  $accordion->addItem($header, $accordion_tpl->get());
5775 
5776  $form_tpl->setVariable('ACC_AUTO_SAVE', $accordion->getHTML());
5777  $form_tpl->parseCurrentBlock();
5778  }
5779 
5780  $form_tpl->setVariable('RESTORE_DATA_EXISTS', 'found_threat_history_to_restore');
5781 
5782  $modal = $this->ui_factory->modal()->interruptive(
5783  $this->lng->txt('restore_draft_from_autosave'),
5784  $form_tpl->get(),
5785  '#'
5786  )->withAdditionalOnLoadCode(function (string $id): string {
5787  return "document.getElementById('$id').dataset.modalId = 'frm_autosave_restore';";
5788  });
5789 
5790  $this->modal_history = $this->ui_renderer->render($modal);
5791  } else {
5793  }
5794  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static getInstancesByDraftId(int $draft_id)
const IL_CAL_DATETIME
static createDraftBackup(int $draft_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
checkDraftAccess(int|ilForumPostDraft $draft)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
$message
Definition: xapiexit.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editDraftObject()

ilObjForumGUI::editDraftObject ( )
protected

Definition at line 5191 of file class.ilObjForumGUI.php.

References doHistoryCheck(), retrieveDraftId(), and viewThreadObject().

5191  : void
5192  {
5193  $this->doHistoryCheck($this->retrieveDraftId());
5194  $this->viewThreadObject();
5195  }
doHistoryCheck(int $draftId)
retrieveDraftId(bool $from_post=false)
+ Here is the call graph for this function:

◆ editStylePropertiesObject()

ilObjForumGUI::editStylePropertiesObject ( )
private

Definition at line 1097 of file class.ilObjForumGUI.php.

1097  : void
1098  {
1099  $this->content_style_gui->redirectToObjectSettings();
1100  }

◆ editThreadDraftObject()

ilObjForumGUI::editThreadDraftObject ( ?ilPropertyFormGUI  $form = null)
protected

Definition at line 4845 of file class.ilObjForumGUI.php.

References $modal_history, ilRTE\_replaceMediaObjectImageSrc(), ILIAS\Repository\access(), buildThreadForm(), checkDraftAccess(), ILIAS\Repository\ctrl(), doHistoryCheck(), ILIAS\Repository\int(), ilForumPostDraft\isSavePostDraftAllowed(), ILIAS\Repository\lng(), ilForumPostDraft\newInstanceByDraftId(), ILIAS\Repository\object(), and ILIAS\Repository\user().

Referenced by updateThreadDraftObject().

4845  : void
4846  {
4848  !$this->access->checkAccess('add_thread', '', $this->object->getRefId()) ||
4849  !$this->access->checkAccess('read', '', $this->object->getRefId())) {
4850  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4851  }
4852 
4853  $frm = $this->object->Forum;
4854  $frm->setForumId($this->object->getId());
4855  $frm->setForumRefId($this->object->getRefId());
4856 
4857  $draft = new ilForumPostDraft();
4858  $draftId = (int) ($this->httpRequest->getQueryParams()['draft_id'] ?? 0);
4859  if ($draftId > 0) {
4860  $draft = ilForumPostDraft::newInstanceByDraftId($draftId);
4861  $this->checkDraftAccess($draft);
4862  }
4863 
4864  $do_history_check = (bool) ($this->httpRequest->getQueryParams()['hist_check'] ?? true);
4865  if (!($form instanceof ilPropertyFormGUI) && $do_history_check) {
4866  $this->doHistoryCheck($draft->getDraftId());
4867  }
4868 
4869  if ($form instanceof ilPropertyFormGUI) {
4870  $this->ctrl->setParameter($this, 'draft_id', $draftId);
4871  } else {
4872  $form = $this->buildThreadForm(true);
4873  $form->setValuesByArray([
4874  'alias' => $draft->getPostUserAlias(),
4875  'subject' => $draft->getPostSubject(),
4876  'message' => ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($draft->getPostMessage(), 2), 1),
4877  'notify' => $draft->isNotificationEnabled() && !$this->user->isAnonymous(),
4878  'userfile' => '',
4879  'del_file' => [],
4880  'draft_id' => $draftId
4881  ]);
4882  }
4883 
4884  $this->tpl->setContent($form->getHTML() . $this->modal_history);
4885  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
buildThreadForm(bool $isDraft=false)
doHistoryCheck(int $draftId)
checkDraftAccess(int|ilForumPostDraft $draft)
static newInstanceByDraftId(int $draft_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enableForumNotificationObject()

ilObjForumGUI::enableForumNotificationObject ( )
protected

Definition at line 4273 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\object(), showThreadsObject(), and ILIAS\Repository\user().

4273  : void
4274  {
4275  if (!$this->access->checkAccess('read', '', $this->object->getRefId()) || $this->user->isAnonymous()) {
4276  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4277  }
4278 
4279  $frm = $this->object->Forum;
4280  $frm->setForumId($this->object->getId());
4281  $frm->enableForumNotification($this->user->getId());
4282 
4283  if ($this->objCurrentTopic->getId() > 0) {
4284  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4285  $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_forum_notification_enabled'), true);
4286  $this->ctrl->redirect($this, 'viewThread');
4287  }
4288 
4289  $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_forum_notification_enabled'));
4290  $this->showThreadsObject();
4291  }
+ Here is the call graph for this function:

◆ ensureThreadBelongsToForum()

ilObjForumGUI::ensureThreadBelongsToForum ( int  $objId,
ilForumTopic  $thread 
)

◆ ensureValidPageForCurrentPosting()

ilObjForumGUI::ensureValidPageForCurrentPosting ( array  $subtree_nodes,
array  $pagedPostings,
int  $pageSize,
ilForumPost  $firstForumPost 
)
protected

Definition at line 175 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl(), ilForumPost\getId(), and getOrderByParam().

Referenced by viewThreadObject().

180  : void {
181  if ($firstForumPost->getId() === $this->objCurrentPost->getId()) {
182  return;
183  }
184 
185  if ($subtree_nodes !== [] && $this->objCurrentPost->getId() > 0) {
186  $isCurrentPostingInPage = array_filter($pagedPostings, fn(ilForumPost $posting): bool => (
187  $posting->getId() === $this->objCurrentPost->getId()
188  ));
189 
190  if ([] === $isCurrentPostingInPage) {
191  $pageOfCurrentPosting = 0;
192  $i = 0;
193  foreach ($subtree_nodes as $node) {
194  if ($i > 0 && $i % $pageSize === 0) {
195  ++$pageOfCurrentPosting;
196  }
197 
198  if ($node->getId() === $this->objCurrentPost->getId()) {
199  break;
200  }
201 
202  ++$i;
203  }
204 
205  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
206  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
207  $this->ctrl->setParameter($this, 'page', $pageOfCurrentPosting);
208  $this->ctrl->setParameter(
209  $this,
210  'orderby',
211  $this->getOrderByParam()
212  );
213  $this->ctrl->redirect($this, 'viewThread', (string) $this->objCurrentPost->getId());
214  }
215  }
216  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eventsFormBuilder()

ilObjForumGUI::eventsFormBuilder ( ?array  $predefined_values = null)
private
Parameters
null|array<string,mixed>$predefined_values
Exceptions
ilCtrlException

Definition at line 4555 of file class.ilObjForumGUI.php.

References ilObjectGUI\$lng, $uiFactory, and ILIAS\Repository\ctrl().

Referenced by initHeaderAction(), and saveUserNotificationSettingsObject().

4556  {
4557  if ($this->objCurrentTopic->getId() > 0) {
4558  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4559  }
4560 
4562  $this->ctrl->getFormAction($this, 'saveUserNotificationSettings'),
4563  $predefined_values,
4565  $this->lng
4566  );
4567  }
ilLanguage $lng
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActionsForThreadOverview()

ilObjForumGUI::getActionsForThreadOverview ( int  $ref_id,
ilForumTopic  $forum_topic 
)
private

Definition at line 953 of file class.ilObjForumGUI.php.

References factory(), getEditTitleModal(), ilForumTopic\getId(), getLinkActionForThread(), getOpenCloseActionForThread(), getStickyActionForThread(), and ILIAS\Repository\lng().

Referenced by renderThreadOverview().

953  : Standard
954  {
955  $actions = $this->uiFactory->dropdown()->standard([]);
956  if ($this->is_moderator) {
957  $open_close = $this->getOpenCloseActionForThread($forum_topic, $ref_id);
958  $stick_or_no_stick = $this->getStickyActionForThread($forum_topic, $ref_id);
959  $edit_title_modal = $this->getEditTitleModal($forum_topic);
960  $this->modal_collection[] = $edit_title_modal;
961  $edit_title = $this->factory->button()->shy($this->lng->txt('frm_edit_title'), '#')->withOnClick(
962  $edit_title_modal->getShowSignal()
963  );
964 
965  $move = $this->getLinkActionForThread(
966  $ref_id,
967  $this->lng->txt('move_thread_to_forum'),
968  'move',
969  $forum_topic->getId()
970  );
971  $merge = $this->getLinkActionForThread(
972  $ref_id,
973  $this->lng->txt('merge_posts_into_thread'),
974  'mergeThreads',
975  $forum_topic->getId()
976  );
977  $delete = $this->getLinkActionForThread(
978  $ref_id,
979  $this->lng->txt('delete_thread'),
980  'confirmDeleteThreads',
981  $forum_topic->getId()
982  );
983  $actions = $this->uiFactory->dropdown()->standard([
984  $stick_or_no_stick,
985  $open_close,
986  $edit_title,
987  $move,
988  $merge,
989  $delete
990  ]);
991  }
992 
993  return $actions;
994  }
getEditTitleModal(ilForumTopic $topic)
factory()
getStickyActionForThread(ilForumTopic $forum_topic, int $ref_id)
getLinkActionForThread(int $ref_id, string $title, string $cmd, ?int $thread_id=null)
getOpenCloseActionForThread(ilForumTopic $forum_topic, int $ref_id)
This describes a Standard Dropdown.
Definition: Standard.php:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContent()

ilObjForumGUI::getContent ( )

Definition at line 674 of file class.ilObjForumGUI.php.

References ilChangeEvent\_recordReadEvent(), ILIAS\Repository\access(), addDraftButtonIfDraftsExists(), ILIAS\Repository\ctrl(), hideToolbar(), ilForumPostDraft\isSavePostDraftAllowed(), ILIAS\Repository\lng(), ILIAS\Repository\object(), renderThreadOverview(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

674  : string
675  {
676  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
677  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
678  }
679 
680  $cmd = $this->ctrl->getCmd();
681  $frm = $this->object->Forum;
682  $frm->setForumId($this->object->getId());
683  $frm->setForumRefId($this->object->getRefId());
684  $frm->setMDB2Wherecondition('top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
685  // Import information: Topic (variable $topicData) means frm object, not thread
686  $frm_object = $frm->getOneTopic();
687  if ($frm_object->getTopPk() > 0) {
688  $frm->setDbTable('frm_data');
689  $frm->setMDB2WhereCondition('top_pk = %s ', ['integer'], [$frm_object->getTopPk()]);
690  $frm->updateVisits($frm_object->getTopPk());
691 
693  $this->object->getType(),
694  $this->object->getRefId(),
695  $this->object->getId(),
696  $this->user->getId()
697  );
698 
699  if ($cmd !== 'showThreads') {
700  $cmd = 'showThreads';
701  }
702  }
703  $this->tpl->setPermanentLink($this->object->getType(), $this->object->getRefId());
704 
705  if (!$this->hideToolbar() && $this->access->checkAccess('add_thread', '', $this->object->getRefId())) {
706  $btn = $this->uiFactory->button()
707  ->standard(
708  $this->lng->txt('forums_new_thread'),
709  $this->ctrl->getLinkTarget($this, 'createThread')
710  );
711  $this->toolbar->addStickyItem($btn);
712  }
713 
715  $this->addDraftButtonIfDraftsExists($cmd);
716  }
717 
718  if ($this->confirmation_gui_html === '' && !$this->user->isAnonymous()) {
719  $this->toolbar->addButton(
720  $this->lng->txt('forums_mark_read'),
721  $this->ctrl->getLinkTarget($this, 'markAllRead')
722  );
723  $this->ctrl->clearParameters($this);
724  }
725 
726  if (!$this->user->isAnonymous() && $this->access->checkAccess('write', '', $this->ref_id)) {
727  $this->lng->loadLanguageModule('cntr');
728  $this->toolbar->addComponent(
729  $this->uiFactory->button()->standard(
730  $this->lng->txt('cntr_text_media_editor'),
731  $this->ctrl->getLinkTargetByClass(ilForumPageGUI::class, 'edit')
732  )
733  );
734  }
735 
736  $this->renderThreadOverview($frm, $frm_object);
737  return '';
738  }
addDraftButtonIfDraftsExists(string $cmd)
hideToolbar($a_flag=null)
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, bool $isCatchupWriteEvents=true, $a_ext_rc=null, $a_ext_time=null)
renderThreadOverview(ilForum $frm, ForumDto $frm_object)
+ Here is the call graph for this function:

◆ getEditFormCustomValues()

ilObjForumGUI::getEditFormCustomValues ( array &  $a_values)
protected

Definition at line 617 of file class.ilObjForumGUI.php.

617  : void
618  {
619  $this->forum_settings_gui->getCustomValues($a_values);
620  }

◆ getEditTitleModal()

ilObjForumGUI::getEditTitleModal ( ilForumTopic  $topic)
private

Definition at line 996 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl(), factory(), ilForumTopic\getId(), ilForumTopic\getSubject(), ILIAS\Repository\lng(), null, ILIAS\Repository\refinery(), and ILIAS\UI\Implementation\Component\Input\withValue().

Referenced by getActionsForThreadOverview(), and updateThreadObject().

996  : RoundTrip
997  {
998  $topic_id = $this->refinery->kindlyTo()->string()->transform($topic->getId());
999  $this->ctrl->setParameter($this, 'thr_pk', (string) $topic_id);
1000  $target = $this->ctrl->getLinkTargetByClass(
1001  ilObjForumGUI::class,
1002  'editThread'
1003  );
1004  $this->ctrl->setParameter($this, 'thread_id', null);
1005 
1006  return $this->factory->modal()->roundtrip(
1007  $this->lng->txt('frm_edit_title'),
1008  [],
1009  [
1010  $this->factory->input()->field()->text($this->lng->txt('frm_edit_title'))->withValue($topic->getSubject()),
1011  ],
1012  $target
1013  );
1014  }
factory()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getForumObjects()

ilObjForumGUI::getForumObjects ( )
private
Returns
array{forumObj: ilObjForum, frm: ilForum, file_obj: ilFileDataForum}

Definition at line 3052 of file class.ilObjForumGUI.php.

References $forumObjects, ilObjectGUI\$object, and null.

Referenced by deletePostingObject(), handleCensorship(), initReplyEditForm(), publishDraftObject(), saveAsDraftObject(), savePostObject(), updateDraftObject(), and viewThreadObject().

3052  : array
3053  {
3054  if ($this->forumObjects === null) {
3055  $forumObj = $this->object;
3056  $file_obj = new ilFileDataForum($forumObj->getId(), $this->objCurrentPost->getId());
3057  $frm = $forumObj->Forum;
3058  $frm->setForumId($forumObj->getId());
3059  $frm->setForumRefId($forumObj->getRefId());
3060 
3061  $this->forumObjects['forumObj'] = $forumObj;
3062  $this->forumObjects['frm'] = $frm;
3063  $this->forumObjects['file_obj'] = $file_obj;
3064  }
3065 
3066  return $this->forumObjects;
3067  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getLinkActionForThread()

ilObjForumGUI::getLinkActionForThread ( int  $ref_id,
string  $title,
string  $cmd,
?int  $thread_id = null 
)
private

Definition at line 936 of file class.ilObjForumGUI.php.

References $url, ILIAS\Repository\ctrl(), and null.

Referenced by getActionsForThreadOverview(), getOpenCloseActionForThread(), getStickyActionForThread(), and renderThreadOverview().

941  : \ILIAS\UI\Component\Link\Link {
942  $this->ctrl->setParameter($this, 'ref_id', $ref_id);
943  $this->ctrl->setParameter($this, 'thr_pk', $thread_id);
944  $this->ctrl->setParameter($this, 'page', 0);
945  $url = $this->ctrl->getLinkTarget($this, $cmd);
946  $this->ctrl->setParameter($this, 'ref_id', null);
947  $this->ctrl->setParameter($this, 'thr_pk', null);
948  $this->ctrl->setParameter($this, 'page', null);
949 
950  return $this->uiFactory->link()->standard($title, $url);
951  }
$url
Definition: shib_logout.php:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getModalActions()

ilObjForumGUI::getModalActions ( )
private

Definition at line 2055 of file class.ilObjForumGUI.php.

Referenced by viewThreadObject().

2055  : string
2056  {
2057  $modalString = '';
2058  foreach ($this->modalActionsContainer as $modal) {
2059  $modalString .= $this->uiRenderer->render($modal);
2060  }
2061 
2062  return $modalString;
2063  }
+ Here is the caller graph for this function:

◆ getModifiedReOnSubject()

ilObjForumGUI::getModifiedReOnSubject ( )
private

Definition at line 3584 of file class.ilObjForumGUI.php.

References ILIAS\Repository\lng().

Referenced by renderPostingForm().

3584  : string
3585  {
3586  return (new \ILIAS\components\Forum\Subject\PostingReplySubjectBuilder(
3587  $this->lng->txt('post_reply'),
3588  $this->lng->txt('post_reply_count')
3589  ))->build($this->objCurrentPost->getSubject());
3590  }
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOpenCloseActionForThread()

ilObjForumGUI::getOpenCloseActionForThread ( ilForumTopic  $forum_topic,
int  $ref_id 
)
private

Definition at line 1067 of file class.ilObjForumGUI.php.

References ilForumTopic\getId(), getLinkActionForThread(), ilForumTopic\isClosed(), and ILIAS\Repository\lng().

Referenced by getActionsForThreadOverview().

1067  : \ILIAS\UI\Component\Link\Link
1068  {
1069  return $this->getLinkActionForThread(
1070  $ref_id,
1071  $this->lng->txt($forum_topic->isClosed() ? 'reopen_topics' : 'close_topics'),
1072  $forum_topic->isClosed() ? 'reopen' : 'close',
1073  $forum_topic->getId()
1074  );
1075  }
getLinkActionForThread(int $ref_id, string $title, string $cmd, ?int $thread_id=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOrderByParam()

ilObjForumGUI::getOrderByParam ( )
private

Definition at line 5946 of file class.ilObjForumGUI.php.

References ILIAS\FileDelivery\http(), ILIAS\Repository\refinery(), and ilUtil\stripSlashes().

Referenced by addActivationFormModal(), createTopLevelPostObject(), ensureValidPageForCurrentPosting(), initReplyEditForm(), renderPostContent(), renderPostingForm(), renderSplitButton(), and viewThreadObject().

5946  : string
5947  {
5948  return ilUtil::stripSlashes($this->http->wrapper()->query()->retrieve(
5949  'orderby',
5950  $this->refinery->byTrying([
5951  $this->refinery->kindlyTo()->string(),
5952  $this->refinery->always('')
5953  ])
5954  ));
5955  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getReplyEditForm()

ilObjForumGUI::getReplyEditForm ( )
private

Definition at line 2551 of file class.ilObjForumGUI.php.

References $replyEditForm, initReplyEditForm(), and null.

Referenced by autosaveDraftAsyncObject(), publishDraftObject(), quotePostObject(), renderDraftContent(), renderPostingForm(), saveAsDraftObject(), savePostObject(), updateDraftObject(), and viewThreadObject().

2552  {
2553  if ($this->replyEditForm === null) {
2554  $this->initReplyEditForm();
2555  }
2556 
2557  return $this->replyEditForm;
2558  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
ilPropertyFormGUI $replyEditForm
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getResetLimitedViewInfo()

ilObjForumGUI::getResetLimitedViewInfo ( )
private

Definition at line 5927 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\UI\examples\MessageBox\Info\info(), and ILIAS\Repository\lng().

Referenced by viewThreadObject().

5927  : string
5928  {
5929  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
5930 
5931  $buttons = [
5932  $this->uiFactory->button()->standard(
5933  $this->lng->txt('reset_limited_view_button'),
5934  $this->ctrl->getLinkTarget($this, 'resetLimitedView')
5935  )
5936  ];
5937 
5938  return $this->uiRenderer->render(
5939  $this->uiFactory
5940  ->messageBox()
5941  ->info($this->lng->txt('reset_limited_view_info'))
5942  ->withButtons($buttons)
5943  );
5944  }
info()
description: > Example for rendering a info message box.
Definition: info.php:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSafePostCommands()

◆ getSortationViewControl()

ilObjForumGUI::getSortationViewControl ( int  $offset)
private

Definition at line 837 of file class.ilObjForumGUI.php.

References $url, ILIAS\Repository\ctrl(), factory(), and ILIAS\Repository\lng().

Referenced by renderThreadOverview().

837  : \ILIAS\UI\Component\ViewControl\Sortation
838  {
839  if ($offset > 0) {
840  $this->ctrl->setParameter($this, 'page', $offset);
841  }
842 
843  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
844  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
845  $base_url = $this->ctrl->getLinkTarget($this, 'showThreads');
846 
847  $translationKeys = [];
848  foreach (ThreadSortation::cases() as $sortation) {
849  $this->ctrl->setParameter($this, 'thread_sortation', $sortation->value);
850  $url = $this->ctrl->getLinkTarget($this, 'showThreads');
851 
852  $translationKeys[$url] = $this->lng->txt($sortation->languageId());
853  }
854  $this->ctrl->clearParameters($this);
855  return $this->factory->viewControl()->sortation(
856  $translationKeys,
857  current(array_keys($translationKeys))
858  )
859  ->withTargetURL($base_url, 'thread_sortation');
860  }
factory()
$url
Definition: shib_logout.php:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStickyActionForThread()

ilObjForumGUI::getStickyActionForThread ( ilForumTopic  $forum_topic,
int  $ref_id 
)
private

Definition at line 1057 of file class.ilObjForumGUI.php.

References ilForumTopic\getId(), getLinkActionForThread(), ilForumTopic\isSticky(), and ILIAS\Repository\lng().

Referenced by getActionsForThreadOverview().

1057  : \ILIAS\UI\Component\Link\Link
1058  {
1059  return $this->getLinkActionForThread(
1060  $ref_id,
1061  $this->lng->txt($forum_topic->isSticky() ? 'make_topics_non_sticky' : 'make_topics_sticky'),
1062  $forum_topic->isSticky() ? 'make_topics_non_sticky' : 'makesticky',
1063  $forum_topic->getId()
1064  );
1065  }
getLinkActionForThread(int $ref_id, string $title, string $cmd, ?int $thread_id=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTableCommands()

ilObjForumGUI::getTableCommands ( )
private
Returns
string[]

Definition at line 587 of file class.ilObjForumGUI.php.

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by getSafePostCommands().

587  : array
588  {
589  $tableCommands = [];
590  if ($this->http->wrapper()->post()->has('selected_cmd')) {
591  $tableCommands[] = $this->http->wrapper()->post()->retrieve(
592  'selected_cmd',
593  $this->refinery->kindlyTo()->string()
594  );
595  }
596  if ($this->http->wrapper()->post()->has('selected_cmd2')) {
597  $tableCommands[] = $this->http->wrapper()->post()->retrieve(
598  'selected_cmd2',
599  $this->refinery->kindlyTo()->string()
600  );
601  }
602 
603  return $tableCommands;
604  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTabs()

ilObjForumGUI::getTabs ( )
protected

Definition at line 1564 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ilLearningProgressAccess\checkAccess(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ILIAS\Repository\refinery(), and ILIAS\Repository\settings().

1564  : void
1565  {
1566  if ($this->in_page_editor_style_context) {
1567  return;
1568  }
1569 
1570  $this->ilHelp->setScreenIdComponent('frm');
1571 
1572  $this->ctrl->setParameter($this, 'ref_id', $this->ref_id);
1573 
1574  $active = [
1575  '',
1576  'showThreads',
1577  'view',
1578  'markAllRead',
1579  'enableForumNotification',
1580  'disableForumNotification',
1581  'moveThreads',
1582  'performMoveThreads',
1583  'cancelMoveThreads',
1584  'performThreadsAction',
1585  'createThread',
1586  'addThread',
1587  'showUser',
1588  'confirmDeleteThreads',
1589  'merge',
1590  'mergeThreads',
1591  'performMergeThreads'
1592  ];
1593 
1594  $force_active = false;
1595  if (in_array($this->ctrl->getCmd(), $active, true)) {
1596  $force_active = true;
1597  }
1598 
1599  if ($this->access->checkAccess(
1600  'read',
1601  '',
1602  $this->ref_id
1603  )) {
1604  $this->tabs_gui->addTarget(
1605  self::UI_TAB_ID_THREADS,
1606  $this->ctrl->getLinkTarget($this, 'showThreads'),
1607  $this->ctrl->getCmd(),
1608  static::class,
1609  '',
1610  $force_active
1611  );
1612  }
1613 
1614  if ($this->access->checkAccess('visible', '', $this->ref_id) || $this->access->checkAccess(
1615  'read',
1616  '',
1617  $this->ref_id
1618  )) {
1619  $cmdClass = $this->http->wrapper()->query()->retrieve(
1620  'cmdClass',
1621  $this->refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always('')])
1622  );
1623 
1624  $force_active = $this->ctrl->getNextClass() === 'ilinfoscreengui' || strtolower($cmdClass) === 'ilnotegui';
1625  $this->tabs_gui->addTarget(
1626  self::UI_TAB_ID_INFO,
1627  $this->ctrl->getLinkTargetByClass([self::class, ilInfoScreenGUI::class], 'showSummary'),
1628  ['showSummary', 'infoScreen'],
1629  '',
1630  '',
1631  $force_active
1632  );
1633  }
1634 
1635  if ($this->access->checkAccess('write', '', $this->ref_id)) {
1636  $force_active = $this->ctrl->getCmd() === 'edit';
1637  $this->tabs_gui->addTarget(
1638  self::UI_TAB_ID_SETTINGS,
1639  $this->ctrl->getLinkTarget($this, 'edit'),
1640  'edit',
1641  $this::class,
1642  '',
1643  $force_active
1644  );
1645  }
1646 
1647  if ($this->access->checkAccess('write', '', $this->ref_id)) {
1648  $this->tabs_gui->addTarget(
1649  self::UI_TAB_ID_MODERATORS,
1650  $this->ctrl->getLinkTargetByClass(ilForumModeratorsGUI::class, 'showModerators'),
1651  'showModerators',
1652  static::class
1653  );
1654  }
1655 
1656  if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
1657  $this->tabs_gui->addTab(
1658  'learning_progress',
1659  $this->lng->txt('learning_progress'),
1660  $this->ctrl->getLinkTargetByClass(ilLearningProgressGUI::class)
1661  );
1662  }
1663 
1664  if ($this->settings->get('enable_fora_statistics', '0')) {
1665  $hasStatisticsAccess = $this->access->checkAccess('write', '', $this->ref_id);
1666  if (!$hasStatisticsAccess) {
1667  $hasStatisticsAccess = (
1668  $this->objProperties->isStatisticEnabled() &&
1669  $this->access->checkAccess('read', '', $this->ref_id)
1670  );
1671  }
1672 
1673  if ($hasStatisticsAccess) {
1674  $force_active = $this->ctrl->getCmd() === 'showStatistics';
1675  $this->tabs_gui->addTarget(
1676  self::UI_TAB_ID_STATS,
1677  $this->ctrl->getLinkTarget($this, 'showStatistics'),
1678  'showStatistics',
1679  static::class,
1680  '',
1681  $force_active
1682  );
1683  }
1684  }
1685 
1686  if ($this->access->checkAccess('write', '', $this->object->getRefId())) {
1687  $this->tabs_gui->addTarget(
1688  self::UI_TAB_ID_EXPORT,
1689  $this->ctrl->getLinkTargetByClass(ilExportGUI::class, ''),
1690  '',
1691  'ilexportgui'
1692  );
1693  }
1694 
1695  if ($this->access->checkAccess('edit_permission', '', $this->ref_id)) {
1696  $this->tabs_gui->addTarget(
1697  self::UI_TAB_ID_PERMISSIONS,
1698  $this->ctrl->getLinkTargetByClass([static::class, ilPermissionGUI::class], 'perm'),
1699  ['perm', 'info', 'owner'],
1700  'ilpermissiongui'
1701  );
1702  }
1703  }
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
static http()
Fetches the global http state from ILIAS.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getThreadProperties()

ilObjForumGUI::getThreadProperties ( ilForumTopic  $forum_topic)
private
Returns
array <string, string>

Definition at line 888 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl(), ilForumTopic\getDisplayUserId(), ilForumTopic\getId(), ilForumTopic\getImportName(), ilForumTopic\getLastPost(), ilForumTopic\getNumPosts(), ilForumTopic\getNumUnreadPosts(), ilForumTopic\getThrAuthorId(), ilForumTopic\getUserAlias(), ilForumTopic\getVisits(), ilForumTopic\isSticky(), ILIAS\Repository\lng(), null, ILIAS\Repository\object(), and ILIAS\Repository\user().

Referenced by renderThreadOverview().

888  : array
889  {
890  $this->ctrl->setParameter($this, 'thr_pk', $forum_topic->getId());
891  $unread_counter = $forum_topic->getNumUnreadPosts();
892  $is_top_thread = $forum_topic->isSticky();
893 
894  if ($unread_counter === 0) {
895  $unread = '';
896  } else {
897  $unread = ' (' . $unread_counter . ' ' . $this->lng->txt('unread') . ')';
898  }
899 
900  $authorinfo = new ilForumAuthorInformation(
901  $forum_topic->getThrAuthorId(),
902  $forum_topic->getDisplayUserId(),
903  (string) $forum_topic->getUserAlias(),
904  (string) $forum_topic->getImportName()
905  );
906 
907  $properties = [
908  $this->lng->txt('forums_created_by') => $authorinfo->getAuthorName(),
909  $this->lng->txt('forums_articles') => $forum_topic->getNumPosts() . $unread,
910  $this->lng->txt('forums_last_post') => $this->object->Forum->convertDate($forum_topic->getLastPost()->getCreateDate()),
911  $this->lng->txt('visits') => $forum_topic->getVisits(),
912  ];
913 
914  if ($is_top_thread === true) {
915  $is_top_thread = [$this->lng->txt('relevance') => $this->lng->txt('sticky')];
916  $properties = array_merge($properties, $is_top_thread);
917  }
918 
919  $rating_property = [];
920  if ($this->objProperties->isIsThreadRatingEnabled()) {
921  $rating = new ilRatingGUI();
922  $rating->setObject(
923  $this->object->getId(),
924  $this->object->getType(),
925  $forum_topic->getId(),
926  'thread'
927  );
928  $rating->setUserId($this->user->getId());
929  $rating_property = [$this->lng->txt('frm_rating') => $rating->getHTML()];
930  }
931  $this->ctrl->setParameter($this, 'thr_pk', null);
932 
933  return array_merge($properties, $rating_property);
934  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUnsafeGetCommands()

ilObjForumGUI::getUnsafeGetCommands ( )

This method must return a list of unsafe GET commands.

Unsafe get commands returned by this method will now be CSRF protected, which means an ilCtrlToken is appended each time a link-target is generated to the class implementing this interface with a command from that list.

Tokens will be validated in

See also
ilCtrlInterface::getCmd(), whereas the fallback command will be used if the CSRF validation fails.
Returns
string[]

Implements ilCtrlSecurityInterface.

Definition at line 265 of file class.ilObjForumGUI.php.

265  : array
266  {
267  return [
268  'enableForumNotification',
269  'disableForumNotification',
270  'toggleThreadNotification'
271  ];
272  }

◆ handleCensorship()

ilObjForumGUI::handleCensorship ( bool  $wasRevoked = false)
private

Definition at line 2065 of file class.ilObjForumGUI.php.

References $message, ensureThreadBelongsToForum(), getForumObjects(), handleFormInput(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ILIAS\Repository\refinery(), and viewThreadObject().

Referenced by addCensorshipObject(), and revokeCensorshipObject().

2065  : void
2066  {
2067  $message = '';
2068  if ($this->is_moderator && !$this->objCurrentTopic->isClosed()) {
2069  if ($this->http->wrapper()->post()->has('formData')) {
2070  $formData = $this->http->wrapper()->post()->retrieve(
2071  'formData',
2072  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string())
2073  );
2074  $message = $this->handleFormInput($formData['cens_message']);
2075  }
2076 
2077  if ($message === '' && $this->http->wrapper()->post()->has('cens_message')) {
2078  $cens_message = $this->http->wrapper()->post()->retrieve(
2079  'cens_message',
2080  $this->refinery->kindlyTo()->string()
2081  );
2082  $message = $this->handleFormInput($cens_message);
2083  }
2084  $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentPost->getThread());
2085 
2086  $oForumObjects = $this->getForumObjects();
2087  $frm = $oForumObjects['frm'];
2088 
2089  if ($wasRevoked) {
2090  $frm->postCensorship($this->object, $message, $this->objCurrentPost->getId());
2091  $this->tpl->setOnScreenMessage('success', $this->lng->txt('frm_censorship_revoked'));
2092  } else {
2093  $frm->postCensorship($this->object, $message, $this->objCurrentPost->getId(), 1);
2094  $this->tpl->setOnScreenMessage('success', $this->lng->txt('frm_censorship_applied'));
2095  }
2096 
2097  $this->viewThreadObject();
2098  return;
2099  }
2100 
2101  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2102  }
static http()
Fetches the global http state from ILIAS.
handleFormInput(string $a_text, bool $a_stripslashes=true)
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleFormInput()

ilObjForumGUI::handleFormInput ( string  $a_text,
bool  $a_stripslashes = true 
)

Definition at line 4340 of file class.ilObjForumGUI.php.

References ilUtil\stripSlashes().

Referenced by autosaveDraftAsyncObject(), autosaveThreadDraftAsyncObject(), createEmptyThread(), createThread(), handleCensorship(), publishDraftObject(), saveAsDraftObject(), savePostObject(), saveThreadAsDraftObject(), updateDraftObject(), and updateThreadDraftObject().

4340  : string
4341  {
4342  $a_text = str_replace(['<', '>'], ['&lt;', '&gt;'], $a_text);
4343  if ($a_stripslashes) {
4344  $a_text = ilUtil::stripSlashes($a_text);
4345  }
4346 
4347  return $a_text;
4348  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasDraftAccess()

ilObjForumGUI::hasDraftAccess ( int|ilForumPostDraft  $draft)
private

Definition at line 5714 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ilForumPostDraft\getDraftId(), ilForumPostDraft\getPostAuthorId(), ilForumPostDraft\newInstanceByDraftId(), ILIAS\Repository\object(), and ILIAS\Repository\user().

Referenced by cancelDraftObject(), cancelPostObject(), checkDraftAccess(), and savePostObject().

5714  : bool
5715  {
5716  $draft = is_int($draft) ? ilForumPostDraft::newInstanceByDraftId($draft) : $draft;
5717  return (
5718  $draft->getDraftId() > 1 &&
5719  !$this->user->isAnonymous() &&
5720  $this->access->checkAccess('add_reply', '', $this->object->getRefId()) &&
5721  $this->user->getId() === $draft->getPostAuthorId()
5722  );
5723  }
static newInstanceByDraftId(int $draft_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hideToolbar()

ilObjForumGUI::hideToolbar (   $a_flag = null)
private

Definition at line 3012 of file class.ilObjForumGUI.php.

References $hideToolbar, and null.

Referenced by getContent(), moveThreadsObject(), and performDeleteThreadsObject().

3013  {
3014  if ($a_flag === null) {
3015  return $this->hideToolbar;
3016  }
3017 
3018  $this->hideToolbar = $a_flag;
3019  return $this;
3020  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
hideToolbar($a_flag=null)
+ Here is the caller graph for this function:

◆ infoScreen()

ilObjForumGUI::infoScreen ( )
protected

Definition at line 4357 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

Referenced by getSafePostCommands(), and infoScreenObject().

4357  : void
4358  {
4359  if (
4360  !$this->access->checkAccess('visible', '', $this->object->getRefId()) &&
4361  !$this->access->checkAccess('read', '', $this->object->getRefId())
4362  ) {
4363  $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
4364  }
4365 
4366  if (strtolower($this->ctrl->getCmd() ?? '') === 'infoscreen') {
4367  $this->ctrl->redirectByClass(ilInfoScreenGUI::class, 'showSummary');
4368  }
4369 
4370  $info = new ilInfoScreenGUI($this);
4371  $info->enablePrivateNotes();
4372  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
4373  $this->ctrl->forwardCommand($info);
4374  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infoScreenObject()

ilObjForumGUI::infoScreenObject ( )

Definition at line 606 of file class.ilObjForumGUI.php.

References infoScreen().

606  : void
607  {
608  $this->infoScreen();
609  }
+ Here is the call graph for this function:

◆ initEditCustomForm()

ilObjForumGUI::initEditCustomForm ( ilPropertyFormGUI  $a_form)
protected

Definition at line 611 of file class.ilObjForumGUI.php.

611  : void
612  {
613  $this->forum_settings_gui = new ilForumSettingsGUI($this);
614  $this->forum_settings_gui->getCustomForm($a_form);
615  }
Class ilForumSettingsGUI.

◆ initHeaderAction()

ilObjForumGUI::initHeaderAction ( ?string  $sub_type = null,
?int  $sub_id = null 
)
protected

Definition at line 4410 of file class.ilObjForumGUI.php.

References ilObjectGUI\$id, ILIAS\Repository\access(), ILIAS\Repository\button(), ilForumNotificationEvents\CENSORED, ILIAS\Repository\ctrl(), eventsFormBuilder(), ilUtil\getImagePath(), isParentObjectCrsOrGrp(), isUserAllowedToDeactivateNotification(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilForumNotificationEvents\POST_DELETED, ILIAS\Repository\settings(), ilForumNotification\setUserId(), ilForumNotificationEvents\THREAD_DELETED, ilForumNotificationEvents\UNCENSORED, ilForumNotificationEvents\UPDATED, ILIAS\Repository\user(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

4410  : ?ilObjectListGUI
4411  {
4412  $lg = parent::initHeaderAction();
4413 
4414  if (!($lg instanceof ilObjForumListGUI) || !((bool) $this->settings->get('forum_notification', '0'))) {
4415  return $lg;
4416  }
4417 
4418  if ($this->user->isAnonymous() || !$this->access->checkAccess('read', '', $this->object->getRefId())) {
4419  return $lg;
4420  }
4421 
4422  $frm = $this->object->Forum;
4423  $frm->setForumId($this->object->getId());
4424  $frm->setForumRefId($this->object->getRefId());
4425  $frm->setMDB2Wherecondition('top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
4426 
4427  $isForumNotificationEnabled = $frm->isForumNotificationEnabled($this->user->getId());
4428  $userMayDisableNotifications = $this->isUserAllowedToDeactivateNotification();
4429 
4430  if ($this->objCurrentTopic->getId() > 0) {
4431  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4432  }
4433 
4434  if (!$this->user->isAnonymous()) {
4435  if ($this->isParentObjectCrsOrGrp()) {
4436  // special behaviour for CRS/GRP-Forum notification!!
4437  if ($isForumNotificationEnabled && $userMayDisableNotifications) {
4438  $lg->addCustomCommand(
4439  $this->ctrl->getLinkTarget($this, 'disableForumNotification'),
4440  'forums_disable_forum_notification'
4441  );
4442  } elseif (!$isForumNotificationEnabled) {
4443  $lg->addCustomCommand(
4444  $this->ctrl->getLinkTarget($this, 'enableForumNotification'),
4445  'forums_enable_forum_notification'
4446  );
4447  }
4448  } elseif ($isForumNotificationEnabled) {
4449  $lg->addCustomCommand(
4450  $this->ctrl->getLinkTarget($this, 'disableForumNotification'),
4451  'forums_disable_forum_notification'
4452  );
4453  } else {
4454  $lg->addCustomCommand(
4455  $this->ctrl->getLinkTarget($this, 'enableForumNotification'),
4456  'forums_enable_forum_notification'
4457  );
4458  }
4459  }
4460 
4461  if (!$this->user->isAnonymous() && $isForumNotificationEnabled && $userMayDisableNotifications) {
4462  $frm_noti = new ilForumNotification($this->object->getRefId());
4463  $frm_noti->setUserId($this->user->getId());
4464  $interested_events = $frm_noti->readInterestedEvents();
4465 
4466  $events_form_builder = $this->eventsFormBuilder([
4467  'hidden_value' => '',
4468  'notify_modified' => (bool) ($interested_events & ilForumNotificationEvents::UPDATED),
4469  'notify_censored' => (bool) ($interested_events & ilForumNotificationEvents::CENSORED),
4470  'notify_uncensored' => (bool) ($interested_events & ilForumNotificationEvents::UNCENSORED),
4471  'notify_post_deleted' => (bool) ($interested_events & ilForumNotificationEvents::POST_DELETED),
4472  'notify_thread_deleted' => (bool) ($interested_events & ilForumNotificationEvents::THREAD_DELETED),
4473  ]);
4474 
4475  $notificationsModal = $this->uiFactory->modal()->roundtrip(
4476  $this->lng->txt('notification_settings'),
4477  [$events_form_builder->build()]
4478  )->withActionButtons([
4479  $this->uiFactory
4480  ->button()
4481  ->primary($this->lng->txt('save'), '#')
4482  ->withOnLoadCode(function (string $id): string {
4483  return "
4484  (function () {
4485  const button = document.getElementById('$id');
4486  if (!button) return;
4487 
4488  const modalDialog = button.closest('.modal-dialog');
4489  if (!modalDialog) return;
4490 
4491  const form = modalDialog.querySelector('.modal-body form');
4492  if (!form) return;
4493 
4494  form.classList.add('ilForumNotificationSettingsForm');
4495  button.addEventListener('click', (event) => {
4496  event.preventDefault();
4497  if (form) {
4498  form.submit();
4499  }
4500  }, true);
4501  }());
4502  ";
4503  })
4504  ]);
4505 
4506  $showNotificationSettingsBtn = $this->uiFactory->button()
4507  ->shy($this->lng->txt('notification_settings'), '#')
4508  ->withOnClick(
4509  $notificationsModal->getShowSignal()
4510  );
4511 
4512  $lg->addCustomCommandButton($showNotificationSettingsBtn, $notificationsModal);
4513  }
4514 
4515  $isThreadNotificationEnabled = false;
4516  if (!$this->user->isAnonymous() && $this->objCurrentTopic->getId() > 0) {
4517  $isThreadNotificationEnabled = $this->objCurrentTopic->isNotificationEnabled($this->user->getId());
4518  if ($isThreadNotificationEnabled) {
4519  $lg->addCustomCommand(
4520  $this->ctrl->getLinkTarget($this, 'toggleThreadNotification'),
4521  'forums_disable_notification'
4522  );
4523  } else {
4524  $lg->addCustomCommand(
4525  $this->ctrl->getLinkTarget($this, 'toggleThreadNotification'),
4526  'forums_enable_notification'
4527  );
4528  }
4529  }
4530  $this->ctrl->setParameter($this, 'thr_pk', '');
4531 
4532  if (!$this->user->isAnonymous()) {
4533  if ($isForumNotificationEnabled || $isThreadNotificationEnabled) {
4534  $lg->addHeaderIcon(
4535  'not_icon',
4536  ilUtil::getImagePath('object/notification_on.svg'),
4537  $this->lng->txt('frm_notification_activated')
4538  );
4539  } else {
4540  $lg->addHeaderIcon(
4541  'not_icon',
4542  ilUtil::getImagePath('object/notification_off.svg'),
4543  $this->lng->txt('frm_notification_deactivated')
4544  );
4545  }
4546  }
4547 
4548  return $lg;
4549  }
button(string $caption, string $cmd)
Class ilObjForumListGUI.
Class ilForumNotification.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
eventsFormBuilder(?array $predefined_values=null)
+ Here is the call graph for this function:

◆ initReplyEditForm()

ilObjForumGUI::initReplyEditForm ( )
private

Definition at line 2301 of file class.ilObjForumGUI.php.

References ilObjAdvancedEditing\_setRichTextEditorUserState(), ilCheckboxGroupInputGUI\addOption(), ILIAS\Repository\ctrl(), decorateWithAutosave(), ilFileDataForumDrafts\getFilesOfPost(), getForumObjects(), ilHtmlPurifierFactory\getInstanceByType(), getOrderByParam(), ILIAS\FileDelivery\http(), ilForumPostDraft\isAutoSavePostDraftAllowed(), ilForumPostDraft\isSavePostDraftAllowed(), isTopLevelReplyCommand(), isWritingWithPseudonymAllowed(), ILIAS\Repository\lng(), ilForumPostDraft\lookupAutosaveInterval(), ILIAS\Repository\rbac(), ILIAS\Repository\refinery(), retrieveDraftId(), ilFileWizardInputGUI\setFilenames(), ilFormPropertyGUI\setRequired(), and ILIAS\Repository\user().

Referenced by getReplyEditForm().

2301  : void
2302  {
2303  $isReply = in_array($this->requestAction, ['showreply', 'ready_showreply']);
2304  $isDraft = in_array($this->requestAction, ['publishDraft', 'editdraft']);
2305 
2306  $draft_id = $this->retrieveDraftId();
2307 
2308  // init objects
2309  $oForumObjects = $this->getForumObjects();
2310  $frm = $oForumObjects['frm'];
2311  $oFDForum = $oForumObjects['file_obj'];
2312 
2313  $this->replyEditForm = new ilPropertyFormGUI();
2314  $this->replyEditForm->setId('id_showreply');
2315  $this->replyEditForm->setTableWidth('100%');
2316  $cancel_cmd = 'cancelPost';
2317  if (in_array($this->requestAction, ['showreply', 'ready_showreply'])) {
2318  $this->ctrl->setParameter($this, 'action', 'ready_showreply');
2319  } elseif (in_array($this->requestAction, ['showdraft', 'editdraft'])) {
2320  $this->ctrl->setParameter($this, 'action', $this->requestAction);
2321  $this->ctrl->setParameter($this, 'draft_id', $draft_id);
2322  } else {
2323  $this->ctrl->setParameter($this, 'action', 'ready_showedit');
2324  }
2325 
2326  $this->ctrl->setParameter($this, 'page', (int) ($this->httpRequest->getQueryParams()['page'] ?? 0));
2327  $this->ctrl->setParameter(
2328  $this,
2329  'orderby',
2330  $this->getOrderByParam()
2331  );
2332  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2333  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2334  if ($this->isTopLevelReplyCommand()) {
2335  $this->replyEditForm->setFormAction(
2336  $this->ctrl->getFormAction($this, 'saveTopLevelPost', 'frm_page_bottom')
2337  );
2338  } elseif (in_array($this->requestAction, ['publishDraft', 'editdraft'])) {
2339  $this->replyEditForm->setFormAction(
2340  $this->ctrl->getFormAction($this, 'publishDraft', (string) $this->objCurrentPost->getId())
2341  );
2342  } else {
2343  $this->replyEditForm->setFormAction(
2344  $this->ctrl->getFormAction($this, 'savePost', (string) $this->objCurrentPost->getId())
2345  );
2346  }
2347  $this->ctrl->clearParameters($this);
2348 
2349  if ($isReply) {
2350  $this->replyEditForm->setTitle($this->lng->txt('forums_your_reply'));
2351  } elseif ($isDraft) {
2352  $this->replyEditForm->setTitle($this->lng->txt('forums_edit_draft'));
2353  } else {
2354  $this->replyEditForm->setTitle($this->lng->txt('forums_edit_post'));
2355  }
2356 
2357  if (
2358  $this->isWritingWithPseudonymAllowed() &&
2359  in_array($this->requestAction, ['showreply', 'ready_showreply', 'editdraft'])
2360  ) {
2361  $oAnonymousNameGUI = new ilTextInputGUI($this->lng->txt('forums_your_name'), 'alias');
2362  $oAnonymousNameGUI->setMaxLength(64);
2363  $oAnonymousNameGUI->setInfo(sprintf($this->lng->txt('forums_use_alias'), $this->lng->txt('forums_anonymous')));
2364 
2365  $this->replyEditForm->addItem($oAnonymousNameGUI);
2366  }
2367 
2368  $oSubjectGUI = new ilTextInputGUI($this->lng->txt('forums_subject'), 'subject');
2369  $oSubjectGUI->setMaxLength(255);
2370  $oSubjectGUI->setRequired(true);
2371 
2372  if ($this->objProperties->getSubjectSetting() === 'empty_subject') {
2373  $oSubjectGUI->setInfo($this->lng->txt('enter_new_subject'));
2374  }
2375 
2376  $this->replyEditForm->addItem($oSubjectGUI);
2377 
2378  $oPostGUI = new ilTextAreaInputGUI(
2379  $isReply ? $this->lng->txt('forums_your_reply') : $this->lng->txt('forums_edit_post'),
2380  'message'
2381  );
2382  $oPostGUI->setRequired(true);
2383  $oPostGUI->setRows(15);
2384  $oPostGUI->setUseRte(true);
2385 
2386  $quotingAllowed = (
2387  !$this->isTopLevelReplyCommand() && (
2388  ($isReply && $this->objCurrentPost->getDepth() >= 2) ||
2389  (!$isDraft && !$isReply && $this->objCurrentPost->getDepth() > 2) ||
2390  ($isDraft && $this->objCurrentPost->getDepth() >= 2)
2391  )
2392  );
2393 
2394  $oPostGUI->removePlugin('advlink');
2395  $oPostGUI->setRTERootBlockElement('');
2396  $oPostGUI->usePurifier(true);
2397  $oPostGUI->disableButtons([
2398  'charmap',
2399  'undo',
2400  'redo',
2401  'justifyleft',
2402  'justifycenter',
2403  'justifyright',
2404  'justifyfull',
2405  'anchor',
2406  'fullscreen',
2407  'cut',
2408  'copy',
2409  'paste',
2410  'pastetext',
2411  'formatselect'
2412  ]);
2413 
2414  if (in_array($this->requestAction, ['showreply', 'ready_showreply', 'showdraft', 'editdraft'])) {
2415  $oPostGUI->setRTESupport(
2416  $this->user->getId(),
2417  'frm~',
2418  'frm_post',
2419  'tpl.tinymce_frm_post.js',
2420  false,
2421  '5.6.0'
2422  );
2423  } else {
2424  $oPostGUI->setRTESupport(
2425  $this->objCurrentPost->getId(),
2426  'frm',
2427  'frm_post',
2428  'tpl.tinymce_frm_post.js',
2429  false,
2430  '5.6.0'
2431  );
2432  }
2433 
2434  $oPostGUI->setPurifier(ilHtmlPurifierFactory::getInstanceByType('frm_post'));
2435 
2436  $this->replyEditForm->addItem($oPostGUI);
2437 
2438  $umail = new ilMail($this->user->getId());
2439  if (!$this->user->isAnonymous() &&
2440  !$this->objProperties->isAnonymized() &&
2441  $this->rbac->system()->checkAccess('internal_mail', $umail->getMailObjectReferenceId()) &&
2442  !$frm->isThreadNotificationEnabled($this->user->getId(), $this->objCurrentPost->getThreadId())) {
2443  $oNotificationGUI = new ilCheckboxInputGUI($this->lng->txt('forum_direct_notification'), 'notify');
2444  $oNotificationGUI->setInfo($this->lng->txt('forum_notify_me'));
2445  $this->replyEditForm->addItem($oNotificationGUI);
2446  }
2447 
2448  if ($this->objProperties->isFileUploadAllowed()) {
2449  $oFileUploadGUI = new ilFileWizardInputGUI($this->lng->txt('forums_attachments_add'), 'userfile');
2450  $oFileUploadGUI->setFilenames([0 => '']);
2451  $this->replyEditForm->addItem($oFileUploadGUI);
2452  }
2453 
2454  $attachments_of_node = $oFDForum->getFilesOfPost();
2455  if (count($attachments_of_node) && in_array($this->requestAction, ['showedit', 'ready_showedit'])) {
2456  $oExistingAttachmentsGUI = new ilCheckboxGroupInputGUI($this->lng->txt('forums_delete_file'), 'del_file');
2457  foreach ($oFDForum->getFilesOfPost() as $file) {
2458  $oExistingAttachmentsGUI->addOption(new ilCheckboxOption($file['name'], $file['md5']));
2459  }
2460  $this->replyEditForm->addItem($oExistingAttachmentsGUI);
2461  }
2462 
2464  if (in_array($this->requestAction, ['showdraft', 'editdraft'])) {
2465  $draftInfoGUI = new ilNonEditableValueGUI('', 'autosave_info', true);
2466  $draftInfoGUI->setValue(sprintf(
2467  $this->lng->txt('autosave_draft_info'),
2469  ));
2470  $this->replyEditForm->addItem($draftInfoGUI);
2471  } elseif (!in_array($this->requestAction, ['showedit', 'ready_showedit'])) {
2472  $draftInfoGUI = new ilNonEditableValueGUI('', 'autosave_info', true);
2473  $draftInfoGUI->setValue(sprintf(
2474  $this->lng->txt('autosave_post_draft_info'),
2476  ));
2477  $this->replyEditForm->addItem($draftInfoGUI);
2478  }
2479  }
2480 
2481  $selected_draft_id = $draft_id;
2482  $draftObj = new ilForumPostDraft(
2483  $this->user->getId(),
2484  $this->objCurrentPost->getId(),
2485  $selected_draft_id
2486  );
2487  if ($draftObj->getDraftId() > 0) {
2488  $oFDForumDrafts = new ilFileDataForumDrafts(0, $draftObj->getDraftId());
2489  $files_of_draft = $oFDForumDrafts->getFilesOfPost();
2490 
2491  if ($files_of_draft !== []) {
2492  $oExistingAttachmentsGUI = new ilCheckboxGroupInputGUI(
2493  $this->lng->txt('forums_delete_file'),
2494  'del_file'
2495  );
2496  foreach ($files_of_draft as $file) {
2497  $oExistingAttachmentsGUI->addOption(new ilCheckboxOption($file['name'], $file['md5']));
2498  }
2499  $this->replyEditForm->addItem($oExistingAttachmentsGUI);
2500  }
2501  }
2502 
2503  if ($this->isTopLevelReplyCommand()) {
2504  $this->replyEditForm->addCommandButton('saveTopLevelPost', $this->lng->txt('create'));
2505  } elseif ($this->requestAction === 'editdraft' && ilForumPostDraft::isSavePostDraftAllowed()) {
2506  $this->replyEditForm->addCommandButton('publishDraft', $this->lng->txt('publish'));
2507  } else {
2508  $this->replyEditForm->addCommandButton('savePost', $this->lng->txt('save'));
2509  }
2510  $hidden_draft_id = new ilHiddenInputGUI('draft_id');
2511  $auto_save_draft_id = $this->retrieveDraftId();
2512 
2513  $hidden_draft_id->setValue((string) $auto_save_draft_id);
2514  $this->replyEditForm->addItem($hidden_draft_id);
2515 
2516  if (in_array($this->requestAction, ['showreply', 'ready_showreply', 'editdraft'])) {
2517  $show_rte = $this->http->wrapper()->post()->retrieve(
2518  'show_rte',
2519  $this->refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
2520  );
2521 
2522  if ($show_rte) {
2524  }
2525 
2526  if ($quotingAllowed) {
2527  $this->replyEditForm->addCommandButton('quotePost', $this->lng->txt('forum_add_quote'));
2528  }
2529 
2530  if (!$this->user->isAnonymous() &&
2531  in_array($this->requestAction, ['editdraft', 'showreply', 'ready_showreply']) &&
2534  $this->decorateWithAutosave($this->replyEditForm);
2535  }
2536 
2537  if ($this->requestAction === 'editdraft') {
2538  $this->replyEditForm->addCommandButton('updateDraft', $this->lng->txt('save_message'));
2539  } elseif ($this->isTopLevelReplyCommand()) {
2540  $this->replyEditForm->addCommandButton('saveTopLevelDraft', $this->lng->txt('save_message'));
2541  } else {
2542  $this->replyEditForm->addCommandButton('saveAsDraft', $this->lng->txt('save_message'));
2543  }
2544 
2545  $cancel_cmd = 'cancelDraft';
2546  }
2547  }
2548  $this->replyEditForm->addCommandButton($cancel_cmd, $this->lng->txt('cancel'));
2549  }
setFilenames(array $a_filenames)
This class represents an option in a checkbox group.
static _setRichTextEditorUserState(int $a_state)
Sets the state of the rich text editor visibility for the current user.
This class represents a file wizard property in a property form.
This class represents a hidden form property in a property form.
static http()
Fetches the global http state from ILIAS.
static getInstanceByType(string $type)
This class represents a property in a property form.
setRequired(bool $a_required)
retrieveDraftId(bool $from_post=false)
This class represents a text area property in a property form.
decorateWithAutosave(ilPropertyFormGUI $form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSessionStorage()

ilObjForumGUI::initSessionStorage ( )
protected

Definition at line 133 of file class.ilObjForumGUI.php.

References ilSession\get(), ILIAS\Repository\int(), and ilSession\set().

Referenced by __construct().

133  : void
134  {
135  $forumValues = ilSession::get('frm');
136  if (!is_array($forumValues)) {
137  $forumValues = [];
138  ilSession::set('frm', $forumValues);
139  }
140 
141  $threadId = $this->objCurrentTopic->getId();
142  if ($threadId > 0 && !isset($forumValues[$threadId])) {
143  $forumValues[(int) $threadId] = [];
144  ilSession::set('frm', $forumValues);
145  }
146 
147  $this->selected_post_storage = new ilForumThreadSettingsSessionStorage('frm_selected_post');
148  }
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initStyleSheets()

ilObjForumGUI::initStyleSheets ( )
private

Definition at line 1089 of file class.ilObjForumGUI.php.

References ilObjStyleSheet\getSyntaxStylePath().

Referenced by renderThreadOverview().

1089  : void
1090  {
1091  $this->content_style_gui->addCss($this->tpl, $this->ref_id);
1092  $this->tpl->setCurrentBlock('SyntaxStyle');
1093  $this->tpl->setVariable('LOCATION_SYNTAX_STYLESHEET', ilObjStyleSheet::getSyntaxStylePath());
1094  $this->tpl->parseCurrentBlock();
1095  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isParentObjectCrsOrGrp()

ilObjForumGUI::isParentObjectCrsOrGrp ( )

Definition at line 4621 of file class.ilObjForumGUI.php.

References ILIAS\Repository\object().

Referenced by initHeaderAction(), and isUserAllowedToDeactivateNotification().

4621  : bool
4622  {
4623  $grpRefId = $this->tree->checkForParentType($this->object->getRefId(), 'grp');
4624  $crsRefId = $this->tree->checkForParentType($this->object->getRefId(), 'crs');
4625 
4626  return ($grpRefId > 0 || $crsRefId > 0);
4627  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isTopLevelReplyCommand()

ilObjForumGUI::isTopLevelReplyCommand ( )
private

Definition at line 256 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl().

Referenced by initReplyEditForm(), and viewThreadObject().

256  : bool
257  {
258  return in_array(
259  strtolower($this->ctrl->getCmd() ?? ''),
260  array_map('strtolower', ['createTopLevelPost', 'saveTopLevelPost', 'saveTopLevelDraft']),
261  true
262  );
263  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isUserAllowedToDeactivateNotification()

ilObjForumGUI::isUserAllowedToDeactivateNotification ( )

Definition at line 4601 of file class.ilObjForumGUI.php.

References isParentObjectCrsOrGrp(), ILIAS\Repository\object(), ilForumNotification\setUserId(), and ILIAS\Repository\user().

Referenced by initHeaderAction().

4601  : bool
4602  {
4603  if ($this->objProperties->getNotificationType() === 'default') {
4604  return true;
4605  }
4606 
4607  if (!$this->objProperties->isUserToggleNoti()) {
4608  return true;
4609  }
4610 
4611  if ($this->isParentObjectCrsOrGrp()) {
4612  $frm_noti = new ilForumNotification($this->object->getRefId());
4613  $frm_noti->setUserId($this->user->getId());
4614 
4615  return !$frm_noti->isUserToggleNotification();
4616  }
4617 
4618  return false;
4619  }
Class ilForumNotification.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isWritingWithPseudonymAllowed()

ilObjForumGUI::isWritingWithPseudonymAllowed ( )
private

Definition at line 3900 of file class.ilObjForumGUI.php.

Referenced by buildMinimalThreadForm(), buildThreadForm(), createEmptyThread(), createThread(), initReplyEditForm(), saveAsDraftObject(), savePostObject(), saveThreadAsDraftObject(), updateDraftObject(), and updateThreadDraftObject().

3900  : bool
3901  {
3902  return (
3903  $this->objProperties->isAnonymized() &&
3904  (!$this->is_moderator || !$this->objProperties->getMarkModeratorPosts())
3905  );
3906  }
+ Here is the caller graph for this function:

◆ markAllReadObject()

ilObjForumGUI::markAllReadObject ( )

Definition at line 657 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\lng(), showThreadsObject(), and ILIAS\Repository\user().

657  : void
658  {
659  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
660  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
661  }
662 
663  $this->object->markAllThreadsRead($this->user->getId());
664  $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_all_threads_marked_read'));
665  $this->showThreadsObject();
666  }
+ Here is the call graph for this function:

◆ markPostReadObject()

ilObjForumGUI::markPostReadObject ( )
protected

Definition at line 4390 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ensureThreadBelongsToForum(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ILIAS\Repository\user().

4390  : void
4391  {
4392  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4393  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4394  }
4395 
4396  if ($this->objCurrentTopic->getId() > 0 && $this->objCurrentPost->getId() > 0) {
4397  $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentPost->getThread());
4398 
4399  $this->object->markPostRead(
4400  $this->user->getId(),
4401  $this->objCurrentTopic->getId(),
4402  $this->objCurrentPost->getId()
4403  );
4404  }
4405 
4406  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4407  $this->ctrl->redirect($this, 'viewThread');
4408  }
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
+ Here is the call graph for this function:

◆ markPostUnreadObject()

ilObjForumGUI::markPostUnreadObject ( )
protected

Definition at line 4376 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ensureThreadBelongsToForum(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ILIAS\Repository\user(), and viewThreadObject().

4376  : void
4377  {
4378  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4379  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4380  }
4381 
4382  if ($this->objCurrentPost->getId() > 0) {
4383  $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentPost->getThread());
4384 
4385  $this->object->markPostUnread($this->user->getId(), $this->objCurrentPost->getId());
4386  }
4387  $this->viewThreadObject();
4388  }
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
+ Here is the call graph for this function:

◆ markTopThreadInOverview()

ilObjForumGUI::markTopThreadInOverview ( ilForumTopic  $current_thread,
Item  $list_item 
)
private

Definition at line 1077 of file class.ilObjForumGUI.php.

References ilForumTopic\isSticky().

Referenced by renderThreadOverview().

1080  : Item {
1081  if ($current_thread->isSticky()) {
1082  $df = new \ILIAS\Data\Factory();
1083  $list_item = $list_item->withColor($df->color('#B54F00'));
1084  }
1085 
1086  return $list_item;
1087  }
Common interface to all items.
Definition: Item.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mergeThreadsObject()

ilObjForumGUI::mergeThreadsObject ( )

Definition at line 4629 of file class.ilObjForumGUI.php.

References $is_moderator, ilForum\_lookupObjIdForForumId(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ILIAS\Repository\refinery(), ilForumTopicTableGUI\setSelectedThread(), and showThreadsObject().

Referenced by confirmMergeThreadsObject(), and performThreadsActionObject().

4629  : void
4630  {
4631  if (!$this->is_moderator) {
4632  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4633  }
4634 
4635  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4636  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4637  }
4638 
4639  $threadIdToMerge = $this->http->wrapper()->query()->retrieve(
4640  'thr_pk',
4641  $this->refinery->byTrying([
4642  $this->refinery->kindlyTo()->int(),
4643  $this->refinery->always(0)
4644  ])
4645  );
4646  if ($threadIdToMerge <= 0) {
4647  $threadIds = array_values(
4648  array_filter(array_map(intval(...), (array) ($this->httpRequest->getParsedBody()['thread_ids'] ?? [])))
4649  );
4650  if (count($threadIds) === 1) {
4651  $threadIdToMerge = current($threadIds);
4652  } else {
4653  $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_one'));
4654  $this->showThreadsObject();
4655  return;
4656  }
4657  }
4658 
4659  $frm = $this->object->Forum;
4660  $frm->setForumId($this->object->getId());
4661  $frm->setForumRefId($this->object->getRefId());
4662 
4663  $threadToMerge = new ilForumTopic($threadIdToMerge);
4664 
4665  if (ilForum::_lookupObjIdForForumId($threadToMerge->getForumId()) !== $frm->getForumId()) {
4666  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('not_allowed_to_merge_into_another_forum'));
4667  $this->showThreadsObject();
4668  return;
4669  }
4670 
4671  $frm->setMDB2Wherecondition('top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
4672 
4673  $threadsTemplate = new ilTemplate(
4674  'tpl.forums_threads_liste.html',
4675  true,
4676  true,
4677  'components/ILIAS/Forum'
4678  );
4679 
4680  $topicData = $frm->getOneTopic();
4681  if ($topicData->getTopPk() > 0) {
4682  $this->ctrl->setParameter($this, 'merge_thread_id', $threadIdToMerge);
4683  $tbl = new ilForumTopicTableGUI(
4684  $this,
4685  'mergeThreads',
4686  (int) $this->httpRequest->getQueryParams()['ref_id'],
4687  $topicData,
4689  );
4690  $tbl->setSelectedThread($threadToMerge);
4691  $tbl->setMapper($frm)->fetchData();
4692  $tbl->init();
4693  $threadsTemplate->setVariable('THREADS_TABLE', $tbl->getHTML());
4694  $this->tpl->setContent($threadsTemplate->get());
4695  } else {
4696  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
4697  $this->showThreadsObject();
4698  }
4699  }
setSelectedThread(ilForumTopic $thread_obj)
Class ilForumTopicTableGUI.
static http()
Fetches the global http state from ILIAS.
static _lookupObjIdForForumId(int $a_for_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ moveThreadsObject()

ilObjForumGUI::moveThreadsObject ( )

Definition at line 3817 of file class.ilObjForumGUI.php.

References $is_moderator, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ensureThreadBelongsToForum(), ilSession\get(), hideToolbar(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), null, ILIAS\Repository\object(), ILIAS\Repository\refinery(), and ILIAS\Repository\toolbar().

Referenced by performMoveThreadsObject(), and performThreadsActionObject().

3817  : bool
3818  {
3819  if (!$this->is_moderator) {
3820  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3821  }
3822 
3823  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3824  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3825  }
3826 
3827  $frm_ref_id = $this->http->wrapper()->post()->retrieve(
3828  'frm_ref_id',
3829  $this->refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(null)])
3830  );
3831 
3832  $threads2move = ilSession::get('threads2move');
3833  if (!is_array($threads2move) || $threads2move === []) {
3834  $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_at_least_one_thread'), true);
3835  $this->ctrl->redirect($this, 'showThreads');
3836  }
3837 
3838  $threads = [];
3839  $isModerator = $this->is_moderator;
3840  array_walk($threads2move, function (int $threadId) use (&$threads, $isModerator): void {
3841  $thread = new ilForumTopic($threadId, $isModerator);
3842  $this->ensureThreadBelongsToForum($this->object->getId(), $thread);
3843 
3844  $threads[] = $thread;
3845  });
3846 
3847  $exp = new ilForumMoveTopicsExplorer($this, 'moveThreads');
3848  $exp->setPathOpen($this->object->getRefId());
3849  $exp->setNodeSelected(isset($frm_ref_id) && (int) $frm_ref_id ? (int) $frm_ref_id : 0);
3850  $exp->setCurrentFrmRefId($this->object->getRefId());
3851  $exp->setHighlightedNode((string) $this->object->getRefId());
3852  if (!$exp->handleCommand()) {
3853  $moveThreadTemplate = new ilTemplate(
3854  'tpl.forums_threads_move.html',
3855  true,
3856  true,
3857  'components/ILIAS/Forum'
3858  );
3859 
3860  if (!$this->hideToolbar()) {
3861  $this->toolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this));
3862  }
3863 
3864  $tblThr = new ilTable2GUI($this);
3865 
3866  $counter = 0;
3867  $result = [];
3868  foreach ($threads as $thread) {
3869  $result[$counter]['num'] = $counter + 1;
3870  $result[$counter]['thr_subject'] = $thread->getSubject();
3871  ++$counter;
3872  }
3873 
3874  $tblThr->setId('frmthrmv' . $this->object->getRefId());
3875  $tblThr->setTitle('');
3876  $tblThr->addColumn($this->lng->txt('subject'), 'top_name', '100%');
3877  $tblThr->disable('header');
3878  $tblThr->disable('footer');
3879  $tblThr->disable('linkbar');
3880  $tblThr->disable('sort');
3881  $tblThr->disable('linkbar');
3882  $tblThr->setLimit(PHP_INT_MAX);
3883  $tblThr->setRowTemplate('tpl.forums_threads_move_thr_row.html', 'components/ILIAS/Forum');
3884  $tblThr->setDefaultOrderField('is_sticky');
3885 
3886  #$tblThr->setData($result);
3887  $moveThreadTemplate->setVariable('THREAD_TITLE', sprintf($this->lng->txt('move_chosen_topics'), $thread->getSubject()));
3888  $moveThreadTemplate->setVariable('THREADS_TABLE', $tblThr->getHTML());
3889  $moveThreadTemplate->setVariable('FRM_SELECTION_TREE', $exp->getHTML());
3890  $moveThreadTemplate->setVariable('CMD_SUBMIT', 'performMoveThreads');
3891  $moveThreadTemplate->setVariable('TXT_SUBMIT', $this->lng->txt('move'));
3892  $moveThreadTemplate->setVariable('FORMACTION', $this->ctrl->getFormAction($this, 'performMoveThreads'));
3893 
3894  $this->tpl->setContent($moveThreadTemplate->get());
3895  }
3896 
3897  return true;
3898  }
static get(string $a_var)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
hideToolbar($a_flag=null)
static http()
Fetches the global http state from ILIAS.
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performDeleteThreadsObject()

ilObjForumGUI::performDeleteThreadsObject ( )

Definition at line 1811 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ensureThreadBelongsToForum(), hideToolbar(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and retrieveThreadIds().

1811  : void
1812  {
1813  $threadIds = $this->retrieveThreadIds();
1814  if ($threadIds === []) {
1815  $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_at_least_one_thread'), true);
1816  $this->ctrl->redirect($this, 'showThreads');
1817  }
1818 
1819  if (!$this->is_moderator) {
1820  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1821  }
1822 
1823  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1824  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1825  }
1826 
1827  $forumObj = new ilObjForum($this->object->getRefId());
1828  $this->objProperties->setObjId($forumObj->getId());
1829 
1830  $frm = new ilForum();
1831 
1832  $success_message = 'forums_thread_deleted';
1833  if (count($threadIds) > 1) {
1834  $success_message = 'forums_threads_deleted';
1835  }
1836 
1837  $threads = [];
1838  array_walk($threadIds, function (int $threadId) use (&$threads): void {
1839  $thread = new ilForumTopic($threadId);
1840  $this->ensureThreadBelongsToForum($this->object->getId(), $thread);
1841 
1842  $threads[] = $thread;
1843  });
1844 
1845  $frm->setForumId($forumObj->getId());
1846  $frm->setForumRefId($forumObj->getRefId());
1847  foreach ($threads as $thread) {
1848  $first_node = $frm->getFirstPostNode($thread->getId());
1849  if (isset($first_node['pos_pk']) && (int) $first_node['pos_pk']) {
1850  $frm->deletePost((int) $first_node['pos_pk']);
1851  $this->tpl->setOnScreenMessage('info', $this->lng->txt($success_message), true);
1852  }
1853  }
1854  $this->ctrl->redirect($this, 'showThreads');
1855  }
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
+ Here is the call graph for this function:

◆ performMergeThreadsObject()

ilObjForumGUI::performMergeThreadsObject ( )

Definition at line 4763 of file class.ilObjForumGUI.php.

References Vendor\Package\$e, ILIAS\Repository\access(), ensureThreadBelongsToForum(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and showThreadsObject().

4763  : void
4764  {
4765  if (!$this->is_moderator) {
4766  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4767  }
4768 
4769  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4770  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4771  }
4772 
4773  $threadIds = array_values(
4774  array_filter(array_map(intval(...), (array) ($this->httpRequest->getParsedBody()['thread_ids'] ?? [])))
4775  );
4776  if (count($threadIds) !== 2) {
4777  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
4778  $this->showThreadsObject();
4779  return;
4780  }
4781 
4782  if ((int) $threadIds[0] === (int) $threadIds[1]) {
4783  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('error_same_thread_ids'));
4784  $this->showThreadsObject();
4785  return;
4786  }
4787 
4788  try {
4789  $frm = new ilForum();
4790  $frm->setForumId($this->object->getId());
4791  $frm->setForumRefId($this->object->getRefId());
4792 
4793  $this->ensureThreadBelongsToForum($this->object->getId(), new ilForumTopic((int) $threadIds[0]));
4794  $this->ensureThreadBelongsToForum($this->object->getId(), new ilForumTopic((int) $threadIds[1]));
4795 
4796  $frm->mergeThreads((int) $threadIds[0], (int) $threadIds[1]);
4797  $this->tpl->setOnScreenMessage('success', $this->lng->txt('merged_threads_successfully'));
4798  } catch (ilException $e) {
4799  $this->tpl->setOnScreenMessage('failure', $this->lng->txt($e->getMessage()));
4800  }
4801 
4802  $this->showThreadsObject();
4803  }
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
+ Here is the call graph for this function:

◆ performMoveThreadsObject()

ilObjForumGUI::performMoveThreadsObject ( )

Definition at line 3752 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ensureThreadBelongsToForum(), ilSession\get(), ILIAS\FileDelivery\http(), ILIAS\Repository\int(), ILIAS\Repository\lng(), moveThreadsObject(), null, ILIAS\Repository\object(), ILIAS\Repository\refinery(), and ilSession\set().

3752  : void
3753  {
3754  if (!$this->is_moderator) {
3755  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3756  }
3757 
3758  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3759  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3760  }
3761 
3762  $frm_ref_id = null;
3763  if ($this->http->wrapper()->post()->has('frm_ref_id')) {
3764  $frm_ref_id = $this->http->wrapper()->post()->retrieve(
3765  'frm_ref_id',
3766  $this->refinery->kindlyTo()->int()
3767  );
3768  } else {
3769  $this->error->raiseError('Please select a forum', $this->error->MESSAGE);
3770  }
3771 
3772  $threads2move = ilSession::get('threads2move');
3773  if (!is_array($threads2move) || $threads2move === []) {
3774  $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_at_least_one_thread'), true);
3775  $this->ctrl->redirect($this, 'showThreads');
3776  }
3777 
3778  if (!$this->access->checkAccess('read', '', (int) $frm_ref_id)) {
3779  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3780  }
3781 
3782  $threads = [];
3783  array_walk($threads2move, function (int $threadId) use (&$threads): void {
3784  $thread = new ilForumTopic($threadId);
3785  $this->ensureThreadBelongsToForum($this->object->getId(), $thread);
3786 
3787  $threads[] = $threadId;
3788  });
3789 
3790  if (isset($frm_ref_id) && (int) $frm_ref_id) {
3791  $errorMessages = $this->object->Forum->moveThreads(
3792  (array) (ilSession::get('threads2move') ?? []),
3793  $this->object,
3794  $this->ilObjDataCache->lookupObjId((int) $frm_ref_id)
3795  );
3796 
3797  if ([] !== $errorMessages) {
3798  $this->tpl->setOnScreenMessage('failure', implode('<br><br>', $errorMessages), true);
3799  $this->ctrl->redirect($this, 'showThreads');
3800  }
3801 
3802  ilSession::set('threads2move', []);
3803  $this->tpl->setOnScreenMessage('info', $this->lng->txt('threads_moved_successfully'), true);
3804  $this->ctrl->redirect($this, 'showThreads');
3805  } else {
3806  $this->tpl->setOnScreenMessage('info', $this->lng->txt('no_forum_selected'));
3807  $this->moveThreadsObject();
3808  }
3809  }
static get(string $a_var)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

◆ performPostActivationObject()

ilObjForumGUI::performPostActivationObject ( )

Definition at line 1975 of file class.ilObjForumGUI.php.

References $GLOBALS, $objCurrentPost, ILIAS\Repository\access(), ensureThreadBelongsToForum(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and viewThreadObject().

1975  : void
1976  {
1977  if (!$this->is_moderator) {
1978  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1979  }
1980 
1981  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1982  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1983  }
1984 
1985  $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentPost->getThread());
1986 
1987  $this->objCurrentPost->activatePost();
1988  $GLOBALS['ilAppEventHandler']->raise(
1989  'components/ILIAS/Forum',
1990  'activatedPost',
1991  [
1992  'object' => $this->object,
1993  'ref_id' => $this->object->getRefId(),
1994  'post' => $this->objCurrentPost
1995  ]
1996  );
1997  $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_post_was_activated'), true);
1998 
1999  $this->viewThreadObject();
2000  }
ilForumPost $objCurrentPost
$GLOBALS["DIC"]
Definition: wac.php:53
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
+ Here is the call graph for this function:

◆ performThreadsActionObject()

ilObjForumGUI::performThreadsActionObject ( )

Definition at line 3636 of file class.ilObjForumGUI.php.

References $message, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ensureThreadBelongsToForum(), ILIAS\Repository\lng(), mergeThreadsObject(), moveThreadsObject(), null, ILIAS\Repository\object(), retrieveThreadIds(), ilSession\set(), ILIAS\Repository\settings(), updateThreadObject(), and ILIAS\Repository\user().

3636  : void
3637  {
3638  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3639  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3640  }
3641 
3642  ilSession::set('threads2move', []);
3643 
3644  $thread_ids = $this->retrieveThreadIds();
3645  $cmd = $this->ctrl->getCmd();
3646  $message = null;
3647 
3648  if ($thread_ids !== []) {
3649  if ($cmd === 'move') {
3650  if ($this->is_moderator) {
3651  ilSession::set('threads2move', $thread_ids);
3652  $this->moveThreadsObject();
3653  }
3654  } elseif ($cmd === 'enable_notifications' && (int) $this->settings->get('forum_notification', '0') !== 0) {
3655  foreach ($thread_ids as $thread_id) {
3656  $tmp_obj = new ilForumTopic($thread_id);
3657  $this->ensureThreadBelongsToForum($this->object->getId(), $tmp_obj);
3658  $tmp_obj->enableNotification($this->user->getId());
3659  }
3660 
3661  $this->ctrl->redirect($this, 'showThreads');
3662  } elseif ($cmd === 'disable_notifications' && (int) $this->settings->get('forum_notification', '0') !== 0) {
3663  foreach ($thread_ids as $thread_id) {
3664  $tmp_obj = new ilForumTopic($thread_id);
3665  $this->ensureThreadBelongsToForum($this->object->getId(), $tmp_obj);
3666  $tmp_obj->disableNotification($this->user->getId());
3667  }
3668 
3669  $this->ctrl->redirect($this, 'showThreads');
3670  } elseif ($cmd === 'close') {
3671  if ($this->is_moderator) {
3672  foreach ($thread_ids as $thread_id) {
3673  $tmp_obj = new ilForumTopic($thread_id);
3674  $this->ensureThreadBelongsToForum($this->object->getId(), $tmp_obj);
3675  $tmp_obj->close();
3676  }
3677  }
3678  $this->tpl->setOnScreenMessage('success', $this->lng->txt('selected_threads_closed'), true);
3679  $this->ctrl->redirect($this, 'showThreads');
3680  } elseif ($cmd === 'reopen') {
3681  if ($this->is_moderator) {
3682  foreach ($thread_ids as $thread_id) {
3683  $tmp_obj = new ilForumTopic($thread_id);
3684  $this->ensureThreadBelongsToForum($this->object->getId(), $tmp_obj);
3685  $tmp_obj->reopen();
3686  }
3687  }
3688 
3689  $this->tpl->setOnScreenMessage('success', $this->lng->txt('selected_threads_reopened'), true);
3690  $this->ctrl->redirect($this, 'showThreads');
3691  } elseif ($cmd === 'makesticky') {
3692  if ($this->is_moderator) {
3693  $message = $this->lng->txt('sel_threads_make_sticky');
3694 
3695  foreach ($thread_ids as $thread_id) {
3696  $tmp_obj = new ilForumTopic($thread_id);
3697  $this->ensureThreadBelongsToForum($this->object->getId(), $tmp_obj);
3698  $makeSticky = $tmp_obj->makeSticky();
3699  if (!$makeSticky) {
3700  $message = $this->lng->txt('sel_threads_already_sticky');
3701  }
3702  }
3703  }
3704  if ($message !== null) {
3705  $this->tpl->setOnScreenMessage('info', $message, true);
3706  }
3707  $this->ctrl->redirect($this, 'showThreads');
3708  } elseif ($cmd === 'unmakesticky' || $cmd === 'make_topics_non_sticky') {
3709  if ($this->is_moderator) {
3710  $message = $this->lng->txt('sel_threads_make_unsticky');
3711  foreach ($thread_ids as $thread_id) {
3712  $tmp_obj = new ilForumTopic($thread_id);
3713  $this->ensureThreadBelongsToForum($this->object->getId(), $tmp_obj);
3714  $unmakeSticky = $tmp_obj->unmakeSticky();
3715  if (!$unmakeSticky) {
3716  $message = $this->lng->txt('sel_threads_already_unsticky');
3717  }
3718  }
3719  }
3720 
3721  if ($message !== null) {
3722  $this->tpl->setOnScreenMessage('info', $message, true);
3723  }
3724  $this->ctrl->redirect($this, 'showThreads');
3725  } elseif ($cmd === 'editThread') {
3726  if ($this->is_moderator) {
3727  $count = count($thread_ids);
3728  if ($count !== 1) {
3729  $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_max_one_thread'), true);
3730  $this->ctrl->redirect($this, 'showThreads');
3731  } else {
3732  $this->updateThreadObject();
3733  return;
3734  }
3735  }
3736 
3737  $this->ctrl->redirect($this, 'showThreads');
3738  } elseif ($cmd === 'confirmDeleteThreads') {
3739  $this->confirmDeleteThreadsObject();
3740  } elseif ($cmd === 'mergeThreads') {
3741  $this->mergeThreadsObject();
3742  } else {
3743  $this->tpl->setOnScreenMessage('info', $this->lng->txt('topics_please_select_one_action'), true);
3744  $this->ctrl->redirect($this, 'showThreads');
3745  }
3746  } else {
3747  $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_at_least_one_thread'), true);
3748  $this->ctrl->redirect($this, 'showThreads');
3749  }
3750  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
$message
Definition: xapiexit.php:31
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

◆ prepareFormOutput()

ilObjForumGUI::prepareFormOutput ( string  $a_text)

Definition at line 4350 of file class.ilObjForumGUI.php.

References ilLegacyFormElementsUtil\prepareFormOutput().

4350  : string
4351  {
4352  $a_text = str_replace(['&lt;', '&gt;'], ['<', '>'], $a_text);
4353 
4355  }
static prepareFormOutput($a_str, bool $a_strip=false)
+ Here is the call graph for this function:

◆ publishDraftObject()

ilObjForumGUI::publishDraftObject ( bool  $use_replyform = true)

Definition at line 2604 of file class.ilObjForumGUI.php.

References $GLOBALS, $message, ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), ilRTE\_replaceMediaObjectImageSrc(), ilObjMediaObject\_saveUsage(), ILIAS\Repository\access(), checkDraftAccess(), ILIAS\Repository\ctrl(), ilSession\get(), getForumObjects(), getReplyEditForm(), handleFormInput(), ilForumPostDraft\isSavePostDraftAllowed(), ILIAS\Repository\lng(), ILIAS\Repository\object(), retrieveDraftId(), ilForumUtil\saveMediaObjects(), ilSession\set(), ilFileDataForum\storeUploadedFiles(), ILIAS\Repository\user(), and viewThreadObject().

Referenced by publishSelectedDraftObject().

2604  : void
2605  {
2607  !$this->access->checkAccess('read', '', $this->object->getRefId())) {
2608  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2609  }
2610 
2611  if (!$this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
2612  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2613  }
2614 
2615  if ($this->objCurrentTopic->getId() === 0) {
2616  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_deleted'), true);
2617  $this->ctrl->redirect($this);
2618  }
2619 
2620  if ($this->objCurrentTopic->isClosed()) {
2621  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_closed'), true);
2622  $this->ctrl->redirect($this);
2623  }
2624 
2625  if ($this->objCurrentPost->getId() === 0) {
2626  $this->requestAction = '';
2627  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_parent_deleted'));
2628  $this->viewThreadObject();
2629  return;
2630  }
2631 
2632  $draft = new ilForumPostDraft($this->user->getId(), $this->objCurrentPost->getId(), $this->retrieveDraftId());
2633  $this->checkDraftAccess($draft->getDraftId());
2634 
2635  if ($use_replyform) {
2636  $oReplyEditForm = $this->getReplyEditForm();
2637  if (!$oReplyEditForm->checkInput()) {
2638  $oReplyEditForm->setValuesByPost();
2639  $this->viewThreadObject();
2640  return;
2641  }
2642  $post_subject = $oReplyEditForm->getInput('subject');
2643  $post_message = $oReplyEditForm->getInput('message');
2644  $mob_direction = 0;
2645  } else {
2646  $post_subject = $draft->getPostSubject();
2647  $post_message = $draft->getPostMessage();
2648  $mob_direction = 1;
2649  }
2650 
2651  $oForumObjects = $this->getForumObjects();
2652  $frm = $oForumObjects['frm'];
2653  $frm->setMDB2WhereCondition(' top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
2654 
2655  // reply: new post
2656  $status = true;
2657  $send_activation_mail = false;
2658 
2659  if ($this->objProperties->isPostActivationEnabled()) {
2660  if (!$this->is_moderator) {
2661  $status = false;
2662  $send_activation_mail = true;
2663  } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2664  $status = false;
2665  }
2666  }
2667 
2668  $newPost = $frm->generatePost(
2669  $draft->getForumId(),
2670  $draft->getThreadId(),
2671  $this->user->getId(),
2672  $draft->getPostDisplayUserId(),
2673  ilRTE::_replaceMediaObjectImageSrc($post_message, $mob_direction),
2674  $draft->getPostId(),
2675  $draft->isNotificationEnabled(),
2676  $this->handleFormInput($post_subject, false),
2677  $draft->getPostUserAlias(),
2678  '',
2679  $status,
2680  $send_activation_mail
2681  );
2682 
2683  $this->object->markPostRead(
2684  $this->user->getId(),
2685  $this->objCurrentTopic->getId(),
2686  $this->objCurrentPost->getId()
2687  );
2688 
2689  $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
2690 
2691  foreach ($uploadedObjects as $mob) {
2692  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
2693  ilObjMediaObject::_saveUsage($mob, 'frm:html', $newPost);
2694  }
2695  ilForumUtil::saveMediaObjects($post_message, 'frm:html', $newPost, $mob_direction);
2696  $post_obj = new ilForumPost($newPost);
2697 
2698  if ($draft->getRCID() > 0) {
2699  $post_obj->setRCID($draft->getRCID());
2700  $post_obj->update();
2701  }
2702 
2703  if ($this->objProperties->isFileUploadAllowed()) {
2704  $file = $_FILES['userfile'] ?? [];
2705  if (is_array($file) && !empty($file)) {
2706  $tmp_file_obj = new ilFileDataForum($this->object->getId(), $newPost);
2707  $tmp_file_obj->storeUploadedFiles();
2708  }
2709  }
2710 
2711  $GLOBALS['ilAppEventHandler']->raise(
2712  'components/ILIAS/Forum',
2713  'publishedDraft',
2714  [
2715  'draftObj' => $draft,
2716  'obj_id' => $this->object->getId(),
2717  'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
2718  ]
2719  );
2720  $draft->deleteDraft();
2721 
2722  $GLOBALS['ilAppEventHandler']->raise(
2723  'components/ILIAS/Forum',
2724  'createdPost',
2725  [
2726  'object' => $this->object,
2727  'ref_id' => $this->object->getRefId(),
2728  'post' => $post_obj,
2729  'notify_moderators' => $send_activation_mail
2730  ]
2731  );
2732 
2733  $message = '';
2734  if (!$this->is_moderator && !$status) {
2735  $message .= $this->lng->txt('forums_post_needs_to_be_activated');
2736  } else {
2737  $message .= $this->lng->txt('forums_post_new_entry');
2738  }
2739 
2740  $frm_session_values = ilSession::get('frm');
2741  if (is_array($frm_session_values)) {
2742  $frm_session_values[$this->objCurrentTopic->getId()]['openTreeNodes'][] = $this->objCurrentPost->getId();
2743  }
2744  ilSession::set('frm', $frm_session_values);
2745 
2746  $this->ctrl->clearParameters($this);
2747  $this->tpl->setOnScreenMessage('success', $message, true);
2748  $this->ctrl->setParameter($this, 'pos_pk', $newPost);
2749  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2750 
2751  $this->ctrl->redirect($this, 'viewThread');
2752  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static get(string $a_var)
static _saveUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Save usage of mob within another container (e.g.
$GLOBALS["DIC"]
Definition: wac.php:53
handleFormInput(string $a_text, bool $a_stripslashes=true)
static saveMediaObjects(string $post_message, string $target_type, int $target_id, int $direction=0)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
static _removeUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Remove usage of mob in another container.
checkDraftAccess(int|ilForumPostDraft $draft)
retrieveDraftId(bool $from_post=false)
$message
Definition: xapiexit.php:31
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ publishSelectedDraftObject()

ilObjForumGUI::publishSelectedDraftObject ( )

Definition at line 2596 of file class.ilObjForumGUI.php.

References publishDraftObject(), and retrieveDraftId().

2596  : void
2597  {
2598  $draft_id = $this->retrieveDraftId();
2599  if ($draft_id > 0) {
2600  $this->publishDraftObject(false);
2601  }
2602  }
publishDraftObject(bool $use_replyform=true)
retrieveDraftId(bool $from_post=false)
+ Here is the call graph for this function:

◆ publishThreadDraftObject()

ilObjForumGUI::publishThreadDraftObject ( )
protected

Definition at line 4245 of file class.ilObjForumGUI.php.

References checkDraftAccess(), createThread(), ilForumPostDraft\isSavePostDraftAllowed(), ILIAS\Repository\lng(), ilForumPostDraft\newInstanceByDraftId(), and retrieveDraftId().

4245  : void
4246  {
4248  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4249  }
4250 
4252  $this->checkDraftAccess($draft);
4253 
4254  $this->createThread($draft, true);
4255  }
checkDraftAccess(int|ilForumPostDraft $draft)
retrieveDraftId(bool $from_post=false)
createThread(ilForumPostDraft $draft, bool $createFromDraft=false)
Refactored thread creation to method, refactoring to a separate class should be done in next refactor...
static newInstanceByDraftId(int $draft_id)
+ Here is the call graph for this function:

◆ quotePostObject()

ilObjForumGUI::quotePostObject ( )

Definition at line 3022 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), getReplyEditForm(), ILIAS\Repository\lng(), and viewThreadObject().

3022  : void
3023  {
3024  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3025  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3026  }
3027 
3028  if ($this->objCurrentTopic->isClosed()) {
3029  $this->requestAction = '';
3030  $this->viewThreadObject();
3031  return;
3032  }
3033 
3034  $oReplyEditForm = $this->getReplyEditForm();
3035 
3036  $oReplyEditForm->getItemByPostVar('subject')->setRequired(false);
3037  $oReplyEditForm->getItemByPostVar('message')->setRequired(false);
3038 
3039  $oReplyEditForm->checkInput();
3040 
3041  $oReplyEditForm->getItemByPostVar('subject')->setRequired(true);
3042  $oReplyEditForm->getItemByPostVar('message')->setRequired(true);
3043 
3044  $this->requestAction = 'showreply';
3045 
3046  $this->viewThreadObject();
3047  }
+ Here is the call graph for this function:

◆ renderDraftContent()

ilObjForumGUI::renderDraftContent ( ilTemplate  $tpl,
string  $action,
ilForumPost  $referencePosting,
array  $drafts 
)
private
Parameters
list<ilForumPostDraft>$drafts

Definition at line 1105 of file class.ilObjForumGUI.php.

References $modal_history, ilForum\_isModerator(), ilRTE\_replaceMediaObjectImageSrc(), ILIAS\Repository\ctrl(), ilForumPost\getDepth(), ilFileDataForumDrafts\getFilesOfPost(), ilForumPost\getId(), getReplyEditForm(), ilForumPost\getThreadId(), ilForumPost\getUpdateUserId(), ILIAS\FileDelivery\http(), ilForumPost\isCensored(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilTemplate\parseCurrentBlock(), ilLegacyFormElementsUtil\prepareFormOutput(), ILIAS\Repository\refinery(), renderPostingForm(), renderSplitButton(), retrieveDraftId(), ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), and ilForumProperties\VIEW_TREE.

Referenced by viewThreadObject().

1110  : void {
1111  $frm = $this->object->Forum;
1112 
1113  $draft_id = $this->retrieveDraftId();
1114  foreach ($drafts as $draft) {
1115  $tmp_file_obj = new ilFileDataForumDrafts($this->object->getId(), $draft->getDraftId());
1116  $filesOfDraft = $tmp_file_obj->getFilesOfPost();
1117  ksort($filesOfDraft);
1118 
1119  if ($action !== 'showdraft' && $filesOfDraft !== []) {
1120  foreach ($filesOfDraft as $file) {
1121  $tpl->setCurrentBlock('attachment_download_row');
1122  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
1123  $this->ctrl->setParameter($this, 'file', $file['md5']);
1124  $tpl->setVariable('HREF_DOWNLOAD', $this->ctrl->getLinkTarget($this, 'viewThread'));
1125  $tpl->setVariable('TXT_FILENAME', $file['name']);
1126  $this->ctrl->setParameter($this, 'file', '');
1127  $this->ctrl->setParameter($this, 'draft_id', '');
1128  $this->ctrl->clearParameters($this);
1129  $tpl->parseCurrentBlock();
1130  }
1131 
1132  $tpl->setCurrentBlock('attachments');
1133  $tpl->setVariable('TXT_ATTACHMENTS_DOWNLOAD', $this->lng->txt('forums_attachments'));
1134  $tpl->setVariable(
1135  'DOWNLOAD_IMG',
1136  $this->uiRenderer->render(
1137  $this->uiFactory->symbol()->glyph()->attachment($this->lng->txt('forums_download_attachment'))
1138  )
1139  );
1140  if (count($filesOfDraft) > 1) {
1141  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
1142  $download_zip_button = $this->uiFactory->button()
1143  ->standard(
1144  $this->lng->txt('download'),
1145  $this->ctrl->getLinkTarget($this, 'deliverDraftZipFile')
1146  );
1147  $this->ctrl->setParameter($this, 'draft_id', '');
1148  $tpl->setVariable('DOWNLOAD_ZIP', $this->uiRenderer->render($download_zip_button));
1149  }
1150  $tpl->parseCurrentBlock();
1151  }
1152 
1153  $page = $this->http->wrapper()->query()->retrieve(
1154  'page',
1155  $this->refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
1156  );
1157 
1158  $this->renderSplitButton(
1159  $tpl,
1160  $action,
1161  false,
1162  $referencePosting,
1163  (int) $page,
1164  $draft
1165  );
1166 
1167  $rowCol = 'tblrowmarked';
1168  $tpl->setVariable('ROWCOL', ' ' . $rowCol);
1169  $depth = $referencePosting->getDepth() - 1;
1170  if ($this->selectedSorting === ilForumProperties::VIEW_TREE) {
1171  ++$depth;
1172  }
1173  $tpl->setVariable('DEPTH', $depth);
1174 
1175  $this->ctrl->setParameter($this, 'pos_pk', $referencePosting->getId());
1176  $this->ctrl->setParameter($this, 'thr_pk', $referencePosting->getThreadId());
1177  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
1178 
1179  $backurl = urlencode($this->ctrl->getLinkTarget($this, 'viewThread', (string) $referencePosting->getId()));
1180 
1181  $this->ctrl->setParameter($this, 'backurl', $backurl);
1182  $this->ctrl->setParameter($this, 'thr_pk', $referencePosting->getThreadId());
1183  $this->ctrl->setParameter($this, 'user', $draft->getPostDisplayUserId());
1184 
1185  $authorinfo = new ilForumAuthorInformation(
1186  $draft->getPostAuthorId(),
1187  $draft->getPostDisplayUserId(),
1188  $draft->getPostUserAlias(),
1189  '',
1190  [
1191  'href' => $this->ctrl->getLinkTarget($this, 'showUser')
1192  ]
1193  );
1194 
1195  $this->ctrl->clearParameters($this);
1196 
1197  if ($authorinfo->hasSuffix()) {
1198  $tpl->setVariable('AUTHOR', $authorinfo->getSuffix());
1199  $tpl->setVariable('USR_NAME', $draft->getPostUserAlias());
1200  } else {
1201  $tpl->setVariable('AUTHOR', $authorinfo->getLinkedAuthorShortName());
1202  if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized()) {
1203  $tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true));
1204  }
1205  }
1206  $tpl->setVariable('DRAFT_ANCHOR', 'draft_' . $draft->getDraftId());
1207 
1208  $tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture());
1209  $tpl->setVariable(
1210  'USR_ICON_ALT',
1211  ilLegacyFormElementsUtil::prepareFormOutput($authorinfo->getAuthorShortName())
1212  );
1213  if ($authorinfo->getAuthor()->getId() && ilForum::_isModerator(
1214  $this->object->getRefId(),
1215  $draft->getPostAuthorId()
1216  )) {
1217  if ($authorinfo->getAuthor()->getGender() === 'f') {
1218  $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_f'));
1219  } elseif ($authorinfo->getAuthor()->getGender() === 'm') {
1220  $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_m'));
1221  } elseif ($authorinfo->getAuthor()->getGender() === 'n') {
1222  $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_n'));
1223  }
1224  }
1225 
1226  if ($draft->getUpdateUserId() > 0) {
1227  $draft->setPostUpdate($draft->getPostUpdate());
1228 
1229  $this->ctrl->setParameter($this, 'backurl', $backurl);
1230  $this->ctrl->setParameter($this, 'thr_pk', $referencePosting->getThreadId());
1231  $this->ctrl->setParameter($this, 'user', $referencePosting->getUpdateUserId());
1232  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
1233 
1234  $authorinfo = new ilForumAuthorInformation(
1235  $draft->getPostAuthorId(),
1236  // We assume the editor is the author here
1237  $draft->getPostDisplayUserId(),
1238  $draft->getPostUserAlias(),
1239  '',
1240  ['href' => $this->ctrl->getLinkTarget($this, 'showUser')]
1241  );
1242 
1243  $this->ctrl->clearParameters($this);
1244 
1245  $tpl->setVariable(
1246  'POST_UPDATE_TXT',
1247  $this->lng->txt('edited_on') . ': ' . $frm->convertDate($draft->getPostUpdate()) . ' - ' . strtolower($this->lng->txt('by'))
1248  );
1249  $tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
1250  if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
1251  $tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true));
1252  }
1253  }
1254 
1255  $draft->setPostMessage($frm->prepareText($draft->getPostMessage()));
1256 
1257  $tpl->setVariable('SUBJECT', $draft->getPostSubject());
1258  $tpl->setVariable('POST_DATE', $frm->convertDate($draft->getPostDate()));
1259 
1260  $tpl->setVariable('POST_DRAFT_TEXT', $this->lng->txt('post_draft_info'));
1261 
1262  if (!$referencePosting->isCensored() || ($this->objCurrentPost->getId() === $referencePosting->getId() && $action === 'censor')) {
1263  $spanClass = '';
1264  if (ilForum::_isModerator($this->ref_id, $draft->getPostDisplayUserId())) {
1265  $spanClass = 'moderator';
1266  }
1267 
1268  if ($draft->getPostMessage() === strip_tags($draft->getPostMessage())) {
1269  // We can be sure, that there are not html tags
1270  $draft->setPostMessage(nl2br($draft->getPostMessage()));
1271  }
1272 
1273  if ($spanClass !== '') {
1274  $tpl->setVariable(
1275  'POST',
1276  '<span class="' . $spanClass . '">' . ilRTE::_replaceMediaObjectImageSrc(
1277  $draft->getPostMessage(),
1278  1
1279  ) . '</span>'
1280  );
1281  } else {
1282  $tpl->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($draft->getPostMessage(), 1));
1283  }
1284  }
1285 
1286  if ($action === 'editdraft' && $draft->getDraftId() === $draft_id) {
1287  $oEditReplyForm = $this->getReplyEditForm();
1288 
1289  if (!$this->objCurrentTopic->isClosed() && in_array($this->requestAction, ['showdraft', 'editdraft'])) {
1290  $this->renderPostingForm($tpl, $frm, $referencePosting, $this->requestAction);
1291  }
1292 
1293  $tpl->setVariable('EDIT_DRAFT_ANCHOR', 'draft_edit_' . $draft->getDraftId());
1294  $tpl->setVariable('DRAFT_FORM', $oEditReplyForm->getHTML() . $this->modal_history);
1295  }
1296 
1297  $tpl->parseCurrentBlock();
1298  }
1299  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
renderPostingForm(ilTemplate $tpl, ilForum $frm, ilForumPost $node, string $action)
renderSplitButton(ilTemplate $tpl, string $action, bool $is_post, ilForumPost $node, int $pageIndex=0, ?ilForumPostDraft $draft=null)
static prepareFormOutput($a_str, bool $a_strip=false)
static http()
Fetches the global http state from ILIAS.
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static _isModerator(int $a_ref_id, int $a_usr_id)
retrieveDraftId(bool $from_post=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderPostContent()

ilObjForumGUI::renderPostContent ( ilTemplate  $tpl,
ilForumPost  $node,
string  $action,
int  $pageIndex,
int  $postIndex 
)
protected

Definition at line 1301 of file class.ilObjForumGUI.php.

References ilObjectGUI\$object, ilForum\_isModerator(), ilRTE\_replaceMediaObjectImageSrc(), ILIAS\Repository\ctrl(), displayConfirmPostActivation(), ilForumPost\getCensorshipComment(), ilForumPost\getChangeDate(), ilForumPost\getCreateDate(), ilForumPost\getDepth(), ilForumPost\getDisplayUserId(), ilFileDataForum\getFilesOfPost(), ilForumPost\getId(), ilUtil\getImagePath(), ilForumPost\getImportName(), ilForumPost\getMessage(), getOrderByParam(), ilForumPost\getPosAuthorId(), ilForumPost\getSubject(), ilForumPost\getThreadId(), ilForumPost\getUpdateUserId(), ilForumPost\getUserAlias(), ilForumPost\isActivated(), ilForumPost\isAuthorModerator(), ilForumPost\isCensored(), ilForumPost\isOwner(), ilForumPost\isPostRead(), ILIAS\Repository\lng(), null, ILIAS\Repository\object(), ilTemplate\parseCurrentBlock(), ilLegacyFormElementsUtil\prepareFormOutput(), renderSplitButton(), ilForumPost\setChangeDate(), ilTemplate\setCurrentBlock(), ilForumPost\setMessage(), HTML_Template_IT\setVariable(), ilUtil\switchColor(), ILIAS\Repository\user(), and ilForumProperties\VIEW_TREE.

Referenced by viewThreadObject().

1307  : void {
1308  $forumObj = $this->object;
1309  $frm = $this->object->Forum;
1310 
1311  $fileDataOfForum = new ilFileDataForum($forumObj->getId(), $node->getId());
1312 
1313  $filesOfPost = $fileDataOfForum->getFilesOfPost();
1314  ksort($filesOfPost);
1315  if ($filesOfPost !== [] && ($action !== 'showedit' || $node->getId() !== $this->objCurrentPost->getId())) {
1316  foreach ($filesOfPost as $file) {
1317  $tpl->setCurrentBlock('attachment_download_row');
1318  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
1319  $this->ctrl->setParameter($this, 'file', $file['md5']);
1320  $tpl->setVariable('HREF_DOWNLOAD', $this->ctrl->getLinkTarget($this, 'viewThread'));
1321  $tpl->setVariable('TXT_FILENAME', $file['name']);
1322  $this->ctrl->clearParameters($this);
1323  $tpl->parseCurrentBlock();
1324  }
1325  $tpl->setCurrentBlock('attachments');
1326  $tpl->setVariable('TXT_ATTACHMENTS_DOWNLOAD', $this->lng->txt('forums_attachments'));
1327  $tpl->setVariable(
1328  'DOWNLOAD_IMG',
1329  $this->uiRenderer->render(
1330  $this->uiFactory->symbol()->glyph()->attachment($this->lng->txt('forums_download_attachment'))
1331  )
1332  );
1333  if (count($filesOfPost) > 1) {
1334  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
1335  $download_zip_button = $this->uiFactory->button()
1336  ->standard(
1337  $this->lng->txt('download'),
1338  $this->ctrl->getLinkTarget($this, 'deliverZipFile')
1339  );
1340  $tpl->setVariable('DOWNLOAD_ZIP', $this->uiRenderer->render($download_zip_button));
1341  }
1342  $tpl->parseCurrentBlock();
1343  }
1344  $this->renderSplitButton($tpl, $action, true, $node, $pageIndex);
1345 
1346  $tpl->setVariable('POST_ANKER', $node->getId());
1347  $tpl->setVariable('TXT_PERMA_LINK', $this->lng->txt('perma_link'));
1348  $tpl->setVariable('PERMA_TARGET', '_top');
1349 
1350  $rowCol = ilUtil::switchColor($postIndex, 'tblrow1', 'tblrow2');
1351  if (($this->is_moderator || $node->isOwner($this->user->getId())) && !$node->isActivated() && !$this->objCurrentTopic->isClosed()) {
1352  $rowCol = 'ilPostingNeedsActivation';
1353  } elseif ($this->objProperties->getMarkModeratorPosts()) {
1354  $isAuthorModerator = ilForum::_isModerator($this->object->getRefId(), $node->getPosAuthorId());
1355  if ($isAuthorModerator && $node->isAuthorModerator() === null) {
1356  $rowCol = 'ilModeratorPosting';
1357  } elseif ($node->isAuthorModerator()) {
1358  $rowCol = 'ilModeratorPosting';
1359  }
1360  }
1361 
1362  if (
1363  (!in_array($action, ['delete', 'censor']) && !$this->displayConfirmPostActivation()) ||
1364  $this->objCurrentPost->getId() !== $node->getId()
1365  ) {
1366  $tpl->setVariable('ROWCOL', ' ' . $rowCol);
1367  } else {
1368  $rowCol = 'tblrowmarked';
1369  }
1370 
1371  if ($node->isCensored()) {
1372  if ($action !== 'censor') {
1373  $tpl->setVariable('TXT_CENSORSHIP_ADVICE', $this->lng->txt('post_censored_comment_by_moderator'));
1374  }
1375 
1376  $rowCol = 'tblrowmarked';
1377  }
1378 
1379  $tpl->setVariable('ROWCOL', ' ' . $rowCol);
1380  $tpl->setVariable('DEPTH', $node->getDepth() - 1);
1381  if (!$node->isActivated() && ($node->isOwner($this->user->getId()) || $this->is_moderator)) {
1382  $tpl->setVariable('POST_NOT_ACTIVATED_YET', $this->lng->txt('frm_post_not_activated_yet'));
1383  }
1384 
1385  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
1386  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
1387  $backurl = urlencode($this->ctrl->getLinkTarget($this, 'viewThread', (string) $node->getId()));
1388  $this->ctrl->clearParameters($this);
1389 
1390  $this->ctrl->setParameter($this, 'backurl', $backurl);
1391  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
1392  $this->ctrl->setParameter($this, 'user', $node->getDisplayUserId());
1393  $authorinfo = new ilForumAuthorInformation(
1394  $node->getPosAuthorId(),
1395  $node->getDisplayUserId(),
1396  (string) $node->getUserAlias(),
1397  (string) $node->getImportName(),
1398  [
1399  'href' => $this->ctrl->getLinkTarget($this, 'showUser')
1400  ]
1401  );
1402  $this->ctrl->clearParameters($this);
1403 
1404  if ($authorinfo->hasSuffix()) {
1405  if (!$authorinfo->isDeleted()) {
1406  $tpl->setVariable('USR_NAME', $authorinfo->getAlias());
1407  }
1408  $tpl->setVariable('AUTHOR', $authorinfo->getSuffix());
1409  } else {
1410  if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized()) {
1411  $tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true));
1412  }
1413  $tpl->setVariable('AUTHOR', $authorinfo->getLinkedAuthorShortName());
1414  }
1415 
1416  $tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture());
1417  $tpl->setVariable(
1418  'USR_ICON_ALT',
1419  ilLegacyFormElementsUtil::prepareFormOutput($authorinfo->getAuthorShortName())
1420  );
1421  $isModerator = ilForum::_isModerator($this->ref_id, $node->getPosAuthorId());
1422  if ($isModerator && $authorinfo->getAuthor()->getId()) {
1423  $authorRole = $this->lng->txt('frm_moderator_n');
1424  if (is_string($authorinfo->getAuthor()->getGender()) && $authorinfo->getAuthor()->getGender() !== '') {
1425  $authorRole = $this->lng->txt('frm_moderator_' . $authorinfo->getAuthor()->getGender());
1426  }
1427  $tpl->setVariable('ROLE', $authorRole);
1428  }
1429 
1430  if ($node->getUpdateUserId() > 0) {
1431  $node->setChangeDate($node->getChangeDate());
1432 
1433  $this->ctrl->setParameter($this, 'backurl', $backurl);
1434  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
1435  $this->ctrl->setParameter($this, 'user', $node->getUpdateUserId());
1436  $update_user_id = $node->getUpdateUserId();
1437  if ($node->getDisplayUserId() === 0 && $node->getPosAuthorId() === $node->getUpdateUserId()) {
1438  $update_user_id = $node->getDisplayUserId();
1439  }
1440  $authorinfo = new ilForumAuthorInformation(
1441  $node->getPosAuthorId(),
1442  $update_user_id,
1443  (string) $node->getUserAlias(),
1444  (string) $node->getImportName(),
1445  [
1446  'href' => $this->ctrl->getLinkTarget($this, 'showUser')
1447  ]
1448  );
1449  $this->ctrl->clearParameters($this);
1450 
1451  $tpl->setVariable(
1452  'POST_UPDATE_TXT',
1453  $this->lng->txt('edited_on') . ': ' . $frm->convertDate($node->getChangeDate()) . ' - ' . strtolower($this->lng->txt('by'))
1454  );
1455  $tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
1456  if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
1457  $tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true));
1458  }
1459  }
1460 
1461  if ($this->selectedSorting === ilForumProperties::VIEW_TREE
1462  && $node->getId() !== $this->selected_post_storage->get($node->getThreadId())) {
1463  $target = $this->uiFactory->symbol()->icon()->custom(
1464  ilUtil::getImagePath('object/target.svg'),
1465  $this->lng->txt('target_select')
1466  );
1467 
1468  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
1469  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
1470 
1471  $tpl->setVariable(
1472  'TARGET',
1473  $this->uiRenderer->render(
1474  $this->uiFactory->link()->bulky(
1475  $target,
1476  $this->lng->txt('select'),
1477  new \ILIAS\Data\URI(
1478  ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTarget($this, 'selectPost', (string) $node->getId())
1479  )
1480  )
1481  )
1482  );
1483  }
1484 
1485  $node->setMessage($frm->prepareText($node->getMessage()));
1486 
1487  if ($this->user->isAnonymous() || $node->isPostRead()) {
1488  $tpl->setVariable('SUBJECT', $node->getSubject());
1489  } else {
1490  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
1491  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
1492  $this->ctrl->setParameter($this, 'page', $pageIndex);
1493  $this->ctrl->setParameter(
1494  $this,
1495  'orderby',
1496  $this->getOrderByParam()
1497  );
1498  $this->ctrl->setParameter($this, 'viewmode', $this->selectedSorting);
1499  $mark_post_target = $this->ctrl->getLinkTarget($this, 'markPostRead', (string) $node->getId());
1500 
1501  $tpl->setVariable(
1502  'SUBJECT',
1503  '<a href="' . $mark_post_target . '"><b>' . $node->getSubject() . '</b></a>'
1504  );
1505  }
1506 
1507  $tpl->setVariable('POST_DATE', $frm->convertDate($node->getCreateDate()));
1508 
1509  if (!$node->isCensored() || ($this->objCurrentPost->getId() === $node->getId() && $action === 'censor')) {
1510  $spanClass = '';
1511  if (ilForum::_isModerator($this->ref_id, $node->getDisplayUserId())) {
1512  $spanClass = 'moderator';
1513  }
1514 
1515  // possible bugfix for mantis #8223
1516  if ($node->getMessage() === strip_tags($node->getMessage())) {
1517  // We can be sure, that there are not html tags
1518  $node->setMessage(nl2br($node->getMessage()));
1519  }
1520 
1521  if ($spanClass !== '') {
1522  $tpl->setVariable(
1523  'POST',
1524  '<span class="' . $spanClass . '">' .
1526  '</span>'
1527  );
1528  } else {
1529  $tpl->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($node->getMessage(), 1));
1530  }
1531  } else {
1532  $tpl->setVariable(
1533  'POST',
1534  '<span class="moderator">' . nl2br((string) $node->getCensorshipComment()) . '</span>'
1535  );
1536  }
1537 
1538  $tpl->parseCurrentBlock();
1539  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static switchColor(int $a_num, string $a_css1, string $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows) ...
setMessage(string $a_message)
renderSplitButton(ilTemplate $tpl, string $action, bool $is_post, ilForumPost $node, int $pageIndex=0, ?ilForumPostDraft $draft=null)
isOwner(int $a_user_id=0)
static prepareFormOutput($a_str, bool $a_strip=false)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setChangeDate(?string $a_changedate)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static _isModerator(int $a_ref_id, int $a_usr_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderPostingForm()

ilObjForumGUI::renderPostingForm ( ilTemplate  $tpl,
ilForum  $frm,
ilForumPost  $node,
string  $action 
)
private

Definition at line 5796 of file class.ilObjForumGUI.php.

References ilRTE\_replaceMediaObjectImageSrc(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilForumPost\getDisplayUserId(), ilForumPost\getImportName(), ilForumPost\getMessage(), getModifiedReOnSubject(), getOrderByParam(), ilForumPost\getPosAuthorId(), getReplyEditForm(), ilForumPost\getUserAlias(), ilForumPost\isCensored(), ilForumPost\isOwner(), ILIAS\Repository\lng(), ilForum\prepareText(), retrieveDraftId(), HTML_Template_IT\setVariable(), ilUtil\stripSlashes(), and ILIAS\Repository\user().

Referenced by renderDraftContent(), and viewThreadObject().

5796  : void
5797  {
5798  $draft_id = $this->retrieveDraftId();
5799  if ($action === 'showedit' && (
5800  (!$this->is_moderator && !$node->isOwner($this->user->getId())) ||
5801  $this->user->isAnonymous() ||
5802  $node->isCensored()
5803  )) {
5804  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5805  } elseif ($action === 'showreply' && !$this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
5806  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5807  }
5808 
5809  $tpl->setVariable('REPLY_ANKER', 'reply_' . $this->objCurrentPost->getId());
5810  $oEditReplyForm = $this->getReplyEditForm();
5811  $subject = '';
5812  if ($action !== 'editdraft') {
5813  switch ($this->objProperties->getSubjectSetting()) {
5814  case 'add_re_to_subject':
5815  $subject = $this->getModifiedReOnSubject();
5816  break;
5817 
5818  case 'preset_subject':
5819  $subject = $this->objCurrentPost->getSubject();
5820  break;
5821 
5822  case 'empty_subject':
5823  $subject = '';
5824  break;
5825  }
5826  }
5827 
5828  switch ($action) {
5829  case 'showreply':
5830  if ($this->ctrl->getCmd() === 'savePost' || $this->ctrl->getCmd() === 'saveAsDraft') {
5831  $oEditReplyForm->setValuesByPost();
5832  } elseif ($this->ctrl->getCmd() === 'quotePost') {
5833  $authorinfo = new ilForumAuthorInformation(
5834  $node->getPosAuthorId(),
5835  $node->getDisplayUserId(),
5836  (string) $node->getUserAlias(),
5837  (string) $node->getImportName()
5838  );
5839 
5840  $oEditReplyForm->setValuesByPost();
5841  $oEditReplyForm->getItemByPostVar('message')->setValue(
5843  $frm->prepareText(
5844  $node->getMessage(),
5845  1,
5846  $authorinfo->getAuthorName()
5847  ) . "\n" . $oEditReplyForm->getInput('message'),
5848  1
5849  )
5850  );
5851  } else {
5852  $oEditReplyForm->setValuesByArray([
5853  'draft_id' => $draft_id,
5854  'alias' => '',
5855  'subject' => $subject,
5856  'message' => '',
5857  'notify' => 0,
5858  'userfile' => '',
5859  'del_file' => []
5860  ]);
5861  }
5862  break;
5863 
5864  case 'showedit':
5865  if ($this->ctrl->getCmd() === 'savePost') {
5866  $oEditReplyForm->setValuesByPost();
5867  } else {
5868  $oEditReplyForm->setValuesByArray([
5869  'alias' => '',
5870  'subject' => $this->objCurrentPost->getSubject(),
5872  $this->objCurrentPost->getMessage(),
5873  2
5874  ), 1),
5875  'notify' => $this->objCurrentPost->isNotificationEnabled() && !$this->user->isAnonymous(),
5876  'userfile' => '',
5877  'del_file' => [],
5878  'draft_id' => $draft_id
5879  ]);
5880  }
5881  break;
5882 
5883  case 'editdraft':
5884  if (in_array($this->ctrl->getCmd(), ['saveDraft', 'updateDraft', 'publishDraft'])) {
5885  $oEditReplyForm->setValuesByPost();
5886  } elseif ($draft_id > 0) {
5887  $draftObject = new ilForumPostDraft(
5888  $this->user->getId(),
5889  $this->objCurrentPost->getId(),
5890  $draft_id
5891  );
5892  $oEditReplyForm->setValuesByArray([
5893  'alias' => $draftObject->getPostUserAlias(),
5894  'subject' => $draftObject->getPostSubject(),
5896  $draftObject->getPostMessage(),
5897  2
5898  ), 1),
5899  'notify' => $draftObject->isNotificationEnabled() && !$this->user->isAnonymous(),
5900  'userfile' => '',
5901  'del_file' => [],
5902  'draft_id' => $draft_id
5903  ]);
5904  }
5905  break;
5906  }
5907 
5908  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
5909  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
5910  $this->ctrl->setParameter($this, 'page', (int) ($this->httpRequest->getQueryParams()['page'] ?? 0));
5911  $this->ctrl->setParameter(
5912  $this,
5913  'orderby',
5914  $this->getOrderByParam()
5915  );
5916  $this->ctrl->setParameter(
5917  $this,
5918  'action',
5919  ilUtil::stripSlashes($this->requestAction)
5920  );
5921  if ($action !== 'editdraft') {
5922  $tpl->setVariable('FORM', $oEditReplyForm->getHTML());
5923  }
5924  $this->ctrl->clearParameters($this);
5925  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
isOwner(int $a_user_id=0)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
prepareText(string $text, int $edit=0, string $quote_user='', string $type='')
retrieveDraftId(bool $from_post=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderSortationControl()

ilObjForumGUI::renderSortationControl ( int  $currentSorting)
private

Definition at line 3563 of file class.ilObjForumGUI.php.

References $sortationOptions, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by viewThreadObject().

3563  : void
3564  {
3565  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3566  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
3567  $target = $this->ctrl->getLinkTarget(
3568  $this,
3569  'viewThread',
3570  ''
3571  );
3572 
3573  $translatedSortationOptions = array_map(function ($value): string {
3574  return $this->lng->txt($value);
3576 
3577  $sortingDirectionViewControl = $this->uiFactory
3578  ->viewControl()
3579  ->sortation($translatedSortationOptions, (string) $currentSorting)
3580  ->withTargetURL($target, 'viewmode');
3581  $this->toolbar->addComponent($sortingDirectionViewControl);
3582  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderSplitButton()

ilObjForumGUI::renderSplitButton ( ilTemplate  $tpl,
string  $action,
bool  $is_post,
ilForumPost  $node,
int  $pageIndex = 0,
?ilForumPostDraft  $draft = null 
)
private

Definition at line 5429 of file class.ilObjForumGUI.php.

References ilObjectGUI\$id, $url, ILIAS\Repository\access(), addActivationFormModal(), ILIAS\Repository\ctrl(), displayConfirmPostActivation(), ilForumPost\getForumId(), ilForumPost\getId(), getOrderByParam(), ilForumPost\getThreadId(), ilForumPost\hasReplies(), ilForumPost\isActivated(), ilForumPost\isCensored(), ilForumPost\isOwner(), ilForumPost\isPostRead(), ILIAS\Repository\lng(), ILIAS\Repository\object(), retrieveDraftId(), ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), ILIAS\Repository\user(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

Referenced by renderDraftContent(), and renderPostContent().

5436  : void {
5437  $draft_id = $this->retrieveDraftId();
5438 
5439  $actions = [];
5440  if ($is_post) {
5441  if (($this->objCurrentPost->getId() !== $node->getId() || (
5442  !in_array($action, ['showreply', 'showedit', 'censor', 'delete'], true) &&
5444  )) && ($this->is_moderator || $node->isActivated() || $node->isOwner($this->user->getId()))) {
5445  if ($this->is_moderator && !$this->objCurrentTopic->isClosed() && !$node->isActivated()) {
5446  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5447  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5448  $this->ctrl->setParameter($this, 'page', $pageIndex);
5449  $this->ctrl->setParameter(
5450  $this,
5451  'orderby',
5452  $this->getOrderByParam()
5453  );
5454  $primary_action = $this->ctrl->getLinkTarget(
5455  $this,
5456  'askForPostActivation',
5457  (string) $node->getId()
5458  );
5459  $primary_action_language_id = 'activate_post';
5460  $this->ctrl->clearParameters($this);
5461  }
5462  if (
5463  !$this->objCurrentTopic->isClosed() && $node->isActivated() && !$node->isCensored() &&
5464  $this->access->checkAccess('add_reply', '', $this->object->getRefId())
5465  ) {
5466  $this->ctrl->setParameter($this, 'action', 'showreply');
5467  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5468  $this->ctrl->setParameter($this, 'page', $pageIndex);
5469  $this->ctrl->setParameter(
5470  $this,
5471  'orderby',
5472  $this->getOrderByParam()
5473  );
5474  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5475  $primary_action = $this->ctrl->getLinkTarget(
5476  $this,
5477  'viewThread',
5478  'reply_' . $node->getId()
5479  );
5480  $primary_action_language_id = 'reply_to_postings';
5481  $this->ctrl->clearParameters($this);
5482  }
5483  if (
5484  !$this->objCurrentTopic->isClosed() &&
5485  !$node->isCensored() &&
5486  !$this->user->isAnonymous() &&
5487  ($node->isOwner($this->user->getId()) || $this->is_moderator)
5488  ) {
5489  $this->ctrl->setParameter($this, 'action', 'showedit');
5490  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5491  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5492  $this->ctrl->setParameter($this, 'page', $pageIndex);
5493  $this->ctrl->setParameter(
5494  $this,
5495  'orderby',
5496  $this->getOrderByParam()
5497  );
5498  $actions['edit'] = $this->ctrl->getLinkTarget($this, 'viewThread', (string) $node->getId());
5499  $this->ctrl->clearParameters($this);
5500  }
5501  if (!$this->user->isAnonymous()) {
5502  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5503  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5504  $this->ctrl->setParameter($this, 'page', $pageIndex);
5505  $this->ctrl->setParameter(
5506  $this,
5507  'orderby',
5508  $this->getOrderByParam()
5509  );
5510  $this->ctrl->setParameter($this, 'viewmode', $this->selectedSorting);
5511 
5512  $read_undread_txt = 'frm_mark_as_read';
5513  $read_undread_cmd = 'markPostRead';
5514  if ($node->isPostRead()) {
5515  $read_undread_txt = 'frm_mark_as_unread';
5516  $read_undread_cmd = 'markPostUnread';
5517  }
5518  $actions[$read_undread_txt] = $this->ctrl->getLinkTarget(
5519  $this,
5520  $read_undread_cmd,
5521  (string) $node->getId()
5522  );
5523 
5524  $this->ctrl->clearParameters($this);
5525  }
5526  if (!$node->isCensored()) {
5527  $this->ctrl->setParameterByClass(ilForumExportGUI::class, 'top_pk', $node->getForumId());
5528  $this->ctrl->setParameterByClass(ilForumExportGUI::class, 'thr_pk', $node->getThreadId());
5529 
5530 
5531  $this->ctrl->clearParameters($this);
5532  }
5533  if (
5534  !$this->objCurrentTopic->isClosed() &&
5535  !$this->user->isAnonymous() &&
5536  ($this->is_moderator || ($node->isOwner($this->user->getId()) && !$node->hasReplies()))
5537  ) {
5538  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5539  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5540  $this->ctrl->setParameter($this, 'page', $pageIndex);
5541  $this->ctrl->setParameter(
5542  $this,
5543  'orderby',
5544  $this->getOrderByParam()
5545  );
5546  $actions['delete'] = $this->ctrl->getFormAction($this, 'deletePosting');
5547  $this->ctrl->clearParameters($this);
5548  }
5549  if ($this->is_moderator && !$this->objCurrentTopic->isClosed()) {
5550  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5551  $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5552  $this->ctrl->setParameter($this, 'page', $pageIndex);
5553  $this->ctrl->setParameter(
5554  $this,
5555  'orderby',
5556  $this->getOrderByParam()
5557  );
5558  if ($node->isCensored()) {
5559  $this->ctrl->setParameter($this, 'action', 'viewThread');
5560  $actions['frm_revoke_censorship'] = $this->ctrl->getFormAction($this, 'revokeCensorship');
5561  } else {
5562  $actions['frm_censorship'] = $this->ctrl->getFormAction($this, 'addCensorship');
5563  }
5564  $this->ctrl->clearParameters($this);
5565  }
5566  }
5567  } elseif ($draft_id !== $draft->getDraftId() || !in_array($action, ['deletedraft', 'editdraft'])) {
5568  // get actions for drafts
5569  $this->ctrl->setParameter($this, 'action', 'publishdraft');
5570  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5571  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
5572  $this->ctrl->setParameter($this, 'page', $pageIndex);
5573  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
5574  $this->ctrl->setParameter(
5575  $this,
5576  'orderby',
5577  $this->getOrderByParam()
5578  );
5579  $primary_action = $this->ctrl->getLinkTarget($this, 'publishSelectedDraft', (string) $node->getId());
5580  $primary_action_language_id = 'publish';
5581  $this->ctrl->clearParameters($this);
5582 
5583  $this->ctrl->setParameter($this, 'action', 'editdraft');
5584  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5585  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
5586  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
5587  $this->ctrl->setParameter($this, 'page', $pageIndex);
5588  $this->ctrl->setParameter(
5589  $this,
5590  'orderby',
5591  $this->getOrderByParam()
5592  );
5593  $actions['edit'] = $this->ctrl->getLinkTarget($this, 'editDraft', 'draft_edit_' . $draft->getDraftId());
5594  $this->ctrl->clearParameters($this);
5595 
5596  $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5597  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
5598  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
5599  $this->ctrl->setParameter($this, 'page', $pageIndex);
5600  $this->ctrl->setParameter(
5601  $this,
5602  'orderby',
5603  $this->getOrderByParam()
5604  );
5605  $actions['delete'] = $this->ctrl->getFormAction($this, 'deletePostingDraft');
5606  $this->ctrl->clearParameters($this);
5607 
5608  if ($draft_id !== 0 && $action === 'editdraft') {
5609  $actions = [];
5610  }
5611  }
5612 
5613  $tpl->setCurrentBlock('posts_row');
5614  if ($actions !== [] && !$this->objCurrentTopic->isClosed()) {
5615  $items = [];
5616  foreach ($actions as $lng_id => $url) {
5617  if ($lng_id === 'frm_revoke_censorship' || $lng_id === 'frm_censorship') {
5618  $modalTemplate = new ilTemplate('tpl.forums_censor_modal.html', true, true, 'components/ILIAS/Forum');
5619  $form_id = str_replace('.', '_', uniqid('form', true));
5620  $modalTemplate->setVariable('FORM_ID', $form_id);
5621 
5622  if ($node->isCensored()) {
5623  $modalTemplate->setVariable('BODY', $this->lng->txt('forums_info_censor2_post'));
5624  } else {
5625  $modalTemplate->setVariable('BODY', $this->lng->txt('forums_info_censor_post'));
5626  $modalTemplate->touchBlock('message');
5627  }
5628 
5629  $modalTemplate->setVariable('FORM_ACTION', $url);
5630 
5631  $content = $this->uifactory->legacy()->content($modalTemplate->get());
5632  $submitBtn = $this->uiFactory->button()->primary(
5633  $this->lng->txt('submit'),
5634  '#'
5635  )->withOnLoadCode(
5636  static function (string $id) use ($form_id): string {
5637  return "
5638  (function () {
5639  const button = document.getElementById('$id');
5640  if (!button) return;
5641 
5642  const form = document.getElementById('$form_id');
5643  if (!form) return;
5644 
5645  button.addEventListener('click', (event) => {
5646  event.preventDefault();
5647  form.submit();
5648  }, true);
5649  }());
5650  ";
5651  }
5652  );
5653  $modal = $this->uiFactory->modal()->roundtrip(
5654  $this->lng->txt($lng_id),
5655  [$content]
5656  )->withActionButtons([$submitBtn]);
5657  $items[] = $this->uiFactory->button()->shy($this->lng->txt($lng_id), '#')->withOnClick(
5658  $modal->getShowSignal()
5659  );
5660 
5661  $this->modalActionsContainer[] = $modal;
5662  continue;
5663  }
5664 
5665  if ($lng_id === 'delete') {
5666  $modal = $this->uiFactory->modal()->interruptive(
5667  $this->lng->txt($lng_id),
5668  str_contains($url, 'deletePostingDraft') ?
5669  $this->lng->txt('forums_info_delete_draft') :
5670  $this->lng->txt('forums_info_delete_post'),
5671  $url
5672  )->withActionButtonLabel(
5673  $this->lng->txt(str_contains($url, 'deletePostingDraft') ? 'deletePostingDraft' : 'deletePosting')
5674  );
5675 
5676  $items[] = $this->uiFactory->button()->shy($this->lng->txt($lng_id), '#')->withOnClick(
5677  $modal->getShowSignal()
5678  );
5679 
5680  $this->modalActionsContainer[] = $modal;
5681 
5682 
5683  continue;
5684  }
5685 
5686  $items[] = $this->uiFactory->button()->shy($this->lng->txt($lng_id), $url);
5687  }
5688 
5689  $dropdown = $this->uiFactory->dropdown()->standard($items);
5690  $render_action_buttons = [$dropdown];
5691  if (isset($primary_action, $primary_action_language_id)) {
5692  if ($primary_action_language_id === 'activate_post') {
5693  $action_button = $this->addActivationFormModal($node);
5694  } else {
5695  $action_button = $this->uiFactory->button()->standard(
5696  $this->lng->txt($primary_action_language_id),
5697  $primary_action
5698  );
5699  }
5700  $tpl->setVariable('MAIN_ACTION', $this->uiRenderer->render($action_button));
5701  }
5702  $tpl->setVariable('DROPDOWN_ACTIONS', $this->uiRenderer->render($render_action_buttons));
5703  }
5704  }
$url
Definition: shib_logout.php:66
isOwner(int $a_user_id=0)
addActivationFormModal(ilForumPost $node)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
retrieveDraftId(bool $from_post=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderThreadOverview()

ilObjForumGUI::renderThreadOverview ( ilForum  $frm,
ForumDto  $frm_object 
)
private

Definition at line 740 of file class.ilObjForumGUI.php.

References $GLOBALS, ilObjectGUI\$ref_id, $url, ILIAS\Repository\ctrl(), factory(), getActionsForThreadOverview(), getLinkActionForThread(), getSortationViewControl(), getThreadProperties(), ForumDto\getTopNumThreads(), ILIAS\FileDelivery\http(), initStyleSheets(), ILIAS\Repository\lng(), markTopThreadInOverview(), ilForumProperties\PAGE_NAME_THREAD_OVERVIEW, ilForumProperties\PAGE_SIZE_THREAD_OVERVIEW, ilForumPageCommandForwarder\PRESENTATION_MODE_PRESENTATION, ILIAS\Repository\refinery(), renderer(), and ILIAS\Repository\user().

Referenced by getContent().

740  : void
741  {
742  $threads_page = $this->forum_thread_table_session_storage->fetchData($frm, $frm_object);
743 
744  $top_group = [];
745  $thread_group = [];
746 
747  if (count($threads_page->getForumTopics()) > 0) {
748  foreach ($threads_page->getForumTopics() as $thread) {
749  $ref_id = $this->object->getRefId();
750  $subject = $thread->getSubject();
751  if ($thread->isClosed()) {
752  $subject .= ' (' . $this->lng->txt('forums_closed') . ')';
753  }
754 
755  $link = $this->getLinkActionForThread($ref_id, $subject, 'viewThread', $thread->getId());
756  $actions = $this->getActionsForThreadOverview($ref_id, $thread);
757 
758  $list_item = $this->factory
759  ->item()
760  ->standard($link)
761  ->withActions($actions)
762  ->withProperties($this->getThreadProperties($thread));
763  $list_item = $this->markTopThreadInOverview($thread, $list_item);
764  if ($thread->isSticky()) {
765  $top_group[] = $list_item;
766  } else {
767  $thread_group[] = $list_item;
768  }
769  }
770  }
771 
772  $found_threads = false;
773  if (count($top_group) > 0) {
774  $top_threads = $this->factory->item()->group($this->lng->txt('top_thema'), $top_group);
775  $found_threads = true;
776  } else {
777  $top_threads = $this->factory->item()->group('', $top_group);
778  }
779 
780  if (count($thread_group) > 0) {
781  $normal_threads = $this->factory->item()->group($this->lng->txt('thema'), $thread_group);
782  $found_threads = true;
783  } else {
784  $normal_threads = $this->factory->item()->group('', $thread_group);
785  }
786 
787  $url = $this->http->request()->getRequestTarget();
788  $current_page = 0;
789  if ($this->http->wrapper()->query()->has(ilForumProperties::PAGE_NAME_THREAD_OVERVIEW)) {
790  $current_page = $this->http->wrapper()->query()->retrieve(
792  $this->refinery->kindlyTo()->int()
793  );
794  }
795 
796  $view_controls[] = $this->getSortationViewControl($this->forum_thread_table_session_storage->getThreadPage());
797  $view_controls[] = $this->factory
798  ->viewControl()
799  ->pagination()
801  ->withTotalEntries($frm_object->getTopNumThreads())
803  ->withMaxPaginationButtons(5)
804  ->withCurrentPage($current_page);
805 
806  if ($found_threads === false) {
807  $vc_container = $this->factory->panel()->listing()->standard(
808  $this->lng->txt('thread_overview'),
809  [$this->factory->item()->group($this->lng->txt('frm_no_threads'), [])]
810  );
811  } else {
812  $vc_container = $this->factory->panel()->listing()->standard(
813  $this->lng->txt('thread_overview'),
814  [$top_threads, $normal_threads]
815  )->withViewControls($view_controls);
816  }
817 
818  $default_html = $this->renderer->render($vc_container);
819  $modals = $this->renderer->render($this->modal_collection);
820 
821  $this->initStyleSheets();
822 
823  $forwarder = new ilForumPageCommandForwarder(
824  $GLOBALS['DIC']['http'],
825  $this->ctrl,
826  $this->tabs_gui,
827  $this->lng,
828  $this->object,
829  $this->user,
830  $this->content_style_domain
831  );
832  $forwarder->setPresentationMode(ilForumPageCommandForwarder::PRESENTATION_MODE_PRESENTATION);
833 
834  $this->tpl->setContent($forwarder->forward() . $default_html . $modals);
835  }
factory()
getThreadProperties(ilForumTopic $forum_topic)
markTopThreadInOverview(ilForumTopic $current_thread, Item $list_item)
renderer()
$url
Definition: shib_logout.php:66
getActionsForThreadOverview(int $ref_id, ilForumTopic $forum_topic)
getLinkActionForThread(int $ref_id, string $title, string $cmd, ?int $thread_id=null)
static http()
Fetches the global http state from ILIAS.
$GLOBALS["DIC"]
Definition: wac.php:53
getSortationViewControl(int $offset)
const PRESENTATION_MODE_PRESENTATION
presentation mode for requesting
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderViewModeControl()

ilObjForumGUI::renderViewModeControl ( int  $currentViewMode)
private

Definition at line 3532 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\toolbar(), and ilForumProperties\VIEW_DATE_ASC.

Referenced by viewThreadObject().

3532  : void
3533  {
3534  if ($currentViewMode === 3) {
3535  $currentViewMode = 2;
3536  }
3537  $translationKeys = [];
3538  foreach ($this->viewModeOptions as $sortingConstantKey => $languageKey) {
3539  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3540  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
3541  $this->ctrl->setParameter($this, 'viewmode', $sortingConstantKey);
3542 
3543  $translationKeys[$this->lng->txt($languageKey)] = $this->ctrl->getLinkTarget(
3544  $this,
3545  'viewThread',
3546  ''
3547  );
3548 
3549  $this->ctrl->clearParameters($this);
3550  }
3551 
3552  if ($currentViewMode > ilForumProperties::VIEW_DATE_ASC) {
3553  $currentViewMode = ilForumProperties::VIEW_DATE_ASC;
3554  }
3555 
3556  $sortViewControl = $this->uiFactory
3557  ->viewControl()
3558  ->mode($translationKeys, $this->lng->txt($this->viewModeOptions[$currentViewMode]))
3559  ->withActive($this->lng->txt($this->viewModeOptions[$currentViewMode]));
3560  $this->toolbar->addComponent($sortViewControl);
3561  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetLimitedViewObject()

ilObjForumGUI::resetLimitedViewObject ( )

Definition at line 3102 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl().

3102  : void
3103  {
3104  $this->selected_post_storage->set($this->objCurrentTopic->getId(), 0);
3105  $this->ctrl->redirect($this, 'viewThread');
3106  }
+ Here is the call graph for this function:

◆ restoreFromHistoryObject()

ilObjForumGUI::restoreFromHistoryObject ( )
protected

Definition at line 4887 of file class.ilObjForumGUI.php.

References checkDraftAccess(), ilForumPostDraft\createDraftBackup(), ILIAS\Repository\ctrl(), ILIAS\Repository\int(), ilForumPostDraft\isSavePostDraftAllowed(), and ILIAS\Repository\lng().

4887  : void
4888  {
4890  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4891  }
4892 
4893  $historyId = (int) ($this->httpRequest->getQueryParams()['history_id'] ?? 0);
4894  $history = new ilForumDraftsHistory($historyId);
4895 
4896  $this->checkDraftAccess($history->getDraftId());
4897 
4898  $draft = $history->rollbackAutosave();
4899  if ($draft->getThreadId() === 0 && $draft->getPostId() === 0) {
4900  $this->ctrl->setParameter($this, 'draft_id', $history->getDraftId());
4901  $this->ctrl->redirect($this, 'editThreadDraft');
4902  }
4903 
4904  $this->ctrl->clearParameters($this);
4905  $this->ctrl->setParameter($this, 'pos_pk', $draft->getPostId());
4906  $this->ctrl->setParameter($this, 'thr_pk', $draft->getThreadId());
4907  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
4908  $this->ctrl->setParameter($this, 'action', 'editdraft');
4909 
4910  ilForumPostDraft::createDraftBackup($draft->getDraftId());
4911 
4912  $this->ctrl->redirect($this, 'viewThread');
4913  }
static createDraftBackup(int $draft_id)
Class ilForumDraftHistory.
checkDraftAccess(int|ilForumPostDraft $draft)
+ Here is the call graph for this function:

◆ retrieveDraftId()

ilObjForumGUI::retrieveDraftId ( bool  $from_post = false)
private

Definition at line 155 of file class.ilObjForumGUI.php.

References ILIAS\FileDelivery\http().

Referenced by addThreadObject(), autosaveDraftAsyncObject(), autosaveThreadDraftAsyncObject(), cancelDraftObject(), cancelPostObject(), createTopLevelPostObject(), decorateWithAutosave(), deleteSelectedDraft(), deliverDraftZipFileObject(), editDraftObject(), initReplyEditForm(), publishDraftObject(), publishSelectedDraftObject(), publishThreadDraftObject(), renderDraftContent(), renderPostingForm(), renderSplitButton(), updateDraftObject(), and updateThreadDraftObject().

155  : int
156  {
157  return $this->retrieveIntOrZeroFrom(
158  $from_post ? $this->http->wrapper()->post() : $this->http->wrapper()->query(),
159  'draft_id'
160  );
161  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ retrieveThreadIds()

ilObjForumGUI::retrieveThreadIds ( )
private
Returns
list<int>

Definition at line 865 of file class.ilObjForumGUI.php.

References $post, ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by performDeleteThreadsObject(), and performThreadsActionObject().

865  : array
866  {
867  $thread_ids = [];
868  $query = $this->http->wrapper()->query()->has('thr_pk');
869  $post = $this->http->wrapper()->post()->has('thread_ids');
870  if ($post) {
871  $thread_ids = $this->http->wrapper()->post()->retrieve(
872  'thread_ids',
873  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
874  );
875  } elseif ($query) {
876  $thread_ids = $this->http->wrapper()->query()->retrieve(
877  'thr_pk',
878  $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
879  );
880  }
881 
882  return $thread_ids;
883  }
static http()
Fetches the global http state from ILIAS.
$post
Definition: ltitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ retrieveThrPk()

ilObjForumGUI::retrieveThrPk ( )
private

Definition at line 150 of file class.ilObjForumGUI.php.

References ILIAS\FileDelivery\http().

Referenced by __construct().

150  : int
151  {
152  return $this->retrieveIntOrZeroFrom($this->http->wrapper()->query(), 'thr_pk');
153  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ revokeCensorshipObject()

ilObjForumGUI::revokeCensorshipObject ( )
private

Definition at line 2045 of file class.ilObjForumGUI.php.

References handleCensorship().

2045  : void
2046  {
2047  $this->handleCensorship(true);
2048  }
handleCensorship(bool $wasRevoked=false)
+ Here is the call graph for this function:

◆ saveAsDraftObject()

ilObjForumGUI::saveAsDraftObject ( )

Definition at line 5072 of file class.ilObjForumGUI.php.

References $GLOBALS, ilRTE\_replaceMediaObjectImageSrc(), ILIAS\Repository\access(), checkDraftAccess(), ILIAS\Repository\ctrl(), ensureThreadBelongsToForum(), ilSession\get(), getForumObjects(), ilForumUtil\getPublicUserAlias(), getReplyEditForm(), handleFormInput(), ILIAS\FileDelivery\http(), ilForumPostDraft\isSavePostDraftAllowed(), isWritingWithPseudonymAllowed(), ILIAS\Repository\lng(), ilForumUtil\moveMediaObjects(), ilForumPostDraft\newInstanceByDraftId(), null, ILIAS\Repository\object(), ILIAS\Repository\refinery(), ilSession\set(), ilFileDataForumDrafts\storeUploadedFiles(), ILIAS\Repository\user(), and viewThreadObject().

Referenced by saveTopLevelDraftObject().

5072  : void
5073  {
5075  !$this->access->checkAccess('read', '', $this->object->getRefId())) {
5076  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5077  }
5078 
5079  $autosave_draft_id = $this->http->wrapper()->post()->retrieve(
5080  'draft_id',
5081  $this->refinery->byTrying([
5082  $this->refinery->kindlyTo()->int(),
5083  $this->refinery->always(null)
5084  ])
5085  );
5086 
5087  if ($this->objCurrentTopic->getId() === 0) {
5088  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_deleted'), true);
5089  $this->ctrl->redirect($this);
5090  }
5091 
5092  if ($this->objCurrentTopic->isClosed()) {
5093  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_closed'), true);
5094  $this->ctrl->redirect($this);
5095  }
5096 
5097  $oReplyEditForm = $this->getReplyEditForm();
5098  if ($oReplyEditForm->checkInput()) {
5099  if ($this->objCurrentPost->getId() === 0) {
5100  $this->requestAction = '';
5101  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_parent_deleted'), true);
5102  $this->viewThreadObject();
5103  return;
5104  }
5105 
5106  $oForumObjects = $this->getForumObjects();
5107  $frm = $oForumObjects['frm'];
5108  $frm->setMDB2WhereCondition(' top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
5109  $topicData = $frm->getOneTopic();
5110 
5111  if ($this->requestAction === 'ready_showreply') {
5112  if (!$this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
5113  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5114  }
5115 
5116  if ($autosave_draft_id > 0) {
5117  $draftObj = ilForumPostDraft::newInstanceByDraftId($autosave_draft_id);
5118  $this->checkDraftAccess($draftObj->getDraftId());
5119  } else {
5120  $draftObj = new ilForumPostDraft();
5121  $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentPost->getThread());
5122  $draftObj->setForumId($topicData->getTopPk());
5123  $draftObj->setThreadId($this->objCurrentTopic->getId());
5124  $draftObj->setPostId($this->objCurrentPost->getId());
5125  }
5126 
5127  $draftObj->setPostSubject($this->handleFormInput($oReplyEditForm->getInput('subject'), false));
5128  $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message')));
5129  $draftObj->setPostUserAlias(ilForumUtil::getPublicUserAlias(
5130  $oReplyEditForm->getInput('alias'),
5131  $this->objProperties->isAnonymized()
5132  ));
5133  $draftObj->setNotificationStatus($oReplyEditForm->getInput('notify') && !$this->user->isAnonymous());
5134  $draftObj->setPostNotificationStatus($oReplyEditForm->getInput('notify_post') && !$this->user->isAnonymous());
5135 
5136  $draftObj->setPostAuthorId($this->user->getId());
5137  $draftObj->setPostDisplayUserId(($this->isWritingWithPseudonymAllowed() ? 0 : $this->user->getId()));
5138 
5139  if ($autosave_draft_id === 0) {
5140  $draft_id = $draftObj->saveDraft();
5141  } else {
5142  $draftObj->updateDraft();
5143  $draft_id = $draftObj->getDraftId();
5144  }
5145 
5146  // copy temporary media objects (frm~)
5148  $oReplyEditForm->getInput('message'),
5149  'frm~d:html',
5150  $draft_id,
5151  'frm~d:html',
5152  $draft_id
5153  );
5154 
5155  if ($this->objProperties->isFileUploadAllowed()) {
5156  $file = $_FILES['userfile'];
5157  if (is_array($file) && !empty($file)) {
5158  $oFDForumDrafts = new ilFileDataForumDrafts($this->object->getId(), $draftObj->getDraftId());
5159  $oFDForumDrafts->storeUploadedFiles();
5160  }
5161  }
5162 
5163  $GLOBALS['ilAppEventHandler']->raise(
5164  'components/ILIAS/Forum',
5165  'savedAsDraft',
5166  [
5167  'draftObj' => $draftObj,
5168  'obj_id' => $this->object->getId(),
5169  'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5170  ]
5171  );
5172 
5173  $frm_session_values = ilSession::get('frm');
5174  if (is_array($frm_session_values)) {
5175  $frm_session_values[$this->objCurrentPost->getThreadId()]['openTreeNodes'][] = $this->objCurrentPost->getId();
5176  }
5177  ilSession::set('frm', $frm_session_values);
5178 
5179  $this->tpl->setOnScreenMessage('success', $this->lng->txt('save_draft_successfully'), true);
5180  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
5181  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
5182  $this->ctrl->redirect($this, 'viewThread');
5183  }
5184  } else {
5185  $oReplyEditForm->setValuesByPost();
5186  $this->requestAction = substr($this->requestAction, 6);
5187  }
5188  $this->viewThreadObject();
5189  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static get(string $a_var)
static moveMediaObjects(string $post_message, string $source_type, int $source_id, string $target_type, int $target_id, int $direction=0)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
$GLOBALS["DIC"]
Definition: wac.php:53
static getPublicUserAlias(string $user_alias, bool $is_anonymized)
handleFormInput(string $a_text, bool $a_stripslashes=true)
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
checkDraftAccess(int|ilForumPostDraft $draft)
static newInstanceByDraftId(int $draft_id)
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePostObject()

ilObjForumGUI::savePostObject ( )

Definition at line 2754 of file class.ilObjForumGUI.php.

References $GLOBALS, $message, $objCurrentPost, $objCurrentTopic, ilObjMediaObject\_exists(), ilRTE\_getMediaObjects(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), ilRTE\_replaceMediaObjectImageSrc(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ensureThreadBelongsToForum(), ilNewsItem\getFirstNewsIdForContext(), getForumObjects(), getReplyEditForm(), handleFormInput(), hasDraftAccess(), ILIAS\FileDelivery\http(), isWritingWithPseudonymAllowed(), ILIAS\Repository\lng(), ilForumUtil\moveMediaObjects(), ILIAS\Repository\object(), ILIAS\Repository\refinery(), ilFileDataForum\storeUploadedFiles(), ILIAS\Repository\user(), and viewThreadObject().

Referenced by saveTopLevelPostObject().

2754  : void
2755  {
2756  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2757  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2758  }
2759 
2760  if ($this->objCurrentTopic->getId() === 0) {
2761  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_deleted'), true);
2762  $this->ctrl->redirect($this);
2763  }
2764 
2765  if ($this->objCurrentTopic->isClosed()) {
2766  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_closed'), true);
2767  $this->ctrl->redirect($this);
2768  }
2769 
2770  $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentTopic);
2771 
2772  $oReplyEditForm = $this->getReplyEditForm();
2773  if ($oReplyEditForm->checkInput()) {
2774  if ($this->objCurrentPost->getId() === 0) {
2775  $this->requestAction = '';
2776  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_parent_deleted'), true);
2777  $this->viewThreadObject();
2778  return;
2779  }
2780 
2781  $oForumObjects = $this->getForumObjects();
2782  $forumObj = $oForumObjects['forumObj'];
2783  $frm = $oForumObjects['frm'];
2784  $frm->setMDB2WhereCondition(' top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
2785  $topicData = $frm->getOneTopic();
2786 
2787  $autosave_draft_id = $this->http->wrapper()->post()->retrieve(
2788  'draft_id',
2789  $this->refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
2790  );
2791 
2792  if ($this->requestAction === 'ready_showreply') {
2793  if (!$this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
2794  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2795  }
2796 
2797  $status = true;
2798  $send_activation_mail = false;
2799 
2800  if ($this->objProperties->isPostActivationEnabled()) {
2801  if (!$this->is_moderator) {
2802  $status = false;
2803  $send_activation_mail = true;
2804  } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2805  $status = false;
2806  }
2807  }
2808 
2809  if ($this->isWritingWithPseudonymAllowed()) {
2810  if ((string) $oReplyEditForm->getInput('alias') === '') {
2811  $user_alias = $this->lng->txt('forums_anonymous');
2812  } else {
2813  $user_alias = $oReplyEditForm->getInput('alias');
2814  }
2815  $display_user_id = 0;
2816  } else {
2817  $user_alias = $this->user->getLogin();
2818  $display_user_id = $this->user->getId();
2819  }
2820 
2821  $newPost = $frm->generatePost(
2822  $topicData->getTopPk(),
2823  $this->objCurrentTopic->getId(),
2824  $this->user->getId(),
2825  $display_user_id,
2826  ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message')),
2827  $this->objCurrentPost->getId(),
2828  $oReplyEditForm->getInput('notify') && !$this->user->isAnonymous(),
2829  $this->handleFormInput($oReplyEditForm->getInput('subject'), false),
2830  $user_alias,
2831  '',
2832  $status,
2833  $send_activation_mail
2834  );
2835 
2836  if ($autosave_draft_id > 0) {
2837  $draft = new ilForumPostDraft(
2838  $this->user->getId(),
2839  $this->objCurrentPost->getId(),
2840  $autosave_draft_id
2841  );
2842  if ($this->hasDraftAccess($draft)) {
2843  $draft->deleteDraft();
2844  }
2845  }
2846 
2847  // mantis #8115: Mark parent as read
2848  $this->object->markPostRead(
2849  $this->user->getId(),
2850  $this->objCurrentTopic->getId(),
2851  $this->objCurrentPost->getId()
2852  );
2853 
2854  // copy temporary media objects (frm~)
2856  $oReplyEditForm->getInput('message'),
2857  'frm~:html',
2858  $this->user->getId(),
2859  'frm:html',
2860  $newPost
2861  );
2862 
2863  if ($this->objProperties->isFileUploadAllowed()) {
2864  $oFDForum = new ilFileDataForum($forumObj->getId(), $newPost);
2865  $file = $_FILES['userfile'];
2866  if (is_array($file) && !empty($file)) {
2867  $oFDForum->storeUploadedFiles();
2868  }
2869  }
2870 
2871  $GLOBALS['ilAppEventHandler']->raise(
2872  'components/ILIAS/Forum',
2873  'createdPost',
2874  [
2875  'object' => $this->object,
2876  'ref_id' => $this->object->getRefId(),
2877  'post' => new ilForumPost($newPost),
2878  'notify_moderators' => $send_activation_mail
2879  ]
2880  );
2881 
2882  $message = '';
2883  if (!$this->is_moderator && !$status) {
2884  $message .= $this->lng->txt('forums_post_needs_to_be_activated');
2885  } else {
2886  $message .= $this->lng->txt('forums_post_new_entry');
2887  }
2888 
2889  $this->tpl->setOnScreenMessage('success', $message, true);
2890  $this->ctrl->clearParameters($this);
2891  $this->ctrl->setParameter($this, 'post_created_below', $this->objCurrentPost->getId());
2892  $this->ctrl->setParameter($this, 'pos_pk', $newPost);
2893  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2894  } else {
2895  if ((!$this->is_moderator &&
2896  !$this->objCurrentPost->isOwner($this->user->getId())) || $this->objCurrentPost->isCensored() ||
2897  $this->user->isAnonymous()) {
2898  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2899  }
2900 
2901  $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentPost->getThread());
2902 
2903  $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm:html', $this->objCurrentPost->getId());
2904  $curMediaObjects = ilRTE::_getMediaObjects($oReplyEditForm->getInput('message'));
2905  foreach ($oldMediaObjects as $oldMob) {
2906  $found = false;
2907  foreach ($curMediaObjects as $curMob) {
2908  if ($oldMob === $curMob) {
2909  $found = true;
2910  break;
2911  }
2912  }
2913  if (!$found && ilObjMediaObject::_exists($oldMob)) {
2914  ilObjMediaObject::_removeUsage($oldMob, 'frm:html', $this->objCurrentPost->getId());
2915  $mob_obj = new ilObjMediaObject($oldMob);
2916  $mob_obj->delete();
2917  }
2918  }
2919 
2920  // save old activation status for send_notification decision
2921  $old_status_was_active = $this->objCurrentPost->isActivated();
2922 
2923  // if active post has been edited posting mus be activated again by moderator
2924  $status = true;
2925  $send_activation_mail = false;
2926 
2927  if ($this->objProperties->isPostActivationEnabled()) {
2928  if (!$this->is_moderator) {
2929  $status = false;
2930  $send_activation_mail = true;
2931  } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2932  $status = false;
2933  }
2934  }
2935  $this->objCurrentPost->setStatus($status);
2936 
2937  $this->objCurrentPost->setSubject($this->handleFormInput($oReplyEditForm->getInput('subject'), false));
2938  $this->objCurrentPost->setMessage(ilRTE::_replaceMediaObjectImageSrc(
2939  $oReplyEditForm->getInput('message')
2940  ));
2941  $this->objCurrentPost->setNotification($oReplyEditForm->getInput('notify') && !$this->user->isAnonymous());
2942  $this->objCurrentPost->setChangeDate(date('Y-m-d H:i:s'));
2943  $this->objCurrentPost->setUpdateUserId($this->user->getId());
2944 
2945  if ($this->objCurrentPost->update()) {
2946  $this->objCurrentPost->reload();
2947 
2948  // Change news item accordingly
2949  // note: $this->objCurrentPost->getForumId() does not give us the forum ID here (why?)
2951  $forumObj->getId(),
2952  'frm',
2953  $this->objCurrentPost->getId(),
2954  'pos'
2955  );
2956  if ($news_id > 0) {
2957  $news_item = new ilNewsItem($news_id);
2958  $news_item->setTitle($this->objCurrentPost->getSubject());
2959  $news_item->setContent(
2960  ilRTE::_replaceMediaObjectImageSrc($frm->prepareText(
2961  $this->objCurrentPost->getMessage()
2962  ), 1)
2963  );
2964 
2965  if ($this->objCurrentPost->getMessage() !== strip_tags($this->objCurrentPost->getMessage())) {
2966  $news_item->setContentHtml(true);
2967  } else {
2968  $news_item->setContentHtml(false);
2969  }
2970  $news_item->update();
2971  }
2972 
2973  $oFDForum = $oForumObjects['file_obj'];
2974 
2975  $file2delete = $oReplyEditForm->getInput('del_file');
2976  if (is_array($file2delete) && count($file2delete)) {
2977  $oFDForum->unlinkFilesByMD5Filenames($file2delete);
2978  }
2979 
2980  if ($this->objProperties->isFileUploadAllowed()) {
2981  $file = $_FILES['userfile'];
2982  if (is_array($file) && !empty($file)) {
2983  $oFDForum->storeUploadedFiles();
2984  }
2985  }
2986 
2987  $GLOBALS['ilAppEventHandler']->raise(
2988  'components/ILIAS/Forum',
2989  'updatedPost',
2990  [
2991  'ref_id' => $this->object->getRefId(),
2992  'post' => $this->objCurrentPost,
2993  'notify_moderators' => $send_activation_mail,
2994  'old_status_was_active' => $old_status_was_active
2995  ]
2996  );
2997 
2998  $this->tpl->setOnScreenMessage('success', $this->lng->txt('forums_post_modified'), true);
2999  }
3000 
3001  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
3002  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
3003  $this->ctrl->setParameter($this, 'viewmode', $this->selectedSorting);
3004  }
3005  $this->ctrl->redirect($this, 'viewThread');
3006  } else {
3007  $this->requestAction = substr($this->requestAction, 6);
3008  }
3009  $this->viewThreadObject();
3010  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static _getMediaObjects(string $a_text, int $a_direction=0)
Returns all media objects found in the passed string.
hasDraftAccess(int|ilForumPostDraft $draft)
static moveMediaObjects(string $post_message, string $source_type, int $source_id, string $target_type, int $target_id, int $direction=0)
ilForumTopic $objCurrentTopic
ilForumPost $objCurrentPost
static http()
Fetches the global http state from ILIAS.
$GLOBALS["DIC"]
Definition: wac.php:53
handleFormInput(string $a_text, bool $a_stripslashes=true)
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
static _exists(int $id, bool $reference=false, ?string $type=null)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
static _removeUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Remove usage of mob in another container.
A news item can be created by different sources.
static getFirstNewsIdForContext(int $a_context_obj_id, string $a_context_obj_type, int $a_context_sub_obj_id=0, string $a_context_sub_obj_type="")
Get first new id of news set related to a certain context.
$message
Definition: xapiexit.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveThreadAsDraftObject()

ilObjForumGUI::saveThreadAsDraftObject ( )
protected

Definition at line 4915 of file class.ilObjForumGUI.php.

References $GLOBALS, ilRTE\_replaceMediaObjectImageSrc(), ILIAS\Repository\access(), buildThreadForm(), checkDraftAccess(), ILIAS\Repository\ctrl(), ilForumUtil\getPublicUserAlias(), handleFormInput(), ILIAS\Repository\int(), ilForumPostDraft\isSavePostDraftAllowed(), isWritingWithPseudonymAllowed(), ILIAS\Repository\lng(), ilForumUtil\moveMediaObjects(), ilForumPostDraft\newInstanceByDraftId(), ILIAS\Repository\object(), ilFileDataForumDrafts\unlinkFilesByMD5Filenames(), and ILIAS\Repository\user().

4915  : void
4916  {
4918  !$this->access->checkAccess('add_thread', '', $this->object->getRefId()) ||
4919  !$this->access->checkAccess('read', '', $this->object->getRefId())) {
4920  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4921  }
4922 
4923  $autosave_draft_id = (int) ($this->httpRequest->getParsedBody()['draft_id'] ?? 0);
4924  if ($autosave_draft_id <= 0) {
4925  $autosave_draft_id = (int) ($this->httpRequest->getQueryParams()['draft_id'] ?? 0);
4926  }
4927 
4928  $frm = $this->object->Forum;
4929  $frm->setForumId($this->object->getId());
4930  $frm->setForumRefId($this->object->getRefId());
4931  $frm->setMDB2WhereCondition('top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
4932  $topicData = $frm->getOneTopic();
4933 
4934  $form = $this->buildThreadForm();
4935  if ($form->checkInput()) {
4936  if ($autosave_draft_id === 0) {
4937  $draft = new ilForumPostDraft();
4938  $draft->setForumId($topicData->getTopPk());
4939  $draft->setThreadId(0);
4940  $draft->setPostId(0);
4941  } else {
4942  $draft = ilForumPostDraft::newInstanceByDraftId($autosave_draft_id);
4943  $this->checkDraftAccess($draft);
4944  }
4945 
4946  $draft->setPostSubject($this->handleFormInput($form->getInput('subject'), false));
4947  $draft->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form->getInput('message')));
4948  $draft->setPostUserAlias(ilForumUtil::getPublicUserAlias(
4949  $form->getInput('alias'),
4950  $this->objProperties->isAnonymized()
4951  ));
4952  $draft->setNotificationStatus($form->getInput('notify') && !$this->user->isAnonymous());
4953  $draft->setPostAuthorId($this->user->getId());
4954  $draft->setPostDisplayUserId($this->isWritingWithPseudonymAllowed() ? 0 : $this->user->getId());
4955 
4956  if ($autosave_draft_id === 0) {
4957  $draftId = $draft->saveDraft();
4958  } else {
4959  $draft->updateDraft();
4960  $draftId = $draft->getDraftId();
4961  }
4962 
4963  $GLOBALS['ilAppEventHandler']->raise(
4964  'components/ILIAS/Forum',
4965  'savedAsDraft',
4966  [
4967  'draftObj' => $draft,
4968  'obj_id' => $this->object->getId(),
4969  'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
4970  ]
4971  );
4972 
4973  ilForumUtil::moveMediaObjects($form->getInput('message'), 'frm~d:html', $draftId, 'frm~d:html', $draftId);
4974 
4975  $draftFileData = new ilFileDataForumDrafts($this->object->getId(), $draftId);
4976 
4977  $files2delete = $form->getInput('del_file');
4978  if (is_array($files2delete) && $files2delete !== []) {
4979  $draftFileData->unlinkFilesByMD5Filenames($files2delete);
4980  }
4981 
4982  if ($this->objProperties->isFileUploadAllowed()) {
4983  $file = $_FILES['userfile'];
4984  if (is_array($file) && !empty($file)) {
4985  $draftFileData->storeUploadedFiles();
4986  }
4987  }
4988 
4989  $this->tpl->setOnScreenMessage('success', $this->lng->txt('save_draft_successfully'), true);
4990  $this->ctrl->clearParameters($this);
4991  $this->ctrl->redirect($this, 'showThreads');
4992  }
4993 
4994  $this->requestAction = substr($this->requestAction, 6);
4995  $form->setValuesByPost();
4996  $this->ctrl->setParameter($this, 'draft_id', $autosave_draft_id);
4997  $this->tpl->setContent($form->getHTML());
4998  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
buildThreadForm(bool $isDraft=false)
static moveMediaObjects(string $post_message, string $source_type, int $source_id, string $target_type, int $target_id, int $direction=0)
$GLOBALS["DIC"]
Definition: wac.php:53
static getPublicUserAlias(string $user_alias, bool $is_anonymized)
handleFormInput(string $a_text, bool $a_stripslashes=true)
checkDraftAccess(int|ilForumPostDraft $draft)
unlinkFilesByMD5Filenames($hashed_filename_or_filenames)
static newInstanceByDraftId(int $draft_id)
+ Here is the call graph for this function:

◆ saveTopLevelDraftObject()

ilObjForumGUI::saveTopLevelDraftObject ( )

Definition at line 5067 of file class.ilObjForumGUI.php.

References saveAsDraftObject().

5067  : void
5068  {
5069  $this->saveAsDraftObject();
5070  }
+ Here is the call graph for this function:

◆ saveTopLevelPostObject()

ilObjForumGUI::saveTopLevelPostObject ( )

Definition at line 2591 of file class.ilObjForumGUI.php.

References savePostObject().

2591  : void
2592  {
2593  $this->savePostObject();
2594  }
+ Here is the call graph for this function:

◆ saveUserNotificationSettingsObject()

ilObjForumGUI::saveUserNotificationSettingsObject ( )

Definition at line 4569 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl(), ilForumNotificationEvents\DEACTIVATED, eventsFormBuilder(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilForumNotification\setUserId(), and ILIAS\Repository\user().

4569  : void
4570  {
4571  $events_form_builder = $this->eventsFormBuilder();
4572 
4573  if ($this->httpRequest->getMethod() === 'POST') {
4574  $form = $events_form_builder->build()->withRequest($this->httpRequest);
4575  $formData = $form->getData();
4576 
4577  $interested_events = ilForumNotificationEvents::DEACTIVATED;
4578 
4579  foreach ($events_form_builder->getValidEvents() as $event) {
4580  $interested_events += isset($formData[$event]) && $formData[$event] ? $events_form_builder->getValueForEvent(
4581  $event
4582  ) : 0;
4583  }
4584 
4585  $frm_noti = new ilForumNotification($this->object->getRefId());
4586  $frm_noti->setUserId($this->user->getId());
4587  $frm_noti->setInterestedEvents($interested_events);
4588  $frm_noti->updateInterestedEvents();
4589  }
4590 
4591  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
4592 
4593  if ($this->objCurrentTopic->getId() > 0) {
4594  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4595  $this->ctrl->redirect($this, 'viewThread');
4596  }
4597 
4598  $this->ctrl->redirect($this, 'showThreads');
4599  }
Class ilForumNotification.
eventsFormBuilder(?array $predefined_values=null)
+ Here is the call graph for this function:

◆ selectPostObject()

ilObjForumGUI::selectPostObject ( )
protected

Definition at line 1541 of file class.ilObjForumGUI.php.

References ILIAS\Repository\int(), and viewThreadObject().

1541  : void
1542  {
1543  $thr_pk = (int) $this->httpRequest->getQueryParams()['thr_pk'];
1544  $pos_pk = (int) $this->httpRequest->getQueryParams()['pos_pk'];
1545 
1546  $this->selected_post_storage->set(
1547  $thr_pk,
1548  $pos_pk
1549  );
1550 
1551  $this->viewThreadObject();
1552  }
+ Here is the call graph for this function:

◆ setColumnSettings()

ilObjForumGUI::setColumnSettings ( ilColumnGUI  $column_gui)

Definition at line 4313 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\lng(), ilColumnGUI\setBlockProperty(), and ilColumnGUI\setRepositoryMode().

4313  : void
4314  {
4315  $column_gui->setBlockProperty('news', 'title', $this->lng->txt('frm_latest_postings'));
4316  $column_gui->setBlockProperty('news', 'prevent_aggregation', '1');
4317  $column_gui->setRepositoryMode(true);
4318 
4319  if ($this->access->checkAccess('write', '', $this->object->getRefId())) {
4320  $news_set = new ilSetting('news');
4321  if ($news_set->get('enable_rss_for_internal')) {
4322  $column_gui->setBlockProperty('news', 'settings', '1');
4323  $column_gui->setBlockProperty('news', 'public_notifications_option', '1');
4324  }
4325  }
4326  }
setRepositoryMode(bool $a_repositorymode)
setBlockProperty(string $a_block_type, string $a_property, string $a_value)
This function is supposed to be used for block type specific properties, that should be passed to ilB...
+ Here is the call graph for this function:

◆ setDisplayConfirmPostActivation()

ilObjForumGUI::setDisplayConfirmPostActivation ( bool  $status = false)

Definition at line 2119 of file class.ilObjForumGUI.php.

Referenced by askForPostActivationObject().

2119  : void
2120  {
2121  $this->display_confirm_post_activation = $status;
2122  }
+ Here is the caller graph for this function:

◆ setSideBlocks()

ilObjForumGUI::setSideBlocks ( )
protected

Definition at line 4805 of file class.ilObjForumGUI.php.

References ILIAS\Repository\ctrl(), ilObjectGUI\getRightColumnHTML(), ilRepositoryObjectSearchGUI\getSearchBlockHTML(), and ILIAS\Repository\lng().

Referenced by getSafePostCommands(), and showThreadsObject().

4805  : void
4806  {
4807  $content = $this->getRightColumnHTML();
4808  if (!$this->ctrl->isAsynch()) {
4809  $content = implode('', [
4810  ilRepositoryObjectSearchGUI::getSearchBlockHTML($this->lng->txt('frm_search')),
4811  $content,
4812  ]);
4813  }
4814  $this->tpl->setRightContent($content);
4815  }
getRightColumnHTML()
Display right column.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showStatisticsObject()

ilObjForumGUI::showStatisticsObject ( )

Definition at line 1705 of file class.ilObjForumGUI.php.

References ILIAS\Repository\access(), ilLearningProgressAccess\checkAccess(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ILIAS\Repository\settings(), and ILIAS\Repository\user().

1705  : void
1706  {
1707  if (!$this->settings->get('enable_fora_statistics', '0')) {
1708  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1709  }
1710 
1711  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1712  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1713  }
1714 
1715  if (!$this->objProperties->isStatisticEnabled()) {
1716  if ($this->access->checkAccess('write', '', $this->object->getRefId())) {
1717  $this->tpl->setOnScreenMessage('info', $this->lng->txt('frm_statistics_disabled_for_participants'));
1718  } else {
1719  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1720  }
1721  }
1722 
1723  $this->object->Forum->setForumId($this->object->getId());
1724 
1725  $tbl = new \ILIAS\Forum\Statistics\ForumStatisticsTable(
1726  $this->object,
1727  $this->objProperties,
1728  ilLearningProgressAccess::checkAccess($this->object->getRefId()),
1729  $this->access->checkRbacOrPositionPermissionAccess(
1730  'read_learning_progress',
1731  'read_learning_progress',
1732  $this->object->getRefId()
1733  ),
1734  $this->user,
1735  $this->ui_factory,
1736  $this->request,
1737  $this->lng
1738  );
1739  $this->tpl->setContent($this->uiRenderer->render($tbl->getComponent()));
1740  }
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
+ Here is the call graph for this function:

◆ showThreadsObject()

ilObjForumGUI::showThreadsObject ( )

Definition at line 668 of file class.ilObjForumGUI.php.

References ilObjectGUI\getCenterColumnHTML(), and setSideBlocks().

Referenced by confirmDeleteThreadDraftsObject(), confirmMergeThreadsObject(), disableForumNotificationObject(), enableForumNotificationObject(), getSafePostCommands(), markAllReadObject(), mergeThreadsObject(), performMergeThreadsObject(), and updateThreadObject().

668  : void
669  {
670  $this->setSideBlocks();
671  $this->getCenterColumnHTML();
672  }
getCenterColumnHTML()
Get center column.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showUserObject()

ilObjForumGUI::showUserObject ( )

Definition at line 3592 of file class.ilObjForumGUI.php.

References $user_id, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilObjectFactory\getInstanceByRefId(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ILIAS\Repository\refinery(), and ilUtil\stripSlashes().

3592  : void
3593  {
3594  $user_id = $this->http->wrapper()->query()->retrieve(
3595  'user',
3596  $this->refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
3597  );
3598  $backurl = $this->http->wrapper()->query()->retrieve(
3599  'backurl',
3600  $this->refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always('')])
3601  );
3602 
3603  $profile_gui = new ilPublicUserProfileGUI($user_id);
3604  $add = $this->getUserProfileAdditional($this->object->getRefId(), $user_id);
3605  $profile_gui->setAdditional($add);
3606  $profile_gui->setBackUrl(ilUtil::stripSlashes($backurl));
3607  $this->tpl->setContent($this->ctrl->getHTML($profile_gui));
3608  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
GUI class for public user profile presentation.
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ toggleExplorerNodeStateObject()

ilObjForumGUI::toggleExplorerNodeStateObject ( )
protected

Definition at line 163 of file class.ilObjForumGUI.php.

References $objCurrentTopic, ilForumTopic\getPostRootNode(), and ilTreeExplorerGUI\toggleExplorerNodeState().

163  : void
164  {
165  $exp = new ilForumExplorerGUI(
166  'frm_exp_' . $this->objCurrentTopic->getId(),
167  $this,
168  'viewThread',
170  $this->objCurrentTopic->getPostRootNode($this->is_moderator)
171  );
172  $exp->toggleExplorerNodeState();
173  }
Class ilForumExplorerGUI.
ilForumTopic $objCurrentTopic
getPostRootNode(bool $isModerator=false, bool $preventImplicitRead=false)
toggleExplorerNodeState()
Should be called by an ilCtrl-enabled command class if a tree node toggle action should be processed...
+ Here is the call graph for this function:

◆ toggleStickinessObject()

ilObjForumGUI::toggleStickinessObject ( )
protected

Definition at line 2149 of file class.ilObjForumGUI.php.

References $objCurrentTopic, ILIAS\Repository\access(), ensureThreadBelongsToForum(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and viewThreadObject().

2149  : void
2150  {
2151  if (!$this->is_moderator) {
2152  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2153  }
2154 
2155  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2156  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2157  }
2158 
2159  $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentTopic);
2160 
2161  if ($this->objCurrentTopic->isSticky()) {
2162  $this->objCurrentTopic->unmakeSticky();
2163  } else {
2164  $this->objCurrentTopic->makeSticky();
2165  }
2166 
2167  $this->viewThreadObject();
2168  }
ilForumTopic $objCurrentTopic
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
+ Here is the call graph for this function:

◆ toggleThreadNotificationObject()

ilObjForumGUI::toggleThreadNotificationObject ( )
protected

Definition at line 2129 of file class.ilObjForumGUI.php.

References $objCurrentTopic, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ensureThreadBelongsToForum(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ILIAS\Repository\user().

2129  : void
2130  {
2131  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2132  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2133  }
2134 
2135  $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentTopic);
2136 
2137  if ($this->objCurrentTopic->isNotificationEnabled($this->user->getId())) {
2138  $this->objCurrentTopic->disableNotification($this->user->getId());
2139  $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_notification_disabled'), true);
2140  } else {
2141  $this->objCurrentTopic->enableNotification($this->user->getId());
2142  $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_notification_enabled'), true);
2143  }
2144 
2145  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
2146  $this->ctrl->redirect($this, 'viewThread');
2147  }
ilForumTopic $objCurrentTopic
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
+ Here is the call graph for this function:

◆ updateCustom()

ilObjForumGUI::updateCustom ( ilPropertyFormGUI  $form)
protected

Definition at line 622 of file class.ilObjForumGUI.php.

622  : void
623  {
624  $this->forum_settings_gui->updateCustomValues($form);
625  }

◆ updateDraftObject()

ilObjForumGUI::updateDraftObject ( )

Definition at line 5197 of file class.ilObjForumGUI.php.

References $GLOBALS, ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), ilRTE\_replaceMediaObjectImageSrc(), ilObjMediaObject\_saveUsage(), ILIAS\Repository\access(), checkDraftAccess(), ILIAS\Repository\ctrl(), ilSession\get(), getForumObjects(), ilForumUtil\getPublicUserAlias(), getReplyEditForm(), handleFormInput(), ilForumPostDraft\isSavePostDraftAllowed(), isWritingWithPseudonymAllowed(), ILIAS\Repository\lng(), ILIAS\Repository\object(), retrieveDraftId(), ilForumUtil\saveMediaObjects(), ilSession\set(), ilFileDataForumDrafts\unlinkFilesByMD5Filenames(), ILIAS\Repository\user(), and viewThreadObject().

5197  : void
5198  {
5200  !$this->access->checkAccess('read', '', $this->object->getRefId())) {
5201  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5202  }
5203 
5204  if ($this->objCurrentTopic->getId() === 0) {
5205  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_deleted'), true);
5206  $this->ctrl->redirect($this);
5207  }
5208 
5209  if ($this->objCurrentTopic->isClosed()) {
5210  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_closed'), true);
5211  $this->ctrl->redirect($this);
5212  }
5213 
5214  if ($this->objCurrentPost->getId() === 0) {
5215  $this->requestAction = '';
5216  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_parent_deleted'));
5217  $this->viewThreadObject();
5218  return;
5219  }
5220 
5221  $oReplyEditForm = $this->getReplyEditForm();
5222  if ($oReplyEditForm->checkInput()) {
5223  $oForumObjects = $this->getForumObjects();
5224  $forumObj = $oForumObjects['forumObj'];
5225 
5226  if (!$this->user->isAnonymous() && in_array($this->requestAction, ['showdraft', 'editdraft'])) {
5227  if (!$this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
5228  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5229  }
5230 
5231  $draft = new ilForumPostDraft(
5232  $this->user->getId(),
5233  $this->objCurrentPost->getId(),
5234  $this->retrieveDraftId()
5235  );
5236 
5237  $this->checkDraftAccess($draft);
5238 
5239  $draft->setPostSubject($this->handleFormInput($oReplyEditForm->getInput('subject'), false));
5240  $draft->setPostMessage(ilRTE::_replaceMediaObjectImageSrc(
5241  $oReplyEditForm->getInput('message')
5242  ));
5243  $draft->setPostUserAlias(ilForumUtil::getPublicUserAlias(
5244  $oReplyEditForm->getInput('alias'),
5245  $this->objProperties->isAnonymized()
5246  ));
5247  $draft->setNotificationStatus($oReplyEditForm->getInput('notify') && !$this->user->isAnonymous());
5248  $draft->setUpdateUserId($this->user->getId());
5249  $draft->setPostAuthorId($this->user->getId());
5250  $draft->setPostDisplayUserId($this->isWritingWithPseudonymAllowed() ? 0 : $this->user->getId());
5251 
5252  $draft->updateDraft();
5253 
5254  $GLOBALS['ilAppEventHandler']->raise(
5255  'components/ILIAS/Forum',
5256  'updatedDraft',
5257  [
5258  'draftObj' => $draft,
5259  'obj_id' => $this->object->getId(),
5260  'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5261  ]
5262  );
5263 
5264  $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
5265 
5266  foreach ($uploadedObjects as $mob) {
5267  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
5268  ilObjMediaObject::_saveUsage($mob, 'frm~d:html', $draft->getDraftId());
5269  }
5271  $oReplyEditForm->getInput('message'),
5272  'frm~d:html',
5273  $draft->getDraftId()
5274  );
5275 
5276  $oFDForumDrafts = new ilFileDataForumDrafts($forumObj->getId(), $draft->getDraftId());
5277 
5278  $file2delete = $oReplyEditForm->getInput('del_file');
5279  if (is_array($file2delete) && count($file2delete)) {
5280  $oFDForumDrafts->unlinkFilesByMD5Filenames($file2delete);
5281  }
5282 
5283  if ($this->objProperties->isFileUploadAllowed()) {
5284  $file = $_FILES['userfile'];
5285  if (is_array($file) && !empty($file)) {
5286  $oFDForumDrafts->storeUploadedFiles();
5287  }
5288  }
5289 
5290  $frm_session_values = ilSession::get('frm');
5291  if (is_array($frm_session_values)) {
5292  $frm_session_values[$this->objCurrentPost->getThreadId()]['openTreeNodes'][] = $this->objCurrentPost->getId();
5293  }
5294  ilSession::set('frm', $frm_session_values);
5295  $this->tpl->setOnScreenMessage('success', $this->lng->txt('save_draft_successfully'), true);
5296  $this->ctrl->clearParameters($this);
5297  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
5298  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
5299  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
5300  }
5301  } else {
5302  $this->ctrl->clearParameters($this);
5303  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
5304  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
5305  $this->ctrl->setParameter($this, 'draft_id', $this->retrieveDraftId());
5306  $this->ctrl->setParameter($this, 'action', 'editdraft');
5307  $oReplyEditForm->setValuesByPost();
5308  $this->viewThreadObject();
5309  return;
5310  }
5311  $this->ctrl->clearParameters($this);
5312  $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
5313  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
5314  $this->ctrl->redirect($this, 'viewThread');
5315  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static get(string $a_var)
static _saveUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Save usage of mob within another container (e.g.
$GLOBALS["DIC"]
Definition: wac.php:53
static getPublicUserAlias(string $user_alias, bool $is_anonymized)
handleFormInput(string $a_text, bool $a_stripslashes=true)
static saveMediaObjects(string $post_message, string $target_type, int $target_id, int $direction=0)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
static _removeUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Remove usage of mob in another container.
checkDraftAccess(int|ilForumPostDraft $draft)
unlinkFilesByMD5Filenames($hashed_filename_or_filenames)
retrieveDraftId(bool $from_post=false)
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

◆ updateThreadDraftObject()

ilObjForumGUI::updateThreadDraftObject ( )
protected

Definition at line 5000 of file class.ilObjForumGUI.php.

References $GLOBALS, ilRTE\_replaceMediaObjectImageSrc(), ILIAS\Repository\access(), buildThreadForm(), checkDraftAccess(), ILIAS\Repository\ctrl(), editThreadDraftObject(), ilForumUtil\getPublicUserAlias(), handleFormInput(), ilForumPostDraft\isSavePostDraftAllowed(), isWritingWithPseudonymAllowed(), ILIAS\Repository\lng(), ilForumUtil\moveMediaObjects(), ilForumPostDraft\newInstanceByDraftId(), ILIAS\Repository\object(), retrieveDraftId(), ilFileDataForumDrafts\unlinkFilesByMD5Filenames(), and ILIAS\Repository\user().

5000  : void
5001  {
5003  !$this->access->checkAccess('add_thread', '', $this->object->getRefId()) ||
5004  !$this->access->checkAccess('read', '', $this->object->getRefId())) {
5005  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5006  }
5007 
5009  $this->checkDraftAccess($draft);
5010 
5011  $form = $this->buildThreadForm(true);
5012  if ($form->checkInput()) {
5013  $draft->setPostSubject($this->handleFormInput($form->getInput('subject'), false));
5014  $draft->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form->getInput('message')));
5015  $draft->setPostUserAlias(ilForumUtil::getPublicUserAlias(
5016  $form->getInput('alias'),
5017  $this->objProperties->isAnonymized()
5018  ));
5019  $draft->setNotificationStatus($form->getInput('notify') && !$this->user->isAnonymous());
5020  $draft->setPostAuthorId($this->user->getId());
5021  $draft->setPostDisplayUserId($this->isWritingWithPseudonymAllowed() ? 0 : $this->user->getId());
5022  $draft->updateDraft();
5023 
5024  $GLOBALS['ilAppEventHandler']->raise(
5025  'components/ILIAS/Forum',
5026  'updatedDraft',
5027  [
5028  'draftObj' => $draft,
5029  'obj_id' => $this->object->getId(),
5030  'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
5031  ]
5032  );
5033 
5035  $form->getInput('message'),
5036  'frm~d:html',
5037  $draft->getDraftId(),
5038  'frm~d:html',
5039  $draft->getDraftId()
5040  );
5041 
5042  $draftFileData = new ilFileDataForumDrafts($this->object->getId(), $draft->getDraftId());
5043 
5044  $files2delete = $form->getInput('del_file');
5045  if (is_array($files2delete) && $files2delete !== []) {
5046  $draftFileData->unlinkFilesByMD5Filenames($files2delete);
5047  }
5048 
5049  if ($this->objProperties->isFileUploadAllowed()) {
5050  $file = $_FILES['userfile'];
5051  if (is_array($file) && !empty($file) && isset($file['full_path'][0]) && !empty($file['full_path'][0])) {
5052  $draftFileData->storeUploadedFiles();
5053  }
5054  }
5055 
5056  $this->tpl->setOnScreenMessage('success', $this->lng->txt('save_draft_successfully'), true);
5057  $this->ctrl->clearParameters($this);
5058  $this->ctrl->redirect($this, 'showThreads');
5059  }
5060 
5061  $form->setValuesByPost();
5062  $this->ctrl->setParameter($this, 'hist_check', 0);
5063  $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
5064  $this->editThreadDraftObject($form);
5065  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
buildThreadForm(bool $isDraft=false)
static moveMediaObjects(string $post_message, string $source_type, int $source_id, string $target_type, int $target_id, int $direction=0)
$GLOBALS["DIC"]
Definition: wac.php:53
static getPublicUserAlias(string $user_alias, bool $is_anonymized)
handleFormInput(string $a_text, bool $a_stripslashes=true)
checkDraftAccess(int|ilForumPostDraft $draft)
unlinkFilesByMD5Filenames($hashed_filename_or_filenames)
retrieveDraftId(bool $from_post=false)
static newInstanceByDraftId(int $draft_id)
editThreadDraftObject(?ilPropertyFormGUI $form=null)
+ Here is the call graph for this function:

◆ updateThreadObject()

ilObjForumGUI::updateThreadObject ( )

Definition at line 627 of file class.ilObjForumGUI.php.

References $objCurrentTopic, ILIAS\Repository\access(), ensureThreadBelongsToForum(), getEditTitleModal(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and showThreadsObject().

Referenced by performThreadsActionObject().

627  : void
628  {
629  if (!$this->is_moderator) {
630  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
631  }
632 
633  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
634  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
635  }
636 
637  if ($this->objCurrentTopic->getId() === 0) {
638  $this->showThreadsObject();
639  return;
640  }
641 
643 
644  $title = $this->getEditTitleModal($this->objCurrentTopic)->withRequest($this->http->request())->getData();
645  if (array_key_exists(0, $title)) {
646  $new_subject = $title[0];
647  if ($new_subject !== '') {
648  $this->objCurrentTopic->setSubject($new_subject);
649  $this->objCurrentTopic->updateThreadTitle();
650  $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
651  }
652 
653  $this->showThreadsObject();
654  }
655  }
getEditTitleModal(ilForumTopic $topic)
ilForumTopic $objCurrentTopic
static http()
Fetches the global http state from ILIAS.
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ viewThreadObject()

ilObjForumGUI::viewThreadObject ( )

Definition at line 3108 of file class.ilObjForumGUI.php.

References $is_moderator, $objCurrentTopic, $post, $selectedSorting, ilObjectGUI\$toolbar, ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilChangeEvent\_recordReadEvent(), ilObjMediaObject\_removeUsage(), ILIAS\Repository\access(), ilObjectGUI\addHeaderAction(), ilNavigationHistory\addItem(), ILIAS\Repository\ctrl(), ilFileDataForumDrafts\deliverFile(), ensureThreadBelongsToForum(), ensureValidPageForCurrentPosting(), ForumGlobalScreenToolsProvider\FORUM_BASE_CONTROLLER, ForumGlobalScreenToolsProvider\FORUM_THEAD, ForumGlobalScreenToolsProvider\FORUM_THREAD_ROOT, ilSession\get(), ilObjectGUI\getCreationMode(), getForumObjects(), ilForumPost\getId(), getModalActions(), getOrderByParam(), getReplyEditForm(), getResetLimitedViewInfo(), ilForumPostDraft\getSortedDrafts(), ILIAS\Repository\globalScreen(), ILIAS\Repository\int(), ilForumPostDraft\isSavePostDraftAllowed(), isTopLevelReplyCommand(), ILIAS\Repository\lng(), ILIAS\Repository\locator(), ILIAS\Repository\object(), ForumGlobalScreenToolsProvider\PAGE, ForumGlobalScreenToolsProvider\REF_ID, renderDraftContent(), renderPostContent(), renderPostingForm(), renderSortationControl(), renderViewModeControl(), ilSession\set(), ILIAS\Repository\settings(), ForumGlobalScreenToolsProvider\SHOW_FORUM_THREADS_TOOL, ilUtil\stripSlashes(), ILIAS\Repository\user(), ilForumProperties\VIEW_DATE_ASC, ilForumProperties\VIEW_DATE_DESC, and ilForumProperties\VIEW_TREE.

Referenced by askForPostActivationObject(), cancelDraftObject(), cancelPostObject(), createTopLevelPostObject(), editDraftObject(), handleCensorship(), markPostUnreadObject(), performPostActivationObject(), publishDraftObject(), quotePostObject(), saveAsDraftObject(), savePostObject(), selectPostObject(), toggleStickinessObject(), and updateDraftObject().

3108  : void
3109  {
3110  $thr_pk = $this->objCurrentTopic->getId();
3111 
3112  $bottom_toolbar = clone $this->toolbar;
3113  $toolbar_items = [];
3114 
3115  // quick and dirty: check for treeview
3116  $thread_control_session_values = ilSession::get('thread_control');
3117  if (is_array($thread_control_session_values)) {
3118  if (!isset($thread_control_session_values['old'])) {
3119  $thread_control_session_values['old'] = $thr_pk;
3120  $thread_control_session_values['new'] = $thr_pk;
3121  ilSession::set('thread_control', $thread_control_session_values);
3122  } elseif (isset($thread_control_session_values['old']) && $thr_pk !== $thread_control_session_values['old']) {
3123  $thread_control_session_values['new'] = $thr_pk;
3124  ilSession::set('thread_control', $thread_control_session_values);
3125  }
3126  }
3127 
3128  if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3129  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3130  }
3131 
3132  $oForumObjects = $this->getForumObjects();
3133  $forumObj = $oForumObjects['forumObj'];
3134  $frm = $oForumObjects['frm'];
3135  $file_obj = $oForumObjects['file_obj'];
3136 
3137  $selected_draft_id = (int) ($this->httpRequest->getQueryParams()['draft_id'] ?? 0);
3138  if (isset($this->httpRequest->getQueryParams()['file'])) {
3139  $file_obj_for_delivery = $file_obj;
3140  if ($selected_draft_id > 0 && ilForumPostDraft::isSavePostDraftAllowed()) {
3141  $file_obj_for_delivery = new ilFileDataForumDrafts($forumObj->getId(), $selected_draft_id);
3142  }
3143  $file_obj_for_delivery->deliverFile(ilUtil::stripSlashes($this->httpRequest->getQueryParams()['file']));
3144  }
3145 
3146  if ($this->objCurrentTopic->getId() === 0) {
3147  $this->ctrl->redirect($this, 'showThreads');
3148  }
3149 
3150  $pageIndex = 0;
3151  if (isset($this->httpRequest->getQueryParams()['page'])) {
3152  $pageIndex = max((int) $this->httpRequest->getQueryParams()['page'], $pageIndex);
3153  }
3154 
3155  if ($this->selected_post_storage->get($this->objCurrentTopic->getId()) > 0) {
3156  $firstNodeInThread = new ilForumPost(
3157  $this->selected_post_storage->get($this->objCurrentTopic->getId()),
3158  $this->is_moderator,
3159  false
3160  );
3161  } else {
3162  $firstNodeInThread = $this->objCurrentTopic->getPostRootNode();
3163  }
3164 
3165  $toolContext = $this->globalScreen
3166  ->tool()
3167  ->context()
3168  ->current();
3169 
3170  $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentTopic);
3171 
3172  $threadContentTemplate = new ilTemplate(
3173  'tpl.forums_threads_view.html',
3174  true,
3175  true,
3176  'components/ILIAS/Forum'
3177  );
3178 
3179 
3180  if ($this->selectedSorting === ilForumProperties::VIEW_TREE) {
3181  $order_field = 'frm_posts_tree.rgt';
3182  $this->objCurrentTopic->setOrderDirection('DESC');
3183  $threadContentTemplate->setVariable('LIST_TYPE', $this->viewModeOptions[$this->selectedSorting]);
3184  } else {
3185  $order_field = 'frm_posts.pos_date';
3186  $this->objCurrentTopic->setOrderDirection(
3187  $this->selectedSorting === ilForumProperties::VIEW_DATE_DESC ? 'DESC' : 'ASC'
3188  );
3189  $threadContentTemplate->setVariable('LIST_TYPE', $this->sortationOptions[$this->selectedSorting]);
3190  }
3191  $this->objCurrentTopic->setOrderField($order_field);
3192 
3193  $additionalDataExists = $toolContext->getAdditionalData()->exists(ForumGlobalScreenToolsProvider::SHOW_FORUM_THREADS_TOOL);
3194  $subtree_nodes = $this->objCurrentTopic->getPostTree($firstNodeInThread);
3195  $numberOfPostings = count($subtree_nodes);
3196  if ($numberOfPostings > 0 && !$additionalDataExists && $this->selectedSorting === ilForumProperties::VIEW_TREE) {
3197  $toolContext
3199  ->addAdditionalData(ForumGlobalScreenToolsProvider::REF_ID, $this->ref_id)
3200  ->addAdditionalData(ForumGlobalScreenToolsProvider::FORUM_THEAD, $this->objCurrentTopic)
3201  ->addAdditionalData(ForumGlobalScreenToolsProvider::FORUM_THREAD_ROOT, $firstNodeInThread)
3202  ->addAdditionalData(ForumGlobalScreenToolsProvider::FORUM_BASE_CONTROLLER, $this)
3203  ->addAdditionalData(ForumGlobalScreenToolsProvider::PAGE, $pageIndex);
3204  }
3205  // Set context for login
3206  $append = '_' . $this->objCurrentTopic->getId() .
3207  ($this->objCurrentPost->getId() !== 0 ? '_' . $this->objCurrentPost->getId() : '');
3208  $this->tpl->setLoginTargetPar('frm_' . $this->object->getRefId() . $append);
3209 
3210  // delete temporary media object (not in case a user adds media objects and wants to save an invalid form)
3211  if (!in_array($this->requestAction, ['showreply', 'showedit'])) {
3212  try {
3213  $mobs = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
3214  foreach ($mobs as $mob) {
3215  if (ilObjMediaObject::_exists($mob)) {
3216  ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
3217  $mob_obj = new ilObjMediaObject($mob);
3218  $mob_obj->delete();
3219  }
3220  }
3221  } catch (Exception) {
3222  }
3223  }
3224 
3225  if (!$this->getCreationMode() && $this->access->checkAccess('read', '', $this->object->getRefId())) {
3226  $this->ilNavigationHistory->addItem(
3227  $this->object->getRefId(),
3228  ilLink::_getLink($this->object->getRefId(), 'frm'),
3229  'frm'
3230  );
3231  }
3232 
3233  $this->prepareThreadScreen($forumObj);
3234 
3235 
3236  if (isset($this->httpRequest->getQueryParams()['anchor'])) {
3237  $threadContentTemplate->setVariable('JUMP2ANCHOR_ID', (int) $this->httpRequest->getQueryParams()['anchor']);
3238  }
3239  $frm->setMDB2WhereCondition('top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
3240 
3242  $this->object->getType(),
3243  $this->object->getRefId(),
3244  $this->object->getId(),
3245  $this->user->getId()
3246  );
3247 
3248  if ($firstNodeInThread) {
3249  $this->objCurrentTopic->updateVisits();
3250 
3251  $this->tpl->setTitle($this->lng->txt('forums_thread') . ' "' . $this->objCurrentTopic->getSubject() . '"');
3252 
3253  $this->locator->addRepositoryItems();
3254  $this->locator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ''), '_top');
3255  $this->tpl->setLocator();
3256 
3257  if (!$this->user->isAnonymous() &&
3258  $forumObj->getCountUnread($this->user->getId(), $this->objCurrentTopic->getId(), true)) {
3259  $this->ctrl->setParameter($this, 'mark_read', '1');
3260  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3261 
3262  $mark_thr_read_button = $this->uiFactory->button()->standard(
3263  $this->lng->txt('forums_mark_read'),
3264  $this->ctrl->getLinkTarget($this, 'viewThread')
3265  );
3266 
3267  $toolbar_items[] = $mark_thr_read_button;
3268 
3269  $this->ctrl->clearParameters($this);
3270  }
3271 
3272  $this->ctrl->setParameterByClass(ilForumExportGUI::class, 'print_thread', $this->objCurrentTopic->getId());
3273  $this->ctrl->setParameterByClass(
3274  ilForumExportGUI::class,
3275  'thr_top_fk',
3276  $this->objCurrentTopic->getForumId()
3277  );
3278 
3279  if ($numberOfPostings > 0 && $this->settings->get('forum_enable_print', '0')) {
3280  $print_thr_button = $this->uiFactory->button()->standard(
3281  $this->lng->txt('forums_print_thread'),
3282  $this->ctrl->getLinkTargetByClass(ilForumExportGUI::class, 'printThread')
3283  );
3284  $toolbar_items[] = $print_thr_button;
3285  }
3286 
3287 
3288  $this->ctrl->clearParametersByClass(ilForumExportGUI::class);
3289 
3290  $this->addHeaderAction();
3291 
3292  if (isset($this->httpRequest->getQueryParams()['mark_read'])) {
3293  $forumObj->markThreadRead($this->user->getId(), $this->objCurrentTopic->getId());
3294  $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_thread_marked'), true);
3295  }
3296 
3297  if ($firstNodeInThread instanceof ilForumPost &&
3298  !$this->isTopLevelReplyCommand() &&
3299  !$this->objCurrentTopic->isClosed() &&
3300  $this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
3301  $this->ctrl->setParameter($this, 'action', 'showreply');
3302  $this->ctrl->setParameter($this, 'pos_pk', $firstNodeInThread->getId());
3303  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3304  $this->ctrl->setParameter(
3305  $this,
3306  'page',
3307  (int) ($this->httpRequest->getQueryParams()['page'] ?? 0)
3308  );
3309  $this->ctrl->setParameter(
3310  $this,
3311  'orderby',
3312  $this->getOrderByParam()
3313  );
3314  if ($numberOfPostings > 0) {
3315  $reply_button = $this->uiFactory->button()->standard(
3316  $this->lng->txt('add_new_answer'),
3317  $this->ctrl->getLinkTarget($this, 'createTopLevelPost', 'frm_page_bottom')
3318  );
3319  } else {
3320  $reply_button = $this->uiFactory->button()->primary(
3321  $this->lng->txt('add_new_answer'),
3322  $this->ctrl->getLinkTarget($this, 'createTopLevelPost', 'frm_page_bottom')
3323  );
3324  }
3325  $this->ctrl->clearParameters($this);
3326  array_unshift($toolbar_items, $reply_button);
3327  }
3328 
3329  // no posts
3330  if ($numberOfPostings === 0 && $firstNodeInThread->getId() === 0) {
3331  $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_no_posts_available'));
3332  }
3333 
3334  $pageSize = $frm->getPageHits();
3335  $postIndex = 0;
3336  if ($numberOfPostings > $pageSize) {
3337  $this->ctrl->setParameter($this, 'ref_id', $this->object->getRefId());
3338  $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3339  $this->ctrl->setParameter(
3340  $this,
3341  'orderby',
3342  $this->getOrderByParam()
3343  );
3344  $paginationUrl = $this->ctrl->getLinkTarget($this, 'viewThread', '');
3345  $this->ctrl->clearParameters($this);
3346 
3347  $pagination = $this->uiFactory->viewControl()
3348  ->pagination()
3349  ->withTargetURL($paginationUrl, 'page')
3350  ->withTotalEntries($numberOfPostings)
3351  ->withPageSize($pageSize)
3352  ->withMaxPaginationButtons(10)
3353  ->withCurrentPage($pageIndex);
3354 
3355  $threadContentTemplate->setVariable('THREAD_MENU', $this->uiRenderer->render(
3356  $pagination
3357  ));
3358  $threadContentTemplate->setVariable('THREAD_MENU_BOTTOM', $this->uiRenderer->render(
3359  $pagination
3360  ));
3361  }
3362 
3363  $doRenderDrafts = ilForumPostDraft::isSavePostDraftAllowed() && !$this->user->isAnonymous();
3364  $draftsObjects = [];
3365  if ($doRenderDrafts) {
3366  $draftsObjects = ilForumPostDraft::getSortedDrafts(
3367  $this->user->getId(),
3368  $this->objCurrentTopic->getId(),
3370  );
3371  }
3372 
3373  $pagedPostings = array_slice($subtree_nodes, $pageIndex * $pageSize, $pageSize);
3374 
3375  $this->ensureValidPageForCurrentPosting($subtree_nodes, $pagedPostings, $pageSize, $firstNodeInThread);
3376 
3377  if ($doRenderDrafts && $pageIndex === 0 &&
3378  $this->selectedSorting === ilForumProperties::VIEW_DATE_DESC) {
3379  foreach ($draftsObjects as $draft) {
3380  $referencePosting = array_values(array_filter(
3381  $subtree_nodes,
3382  static function (ilForumPost $post) use ($draft): bool {
3383  return $draft->getPostId() === $post->getId();
3384  }
3385  ))[0] ?? $firstNodeInThread;
3386 
3387  $this->renderDraftContent(
3388  $threadContentTemplate,
3389  $this->requestAction,
3390  $referencePosting,
3391  [$draft]
3392  );
3393  }
3394  }
3395 
3396  foreach ($pagedPostings as $node) {
3397  $this->ctrl->clearParameters($this);
3398 
3399  if (!$this->isTopLevelReplyCommand() && $this->objCurrentPost->getId() === $node->getId() &&
3400  ($this->is_moderator || $node->isActivated() || $node->isOwner($this->user->getId()))) {
3401  if (!$this->objCurrentTopic->isClosed() && in_array($this->requestAction, [
3402  'showreply',
3403  'showedit',
3404  ])) {
3405  $this->renderPostingForm($threadContentTemplate, $frm, $node, $this->requestAction);
3406  } elseif ($this->requestAction === 'censor' &&
3407  !$this->objCurrentTopic->isClosed() && $this->is_moderator) {
3408  $threadContentTemplate->setVariable('FORM', $this->getCensorshipFormHTML());
3409  }
3410  }
3411 
3412  $this->renderPostContent($threadContentTemplate, $node, $this->requestAction, $pageIndex, $postIndex);
3413  if ($doRenderDrafts && $this->selectedSorting === ilForumProperties::VIEW_TREE) {
3414  $this->renderDraftContent(
3415  $threadContentTemplate,
3416  $this->requestAction,
3417  $node,
3418  $draftsObjects[$node->getId()] ?? []
3419  );
3420  }
3421 
3422  $postIndex++;
3423  }
3424 
3425  if (
3426  $this->selectedSorting === ilForumProperties::VIEW_DATE_ASC &&
3427  $doRenderDrafts && $pageIndex === max(0, (int) (ceil($numberOfPostings / $pageSize) - 1))
3428  ) {
3429  foreach ($draftsObjects as $draft) {
3430  $referencePosting = array_values(array_filter(
3431  $subtree_nodes,
3432  static function (ilForumPost $post) use ($draft): bool {
3433  return $draft->getPostId() === $post->getId();
3434  }
3435  ))[0] ?? $firstNodeInThread;
3436 
3437  $this->renderDraftContent(
3438  $threadContentTemplate,
3439  $this->requestAction,
3440  $referencePosting,
3441  [$draft]
3442  );
3443  }
3444  }
3445 
3446  if (
3447  $firstNodeInThread instanceof ilForumPost && $doRenderDrafts &&
3448  $this->selectedSorting === ilForumProperties::VIEW_TREE
3449  ) {
3450  $this->renderDraftContent(
3451  $threadContentTemplate,
3452  $this->requestAction,
3453  $firstNodeInThread,
3454  $draftsObjects[$firstNodeInThread->getId()] ?? []
3455  );
3456  }
3457 
3458  if ($firstNodeInThread instanceof ilForumPost &&
3459  !$this->objCurrentTopic->isClosed() &&
3460  in_array($this->ctrl->getCmd(), ['createTopLevelPost', 'saveTopLevelPost', 'saveTopLevelDraft'], true) &&
3461  $this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
3462  // Important: Don't separate the following two lines (very fragile code ...)
3463  $this->objCurrentPost->setId($firstNodeInThread->getId());
3464  $form = $this->getReplyEditForm();
3465 
3466  if (in_array($this->ctrl->getCmd(), ['saveTopLevelPost', 'saveTopLevelDraft'])) {
3467  $form->setValuesByPost();
3468  }
3469  $threadContentTemplate->setVariable('BOTTOM_FORM', $form->getHTML());
3470  }
3471  } else {
3472  $threadContentTemplate->setCurrentBlock('posts_no');
3473  $threadContentTemplate->setVariable(
3474  'TXT_MSG_NO_POSTS_AVAILABLE',
3475  $this->lng->txt('forums_posts_not_available')
3476  );
3477  $threadContentTemplate->parseCurrentBlock();
3478  }
3479 
3480  $to_top_button = $this->uiFactory->button()
3481  ->standard($this->lng->txt('top_of_page'), '#frm_page_top');
3482  $bottom_toolbar->addComponent($to_top_button);
3483  if ($numberOfPostings > 0) {
3484  $threadContentTemplate->setVariable('TOOLBAR_BOTTOM', $bottom_toolbar->getHTML());
3485  }
3486 
3487  if ($toolbar_items !== []) {
3488  foreach ($toolbar_items as $component_index => $item) {
3489  $this->toolbar->addComponent($item);
3490  $bottom_toolbar->addComponent($item);
3491  if ($component_index === 0 && $numberOfPostings > 0) {
3492  $this->renderViewModeControl($this->selectedSorting);
3493  if ($this->selectedSorting !== ilForumProperties::VIEW_TREE) {
3494  $this->renderSortationControl($this->selectedSorting);
3495  }
3496  }
3497  }
3498  }
3499 
3500  $this->tpl->setPermanentLink(
3501  $this->object->getType(),
3502  $this->object->getRefId(),
3503  (string) $this->objCurrentTopic->getId()
3504  );
3505 
3506  $this->tpl->addOnLoadCode(
3507  <<<'EOD'
3508  document.querySelectorAll('.ilFrmPostContent img').forEach((img) => {
3509  const maxWidth = img.getAttribute('width');
3510  const maxHeight = img.getAttribute('height');
3511 
3512  if (maxWidth) {
3513  img.style.maxWidth = maxWidth + 'px';
3514  img.removeAttribute('width');
3515  }
3516 
3517  if (maxHeight) {
3518  img.style.maxHeight = maxHeight + 'px';
3519  img.removeAttribute('height');
3520  }
3521  });
3522 EOD
3523  );
3524 
3525  if ($this->selectedSorting === ilForumProperties::VIEW_TREE && ($this->selected_post_storage->get($thr_pk) > 0)) {
3526  $info = $this->getResetLimitedViewInfo();
3527  }
3528 
3529  $this->tpl->setContent(($info ?? '') . $threadContentTemplate->get() . $this->getModalActions());
3530  }
renderPostContent(ilTemplate $tpl, ilForumPost $node, string $action, int $pageIndex, int $postIndex)
static get(string $a_var)
renderSortationControl(int $currentSorting)
renderPostingForm(ilTemplate $tpl, ilForum $frm, ilForumPost $node, string $action)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
ilForumTopic $objCurrentTopic
ensureValidPageForCurrentPosting(array $subtree_nodes, array $pagedPostings, int $pageSize, ilForumPost $firstForumPost)
renderDraftContent(ilTemplate $tpl, string $action, ilForumPost $referencePosting, array $drafts)
renderViewModeControl(int $currentViewMode)
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, bool $isCatchupWriteEvents=true, $a_ext_rc=null, $a_ext_time=null)
ilToolbarGUI $toolbar
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
static _exists(int $id, bool $reference=false, ?string $type=null)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Last visited history for repository items.
static _removeUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Remove usage of mob in another container.
static getSortedDrafts(int $usrId, int $threadId, int $sorting=ilForumProperties::VIEW_DATE_ASC)
$post
Definition: ltitoken.php:46
addHeaderAction()
Add header action menu.
addItem(int $a_ref_id, string $a_link, string $a_type, string $a_title="", ?int $a_sub_obj_id=null, string $a_goto_link="")
Add an item to the stack.
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $confirmation_gui_html

string ilObjForumGUI::$confirmation_gui_html = ''
private

Definition at line 65 of file class.ilObjForumGUI.php.

◆ $content_style_domain

ILIAS Style Content Object ObjectFacade ilObjForumGUI::$content_style_domain
protected

Definition at line 79 of file class.ilObjForumGUI.php.

◆ $content_style_gui

ILIAS Style Content GUIService ilObjForumGUI::$content_style_gui
protected

Definition at line 80 of file class.ilObjForumGUI.php.

◆ $display_confirm_post_activation

bool ilObjForumGUI::$display_confirm_post_activation = false
private

Definition at line 56 of file class.ilObjForumGUI.php.

Referenced by displayConfirmPostActivation().

◆ $factory

Factory ilObjForumGUI::$factory
private

Definition at line 74 of file class.ilObjForumGUI.php.

◆ $forum_settings_gui

ilForumSettingsGUI ilObjForumGUI::$forum_settings_gui
private

Definition at line 66 of file class.ilObjForumGUI.php.

◆ $forum_thread_table_session_storage

ForumThreadTableSessionStorage ilObjForumGUI::$forum_thread_table_session_storage
private

Definition at line 83 of file class.ilObjForumGUI.php.

◆ $forumObjects

array ilObjForumGUI::$forumObjects = null
private

Definition at line 64 of file class.ilObjForumGUI.php.

Referenced by getForumObjects().

◆ $globalScreen

ILIAS GlobalScreen Services ilObjForumGUI::$globalScreen
private

Definition at line 51 of file class.ilObjForumGUI.php.

◆ $hideToolbar

bool ilObjForumGUI::$hideToolbar = false
private

Definition at line 59 of file class.ilObjForumGUI.php.

Referenced by hideToolbar().

◆ $http

ILIAS HTTP Services ilObjForumGUI::$http
private

Definition at line 61 of file class.ilObjForumGUI.php.

◆ $httpRequest

Psr Http Message ServerRequestInterface ilObjForumGUI::$httpRequest
private

Definition at line 60 of file class.ilObjForumGUI.php.

◆ $ilHelp

ilHelpGUI ilObjForumGUI::$ilHelp

Definition at line 73 of file class.ilObjForumGUI.php.

◆ $ilNavigationHistory

ilNavigationHistory ilObjForumGUI::$ilNavigationHistory

Definition at line 67 of file class.ilObjForumGUI.php.

◆ $ilObjDataCache

ilObjectDataCache ilObjForumGUI::$ilObjDataCache

Definition at line 71 of file class.ilObjForumGUI.php.

◆ $in_page_editor_style_context

readonly bool ilObjForumGUI::$in_page_editor_style_context
private

Definition at line 82 of file class.ilObjForumGUI.php.

◆ $is_moderator

bool ilObjForumGUI::$is_moderator
private

◆ $modal_collection

array ilObjForumGUI::$modal_collection = []
private

Definition at line 81 of file class.ilObjForumGUI.php.

◆ $modal_history

string ilObjForumGUI::$modal_history = ''

Definition at line 52 of file class.ilObjForumGUI.php.

Referenced by editThreadDraftObject(), and renderDraftContent().

◆ $modalActionsContainer

array ilObjForumGUI::$modalActionsContainer = []
private

Definition at line 69 of file class.ilObjForumGUI.php.

◆ $objCurrentPost

ilForumPost ilObjForumGUI::$objCurrentPost
private

Definition at line 55 of file class.ilObjForumGUI.php.

Referenced by performPostActivationObject(), and savePostObject().

◆ $objCurrentTopic

◆ $objProperties

ilForumProperties ilObjForumGUI::$objProperties

Definition at line 53 of file class.ilObjForumGUI.php.

◆ $rbac

ILIAS DI RBACServices ilObjForumGUI::$rbac

Definition at line 72 of file class.ilObjForumGUI.php.

◆ $renderer

Renderer ilObjForumGUI::$renderer
private

Definition at line 75 of file class.ilObjForumGUI.php.

◆ $replyEditForm

ilPropertyFormGUI ilObjForumGUI::$replyEditForm = null
private

Definition at line 58 of file class.ilObjForumGUI.php.

Referenced by getReplyEditForm().

◆ $requestAction

string ilObjForumGUI::$requestAction
private

Definition at line 68 of file class.ilObjForumGUI.php.

◆ $selected_post_storage

ilForumThreadSettingsSessionStorage ilObjForumGUI::$selected_post_storage
private

Definition at line 78 of file class.ilObjForumGUI.php.

◆ $selectedSorting

int ilObjForumGUI::$selectedSorting
private

Definition at line 77 of file class.ilObjForumGUI.php.

Referenced by checkUsersViewMode(), and viewThreadObject().

◆ $sortationOptions

array ilObjForumGUI::$sortationOptions
private
Initial value:
= [
ilForumProperties::VIEW_DATE_ASC => 'ascending_order'

Definition at line 46 of file class.ilObjForumGUI.php.

Referenced by renderSortationControl().

◆ $uiFactory

Factory ilObjForumGUI::$uiFactory
private

Definition at line 62 of file class.ilObjForumGUI.php.

Referenced by eventsFormBuilder().

◆ $uiRenderer

Renderer ilObjForumGUI::$uiRenderer
private

Definition at line 63 of file class.ilObjForumGUI.php.

◆ $viewModeOptions

array ilObjForumGUI::$viewModeOptions
private
Initial value:
= [
ilForumProperties::VIEW_TREE => 'sort_by_posts'

Definition at line 41 of file class.ilObjForumGUI.php.


The documentation for this class was generated from the following file: