root/trunk/website/blog/includes/pods/subscribe.cfm @ 5

Revision 5, 3.6 kB (checked in by DanWilson, 17 years ago)

Initial Commit Of ModelGlue? Website (upgrade to blogcfc 511)

Line 
1<cfsetting enablecfoutputonly=true>
2<cfprocessingdirective pageencoding="utf-8">
3<!---
4        Name         : subscribe.cfm
5        Author       : Raymond Camden
6        Created      : May 12, 2005
7        Last Updated : February 28, 2007
8        History      : Send email for verification (rkc 7/7/06)
9                                 : JavaScript fix, thanks to Charlie (rkc 7/10/06)
10                                 : Make formfield dynamic, thanks Andy Jarret (rkc 8/20/06)
11                                 : Forgot to make JS dynamic, thanks Tom C (rkc 10/29/06)
12                                 : Add a return msg on subscribing. Someone else did this - I forget who.
13        Purpose          : Allow folks to subscribe.
14--->
15
16<!---
17Andy Jarret had suggested renaming the field to help stop spammers.
18I'm making it dynamic in case folks to want to change it quickly on their own blogs.
19--->
20<cfset formField = "user_register">
21
22<!--- confirmation vars --->
23<cfparam name="errorMessage" default="">
24<cfparam name="successMessage" default="">
25
26<!---
27          I know. The caller. syntax is icky. This should be safe since all pods work in the same context.
28          I may move the UDFs to the request scope so it's less icky. At the same time, it's not the big huge of
29          a deal. In fact, I bet no one is even going to read this. If you do, hi, how are you. Send me an email
30          and we can talk about how sometimes it is necessary to break the rules a bit. Then maybe we can have a
31          beer and talk about good sci-fi movies.
32--->
33<cfif structKeyExists(form, formField) and len(trim(form[formField]))>
34        <cfif caller.isEmail(trim(form[formField]))>
35               
36                <cfset token = application.blog.addSubscriber(trim(form[formField]))>
37               
38                <cfif token is not "">
39               
40                        <!--- Now send confirmation email to subscriber --->
41                        <cfsavecontent variable="body">
42                        <cfoutput>
43        #application.resourceBundle.getResource("subscribeconfirmation")#
44                       
45        #application.rooturl#/confirmsubscription.cfm?t=#token#
46                        </cfoutput>
47                        </cfsavecontent>
48       
49                        <cfset application.utils.mail(
50                                        to=form[formField],
51                                        from=application.blog.getProperty("owneremail"),
52                                        subject="#application.blog.getProperty("blogtitle")# #application.resourceBundle.getResource("subscribeconfirm")#",
53                                        type="text",
54                                        body=body,
55                                        mailserver=application.blog.getProperty("mailserver"),
56                                        mailusername=application.blog.getProperty("mailusername"),
57                                        mailpassword=application.blog.getProperty("mailpassword")
58                                        )>
59                <cfset successMessage = "We have received your request.  Please keep an eye on your email; we will send you a link to confirm your subscription.">
60                </cfif>                                                         
61                                               
62        <cfelse> <!--- bad email syntax --->
63                <cfset errorMessage = "Whoops! The email you entered is not valid syntax.">
64        </cfif>
65       
66</cfif>
67
68<cfmodule template="../../tags/podlayout.cfm" title="#application.resourceBundle.getResource("subscribe")#">
69
70        <!--- handle: http://www.coldfusionjedi.com/forums/messages.cfm?threadid=4DF1ED1F-19B9-E658-9D12DBFBCA680CC6 --->
71        <cfset qs = reReplace(cgi.query_string, "<.*?>", "", "all")>
72        <cfset qs = reReplace(qs, "[\<\>]", "", "all")>
73
74        <cfoutput>
75        <div class="center">
76        #application.resourceBundle.getResource("subscribeblog")#
77        <form action="#application.blog.getProperty("blogurl")#?#qs#" method="post" onsubmit="return(this.#formField#.value.length != 0)">
78        <p><input type="text" name="#formField#" size="15"> <input type="submit" value="#application.resourceBundle.getResource("subscribe")#"></p>
79        </form>
80        <cfif len(successMessage)>
81                <span style="color:##00ee00">#successMessage#</span>
82        <cfelseif len(errorMessage)>
83                <span style="color:##ee0000">#errorMessage#</span>
84        </cfif>
85        </div>
86        </cfoutput>
87                       
88</cfmodule>
89       
90<cfsetting enablecfoutputonly=false>
Note: See TracBrowser for help on using the browser.