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