Commit fdc3e957f65cc682cf914fc6647b1f0b5e4bdbb2

Authored by megan_w
1 parent 5cee6ef0

KTC-177

"RSS feed appears wrong when launched from the 'Actions on this folder' when the folder has the internationalisation string as its name or the name of any of its subfolders."
Fixed. Added headers before displaying the feed. Cleaned up the htmlentities in the feed.

Committed By: Megan Watson
Reviewed By: Jonathan Byrne

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@8059 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/rssplugin/KTrss.inc.php
@@ -336,111 +336,145 @@ class KTrss{ @@ -336,111 +336,145 @@ class KTrss{
336 $sSuffix = ''; 336 $sSuffix = '';
337 } 337 }
338 $hostPath = "http" . ($default->sslEnabled ? "s" : "") . "://".$_SERVER['HTTP_HOST']."/".$sSuffix; 338 $hostPath = "http" . ($default->sslEnabled ? "s" : "") . "://".$_SERVER['HTTP_HOST']."/".$sSuffix;
339 - $feed = "<?xml version=\"1.0\"?>\n";  
340 - $feed .= "<rss version=\"2.0\">\n".  
341 - "<channel>\n" .  
342 - "<title>".APP_NAME." RSS</title>\n" .  
343 - "<copyright>(c) 2007 The Jam Warehouse Software (Pty) Ltd. All Rights Reserved</copyright>\n" .  
344 - "<link>".$hostPath."</link>\n" .  
345 - "<description>KT-RSS</description>\n" .  
346 - "<image>\n".  
347 - "<title>".APP_NAME." RSS</title>\n".  
348 - "<width>140</width>\n".  
349 - "<height>28</height>".  
350 - "<link>".$hostPath."knowledgeTree/</link>\n".  
351 - "<url>".$hostPath."resources/graphics/ktlogo_rss.png</url>\n".  
352 - "</image>\n";  
353 - foreach($aItems as $aItems){  
354 - if($aItems[0][itemType] == 'folder'){  
355 - $sTypeSelect = 'folder.transactions&amp;fFolderId';  
356 - }elseif($aItems[0][itemType] == 'document'){  
357 - $sTypeSelect = 'document.transactionhistory&amp;fDocumentId'; 339 +
  340 + $head = "<?xml version=\"1.0\"?>\n
  341 + <rss version=\"2.0\">\n
  342 + <channel>\n
  343 + <title>".APP_NAME." RSS</title>\n
  344 + <copyright>(c) 2007 The Jam Warehouse Software (Pty) Ltd. All Rights Reserved</copyright>\n
  345 + <link>".$hostPath."</link>\n
  346 + <description>KT-RSS</description>\n
  347 + <image>\n
  348 + <title>".APP_NAME." RSS</title>\n
  349 + <width>140</width>\n
  350 + <height>28</height>
  351 + <link>".$hostPath."knowledgeTree/</link>\n
  352 + <url>".$hostPath."resources/graphics/ktlogo_rss.png</url>\n
  353 + </image>\n";
  354 +
  355 +
  356 + $feed = '';
  357 + foreach($aItems as $aItem){
  358 +
  359 + $aItemHead = $aItem[0][0];
  360 + $aItemList = $aItem[1];
  361 +
  362 + if($aItem[0][itemType] == 'folder'){
  363 + $sTypeSelect = 'folder.transactions&fFolderId';
  364 + }elseif($aItem[0][itemType] == 'document'){
  365 + $sTypeSelect = 'document.transactionhistory&fDocumentId';
358 } 366 }
359 - $feed .= "<item>\n" .  
360 - "<title>".htmlentities(KTrss::rss_sanitize($aItems[0][0][name],false), ENT_QUOTES, 'UTF-8')."</title>\n" .  
361 - "<link>".$hostPath."action.php?kt_path_info=ktcore.actions.".$sTypeSelect."=".$aItems[0][0]['id']."</link>\n" .  
362 - "<description>\n" .  
363 - "&lt;table border='0' width='90%'&gt;\n".  
364 - "&lt;tr&gt;\n".  
365 - "&lt;td width='5%' height='16px'&gt;" .  
366 - "&lt;a href='".$hostPath."action.php?kt_path_info=ktcore.actions.".$sTypeSelect."=".$aItems[0][0][id]."' &gt;&lt;img src='".$aItems[0][mimeTypeIcon]."' align='left' height='16px' width='16px' alt='' border='0' /&gt;&lt;/a&gt;" .  
367 - "&lt;/td&gt;\n".  
368 - "&lt;td align='left'&gt; ".$aItems[0][mimeTypeFName]."&lt;/td&gt;\n".  
369 - "&lt;/tr&gt;\n".  
370 - "&lt;tr&gt;\n".  
371 - "&lt;td colspan='2'&gt;\n".  
372 - ucfirst($aItems[0]['itemType'])." Information (ID: ".$aItems[0][0][id].")&lt;/&gt;\n".  
373 - "&lt;hr&gt;\n".  
374 - "&lt;table width='95%'&gt;\n".  
375 - "&lt;tr&gt;\n".  
376 - "&lt;td&gt;Filename: ".KTrss::rss_sanitize($aItems[0][0][filename])."&lt;/td&gt;\n".  
377 - "&lt;td&gt;\n".  
378 - "&lt;/tr&gt;\n".  
379 - "&lt;tr&gt;\n".  
380 - "&lt;td&gt;Author: ".$aItems[0][0][author]."&lt;/td&gt;\n".  
381 - "&lt;td&gt;\n".  
382 - "&lt;/tr&gt;\n".  
383 - "&lt;tr&gt;\n".  
384 - "&lt;td&gt;Owner: ";if($aItems[0][0][owner]){$feed .= $aItems[0][0][owner];}else{$feed .= "None";}  
385 - $feed .= "&lt;/td&gt;\n".  
386 - "&lt;td&gt;&lt;/td&gt;\n".  
387 - "&lt;/tr&gt;\n".  
388 - "&lt;tr&gt;\n";if($aItems[0][0][type]){  
389 - $feed .= "&lt;td&gt;Document type: ".$aItems[0][0][type]."&lt;/td&gt;\n".  
390 - "&lt;td&gt;&lt;/td&gt;\n";}  
391 - $feed .= "&lt;/tr&gt;\n".  
392 - "&lt;tr&gt;\n".  
393 - "&lt;td&gt;Workflow status: ";if($aItems[0][0][workflow_status]){$feed .= $aItems[0][0][workflow_status];}else{$feed .= "No Workflow";}  
394 - $feed .= "&lt;/td&gt;\n".  
395 - "&lt;td&gt;&lt;/td&gt;\n".  
396 - "&lt;/tr&gt;\n".  
397 - "&lt;/table&gt;&lt;br&gt;\n".  
398 - "Transaction Summary (Last 4)\n".  
399 - "&lt;hr&gt;\n".  
400 - "&lt;table width='100%'&gt;\n";  
401 - foreach($aItems[1] as $item){  
402 - $feed .= "&lt;tr&gt;\n".  
403 - "&lt;td&gt;".$item[type]." name:&lt;/td&gt;\n".  
404 - "&lt;td&gt;".KTrss::rss_sanitize($item[name] )."&lt;/td&gt;\n".  
405 - "&lt;/tr&gt;\n".  
406 - "&lt;tr&gt;\n".  
407 - "&lt;td&gt;Path:&lt;/td&gt;\n".  
408 - "&lt;td&gt;".KTrss::rss_sanitize($item[fullpath] )."&lt;/td&gt;\n".  
409 - "&lt;/tr&gt;\n".  
410 - "&lt;tr&gt;\n".  
411 - "&lt;td&gt;Transaction:&lt;/td&gt;\n".  
412 - "&lt;td&gt;".$item[transaction_name]."&lt;/td&gt;\n".  
413 - "&lt;/tr&gt;\n".  
414 - "&lt;tr&gt;\n".  
415 - "&lt;td&gt;Comment:&lt;/td&gt;\n".  
416 - "&lt;td&gt;".KTrss::rss_sanitize($item[comment] )."&lt;/td&gt;\n".  
417 - "&lt;/tr&gt;\n".  
418 - "&lt;tr&gt;\n";if($item[version]){  
419 - $feed .= "&lt;td&gt;Version:&lt;/td&gt;\n".  
420 - "&lt;td&gt;".$item[version]."&lt;/td&gt;\n";}  
421 - $feed .= "&lt;/tr&gt;\n".  
422 - "&lt;tr&gt;\n".  
423 - "&lt;td&gt;Date:&lt;/td&gt;\n".  
424 - "&lt;td&gt;".$item[datetime]."&lt;/td&gt;\n".  
425 - "&lt;/tr&gt;\n".  
426 - "&lt;tr&gt;\n".  
427 - "&lt;td&gt;User:&lt;/td&gt;\n".  
428 - "&lt;td&gt;".$item[user_name]."&lt;/td&gt;\n".  
429 - "&lt;/tr&gt;\n".  
430 - "&lt;tr&gt;\n".  
431 - "&lt;td colspan='2'&gt;&lt;hr width='100' align='left'&gt;&lt;/td&gt;\n".  
432 - "&lt;/tr&gt;\n";}  
433 - $feed .= "&lt;/table&gt;\n".  
434 - "&lt;/td&gt;\n".  
435 - "&lt;/tr&gt;\n".  
436 - "&lt;/table&gt;".  
437 - "</description>\n".  
438 - "</item>\n"; 367 +
  368 +
  369 + if($aItem[0][0][owner]){
  370 + $owner = $aItem[0][0][owner];
  371 + }else{
  372 + $owner = _kt('None');
  373 + }
  374 +
  375 + $type = '';
  376 + if($aItem[0][0][type]){
  377 + $type = '<tr><td>Document type: '.$aItem[0][0][type]."</td>\n<td></td></tr>\n";
  378 + }
  379 +
  380 + if($aItem[0][0][workflow_status]){
  381 + $workflow = $aItem[0][0][workflow_status];
  382 + }else{
  383 + $workflow = _kt('No Workflow');
  384 + }
  385 +
  386 + $xmlItemHead = "<item>\n
  387 + <title>".htmlentities($aItem[0][0][name], ENT_QUOTES, 'UTF-8')."</title>\n
  388 + <link>".$hostPath."action.php?kt_path_info=ktcore.actions.".htmlentities($sTypeSelect, ENT_QUOTES, 'UTF-8')."=".$aItem[0][0]['id']."</link>\n
  389 + <description>\n";
  390 +
  391 + $htmlItem = "<table border='0' width='90%'>\n
  392 + <tr>\n
  393 + <td width='5%' height='16px'>
  394 + <a href='".$hostPath."action.php?kt_path_info=ktcore.actions.".$sTypeSelect."=".$aItem[0][0][id]."' >
  395 + <img src='".$aItem[0][mimeTypeIcon]."' align='left' height='16px' width='16px' alt='' border='0' /></a>
  396 + </td>\n
  397 + <td align='left'> ".$aItem[0][mimeTypeFName]."</td>\n
  398 + </tr>\n
  399 + <tr>\n
  400 + <td colspan='2'>\n
  401 + ".ucfirst($aItem[0]['itemType'])." Information (ID: ".$aItem[0][0][id].")</>\n
  402 + <hr>\n
  403 +
  404 + <table width='95%'>\n
  405 + <tr>\n
  406 + <td>"._kt('Filename').": ".$aItem[0][0][filename]."</td>\n
  407 + </tr>\n
  408 + <tr>\n
  409 + <td>"._kt('Author').": ".$aItem[0][0][author]."</td>\n
  410 + </tr>\n
  411 + <tr>\n
  412 + <td>"._kt('Owner').": ".$owner."</td>\n
  413 + <td></td>\n
  414 + </tr>\n
  415 + ".$type."\n
  416 + <tr>\n
  417 + <td>"._kt('Workflow status').": ".$workflow."</td>\n
  418 + <td></td>\n
  419 + </tr>\n
  420 + </table><br>\n
  421 +
  422 + "._kt('Transaction Summary (Last 4)')."\n
  423 + <hr>\n
  424 +
  425 + <table width='100%'>\n";
  426 +
  427 + foreach($aItem[1] as $item){
  428 + $htmlItem .= "<tr>\n
  429 + <td>".$item[type]." name:</td>\n
  430 + <td>".$item[name]."</td>\n
  431 + </tr>\n
  432 + <tr>\n
  433 + <td>Path:</td>\n
  434 + <td>".$item[fullpath]."</td>\n
  435 + </tr>\n
  436 + <tr>\n
  437 + <td>Transaction:</td>\n
  438 + <td>".$item[transaction_name]."</td>\n
  439 + </tr>\n
  440 + <tr>\n
  441 + <td>Comment:</td>\n
  442 + <td>".$item[comment]."</td>\n
  443 + </tr>\n
  444 + <tr>\n";
  445 +
  446 + if($item[version]){
  447 + $htmlItem .= "<td>Version:</td>\n
  448 + <td>".$item[version]."</td>\n";
  449 + }
  450 + $htmlItem .= "</tr>\n
  451 + <tr>\n
  452 + <td>Date:</td>\n
  453 + <td>".$item[datetime]."</td>\n
  454 + </tr>\n
  455 + <tr>\n
  456 + <td>User:</td>\n
  457 + <td>".$item[user_name]."</td>\n
  458 + </tr>\n
  459 + <tr>\n
  460 + <td colspan='2'><hr width='100' align='left'></td>\n
  461 + </tr>\n";
  462 + }
  463 + $htmlItem .= "</table>\n
  464 + </td>\n
  465 + </tr>\n
  466 + </table>";
  467 +
  468 + $xmlItemFooter = "</description>\n</item>\n";
  469 +
  470 + // Use htmlentities to allow html tags in the xml.
  471 + $htmlItem = htmlentities($htmlItem, ENT_QUOTES, 'UTF-8');
  472 +
  473 + $feed .= $xmlItemHead.$htmlItem.$xmlItemFooter;
439 } 474 }
440 - $feed .= "</channel>\n" .  
441 - "</rss>\n"; 475 + $footer = "</channel>\n</rss>\n";
442 476
443 - return $feed; 477 + return $head.$feed.$footer;
444 } 478 }
445 479
446 // Takes in an array as a parameter and returns rss2.0 compatible xml 480 // Takes in an array as a parameter and returns rss2.0 compatible xml
@@ -449,26 +483,28 @@ class KTrss{ @@ -449,26 +483,28 @@ class KTrss{
449 $aPath = explode('/', trim($_SERVER['PHP_SELF'])); 483 $aPath = explode('/', trim($_SERVER['PHP_SELF']));
450 global $default; 484 global $default;
451 $hostPath = "http" . ($default->sslEnabled ? "s" : "") . "://".$_SERVER['HTTP_HOST']."/".$aPath[1]."/"; 485 $hostPath = "http" . ($default->sslEnabled ? "s" : "") . "://".$_SERVER['HTTP_HOST']."/".$aPath[1]."/";
452 - $feed = "<?xml version=\"1.0\"?>\n";  
453 - $feed .= "<rss version=\"2.0\">\n".  
454 - "<channel>\n" .  
455 - "<title>".APP_NAME." RSS</title>\n" .  
456 - "<copyright>(c) 2007 The Jam Warehouse Software (Pty) Ltd. All Rights Reserved</copyright>\n" .  
457 - "<link>".$hostPath."</link>\n" .  
458 - "<description>KT-RSS</description>\n" .  
459 - "<image>\n".  
460 - "<title>".APP_NAME." RSS</title>\n".  
461 - "<width>140</width>\n".  
462 - "<height>28</height>".  
463 - "<link>".$hostPath."knowledgeTree/</link>\n".  
464 - "<url>".$hostPath."resources/graphics/ktlogo_rss.png</url>\n".  
465 - "</image>\n";  
466 - $feed .= "<item>\n".  
467 - "<title>Feed load error</title>\n" .  
468 - "<description>".$sError."</description>\n".  
469 - "</item>\n";  
470 - $feed .= "</channel>\n" .  
471 - "</rss>\n"; 486 + $feed = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n
  487 + <rss version=\"2.0\">\n
  488 +
  489 + <channel>\n
  490 + <title>".APP_NAME." RSS</title>\n
  491 + <copyright>(c) 2007 The Jam Warehouse Software (Pty) Ltd. All Rights Reserved</copyright>\n
  492 + <link>{$hostPath}</link>\n
  493 + <description>KT-RSS</description>\n
  494 + <image>\n
  495 + <title>".APP_NAME." RSS</title>\n
  496 + <width>140</width>\n
  497 + <height>28</height>
  498 + <link>{$hostPath}knowledgeTree/</link>\n
  499 + <url>{$hostPath}resources/graphics/ktlogo_rss.png</url>\n
  500 + </image>\n
  501 + <item>\n
  502 + <title>Feed load error</title>\n
  503 + <description>".$sError."</description>\n
  504 + </item>\n
  505 + </channel>\n
  506 +
  507 + </rss>\n";
472 508
473 return $feed; 509 return $feed;
474 } 510 }
@@ -5,32 +5,32 @@ @@ -5,32 +5,32 @@
5 * KnowledgeTree Open Source Edition 5 * KnowledgeTree Open Source Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited 7 * Copyright (C) 2004 - 2008 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
@@ -66,75 +66,79 @@ if ( !empty( $altinfo) &amp;&amp; !isset( $_SERVER[&#39;PHP_AUTH_USER&#39;])) { @@ -66,75 +66,79 @@ if ( !empty( $altinfo) &amp;&amp; !isset( $_SERVER[&#39;PHP_AUTH_USER&#39;])) {
66 } 66 }
67 67
68 if (!validateUser($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) { 68 if (!validateUser($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
69 - header('WWW-Authenticate: Basic realm="KnowledgeTree DMS"');  
70 - header('HTTP/1.0 401 Unauthorized');  
71 - echo 'This RSS feed requires authentication. Please enter your username and password.';  
72 - exit; 69 + header('WWW-Authenticate: Basic realm="KnowledgeTree DMS"');
  70 + header('HTTP/1.0 401 Unauthorized');
  71 + echo 'This RSS feed requires authentication. Please enter your username and password.';
  72 + exit;
73 } else { 73 } else {
74 - $user = DBAuthenticator::getUser($_SERVER['PHP_AUTH_USER'], array('id'=>'id',));  
75 - $id = $user[$_SERVER['PHP_AUTH_USER']]['id']; 74 + $user = DBAuthenticator::getUser($_SERVER['PHP_AUTH_USER'], array('id'=>'id',));
  75 + $id = $user[$_SERVER['PHP_AUTH_USER']]['id'];
76 76
  77 + header('Content-Type: application/rss+xml; charset=utf-8;');
  78 + header('Content-Disposition: inline; filename="rss.xml"');
  79 + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
  80 + header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
77 81
78 - if(KTUtil::arrayGet($_REQUEST, 'docId')){ // if a docId parameter is passed  
79 - // get document id from http request object  
80 - $iDocumentId = KTUtil::arrayGet($_REQUEST, 'docId'); 82 + if(KTUtil::arrayGet($_REQUEST, 'docId')){ // if a docId parameter is passed
  83 + // get document id from http request object
  84 + $iDocumentId = KTUtil::arrayGet($_REQUEST, 'docId');
81 85
82 - if(KTrss::validateDocumentPermissions($id, $iDocumentId)){ // if document passes validation check  
83 - // get document info  
84 - $aDocumentInfo[] = KTrss::getOneDocument($iDocumentId, $id); 86 + if(KTrss::validateDocumentPermissions($id, $iDocumentId)){ // if document passes validation check
  87 + // get document info
  88 + $aDocumentInfo[] = KTrss::getOneDocument($iDocumentId, $id);
85 89
86 - if($aDocumentInfo){  
87 - // create rss xml for document  
88 - $documentFeed = KTrss::arrayToXML($aDocumentInfo);  
89 - }else{  
90 - // create rss xml for the error  
91 - $error = KTrss::errorToXML(_kt('This document has returned a empty response'));  
92 - }  
93 - }else{  
94 - // create rss xml for error  
95 - $error = KTrss::errorToXML(_kt('You are either not authorised to view details on this document or it does not exist.' .  
96 - ' Please visit http://' .$_SERVER['HTTP_HOST'].'/'.$GLOBALS['KTRootUrl'].'/ to browse for a valid document.'));  
97 - }  
98 - if(isset($error)){ // if an error exist, output...else out the result  
99 - echo $error;  
100 - }else{  
101 - echo $documentFeed;  
102 - }  
103 - }elseif(KTUtil::arrayGet($_REQUEST, 'folderId')){ // if a folderId parameter is passed  
104 - // get folder id from http request object  
105 - $iFolderId = KTUtil::arrayGet($_REQUEST, 'folderId'); 90 + if($aDocumentInfo){
  91 + // create rss xml for document
  92 + $documentFeed = KTrss::arrayToXML($aDocumentInfo);
  93 + }else{
  94 + // create rss xml for the error
  95 + $error = KTrss::errorToXML(_kt('This document has returned a empty response'));
  96 + }
  97 + }else{
  98 + // create rss xml for error
  99 + $error = KTrss::errorToXML(_kt('You are either not authorised to view details on this document or it does not exist.' .
  100 + ' Please visit http://' .$_SERVER['HTTP_HOST'].'/'.$GLOBALS['KTRootUrl'].'/ to browse for a valid document.'));
  101 + }
  102 + if(isset($error)){ // if an error exist, output...else out the result
  103 + echo $error;
  104 + }else{
  105 + echo $documentFeed;
  106 + }
  107 + }elseif(KTUtil::arrayGet($_REQUEST, 'folderId')){ // if a folderId parameter is passed
  108 + // get folder id from http request object
  109 + $iFolderId = KTUtil::arrayGet($_REQUEST, 'folderId');
106 110
107 - if(KTrss::validateFolderPermissions($id, $iFolderId)){ // if folder passes validation check  
108 - // get folder info  
109 - $aFolderInfo[] = KTrss::getOneFolder($iFolderId); 111 + if(KTrss::validateFolderPermissions($id, $iFolderId)){ // if folder passes validation check
  112 + // get folder info
  113 + $aFolderInfo[] = KTrss::getOneFolder($iFolderId);
110 114
111 - if($aFolderInfo){  
112 - // create rss xml for folder  
113 - $folderFeed = KTrss::arrayToXML($aFolderInfo);  
114 - }else{  
115 - // create rss xml for error  
116 - $error = KTrss::errorToXML(_kt('This document has returned a empty response'));  
117 - }  
118 - }else{  
119 - // create rss xml for error  
120 - $error = KTrss::errorToXML(_kt('You are either not authorised to view details on this folder or it does not exist.' .  
121 - ' Please visit http://' .$_SERVER['HTTP_HOST'].'/'.$GLOBALS['KTRootUrl'].'/ to browse for a valid folder.'));  
122 - }  
123 - if(isset($error)){ // if an error exist, output...else out the result  
124 - echo $error;  
125 - }else{  
126 - echo $folderFeed;  
127 - }  
128 - }else{ // else do normal rss parsing  
129 - // get full list of subscribed documents and folders  
130 - $aFullList = kt_array_merge(KTrss::getDocuments($id), KTrss::getFolders($id));  
131 - $internalFeed = KTrss::arrayToXML($aFullList);  
132 - echo $internalFeed;  
133 - } 115 + if($aFolderInfo){
  116 + // create rss xml for folder
  117 + $folderFeed = KTrss::arrayToXML($aFolderInfo);
  118 + }else{
  119 + // create rss xml for error
  120 + $error = KTrss::errorToXML(_kt('This document has returned a empty response'));
  121 + }
  122 + }else{
  123 + // create rss xml for error
  124 + $error = KTrss::errorToXML(_kt('You are either not authorised to view details on this folder or it does not exist.' .
  125 + ' Please visit http://' .$_SERVER['HTTP_HOST'].'/'.$GLOBALS['KTRootUrl'].'/ to browse for a valid folder.'));
  126 + }
  127 + if(isset($error)){ // if an error exist, output...else out the result
  128 + echo $error;
  129 + }else{
  130 + echo $folderFeed;
  131 + }
  132 + }else{ // else do normal rss parsing
  133 + // get full list of subscribed documents and folders
  134 + $aFullList = kt_array_merge(KTrss::getDocuments($id), KTrss::getFolders($id));
  135 + $internalFeed = KTrss::arrayToXML($aFullList);
  136 + echo $internalFeed;
  137 + }
134 } 138 }
135 139
136 // Validate user credentials 140 // Validate user credentials
137 function validateUser($username, $password){ 141 function validateUser($username, $password){
138 - return DBAuthenticator::checkPassword($username, $password); 142 + return DBAuthenticator::checkPassword($username, $password);
139 } 143 }
140 -?> 144 -?>
  145 +?>
141 \ No newline at end of file 146 \ No newline at end of file