ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  Header("WWW-Authenticate: Basic realm=\"ILIAS Newsfeed\"");
24  Header("HTTP/1.0 401 Unauthorized");
25 
26  exit;
27  } else {
28  if ($_GET["user_id"] != "" && ilObjUser::_getFeedPass($_GET["user_id"]) != "" &&
29  (md5($_SERVER['PHP_AUTH_PW']) == ilObjUser::_getFeedPass($_GET["user_id"]) &&
30  $_SERVER['PHP_AUTH_USER'] == ilObjUser::_lookupLogin($_GET["user_id"]))
31  && $feed_set->get("enable_private_feed")) {
32  include_once("./Services/Feeds/classes/class.ilUserFeedWriter.php");
33  // Third parameter is true for private feed
34  $writer = new ilUserFeedWriter($_GET["user_id"], $_GET["hash"], true);
35  $writer->showFeed();
36  } elseif ($_GET["ref_id"] != "" && md5($_SERVER['PHP_AUTH_PW']) == ilObjUser::_getFeedPass(ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER']))) {
37  include_once("./Services/Feeds/classes/class.ilObjectFeedWriter.php");
38  // Second parameter is optional to pass on to database-level to get news for logged-in users
39  $writer = new ilObjectFeedWriter($_GET["ref_id"], ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER']));
40  $writer->showFeed();
41  } else {
42 
43  // send appropriate header, if password is wrong, otherwise
44  // there is no chance to re-enter it (unless, e.g. the browser is closed)
45  if (md5($_SERVER['PHP_AUTH_PW']) != ilObjUser::_getFeedPass(ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER']))) {
46  Header("WWW-Authenticate: Basic realm=\"ILIAS Newsfeed\"");
47  Header("HTTP/1.0 401 Unauthorized");
48  exit;
49  }
50 
51  include_once("./Services/Feeds/classes/class.ilFeedItem.php");
52  include_once("./Services/Feeds/classes/class.ilFeedWriter.php");
53 
54  $blankFeedWriter = new ilFeedWriter();
55  $feed_item = new ilFeedItem();
56  $lng->loadLanguageModule("news");
57 
58  if ($ilSetting->get('short_inst_name') != "") {
59  $blankFeedWriter->setChannelTitle($ilSetting->get('short_inst_name'));
60  } else {
61  $blankFeedWriter->setChannelTitle("ILIAS");
62  }
63 
64 
65 
66 
67  if (!$feed_set->get("enable_private_feed")) {
68  $blankFeedWriter->setChannelAbout(ILIAS_HTTP_PATH);
69  $blankFeedWriter->setChannelLink(ILIAS_HTTP_PATH);
70  // title
71  $feed_item->setTitle($lng->txt("priv_feed_no_access_title"));
72 
73  // description
74  $feed_item->setDescription($lng->txt("priv_feed_no_access_body"));
75  $feed_item->setLink(ILIAS_HTTP_PATH);
76  } else {
77  $blankFeedWriter->setChannelAbout(ILIAS_HTTP_PATH);
78  $blankFeedWriter->setChannelLink(ILIAS_HTTP_PATH);
79  // title
80  $feed_item->setTitle($lng->txt("priv_feed_no_auth_title"));
81 
82  // description
83  $feed_item->setDescription($lng->txt("priv_feed_no_auth_body"));
84  $feed_item->setLink(ILIAS_HTTP_PATH);
85  }
86  $blankFeedWriter->addItem($feed_item);
87  $blankFeedWriter->showFeed();
88  }
89  }
Feed writer class.
static _lookupLogin($a_user_id)
lookup login
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.