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,6 +84,27 @@ class KTrss{
84 return $response; 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 // Get list of document subscriptions 108 // Get list of document subscriptions
88 function getDocumentList($iUserId){ 109 function getDocumentList($iUserId){
89 $sQuery = "SELECT document_id as id FROM document_subscriptions WHERE user_id = ?"; 110 $sQuery = "SELECT document_id as id FROM document_subscriptions WHERE user_id = ?";
plugins/rssplugin/loadFeed.inc.php
@@ -5,49 +5,69 @@ @@ -5,49 +5,69 @@
5 * KnowledgeTree Open Source Edition 5 * KnowledgeTree Open Source Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited 7 * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
8 - * 8 + *
9 * This program is free software; you can redistribute it and/or modify it under 9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License version 3 as published by the 10 * the terms of the GNU General Public License version 3 as published by the
11 * Free Software Foundation. 11 * Free Software Foundation.
12 - * 12 + *
13 * This program is distributed in the hope that it will be useful, but WITHOUT 13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * details. 16 * details.
17 - * 17 + *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 - * 20 + *
21 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, 21 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
22 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. 22 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
23 - * 23 + *
24 * The interactive user interfaces in modified source and object code versions 24 * The interactive user interfaces in modified source and object code versions
25 * of this program must display Appropriate Legal Notices, as required under 25 * of this program must display Appropriate Legal Notices, as required under
26 * Section 5 of the GNU General Public License version 3. 26 * Section 5 of the GNU General Public License version 3.
27 - * 27 + *
28 * In accordance with Section 7(b) of the GNU General Public License version 3, 28 * In accordance with Section 7(b) of the GNU General Public License version 3,
29 * these Appropriate Legal Notices must retain the display of the "Powered by 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 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices 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 * Contributor( s): ______________________________________ 34 * Contributor( s): ______________________________________
35 * 35 *
36 */ 36 */
37 require_once('../../config/dmsDefaults.php'); 37 require_once('../../config/dmsDefaults.php');
38 require_once(KT_DIR. '/plugins/rssplugin/rss2array.inc.php'); 38 require_once(KT_DIR. '/plugins/rssplugin/rss2array.inc.php');
39 require_once(KT_DIR. '/plugins/rssplugin/KTrss.inc.php'); 39 require_once(KT_DIR. '/plugins/rssplugin/KTrss.inc.php');
40 - 40 +
41 $feed = $_GET["feed"]; 41 $feed = $_GET["feed"];
42 $user = $_GET["user"]; 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 // Check if the feed matches a url 49 // Check if the feed matches a url
45 if(!preg_match("/^http:\/\/([^\/]+)(.*)$/", $feed, $matches)){ 50 if(!preg_match("/^http:\/\/([^\/]+)(.*)$/", $feed, $matches)){
46 // If not, it is an internal feed 51 // If not, it is an internal feed
47 $aRSSArray = KTrss::getInternalFeed($user); 52 $aRSSArray = KTrss::getInternalFeed($user);
48 }else{ 53 }else{
49 // If it is a url, it is an external feed 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 if(count($aRSSArray[errors]) > 0){ 72 if(count($aRSSArray[errors]) > 0){
53 for($i=0;$i<count($aRSSArray[errors]);$i++){ 73 for($i=0;$i<count($aRSSArray[errors]);$i++){
@@ -70,6 +90,6 @@ @@ -70,6 +90,6 @@
70 <tr><td colspan='2'><br></td></tr>"; 90 <tr><td colspan='2'><br></td></tr>";
71 } 91 }
72 $response .= "</table></div><br>"; 92 $response .= "</table></div><br>";
73 - 93 +
74 echo $response; 94 echo $response;
75 -?> 95 -?>
  96 +?>
76 \ No newline at end of file 97 \ No newline at end of file