PDA

View Full Version : Request - Private Message Hack


Rose
08-27-2002, 05:25 PM
I did a quick search and couldn't find what I"m looking for. If I've overlooked something, please let me know and point me in the right direction. ;)

Anyway, I'd like to set private message permissions via usergroup. Not all usergroups, just one.


I've setup a certain group of members. It's important that they cannot read private messages unless it comes from an administrator or from someone in the same usergroup. The group-group pm'ing isn't super important, but having this group receive pm's from Admin is.


Is this possible? I don't want them to be able to send or receive any pm's unless it comes from admin. (or within their group if possible).

g-force2k2
08-27-2002, 05:47 PM
hmm... lets see... right now im at school so i can't tell you where to find the coding in the private.php

but for allowing usergroups to send pms only to certain usergroups is pretty easy to do i believe... i will set something up for you when i get home in a little... regards...

g-force2k2

Rose
08-27-2002, 06:22 PM
Thanks, G-Force. I'll pm you my IM info if you want to chat. Otherwise, I will anxiously await here. ;)

g-force2k2
08-27-2002, 06:47 PM
okay whatever is cool... shouldn't be hard at all... just installing my 2.2.7 and i'll do the test on that ;) regards...

g-force2k2

g-force2k2
08-27-2002, 07:36 PM
find ::

if (!$touserinfo['receivepm'] or !$touserinfo['canusepm']) {
eval("standarderror(\"".gettemplate("error_pmrecipturnedoff")."\");");
exit;
}

under it add:

if(($touserinfo[usergroupid] != $bbuserinfo[usergroupid]) OR ($bbuserinfo[usergroupid] != 6)) {
eval("standarderror(\"".gettemplate("error_pmrestricted")."\");");
exit;
}

that should do the trick :) it allows Administrators to pm anyone and allows only certain usergroups to pm another user in that same usergroup ;) thats all... don't forget to make a new template call it ::

error_pmrestricted

and put whatever info you want in the template (error-wise) regards :)

oh and one more thing... make sure to disable pming to buddies ;p or you could make a similiar code when adding buddies... else they can foward messages and such... to disable simply in the usergroup set max pm to forward and max users to pm at 0...

g-force2k2

Rose
08-27-2002, 07:43 PM
Thanks, G-Force! I'll try it right now. Um, don't mean to be a dunce, though - and I assume private.php is the file I need - but.....what is the file to make teh above changes to? Just so I don't assume. ;)

Rose
08-27-2002, 07:54 PM
Okay, I've made the change. :) But now as administrator, I can't pm outside my own group. :( I just need it set for one usergroup, not all of them. Is this possible, or a pain? :s


edited to add This fix seems to only work within the usergroup, I don't seem to be able to define which usergruops I want to restrict.

g-force2k2
08-27-2002, 09:58 PM
eh? Administrators can't send pms? or am i wrong? maybe i made a mistake in my coding... :p i will test it and look into it... do you want all usergroups restricted though? regards...

g-force2k2

Rose
08-27-2002, 10:16 PM
Originally posted by g-force2k2
eh? Administrators can't send pms? or am i wrong? maybe i made a mistake in my coding... :p i will test it and look into it... do you want all usergroups restricted though? regards...

g-force2k2


Nope, not all usergruops. There's just one I want restricted. And nope, if a user sets pm's to NO or the usergroup properties are set to "no" for pm's, an admin cannot pm them.

I thought there was a pm feature in the admin cp that would work, but tehre's not one there. *heh*

g-force2k2
08-27-2002, 10:49 PM
okay can you give me that usergroup that you want restricted? thanks in advance... regards...

g-force2k2

Rose
08-27-2002, 11:00 PM
It's Usergroup ID 10.

g-force2k2
08-28-2002, 03:09 AM
if($bbuserinfo[usergroupid] == 10) {
if($touserinfo[usergroupid] != 10) {
eval("standarderror(\"".gettemplate('error_pmrestricted')."\");");
exit;
}
}

g-force2k2

Rose
08-28-2002, 03:26 PM
G-Force

I think that's a great start! So far, here's what happens:

No one can send a pm to anyone in usergroup 10. This is good.
Members in Usergroup 10 still get their messages (the pop up pops up, anyway) - This is good.
Here's what's bad - the member does not have access to the private messages. The pop up works, but once they try to get into the pm box it simply gives them the restricted access error. This also doesn't show the pm info on the forum home for the members in usergroup 10.

g-force2k2
08-28-2002, 03:33 PM
hmm... okay i will look into Rose sorry for the trouble :p regards...

g-force2k2

Rose
08-28-2002, 03:46 PM
no sorries. ;) Thanks for helping me out on such quick response! :D

