ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilObjForumGUI Class Reference

@ilCtrl_Calls ilObjForumGUI: ilPermissionGUI, ilForumExportGUI, ilInfoScreenGUI @ilCtrl_Calls ilObjForumGUI: ilColumnGUI, ILIAS\User\Profile\PublicProfileGUI, ilForumModeratorsGUI, ilRepositoryObjectSearchGUI @ilCtrl_Calls ilObjForumGUI: ilObjectCopyGUI, ilExportGUI, ilCommonActionDispatcherGUI, ilRatingGUI @ilCtrl_Calls ilObjForumGUI: ilForumSettingsGUI, ilContainerNewsSettingsGUI, ilLearningProgressGUI, ilForumPageGUI @ilCtrl_Calls 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 ()
 
 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 ()
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 

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)
 Add custom fields to update form. More...
 
 getEditFormCustomValues (array &$a_values)
 Add values to custom edit fields. More...
 
 updateCustom (ilPropertyFormGUI $form)
 Insert custom update form values into object. More...
 
 renderPostContent (ilTemplate $tpl, ilForumPost $node, string $action, int $pageIndex, int $postIndex)
 
 selectPostObject ()
 
 afterSave (ilObject $new_object)
 
 getTabs ()
 @abstract overwrite in derived GUI class of your object type More...
 
 confirmDeleteThreadDraftsObject ()
 
 toggleThreadNotificationObject ()
 
 toggleStickinessObject ()
 
 deleteThreadDraftsObject ()
 
 publishThreadDraftObject ()
 
 addThreadObject ()
 
 addEmptyThreadObject ()
 
 enableForumNotificationObject ()
 
 disableForumNotificationObject ()
 
 addLocatorItems ()
 should be overwritten to add object specific items (repository items are preloaded) More...
 
 infoScreen ()
 
 markPostUnreadObject ()
 
 markPostReadObject ()
 
 initHeaderAction (?string $sub_type=null, ?int $sub_id=null)
 Add header action menu. More...
 
 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 ()
 @abstract 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
 
GlobalHttpState $http
 
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
 
CustomIconFactory $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)
 
 denyUnlessGranted (BindingDecision $decision)
 
 postingAttachmentDelivery (ilFileDataForumInterface $storage)
 
 draftAttachmentDelivery (ilFileDataForumInterface $storage)
 
 auditedDelivery (AddressedAttachmentDelivery $delivery)
 
 deliverZipFileOrRedirect (AttachmentDelivery $delivery)
 
 decorateWithAutosave (ilPropertyFormGUI $form)
 
 isTopLevelReplyCommand ()
 
 renderThreadOverview (ilForum $frm, ?ForumDto $frm_object)
 
 getSortationViewControl (int $offset, ThreadSortation $effective_sortation)
 
 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 ()
 
 preloadPostingFileResources (array $postings, array $draftsObjects)
 

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
 
Factory $uiFactory
 
Renderer $uiRenderer
 
array $forumObjects = null
 
string $confirmation_gui_html = ''
 
ilForumSettingsGUI $forum_settings_gui
 
string $requestAction
 
array $modalActionsContainer = []
 
Factory $factory
 
Renderer $renderer
 
IRSS $irss
 
int $selectedSorting
 
ilForumThreadSettingsSessionStorage $selected_post_storage
 
readonly OwnershipRepository $attachment_ownership
 
readonly PostingPlacementRepository $posting_placement
 
readonly DraftPlacementRepository $draft_placement
 
readonly ilLogger $attachment_logger
 
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 108 of file class.ilObjForumGUI.php.

109 {
110 global $DIC;
111
112 $this->httpRequest = $DIC->http()->request();
113
114 $this->uiFactory = $DIC->ui()->factory();
115 $this->uiRenderer = $DIC->ui()->renderer();
116 $this->globalScreen = $DIC->globalScreen();
117
118 $this->irss = $DIC->resourceStorage();
119
120 $this->ilObjDataCache = $DIC['ilObjDataCache'];
121 $this->ilNavigationHistory = $DIC['ilNavigationHistory'];
122 $this->ilHelp = $DIC['ilHelp'];
123 $this->rbac = $DIC->rbac();
124 $this->factory = $DIC->ui()->factory();
125 $this->renderer = $DIC->ui()->renderer();
126
127 $this->type = 'frm';
129 $this->ctrl->saveParameter($this, ['ref_id']);
130 $this->tpl->addJavaScript('assets/js/Basic.js');
131
132 $this->lng->loadLanguageModule('forum');
133 $this->lng->loadLanguageModule('content');
134
135 $ref_id = $this->retrieveIntOrZeroFrom($this->http->wrapper()->query(), 'ref_id');
136
137 $this->objProperties = ilForumProperties::getInstance($this->ilObjDataCache->lookupObjId($ref_id));
138 $this->is_moderator = $this->access->checkAccess('moderate_frm', '', $ref_id);
139
140 $this->objCurrentTopic = new ilForumTopic($this->retrieveThrPk(), $this->is_moderator);
141 $this->requestAction = (string) ($this->httpRequest->getQueryParams()['action'] ?? '');
142 $this->attachment_ownership = new DbOwnershipRepository($DIC->database());
143 $placement = new DbPlacementRepository($DIC->database());
144 $this->posting_placement = $placement;
145 $this->draft_placement = $placement;
146 $this->attachment_logger = $DIC->logger()->root();
147 $cs = $DIC->contentStyle();
148 $this->content_style_gui = $cs->gui();
149 if (is_object($this->object)) {
150 $this->content_style_domain = $cs->domain()->styleForRefId($this->object->getRefId());
151 }
152 $this->in_page_editor_style_context = $this->http->wrapper()->query()->has('page_editor_style');
153 $this->ctrl->saveParameterByClass(ilObjectContentStyleSettingsGUI::class, 'page_editor_style');
154
155 $this->initSessionStorage();
156 $this->forum_thread_table_session_storage = new ForumThreadTableSessionStorage(
157 $this->ref_id,
158 $this->is_moderator
159 );
160 }
renderer()
factory()
static getInstance(int $a_obj_id=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Last visited history for repository items.
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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().

+ 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 1801 of file class.ilObjForumGUI.php.

1801 : void
1802 {
1803 global $DIC;
1804 $main_tpl = $DIC->ui()->mainTemplate();
1805
1806 $ilAccess = $DIC->access();
1807 $lng = $DIC->language();
1808 $ilErr = $DIC['ilErr'];
1809
1810 $a_target = is_numeric($a_target) ? (int) $a_target : 0;
1811 $a_thread = is_numeric($a_thread) ? (int) $a_thread : 0;
1812 if ($ilAccess->checkAccess('read', '', $a_target)) {
1813 if ($a_thread !== 0) {
1814 $objTopic = new ilForumTopic($a_thread);
1815 if ($objTopic->getFrmObjId() &&
1816 $objTopic->getFrmObjId() !== ilObject::_lookupObjectId($a_target)) {
1817 $ref_ids = ilObject::_getAllReferences($objTopic->getFrmObjId());
1818 foreach ($ref_ids as $ref_id) {
1819 if ($ilAccess->checkAccess('read', '', $ref_id)) {
1820 $new_ref_id = $ref_id;
1821 break;
1822 }
1823 }
1824
1825 if (isset($new_ref_id) && $new_ref_id !== $a_target) {
1826 $DIC->ctrl()->redirectToURL(
1827 ILIAS_HTTP_PATH . '/goto.php?target=frm_' . $new_ref_id . '_' . $a_thread . '_' . $a_posting
1828 );
1829 }
1830 }
1831
1832 $DIC->ctrl()->setParameterByClass(self::class, 'ref_id', (string) ((int) $a_target));
1833 if (is_numeric($a_thread)) {
1834 $DIC->ctrl()->setParameterByClass(self::class, 'thr_pk', (string) ((int) $a_thread));
1835 }
1836 if (is_numeric($a_posting)) {
1837 $DIC->ctrl()->setParameterByClass(self::class, 'pos_pk', (string) ((int) $a_posting));
1838 }
1839 $DIC->ctrl()->redirectByClass(
1840 [ilRepositoryGUI::class, self::class],
1841 'viewThread',
1842 is_numeric($a_posting) ? (string) ((int) $a_posting) : ''
1843 );
1844 } else {
1845 $DIC->ctrl()->setParameterByClass(self::class, 'ref_id', $a_target);
1846 $DIC->ctrl()->redirectByClass([ilRepositoryGUI::class, self::class,], '');
1847 $DIC->http()->close();
1848 }
1849 } elseif ($ilAccess->checkAccess('visible', '', $a_target)) {
1850 $DIC->ctrl()->setParameterByClass(ilInfoScreenGUI::class, 'ref_id', $a_target);
1851 $DIC->ctrl()->redirectByClass(
1852 [
1853 ilRepositoryGUI::class,
1854 self::class,
1855 ilInfoScreenGUI::class
1856 ],
1857 'showSummary'
1858 );
1859 } elseif ($ilAccess->checkAccess('read', '', ROOT_FOLDER_ID)) {
1860 $main_tpl->setOnScreenMessage('info', sprintf(
1861 $lng->txt('msg_no_perm_read_item'),
1863 ), true);
1864 $DIC->http()->close();
1865 }
1866
1867 $ilErr->raiseError($lng->txt('msg_no_perm_read'), $ilErr->FATAL);
1868 }
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
ilLanguage $lng
static _lookupObjectId(int $ref_id)
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
const ROOT_FOLDER_ID
Definition: constants.php:32

References $DIC, $lng, ilObject\_getAllReferences(), ilObject\_lookupObjectId(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ILIAS\Repository\int(), and ROOT_FOLDER_ID.

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addActivationFormModal()

ilObjForumGUI::addActivationFormModal ( ilForumPost  $node)

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

2272 {
2273 $form = new ilPropertyFormGUI();
2274 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
2275 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
2276 $this->ctrl->setParameter(
2277 $this,
2278 'orderby',
2279 $this->getOrderByParam()
2280 );
2281 $form->setFormAction($this->ctrl->getFormAction($this, 'performPostActivation'));
2282 $this->ctrl->clearParameters($this);
2283 $form->setId('frm_activate_post_' . $node->getId());
2284 $form_id = $form->getId();
2285 $message = $this->uiFactory->messageBox()->confirmation($this->lng->txt('activate_post_txt'));
2286 $submitBtn = $this->uiFactory->button()->primary(
2287 $this->lng->txt('activate_only_current'),
2288 '#'
2289 )->withOnLoadCode(
2290 static function (string $id) use ($form_id): string {
2291 return "
2292 (function () {
2293 const button = document.getElementById('$id');
2294 if (!button) return;
2295
2296 const form = document.getElementById('form_$form_id');
2297 if (!form) return;
2298
2299 button.addEventListener('click', (event) => {
2300 event.preventDefault();
2301 form.submit();
2302 }, true);
2303 }());
2304 ";
2305 }
2306 );
2307 $modal = $this->uiFactory->modal()->roundtrip(
2308 $this->lng->txt('activate_only_current'),
2309 [$this->uiFactory->legacy()->content($form->getHTML()), $message]
2310 )->withActionButtons([$submitBtn]);
2311 $action_button = $this->uiFactory->button()->standard($this->lng->txt('activate_post'), '#')->withOnClick(
2312 $modal->getShowSignal()
2313 );
2314 $this->modalActionsContainer[] = $modal;
2315 $this->ctrl->clearParameters($this);
2316
2317 return $action_button;
2318 }
This class represents a property form user interface.
This describes a standard button.
Definition: Standard.php:27

References $id, $message, ILIAS\Repository\ctrl(), ilForumPost\getId(), ilForumPost\getThreadId(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ addCensorshipObject()

ilObjForumGUI::addCensorshipObject ( )
private

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

2107 : void
2108 {
2109 $this->handleCensorship();
2110 }
handleCensorship(bool $wasRevoked=false)

◆ addDraftButtonIfDraftsExists()

ilObjForumGUI::addDraftButtonIfDraftsExists ( string  $cmd)
private

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

1075 : void
1076 {
1078 $this->user->getId(),
1079 ilObjForum::lookupForumIdByObjId($this->object->getId())
1080 );
1081 if ($drafts === []) {
1082 return;
1083 }
1084
1085 $table = new ForumDraftsTable(
1086 $this->object,
1087 $this->ui_factory,
1088 $this->httpRequest,
1089 $this->lng,
1090 $cmd,
1091 $this->ctrl,
1092 new DataFactory(),
1093 $this->user,
1094 $this->access->checkAccess('add_thread', '', $this->object->getRefId()),
1095 $this
1096 );
1097 $threadsTemplate = new ilTemplate(
1098 'tpl.forums_threads_liste.html',
1099 true,
1100 true,
1101 'components/ILIAS/Forum'
1102 );
1103 $threadsTemplate->setVariable('THREADS_DRAFTS_TABLE', $this->uiRenderer->render($table->getComponent()));
1104
1105 $draft_modal = $this->factory->modal()->roundtrip(
1106 $this->lng->txt('drafts'),
1107 [$this->factory->legacy()->content($threadsTemplate->get())]
1108 );
1109 $this->modal_collection[] = $draft_modal;
1110 $edit_title = $this->factory->button()->standard($this->lng->txt('drafts'), '#')->withOnClick(
1111 $draft_modal->getShowSignal()
1112 );
1113 $this->toolbar->addComponent($edit_title);
1114 }
static getThreadDraftData(int $post_author_id, int $forum_id)
static lookupForumIdByObjId(int $obj_id)
special template class to simplify handling of ITX/PEAR

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

+ Here is the call graph for this function:

◆ addEmptyThreadObject()

ilObjForumGUI::addEmptyThreadObject ( )
protected

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

4359 : void
4360 {
4361 $this->createEmptyThread();
4362 }
createEmptyThread()
Refactored thread creation to method, refactoring to a separate class should be done in next refactor...

◆ addLocatorItems()

ilObjForumGUI::addLocatorItems ( )
protected

should be overwritten to add object specific items (repository items are preloaded)

Reimplemented from ilObjectGUI.

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

4419 : void
4420 {
4421 if ($this->object instanceof ilObjForum) {
4422 $this->locator->addItem(
4423 $this->object->getTitle(),
4424 $this->ctrl->getLinkTarget($this),
4425 '',
4426 $this->object->getRefId()
4427 );
4428 }
4429 }
Class ilObjForum.

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

+ Here is the call graph for this function:

◆ addThreadObject()

ilObjForumGUI::addThreadObject ( )
protected

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

4342 : void
4343 {
4344 $draft = new ilForumPostDraft();
4347 $this->checkDraftAccess($draft);
4348 $this->denyUnlessGranted(
4349 (new DraftBindingGuard($this->draft_placement, $this->user->getId()))->decideUnboundThread(
4350 $this->object->getId(),
4351 $draft->getDraftId()
4352 )
4353 );
4354 }
4355
4356 $this->createThread($draft);
4357 }
Binds a draft addressed by a publish or save action to the forum object of the current request and to...
Class ilForumPostDraft.
static newInstanceByDraftId(int $draft_id)
checkDraftAccess(int|ilForumPostDraft $draft)
createThread(ilForumPostDraft $draft, bool $createFromDraft=false)
Refactored thread creation to method, refactoring to a separate class should be done in next refactor...
retrieveDraftId(bool $from_post=false)
denyUnlessGranted(BindingDecision $decision)

References ilForumPostDraft\isSavePostDraftAllowed(), ilForumPostDraft\newInstanceByDraftId(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ afterSave()

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

Reimplemented from ilObjectGUI.

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

1616 : void
1617 {
1618 $this->tpl->setOnScreenMessage('success', $this->lng->txt('frm_added'), true);
1619 $this->ctrl->setParameter($this, 'ref_id', $new_object->getRefId());
1620 $this->ctrl->redirect($this, 'createThread');
1621 }

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

+ Here is the call graph for this function:

◆ askForPostActivationObject()

ilObjForumGUI::askForPostActivationObject ( )

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

2161 : void
2162 {
2163 if (!$this->is_moderator) {
2164 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2165 }
2166
2167 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2168 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2169 }
2170
2172
2173 $this->viewThreadObject();
2174 }
setDisplayConfirmPostActivation(bool $status=false)

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

+ Here is the call graph for this function:

◆ auditedDelivery()

ilObjForumGUI::auditedDelivery ( AddressedAttachmentDelivery  $delivery)
private

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

286 {
287 return new LoggedAttachmentDelivery($delivery, $this->attachment_logger, $this->user->getId());
288 }
Records denied attachment requests, so repeated attempts to address a container through a foreign for...
The delivery capability of the forum file storage, segregated from its management capabilities (uploa...

References ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ autosaveDraftAsyncObject()

ilObjForumGUI::autosaveDraftAsyncObject ( )
protected

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

5469 : void
5470 {
5471 if ($this->requestAction !== 'ready_showreply' &&
5473 $this->access->checkAccess('read', '', $this->object->getRefId()) &&
5474 $this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
5475 $action = new ilForumAutoSaveAsyncDraftAction(
5476 $this->user,
5477 $this->getReplyEditForm(),
5478 $this->objProperties,
5479 $this->objCurrentTopic,
5480 $this->objCurrentPost,
5481 fn(string $message): string => $this->handleFormInput($message),
5482 $this->retrieveDraftId(),
5483 ilObjForum::lookupForumIdByRefId($this->ref_id),
5484 ilUtil::stripSlashes($this->requestAction)
5485 );
5486
5487 $this->http->saveResponse($this->http->response()->withBody(
5488 \ILIAS\Filesystem\Stream\Streams::ofString(json_encode(
5489 $action->executeAndGetResponseObject(),
5490 JSON_THROW_ON_ERROR
5491 ))
5492 ));
5493 }
5494
5495 $this->http->sendResponse();
5496 $this->http->close();
5497 }
handleFormInput(string $a_text, bool $a_stripslashes=true)
static lookupForumIdByRefId(int $ref_id)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

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

+ Here is the call graph for this function:

◆ autosaveThreadDraftAsyncObject()

ilObjForumGUI::autosaveThreadDraftAsyncObject ( )
protected

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

5499 : void
5500 {
5501 if ($this->requestAction !== 'ready_showreply' &&
5503 $this->access->checkAccess('read', '', $this->object->getRefId()) &&
5504 $this->access->checkAccess('add_thread', '', $this->object->getRefId())) {
5505 $action = new ilForumAutoSaveAsyncDraftAction(
5506 $this->user,
5507 $this->buildThreadForm(),
5508 $this->objProperties,
5509 $this->objCurrentTopic,
5510 $this->objCurrentPost,
5511 fn(string $message): string => $this->handleFormInput($message, false),
5512 $this->retrieveDraftId(),
5513 ilObjForum::lookupForumIdByRefId($this->ref_id),
5514 ilUtil::stripSlashes($this->requestAction)
5515 );
5516
5517 $this->http->saveResponse($this->http->response()->withBody(
5518 \ILIAS\Filesystem\Stream\Streams::ofString(json_encode(
5519 $action->executeAndGetResponseObject(),
5520 JSON_THROW_ON_ERROR
5521 ))
5522 ));
5523 }
5524
5525 $this->http->sendResponse();
5526 $this->http->close();
5527 }
buildThreadForm(bool $isDraft=false)

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

+ Here is the call graph for this function:

◆ buildMinimalThreadForm()

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

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

4057 {
4058 $draftId = (int) ($this->httpRequest->getQueryParams()['draft_id'] ?? 0);
4059 $allowNotification = !$this->objProperties->isAnonymized() && !$this->user->isAnonymous();
4060
4061 $mail = new ilMail($this->user->getId());
4062 if (!$this->rbac->system()->checkAccess('internal_mail', $mail->getMailObjectReferenceId())) {
4063 $allowNotification = false;
4064 }
4065
4066 $minimal_form = new ilForumThreadFormGUI(
4067 $this,
4068 $this->objProperties,
4070 $allowNotification,
4071 $isDraft,
4072 $draftId
4073 );
4074
4075 $minimal_form->addInputItem(ilForumThreadFormGUI::ALIAS_INPUT);
4076 $minimal_form->addInputItem(ilForumThreadFormGUI::SUBJECT_INPUT);
4077
4078 $minimal_form->generateMinimalForm();
4079
4080 return $minimal_form;
4081 }

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

+ Here is the call graph for this function:

◆ buildThreadForm()

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

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

4025 {
4026 $draftId = (int) ($this->httpRequest->getQueryParams()['draft_id'] ?? 0);
4027 $allowNotification = !$this->objProperties->isAnonymized() && !$this->user->isAnonymous();
4028
4029 $mail = new ilMail($this->user->getId());
4030 if (!$this->rbac->system()->checkAccess('internal_mail', $mail->getMailObjectReferenceId())) {
4031 $allowNotification = false;
4032 }
4033
4034 $default_form = new ilForumThreadFormGUI(
4035 $this,
4036 $this->objProperties,
4038 $allowNotification,
4039 $isDraft,
4040 $draftId
4041 );
4042
4043 $default_form->addInputItem(ilForumThreadFormGUI::ALIAS_INPUT);
4044 $default_form->addInputItem(ilForumThreadFormGUI::SUBJECT_INPUT);
4045 $default_form->addInputItem(ilForumThreadFormGUI::MESSAGE_INPUT);
4046 $default_form->addInputItem(ilForumThreadFormGUI::FILE_UPLOAD_INPUT);
4047 $default_form->addInputItem(ilForumThreadFormGUI::ALLOW_NOTIFICATION_INPUT);
4048
4049 $default_form->generateDefaultForm();
4050
4051 $this->decorateWithAutosave($default_form);
4052
4053 return $default_form;
4054 }
decorateWithAutosave(ilPropertyFormGUI $form)

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

+ Here is the call graph for this function:

◆ cancelDraftObject()

ilObjForumGUI::cancelDraftObject ( )

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

2241 : void
2242 {
2243 $this->requestAction = '';
2244 $draft_id = $this->retrieveDraftId();
2245 if ($draft_id > 0) {
2246 $history_entry = new ilForumDraftsHistory();
2247 $history_entry->populateWithFirstAutosaveByDraftId($draft_id);
2248 $draft = ilForumPostDraft::newInstanceByDraftId($history_entry->getDraftId());
2249 if ($this->hasDraftAccess($draft)) {
2250 $draft->setPostSubject($history_entry->getPostSubject());
2251 $draft->setPostMessage($history_entry->getPostMessage());
2252
2254 $history_entry->getPostMessage(),
2256 $history_entry->getHistoryId(),
2258 $draft->getDraftId()
2259 );
2260
2261 $draft->updateDraft();
2262
2263 $history_entry->deleteHistoryByDraftIds([$draft->getDraftId()]);
2264 }
2265 }
2266
2267 $this->ctrl->clearParameters($this);
2268 $this->viewThreadObject();
2269 }
Class ilForumDraftHistory.
static moveMediaObjects(string $post_message, string $source_type, int $source_id, string $target_type, int $target_id, int $direction=0)
hasDraftAccess(int|ilForumPostDraft $draft)

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

+ Here is the call graph for this function:

◆ cancelMoveThreadsObject()

ilObjForumGUI::cancelMoveThreadsObject ( )

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

3903 : void
3904 {
3905 ilSession::set('threads2move', []);
3906 $this->ctrl->redirect($this, 'showThreads');
3907 }
static set(string $a_var, $a_val)
Set a value.

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

+ Here is the call graph for this function:

◆ cancelPostObject()

ilObjForumGUI::cancelPostObject ( )

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

2227 : void
2228 {
2229 $this->requestAction = '';
2230 $draft_id = $this->retrieveDraftId(true);
2231 if ($draft_id > 0) {
2232 $draft = ilForumPostDraft::newInstanceByDraftId($draft_id);
2233 if ($this->hasDraftAccess($draft)) {
2234 $draft->deleteDraftsByDraftIds([$draft_id]);
2235 }
2236 }
2237
2238 $this->viewThreadObject();
2239 }

References ilForumPostDraft\newInstanceByDraftId().

+ Here is the call graph for this function:

◆ checkDraftAccess()

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

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

5806 : void
5807 {
5808 $draft = is_int($draft) ? ilForumPostDraft::newInstanceByDraftId($draft) : $draft;
5809 if (!$this->hasDraftAccess($draft)) {
5810 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5811 }
5812 }

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

+ Here is the call graph for this function:

◆ checkUsersViewMode()

ilObjForumGUI::checkUsersViewMode ( )

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

3154 : void
3155 {
3156 $this->selectedSorting = $this->objProperties->getDefaultView();
3157
3158 if ($this->getObject() !== null) {
3159 $view_mode = 'viewmode_' . $this->getObject()->getId();
3160 if (in_array((int) ilSession::get($view_mode), [
3164 ], true)) {
3165 $this->selectedSorting = ilSession::get($view_mode);
3166 }
3167
3168 if (
3169 isset($this->httpRequest->getQueryParams()['viewmode']) &&
3170 (int) $this->httpRequest->getQueryParams()['viewmode'] !== $this->selectedSorting
3171 ) {
3172 $this->selectedSorting = (int) $this->httpRequest->getQueryParams()['viewmode'];
3173 }
3174
3175 if (!in_array($this->selectedSorting, [
3179 ], true)) {
3180 $this->selectedSorting = $this->objProperties->getDefaultView();
3181 }
3182
3183 ilSession::set($view_mode, $this->selectedSorting);
3184 }
3185 }
static get(string $a_var)

References ilSession\get(), ILIAS\Repository\int(), ilSession\set(), ilForumProperties\VIEW_DATE_ASC, ilForumProperties\VIEW_DATE_DESC, and ilForumProperties\VIEW_TREE.

+ Here is the call graph for this function:

◆ confirmDeleteThreadDraftsObject()

ilObjForumGUI::confirmDeleteThreadDraftsObject ( )
protected

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

1958 : void
1959 {
1960 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1961 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1962 }
1963
1964 $draft_ids = $this->http->wrapper()->query()->retrieve(
1965 'forum_drafts_delete_draft_ids',
1966 $this->refinery->byTrying([
1967 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
1968 $this->refinery->always([])
1969 ])
1970 );
1971
1972 if ($draft_ids === []) {
1973 $draft_ids = $this->http->wrapper()->query()->retrieve(
1974 'forum_drafts_delete_draft_ids',
1975 $this->refinery->byTrying([
1976 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string()),
1977 $this->refinery->always([])
1978 ])
1979 );
1980
1981 if (!isset($draft_ids[0]) || $draft_ids[0] !== 'ALL_OBJECTS') {
1982 $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_at_least_one_thread'));
1983 $this->showThreadsObject();
1984 return;
1985 }
1986
1987 $draft_ids = array_filter(array_map(
1988 static fn(array $draft): int => $draft['draft_id'] ?? 0,
1990 $this->user->getId(),
1991 ilObjForum::lookupForumIdByObjId($this->object->getId())
1992 )
1993 ));
1994 }
1995
1996 $confirmation = new ilConfirmationGUI();
1997 $confirmation->setFormAction($this->ctrl->getFormAction($this, 'deleteThreadDrafts'));
1998 $confirmation->setHeaderText($this->lng->txt('sure_delete_drafts'));
1999 $confirmation->setCancel($this->lng->txt('cancel'), 'showThreads');
2000 $confirmation->setConfirm($this->lng->txt('confirm'), 'deleteThreadDrafts');
2001 $instances = ilForumPostDraft::getDraftInstancesByUserId($this->user->getId());
2002 foreach ($draft_ids as $draftId) {
2003 if (array_key_exists($draftId, $instances)) {
2004 $confirmation->addItem('draft_ids[]', (string) $draftId, $instances[$draftId]->getPostSubject());
2005 }
2006 }
2007
2008 $this->tpl->setContent($confirmation->getHTML());
2009 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getDraftInstancesByUserId(int $user_id)

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

+ Here is the call graph for this function:

◆ confirmMergeThreadsObject()

ilObjForumGUI::confirmMergeThreadsObject ( )

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

4788 : void
4789 {
4790 if (!$this->is_moderator) {
4791 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4792 }
4793
4794 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4795 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4796 }
4797
4798 $sourceThreadId = (int) ($this->httpRequest->getQueryParams()['merge_thread_id'] ?? 0);
4799 $targetThreadIds = array_values(
4800 array_filter(array_map(intval(...), (array) ($this->httpRequest->getParsedBody()['thread_ids'] ?? [])))
4801 );
4802
4803 if ($sourceThreadId <= 0 || count($targetThreadIds) !== 1) {
4804 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
4805 $this->mergeThreadsObject();
4806 return;
4807 }
4808
4809 $targetThreadId = current($targetThreadIds);
4810 if ($sourceThreadId === $targetThreadId) {
4811 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('error_same_thread_ids'));
4812 $this->showThreadsObject();
4813 return;
4814 }
4815
4816 if (ilForumTopic::lookupForumIdByTopicId($sourceThreadId) !== ilForumTopic::lookupForumIdByTopicId($targetThreadId)) {
4817 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('not_allowed_to_merge_into_another_forum'));
4818 $this->ctrl->clearParameters($this);
4819 $this->showThreadsObject();
4820 return;
4821 }
4822
4823 if (ilForumTopic::lookupCreationDate($sourceThreadId) < ilForumTopic::lookupCreationDate($targetThreadId)) {
4824 $this->tpl->setOnScreenMessage('info', $this->lng->txt('switch_threads_for_merge'));
4825 }
4826
4827 $this->ensureThreadBelongsToForum($this->object->getId(), new ilForumTopic($sourceThreadId));
4828 $this->ensureThreadBelongsToForum($this->object->getId(), new ilForumTopic($targetThreadId));
4829
4830 $c_gui = new ilConfirmationGUI();
4831
4832 $c_gui->setFormAction($this->ctrl->getFormAction($this, 'performMergeThreads'));
4833 $c_gui->setHeaderText($this->lng->txt('frm_sure_merge_threads'));
4834 $c_gui->setCancel($this->lng->txt('cancel'), 'showThreads');
4835 $c_gui->setConfirm($this->lng->txt('confirm'), 'performMergeThreads');
4836
4837 $c_gui->addItem(
4838 'thread_ids[]',
4839 (string) $sourceThreadId,
4840 sprintf($this->lng->txt('frm_merge_src'), ilForumTopic::lookupTitle($sourceThreadId))
4841 );
4842 $c_gui->addItem(
4843 'thread_ids[]',
4844 (string) $targetThreadId,
4845 sprintf($this->lng->txt('frm_merge_target'), ilForumTopic::lookupTitle($targetThreadId))
4846 );
4847 $this->tpl->setContent($c_gui->getHTML());
4848 }
static lookupTitle(int $a_topic_id)
static lookupCreationDate(int $thread_id)
static lookupForumIdByTopicId(int $a_topic_id)
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)

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

