Both osTicket System version 1.6 RC4 and 1.6 RC5 have not implemented displaying and searching Knowledge Base properly. Every time I try to search the certain keyword that already exists in database, this system always gives me an output: Query returned 0 results. This is really really weird, I think. So I made a modification in order staffs are able to search and displaying the result based on the keyword they entered.
Open \include\staff\premade.inc.php file, and find this code:
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | //List premade answers. $select='SELECT premade.*,dept_name '; $from='FROM '.KB_PREMADE_TABLE.' premade LEFT JOIN '.DEPT_TABLE.' USING(dept_id) '; //make sure the search query is 3 chars min...defaults to no query with warning message if($_REQUEST['a']=='search') { if(!$_REQUEST['query'] || strlen($_REQUEST['query'])<3) { $errors['err']='Search term must be more than 3 chars'; }else{ //fulltext search. $search=true; $qstr.='&a='.urlencode($_REQUEST['a']); $qstr.='&query='.urlencode($_REQUEST['query']); $where=' WHERE MATCH(title,answer) AGAINST ('.db_input($_REQUEST['query']).')'; if($_REQUEST['dept']) $where.=' AND dept_id='.db_input($_REQUEST['dept']); } } //I admit this crap sucks...but who cares?? |
then replace with this following code:
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | //List premade answers. $select='SELECT DISTINCT(d.dept_name), premade.* '; $from='FROM '.KB_PREMADE_TABLE.' premade, '.DEPT_TABLE.' d '; //make sure the search query is 3 chars min...defaults to no query with warning message if($_REQUEST['a']=='search') { if(!$_REQUEST['query'] || strlen($_REQUEST['query'])<3) { $errors['err']=I_S_PREM_SEARCH_TERM; }else{ //fulltext search. $search=true; $qstr.='&a='.urlencode($_REQUEST['a']); $qstr.='&query='.urlencode($_REQUEST['query']); $searchfor = $_REQUEST['query']; $where=" WHERE (premade.title LIKE '%$searchfor%' OR premade.answer LIKE '%$searchfor%') AND (d.dept_id = premade.dept_id OR premade.dept_id = 0) "; if($_REQUEST['dept']) $where.=' AND d.dept_id='.db_input($_REQUEST['dept']); } } if (!isset($where)) $where = 'WHERE d.dept_id = premade.dept_id OR premade.dept_id = 0'; //I admit this crap sucks...but who cares?? |
Now staffs are able to search and displaying the result properly. Besides that, if a Premade Reply belongs to All Departments (for example, currently you already have 3 departments), then you will see now in the table list of Premade Replies, there are 3 records of Premade Reply for that 3 departments. With this way, when staff search for Premade Reply that belongs to certain department, then system will display the record belongs to such department only.

Recent Comments