• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Feeds/classes/class.ilUserFeedWriter.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 include_once("./Services/News/classes/class.ilNewsItem.php");
00025 include_once("./Services/Feeds/classes/class.ilFeedItem.php");
00026 include_once("./Services/Feeds/classes/class.ilFeedWriter.php");
00027 
00038 class ilUserFeedWriter extends ilFeedWriter
00039 {
00040         
00041         function ilUserFeedWriter($a_user_id, $a_hash)
00042         {
00043                 global $ilSetting, $lng;
00044                 
00045                 parent::ilFeedWriter();
00046                 
00047                 //$lng->loadLanguageModule("news");
00048                 
00049                 if ($a_user_id == "" || $a_hash == "")
00050                 {
00051                         return;
00052                 }
00053                 
00054                 $news_set = new ilSetting("news");
00055                 if (!$news_set->get("enable_rss_for_internal"))
00056                 {
00057                         return;
00058                 }
00059 
00060                 $hash = ilObjUser::_lookupFeedHash($a_user_id);
00061                 
00062                 include_once("./Services/News/classes/class.ilNewsItem.php");
00063                 $rss_period = ilNewsItem::_lookupRSSPeriod();
00064 
00065                 if ($a_hash == $hash)
00066                 {
00067                         $items = ilNewsItem::_getNewsItemsOfUser($a_user_id, true, true, $rss_period);
00068                         if ($ilSetting->get('short_inst_name') != "")
00069                         {
00070                                 $this->setChannelTitle($ilSetting->get('short_inst_name'));
00071                         }
00072                         else
00073                         {
00074                                 $this->setChannelTitle("ILIAS");
00075                         }
00076 
00077                         $this->setChannelAbout(ILIAS_HTTP_PATH);
00078                         $this->setChannelLink(ILIAS_HTTP_PATH);
00079                         //$this->setChannelDescription("ILIAS Channel Description");
00080                         $i = 0;
00081                         foreach($items as $item)
00082                         {
00083                                 $obj_id = ilObject::_lookupObjId($item["ref_id"]);
00084                                 $obj_type = ilObject::_lookupType($obj_id);
00085                                 $obj_title = ilObject::_lookupTitle($obj_id);
00086 
00087                                 // not nice, to do: general solution
00088                                 if ($obj_type == "mcst")
00089                                 {
00090                                         include_once("./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php");
00091                                         if (!ilObjMediaCastAccess::_lookupOnline($obj_id))
00092                                         {
00093                                                 continue;
00094                                         }
00095                                 }
00096 
00097                                 $i++;
00098                                 $feed_item = new ilFeedItem();
00099                                 $title = ilNewsItem::determineNewsTitle
00100                                         ($item["context_obj_type"], $item["title"], $item["content_is_lang_var"],
00101                                         $item["agg_ref_id"], $item["aggregation"]);
00102 
00103                                 // path
00104                                 $cont_loc = new ilLocatorGUI();
00105                                 $cont_loc->addContextItems($item["ref_id"], true);
00106                                 $cont_loc->setTextOnly(true);
00107                                 $loc = "[".$cont_loc->getHTML()."]";
00108                                 
00109                                 // title
00110                                 $feed_item->setTitle($this->prepareStr($loc)." ".$this->prepareStr($obj_title).": ".$this->prepareStr(str_replace("<br />", " ", $title)));
00111                                                                 
00112                                 // description
00113                                 $content = $this->prepareStr(nl2br($item["content"]));
00114                                 $feed_item->setDescription($content);
00115                                 $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
00116                                         "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"]);
00117                                 $feed_item->setAbout($feed_item->getLink()."&amp;il_about_feed=".$item["id"]);
00118                                 $this->addItem($feed_item);
00119                         }
00120                 }
00121         }
00122 }
00123 ?>

Generated on Fri Dec 13 2013 17:56:57 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1