Usergroups As Mods v0.32
Authors: xandra & Daywalker
PHP-Fusion Copyright © 2002 - 2006 Nick Jones
Released under the terms & conditions of v2 of the GNU General Public License. For details refer to the included gpl.txt file or visit http://gnu.org
Description:
This mod will give you the ability to add usergroups as mods in the forum.
Questions?
Post them at http://beta.phpfusion-mods.com or http://phpfusion-mods.com.
Installation Instructions:
Backup your website before uploading or modifying any files.
Step 1: Choose either Option 1 or Option 2 below...
This package may or may not include modified files for your specific php-fusion version.
Do NOT use the modified files from this package if you have modified any of the above files on your site. Instead, follow the mod instructions provided below.
Option 1: If you have not modified any of the above files on your site, you should be able to use the included files without any problems. Check the mod folder to see if there is a folder that corresponds with your php-fusion version number. If so, upload the contents of that folder to the appropriate directories on your site and installation will be complete.
Option 2: If there are no files included for your specific php-fusion version or you have modified any of the above files on your site, you will need to modify your existing files using the mod instructions below.
Mod Instructions:
Mod instructions for other PHP-Fusion versions:
- 6.01.300.html
- 6.00.3xx.html
The instructions below are for PHP-Fusion v6.01.400.
Colored Code: Throughout the mod instructions, some of the code is colored red and some blue. The colors show the code changes made for this mod... red is the code that's been removed, while blue is the code that's been added. This should help you figure out what needs to be changed if you have previously modified some of the lines used in this mod.
administration/forums.php
Find...
opentable($locale['408']);
ADD below it...
$result = dbquery("SELECT group_id, group_name FROM ".$db_prefix."user_groups ORDER BY group_name");
while ($data3 = dbarray($result)) {
$group_id = $data3['group_id'];
if (!preg_match("(^G{$group_id}$|^G{$group_id}\.|\.G{$group_id}\.|\.G{$group_id}$)", $data['forum_moderators'])) {
$mods3_group_id[] = "G".$data3['group_id'];
$mods3_group_name[] = $data3['group_name'];
} else {
$mods4_group_id[] = "G".$data3['group_id'];
$mods4_group_name[] = $data3['group_name'];
}
unset($group_id);
}
Find...
<table align='center' cellpadding='0' cellspacing='0' class='tbl'>
ADD below it...
<tr>
<td>".$locale['UGM_400']."</td>
</tr>
<tr>
<td>
<select multiple size='15' name='modlist3' id='modlist3' class='textbox' style='width:150' onChange=\"addUser('modlist4','modlist3');\">\n";
for ($i=0;$i < count($mods3_group_id);$i++) echo "<option value='".$mods3_group_id[$i]."'>".$mods3_group_name[$i]."</option>\n";
echo "</select>
</td>
<td align='center' valign='middle'>
</td>
<td>
<select multiple size='15' name='modlist4' id='modlist4' class='textbox' style='width:150' onChange=\"addUser('modlist3','modlist4');\">\n";
for ($i=0;$i < count($mods4_group_id);$i++) echo "<option value='".$mods4_group_id[$i]."'>".$mods4_group_name[$i]."</option>\n";
echo "</select>
</td>
</tr>
<tr>
<td><br />".$locale['UGM_401']."</td>
</tr>
Find...
var strValues = \"\";
var boxLength = document.getElementById('modlist2').length;
var count = 0;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
if (count == 0) {
strValues = document.getElementById('modlist2').options[i].value;
} else {
strValues = strValues + \".\" + document.getElementById('modlist2').options[i].value;
}
count++;
}
}
REPLACE it all with...
var strValuesG = \"\";
var boxLength = document.getElementById('modlist4').length;
var count = 0;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
if (count == 0) {
strValuesG = document.getElementById('modlist4').options[i].value;
} else {
strValuesG = strValuesG + \".\" + document.getElementById('modlist4').options[i].value;
}
count++;
}
}
var strValuesU = \"\";
var boxLength = document.getElementById('modlist2').length;
var count = 0;
if (boxLength != 0) {
for (i = 0; i < boxLength; i++) {
if (count == 0) {
strValuesU = document.getElementById('modlist2').options[i].value;
} else {
strValuesU = strValuesU + \".\" + document.getElementById('modlist2').options[i].value;
}
count++;
}
}
if (strValuesG.length == 0) {
strValues = strValuesU;
} else if(strValuesU.length == 0) {
strValues = strValuesG;
} else {
strValues = strValuesG + \".\" + strValuesU;
}
Save and close.
Open forum/index.php
Find...
$res = "user_id='".str_replace(".", "' OR user_id='", $data['forum_moderators'])."'";
$result2 = dbquery("SELECT user_id,user_name FROM ".$db_prefix."users WHERE (".$res.")");
while ($data2 = dbarray($result2)) {
if ($moderators) $moderators .= ", ";
$moderators .= "<a href='".BASEDIR."profile.php?lookup=".$data2['user_id']."'>".$data2['user_name']."</a>";
}
REPLACE it all with...
$groupmods = array(); $usermods = array();
$forum_mods = explode(".", $data['forum_moderators']);
for($i = 0; $i < count($forum_mods); $i ++) {
if (!isnum($forum_mods[$i])) { $groupmods[] = substr($forum_mods[$i], 1); }
else { $usermods[] = $forum_mods[$i]; }
}
if (count($groupmods) != 0) {
$res = "group_id='".implode("' OR group_id='", $groupmods)."'";
$result2 = dbquery("SELECT group_id, group_name FROM ".$db_prefix."user_groups WHERE (".$res.") ORDER BY group_name");
while ($data2 = dbarray($result2)) {
if ($moderators) $moderators .= ", ";
$moderators .= "<a href='".BASEDIR."profile.php?group_id=".$data2['group_id']."'>".$data2['group_name']."</a>";
}
}
if (count($usermods) != 0) {
$res = "user_id='".implode("' OR user_id='", $usermods)."'";
$result2 = dbquery("SELECT user_id, user_name FROM ".$db_prefix."users WHERE (".$res.") ORDER BY user_level DESC, user_name ASC");
while ($data2 = dbarray($result2)) {
if ($moderators) $moderators .= ", ";
$moderators .= "<a href='".BASEDIR."profile.php?lookup=".$data2['user_id']."'>".$data2['user_name']."</a>";
}
}
Save and close.
Open forum/options.php
Find...
if (in_array($userdata['user_id'], $forum_mods)) { define("iMOD", true); } else { define("iMOD", false); }
REPLACE with...
function UGMODS_groupcheck($mods) {
$results = 0;
for($i = 0; $i < count($mods); $i ++) {
if (substr($mods[$i], 1) > "" && checkgroup(substr($mods[$i], 1))) { $results ++; break; }
}
if ($results != 0) { return true; } else { return false; }
}
if (in_array($userdata['user_id'], $forum_mods) || UGMODS_groupcheck($forum_mods)) { define("iMOD", true); } else { define("iMOD", false); }
Save and close.
Open forum/post.php
Find...
if (iMEMBER && in_array($userdata['user_id'], $forum_mods)) { define("iMOD", true); } else { define("iMOD", false); }
REPLACE with...
function UGMODS_groupcheck($groups, $mods) {
$results = 0;
for($i = 0; $i < count($mods); $i ++) {
if (substr($mods[$i], 1) > "" && in_array(substr($mods[$i], 1), explode(".", $groups))) { $results ++; break; }
}
if ($results != 0) { return true; } else { return false; }
}
if (iMEMBER && (in_array($userdata['user_id'], $forum_mods) || UGMODS_groupcheck($userdata['user_groups'], $forum_mods))) { define("iMOD", true); } else { define("iMOD", false); }
Save and close.
Open forum/postedit.php
Find...
$is_mod = in_array($udata['user_id'], $forum_mods) && $udata['user_level'] < "102" ? true : false;
REPLACE with...
$is_mod = (in_array($udata['user_id'], $forum_mods) || UGMODS_groupcheck($udata['user_groups'], $forum_mods)) && $udata['user_level'] < "102" ? true : false;
Save and close.
Open forum/postnewthread.php
Find...
$is_mod = iMOD && iUSER < "102" ? true : false;
REPLACE with...
$is_mod = (iMOD || UGMODS_groupcheck($data['user_groups'], $forum_mods)) && iUSER < "102" ? true : false;
Save and close.
Open forum/postreply.php
Find...
$is_mod = iMOD && iUSER < "102" ? true : false;
ADD below it...
$is_mod = (iMOD || UGMODS_groupcheck($data['user_groups'], $forum_mods)) && iUSER < "102" ? true : false;
Save and close.
Open forum/viewthread.php
Find...
if (iMEMBER && in_array($userdata['user_id'], $forum_mods)) { define("iMOD", true); } else { define("iMOD", false); }
REPLACE with...
function UGMODS_groupcheck($groups, $mods) {
$results = 0;
for($i = 0; $i < count($mods); $i ++) {
if (substr($mods[$i], 1) > "" && in_array(substr($mods[$i], 1), explode(".", $groups))) { $results ++; break; }
}
if ($results != 0) { return true; } else { return false; }
}
if (iMEMBER && (in_array($userdata['user_id'], $forum_mods) || UGMODS_groupcheck($userdata['user_groups'], $forum_mods))) { define("iMOD", true); } else { define("iMOD", false); }
Find...
$is_mod = in_array($data['user_id'], $forum_mods) && $data['user_level'] < "102" ? true : false;
REPLACE with...
$is_mod = (in_array($data['user_id'], $forum_mods) || UGMODS_groupcheck($data['user_groups'], $forum_mods)) && $data['user_level'] < "102" ? true : false;
Save and close.
Open locale/English/admin/forums.php
Find...
?>
ADD above it...
// Usergroups As Mods
$locale['UGM_400'] = "Usergroups";
$locale['UGM_401'] = "Users";
Save and close.