MyBB Community Forums

Full Version: Admin CP Settings Suggestion
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Just a quick one. The settings panel is fine but I'd (as a modder) would like to someone know when my setting has been activated/deactivated.
As an example. I have three radio buttons. When one of them is selected, it would edit a different template. But at the minute there isn't anyway for me to know what has been edited/changed.

Would it be possible to have something like the plugins manager. We can call a function like "addSettingFunction(setting_title)" in MyBB and then when our setting is changed, it would call this function? Obviously the function would need to be stored somewhere by MyBB but I can't see any other way around it. Otherwise I'm going to have to copy the settings.php file and then change the bits I need which is pretty silly.
well I don't quite understand what you're saying (my fault since I'm not a modder) but I was working on my first mod yesterday and I noticed this code in a lot of the mods:
if(!function_exists("rebuild_settings"))
{
	function rebuild_settings()
	{
		global $db;
		$query = $db->query("SELECT * FROM ".TABLE_PREFIX."settings ORDER BY title ASC");
		while($setting = $db->fetch_array($query))
		{
			$setting['value'] = addslashes($setting['value']);
			$settings .= "\$settings['".$setting['name']."'] = \"".$setting['value']."\";\n";
		}
		$settings = "<?php\n/*********************************\ \n  DO NOT EDIT THIS FILE, PLEASE USE\n  THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?>";
		$file = fopen("./inc/settings.php", "w");
		fwrite($file, $settings);
		fclose($file);
	}
}

they call this at the end of activate and deactivate. Is this doing what you mean in regards to the settings.php?
No I think decswxaqz means that he wants to know if a certain setting has been updated in the Admin CP and use that in another script. But the part I don't understand is why can't you figure out what template to use when you run the other script, and find the settings and decide then?

I think that plugin hooks will be introduced in a later version of the Admin CP, but for now I think the only way would be to add your own function to call when the settings are updated

Find
			$db->query("UPDATE ".TABLE_PREFIX."settings SET value='$val' WHERE sid='$key'");
in admin/settings.php and add the following below it:
if(function_exists('updatedSetting')) {
updatedSetting($key);
}
And then you can add that function in the integration.php
function updatedSetting($sid) {
global $db;
// Do whatever here
}

Maybe that's what you're looking for?
Of course I make the modification to my own forum but I would need the feature to be in the default install of MyBB for it to work.

The thing I was thinking about was a mod for payed membership to the forums.
The person could choose one of say 3 places, change it in the Admin CP, and the plugin would update the template code to reflect where the user wants the button.
Using a normal plugin, it wouldn't know if/when a setting was changed and therefore wouldn't know where to alter template code.
As another quick example,