Commit db72fe80f0a1949a49761a3dffbd6018f46414f4

Authored by Megan Watson
1 parent 9fd6ea86

KTC-263

"Internal RSS feed does not work on FF but partially works on IE"
Fixed. Added a check on whether an external feed is pointing to an internal document.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7846 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/rssplugin/KTrss.inc.php
... ... @@ -84,6 +84,27 @@ class KTrss{
84 84 return $response;
85 85 }
86 86  
  87 + // Get the data for the document or folder
  88 + function getExternalInternalFeed($sFeed, $iUserId){
  89 + $aRss = array();
  90 + $pos = strpos($sFeed, 'docId');
  91 +
  92 + if($pos === false){
  93 + $pos = strpos($sFeed, 'folderId');
  94 + $folderId = substr($sFeed, $pos+9);
  95 + $aRss[] = KTrss::getOneFolder($folderId, $iUserId);
  96 + }else{
  97 + $docId = substr($sFeed, $pos+6);
  98 + $aRss[] = KTrss::getOneDocument($docId, $iUserId);
  99 + }
  100 +
  101 + if($aRss){
  102 + $internalFeed = KTrss::arrayToXML($aRss);
  103 + $response = rss2arrayBlock($internalFeed);
  104 + }
  105 + return $response;
  106 + }
  107 +
87 108 // Get list of document subscriptions
88 109 function getDocumentList($iUserId){
89 110 $sQuery = "SELECT document_id as id FROM document_subscriptions WHERE user_id = ?";
... ...
plugins/rssplugin/loadFeed.inc.php
... ... @@ -5,49 +5,69 @@
5 5 * KnowledgeTree Open Source Edition
6 6 * Document Management Made Simple
7 7 * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
8   - *
  8 + *
9 9 * This program is free software; you can redistribute it and/or modify it under
10 10 * the terms of the GNU General Public License version 3 as published by the
11 11 * Free Software Foundation.
12   - *
  12 + *
13 13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 16 * details.
17   - *
  17 + *
18 18 * You should have received a copy of the GNU General Public License
19 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20   - *
  20 + *
21 21 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
22 22 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
23   - *
  23 + *
24 24 * The interactive user interfaces in modified source and object code versions
25 25 * of this program must display Appropriate Legal Notices, as required under
26 26 * Section 5 of the GNU General Public License version 3.
27   - *
  27 + *
28 28 * In accordance with Section 7(b) of the GNU General Public License version 3,
29 29 * these Appropriate Legal Notices must retain the display of the "Powered by
30   - * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  30 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
31 31 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
32   - * must display the words "Powered by KnowledgeTree" and retain the original
33   - * copyright notice.
  32 + * must display the words "Powered by KnowledgeTree" and retain the original
  33 + * copyright notice.
34 34 * Contributor( s): ______________________________________
35 35 *
36 36 */
37 37 require_once('../../config/dmsDefaults.php');
38 38 require_once(KT_DIR. '/plugins/rssplugin/rss2array.inc.php');
39 39 require_once(KT_DIR. '/plugins/rssplugin/KTrss.inc.php');
40   -
  40 +
41 41 $feed = $_GET["feed"];
42 42 $user = $_GET["user"];
43   -
  43 +
  44 + // URL must start with http:// - change it if it starts with feed://
  45 + if(preg_match("/^feed:\/\/([^\/]+)(.*)$/", $feed, $matches)){
  46 + $feed = preg_replace("/^feed:\/\//", "http://", $feed);
  47 + }
  48 +
44 49 // Check if the feed matches a url
45 50 if(!preg_match("/^http:\/\/([^\/]+)(.*)$/", $feed, $matches)){
46 51 // If not, it is an internal feed
47 52 $aRSSArray = KTrss::getInternalFeed($user);
48 53 }else{
49 54 // If it is a url, it is an external feed
50   - $aRSSArray = rss2array($feed);
  55 + // However, sometimes internal documents get added as external feeds
  56 + // Check that the url isn't an internal one.
  57 + global $default;
  58 + $rootUrl = $default->rootUrl;
  59 + $bSSL = $default->sslEnabled;
  60 +
  61 + $sProtocol = ($bSSL) ? 'https' : 'http';
  62 + $sBaseUrl = $sProtocol.'://'.$_SERVER['HTTP_HOST'].$rootUrl;
  63 +
  64 + $sInternal = $sBaseUrl.'/rss.php';
  65 + if(!(strpos($feed, $sInternal) === FALSE)){
  66 + // Feed is internal
  67 + $aRSSArray = KTrss::getExternalInternalFeed($feed, $user);
  68 + }else{
  69 + $aRSSArray = rss2array($feed);
  70 + }
51 71 }
52 72 if(count($aRSSArray[errors]) > 0){
53 73 for($i=0;$i<count($aRSSArray[errors]);$i++){
... ... @@ -70,6 +90,6 @@
70 90 <tr><td colspan='2'><br></td></tr>";
71 91 }
72 92 $response .= "</table></div><br>";
73   -
  93 +
74 94 echo $response;
75 95 -?>
  96 +?>
76 97 \ No newline at end of file
... ...