ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
5include_once("./Services/News/classes/class.ilNewsItem.php");
6include_once("./Services/Feeds/classes/class.ilFeedItem.php");
7include_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
26 parent::ilFeedWriter();
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 include_once "Services/User/classes/class.ilObjUser.php";
42 $hash = ilObjUser::_lookupFeedHash($a_user_id);
43
44 include_once("./Services/News/classes/class.ilNewsItem.php");
45 $rss_period = ilNewsItem::_lookupRSSPeriod();
46
47 if ($a_hash == $hash)
48 {
49 if ($privFeed)
50 {
51 //ilNewsItem::setPrivateFeedId($a_user_id);
52 $items = ilNewsItem::_getNewsItemsOfUser($a_user_id, false, true, $rss_period);
53 }
54 else
55 {
56 $items = ilNewsItem::_getNewsItemsOfUser($a_user_id, true, true, $rss_period);
57 }
58
59 if ($ilSetting->get('short_inst_name') != "")
60 {
61 $this->setChannelTitle($ilSetting->get('short_inst_name'));
62 }
63 else
64 {
65 $this->setChannelTitle("ILIAS");
66 }
67
68 $this->setChannelAbout(ILIAS_HTTP_PATH);
69 $this->setChannelLink(ILIAS_HTTP_PATH);
70 //$this->setChannelDescription("ILIAS Channel Description");
71 $i = 0;
72 foreach($items as $item)
73 {
74 $obj_id = ilObject::_lookupObjId($item["ref_id"]);
75 $obj_type = ilObject::_lookupType($obj_id);
76 $obj_title = ilObject::_lookupTitle($obj_id);
77
78 // not nice, to do: general solution
79 if ($obj_type == "mcst")
80 {
81 include_once("./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php");
83 {
84 continue;
85 }
86 }
87
88 $i++;
89 $feed_item = new ilFeedItem();
91 ($item["context_obj_type"], $item["title"], $item["content_is_lang_var"],
92 $item["agg_ref_id"], $item["aggregation"]);
93
94 // path
95 $loc = $this->getContextPath($item["ref_id"]);
96
97 // title
98 if ($news_set->get("rss_title_format") == "news_obj")
99 {
100 $feed_item->setTitle($this->prepareStr(str_replace("<br />", " ", $title)).
101 " (".$this->prepareStr($loc)." ".$this->prepareStr($obj_title).
102 ")");
103 }
104 else
105 {
106 $feed_item->setTitle($this->prepareStr($loc)." ".$this->prepareStr($obj_title).
107 ": ".$this->prepareStr(str_replace("<br />", " ", $title)));
108 }
109
110 // description
111 $content = $this->prepareStr(nl2br(
112 ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"])));
113 $feed_item->setDescription($content);
114
115 // lm page hack, not nice
116 if (in_array($item["context_obj_type"], array("dbk", "lm")) && $item["context_sub_obj_type"] == "pg"
117 && $item["context_sub_obj_id"] > 0)
118 {
119 $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
120 "&amp;target=pg_".$item["context_sub_obj_id"]."_".$item["ref_id"]);
121 }
122 else if ($item["context_obj_type"] == "wiki" && $item["context_sub_obj_type"] == "wpg"
123 && $item["context_sub_obj_id"] > 0)
124 {
125 include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
126 $wptitle = ilWikiPage::lookupTitle($item["context_sub_obj_id"]);
127 $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
128 "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"]."_".urlencode($wptitle)); // #14629
129 }
130 else if (in_array($item["context_obj_type"], array("frm")) && $item["context_sub_obj_type"] == "pos"
131 && $item["context_sub_obj_id"] > 0)
132 {
133 // frm hack, not nice
134 include_once("./Modules/Forum/classes/class.ilObjForumAccess.php");
135 $thread_id = ilObjForumAccess::_getThreadForPosting($item["context_sub_obj_id"]);
136 if ($thread_id > 0)
137 {
138 $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
139 "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"]."_".$thread_id."_".$item["context_sub_obj_id"]);
140 }
141 else
142 {
143 $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
144 "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"]);
145 }
146 }
147 else
148 {
149 $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
150 "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"]);
151 }
152 $feed_item->setAbout($feed_item->getLink()."&amp;il_about_feed=".$item["id"]);
153 $feed_item->setDate($item["creation_date"]);
154 $this->addItem($feed_item);
155 }
156 }
157 }
158}
159?>
A FeedItem represents an item in a News Feed.
Feed writer class.
addItem($a_item)
Add Item Item is an object of type ilFeedItem.
setChannelLink($a_link)
Channel Link URL to which an HTML rendering of the channel title will link.
setChannelAbout($a_ab)
Unique URI that defines the channel.
getContextPath($a_ref_id)
setChannelTitle($a_title)
Channel Title.
static _getNewsItemsOfUser($a_user_id, $a_only_public=false, $a_prevent_aggregation=false, $a_per=0, &$a_cnt=NULL)
Get all news items for a user.
static determineNewsContent($a_context_obj_type, $a_content, $a_is_lang_var)
Determine new content.
static determineNewsTitle($a_context_obj_type, $a_title, $a_content_is_lang_var, $a_agg_ref_id=0, $a_aggregation="")
Determine title for news item entry.
_lookupOnline($a_id)
Check wether media cast is online.
_lookupFeedHash($a_user_id, $a_create=false)
Lookup news feed hash for user.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
ILIAS Setting Class.
Feed writer for personal user feeds.
ilUserFeedWriter($a_user_id, $a_hash, $privFeed=false)
static lookupTitle($a_page_id)
Checks whether a page with given title exists.
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40