ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  {
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  {
77  global $lng, $ilUser, $ilAccess;
78 
79  if(!$ilAccess->checkAccess('read', '', $this->ref_id))
80  {
81  return array();
82  }
83 
84  $lng->loadLanguageModule('forum');
85 
86  $props = array();
87 
88  include_once 'Modules/Forum/classes/class.ilObjForumAccess.php';
89  $properties = ilObjForumAccess::getStatisticsByRefId($this->ref_id);
90  $num_posts_total = $properties['num_posts'];
91  $num_unread_total = $properties['num_unread_posts'];
92  $num_new_total = $properties['num_new_posts'];
93  $last_post = ilObjForumAccess::getLastPostByRefId($this->ref_id);
94 
95  if(!$ilUser->isAnonymous())
96  {
98  {
99  $alert = ($num_unread_total > 0) ? true : false;
100  $props[] = array(
101  'alert' => $alert,
102  'property' => $lng->txt('forums_articles') . ' (' . $lng->txt('unread') . ')',
103  'value' => $num_posts_total . ' (' . $num_unread_total . ')'
104  );
105 
106  // New
107  $alert = ($num_new_total > 0) ? true : false;
108  $props[] = array(
109  'alert' => $alert,
110  'property' => $lng->txt('forums_new_articles'),
111  'value' => $num_new_total
112  );
113  }
114  }
115  else
116  {
117  $props[] = array(
118  'alert' => false,
119  'property' => $lng->txt('forums_articles'),
120  'value' => $num_posts_total
121  );
122  }
123 
124  include_once 'Modules/Forum/classes/class.ilForumProperties.php';
126  {
127  if(ilForumProperties::getInstance($this->obj_id)->isAnonymized())
128  {
129  $props[] = array(
130  'alert' => false,
131  'newline' => false,
132  'property' => $lng->txt('forums_anonymized'),
133  'value' => $lng->txt('yes')
134  );
135  }
136  }
137 
138  // Last Post
139  if((int)$last_post['pos_pk'])
140  {
141  $lpCont = "<a class=\"il_ItemProperty\" target=\"" . ilFrameTargetInfo::_getFrame('MainContent') .
142  "\" href=\"ilias.php?baseClass=ilRepositoryGUI&amp;cmd=viewThread&amp;cmdClass=ilobjforumgui&amp;target=true&amp;pos_pk=" .
143  $last_post['pos_pk'] . "&amp;thr_pk=" . $last_post['pos_thr_fk'] . "&amp;ref_id=" .
144  $this->ref_id . "#" . $last_post["pos_pk"] . "\">" .
145  ilObjForumAccess::prepareMessageForLists($last_post['pos_message']) . "</a> " .
146  strtolower($lng->txt('from')) . "&nbsp;";
147 
148  require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
149  $authorinfo = new ilForumAuthorInformation(
150  $last_post['pos_usr_id'],
151  $last_post['pos_usr_alias'],
152  $last_post['import_name'],
153  array(
154  'class' => 'il_ItemProperty',
155  'href' => 'ilias.php?baseClass=ilRepositoryGUI&amp;cmd=showUser&amp;cmdClass=ilobjforumgui&amp;ref_id=' . $this->ref_id . '&amp;user='.$last_post['pos_usr_id'].'&amp;offset=0&amp;backurl=' . urlencode('ilias.php?baseClass=ilRepositoryGUI&amp;ref_id=' . $_GET['ref_id'])
156  )
157  );
158 
159  $lpCont .= $authorinfo->getLinkedAuthorName();
160  $lpCont .= ', ' . ilDatePresentation::formatDate(new ilDateTime($last_post['pos_date'], IL_CAL_DATETIME));
161 
162  $props[] = array(
163  'alert' => false,
164  'newline' => true,
165  'property' => $lng->txt('forums_last_post'),
166  'value' => $lpCont
167  );
168  }
169 
170  return $props;
171  }
172 
177  public function getCommandFrame($a_cmd)
178  {
179  return ilFrameTargetInfo::_getFrame('MainContent');
180  }
181 
186  public function getCommandLink($a_cmd)
187  {
188  switch($a_cmd)
189  {
190  case 'thread':
191  return 'ilias.php?baseClass=ilRepositoryGUI&amp;cmd=viewThread&amp;cmdClass=ilobjforumgui&amp;ref_id=' . $this->ref_id . '&amp;thr_pk=' . $this->getChildId();
192 
193  case 'posting':
194  $thread_post = $this->getChildId();
195  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];
196 
197  default:
198  return parent::getCommandLink($a_cmd);
199  }
200  }
201 }