FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » Private Forums Hack
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
Private Forums Hack [message #1028] Tue, 19 March 2002 22:58 Go to next message
Luterin is currently offline  Luterin   Sweden
Messages: 17
Registered: March 2002
Location: Malmö/Sweden
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user

This is just something I did real quick today, and it's getting real late, but I'll post the changes I made here, and if it's unclear what I've done to many, just ask and I'll clarify.

In MySQL do:
alter table fud_forum add private enum('Y','N') NOT NULL DEFAULT 'N';
alter table fud_users add private_access enum('Y','N') NOT NULL DEFAULT 'N';

Now for codechanges...

* thread.php:
* Add this line after the line "cache_buster();"

if ($frm->private=='Y' && !($usr->private_access=='Y')) error_dialog('This is a Private Forum', 'This is a Private Forum, only invited users may view these forums.' , '');

* admuser.php:
* Add this code before "case 'block':"
case 'private':
if ( $usr->private_access == 'Y' )
$usr->clear_private_access();
else
$usr->set_private_access();
header("Location: admuser.php?".$_RSID."&usr_login=".urlencode($usr->lo gin));
exit();
break;
* Add this line after "<tr bgcolor="#f1f1f1"><td>Blocked: ..... " at the end of the form
<tr bgcolor="#f1f1f1"><td>Private Access:</td></td><?php echo $usr->private_access; ?> &lt;<a href="admuser.php?act=private&
usr_id=<?php echo $usr->id.'&'.$_RSID; ?>">Toggle</a>&gt;</td></tr>

* users_adm.inc:
* Add this code before "function block_user()"
function set_private_access()
{
Q("UPDATE fud_users SET private_access='Y' where id=".$this->id);
}

function clear_private_access()
{
Q("UPDATE fud_users SET private_access='N' where id=".$this->id);
}

* admforum.php:
* Add this code before the submit button at the end of the form
<tr bgcolor="#bff8ff">
<td>Private</td>
<td><?php draw_select('frm_private', "No\nYes", "N\nY", empty($frm_private)?'':$frm_private); ?></td>
</tr>

* forum_adm.inc:
* Add this line at the end of the SQL statement in function add()
'".$this->private."'
* Add this line at the end of the SQL statement in function sync()
private='".YN($this->private)."'

* users.inc:
* Add this among the other var definitions in the beginning
var $private_access=NULL;

* forum.inc
* Add this among the other var definitions in the beginning
var $private=NULL;


After doing this, if you understood what I tried to explain, you will have a private flag available on all forums and users.

Set it on a forum to make it usable only by users with the private_access flag set.

This is not a feature supported by Advanced Internet Designs Inc., it's just something I cooked up in a few hours since I lacked that feature and wanted it for my own use, but since others also have asked for it I wanted to share what I had done.

Feel free to ask if you have any questions.
Re: Private Forums Hack [message #1038 is a reply to message #1028] Wed, 20 March 2002 07:34 Go to previous messageGo to next message
Luterin is currently offline  Luterin   Sweden
Messages: 17
Registered: March 2002
Location: Malmö/Sweden
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user

Found a little bug where people could "sneak in" and read messages in a private
area,

* msg.php
* Before the line which checks if the user is registerd, add this line.
* The line is "if (!isset($usr) && $frm->anon_viewing=='N') ..........."

if ($frm->private=='Y' && !($usr->private_access=='Y')) error_dialog('This is a Private Forum', 'This is a Private Forum, only invited users may view these forums.' , '');
Re: Private Forums Hack [message #1039 is a reply to message #1028] Wed, 20 March 2002 07:50 Go to previous messageGo to next message
Luterin is currently offline  Luterin   Sweden
Messages: 17
Registered: March 2002
Location: Malmö/Sweden
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user

Found another little bug.

* tree.php
* Before the line which checks if the user is registerd, add this line.
* The line is "if (!isset($usr) && $frm->anon_viewing=='N') ..........."

if ($frm->private=='Y' && !($usr->private_access=='Y')) error_dialog('This is a Private Forum', 'This is a Private Forum, only invited users may view these forums.' , '');
Re: Private Forums Hack [message #1043 is a reply to message #1028] Wed, 20 March 2002 08:52 Go to previous message
Luterin is currently offline  Luterin   Sweden
Messages: 17
Registered: March 2002
Location: Malmö/Sweden
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
Found another little bug.

* selmsg.php
* After this line:
* $anon = ( !isset($usr) ) ? " fud_forum.anon_viewing!='N' AND " : '';

$private = ( $usr->private_access!='Y' ) ? " fud_forum.private!='Y' AND " : '';

* change line:
* '.$anon.'
'.$anon.$private.'

* NOTE: There are 2 copies of that last line close to eachother, change both!

*** Fixed typo inside file name
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: scalable fonts -- header_1.inc hack
Next Topic: Extra FUDCode tags
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Oct 20 06:49:29 EDT 2017

Total time taken to generate the page: 0.00608 seconds