+ 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 4248 of file class.ilObjForumGUI.php.

4248 : void
4249 {
4250 if (!$this->access->checkAccess('add_thread', '', $this->object->getRefId()) ||
4251 !$this->access->checkAccess('read', '', $this->object->getRefId())) {
4252 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4253 }
4254
4255 $frm = $this->object->Forum;
4256 $frm->setForumId($this->object->getId());
4257 $frm->setForumRefId($this->object->getRefId());
4258 $frm->setMDB2WhereCondition('top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
4259 $topicData = $frm->getOneTopic();
4260 if ($topicData === null) {
4261 $this->error->raiseError($this->lng->txt('obj_not_found'), $this->error->MESSAGE);
4262 return;
4263 }
4264
4265 $form = $this->buildThreadForm();
4266 $minimal_form = $this->buildMinimalThreadForm();
4267
4268 if ($minimal_form->checkInput()) {
4269 $userIdForDisplayPurposes = $this->user->getId();
4270 if ($this->isWritingWithPseudonymAllowed()) {
4271 $userIdForDisplayPurposes = 0;
4272 }
4273
4274 $status = true;
4275 if (
4276 ($this->objProperties->isPostActivationEnabled() && !$this->is_moderator) ||
4277 $this->objCurrentPost->isAnyParentDeactivated()
4278 ) {
4279 $status = false;
4280 }
4281
4282 $newThread = new ilForumTopic(0, true, true);
4283 $newThread->setForumId($topicData->getTopPk());
4284 $newThread->setThrAuthorId($this->user->getId());
4285 $newThread->setDisplayUserId($userIdForDisplayPurposes);
4286 $newThread->setSubject($this->handleFormInput($minimal_form->getInput('subject'), false));
4287 $newThread->setUserAlias(ilForumUtil::getPublicUserAlias(
4288 $minimal_form->getInput('alias'),
4289 $this->objProperties->isAnonymized()
4290 ));
4291
4292 $frm->generateThread(
4293 $newThread,
4294 '',
4295 false,
4296 false, // #19980
4297 $status,
4298 false
4299 );
4300
4301 $frm->setDbTable('frm_data');
4302 $frm->setMDB2WhereCondition('top_pk = %s ', ['integer'], [$topicData->getTopPk()]);
4303 $frm->updateVisits($topicData->getTopPk());
4304
4305 $this->tpl->setOnScreenMessage('success', $this->lng->txt('forums_thread_new_entry'), true);
4306 $this->ctrl->redirect($this);
4307 }
4308
4309 $form->setValuesByPost();
4310
4311 if (!$this->objProperties->isAnonymized()) {
4312 $form->getItemByPostVar('alias')->setValue($this->user->getLogin());
4313 }
4314
4315 $accordion = new ilAccordionGUI();
4316 $accordion->setId('acc_' . $this->obj_id);
4317 $accordion->setBehaviour(ilAccordionGUI::FIRST_OPEN);
4318 $accordion->addItem($this->lng->txt('new_thread_with_post'), $form->getHTML());
4319 $accordion->addItem($this->lng->txt('empty_thread'), $minimal_form->getHTML());
4320
4321 $this->tpl->setContent($accordion->getHTML());
4322 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getPublicUserAlias(string $user_alias, bool $is_anonymized)
buildMinimalThreadForm(bool $isDraft=false)

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilAccordionGUI\FIRST_OPEN, ilForumUtil\getPublicUserAlias(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ILIAS\Repository\user().

+ Here is the call 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 4111 of file class.ilObjForumGUI.php.

4111 : void
4112 {
4113 if (!$this->access->checkAccess('add_thread', '', $this->object->getRefId()) ||
4114 !$this->access->checkAccess('read', '', $this->object->getRefId())) {
4115 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4116 }
4117
4118 $frm = $this->object->Forum;
4119 $frm->setForumId($this->object->getId());
4120 $frm->setForumRefId($this->object->getRefId());
4121 $frm->setMDB2WhereCondition('top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
4122 $topicData = $frm->getOneTopic();
4123 if ($topicData === null) {
4124 $this->error->raiseError($this->lng->txt('obj_not_found'), $this->error->MESSAGE);
4125 return;
4126 }
4127
4128 $form = $this->buildThreadForm($createFromDraft);
4129 $minimal_form = $this->buildMinimalThreadForm($createFromDraft);
4130
4131 if ($form->checkInput()) {
4132 $userIdForDisplayPurposes = $this->user->getId();
4133 if ($this->isWritingWithPseudonymAllowed()) {
4134 $userIdForDisplayPurposes = 0;
4135 }
4136
4137 $status = true;
4138 if (
4139 ($this->objProperties->isPostActivationEnabled() && !$this->is_moderator) ||
4140 $this->objCurrentPost->isAnyParentDeactivated()
4141 ) {
4142 $status = false;
4143 }
4144
4145 if ($createFromDraft) {
4146 $newThread = new ilForumTopic(0, true, true);
4147 $newThread->setForumId($topicData->getTopPk());
4148 $newThread->setThrAuthorId($draft->getPostAuthorId());
4149 $newThread->setDisplayUserId($draft->getPostDisplayUserId());
4150 $newThread->setSubject($this->handleFormInput($form->getInput('subject'), false));
4151 $newThread->setUserAlias($draft->getPostUserAlias());
4152
4153 $newPost = $frm->generateThread(
4154 $newThread,
4155 ilRTE::_replaceMediaObjectImageSrc($form->getInput('message')),
4156 $draft->isNotificationEnabled() && !$this->user->isAnonymous(),
4157 $draft->isPostNotificationEnabled() && !$this->user->isAnonymous(),
4158 $status
4159 );
4160 } else {
4161 $newThread = new ilForumTopic(0, true, true);
4162 $newThread->setForumId($topicData->getTopPk());
4163 $newThread->setThrAuthorId($this->user->getId());
4164 $newThread->setDisplayUserId($userIdForDisplayPurposes);
4165 $newThread->setSubject($this->handleFormInput($form->getInput('subject'), false));
4166 $newThread->setUserAlias(ilForumUtil::getPublicUserAlias(
4167 $form->getInput('alias'),
4168 $this->objProperties->isAnonymized()
4169 ));
4170
4171 $newPost = $frm->generateThread(
4172 $newThread,
4173 ilRTE::_replaceMediaObjectImageSrc($form->getInput('message')),
4174 $form->getItemByPostVar('notify') && $form->getInput('notify') && !$this->user->isAnonymous(),
4175 false, // #19980
4176 $status
4177 );
4178 }
4179
4180 $post_obj = new ilForumPost($newPost);
4181 if ($draft->getRCID() > 0) {
4182 $post_obj->setRCID($draft->getRCID());
4183 $post_obj->update();
4184 }
4185
4186 if ($this->objProperties->isFileUploadAllowed()) {
4187 $file = $_FILES['userfile'];
4188 if (is_array($file) && !empty($file)) {
4189 $fileData = new ilFileDataForum($this->object->getId(), $newPost);
4190 $fileData->storeUploadedFiles();
4191 }
4192 }
4193
4194 $frm->setDbTable('frm_data');
4195 $frm->setMDB2WhereCondition('top_pk = %s ', ['integer'], [$topicData->getTopPk()]);
4196 $frm->updateVisits($topicData->getTopPk());
4197
4198 if ($createFromDraft) {
4199 $mediaObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
4200 } else {
4201 $mediaObjects = ilRTE::_getMediaObjects($form->getInput('message'));
4202 }
4203 foreach ($mediaObjects as $mob) {
4204 if (ilObjMediaObject::_exists($mob)) {
4205 ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
4206 ilObjMediaObject::_saveUsage($mob, 'frm:html', $newPost);
4207 }
4208 }
4209
4210 if ($draft->getDraftId() > 0) {
4211 $draftHistory = new ilForumDraftsHistory();
4212 $draftHistory->deleteHistoryByDraftIds([$draft->getDraftId()]);
4213 $draft->deleteDraft();
4214 }
4215
4216 $GLOBALS['ilAppEventHandler']->raise(
4217 'components/ILIAS/Forum',
4218 'createdPost',
4219 [
4220 'object' => $this->object,
4221 'ref_id' => $this->object->getRefId(),
4222 'post' => $post_obj,
4223 'notify_moderators' => !$status
4224 ]
4225 );
4226
4227 $this->tpl->setOnScreenMessage('success', $this->lng->txt('forums_thread_new_entry'), true);
4228 $this->ctrl->redirect($this);
4229 }
4230
4231 $form->setValuesByPost();
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 }
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
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 _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.
static _getMobsOfObject(string $a_type, int $a_id, int|false $a_usage_hist_nr=0, string $a_lang="-")
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.
$GLOBALS["DIC"]
Definition: wac.php:66

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

+ Here is the call graph for this function:

◆ createThreadObject()

ilObjForumGUI::createThreadObject ( )
private

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

4083 : void
4084 {
4085 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4086 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4087 }
4088
4089 if (!$this->access->checkAccess('add_thread', '', $this->object->getRefId())) {
4090 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4091 }
4092
4093 $tpl = new ilTemplate('tpl.create_thread_form.html', true, true, 'components/ILIAS/Forum');
4094
4095 $accordion = new ilAccordionGUI();
4096 $accordion->setId('acc_' . $this->obj_id);
4097 $accordion->setBehaviour(ilAccordionGUI::FIRST_OPEN);
4098
4099 $accordion->addItem($this->lng->txt('new_thread_with_post'), $this->buildThreadForm()->getHTML());
4100 $accordion->addItem($this->lng->txt('empty_thread'), $this->buildMinimalThreadForm()->getHTML());
4101
4102 $tpl->setVariable('CREATE_FORM', $accordion->getHTML());
4104
4105 $this->tpl->setContent($tpl->get());
4106 }
ilGlobalTemplateInterface $tpl
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.

References ILIAS\News\Common\Table\$tpl, ILIAS\Repository\access(), ilAccordionGUI\FIRST_OPEN, ILIAS\UICore\GlobalTemplate\get(), ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), and ILIAS\UICore\GlobalTemplate\setVariable().

+ Here is the call graph for this function:

◆ createTopLevelPostObject()

ilObjForumGUI::createTopLevelPostObject ( )

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

2618 : void
2619 {
2620 $draft_obj = null;
2621 $draft_id = $this->retrieveDraftId();
2622
2623 if ($draft_id > 0 && !$this->user->isAnonymous()
2625 $draft_obj = new ilForumPostDraft(
2626 $this->user->getId(),
2627 $this->objCurrentPost->getId(),
2628 $draft_id
2629 );
2630 }
2631
2632 if ($draft_obj instanceof ilForumPostDraft && $draft_obj->getDraftId() > 0) {
2633 $this->ctrl->setParameter($this, 'action', 'editdraft');
2634 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2635 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
2636 $this->ctrl->setParameter($this, 'draft_id', $draft_obj->getDraftId());
2637 $this->ctrl->setParameter($this, 'page', 0);
2638 $this->ctrl->setParameter(
2639 $this,
2640 'orderby',
2641 $this->getOrderByParam()
2642 );
2643 $this->ctrl->redirect($this, 'editDraft');
2644 } else {
2645 $this->viewThreadObject();
2646 }
2647 }

References ILIAS\Repository\ctrl(), ilForumPostDraft\getDraftId(), ilForumPostDraft\isSavePostDraftAllowed(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ decorateWithAutosave()

ilObjForumGUI::decorateWithAutosave ( ilPropertyFormGUI  $form)
private

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

301 : void
302 {
305
306 $this->tpl->addJavaScript('assets/js/autosave_forum.js');
307 $autosave_cmd = 'autosaveDraftAsync';
308 if ($this->objCurrentPost->getId() === 0 && $this->objCurrentPost->getThreadId() === 0) {
309 $autosave_cmd = 'autosaveThreadDraftAsync';
310 }
311 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
312 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
313 $this->ctrl->setParameter($this, 'draft_id', $this->retrieveDraftId());
314 $this->ctrl->setParameter($this, 'action', ilUtil::stripSlashes($this->requestAction));
315 $this->tpl->addOnLoadCode(
316 "il.Language.setLangVar('saving', " . json_encode($this->lng->txt('saving'), JSON_THROW_ON_ERROR) . ');'
317 );
318
319 $this->tpl->addOnLoadCode('il.ForumDraftsAutosave.init(' . json_encode([
320 'loadingImgSrc' => ilUtil::getImagePath('media/loader.svg'),
321 'draftId' => $this->retrieveDraftId(),
322 'interval' => $interval * 1000,
323 'url' => $this->ctrl->getFormAction($this, $autosave_cmd, '', true),
324 'selectors' => [
325 'form' => '#form_' . $form->getId()
326 ]
327 ], JSON_THROW_ON_ERROR) . ');');
328 }
329 }
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

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

+ Here is the call graph for this function:

◆ deleteMobsOfDraft()

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

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

5421 : void
5422 {
5423 $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm~d:html', $draft_id);
5424 $curMediaObjects = ilRTE::_getMediaObjects($message);
5425 foreach ($oldMediaObjects as $oldMob) {
5426 $found = false;
5427 foreach ($curMediaObjects as $curMob) {
5428 if ($oldMob === $curMob) {
5429 $found = true;
5430 break;
5431 }
5432 }
5433 if (!$found && ilObjMediaObject::_exists($oldMob)) {
5434 ilObjMediaObject::_removeUsage($oldMob, 'frm~d:html', $draft_id);
5435 $mob_obj = new ilObjMediaObject($oldMob);
5436 $mob_obj->delete();
5437 }
5438 }
5439 }

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

+ Here is the call graph for this function:

◆ deletePostingDraftObject()

ilObjForumGUI::deletePostingDraftObject ( )
private

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

2097 : void
2098 {
2099 $this->deleteSelectedDraft();
2100 }

◆ deletePostingObject()

ilObjForumGUI::deletePostingObject ( )
private

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

2059 : void
2060 {
2061 if (
2062 !$this->user->isAnonymous() &&
2063 !$this->objCurrentTopic->isClosed() && (
2064 $this->is_moderator ||
2065 ($this->objCurrentPost->isOwner($this->user->getId()) && !$this->objCurrentPost->hasReplies())
2066 )
2067 ) {
2068 $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentPost->getThread());
2069
2070 $oForumObjects = $this->getForumObjects();
2071 $forumObj = $oForumObjects['forumObj'];
2072
2073 $frm = new ilForum();
2074 $frm->setForumId($forumObj->getId());
2075 $frm->setForumRefId($forumObj->getRefId());
2076 $dead_thr = $frm->deletePost($this->objCurrentPost->getId());
2077
2078 // if complete thread was deleted ...
2079 if ($dead_thr === $this->objCurrentTopic->getId()) {
2080 $frm->setMDB2WhereCondition('top_frm_fk = %s ', ['integer'], [$forumObj->getId()]);
2081 $topicData = $frm->getOneTopic();
2082 $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_post_deleted'), true);
2083 if ($topicData === null || $topicData->getTopNumThreads() > 0) {
2084 $this->ctrl->redirect($this, 'showThreads');
2085 } else {
2086 $this->ctrl->redirect($this, 'createThread');
2087 }
2088 }
2089 $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_post_deleted'), true);
2090 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
2091 $this->ctrl->redirect($this, 'viewThread');
2092 }
2093
2094 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2095 }
Class Forum core functions for forum.

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

+ Here is the call graph for this function:

◆ deleteSelectedDraft()

ilObjForumGUI::deleteSelectedDraft ( )
protected

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

5441 : void
5442 {
5443 $draft = new ilForumPostDraft($this->user->getId(), $this->objCurrentPost->getId(), $this->retrieveDraftId());
5444 $this->checkDraftAccess($draft);
5445
5446 $this->deleteMobsOfDraft($draft->getDraftId(), $draft->getPostMessage());
5447
5448 $objFileDataForumDrafts = new ilFileDataForumDrafts($this->object->getId());
5449 $objFileDataForumDrafts->delete([$draft->getDraftId()]);
5450
5451 $GLOBALS['ilAppEventHandler']->raise(
5452 'components/ILIAS/Forum',
5453 'deletedDraft',
5454 [
5455 'draftObj' => $draft,
5456 'obj_id' => $this->object->getId(),
5457 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5458 ]
5459 );
5460 $draft->deleteDraft();
5461
5462 $this->tpl->setOnScreenMessage('success', $this->lng->txt('delete_draft_successfully'), true);
5463 $this->ctrl->clearParameters($this);
5464 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
5465 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
5466 $this->ctrl->redirect($this, 'viewThread');
5467 }
deleteMobsOfDraft(int $draft_id, string $message)

References $GLOBALS, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ deleteThreadDraftsObject()

ilObjForumGUI::deleteThreadDraftsObject ( )
protected

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

3982 : void
3983 {
3984 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3985 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3986 }
3987
3988 $draftIds = array_filter((array) ($this->httpRequest->getParsedBody()['draft_ids'] ?? []));
3989
3990 $instances = ilForumPostDraft::getDraftInstancesByUserId($this->user->getId());
3991 $checkedDraftIds = [];
3992 foreach ($draftIds as $draftId) {
3993 if (array_key_exists($draftId, $instances)) {
3994 $checkedDraftIds[] = $draftId;
3995 $draft = $instances[$draftId];
3996
3997 $this->deleteMobsOfDraft($draft->getDraftId(), $draft->getPostMessage());
3998
3999 $GLOBALS['ilAppEventHandler']->raise(
4000 'components/ILIAS/Forum',
4001 'deletedDraft',
4002 [
4003 'draftObj' => $draft,
4004 'obj_id' => $this->object->getId(),
4005 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
4006 ]
4007 );
4008
4009 $draftFileData = new ilFileDataForumDrafts();
4010 $draftFileData->delete([$draft->getDraftId()]);
4011
4012 $draft->deleteDraft();
4013 }
4014 }
4015
4016 if (count($checkedDraftIds) > 1) {
4017 $this->tpl->setOnScreenMessage('info', $this->lng->txt('delete_drafts_successfully'), true);
4018 } else {
4019 $this->tpl->setOnScreenMessage('info', $this->lng->txt('delete_draft_successfully'), true);
4020 }
4021 $this->ctrl->redirect($this, 'showThreads');
4022 }

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

+ Here is the call graph for this function:

◆ deliverDraftZipFileObject()

ilObjForumGUI::deliverDraftZipFileObject ( )
protected

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

4904 : void
4905 {
4906 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4907 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4908 }
4909
4911 $this->checkDraftAccess($draft);
4912
4915 new ilFileDataForumDrafts($this->object->getId(), $draft->getDraftId())
4916 )
4917 );
4918 }
draftAttachmentDelivery(ilFileDataForumInterface $storage)
deliverZipFileOrRedirect(AttachmentDelivery $delivery)

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

+ Here is the call graph for this function:

◆ deliverZipFileObject()

ilObjForumGUI::deliverZipFileObject ( )
protected

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

4920 : void
4921 {
4922 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4923 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4924 }
4925
4928 new ilFileDataForum($this->object->getId(), $this->objCurrentPost->getId())
4929 )
4930 );
4931 }
postingAttachmentDelivery(ilFileDataForumInterface $storage)

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

+ Here is the call graph for this function:

◆ deliverZipFileOrRedirect()

ilObjForumGUI::deliverZipFileOrRedirect ( AttachmentDelivery  $delivery)
private

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

290 : void
291 {
292 try {
293 if (!$delivery->deliverZipFile()) {
294 $this->ctrl->redirect($this);
295 }
296 } catch (AttachmentAccessDenied) {
297 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
298 }
299 }

References ILIAS\Repository\ctrl(), ILIAS\Forum\Files\Access\AttachmentDelivery\deliverZipFile(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ denyUnlessGranted()

ilObjForumGUI::denyUnlessGranted ( BindingDecision  $decision)
private

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

255 : void
256 {
257 if (!$decision->isGranted()) {
258 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
259 }
260 }

References ILIAS\Forum\Posting\BindingDecision\isGranted(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ disableForumNotificationObject()

ilObjForumGUI::disableForumNotificationObject ( )
protected

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

4384 : void
4385 {
4386 if (!$this->access->checkAccess('read', '', $this->object->getRefId()) || $this->user->isAnonymous()) {
4387 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4388 }
4389
4390 $frm = $this->object->Forum;
4391 $frm->setForumId($this->object->getId());
4392 $frm->disableForumNotification($this->user->getId());
4393
4394 if ($this->objCurrentTopic->getId() > 0) {
4395 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4396 $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_forum_notification_disabled'), true);
4397 $this->ctrl->redirect($this, 'viewThread');
4398 }
4399
4400 $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_forum_notification_disabled'));
4401 $this->showThreadsObject();
4402 }

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

+ Here is the call graph for this function:

◆ displayConfirmPostActivation()

ilObjForumGUI::displayConfirmPostActivation ( )

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

2181 : bool
2182 {
2184 }
bool $display_confirm_post_activation

◆ doHistoryCheck()

ilObjForumGUI::doHistoryCheck ( int  $draftId)
private

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

5825 : void
5826 {
5828 return;
5829 }
5830
5831 $this->checkDraftAccess($draftId);
5832
5834 $draftsFromHistory = ilForumDraftsHistory::getInstancesByDraftId($draftId);
5835 if ($draftsFromHistory !== []) {
5836 $form_tpl = new ilTemplate('tpl.restore_thread_draft.html', true, true, 'components/ILIAS/Forum');
5837
5838 $first_open = null;
5839 foreach ($draftsFromHistory as $history_instance) {
5840 $accordion = new ilAccordionGUI();
5841 $accordion->setId('acc_' . $history_instance->getHistoryId());
5842 $accordion->setBehaviour(ilAccordionGUI::ALL_CLOSED);
5843 if ($first_open === null) {
5844 $first_open = $history_instance->getHistoryId();
5845 $accordion->setBehaviour(ilAccordionGUI::FIRST_OPEN);
5846 }
5847
5848 $form_tpl->setCurrentBlock('list_item');
5849 $message = ilRTE::_replaceMediaObjectImageSrc($history_instance->getPostMessage(), 1);
5850
5851 $history_date = ilDatePresentation::formatDate(new ilDateTime(
5852 $history_instance->getDraftDate(),
5854 ));
5855 $this->ctrl->setParameter($this, 'history_id', $history_instance->getHistoryId());
5856 $header = $history_date . ': ' . $history_instance->getPostSubject();
5857
5858 $accordion_tpl = new ilTemplate(
5859 'tpl.restore_thread_draft_accordion_content.html',
5860 true,
5861 true,
5862 'components/ILIAS/Forum'
5863 );
5864 $accordion_tpl->setVariable('MESSAGE', $message);
5865 $accordion_tpl->setVariable(
5866 'BUTTON',
5867 $this->uiRenderer->render(
5868 $this->uiFactory->button()->standard(
5869 $this->lng->txt('restore'),
5870 $this->ctrl->getLinkTarget($this, 'restoreFromHistory')
5871 )
5872 )
5873 );
5874 $accordion->addItem($header, $accordion_tpl->get());
5875
5876 $form_tpl->setVariable('ACC_AUTO_SAVE', $accordion->getHTML());
5877 $form_tpl->parseCurrentBlock();
5878 }
5879
5880 $form_tpl->setVariable('RESTORE_DATA_EXISTS', 'found_threat_history_to_restore');
5881
5882 $modal = $this->ui_factory->modal()->interruptive(
5883 $this->lng->txt('restore_draft_from_autosave'),
5884 $form_tpl->get(),
5885 '#'
5886 )->withAdditionalOnLoadCode(function (string $id): string {
5887 return "document.getElementById('$id').dataset.modalId = 'frm_autosave_restore';";
5888 });
5889
5890 $this->modal_history = $this->ui_renderer->render($modal);
5891 } else {
5893 }
5894 }
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static getInstancesByDraftId(int $draft_id)
static createDraftBackup(int $draft_id)
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template

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

+ Here is the call graph for this function:

◆ draftAttachmentDelivery()

ilObjForumGUI::draftAttachmentDelivery ( ilFileDataForumInterface  $storage)
private

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

276 {
277 return $this->auditedDelivery(
279 new ForumFileStorageDelivery($storage),
280 new DraftAttachmentGuard($this->attachment_ownership, $this->user->getId())
281 )
282 );
283 }
Binds a draft to the forum object the request was routed to and to its author, since drafts are never...
Adapts the forum file storage to the narrow delivery port.
Passes a delivery request on only after a guard confirmed that the addressed container belongs to the...
auditedDelivery(AddressedAttachmentDelivery $delivery)

References ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ editDraftObject()

ilObjForumGUI::editDraftObject ( )
protected

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

5295 : void
5296 {
5297 $this->doHistoryCheck($this->retrieveDraftId());
5298 $this->viewThreadObject();
5299 }
doHistoryCheck(int $draftId)

◆ editStylePropertiesObject()

ilObjForumGUI::editStylePropertiesObject ( )
private

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

1156 : void
1157 {
1158 $this->content_style_gui->redirectToObjectSettings();
1159 }

◆ editThreadDraftObject()

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

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

4933 : void
4934 {
4936 !$this->access->checkAccess('add_thread', '', $this->object->getRefId()) ||
4937 !$this->access->checkAccess('read', '', $this->object->getRefId())) {
4938 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4939 }
4940
4941 $frm = $this->object->Forum;
4942 $frm->setForumId($this->object->getId());
4943 $frm->setForumRefId($this->object->getRefId());
4944
4945 $draft = new ilForumPostDraft();
4946 $draftId = (int) ($this->httpRequest->getQueryParams()['draft_id'] ?? 0);
4947 if ($draftId > 0) {
4948 $draft = ilForumPostDraft::newInstanceByDraftId($draftId);
4949 $this->checkDraftAccess($draft);
4950 }
4951
4952 $do_history_check = (bool) ($this->httpRequest->getQueryParams()['hist_check'] ?? true);
4953 if (!($form instanceof ilPropertyFormGUI) && $do_history_check) {
4954 $this->doHistoryCheck($draft->getDraftId());
4955 }
4956
4957 if ($form instanceof ilPropertyFormGUI) {
4958 $this->ctrl->setParameter($this, 'draft_id', $draftId);
4959 } else {
4960 $form = $this->buildThreadForm(true);
4961 $form->setValuesByArray([
4962 'alias' => $draft->getPostUserAlias(),
4963 'subject' => $draft->getPostSubject(),
4964 'message' => ilRTE::_replaceMediaObjectImageSrc($frm->prepareText($draft->getPostMessage(), 2), 1),
4965 'notify' => $draft->isNotificationEnabled() && !$this->user->isAnonymous(),
4966 'userfile' => '',
4967 'del_file' => [],
4968 'draft_id' => $draftId
4969 ]);
4970 }
4971
4972 $this->tpl->setContent($form->getHTML() . $this->modal_history);
4973 }

