MyBB Community Forums

Full Version: POST COUNT! NOT FOR PREMIUM! URGENT!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So many people are upgrading theirselfs on my forum today, and I got a special post count forum requirements on some forums, now I want the upgraded ones to be able to skip this feature, and have 0 posts and enter the forum. The GID is 9

Please help!

<?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("admin_formcontainer_output_row", "ForumsRequirements_admin");
$plugins->add_hook("admin_forum_management_add_commit", "ForumsRequirements_save");
$plugins->add_hook("admin_forum_management_edit_commit", "ForumsRequirements_save");
$plugins->add_hook("forumdisplay_end", "ForumsRequirements_forum");
$plugins->add_hook("showthread_end", "ForumsRequirements_forum");
$plugins->add_hook("archive_start", "ForumsRequirements_archive");


function ForumsRequirements_info()
{
	return array(
		"name" => "Forums Requirements",
		"description" => "A minimum post count requirement to access a forums.",
		"website" => "mailto:[email protected]",
		"author" => "Edson Ordaz",
		"authorsite" => "mailto:[email protected]",
		"version" => "1.0",
		"compatibility" => "16*",
		"guid" => "1501065c1ac040fd60db0eb92c9cc8fd"
	);
}

function ForumsRequirements_activate()
{

	global $db;
	$ForumsRequirements = array(
		"gid"			=> "NULL",
		"name"			=> "ForumsRequirements",
		"title" 		=> "Forums Requirements",
		"description"	=> "Configura plugin para mostrar mensaje de error",
		"disporder"		=> "0",
		"isdefault"		=> "no",
	);
	$db->insert_query("settinggroups", $ForumsRequirements);
	$gid = $db->insert_id();
	
	$ForumsRequirements_1 = array(
		"sid"			=> "NULL",
		"name"			=> "ForumsRequirements_title",
		"title"			=> "Titulo de Error",
		"description"	=> "Ingresa el titulo a mostrar en el error",
		"optionscode"	=> "text",
		"value"			=> "",
		"disporder"		=> "1",
		"gid"			=> intval($gid),
	);
	
	$ForumsRequirements_2 = array(
		"sid"			=> "NULL",
		"name"			=> "ForumsRequirements_body",
		"title"			=> "Mensaje de Error",
		"description"	=> "Ingresa el mensaje a mostrar en el error",
		"optionscode"	=> "textarea",
		"value"			=> "",
		"disporder"		=> "2",
		"gid"			=> intval($gid),
	);
	
	$ForumsRequirements_3 = array(
		"sid"			=> "NULL",
		"name"			=> "ForumsRequirements_archive",
		"title"			=> "Mensaje de Error en el Archivo",
		"description"	=> "Ingresa el mensaje a mostrar en el error si intentan ver en el archivo el foro",
		"optionscode"	=> "textarea",
		"value"			=> "",
		"disporder"		=> "3",
		"gid"			=> intval($gid),
	);
	$db->insert_query("settings", $ForumsRequirements_1);
	$db->insert_query("settings", $ForumsRequirements_2);
	$db->insert_query("settings", $ForumsRequirements_3);
	$db->query("ALTER TABLE ".TABLE_PREFIX."forums ADD ForumsRequirements INT(4) NOT NULL");
}

function ForumsRequirements_deactivate()
{

	global $db, $cache;
	$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='ForumsRequirements'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='ForumsRequirements_title'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='ForumsRequirements_body'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='ForumsRequirements_archive'");
	$db->query("ALTER TABLE ".TABLE_PREFIX."forums DROP ForumsRequirements");

	$cache->update_forums();
}


function ForumsRequirements_save()
{

	global $db, $mybb, $cache;

	$ForumsRequirements_update = array(
		'ForumsRequirements' => abs(floatval($mybb->input['ForumsRequirements']))
	);
	$db->update_query("forums", $ForumsRequirements_update, "fid='".intval($mybb->input['fid'])."'");

	$cache->update_forums();
}



function ForumsRequirements_admin(&$formvars)
{

	global $mybb, $forum_data, $form, $form_container, $cache, $lang;

	$ForumsRequirements = $cache->cache['forums'][$mybb->input['fid']]['ForumsRequirements'];

	if($formvars['title'] === $lang->forum_link && $lang->forum_link)
	{

		$form_container->output_row("Forums Requirements", "Post minimos requeridos para tener accesso a este foro", $form->generate_text_box('ForumsRequirements', $ForumsRequirements, array('id' => 'ForumsRequirements')), 'ForumsRequirements');

	}


}

function ForumsRequirements_forum()
{

	global $mybb;

	global $forum_cache, $fid, $forum;
	$title_error = $mybb->settings['ForumsRequirements_title'];
	$body_error = $mybb->settings['ForumsRequirements_body'];
	if(intval($mybb->user['postnum']) < $forum_cache[$fid]['ForumsRequirements'])
	{

		$title = $title_error;
		$message = $body_error; 
		$message = preg_replace("!\[ForumsRequirements\]!Us", $forum_cache[$fid]['ForumsRequirements'], $message);
		error($message,$title);

	}

}

function ForumsRequirements_archive()
{

	global $mybb, $forum;
	$body_archive = $mybb->settings['ForumsRequirements_archive'];
	if(intval($mybb->user['postnum']) < $forum['ForumsRequirements'])
	{

		$body_archive = preg_replace("!\[ForumsRequirements\]!Us", $forum['ForumsRequirements'], $body_archive);
		archive_error($body_archive);

	}

}

?>

Please? Anyone?