%
'Include Security
'do not include security because this file is referenced from the client side
'Server.Execute("/admin/includes/popup_security.asp")
%>
<%'Include Data Connection%>
<%'Include ADO constants include file for VBScript%>
<%
'open data connection
OpenConn()
%>
<%'Include Utility Scripts%>
<%
'dim strMode - The strMode variable is defined in the header_inc.asp file.
Dim intIsAllGroups
dim strFirstName
dim strLastName
dim strEmail
dim strOrganization
dim strRelevantEducation
dim intFirstDegreeObtainedCountryId
dim bolByName
dim intContactTypeId
dim strSubscriberType
dim intSubscriberId
dim strEmploymentStatus
dim strStatementOfInterest
dim intYearsOfProfessionalExperience
dim bolActive
dim strActive
dim intItem
dim strCheckBoxName
dim intCheckBoxValue
dim intTempCheckBoxValue
dim arrCheckBoxValues
dim intInsertCounter
dim intCheckEmptyValue
If Request.Form <> "" Then
'BEGIN: ADD/EDIT (DB TRANSACTION)
dim strDel
dim arPostingTypes
dim intSusbscriberPostingTypeCounter
dim strUserFeedback
dim intSubscriberIsLive
dim strRefererURL
'get form elements values
strMode = Request.Form("txtMode")
strFirstName = Request.Form("txtFirstName")
strLastName = Request.Form("txtLastName")
strEmail = Request.Form("txtEmail")
strOrganization = Request.Form("txtOrganization")
intSubscriberId = Request.Form("txtId")
strDel = Request.Form("txtDelimiter")
strSubscriberType = Request.Form("txtSubscriberType")
strRefererURL = Request.Form("txtRefererURL")
arPostingTypes = Split(Request.Form("txtSelected"), strDel)
strRelevantEducation = Request.Form("txtRelevantEducation")
intFirstDegreeObtainedCountryId = CInt(Request.Form("selCountry"))
intContactTypeId = CInt(Request.Form("selContactType"))
strEmploymentStatus = Request.Form("selEmploymentStatus")
strStatementOfInterest = Request.Form("txtStatementOfInterest")
intYearsOfProfessionalExperience = Request.Form("txtYearsOfProExperience")
bolActive = Request.Form("checkboxActive")
if Request.Form("checkboxActive") = 1 then
bolactive = 1
else
bolactive = 0
end if
'if new subscriber is live then...
If strSubscriberType = "live" Then
intSubscriberIsLive = 1
Else
intSubscriberIsLive = 0
End If
'if the application is in 'edit' mode
If LCase(strMode) = "edit" Then
dim intAllGroups
'modify Posting Type Name
Call ModifySubscriber(CInt(intSubscriberId), strFirstName, strLastName, strEmail, strOrganization, intSubscriberIsLive, strRelevantEducation, intFirstDegreeObtainedCountryId, intContactTypeId, strEmploymentStatus, strStatementOfInterest, intYearsOfProfessionalExperience, bolActive)
'delete posting type records related to the selected subscriber id
Call Delete_Subscriber_PostingType(intSubscriberId)
Call Delete_LookUpSubscriber(intSubscriberId)
'if the application is in 'add' mode
Else
'verify the subscriber's existence
intSubscriberId = VerifySubscribersExistence(strEmail, intSubscriberIsLive)
'if the susbscriber does not exist then...
If intSubscriberId = "" Then
'response.write Request.Form("txtRelevantEducation") &"
"
'add Subscriber
intSubscriberId = AddSubscriber(strFirstName, strLastName, strEmail, strOrganization, intSubscriberIsLive, strRelevantEducation, intFirstDegreeObtainedCountryId, intContactTypeId, strEmploymentStatus, strStatementOfInterest, intYearsOfProfessionalExperience, bolActive)
'Get all the checkboxes' value
'if the susbscriber does exist then...
Else
'modify Posting Type Name
Call ModifySubscriber(CInt(intSubscriberId), strFirstName, strLastName, strEmail, strOrganization, intSubscriberIsLive, strRelevantEducation, intFirstDegreeObtainedCountryId, intContactTypeId, strEmploymentStatus, strStatementOfInterest, intYearsOfProfessionalExperience, bolActive)
'delete posting type records related to the selected subscriber id
Call Delete_Subscriber_PostingType(intSubscriberId)
End If
End If
Call Delete_LookUpSubscriber(intSubscriberId)
'Get all the checkboxes' value
For Each intItem In Request.Form
If inStr(intItem,"AllGroups") > 0 Then
'if allgroups is checked dont do the rest
intCheckBoxValue = 1
intIsAllGroups = 1
elseif Request("AllGroups") <> "1" then
intIsAllGroups = 0
If inStr(intItem,"chk") Then
strCheckBoxName = Right(intItem, Len(intItem)-3)
intTempCheckBoxValue = Request("chk"& CStr(strCheckBoxName)) &","
intCheckBoxValue = intCheckBoxValue & intTempCheckBoxValue
End if
End if
Next
'if no groups are selected, make Other the default value
if intCheckBoxValue = "" then
intCheckBoxValue = 5
intIsAllGroups = 1
end if
if intIsAllGroups = 0 then
'if all groups isnt checked then enter in the new groups for the user
intCheckBoxValue = Left(intCheckBoxValue, Len(intCheckBoxValue)-1)
arrCheckBoxValues = Split(intCheckBoxValue, ",")
For intInsertCounter = Lbound(arrCheckBoxValues) to Ubound(arrCheckBoxValues)
'if there is an array value then...
If arrCheckBoxValues(intInsertCounter) <> "" Then
Call InsertUserGroups(intSubscriberId, CInt(arrCheckBoxValues(intInsertCounter)))
End If
Next
else
'If allgroups is checked or Other is the default group...enter in one group
Call InsertUserGroups(intSubscriberId, CInt(intCheckBoxValue))
end if
'for each posting type...
For intSusbscriberPostingTypeCounter = LBound(arPostingTypes) To UBound(arPostingTypes)
'if the array item is not an empty string then...
If Trim(arPostingTypes(intSusbscriberPostingTypeCounter)) <> "" Then
'add a posting type record related to the subscriber
Call Add_Subscriber_PostingType(arPostingTypes(intSusbscriberPostingTypeCounter), intSubscriberId)
End If
Next
'if the this transaction is initiated from the client (user) side of the site then...
If strRefererURL <> "" Then
'if any error occurred then...
If err.number <> 0 Then
'set the querystring with the error code
strRefererURL = strRefererURL & "?subscribed=" & err.number
'if no errors occurred then...
Else
'set the querystring with ok
strRefererURL = strRefererURL & "?subscribed=ok"
End If
'redirect the user to the refering page and inform the user of the occurence of any errors
Response.Redirect(strRefererURL)
End If
'give the user feedback with regards to the success of the add/edit database transaction
Session("FeedbackMode") = LCase(strMode)
Session("FeedbackError") = err.number
Session("FeedbackModule") = "subscriber"
Response.Write("")
Response.Write("")
'Server.Execute("/admin/feedback.asp")
'END: ADD/EDIT (DB TRANSACTION)
Else
'BEGIN: INPUT (ADD/EDIT)
'get the application's transaction mode
strMode = Trim(Request.QueryString("mode"))
'get the subscriber's type
strSubscriberType = Trim(Request.QueryString("type"))
'if application is in edit mode then...
If LCase(strMode) = "edit" Then
'begin: get current Posting Type info to be edited
dim rsSubscriber
intSubscriberId = Trim(Request.QueryString("id"))
'if intSubscriberId is not a valid value then...
If Not IsNumeric(intSubscriberId) or Not (intSubscriberId <> "") Then
'close the window
Response.write("")
'if intSubscriberId is a valid value then...
Else
'get the related Subscriber information
Set rsSubscriber = GetSelectedSubscriber(CInt(intSubscriberId))
End If
'if intSubscriberId does not relate to an existing Subscriber id then...
If rsSubscriber.EOF Then
'release the recordset from memory
rsSubscriber.Close
set rsSubscriber = Nothing
'release the connection object from memory before closing the window
conn.Close
Set conn = Nothing
'close the window
Response.write("")
'if intSubscriberId does relate to an existing Subscriber id then...
Else
'get the subscriber information into the relevant variables
strFirstName = rsSubscriber("SUBSCRIBER_FIRST_NAME")
strLastName = rsSubscriber("SUBSCRIBER_LAST_NAME")
strEmail = rsSubscriber("SUBSCRIBER_EMAIL")
strOrganization = rsSubscriber("SUBSCRIBER_ORGANIZATION")
intContactTypeId = rsSubscriber("CONTACT_TYPE_ID")
intFirstDegreeObtainedCountryId = rsSubscriber("SUBSCRIBER_COUNTRY_OF_FIRST_DEGREE")
strRelevantEducation = rsSubscriber("SUBSCRIBER_RELEVANT_EDUCATION")
strEmploymentStatus = rsSubscriber("SUBSCRIBER_EMPLOYMENT_STATUS")
strStatementOfInterest = rsSubscriber("SUBSCRIBER_STATEMENT_OF_INTEREST")
intYearsOfProfessionalExperience = rsSubscriber("SUBSCRIBER_YEARS_OF_PROFESSIONAL_EXPERIENCE")
bolActive = rsSubscriber("SUBSCRIBER_IS_ACTIVE")
'release the recordset from memory
rsSubscriber.Close
set rsSubscriber = Nothing
End If
'end: get current subscriber info to be edited
'if application is in add mode then...
Else
strFirstName = ""
strLastName = ""
strOrganization = ""
End If
%>