MyBB Community Forums

Full Version: How to make the games section a pure plugin.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I just took a look and found that I could make the games section a pure plugin so that core file changes weren't needed.

Here are my changes:


Your first change is for the games_global function which loads the language. You can either hard code the language into the header or use this function instead:

function games_global()
{
	global $lang, $mybb, $db;
	
	$language = $mybb->settings['bblanguage'];
	if(!$lang->language_exists($language."/games.lang.php"))
	{
		$lang->set_language("english");
	}
	$lang->load("games");
}

To fix the language for admin add this to your /admin/games.php near the top

global $lang;
$lang->load("games");

You will also need to move these language variables from the admin part to the regular area (plugin files load the regular directory and that's where you have nav info).

Quote:$l['nav_add_game'] = "Add Game";
$l['nav_add_game_simple'] = "Add Game (Simple)";
$l['nav_add_cat'] = "Add Category";
$l['nav_overview'] = "Overview";
$l['nav_overview_cats'] = "Overview Categories";
$l['nav_gsettings'] = "Settings";
$l['nav_themes'] = "Themes";
$l['nav_templates'] = "Templates";
$l['nav_repair_champs'] = "Repair Champions";
$l['nav_repair_scores'] = "Repair Scores";
$l['nav_repair_perms'] = "Repair Default Permissions";
$l['nav_version'] = "Version Check";

$l['perm_gamesection'] = "Permissions: Game Section";
$l['perm_canviewgames'] = "Can View Game Section";
$l['perm_canplaygames'] = "Can Play on the Game Section";
$l['can_manage_games'] = "Can Manage Game Section";


Now you can get rid of that hook function call in the plugin file.


I also needed to make a new function in the plugin so that the usergroup permissions would be added.

function games_usergroups_edit()
{
	global $grouparray,$lang, $db, $mybb, $usergroup;

	$lang->edit_group = sprintf($lang->edit_group, $usergroup['title']);
	cpheader();
	startform("usergroups.php", "", "do_edit");
	makehiddencode("gid", htmlspecialchars($mybb->input['gid']));
	starttable();
	tableheader($lang->perm_gameheader);
	tablesubheader($lang->perm_gamesection);
	makehiddencode("title", $usergroup['title']);
	makehiddencode("namestyle", $usergroup['namestyle']);
	makeyesnocode($lang->perm_canviewgames, "canviewgames", $usergroup['canviewgames']);
	makeyesnocode($lang->perm_canplaygames, "canplaygames", $usergroup['canplaygames']);
	endtable();
	endform($lang->update_group, $lang->reset_button);

}

Called with this line added to the plugin file.

$plugins->add_hook("admin_usergroups_add", "games_usergroup_add");


I also added this to the regular language file:

$l['perm_gameheader'] = "Games Usergroup Permissions";


Well I think that's all my changes. I will let you know if I make more. But those changes would basically make the plugin a PURE plugin with NO core file changes. Smile
The other one is the Who's Online List Toungue
http://community.mybboard.net/showthread...#pid183130
Yeah I see I need to add that...I normally haven't messed with that page so I have to see what I can do.