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)
 chkForumModerator
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

GauravBhabu
Advanced Member

4288 Posts

Posted - 09 September 2002 :  11:16:35  Show Profile
It will prevent a DB call if the member level is checked before processing the code in the function.

The code within the function may be modified as below.


function chkForumModerator(fForum_ID, fMember_Name)
    chkForumModerator = "0"
    if mLev = 3 then
        '## Forum_SQL 
	strSql = "SELECT mo.FORUM_ID "	
	strSql = strSql & " FROM " & strTablePrefix & "MODERATOR mo, " & strMemberTablePrefix & "MEMBERS me "	
	strSql = strSql & " WHERE mo.FORUM_ID = " & fForum_ID & " "	
	strSql = strSql & " AND   mo.MEMBER_ID = me.MEMBER_ID "	
	strSql = strSql & " AND   me." & strDBNTSQLName & " = '" & chkString(fMember_Name, "SQLString") & "'"

	Set rsChk = Server.CreateObject("ADODB.Recordset")
	rsChk.open strSql, my_Conn
	
	if not(rsChk.bof or rsChk.eof) then		
		chkForumModerator = "1"	
	end if 	
	rsChk.close	
	set rsChk = nothing
    end if
end function



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)

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 09 September 2002 :  13:00:45  Show Profile
implemented in v3.4.03

NOT implemented in v3.4.03
Go to Top of Page

pweighill
Junior Member

United Kingdom
453 Posts

Posted - 09 September 2002 :  14:41:01  Show Profile
I think that change may not work when called from admin_moderators.asp

Lines:128-131
if chkForumModerator(Forum_ID, rs("M_NAME")) then Response.Write("<b>")
Response.Write	"<span class=""spnMessageText""><a href=""admin_moderators.asp?forum=" & Forum_ID & "&UserID=" & rs("MEMBER_ID")& """>" & rs("M_NAME") & "</a></span>"
If chkForumModerator(Forum_ID, rs("M_NAME")) then Response.Write("</b>")


I would change chkForumModerator as follows:

function chkForumModerator(fForum_ID, fMember_Name)
	chkForumModerator = "0"
	if fMember_Name="" and mLev<>3 then exit function

	if fMember_Name="" then
		strSql = "SELECT FORUM_ID "	
		strSql = strSql & " FROM " & strTablePrefix & "MODERATOR "	
		strSql = strSql & " WHERE FORUM_ID = " & fForum_ID & " "	
		strSql = strSql & " AND   MEMBER_ID = "	& MemberID
	else
		strSql = "SELECT mo.FORUM_ID "	
		strSql = strSql & " FROM " & strTablePrefix & "MODERATOR mo, " & strMemberTablePrefix & "MEMBERS me "	
		strSql = strSql & " WHERE mo.FORUM_ID = " & fForum_ID & " "	
		strSql = strSql & " AND   mo.MEMBER_ID = me.MEMBER_ID "	
		strSql = strSql & " AND   me." & strDBNTSQLName & " = '" & chkString(fMember_Name,"SQLString") & "'"
	end if

	Set rsChk = Server.CreateObject("ADODB.Recordset")
	rsChk.open strSql, my_Conn
	if not(rsChk.bof or rsChk.eof) then		
		chkForumModerator = "1"	
	end if
	rsChk.close	
	set rsChk = nothing
end function


and then search for occurences of chkForumModerator and set the second paramter to "" in most cases. (apar from in admin_moderators.asp)

Another alternative is to have two functions. One with a fMember_Name parameter and one without.

Edited by - pweighill on 09 September 2002 14:41:47
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 09 September 2002 :  15:10:55  Show Profile
if fMember_Name="" and mLev <> 3 then exit function


With this statement the function will return a false value if mLev is not = 3 same as with the code posted by me. What is the difference

When will the M_Name in members table be = ""

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)

Edited by - GauravBhabu on 09 September 2002 15:24:17
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 09 September 2002 :  15:17:51  Show Profile
File: admin_moderators.asp

Lines 128-130
if chkForumModerator(Forum_ID, rs("M_NAME")) then Response.Write("<b>")
	Response.Write	"<span class=""spnMessageText""><a href=""admin_moderators.asp?forum=" & Forum_ID & "&UserID=" & rs("MEMBER_ID")& """>" & rs("M_NAME") & "</a></span>"
If chkForumModerator(Forum_ID, rs("M_NAME")) then Response.Write("</b>")


...should be replaced as follows. Will save one call for each Modeartor.

blnModerator = chkForumModerator(Forum_ID, rs("M_NAME"))
if blnModerator then Response.Write("<b>")
Response.Write	"<span class=""spnMessageText""><a href=""admin_moderators.asp?forum=" & Forum_ID & "&UserID=" & rs("MEMBER_ID")& """>" & rs("M_NAME") & "</a></span>"
If blnModerator then Response.Write("</b>")



P.S.
Why not use GetRows to get all the Moderators Will save multiple Calls.

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)

Edited by - GauravBhabu on 09 September 2002 15:38:11
Go to Top of Page

pweighill
Junior Member

United Kingdom
453 Posts

Posted - 09 September 2002 :  15:32:05  Show Profile
quote:
Originally posted by GauravBhabu

When will the M_Name in members table be = ""


You would have to edit the other files and change the calls to the function.

The bit of code in admin_moderators.asp could be written:

if chkForumModerator(Forum_ID, rs("M_NAME")) = "1" then
Response.Write	"<b><span class=""spnMessageText""><a href=""admin_moderators.asp?forum=" & Forum_ID & "&UserID=" & rs("MEMBER_ID")& """>" & rs("M_NAME") & "</a></span></b>"
end if


But you are missing the point. If an admin (mLev=4) goes to edit the moderators of the forums by going to admin_moderators.asp, chkForumModerator(Forum_ID, rs("M_NAME")) will return "0" when it should be returning either "0" or "1".
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 09 September 2002 :  15:34:08  Show Profile
let's just rewrite the whole forum...
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 09 September 2002 :  15:49:27  Show Profile
In most pages (the pages that are used the most anyways), chkForumModerator is only called if the user's mLev = 3). So, I see no reason to change this function at all.
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 09 September 2002 :  15:54:23  Show Profile
quote:
Originally posted by RichardKinser

In most pages (the pages that are used the most anyways), chkForumModerator is only called if the user's mLev = 3). So, I see no reason to change this function at all.



In most pages as you said. I have not looked all the pages. One file which I found where mLev = 3 is not checked is

pop_delete.asp
Line 86 and 221.

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

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 09 September 2002 :  15:55:20  Show Profile
pop_delete.asp, pop_lock.asp, pop_open.asp, a few others. But these files are not used often, and only by Admins or Moderators. Not a big deal.
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 09 September 2002 :  15:56:29  Show Profile
quote:
Originally posted by RichardKinser

let's just rewrite the whole forum...




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 - 09 September 2002 :  15:57:32  Show Profile
quote:
Originally posted by RichardKinser

pop_delete.asp, pop_lock.asp, pop_open.asp, a few others. But these files are not used often, and only by Admins or Moderators. Not a big deal.



Well! No problems.

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.3 seconds. Powered By: Snitz Forums 2000 Version 3.4.07