Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
NoFantasy
Worker
Worker



Joined: Apr 26, 2005
Posts: 114

PostPosted: Mon Aug 22, 2005 9:10 am Reply with quote

Currently i'm trying to build up a decent searchmodule for my whole site using mSearch 3.0.2 ( [ Only registered users can see links on this board! Get registered or login! ] )

This is indeed a great module and should get more attention. As for now, my testing shows that most of my site is searchable AND RSS-enabled. The one thing I have not implemented is searching in Forum.

The plugin for searching in Forums search and displays ALL posts also the content in restricted areas. We don't want that, will we?

Has anyone been able to find a solution to this? Or might want to try? If so, i'd appreciate any help I can get.
 
View user's profile Send private message
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6433

PostPosted: Mon Aug 22, 2005 10:09 am Reply with quote

I've been looking at this as well and agree it should get more attention. I played around with some custom search objects for additional content types / modules. I believe we could modify the forums object to only search non restricted forums, and possibly even include restricted forums when the user is allowed.

_________________
I search, therefore I exist...
nukeSEO - nukeFEED - nukePIE - nukeSPAM - nukeWYSIWYG
 
View user's profile Send private message
NoFantasy







PostPosted: Mon Aug 22, 2005 10:34 am Reply with quote

Sounds great!
Any idea how to accomplish this? I'm no programmer myself, so what i can do with the code is limited. What i can do, is to test any suggestions to code-changes in the Forum-searchmodule.

I have tried to get in touch with the developers at [ Only registered users can see links on this board! Get registered or login! ] but it seems thay are too busy. I have also posted some small fixes regarding the RSS-feed for those interested.
 
kguske







PostPosted: Mon Aug 22, 2005 12:07 pm Reply with quote

Open modules/mSearch/modules/Forums.php, replace the entire function DoQuery with this:
Code:
   function doquery(){

      global $prefix, $tblname, $db;
      $q = $this->query[0][1];
      foreach ($q as $query){
         $db->sql_query('INSERT INTO '.$tblname.'
                  (`id`, `relevance`, `date`, `title`, `rid`, `desc`, `author`, `searchmodule`)
                  SELECT CONCAT("Forums", t.post_id) AS `id`, \'1\', \'0\', t.post_subject,
                  t.post_id, t.post_text, \'0\', "Forums" FROM '.$prefix.'_bbposts_text t,'.$prefix.'_bbposts p, '.$prefix.'_bbforums f
                  WHERE t.post_id = p.post_id AND f.forum_id=p.forum_id  AND (f.auth_view < 2 or f.auth_read < 2) AND
                  ((t.post_subject like \'%'.$query.'%\')
                  OR (t.post_text like \'%'.$query.'%\'))');
      }
   }


That will exclude posts in private forums from the search. It's not pretty, but it's a start...
 
NoFantasy







PostPosted: Mon Aug 22, 2005 2:21 pm Reply with quote

None of my users will ever see that code anyway Mr. Green
It works just great, thanks worship I noticed it took a bit longer time to search, but of course it's much more data to search and compare.

Next step: What about the issue sorting results? As for now the results showing oldest forumposts first.
 
kguske







PostPosted: Mon Aug 22, 2005 3:39 pm Reply with quote

We could probably improve the performance with additional changes to this class (though I won't be able to do that this week...).

Sorting the results would require an additional order by clause ( order by t.post_id desc ) on the SQL statement in function doquery.

Try:
Code:
   function doquery(){ 

      global $prefix, $tblname, $db;
      $q = $this->query[0][1];
      foreach ($q as $query){
         $db->sql_query('INSERT INTO '.$tblname.'
                  (`id`, `relevance`, `date`, `title`, `rid`, `desc`, `author`, `searchmodule`)
                  SELECT CONCAT("Forums", t.post_id) AS `id`, \'1\', \'0\', t.post_subject,
                  t.post_id, t.post_text, \'0\', "Forums" FROM '.$prefix.'_bbposts_text t,'.$prefix.'_bbposts p, '.$prefix.'_bbforums f
                  WHERE t.post_id = p.post_id AND f.forum_id=p.forum_id  AND (f.auth_view < 2 or f.auth_read < 2) AND
                  ((t.post_subject like \'%'.$query.'%\')
                  OR (t.post_text like \'%'.$query.'%\')) order by t.post_id desc');
      }
   }
 
NoFantasy







PostPosted: Mon Aug 22, 2005 5:06 pm Reply with quote

Sorting works fine too!

And it's no rush with the performance, it's reasonable. It might be sluggish with a large Forum tough.

Still got a few searchmodules to make so my site is fully covered by mSearch.
 
Camber
New Member
New Member



Joined: Apr 02, 2006
Posts: 13

PostPosted: Wed Sep 05, 2007 1:08 pm Reply with quote

I am playing around with msearch and I ran across this thread on sorting and filtering. I find that the sorting fix in this post works well but I am have difficulty filtering out the private forum posts from search results. Can anyone help out? This is the code from the current forum modules of msearch:

Code:
   function doquery(){

      global $prefix, $tblname, $db;
      $q = $this->query[0][1];
      foreach ($q as $query){
         $db->sql_query('INSERT INTO '.$tblname.'
                  (`id`, `relevance`, `date`, `title`, `rid`, `desc`, `author`, `searchmodule`)
                  SELECT CONCAT("Forums", `post_id`) AS `id`, \'1\', \'0\', `post_subject`,
                  `post_id`, `post_text`, \'0\', "Forums" FROM '.$prefix.'_bbposts_text
                  WHERE ((post_subject like \'%'.$query.'%\')
                  OR (post_text like \'%'.$query.'%\')) order by post_id desc');}}}
 
View user's profile Send private message
Gremmie
Former Moderator in Good Standing



Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Wed Sep 05, 2007 2:39 pm Reply with quote

You'll have to check the _bbforums table that "owns" the post and make sure that its auth_view is set to 0. A non-zero indicates it is a private forum of some kind I think.

_________________
GCalendar - An Event Calendar for PHP-Nuke
Member_Map - A Google Maps Nuke Module 
View user's profile Send private message
Camber







PostPosted: Wed Sep 05, 2007 2:54 pm Reply with quote

Gremmie, thanks for the reply! You are right about the auth_view and auth_read. I cut the older code in and it seemed to work this time. I must have had something wrong in the syntax. Thanks for kicking me back to take a second look!
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©