Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 DEV-Group
 DEV Discussions (General)
 inc_jump_to.asp - Coding
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

GauravBhabu
Advanced Member

4288 Posts

Posted - 15 September 2002 :  18:07:30  Show Profile
File: inc_jump_to.asp
Lines: 84-94



if mLev = 4 then
 ModerateAllowed = "Y"
elseif mLev = 3 and ModOfForums <> "" then
 if (strAuthType = "nt") then
  if (chkForumModerator(Forum_ID, Session(strCookieURL & "username")) = "1") then ModerateAllowed = "Y" else ModerateAllowed = "N"
 else 
  if (instr("," & ModOfForums & "," ,"," & Forum_ID & ",") > 0) then ModerateAllowed = "Y" else ModerateAllowed = "N"
 end if
else
 ModerateAllowed = "N"
end if


inc_jump_to.asp is included in active.asp, topic.asp and forum.asp.

The variable ModOfForums is populated in active.asp (Lines 156-186).

However unless I am missing something, with active.asp the code between lines (54-102) in inc_jump_to.asp will never be executed. That is probably the intention also.

But in topic.asp and forum.asp the variable ModOfForums is not populated anywhere (I could not find if it is being populated).

So the statement highlighted in blue above will always force ModearteAllowed = "N".

This behavior will force the code between lines (103-141) in inc_func_secure.asp to be executed. (see statement on Line 95 in inc_jump_to.asp which calls the function chkDisplayForum).

IMO, The code mentioned above is not required. or the variable ModOfForums be populated in inc_jump_to.asp the same way it is done in active.asp.

Leaving the code has no affect, anyway.

CSS and HTML4.01 Compilant Snitz Forum . ForumSquare . Rakesh Jain

It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.

Prayer Of Forgiveness
"I forgive all living beings. May all living beings forgive me!
I cherish the friendliness towards all and harbour enmity towards none." -- Aavashyaka Sutra(Translated)

pweighill
Junior Member

United Kingdom
453 Posts

Posted - 15 September 2002 :  18:56:58  Show Profile
As a side topic, the code which sets the variable ModOfForums is contained in 4 files, default.asp, active.asp, search.asp and moderate.asp and is the same in all of them.

This could be converted into a function and placed into inc_moderation.asp

Function GetModOfForums()
	GetModOfForums = ""

	strSql = "SELECT FORUM_ID FROM " & strTablePrefix & "MODERATOR " & _
		 " WHERE MEMBER_ID = " & MemberID

	Set rsMod = Server.CreateObject("ADODB.Recordset")
	rsMod.open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText

	if rsMod.EOF then
		recModCount = ""
	else
		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
				GetModOfForums = allModData(0,x)
			else
				GetModOfForums = GetModOfForums & "," & allModData(0,x)
			end if
		next
	end if
end function


And called thus:

if mlev = 3 then
	ModOfForums = GetModOfForums()
else
	ModOfForums = ""
end if

Edited by - pweighill on 15 September 2002 18:59:14
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 15 September 2002 :  19:03:50  Show Profile
Yes! That is what I have done. I also did the same to populate the variable allAllowedForums.

CSS and HTML4.01 Compilant Snitz Forum . ForumSquare . Rakesh Jain

It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.

Prayer Of Forgiveness
"I forgive all living beings. May all living beings forgive me!
I cherish the friendliness towards all and harbour enmity towards none." -- Aavashyaka Sutra(Translated)
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 15 September 2002 :  19:08:31  Show Profile
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

CSS and HTML4.01 Compilant Snitz Forum . ForumSquare . Rakesh Jain

It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.

Prayer Of Forgiveness
"I forgive all living beings. May all living beings forgive me!
I cherish the friendliness towards all and harbour enmity towards none." -- Aavashyaka Sutra(Translated)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.22 seconds. Powered By: Snitz Forums 2000 Version 3.4.07