1
tvn3015
SmartFAQ won't work with XOOPS search
  • 2008/6/1 22:09

  • tvn3015

  • Just popping in

  • Posts: 53

  • Since: 2007/4/18


When I use the "Search" capability in XOOPS as a user in a group with Admin Rights to SmartFAQ, I see the proper search results in SmartFAQ.

When I use the "Search" capability in XOOPS as a anonymous user, I don't see any search result in SmartFAQ.

All permisions are set correctly!

Anyone else get this issue? Any advice will be appreciated. Thanks in advance!
hhttp://www.XoopsViet.com - Xoops for Vietnamese

2
avtx30
Re: SmartFAQ won't work with XOOPS search
  • 2008/6/1 23:12

  • avtx30

  • Not too shy to talk

  • Posts: 181

  • Since: 2006/10/12


Hi tvn,

Replace modules/smartfaq/include/search.inc.php with these codes (thanks to photositelinks.com)

// $Id: search.inc.php,v 1.0 2007/06/10 21:29:00 photosite
// FILE        ::    search.inc.php
// AUTHOR    ::    photosite
// WEB        ::    Photo Site Links 
//
function smartfaq_search($queryarray$andor$limit$offset$userid)
{
    global 
$xoopsDB ;
        
$showcontext = isset( $_GET['showcontext'] ) ? $_GET['showcontext'] : ;
    if( 
$showcontext == 1){
        
$sql "SELECT f.faqid, f.categoryid, f.question, f.datesub, f.status, a.answer, a.uid FROM ".$xoopsDB->prefix("smartfaq_faq")." f LEFT JOIN ".$xoopsDB->prefix("smartfaq_answers")." a ON f.faqid = a.faqid WHERE ( f.status = 5 OR f.status = 6 )";
    }else{
        
$sql "SELECT f.faqid, f.categoryid, f.question, f.datesub, f.status, a.uid FROM ".$xoopsDB->prefix("smartfaq_faq")." f LEFT JOIN ".$xoopsDB->prefix("smartfaq_answers")." a ON f.faqid = a.faqid WHERE ( f.status = 5 OR f.status = 6 )";
    }
    if ( 
$userid != ) {
        
$sql .= " AND a.uid=".$userid." ";
    }
    
// because count() returns 1 even if a supplied variable
    // is not an array, we must check if $querryarray is really an array
    
if ( is_array($queryarray) && $count count($queryarray) ) {
        
$sql .= " AND ((f.question LIKE '%$queryarray[0]%' OR a.answer LIKE '%$queryarray[0]%')";
        for(
$i=1;$i<$count;$i++){
            
$sql .= $andor ";
            
$sql .= "(f.question LIKE '%$queryarray[$i]%' OR a.answer LIKE '%$queryarray[$i]%')";
        }
        
$sql .= ") ";
    }
    
$sql .= "ORDER BY f.datesub DESC";
    
// get twice records 
    
$result $xoopsDB->query($sql2*$limit$offset);
    
    
$module_handler = &xoops_gethandler('module');
    
$module $module_handler->getByDirname('smartfaq');
    
$mid    $module->getVar('mid');

    
$gperm_handler = &xoops_gethandler('groupperm');

    global 
$xoopsUser;
    if ( 
is_object($xoopsUser) )
    {
        
$groups $xoopsUser->getGroups();
    }
    else
    {
        
$groups XOOPS_GROUP_ANONYMOUS;
    }

    
$ret = array();
    
$i 0;
    
    
$myts =& MyTextSanitizer::getInstance();
    
    while(
$myrow $xoopsDB->fetchArray($result) )
    {
        
$faqid $myrow['faqid'];
        
$catid $myrow['categoryid'];
        
// permission
        
if ( !$gperm_handler->checkRight('category_read'$catid$groups$mid) )
        {
            continue;
        }

        if ( !
$gperm_handler->checkRight('item_read'$faqid$groups$mid) )
        {
            continue;
        }
        
        
$ret[$i]['image'] = 'images/smartfaq.gif';
        
$ret[$i]['link']  = 'faq.php?faqid='.$myrow['faqid'];
        
$ret[$i]['title'] = $myts->htmlSpecialChars($myrow['question']);
        
$ret[$i]['time']  = $myrow['datesub'];
        
$ret[$i]['uid']   = $myrow['uid'];
        if( 
function_exists'search_make_context' ) && ! empty( $_GET['showcontext'] ) ) {
            
$context $myrow['answer'];
            
$context strip_tags($myts->displayTarea(strip_tags($context)));
            
$ret[$i]['context'] = search_make_context($context,$queryarray);
        }
        
$i++;

// show twice of limit
        
if (($limit 0) && ($i >= $limit))  break;
    }

    return 
$ret;
}

?>

3
tvn3015
Re: SmartFAQ won't work with XOOPS search
  • 2008/6/2 0:23

  • tvn3015

  • Just popping in

  • Posts: 53

  • Since: 2007/4/18


Thanks avtx!

Replacing the code and the search works great!

tvn
hhttp://www.XoopsViet.com - Xoops for Vietnamese

4
Runeher
Re: SmartFAQ won't work with XOOPS search
  • 2008/6/2 3:41

  • Runeher

  • Module Developer

  • Posts: 825

  • Since: 2008/1/24


Thanks avtx!

Login

Who's Online

401 user(s) are online (262 user(s) are browsing Support Forums)


Members: 0


Guests: 401


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits