ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 include_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->info_screen_enabled = true;
47  $this->type = 'frm';
48  $this->gui_class_name = 'ilobjforumgui';
49 
50  // general commands array
51  include_once 'Modules/Forum/classes/class.ilObjForumAccess.php';
52  $this->commands = ilObjForumAccess::_getCommands();
53  }
54 
58  public function getProperties()
59  {
66  global $lng, $ilUser, $ilAccess, $ilSetting;
67 
68  if(!$ilAccess->checkAccess('read', '', $this->ref_id))
69  {
70  return array();
71  }
72 
73  $lng->loadLanguageModule('forum');
74 
75  $props = array();
76 
77  include_once 'Modules/Forum/classes/class.ilObjForumAccess.php';
78  $properties = ilObjForumAccess::getStatisticsByRefId($this->ref_id);
79  $num_posts_total = $properties['num_posts'];
80  $num_unread_total = $properties['num_unread_posts'];
81 
82  include_once 'Modules/Forum/classes/class.ilForumPostDraft.php';
83  $num_drafts_total = 0;
85  {
86  $drafts_statistics = ilForumPostDraft::getDraftsStatisticsByRefId($this->ref_id);
87  $num_drafts_total = $drafts_statistics['total'];
88  }
89 
90  $frm_overview_setting = (int)$ilSetting::_lookupValue('frma','forum_overview');
91  $num_new_total = 0;
92  if($frm_overview_setting == ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS)
93  {
94  $num_new_total = $properties['num_new_posts'];
95  }
96 
97  $last_post = ilObjForumAccess::getLastPostByRefId($this->ref_id);
98 
99  if(!$ilUser->isAnonymous())
100  {
102  {
103  $alert = ($num_unread_total > 0) ? true : false;
104  $props[] = array(
105  'alert' => $alert,
106  'property' => $lng->txt('forums_articles') . ' (' . $lng->txt('unread') . ')',
107  'value' => $num_posts_total . ' (' . $num_unread_total . ')'
108  );
109  if($frm_overview_setting == ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS)
110  {
111  if($num_new_total > 0)
112  {
113  // New
114  $alert = ($num_new_total > 0) ? true : false;
115  $props[] = array(
116  'alert' => $alert, 'property' => $lng->txt('forums_new_articles'), 'value' => $num_new_total
117  );
118  }
119  }
120  }
121 
122  if(ilForumPostDraft::isSavePostDraftAllowed() && $num_drafts_total > 0)
123  {
124  $props[] = array(
125  'alert' => ($num_drafts_total > 0) ? true : false,
126  'property' => $lng->txt('drafts'),
127  'value' => $num_drafts_total
128  );
129  }
130  }
131  else
132  {
133  $props[] = array(
134  'alert' => false,
135  'property' => $lng->txt('forums_articles'),
136  'value' => $num_posts_total
137  );
138  }
139 
140  include_once 'Modules/Forum/classes/class.ilForumProperties.php';
142  {
143  if(ilForumProperties::getInstance($this->obj_id)->isAnonymized())
144  {
145  $props[] = array(
146  'alert' => false,
147  'newline' => false,
148  'property' => $lng->txt('forums_anonymized'),
149  'value' => $lng->txt('yes')
150  );
151  }
152  }
153 
154  // Last Post
155  if((int)$last_post['pos_pk'])
156  {
157  $lpCont = "<a class=\"il_ItemProperty\" target=\"" . ilFrameTargetInfo::_getFrame('MainContent') .
158  "\" href=\"ilias.php?baseClass=ilRepositoryGUI&amp;cmd=viewThread&amp;cmdClass=ilobjforumgui&amp;target=true&amp;pos_pk=" .
159  $last_post['pos_pk'] . "&amp;thr_pk=" . $last_post['pos_thr_fk'] . "&amp;ref_id=" .
160  $this->ref_id . "#" . $last_post["pos_pk"] . "\">" .
161  ilObjForumAccess::prepareMessageForLists($last_post['pos_message']) . "</a> " .
162  strtolower($lng->txt('from')) . "&nbsp;";
163 
164  require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
165  $authorinfo = new ilForumAuthorInformation(
166  $last_post['pos_author_id'],
167  $last_post['pos_display_user_id'],
168  $last_post['pos_usr_alias'],
169  $last_post['import_name'],
170  array(
171  'class' => 'il_ItemProperty',
172  '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'])
173  )
174  );
175 
176  $lpCont .= $authorinfo->getLinkedAuthorName();
177  $lpCont .= ', ' . ilDatePresentation::formatDate(new ilDateTime($last_post['pos_date'], IL_CAL_DATETIME));
178 
179  $props[] = array(
180  'alert' => false,
181  'newline' => true,
182  'property' => $lng->txt('forums_last_post'),
183  'value' => $lpCont
184  );
185  }
186 
187  return $props;
188  }
189 
193  public function getCommandFrame($a_cmd)
194  {
195  return ilFrameTargetInfo::_getFrame('MainContent');
196  }
197 
201  public function getCommandLink($a_cmd)
202  {
203  switch($a_cmd)
204  {
205  case 'thread':
206  return 'ilias.php?baseClass=ilRepositoryGUI&amp;cmd=viewThread&amp;cmdClass=ilobjforumgui&amp;ref_id=' . $this->ref_id . '&amp;thr_pk=' . $this->getChildId();
207 
208  case 'posting':
209  $thread_post = $this->getChildId();
210  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];
211 
212  default:
213  return parent::getCommandLink($a_cmd);
214  }
215  }
216 }
const IL_CAL_DATETIME
static getLastPostByRefId($ref_id)
$_GET["client_id"]
Class ilObjForumListGUI.
static getInstance($a_obj_id=0)
getProperties()
Get item properties.
Class ilObjectListGUI.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
$ilUser
Definition: imgupload.php:18
getDetailsLevel()
Get current details level.
Create styles array
The data for the language used.
static _getFrame($a_class, $a_type='')
Get content frame name.
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
static getStatisticsByRefId($ref_id)
static prepareMessageForLists($text)
Prepare message for container view.
static getDraftsStatisticsByRefId($ref_id)
static _getCommands()
get commands this method returns an array of all possible commands/permission combinations example: $...