ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilUserFeedWriter.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once("./Services/News/classes/class.ilNewsItem.php");
25 include_once("./Services/Feeds/classes/class.ilFeedItem.php");
26 include_once("./Services/Feeds/classes/class.ilFeedWriter.php");
27 
39 {
40 
41  function ilUserFeedWriter($a_user_id, $a_hash, $privFeed = false)
42  {
43  global $ilSetting, $lng;
44 
46 
47  //$lng->loadLanguageModule("news");
48 
49  if ($a_user_id == "" || $a_hash == "")
50  {
51  return;
52  }
53 
54  $news_set = new ilSetting("news");
55  if (!$news_set->get("enable_rss_for_internal"))
56  {
57  return;
58  }
59 
60  $hash = ilObjUser::_lookupFeedHash($a_user_id);
61 
62  include_once("./Services/News/classes/class.ilNewsItem.php");
63  $rss_period = ilNewsItem::_lookupRSSPeriod();
64 
65  if ($a_hash == $hash)
66  {
67  if ($privFeed)
68  {
69  ilNewsItem::setPrivateFeedId($a_user_id);
70  }
71  $items = ilNewsItem::_getNewsItemsOfUser($a_user_id, true, true, $rss_period);
72  if ($ilSetting->get('short_inst_name') != "")
73  {
74  $this->setChannelTitle($ilSetting->get('short_inst_name'));
75  }
76  else
77  {
78  $this->setChannelTitle("ILIAS");
79  }
80 
81  $this->setChannelAbout(ILIAS_HTTP_PATH);
82  $this->setChannelLink(ILIAS_HTTP_PATH);
83  //$this->setChannelDescription("ILIAS Channel Description");
84  $i = 0;
85  foreach($items as $item)
86  {
87  $obj_id = ilObject::_lookupObjId($item["ref_id"]);
88  $obj_type = ilObject::_lookupType($obj_id);
89  $obj_title = ilObject::_lookupTitle($obj_id);
90 
91  // not nice, to do: general solution
92  if ($obj_type == "mcst")
93  {
94  include_once("./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php");
96  {
97  continue;
98  }
99  }
100 
101  $i++;
102  $feed_item = new ilFeedItem();
104  ($item["context_obj_type"], $item["title"], $item["content_is_lang_var"],
105  $item["agg_ref_id"], $item["aggregation"]);
106 
107  // path
108  $cont_loc = new ilLocatorGUI();
109  $cont_loc->addContextItems($item["ref_id"], true);
110  $cont_loc->setTextOnly(true);
111  $loc = "[".$cont_loc->getHTML()."]";
112 
113  // title
114  $feed_item->setTitle($this->prepareStr($loc)." ".$this->prepareStr($obj_title).": ".$this->prepareStr(str_replace("<br />", " ", $title)));
115 
116  // description
117  $content = $this->prepareStr(nl2br($item["content"]));
118  $feed_item->setDescription($content);
119  $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
120  "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"]);
121  $feed_item->setAbout($feed_item->getLink()."&amp;il_about_feed=".$item["id"]);
122  $this->addItem($feed_item);
123  }
124  }
125  }
126 }
127 ?>