ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
11 {
12  public $lng;
13  public $user;
14  public $access;
15  public $settings;
16 
20  public function __construct()
21  {
22  parent::__construct();
23 
24  global $DIC;
25  $this->lng = $DIC->language();
26  $this->user = $DIC->user();
27  $this->access = $DIC->access();
28  $this->settings = $DIC->settings();
29  }
30 
34  public function setChildId($a_child_id)
35  {
36  $this->child_id = $a_child_id;
37  }
38 
42  public function getChildId()
43  {
44  return $this->child_id;
45  }
46 
47  public function init()
48  {
49  $this->static_link_enabled = true;
50  $this->delete_enabled = true;
51  $this->cut_enabled = true;
52  $this->copy_enabled = true;
53  $this->subscribe_enabled = true;
54  $this->link_enabled = true;
55  $this->info_screen_enabled = true;
56  $this->type = 'frm';
57  $this->gui_class_name = 'ilobjforumgui';
58 
59  // general commands array
60  $this->commands = ilObjForumAccess::_getCommands();
61  }
62 
66  public function getProperties()
67  {
68  if (!$this->access->checkAccess('read', '', $this->ref_id)) {
69  return array();
70  }
71 
72  $this->lng->loadLanguageModule('forum');
73 
74  $props = array();
75 
76  $properties = ilObjForumAccess::getStatisticsByRefId($this->ref_id);
77  $num_posts_total = $properties['num_posts'];
78  $num_unread_total = $properties['num_unread_posts'];
79 
80  $num_drafts_total = 0;
82  $drafts_statistics = ilForumPostDraft::getDraftsStatisticsByRefId($this->ref_id);
83  $num_drafts_total = $drafts_statistics['total'];
84  }
85 
86  $frm_overview_setting = (int) $this->settings->get('forum_overview');
87  $num_new_total = 0;
88  if ($frm_overview_setting == ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS) {
89  $num_new_total = $properties['num_new_posts'];
90  }
91 
92  $last_post = ilObjForumAccess::getLastPostByRefId($this->ref_id);
93 
94  if (!$this->user->isAnonymous()) {
96  $props[] = array(
97  'alert' => false,
98  'property' => $this->lng->txt('forums_articles') . ' (' . $this->lng->txt('unread') . ')',
99  'value' => $num_posts_total . ' (' . $num_unread_total . ')'
100  );
101  if ($frm_overview_setting == ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS) {
102  if ($num_new_total > 0) {
103  // New
104  $props[] = array(
105  'alert' => false, 'property' => $this->lng->txt('forums_new_articles'), 'value' => $num_new_total
106  );
107  }
108  }
109  }
110 
111  if (ilForumPostDraft::isSavePostDraftAllowed() && $num_drafts_total > 0) {
112  $props[] = array(
113  'alert' => false,
114  'property' => $this->lng->txt('drafts'),
115  'value' => $num_drafts_total
116  );
117  }
118  } else {
119  $props[] = array(
120  'alert' => false,
121  'property' => $this->lng->txt('forums_articles'),
122  'value' => $num_posts_total
123  );
124  }
125 
127  if (ilForumProperties::getInstance($this->obj_id)->isAnonymized()) {
128  $props[] = array(
129  'alert' => false,
130  'newline' => false,
131  'property' => $this->lng->txt('forums_anonymized'),
132  'value' => $this->lng->txt('yes')
133  );
134  }
135  }
136 
137  // Last Post
138  if ((int) $last_post['pos_pk']) {
139  $lpCont = "<a class=\"il_ItemProperty\" target=\"" . ilFrameTargetInfo::_getFrame('MainContent') .
140  "\" href=\"ilias.php?baseClass=ilRepositoryGUI&amp;cmd=viewThread&amp;cmdClass=ilobjforumgui&amp;target=true&amp;pos_pk=" .
141  $last_post['pos_pk'] . "&amp;thr_pk=" . $last_post['pos_thr_fk'] . "&amp;ref_id=" .
142  $this->ref_id . "#" . $last_post["pos_pk"] . "\">" .
143  ilObjForumAccess::prepareMessageForLists($last_post['pos_message']) . "</a> " .
144  strtolower($this->lng->txt('from')) . "&nbsp;";
145 
146  $authorinfo = new ilForumAuthorInformation(
147  $last_post['pos_author_id'],
148  $last_post['pos_display_user_id'],
149  $last_post['pos_usr_alias'],
150  $last_post['import_name'],
151  array(
152  'class' => 'il_ItemProperty',
153  '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'])
154  )
155  );
156 
157  $lpCont .= $authorinfo->getLinkedAuthorName();
158  $lpCont .= ', ' . ilDatePresentation::formatDate(new ilDateTime($last_post['pos_date'], IL_CAL_DATETIME));
159 
160  $props[] = array(
161  'alert' => false,
162  'newline' => true,
163  'property' => $this->lng->txt('forums_last_post'),
164  'value' => $lpCont
165  );
166  }
167 
168  return $props;
169  }
170 
174  public function getCommandFrame($a_cmd)
175  {
176  return ilFrameTargetInfo::_getFrame('MainContent');
177  }
178 
182  public function getCommandLink($a_cmd)
183  {
184  switch ($a_cmd) {
185  case 'thread':
186  return 'ilias.php?baseClass=ilRepositoryGUI&amp;cmd=viewThread&amp;cmdClass=ilobjforumgui&amp;ref_id=' . $this->ref_id . '&amp;thr_pk=' . $this->getChildId();
187 
188  case 'posting':
189  $thread_post = $this->getChildId();
190  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];
191 
192  default:
193  return parent::getCommandLink($a_cmd);
194  }
195  }
196 }
settings()
Definition: settings.php:2
const IL_CAL_DATETIME
static getLastPostByRefId($ref_id)
global $DIC
Definition: saml.php:7
$_GET["client_id"]
Class ilObjForumListGUI.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
user()
Definition: user.php:4
static getInstance($a_obj_id=0)
Class ilObjectListGUI.
Date and time handling
getDetailsLevel()
Get current details level.
static _getFrame($a_class, $a_type='')
Get content frame name.
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: $...