merk
04-09-2002, 07:48 AM
I have some code for the moderators control panel, and i cant seem to get any inheritence working. I really need it to happen :|
function getaccess () {
global $DB_site,$bbuserinfo,$forumaccess;
if($bbuserinfo[usergroupid]==6) {
$accessquery=$DB_site->query("SELECT forum.forumid,forum.title FROM forum ORDER BY forum.parentid,forum.parentlist");
while($access=$DB_site->fetch_array($accessquery)) {
$forumaccess[]=array(forumid=>"$access[forumid]",title=>"$access[title]",modid=>"$access[moderatorid]");
}
}
else {
$accessquery=$DB_site->query("SELECT moderator.*,forum.title FROM moderator LEFT JOIN forum ON forum.forumid=moderator.forumid WHERE moderator.userid=$bbuserinfo[userid]");
if (!$accessquery) {
echo "No access detected. If you have access please email the administrator."; exit;
}
while($access=$DB_site->fetch_array($accessquery)) {
$forumaccess[]=array(forumid=>"$access[forumid]",title=>"$access[title]",modid=>"$access[moderatorid]");
}
}
}
Thats the function i use to get the forums a moderator has access to. How would i adapt this to also allow inheritence?
I use a foreach($forumaccess as $key=>$forum) sort of thing to access the array. Would it be easier to work out the inheritence in the foreach or in the getaccess function?
function getaccess () {
global $DB_site,$bbuserinfo,$forumaccess;
if($bbuserinfo[usergroupid]==6) {
$accessquery=$DB_site->query("SELECT forum.forumid,forum.title FROM forum ORDER BY forum.parentid,forum.parentlist");
while($access=$DB_site->fetch_array($accessquery)) {
$forumaccess[]=array(forumid=>"$access[forumid]",title=>"$access[title]",modid=>"$access[moderatorid]");
}
}
else {
$accessquery=$DB_site->query("SELECT moderator.*,forum.title FROM moderator LEFT JOIN forum ON forum.forumid=moderator.forumid WHERE moderator.userid=$bbuserinfo[userid]");
if (!$accessquery) {
echo "No access detected. If you have access please email the administrator."; exit;
}
while($access=$DB_site->fetch_array($accessquery)) {
$forumaccess[]=array(forumid=>"$access[forumid]",title=>"$access[title]",modid=>"$access[moderatorid]");
}
}
}
Thats the function i use to get the forums a moderator has access to. How would i adapt this to also allow inheritence?
I use a foreach($forumaccess as $key=>$forum) sort of thing to access the array. Would it be easier to work out the inheritence in the foreach or in the getaccess function?