Page 1 of 2

RSS-FEED for knowledgebase

Posted: Tue Jan 26, 2010 12:33 pm
by fk59
It would be nice, to have a RSS-Funktion for the Knowledgebase!

Is that possible in future version?

Greetz
Frank

Re: RSS-FEED for knowledgebase

Posted: Tue Jan 26, 2010 12:59 pm
by Petert
fk59 wrote:It would be nice, to have a RSS-Funktion for the Knowledgebase!
I am working on an RSS feed for tickets. But why would you want a feed for the KB?

Posted: Tue Jan 26, 2010 1:14 pm
by fk59
cause we use it in Intranet and have round about 80 users who reads the KB AND who enters new storys.

So it would be nice to get the news via RSS

ciao :o

Re: RSS-FEED for knowledgebase

Posted: Wed Jan 27, 2010 9:01 pm
by Petert
fk59 wrote:It would be nice, to have a RSS-Funktion for the Knowledgebase!
I whipped the following very rough stuff.
If you want me to, I can make it working and to your specs.

In your index.php place a link like this:

Code: Select all

<a type="application/rss+xml" href="rss.php"><img src="img/rss.png" alt="RSS feed for this site"></a>
I placed mine in inc/common.inc.php at around line 169 (Hesk 2.1). But you can put it anywhere. (I attached the rss.png Image to this message).

rss.php

Code: Select all

<?php
  header("Content-Type: application/xml; charset=ISO-8859-1"); 
 
/*******************************************************************************
*  Title: Help Desk Software HESK
*  Version: 2.1 from 7th August 2009
*  Author: Klemen Stirn
*  Website: http://www.hesk.com
********************************************************************************
*  COPYRIGHT AND TRADEMARK NOTICE
*  Copyright 2005-2009 Klemen Stirn. All Rights Reserved.
*  HESK is a trademark of Klemen Stirn.

*  The HESK may be used and modified free of charge by anyone
*  AS LONG AS COPYRIGHT NOTICES AND ALL THE COMMENTS REMAIN INTACT.
*  By using this code you agree to indemnify Klemen Stirn from any
*  liability that might arise from it's use.

*  Selling the code for this program, in part or full, without prior
*  written consent is expressly forbidden.

*  Using this code, in part or full, to create derivate work,
*  new scripts or products is expressly forbidden. Obtain permission
*  before redistributing this software over the Internet or in
*  any other medium. In all cases copyright and header must remain intact.
*  This Copyright is in full effect in any country that has International
*  Trade Agreements with the United States of America or
*  with the European Union.

*  Removing any of the copyright notices without purchasing a license
*  is expressly forbidden. To remove HESK copyright notice you must purchase
*  a license for this script. For more information on how to obtain
*  a license please visit the page below:
*  https://www.hesk.com/buy.php
*******************************************************************************/

define('IN_SCRIPT',1);
define('HESK_PATH','');

/* Get all the required files and functions */
require(HESK_PATH . 'hesk_settings.inc.php');
$hesk_settings['debug_mode']=0;
error_reporting('E_ALL');
require(HESK_PATH . 'inc/common.inc.php');
require(HESK_PATH . 'inc/database.inc.php');

/* Is Knowledgebase enabled? */
if (!$hesk_settings['kb_enable'])
{
	hesk_error($hesklang['kbdis']);
}

$now = date("D, d M Y H:i:s T");

$output = "<?xml version="1.0"?>
            <rss version="2.0">
                <channel>
                    <title>" . $hesk_settings['site_title'] . "</title>
                    <link>" . $hesk_settings['site_url'] . "rss.php" . "</link>
                    <description>" . $hesk_settings['hesk_title'] . "</description>
                    <language>en-us</language>
                    <pubDate>$now</pubDate>
                    <lastBuildDate>$now</lastBuildDate>
                    <docs>http://someurl.com</docs>
                    <managingEditor>" . $hesk_settings['webmaster_mail'] . "</managingEditor>
                    <webMaster>you@youremail.com</webMaster>            ";

print $output;


/* Connect to database */
hesk_dbConnect();

