#92 Update knowledgebase.php
This commit is contained in:
parent
cf680463f3
commit
841b0eddff
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Title: Help Desk Software HESK
|
* Title: Help Desk Software HESK
|
||||||
* Version: 2.5.5 from 5th August 2014
|
* Version: 2.6.0 beta 1 from 30th December 2014
|
||||||
* Author: Klemen Stirn
|
* Author: Klemen Stirn
|
||||||
* Website: http://www.hesk.com
|
* Website: http://www.hesk.com
|
||||||
********************************************************************************
|
********************************************************************************
|
||||||
@ -39,6 +39,11 @@ define('HESK_PATH','./');
|
|||||||
require(HESK_PATH . 'hesk_settings.inc.php');
|
require(HESK_PATH . 'hesk_settings.inc.php');
|
||||||
require(HESK_PATH . 'inc/common.inc.php');
|
require(HESK_PATH . 'inc/common.inc.php');
|
||||||
require(HESK_PATH . 'inc/knowledgebase_functions.inc.php');
|
require(HESK_PATH . 'inc/knowledgebase_functions.inc.php');
|
||||||
|
|
||||||
|
// Are we in maintenance mode?
|
||||||
|
hesk_check_maintenance();
|
||||||
|
|
||||||
|
// Load Knowledgebase-related functions
|
||||||
hesk_load_database_functions();
|
hesk_load_database_functions();
|
||||||
|
|
||||||
/* Is Knowledgebase enabled? */
|
/* Is Knowledgebase enabled? */
|
||||||
@ -182,7 +187,7 @@ function hesk_kb_search($query) {
|
|||||||
require_once(HESK_PATH . 'inc/header.inc.php');
|
require_once(HESK_PATH . 'inc/header.inc.php');
|
||||||
hesk_kb_header($hesk_settings['kb_link']);
|
hesk_kb_header($hesk_settings['kb_link']);
|
||||||
|
|
||||||
$res = hesk_dbQuery('SELECT t1.`id`, t1.`subject`, t1.`content`, t1.`rating` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'kb_articles` AS t1
|
$res = hesk_dbQuery('SELECT t1.`id`, t1.`subject`, LEFT(`t1`.`content`, '.max(200, $hesk_settings['kb_substrart'] * 2).') AS `content`, t1.`rating` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'kb_articles` AS t1
|
||||||
LEFT JOIN `'.hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` AS t2 ON t1.`catid` = t2.`id`
|
LEFT JOIN `'.hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` AS t2 ON t1.`catid` = t2.`id`
|
||||||
WHERE t1.`type`='0' AND t2.`type`='0' AND MATCH(`subject`,`content`,`keywords`) AGAINST ('".hesk_dbEscape($query)."') LIMIT " . intval($hesk_settings['kb_search_limit']));
|
WHERE t1.`type`='0' AND t2.`type`='0' AND MATCH(`subject`,`content`,`keywords`) AGAINST ('".hesk_dbEscape($query)."') LIMIT " . intval($hesk_settings['kb_search_limit']));
|
||||||
$num = hesk_dbNumRows($res);
|
$num = hesk_dbNumRows($res);
|
||||||
@ -269,7 +274,7 @@ function hesk_show_kb_article($artid)
|
|||||||
// Update views by 1 - exclude known bots and reloads because of ratings
|
// Update views by 1 - exclude known bots and reloads because of ratings
|
||||||
if ( ! isset($_GET['rated']) && ! hesk_detect_bots())
|
if ( ! isset($_GET['rated']) && ! hesk_detect_bots())
|
||||||
{
|
{
|
||||||
hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` SET `views`=`views`+1 WHERE `id`='".intval($artid)."' LIMIT 1");
|
hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` SET `views`=`views`+1 WHERE `id`={$artid} LIMIT 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<h3 class="text-left">'.$article['subject'].'</h3>
|
echo '<h3 class="text-left">'.$article['subject'].'</h3>
|
||||||
@ -290,6 +295,7 @@ function hesk_show_kb_article($artid)
|
|||||||
echo '</p>';
|
echo '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Article rating
|
||||||
if ($hesk_settings['kb_rating'] && strpos( hesk_COOKIE('hesk_kb_rate'),'a'.$artid.'%')===false )
|
if ($hesk_settings['kb_rating'] && strpos( hesk_COOKIE('hesk_kb_rate'),'a'.$artid.'%')===false )
|
||||||
{
|
{
|
||||||
echo '
|
echo '
|
||||||
@ -300,6 +306,55 @@ function hesk_show_kb_article($artid)
|
|||||||
';
|
';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Related articles
|
||||||
|
if ($hesk_settings['kb_related'])
|
||||||
|
{
|
||||||
|
require(HESK_PATH . 'inc/mail/email_parser.php');
|
||||||
|
|
||||||
|
$query = hesk_dbEscape( $article['subject'] . ' ' . convert_html_to_text($article['content']) );
|
||||||
|
|
||||||
|
// Get relevant articles from the database
|
||||||
|
$res = hesk_dbQuery("SELECT t1.`id`, t1.`subject`, MATCH(`subject`,`content`,`keywords`) AGAINST ('{$query}') AS `score` FROM `".hesk_dbEscape($hesk_settings['db_pfix']).'kb_articles` AS t1 LEFT JOIN `'.hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` AS t2 ON t1.`catid` = t2.`id` WHERE t1.`type`='0' AND t2.`type`='0' AND MATCH(`subject`,`content`,`keywords`) AGAINST ('{$query}') LIMIT ".intval($hesk_settings['kb_related']+1));
|
||||||
|
|
||||||
|
// Array with related articles
|
||||||
|
$related_articles = array();
|
||||||
|
|
||||||
|
while ($related = hesk_dbFetchAssoc($res))
|
||||||
|
{
|
||||||
|
// Get base match score from the first article
|
||||||
|
if ( ! isset($base_score) )
|
||||||
|
{
|
||||||
|
$base_score = $related['score'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore this article
|
||||||
|
if ( $related['id'] == $artid )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop when articles reach less than 10% of base score
|
||||||
|
if ($related['score'] / $base_score < 0.10)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is a valid related article
|
||||||
|
$related_articles[$related['id']] = $related['subject'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print related articles if we have any valid matches
|
||||||
|
if ( count($related_articles) )
|
||||||
|
{
|
||||||
|
echo '<fieldset><legend>'.$hesklang['relart'].'</legend>';
|
||||||
|
foreach ($related_articles as $id => $subject)
|
||||||
|
{
|
||||||
|
echo '<img src="img/article_text.png" width="16" height="16" border="0" alt="" style="vertical-align:middle;padding:2px;" /> <a href="knowledgebase.php?article='.$id.'">'.$subject.'</a><br />';
|
||||||
|
}
|
||||||
|
echo '</fieldset>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($article['catid']==1)
|
if ($article['catid']==1)
|
||||||
{
|
{
|
||||||
$link = 'knowledgebase.php';
|
$link = 'knowledgebase.php';
|
||||||
@ -361,7 +416,7 @@ function hesk_show_kb_article($artid)
|
|||||||
function hesk_show_kb_category($catid, $is_search = 0) {
|
function hesk_show_kb_category($catid, $is_search = 0) {
|
||||||
global $hesk_settings, $hesklang;
|
global $hesk_settings, $hesklang;
|
||||||
|
|
||||||
$res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` WHERE `id`='{$catid}' AND `type`='0' LIMIT 1");
|
$res = hesk_dbQuery("SELECT `name`,`parent` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` WHERE `id`='{$catid}' AND `type`='0' LIMIT 1");
|
||||||
$thiscat = hesk_dbFetchAssoc($res) or hesk_error($hesklang['kb_cat_inv']);
|
$thiscat = hesk_dbFetchAssoc($res) or hesk_error($hesklang['kb_cat_inv']);
|
||||||
|
|
||||||
if ($is_search == 0)
|
if ($is_search == 0)
|
||||||
@ -372,6 +427,17 @@ function hesk_show_kb_category($catid, $is_search = 0) {
|
|||||||
hesk_kb_header($hesk_settings['kb_link']);
|
hesk_kb_header($hesk_settings['kb_link']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we are in "Knowledgebase only" mode show system messages
|
||||||
|
if ($catid == 1 && hesk_check_kb_only(false) )
|
||||||
|
{
|
||||||
|
// Service messages
|
||||||
|
$res = hesk_dbQuery('SELECT `title`, `message`, `style` FROM `'.hesk_dbEscape($hesk_settings['db_pfix'])."service_messages` WHERE `type`='0' ORDER BY `order` ASC");
|
||||||
|
while ($sm=hesk_dbFetchAssoc($res))
|
||||||
|
{
|
||||||
|
hesk_service_message($sm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($thiscat['parent'])
|
if ($thiscat['parent'])
|
||||||
{
|
{
|
||||||
$link = ($thiscat['parent'] == 1) ? 'knowledgebase.php' : 'knowledgebase.php?category='.$thiscat['parent'];
|
$link = ($thiscat['parent'] == 1) ? 'knowledgebase.php' : 'knowledgebase.php?category='.$thiscat['parent'];
|
||||||
@ -382,7 +448,7 @@ function hesk_show_kb_category($catid, $is_search = 0) {
|
|||||||
';
|
';
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` WHERE `parent`='{$catid}' AND `type`='0' ORDER BY `parent` ASC, `cat_order` ASC");
|
$result = hesk_dbQuery("SELECT `id`,`name`,`articles` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` WHERE `parent`='{$catid}' AND `type`='0' ORDER BY `cat_order` ASC");
|
||||||
if (hesk_dbNumRows($result) > 0)
|
if (hesk_dbNumRows($result) > 0)
|
||||||
{
|
{
|
||||||
?>
|
?>
|
||||||
@ -486,7 +552,7 @@ function hesk_show_kb_category($catid, $is_search = 0) {
|
|||||||
<td>
|
<td>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$res = hesk_dbQuery("SELECT `id`, `subject`, `content`, `rating` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `catid`='{$catid}' AND `type`='0' ORDER BY `sticky` DESC, `art_order` ASC");
|
$res = hesk_dbQuery("SELECT `id`, `subject`, LEFT(`content`, ".max(200, $hesk_settings['kb_substrart'] * 2).") AS `content`, `rating` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `catid`='{$catid}' AND `type`='0' ORDER BY `sticky` DESC, `art_order` ASC");
|
||||||
if (hesk_dbNumRows($res) == 0)
|
if (hesk_dbNumRows($res) == 0)
|
||||||
{
|
{
|
||||||
echo '<p><i>'.$hesklang['noac'].'</i></p>';
|
echo '<p><i>'.$hesklang['noac'].'</i></p>';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user