home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 November / PCWNOV07.iso / shared / regwiz.cab / RegWizUI.dll / HTML / PROFILE.VBS < prev    next >
Encoding:
Text File  |  2005-07-13  |  7.8 KB  |  308 lines

  1. Option Explicit
  2.  
  3. Function OnProfileBodyLoad()
  4. '{
  5.     Dim sRegWizDataDir, nRegForce
  6.     Dim bOldObfuscate
  7.  
  8.     Call SetExternalObject(gobjExternal)
  9.     Call SetWizardStatus (REGWIZ_ONREBOOT)
  10.  
  11.     sRegWizDataDir = GetRegWizDataDir()
  12.  
  13.     bOldObfuscate = gobjReg.Obfuscate
  14.     gobjReg.Obfuscate = True
  15.         
  16.     txtFName.Value = Trim(CStr(gobjReg.IniGetValue( CStr(sRegWizDataDir & PROFILE_INI), SECTION_USERPROFILE, KEY_FIRSTNAME )))
  17.     txtLName.Value = Trim(CStr(gobjReg.IniGetValue( CStr(sRegWizDataDir & PROFILE_INI), SECTION_USERPROFILE, KEY_LASTNAME )))
  18.     txtEmail.Value = Trim(CStr(gobjReg.IniGetValue( CStr(sRegWizDataDir & PROFILE_INI), SECTION_USERPROFILE, KEY_EMAILADDRESS )))
  19. '    txtREmail.Value = txtEmail.Value
  20.     txtPwd.Value = Trim(CStr(gobjReg.IniGetValue( CStr(sRegWizDataDir & PROFILE_INI), SECTION_USERPROFILE, KEY_PASSWORD )))
  21.     txtRPwd.Value = txtPwd.Value
  22.  
  23.     gobjReg.Obfuscate = bOldObfuscate
  24.  
  25.     ' Hide Cancel button for force registration
  26.     nRegForce = gobjExternal.GetParam ( PROP_FORCE_REG )
  27.  
  28.     If nRegForce = 1 Then
  29.         idProfileCancel.style.display = "none"
  30.     End If
  31. '}
  32. End Function
  33.  
  34. Function OnProfileBack()
  35. '{
  36.     If True = CanShowPage ( KEY_SHOW_EULA ) Then
  37.     '{
  38.         Call window.location.replace (CStr(EULA_HTM))
  39.     '}
  40.     Else
  41.     '{
  42.         Call window.location.replace (CStr(UPROSET_HTM))
  43.     '}
  44.     End If
  45. '}
  46. End Function
  47.  
  48. Function OnProfileCancel()
  49. '{
  50.     Call window.location.replace (CStr(THANKYOU_HTM))
  51. '}
  52. End Function
  53.  
  54. Function LoginUser()
  55. '{
  56.     Dim bInternetConnection, strRegUrl, objRequest
  57.  
  58.     bInternetConnection = False
  59.     bInternetConnection = gobjOS.InternetGetConnectedState()
  60.  
  61.     LoginUser = False
  62.  
  63.     If False = bInternetConnection Then
  64.     '{
  65.         Call LogDetails ( "Profile/Product Setup: No internet connection available" )
  66.         MsgBox STR_CONNECT_TO_INTERNET, VBSystemModal Or VBInformation Or VBOKOnly, STR_APP_ERROR_TITLE
  67.         Exit Function
  68.     '}
  69.     End If
  70.  
  71.     Set objRequest = gobjExternal.GetParam ( PROP_REGREQUEST )
  72.  
  73.     If (Not objRequest Is Nothing) And IsObject(objRequest) Then
  74.     '{
  75.         If True = objRequest.Exists (PROP_PROFILE) Then
  76.         '{
  77.             objRequest.Remove ( PROP_PROFILE )
  78.         '}
  79.         End If
  80.  
  81.         objRequest.Add PROP_PROFILE, Nothing
  82.     '}
  83.     End If
  84.     
  85.     strRegUrl = gobjExternal.GetParam ( PROP_REGURL )
  86.     strRegUrl = strRegUrl & MODE_LOGIN
  87.  
  88.     LoginUser = True
  89.     
  90.     Call LogDetails ( "Profile/Product Setup: submit data to "  & strRegUrl )
  91.     Call window.location.replace (CStr(strRegUrl))
  92. '}
  93. End Function
  94.  
  95. Function SubmitProfile()
  96. '{
  97.     Dim bIsProfileValid, strErrMsg
  98.  
  99.     bIsProfileValid = ValidateProfile( strErrMsg )
  100.  
  101.     If False = bIsProfileValid Then
  102.     '{
  103.         Call LogDetails ( "Profile/Product Setup: Profile not valid" )
  104.         idProfileErrMsg.style.display = ""
  105.         idProfileErrMsg.innerHTML = strErrMsg
  106.         Exit Function
  107.     '}
  108.     End If
  109.  
  110.     Call CacheUserProfileDetails()
  111.     Call RegisterUser()
  112. '}
  113. End Function
  114.  
  115. Function ClickOnce()
  116. '{
  117. '}
  118. End Function
  119.  
  120. Function RegisterUser()
  121. '{
  122.     Dim strRegUrl, strErrMsg
  123.     Dim nRegForce, nSubmitResult
  124.  
  125.     btnProfileSubmit.OnClick = GetRef("ClickOnce")
  126.     btnProfileSubmit.className = "clsStdBtnDisabled"
  127.     btnProfileSubmit.disabled = true
  128.  
  129.     btnProfileBack.OnClick = GetRef("ClickOnce")
  130.     btnProfileBack.className = "clsStdBtnDisabled"
  131.     btnProfileBack.disabled = true
  132.  
  133.     btnProfileCancel.OnClick = GetRef("ClickOnce")
  134.     btnProfileCancel.className = "clsStdBtnDisabled"
  135.     btnProfileCancel.disabled = true
  136.  
  137.  
  138.     nSubmitResult = SubmitDataForRegistration ( MODE_REG )
  139.  
  140.     ' Hide Cancel button for force registration
  141.     nRegForce = gobjExternal.GetParam ( PROP_FORCE_REG )
  142.  
  143.     If REGWIZ_STATUS_NOINTERNET = nSubmitResult Then
  144.     '{
  145.         If 1 = nRegForce Then
  146.         '{
  147.             Call LogDetails ( "Profile/Product Setup: No internet connection available. Goto page : " & SUBMITONCONNECT_HTM )
  148.             Call window.location.replace (CStr(SUBMITONCONNECT_HTM))
  149.         '}
  150.         Else
  151.         '{
  152.             Call LogDetails ( "Profile/Product Setup: No internet connection available. Goto page : " & REMINDME_HTM )
  153.             Call window.location.replace (CStr(REMINDME_HTM))
  154.         '}
  155.         End If
  156.     '}
  157.     End If
  158. '}
  159. End Function
  160.  
  161. Function CacheUserProfileDetails ()
  162. '{
  163.     Dim objRequest, objProfile, objWP
  164.     Dim sRegWizDir
  165.     Dim bOldObfuscate
  166.  
  167.     Call LogDetails ( "Profile/Product Setup: Cache user profile details" )
  168.  
  169.     sRegWizDir = GetRegWizDataDir()
  170.  
  171.     bOldObfuscate = gobjReg.Obfuscate
  172.     gobjReg.Obfuscate = True
  173.  
  174.     Call gobjReg.IniWriteValue( CStr(sRegWizDir & PROFILE_INI), SECTION_USERPROFILE, KEY_FIRSTNAME, CStr(txtFName.Value) )
  175.     Call gobjReg.IniWriteValue( CStr(sRegWizDir & PROFILE_INI), SECTION_USERPROFILE, KEY_LASTNAME, CStr(txtLName.Value) )
  176.     Call gobjReg.IniWriteValue( CStr(sRegWizDir & PROFILE_INI), SECTION_USERPROFILE, KEY_EMAILADDRESS, CStr(txtEmail.Value) )
  177.     Call gobjReg.IniWriteValue( CStr(sRegWizDir & PROFILE_INI), SECTION_USERPROFILE, KEY_PASSWORD, CStr(txtPwd.Value) )
  178.     Call gobjReg.IniWriteValue( CStr(sRegWizDir & PROFILE_INI), SECTION_USERPROFILE, KEY_LANGUAGE, CStr(REGWIZ_LANG_ID) )
  179.     Call gobjReg.IniWriteValue( CStr(sRegWizDir & PROFILE_INI), SECTION_USERPROFILE, KEY_COUNTRY, CStr(USER_PROFILE_COUNTRY) )
  180.  
  181.     gobjReg.Obfuscate = bOldObfuscate
  182.  
  183.     Set objRequest = gobjExternal.GetParam ( PROP_REGREQUEST )
  184.  
  185.     If (Not objRequest Is Nothing) And IsObject(objRequest) Then
  186.     '{
  187.         If True = objRequest.Exists (PROP_PROFILE) Then
  188.         '{
  189.             objRequest.Remove ( PROP_PROFILE )
  190.         '}
  191.         End If
  192.  
  193.         Set objProfile = CreateObject ( "Scripting.Dictionary" )
  194.  
  195.         objProfile.Add PROP_FIRSTNAME, txtFName.Value
  196.         objProfile.Add PROP_LASTNAME, txtLName.Value
  197.         objProfile.Add PROP_EMAILADDRESS, txtEmail.Value
  198.         objProfile.Add PROP_PASSWORD, txtPwd.Value
  199.         objProfile.Add PROP_COUNTRY, USER_PROFILE_COUNTRY
  200.  
  201.         If True = objRequest.Exists (PROP_WIZARDPARAM) Then
  202.         '{
  203.             Set objWP = objRequest.Item (PROP_WIZARDPARAM)
  204.  
  205.             If IsObject(objWP) Then
  206.             '{
  207.                 objProfile.Add PROP_LANGUAGE, objWP.Item(PROP_LANGUAGE)
  208.             '}
  209.             Else
  210.                 objProfile.Add PROP_LANGUAGE, REGWIZ_LANG_ID
  211.             End If
  212.         '}
  213.         Else
  214.             objProfile.Add PROP_LANGUAGE, REGWIZ_LANG_ID
  215.         End If
  216.  
  217.         objRequest.Add PROP_PROFILE, objProfile
  218.     '}
  219.     End If
  220. '}
  221. End Function
  222.  
  223. Function ValidateProfile( ByRef strErrMsg )
  224. '{
  225.     Dim sFName, sLName, sEmail, sPwd, sRPwd, bPwdFlag
  226.  
  227.     sFName = Trim(txtFName.Value)
  228.     sLName = Trim(txtLName.Value)
  229.     sEmail = Trim(txtEmail.Value)
  230.     sPwd   = Trim(txtPwd.Value)
  231.     sRPwd  = Trim(txtRPwd.Value)
  232.  
  233.     ValidateProfile = True
  234.     bPwdFlag = True
  235.     strErrMsg = ""
  236.  
  237.     idFN.className = "noErrorFields"
  238.     idLN.className = "noErrorFields"
  239.     idEmail.className = "noErrorFields"
  240.     idPwd.className = "noErrorFields"
  241.     idRPwd.className = "noErrorFields"
  242.  
  243.     If False = CheckFields(sFName) Then 
  244.     '{
  245.         strErrMsg = REGWIZ_ERR_MSG_ENTER_FIRSTNAME & "|"
  246.         idFN.className = "errorFields"
  247.     '}
  248.     End If
  249.  
  250.     If False = CheckFields(sLName) Then 
  251.     '{
  252.         strErrMsg = strErrMsg & REGWIZ_ERR_MSG_ENTER_LASTNAME & "|"
  253.         idLN.className = "errorFields"
  254.     '}
  255.     End If
  256.  
  257.     If False = CheckFields(sEmail) Then
  258.     '{
  259.         strErrMsg = strErrMsg & REGWIZ_ERR_MSG_ENTER_EMAIL & "|"
  260.         idEmail.className = "errorFields"
  261.     '}
  262.     ElseIf     False = CheckEmail(sEmail) Then
  263.     '{
  264.         strErrMsg = strErrMsg & REGWIZ_ERR_MSG_ENTER_VALID_EMAIL & "|"
  265.         idEmail.className = "errorFields"
  266.     '}
  267.     End If
  268.  
  269.     If False = CheckFields(sPwd) Then 
  270.     '{
  271.         strErrMsg = strErrMsg & REGWIZ_ERR_MSG_ENTER_PWD & "|"
  272.         bPwdFlag = False
  273.     '}
  274.     ElseIf False = CheckPassword(sPwd) Then
  275.     '{
  276.         strErrMsg = strErrMsg & REGWIZ_ERR_MSG_PWD_LENGTH & "|"
  277.         bPwdFlag = False
  278.     '}
  279.     ElseIf sPwd <> sRPwd Then 
  280.     '{
  281.         strErrMsg = strErrMsg & REGWIZ_ERR_MSG_PWD_NO_MATCH & "|"
  282.         bPwdFlag = False
  283.     '}
  284.     End If
  285.  
  286.     If bPwdFlag = False Then
  287.     '{
  288.         idPwd.className = "errorFields"
  289.         idRPwd.className = "errorFields"
  290.         txtPwd.value = ""
  291.         txtRPwd.value = ""
  292.     '}
  293.     End If
  294.  
  295.     If "" <> strErrMsg Then
  296.     '{
  297.         strErrMsg = Left(strErrMsg, Len(strErrMsg)-1)
  298.  
  299.         If InStr (strErrMsg, "|")  > 0 Then
  300.         '{
  301.             strErrMsg = REGWIZ_ERR_MSG_MULTI_FIELDS
  302.         '}
  303.         End If
  304.         ValidateProfile = False
  305.     '}
  306.     End If
  307. '}
  308. End Function