Author |
Message |
NoFantasy
Worker


Joined: Apr 26, 2005
Posts: 114
|
Posted:
Mon Aug 22, 2005 9:10 am |
|
Currently i'm trying to build up a decent searchmodule for my whole site using mSearch 3.0.2 ( http://www.webdever.net/ )
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. |
|
|
|
 |
kguske
Site Admin

Joined: Jun 04, 2004
Posts: 6437
|
Posted:
Mon Aug 22, 2005 10:09 am |
|
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...
Only registered users can see links on this board! Get registered or login! |
|
|
 |
NoFantasy

|
Posted:
Mon Aug 22, 2005 10:34 am |
|
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 http://www.webdever.net/modules.php?name=Forums&file=viewforum&f=2 but it seems thay are too busy. I have also posted some small fixes regarding the RSS-feed for those interested. |
|
|
|
 |
kguske

|
Posted:
Mon Aug 22, 2005 12:07 pm |
|
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

|
Posted:
Mon Aug 22, 2005 2:21 pm |
|
None of my users will ever see that code anyway
It works just great, thanks 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

|
Posted:
Mon Aug 22, 2005 3:39 pm |
|
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

|
Posted:
Mon Aug 22, 2005 5:06 pm |
|
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


Joined: Apr 02, 2006
Posts: 13
|
Posted:
Wed Sep 05, 2007 1:08 pm |
|
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');}}}
|
|
|
|
|
 |
Gremmie
Former Moderator in Good Standing

Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA
|
Posted:
Wed Sep 05, 2007 2:39 pm |
|
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. |
_________________ Only registered users can see links on this board! Get registered or login! - An Event Calendar for PHP-Nuke
Only registered users can see links on this board! Get registered or login! - A Google Maps Nuke Module |
|
|
 |
Camber

|
Posted:
Wed Sep 05, 2007 2:54 pm |
|
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! |
|
|
|
 |
|