References ilRTE\_replaceMediaObjectImageSrc(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\int(), ilForumPostDraft\isSavePostDraftAllowed(), ILIAS\Repository\lng(), ilForumPostDraft\newInstanceByDraftId(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ enableForumNotificationObject()

ilObjForumGUI::enableForumNotificationObject ( )
protected

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

4364 : void
4365 {
4366 if (!$this->access->checkAccess('read', '', $this->object->getRefId()) || $this->user->isAnonymous()) {
4367 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4368 }
4369
4370 $frm = $this->object->Forum;
4371 $frm->setForumId($this->object->getId());
4372 $frm->enableForumNotification($this->user->getId());
4373
4374 if ($this->objCurrentTopic->getId() > 0) {
4375 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4376 $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_forum_notification_enabled'), true);
4377 $this->ctrl->redirect($this, 'viewThread');
4378 }
4379
4380 $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_forum_notification_enabled'));
4381 $this->showThreadsObject();
4382 }

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

+ Here is the call graph for this function:

◆ ensureThreadBelongsToForum()

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

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

247 : void
248 {
250 if ($thread->getForumId() !== $forumId) {
251 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
252 }
253 }
$objId
Definition: xapitoken.php:57

References $objId, ilForumTopic\getForumId(), ILIAS\Repository\lng(), and ilObjForum\lookupForumIdByObjId().

+ Here is the call graph for this function:

◆ ensureValidPageForCurrentPosting()

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

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

209 : void {
210 if ($firstForumPost->getId() === $this->objCurrentPost->getId()) {
211 return;
212 }
213
214 if ($subtree_nodes !== [] && $this->objCurrentPost->getId() > 0) {
215 $isCurrentPostingInPage = array_filter($pagedPostings, fn(ilForumPost $posting): bool => (
216 $posting->getId() === $this->objCurrentPost->getId()
217 ));
218
219 if ([] === $isCurrentPostingInPage) {
220 $pageOfCurrentPosting = 0;
221 $i = 0;
222 foreach ($subtree_nodes as $node) {
223 if ($i > 0 && $i % $pageSize === 0) {
224 ++$pageOfCurrentPosting;
225 }
226
227 if ($node->getId() === $this->objCurrentPost->getId()) {
228 break;
229 }
230
231 ++$i;
232 }
233
234 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
235 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
236 $this->ctrl->setParameter($this, 'page', $pageOfCurrentPosting);
237 $this->ctrl->setParameter(
238 $this,
239 'orderby',
240 $this->getOrderByParam()
241 );
242 $this->ctrl->redirect($this, 'viewThread', (string) $this->objCurrentPost->getId());
243 }
244 }
245 }

◆ eventsFormBuilder()

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

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

4649 {
4650 if ($this->objCurrentTopic->getId() > 0) {
4651 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4652 }
4653
4655 $this->ctrl->getFormAction($this, 'saveUserNotificationSettings'),
4656 $predefined_values,
4657 $this->uiFactory,
4658 $this->lng
4659 );
4660 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getActionsForThreadOverview()

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

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

1012 : Standard
1013 {
1014 $actions = $this->uiFactory->dropdown()->standard([]);
1015 if ($this->is_moderator) {
1016 $open_close = $this->getOpenCloseActionForThread($forum_topic, $ref_id);
1017 $stick_or_no_stick = $this->getStickyActionForThread($forum_topic, $ref_id);
1018 $edit_title_modal = $this->getEditTitleModal($forum_topic);
1019 $this->modal_collection[] = $edit_title_modal;
1020 $edit_title = $this->factory->button()->shy($this->lng->txt('frm_edit_title'), '#')->withOnClick(
1021 $edit_title_modal->getShowSignal()
1022 );
1023
1024 $move = $this->getLinkActionForThread(
1025 $ref_id,
1026 $this->lng->txt('move_thread_to_forum'),
1027 'move',
1028 $forum_topic->getId()
1029 );
1030 $merge = $this->getLinkActionForThread(
1031 $ref_id,
1032 $this->lng->txt('merge_posts_into_thread'),
1033 'mergeThreads',
1034 $forum_topic->getId()
1035 );
1036 $delete = $this->getLinkActionForThread(
1037 $ref_id,
1038 $this->lng->txt('delete_thread'),
1039 'confirmDeleteThreads',
1040 $forum_topic->getId()
1041 );
1042 $actions = $this->uiFactory->dropdown()->standard([
1043 $stick_or_no_stick,
1044 $open_close,
1045 $edit_title,
1046 $move,
1047 $merge,
1048 $delete
1049 ]);
1050 }
1051
1052 return $actions;
1053 }
getOpenCloseActionForThread(ilForumTopic $forum_topic, int $ref_id)
getStickyActionForThread(ilForumTopic $forum_topic, int $ref_id)
getEditTitleModal(ilForumTopic $topic)
getLinkActionForThread(int $ref_id, string $title, string $cmd, ?int $thread_id=null)
This describes a Standard Dropdown.
Definition: Standard.php:27

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

+ Here is the call graph for this function:

◆ getContent()

ilObjForumGUI::getContent ( )

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

720 : string
721 {
722 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
723 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
724 }
725
726 $cmd = $this->ctrl->getCmd();
727 $frm = $this->object->Forum;
728 $frm->setForumId($this->object->getId());
729 $frm->setForumRefId($this->object->getRefId());
730 $frm->setMDB2Wherecondition('top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
731 // Import information: Topic (variable $topicData) means frm object, not thread
732 $frm_object = $frm->getOneTopic();
733 if ($frm_object !== null) {
734 $frm->setDbTable('frm_data');
735 $frm->setMDB2WhereCondition('top_pk = %s ', ['integer'], [$frm_object->getTopPk()]);
736 $frm->updateVisits($frm_object->getTopPk());
737
739 $this->object->getType(),
740 $this->object->getRefId(),
741 $this->object->getId(),
742 $this->user->getId()
743 );
744
745 if ($cmd !== 'showThreads') {
746 $cmd = 'showThreads';
747 }
748 }
749 $this->tpl->setPermanentLink($this->object->getType(), $this->object->getRefId());
750
751 if (!$this->hideToolbar() && $this->access->checkAccess('add_thread', '', $this->object->getRefId())) {
752 $btn = $this->uiFactory->button()
753 ->standard(
754 $this->lng->txt('forums_new_thread'),
755 $this->ctrl->getLinkTarget($this, 'createThread')
756 );
757 $this->toolbar->addStickyItem($btn);
758 }
759
761 $this->addDraftButtonIfDraftsExists($cmd);
762 }
763
764 if ($this->confirmation_gui_html === '' && !$this->user->isAnonymous()) {
765 $this->toolbar->addButton(
766 $this->lng->txt('forums_mark_read'),
767 $this->ctrl->getLinkTarget($this, 'markAllRead')
768 );
769 $this->ctrl->clearParameters($this);
770 }
771
772 if (!$this->user->isAnonymous() && $this->access->checkAccess('write', '', $this->ref_id)) {
773 $this->lng->loadLanguageModule('cntr');
774 $this->toolbar->addComponent(
775 $this->uiFactory->button()->standard(
776 $this->lng->txt('cntr_text_media_editor'),
777 $this->ctrl->getLinkTargetByClass(ilForumPageGUI::class, 'edit')
778 )
779 );
780 }
781
782 $this->renderThreadOverview($frm, $frm_object);
783 return '';
784 }
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, $a_ext_rc=null, $a_ext_time=null)
addDraftButtonIfDraftsExists(string $cmd)
hideToolbar($a_flag=null)
renderThreadOverview(ilForum $frm, ?ForumDto $frm_object)

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

+ Here is the call graph for this function:

◆ getEditFormCustomValues()

ilObjForumGUI::getEditFormCustomValues ( array &  $a_values)
protected

Add values to custom edit fields.

Reimplemented from ilObjectGUI.

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

663 : void
664 {
665 $this->forum_settings_gui->getCustomValues($a_values);
666 }

◆ getEditTitleModal()

ilObjForumGUI::getEditTitleModal ( ilForumTopic  $topic)
private

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

1055 : RoundTrip
1056 {
1057 $topic_id = $this->refinery->kindlyTo()->string()->transform($topic->getId());
1058 $this->ctrl->setParameter($this, 'thr_pk', (string) $topic_id);
1059 $target = $this->ctrl->getLinkTargetByClass(
1060 ilObjForumGUI::class,
1061 'editThread'
1062 );
1063 $this->ctrl->setParameter($this, 'thread_id', null);
1064
1065 return $this->factory->modal()->roundtrip(
1066 $this->lng->txt('frm_edit_title'),
1067 [],
1068 [
1069 $this->factory->input()->field()->text($this->lng->txt('frm_edit_title'))->withValue($topic->getSubject()),
1070 ],
1071 $target
1072 );
1073 }

References ILIAS\Scripts\PHPStan\$target, ILIAS\Repository\ctrl(), factory(), ilForumTopic\getId(), ilForumTopic\getSubject(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getForumObjects()

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

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

3137 : array
3138 {
3139 if ($this->forumObjects === null) {
3140 $forumObj = $this->object;
3141 $file_obj = new ilFileDataForum($forumObj->getId(), $this->objCurrentPost->getId());
3142 $frm = $forumObj->Forum;
3143 $frm->setForumId($forumObj->getId());
3144 $frm->setForumRefId($forumObj->getRefId());
3145
3146 $this->forumObjects['forumObj'] = $forumObj;
3147 $this->forumObjects['frm'] = $frm;
3148 $this->forumObjects['file_obj'] = $file_obj;
3149 }
3150
3151 return $this->forumObjects;
3152 }

◆ getLinkActionForThread()

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

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

1001 $this->ctrl->setParameter($this, 'ref_id', $ref_id);
1002 $this->ctrl->setParameter($this, 'thr_pk', $thread_id);
1003 $this->ctrl->setParameter($this, 'page', 0);
1004 $url = $this->ctrl->getLinkTarget($this, $cmd);
1005 $this->ctrl->setParameter($this, 'ref_id', null);
1006 $this->ctrl->setParameter($this, 'thr_pk', null);
1007 $this->ctrl->setParameter($this, 'page', null);
1008
1009 return $this->uiFactory->link()->standard($title, $url);
1010 }

◆ getModalActions()

ilObjForumGUI::getModalActions ( )
private

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

2112 : string
2113 {
2114 $modalString = '';
2115 foreach ($this->modalActionsContainer as $modal) {
2116 $modalString .= $this->uiRenderer->render($modal);
2117 }
2118
2119 return $modalString;
2120 }

◆ getModifiedReOnSubject()

ilObjForumGUI::getModifiedReOnSubject ( )
private

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

3673 : string
3674 {
3675 return (new \ILIAS\components\Forum\Subject\PostingReplySubjectBuilder(
3676 $this->lng->txt('post_reply'),
3677 $this->lng->txt('post_reply_count')
3678 ))->build($this->objCurrentPost->getSubject());
3679 }
Class ilChatroomConfigFileHandler \ILIAS\Chatroom\classes.

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getOpenCloseActionForThread()

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

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

1127 {
1128 return $this->getLinkActionForThread(
1129 $ref_id,
1130 $this->lng->txt($forum_topic->isClosed() ? 'reopen_topics' : 'close_topics'),
1131 $forum_topic->isClosed() ? 'reopen' : 'close',
1132 $forum_topic->getId()
1133 );
1134 }

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

+ Here is the call graph for this function:

◆ getOrderByParam()

ilObjForumGUI::getOrderByParam ( )
private

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

6046 : string
6047 {
6048 return ilUtil::stripSlashes($this->http->wrapper()->query()->retrieve(
6049 'orderby',
6050 $this->refinery->byTrying([
6051 $this->refinery->kindlyTo()->string(),
6052 $this->refinery->always('')
6053 ])
6054 ));
6055 }

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

+ Here is the call graph for this function:

◆ getReplyEditForm()

ilObjForumGUI::getReplyEditForm ( )
private

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

2610 {
2611 if ($this->replyEditForm === null) {
2612 $this->initReplyEditForm();
2613 }
2614
2615 return $this->replyEditForm;
2616 }
ilPropertyFormGUI $replyEditForm

◆ getResetLimitedViewInfo()

ilObjForumGUI::getResetLimitedViewInfo ( )
private

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

6027 : string
6028 {
6029 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
6030
6031 $buttons = [
6032 $this->uiFactory->button()->standard(
6033 $this->lng->txt('reset_limited_view_button'),
6034 $this->ctrl->getLinkTarget($this, 'resetLimitedView')
6035 )
6036 ];
6037
6038 return $this->uiRenderer->render(
6039 $this->uiFactory
6040 ->messageBox()
6041 ->info($this->lng->txt('reset_limited_view_info'))
6042 ->withButtons($buttons)
6043 );
6044 }

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

+ Here is the call graph for this function:

◆ getSafePostCommands()

ilObjForumGUI::getSafePostCommands ( )

This method must return a list of safe POST commands.

Safe post commands returned by this method will no longer be CSRF protected and will NOT be appended by an ilCtrlToken.

Returns
string[]

Implements ilCtrlSecurityInterface.

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

350 : array
351 {
352 return [];
353 }

◆ getSortationViewControl()

ilObjForumGUI::getSortationViewControl ( int  $offset,
ThreadSortation  $effective_sortation 
)
private

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

902 if ($offset > 0) {
903 $this->ctrl->setParameter($this, 'page', $offset);
904 }
905
906 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
907 $base_url = $this->ctrl->getLinkTarget($this, 'showThreads');
908
909 $translation_keys = [];
910 foreach (ThreadSortation::cases() as $sortation) {
911 $translation_keys[$sortation->value] = $this->lng->txt($sortation->languageId());
912 }
913 $this->ctrl->clearParameters($this);
914
915 return $this->factory->viewControl()->sortation(
916 $translation_keys,
917 (string) $effective_sortation->value
918 )->withTargetURL($base_url, ForumThreadTableSessionStorage::KEY_THREAD_SORTATION);
919 }
This describes a Sortation Control.
Definition: Sortation.php:34

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getStickyActionForThread()

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

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

1117 {
1118 return $this->getLinkActionForThread(
1119 $ref_id,
1120 $this->lng->txt($forum_topic->isSticky() ? 'make_topics_non_sticky' : 'make_topics_sticky'),
1121 $forum_topic->isSticky() ? 'make_topics_non_sticky' : 'makesticky',
1122 $forum_topic->getId()
1123 );
1124 }

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

+ Here is the call graph for this function:

◆ getTabs()

ilObjForumGUI::getTabs ( )
protected

@abstract overwrite in derived GUI class of your object type

Reimplemented from ilObjectGUI.

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

1623 : void
1624 {
1625 if ($this->in_page_editor_style_context) {
1626 return;
1627 }
1628
1629 $this->ilHelp->setScreenIdComponent('frm');
1630
1631 $this->ctrl->setParameter($this, 'ref_id', $this->ref_id);
1632
1633 $active = [
1634 '',
1635 'showThreads',
1636 'view',
1637 'markAllRead',
1638 'enableForumNotification',
1639 'disableForumNotification',
1640 'moveThreads',
1641 'performMoveThreads',
1642 'cancelMoveThreads',
1643 'performThreadsAction',
1644 'createThread',
1645 'addThread',
1646 'showUser',
1647 'confirmDeleteThreads',
1648 'merge',
1649 'mergeThreads',
1650 'performMergeThreads'
1651 ];
1652
1653 $force_active = false;
1654 if (in_array($this->ctrl->getCmd(), $active, true)) {
1655 $force_active = true;
1656 }
1657
1658 if ($this->access->checkAccess(
1659 'read',
1660 '',
1661 $this->ref_id
1662 )) {
1663 $this->tabs_gui->addTarget(
1664 self::UI_TAB_ID_THREADS,
1665 $this->ctrl->getLinkTarget($this, 'showThreads'),
1666 $this->ctrl->getCmd(),
1667 static::class,
1668 '',
1669 $force_active
1670 );
1671 }
1672
1673 if ($this->access->checkAccess('visible', '', $this->ref_id) || $this->access->checkAccess(
1674 'read',
1675 '',
1676 $this->ref_id
1677 )) {
1678 $cmdClass = $this->http->wrapper()->query()->retrieve(
1679 'cmdClass',
1680 $this->refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always('')])
1681 );
1682
1683 $force_active = $this->ctrl->getNextClass() === 'ilinfoscreengui' || strtolower($cmdClass) === 'ilnotegui';
1684 $this->tabs_gui->addTarget(
1685 self::UI_TAB_ID_INFO,
1686 $this->ctrl->getLinkTargetByClass([self::class, ilInfoScreenGUI::class], 'showSummary'),
1687 ['showSummary', 'infoScreen'],
1688 '',
1689 '',
1690 $force_active
1691 );
1692 }
1693
1694 if ($this->access->checkAccess('write', '', $this->ref_id)) {
1695 $force_active = $this->ctrl->getCmd() === 'edit';
1696 $this->tabs_gui->addTarget(
1697 self::UI_TAB_ID_SETTINGS,
1698 $this->ctrl->getLinkTarget($this, 'edit'),
1699 'edit',
1700 static::class,
1701 '',
1702 $force_active
1703 );
1704 }
1705
1706 if ($this->access->checkAccess('write', '', $this->ref_id)) {
1707 $this->tabs_gui->addTarget(
1708 self::UI_TAB_ID_MODERATORS,
1709 $this->ctrl->getLinkTargetByClass(ilForumModeratorsGUI::class, 'showModerators'),
1710 'showModerators',
1711 static::class
1712 );
1713 }
1714
1715 if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
1716 $this->tabs_gui->addTab(
1717 'learning_progress',
1718 $this->lng->txt('learning_progress'),
1719 $this->ctrl->getLinkTargetByClass(ilLearningProgressGUI::class)
1720 );
1721 }
1722
1723 if ($this->settings->get('enable_fora_statistics', '0')) {
1724 $hasStatisticsAccess = $this->access->checkAccess('write', '', $this->ref_id);
1725 if (!$hasStatisticsAccess) {
1726 $hasStatisticsAccess = (
1727 $this->objProperties->isStatisticEnabled() &&
1728 $this->access->checkAccess('read', '', $this->ref_id)
1729 );
1730 }
1731
1732 if ($hasStatisticsAccess) {
1733 $force_active = $this->ctrl->getCmd() === 'showStatistics';
1734 $this->tabs_gui->addTarget(
1735 self::UI_TAB_ID_STATS,
1736 $this->ctrl->getLinkTarget($this, 'showStatistics'),
1737 'showStatistics',
1738 static::class,
1739 '',
1740 $force_active
1741 );
1742 }
1743 }
1744
1745 if ($this->access->checkAccess('write', '', $this->object->getRefId())) {
1746 $this->tabs_gui->addTarget(
1747 self::UI_TAB_ID_EXPORT,
1748 $this->ctrl->getLinkTargetByClass(ilExportGUI::class, ''),
1749 '',
1750 'ilexportgui'
1751 );
1752 }
1753
1754 if ($this->access->checkAccess('edit_permission', '', $this->ref_id)) {
1755 $this->tabs_gui->addTarget(
1756 self::UI_TAB_ID_PERMISSIONS,
1757 $this->ctrl->getLinkTargetByClass([static::class, ilPermissionGUI::class], 'perm'),
1758 ['perm', 'info', 'owner'],
1759 'ilpermissiongui'
1760 );
1761 }
1762 }
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress

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().

+ Here is the call graph for this function:

◆ getThreadProperties()

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

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

947 : array
948 {
949 $this->ctrl->setParameter($this, 'thr_pk', $forum_topic->getId());
950 $unread_counter = $forum_topic->getNumUnreadPosts();
951 $is_top_thread = $forum_topic->isSticky();
952
953 if ($unread_counter === 0) {
954 $unread = '';
955 } else {
956 $unread = ' (' . $unread_counter . ' ' . $this->lng->txt('unread') . ')';
957 }
958
959 $authorinfo = new ilForumAuthorInformation(
960 $forum_topic->getThrAuthorId(),
961 $forum_topic->getDisplayUserId(),
962 (string) $forum_topic->getUserAlias(),
963 (string) $forum_topic->getImportName()
964 );
965
966 $properties = [
967 $this->lng->txt('forums_created_by') => $authorinfo->getAuthorName(),
968 $this->lng->txt('forums_articles') => $forum_topic->getNumPosts() . $unread,
969 $this->lng->txt('forums_last_post') => $this->object->Forum->convertDate($forum_topic->getLastPost()->getCreateDate()),
970 $this->lng->txt('visits') => $forum_topic->getVisits(),
971 ];
972
973 if ($is_top_thread === true) {
974 $is_top_thread = [$this->lng->txt('relevance') => $this->lng->txt('sticky')];
975 $properties = array_merge($properties, $is_top_thread);
976 }
977
978 $rating_property = [];
979 if ($this->objProperties->isIsThreadRatingEnabled()) {
980 $rating = new ilRatingGUI();
981 $rating->setObject(
982 $this->object->getId(),
983 $this->object->getType(),
984 $forum_topic->getId(),
985 'thread'
986 );
987 $rating->setUserId($this->user->getId());
988 $rating_property = [$this->lng->txt('frm_rating') => $rating->getHTML()];
989 }
990 $this->ctrl->setParameter($this, 'thr_pk', null);
991
992 return array_merge($properties, $rating_property);
993 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

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(), ILIAS\Repository\object(), and ILIAS\Repository\user().

+ Here is the call 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 340 of file class.ilObjForumGUI.php.

340 : array
341 {
342 return [
343 'enableForumNotification',
344 'disableForumNotification',
345 'toggleThreadNotification',
346 'confirmDeleteThreadDrafts'
347 ];
348 }

◆ handleCensorship()

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

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

2122 : void
2123 {
2124 $message = '';
2125 if ($this->is_moderator && !$this->objCurrentTopic->isClosed()) {
2126 if ($this->http->wrapper()->post()->has('formData')) {
2127 $formData = $this->http->wrapper()->post()->retrieve(
2128 'formData',
2129 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string())
2130 );
2131 $message = $this->handleFormInput($formData['cens_message']);
2132 }
2133
2134 if ($message === '' && $this->http->wrapper()->post()->has('cens_message')) {
2135 $cens_message = $this->http->wrapper()->post()->retrieve(
2136 'cens_message',
2137 $this->refinery->kindlyTo()->string()
2138 );
2139 $message = $this->handleFormInput($cens_message);
2140 }
2141 $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentPost->getThread());
2142
2143 $oForumObjects = $this->getForumObjects();
2144 $frm = $oForumObjects['frm'];
2145
2146 if ($wasRevoked) {
2147 $frm->postCensorship($this->object, $message, $this->objCurrentPost->getId());
2148 $this->tpl->setOnScreenMessage('success', $this->lng->txt('frm_censorship_revoked'));
2149 } else {
2150 $frm->postCensorship($this->object, $message, $this->objCurrentPost->getId(), 1);
2151 $this->tpl->setOnScreenMessage('success', $this->lng->txt('frm_censorship_applied'));
2152 }
2153
2154 $this->viewThreadObject();
2155 return;
2156 }
2157
2158 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2159 }

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

+ Here is the call graph for this function:

◆ handleFormInput()

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

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

4431 : string
4432 {
4433 $a_text = str_replace(['<', '>'], ['&lt;', '&gt;'], $a_text);
4434 if ($a_stripslashes) {
4435 $a_text = ilUtil::stripSlashes($a_text);
4436 }
4437
4438 return $a_text;
4439 }

References ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ hasDraftAccess()

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

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

5814 : bool
5815 {
5816 $draft = is_int($draft) ? ilForumPostDraft::newInstanceByDraftId($draft) : $draft;
5817 return (
5818 $draft->getDraftId() &&
5819 !$this->user->isAnonymous() &&
5820 $this->access->checkAccess('add_reply', '', $this->object->getRefId()) &&
5821 $this->user->getId() === $draft->getPostAuthorId()
5822 );
5823 }

References ilForumPostDraft\getDraftId(), ilForumPostDraft\getPostAuthorId(), and ilForumPostDraft\newInstanceByDraftId().

+ Here is the call graph for this function:

◆ hideToolbar()

ilObjForumGUI::hideToolbar (   $a_flag = null)
private

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

3098 {
3099 if ($a_flag === null) {
3100 return $this->hideToolbar;
3101 }
3102
3103 $this->hideToolbar = $a_flag;
3104 return $this;
3105 }

◆ infoScreen()

ilObjForumGUI::infoScreen ( )
protected

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

4448 : void
4449 {
4450 if (
4451 !$this->access->checkAccess('visible', '', $this->object->getRefId()) &&
4452 !$this->access->checkAccess('read', '', $this->object->getRefId())
4453 ) {
4454 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
4455 }
4456
4457 if (strtolower($this->ctrl->getCmd() ?? '') === 'infoscreen') {
4458 $this->ctrl->redirectByClass(ilInfoScreenGUI::class, 'showSummary');
4459 }
4460
4461 $info = new ilInfoScreenGUI($this);
4462 $info->enablePrivateNotes();
4463 $this->ctrl->forwardCommand($info);
4464 }
Class ilInfoScreenGUI.
$info
Definition: entry_point.php:21

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

+ Here is the call graph for this function:

◆ infoScreenObject()

ilObjForumGUI::infoScreenObject ( )

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

652 : void
653 {
654 $this->infoScreen();
655 }

◆ initEditCustomForm()

ilObjForumGUI::initEditCustomForm ( ilPropertyFormGUI  $a_form)
protected

Add custom fields to update form.

Reimplemented from ilObjectGUI.

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

657 : void
658 {
659 $this->forum_settings_gui = new ilForumSettingsGUI($this, $this->object);
660 $this->forum_settings_gui->getCustomForm($a_form);
661 }
@ilCtrl_Calls ilForumSettingsGUI: ilObjectContentStyleSettingsGUI

◆ initHeaderAction()

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

Add header action menu.

Reimplemented from ilObjectGUI.

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

4501 {
4502 $lg = parent::initHeaderAction();
4503
4504 if (!($lg instanceof ilObjForumListGUI) || !((bool) $this->settings->get('forum_notification', '0'))) {
4505 return $lg;
4506 }
4507
4508 if ($this->user->isAnonymous() || !$this->access->checkAccess('read', '', $this->object->getRefId())) {
4509 return $lg;
4510 }
4511
4512 $frm = $this->object->Forum;
4513 $frm->setForumId($this->object->getId());
4514 $frm->setForumRefId($this->object->getRefId());
4515 $frm->setMDB2Wherecondition('top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
4516
4517 $are_notifications_enabled = $frm->isForumNotificationEnabled($this->user->getId());
4518 $has_membership_enabled_parent_container = $this->object->isParentMembershipEnabledContainer();
4519 $user_may_disable_notifcations = (
4521 !$has_membership_enabled_parent_container
4522 );
4523
4524 if ($this->objCurrentTopic->getId() > 0) {
4525 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4526 }
4527
4528 if (!$this->user->isAnonymous()) {
4529 if ($has_membership_enabled_parent_container) {
4530 if ($are_notifications_enabled && $user_may_disable_notifcations) {
4531 $lg->addCustomCommand(
4532 $this->ctrl->getLinkTarget($this, 'disableForumNotification'),
4533 'forums_disable_forum_notification'
4534 );
4535 } elseif (!$are_notifications_enabled) {
4536 $lg->addCustomCommand(
4537 $this->ctrl->getLinkTarget($this, 'enableForumNotification'),
4538 'forums_enable_forum_notification'
4539 );
4540 }
4541 } elseif ($are_notifications_enabled) {
4542 $lg->addCustomCommand(
4543 $this->ctrl->getLinkTarget($this, 'disableForumNotification'),
4544 'forums_disable_forum_notification'
4545 );
4546 } else {
4547 $lg->addCustomCommand(
4548 $this->ctrl->getLinkTarget($this, 'enableForumNotification'),
4549 'forums_enable_forum_notification'
4550 );
4551 }
4552 }
4553
4554 if ($are_notifications_enabled && $user_may_disable_notifcations && !$this->user->isAnonymous()) {
4555 $frm_noti = new ilForumNotification($this->object->getRefId());
4556 $frm_noti->setUserId($this->user->getId());
4557 $interested_events = $frm_noti->readInterestedEvents();
4558
4559 $events_form_builder = $this->eventsFormBuilder([
4560 'hidden_value' => '',
4561 'notify_modified' => (bool) ($interested_events & ilForumNotificationEvents::UPDATED),
4562 'notify_censored' => (bool) ($interested_events & ilForumNotificationEvents::CENSORED),
4563 'notify_uncensored' => (bool) ($interested_events & ilForumNotificationEvents::UNCENSORED),
4564 'notify_post_deleted' => (bool) ($interested_events & ilForumNotificationEvents::POST_DELETED),
4565 'notify_thread_deleted' => (bool) ($interested_events & ilForumNotificationEvents::THREAD_DELETED),
4566 ]);
4567
4568 $notificationsModal = $this->uiFactory->modal()->roundtrip(
4569 $this->lng->txt('notification_settings'),
4570 [$events_form_builder->build()]
4571 )->withActionButtons([
4572 $this->uiFactory
4573 ->button()
4574 ->primary($this->lng->txt('save'), '#')
4575 ->withOnLoadCode(function (string $id): string {
4576 return "
4577 (function () {
4578 const button = document.getElementById('$id');
4579 if (!button) return;
4580
4581 const modalDialog = button.closest('.modal-dialog');
4582 if (!modalDialog) return;
4583
4584 const form = modalDialog.querySelector('.modal-body form');
4585 if (!form) return;
4586
4587 form.classList.add('ilForumNotificationSettingsForm');
4588 button.addEventListener('click', (event) => {
4589 event.preventDefault();
4590 if (form) {
4591 form.submit();
4592 }
4593 }, true);
4594 }());
4595 ";
4596 })
4597 ]);
4598
4599 $showNotificationSettingsBtn = $this->uiFactory->button()
4600 ->shy($this->lng->txt('notification_settings'), '#')
4601 ->withOnClick(
4602 $notificationsModal->getShowSignal()
4603 );
4604
4605 $lg->addCustomCommandButton($showNotificationSettingsBtn, $notificationsModal);
4606 }
4607
4608 $are_thread_notifications_enabled = false;
4609 if (!$this->user->isAnonymous() && $this->objCurrentTopic->getId() > 0) {
4610 $are_thread_notifications_enabled = $this->objCurrentTopic->isNotificationEnabled($this->user->getId());
4611 if ($are_thread_notifications_enabled) {
4612 $lg->addCustomCommand(
4613 $this->ctrl->getLinkTarget($this, 'toggleThreadNotification'),
4614 'forums_disable_notification'
4615 );
4616 } else {
4617 $lg->addCustomCommand(
4618 $this->ctrl->getLinkTarget($this, 'toggleThreadNotification'),
4619 'forums_enable_notification'
4620 );
4621 }
4622 }
4623 $this->ctrl->setParameter($this, 'thr_pk', '');
4624
4625 if (!$this->user->isAnonymous()) {
4626 if ($are_notifications_enabled || $are_thread_notifications_enabled) {
4627 $lg->addHeaderIcon(
4628 'not_icon',
4629 ilUtil::getImagePath('object/notification_on.svg'),
4630 $this->lng->txt('frm_notification_activated')
4631 );
4632 } else {
4633 $lg->addHeaderIcon(
4634 'not_icon',
4635 ilUtil::getImagePath('object/notification_off.svg'),
4636 $this->lng->txt('frm_notification_deactivated')
4637 );
4638 }
4639 }
4640
4641 return $lg;
4642 }
Class ilForumNotification.
eventsFormBuilder(?array $predefined_values=null)
Class ilObjForumListGUI.
button(string $caption, string $cmd)

References $id, ILIAS\Repository\button(), ilForumNotificationEvents\CENSORED, ILIAS\Repository\ctrl(), ilUtil\getImagePath(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilForumNotificationEvents\POST_DELETED, ILIAS\Repository\settings(), ilForumNotificationEvents\THREAD_DELETED, ilForumNotificationEvents\UNCENSORED, ilForumNotificationEvents\UPDATED, and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ initReplyEditForm()

ilObjForumGUI::initReplyEditForm ( )
private

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

2358 : void
2359 {
2360 $isReply = in_array($this->requestAction, ['showreply', 'ready_showreply']);
2361 $isDraft = in_array($this->requestAction, ['publishDraft', 'editdraft']);
2362
2363 $draft_id = $this->retrieveDraftId();
2364
2365 // init objects
2366 $oForumObjects = $this->getForumObjects();
2367 $frm = $oForumObjects['frm'];
2368 $oFDForum = $oForumObjects['file_obj'];
2369
2370 $this->replyEditForm = new ilPropertyFormGUI();
2371 $this->replyEditForm->setId('id_showreply');
2372 $this->replyEditForm->setTableWidth('100%');
2373 $cancel_cmd = 'cancelPost';
2374 if (in_array($this->requestAction, ['showreply', 'ready_showreply'])) {
2375 $this->ctrl->setParameter($this, 'action', 'ready_showreply');
2376 } elseif (in_array($this->requestAction, ['showdraft', 'editdraft'])) {
2377 $this->ctrl->setParameter($this, 'action', $this->requestAction);
2378 $this->ctrl->setParameter($this, 'draft_id', $draft_id);
2379 } else {
2380 $this->ctrl->setParameter($this, 'action', 'ready_showedit');
2381 }
2382
2383 $this->ctrl->setParameter($this, 'page', (int) ($this->httpRequest->getQueryParams()['page'] ?? 0));
2384 $this->ctrl->setParameter(
2385 $this,
2386 'orderby',
2387 $this->getOrderByParam()
2388 );
2389 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
2390 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2391 if ($this->isTopLevelReplyCommand()) {
2392 $this->replyEditForm->setFormAction(
2393 $this->ctrl->getFormAction($this, 'saveTopLevelPost', 'frm_page_bottom')
2394 );
2395 } elseif (in_array($this->requestAction, ['publishDraft', 'editdraft'])) {
2396 $this->replyEditForm->setFormAction(
2397 $this->ctrl->getFormAction($this, 'publishDraft', (string) $this->objCurrentPost->getId())
2398 );
2399 } else {
2400 $this->replyEditForm->setFormAction(
2401 $this->ctrl->getFormAction($this, 'savePost', (string) $this->objCurrentPost->getId())
2402 );
2403 }
2404 $this->ctrl->clearParameters($this);
2405
2406 if ($isReply) {
2407 $this->replyEditForm->setTitle($this->lng->txt('forums_your_reply'));
2408 } elseif ($isDraft) {
2409 $this->replyEditForm->setTitle($this->lng->txt('forums_edit_draft'));
2410 } else {
2411 $this->replyEditForm->setTitle($this->lng->txt('forums_edit_post'));
2412 }
2413
2414 if (
2416 in_array($this->requestAction, ['showreply', 'ready_showreply', 'editdraft'])
2417 ) {
2418 $oAnonymousNameGUI = new ilTextInputGUI($this->lng->txt('forums_your_name'), 'alias');
2419 $oAnonymousNameGUI->setMaxLength(64);
2420 $oAnonymousNameGUI->setInfo(sprintf($this->lng->txt('forums_use_alias'), $this->lng->txt('forums_anonymous')));
2421
2422 $this->replyEditForm->addItem($oAnonymousNameGUI);
2423 }
2424
2425 $oSubjectGUI = new ilTextInputGUI($this->lng->txt('forums_subject'), 'subject');
2426 $oSubjectGUI->setMaxLength(255);
2427 $oSubjectGUI->setRequired(true);
2428
2429 if ($this->objProperties->getSubjectSetting() === 'empty_subject') {
2430 $oSubjectGUI->setInfo($this->lng->txt('enter_new_subject'));
2431 }
2432
2433 $this->replyEditForm->addItem($oSubjectGUI);
2434
2435 $oPostGUI = new ilTextAreaInputGUI(
2436 $isReply ? $this->lng->txt('forums_your_reply') : $this->lng->txt('forums_edit_post'),
2437 'message'
2438 );
2439 $oPostGUI->setRequired(true);
2440 $oPostGUI->setRows(15);
2441 $oPostGUI->setUseRte(true);
2442
2443 $quotingAllowed = (
2444 !$this->isTopLevelReplyCommand() && (
2445 ($isReply && $this->objCurrentPost->getDepth() >= 2) ||
2446 (!$isDraft && !$isReply && $this->objCurrentPost->getDepth() > 2) ||
2447 ($isDraft && $this->objCurrentPost->getDepth() >= 2)
2448 )
2449 );
2450
2451 $oPostGUI->removePlugin('advlink');
2452 $oPostGUI->setRTERootBlockElement('');
2453 $oPostGUI->usePurifier(true);
2454 $oPostGUI->disableButtons([
2455 'charmap',
2456 'undo',
2457 'redo',
2458 'alignleft',
2459 'aligncenter',
2460 'alignright',
2461 'alignjustify',
2462 'anchor',
2463 'fullscreen',
2464 'cut',
2465 'copy',
2466 'paste',
2467 'pastetext',
2468 'formatselect'
2469 ]);
2470
2471 if (in_array($this->requestAction, ['showreply', 'ready_showreply', 'showdraft', 'editdraft'])) {
2472 $oPostGUI->setRTESupport(
2473 $this->user->getId(),
2474 'frm~',
2475 'frm_post',
2476 'tpl.tinymce_frm_post.js',
2477 false,
2478 '5.6.0'
2479 );
2480 } else {
2481 $oPostGUI->setRTESupport(
2482 $this->objCurrentPost->getId(),
2483 'frm',
2484 'frm_post',
2485 'tpl.tinymce_frm_post.js',
2486 false,
2487 '5.6.0'
2488 );
2489 }
2490
2491 $oPostGUI->setPurifier(ilHtmlPurifierFactory::getInstanceByType('frm_post'));
2492 $oPostGUI->setInfo($this->lng->txt('latex_edit_info'));
2493
2494 $this->replyEditForm->addItem($oPostGUI);
2495
2496 $umail = new ilMail($this->user->getId());
2497 if (!$this->user->isAnonymous() &&
2498 !$this->objProperties->isAnonymized() &&
2499 $this->rbac->system()->checkAccess('internal_mail', $umail->getMailObjectReferenceId()) &&
2500 !$frm->isThreadNotificationEnabled($this->user->getId(), $this->objCurrentPost->getThreadId())) {
2501 $oNotificationGUI = new ilCheckboxInputGUI($this->lng->txt('forum_direct_notification'), 'notify');
2502 $oNotificationGUI->setInfo($this->lng->txt('forum_notify_me'));
2503 $this->replyEditForm->addItem($oNotificationGUI);
2504 }
2505
2506 if ($this->objProperties->isFileUploadAllowed()) {
2507 $oFileUploadGUI = new ilFileWizardInputGUI($this->lng->txt('forums_attachments_add'), 'userfile');
2508 $oFileUploadGUI->setFilenames([0 => '']);
2509 $this->replyEditForm->addItem($oFileUploadGUI);
2510 }
2511
2512 $attachments_of_node = $oFDForum->getFilesOfPost();
2513 if (count($attachments_of_node) && in_array($this->requestAction, ['showedit', 'ready_showedit'])) {
2514 $oExistingAttachmentsGUI = new ilCheckboxGroupInputGUI($this->lng->txt('forums_delete_file'), 'del_file');
2515 foreach ($oFDForum->getFilesOfPost() as $file) {
2516 $oExistingAttachmentsGUI->addOption(new ilCheckboxOption($file['name'], $file['md5']));
2517 }
2518 $this->replyEditForm->addItem($oExistingAttachmentsGUI);
2519 }
2520
2522 if (in_array($this->requestAction, ['showdraft', 'editdraft'])) {
2523 $draftInfoGUI = new ilNonEditableValueGUI('', 'autosave_info', true);
2524 $draftInfoGUI->setValue(sprintf(
2525 $this->lng->txt('autosave_draft_info'),
2527 ));
2528 $this->replyEditForm->addItem($draftInfoGUI);
2529 } elseif (!in_array($this->requestAction, ['showedit', 'ready_showedit'])) {
2530 $draftInfoGUI = new ilNonEditableValueGUI('', 'autosave_info', true);
2531 $draftInfoGUI->setValue(sprintf(
2532 $this->lng->txt('autosave_post_draft_info'),
2534 ));
2535 $this->replyEditForm->addItem($draftInfoGUI);
2536 }
2537 }
2538
2539 $selected_draft_id = $draft_id;
2540 $draftObj = new ilForumPostDraft(
2541 $this->user->getId(),
2542 $this->objCurrentPost->getId(),
2543 $selected_draft_id
2544 );
2545 if ($draftObj->getDraftId() > 0) {
2546 $oFDForumDrafts = new ilFileDataForumDrafts(0, $draftObj->getDraftId());
2547 $files_of_draft = $oFDForumDrafts->getFilesOfPost();
2548
2549 if ($files_of_draft !== []) {
2550 $oExistingAttachmentsGUI = new ilCheckboxGroupInputGUI(
2551 $this->lng->txt('forums_delete_file'),
2552 'del_file'
2553 );
2554 foreach ($files_of_draft as $file) {
2555 $oExistingAttachmentsGUI->addOption(new ilCheckboxOption($file['name'], $file['md5']));
2556 }
2557 $this->replyEditForm->addItem($oExistingAttachmentsGUI);
2558 }
2559 }
2560
2561 if ($this->isTopLevelReplyCommand()) {
2562 $this->replyEditForm->addCommandButton('saveTopLevelPost', $this->lng->txt('create'));
2563 } elseif ($this->requestAction === 'editdraft' && ilForumPostDraft::isSavePostDraftAllowed()) {
2564 $this->replyEditForm->addCommandButton('publishDraft', $this->lng->txt('publish'));
2565 } else {
2566 $this->replyEditForm->addCommandButton('savePost', $this->lng->txt('save'));
2567 }
2568 $hidden_draft_id = new ilHiddenInputGUI('draft_id');
2569 $auto_save_draft_id = $this->retrieveDraftId();
2570
2571 $hidden_draft_id->setValue((string) $auto_save_draft_id);
2572 $this->replyEditForm->addItem($hidden_draft_id);
2573
2574 if (in_array($this->requestAction, ['showreply', 'ready_showreply', 'editdraft'])) {
2575 $show_rte = $this->http->wrapper()->post()->retrieve(
2576 'show_rte',
2577 $this->refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
2578 );
2579
2580 if ($show_rte) {
2581 (new ilRTESettings($this->lng, $this->user))->setRichTextEditorUserState($show_rte);
2582 }
2583
2584 if ($quotingAllowed) {
2585 $this->replyEditForm->addCommandButton('quotePost', $this->lng->txt('forum_add_quote'));
2586 }
2587
2588 if (!$this->user->isAnonymous() &&
2589 in_array($this->requestAction, ['editdraft', 'showreply', 'ready_showreply']) &&
2592 $this->decorateWithAutosave($this->replyEditForm);
2593 }
2594
2595 if ($this->requestAction === 'editdraft') {
2596 $this->replyEditForm->addCommandButton('updateDraft', $this->lng->txt('save_message'));
2597 } elseif ($this->isTopLevelReplyCommand()) {
2598 $this->replyEditForm->addCommandButton('saveTopLevelDraft', $this->lng->txt('save_message'));
2599 } else {
2600 $this->replyEditForm->addCommandButton('saveAsDraft', $this->lng->txt('save_message'));
2601 }
2602
2603 $cancel_cmd = 'cancelDraft';
2604 }
2605 }
2606 $this->replyEditForm->addCommandButton($cancel_cmd, $this->lng->txt('cancel'));
2607 }
This class represents a property in a property form.
This class represents a checkbox property in a property form.
This class represents an option in a checkbox group.
This class represents a file wizard property in a property form.
This class represents a hidden form property in a property form.
static getInstanceByType(string $type)
This class represents a non editable value in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.

References ILIAS\Repository\ctrl(), ilHtmlPurifierFactory\getInstanceByType(), ILIAS\FileDelivery\http(), ilForumPostDraft\isAutoSavePostDraftAllowed(), ilForumPostDraft\isSavePostDraftAllowed(), ILIAS\Repository\lng(), ilForumPostDraft\lookupAutosaveInterval(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ initSessionStorage()

ilObjForumGUI::initSessionStorage ( )
protected

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

162 : void
163 {
164 $forumValues = ilSession::get('frm');
165 if (!is_array($forumValues)) {
166 $forumValues = [];
167 ilSession::set('frm', $forumValues);
168 }
169
170 $threadId = $this->objCurrentTopic->getId();
171 if ($threadId > 0 && !isset($forumValues[$threadId])) {
172 $forumValues[(int) $threadId] = [];
173 ilSession::set('frm', $forumValues);
174 }
175
176 $this->selected_post_storage = new ilForumThreadSettingsSessionStorage('frm_selected_post');
177 }

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

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initStyleSheets()

ilObjForumGUI::initStyleSheets ( )
private

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

1148 : void
1149 {
1150 $this->content_style_gui->addCss($this->tpl, $this->ref_id);
1151 $this->tpl->setCurrentBlock('SyntaxStyle');
1152 $this->tpl->setVariable('LOCATION_SYNTAX_STYLESHEET', ilObjStyleSheet::getSyntaxStylePath());
1153 $this->tpl->parseCurrentBlock();
1154 }

References ilObjStyleSheet\getSyntaxStylePath().

+ Here is the call graph for this function:

◆ isTopLevelReplyCommand()

ilObjForumGUI::isTopLevelReplyCommand ( )
private

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

331 : bool
332 {
333 return in_array(
334 strtolower($this->ctrl->getCmd() ?? ''),
335 array_map('strtolower', ['createTopLevelPost', 'saveTopLevelPost', 'saveTopLevelDraft']),
336 true
337 );
338 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ isUserAllowedToDeactivateNotification()

ilObjForumGUI::isUserAllowedToDeactivateNotification ( )

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

4694 : bool
4695 {
4696 if ($this->objProperties->getNotificationType() === NotificationType::DEFAULT) {
4697 return true;
4698 }
4699
4700 if (!$this->objProperties->isUserToggleNoti() &&
4701 $this->objProperties->getNotificationType() === NotificationType::ALL_USERS) {
4702 return true;
4703 }
4704
4705 if ($this->objProperties->getNotificationType() === NotificationType::PER_USER &&
4706 $this->object->isParentMembershipEnabledContainer()) {
4707 $frm_noti = new ilForumNotification($this->object->getRefId());
4708 $frm_noti->setUserId($this->user->getId());
4709
4710 return !$frm_noti->isUserToggleNotification();
4711 }
4712
4713 return false;
4714 }

References ILIAS\Forum\Notification\DEFAULT, ILIAS\Repository\object(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ isWritingWithPseudonymAllowed()

ilObjForumGUI::isWritingWithPseudonymAllowed ( )
private

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

3974 : bool
3975 {
3976 return (
3977 $this->objProperties->isAnonymized() &&
3978 (!$this->is_moderator || !$this->objProperties->getMarkModeratorPosts())
3979 );
3980 }

◆ markAllReadObject()

ilObjForumGUI::markAllReadObject ( )

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

703 : void
704 {
705 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
706 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
707 }
708
709 $this->object->markAllThreadsRead($this->user->getId());
710 $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_all_threads_marked_read'));
711 $this->showThreadsObject();
712 }

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

+ Here is the call graph for this function:

◆ markPostReadObject()

ilObjForumGUI::markPostReadObject ( )
protected

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

4480 : void
4481 {
4482 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4483 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4484 }
4485
4486 if ($this->objCurrentTopic->getId() > 0 && $this->objCurrentPost->getId() > 0) {
4487 $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentPost->getThread());
4488
4489 $this->object->markPostRead(
4490 $this->user->getId(),
4491 $this->objCurrentTopic->getId(),
4492 $this->objCurrentPost->getId()
4493 );
4494 }
4495
4496 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4497 $this->ctrl->redirect($this, 'viewThread');
4498 }

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

+ Here is the call graph for this function:

◆ markPostUnreadObject()

ilObjForumGUI::markPostUnreadObject ( )
protected

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

4466 : void
4467 {
4468 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4469 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4470 }
4471
4472 if ($this->objCurrentPost->getId() > 0) {
4473 $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentPost->getThread());
4474
4475 $this->object->markPostUnread($this->user->getId(), $this->objCurrentPost->getId());
4476 }
4477 $this->viewThreadObject();
4478 }

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

+ Here is the call graph for this function:

◆ markTopThreadInOverview()

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

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

1139 : Item {
1140 if ($current_thread->isSticky()) {
1141 $df = new \ILIAS\Data\Factory();
1142 $list_item = $list_item->withColor($df->color('#B54F00'));
1143 }
1144
1145 return $list_item;
1146 }
Common interface to all items.
Definition: Item.php:32

◆ mergeThreadsObject()

ilObjForumGUI::mergeThreadsObject ( )

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

4716 : void
4717 {
4718 if (!$this->is_moderator) {
4719 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4720 }
4721
4722 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4723 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4724 }
4725
4726 $threadIdToMerge = $this->http->wrapper()->query()->retrieve(
4727 'thr_pk',
4728 $this->refinery->byTrying([
4729 $this->refinery->kindlyTo()->int(),
4730 $this->refinery->always(0)
4731 ])
4732 );
4733 if ($threadIdToMerge <= 0) {
4734 $threadIds = array_values(
4735 array_filter(array_map(intval(...), (array) ($this->httpRequest->getParsedBody()['thread_ids'] ?? [])))
4736 );
4737 if (count($threadIds) === 1) {
4738 $threadIdToMerge = current($threadIds);
4739 } else {
4740 $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_one'));
4741 $this->showThreadsObject();
4742 return;
4743 }
4744 }
4745
4746 $frm = $this->object->Forum;
4747 $frm->setForumId($this->object->getId());
4748 $frm->setForumRefId($this->object->getRefId());
4749
4750 $threadToMerge = new ilForumTopic($threadIdToMerge);
4751
4752 if (ilForum::_lookupObjIdForForumId($threadToMerge->getForumId()) !== $frm->getForumId()) {
4753 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('not_allowed_to_merge_into_another_forum'));
4754 $this->showThreadsObject();
4755 return;
4756 }
4757
4758 $frm->setMDB2Wherecondition('top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
4759
4760 $threadsTemplate = new ilTemplate(
4761 'tpl.forums_threads_liste.html',
4762 true,
4763 true,
4764 'components/ILIAS/Forum'
4765 );
4766
4767 $topicData = $frm->getOneTopic();
4768 if ($topicData !== null) {
4769 $this->ctrl->setParameter($this, 'merge_thread_id', $threadIdToMerge);
4770 $tbl = new ilForumTopicTableGUI(
4771 $this,
4772 'mergeThreads',
4773 (int) $this->httpRequest->getQueryParams()['ref_id'],
4774 $topicData,
4775 $this->is_moderator
4776 );
4777 $tbl->setSelectedThread($threadToMerge);
4778 $tbl->setMapper($frm)->fetchData();
4779 $tbl->init();
4780 $threadsTemplate->setVariable('THREADS_TABLE', $tbl->getHTML());
4781 $this->tpl->setContent($threadsTemplate->get());
4782 } else {
4783 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
4784 $this->showThreadsObject();
4785 }
4786 }
Class ilForumTopicTableGUI.
static _lookupObjIdForForumId(int $a_for_id)

References ilForum\_lookupObjIdForForumId(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ moveThreadsObject()

ilObjForumGUI::moveThreadsObject ( )

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

3909 : bool
3910 {
3911 if (!$this->is_moderator) {
3912 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3913 }
3914
3915 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3916 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3917 }
3918
3919 $frm_ref_id = $this->http->wrapper()->post()->retrieve(
3920 'frm_ref_id',
3921 $this->refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(null)])
3922 );
3923
3924 $threads2move = ilSession::get('threads2move');
3925 if (!is_array($threads2move) || $threads2move === []) {
3926 $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_at_least_one_thread'), true);
3927 $this->ctrl->redirect($this, 'showThreads');
3928 }
3929
3930 $threads = [];
3931 $isModerator = $this->is_moderator;
3932 array_walk($threads2move, function (int $threadId) use (&$threads, $isModerator): void {
3933 $thread = new ilForumTopic($threadId, $isModerator);
3934 $this->ensureThreadBelongsToForum($this->object->getId(), $thread);
3935
3936 $threads[] = $thread;
3937 });
3938
3939 $exp = new ilForumMoveTopicsExplorer($this, 'moveThreads');
3940 $exp->setPathOpen($this->object->getRefId());
3941 $exp->setNodeSelected(isset($frm_ref_id) && (int) $frm_ref_id ? (int) $frm_ref_id : 0);
3942 $exp->setCurrentFrmRefId($this->object->getRefId());
3943 $exp->setHighlightedNode((string) $this->object->getRefId());
3944 if (!$exp->handleCommand()) {
3945 $moveThreadTemplate = new ilTemplate(
3946 'tpl.forums_threads_move.html',
3947 true,
3948 true,
3949 'components/ILIAS/Forum'
3950 );
3951
3952 if (!$this->hideToolbar()) {
3953 $this->toolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this));
3954 }
3955
3956 $messages = [];
3957 foreach ($threads as $thread) {
3958 $messages[] = $this->ui_factory->messageBox()->info(
3959 sprintf($this->lng->txt('move_chosen_topics'), $thread->getSubject())
3960 );
3961 }
3962 $moveThreadTemplate->setVariable('THREAD_MESSAGE', $this->uiRenderer->render($messages));
3963 $moveThreadTemplate->setVariable('FRM_SELECTION_TREE', $exp->getHTML());
3964 $moveThreadTemplate->setVariable('CMD_SUBMIT', 'performMoveThreads');
3965 $moveThreadTemplate->setVariable('TXT_SUBMIT', $this->lng->txt('move'));
3966 $moveThreadTemplate->setVariable('FORMACTION', $this->ctrl->getFormAction($this, 'performMoveThreads'));
3967
3968 $this->tpl->setContent($moveThreadTemplate->get());
3969 }
3970
3971 return true;
3972 }

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilSession\get(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ILIAS\Repository\refinery(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

◆ performDeleteThreadsObject()

ilObjForumGUI::performDeleteThreadsObject ( )

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

1870 : void
1871 {
1872 $threadIds = $this->retrieveThreadIds();
1873 if ($threadIds === []) {
1874 $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_at_least_one_thread'), true);
1875 $this->ctrl->redirect($this, 'showThreads');
1876 }
1877
1878 if (!$this->is_moderator) {
1879 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1880 }
1881
1882 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1883 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1884 }
1885
1886 $forumObj = new ilObjForum($this->object->getRefId());
1887 $this->objProperties->setObjId($forumObj->getId());
1888
1889 $frm = new ilForum();
1890
1891 $success_message = 'forums_thread_deleted';
1892 if (count($threadIds) > 1) {
1893 $success_message = 'forums_threads_deleted';
1894 }
1895
1896 $threads = [];
1897 array_walk($threadIds, function (int $threadId) use (&$threads): void {
1898 $thread = new ilForumTopic($threadId);
1899 $this->ensureThreadBelongsToForum($this->object->getId(), $thread);
1900
1901 $threads[] = $thread;
1902 });
1903
1904 $frm->setForumId($forumObj->getId());
1905 $frm->setForumRefId($forumObj->getRefId());
1906 foreach ($threads as $thread) {
1907 $first_node = $frm->getFirstPostNode($thread->getId());
1908 if (isset($first_node['pos_pk']) && (int) $first_node['pos_pk']) {
1909 $frm->deletePost((int) $first_node['pos_pk']);
1910 $this->tpl->setOnScreenMessage('info', $this->lng->txt($success_message), true);
1911 }
1912 }
1913 $this->ctrl->redirect($this, 'showThreads');
1914 }

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

+ Here is the call graph for this function:

◆ performMergeThreadsObject()

ilObjForumGUI::performMergeThreadsObject ( )

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

4850 : void
4851 {
4852 if (!$this->is_moderator) {
4853 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4854 }
4855
4856 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
4857 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4858 }
4859
4860 $threadIds = array_values(
4861 array_filter(array_map(intval(...), (array) ($this->httpRequest->getParsedBody()['thread_ids'] ?? [])))
4862 );
4863 if (count($threadIds) !== 2) {
4864 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_one'));
4865 $this->showThreadsObject();
4866 return;
4867 }
4868
4869 if ((int) $threadIds[0] === (int) $threadIds[1]) {
4870 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('error_same_thread_ids'));
4871 $this->showThreadsObject();
4872 return;
4873 }
4874
4875 try {
4876 $frm = new ilForum();
4877 $frm->setForumId($this->object->getId());
4878 $frm->setForumRefId($this->object->getRefId());
4879
4880 $this->ensureThreadBelongsToForum($this->object->getId(), new ilForumTopic((int) $threadIds[0]));
4881 $this->ensureThreadBelongsToForum($this->object->getId(), new ilForumTopic((int) $threadIds[1]));
4882
4883 $frm->mergeThreads((int) $threadIds[0], (int) $threadIds[1]);
4884 $this->tpl->setOnScreenMessage('success', $this->lng->txt('merged_threads_successfully'));
4885 } catch (ilException $e) {
4886 $this->tpl->setOnScreenMessage('failure', $this->lng->txt($e->getMessage()));
4887 }
4888
4889 $this->showThreadsObject();
4890 }
Base class for ILIAS Exception handling.

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

+ Here is the call graph for this function:

◆ performMoveThreadsObject()

ilObjForumGUI::performMoveThreadsObject ( )

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

3841 : void
3842 {
3843 if (!$this->is_moderator) {
3844 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3845 }
3846
3847 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3848 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3849 }
3850
3851 $frm_ref_id = null;
3852 if ($this->http->wrapper()->post()->has('frm_ref_id')) {
3853 $frm_ref_id = $this->http->wrapper()->post()->retrieve(
3854 'frm_ref_id',
3855 $this->refinery->kindlyTo()->int()
3856 );
3857 } else {
3858 $this->error->raiseError('Please select a forum', $this->error->MESSAGE);
3859 }
3860
3861 $threads2move = ilSession::get('threads2move');
3862 if (!is_array($threads2move) || $threads2move === []) {
3863 $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_at_least_one_thread'), true);
3864 $this->ctrl->redirect($this, 'showThreads');
3865 }
3866
3867 if ((int) $frm_ref_id === $this->object->getRefId()
3868 || ilObject::_lookupType((int) $frm_ref_id, true) !== 'frm'
3869 || !$this->access->checkAccess('read', '', (int) $frm_ref_id)
3870 || !$this->access->checkAccess('moderate_frm', '', (int) $frm_ref_id)) {
3871 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3872 }
3873
3874 $threads = [];
3875 array_walk($threads2move, function (int $threadId) use (&$threads): void {
3876 $thread = new ilForumTopic($threadId);
3877 $this->ensureThreadBelongsToForum($this->object->getId(), $thread);
3878
3879 $threads[] = $threadId;
3880 });
3881
3882 if (isset($frm_ref_id) && (int) $frm_ref_id) {
3883 $errorMessages = $this->object->Forum->moveThreads(
3884 (array) (ilSession::get('threads2move') ?? []),
3885 $this->object,
3886 $this->ilObjDataCache->lookupObjId((int) $frm_ref_id)
3887 );
3888
3889 if ([] !== $errorMessages) {
3890 $this->tpl->setOnScreenMessage('failure', implode('<br><br>', $errorMessages), true);
3891 $this->ctrl->redirect($this, 'showThreads');
3892 }
3893
3894 ilSession::set('threads2move', []);
3895 $this->tpl->setOnScreenMessage('info', $this->lng->txt('threads_moved_successfully'), true);
3896 $this->ctrl->redirect($this, 'showThreads');
3897 } else {
3898 $this->tpl->setOnScreenMessage('info', $this->lng->txt('no_forum_selected'));
3899 $this->moveThreadsObject();
3900 }
3901 }
static _lookupType(int $id, bool $reference=false)

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

+ Here is the call graph for this function:

◆ performPostActivationObject()

ilObjForumGUI::performPostActivationObject ( )

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

2032 : void
2033 {
2034 if (!$this->is_moderator) {
2035 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2036 }
2037
2038 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2039 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2040 }
2041
2042 $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentPost->getThread());
2043
2044 $this->objCurrentPost->activatePost();
2045 $GLOBALS['ilAppEventHandler']->raise(
2046 'components/ILIAS/Forum',
2047 'activatedPost',
2048 [
2049 'object' => $this->object,
2050 'ref_id' => $this->object->getRefId(),
2051 'post' => $this->objCurrentPost
2052 ]
2053 );
2054 $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_post_was_activated'), true);
2055
2056 $this->viewThreadObject();
2057 }

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

+ Here is the call graph for this function:

◆ performThreadsActionObject()

ilObjForumGUI::performThreadsActionObject ( )

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

