#INCLUDE WCONNECT.H
DEFINE CLASS TipSubmit AS rbPage
FUNCTION Page()
This.PageTitle = [Submit URL]
This.oData = This.DataObject('-1')
This.Content = this.MergeToString('TipSubmit.htm')
This.Merge('TemplatePage.htm')
ENDFUNC
FUNCTION Submit()
This.oData = This.ReadForm("tip","tipid")
This.oData.PostedDate=DATE()
This.oData.Approved=.f.
IF this.Validate(This.oData) AND This.Save(This.oData)
this.EmailToAdmin()
This.Content = "Thanks for the Tip!<br>"+;
"The Webmaster has been notified.<br>"+;
"Please allow 24 hours for your tip to be approved and show on the site."
This.PageTitle = [Submit Tips]
This.Merge('TemplatePage.htm')
ELSE
This.Content = this.MergeToString('TipSubmit.htm')
This.Merge('TemplatePage.htm')
ENDIF
ENDFUNC
HIDDEN FUNCTION DataObject(tcID)
LOCAL loData
IF NOT USED('TIP')
USE (Site.DataPath + 'TIP.dbf' ) IN 0 SHARED AGAIN
ENDIF
SELECT Tip
IF ( not EMPTY(tcID) ) AND SEEK(tcID, 'TIP', 'TIPID')
SCATTER MEMO NAME loData
ELSE
SCATTER MEMO BLANK NAME loData
endif
RETURN loData
ENDFUNC
HIDDEN Function ReadForm()
LOCAL loDataMan, lcTIPID
lcTIPID = request.form('TIPID')
loDataMan = this.DataObject(lcTIPID)
request.FormVarsToObject(loDataMan)
RETURN loDataMan
ENDFUNC
HIDDEN Function Validate(toData)
This.ErrorMessage=[]
IF EMPTY(toData.Title)
This.AddError([Title must not be blank])
ENDIF
IF EMPTY(toData.PostedBy)
This.AddError([Your Name must not be blank])
ENDIF
IF EMPTY(toData.Email)
This.AddError([Your Email must not be blank])
ENDIF
IF EMPTY(toData.Tip)
This.AddError([Tip must not be blank])
ENDIF
RETURN EMPTY(This.ErrorMessage)
ENDFUNC
HIDDEN Function Save(toData)
IF NOT USED('TIP')
USE (Site.DataPath + 'TIP.dbf' ) IN 0 SHARED AGAIN
ENDIF
SELECT TIP
IF ( not EMPTY(toData.TIPID) ) ;
AND SEEK(toData.TIPID, 'TIP', 'TIPID')
GATHER NAME toData MEMO
ELSE
APPEND BLANK
toData.TIPID=TIP.TIPID
GATHER NAME toData MEMO
endif
ENDFUNC
HIDDEN Function EMailToAdmin()
Server.SendMail( ;
"mail.bricksoftware.com", ;
Site.SiteName, ;
'website@' + site.SiteName + '.org' , ;
'webmaster@' + site.SiteName + '.org', ;
[], ;
"New URL for Approval", ;
'http://www.' + site.SiteName + '.org/UrlApprove.page.fox?SessionID=_6VU00A5EO' )
ENDFUNC
ENDDEFINE
csCodeParser v0.9 stats: 198 lines in 0.01 seconds.