MyBB Community Forums

Full Version: Board Message Plugin wont update.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey there, I've made myself a little custom admin mod for MyBB which does a few little extra things I need which arn't in the current version and I wanted to be able to edit the settings of Musicalmidget's Board Message plugin mod from it too.

I found the showboardmsg & boardmsg values under the settings table in the database but whenever I update them it doesn't take effect on the board.
It works fine from the normal MyBB admin console so I'm guessing it does something else I'm not aware of.

Any ideas on what I'm missing?

Thanks in advance,

Andy.

---
MyBB version: 1.2.2
MySQL 4.1.21
PHP version: 4.4.4
http://mods.mybboard.com/view.php?did=6
Can i see the plugin file you have updated of course with the modifications you have done? Big Grin
Oh sorry, I should have explained better, its a completly detached mod which just edits the database as I want it to, not a plugin mod.

I'm updating the showboardmsg & boardmsg values the Board Message Plugin adds to the DB.
Alright.. but what i asked in another word is to show me your codes please because i need to check them see if any error in some place.
I already know my code works because when I look at the database the values have changed, thats not the problem.
The problem is the board doesn't seem to notice the updates so I must be missing something else.

The plugin code is this:

<?php
/**
 * Board Message Plugin for MyBB
 * Copyright © 2005 MyBB Mods
 * URL: http://mods.mybboard.com/
 * 
 * By: Musicalmidget
 * Website: http://www.musicalmidget.com/
 */

$plugins->add_hook('global_start', 'boardmsg');

function boardmsg_info()
{
	return array(
		'name'			=> 'Board Message',
		'description'	=> 'Allows administrators to add a global message to the forums header from the settings administration.',
		'website'		=> 'http://mods.mybboard.com/',
		'author'		=> 'Musicalmidget',
		'authorsite'	=> 'http://www.musicalmidget.com/',
		'version'		=> '1.0.1',
	);
}

function boardmsg_activate()
{
	require MYBB_ROOT.'/inc/adminfunctions_templates.php';
	global $db;
	
	$boardmsg_group = array(
		'name'			=> 'boardmsg',
		'title'			=> 'Board Message Settings',
		'description'	=> 'Settings for the Board Message plugin.',
		'disporder'		=> 3,
		'isdefault'		=> 'no',
	);
	
	$db->insert_query(TABLE_PREFIX.'settinggroups', $boardmsg_group);
	$gid = $db->insert_id();
	
	$boardmsg_setting_1 = array(
		'name'			=> 'showboardmsg',
		'title'			=> 'Enable Board Message',
		'description'	=> 'Display the board message in the forum header?',
		'optionscode'	=> 'onoff',
		'value'			=> 'on',
		'disporder'		=> 1,
		'gid'			=> intval($gid),
	);
	
	$boardmsg_setting_2 = array(
		'name'			=> 'boardmsg',
		'title'			=> 'Board Message',
		'description'	=> 'Enter the message you would like to be displayed in the forum header when the board message is enabled.',
		'optionscode'	=> 'textarea',
		'value'			=> 'This is a global board message which administrators can modify from the \"Board Message Settings\" category of the Settings area in the Admin CP.',
		'disporder'		=> 2,
		'gid'			=> intval($gid),
	);
	
	$db->insert_query(TABLE_PREFIX.'settings', $boardmsg_setting_1);
	$db->insert_query(TABLE_PREFIX.'settings', $boardmsg_setting_2);
	
	$boardmsg_template = array(
		"title"		=> 'global_boardmsg',
		"template"	=> "<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\" class=\"tborder\">
<tbody>
<tr>
<td class=\"trow1\">\$boardmessage</td>
</tr>
</tbody>
</table>
<br />",
		"sid"		=> -1,
		"version"	=> 120,
		"status"	=> '',
		"dateline"	=> 1134703642,
	);
	
	$db->insert_query(TABLE_PREFIX.'templates', $boardmsg_template);
	find_replace_templatesets('header', '#<navigation>#', "{\$boardmsg}\n\t\t\t<navigation>");
}

function boardmsg_deactivate()
{
	require MYBB_ROOT.'/inc/adminfunctions_templates.php';
	global $db;
	
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('showboardmsg', 'boardmsg')");
	$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='boardmsg'");
	$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='global_boardmsg'");
	
	find_replace_templatesets('header', '#{\$boardmsg}\n\t\t\t#', '', 0);
}

function boardmsg()
{
	global $mybb, $templates, $boardmsg;
	
	if($mybb->settings['showboardmsg'] != 'off')
	{
		$boardmessage = $mybb->settings['boardmsg'];
		eval("\$boardmsg = \"".$templates->get('global_boardmsg')."\";");
	}
}
?>

I can't see anything in there that stands out, perhaps its something the admin page itself does? :eek:
I read your 1st post again.. you have to remember something.. you CAN'T only modify the setting from the db by editing it manually through phpmyadmin.. because the settings are cached which means mybb uses those settings in the cache and if you don't update the settings cache it is like you haven't changed anything.

I asked for your codes.. not the board message plugin file Toungue cause i know its codes.. i want to see yours.