ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 // this should bring us all session data of the desired
12 // client
13 if (isset($_GET["client_id"]))
14 {
15  $cookie_domain = $_SERVER['SERVER_NAME'];
16  $cookie_path = dirname( $_SERVER['PHP_SELF'] );
17 
18  /* if ilias is called directly within the docroot $cookie_path
19  is set to '/' expecting on servers running under windows..
20  here it is set to '\'.
21  in both cases a further '/' won't be appended due to the following regex
22  */
23  $cookie_path .= (!preg_match("/[\/|\\\\]$/", $cookie_path)) ? "/" : "";
24 
25  if($cookie_path == "\\") $cookie_path = '/';
26 
27  $cookie_domain = ''; // Temporary Fix
28 
29  setcookie("ilClientId", $_GET["client_id"], 0, $cookie_path, $cookie_domain);
30 
31  $_COOKIE["ilClientId"] = $_GET["client_id"];
32 }
33 
34 require_once("Services/Init/classes/class.ilInitialisation.php");
36 $GLOBALS['ilInit'] =& $ilInit;
37 $ilInit->initFeed();
38 $ilInit->initAccessHandling();
39 
40 global $lng, $ilSetting;
41 
42 $feed_set = new ilSetting("news");
43 
44 
45  if (!isset($_SERVER['PHP_AUTH_PW']) || !isset($_SERVER['PHP_AUTH_USER']))
46  {
47  Header("WWW-Authenticate: Basic realm=\"ILIAS Newsfeed\"");
48  Header("HTTP/1.0 401 Unauthorized");
49 
50  exit;
51  }
52  else
53  {
54  if ($_GET["user_id"] != "" && ilObjUser::_getFeedPass($_GET["user_id"]) != "" &&
55  (md5($_SERVER['PHP_AUTH_PW']) == ilObjUser::_getFeedPass($_GET["user_id"]) &&
56  $_SERVER['PHP_AUTH_USER'] == ilObjUser::_lookupLogin($_GET["user_id"]))
57  && $feed_set->get("enable_private_feed"))
58  {
59  include_once("./Services/Feeds/classes/class.ilUserFeedWriter.php");
60  // Third parameter is true for private feed
61  $writer = new ilUserFeedWriter($_GET["user_id"], $_GET["hash"], true);
62  $writer->showFeed();
63  }
64  else if ($_GET["ref_id"] != "" && md5($_SERVER['PHP_AUTH_PW']) == ilObjUser::_getFeedPass(ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER'])))
65  {
66 
67  include_once("./Services/Feeds/classes/class.ilObjectFeedWriter.php");
68  // Second parameter is optional to pass on to database-level to get news for logged-in users
69  $writer = new ilObjectFeedWriter($_GET["ref_id"], ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER']));
70  $writer->showFeed();
71  }
72  else {
73  include_once("./Services/Feeds/classes/class.ilFeedItem.php");
74  include_once("./Services/Feeds/classes/class.ilFeedWriter.php");
75 
76  $blankFeedWriter = new ilFeedWriter();
77  $feed_item = new ilFeedItem();
78  $lng->loadLanguageModule("news");
79 
80  if ($ilSetting->get('short_inst_name') != "")
81  {
82  $blankFeedWriter->setChannelTitle($ilSetting->get('short_inst_name'));
83  }
84  else
85  {
86  $blankFeedWriter->setChannelTitle("ILIAS");
87  }
88 
89 
90 
91 
92  if (!$feed_set->get("enable_private_feed"))
93  {
94  $blankFeedWriter->setChannelAbout(ILIAS_HTTP_PATH);
95  $blankFeedWriter->setChannelLink(ILIAS_HTTP_PATH);
96  // title
97  $feed_item->setTitle($lng->txt("priv_feed_no_access_title"));
98 
99  // description
100  $feed_item->setDescription($lng->txt("priv_feed_no_access_body"));
101  $feed_item->setLink(ILIAS_HTTP_PATH);
102  }
103  else
104  {
105  $blankFeedWriter->setChannelAbout(ILIAS_HTTP_PATH);
106  $blankFeedWriter->setChannelLink(ILIAS_HTTP_PATH);
107  // title
108  $feed_item->setTitle($lng->txt("priv_feed_no_auth_title"));
109 
110  // description
111  $feed_item->setDescription($lng->txt("priv_feed_no_auth_body"));
112  $feed_item->setLink(ILIAS_HTTP_PATH);
113  }
114  $blankFeedWriter->addItem($feed_item);
115  $blankFeedWriter->showFeed();
116  }
117 
118  }
119 ?>