ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilUserFeedWriter.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/News/classes/class.ilNewsItem.php");
6 include_once("./Services/Feeds/classes/class.ilFeedItem.php");
7 include_once("./Services/Feeds/classes/class.ilFeedWriter.php");
8 
20 {
21 
22  function ilUserFeedWriter($a_user_id, $a_hash, $privFeed = false)
23  {
24  global $ilSetting, $lng;
25 
27 
28  //$lng->loadLanguageModule("news");
29 
30  if ($a_user_id == "" || $a_hash == "")
31  {
32  return;
33  }
34 
35  $news_set = new ilSetting("news");
36  if (!$news_set->get("enable_rss_for_internal"))
37  {
38  return;
39  }
40 
41  $hash = ilObjUser::_lookupFeedHash($a_user_id);
42 
43  include_once("./Services/News/classes/class.ilNewsItem.php");
44  $rss_period = ilNewsItem::_lookupRSSPeriod();
45 
46  if ($a_hash == $hash)
47  {
48  if ($privFeed)
49  {
50  ilNewsItem::setPrivateFeedId($a_user_id);
51  }
52  $items = ilNewsItem::_getNewsItemsOfUser($a_user_id, true, true, $rss_period);
53  if ($ilSetting->get('short_inst_name') != "")
54  {
55  $this->setChannelTitle($ilSetting->get('short_inst_name'));
56  }
57  else
58  {
59  $this->setChannelTitle("ILIAS");
60  }
61 
62  $this->setChannelAbout(ILIAS_HTTP_PATH);
63  $this->setChannelLink(ILIAS_HTTP_PATH);
64  //$this->setChannelDescription("ILIAS Channel Description");
65  $i = 0;
66  foreach($items as $item)
67  {
68  $obj_id = ilObject::_lookupObjId($item["ref_id"]);
69  $obj_type = ilObject::_lookupType($obj_id);
70  $obj_title = ilObject::_lookupTitle($obj_id);
71 
72  // not nice, to do: general solution
73  if ($obj_type == "mcst")
74  {
75  include_once("./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php");
77  {
78  continue;
79  }
80  }
81 
82  $i++;
83  $feed_item = new ilFeedItem();
85  ($item["context_obj_type"], $item["title"], $item["content_is_lang_var"],
86  $item["agg_ref_id"], $item["aggregation"]);
87 
88  // path
89  $cont_loc = new ilLocatorGUI();
90  $cont_loc->addContextItems($item["ref_id"], true);
91  $cont_loc->setTextOnly(true);
92  $loc = "[".$cont_loc->getHTML()."]";
93 
94  // title
95  if ($news_set->get("rss_title_format") == "news_obj")
96  {
97  $feed_item->setTitle($this->prepareStr(str_replace("<br />", " ", $title)).
98  " (".$this->prepareStr($loc)." ".$this->prepareStr($obj_title).
99  ")");
100  }
101  else
102  {
103  $feed_item->setTitle($this->prepareStr($loc)." ".$this->prepareStr($obj_title).
104  ": ".$this->prepareStr(str_replace("<br />", " ", $title)));
105  }
106 
107  // description
108  $content = $this->prepareStr(nl2br(
109  ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"])));
110  $feed_item->setDescription($content);
111 
112  // lm page hack, not nice
113  if (in_array($item["context_obj_type"], array("dbk", "lm")) && $item["context_sub_obj_type"] == "pg"
114  && $item["context_sub_obj_id"] > 0)
115  {
116  $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
117  "&amp;target=pg_".$item["context_sub_obj_id"]."_".$item["ref_id"]);
118  }
119  else if ($item["context_obj_type"] == "wiki" && $item["context_sub_obj_type"] == "wpg"
120  && $item["context_sub_obj_id"] > 0)
121  {
122  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
123  $wptitle = ilWikiPage::lookupTitle($item["context_sub_obj_id"]);
124  $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
125  "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"]."_".$wptitle);
126  }
127  else if (in_array($item["context_obj_type"], array("frm")) && $item["context_sub_obj_type"] == "pos"
128  && $item["context_sub_obj_id"] > 0)
129  {
130  // frm hack, not nice
131  include_once("./Modules/Forum/classes/class.ilObjForumAccess.php");
132  $thread_id = ilObjForumAccess::_getThreadForPosting($item["context_sub_obj_id"]);
133  if ($thread_id > 0)
134  {
135  $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
136  "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"]."_".$thread_id."_".$item["context_sub_obj_id"]);
137  }
138  else
139  {
140  $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
141  "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"]);
142  }
143  }
144  else
145  {
146  $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
147  "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"]);
148  }
149  $feed_item->setAbout($feed_item->getLink()."&amp;il_about_feed=".$item["id"]);
150  $this->addItem($feed_item);
151  }
152  }
153  }
154 }
155 ?>