Need help with plugin to allow only one thread in selected forums
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Need help with plugin to allow only one thread in selected forums
Okay, firstly the hook newthread_do_newthread_end is probably too late for your purposes.  The check should be done before the thread is inserted, not after.
Try hooking into datahandler_post_validate_thread and perform the check there.
Obviously, your function will need to be changed to reflect this new hook.

You seem to have some idea of what's going on, but you have some issues in this piece of code:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
			if (in_array($forum,$limit))			
		
		$query = $db->simple_select("threads", "uid");		
		$uid = explode(",", $db->threads['uid']);
		$forum = $new_thread['fid'];	

		if (in_array($forum,$uid))			

		{
			exit("You cannot post more than one thread in this forum");
		}				
        
		elseif (empty($new_thread['uid']))
		return;

There's a number of problems, including your lack of braces around the if block, there is no $db->threads['uid'] variable (check MyBB code to see how it performs queries with the $db->fetch_array function), and if (in_array($forum,$uid)) doesn't really make sense (why check if a forum is in a uid?).

Some other issues - be more consistent with the following two lines:

PHP Code:
	
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='limitthreadsinforums'");
	$db->delete_query("settinggroups","name='limitonethreadinforum'");


Also, rebuildsettings() should be rebuild_settings().  Your compatibility should probably be set to 14* and higher, since your code won't work on MyBb 1.2.

Hope that helps.


My Blog
07-06-2010 10:29 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
RE: Need help with plugin to allow only one thread in selected forums - ZiNgA BuRgA - 07-06-2010 10:29 AM

 Standard Tools
Forum Jump: