PDA

View Full Version : Anyone can post, but restrict thread view to usergroup


matthew tucker
12-06-2002, 04:58 AM
I've looked for this hack but I can't find how to do it.

I need to have a forum where ANYONE can post a message, ANYONE can view the subject line, but only members of USERGROUP can read the detail of the thread.

i can't seem to do it via the usual forum permissions changes.

Anyone know how to do this?

I need it because I want to be able to have a "jobs available" section that anyone can post a legit job to, ordinary users can see the list of jobs available, but only financial members can read and get the job detail.

thanks

Matthew

Logician
12-08-2002, 12:16 PM
enjoy..

matthew tucker
12-08-2002, 10:36 PM
No luck yet. edited showthread.php with following code, enabled default permissions for usergroupid==4 (registered members) and made up template. Logged in as a registered member, but can still see all threads in forum id==5.


$getperms=getpermissions($thread['forumid'],-1,-1,$forum['parentlist']);
if (!$getperms['canview']) {
show_nopermission();
}
if (!$getperms['canviewothers'] and ($thread['postuserid']!=$bbuserinfo['userid'] or $bbuserinfo['userid']==0)) {
show_nopermission();
}

// ** hack - can view thread titles but not detail **
if ($forum['forumid']==5 AND $bbuserinfo['usergroupid']==4)
{
eval("standarderror(\"".gettemplate("error_youdonthavepermission")."\");");
exit;
}
// *** end hack, see also printthread.php ****

$bbcodeon=iif($forum[allowbbcode],$ontext,$offtext);
// etc

Logician
12-08-2002, 10:57 PM
are u sure your registered users is 4? 4 is suppose to be COPPA while registered users are 2.. check it out

matthew tucker
12-09-2002, 12:27 AM
Yes, I did check that and you were right, I had confusled these (it takes real guts to be stupid ;-) BUT unfortunately after updating the two files to reflect the correct usergroupid, it still doesn't appear to work.

Now, in order for the hack to work, I understand the user permissions must be set so that that usergroup Can see own threads, Can see others threads, Can etc etc, .... and then the hack code short-circuits this and says if you're a member of Y group, you ain't getting any further in this X forum despite what the permissions say.

That right? Seems like it should work but still no joy. Thanks for your help so far.

Matthew

Logician
12-09-2002, 08:50 AM
matthew your logic is correct. That's how the hack works..

I believe your problem is related to your somehow. It was a tested hack and after your message I replied it to a test board and it worked: This is what this the hack does:
It allows the usergroup X to browse inside forum Y and list thread titles but if they click on a thread, they receive your custom error message and cant read it.

You might be missing something while installing.. Please double check:

1- you installed correctly
2- you try the hack with a usergroup account you restricted.
3- You enter your forumid correctly and you test the hack in that forum

matthew tucker
12-13-2002, 03:28 AM
Logician, I checked all above several times, and still no joy.

Can I somehow echo $forum['forumid'] and $bbuserinfo['usergroupid'] to the screen at the point of loading the page so I can check that the values I am trying to restrict are correct? How do I add this sort of debug info to my page?

Thanks for all your help.

Logician
12-13-2002, 06:17 AM
Originally posted by matthew tucker
Can I somehow echo $forum['forumid'] and $bbuserinfo['usergroupid'] to the screen at the point of loading the page so I can check that the values I am trying to restrict are correct? How do I add this sort of debug info to my page?

yes good idea:

find
if ($forum['forumid']==X AND $bbuserinfo['usergroupid']==Y)
before that add:

echo "forumid :".$forum['forumid'].' - usergroupid :'.$bbuserinfo['usergroupid'];

Logician
12-13-2002, 06:26 AM
nm, I found your problem: please try adding the code in showthread.php right BEFORE here TOO:

if ((!isset($pagenumber) or $pagenumber==0) and $pagenumber!="lastpage") {

The location you added in the first place has 2 instances and it should be added to the both.. ;)

matthew tucker
12-15-2002, 10:32 PM
THANKS that worked, its great, does exactly what I want.

Now I have to read showthread.php and try to understand it!

Again, thanks for your efforts.

TECK
12-16-2002, 03:01 AM
Logician, is alot more extensive then this... with your code, I can see the posts, while I search...
I wrote one for my board so i know the little bells...

Logician
12-16-2002, 06:11 AM
Originally posted by TECK
Logician, is alot more extensive then this... with your code, I can see the posts, while I search...
I wrote one for my board so i know the little bells...
I know that user can see part of the post if he uses search. The quick cure of it may be disabling his search rights..

Anyway this not a full release hack, it's one of my 2 minute hacks which I give away to help requesters. So if you patched the searching gap in your hack, please feel welcomed to share yours in Full Releases or here..