/* Any category ID set? */
$catid = isset($_GET['category']) ? intval($_GET['category']) : 2;
$artid = isset($_GET['article']) ? intval($_GET['article']) : 0;

$hesk_settings['kb_link'] = ($artid || $catid != 1 || $query) ? '<a href="knowledgebase.php" class="smaller">'.$hesklang['kb_text'].'</a>' : $hesklang['kb_text'];





/*** START FUNCTIONS ***/

function hesk_show_kb_article($catid) {
	global $hesk_settings, $hesklang;

$sql = 'SELECT `id`,`subject`, content FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'kb_articles` WHERE  `type`=\'0\' ORDER BY `views` DESC, `art_order` ASC LIMIT '.hesk_dbEscape($hesk_settings['kb_numshow']+1);

//print $sql;
	$result   = hesk_dbQuery($sql);
  $items = '';
while ($article = hesk_dbFetchAssoc($result))
{
 $items .= '<item> 
	                <title>'. $article['subject'] .'</title> 
	                <link>'. $row["link"] .'</link> 
	                <description><![CDATA['. $row["content"] .']]></description> 
	            </item>'; 
	        
   
} // while
$items .= '</channel> 
          </rss>'; 
print $items;

} // END hesk_show_kb_article()


//hesk_show_kb_article(3);
hesk_show_kb_article(2);


?> 

Posted: Thu Jan 28, 2010 7:24 am
by fk59
hm, i got this error:


Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\html\helpdesk\rss.php:1) in C:\xampp\htdocs\html\helpdesk\rss.php on line 2

Posted: Thu Jan 28, 2010 9:19 am
by Klemen
Delete the first empty line in rss.php (any lines or spaces before <?php )

Posted: Thu Jan 28, 2010 9:46 am
by fk59
ok, i have removed now this line:

" header("Content-Type: application/xml; charset=ISO-8859-1"); "

FF shows the feed, but only with 2 articles

IE shows only an error.

Any hints?

Greetz
Frank

Posted: Thu Jan 28, 2010 9:52 am
by Klemen
No, you misunderstood me - don't delete the "header" code. You have (or had) some empty lines or spaces before

Code: Select all

<?php
(not after), that was the cause of the error.

Posted: Thu Jan 28, 2010 9:53 am
by fk59
hm, looks like it happens only in a local installation with XAMPP.

Online, the rss.php works fine....

Posted: Thu Jan 28, 2010 9:54 am
by fk59
no, i have no empty lines before .... i looked for that in notepad ++.....

Posted: Thu Jan 28, 2010 10:06 am
by Klemen
So you don't get the "Warning: Cannot modify header information" error anymore?

Posted: Thu Jan 28, 2010 10:11 am
by fk59
not online. Here all works fine.
http://www.wormserwebtreff.de/Helpdesk/rss.php

Locally with XAMPP in our intranet it dont works. Why ever....

IE says " Feed got errors" and FF shows only 2 articles in the feed.

Do you have any idea?

Posted: Thu Jan 28, 2010 10:16 am
by fk59
seems to be an error with german "ä,ü,ö" etc.

Posted: Thu Jan 28, 2010 10:48 am
by fk59
with the line "header" included:
Error:

Code: Select all

<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\html\helpdesk\rss.php:1) in <b>C:\xampp\htdocs\html\helpdesk\rss.php</b> on line <b>2</b><br />
The RSS:

Code: Select all

<?php
Header("Content-Type: application/xml; charset=ISO-8859-1"); 
/*******************************************************************************
*  Title: Help Desk Software HESK
*  Version: 2.1 from 7th August 2009
*  Author: Klemen Stirn
*  Website: http://www.hesk.com
********************************************************************************
*  COPYRIGHT AND TRADEMARK NOTICE
*  Copyright 2005-2009 Klemen Stirn. All Rights Reserved.
*  HESK is a trademark of Klemen Stirn.

*  The HESK may be used and modified free of charge by anyone
*  AS LONG AS COPYRIGHT NOTICES AND ALL THE COMMENTS REMAIN INTACT.
*  By using this code you agree to indemnify Klemen Stirn from any
*  liability that might arise from it's use.

*  Selling the code for this program, in part or full, without prior
*  written consent is expressly forbidden.

*  Using this code, in part or full, to create derivate work,
*  new scripts or products is expressly forbidden. Obtain permission
*  before redistributing this software over the Internet or in
*  any other medium. In all cases copyright and header must remain intact.
*  This Copyright is in full effect in any country that has International
*  Trade Agreements with the United States of America or
*  with the European Union.

*  Removing any of the copyright notices without purchasing a license
*  is expressly forbidden. To remove HESK copyright notice you must purchase
*  a license for this script. For more information on how to obtain
*  a license please visit the page below:
*  https://www.hesk.com/buy.php
*******************************************************************************/

define('IN_SCRIPT',1);
define('HESK_PATH','');

/* Get all the required files and functions */
require(HESK_PATH . 'hesk_settings.inc.php');
$hesk_settings['debug_mode']=0;
error_reporting('E_ALL');
require(HESK_PATH . 'inc/common.inc.php');
require(HESK_PATH . 'inc/database.inc.php');

/* Is Knowledgebase enabled? */
if (!$hesk_settings['kb_enable'])
{
   hesk_error($hesklang['kbdis']);
}

$now = date("D, d M Y H:i:s T");

$output = "<?xml version=\"1.0\"?>
            <rss version=\"2.0\">
                <channel>
                    <title>" . $hesk_settings['site_title'] . "</title>
                    <link>" . $hesk_settings['http://192.168.70.10/html/helpdesk'] . "rss.php" . "</link>
                    <description>" . $hesk_settings['hesk_title'] . "</description>
                    <language>de-de</language>
                    <pubDate>$now</pubDate>
                    <lastBuildDate>$now</lastBuildDate>
                    <docs>http://192.168.70.10/html/helpdesk</docs>
                    <managingEditor>" . $hesk_settings['webmaster_mail'] . "</managingEditor>
                    <webMaster>webmaster@wp-rd.de</webMaster>            ";

print $output;


/* Connect to database */
hesk_dbConnect();

/* Any category ID set? */
$catid = isset($_GET['category']) ? intval($_GET['category']) : 10;
$artid = isset($_GET['article']) ? intval($_GET['article']) : 0;

$hesk_settings['kb_link'] = ($artid || $catid != 1 || $query) ? '<a href="knowledgebase.php" class="smaller">'.$hesklang['kb_text'].'</a>' : $hesklang['kb_text'];





/*** START FUNCTIONS ***/

function hesk_show_kb_article($catid) {
   global $hesk_settings, $hesklang;

$sql = 'SELECT `id`,`subject`, content FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'kb_articles` WHERE  `type`=\'0\' ORDER BY `views` DESC, `art_order` ASC LIMIT '.hesk_dbEscape($hesk_settings['kb_numshow']+1);

//print $sql;
   $result   = hesk_dbQuery($sql);
  $items = '';
while ($article = hesk_dbFetchAssoc($result))
{
 $items .= '<item>
                   <title>'. $article['subject'] .'</title>
                   <link>'. $row["link"] .'</link>
                   <description><![CDATA['. $row["content"] .']]></description>
               </item>';
          
   
} // while
$items .= '</channel>
          </rss>';
print $items;

} // END hesk_show_kb_article()


//hesk_show_kb_article(3);
hesk_show_kb_article(2);
?>

Posted: Thu Jan 28, 2010 11:02 am
by Petert
fk59 wrote: IE says " Feed got errors" and FF shows only 2 articles in the feed.
IE sucks, I won't even go there.

The SQL statement looks at the type of the article. Remove that from the sql statement and all articles should be visisble.

Code: Select all

$sql = 'SELECT `id`,`subject`, content FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'kb_articles` WHERE  `type`=\'0\' ORDER BY `views` DESC, `art_order` ASC LIMIT '.hesk_dbEscape($hesk_settings['kb_numshow']+1);
change it to:

Code: Select all

$sql = 'SELECT `id`,`subject`, content FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'kb_articles` WHERE id  ORDER BY `views` DESC, `art_order` ASC LIMIT '.hesk_dbEscape($hesk_settings['kb_numshow']+1);
btw: would it really hurt to say thank you?[/code]