root/trunk/website/forums/messages.cfm @ 21

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

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

Line 
1<cfsetting enablecfoutputonly=true>
2<!---
3        Name         : messages.cfm
4        Author       : Raymond Camden
5        Created      : June 10, 2004
6        Last Updated : May 1, 2007
7        History      : Support for UUID (rkc 1/27/05)
8                                   Update to allow posting here (rkc 3/31/05)
9                                   Fixed code that gets # of pages (rkc 4/8/05)
10                                   Hide the darn error msg if errors is blank, links to messages (rkc 7/15/05)
11                                   Form posts so that if error, you go back down to form. If no error, you cflocate to top (rkc 7/29/05)
12                                   Have subscribe option (rkc 7/29/05)
13                                   Refresh user cache on post, change links a bit (rkc 8/3/05)                         
14                                   Fix typo (rkc 8/9/05)
15                                   Fix pages. Add anchor for last post (rkc 9/15/05)
16                                   It's possible form.title and form.body may not exist and my code didn't handle it (rkc 10/7/05)
17                                   IE cflocation bug fix, ensure logged on before posting (rkc 10/10/05)
18                                   Simple size change (rkc 7/27/06)
19                                   gravatar, sig, attachments (rkc 11/3/06)
20                                   bug when no attachment (rkc 11/6/06)
21                                   lcase the hash for gravatar (rkc 12/18/06)
22                                   Use renderMessage, bd fix (rkc 2/21/07)
23                                   Changed calls to isUserInAnyRole to isTheUserInAnyRole (rkc 5/1/07)                                                                                                     
24        Purpose          : Displays messages for a thread
25--->
26
27<cfif not isDefined("url.threadid") or not len(url.threadid)>
28        <cflocation url="index.cfm" addToken="false">
29</cfif>
30
31<!--- get parents --->
32<cftry>
33        <cfset request.thread = application.galleon.thread.getThread(url.threadid)>
34        <cfset request.forum = application.galleon.forum.getForum(request.thread.forumidfk)>
35        <cfset request.conference = application.galleon.conference.getConference(request.forum.conferenceidfk)>
36        <cfcatch>
37                <cflocation url="index.cfm" addToken="false">
38        </cfcatch>
39</cftry>
40
41<!--- determine if read only --->
42<cfif request.forum.readonly or request.thread.readonly>
43        <cfset readonly = true>
44<cfelse>
45        <cfset readonly = false>
46</cfif>
47
48<!--- handle new post --->
49<cfparam name="form.title" default="RE: #request.thread.name#">
50<cfparam name="form.body" default="">
51<cfparam name="form.subscribe" default="true">
52<cfparam name="form.oldattachment" default="">
53<cfparam name="form.attachment" default="">
54<cfparam name="form.filename" default="">
55
56<cfif isDefined("form.post") and request.udf.isLoggedOn() and (application.galleon.utils.isTheUserInAnyRole("forumsadmin,forumsmoderator") or (not readonly))>
57
58        <cfset errors = "">
59        <!--- clean the fields --->
60        <!--- Added the params since its possible someone could remove them. --->
61        <cfparam name="form.title" default="">
62        <cfparam name="form.body" default="">
63       
64        <cfset form.title = trim(htmlEditFormat(form.title))>
65        <cfset form.body = trim(form.body)>
66       
67        <cfif not len(form.title)>
68                <cfset errors = errors & "You must enter a title.<br>">
69        </cfif>
70       
71        <cfif not len(form.body)>
72                <cfset errors = errors & "You must enter a body.<br>">
73        </cfif>
74       
75        <cfif len(form.title) gt 255>
76                <cfset errors = errors & "Your title is too long.<br>">
77        </cfif>
78
79        <cfif isBoolean(request.forum.attachments) and request.forum.attachments and len(trim(form.attachment))>
80                <cffile action="upload" destination="#expandPath("./attachments")#" filefield="attachment" nameConflict="makeunique">
81               
82                <cfif cffile.fileWasSaved>
83                        <!--- Is the extension allowed? --->
84                        <cfset newFileName = cffile.serverDirectory & "/" & cffile.serverFile>
85                        <cfset newExtension = cffile.serverFileExt>
86                       
87                        <cfif not listFindNoCase(application.galleon.settings.safeExtensions, newExtension)>
88                                <cfset errors = errors & "Your file did not have a extension. Allowed extensions are: #application.galleon.settings.safeExtensions#.<br>">
89                                <cffile action="delete" file="#newFilename#">
90                                <cfset form.attachment = "">
91                                <cfset form.filename = "">
92                        <cfelse>
93                                <cfset form.oldattachment = cffile.clientFile>
94                                <cfset form.attachment = cffile.clientFile>
95                                <cfset form.filename = cffile.serverFile>
96                        </cfif>
97                </cfif>
98        <cfelseif len(form.oldattachment)>
99                <cfset form.attachment = form.oldattachment>
100        </cfif>
101       
102        <cfif not len(errors)>
103                <cfset message = structNew()>
104                <cfset message.title = form.title>
105                <cfset message.body = form.body>
106                <cfset message.attachment = form.attachment>
107                <cfset message.filename = form.filename>
108               
109                <cfset args = structNew()>
110                <cfset args.message = message>
111                <cfset args.forumid = request.forum.id>
112                <cfset args.threadid = url.threadid>
113                <cfset msgid = application.galleon.message.addMessage(argumentCollection=args)>
114                <cfif form.subscribe>
115                        <cfset application.galleon.user.subscribe(getAuthUser(), "thread", url.threadid)>
116                </cfif>
117               
118                <!--- clear my user info --->
119                <cfset uinfo = request.udf.cachedUserInfo(getAuthUser(), false)>
120
121                <cflocation url="messages.cfm?threadid=#url.threadid#&##top" addToken="false">
122        </cfif>
123       
124</cfif>
125
126<!--- get my messages --->
127<cfset data = application.galleon.message.getMessages(threadid=request.thread.id)>
128
129<!--- Loads header --->
130<cfmodule template="tags/layout.cfm" templatename="main" title="#application.galleon.settings.title# : #request.conference.name# : #request.forum.name# : #request.thread.name#">
131
132<!--- determine max pages --->
133<cfif data.recordCount and data.recordCount gt application.galleon.settings.perpage>
134        <cfset pages = ceiling(data.recordCount / application.galleon.settings.perpage)>
135<cfelse>
136        <cfset pages = 1>
137</cfif>
138
139<!--- Displays pagination on right side, plus left side buttons for threads --->
140<cfmodule template="tags/pagination.cfm" pages="#pages#" mode="messages" />
141
142<!--- Now display the table. This changes based on what our data is. --->
143<cfoutput>
144<a name="top" />
145<p>
146<table width="100%" cellpadding="6" class="tableDisplay" cellspacing="1" border="0">
147        <tr class="tableHeader">
148                <td colspan="2" class="tableHeader">Thread: #request.thread.name#</td>
149        </tr>
150        <tr class="tableSubHeader">
151                <td class="tableSubHeader" colspan="2">
152                        <table width="100%" cellpadding="0" cellspacing="0" border="0">
153                                <tr>
154                                <td><b>Created on:</b> #dateFormat(request.thread.dateCreated,"mm/dd/yy")# #timeFormat(request.thread.dateCreated,"hh:mm tt")#</td>
155                                <td align="right"><b>Replies:</b> #max(0,data.recordCount-1)#</td>
156                                </tr>
157                        </table>
158                </td>
159        </tr>
160        <cfif data.recordCount>
161                <cfloop query="data" startrow="#(url.page-1)*application.galleon.settings.perpage+1#" endrow="#(url.page-1)*application.galleon.settings.perpage+application.galleon.settings.perpage#">
162                        <cfset uinfo = request.udf.cachedUserInfo(username)>
163                        <tr class="tableRow#currentRow mod 2#" valign="top">
164                                <td width="170" class="tableMessageCell" rowspan="2"><b>#username#</b><br>
165                                #uInfo.rank#<br>
166                                <cfif application.galleon.settings.allowgravatars>
167                                <img src="http://www.gravatar.com/avatar.php?gravatar_id=#lcase(hash(uinfo.emailaddress))#&amp;rating=PG&amp;size=80&amp;default=#application.galleon.settings.rooturl#/images/gravatar.gif" alt="#username#'s Gravatar" border="0">
168                                </cfif>
169                                <br>
170                                <b>Joined:</b> #dateFormat(uInfo.dateCreated,"mm/dd/yy")#<br>
171                                <b>Posts:</b> #uInfo.postcount#</td>
172                                <td class="tableMessageCellRight">
173                                        <a name="#currentRow#"></a>
174                                        <cfif currentRow is recordCount><a name="last"></a></cfif>
175                                        <b>#title#</b><br>
176                                        #dateFormat(posted,"mm/dd/yy")# #timeFormat(posted,"h:mm tt")#<br>
177                                        <cfif len(attachment)>Attachment: <a href="attachment.cfm?id=#id#">#attachment#</a><br></cfif>
178                                        <br>
179                                        <!---
180                                        #request.udf.paragraphFormat2(request.udf.activateURL(body))#
181                                        --->
182                                        #application.galleon.message.renderMessage(body)#
183                                       
184                                        <cfif len(uinfo.signature)><div class="signature">#uinfo.signature#</div></cfif>
185                                       
186                                        <cfif request.udf.isLoggedOn() and application.galleon.utils.isTheUserInAnyRole("forumsadmin,forumsmoderator")>
187                                        <p align="right"><a href="message_edit.cfm?id=#id#">[Edit Post]</a></p>
188                                        </cfif>
189                                </td>
190                        </tr>
191                        <tr>
192                                <td class="tableMessageCellRight" align="right">
193                                <cfif isBoolean(cgi.server_port_secure) and cgi.server_port_secure>
194                                        <cfset pre = "https">
195                                <cfelse>
196                                        <cfset pre = "http">
197                                </cfif>
198                                <cfset link = "#pre#://#cgi.server_name##cgi.script_name#?#cgi.query_string####currentrow#">
199                                <span class="linktext"><a href="#link#">Link</a> | <a href="##top">Top</a> | <a href="##bottom">Bottom</a></span>
200                                </td>
201                        </tr>
202                </cfloop>
203        <cfelse>
204                <tr class="tableRow1">
205                        <td colspan="2">Sorry, but there are no messages available for this thread.</td>
206                </tr>
207        </cfif>
208</table>
209</p>
210<a name="bottom" />
211</cfoutput>
212
213<cfoutput>
214<a name="newpost" />
215<p>
216<table width="100%" cellpadding="6" class="tableDisplay" cellspacing="1" border="0">
217        <tr class="tableHeader">
218                <td class="tableHeader">New Post</td>
219        </tr>
220        <cfif isDefined("errors") and len(errors)>
221        <tr class="tableRowMain">
222                <td>
223                Please correct the following error(s):<ul><b>#errors#</b></ul>
224                </td>
225        </tr>
226        </cfif>
227        <tr class="tableRowMain">
228                <td>
229                <form action="#cgi.script_name#?#cgi.query_string#&##newpost" method="post" enctype="multipart/form-data">
230                <input type="hidden" name="post" value="1">
231
232                <table>
233                        <cfif not request.udf.isLoggedOn()>
234                                <cfset thisPage = cgi.script_name & "?" & cgi.query_string & "&##newpost">
235                                <cfset link = "login.cfm?ref=#urlEncodedFormat(thisPage)#">
236
237                                <tr>
238                                        <td>Please <a href="#link#">login</a> to post a response.</td>
239                                </tr>
240                        <cfelseif application.galleon.utils.isTheUserInAnyRole("forumsadmin,forumsmoderator") or not readonly>
241                                <tr>
242                                        <td><b>Title: </b></td>
243                                        <td><input type="text" name="title" value="#form.title#" class="formBox"></td>
244                                </tr>
245                                <tr>
246                                        <td colspan="2"><b>Body: </b><br>
247                                        <p>
248                                        #application.galleon.message.renderHelp()#
249                                        </p>
250                                        <textarea name="body" cols="50" rows="20">#form.body#</textarea></td>
251                                </tr>
252                                <tr>
253                                        <td><b>Subscribe to Thread: </b></td>
254                                        <td><select name="subscribe">
255                                        <option value="true" <cfif form.subscribe>selected</cfif>>Yes</option>
256                                        <option value="false" <cfif not form.subscribe>selected</cfif>>No</option>
257                                        </select></td>
258                                </tr>
259                                <cfif isBoolean(request.forum.attachments) and request.forum.attachments>
260                                <tr>
261                                        <td><b>Attach File:</b></td>
262                                        <td>
263                                        <input type="file" name="attachment">
264                                        <cfif len(form.oldattachment)>
265                                        <input type="hidden" name="oldattachment" value="#form.oldattachment#">
266                                        <input type="hidden" name="filename" value="#form.filename#">
267                                        <br>
268                                        File already attached: #form.oldattachment#
269                                        </cfif>
270                                        </td>
271                                </tr>
272                                </cfif>                                                         
273                                <tr>
274                                        <td>&nbsp;</td>
275                                        <td align="right"><cfif not isDefined("request.thread")><input type="image" src="images/btn_new_topic.gif" alt="New Topic" title="New Topic" width="71" height="19" name="post"><cfelse><input type="image" src="images/btn_reply.gif" alt="Reply" title="Reply" width="52" height="19" name="post"></cfif></td>
276                                </tr>
277                        <cfelse>
278                                <tr>
279                                        <td><b>Sorry, but this area is readonly.</b></td>
280                                </tr>
281                        </cfif>
282                </table>
283                </form>
284                </td>
285        </tr>
286</table>
287</p>
288</cfoutput>
289       
290</cfmodule>
291
292<cfsetting enablecfoutputonly=false>
Note: See TracBrowser for help on using the browser.