MyBB Community Forums

Full Version: Warn System
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hello guys =) I was edit some plugin whitch show person who was warned in postbit, could someone cheak my code ? I would like to know if everythink here is fine.

<?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("postbit", "warned_postbit");


function warned_info()
{
	return array(
		"name"			=> "Warn System",
		"description"	=> "Post a message in post than user has been warned.",
		"website"		=> "*",
		"author"		=> "metonator",
		"authorsite"	=> "*",
		"version"		=> "1.0",
		'guid'        => '*',
		'compatibility'    => '14*, 16*'
	);
}

function warned_activate()
{
		require MYBB_ROOT.'/inc/adminfunctions_templates.php';
	find_replace_templatesets("postbit", '#'.preg_quote('{$post[\'message\']}').'#', '{$post[\'message\']}<br /><br /><br />{$post[\'warned\']}');
	find_replace_templatesets("postbit_classic", '#'.preg_quote('{$post[\'message\']}').'#', '{$post[\'message\']}<br /><br /><br />{$post[\'warned\']}');
}

function warned_deactivate()
{
	require MYBB_ROOT.'/inc/adminfunctions_templates.php';
	
	find_replace_templatesets("postbit_classic", '#'.preg_quote('{$post[\'warned\']}').'#', '', 0);
	find_replace_templatesets("postbit", '#'.preg_quote('{$post[\'warned\']}').'#', '', 0);
}


function warned_postbit(&$post)
{
global $db;

			$query = $db->simple_select("warnings", "*", "pid='{$post['pid']}'");
      $result = $db->fetch_field($query, "pid");

if($result)
{
	global $mybb, $theme;
	
	$post['warned'] = "<div style=\"border: 1px solid red; background: #400; font-weight: bold;  padding: 2px;\"><img src=\"{$theme['imgdir']}/error.gif\" alt=\"Post User has been warned\" />Post User has been warned.</div>";
}
}
?>


please let me know
Change this: function warned_postbit($post)
to this: function warned_postbit(&$post)
and that all ? I made it correct?