Web Connect How To : Show Me the Code!

 LAFOX Home How URL Maps to Code  LAFOX Design Oveview  Framework Extensions 
*Jobboardsubmit.prg * JobBoardSubmit.prg * 03/08/2002-pa #INCLUDE WCONNECT.H ************************************************************* DEFINE CLASS JobBoardSubmit AS rbPage ************************************************************* ********************************************************** ** Page() - PUBLIC - ** Show Job Board submit page ********************************************************** FUNCTION Page() STORE .NULL. to This.oData && always init our vars ** create a blank data object - table has char(10) for the xID col This.oData = This.DataObject("JobBoard","JobBoardID",'-1') ** Merge the page fragment (always a blank entry form) This.Content = this.MergeToString('JobBoardSubmit.htm') ** Merge the final page This.PageTitle = [Submit a Job] This.Merge('TemplatePage.htm') ENDFUNC ********************************************************** ** Submit() - PUBLIC - ** ********************************************************** FUNCTION Submit() This.PageTitle = [Submit Job] ** Read Form This.oData = This.ReadForm("JobBoard","JobBoardID") This.oData.Approved = .F. This.oData.DatePosted = DATE() ** validate & save IF this.Validate(This.oData) AND This.Save("JobBoard","JobBoardID",This.oData) ** Email to admin this.EmailToAdmin() ** Email to address posted with the new job this.EmailToJobPoster(This.oData.Email) ** Show thank you page (WaitWindow.htm) ** and re-direct to the home page ** params for WaitWindow.htm This.WaitWindow("Record Saved!", "/Home.Page.fox?SessionID=_6FN1AN0FD") ELSE ** failed validation so redisplay page ** Merge the page fragment with the user entered data values ** pcError (set in this.validate() ) is displayed at top of page This.Content = this.MergeToString('JobBoardSubmit.htm') ** Display the page with the main menu ** Merge the final page This.Merge('TemplatePage.htm') ENDIF ENDFUNC **************************************************************** ** Helper Functions Below **************************************************************** ********************************************************** ** Validate(tcError) ** tcError must be passed by reference ** (for Perry - the tag <br> is a line feed - use if multiple errors ) ** Is the submitted form OK? ********************************************************** HIDDEN Function Validate(toData) This.ErrorMessage = [] * use iif() so the function contains less lines This.AddConditionalError(EMPTY(toData.Company), [Company must not be blank]) This.AddConditionalError(EMPTY(toData.Contact), [Contact must not be blank]) This.AddConditionalError(EMPTY(toData.Phone), [Phone must not be blank]) This.AddConditionalError(EMPTY(toData.Fax), [Fax must not be blank]) This.AddConditionalError(EMPTY(toData.Email), [Email must not be blank]) This.AddConditionalError(EMPTY(toData.Position), [Position must not be blank]) This.AddConditionalError(EMPTY(toData.Description), [Description must not be blank]) * return .f. if any errors RETURN EMPTY(This.ErrorMessage) ENDFUNC ********************************************************** ** EMailToAdmin() ********************************************************** HIDDEN Function EMailToAdmin() ** Ask for approval ** Include link to approval page *** Pass: tcMailServer - IP Address or domain name of the server *** tcSenderName - Sender Display Name (Rick Strahl) *** tcSenderMailAddress Sender's full email address (rstrahl@west-wind.com) *** tcRecipientList - Recipients separated by commas (ben@test.com, jim@test.com) *** tcCCList - List of CCs separated by commas *** tcSubject - Subject Header *** tcMessage - Message Body *** tcAttachement - Not supported any longer *** tcBCC - BCC List Server.SendMail( ; "mail.bricksoftware.com",; Site.SiteName, ; 'website@' + site.SiteName + '.org' ,; 'webmaster@' + site.SiteName + '.org', ; [], ; "New Job for Approval",; 'http://www.' + site.SiteName + '.org/JobBoardApprove.page.fox?SessionID=_6FN1AN0FD' ) ENDFUNC ********************************************************** ** EMailToJobPoster() ********************************************************** HIDDEN Function EMailToJobPoster(tcEmailTo) ** Send thank you email to job poster *** Pass: tcMailServer - IP Address or domain name of the server *** tcSenderName - Sender Display Name (Rick Strahl) *** tcSenderMailAddress Sender's full email address (rstrahl@west-wind.com) *** tcRecipientList - Recipients separated by commas (ben@test.com, jim@test.com) *** tcCCList - List of CCs separated by commas *** tcSubject - Subject Header *** tcMessage - Message Body *** tcAttachement - Not supported any longer *** tcBCC - BCC List Server.SendMail( ; "mail.bricksoftware.com",; site.SiteName, ; 'website@' + site.SiteName + '.org' ,; tcEmailTo, ; [], ; "Thanks for Submitting Your Job",; 'An Adminsitrator will review your Job Posting and add it to the web site.' ) ENDFUNC ENDDEFINE
csCodeParser v0.9 stats: 147 lines in 0.00 seconds.