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 MOD-Group
 MOD Add-On Forum (W/Code)
 MOD: Subscribe a user to category
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

bfeucht
Starting Member

7 Posts

Posted - 15 November 2004 :  11:10:15  Show Profile
I just stole code from different files on the forums to make this quick and dirty mod that allows you to subscribe a choosen user to a certain category. It met my needs as is but could easily be expanded to be more functional. Copy and paste code into a new file.

<%
'#################################################################################
'## Snitz Forums 2000 v3.4.04
'#################################################################################
'## Copyright (C) 2000-04 Michael Anderson, Pierre Gorissen,
'##                       Huw Reddick and Richard Kinser
'##
'## This program is free software; you can redistribute it and/or
'## modify it under the terms of the GNU General Public License
'## as published by the Free Software Foundation; either version 2
'## of the License, or (at your option) any later version.
'##
'## All copyright notices regarding Snitz Forums 2000
'## must remain intact in the scripts and in the outputted HTML
'## The "powered by" text/logo with a link back to
'## http://forum.snitz.com in the footer of the pages MUST
'## remain visible when the pages are viewed on the internet or intranet.
'##
'## This program is distributed in the hope that it will be useful,
'## but WITHOUT ANY WARRANTY; without even the implied warranty of
'## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'## GNU General Public License for more details.
'##
'## You should have received a copy of the GNU General Public License
'## along with this program; if not, write to the Free Software
'## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
'##
'## Support can be obtained from our support forums at:
'## http://forum.snitz.com
'##
'## Correspondence and Marketing Questions can be sent to:
'## manderson@snitz.com
'##
'#################################################################################
%>
<!--#INCLUDE FILE="config.asp"-->
<%
Dim HasHigherSub
Dim HeldFound, UnApprovedFound, UnModeratedPosts, UnModeratedFPosts
Dim canView
HasHigherSub = false
Dim strUseMemberDropDownBox
strUseMemberDropDownBox = 1
%>
<!--#INCLUDE FILE="inc_sha256.asp"-->
<!--#INCLUDE FILE="inc_header.asp" -->
<!--#INCLUDE FILE="inc_func_secure.asp" -->
<!--#INCLUDE FILE="inc_func_chknew.asp" -->
<!--#INCLUDE FILE="inc_moderation.asp" -->
<!--#INCLUDE FILE="inc_subscription.asp" -->

<%

if Request.QueryString("mode") = "DoIt" then
  
  dim CAT_ID, MEM_ID
  CAT_ID = Request.Form("Category")
  MEM_ID = Request.Form("SearchMember")

  AddSubscription "CAT", MEM_ID, CAT_ID, 0, 0

else