3725 : void
3726 {
3727 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3728 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3729 }
3730
3731 ilSession::set('threads2move', []);
3732
3733 $thread_ids = $this->retrieveThreadIds();
3734 $cmd = $this->ctrl->getCmd();
3735 $message = null;
3736
3737 if ($thread_ids !== []) {
3738 if ($cmd === 'move') {
3739 if ($this->is_moderator) {
3740 ilSession::set('threads2move', $thread_ids);
3741 $this->moveThreadsObject();
3742 }
3743 } elseif ($cmd === 'enable_notifications' && (int) $this->settings->get('forum_notification', '0') !== 0) {
3744 foreach ($thread_ids as $thread_id) {
3745 $tmp_obj = new ilForumTopic($thread_id);
3746 $this->ensureThreadBelongsToForum($this->object->getId(), $tmp_obj);
3747 $tmp_obj->enableNotification($this->user->getId());
3748 }
3749
3750 $this->ctrl->redirect($this, 'showThreads');
3751 } elseif ($cmd === 'disable_notifications' && (int) $this->settings->get('forum_notification', '0') !== 0) {
3752 foreach ($thread_ids as $thread_id) {
3753 $tmp_obj = new ilForumTopic($thread_id);
3754 $this->ensureThreadBelongsToForum($this->object->getId(), $tmp_obj);
3755 $tmp_obj->disableNotification($this->user->getId());
3756 }
3757
3758 $this->ctrl->redirect($this, 'showThreads');
3759 } elseif ($cmd === 'close') {
3760 if ($this->is_moderator) {
3761 foreach ($thread_ids as $thread_id) {
3762 $tmp_obj = new ilForumTopic($thread_id);
3763 $this->ensureThreadBelongsToForum($this->object->getId(), $tmp_obj);
3764 $tmp_obj->close();
3765 }
3766 }
3767 $this->tpl->setOnScreenMessage('success', $this->lng->txt('selected_threads_closed'), true);
3768 $this->ctrl->redirect($this, 'showThreads');
3769 } elseif ($cmd === 'reopen') {
3770 if ($this->is_moderator) {
3771 foreach ($thread_ids as $thread_id) {
3772 $tmp_obj = new ilForumTopic($thread_id);
3773 $this->ensureThreadBelongsToForum($this->object->getId(), $tmp_obj);
3774 $tmp_obj->reopen();
3775 }
3776 }
3777
3778 $this->tpl->setOnScreenMessage('success', $this->lng->txt('selected_threads_reopened'), true);
3779 $this->ctrl->redirect($this, 'showThreads');
3780 } elseif ($cmd === 'makesticky') {
3781 if ($this->is_moderator) {
3782 $message = $this->lng->txt('sel_threads_make_sticky');
3783
3784 foreach ($thread_ids as $thread_id) {
3785 $tmp_obj = new ilForumTopic($thread_id);
3786 $this->ensureThreadBelongsToForum($this->object->getId(), $tmp_obj);
3787 $makeSticky = $tmp_obj->makeSticky();
3788 if (!$makeSticky) {
3789 $message = $this->lng->txt('sel_threads_already_sticky');
3790 }
3791 }
3792 }
3793 if ($message !== null) {
3794 $this->tpl->setOnScreenMessage('info', $message, true);
3795 }
3796 $this->ctrl->redirect($this, 'showThreads');
3797 } elseif ($cmd === 'unmakesticky' || $cmd === 'make_topics_non_sticky') {
3798 if ($this->is_moderator) {
3799 $message = $this->lng->txt('sel_threads_make_unsticky');
3800 foreach ($thread_ids as $thread_id) {
3801 $tmp_obj = new ilForumTopic($thread_id);
3802 $this->ensureThreadBelongsToForum($this->object->getId(), $tmp_obj);
3803 $unmakeSticky = $tmp_obj->unmakeSticky();
3804 if (!$unmakeSticky) {
3805 $message = $this->lng->txt('sel_threads_already_unsticky');
3806 }
3807 }
3808 }
3809
3810 if ($message !== null) {
3811 $this->tpl->setOnScreenMessage('info', $message, true);
3812 }
3813 $this->ctrl->redirect($this, 'showThreads');
3814 } elseif ($cmd === 'editThread') {
3815 if ($this->is_moderator) {
3816 $count = count($thread_ids);
3817 if ($count !== 1) {
3818 $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_max_one_thread'), true);
3819 $this->ctrl->redirect($this, 'showThreads');
3820 } else {
3821 $this->updateThreadObject();
3822 return;
3823 }
3824 }
3825
3826 $this->ctrl->redirect($this, 'showThreads');
3827 } elseif ($cmd === 'confirmDeleteThreads') {
3828 $this->confirmDeleteThreadsObject();
3829 } elseif ($cmd === 'mergeThreads') {
3830 $this->mergeThreadsObject();
3831 } else {
3832 $this->tpl->setOnScreenMessage('info', $this->lng->txt('topics_please_select_one_action'), true);
3833 $this->ctrl->redirect($this, 'showThreads');
3834 }
3835 } else {
3836 $this->tpl->setOnScreenMessage('info', $this->lng->txt('select_at_least_one_thread'), true);
3837 $this->ctrl->redirect($this, 'showThreads');
3838 }
3839 }

References $message, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilSession\set(), ILIAS\Repository\settings(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ postingAttachmentDelivery()

ilObjForumGUI::postingAttachmentDelivery ( ilFileDataForumInterface  $storage)
private

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

263 {
264 return $this->auditedDelivery(
266 new ForumFileStorageDelivery($storage),
268 $this->attachment_ownership,
269 $this->objCurrentTopic->getId() > 0 ? $this->objCurrentTopic->getId() : null
270 )
271 )
272 );
273 }
Binds a posting to the forum object (and optionally to the thread) the request was routed to.

◆ preloadPostingFileResources()

ilObjForumGUI::preloadPostingFileResources ( array  $postings,
array  $draftsObjects 
)
private
Parameters
ilForumPost[]$postings
ilForumPostDraft[]$draftsObjects

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

6061 : void
6062 {
6063 $collectionIds = [];
6064
6065 foreach ($postings as $posting) {
6066 $rcid = $posting->getRCID();
6067 if ($rcid !== ilForumPost::NO_RCID && !empty($rcid)) {
6068 $collection_ids[] = $rcid;
6069 }
6070 }
6071
6072 foreach ($draftsObjects as $draft) {
6073 $rcid = $draft->getRCID();
6074 if ($rcid !== ilForumPostDraft::NO_RCID && !empty($rcid)) {
6075 $collection_ids[] = $rcid;
6076 }
6077 }
6078
6079 if (!empty($collection_ids)) {
6080 $this->irss->preloadCollections(array_unique($collection_ids));
6081 }
6082 }

References ilForumPost\NO_RCID, and ilForumPostDraft\NO_RCID.

◆ prepareFormOutput()

ilObjForumGUI::prepareFormOutput ( string  $a_text)

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

4441 : string
4442 {
4443 $a_text = str_replace(['&lt;', '&gt;'], ['<', '>'], $a_text);
4444
4446 }
static prepareFormOutput($a_str, bool $a_strip=false)

References ilLegacyFormElementsUtil\prepareFormOutput().

+ Here is the call graph for this function:

◆ publishDraftObject()

ilObjForumGUI::publishDraftObject ( bool  $use_replyform = true)

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

2662 : void
2663 {
2665 !$this->access->checkAccess('read', '', $this->object->getRefId())) {
2666 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2667 }
2668
2669 if (!$this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
2670 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2671 }
2672
2673 if ($this->objCurrentTopic->getId() === 0) {
2674 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_deleted'), true);
2675 $this->ctrl->redirect($this);
2676 }
2677
2678 if ($this->objCurrentTopic->isClosed()) {
2679 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_closed'), true);
2680 $this->ctrl->redirect($this);
2681 }
2682
2683 if ($this->objCurrentPost->getId() === 0) {
2684 $this->requestAction = '';
2685 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_parent_deleted'));
2686 $this->viewThreadObject();
2687 return;
2688 }
2689
2690 $draft = new ilForumPostDraft($this->user->getId(), $this->objCurrentPost->getId(), $this->retrieveDraftId());
2691 $this->checkDraftAccess($draft->getDraftId());
2692 $this->denyUnlessGranted(
2693 (new PostingBindingGuard($this->posting_placement))->decide(
2694 $this->object->getId(),
2695 $this->objCurrentTopic->getId(),
2696 $this->objCurrentPost->getId()
2697 )
2698 );
2699 $this->denyUnlessGranted(
2700 (new DraftBindingGuard($this->draft_placement, $this->user->getId()))->decideReply(
2701 $this->object->getId(),
2702 $this->objCurrentTopic->getId(),
2703 $this->objCurrentPost->getId(),
2704 $draft->getDraftId()
2705 )
2706 );
2707
2708 if ($use_replyform) {
2709 $oReplyEditForm = $this->getReplyEditForm();
2710 if (!$oReplyEditForm->checkInput()) {
2711 $oReplyEditForm->setValuesByPost();
2712 $this->viewThreadObject();
2713 return;
2714 }
2715 $post_subject = $oReplyEditForm->getInput('subject');
2716 $post_message = $oReplyEditForm->getInput('message');
2717 $mob_direction = 0;
2718 } else {
2719 $post_subject = $draft->getPostSubject();
2720 $post_message = $draft->getPostMessage();
2721 $mob_direction = 1;
2722 }
2723
2724 $oForumObjects = $this->getForumObjects();
2725 $frm = $oForumObjects['frm'];
2726 $frm->setMDB2WhereCondition(' top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
2727
2728 // reply: new post
2729 $status = true;
2730 $send_activation_mail = false;
2731
2732 if ($this->objProperties->isPostActivationEnabled()) {
2733 if (!$this->is_moderator) {
2734 $status = false;
2735 $send_activation_mail = true;
2736 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2737 $status = false;
2738 }
2739 }
2740
2741 $newPost = $frm->generatePost(
2742 $draft->getForumId(),
2743 $draft->getThreadId(),
2744 $this->user->getId(),
2745 $draft->getPostDisplayUserId(),
2746 ilRTE::_replaceMediaObjectImageSrc($post_message, $mob_direction),
2747 $draft->getPostId(),
2748 $draft->isNotificationEnabled(),
2749 $this->handleFormInput($post_subject, false),
2750 $draft->getPostUserAlias(),
2751 '',
2752 $status,
2753 $send_activation_mail
2754 );
2755
2756 $this->object->markPostRead(
2757 $this->user->getId(),
2758 $this->objCurrentTopic->getId(),
2759 $this->objCurrentPost->getId()
2760 );
2761
2762 $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
2763
2764 foreach ($uploadedObjects as $mob) {
2765 ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
2766 ilObjMediaObject::_saveUsage($mob, 'frm:html', $newPost);
2767 }
2768 ilForumUtil::saveMediaObjects($post_message, 'frm:html', $newPost, $mob_direction);
2769 $post_obj = new ilForumPost($newPost);
2770
2771 if ($draft->getRCID() > 0) {
2772 $post_obj->setRCID($draft->getRCID());
2773 $post_obj->update();
2774 }
2775
2776 if ($this->objProperties->isFileUploadAllowed()) {
2777 $file = $_FILES['userfile'] ?? [];
2778 if (is_array($file) && !empty($file)) {
2779 $tmp_file_obj = new ilFileDataForum($this->object->getId(), $newPost);
2780 $tmp_file_obj->storeUploadedFiles();
2781 }
2782 }
2783
2784 $GLOBALS['ilAppEventHandler']->raise(
2785 'components/ILIAS/Forum',
2786 'publishedDraft',
2787 [
2788 'draftObj' => $draft,
2789 'obj_id' => $this->object->getId(),
2790 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
2791 ]
2792 );
2793 $draft->deleteDraft();
2794
2795 $GLOBALS['ilAppEventHandler']->raise(
2796 'components/ILIAS/Forum',
2797 'createdPost',
2798 [
2799 'object' => $this->object,
2800 'ref_id' => $this->object->getRefId(),
2801 'post' => $post_obj,
2802 'notify_moderators' => $send_activation_mail
2803 ]
2804 );
2805
2806 $message = '';
2807 if (!$this->is_moderator && !$status) {
2808 $message .= $this->lng->txt('forums_post_needs_to_be_activated');
2809 } else {
2810 $message .= $this->lng->txt('forums_post_new_entry');
2811 }
2812
2813 $frm_session_values = ilSession::get('frm');
2814 if (is_array($frm_session_values)) {
2815 $frm_session_values[$this->objCurrentTopic->getId()]['openTreeNodes'][] = $this->objCurrentPost->getId();
2816 }
2817 ilSession::set('frm', $frm_session_values);
2818
2819 $this->ctrl->clearParameters($this);
2820 $this->tpl->setOnScreenMessage('success', $message, true);
2821 $this->ctrl->setParameter($this, 'pos_pk', $newPost);
2822 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2823
2824 $this->ctrl->redirect($this, 'viewThread');
2825 }
Binds a posting addressed by a reply or a draft action to the forum object and the thread of the curr...
static saveMediaObjects(string $post_message, string $target_type, int $target_id, int $direction=0)

References $GLOBALS, $message, ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), ilRTE\_replaceMediaObjectImageSrc(), ilObjMediaObject\_saveUsage(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilSession\get(), ilForumPostDraft\isSavePostDraftAllowed(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilForumUtil\saveMediaObjects(), ilSession\set(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ publishSelectedDraftObject()

ilObjForumGUI::publishSelectedDraftObject ( )

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

2654 : void
2655 {
2656 $draft_id = $this->retrieveDraftId();
2657 if ($draft_id > 0) {
2658 $this->publishDraftObject(false);
2659 }
2660 }
publishDraftObject(bool $use_replyform=true)

◆ publishThreadDraftObject()

ilObjForumGUI::publishThreadDraftObject ( )
protected

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

4324 : void
4325 {
4327 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4328 }
4329
4331 $this->checkDraftAccess($draft);
4332 $this->denyUnlessGranted(
4333 (new DraftBindingGuard($this->draft_placement, $this->user->getId()))->decideUnboundThread(
4334 $this->object->getId(),
4335 $draft->getDraftId()
4336 )
4337 );
4338
4339 $this->createThread($draft, true);
4340 }

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

+ Here is the call graph for this function:

◆ quotePostObject()

ilObjForumGUI::quotePostObject ( )

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

3107 : void
3108 {
3109 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3110 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3111 }
3112
3113 if ($this->objCurrentTopic->isClosed()) {
3114 $this->requestAction = '';
3115 $this->viewThreadObject();
3116 return;
3117 }
3118
3119 $oReplyEditForm = $this->getReplyEditForm();
3120
3121 $oReplyEditForm->getItemByPostVar('subject')->setRequired(false);
3122 $oReplyEditForm->getItemByPostVar('message')->setRequired(false);
3123
3124 $oReplyEditForm->checkInput();
3125
3126 $oReplyEditForm->getItemByPostVar('subject')->setRequired(true);
3127 $oReplyEditForm->getItemByPostVar('message')->setRequired(true);
3128
3129 $this->requestAction = 'showreply';
3130
3131 $this->viewThreadObject();
3132 }

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

+ 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 1164 of file class.ilObjForumGUI.php.

1169 : void {
1170 $frm = $this->object->Forum;
1171
1172 $draft_id = $this->retrieveDraftId();
1173 foreach ($drafts as $draft) {
1174 $tmp_file_obj = new ilFileDataForumDrafts($this->object->getId(), $draft->getDraftId());
1175 $filesOfDraft = $tmp_file_obj->getFilesOfPost();
1176 ksort($filesOfDraft);
1177
1178 if ($action !== 'showdraft' && $filesOfDraft !== []) {
1179 foreach ($filesOfDraft as $file) {
1180 $tpl->setCurrentBlock('attachment_download_row');
1181 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
1182 $this->ctrl->setParameter($this, 'file', $file['md5']);
1183 $tpl->setVariable('HREF_DOWNLOAD', $this->ctrl->getLinkTarget($this, 'viewThread'));
1184 $tpl->setVariable('TXT_FILENAME', $file['name']);
1185 $this->ctrl->setParameter($this, 'file', '');
1186 $this->ctrl->setParameter($this, 'draft_id', '');
1187 $this->ctrl->clearParameters($this);
1189 }
1190
1191 $tpl->setCurrentBlock('attachments');
1192 $tpl->setVariable('TXT_ATTACHMENTS_DOWNLOAD', $this->lng->txt('forums_attachments'));
1193 $tpl->setVariable(
1194 'DOWNLOAD_IMG',
1195 $this->uiRenderer->render(
1196 $this->uiFactory->symbol()->glyph()->attachment()
1197 )
1198 );
1199 if (count($filesOfDraft) > 1) {
1200 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
1201 $download_zip_button = $this->uiFactory->button()
1202 ->standard(
1203 $this->lng->txt('download'),
1204 $this->ctrl->getLinkTarget($this, 'deliverDraftZipFile')
1205 );
1206 $this->ctrl->setParameter($this, 'draft_id', '');
1207 $tpl->setVariable('DOWNLOAD_ZIP', $this->uiRenderer->render($download_zip_button));
1208 }
1210 }
1211
1212 $page = $this->http->wrapper()->query()->retrieve(
1213 'page',
1214 $this->refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
1215 );
1216
1217 $this->renderSplitButton(
1218 $tpl,
1219 $action,
1220 false,
1221 $referencePosting,
1222 (int) $page,
1223 $draft
1224 );
1225
1226 $rowCol = 'tblrowmarked';
1227 $tpl->setVariable('ROWCOL', ' ' . $rowCol);
1228 $depth = $referencePosting->getDepth() - 1;
1229 if ($this->selectedSorting === ilForumProperties::VIEW_TREE) {
1230 ++$depth;
1231 }
1232 $tpl->setVariable('DEPTH', $depth);
1233
1234 $this->ctrl->setParameter($this, 'pos_pk', $referencePosting->getId());
1235 $this->ctrl->setParameter($this, 'thr_pk', $referencePosting->getThreadId());
1236 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
1237
1238 $backurl = urlencode($this->ctrl->getLinkTarget($this, 'viewThread', (string) $referencePosting->getId()));
1239
1240 $this->ctrl->setParameter($this, 'backurl', $backurl);
1241 $this->ctrl->setParameter($this, 'thr_pk', $referencePosting->getThreadId());
1242 $this->ctrl->setParameter($this, 'user', $draft->getPostDisplayUserId());
1243
1244 $authorinfo = new ilForumAuthorInformation(
1245 $draft->getPostAuthorId(),
1246 $draft->getPostDisplayUserId(),
1247 $draft->getPostUserAlias(),
1248 '',
1249 [
1250 'href' => $this->ctrl->getLinkTarget($this, 'showUser')
1251 ]
1252 );
1253
1254 $this->ctrl->clearParameters($this);
1255
1256 if ($authorinfo->hasSuffix()) {
1257 $tpl->setVariable('AUTHOR', $authorinfo->getSuffix());
1258 $tpl->setVariable('USR_NAME', $draft->getPostUserAlias());
1259 } else {
1260 $tpl->setVariable('AUTHOR', $authorinfo->getLinkedAuthorShortName());
1261 if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized()) {
1262 $tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true));
1263 }
1264 }
1265 $tpl->setVariable('DRAFT_ANCHOR', 'draft_' . $draft->getDraftId());
1266
1267 $tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture());
1269 'USR_ICON_ALT',
1270 ilLegacyFormElementsUtil::prepareFormOutput($authorinfo->getAuthorShortName())
1271 );
1272 if ($authorinfo->getAuthor()->getId() && ilForum::_isModerator(
1273 $this->object->getRefId(),
1274 $draft->getPostAuthorId()
1275 )) {
1276 if ($authorinfo->getAuthor()->getGender() === 'f') {
1277 $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_f'));
1278 } elseif ($authorinfo->getAuthor()->getGender() === 'm') {
1279 $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_m'));
1280 } elseif ($authorinfo->getAuthor()->getGender() === 'n') {
1281 $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_n'));
1282 }
1283 }
1284
1285 if ($draft->getUpdateUserId() > 0) {
1286 $draft->setPostUpdate($draft->getPostUpdate());
1287
1288 $this->ctrl->setParameter($this, 'backurl', $backurl);
1289 $this->ctrl->setParameter($this, 'thr_pk', $referencePosting->getThreadId());
1290 $this->ctrl->setParameter($this, 'user', $referencePosting->getUpdateUserId());
1291 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
1292
1293 $authorinfo = new ilForumAuthorInformation(
1294 $draft->getPostAuthorId(),
1295 // We assume the editor is the author here
1296 $draft->getPostDisplayUserId(),
1297 $draft->getPostUserAlias(),
1298 '',
1299 ['href' => $this->ctrl->getLinkTarget($this, 'showUser')]
1300 );
1301
1302 $this->ctrl->clearParameters($this);
1303
1305 'POST_UPDATE_TXT',
1306 $this->lng->txt('edited_on') . ': ' . $frm->convertDate($draft->getPostUpdate()) . ' - ' . strtolower($this->lng->txt('by'))
1307 );
1308 $tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
1309 if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
1310 $tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true));
1311 }
1312 }
1313
1314 $draft->setPostMessage($frm->prepareText($draft->getPostMessage()));
1315
1316 $tpl->setVariable('SUBJECT', $draft->getPostSubject());
1317 $tpl->setVariable('POST_DATE', $frm->convertDate($draft->getPostDate()));
1318
1319 $tpl->setVariable('POST_DRAFT_TEXT', $this->lng->txt('post_draft_info'));
1320
1321 if (!$referencePosting->isCensored() || ($this->objCurrentPost->getId() === $referencePosting->getId() && $action === 'censor')) {
1322 $spanClass = '';
1323 if (ilForum::_isModerator($this->ref_id, $draft->getPostDisplayUserId())) {
1324 $spanClass = 'moderator';
1325 }
1326
1327 if ($draft->getPostMessage() === strip_tags($draft->getPostMessage())) {
1328 // We can be sure, that there are not html tags
1329 $draft->setPostMessage(nl2br($draft->getPostMessage()));
1330 }
1331
1332 if ($spanClass !== '') {
1334 'POST',
1335 '<span class="' . $spanClass . '">' . ilRTE::_replaceMediaObjectImageSrc(
1336 $draft->getPostMessage(),
1337 1
1338 ) . '</span>'
1339 );
1340 } else {
1341 $tpl->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($draft->getPostMessage(), 1));
1342 }
1343 }
1344
1345 if ($action === 'editdraft' && $draft->getDraftId() === $draft_id) {
1346 $oEditReplyForm = $this->getReplyEditForm();
1347
1348 if (!$this->objCurrentTopic->isClosed() && in_array($this->requestAction, ['showdraft', 'editdraft'])) {
1349 $this->renderPostingForm($tpl, $frm, $referencePosting, $this->requestAction);
1350 }
1351
1352 $tpl->setVariable('EDIT_DRAFT_ANCHOR', 'draft_edit_' . $draft->getDraftId());
1353 $tpl->setVariable('DRAFT_FORM', $oEditReplyForm->getHTML() . $this->modal_history);
1354 }
1355
1357 }
1358 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
static _isModerator(int $a_ref_id, int $a_usr_id)
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)
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.

◆ renderPostContent()

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

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

1366 : void {
1367 $forumObj = $this->object;
1368 $frm = $this->object->Forum;
1369
1370 $fileDataOfForum = new ilFileDataForum($forumObj->getId(), $node->getId());
1371
1372 $filesOfPost = $fileDataOfForum->getFilesOfPost();
1373 ksort($filesOfPost);
1374 if ($filesOfPost !== [] && ($action !== 'showedit' || $node->getId() !== $this->objCurrentPost->getId())) {
1375 foreach ($filesOfPost as $file) {
1376 $tpl->setCurrentBlock('attachment_download_row');
1377 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
1378 $this->ctrl->setParameter($this, 'file', $file['md5']);
1379 $tpl->setVariable('HREF_DOWNLOAD', $this->ctrl->getLinkTarget($this, 'viewThread'));
1380 $tpl->setVariable('TXT_FILENAME', $file['name']);
1381 $this->ctrl->clearParameters($this);
1383 }
1384 $tpl->setCurrentBlock('attachments');
1385 $tpl->setVariable('TXT_ATTACHMENTS_DOWNLOAD', $this->lng->txt('forums_attachments'));
1386 $tpl->setVariable(
1387 'DOWNLOAD_IMG',
1388 $this->uiRenderer->render(
1389 $this->uiFactory->symbol()->glyph()->attachment()
1390 )
1391 );
1392 if (count($filesOfPost) > 1) {
1393 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
1394 $download_zip_button = $this->uiFactory->button()
1395 ->standard(
1396 $this->lng->txt('download'),
1397 $this->ctrl->getLinkTarget($this, 'deliverZipFile')
1398 );
1399 $tpl->setVariable('DOWNLOAD_ZIP', $this->uiRenderer->render($download_zip_button));
1400 }
1402 }
1403 $this->renderSplitButton($tpl, $action, true, $node, $pageIndex);
1404
1405 $tpl->setVariable('POST_ANKER', $node->getId());
1406 $tpl->setVariable('TXT_PERMA_LINK', $this->lng->txt('perma_link'));
1407 $tpl->setVariable('PERMA_TARGET', '_top');
1408
1409 $rowCol = ilUtil::switchColor($postIndex, 'tblrow1', 'tblrow2');
1410 if (($this->is_moderator || $node->isOwner($this->user->getId())) && !$node->isActivated() && !$this->objCurrentTopic->isClosed()) {
1411 $rowCol = 'ilPostingNeedsActivation';
1412 } elseif ($this->objProperties->getMarkModeratorPosts()) {
1413 $isAuthorModerator = ilForum::_isModerator($this->object->getRefId(), $node->getPosAuthorId());
1414 if ($isAuthorModerator && $node->isAuthorModerator() === null) {
1415 $rowCol = 'ilModeratorPosting';
1416 } elseif ($node->isAuthorModerator()) {
1417 $rowCol = 'ilModeratorPosting';
1418 }
1419 }
1420
1421 if (
1422 (!in_array($action, ['delete', 'censor']) && !$this->displayConfirmPostActivation()) ||
1423 $this->objCurrentPost->getId() !== $node->getId()
1424 ) {
1425 $tpl->setVariable('ROWCOL', ' ' . $rowCol);
1426 } else {
1427 $rowCol = 'tblrowmarked';
1428 }
1429
1430 if ($node->isCensored()) {
1431 if ($action !== 'censor') {
1432 $tpl->setVariable('TXT_CENSORSHIP_ADVICE', $this->lng->txt('post_censored_comment_by_moderator'));
1433 }
1434
1435 $rowCol = 'tblrowmarked';
1436 }
1437
1438 $tpl->setVariable('ROWCOL', ' ' . $rowCol);
1439 $tpl->setVariable('DEPTH', $node->getDepth() - 1);
1440 if (!$node->isActivated() && ($node->isOwner($this->user->getId()) || $this->is_moderator)) {
1441 $tpl->setVariable('POST_NOT_ACTIVATED_YET', $this->lng->txt('frm_post_not_activated_yet'));
1442 }
1443
1444 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
1445 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
1446 $backurl = urlencode($this->ctrl->getLinkTarget($this, 'viewThread', (string) $node->getId()));
1447 $this->ctrl->clearParameters($this);
1448
1449 $this->ctrl->setParameter($this, 'backurl', $backurl);
1450 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
1451 $this->ctrl->setParameter($this, 'user', $node->getDisplayUserId());
1452 $authorinfo = new ilForumAuthorInformation(
1453 $node->getPosAuthorId(),
1454 $node->getDisplayUserId(),
1455 (string) $node->getUserAlias(),
1456 (string) $node->getImportName(),
1457 [
1458 'href' => $this->ctrl->getLinkTarget($this, 'showUser')
1459 ]
1460 );
1461 $this->ctrl->clearParameters($this);
1462
1463 if ($authorinfo->hasSuffix()) {
1464 if (!$authorinfo->isDeleted()) {
1465 $tpl->setVariable('USR_NAME', $authorinfo->getAlias());
1466 }
1467 $tpl->setVariable('AUTHOR', $authorinfo->getSuffix());
1468 } else {
1469 if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized()) {
1470 $tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true));
1471 }
1472 $tpl->setVariable('AUTHOR', $authorinfo->getLinkedAuthorShortName());
1473 }
1474
1475 $tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture());
1477 'USR_ICON_ALT',
1478 ilLegacyFormElementsUtil::prepareFormOutput($authorinfo->getAuthorShortName())
1479 );
1480 $isModerator = ilForum::_isModerator($this->ref_id, $node->getPosAuthorId());
1481 if ($isModerator && $authorinfo->getAuthor()->getId()) {
1482 $authorRole = $this->lng->txt('frm_moderator_n');
1483 if (is_string($authorinfo->getAuthor()->getGender()) && $authorinfo->getAuthor()->getGender() !== '') {
1484 $authorRole = $this->lng->txt('frm_moderator_' . $authorinfo->getAuthor()->getGender());
1485 }
1486 $tpl->setVariable('ROLE', $authorRole);
1487 }
1488
1489 if ($node->getUpdateUserId() > 0) {
1490 $node->setChangeDate($node->getChangeDate());
1491
1492 $this->ctrl->setParameter($this, 'backurl', $backurl);
1493 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
1494 $this->ctrl->setParameter($this, 'user', $node->getUpdateUserId());
1495 $update_user_id = $node->getUpdateUserId();
1496 if ($node->getDisplayUserId() === 0 && $node->getPosAuthorId() === $node->getUpdateUserId()) {
1497 $update_user_id = $node->getDisplayUserId();
1498 }
1499 $authorinfo = new ilForumAuthorInformation(
1500 $node->getPosAuthorId(),
1501 $update_user_id,
1502 (string) $node->getUserAlias(),
1503 (string) $node->getImportName(),
1504 [
1505 'href' => $this->ctrl->getLinkTarget($this, 'showUser')
1506 ]
1507 );
1508 $this->ctrl->clearParameters($this);
1509
1511 'POST_UPDATE_TXT',
1512 $this->lng->txt('edited_on') . ': ' . $frm->convertDate($node->getChangeDate()) . ' - ' . strtolower($this->lng->txt('by'))
1513 );
1514 $tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
1515 if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized() && !$authorinfo->hasSuffix()) {
1516 $tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true));
1517 }
1518 }
1519
1520 if ($this->selectedSorting === ilForumProperties::VIEW_TREE
1521 && $node->getId() !== $this->selected_post_storage->get($node->getThreadId())) {
1522 $target = $this->uiFactory->symbol()->icon()->custom(
1523 ilUtil::getImagePath('object/target.svg'),
1524 $this->lng->txt('target_select')
1525 );
1526
1527 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
1528 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
1529
1531 'TARGET',
1532 $this->uiRenderer->render(
1533 $this->uiFactory->link()->bulky(
1534 $target,
1535 $this->lng->txt('select'),
1536 new \ILIAS\Data\URI(
1537 ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTarget($this, 'selectPost', (string) $node->getId())
1538 )
1539 )
1540 )
1541 );
1542 }
1543
1544 $node->setMessage($frm->prepareText($node->getMessage()));
1545
1546 if ($this->user->isAnonymous() || $node->isPostRead()) {
1547 $tpl->setVariable('SUBJECT', $node->getSubject());
1548 } else {
1549 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
1550 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
1551 $this->ctrl->setParameter($this, 'page', $pageIndex);
1552 $this->ctrl->setParameter(
1553 $this,
1554 'orderby',
1555 $this->getOrderByParam()
1556 );
1557 $this->ctrl->setParameter($this, 'viewmode', $this->selectedSorting);
1558 $mark_post_target = $this->ctrl->getLinkTarget($this, 'markPostRead', (string) $node->getId());
1559
1561 'SUBJECT',
1562 '<a href="' . $mark_post_target . '"><b>' . $node->getSubject() . '</b></a>'
1563 );
1564 }
1565
1566 $tpl->setVariable('POST_DATE', $frm->convertDate($node->getCreateDate()));
1567
1568 if (!$node->isCensored() || ($this->objCurrentPost->getId() === $node->getId() && $action === 'censor')) {
1569 $spanClass = '';
1570 if (ilForum::_isModerator($this->ref_id, $node->getDisplayUserId())) {
1571 $spanClass = 'moderator';
1572 }
1573
1574 // possible bugfix for mantis #8223
1575 if ($node->getMessage() === strip_tags($node->getMessage())) {
1576 // We can be sure, that there are not html tags
1577 $node->setMessage(nl2br($node->getMessage()));
1578 }
1579
1580 if ($spanClass !== '') {
1582 'POST',
1583 '<span class="' . $spanClass . '">' .
1585 '</span>'
1586 );
1587 } else {
1589 }
1590 } else {
1592 'POST',
1593 '<span class="moderator">' . nl2br((string) $node->getCensorshipComment()) . '</span>'
1594 );
1595 }
1596
1598 }
setMessage(string $a_message)
isOwner(int $a_user_id=0)
setChangeDate(?string $a_changedate)
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)

