<?php
/***************************************************************************
 *                            functions_modcp.php
 *                            -------------------
 *   begin                : Sunday, Aug 07, 2005
 *   copyright            : (C) Milkman
 *   email                : milkman@web-milk.co.uk
 *
 *   $Id: functions.php,v 1.0.0 2005/08/07 14:02:?? Milkman Exp $
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB', 1);

function check_perms($category, $module, $level = '')
{
	global $userdata, $board_config;

	if ($level == '')
	{
		$level = $userdata['user_level'];
	}

	// Admin has full access.  Regardless of if it's disabled.
	if ($level == ADMIN) return true;

	// Check the module
	$category = str_replace(array(' ', '_'), '-', $category);
	$module   = str_replace(array(' ', '_'), '-', $module);

	$field_name = "modcp_module_${category}_${module}";

	if (isset($board_config[$field_name]))
	{
		$perms = explode(',', $board_config[$field_name]);

		return in_array($level, $perms);
	}
	return false;
}

?>