MyBB Community Forums

Full Version: Hide post or warning
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i am using this warning plugin https://community.mybb.com/mods.php?action=view&pid=845
its showing red massage. but i want to hide the text and show only the red massage .
[Image: 217731dfef8954d1e3e1c668edc50793.png]

i fix this myself. by using this code

<?php
if (!defined('IN_MYBB')) {
	die('This file cannot be accessed directly.');
}

function postwarningreason_info(){
	global $lang;
	$lang->load('postwarningreason');
	
	return array(
		'name'			=> $lang->postwarningreason,
		'description'	=> $lang->postwarningreason_desc,
		'website'		=> '',
		'author'		=> 'arcle',
		'authorsite'	=> '',
		'version'		=> '1.1',
		'compatibility'	=> '18*',
		'codename'		=> 'postwarningreason'
	);
}

function postwarningreason_install(){
	global $db;
	$db->write_query("CREATE TABLE `".TABLE_PREFIX."postwarningreason` ( `id` INT NOT NULL AUTO_INCREMENT , `host` TEXT NOT NULL , PRIMARY KEY (`id`)) ENGINE = MyISAM");
	$id = $db->insert_query('settinggroups', array(
		'name' => 'postwarningreason',
		'title' => 'Post Warning Reason',
		'description' => '',
		'isdefault' => '0'
	));
	$db->insert_query('settings', array(
		'name' => 'postwarningreason_template',
		'title' => 'Template',
		'description' => 'Variables: {reason}, {moderator_id}, {moderator_name}, {date}',
		'optionscode' => 'textarea',
		'gid' => $id,
		'value' => '<div style="color: white; background-color:red; display: inline-block;">User has been warned for this post. Reason: {reason}</div>',
		'disporder' => 1
	));
	rebuild_settings();
}

function postwarningreason_uninstall(){
	global $db;
	$db->drop_table('postwarningreason');
	$db->delete_query('settinggroups', "name='postwarningreason'");
	$db->delete_query('settings', "name='postwarningreason_template'");
	rebuild_settings();
}

function postwarningreason_is_installed(){
	global $db;
	$query = $db->simple_select('settinggroups', 'gid', "name='postwarningreason'");
	$result = $db->fetch_array($query);
	if($result['gid']) return true;
	else return false;
}

$plugins->add_hook('xmlhttp_update_post', 'postwarningreason_search');
$plugins->add_hook('postbit', 'postwarningreason_search');
function postwarningreason_search(&$post){
	global $db, $lang;

	$lang->load('postwarningreason');

	$query = $db->simple_select("warnings", "issuedby, dateline, title", 'revokedby=0 AND pid='.$post['pid'], array(
		"order_by" => 'wid',
		"order_dir" => 'DESC',
		"limit" => 1
	));
	$warnings = $db->fetch_array($query);

	if ($warnings['title']) {
		$query = $db->simple_select('settings', 'value', "name='postwarningreason_template'");
		$text = $db->fetch_array($query);
		$text = $text['value'];
		
		$get_user = get_user($warnings['issuedby']);
		$regular = array(
			'{reason}' => $warnings['title'],
			'{moderator_name}' => $get_user['username'],
			'{moderator_id}' => $warnings['tid'],
			'{date}' => date('Y/m/d, H:i', $warnings['dateline'])
		);

		foreach ($regular as $val => $ex) {
			$text = str_replace($val, $ex, $text);
		}

		$post['message'] = '<div style="color: white; background-color:red; display: inline-block;">' . $text . '</div>';
	}
}

and also add a language file