◆ renderPostingForm()

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

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

5896 : void
5897 {
5898 $draft_id = $this->retrieveDraftId();
5899 if ($action === 'showedit' && (
5900 (!$this->is_moderator && !$node->isOwner($this->user->getId())) ||
5901 $this->user->isAnonymous() ||
5902 $node->isCensored()
5903 )) {
5904 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5905 } elseif ($action === 'showreply' && !$this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
5906 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5907 }
5908
5909 $tpl->setVariable('REPLY_ANKER', 'reply_' . $this->objCurrentPost->getId());
5910 $oEditReplyForm = $this->getReplyEditForm();
5911 $subject = '';
5912 if ($action !== 'editdraft') {
5913 switch ($this->objProperties->getSubjectSetting()) {
5914 case 'add_re_to_subject':
5915 $subject = $this->getModifiedReOnSubject();
5916 break;
5917
5918 case 'preset_subject':
5919 $subject = $this->objCurrentPost->getSubject();
5920 break;
5921
5922 case 'empty_subject':
5923 $subject = '';
5924 break;
5925 }
5926 }
5927
5928 switch ($action) {
5929 case 'showreply':
5930 if ($this->ctrl->getCmd() === 'savePost' || $this->ctrl->getCmd() === 'saveAsDraft') {
5931 $oEditReplyForm->setValuesByPost();
5932 } elseif ($this->ctrl->getCmd() === 'quotePost') {
5933 $authorinfo = new ilForumAuthorInformation(
5934 $node->getPosAuthorId(),
5935 $node->getDisplayUserId(),
5936 (string) $node->getUserAlias(),
5937 (string) $node->getImportName()
5938 );
5939
5940 $oEditReplyForm->setValuesByPost();
5941 $oEditReplyForm->getItemByPostVar('message')->setValue(
5943 $frm->prepareText(
5944 $node->getMessage(),
5945 1,
5946 $authorinfo->getAuthorName()
5947 ) . "\n" . $oEditReplyForm->getInput('message'),
5948 1
5949 )
5950 );
5951 } else {
5952 $oEditReplyForm->setValuesByArray([
5953 'draft_id' => $draft_id,
5954 'alias' => '',
5955 'subject' => $subject,
5956 'message' => '',
5957 'notify' => 0,
5958 'userfile' => '',
5959 'del_file' => []
5960 ]);
5961 }
5962 break;
5963
5964 case 'showedit':
5965 if ($this->ctrl->getCmd() === 'savePost') {
5966 $oEditReplyForm->setValuesByPost();
5967 } else {
5968 $oEditReplyForm->setValuesByArray([
5969 'alias' => '',
5970 'subject' => $this->objCurrentPost->getSubject(),
5972 $this->objCurrentPost->getMessage(),
5973 2
5974 ), 1),
5975 'notify' => $this->objCurrentPost->isNotificationEnabled() && !$this->user->isAnonymous(),
5976 'userfile' => '',
5977 'del_file' => [],
5978 'draft_id' => $draft_id
5979 ]);
5980 }
5981 break;
5982
5983 case 'editdraft':
5984 if (in_array($this->ctrl->getCmd(), ['saveDraft', 'updateDraft', 'publishDraft'])) {
5985 $oEditReplyForm->setValuesByPost();
5986 } elseif ($draft_id > 0) {
5987 $draftObject = new ilForumPostDraft(
5988 $this->user->getId(),
5989 $this->objCurrentPost->getId(),
5990 $draft_id
5991 );
5992 $oEditReplyForm->setValuesByArray([
5993 'alias' => $draftObject->getPostUserAlias(),
5994 'subject' => $draftObject->getPostSubject(),
5996 $draftObject->getPostMessage(),
5997 2
5998 ), 1),
5999 'notify' => $draftObject->isNotificationEnabled() && !$this->user->isAnonymous(),
6000 'userfile' => '',
6001 'del_file' => [],
6002 'draft_id' => $draft_id
6003 ]);
6004 }
6005 break;
6006 }
6007
6008 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
6009 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
6010 $this->ctrl->setParameter($this, 'page', (int) ($this->httpRequest->getQueryParams()['page'] ?? 0));
6011 $this->ctrl->setParameter(
6012 $this,
6013 'orderby',
6014 $this->getOrderByParam()
6015 );
6016 $this->ctrl->setParameter(
6017 $this,
6018 'action',
6019 ilUtil::stripSlashes($this->requestAction)
6020 );
6021 if ($action !== 'editdraft') {
6022 $tpl->setVariable('FORM', $oEditReplyForm->getHTML());
6023 }
6024 $this->ctrl->clearParameters($this);
6025 }
prepareText(string $text, int $edit=0, string $quote_user='', string $type='')

