ILIAS  release_8 Revision v8.24
class.ilObjForumListGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 private int $child_id;
30
31 public function __construct()
32 {
34 }
35
36 public function init(): void
37 {
38 $this->static_link_enabled = true;
39 $this->delete_enabled = true;
40 $this->cut_enabled = true;
41 $this->copy_enabled = true;
42 $this->subscribe_enabled = true;
43 $this->link_enabled = true;
44 $this->info_screen_enabled = true;
45 $this->type = 'frm';
46 $this->gui_class_name = ilObjForumGUI::class;
47
48 $this->commands = ilObjForumAccess::_getCommands();
49 }
50
51 public function setChildId(int $a_child_id): void
52 {
53 $this->child_id = $a_child_id;
54 }
55
56 public function getChildId(): int
57 {
58 return $this->child_id;
59 }
60
61 public function getProperties(): array
62 {
63 $props = [];
64
65 $maySee = $this->rbacsystem->checkAccess('visible', $this->ref_id);
66 $mayRead = $this->rbacsystem->checkAccess('read', $this->ref_id);
67
68 if (!$maySee && !$mayRead) {
69 return $props;
70 }
71
72 $props = parent::getProperties();
73
74 if (!$mayRead || ilObject::lookupOfflineStatus($this->obj_id)) {
75 return $props;
76 }
77
78 $this->lng->loadLanguageModule('forum');
79
80 $properties = ilObjForumAccess::getStatisticsByRefId($this->ref_id);
81 $num_posts_total = $properties['num_posts'];
82 $num_unread_total = $properties['num_unread_posts'];
83
84 $num_drafts_total = 0;
86 $drafts_statistics = ilForumPostDraft::getDraftsStatisticsByRefId($this->ref_id);
87 $num_drafts_total = $drafts_statistics['total'];
88 }
89
90 $frm_overview_setting = (int) (new ilSetting('frma'))->get(
91 'forum_overview',
93 );
94 $num_new_total = 0;
95 if ($frm_overview_setting === ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS) {
96 $num_new_total = $properties['num_new_posts'];
97 }
98
99 if (!$this->user->isAnonymous()) {
101 $props[] = [
102 'alert' => false,
103 'property' => $this->lng->txt('forums_articles') . ' (' . $this->lng->txt('unread') . ')',
104 'value' => $num_posts_total . ' (' . $num_unread_total . ')'
105 ];
106 if ($frm_overview_setting === ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS && $num_new_total > 0) {
107 $props[] = [
108 'alert' => false,
109 'property' => $this->lng->txt('forums_new_articles'),
110 'value' => $num_new_total
111 ];
112 }
113 }
114
115 if ($num_drafts_total > 0 && ilForumPostDraft::isSavePostDraftAllowed()) {
116 $props[] = [
117 'alert' => false,
118 'property' => $this->lng->txt('drafts'),
119 'value' => $num_drafts_total
120 ];
121 }
122 } else {
123 $props[] = [
124 'alert' => false,
125 'property' => $this->lng->txt('forums_articles'),
126 'value' => $num_posts_total
127 ];
128 }
129
130 if (
132 ilForumProperties::getInstance($this->obj_id)->isAnonymized()
133 ) {
134 $props[] = [
135 'alert' => false,
136 'newline' => false,
137 'property' => $this->lng->txt('forums_anonymized'),
138 'value' => $this->lng->txt('yes')
139 ];
140 }
141
142 $last_post = ilObjForumAccess::getLastPostByRefId($this->ref_id);
143 if (is_array($last_post) && $last_post['pos_pk'] > 0) {
144 $lpCont = "<a class=\"il_ItemProperty\" target=\"" . ilFrameTargetInfo::_getFrame('MainContent') .
145 "\" href=\"ilias.php?baseClass=" . ilRepositoryGUI::class . "&amp;cmd=viewThread&amp;cmdClass=" .
146 ilObjForumGUI::class . "&amp;target=true&amp;pos_pk=" .
147 $last_post['pos_pk'] . "&amp;thr_pk=" . $last_post['pos_thr_fk'] . "&amp;ref_id=" .
148 $this->ref_id . "#" . $last_post["pos_pk"] . "\">" .
149 ilObjForumAccess::prepareMessageForLists($last_post['pos_message']) . "</a> " .
150 strtolower($this->lng->txt('from')) . "&nbsp;";
151
152 $authorinfo = new ilForumAuthorInformation(
153 (int) $last_post['pos_author_id'],
154 (int) $last_post['pos_display_user_id'],
155 (string) $last_post['pos_usr_alias'],
156 (string) $last_post['import_name'],
157 [
158 'class' => 'il_ItemProperty',
159 'href' => 'ilias.php?baseClass=' . ilRepositoryGUI::class . '&amp;cmd=showUser&amp;' .
160 'cmdClass=' . ilObjForumGUI::class . '&amp;ref_id=' . $this->ref_id . '&amp;' .
161 'user=' . $last_post['pos_display_user_id'] . '&amp;offset=0&amp;backurl=' .
162 urlencode('ilias.php?baseClass=' . ilRepositoryGUI::class . '&amp;ref_id=' . $this->ref_id)
163 ]
164 );
165
166 $lpCont .= $authorinfo->getLinkedAuthorName();
167 $lpCont .= ', ' . ilDatePresentation::formatDate(new ilDateTime($last_post['pos_date'], IL_CAL_DATETIME));
168
169 $props[] = [
170 'alert' => false,
171 'newline' => true,
172 'property' => $this->lng->txt('forums_last_post'),
173 'value' => $lpCont
174 ];
175 }
176
177 return $props;
178 }
179
180 public function getCommandFrame(string $cmd): string
181 {
182 return ilFrameTargetInfo::_getFrame('MainContent');
183 }
184
185 public function getCommandLink(string $cmd): string
186 {
187 switch ($cmd) {
188 case 'thread':
189 return (
190 'ilias.php?baseClass=' . ilRepositoryGUI::class . '&amp;cmd=viewThread&amp;cmdClass=' .
191 ilObjForumGUI::class . '&amp;ref_id=' . $this->ref_id . '&amp;thr_pk=' . $this->getChildId()
192 );
193
194 case 'posting':
195 $thread_post = $this->getChildId();
196 // TODO PHP 8 This cannot be correct, an id which is used as an array (don't know what is the correct code here) ...
197 return (
198 'ilias.php?baseClass=' . ilRepositoryGUI::class . '&amp;cmd=viewThread&amp;cmdClass=' .
199 ilObjForumGUI::class . '&amp;target=1&amp;ref_id=' . $this->ref_id . '&amp;thr_pk=' .
200 $thread_post[0] . '&amp;pos_pk=' . $thread_post[1] . '#' . $thread_post[1]
201 );
202
203 default:
204 return parent::getCommandLink($cmd);
205 }
206 }
207}
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
static getDraftsStatisticsByRefId(int $ref_id)
static getInstance(int $a_obj_id=0)
static _getFrame(string $a_class)
static getStatisticsByRefId(int $ref_id)
static _getCommands()
get commands
static prepareMessageForLists(string $text)
static getLastPostByRefId(int $ref_id)
Class ilObjForumListGUI.
setChildId(int $a_child_id)
getCommandFrame(string $cmd)
Get command target frame.
getProperties()
Get item properties.
getCommandLink(string $cmd)
Get command link url.
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc