ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
privfeed.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 include_once "Services/Context/classes/class.ilContext.php";
13 
14 require_once("Services/Init/classes/class.ilInitialisation.php");
16 
17 global $lng, $ilSetting;
18 
19 $feed_set = new ilSetting("news");
20 
21 
22  if (!isset($_SERVER['PHP_AUTH_PW']) || !isset($_SERVER['PHP_AUTH_USER']))
23  {
24  Header("WWW-Authenticate: Basic realm=\"ILIAS Newsfeed\"");
25  Header("HTTP/1.0 401 Unauthorized");
26 
27  exit;
28  }
29  else
30  {
31  if ($_GET["user_id"] != "" && ilObjUser::_getFeedPass($_GET["user_id"]) != "" &&
32  (md5($_SERVER['PHP_AUTH_PW']) == ilObjUser::_getFeedPass($_GET["user_id"]) &&
33  $_SERVER['PHP_AUTH_USER'] == ilObjUser::_lookupLogin($_GET["user_id"]))
34  && $feed_set->get("enable_private_feed"))
35  {
36  include_once("./Services/Feeds/classes/class.ilUserFeedWriter.php");
37  // Third parameter is true for private feed
38  $writer = new ilUserFeedWriter($_GET["user_id"], $_GET["hash"], true);
39  $writer->showFeed();
40  }
41  else if ($_GET["ref_id"] != "" && md5($_SERVER['PHP_AUTH_PW']) == ilObjUser::_getFeedPass(ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER'])))
42  {
43 
44  include_once("./Services/Feeds/classes/class.ilObjectFeedWriter.php");
45  // Second parameter is optional to pass on to database-level to get news for logged-in users
46  $writer = new ilObjectFeedWriter($_GET["ref_id"], ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER']));
47  $writer->showFeed();
48  }
49  else {
50 
51  // send appropriate header, if password is wrong, otherwise
52  // there is no chance to re-enter it (unless, e.g. the browser is closed)
53  if (md5($_SERVER['PHP_AUTH_PW']) != ilObjUser::_getFeedPass(ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER'])))
54  {
55  Header("WWW-Authenticate: Basic realm=\"ILIAS Newsfeed\"");
56  Header("HTTP/1.0 401 Unauthorized");
57  exit;
58  }
59 
60  include_once("./Services/Feeds/classes/class.ilFeedItem.php");
61  include_once("./Services/Feeds/classes/class.ilFeedWriter.php");
62 
63  $blankFeedWriter = new ilFeedWriter();
64  $feed_item = new ilFeedItem();
65  $lng->loadLanguageModule("news");
66 
67  if ($ilSetting->get('short_inst_name') != "")
68  {
69  $blankFeedWriter->setChannelTitle($ilSetting->get('short_inst_name'));
70  }
71  else
72  {
73  $blankFeedWriter->setChannelTitle("ILIAS");
74  }
75 
76 
77 
78 
79  if (!$feed_set->get("enable_private_feed"))
80  {
81  $blankFeedWriter->setChannelAbout(ILIAS_HTTP_PATH);
82  $blankFeedWriter->setChannelLink(ILIAS_HTTP_PATH);
83  // title
84  $feed_item->setTitle($lng->txt("priv_feed_no_access_title"));
85 
86  // description
87  $feed_item->setDescription($lng->txt("priv_feed_no_access_body"));
88  $feed_item->setLink(ILIAS_HTTP_PATH);
89  }
90  else
91  {
92  $blankFeedWriter->setChannelAbout(ILIAS_HTTP_PATH);
93  $blankFeedWriter->setChannelLink(ILIAS_HTTP_PATH);
94  // title
95  $feed_item->setTitle($lng->txt("priv_feed_no_auth_title"));
96 
97  // description
98  $feed_item->setDescription($lng->txt("priv_feed_no_auth_body"));
99  $feed_item->setLink(ILIAS_HTTP_PATH);
100  }
101  $blankFeedWriter->addItem($feed_item);
102  $blankFeedWriter->showFeed();
103  }
104 
105  }
106 ?>
Feed writer class.
static _lookupLogin($a_user_id)
lookup login
ILIAS Setting Class.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$_GET["client_id"]
static _getFeedPass($a_user_id)
Lookup news feed password for user.
static _lookupId($a_user_str)
Lookup id by login.
const CONTEXT_RSS_AUTH
A FeedItem represents an item in a News Feed.
static initILIAS()
ilias initialisation
$feed_set
Definition: privfeed.php:19
Feed writer for objects.
static init($a_type)
Init context by type.
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
Feed writer for personal user feeds.