PortalParts.com Site

 Forum Index > Geeklog > Filemgmt Plugin Support New Topic Post Reply
 Filemgmt and Search
 |  Printable Version
sabhasin
 January 28 2008 20:42 PM (Read 1791 times)  
Forum Newbie
Newbie

Status: offline

Registered: 11/12/07
Posts: 2

I was wondering if someone can help me out with a strange thing i'm observing (it's probably been like this for a while but i just noticed it). Perhaps, it has to do with upgrading to the custom filemgmt code but i'm not sure. Anyways, so here's the problem - When i search using the main geeklog search function (from the site's homepage), I see the search work perfectly for stories, staticpages, dokuwiki etc however, the filemgmt search results just seem to return all files in the repository - page after page....

Any ideas as to what might be wrong? I tried asking on the GL mailing list and couldn't really get anywhere and i'd really not want to comment this out from filemgmt's functions.inc.

Please help.
-Saurabh


 
Profile Email PM
Quote
Blaine
 January 28 2008 20:51 PM  
Forum Admin
Admin

Status: offline

Registered: 03/01/02
Posts: 3576

Hi Saurabh,

Please try this replacement function - in the plugins functions.inc file

PHP Formatted Code

function plugin_dopluginsearch_filemgmt($query, $datestart, $dateend, $topic, $type, $author)
{
    global $LANG_FILEMGMT, $_TABLES, $_FM_TABLES, $_CONF, $filemgmt_FileStoreURL;

    $query = addslashes($query);
    if (empty($type)) {
        $type = 'all';
    }

    // Bail if we aren't supppose to do our search
    if ($type <> 'all' AND $type <> 'filemgmt') {
        $plugin_results = new Plugin();
        $plugin_results->plugin_name = $LANG_FILEMGMT['plugin_name'];
        $plugin_results->searchlabel = $LANG_FILEMGMT['searchlabel'];
        return $plugin_results;
    }

    // Build search SQL
        $accessSQL = filemgmt_buildAccessSql('WHERE');

    $sql  = "SELECT a.lid, a.lid, a.cid, a.title, url, submitter, comments, hits, UNIX_TIMESTAMP(date) as day, description ";
    $sql .= "FROM {$_FM_TABLES['filemgmt_filedetail']} a ";
    $sql .= "LEFT JOIN {$_FM_TABLES['filemgmt_cat']} b ON b.cid=a.cid ";
    $sql .= "LEFT JOIN {$_FM_TABLES['filemgmt_filedesc']} c ON c.lid=a.lid ";
        if (!empty($accessSQL)) {
        $sql .= filemgmt_buildAccessSql('WHERE');
         $sql .= " AND a.status > 0 AND (";
    } else {
         $sql .= " WHERE a.status > 0 AND (";
        }

    $sql .= "(a.title like '%$query%' OR a.title like '$query%' OR a.title like '%$query') ";
    $sql .= "OR (c.description like '%$query%' OR c.description like '$query%' OR c.description like '%$query')) ";

    if (!empty($datestart) && !empty($dateend)) {
        $delim = substr($datestart, 4, 1);
        $DS = explode($delim,$datestart);
        $DE = explode($delim,$dateend);
        $startdate = mktime(0,0,0,$DS[1],$DS[2],$DS[0]);
        $enddate = mktime(0,0,0,$DE[1],$DE[2],$DE[0]) + 3600;
        $sql .= "AND (UNIX_TIMESTAMP(date) BETWEEN '$startdate' AND '$enddate') ";
    }

    if (!empty($author)) {
        $sql .= "AND (submitter = '$author') ";
    }
    $sql    .= "ORDER BY date desc";

    // Perform search
    $result = DB_query($sql);

    // OK, now return coma delmited string of table header labels
    // Need to use language variables
    require_once($_CONF['path_system'] . 'classes/plugin.class.php');
    $plugin_results = new Plugin();
    $plugin_results->plugin_name = 'filemgmt';
    $plugin_results->searchlabel = $LANG_FILEMGMT['searchlabel_results'];
    $plugin_results->addSearchHeading('Title');
    $plugin_results->addSearchHeading('Description');
    $plugin_results->addSearchHeading('Author');
    $plugin_results->addSearchHeading('Downloads');
    $plugin_results->num_searchresults = DB_numRows($result);

    // NOTE if any of your data items need to be links then add them here!
    // make sure data elements are in an array and in the same order as your
    // headings above!

    for ($i = 1; $i <= $plugin_results->num_searchresults; $i++) {
        $A = DB_fetchArray($result);
        $thetime = COM_getUserDateTimeFormat($A['day']);
        $url = $_CONF[site_url]. "/filemgmt/index.php?id=".$A['lid'];
        $row = array("<a href={$url}>{$A['title']}</a>", wordwrap($A['description'],70,"<br>"), COM_getDisplayName($A['submitter']), $A['hits']);
        $plugin_results->addSearchResult($row);
    }

    $plugin_results->num_itemssearched = DB_count($_FM_TABLES['filemgmt_filedetail']);

    return $plugin_results;
}
 


Please consider contributing to support my efforts ..
 
Profile Email Website PM
Quote
sabhasin
 January 28 2008 20:59 PM  
Forum Newbie
Newbie

Status: offline

Registered: 11/12/07
Posts: 2

Howdy, Blaine - thanks so much for the quick response. I just replaced the function and did a quick test and it's looking terrific. Works as I expect. I'll ask a few others to try and see if they're happy (and will leave me alone!). Just out of curiosity, was this related to the custom work and we didn't include something in the function? thanks so much again.
-Saurabh


 
Profile Email PM
Quote
Content generated in: 0.23 seconds
New Topic Post Reply



 All times are CDT. The time is now 03:51 PM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content