These are the function I have used in active.asp. These functions can be used from a common file.
Rem -Returns List of Moderated Forums if the member is Modeartor
function ModForumList()
dim strSqlMod, rsMod, recModCount, allModData, strForumList, strComma
dim x
strForumList = "" : strComma = "" : recModCount = ""
if mlev = 3 then
strSqlMod = "SELECT MO.FORUM_ID FROM " & strTablePrefix & "MODERATOR MO " & _
"WHERE MO.MEMBER_ID = " & MemberID
Set rsMod = Server.CreateObject("ADODB.Recordset")
rsMod.open strSqlMod, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
if not (rsMod.BOF or rsMod.EOF) then
allModData = rsMod.GetRows(adGetRowsRest)
recModCount = UBound(allModData, 2)
end if
rsMod.close
set rsMod = nothing
if recModCount <> "" then
for x = 0 to recModCount
if x > 0 then strComma = ","
strForumList = strForumList & strComma & allModData(0,x)
next
end if
end if
ModForumList = strForumList
end function
Rem -Returns List of Allowed Forums for the Member
function AllowedForumList()
dim allowSql, rsAllowed
dim strAllowedForums, allAllowedData
dim recAllowedCount, RowCount, strComma
dim Forum_ID, Forum_PrivateForums, Forum_FPasswordNew
strComma = ""
strAllowedForums = ""
allowSql = "SELECT F.FORUM_ID, F.F_PRIVATEFORUMS, F.F_PASSWORD_NEW " & _
"FROM " & strTablePrefix & "FORUM F " & _
"WHERE F.F_TYPE = 0 " & _
"ORDER BY F.FORUM_ID"
set rsAllowed = Server.CreateObject("ADODB.Recordset")
rsAllowed.open allowSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
if (rsAllowed.BOF OR rsAllowed.EOF) then
recAllowedCount = ""
else
allAllowedData = rsAllowed.GetRows(adGetRowsRest)
recAllowedCount = UBound(allAllowedData,2)
end if
rsAllowed.close
set rsAllowed = nothing
if recAllowedCount <> "" then
Const iFORUM_ID = 0
Const iF_PRIVATEFORUMS = 1
Const iF_PASSWORD_NEW = 2
for RowCount = 0 to recAllowedCount step 1
Forum_ID = allAllowedData(iFORUM_ID, RowCount)
Forum_PrivateForums = allAllowedData(iF_PRIVATEFORUMS, RowCount)
Forum_FPasswordNew = allAllowedData(iF_PASSWORD_NEW, RowCount)
Rem -Find if user is allowed to Moderate the forum
Call ModeratePermission(Forum_ID, ModerateAllowed)
Rem -If the forum can be displayed to the user then add it to the allowed forum list
if ChkDisplayForum(Forum_PrivateForums, Forum_FPasswordNew, Forum_ID, MemberID) = true then
if strAllowedForums <> "" then strComma = ","
strAllowedForums = strAllowedForums & strComma & Forum_ID
end if
next
end if
if strAllowedForums = "" then strAllowedForums = 0
AllowedForumList = strAllowedForums
end function
Rem -Returns Y/N if the user is a Moderator/Not Moderator for the given Forum
function ModeratePermission(ByVal Forum_ID, ByRef ModerateAllowed)
dim strModerateAllowed
strModerateAllowed = "N"
if mLev = 4 then
strModerateAllowed = "Y"
elseif mLev = 3 and ModOfForums <> "" then
if (strAuthType = "nt") then
if (chkForumModerator(Forum_ID, Session(strCookieURL & "username")) = "1") then strModerateAllowed = "Y"
else
if (instr("," & ModOfForums & "," ,"," & Forum_ID & ",") > 0) then strModerateAllowed = "Y"
end if
end if
ModerateAllowed = strModerateAllowed
ModeratePermission = strModerateAllowed
strModerateAllowed = Empty
end function
and this is how I call them
Rem -Get list of Moderated Forums if the user is a Moderator
dim ModOfForums
ModOfForums = ModForumList()
Rem -Get list of Allowed Forums
dim allAllowedForums
if strPrivateForums = "1" and mLev < 4 then
allAllowedForums = AllowedForumList()
end if