ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
privfeed.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 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 
31 // this should bring us all session data of the desired
32 // client
33 if (isset($_GET["client_id"]))
34 {
35  setcookie("ilClientId",$_GET["client_id"]);
36  $_COOKIE["ilClientId"] = $_GET["client_id"];
37 }
38 
39 require_once("Services/Init/classes/class.ilInitialisation.php");
41 $GLOBALS['ilInit'] =& $ilInit;
42 $ilInit->initFeed();
43 $ilInit->initAccessHandling();
44 
45 global $lng, $ilSetting;
46 
47 $feed_set = new ilSetting("news");
48 
49 
50  if (!isset($_SERVER['PHP_AUTH_PW']) || !isset($_SERVER['PHP_AUTH_USER']))
51  {
52  Header("WWW-Authenticate: Basic realm=\"ILIAS Newsfeed\"");
53  Header("HTTP/1.0 401 Unauthorized");
54 
55  exit;
56  }
57  else
58  {
59  if ($_GET["user_id"] != "" && ilObjUser::_getFeedPass($_GET["user_id"]) != "" &&
60  (md5($_SERVER['PHP_AUTH_PW']) == ilObjUser::_getFeedPass($_GET["user_id"]) &&
61  $_SERVER['PHP_AUTH_USER'] == ilObjUser::_lookupLogin($_GET["user_id"]))
62  && $feed_set->get("enable_private_feed"))
63  {
64  include_once("./Services/Feeds/classes/class.ilUserFeedWriter.php");
65  // Third parameter is true for private feed
66  $writer = new ilUserFeedWriter($_GET["user_id"], $_GET["hash"], true);
67  $writer->showFeed();
68  }
69  else if ($_GET["ref_id"] != "" && md5($_SERVER['PHP_AUTH_PW']) == ilObjUser::_getFeedPass(ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER'])))
70  {
71 
72  include_once("./Services/Feeds/classes/class.ilObjectFeedWriter.php");
73  // Second parameter is optional to pass on to database-level to get news for logged-in users
74  $writer = new ilObjectFeedWriter($_GET["ref_id"], ilObjUser::_lookupId($_SERVER['PHP_AUTH_USER']));
75  $writer->showFeed();
76  }
77  else {
78  include_once("./Services/Feeds/classes/class.ilFeedItem.php");
79  include_once("./Services/Feeds/classes/class.ilFeedWriter.php");
80 
81  $blankFeedWriter = new ilFeedWriter();
82  $feed_item = new ilFeedItem();
83  $lng->loadLanguageModule("news");
84 
85  if ($ilSetting->get('short_inst_name') != "")
86  {
87  $blankFeedWriter->setChannelTitle($ilSetting->get('short_inst_name'));
88  }
89  else
90  {
91  $blankFeedWriter->setChannelTitle("ILIAS");
92  }
93 
94 
95 
96 
97  if (!$feed_set->get("enable_private_feed"))
98  {
99  $blankFeedWriter->setChannelAbout(ILIAS_HTTP_PATH);
100  $blankFeedWriter->setChannelLink(ILIAS_HTTP_PATH);
101  // title
102  $feed_item->setTitle($lng->txt("priv_feed_no_access_title"));
103 
104  // description
105  $feed_item->setDescription($lng->txt("priv_feed_no_access_body"));
106  $feed_item->setLink(ILIAS_HTTP_PATH);
107  }
108  else
109  {
110  $blankFeedWriter->setChannelAbout(ILIAS_HTTP_PATH);
111  $blankFeedWriter->setChannelLink(ILIAS_HTTP_PATH);
112  // title
113  $feed_item->setTitle($lng->txt("priv_feed_no_auth_title"));
114 
115  // description
116  $feed_item->setDescription($lng->txt("priv_feed_no_auth_body"));
117  $feed_item->setLink(ILIAS_HTTP_PATH);
118  }
119  $blankFeedWriter->addItem($feed_item);
120  $blankFeedWriter->showFeed();
121  }
122 
123  }
124 ?>