| 1 | <cfsetting enablecfoutputonly=true> |
|---|
| 2 | <cfprocessingdirective pageencoding="utf-8"> |
|---|
| 3 | <!--- |
|---|
| 4 | Name : C:\projects\blogcfc5\client\admin\mailsubscribers.cfm |
|---|
| 5 | Author : Raymond Camden |
|---|
| 6 | Created : 07/07/06 |
|---|
| 7 | Last Updated : |
|---|
| 8 | History : |
|---|
| 9 | ---> |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | <cfset vSubscribers = application.blog.getSubscribers(true)> |
|---|
| 14 | |
|---|
| 15 | <cfparam name="form.subject" default=""> |
|---|
| 16 | <cfparam name="form.body" default=""> |
|---|
| 17 | |
|---|
| 18 | <cfif structKeyExists(form, "send")> |
|---|
| 19 | |
|---|
| 20 | <cfset errors = arrayNew(1)> |
|---|
| 21 | |
|---|
| 22 | <cfif not len(trim(form.subject))> |
|---|
| 23 | <cfset arrayAppend(errors, "The subject cannot be blank.")> |
|---|
| 24 | </cfif> |
|---|
| 25 | <cfif not len(trim(form.body))> |
|---|
| 26 | <cfset arrayAppend(errors, "The body cannot be blank.")> |
|---|
| 27 | </cfif> |
|---|
| 28 | |
|---|
| 29 | <cfif not arrayLen(errors)> |
|---|
| 30 | |
|---|
| 31 | <cfloop query="vSubscribers"> |
|---|
| 32 | |
|---|
| 33 | <!--- This should maybe be abstracted. It's copied from blog.cfc ---> |
|---|
| 34 | <cfsavecontent variable="link"> |
|---|
| 35 | <cfoutput> |
|---|
| 36 | <p> |
|---|
| 37 | You are receiving this email because you have subscribed to this blog.<br /> |
|---|
| 38 | To unsubscribe, please go to this URL: |
|---|
| 39 | <a href="#application.rooturl#/unsubscribe.cfm?email=#email#&token=#token#">#application.rooturl#/unsubscribe.cfm?email=#email#&token=#token#</a> |
|---|
| 40 | </p> |
|---|
| 41 | </cfoutput> |
|---|
| 42 | </cfsavecontent> |
|---|
| 43 | |
|---|
| 44 | <cfset body = form.body & "<br />" & link> |
|---|
| 45 | |
|---|
| 46 | <cfset application.utils.mail( |
|---|
| 47 | to=email, |
|---|
| 48 | from=application.blog.getProperty("owneremail"), |
|---|
| 49 | subject=form.subject, |
|---|
| 50 | type="html", |
|---|
| 51 | body=body, |
|---|
| 52 | mailserver=application.blog.getProperty("mailserver"), |
|---|
| 53 | mailusername=application.blog.getProperty("mailusername"), |
|---|
| 54 | mailpassword=application.blog.getProperty("mailpassword") |
|---|
| 55 | )> |
|---|
| 56 | |
|---|
| 57 | </cfloop> |
|---|
| 58 | |
|---|
| 59 | <cfset success = true> |
|---|
| 60 | </cfif> |
|---|
| 61 | |
|---|
| 62 | </cfif> |
|---|
| 63 | |
|---|
| 64 | <cfmodule template="../tags/adminlayout.cfm" title="Subscribers"> |
|---|
| 65 | |
|---|
| 66 | <cfoutput> |
|---|
| 67 | <p> |
|---|
| 68 | Your blog currently has |
|---|
| 69 | <cfif vSubscribers.recordCount gt 1> |
|---|
| 70 | #vSubscribers.recordcount# verified subscribers |
|---|
| 71 | <cfelseif vSubscribers.recordCount is 1> |
|---|
| 72 | 1 subscriber |
|---|
| 73 | <cfelse> |
|---|
| 74 | 0 subscribers |
|---|
| 75 | </cfif>. The form below will let you email your subscribers. It will automatically |
|---|
| 76 | add an unsubscribe link to the bottom of the email. HTML is allowed. |
|---|
| 77 | </p> |
|---|
| 78 | </cfoutput> |
|---|
| 79 | |
|---|
| 80 | <cfif vSubscribers.recordCount is 0> |
|---|
| 81 | |
|---|
| 82 | <cfoutput> |
|---|
| 83 | <p> |
|---|
| 84 | Since you do not have any verified subscribers, you will not be able to send a message. |
|---|
| 85 | </p> |
|---|
| 86 | </cfoutput> |
|---|
| 87 | |
|---|
| 88 | <cfelse> |
|---|
| 89 | |
|---|
| 90 | <cfif not structKeyExists(variables, "success")> |
|---|
| 91 | |
|---|
| 92 | <cfif structKeyExists(variables, "errors") and arrayLen(errors)> |
|---|
| 93 | <cfoutput> |
|---|
| 94 | <div class="errors"> |
|---|
| 95 | Please correct the following error(s): |
|---|
| 96 | <ul> |
|---|
| 97 | <cfloop index="x" from="1" to="#arrayLen(errors)#"> |
|---|
| 98 | <li>#errors[x]#</li> |
|---|
| 99 | </cfloop> |
|---|
| 100 | </ul> |
|---|
| 101 | </div> |
|---|
| 102 | </cfoutput> |
|---|
| 103 | </cfif> |
|---|
| 104 | |
|---|
| 105 | <cfoutput> |
|---|
| 106 | <form action="mailsubscribers.cfm" method="post"> |
|---|
| 107 | <table> |
|---|
| 108 | <tr> |
|---|
| 109 | <td align="right">subject:</td> |
|---|
| 110 | <td><input type="text" name="subject" value="#form.subject#" class="txtField" maxlength="255"></td> |
|---|
| 111 | </tr> |
|---|
| 112 | <tr valign="top"> |
|---|
| 113 | <td align="right">body:</td> |
|---|
| 114 | <td><textarea name="body" class="txtArea">#form.body#</textarea></td> |
|---|
| 115 | </tr> |
|---|
| 116 | <tr> |
|---|
| 117 | <td> </td> |
|---|
| 118 | <td><input type="submit" name="cancel" value="Cancel"> <input type="submit" name="send" value="Send"></td> |
|---|
| 119 | </tr> |
|---|
| 120 | </table> |
|---|
| 121 | </form> |
|---|
| 122 | </cfoutput> |
|---|
| 123 | |
|---|
| 124 | <cfelse> |
|---|
| 125 | |
|---|
| 126 | <cfoutput> |
|---|
| 127 | <p> |
|---|
| 128 | Your message has been sent. |
|---|
| 129 | </p> |
|---|
| 130 | </cfoutput> |
|---|
| 131 | |
|---|
| 132 | </cfif> |
|---|
| 133 | |
|---|
| 134 | </cfif> |
|---|
| 135 | |
|---|
| 136 | </cfmodule> |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | <cfsetting enablecfoutputonly=false> |
|---|