ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjForumListGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once 'Services/Object/classes/class.ilObjectListGUI.php';
5
13{
17 public function __construct()
18 {
19 parent::__construct();
20 }
21
25 public function setChildId($a_child_id)
26 {
27 $this->child_id = $a_child_id;
28 }
29
33 public function getChildId()
34 {
35 return $this->child_id;
36 }
37
38 public function init()
39 {
40 $this->static_link_enabled = true;
41 $this->delete_enabled = true;
42 $this->cut_enabled = true;
43 $this->copy_enabled = true;
44 $this->subscribe_enabled = true;
45 $this->link_enabled = true;
46 $this->payment_enabled = false;
47 $this->info_screen_enabled = true;
48 $this->type = 'frm';
49 $this->gui_class_name = 'ilobjforumgui';
50
51 // general commands array
52 include_once 'Modules/Forum/classes/class.ilObjForumAccess.php';
53 $this->commands = ilObjForumAccess::_getCommands();
54 }
55
62 public function initItem($a_ref_id, $a_obj_id, $a_title = "", $a_description = "")
63 {
64 parent::initItem($a_ref_id, $a_obj_id, $a_title, $a_description);
65 }
66
70 public function getProperties()
71 {
78 global $lng, $ilUser, $ilAccess, $ilSetting;
79
80 if(!$ilAccess->checkAccess('read', '', $this->ref_id))
81 {
82 return array();
83 }
84
85 $lng->loadLanguageModule('forum');
86
87 $props = array();
88
89 include_once 'Modules/Forum/classes/class.ilObjForumAccess.php';
90 $properties = ilObjForumAccess::getStatisticsByRefId($this->ref_id);
91 $num_posts_total = $properties['num_posts'];
92 $num_unread_total = $properties['num_unread_posts'];
93
94 $frm_overview_setting = (int)$ilSetting::_lookupValue('frma','forum_overview');
95 $num_new_total = 0;
96 if($frm_overview_setting == ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS)
97 {
98 $num_new_total = $properties['num_new_posts'];
99 }
100
101 $last_post = ilObjForumAccess::getLastPostByRefId($this->ref_id);
102
103 if(!$ilUser->isAnonymous())
104 {
106 {
107 $alert = ($num_unread_total > 0) ? true : false;
108 $props[] = array(
109 'alert' => $alert,
110 'property' => $lng->txt('forums_articles') . ' (' . $lng->txt('unread') . ')',
111 'value' => $num_posts_total . ' (' . $num_unread_total . ')'
112 );
113 if($frm_overview_setting == ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS)
114 {
115 if($num_new_total > 0)
116 {
117 // New
118 $alert = ($num_new_total > 0) ? true : false;
119 $props[] = array(
120 'alert' => $alert, 'property' => $lng->txt('forums_new_articles'), 'value' => $num_new_total
121 );
122 }
123 }
124 }
125 }
126 else
127 {
128 $props[] = array(
129 'alert' => false,
130 'property' => $lng->txt('forums_articles'),
131 'value' => $num_posts_total
132 );
133 }
134
135 include_once 'Modules/Forum/classes/class.ilForumProperties.php';
137 {
138 if(ilForumProperties::getInstance($this->obj_id)->isAnonymized())
139 {
140 $props[] = array(
141 'alert' => false,
142 'newline' => false,
143 'property' => $lng->txt('forums_anonymized'),
144 'value' => $lng->txt('yes')
145 );
146 }
147 }
148
149 // Last Post
150 if((int)$last_post['pos_pk'])
151 {
152 $lpCont = "<a class=\"il_ItemProperty\" target=\"" . ilFrameTargetInfo::_getFrame('MainContent') .
153 "\" href=\"ilias.php?baseClass=ilRepositoryGUI&amp;cmd=viewThread&amp;cmdClass=ilobjforumgui&amp;target=true&amp;pos_pk=" .
154 $last_post['pos_pk'] . "&amp;thr_pk=" . $last_post['pos_thr_fk'] . "&amp;ref_id=" .
155 $this->ref_id . "#" . $last_post["pos_pk"] . "\">" .
156 ilObjForumAccess::prepareMessageForLists($last_post['pos_message']) . "</a> " .
157 strtolower($lng->txt('from')) . "&nbsp;";
158
159 require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
160 $authorinfo = new ilForumAuthorInformation(
161 $last_post['pos_author_id'],
162 $last_post['pos_display_user_id'],
163 $last_post['pos_usr_alias'],
164 $last_post['import_name'],
165 array(
166 'class' => 'il_ItemProperty',
167 'href' => 'ilias.php?baseClass=ilRepositoryGUI&amp;cmd=showUser&amp;cmdClass=ilobjforumgui&amp;ref_id=' . $this->ref_id . '&amp;user='.$last_post['pos_display_user_id'].'&amp;offset=0&amp;backurl=' . urlencode('ilias.php?baseClass=ilRepositoryGUI&amp;ref_id=' . $_GET['ref_id'])
168 )
169 );
170
171 $lpCont .= $authorinfo->getLinkedAuthorName();
172 $lpCont .= ', ' . ilDatePresentation::formatDate(new ilDateTime($last_post['pos_date'], IL_CAL_DATETIME));
173
174 $props[] = array(
175 'alert' => false,
176 'newline' => true,
177 'property' => $lng->txt('forums_last_post'),
178 'value' => $lpCont
179 );
180 }
181
182 return $props;
183 }
184
189 public function getCommandFrame($a_cmd)
190 {
191 return ilFrameTargetInfo::_getFrame('MainContent');
192 }
193
198 public function getCommandLink($a_cmd)
199 {
200 switch($a_cmd)
201 {
202 case 'thread':
203 return 'ilias.php?baseClass=ilRepositoryGUI&amp;cmd=viewThread&amp;cmdClass=ilobjforumgui&amp;ref_id=' . $this->ref_id . '&amp;thr_pk=' . $this->getChildId();
204
205 case 'posting':
206 $thread_post = $this->getChildId();
207 return 'ilias.php?baseClass=ilRepositoryGUI&amp;cmd=viewThread&amp;cmdClass=ilobjforumgui&amp;target=1&amp;ref_id=' . $this->ref_id . '&amp;thr_pk=' . $thread_post[0] . '&amp;pos_pk=' . $thread_post[1] . '#' . $thread_post[1];
208
209 default:
210 return parent::getCommandLink($a_cmd);
211 }
212 }
213}
$_GET["client_id"]
const IL_CAL_DATETIME
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
static getInstance($a_obj_id=0)
static _getFrame($a_class, $a_type='')
Get content frame name.
static getLastPostByRefId($ref_id)
static getStatisticsByRefId($ref_id)
static prepareMessageForLists($text)
Prepare message for container view.
_getCommands()
get commands this method returns an array of all possible commands/permission combinations example: $...
Class ilObjForumListGUI.
initItem($a_ref_id, $a_obj_id, $a_title="", $a_description="")
Class ilObjectListGUI.
getProperties($a_item='')
Get item properties.
getDetailsLevel()
Get current details level.
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40
global $ilUser
Definition: imgupload.php:15