| 1 | <cfsetting enablecfoutputonly=true> |
|---|
| 2 | <!--- |
|---|
| 3 | Name : newpost.cfm |
|---|
| 4 | Author : Raymond Camden |
|---|
| 5 | Created : June 10, 2004 |
|---|
| 6 | Last Updated : May 1, 2007 |
|---|
| 7 | History : Maxlength on title (rkc 8/30/04) |
|---|
| 8 | Support for UUID (rkc 1/27/05) |
|---|
| 9 | Now only does new threads (rkc 3/28/05) |
|---|
| 10 | Subscribe (rkc 7/29/05) |
|---|
| 11 | Refresh user cache on post (rkc 8/3/05) |
|---|
| 12 | Removed mappings (rkc 8/27/05) |
|---|
| 13 | Simple size change (rkc 7/27/06) |
|---|
| 14 | title fix (rkc 8/4/06) |
|---|
| 15 | attachment support (rkc 11/3/06) |
|---|
| 16 | error if attachments disabled (rkc 11/6/06) |
|---|
| 17 | Changed calls to isUserInAnyRole to isTheUserInAnyRole (rkc 5/1/07) |
|---|
| 18 | Purpose : Displays form to add a thread. |
|---|
| 19 | ---> |
|---|
| 20 | |
|---|
| 21 | <cfif not request.udf.isLoggedOn()> |
|---|
| 22 | <cfset thisPage = cgi.script_name & "?" & cgi.query_string> |
|---|
| 23 | <cflocation url="login.cfm?ref=#urlEncodedFormat(thisPage)#" addToken="false"> |
|---|
| 24 | </cfif> |
|---|
| 25 | |
|---|
| 26 | <cfif not isDefined("url.forumid") or not len(url.forumid)> |
|---|
| 27 | <cflocation url="index.cfm" addToken="false"> |
|---|
| 28 | </cfif> |
|---|
| 29 | |
|---|
| 30 | <!--- checks to see if we can post ---> |
|---|
| 31 | <cfset blockedAttempt = false> |
|---|
| 32 | |
|---|
| 33 | <!--- get parents ---> |
|---|
| 34 | <cftry> |
|---|
| 35 | <cfset request.forum = application.galleon.forum.getForum(url.forumid)> |
|---|
| 36 | <cfset request.conference = application.galleon.conference.getConference(request.forum.conferenceidfk)> |
|---|
| 37 | <!--- check both thread and forum for readonly and not admin ---> |
|---|
| 38 | <cfif request.forum.readonly or (isDefined("request.thread") and request.thread.readonly)> |
|---|
| 39 | <cfif not application.galleon.utils.isTheUserInAnyRole("forumsadmin,forumsmoderator")> |
|---|
| 40 | <cfset blockedAttempt = true> |
|---|
| 41 | </cfif> |
|---|
| 42 | </cfif> |
|---|
| 43 | <cfcatch> |
|---|
| 44 | <cflocation url="index.cfm" addToken="false"> |
|---|
| 45 | </cfcatch> |
|---|
| 46 | </cftry> |
|---|
| 47 | |
|---|
| 48 | <cfparam name="form.title" default=""> |
|---|
| 49 | <cfparam name="form.body" default=""> |
|---|
| 50 | <cfparam name="form.subscribe" default="true"> |
|---|
| 51 | <cfparam name="form.oldattachment" default=""> |
|---|
| 52 | <cfparam name="form.attachment" default=""> |
|---|
| 53 | <cfparam name="form.filename" default=""> |
|---|
| 54 | |
|---|
| 55 | <cfif isDefined("form.post") and not blockedAttempt> |
|---|
| 56 | <cfset errors = ""> |
|---|
| 57 | <!--- clean the fields ---> |
|---|
| 58 | <cfset form.title = trim(htmlEditFormat(form.title))> |
|---|
| 59 | <cfset form.body = trim(form.body)> |
|---|
| 60 | |
|---|
| 61 | <cfif not len(form.title)> |
|---|
| 62 | <cfset errors = errors & "You must enter a title.<br>"> |
|---|
| 63 | </cfif> |
|---|
| 64 | |
|---|
| 65 | <cfif not len(form.body)> |
|---|
| 66 | <cfset errors = errors & "You must enter a body.<br>"> |
|---|
| 67 | </cfif> |
|---|
| 68 | |
|---|
| 69 | <cfif len(form.title) gt 255> |
|---|
| 70 | <cfset errors = errors & "Your title is too long.<br>"> |
|---|
| 71 | </cfif> |
|---|
| 72 | |
|---|
| 73 | <cfif isBoolean(request.forum.attachments) and request.forum.attachments and len(trim(form.attachment))> |
|---|
| 74 | <cffile action="upload" destination="#expandPath("./attachments")#" filefield="attachment" nameConflict="makeunique"> |
|---|
| 75 | |
|---|
| 76 | <cfif cffile.fileWasSaved> |
|---|
| 77 | <!--- Is the extension allowed? ---> |
|---|
| 78 | <cfset newFileName = cffile.serverDirectory & "/" & cffile.serverFile> |
|---|
| 79 | <cfset newExtension = cffile.serverFileExt> |
|---|
| 80 | |
|---|
| 81 | <cfif not listFindNoCase(application.galleon.settings.safeExtensions, newExtension)> |
|---|
| 82 | <cfset errors = errors & "Your file did not have a extension. Allowed extensions are: #application.galleon.settings.safeExtensions#.<br>"> |
|---|
| 83 | <cffile action="delete" file="#newFilename#"> |
|---|
| 84 | <cfset form.attachment = ""> |
|---|
| 85 | <cfset form.filename = ""> |
|---|
| 86 | <cfelse> |
|---|
| 87 | <cfset form.oldattachment = cffile.clientFile> |
|---|
| 88 | <cfset form.attachment = cffile.clientFile> |
|---|
| 89 | <cfset form.filename = cffile.serverFile> |
|---|
| 90 | </cfif> |
|---|
| 91 | </cfif> |
|---|
| 92 | <cfelseif len(form.oldattachment)> |
|---|
| 93 | <cfset form.attachment = form.oldattachment> |
|---|
| 94 | </cfif> |
|---|
| 95 | |
|---|
| 96 | <cfif not len(errors)> |
|---|
| 97 | |
|---|
| 98 | <cfset message = structNew()> |
|---|
| 99 | <cfset message.title = form.title> |
|---|
| 100 | <cfset message.body = form.body> |
|---|
| 101 | <cfset message.attachment = form.attachment> |
|---|
| 102 | <cfset message.filename = form.filename> |
|---|
| 103 | |
|---|
| 104 | <cfset args = structNew()> |
|---|
| 105 | <cfset args.message = message> |
|---|
| 106 | <cfset args.forumid = url.forumid> |
|---|
| 107 | <cfset msgid = application.galleon.message.addMessage(argumentCollection=args)> |
|---|
| 108 | <!--- get the message so we can get thread id ---> |
|---|
| 109 | <cfset message = application.galleon.message.getMessage(msgid)> |
|---|
| 110 | |
|---|
| 111 | <cfif form.subscribe> |
|---|
| 112 | <cfset application.galleon.user.subscribe(getAuthUser(), "thread", message.threadidfk)> |
|---|
| 113 | </cfif> |
|---|
| 114 | |
|---|
| 115 | <!--- clear my user info ---> |
|---|
| 116 | <cfset uinfo = request.udf.cachedUserInfo(getAuthUser(), false)> |
|---|
| 117 | |
|---|
| 118 | <cflocation url="messages.cfm?threadid=#message.threadidfk#" addToken="false"> |
|---|
| 119 | </cfif> |
|---|
| 120 | |
|---|
| 121 | </cfif> |
|---|
| 122 | |
|---|
| 123 | <!--- Loads header ---> |
|---|
| 124 | <cfmodule template="tags/layout.cfm" templatename="main" title="#application.galleon.settings.title# : New Post"> |
|---|
| 125 | |
|---|
| 126 | <cfoutput> |
|---|
| 127 | <p> |
|---|
| 128 | <table width="500" cellpadding="6" class="tableDisplay" cellspacing="1" border="0"> |
|---|
| 129 | <tr class="tableHeader"> |
|---|
| 130 | <td class="tableHeader">New Post</td> |
|---|
| 131 | </tr> |
|---|
| 132 | <cfif isDefined("errors")> |
|---|
| 133 | <tr class="tableRowMain"> |
|---|
| 134 | <td> |
|---|
| 135 | Please correct the following error(s):<ul><b>#errors#</b></ul> |
|---|
| 136 | </td> |
|---|
| 137 | </tr> |
|---|
| 138 | </cfif> |
|---|
| 139 | <tr class="tableRowMain"> |
|---|
| 140 | <td> |
|---|
| 141 | <form action="#cgi.script_name#?#cgi.query_string#" method="post" enctype="multipart/form-data"> |
|---|
| 142 | <input type="hidden" name="post" value="1"> |
|---|
| 143 | |
|---|
| 144 | <table> |
|---|
| 145 | <cfif not blockedAttempt> |
|---|
| 146 | <tr> |
|---|
| 147 | <td><b>Title: </b></td> |
|---|
| 148 | <td><input type="text" name="title" value="#form.title#" class="formBox"></td> |
|---|
| 149 | </tr> |
|---|
| 150 | <tr> |
|---|
| 151 | <td colspan="2"><b>Body: </b><br> |
|---|
| 152 | <p> |
|---|
| 153 | #application.galleon.message.renderHelp()# |
|---|
| 154 | </p> |
|---|
| 155 | <textarea name="body" cols="50" rows="20">#form.body#</textarea></td> |
|---|
| 156 | </tr> |
|---|
| 157 | <tr> |
|---|
| 158 | <td><b>Subscribe to Thread: </b></td> |
|---|
| 159 | <td><select name="subscribe"> |
|---|
| 160 | <option value="true" <cfif form.subscribe>selected</cfif>>Yes</option> |
|---|
| 161 | <option value="false" <cfif not form.subscribe>selected</cfif>>No</option> |
|---|
| 162 | </select></td> |
|---|
| 163 | </tr> |
|---|
| 164 | <cfif isBoolean(request.forum.attachments) and request.forum.attachments> |
|---|
| 165 | <tr> |
|---|
| 166 | <td><b>Attach File:</b></td> |
|---|
| 167 | <td> |
|---|
| 168 | <input type="file" name="attachment"> |
|---|
| 169 | <cfif len(form.oldattachment)> |
|---|
| 170 | <input type="hidden" name="oldattachment" value="#form.oldattachment#"> |
|---|
| 171 | <input type="hidden" name="filename" value="#form.filename#"> |
|---|
| 172 | <br> |
|---|
| 173 | File already attached: #form.oldattachment# |
|---|
| 174 | </cfif> |
|---|
| 175 | </td> |
|---|
| 176 | </tr> |
|---|
| 177 | </cfif> |
|---|
| 178 | <tr> |
|---|
| 179 | <td> </td> |
|---|
| 180 | <td align="right"><input type="image" src="images/btn_new_topic.gif" alt="New Topic" title="New Topic" width="71" height="19" name="post"></td> |
|---|
| 181 | </tr> |
|---|
| 182 | <cfelse> |
|---|
| 183 | <tr> |
|---|
| 184 | <td><b>Sorry, but this area is readonly.</b></td> |
|---|
| 185 | </tr> |
|---|
| 186 | </cfif> |
|---|
| 187 | </table> |
|---|
| 188 | </form> |
|---|
| 189 | </td> |
|---|
| 190 | </tr> |
|---|
| 191 | </table> |
|---|
| 192 | </p> |
|---|
| 193 | </cfoutput> |
|---|
| 194 | |
|---|
| 195 | </cfmodule> |
|---|
| 196 | |
|---|
| 197 | <cfsetting enablecfoutputonly=false> |
|---|