root/trunk/website/forums/profile.cfm @ 5

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

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

RevLine 
[5]1<cfsetting enablecfoutputonly=true>
2<!---
3        Name         : profile.cfm
4        Author       : Raymond Camden
5        Created      : July 5, 2004
6        Last Updated : November 3, 2006
7        History      : Changes due to subscriptions (7/29/05)
8                                   Removed mappings (rkc 8/27/05)
9                                   title fix (rkc 8/4/06)
10                                   signature fix, email fix (rkc 11/3/06)
11        Purpose          : Displays form to edit your settings.
12--->
13
14<cfif not request.udf.isLoggedOn()>
15        <cfset thisPage = cgi.script_name & "?" & cgi.query_string>
16        <cflocation url="login.cfm?ref=#urlEncodedFormat(thisPage)#" addToken="false">
17</cfif>
18
19<!--- attempt to subscribe --->
20<cfif isDefined("url.s")>
21        <cftry>
22        <cfif isDefined("url.threadid")>
23                <cfset subMode = "thread">
24                <cfset subID = url.threadID>
25                <cfset thread = application.galleon.thread.getThread(subID)>
26                <cfset name = thread.name>
27        <cfelseif isDefined("url.forumid")>
28                <cfset subMode = "forum">
29                <cfset subID = url.forumid>
30                <cfset forum = application.galleon.forum.getForum(subID)>
31                <cfset name = forum.name>
32        <cfelseif isDefined("url.conferenceid")>
33                <cfset subMode = "conference">
34                <cfset subID = url.conferenceid>
35                <cfset conference = application.galleon.conference.getConference(subid)>
36                <cfset name = conference.name>
37        </cfif>
38        <cfcatch>
39                <cflocation url="/" addToken="false">
40        </cfcatch>
41        </cftry>
42        <cfif isDefined("variables.subMode")>
43                <cfset application.galleon.user.subscribe(getAuthUser(), subMode, subID)>
44                <cfset subscribeMessage = "You have been subscribed to the #submode#: <b>#name#</b>">
45        </cfif>
46       
47</cfif>
48
49<!--- attempt to unsubscribe --->
50<cfif isDefined("url.removeSub")>
51        <cftry>
52                <cfset application.galleon.user.unsubscribe(getAuthUser(), url.removeSub)>
53                <cfset subscribeMessage = "Your unsubscribe request has been processed.<br>">
54                <cfcatch>
55                        <!--- silently fail ---><cfdump var="#cfcatch#"><cfabort>
56                </cfcatch>
57        </cftry>
58</cfif>
59
60<cfset user = application.galleon.user.getUser(getAuthUser())>
61<cfset subs = application.galleon.user.getSubscriptions(getAuthUser())>
62
63<cfparam name="form.emailaddress" default="#user.emailaddress#">
64<cfparam name="form.password_new" default="">
65<cfparam name="form.password_confirm" default="">
66<cfparam name="form.signature" default="#user.signature#">
67
68<!--- Loads header --->
69<cfmodule template="tags/layout.cfm" templatename="main" title="#application.galleon.settings.title# : Profile">
70
71<!--- Handle attempted update --->
72<cfif isDefined("form.save")>
73        <cfset errors = "">
74       
75        <cfif not len(trim(form.emailaddress)) or not request.udf.isEmail(form.emailaddress)>
76                <cfset errors = errors & "You must enter a valid email address.<br>">
77        <cfelse>
78                <cfset user.emailaddress = trim(htmlEditFormat(form.emailaddress))>
79        </cfif>
80       
81        <cfif len(trim(form.password_new)) and form.password_new neq form.password_confirm>
82                <cfset errors = errors & "To change your password, your confirmation password must match.<br>">
83        </cfif>
84       
85        <cfif not len(errors)>
86
87                <cfif len(trim(form.password_new))>
88                        <cfset user.password = form.password_new>
89                </cfif>
90                       
91                <cfset application.galleon.user.saveUser(username=getAuthUser(),password=user.password,emailaddress=form.emailaddress,datecreated=user.datecreated,groups=application.galleon.user.getGroupsForUser(getAuthUser()), signature=form.signature, confirmed=true)>
92                               
93        </cfif>
94               
95</cfif>
96
97<cfoutput>
98<p>
99<table width="500" cellpadding="6" class="tableDisplay" cellspacing="1" border="0">
100        <tr class="tableHeader">
101                <td class="tableHeader">Profile</td>
102        </tr>
103        <tr class="tableRowMain">
104                <td>
105                Please use the form below to edit your profile.
106                <cfif isDefined("errors")>
107                        <cfif len(errors)>
108                                <p>
109                                Please correct the following error(s):<ul><b>#errors#</b></ul>
110                                </p>
111                        <cfelse>
112                                <p>
113                                Your profile has been updated.
114                                </p>
115                        </cfif>
116                </cfif>
117                </td>
118        </tr>
119        <tr class="tableRowMain">
120                <td>
121                <form action="#cgi.script_name#" method="post">
122                <input type="hidden" name="save" value="1">
123                <table>
124                        <tr>
125                                <td><b>Username:</b></td>
126                                <td>#user.username#</td>
127                        </tr>
128                        <tr>
129                                <td><b>Email Address:</b></td>
130                                <td><input type="text" name="emailaddress" value="#user.emailaddress#" class="formBox"></td>
131                        </tr>
132                        <tr>
133                                <td><b>New Password:</b></td>
134                                <td><input type="password" name="password_new" class="formBox"></td>
135                        </tr>
136                        <tr>
137                                <td><b>Confirm Password:</b></td>
138                                <td><input type="password" name="password_confirm" class="formBox"></td>
139                        </tr>
140                        <tr valign="top">
141                                <td><b>Signature (1000 character max):</b></td>
142                                <td><textarea name="signature" class="formTextArea">#form.signature#</textarea></td>
143                        </tr>
144                        <tr>
145                                <td>&nbsp;</td>
146                                <td align="right"><input type="image" src="images/btn_save.gif" alt="Save" width="49" height="19" name="save"></td>
147                        </tr>
148                </table>
149                </form>
150                </td>
151        </tr>
152
153</table>
154</p>
155
156<p>
157<table width="500" cellpadding="6" class="tableDisplay" cellspacing="1" border="0">
158        <tr class="tableHeader">
159                <td class="tableHeader">Subscriptions</td>
160        </tr>
161        <cfif isDefined("subscribeMessage")>
162        <tr class="tableRowMain">
163                <td>
164                #subscribeMessage#
165                </td>
166        </tr>
167        </cfif>
168        <tr class="tableRowMain">
169                <td>
170                <cfif subs.recordCount is 0>
171                        You are not currently subscribed to anything.
172                <cfelse>
173                        The following are your subscription(s):
174                        <p>
175                        <table>
176                        <cfloop query="subs">
177                                <tr>
178                                        <td>
179                                        <cfif len(conferenceidfk)>
180                                                <cfset data = application.galleon.conference.getConference(conferenceidfk)>
181                                                <cfset label = "Conference">
182                                                <cfset link = "forums.cfm?conferenceid=#conferenceidfk#">
183                                        <cfelseif len(forumidfk)>
184                                                <cfset data = application.galleon.forum.getForum(forumidfk)>
185                                                <cfset label = "Forum">
186                                                <cfset link = "threads.cfm?forumid=#threadidfk#">
187                                        <cfelse>
188                                                <cfset data = application.galleon.thread.getThread(threadidfk)>
189                                                <cfset label = "Thread">
190                                                <cfset link = "messages.cfm?threadid=#threadidfk#">
191                                        </cfif>
192                                        #label#:
193                                        </td>
194                                        <td><a href="#link#">#data.name#</a></td>
195                                        <td>[<a href="profile.cfm?removeSub=#id#">Unsubscribe</a>]</td>
196                        </cfloop>
197                        </table>
198                        </p>
199                </cfif>
200                </td>
201        </tr>
202
203</table>
204</p>
205
206</cfoutput>
207       
208</cfmodule>
209
210<cfsetting enablecfoutputonly=false>
Note: See TracBrowser for help on using the browser.