Not Solved Predefined Variables?
#11
Not Solved
Oh jesus of course! I think I even read this somewhere Blush
Ok so this seems to be working!

Here is the function so far:
function anon_posting(&$insert_data)
{	
	global $mybb, $realuser;
    if($insert_data->post_insert_data['fid'] == 3)
    {
		// First of all let's look up the real user name
		$realuser = $mybb->user['uid'];

        $insert_data->post_insert_data['uid'] = "2";
        $insert_data->post_insert_data['username'] = "Anonymous";
		$insert_data->post_insert_data['origuserid'] = $realuser;
    }
    
    return $insert_data;
}
I have added a column to the mybb_posts table called "origuserid" to store the original userid of the person posting in the anonymous forum. That way (in cases of abuse) the admin can retrieve the original username from the post.
I looked at lines 813-830 of ./inc/datahandlers/post.php which is this:
// Insert the post.
			$this->post_insert_data = array(
				"tid" => intval($post['tid']),
				"replyto" => intval($post['replyto']),
				"fid" => intval($post['fid']),
				"subject" => $db->escape_string($post['subject']),
				"icon" => intval($post['icon']),
				"uid" => $post['uid'],
				"username" => $db->escape_string($post['username']),
				"dateline" => $post['dateline'],
				"message" => $db->escape_string($post['message']),
				"ipaddress" => $db->escape_string($post['ipaddress']),
				"longipaddress" => intval(ip2long($post['ipaddress'])),
				"includesig" => $post['options']['signature'],
				"smilieoff" => $post['options']['disablesmilies'],
				"visible" => $visible,
				"posthash" => $db->escape_string($post['posthash'])
			);
So I figured in my function I just add a value to the array, like this:
$insert_data->post_insert_data['origuserid'] = $realuser;
And that actually seems to work. Smile
So what I'm gonna try to figure out now is how to create an admin front-end to let the admin choose in the admin CP, which forum should be anonymous and which user is the anonymous user.
Is there any documentation on making modules for the Admin CP or something of the sort?
Reply
#12
Not Solved
You could try this: http://www.mybbcentral.com/thread-76.html

That's Labrocca's tutorial on making a plugin. It doesn't go into making an admin module as such, but it explains how to add settings to the ACP, which is probably what you're after with your plugin.
Reply
#13
Not Solved
Great, thanks! Looks promising. Smile I'll check this out when I get home.
This community is great and very helpful, I'm really impressed!!!
Reply
#14
Not Solved
Ok I have the admin area sorted now. Smile And thanks for the help so far guys, very much appreciated!

I'm at my next "wtf?" moment though. Lol.

I am writing a function that checks if the person viewing a post is a supermod or admin. If they are, then the function makes a little button that let's the admin/supermod discover the real username of the anonymous poster. The button would appear next to the "IP Address: Logged" bit.
So first I gotta figure out a way to manipulate templates. I have this so far, which is not working lol.

$plugins->add_hook("postbit", "anon_retrieve");

function anon_retrieve($post) 
{
	
	if($mybb->usergroup['isadmin'] == 1 || $mybb->usergroup['issupermod'] == 1) 
	{
		include MYBB_ROOT . '/inc/adminfunctions_templates.php';
		$find     = '{$post[\'iplogged\']}';
		$replace  = '{$post[\'iplogged\']} Bla';
		find_replace_templatesets('postbit', $find, $replace, 1);
		find_replace_templatesets('postbit_classic', $find, $replace, 1);
		return $post;
	}
}
Could a kind soul tell me what I'm doing wrong?
Yes, the "Bla" is intended - just for testing.
Reply
#15
Not Solved
First of all, I would do:

if($mybb->usergroup['cancp'] == 1 || $mybb->usergroup['issupermod'])

'isadmin' isn't really a suitable check - 'cancp' checks if they have access to the ACP, and therefore, an Administrator.

Second, the right thing to do with templates, well I've found it to be, this:

find_replace_templatesets('showthread', '#'.preg_quote('{what you're looking for}').'#', '{What you want to replace it with}');

Doing it like this will change the template. Adding the '1' at the end will remove the changes.
Reply
#16
Not Solved
This user has been denied support. This user has been denied support.
did this ever get released?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)