19 declare(strict_types=1);
46 bool $is_moderator =
false 50 $this->
lng = $DIC->language();
52 $this->
user = $DIC->user();
55 $this->parent_cmd = $a_parent_cmd;
60 $id =
'frm_tt_' . substr(md5($this->parent_cmd), 0, 3) .
'_' . $this->
getRefId();
69 $this->
mainTemplate->addCss(
'./assets/css/forum_table.css');
73 public function init(): void
75 if ($this->parent_cmd ===
'mergeThreads') {
84 if ($this->parent_cmd ===
"showThreads") {
86 $this->
addColumn(
'',
'check',
'1px',
true);
88 $this->
addColumn(
'',
'check',
'10px',
true);
91 $this->
addColumn($this->
lng->txt(
'forums_thread'),
'thr_subject');
92 $this->
addColumn($this->
lng->txt(
'forums_created_by'),
'');
93 $this->
addColumn($this->
lng->txt(
'forums_articles'),
'num_posts');
94 $this->
addColumn($this->
lng->txt(
'visits'),
'num_visit');
96 if ($this->is_post_draft_allowed) {
100 $this->
addColumn($this->
lng->txt(
'forums_last_post'),
'post_date');
101 if (
'showThreads' === $this->parent_cmd && $this->parent_obj->objProperties->isIsThreadRatingEnabled()) {
102 $this->
addColumn($this->
lng->txt(
'frm_rating'),
'rating');
105 $this->
setFormAction($this->
ctrl->getFormAction($this->getParentObject(),
'showThreads'));
106 $this->
setRowTemplate(
'tpl.forums_threads_table.html',
'components/ILIAS/Forum');
109 if ($this->
settings->get(
'forum_notification') > 0 && !$this->
user->isAnonymous()) {
110 $this->
addMultiCommand(
'enable_notifications', $this->
lng->txt(
'forums_enable_notification'));
111 $this->
addMultiCommand(
'disable_notifications', $this->
lng->txt(
'forums_disable_notification'));
132 $this->
addColumn(
'',
'check',
'1px',
true);
133 $this->
addColumn($this->
lng->txt(
'forums_thread'),
'th_title');
134 $this->
addColumn($this->
lng->txt(
'forums_created_by'),
'author');
135 $this->
addColumn($this->
lng->txt(
'forums_articles'),
'num_posts');
136 $this->
addColumn($this->
lng->txt(
'visits'),
'num_visit');
137 if ($this->is_post_draft_allowed) {
140 $this->
addColumn($this->
lng->txt(
'forums_last_post'),
'lp_date');
143 $this->
setFormAction($this->
ctrl->getFormAction($this->getParentObject(),
'confirmMergeThreads'));
144 $this->
setRowTemplate(
'tpl.forums_threads_table.html',
'components/ILIAS/Forum');
146 $this->
mainTemplate->setOnScreenMessage(
'info', $this->
lng->txt(
'please_choose_target'));
156 protected function fillRow(array $a_set):
void 159 $thread = $a_set[
'thread'];
164 if ($DIC->http()->wrapper()->post()->has(
'thread_ids')) {
165 $thread_ids = $DIC->http()->wrapper()->post()->retrieve(
167 $DIC->refinery()->kindlyTo()->listOf($DIC->refinery()->kindlyTo()->int())
171 if (
'mergeThreads' === $this->parent_cmd) {
172 $checked = $this->max_count === 1 || (isset($thread_ids) && in_array($thread->getId(), $thread_ids,
true));
173 $this->tpl->setVariable(
178 (
string) $thread->getId()
182 $this->tpl->setVariable(
185 (isset($thread_ids) && in_array($thread->getId(), $thread_ids,
true)),
187 (string) $thread->getId()
191 if ($this->parent_obj->objProperties->isIsThreadRatingEnabled()) {
194 $this->parent_obj->getObject()->getId(),
195 $this->parent_obj->getObject()->getType(),
199 $rating->setUserId($this->
user->getId());
200 $this->tpl->setVariable(
'VAL_RATING', $rating->getHTML());
205 if ($thread->isSticky()) {
206 $subject .=
'<span class="light">[' . $this->
lng->txt(
'sticky') .
']</span> ';
208 if ($thread->isClosed()) {
209 $subject .=
'<span class="light">[' . $this->
lng->txt(
'topic_close') .
']</span> ';
212 if (!$this->
user->isAnonymous() &&
213 (
int) $this->
settings->get(
'forum_notification',
'0') !== 0 &&
214 $thread->isUserNotificationEnabled()
216 $subject .=
'<span class="light">[' . $this->
lng->txt(
'forums_notification_enabled') .
']</span> ';
219 $num_posts = $thread->getNumPosts();
220 $num_unread = $thread->getNumUnreadPosts();
223 $subject = $thread->getSubject();
226 $this->tpl->setVariable(
'VAL_SUBJECT', $subject);
228 $this->
ctrl->setParameter(
231 urlencode($this->
ctrl->getLinkTargetByClass(
"ilrepositorygui",
""))
236 $thread->getThrAuthorId(),
237 $thread->getDisplayUserId(),
238 (string) $thread->getUserAlias(),
239 (string) $thread->getImportName(),
241 'class' =>
'il_ItemProperty',
245 $this->tpl->setVariable(
'VAL_AUTHOR', $authorinfo->getLinkedAuthorName());
247 $topicStats = $num_posts;
248 if (!$this->
user->isAnonymous()) {
249 if ($num_unread > 0) {
250 $topicStats .=
'<br /><span class="ilAlert ilWhiteSpaceNowrap">' . $this->
lng->txt(
'unread') .
': ' . $num_unread .
'</span>';
254 $this->tpl->setVariable(
'VAL_ARTICLE_STATS', $topicStats);
255 $this->tpl->setVariable(
'VAL_NUM_VISIT', $thread->getVisits());
256 if ($this->is_post_draft_allowed) {
258 $this->tpl->setVariable(
260 (
int) isset($draft_statistics[$thread->getId()]) !== 0 ? $draft_statistics[$thread->getId()] : 0
264 if ($num_posts > 0 && $thread->getLastPostForThreadOverview() instanceof
ilForumPost) {
265 $objLastPost = $thread->getLastPostForThreadOverview();
267 $this->
ctrl->setParameter($this->
getParentObject(),
'user', $objLastPost->getDisplayUserId());
269 $objLastPost->getPosAuthorId(),
270 $objLastPost->getDisplayUserId(),
271 (string) $objLastPost->getUserAlias(),
272 (string) $objLastPost->getImportName(),
278 $this->tpl->setVariable(
281 $objLastPost->getCreateDate(),
284 '<div class="ilWhiteSpaceNowrap">' . $this->
lng->txt(
'from') .
' ' . $authorinfo->getLinkedAuthorName() .
'</div>' 289 if ($thread->isSticky()) {
292 $this->tpl->setVariable(
'CSS_ROW',
$css_row);
304 if ($this->parent_cmd ===
'mergeThreads' &&
311 'excluded_ids' => $excluded_ids,
317 $this->topicData->getTopPk(),
325 $this->topicData->getTopPk(),
333 $this->
setData(
array_map(
static fn(ilForumTopic $thread): array => [
'thread' => $thread],
$data[
'items']));
337 foreach (
$data[
'items'] as $thread) {
339 $thread_ids[] = $thread->getId();
340 if ($thread->getDisplayUserId() > 0) {
341 $user_ids[$thread->getDisplayUserId()] = $thread->getDisplayUserId();
345 $user_ids = array_merge(
401 $this->merge_thread_obj = $thread_obj;
setFormAction(string $a_form_action, bool $a_multipart=false)
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
static getUserIdsOfLastPostsByRefIdAndThreadIds(int $ref_id, array $thread_ids)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setIsModerator(bool $is_moderator)
__construct(ilObjForumGUI $a_parent_obj, string $a_parent_cmd, int $ref_id, ForumDto $topicData, bool $is_moderator=false)
setSelectedThread(ilForumTopic $thread_obj)
Class ilForumTopicTableGUI.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
resetOffset(bool $a_in_determination=false)
setExternalSorting(bool $a_val)
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
readonly ilSetting $settings
fillRow(array $a_set)
Standard Version of Fill Row.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setDefaultOrderField(string $a_defaultorderfield)
static getDraftsStatisticsByRefId(int $ref_id)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
readonly ilGlobalTemplateInterface $mainTemplate
static isSavePostDraftAllowed()
setMapper(ilForum $mapper)
ilForumTopic $merge_thread_obj
setRowSelectorLabel(string $row_selector_label)
readonly bool $is_post_draft_allowed
__construct(Container $dic, ilPlugin $plugin)
initTopicsOverviewTable()
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
disable(string $a_module_name)
setTopicData(ForumDto $topicData)
addMultiCommand(string $a_cmd, string $a_text)
determineOffsetAndOrder(bool $a_omit_offset=false)
setMaxCount(int $a_max_count)
set max.
setExternalSegmentation(bool $a_val)