merk
09-18-2001, 10:00 PM
Purpose: I run many many forums(120+ including subcatagories) so i needed a more efficient way of controlling access masks(there is an infinite combination of usergroups if i was to use that method.)
So set about creating a better system.
For an example, view the attachment. (default setting=green, yes=red, no=blue).
Installation:
First, you need to open up adminfunctions.php in the /admin/ directory and add (just before the ?>)
// ###################### Start makeoptioncode #######################
function makeoptioncode ($value="",$description, $selected="", $color="green") {
// similar to makeinputcode, only for a text area
echo "\n<OPTION value=\"$value\" $selected style=\"color:$color\">$description</option>";
}
Then go into user.php in the /admin/ directory
Go to ~~ 358 and find
// ###################### Start Edit Access #######################
/*if ($action=="editaccess") {
Delete everything from that point to
doformfooter("Save Changes");
}
(Thats just the edit access bit, nothing else!)
Then, put where that was
// ###################### Start accessmasks function #######################
function accessmasks($parentid=-1) {
global $DB_site, $userid, $forumid;
$forums=$DB_site->query("SELECT forumid,title,displayorder FROM forum WHERE parentid=$parentid ORDER BY displayorder");
while ($forum=$DB_site->fetch_array($forums)) {
$accesslist=$DB_site->query_first("SELECT * FROM access WHERE userid='$userid' AND forumid='$forum[forumid]'");
if ( is_array($accesslist) )
{if ($accesslist['accessmask']==0)
{$sel = 0; $tempcolour="blue";}
elseif ($accesslist['accessmask']==1)
{$sel = 1; $tempcolour="red";}
else {$sel = -1; $tempcolour="green";}}
else
{$sel = -1; $tempcolour="green";}
echo "<li><div style=\"color:$tempcolour\"><b>$forum[title]</b>";
echo " > > > <SELECT name=\"accessupdate[".$forum['forumid']."]\" style=\"font-size: 7pt; background-color: #dfdfdf; font-family: Arial, Tahoma;\" maxlength=\"20\">";
makeoptioncode(1,"Yes",iif($sel==1,"selected",""),"red");
makeoptioncode(0,"No",iif($sel==0,"selected",""),"blue");
makeoptioncode(-1,"Default",iif($sel==-1,"selected",""),"green");
echo "</select></div>\n\n";
echo "<input type=\"hidden\" name=\"oldcache[".$forum['forumid']."]\" value=\"$sel\">";
echo "<ul>";
accessmasks($forum[forumid]);
echo "</ul>\n";
echo "</li>\n";
}}
// ###################### Start modify #######################
if ($action=="editaccess") {
$user=$DB_site->query_first("SELECT username FROM user WHERE userid='$userid'");
doformheader("user","updateaccess",0,0);
makehiddencode("userid","$userid");
echo "<div align=center><h3>User Forum Access for <i>$user[username]</i></h3></div>";
echo "<tr class='firstalt'><td colspan=2><p>Here you may edit forum access on a user-by-user basis.
<BR>Selecting \"yes\" will allow this user access to the forum. Selecting \"no\" will deny this user access to the forum. Any changes made to this user's account will override the default permission settings in their usergroup.
<br><br>Selecting \"default\" will revert this user to the default permissions settings for their usergroup.
<BR><br>(Please note that the permission inheritance system still works here)
<br><br>(Ensure that you have access masks enabled before attempting to use these!)</p></td></tr>\n";
echo "<br>";
echo "<ul>\n";
accessmasks(-1);
echo "</ul>\n";
doformfooter("Save Changes");
}
Thats it!
PS. Devlopers / Moderators - i wasnt sure if i copied and
pasted too much code in the above, well actually i rewrote most
of it, but based on your principles in the modify forums section. If
its too much, please feel free to delete it, but because i didnt
know...!
Demo Screenshot attached
So set about creating a better system.
For an example, view the attachment. (default setting=green, yes=red, no=blue).
Installation:
First, you need to open up adminfunctions.php in the /admin/ directory and add (just before the ?>)
// ###################### Start makeoptioncode #######################
function makeoptioncode ($value="",$description, $selected="", $color="green") {
// similar to makeinputcode, only for a text area
echo "\n<OPTION value=\"$value\" $selected style=\"color:$color\">$description</option>";
}
Then go into user.php in the /admin/ directory
Go to ~~ 358 and find
// ###################### Start Edit Access #######################
/*if ($action=="editaccess") {
Delete everything from that point to
doformfooter("Save Changes");
}
(Thats just the edit access bit, nothing else!)
Then, put where that was
// ###################### Start accessmasks function #######################
function accessmasks($parentid=-1) {
global $DB_site, $userid, $forumid;
$forums=$DB_site->query("SELECT forumid,title,displayorder FROM forum WHERE parentid=$parentid ORDER BY displayorder");
while ($forum=$DB_site->fetch_array($forums)) {
$accesslist=$DB_site->query_first("SELECT * FROM access WHERE userid='$userid' AND forumid='$forum[forumid]'");
if ( is_array($accesslist) )
{if ($accesslist['accessmask']==0)
{$sel = 0; $tempcolour="blue";}
elseif ($accesslist['accessmask']==1)
{$sel = 1; $tempcolour="red";}
else {$sel = -1; $tempcolour="green";}}
else
{$sel = -1; $tempcolour="green";}
echo "<li><div style=\"color:$tempcolour\"><b>$forum[title]</b>";
echo " > > > <SELECT name=\"accessupdate[".$forum['forumid']."]\" style=\"font-size: 7pt; background-color: #dfdfdf; font-family: Arial, Tahoma;\" maxlength=\"20\">";
makeoptioncode(1,"Yes",iif($sel==1,"selected",""),"red");
makeoptioncode(0,"No",iif($sel==0,"selected",""),"blue");
makeoptioncode(-1,"Default",iif($sel==-1,"selected",""),"green");
echo "</select></div>\n\n";
echo "<input type=\"hidden\" name=\"oldcache[".$forum['forumid']."]\" value=\"$sel\">";
echo "<ul>";
accessmasks($forum[forumid]);
echo "</ul>\n";
echo "</li>\n";
}}
// ###################### Start modify #######################
if ($action=="editaccess") {
$user=$DB_site->query_first("SELECT username FROM user WHERE userid='$userid'");
doformheader("user","updateaccess",0,0);
makehiddencode("userid","$userid");
echo "<div align=center><h3>User Forum Access for <i>$user[username]</i></h3></div>";
echo "<tr class='firstalt'><td colspan=2><p>Here you may edit forum access on a user-by-user basis.
<BR>Selecting \"yes\" will allow this user access to the forum. Selecting \"no\" will deny this user access to the forum. Any changes made to this user's account will override the default permission settings in their usergroup.
<br><br>Selecting \"default\" will revert this user to the default permissions settings for their usergroup.
<BR><br>(Please note that the permission inheritance system still works here)
<br><br>(Ensure that you have access masks enabled before attempting to use these!)</p></td></tr>\n";
echo "<br>";
echo "<ul>\n";
accessmasks(-1);
echo "</ul>\n";
doformfooter("Save Changes");
}
Thats it!
PS. Devlopers / Moderators - i wasnt sure if i copied and
pasted too much code in the above, well actually i rewrote most
of it, but based on your principles in the modify forums section. If
its too much, please feel free to delete it, but because i didnt
know...!
Demo Screenshot attached