I'm online if you need to im chat.


Rose

Rose
08-29-2002, 03:34 PM
*blushes* Politely bumps. *blushes*

g-force2k2
08-29-2002, 08:17 PM
if($bbuserinfo[usergroupid] == 10) {
if($touserinfo[usergroupid] != 10) {
eval("standarderror(\"".gettemplate('error_pmrestricted')."\");");
exit;
}
}
if(($bbuserinfo[usergroupid] != 10 OR $bbuserinfo[usergroupid] == 6) AND ($touserinfo[usergroupid] == 10)) {
eval("standarderror(\"".gettemplate('error_pmrestricted')."\");");
exit;
}

modified :) regards...

g-force2k2

Rose
08-29-2002, 09:08 PM
Thank you, G-Force.

But that's not working, either. Administrators cannot send usergroup 10 pm's. I get the "they have chosen not to accept pm's or the administrator ...blah".

Also, as a member of usergroup 10, I cannot access the pm's, but I can see new ones in the user cp. However I can't clikc on "private messages" in the usercp and the $pminfo doesn't show up on the forumhome.

:( Maybe this just isn't possible. :(

Scott MacVicar
08-29-2002, 09:26 PM
Can you try and describe it all in one post :)

It sounds like you want people only to recieve pms from people in the same usergroup unless they are admins and in that case they can send to all?

Correct me if im wrong though :)

g-force2k2
08-30-2002, 12:04 AM
if($bbuserinfo[usergroupid] == 10) {
if($touserinfo[usergroupid] != 10) {
eval("standarderror(\"".gettemplate('error_pmrestricted')."\");");
exit;
}
}
if(($bbuserinfo[usergroupid] != 10 OR $bbuserinfo[usergroupid] != 6) AND ($touserinfo[usergroupid] == 10)) {
eval("standarderror(\"".gettemplate('error_pmrestricted')."\");");
exit;
}

modified again... sorry i made a math error i meat not equal but i said equal... and i don't see how that would effect the $pminfo from showing i could be wrong though...

PPN :: Rose wants a hack where usergroupid 10 is restricted to use the pms unless to usergroupid 10 and no one can send them pms unless its an admin... i though my code was okay :p but i didnt' test it x_X regards...

g-force2k2

Rose
08-30-2002, 12:24 AM
PPN - G-force is correct. I want to restrict Usergroup 10 to only received pm's from other members in usergroup 10. No one else (admin would be nice, but not necessary).

G-Force - still the same problem - usergroup10 can see their new pm's in the user cp, but not access anything.

g-force2k2
08-30-2002, 12:31 AM
okay thats it >_O im breaking it out on my forum now :p please excuse me... be back shortly :p regards...

oh btw that politely bumps was funny :)

okay one last time... open private.php

find:

if (!$touserinfo['receivepm'] or !$touserinfo['canusepm']) {

above it add:

$info = $DB_site->query_first("SELECT usergroupid FROM user WHERE userid='$touserinfo[userid]'");
if($bbuserinfo[usergroupid] == 10) {
if($info[usergroupid] != 10) {
eval("standarderror(\"".gettemplate('error_pmrestricted')."\");");
exit;
}
}
if($bbuserinfo[usergroupid] != 10) {
if($info[usergroupid] == 10 AND $bbuserinfo[usergroupid] != 6) {
eval("standarderror(\"".gettemplate('error_pmrestricted')."\");");
exit;
}
}

Hopefull that'll do the trick ;) regards.... sorry for the long time it took x_X

g-force2k2

Scott MacVicar
08-30-2002, 01:29 AM
Could always try

if(($bbuserinfo['usergroupid'] == 10 and $touserinfo['usergroupid'] != 10) or ($touserinfo['usergroupid'] == 10 and $bbuserinfo['usergroupid'] != 6)) {
eval("standarderror(\"".gettemplate('error_pmrestricted')."\");");
exit;
}

:)

Rose
08-30-2002, 01:33 AM
I'm still getting the "usergroup 10" members "do not have permission to acces this page" error. :(

edited to say: abovemessage for g-force


will try ppn's now.

Rose
08-30-2002, 01:39 AM
And samething with ppn's too. Maybe something else needs to be done, or I'm getting the wrong editing?

I've got no access in usergrup 10, but I can see new messages in the user cp.

g-force2k2
08-30-2002, 01:56 AM
Rose did you place it under the code i gave you? because the first place was incorrect on the first page... regards...

btw PPN i was trying to make it as simple as possible... how could i have just used the $touserinfo query to select the usergroup? because it doesn't select the usergroup... wouldn't it have to be a LEFT JOIN? regards...

g-force2k2

Rose
08-30-2002, 02:02 AM
Originally posted by g-force2k2
Rose did you place it under the code i gave you? because the first place was incorrect on the first page... regards...

btw PPN i was trying to make it as simple as possible... how could i have just used the $touserinfo query to select the usergroup? because it doesn't select the usergroup... wouldn't it have to be a LEFT JOIN? regards...

g-force2k2


G-Force, I took all modifications out fromt his thread and simply did what you said in your most recent modification post - placing the code above the "if (!$touserinfo['receivepm'] or !$touserinfo['canusepm']) {" Did Imisunderstand somewhere?

I will be back tomorrow. :) And thanks again for helping!!!

g-force2k2
08-30-2002, 02:10 AM
k... i dunno though... cause i tested it and it seemed to work fine for me :p but we'll just do more testing tomarrow i guess :) regards...

g-force2k2

Rose
08-30-2002, 02:45 AM
Sounds great, G-Force. ANd I just added you to my aim, soyou know. :D

g-force2k2
08-30-2002, 02:48 AM
okay Rose i'll see if i can catch you tomarrow then... btw... did you remove the first codes that i had given you? maybe thats causing the issues? regards...

g-force2k2

Rose
08-30-2002, 02:54 AM
As far as I know I removed all codes in this thread except the most recent of yours. Post #22. I actually tried it with the first post and #22, but that didn't work so I tried just #22. But I may be tired so I can recheck tomorrow. Catch you then!

Scott MacVicar
08-30-2002, 06:49 AM
You have enabled pm's for that usergroup right?

I also tested mine and it worked fine. Send your private.php file to scott.macvicar@vbulletin.org and I will look over it for you cause I'm very confused to why this doesn't work.

Rose
08-30-2002, 01:41 PM
:$ Thank you both very much for your help. I must have been too tired last night, but all is working now, I've tested and retested. I hope I've not wasted any time for either of you. Usergroup 10 can now successfully access pm's, as well as send and receive pm's from other members in the same usergroup.

Members outside the usergroup cannot send pm's into the "10" group, and the "10" group cannot send pm's to other members in other groups.

This is also restricted to admin as they can't pm usergroup 10, but that is quite alright. This is working exactly as I had hoped for.

Thanks again, G-Force for all your help and patience! And thanks, PPN, for taking time to help, as well. You pointed something major out that I won't embarress myself to tell. ;) But thanks.

:D