Response.Write	"      <table border=""0"" cellspacing=""0"" cellpadding=""0"" align=""center"">" & vbNewLine & _
		"              <tr>" & vbNewLine & _
		"                <td bgColor=""" & strPopUpTableColor & """ align=""right"" valign=""middle""><b><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>Member:</font></b></td>" & vbNewLine
'##
'##  List Users
'##
Response.Write	"      <form action='admin_subscription.asp?Mode=DoIt' name='Subscribe' id='Subscribe' method='post'>" & vbNewLine & _
		"                <td bgColor=""" & strPopUpTableColor & """ align=""left"" valign=""middle"">" & vbNewLine & _
		"		 <select name=""SearchMember"">" & vbNewLine
		'## Forum_SQL
		strSql = "SELECT MEMBER_ID, M_NAME "
		strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS"
		strSql = strSql & " WHERE M_STATUS = " & 1
		strSql = strSql & " ORDER BY M_NAME ASC;"
	
		set rs = Server.CreateObject("ADODB.Recordset")
		rs.open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText

		if rs.EOF then
			recMemberCount = ""
		else
			allMemberData = rs.GetRows(adGetRowsRest)
			recMemberCount = UBound(allMemberData,2)
			meMEMBER_ID = 0
			meM_NAME = 1
		end if

		rs.close
		set rs = nothing

		if recMemberCount <> "" then
			for iMember = 0 to recMemberCount
				MembersMemberID = allMemberData(meMEMBER_ID, iMember)
				MembersMemberName = allMemberData(meM_NAME, iMember)
				Response.Write	"                	<option value=""" & MembersMemberID & """>" & ChkString(MembersMemberName,"display") & "</option>" & vbNewline
			next
		end if
		Response.Write	"                </select> </td></tr>"& vbNewLine



'##
'##  List Forums
'## 
Response.Write		"              <tr>" & vbNewLine & _
			"                <td bgColor=""" & strPopUpTableColor & """ noWrap vAlign=""top"" align=""right""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><b>Category:</b></font></td>" & vbNewLine & _
			"                <td bgColor=""" & strPopUpTableColor & """>" & vbNewLine & _
			"                <select name=""Category"" size=""1"">" & vbNewLine
	'## Forum_SQL
	strSql = "SELECT CAT_ID, CAT_NAME "
	strSql = strSql & " FROM " & strTablePrefix & "CATEGORY "
	if mlev = 3 then 
		strSql = strSql & " WHERE CAT_ID = " & strRqCatID
	end if 
	strSql = strSql & " ORDER BY CAT_ORDER, CAT_NAME ASC;"

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

	if rsCat.EOF then
		recCatCount = ""
	else
		allCatData = rsCat.GetRows(adGetRowsRest)
		recCatCount = UBound(allCatData,2)
	end if

	rsCat.close
	set rsCat = nothing

	if recCatCount <> "" then
		cCAT_ID = 0
		cCAT_NAME = 1

		for iCat = 0 to recCatCount
			CatID = allCatData(cCAT_ID,iCat)
			CatName = allCatData(cCAT_NAME,iCat)

			Response.Write "                	<option value=""" & CatID & """"
			if cLng(strRqCatID) = CatID then
				Response.Write " selected"
			end if
			Response.Write ">" & ChkString(CatName,"display") & "</option>" & vbNewline
		next
	end if
	Response.Write	"                </select>" & vbNewLine & _
			"              </tr>" & vbNewLine & _
			"	       <tr>" & vbNewLine & _
			"                <td bgColor='lightsteelblue' align='center' valign='middle' colspan='2'><input type='submit' value='Subscribe'></td>" & vbNewLine & _
			"              </tr>" & vbNewLine & _
			"	     </table>" & vbNewLine & _
			"	</form>"
end if

%>


<%

sub AddSubscription(SubLevel, Member_ID, CatID, ForumID, TopicID)
	' --- Insert the appropriate sublevel subscription
        strSql = "INSERT INTO " & strTablePrefix & "SUBSCRIPTIONS"
        strSql = strSql & "(MEMBER_ID, CAT_ID, FORUM_ID, TOPIC_ID) VALUES (" & Member_ID & ", "
        if sublevel = "BOARD" then
		strSql = strSql & "0, 0, 0)"
	elseif sublevel = "CAT" then
		strSql = strSql & CatID & ", 0, 0)"
	elseif sublevel = "FORUM" then
		strSql = strSql & CatID & ", " & ForumID & ", 0)"
	else
		strSql = strSql & CatID & ", " & ForumID & ", " & TopicID & ")"
	end if
	my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
	Response.Write	"User was subscribed to "
	Response.Write	"<table border=""0"" cellspacing=""0"" cellpadding=""0"" align=""center"">" & vbNewLine
	if sublevel = "BOARD" then
		Response.Write	"<br />all posts in the " 
		Response.Write	"<br />" & strForumTitle & " forums "
	elseif sublevel = "CAT" then
		strSql = "SELECT " & strTablePrefix & "CATEGORY.CAT_NAME "
		strSql = strSql & "FROM " & strTablePrefix & "CATEGORY "
		strSql = strSql & "WHERE " & strTablePrefix & "CATEGORY.CAT_ID = " & CatID

		set rs = my_Conn.Execute (strSql)
		strCategory = rs("CAT_NAME")

		rs.close
		set rs = nothing

		Response.Write	"<br />all posts in "
		Response.Write	"<br />" & strCategory

	elseif sublevel = "FORUM" then
		strSql = "SELECT " & strTablePrefix & "FORUM.F_SUBJECT "
		strSql = strSql & "FROM " & strTablePrefix & "FORUM "
		strSql = strSql & "WHERE " & strTablePrefix & "FORUM.FORUM_ID = " & ForumId
		set rs = my_Conn.Execute (strSql)
		strForum = rs("F_SUBJECT")

		rs.close
		set rs = nothing

		Response.Write	"<br />all posts in "
		Response.Write	"<br />" & strForum
	else
		Response.Write	"<br />all replies made to this Topic"
	end if
	Response.Write	"</table>" & vbNewline & _
			"</font></p>" & vbNewline & _
			"      <script language=""javascript1.2"">self.opener.location.reload();</script>" & vbNewLine
end sub
%>

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 15 November 2004 :  13:01:56  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
And what should this new file be named? what do you do after you make the new file?

might want to give more details with this...

-Stim
Go to Top of Page

bfeucht
Starting Member

7 Posts

Posted - 30 November 2004 :  16:11:51  Show Profile
Save the file as an ASP with whatever you name you want. (ie admin_subscription.asp)
Upload the file to your websever.
Access the page by either typing in the filename in the address bar or create a link in the admin control panel for it.

This page does NOT check user permisions so anyone who knows the files path will have access to this page. This probably should be fixed but like I said before this is a quick and dirty mod that should probably be developed more.
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.16 seconds. Powered By: Snitz Forums 2000 Version 3.4.07