Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Check if the user made any thread in the forum section using Template Conditionals
Skiilz Offline
Member
***
Posts: 198
Joined: Nov 2010
Post: #9
RE: Check if the user made any thread in the forum section using Template Conditionals
Yes it works but admins/mods can't make it too :/ anyway to edit the plugin to make it check for GID?

PHP 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php

/**
* MyBB Plugin: Limit User Threads in Forums v 1.0
* -------------------------------------------------------------------------------------------
Special thanks to LeX, from mybbcentral.com, because without his help this plugin would not exist!
* -------------------------------------------------------------------------------------------
**/

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_start", "limitthreadsinforums_addthread");

$plugins->add_hook("forumdisplay_thread", "limitthreadsinforums_threadbutton");

function limitthreadsinforums_info()
{
    return array(
        "name"            => "Limit user threads in forums",
        "description"    => "Prevent users from posting more than one thread in certain forums.  ",
        "website"        => "http://community.mybb.com/user-22006.html",
        "author"        => "mark-in-dallas",
        "authorsite"    => "http://community.mybb.com/user-22006.html",
        "version"        => "1.0",
        "guid"            => "59c0f556b72c6ed5999fb583671782be",
        "compatibility" => "14*,16",
    );
}

function limitthreadsinforums_activate()
{
    global $db;
    
    $limitthreadsinforums_group = array(
        "name"            => "limitthreadsinforums",
        "title"            => "Limit user threads in forums",
        "description"    => "Prevent users from posting more than one thread in select forums",
        "disporder"        => "2",
        "isdefault"        => "no",
    );
    
    $db->insert_query("settinggroups", $limitthreadsinforums_group);
    $gid = $db->insert_id();
    
    $new_setting = array(
        'name'            => 'limitthreadsinforums',
        'title'            => 'Prevent users from posting more than one thread in these forums.',
        'description'    => 'Forums to limit by fid # separated by commas',
        'optionscode'    => 'text',
        'value'            => '',
        'disporder'        => '1',
        'gid'            => intval($gid)
    );

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

function limitthreadsinforums_deactivate()
{
    global $db;
    

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

    
    rebuild_settings();
}

function limitthreadsinforums_addthread()
{
	global $fid, $mybb, $db;
	if(!$fid || !$mybb->settings['limitthreadsinforums'] || !$mybb->user['uid'])
	{
		return;
	}               
	$fids = $db->escape_string($mybb->settings['limitthreadsinforums']);
	if(in_array($fid, explode(",", $fids)))
	{
		$count = $db->fetch_field($db->simple_select("threads", "COUNT(*) as threads", "uid='{$mybb->user['uid']}' AND fid='{$fid}'"), "threads");       
		if($count)
		{
			error("You cannot post more than one thread in this forum");
		}  
	}        
}  

function limitthreadsinforums_threadbutton()
{
	global $fid, $mybb, $db, $newthread, $hide;
	if(!$fid || !$mybb->settings['limitthreadsinforums'] || !$mybb->user['uid'])
	{
		return;
	}               
	$hide = false;
	$fids = $db->escape_string($mybb->settings['limitthreadsinforums']);

	if(!$hide)
	{
		if(in_array($fid, explode(",", $fids)))
		{
			$count = $db->fetch_field($db->simple_select("threads", "COUNT(*) as threads", "uid='{$mybb->user['uid']}' AND fid='{$fid}'"), "threads");       
			if($count)
			{
				$hide = true;
				$newthread = "";
			}  
		}  
	}   
}        

?>


[Image: 468x602b.png]
11-23-2010 02:22 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
RE: Check if the user made any thread in the forum section using Template Conditionals - Skiilz - 11-23-2010 02:22 AM

 Standard Tools
Forum Jump: