2005-12-25, 09:43 PM
Ok I haven't tested this code, so give this a try and tell me the results:
In your phpMyAdmin, navigate to your mybb_themes table (change mybb_ to your forum's table prefix if it's different). Add a column called 'usergroups' (without the quotation marks) and make it VARCHAR 100.
Open inc/functions.php. Replace the existing themeselect function with:
Open usergroup.php.
Find:
Open admin/themes.php.
Find:
Again, I haven't tested this code, so tell me what errors you get and we'll troubleshoot it.
In your phpMyAdmin, navigate to your mybb_themes table (change mybb_ to your forum's table prefix if it's different). Add a column called 'usergroups' (without the quotation marks) and make it VARCHAR 100.
Open inc/functions.php. Replace the existing themeselect function with:
function themeselect($name, $selected="", $tid=0, $depth="", $usergroup="")
{
global $db, $themeselect, $tcache, $lang, $tgroupcache;
if(!$tid)
{
$themeselect = "<select name=\"$name\">";
$themeselect .= "<option value=\"0\">".$lang->use_default."</option>\n";
$themeselect .= "<option value=\"0\">-----------</option>\n";
}
if(!is_array($tcache))
{
$query = $db->query("SELECT name,pid,tid FROM ".TABLE_PREFIX."themes ORDER BY pid, name");
while($theme = $db->fetch_array($query))
{
$tcache[$theme['pid']][$theme['tid']] = $theme;
}
}
if(!is_array($tgroupcache))
{
$query = $db->query("SELECT tid,usergroups FROM ".TABLE_PREFIX."themes");
while($row = $db->fetch_array($query))
{
$tgroupcache[$row['tid']] = $row['usergroups'];
}
}
if(is_array($tcache[$tid]))
{
if(!empty($usergroup) && !is_array($usergroup))
{
$in_groups = array($usergroup);
}
elseif(!empty($usergroup) && is_array($usergroup))
{
$in_groups = $usergroup;
}
else
{
$in_groups = false;
}
foreach($tcache[$tid] as $theme)
{
$allowed = explode(',', $tgroupcache[$theme['tid']]);
if(empty($tgroupcache[$theme['tid']]) || !$in_groups || in_array($in_groups, $allowed))
{
$sel = "";
if($theme['tid'] == $selected)
{
$sel = "selected=\"selected\"";
}
if($theme['pid'] != 0)
{
$themeselect .= "<option value=\"".$theme['tid']."\" $sel>".$depth.$theme['name']."</option>";
$depthit = $depth."--";
}
if(is_array($tcache[$theme['tid']]))
{
themeselect($name, $selected, $theme['tid'], $depthit, $usergroup);
}
}
}
}
if(!$tid)
{
$themeselect .= "</select>";
}
return $themeselect;
}
Open usergroup.php.
Find:
$stylelist = themeselect("style", $mybb->user['style']);
Replace with: $ugarray = explode(',', $mybb->user['additionalgroups']);
$ugarray[] = $mybb->user['usergroup'];
$stylelist = themeselect("style", $mybb->user['style'],0,"",$ugarray);
Open admin/themes.php.
Find:
$themearray = array(
"name" => addslashes($mybb->input['name']),
Add after: "usergroups" => addslashes($mybb->input['usergroups']),
Find next (should be several lines below): $themearray = array(
"name" => addslashes($mybb->input['name']),
Add after: "usergroups" => addslashes($mybb->input['usergroups']),
Find: makeinputcode($lang->theme_name, "name");
Add after: makeinputcode("Allowed Usergroups (separate by comma, or leave blank for all groups)", "usergroups");
Find: makeinputcode($lang->theme_name, "name", $theme['name']);
Add after: makeinputcode("Allowed Usergroups (separate by comma, or leave blank for all groups)", "usergroups", $theme['usergroups']);
Again, I haven't tested this code, so tell me what errors you get and we'll troubleshoot it.