MyBB Community Forums

Full Version: Modification Settings
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Some of you creators may know I recently made the mod "Usertitles through Member Ratings". If you read the current features in the post I made about it, you might have noticed I made a settings group called "Modification Settings". I think it would be easy to make modifications installed on the board disableable. And in that group you could add your option to enable/disable the mod. You could also add other settings you'd like to add, if you don't want to make a particular page for themSmile

You can use this code in a php-file to make the section. It's rather quick to add it this way Smile
/////////////////*This makes the Settings Group*/
/* Check if Group already exists */
$sql = $db->query("SELECT * FROM ".TABLE_PREFIX."settinggroups WHERE name='Modification Settings' ");
$result = $db->num_rows($sql);
if($result=="0"){ /*Group exists*/
	echo "The Settings Group already exists. The Modification Settings group will <b>not</b> be added to ".TABLE_PREFIX."settinggroups";
}
else { /*Group doesn't exist*/
	$sql = "INSERT INTO ".TABLE_PREFIX."settinggroups VALUES ('', 'Modification Settings', 'Settings for all sorts of MyBB Modifications', '20', 'no')";
	if($result = $db->query($sql, 1)){
		echo "Modification Settings added to " . TABLE_PREFIX . "settinggroups table<br>";
	}
	else{
		echo "Could not add Modification Settings to " . TABLE_PREFIX . "settinggroups table<br>";
		$error = TRUE;
	}
}
////////////////
/////////////////*This gets the group ID from the settings group (useful when there are already groups added by the user himself)*/
$sql = "SELECT gid FROM ".TABLE_PREFIX."settinggroups WHERE name='Modification Settings' ";
if($result = $db->query($sql, 1)){
   echo "Got gid from Modification Settings from " . TABLE_PREFIX . "settinggroups table<br>";
   $mod = $db->fetch_array($db->query($sql));
}
else{
   echo "Could not get gid from Modification Settings from " . TABLE_PREFIX . "settinggroups table<br>";
   $error = TRUE;
}
////////////////
/////////////////*This adds the setting in the group using the group ID from above*/
$sql = "INSERT INTO ".TABLE_PREFIX."settings VALUES ('', 'ratingtitles', 'Usertitle through Member Ratings?', 'For the Usertitle through Member Ratings', 'yesno', 'no', '1', '".$mod['gid']."')";
if($result = $db->query($sql, 1)){
   echo "Usertitles through Member Ratings added to " . TABLE_PREFIX . "settings table<br>";
}
else{
   echo "Could not add Usertitle through Member Ratings to " . TABLE_PREFIX . "settings table<br>";
   $error = TRUE;
}
////////////////

Make sure you have this on the top of the php-file:
require_once("global.php");