Need help with plugin to allow only one thread in selected forums
mark-in-dallas Offline
Junior Member
**
Posts: 5
Joined: Jul 2010
Post: #1
Need help with plugin to allow only one thread in selected forums
I am trying to make a plugin to prevent users from posting more than one thread in selected forums.  This should be pretty simple, but I'm not a very experienced programmer, and just can't seem get it right.  I think I'm pretty close, but just not quite there.

Any help would be appreciated.  Here's what I have:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php

if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

$plugins->add_hook("newthread_do_newthread_end", "limitthreadsinforums_addthread");

function limitthreadsinforums_info()
{
    return array(
        "name"            => "Limit to one thread in selected Forums",
        "description"    => "Limits users from posting more than one thread in selected forums!",
        "website"        => "http://websitesdallas.com",
        "author"        => "mark-in-dallas",
        "authorsite"    => "http://websitesdallas.com",
        "version"        => "1.0",
        "guid"            => "",
        "compatibility" => "1*",
    );
}

function limitthreadsinforums_activate()
{
	global $db;
	
	$limitthreadsinforums_group = array(
		"name"			=> "limitonethreadinforums",
		"title"			=> "Limit to one thread post in specified forums",
		"description"	=> "Limits users from posting more than one thread in specified forums",
		"disporder"		=> "2",
		"isdefault"		=> "no",
	);
	
	$db->insert_query("settinggroups", $limitthreadsinforums_group);
	$gid = $db->insert_id();
	
	$new_setting = array(
		'name'			=> 'limitthreadsinforums',
		'title'			=> 'Limit users to posting only one thread in specified forums.  Separate FIDs with commas',
		'description'	=> 'Forums to limit',
		'optionscode'	=> 'text',
		'value'			=> '',
		'disporder'		=> '1',
		'gid'			=> intval($gid)
	);

	$db->insert_query('settings', $new_setting);
	
	rebuildsettings();
}

function limitthreadsinforums_deactivate()
{
	global $db;
	

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

	
	rebuildsettings();
}

function limitthreadsinforums_addthread()
{
        global $new_thread, $mybb, $db, $fid;
		
        if (empty($new_thread['fid']))
			return;	

		if (empty($mybb->settings['fid']))
			return;		

		$limit = explode(",", $mybb->settings['fid']);
		$forum = $new_thread['fid'];

			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;

			
	
}		

?>

(This post was last modified: 07-06-2010 09:52 AM by mark-in-dallas.)
07-06-2010 09:52 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
Need help with plugin to allow only one thread in selected forums - mark-in-dallas - 07-06-2010 09:52 AM

 Standard Tools
Forum Jump: