root/trunk/website/forums/admin/users_edit.cfm @ 47

Revision 5, 5.2 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         : users_edit.cfm
4        Author       : Raymond Camden
5        Created      : July 5, 2004
6        Last Updated : May 3, 2007
7        History      : Fixed bugs related to sendnotifications change (rkc 8/3/05)
8                                   Removed mappings (rkc 8/27/05)
9                                   Handle confirmation, and require one group (rkc 7/12/06)
10                                   Fix error thrown when requireconfirmation=false (rkc 7/17/06)
11                                   Don't html encode the password or email address (rkc 5/3/07)
12        Purpose          :
13--->
14
15<cfif isDefined("form.cancel") or not isDefined("url.id")>
16        <cflocation url="users.cfm" addToken="false">
17</cfif>
18
19<cfif isDefined("form.save")>
20        <cfset errors = "">
21
22        <cfif not len(trim(form.username))>
23                <cfset errors = errors & "You must specify a username.<br>">
24        </cfif>
25        <cfif not len(trim(form.emailaddress)) or not request.udf.isEmail(trim(form.emailaddress))>
26                <cfset errors = errors & "You must specify an emailaddress.<br>">
27        </cfif>
28        <cfif not len(trim(form.password))>
29                <cfset errors = errors & "You must specify a password.<br>">
30        </cfif>
31        <cfif not len(trim(form.datecreated)) or not isDate(form.datecreated)>
32                <cfset errors = errors & "You must specify a creation date.<br>">
33        </cfif>
34        <cfif not structKeyExists(form,"groups") or not len(form.groups)>
35                <cfset errors = errors & "You must specify at least one group for the user.<br>">
36        </cfif>
37        <cfif not len(errors)>
38                <cfset user = structNew()>
39                <cfset form.username = trim(htmlEditFormat(form.username))>
40                <cfset form.emailaddress = trim(form.emailaddress)>
41                <cfset form.password = trim(form.password)>
42                <cfset form.datecreated = trim(htmlEditFormat(form.datecreated))>
43                <cfparam name="form.groups" default="">
44                <!--- set confirmed to true if not passed --->
45                <cfparam name="form.confirmed" default="true">
46                <cfif url.id neq 0>
47                        <cfset application.galleon.user.saveUser(form.username, form.password, form.emailaddress, form.datecreated,form.groups,form.confirmed)>
48                <cfelse>
49                        <cftry>
50                                <cfset application.galleon.user.addUser(form.username, form.password, form.emailaddress, form.groups,form.confirmed)>
51                                <cfcatch><cfdump var="#cfcatch#">
52                                        <cfset errors = cfcatch.message>
53                                </cfcatch>
54                        </cftry>
55                </cfif>
56                <cfif not len(errors)>
57                        <cfset msg = "User, #form.username#, has been updated.">
58                        <cflocation url="users.cfm?msg=#urlEncodedFormat(msg)#">
59                </cfif>
60        </cfif>
61</cfif>
62
63<!--- get user if not new --->
64<cfif url.id gte 1>
65        <cfset user = application.galleon.user.getUser(url.id)>
66        <cfparam name="form.username" default="#user.username#">
67        <cfparam name="form.emailaddress" default="#user.emailaddress#">
68        <cfparam name="form.password" default="#user.password#">
69        <cfparam name="form.datecreated" default="#dateFormat(user.datecreated,"m/dd/yy")# #timeFormat(user.datecreated,"h:mm tt")#">
70        <cfparam name="form.groups" default="#user.groups#">
71        <cfparam name="form.confirmed" default="#user.confirmed#">
72<cfelse>
73        <cfparam name="form.username" default="">
74        <cfparam name="form.emailaddress" default="">
75        <cfparam name="form.password" default="">
76        <cfparam name="form.datecreated" default="#dateFormat(now(),"m/dd/yy")# #timeFormat(now(),"h:mm tt")#">
77        <cfparam name="form.groups" default="">
78        <cfparam name="form.confirmed" default="0">
79</cfif>
80
81<cfset groups = application.galleon.user.getGroups()>
82
83<cfmodule template="../tags/layout.cfm" templatename="admin" title="User Editor">
84
85<cfoutput>
86<p>
87<cfif isDefined("errors")><ul><b>#errors#</b></ul></cfif>
88<form action="#cgi.script_name#?#cgi.query_string#" method="post">
89<table width="100%" cellspacing=0 cellpadding=5 class="adminEditTable">
90        <tr valign="top">
91                <td align="right"><b>User Name:</b></td>
92                <td>
93                        <cfif url.id is not "0">
94                                <input type="hidden" name="username" value="#form.username#">#form.username#
95                        <cfelse>
96                                <input type="text" name="username" value="#form.username#" size="50"></td>
97                        </cfif>
98                </td>
99        </tr>
100        <tr valign="top">
101                <td align="right"><b>Email Address:</b></td>
102                <td><input type="text" name="emailaddress" value="#form.emailaddress#" size="50"></td>
103        </tr>
104        <tr valign="top">
105                <td align="right"><b>Password:</b></td>
106                <td><input type="text" name="password" value="#form.password#" size="50"></td>
107        </tr>
108        <tr valign="top">
109                <td align="right"><b>Date Created:</b></td>
110                <td><input type="text" name="datecreated" value="#form.datecreated#" size="50"></td>
111        </tr>
112        <tr valign="top">
113                <td align="right"><b>Groups:</b></td>
114                <td>
115                <select name="groups" multiple size="3">
116                <cfloop query="groups">
117                <option value="#group#" <cfif listFindNoCase(form.groups, group)>selected</cfif>>#group#</option>
118                </cfloop>
119                </select>
120                </td>
121        </tr>
122        <cfif application.galleon.settings.requireconfirmation>
123        <tr valign="top">
124                <td align="right"><b>Confirmed:</b></td>       
125                <td><select name="confirmed">
126                <option value="0" <cfif not form.confirmed>selected</cfif>>No</option>
127                <option value="1" <cfif form.confirmed>selected</cfif>>Yes</option>
128                </select></td>
129        </tr>
130        </cfif>
131        <tr>
132                <td>&nbsp;</td>
133                <td><input type="submit" name="save" value="Save"> <input type="submit" name="cancel" value="Cancel"></td>
134        </tr>
135</table>
136</form>
137</p>
138</cfoutput>
139
140</cfmodule>
141
142<cfsetting enablecfoutputonly=false>
Note: See TracBrowser for help on using the browser.