References ILIAS\News\Common\Table\$tpl, ilRTE\_replaceMediaObjectImageSrc(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilForumPost\getDisplayUserId(), ilForumPost\getImportName(), ilForumPost\getMessage(), ilForumPost\getPosAuthorId(), ilForumPost\getUserAlias(), ilForumPost\isCensored(), ilForumPost\isOwner(), ILIAS\Repository\lng(), ilForum\prepareText(), ILIAS\UICore\GlobalTemplate\setVariable(), ilUtil\stripSlashes(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ renderSortationControl()

ilObjForumGUI::renderSortationControl ( int  $currentSorting)
private

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

3654 : void
3655 {
3656 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3657 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
3658 $target = $this->ctrl->getLinkTarget(
3659 $this,
3660 'viewThread',
3661 ''
3662 );
3663
3664 $translatedSortationOptions = array_map(fn($value): string => $this->lng->txt($value), $this->sortationOptions);
3665
3666 $sortingDirectionViewControl = $this->uiFactory
3667 ->viewControl()
3668 ->sortation($translatedSortationOptions, (string) $currentSorting)
3669 ->withTargetURL($target, 'viewmode');
3670 $this->toolbar->addComponent($sortingDirectionViewControl);
3671 }

References ILIAS\Scripts\PHPStan\$target, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

+ Here is the call 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 5529 of file class.ilObjForumGUI.php.

5536 : void {
5537 $draft_id = $this->retrieveDraftId();
5538
5539 $actions = [];
5540 if ($is_post) {
5541 if (($this->objCurrentPost->getId() !== $node->getId() || (
5542 !in_array($action, ['showreply', 'showedit', 'censor', 'delete'], true) &&
5544 )) && ($this->is_moderator || $node->isActivated() || $node->isOwner($this->user->getId()))) {
5545 if ($this->is_moderator && !$this->objCurrentTopic->isClosed() && !$node->isActivated()) {
5546 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5547 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5548 $this->ctrl->setParameter($this, 'page', $pageIndex);
5549 $this->ctrl->setParameter(
5550 $this,
5551 'orderby',
5552 $this->getOrderByParam()
5553 );
5554 $primary_action = $this->ctrl->getLinkTarget(
5555 $this,
5556 'askForPostActivation',
5557 (string) $node->getId()
5558 );
5559 $primary_action_language_id = 'activate_post';
5560 $this->ctrl->clearParameters($this);
5561 }
5562 if (
5563 !$this->objCurrentTopic->isClosed() && $node->isActivated() && !$node->isCensored() &&
5564 $this->access->checkAccess('add_reply', '', $this->object->getRefId())
5565 ) {
5566 $this->ctrl->setParameter($this, 'action', 'showreply');
5567 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5568 $this->ctrl->setParameter($this, 'page', $pageIndex);
5569 $this->ctrl->setParameter(
5570 $this,
5571 'orderby',
5572 $this->getOrderByParam()
5573 );
5574 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5575 $primary_action = $this->ctrl->getLinkTarget(
5576 $this,
5577 'viewThread',
5578 'reply_' . $node->getId()
5579 );
5580 $primary_action_language_id = 'reply_to_postings';
5581 $this->ctrl->clearParameters($this);
5582 }
5583 if (
5584 !$this->objCurrentTopic->isClosed() &&
5585 !$node->isCensored() &&
5586 !$this->user->isAnonymous() &&
5587 ($node->isOwner($this->user->getId()) || $this->is_moderator)
5588 ) {
5589 $this->ctrl->setParameter($this, 'action', 'showedit');
5590 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5591 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5592 $this->ctrl->setParameter($this, 'page', $pageIndex);
5593 $this->ctrl->setParameter(
5594 $this,
5595 'orderby',
5596 $this->getOrderByParam()
5597 );
5598 $actions['edit'] = $this->ctrl->getLinkTarget($this, 'viewThread', (string) $node->getId());
5599 $this->ctrl->clearParameters($this);
5600 }
5601 if (!$this->user->isAnonymous()) {
5602 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5603 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5604 $this->ctrl->setParameter($this, 'page', $pageIndex);
5605 $this->ctrl->setParameter(
5606 $this,
5607 'orderby',
5608 $this->getOrderByParam()
5609 );
5610 $this->ctrl->setParameter($this, 'viewmode', $this->selectedSorting);
5611
5612 $read_undread_txt = 'frm_mark_as_read';
5613 $read_undread_cmd = 'markPostRead';
5614 if ($node->isPostRead()) {
5615 $read_undread_txt = 'frm_mark_as_unread';
5616 $read_undread_cmd = 'markPostUnread';
5617 }
5618 $actions[$read_undread_txt] = $this->ctrl->getLinkTarget(
5619 $this,
5620 $read_undread_cmd,
5621 (string) $node->getId()
5622 );
5623
5624 $this->ctrl->clearParameters($this);
5625 }
5626 if (!$node->isCensored()) {
5627 $this->ctrl->setParameterByClass(ilForumExportGUI::class, 'top_pk', $node->getForumId());
5628 $this->ctrl->setParameterByClass(ilForumExportGUI::class, 'thr_pk', $node->getThreadId());
5629
5630
5631 $this->ctrl->clearParameters($this);
5632 }
5633 if (
5634 !$this->objCurrentTopic->isClosed() &&
5635 !$this->user->isAnonymous() &&
5636 ($this->is_moderator || ($node->isOwner($this->user->getId()) && !$node->hasReplies()))
5637 ) {
5638 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5639 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5640 $this->ctrl->setParameter($this, 'page', $pageIndex);
5641 $this->ctrl->setParameter(
5642 $this,
5643 'orderby',
5644 $this->getOrderByParam()
5645 );
5646 $actions['delete'] = $this->ctrl->getFormAction($this, 'deletePosting');
5647 $this->ctrl->clearParameters($this);
5648 }
5649 if ($this->is_moderator && !$this->objCurrentTopic->isClosed()) {
5650 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5651 $this->ctrl->setParameter($this, 'thr_pk', $node->getThreadId());
5652 $this->ctrl->setParameter($this, 'page', $pageIndex);
5653 $this->ctrl->setParameter(
5654 $this,
5655 'orderby',
5656 $this->getOrderByParam()
5657 );
5658 if ($node->isCensored()) {
5659 $this->ctrl->setParameter($this, 'action', 'viewThread');
5660 $actions['frm_revoke_censorship'] = $this->ctrl->getFormAction($this, 'revokeCensorship');
5661 } else {
5662 $actions['frm_censorship'] = $this->ctrl->getFormAction($this, 'addCensorship');
5663 }
5664 $this->ctrl->clearParameters($this);
5665 }
5666 }
5667 } elseif ($draft_id !== $draft->getDraftId() || !in_array($action, ['deletedraft', 'editdraft'])) {
5668 // get actions for drafts
5669 $this->ctrl->setParameter($this, 'action', 'publishdraft');
5670 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5671 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
5672 $this->ctrl->setParameter($this, 'page', $pageIndex);
5673 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
5674 $this->ctrl->setParameter(
5675 $this,
5676 'orderby',
5677 $this->getOrderByParam()
5678 );
5679 $primary_action = $this->ctrl->getLinkTarget($this, 'publishSelectedDraft', (string) $node->getId());
5680 $primary_action_language_id = 'publish';
5681 $this->ctrl->clearParameters($this);
5682
5683 $this->ctrl->setParameter($this, 'action', 'editdraft');
5684 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5685 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
5686 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
5687 $this->ctrl->setParameter($this, 'page', $pageIndex);
5688 $this->ctrl->setParameter(
5689 $this,
5690 'orderby',
5691 $this->getOrderByParam()
5692 );
5693 $actions['edit'] = $this->ctrl->getLinkTarget($this, 'editDraft', 'draft_edit_' . $draft->getDraftId());
5694 $this->ctrl->clearParameters($this);
5695
5696 $this->ctrl->setParameter($this, 'pos_pk', $node->getId());
5697 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
5698 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
5699 $this->ctrl->setParameter($this, 'page', $pageIndex);
5700 $this->ctrl->setParameter(
5701 $this,
5702 'orderby',
5703 $this->getOrderByParam()
5704 );
5705 $actions['delete'] = $this->ctrl->getFormAction($this, 'deletePostingDraft');
5706 $this->ctrl->clearParameters($this);
5707
5708 if ($draft_id !== 0 && $action === 'editdraft') {
5709 $actions = [];
5710 }
5711 }
5712
5713 $tpl->setCurrentBlock('posts_row');
5714 if ($actions !== [] && !$this->objCurrentTopic->isClosed()) {
5715 $items = [];
5716 foreach ($actions as $lng_id => $url) {
5717 if ($lng_id === 'frm_revoke_censorship' || $lng_id === 'frm_censorship') {
5718 $modalTemplate = new ilTemplate('tpl.forums_censor_modal.html', true, true, 'components/ILIAS/Forum');
5719 $form_id = str_replace('.', '_', uniqid('form', true));
5720 $modalTemplate->setVariable('FORM_ID', $form_id);
5721
5722 if ($node->isCensored()) {
5723 $modalTemplate->setVariable('BODY', $this->lng->txt('forums_info_censor2_post'));
5724 } else {
5725 $modalTemplate->setVariable('BODY', $this->lng->txt('forums_info_censor_post'));
5726 $modalTemplate->touchBlock('message');
5727 }
5728
5729 $modalTemplate->setVariable('FORM_ACTION', $url);
5730
5731 $content = $this->uiFactory->legacy()->content($modalTemplate->get());
5732 $submitBtn = $this->uiFactory->button()->primary(
5733 $this->lng->txt('submit'),
5734 '#'
5735 )->withOnLoadCode(
5736 static function (string $id) use ($form_id): string {
5737 return "
5738 (function () {
5739 const button = document.getElementById('$id');
5740 if (!button) return;
5741
5742 const form = document.getElementById('$form_id');
5743 if (!form) return;
5744
5745 button.addEventListener('click', (event) => {
5746 event.preventDefault();
5747 form.submit();
5748 }, true);
5749 }());
5750 ";
5751 }
5752 );
5753 $modal = $this->uiFactory->modal()->roundtrip(
5754 $this->lng->txt($lng_id),
5755 [$content]
5756 )->withActionButtons([$submitBtn]);
5757 $items[] = $this->uiFactory->button()->shy($this->lng->txt($lng_id), '#')->withOnClick(
5758 $modal->getShowSignal()
5759 );
5760
5761 $this->modalActionsContainer[] = $modal;
5762 continue;
5763 }
5764
5765 if ($lng_id === 'delete') {
5766 $modal = $this->uiFactory->modal()->interruptive(
5767 $this->lng->txt($lng_id),
5768 str_contains($url, 'deletePostingDraft') ?
5769 $this->lng->txt('forums_info_delete_draft') :
5770 $this->lng->txt('forums_info_delete_post'),
5771 $url
5772 )->withActionButtonLabel(
5773 $this->lng->txt(str_contains($url, 'deletePostingDraft') ? 'deletePostingDraft' : 'deletePosting')
5774 );
5775
5776 $items[] = $this->uiFactory->button()->shy($this->lng->txt($lng_id), '#')->withOnClick(
5777 $modal->getShowSignal()
5778 );
5779
5780 $this->modalActionsContainer[] = $modal;
5781
5782
5783 continue;
5784 }
5785
5786 $items[] = $this->uiFactory->button()->shy($this->lng->txt($lng_id), $url);
5787 }
5788
5789 $dropdown = $this->uiFactory->dropdown()->standard($items);
5790 $render_action_buttons = [$dropdown];
5791 if (isset($primary_action, $primary_action_language_id)) {
5792 if ($primary_action_language_id === 'activate_post') {
5793 $action_button = $this->addActivationFormModal($node);
5794 } else {
5795 $action_button = $this->uiFactory->button()->standard(
5796 $this->lng->txt($primary_action_language_id),
5797 $primary_action
5798 );
5799 }
5800 $tpl->setVariable('MAIN_ACTION', $this->uiRenderer->render($action_button));
5801 }
5802 $tpl->setVariable('DROPDOWN_ACTIONS', $this->uiRenderer->render($render_action_buttons));
5803 }
5804 }
addActivationFormModal(ilForumPost $node)

References ILIAS\Repository\ctrl(), ilForumPost\getForumId(), ilForumPost\getId(), ilForumPost\getThreadId(), ilForumPost\hasReplies(), ilForumPost\isActivated(), ilForumPost\isCensored(), ilForumPost\isOwner(), ilForumPost\isPostRead(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ renderThreadOverview()

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

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

786 : void
787 {
788 if ($frm_object === null) {
789 $vc_container = $this->factory->panel()->listing()->standard(
790 $this->lng->txt('thread_overview'),
791 [$this->factory->item()->group($this->lng->txt('frm_no_threads'), [])]
792 );
793 $default_html = $this->renderer->render($vc_container);
794 $modals = '';
795 } else {
796 $current_page = $this->forum_thread_table_session_storage->getThreadPage();
797 $last_page = max(
798 0,
799 (int) ceil($frm_object->getTopNumThreads() / ilForumProperties::PAGE_SIZE_THREAD_OVERVIEW) - 1
800 );
801 if ($current_page > $last_page) {
802 $current_page = 0;
803 }
804 $threads_page = $this->forum_thread_table_session_storage->fetchData($frm, $frm_object, $current_page);
805
806 $sticky_threads = [];
807 $regular_threads = [];
808
809 if (count($threads_page->getForumTopics()) > 0) {
810 foreach ($threads_page->getForumTopics() as $thread) {
811 $ref_id = $this->object->getRefId();
812 $subject = $thread->getSubject();
813 if ($thread->isClosed()) {
814 $subject .= ' (' . $this->lng->txt('forums_closed') . ')';
815 }
816
817 $link = $this->getLinkActionForThread($ref_id, $subject, 'viewThread', $thread->getId());
818 $actions = $this->getActionsForThreadOverview($ref_id, $thread);
819
820 $list_item = $this->factory
821 ->item()
822 ->standard($link)
823 ->withActions($actions)
824 ->withProperties($this->getThreadProperties($thread));
825 $list_item = $this->markTopThreadInOverview($thread, $list_item);
826 if ($thread->isSticky()) {
827 $sticky_threads[] = $list_item;
828 } else {
829 $regular_threads[] = $list_item;
830 }
831 }
832 }
833
834 $sticky_threads_item_group = null;
835 if (count($sticky_threads) > 0) {
836 $sticky_threads_item_group = $this->factory->item()->group(
837 count($regular_threads) > 0 ? $this->lng->txt('top_thema') : '',
838 $sticky_threads
839 );
840 }
841
842 $regular_threads_item_group = null;
843 if (count($regular_threads) > 0) {
844 $regular_threads_item_group = $this->factory->item()->group(
845 count($sticky_threads) > 0 ? $this->lng->txt('thema') : '',
846 $regular_threads
847 );
848 }
849
850 $url = $this->http->request()->getRequestTarget();
851
852 $view_controls[] = $this->getSortationViewControl(
853 $current_page,
854 $this->forum_thread_table_session_storage->getThreadSortation()
855 );
856 $view_controls[] = $this->factory
857 ->viewControl()
858 ->pagination()
860 ->withTotalEntries($frm_object->getTopNumThreads())
862 ->withMaxPaginationButtons(5)
863 ->withCurrentPage($current_page);
864
865 $item_groups = array_filter([$sticky_threads_item_group, $regular_threads_item_group]);
866 if ($item_groups === []) {
867 $vc_container = $this->factory->panel()->listing()->standard(
868 $this->lng->txt('thread_overview'),
869 [$this->factory->item()->group($this->lng->txt('frm_no_threads'), [])]
870 );
871 } else {
872 $vc_container = $this->factory->panel()->listing()->standard(
873 $this->lng->txt('thread_overview'),
874 $item_groups
875 )->withViewControls($view_controls);
876 }
877
878 $default_html = $this->renderer->render($vc_container);
879 $modals = $this->renderer->render($this->modal_collection);
880 }
881
882 $this->initStyleSheets();
883
884 $forwarder = new ilForumPageCommandForwarder(
885 $GLOBALS['DIC']['http'],
886 $this->ctrl,
887 $this->tabs_gui,
888 $this->lng,
889 $this->object,
890 $this->user,
891 $this->content_style_domain
892 );
894
895 $this->tpl->setContent($forwarder->forward() . $default_html . $modals);
896 }
const PRESENTATION_MODE_PRESENTATION
presentation mode for requesting
getThreadProperties(ilForumTopic $forum_topic)
markTopThreadInOverview(ilForumTopic $current_thread, Item $list_item)
getSortationViewControl(int $offset, ThreadSortation $effective_sortation)
getActionsForThreadOverview(int $ref_id, ilForumTopic $forum_topic)

References $GLOBALS, ILIAS\Repository\ctrl(), factory(), ForumDto\getTopNumThreads(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ilForumProperties\PAGE_NAME_THREAD_OVERVIEW, ilForumProperties\PAGE_SIZE_THREAD_OVERVIEW, ilForumPageCommandForwarder\PRESENTATION_MODE_PRESENTATION, renderer(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ renderViewModeControl()

ilObjForumGUI::renderViewModeControl ( int  $currentViewMode)
private

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

3623 : void
3624 {
3625 if ($currentViewMode === 3) {
3626 $currentViewMode = 2;
3627 }
3628 $translationKeys = [];
3629 foreach ($this->viewModeOptions as $sortingConstantKey => $languageKey) {
3630 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3631 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
3632 $this->ctrl->setParameter($this, 'viewmode', $sortingConstantKey);
3633
3634 $translationKeys[$this->lng->txt($languageKey)] = $this->ctrl->getLinkTarget(
3635 $this,
3636 'viewThread',
3637 ''
3638 );
3639
3640 $this->ctrl->clearParameters($this);
3641 }
3642
3643 if ($currentViewMode > ilForumProperties::VIEW_DATE_ASC) {
3644 $currentViewMode = ilForumProperties::VIEW_DATE_ASC;
3645 }
3646
3647 $sortViewControl = $this->uiFactory
3648 ->viewControl()
3649 ->mode($translationKeys, $this->lng->txt($this->viewModeOptions[$currentViewMode]))
3650 ->withActive($this->lng->txt($this->viewModeOptions[$currentViewMode]));
3651 $this->toolbar->addComponent($sortViewControl);
3652 }

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

+ Here is the call graph for this function:

◆ resetLimitedViewObject()

ilObjForumGUI::resetLimitedViewObject ( )

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

3187 : void
3188 {
3189 $this->selected_post_storage->set($this->objCurrentTopic->getId(), 0);
3190 $this->ctrl->redirect($this, 'viewThread');
3191 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ restoreFromHistoryObject()

ilObjForumGUI::restoreFromHistoryObject ( )
protected

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

4975 : void
4976 {
4978 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
4979 }
4980
4981 $historyId = (int) ($this->httpRequest->getQueryParams()['history_id'] ?? 0);
4982 $history = new ilForumDraftsHistory($historyId);
4983
4984 $this->checkDraftAccess($history->getDraftId());
4985
4986 $draft = $history->rollbackAutosave();
4987 if ($draft->getThreadId() === 0 && $draft->getPostId() === 0) {
4988 $this->ctrl->setParameter($this, 'draft_id', $history->getDraftId());
4989 $this->ctrl->redirect($this, 'editThreadDraft');
4990 }
4991
4992 $this->ctrl->clearParameters($this);
4993 $this->ctrl->setParameter($this, 'pos_pk', $draft->getPostId());
4994 $this->ctrl->setParameter($this, 'thr_pk', $draft->getThreadId());
4995 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
4996 $this->ctrl->setParameter($this, 'action', 'editdraft');
4997
4998 ilForumPostDraft::createDraftBackup($draft->getDraftId());
4999
5000 $this->ctrl->redirect($this, 'viewThread');
5001 }

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

+ Here is the call graph for this function:

◆ retrieveDraftId()

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

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

184 : int
185 {
186 return $this->retrieveIntOrZeroFrom(
187 $from_post ? $this->http->wrapper()->post() : $this->http->wrapper()->query(),
188 'draft_id'
189 );
190 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ retrieveThreadIds()

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

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

924 : array
925 {
926 $thread_ids = [];
927 $query = $this->http->wrapper()->query()->has('thr_pk');
928 $post = $this->http->wrapper()->post()->has('thread_ids');
929 if ($post) {
930 $thread_ids = $this->http->wrapper()->post()->retrieve(
931 'thread_ids',
932 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
933 );
934 } elseif ($query) {
935 $thread_ids = $this->http->wrapper()->query()->retrieve(
936 'thr_pk',
937 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
938 );
939 }
940
941 return $thread_ids;
942 }

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

+ Here is the call graph for this function:

◆ retrieveThrPk()

ilObjForumGUI::retrieveThrPk ( )
private

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

179 : int
180 {
181 return $this->retrieveIntOrZeroFrom($this->http->wrapper()->query(), 'thr_pk');
182 }

References ILIAS\FileDelivery\http().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ revokeCensorshipObject()

ilObjForumGUI::revokeCensorshipObject ( )
private

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

2102 : void
2103 {
2104 $this->handleCensorship(true);
2105 }

◆ saveAsDraftObject()

ilObjForumGUI::saveAsDraftObject ( )

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

5164 : void
5165 {
5167 !$this->access->checkAccess('read', '', $this->object->getRefId())) {
5168 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5169 }
5170
5171 $autosave_draft_id = $this->http->wrapper()->post()->retrieve(
5172 'draft_id',
5173 $this->refinery->byTrying([
5174 $this->refinery->kindlyTo()->int(),
5175 $this->refinery->always(null)
5176 ])
5177 );
5178
5179 if ($this->objCurrentTopic->getId() === 0) {
5180 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_deleted'), true);
5181 $this->ctrl->redirect($this);
5182 }
5183
5184 if ($this->objCurrentTopic->isClosed()) {
5185 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_closed'), true);
5186 $this->ctrl->redirect($this);
5187 }
5188
5189 $oReplyEditForm = $this->getReplyEditForm();
5190 if ($oReplyEditForm->checkInput()) {
5191 if ($this->objCurrentPost->getId() === 0) {
5192 $this->requestAction = '';
5193 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_parent_deleted'), true);
5194 $this->viewThreadObject();
5195 return;
5196 }
5197
5198 $this->denyUnlessGranted(
5199 (new PostingBindingGuard($this->posting_placement))->decide(
5200 $this->object->getId(),
5201 $this->objCurrentTopic->getId(),
5202 $this->objCurrentPost->getId()
5203 )
5204 );
5205
5206 $oForumObjects = $this->getForumObjects();
5207 $frm = $oForumObjects['frm'];
5208 $frm->setMDB2WhereCondition(' top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
5209 $topicData = $frm->getOneTopic();
5210
5211 if ($this->requestAction === 'ready_showreply') {
5212 if (!$this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
5213 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5214 }
5215
5216 if ($autosave_draft_id > 0) {
5217 $draftObj = ilForumPostDraft::newInstanceByDraftId($autosave_draft_id);
5218 $this->checkDraftAccess($draftObj->getDraftId());
5219 } else {
5220 $draftObj = new ilForumPostDraft();
5221 $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentPost->getThread());
5222 if ($topicData === null) {
5223 $this->error->raiseError($this->lng->txt('obj_not_found'), $this->error->MESSAGE);
5224 return;
5225 }
5226 $draftObj->setForumId($topicData->getTopPk());
5227 $draftObj->setThreadId($this->objCurrentTopic->getId());
5228 $draftObj->setPostId($this->objCurrentPost->getId());
5229 }
5230
5231 $draftObj->setPostSubject($this->handleFormInput($oReplyEditForm->getInput('subject'), false));
5232 $draftObj->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message')));
5233 $draftObj->setPostUserAlias(ilForumUtil::getPublicUserAlias(
5234 $oReplyEditForm->getInput('alias'),
5235 $this->objProperties->isAnonymized()
5236 ));
5237 $draftObj->setNotificationStatus($oReplyEditForm->getInput('notify') && !$this->user->isAnonymous());
5238 $draftObj->setPostNotificationStatus($oReplyEditForm->getInput('notify_post') && !$this->user->isAnonymous());
5239
5240 $draftObj->setPostAuthorId($this->user->getId());
5241 $draftObj->setPostDisplayUserId(($this->isWritingWithPseudonymAllowed() ? 0 : $this->user->getId()));
5242
5243 if ($autosave_draft_id === 0) {
5244 $draft_id = $draftObj->saveDraft();
5245 } else {
5246 $draftObj->updateDraft();
5247 $draft_id = $draftObj->getDraftId();
5248 }
5249
5250 // copy temporary media objects (frm~)
5252 $oReplyEditForm->getInput('message'),
5253 'frm~d:html',
5254 $draft_id,
5255 'frm~d:html',
5256 $draft_id
5257 );
5258
5259 if ($this->objProperties->isFileUploadAllowed()) {
5260 $file = $_FILES['userfile'];
5261 if (is_array($file) && !empty($file)) {
5262 $oFDForumDrafts = new ilFileDataForumDrafts($this->object->getId(), $draftObj->getDraftId());
5263 $oFDForumDrafts->storeUploadedFiles();
5264 }
5265 }
5266
5267 $GLOBALS['ilAppEventHandler']->raise(
5268 'components/ILIAS/Forum',
5269 'savedAsDraft',
5270 [
5271 'draftObj' => $draftObj,
5272 'obj_id' => $this->object->getId(),
5273 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5274 ]
5275 );
5276
5277 $frm_session_values = ilSession::get('frm');
5278 if (is_array($frm_session_values)) {
5279 $frm_session_values[$this->objCurrentPost->getThreadId()]['openTreeNodes'][] = $this->objCurrentPost->getId();
5280 }
5281 ilSession::set('frm', $frm_session_values);
5282
5283 $this->tpl->setOnScreenMessage('success', $this->lng->txt('save_draft_successfully'), true);
5284 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
5285 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
5286 $this->ctrl->redirect($this, 'viewThread');
5287 }
5288 } else {
5289 $oReplyEditForm->setValuesByPost();
5290 $this->requestAction = substr($this->requestAction, 6);
5291 }
5292 $this->viewThreadObject();
5293 }

References $GLOBALS, ilRTE\_replaceMediaObjectImageSrc(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilSession\get(), ilForumUtil\getPublicUserAlias(), ILIAS\FileDelivery\http(), ilForumPostDraft\isSavePostDraftAllowed(), ILIAS\Repository\lng(), ilForumUtil\moveMediaObjects(), ilForumPostDraft\newInstanceByDraftId(), ILIAS\Repository\object(), ILIAS\Repository\refinery(), ilSession\set(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ savePostObject()

ilObjForumGUI::savePostObject ( )

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

2827 : void
2828 {
2829 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2830 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2831 }
2832
2833 if ($this->objCurrentTopic->getId() === 0) {
2834 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_deleted'), true);
2835 $this->ctrl->redirect($this);
2836 }
2837
2838 if ($this->objCurrentTopic->isClosed()) {
2839 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_closed'), true);
2840 $this->ctrl->redirect($this);
2841 }
2842
2843 $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentTopic);
2844
2845 $oReplyEditForm = $this->getReplyEditForm();
2846 if ($oReplyEditForm->checkInput()) {
2847 if ($this->objCurrentPost->getId() === 0) {
2848 $this->requestAction = '';
2849 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_parent_deleted'), true);
2850 $this->viewThreadObject();
2851 return;
2852 }
2853
2854 $this->denyUnlessGranted(
2855 (new PostingBindingGuard($this->posting_placement))->decide(
2856 $this->object->getId(),
2857 $this->objCurrentTopic->getId(),
2858 $this->objCurrentPost->getId()
2859 )
2860 );
2861
2862 $oForumObjects = $this->getForumObjects();
2863 $forumObj = $oForumObjects['forumObj'];
2864 $frm = $oForumObjects['frm'];
2865 $frm->setMDB2WhereCondition(' top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
2866 $topicData = $frm->getOneTopic();
2867 if ($topicData === null) {
2868 $this->error->raiseError($this->lng->txt('obj_not_found'), $this->error->MESSAGE);
2869 return;
2870 }
2871
2872 $autosave_draft_id = $this->http->wrapper()->post()->retrieve(
2873 'draft_id',
2874 $this->refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
2875 );
2876
2877 if ($this->requestAction === 'ready_showreply') {
2878 if (!$this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
2879 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2880 }
2881
2882 $status = true;
2883 $send_activation_mail = false;
2884
2885 if ($this->objProperties->isPostActivationEnabled()) {
2886 if (!$this->is_moderator) {
2887 $status = false;
2888 $send_activation_mail = true;
2889 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
2890 $status = false;
2891 }
2892 }
2893
2894 if ($this->isWritingWithPseudonymAllowed()) {
2895 if ((string) $oReplyEditForm->getInput('alias') === '') {
2896 $user_alias = $this->lng->txt('forums_anonymous');
2897 } else {
2898 $user_alias = $oReplyEditForm->getInput('alias');
2899 }
2900 $display_user_id = 0;
2901 } else {
2902 $user_alias = $this->user->getLogin();
2903 $display_user_id = $this->user->getId();
2904 }
2905
2906 $newPost = $frm->generatePost(
2907 $topicData->getTopPk(),
2908 $this->objCurrentTopic->getId(),
2909 $this->user->getId(),
2910 $display_user_id,
2911 ilRTE::_replaceMediaObjectImageSrc($oReplyEditForm->getInput('message')),
2912 $this->objCurrentPost->getId(),
2913 $oReplyEditForm->getInput('notify') && !$this->user->isAnonymous(),
2914 $this->handleFormInput($oReplyEditForm->getInput('subject'), false),
2915 $user_alias,
2916 '',
2917 $status,
2918 $send_activation_mail
2919 );
2920
2921 if ($autosave_draft_id > 0) {
2922 $draft = new ilForumPostDraft(
2923 $this->user->getId(),
2924 $this->objCurrentPost->getId(),
2925 $autosave_draft_id
2926 );
2927 if ($this->hasDraftAccess($draft)) {
2928 $draft->deleteDraft();
2929 }
2930 }
2931
2932 // mantis #8115: Mark parent as read
2933 $this->object->markPostRead(
2934 $this->user->getId(),
2935 $this->objCurrentTopic->getId(),
2936 $this->objCurrentPost->getId()
2937 );
2938
2939 // copy temporary media objects (frm~)
2941 $oReplyEditForm->getInput('message'),
2942 'frm~:html',
2943 $this->user->getId(),
2944 'frm:html',
2945 $newPost
2946 );
2947
2948 if ($this->objProperties->isFileUploadAllowed()) {
2949 $oFDForum = new ilFileDataForum($forumObj->getId(), $newPost);
2950 $file = $_FILES['userfile'];
2951 if (is_array($file) && !empty($file)) {
2952 $oFDForum->storeUploadedFiles();
2953 }
2954 }
2955
2956 $GLOBALS['ilAppEventHandler']->raise(
2957 'components/ILIAS/Forum',
2958 'createdPost',
2959 [
2960 'object' => $this->object,
2961 'ref_id' => $this->object->getRefId(),
2962 'post' => new ilForumPost($newPost),
2963 'notify_moderators' => $send_activation_mail
2964 ]
2965 );
2966
2967 $message = '';
2968 if (!$this->is_moderator && !$status) {
2969 $message .= $this->lng->txt('forums_post_needs_to_be_activated');
2970 } else {
2971 $message .= $this->lng->txt('forums_post_new_entry');
2972 }
2973
2974 $this->tpl->setOnScreenMessage('success', $message, true);
2975 $this->ctrl->clearParameters($this);
2976 $this->ctrl->setParameter($this, 'post_created_below', $this->objCurrentPost->getId());
2977 $this->ctrl->setParameter($this, 'pos_pk', $newPost);
2978 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
2979 } else {
2980 if ((!$this->is_moderator &&
2981 !$this->objCurrentPost->isOwner($this->user->getId())) || $this->objCurrentPost->isCensored() ||
2982 $this->user->isAnonymous()) {
2983 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2984 }
2985
2986 $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentPost->getThread());
2987
2988 $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('frm:html', $this->objCurrentPost->getId());
2989 $curMediaObjects = ilRTE::_getMediaObjects($oReplyEditForm->getInput('message'));
2990 foreach ($oldMediaObjects as $oldMob) {
2991 $found = false;
2992 foreach ($curMediaObjects as $curMob) {
2993 if ($oldMob === $curMob) {
2994 $found = true;
2995 break;
2996 }
2997 }
2998 if (!$found && ilObjMediaObject::_exists($oldMob)) {
2999 ilObjMediaObject::_removeUsage($oldMob, 'frm:html', $this->objCurrentPost->getId());
3000 $mob_obj = new ilObjMediaObject($oldMob);
3001 $mob_obj->delete();
3002 }
3003 }
3004
3005 // save old activation status for send_notification decision
3006 $old_status_was_active = $this->objCurrentPost->isActivated();
3007
3008 // if active post has been edited posting mus be activated again by moderator
3009 $status = true;
3010 $send_activation_mail = false;
3011
3012 if ($this->objProperties->isPostActivationEnabled()) {
3013 if (!$this->is_moderator) {
3014 $status = false;
3015 $send_activation_mail = true;
3016 } elseif ($this->objCurrentPost->isAnyParentDeactivated()) {
3017 $status = false;
3018 }
3019 }
3020 $this->objCurrentPost->setStatus($status);
3021
3022 $this->objCurrentPost->setSubject($this->handleFormInput($oReplyEditForm->getInput('subject'), false));
3023 $this->objCurrentPost->setMessage(ilRTE::_replaceMediaObjectImageSrc(
3024 $oReplyEditForm->getInput('message')
3025 ));
3026 $this->objCurrentPost->setNotification($oReplyEditForm->getInput('notify') && !$this->user->isAnonymous());
3027 $this->objCurrentPost->setChangeDate(date('Y-m-d H:i:s'));
3028 $this->objCurrentPost->setUpdateUserId($this->user->getId());
3029
3030 if ($this->objCurrentPost->update()) {
3031 $this->objCurrentPost->reload();
3032
3033 // Change news item accordingly
3034 // note: $this->objCurrentPost->getForumId() does not give us the forum ID here (why?)
3036 $forumObj->getId(),
3037 'frm',
3038 $this->objCurrentPost->getId(),
3039 'pos'
3040 );
3041 if ($news_id > 0) {
3042 $news_item = new ilNewsItem($news_id);
3043 $news_item->setTitle($this->objCurrentPost->getSubject());
3044 $news_item->setContent(
3045 ilRTE::_replaceMediaObjectImageSrc($frm->prepareText(
3046 $this->objCurrentPost->getMessage()
3047 ), 1)
3048 );
3049
3050 if ($this->objCurrentPost->getMessage() !== strip_tags($this->objCurrentPost->getMessage())) {
3051 $news_item->setContentHtml(true);
3052 } else {
3053 $news_item->setContentHtml(false);
3054 }
3055 $news_item->update();
3056 }
3057
3058 $oFDForum = $oForumObjects['file_obj'];
3059
3060 $file2delete = $oReplyEditForm->getInput('del_file');
3061 if (is_array($file2delete) && count($file2delete)) {
3062 $oFDForum->unlinkFilesByMD5Filenames($file2delete);
3063 }
3064
3065 if ($this->objProperties->isFileUploadAllowed()) {
3066 $file = $_FILES['userfile'];
3067 if (is_array($file) && !empty($file)) {
3068 $oFDForum->storeUploadedFiles();
3069 }
3070 }
3071
3072 $GLOBALS['ilAppEventHandler']->raise(
3073 'components/ILIAS/Forum',
3074 'updatedPost',
3075 [
3076 'ref_id' => $this->object->getRefId(),
3077 'post' => $this->objCurrentPost,
3078 'notify_moderators' => $send_activation_mail,
3079 'old_status_was_active' => $old_status_was_active
3080 ]
3081 );
3082
3083 $this->tpl->setOnScreenMessage('success', $this->lng->txt('forums_post_modified'), true);
3084 }
3085
3086 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
3087 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
3088 $this->ctrl->setParameter($this, 'viewmode', $this->selectedSorting);
3089 }
3090 $this->ctrl->redirect($this, 'viewThread');
3091 } else {
3092 $this->requestAction = substr($this->requestAction, 6);
3093 }
3094 $this->viewThreadObject();
3095 }
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.

References $GLOBALS, $message, ilObjMediaObject\_exists(), ilRTE\_getMediaObjects(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), ilRTE\_replaceMediaObjectImageSrc(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\UI\examples\Symbol\Glyph\Date\date(), ilNewsItem\getFirstNewsIdForContext(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ilForumUtil\moveMediaObjects(), ILIAS\Repository\object(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ saveThreadAsDraftObject()

ilObjForumGUI::saveThreadAsDraftObject ( )
protected

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

5003 : void
5004 {
5006 !$this->access->checkAccess('add_thread', '', $this->object->getRefId()) ||
5007 !$this->access->checkAccess('read', '', $this->object->getRefId())) {
5008 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5009 }
5010
5011 $autosave_draft_id = (int) ($this->httpRequest->getParsedBody()['draft_id'] ?? 0);
5012 if ($autosave_draft_id <= 0) {
5013 $autosave_draft_id = (int) ($this->httpRequest->getQueryParams()['draft_id'] ?? 0);
5014 }
5015
5016 $frm = $this->object->Forum;
5017 $frm->setForumId($this->object->getId());
5018 $frm->setForumRefId($this->object->getRefId());
5019 $frm->setMDB2WhereCondition('top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
5020 $topicData = $frm->getOneTopic();
5021
5022 $form = $this->buildThreadForm();
5023 if ($form->checkInput()) {
5024 if ($autosave_draft_id === 0) {
5025 if ($topicData === null) {
5026 $this->error->raiseError($this->lng->txt('obj_not_found'), $this->error->MESSAGE);
5027 return;
5028 }
5029 $draft = new ilForumPostDraft();
5030 $draft->setForumId($topicData->getTopPk());
5031 $draft->setThreadId(0);
5032 $draft->setPostId(0);
5033 } else {
5034 $draft = ilForumPostDraft::newInstanceByDraftId($autosave_draft_id);
5035 $this->checkDraftAccess($draft);
5036 }
5037
5038 $draft->setPostSubject($this->handleFormInput($form->getInput('subject'), false));
5039 $draft->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form->getInput('message')));
5040 $draft->setPostUserAlias(ilForumUtil::getPublicUserAlias(
5041 $form->getInput('alias'),
5042 $this->objProperties->isAnonymized()
5043 ));
5044 $draft->setNotificationStatus($form->getInput('notify') && !$this->user->isAnonymous());
5045 $draft->setPostAuthorId($this->user->getId());
5046 $draft->setPostDisplayUserId($this->isWritingWithPseudonymAllowed() ? 0 : $this->user->getId());
5047
5048 if ($autosave_draft_id === 0) {
5049 $draftId = $draft->saveDraft();
5050 } else {
5051 $draft->updateDraft();
5052 $draftId = $draft->getDraftId();
5053 }
5054
5055 $GLOBALS['ilAppEventHandler']->raise(
5056 'components/ILIAS/Forum',
5057 'savedAsDraft',
5058 [
5059 'draftObj' => $draft,
5060 'obj_id' => $this->object->getId(),
5061 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
5062 ]
5063 );
5064
5065 ilForumUtil::moveMediaObjects($form->getInput('message'), 'frm~d:html', $draftId, 'frm~d:html', $draftId);
5066
5067 $draftFileData = new ilFileDataForumDrafts($this->object->getId(), $draftId);
5068
5069 $files2delete = $form->getInput('del_file');
5070 if (is_array($files2delete) && $files2delete !== []) {
5071 $draftFileData->unlinkFilesByMD5Filenames($files2delete);
5072 }
5073
5074 if ($this->objProperties->isFileUploadAllowed()) {
5075 $file = $_FILES['userfile'];
5076 if (is_array($file) && !empty($file)) {
5077 $draftFileData->storeUploadedFiles();
5078 }
5079 }
5080
5081 $this->tpl->setOnScreenMessage('success', $this->lng->txt('save_draft_successfully'), true);
5082 $this->ctrl->clearParameters($this);
5083 $this->ctrl->redirect($this, 'showThreads');
5084 }
5085
5086 $this->requestAction = substr($this->requestAction, 6);
5087 $form->setValuesByPost();
5088 $this->ctrl->setParameter($this, 'draft_id', $autosave_draft_id);
5089 $this->tpl->setContent($form->getHTML());
5090 }

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

+ Here is the call graph for this function:

◆ saveTopLevelDraftObject()

ilObjForumGUI::saveTopLevelDraftObject ( )

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

5159 : void
5160 {
5161 $this->saveAsDraftObject();
5162 }

◆ saveTopLevelPostObject()

ilObjForumGUI::saveTopLevelPostObject ( )

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

2649 : void
2650 {
2651 $this->savePostObject();
2652 }

◆ saveUserNotificationSettingsObject()

ilObjForumGUI::saveUserNotificationSettingsObject ( )

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

4662 : void
4663 {
4664 $events_form_builder = $this->eventsFormBuilder();
4665
4666 if ($this->httpRequest->getMethod() === 'POST') {
4667 $form = $events_form_builder->build()->withRequest($this->httpRequest);
4668 $formData = $form->getData();
4669
4670 $interested_events = ilForumNotificationEvents::DEACTIVATED;
4671
4672 foreach ($events_form_builder->getValidEvents() as $event) {
4673 $interested_events += isset($formData[$event]) && $formData[$event] ? $events_form_builder->getValueForEvent(
4674 $event
4675 ) : 0;
4676 }
4677
4678 $frm_noti = new ilForumNotification($this->object->getRefId());
4679 $frm_noti->setUserId($this->user->getId());
4680 $frm_noti->setInterestedEvents($interested_events);
4681 $frm_noti->updateInterestedEvents();
4682 }
4683
4684 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
4685
4686 if ($this->objCurrentTopic->getId() > 0) {
4687 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
4688 $this->ctrl->redirect($this, 'viewThread');
4689 }
4690
4691 $this->ctrl->redirect($this, 'showThreads');
4692 }

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

+ Here is the call graph for this function:

◆ selectPostObject()

ilObjForumGUI::selectPostObject ( )
protected

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

1600 : void
1601 {
1602 $thr_pk = (int) $this->httpRequest->getQueryParams()['thr_pk'];
1603 $pos_pk = (int) $this->httpRequest->getQueryParams()['pos_pk'];
1604
1605 $this->selected_post_storage->set(
1606 $thr_pk,
1607 $pos_pk
1608 );
1609
1610 $this->viewThreadObject();
1611 }

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ setColumnSettings()

ilObjForumGUI::setColumnSettings ( ilColumnGUI  $column_gui)

Reimplemented from ilObjectGUI.

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

4404 : void
4405 {
4406 $column_gui->setBlockProperty('news', 'title', $this->lng->txt('frm_latest_postings'));
4407 $column_gui->setBlockProperty('news', 'prevent_aggregation', '1');
4408 $column_gui->setRepositoryMode(true);
4409
4410 if ($this->access->checkAccess('write', '', $this->object->getRefId())) {
4411 $news_set = new ilSetting('news');
4412 if ($news_set->get('enable_rss_for_internal')) {
4413 $column_gui->setBlockProperty('news', 'settings', '1');
4414 $column_gui->setBlockProperty('news', 'public_notifications_option', '1');
4415 }
4416 }
4417 }
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...
ILIAS Setting Class.

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

+ Here is the call graph for this function:

◆ setDisplayConfirmPostActivation()

ilObjForumGUI::setDisplayConfirmPostActivation ( bool  $status = false)

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

2176 : void
2177 {
2178 $this->display_confirm_post_activation = $status;
2179 }

◆ setSideBlocks()

ilObjForumGUI::setSideBlocks ( )
protected

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

4892 : void
4893 {
4894 $content = $this->getRightColumnHTML();
4895 if (!$this->ctrl->isAsynch()) {
4896 $content = implode('', [
4897 ilRepositoryObjectSearchGUI::getSearchBlockHTML($this->lng->txt('frm_search')),
4898 $content,
4899 ]);
4900 }
4901 $this->tpl->setRightContent($content);
4902 }
getRightColumnHTML()
Display right column.

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

+ Here is the call graph for this function:

◆ showStatisticsObject()

ilObjForumGUI::showStatisticsObject ( )

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

1764 : void
1765 {
1766 if (!$this->settings->get('enable_fora_statistics', '0')) {
1767 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1768 }
1769
1770 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
1771 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1772 }
1773
1774 if (!$this->objProperties->isStatisticEnabled()) {
1775 if ($this->access->checkAccess('write', '', $this->object->getRefId())) {
1776 $this->tpl->setOnScreenMessage('info', $this->lng->txt('frm_statistics_disabled_for_participants'));
1777 } else {
1778 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
1779 }
1780 }
1781
1782 $this->object->Forum->setForumId($this->object->getId());
1783
1784 $tbl = new \ILIAS\Forum\Statistics\ForumStatisticsTable(
1785 $this->object,
1786 $this->objProperties,
1788 $this->access->checkRbacOrPositionPermissionAccess(
1789 'read_learning_progress',
1790 'read_learning_progress',
1791 $this->object->getRefId()
1792 ),
1793 $this->user,
1794 $this->ui_factory,
1795 $this->request,
1796 $this->lng
1797 );
1798 $this->tpl->setContent($this->uiRenderer->render($tbl->getComponent()));
1799 }

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

+ Here is the call graph for this function:

◆ showThreadsObject()

ilObjForumGUI::showThreadsObject ( )

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

714 : void
715 {
716 $this->setSideBlocks();
717 $this->getCenterColumnHTML();
718 }
getCenterColumnHTML()
Get center column.

◆ showUserObject()

ilObjForumGUI::showUserObject ( )

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

3681 : void
3682 {
3683 $user_id = $this->http->wrapper()->query()->retrieve(
3684 'user',
3685 $this->refinery->byTrying([$this->refinery->kindlyTo()->int(), $this->refinery->always(0)])
3686 );
3687 $backurl = $this->http->wrapper()->query()->retrieve(
3688 'backurl',
3689 $this->refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always('')])
3690 );
3691
3692 $profile_gui = new PublicProfileGUI($user_id);
3693 $add = $this->getUserProfileAdditional($this->object->getRefId(), $user_id);
3694 $profile_gui->setAdditional($add);
3695 $profile_gui->setBackUrl(ilUtil::stripSlashes($backurl));
3696 $this->tpl->setContent($this->ctrl->getHTML($profile_gui));
3697 }
GUI class for public user profile presentation.

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

+ Here is the call graph for this function:

◆ toggleExplorerNodeStateObject()

ilObjForumGUI::toggleExplorerNodeStateObject ( )
protected

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

192 : void
193 {
194 $exp = new ilForumExplorerGUI(
195 'frm_exp_' . $this->objCurrentTopic->getId(),
196 $this,
197 'viewThread',
198 $this->objCurrentTopic,
199 $this->objCurrentTopic->getPostRootNode($this->is_moderator)
200 );
201 $exp->toggleExplorerNodeState();
202 }
Class ilForumExplorerGUI.

◆ toggleStickinessObject()

ilObjForumGUI::toggleStickinessObject ( )
protected

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

2206 : void
2207 {
2208 if (!$this->is_moderator) {
2209 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2210 }
2211
2212 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2213 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2214 }
2215
2216 $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentTopic);
2217
2218 if ($this->objCurrentTopic->isSticky()) {
2219 $this->objCurrentTopic->unmakeSticky();
2220 } else {
2221 $this->objCurrentTopic->makeSticky();
2222 }
2223
2224 $this->viewThreadObject();
2225 }

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

+ Here is the call graph for this function:

◆ toggleThreadNotificationObject()

ilObjForumGUI::toggleThreadNotificationObject ( )
protected

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

2186 : void
2187 {
2188 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
2189 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
2190 }
2191
2192 $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentTopic);
2193
2194 if ($this->objCurrentTopic->isNotificationEnabled($this->user->getId())) {
2195 $this->objCurrentTopic->disableNotification($this->user->getId());
2196 $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_notification_disabled'), true);
2197 } else {
2198 $this->objCurrentTopic->enableNotification($this->user->getId());
2199 $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_notification_enabled'), true);
2200 }
2201
2202 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
2203 $this->ctrl->redirect($this, 'viewThread');
2204 }

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

+ Here is the call graph for this function:

◆ updateCustom()

ilObjForumGUI::updateCustom ( ilPropertyFormGUI  $form)
protected

Insert custom update form values into object.

Reimplemented from ilObjectGUI.

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

668 : void
669 {
670 $this->forum_settings_gui->updateCustomValues($form);
671 }

◆ updateDraftObject()

ilObjForumGUI::updateDraftObject ( )

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

5301 : void
5302 {
5304 !$this->access->checkAccess('read', '', $this->object->getRefId())) {
5305 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5306 }
5307
5308 if ($this->objCurrentTopic->getId() === 0) {
5309 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_deleted'), true);
5310 $this->ctrl->redirect($this);
5311 }
5312
5313 if ($this->objCurrentTopic->isClosed()) {
5314 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_thr_closed'), true);
5315 $this->ctrl->redirect($this);
5316 }
5317
5318 if ($this->objCurrentPost->getId() === 0) {
5319 $this->requestAction = '';
5320 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('frm_action_not_possible_parent_deleted'));
5321 $this->viewThreadObject();
5322 return;
5323 }
5324
5325 $oReplyEditForm = $this->getReplyEditForm();
5326 if ($oReplyEditForm->checkInput()) {
5327 $oForumObjects = $this->getForumObjects();
5328 $forumObj = $oForumObjects['forumObj'];
5329
5330 if (!$this->user->isAnonymous() && in_array($this->requestAction, ['showdraft', 'editdraft'])) {
5331 if (!$this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
5332 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5333 }
5334
5335 $draft = new ilForumPostDraft(
5336 $this->user->getId(),
5337 $this->objCurrentPost->getId(),
5338 $this->retrieveDraftId()
5339 );
5340
5341 $this->checkDraftAccess($draft);
5342
5343 $draft->setPostSubject($this->handleFormInput($oReplyEditForm->getInput('subject'), false));
5344 $draft->setPostMessage(ilRTE::_replaceMediaObjectImageSrc(
5345 $oReplyEditForm->getInput('message')
5346 ));
5347 $draft->setPostUserAlias(ilForumUtil::getPublicUserAlias(
5348 $oReplyEditForm->getInput('alias'),
5349 $this->objProperties->isAnonymized()
5350 ));
5351 $draft->setNotificationStatus($oReplyEditForm->getInput('notify') && !$this->user->isAnonymous());
5352 $draft->setUpdateUserId($this->user->getId());
5353 $draft->setPostAuthorId($this->user->getId());
5354 $draft->setPostDisplayUserId($this->isWritingWithPseudonymAllowed() ? 0 : $this->user->getId());
5355
5356 $draft->updateDraft();
5357
5358 $GLOBALS['ilAppEventHandler']->raise(
5359 'components/ILIAS/Forum',
5360 'updatedDraft',
5361 [
5362 'draftObj' => $draft,
5363 'obj_id' => $this->object->getId(),
5364 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed()
5365 ]
5366 );
5367
5368 $uploadedObjects = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
5369
5370 foreach ($uploadedObjects as $mob) {
5371 ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
5372 ilObjMediaObject::_saveUsage($mob, 'frm~d:html', $draft->getDraftId());
5373 }
5375 $oReplyEditForm->getInput('message'),
5376 'frm~d:html',
5377 $draft->getDraftId()
5378 );
5379
5380 $oFDForumDrafts = new ilFileDataForumDrafts($forumObj->getId(), $draft->getDraftId());
5381
5382 $file2delete = $oReplyEditForm->getInput('del_file');
5383 if (is_array($file2delete) && count($file2delete)) {
5384 $oFDForumDrafts->unlinkFilesByMD5Filenames($file2delete);
5385 }
5386
5387 if ($this->objProperties->isFileUploadAllowed()) {
5388 $file = $_FILES['userfile'];
5389 if (is_array($file) && !empty($file)) {
5390 $oFDForumDrafts->storeUploadedFiles();
5391 }
5392 }
5393
5394 $frm_session_values = ilSession::get('frm');
5395 if (is_array($frm_session_values)) {
5396 $frm_session_values[$this->objCurrentPost->getThreadId()]['openTreeNodes'][] = $this->objCurrentPost->getId();
5397 }
5398 ilSession::set('frm', $frm_session_values);
5399 $this->tpl->setOnScreenMessage('success', $this->lng->txt('save_draft_successfully'), true);
5400 $this->ctrl->clearParameters($this);
5401 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
5402 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
5403 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
5404 }
5405 } else {
5406 $this->ctrl->clearParameters($this);
5407 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
5408 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
5409 $this->ctrl->setParameter($this, 'draft_id', $this->retrieveDraftId());
5410 $this->ctrl->setParameter($this, 'action', 'editdraft');
5411 $oReplyEditForm->setValuesByPost();
5412 $this->viewThreadObject();
5413 return;
5414 }
5415 $this->ctrl->clearParameters($this);
5416 $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId());
5417 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId());
5418 $this->ctrl->redirect($this, 'viewThread');
5419 }

