diff --git a/plugins/rssplugin/KTrss.inc.php b/plugins/rssplugin/KTrss.inc.php index bf94e9b..2d15cf2 100644 --- a/plugins/rssplugin/KTrss.inc.php +++ b/plugins/rssplugin/KTrss.inc.php @@ -336,111 +336,145 @@ class KTrss{ $sSuffix = ''; } $hostPath = "http" . ($default->sslEnabled ? "s" : "") . "://".$_SERVER['HTTP_HOST']."/".$sSuffix; - $feed = "\n"; - $feed .= "\n". - "\n" . - "".APP_NAME." RSS\n" . - "(c) 2007 The Jam Warehouse Software (Pty) Ltd. All Rights Reserved\n" . - "".$hostPath."\n" . - "KT-RSS\n" . - "\n". - "".APP_NAME." RSS\n". - "140\n". - "28". - "".$hostPath."knowledgeTree/\n". - "".$hostPath."resources/graphics/ktlogo_rss.png\n". - "\n"; - foreach($aItems as $aItems){ - if($aItems[0][itemType] == 'folder'){ - $sTypeSelect = 'folder.transactions&fFolderId'; - }elseif($aItems[0][itemType] == 'document'){ - $sTypeSelect = 'document.transactionhistory&fDocumentId'; + + $head = "\n + \n + \n + ".APP_NAME." RSS\n + (c) 2007 The Jam Warehouse Software (Pty) Ltd. All Rights Reserved\n + ".$hostPath."\n + KT-RSS\n + \n + ".APP_NAME." RSS\n + 140\n + 28 + ".$hostPath."knowledgeTree/\n + ".$hostPath."resources/graphics/ktlogo_rss.png\n + \n"; + + + $feed = ''; + foreach($aItems as $aItem){ + + $aItemHead = $aItem[0][0]; + $aItemList = $aItem[1]; + + if($aItem[0][itemType] == 'folder'){ + $sTypeSelect = 'folder.transactions&fFolderId'; + }elseif($aItem[0][itemType] == 'document'){ + $sTypeSelect = 'document.transactionhistory&fDocumentId'; } - $feed .= "\n" . - "".htmlentities(KTrss::rss_sanitize($aItems[0][0][name],false), ENT_QUOTES, 'UTF-8')."\n" . - "".$hostPath."action.php?kt_path_info=ktcore.actions.".$sTypeSelect."=".$aItems[0][0]['id']."\n" . - "\n" . - "<table border='0' width='90%'>\n". - "<tr>\n". - "<td width='5%' height='16px'>" . - "<a href='".$hostPath."action.php?kt_path_info=ktcore.actions.".$sTypeSelect."=".$aItems[0][0][id]."' ><img src='".$aItems[0][mimeTypeIcon]."' align='left' height='16px' width='16px' alt='' border='0' /></a>" . - "</td>\n". - "<td align='left'> ".$aItems[0][mimeTypeFName]."</td>\n". - "</tr>\n". - "<tr>\n". - "<td colspan='2'>\n". - ucfirst($aItems[0]['itemType'])." Information (ID: ".$aItems[0][0][id].")</>\n". - "<hr>\n". - "<table width='95%'>\n". - "<tr>\n". - "<td>Filename: ".KTrss::rss_sanitize($aItems[0][0][filename])."</td>\n". - "<td>\n". - "</tr>\n". - "<tr>\n". - "<td>Author: ".$aItems[0][0][author]."</td>\n". - "<td>\n". - "</tr>\n". - "<tr>\n". - "<td>Owner: ";if($aItems[0][0][owner]){$feed .= $aItems[0][0][owner];}else{$feed .= "None";} - $feed .= "</td>\n". - "<td></td>\n". - "</tr>\n". - "<tr>\n";if($aItems[0][0][type]){ - $feed .= "<td>Document type: ".$aItems[0][0][type]."</td>\n". - "<td></td>\n";} - $feed .= "</tr>\n". - "<tr>\n". - "<td>Workflow status: ";if($aItems[0][0][workflow_status]){$feed .= $aItems[0][0][workflow_status];}else{$feed .= "No Workflow";} - $feed .= "</td>\n". - "<td></td>\n". - "</tr>\n". - "</table><br>\n". - "Transaction Summary (Last 4)\n". - "<hr>\n". - "<table width='100%'>\n"; - foreach($aItems[1] as $item){ - $feed .= "<tr>\n". - "<td>".$item[type]." name:</td>\n". - "<td>".KTrss::rss_sanitize($item[name] )."</td>\n". - "</tr>\n". - "<tr>\n". - "<td>Path:</td>\n". - "<td>".KTrss::rss_sanitize($item[fullpath] )."</td>\n". - "</tr>\n". - "<tr>\n". - "<td>Transaction:</td>\n". - "<td>".$item[transaction_name]."</td>\n". - "</tr>\n". - "<tr>\n". - "<td>Comment:</td>\n". - "<td>".KTrss::rss_sanitize($item[comment] )."</td>\n". - "</tr>\n". - "<tr>\n";if($item[version]){ - $feed .= "<td>Version:</td>\n". - "<td>".$item[version]."</td>\n";} - $feed .= "</tr>\n". - "<tr>\n". - "<td>Date:</td>\n". - "<td>".$item[datetime]."</td>\n". - "</tr>\n". - "<tr>\n". - "<td>User:</td>\n". - "<td>".$item[user_name]."</td>\n". - "</tr>\n". - "<tr>\n". - "<td colspan='2'><hr width='100' align='left'></td>\n". - "</tr>\n";} - $feed .= "</table>\n". - "</td>\n". - "</tr>\n". - "</table>". - "\n". - "\n"; + + + if($aItem[0][0][owner]){ + $owner = $aItem[0][0][owner]; + }else{ + $owner = _kt('None'); + } + + $type = ''; + if($aItem[0][0][type]){ + $type = 'Document type: '.$aItem[0][0][type]."\n\n"; + } + + if($aItem[0][0][workflow_status]){ + $workflow = $aItem[0][0][workflow_status]; + }else{ + $workflow = _kt('No Workflow'); + } + + $xmlItemHead = "\n + ".htmlentities($aItem[0][0][name], ENT_QUOTES, 'UTF-8')."\n + ".$hostPath."action.php?kt_path_info=ktcore.actions.".htmlentities($sTypeSelect, ENT_QUOTES, 'UTF-8')."=".$aItem[0][0]['id']."\n + \n"; + + $htmlItem = "\n + \n + \n + \n + \n + \n + \n + \n +
+ + + ".$aItem[0][mimeTypeFName]."
\n + ".ucfirst($aItem[0]['itemType'])." Information (ID: ".$aItem[0][0][id].")\n +
\n + + \n + \n + \n + \n + \n + \n + \n + \n + \n + \n + \n + ".$type."\n + \n + \n + \n + \n +
"._kt('Filename').": ".$aItem[0][0][filename]."
"._kt('Author').": ".$aItem[0][0][author]."
"._kt('Owner').": ".$owner."
"._kt('Workflow status').": ".$workflow."

\n + + "._kt('Transaction Summary (Last 4)')."\n +
\n + + \n"; + + foreach($aItem[1] as $item){ + $htmlItem .= "\n + \n + \n + \n + \n + \n + \n + \n + \n + \n + \n + \n + \n + \n + \n + \n + \n"; + + if($item[version]){ + $htmlItem .= "\n + \n"; + } + $htmlItem .= "\n + \n + \n + \n + \n + \n + \n + \n + \n + \n + \n + \n"; + } + $htmlItem .= "
".$item[type]." name:".$item[name]."
Path:".$item[fullpath]."
Transaction:".$item[transaction_name]."
Comment:".$item[comment]."
Version:".$item[version]."
Date:".$item[datetime]."
User:".$item[user_name]."

\n +
"; + + $xmlItemFooter = "
\n
\n"; + + // Use htmlentities to allow html tags in the xml. + $htmlItem = htmlentities($htmlItem, ENT_QUOTES, 'UTF-8'); + + $feed .= $xmlItemHead.$htmlItem.$xmlItemFooter; } - $feed .= "
\n" . - "
\n"; + $footer = "
\n
\n"; - return $feed; + return $head.$feed.$footer; } // Takes in an array as a parameter and returns rss2.0 compatible xml @@ -449,26 +483,28 @@ class KTrss{ $aPath = explode('/', trim($_SERVER['PHP_SELF'])); global $default; $hostPath = "http" . ($default->sslEnabled ? "s" : "") . "://".$_SERVER['HTTP_HOST']."/".$aPath[1]."/"; - $feed = "\n"; - $feed .= "\n". - "\n" . - "".APP_NAME." RSS\n" . - "(c) 2007 The Jam Warehouse Software (Pty) Ltd. All Rights Reserved\n" . - "".$hostPath."\n" . - "KT-RSS\n" . - "\n". - "".APP_NAME." RSS\n". - "140\n". - "28". - "".$hostPath."knowledgeTree/\n". - "".$hostPath."resources/graphics/ktlogo_rss.png\n". - "\n"; - $feed .= "\n". - "Feed load error\n" . - "".$sError."\n". - "\n"; - $feed .= "\n" . - "\n"; + $feed = "\n + \n + + \n + ".APP_NAME." RSS\n + (c) 2007 The Jam Warehouse Software (Pty) Ltd. All Rights Reserved\n + {$hostPath}\n + KT-RSS\n + \n + ".APP_NAME." RSS\n + 140\n + 28 + {$hostPath}knowledgeTree/\n + {$hostPath}resources/graphics/ktlogo_rss.png\n + \n + \n + Feed load error\n + ".$sError."\n + \n + \n + + \n"; return $feed; } diff --git a/rss.php b/rss.php index 8ba71d7..a28f131 100644 --- a/rss.php +++ b/rss.php @@ -5,32 +5,32 @@ * KnowledgeTree Open Source Edition * Document Management Made Simple * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited - * + * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * + * * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. - * + * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. - * + * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original - * copyright notice. + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. * Contributor( s): ______________________________________ */ @@ -66,75 +66,79 @@ if ( !empty( $altinfo) && !isset( $_SERVER['PHP_AUTH_USER'])) { } if (!validateUser($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) { - header('WWW-Authenticate: Basic realm="KnowledgeTree DMS"'); - header('HTTP/1.0 401 Unauthorized'); - echo 'This RSS feed requires authentication. Please enter your username and password.'; - exit; + header('WWW-Authenticate: Basic realm="KnowledgeTree DMS"'); + header('HTTP/1.0 401 Unauthorized'); + echo 'This RSS feed requires authentication. Please enter your username and password.'; + exit; } else { - $user = DBAuthenticator::getUser($_SERVER['PHP_AUTH_USER'], array('id'=>'id',)); - $id = $user[$_SERVER['PHP_AUTH_USER']]['id']; + $user = DBAuthenticator::getUser($_SERVER['PHP_AUTH_USER'], array('id'=>'id',)); + $id = $user[$_SERVER['PHP_AUTH_USER']]['id']; + header('Content-Type: application/rss+xml; charset=utf-8;'); + header('Content-Disposition: inline; filename="rss.xml"'); + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); + header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - if(KTUtil::arrayGet($_REQUEST, 'docId')){ // if a docId parameter is passed - // get document id from http request object - $iDocumentId = KTUtil::arrayGet($_REQUEST, 'docId'); + if(KTUtil::arrayGet($_REQUEST, 'docId')){ // if a docId parameter is passed + // get document id from http request object + $iDocumentId = KTUtil::arrayGet($_REQUEST, 'docId'); - if(KTrss::validateDocumentPermissions($id, $iDocumentId)){ // if document passes validation check - // get document info - $aDocumentInfo[] = KTrss::getOneDocument($iDocumentId, $id); + if(KTrss::validateDocumentPermissions($id, $iDocumentId)){ // if document passes validation check + // get document info + $aDocumentInfo[] = KTrss::getOneDocument($iDocumentId, $id); - if($aDocumentInfo){ - // create rss xml for document - $documentFeed = KTrss::arrayToXML($aDocumentInfo); - }else{ - // create rss xml for the error - $error = KTrss::errorToXML(_kt('This document has returned a empty response')); - } - }else{ - // create rss xml for error - $error = KTrss::errorToXML(_kt('You are either not authorised to view details on this document or it does not exist.' . - ' Please visit http://' .$_SERVER['HTTP_HOST'].'/'.$GLOBALS['KTRootUrl'].'/ to browse for a valid document.')); - } - if(isset($error)){ // if an error exist, output...else out the result - echo $error; - }else{ - echo $documentFeed; - } - }elseif(KTUtil::arrayGet($_REQUEST, 'folderId')){ // if a folderId parameter is passed - // get folder id from http request object - $iFolderId = KTUtil::arrayGet($_REQUEST, 'folderId'); + if($aDocumentInfo){ + // create rss xml for document + $documentFeed = KTrss::arrayToXML($aDocumentInfo); + }else{ + // create rss xml for the error + $error = KTrss::errorToXML(_kt('This document has returned a empty response')); + } + }else{ + // create rss xml for error + $error = KTrss::errorToXML(_kt('You are either not authorised to view details on this document or it does not exist.' . + ' Please visit http://' .$_SERVER['HTTP_HOST'].'/'.$GLOBALS['KTRootUrl'].'/ to browse for a valid document.')); + } + if(isset($error)){ // if an error exist, output...else out the result + echo $error; + }else{ + echo $documentFeed; + } + }elseif(KTUtil::arrayGet($_REQUEST, 'folderId')){ // if a folderId parameter is passed + // get folder id from http request object + $iFolderId = KTUtil::arrayGet($_REQUEST, 'folderId'); - if(KTrss::validateFolderPermissions($id, $iFolderId)){ // if folder passes validation check - // get folder info - $aFolderInfo[] = KTrss::getOneFolder($iFolderId); + if(KTrss::validateFolderPermissions($id, $iFolderId)){ // if folder passes validation check + // get folder info + $aFolderInfo[] = KTrss::getOneFolder($iFolderId); - if($aFolderInfo){ - // create rss xml for folder - $folderFeed = KTrss::arrayToXML($aFolderInfo); - }else{ - // create rss xml for error - $error = KTrss::errorToXML(_kt('This document has returned a empty response')); - } - }else{ - // create rss xml for error - $error = KTrss::errorToXML(_kt('You are either not authorised to view details on this folder or it does not exist.' . - ' Please visit http://' .$_SERVER['HTTP_HOST'].'/'.$GLOBALS['KTRootUrl'].'/ to browse for a valid folder.')); - } - if(isset($error)){ // if an error exist, output...else out the result - echo $error; - }else{ - echo $folderFeed; - } - }else{ // else do normal rss parsing - // get full list of subscribed documents and folders - $aFullList = kt_array_merge(KTrss::getDocuments($id), KTrss::getFolders($id)); - $internalFeed = KTrss::arrayToXML($aFullList); - echo $internalFeed; - } + if($aFolderInfo){ + // create rss xml for folder + $folderFeed = KTrss::arrayToXML($aFolderInfo); + }else{ + // create rss xml for error + $error = KTrss::errorToXML(_kt('This document has returned a empty response')); + } + }else{ + // create rss xml for error + $error = KTrss::errorToXML(_kt('You are either not authorised to view details on this folder or it does not exist.' . + ' Please visit http://' .$_SERVER['HTTP_HOST'].'/'.$GLOBALS['KTRootUrl'].'/ to browse for a valid folder.')); + } + if(isset($error)){ // if an error exist, output...else out the result + echo $error; + }else{ + echo $folderFeed; + } + }else{ // else do normal rss parsing + // get full list of subscribed documents and folders + $aFullList = kt_array_merge(KTrss::getDocuments($id), KTrss::getFolders($id)); + $internalFeed = KTrss::arrayToXML($aFullList); + echo $internalFeed; + } } // Validate user credentials function validateUser($username, $password){ - return DBAuthenticator::checkPassword($username, $password); + return DBAuthenticator::checkPassword($username, $password); } -?> +?> \ No newline at end of file