References $GLOBALS, ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), ilRTE\_replaceMediaObjectImageSrc(), ilObjMediaObject\_saveUsage(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilSession\get(), ilForumUtil\getPublicUserAlias(), ilForumPostDraft\isSavePostDraftAllowed(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilForumUtil\saveMediaObjects(), ilSession\set(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ updateThreadDraftObject()

ilObjForumGUI::updateThreadDraftObject ( )
protected

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

5092 : void
5093 {
5095 !$this->access->checkAccess('add_thread', '', $this->object->getRefId()) ||
5096 !$this->access->checkAccess('read', '', $this->object->getRefId())) {
5097 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
5098 }
5099
5101 $this->checkDraftAccess($draft);
5102
5103 $form = $this->buildThreadForm(true);
5104 if ($form->checkInput()) {
5105 $draft->setPostSubject($this->handleFormInput($form->getInput('subject'), false));
5106 $draft->setPostMessage(ilRTE::_replaceMediaObjectImageSrc($form->getInput('message')));
5107 $draft->setPostUserAlias(ilForumUtil::getPublicUserAlias(
5108 $form->getInput('alias'),
5109 $this->objProperties->isAnonymized()
5110 ));
5111 $draft->setNotificationStatus($form->getInput('notify') && !$this->user->isAnonymous());
5112 $draft->setPostAuthorId($this->user->getId());
5113 $draft->setPostDisplayUserId($this->isWritingWithPseudonymAllowed() ? 0 : $this->user->getId());
5114 $draft->updateDraft();
5115
5116 $GLOBALS['ilAppEventHandler']->raise(
5117 'components/ILIAS/Forum',
5118 'updatedDraft',
5119 [
5120 'draftObj' => $draft,
5121 'obj_id' => $this->object->getId(),
5122 'is_file_upload_allowed' => $this->objProperties->isFileUploadAllowed(),
5123 ]
5124 );
5125
5127 $form->getInput('message'),
5128 'frm~d:html',
5129 $draft->getDraftId(),
5130 'frm~d:html',
5131 $draft->getDraftId()
5132 );
5133
5134 $draftFileData = new ilFileDataForumDrafts($this->object->getId(), $draft->getDraftId());
5135
5136 $files2delete = $form->getInput('del_file');
5137 if (is_array($files2delete) && $files2delete !== []) {
5138 $draftFileData->unlinkFilesByMD5Filenames($files2delete);
5139 }
5140
5141 if ($this->objProperties->isFileUploadAllowed()) {
5142 $file = $_FILES['userfile'];
5143 if (is_array($file) && !empty($file) && isset($file['full_path'][0]) && !empty($file['full_path'][0])) {
5144 $draftFileData->storeUploadedFiles();
5145 }
5146 }
5147
5148 $this->tpl->setOnScreenMessage('success', $this->lng->txt('save_draft_successfully'), true);
5149 $this->ctrl->clearParameters($this);
5150 $this->ctrl->redirect($this, 'showThreads');
5151 }
5152
5153 $form->setValuesByPost();
5154 $this->ctrl->setParameter($this, 'hist_check', 0);
5155 $this->ctrl->setParameter($this, 'draft_id', $draft->getDraftId());
5156 $this->editThreadDraftObject($form);
5157 }
editThreadDraftObject(?ilPropertyFormGUI $form=null)

References $GLOBALS, ilRTE\_replaceMediaObjectImageSrc(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilForumUtil\getPublicUserAlias(), ilForumPostDraft\isSavePostDraftAllowed(), ILIAS\Repository\lng(), ilForumUtil\moveMediaObjects(), ilForumPostDraft\newInstanceByDraftId(), ILIAS\Repository\object(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ updateThreadObject()

ilObjForumGUI::updateThreadObject ( )

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

673 : void
674 {
675 if (!$this->is_moderator) {
676 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
677 }
678
679 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
680 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
681 }
682
683 if ($this->objCurrentTopic->getId() === 0) {
684 $this->showThreadsObject();
685 return;
686 }
687
688 $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentTopic);
689
690 $title = $this->getEditTitleModal($this->objCurrentTopic)->withRequest($this->http->request())->getData();
691 if (array_key_exists(0, $title)) {
692 $new_subject = $title[0];
693 if ($new_subject !== '') {
694 $this->objCurrentTopic->setSubject($new_subject);
695 $this->objCurrentTopic->updateThreadTitle();
696 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'));
697 }
698
699 $this->ctrl->redirect($this, 'showThreads');
700 }
701 }

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

+ Here is the call graph for this function:

◆ viewThreadObject()

ilObjForumGUI::viewThreadObject ( )

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

3193 : void
3194 {
3195 $thr_pk = $this->objCurrentTopic->getId();
3196
3197 $bottom_toolbar = clone $this->toolbar;
3198 $toolbar_items = [];
3199
3200 // quick and dirty: check for treeview
3201 $thread_control_session_values = ilSession::get('thread_control');
3202 if (is_array($thread_control_session_values)) {
3203 if (!isset($thread_control_session_values['old'])) {
3204 $thread_control_session_values['old'] = $thr_pk;
3205 $thread_control_session_values['new'] = $thr_pk;
3206 ilSession::set('thread_control', $thread_control_session_values);
3207 } elseif (isset($thread_control_session_values['old']) && $thr_pk !== $thread_control_session_values['old']) {
3208 $thread_control_session_values['new'] = $thr_pk;
3209 ilSession::set('thread_control', $thread_control_session_values);
3210 }
3211 }
3212
3213 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
3214 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3215 }
3216
3217 $oForumObjects = $this->getForumObjects();
3218 $forumObj = $oForumObjects['forumObj'];
3219 $frm = $oForumObjects['frm'];
3220 $file_obj = $oForumObjects['file_obj'];
3221
3222 $selected_draft_id = (int) ($this->httpRequest->getQueryParams()['draft_id'] ?? 0);
3223 if (isset($this->httpRequest->getQueryParams()['file'])) {
3224 if ($selected_draft_id > 0 && ilForumPostDraft::isSavePostDraftAllowed()) {
3225 $delivery = $this->draftAttachmentDelivery(
3226 new ilFileDataForumDrafts($forumObj->getId(), $selected_draft_id)
3227 );
3228 } else {
3229 $delivery = $this->postingAttachmentDelivery($file_obj);
3230 }
3231
3232 try {
3233 $delivery->deliverFile(ilUtil::stripSlashes($this->httpRequest->getQueryParams()['file']));
3234 } catch (AttachmentAccessDenied) {
3235 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
3236 }
3237 }
3238
3239 if ($this->objCurrentTopic->getId() === 0) {
3240 $this->ctrl->redirect($this, 'showThreads');
3241 }
3242
3243 $pageIndex = 0;
3244 if (isset($this->httpRequest->getQueryParams()['page'])) {
3245 $pageIndex = max((int) $this->httpRequest->getQueryParams()['page'], $pageIndex);
3246 }
3247
3248 if ($this->selected_post_storage->get($this->objCurrentTopic->getId()) > 0) {
3249 $firstNodeInThread = new ilForumPost(
3250 $this->selected_post_storage->get($this->objCurrentTopic->getId()),
3251 $this->is_moderator,
3252 false
3253 );
3254 } else {
3255 $firstNodeInThread = $this->objCurrentTopic->getPostRootNode();
3256 }
3257
3258 $toolContext = $this->globalScreen
3259 ->tool()
3260 ->context()
3261 ->current();
3262
3263 $this->ensureThreadBelongsToForum($this->object->getId(), $this->objCurrentTopic);
3264
3265 $threadContentTemplate = new ilTemplate(
3266 'tpl.forums_threads_view.html',
3267 true,
3268 true,
3269 'components/ILIAS/Forum'
3270 );
3271
3272
3273 if ($this->selectedSorting === ilForumProperties::VIEW_TREE) {
3274 $order_field = 'frm_posts_tree.rgt';
3275 $this->objCurrentTopic->setOrderDirection('DESC');
3276 $threadContentTemplate->setVariable('LIST_TYPE', $this->viewModeOptions[$this->selectedSorting]);
3277 } else {
3278 $order_field = 'frm_posts.pos_date';
3279 $this->objCurrentTopic->setOrderDirection(
3280 $this->selectedSorting === ilForumProperties::VIEW_DATE_DESC ? 'DESC' : 'ASC'
3281 );
3282 $threadContentTemplate->setVariable('LIST_TYPE', $this->sortationOptions[$this->selectedSorting]);
3283 }
3284 $this->objCurrentTopic->setOrderField($order_field);
3285
3286 $additionalDataExists = $toolContext->getAdditionalData()->exists(ForumGlobalScreenToolsProvider::SHOW_FORUM_THREADS_TOOL);
3287 $subtree_nodes = $this->objCurrentTopic->getPostTree($firstNodeInThread);
3288 $numberOfPostings = count($subtree_nodes);
3289 if ($numberOfPostings > 0 && !$additionalDataExists && $this->selectedSorting === ilForumProperties::VIEW_TREE) {
3290 $toolContext
3292 ->addAdditionalData(ForumGlobalScreenToolsProvider::REF_ID, $this->ref_id)
3293 ->addAdditionalData(ForumGlobalScreenToolsProvider::FORUM_THEAD, $this->objCurrentTopic)
3294 ->addAdditionalData(ForumGlobalScreenToolsProvider::FORUM_THREAD_ROOT, $firstNodeInThread)
3296 ->addAdditionalData(ForumGlobalScreenToolsProvider::PAGE, $pageIndex);
3297 }
3298 // Set context for login
3299 $append = '_' . $this->objCurrentTopic->getId() .
3300 ($this->objCurrentPost->getId() !== 0 ? '_' . $this->objCurrentPost->getId() : '');
3301 $this->tpl->setLoginTargetPar('frm_' . $this->object->getRefId() . $append);
3302
3303 // delete temporary media object (not in case a user adds media objects and wants to save an invalid form)
3304 if (!in_array($this->requestAction, ['showreply', 'showedit'])) {
3305 try {
3306 $mobs = ilObjMediaObject::_getMobsOfObject('frm~:html', $this->user->getId());
3307 foreach ($mobs as $mob) {
3308 if (ilObjMediaObject::_exists($mob)) {
3309 ilObjMediaObject::_removeUsage($mob, 'frm~:html', $this->user->getId());
3310 $mob_obj = new ilObjMediaObject($mob);
3311 $mob_obj->delete();
3312 }
3313 }
3314 } catch (Exception) {
3315 }
3316 }
3317
3318 if (!$this->getCreationMode() && $this->access->checkAccess('read', '', $this->object->getRefId())) {
3320 $this->object->getRefId(),
3321 ilLink::_getLink($this->object->getRefId(), 'frm'),
3322 'frm'
3323 );
3324 }
3325
3326 $this->prepareThreadScreen($forumObj);
3327
3328
3329 if (isset($this->httpRequest->getQueryParams()['anchor'])) {
3330 $threadContentTemplate->setVariable('JUMP2ANCHOR_ID', (int) $this->httpRequest->getQueryParams()['anchor']);
3331 }
3332 $frm->setMDB2WhereCondition('top_frm_fk = %s ', ['integer'], [$frm->getForumId()]);
3333
3335 $this->object->getType(),
3336 $this->object->getRefId(),
3337 $this->object->getId(),
3338 $this->user->getId()
3339 );
3340
3341 if ($firstNodeInThread) {
3342 $this->objCurrentTopic->updateVisits();
3343
3344 $this->tpl->setTitle($this->lng->txt('forums_thread') . ' "' . $this->objCurrentTopic->getSubject() . '"');
3345
3346 $this->locator->addRepositoryItems();
3347 $this->locator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ''), '_top');
3348 $this->tpl->setLocator();
3349
3350 if (!$this->user->isAnonymous() &&
3351 $forumObj->getCountUnread($this->user->getId(), $this->objCurrentTopic->getId(), true)) {
3352 $this->ctrl->setParameter($this, 'mark_read', '1');
3353 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3354
3355 $mark_thr_read_button = $this->uiFactory->button()->standard(
3356 $this->lng->txt('forums_mark_read'),
3357 $this->ctrl->getLinkTarget($this, 'viewThread')
3358 );
3359
3360 $toolbar_items[] = $mark_thr_read_button;
3361
3362 $this->ctrl->clearParameters($this);
3363 }
3364
3365 $this->ctrl->setParameterByClass(ilForumExportGUI::class, 'print_thread', $this->objCurrentTopic->getId());
3366 $this->ctrl->setParameterByClass(
3367 ilForumExportGUI::class,
3368 'thr_top_fk',
3369 $this->objCurrentTopic->getForumId()
3370 );
3371
3372 if ($numberOfPostings > 0 && $this->settings->get('forum_enable_print', '0')) {
3373 $print_thr_button = $this->uiFactory->button()->standard(
3374 $this->lng->txt('forums_print_thread'),
3375 $this->ctrl->getLinkTargetByClass(ilForumExportGUI::class, 'printThread')
3376 );
3377 $toolbar_items[] = $print_thr_button;
3378 }
3379
3380
3381 $this->ctrl->clearParametersByClass(ilForumExportGUI::class);
3382
3383 $this->addHeaderAction();
3384
3385 if (isset($this->httpRequest->getQueryParams()['mark_read'])) {
3386 $forumObj->markThreadRead($this->user->getId(), $this->objCurrentTopic->getId());
3387 $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_thread_marked'), true);
3388 }
3389
3390 if ($firstNodeInThread instanceof ilForumPost &&
3391 !$this->isTopLevelReplyCommand() &&
3392 !$this->objCurrentTopic->isClosed() &&
3393 $this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
3394 $this->ctrl->setParameter($this, 'action', 'showreply');
3395 $this->ctrl->setParameter($this, 'pos_pk', $firstNodeInThread->getId());
3396 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3397 $this->ctrl->setParameter(
3398 $this,
3399 'page',
3400 (int) ($this->httpRequest->getQueryParams()['page'] ?? 0)
3401 );
3402 $this->ctrl->setParameter(
3403 $this,
3404 'orderby',
3405 $this->getOrderByParam()
3406 );
3407 if ($numberOfPostings > 0) {
3408 $reply_button = $this->uiFactory->button()->standard(
3409 $this->lng->txt('add_new_answer'),
3410 $this->ctrl->getLinkTarget($this, 'createTopLevelPost', 'frm_page_bottom')
3411 );
3412 } else {
3413 $reply_button = $this->uiFactory->button()->primary(
3414 $this->lng->txt('add_new_answer'),
3415 $this->ctrl->getLinkTarget($this, 'createTopLevelPost', 'frm_page_bottom')
3416 );
3417 }
3418 $this->ctrl->clearParameters($this);
3419 array_unshift($toolbar_items, $reply_button);
3420 }
3421
3422 // no posts
3423 if ($numberOfPostings === 0 && $firstNodeInThread->getId() === 0) {
3424 $this->tpl->setOnScreenMessage('info', $this->lng->txt('forums_no_posts_available'));
3425 }
3426
3427 $pageSize = $frm->getPageHits();
3428 $postIndex = 0;
3429 if ($numberOfPostings > $pageSize) {
3430 $this->ctrl->setParameter($this, 'ref_id', $this->object->getRefId());
3431 $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentTopic->getId());
3432 $this->ctrl->setParameter(
3433 $this,
3434 'orderby',
3435 $this->getOrderByParam()
3436 );
3437 $paginationUrl = $this->ctrl->getLinkTarget($this, 'viewThread', '');
3438 $this->ctrl->clearParameters($this);
3439
3440 $pagination = $this->uiFactory->viewControl()
3441 ->pagination()
3442 ->withTargetURL($paginationUrl, 'page')
3443 ->withTotalEntries($numberOfPostings)
3444 ->withPageSize($pageSize)
3445 ->withMaxPaginationButtons(10)
3446 ->withCurrentPage($pageIndex);
3447
3448 $threadContentTemplate->setVariable('THREAD_MENU', $this->uiRenderer->render(
3449 $pagination
3450 ));
3451 $threadContentTemplate->setVariable('THREAD_MENU_BOTTOM', $this->uiRenderer->render(
3452 $pagination
3453 ));
3454 }
3455
3456 $doRenderDrafts = ilForumPostDraft::isSavePostDraftAllowed() && !$this->user->isAnonymous();
3457 $draftsObjects = [];
3458 if ($doRenderDrafts) {
3459 $draftsObjects = ilForumPostDraft::getSortedDrafts(
3460 $this->user->getId(),
3461 $this->objCurrentTopic->getId(),
3462 $this->selectedSorting
3463 );
3464 }
3465
3466 $pagedPostings = array_slice($subtree_nodes, $pageIndex * $pageSize, $pageSize);
3467
3468 $this->ensureValidPageForCurrentPosting($subtree_nodes, $pagedPostings, $pageSize, $firstNodeInThread);
3469
3470 $this->preloadPostingFileResources($pagedPostings, $draftsObjects);
3471 if ($doRenderDrafts && $pageIndex === 0 &&
3472 $this->selectedSorting === ilForumProperties::VIEW_DATE_DESC) {
3473 foreach ($draftsObjects as $draft) {
3474 $referencePosting = array_values(array_filter(
3475 $subtree_nodes,
3476 static fn(ilForumPost $post): bool => $draft->getPostId() === $post->getId()
3477 ))[0] ?? $firstNodeInThread;
3478
3479 $this->renderDraftContent(
3480 $threadContentTemplate,
3481 $this->requestAction,
3482 $referencePosting,
3483 [$draft]
3484 );
3485 }
3486 }
3487
3488 foreach ($pagedPostings as $node) {
3489 $this->ctrl->clearParameters($this);
3490
3491 if (!$this->isTopLevelReplyCommand() && $this->objCurrentPost->getId() === $node->getId() &&
3492 ($this->is_moderator || $node->isActivated() || $node->isOwner($this->user->getId()))) {
3493 if (!$this->objCurrentTopic->isClosed() && in_array($this->requestAction, [
3494 'showreply',
3495 'showedit',
3496 ])) {
3497 $this->renderPostingForm($threadContentTemplate, $frm, $node, $this->requestAction);
3498 } elseif ($this->requestAction === 'censor' &&
3499 !$this->objCurrentTopic->isClosed() && $this->is_moderator) {
3500 $threadContentTemplate->setVariable('FORM', $this->getCensorshipFormHTML());
3501 }
3502 }
3503
3504 $this->renderPostContent($threadContentTemplate, $node, $this->requestAction, $pageIndex, $postIndex);
3505 if ($doRenderDrafts && $this->selectedSorting === ilForumProperties::VIEW_TREE) {
3506 $this->renderDraftContent(
3507 $threadContentTemplate,
3508 $this->requestAction,
3509 $node,
3510 $draftsObjects[$node->getId()] ?? []
3511 );
3512 }
3513
3514 $postIndex++;
3515 }
3516
3517 if (
3518 $this->selectedSorting === ilForumProperties::VIEW_DATE_ASC &&
3519 $doRenderDrafts && $pageIndex === max(0, (int) (ceil($numberOfPostings / $pageSize) - 1))
3520 ) {
3521 foreach ($draftsObjects as $draft) {
3522 $referencePosting = array_values(array_filter(
3523 $subtree_nodes,
3524 static fn(ilForumPost $post): bool => $draft->getPostId() === $post->getId()
3525 ))[0] ?? $firstNodeInThread;
3526
3527 $this->renderDraftContent(
3528 $threadContentTemplate,
3529 $this->requestAction,
3530 $referencePosting,
3531 [$draft]
3532 );
3533 }
3534 }
3535
3536 if (
3537 $firstNodeInThread instanceof ilForumPost && $doRenderDrafts &&
3538 $this->selectedSorting === ilForumProperties::VIEW_TREE &&
3539 $firstNodeInThread->getLft() <= 1
3540 ) {
3541 $this->renderDraftContent(
3542 $threadContentTemplate,
3543 $this->requestAction,
3544 $firstNodeInThread,
3545 $draftsObjects[$firstNodeInThread->getId()] ?? []
3546 );
3547 }
3548
3549 if ($firstNodeInThread instanceof ilForumPost &&
3550 !$this->objCurrentTopic->isClosed() &&
3551 in_array($this->ctrl->getCmd(), ['createTopLevelPost', 'saveTopLevelPost', 'saveTopLevelDraft'], true) &&
3552 $this->access->checkAccess('add_reply', '', $this->object->getRefId())) {
3553 // Important: Don't separate the following two lines (very fragile code ...)
3554 $this->objCurrentPost->setId($firstNodeInThread->getId());
3555 $form = $this->getReplyEditForm();
3556
3557 if (in_array($this->ctrl->getCmd(), ['saveTopLevelPost', 'saveTopLevelDraft'])) {
3558 $form->setValuesByPost();
3559 }
3560 $threadContentTemplate->setVariable('BOTTOM_FORM', $form->getHTML());
3561 }
3562 } else {
3563 $threadContentTemplate->setCurrentBlock('posts_no');
3564 $threadContentTemplate->setVariable(
3565 'TXT_MSG_NO_POSTS_AVAILABLE',
3566 $this->lng->txt('forums_posts_not_available')
3567 );
3568 $threadContentTemplate->parseCurrentBlock();
3569 }
3570
3571 $to_top_button = $this->uiFactory->button()
3572 ->standard($this->lng->txt('top_of_page'), '#frm_page_top');
3573 $bottom_toolbar->addComponent($to_top_button);
3574 if ($numberOfPostings > 0) {
3575 $threadContentTemplate->setVariable('TOOLBAR_BOTTOM', $bottom_toolbar->getHTML());
3576 }
3577
3578 if ($toolbar_items !== []) {
3579 foreach ($toolbar_items as $component_index => $item) {
3580 $this->toolbar->addComponent($item);
3581 $bottom_toolbar->addComponent($item);
3582 if ($component_index === 0 && $numberOfPostings > 0) {
3583 $this->renderViewModeControl($this->selectedSorting);
3584 if ($this->selectedSorting !== ilForumProperties::VIEW_TREE) {
3585 $this->renderSortationControl($this->selectedSorting);
3586 }
3587 }
3588 }
3589 }
3590
3591 $this->tpl->setPermanentLink(
3592 $this->object->getType(),
3593 $this->object->getRefId(),
3594 (string) $this->objCurrentTopic->getId()
3595 );
3596
3597 $this->tpl->addOnLoadCode(
3598 <<<EOD
3599 document.querySelectorAll('.ilFrmPostContent img').forEach((img) => {
3600 const maxWidth = img.getAttribute('width');
3601 const maxHeight = img.getAttribute('height');
3602
3603 if (maxWidth) {
3604 img.style.maxWidth = maxWidth + 'px';
3605 img.removeAttribute('width');
3606 }
3607
3608 if (maxHeight) {
3609 img.style.maxHeight = maxHeight + 'px';
3610 img.removeAttribute('height');
3611 }
3612 });
3613EOD
3614 );
3615
3616 if ($this->selectedSorting === ilForumProperties::VIEW_TREE && ($this->selected_post_storage->get($thr_pk) > 0)) {
3617 $info = $this->getResetLimitedViewInfo();
3618 }
3619
3620 $this->tpl->setContent(($info ?? '') . $threadContentTemplate->get() . $this->getModalActions());
3621 }
static getSortedDrafts(int $usrId, int $threadId, int $sorting=ilForumProperties::VIEW_DATE_ASC)
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.
renderDraftContent(ilTemplate $tpl, string $action, ilForumPost $referencePosting, array $drafts)
renderPostContent(ilTemplate $tpl, ilForumPost $node, string $action, int $pageIndex, int $postIndex)
ensureValidPageForCurrentPosting(array $subtree_nodes, array $pagedPostings, int $pageSize, ilForumPost $firstForumPost)
preloadPostingFileResources(array $postings, array $draftsObjects)
renderSortationControl(int $currentSorting)
renderViewModeControl(int $currentViewMode)
addHeaderAction()
Add header action menu.
ilToolbarGUI $toolbar
if(!file_exists('../ilias.ini.php'))

References ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilChangeEvent\_recordReadEvent(), ilObjMediaObject\_removeUsage(), ILIAS\Repository\access(), ilNavigationHistory\addItem(), ILIAS\Repository\ctrl(), ForumGlobalScreenToolsProvider\FORUM_BASE_CONTROLLER, ForumGlobalScreenToolsProvider\FORUM_THEAD, ForumGlobalScreenToolsProvider\FORUM_THREAD_ROOT, ilSession\get(), ilForumPost\getId(), ilForumPostDraft\getSortedDrafts(), ILIAS\Repository\globalScreen(), if, ILIAS\Repository\int(), ilForumPostDraft\isSavePostDraftAllowed(), ILIAS\Repository\lng(), ILIAS\Repository\locator(), ILIAS\Repository\object(), ForumGlobalScreenToolsProvider\PAGE, ForumGlobalScreenToolsProvider\REF_ID, 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.

+ Here is the call graph for this function:

Field Documentation

◆ $attachment_logger

readonly ilLogger ilObjForumGUI::$attachment_logger
private

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

◆ $attachment_ownership

readonly OwnershipRepository ilObjForumGUI::$attachment_ownership
private

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

◆ $confirmation_gui_html

string ilObjForumGUI::$confirmation_gui_html = ''
private

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

◆ $content_style_domain

ILIAS Style Content Object ObjectFacade ilObjForumGUI::$content_style_domain
protected

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

◆ $content_style_gui

ILIAS Style Content GUIService ilObjForumGUI::$content_style_gui
protected

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

◆ $display_confirm_post_activation

bool ilObjForumGUI::$display_confirm_post_activation = false
private

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

◆ $draft_placement

readonly DraftPlacementRepository ilObjForumGUI::$draft_placement
private

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

◆ $factory

Factory ilObjForumGUI::$factory
private

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

◆ $forum_settings_gui

ilForumSettingsGUI ilObjForumGUI::$forum_settings_gui
private

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

◆ $forum_thread_table_session_storage

ForumThreadTableSessionStorage ilObjForumGUI::$forum_thread_table_session_storage
private

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

◆ $forumObjects

array ilObjForumGUI::$forumObjects = null
private

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

◆ $globalScreen

ILIAS GlobalScreen Services ilObjForumGUI::$globalScreen
private

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

◆ $hideToolbar

bool ilObjForumGUI::$hideToolbar = false
private

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

◆ $httpRequest

Psr Http Message ServerRequestInterface ilObjForumGUI::$httpRequest
private

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

◆ $ilHelp

ilHelpGUI ilObjForumGUI::$ilHelp

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

◆ $ilNavigationHistory

ilNavigationHistory ilObjForumGUI::$ilNavigationHistory

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

◆ $ilObjDataCache

ilObjectDataCache ilObjForumGUI::$ilObjDataCache

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

◆ $in_page_editor_style_context

readonly bool ilObjForumGUI::$in_page_editor_style_context
private

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

◆ $irss

IRSS ilObjForumGUI::$irss
private

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

◆ $is_moderator

bool ilObjForumGUI::$is_moderator
private

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

◆ $modal_collection

array ilObjForumGUI::$modal_collection = []
private

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

◆ $modal_history

string ilObjForumGUI::$modal_history = ''

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

◆ $modalActionsContainer

array ilObjForumGUI::$modalActionsContainer = []
private

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

◆ $objCurrentPost

ilForumPost ilObjForumGUI::$objCurrentPost
private

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

◆ $objCurrentTopic

ilForumTopic ilObjForumGUI::$objCurrentTopic
private

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

◆ $objProperties

ilForumProperties ilObjForumGUI::$objProperties

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

◆ $posting_placement

readonly PostingPlacementRepository ilObjForumGUI::$posting_placement
private

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

◆ $rbac

ILIAS DI RBACServices ilObjForumGUI::$rbac

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

◆ $renderer

Renderer ilObjForumGUI::$renderer
private

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

◆ $replyEditForm

ilPropertyFormGUI ilObjForumGUI::$replyEditForm = null
private

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

◆ $requestAction

string ilObjForumGUI::$requestAction
private

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

◆ $selected_post_storage

ilForumThreadSettingsSessionStorage ilObjForumGUI::$selected_post_storage
private

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

◆ $selectedSorting

int ilObjForumGUI::$selectedSorting
private

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

◆ $sortationOptions

array ilObjForumGUI::$sortationOptions
private
Initial value:
= [
ilForumProperties::VIEW_DATE_ASC => 'ascending_order',
ilForumProperties::VIEW_DATE_DESC => 'descending_order',
]

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

◆ $uiFactory

Factory ilObjForumGUI::$uiFactory
private

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

◆ $uiRenderer

Renderer ilObjForumGUI::$uiRenderer
private

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

◆ $viewModeOptions

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

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


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