| 1 | <cfsetting enablecfoutputonly=true> |
|---|
| 2 | <!--- |
|---|
| 3 | Name : user_edit.cfm |
|---|
| 4 | Author : Raymond Camden |
|---|
| 5 | Created : August 3, 2007 |
|---|
| 6 | Last Updated : |
|---|
| 7 | History : |
|---|
| 8 | ---> |
|---|
| 9 | <cfimport taglib="../tags/" prefix="tags"> |
|---|
| 10 | |
|---|
| 11 | <cfif isDefined("form.cancel") or not isDefined("url.id")> |
|---|
| 12 | <cflocation url="users.cfm" addToken="false"> |
|---|
| 13 | </cfif> |
|---|
| 14 | |
|---|
| 15 | <cfif isDefined("form.save")> |
|---|
| 16 | <cfset form = request.udf.cleanStruct(form)> |
|---|
| 17 | <cfset errors = ""> |
|---|
| 18 | <cfif not len(form.username)> |
|---|
| 19 | <cfset errors = errors & "You must specify a username.<br>"> |
|---|
| 20 | </cfif> |
|---|
| 21 | <cfif url.id is 0 and not len(form.password)> |
|---|
| 22 | <cfset errors = errors & "You must specify a password for a new user.<br>"> |
|---|
| 23 | </cfif> |
|---|
| 24 | |
|---|
| 25 | <cfif not len(errors)> |
|---|
| 26 | |
|---|
| 27 | <cfset data = structNew()> |
|---|
| 28 | <cfset data.username = form.username> |
|---|
| 29 | <cfif len(trim(form.password))> |
|---|
| 30 | <cfset data.password = form.password> |
|---|
| 31 | </cfif> |
|---|
| 32 | |
|---|
| 33 | <cftry> |
|---|
| 34 | <cfif url.id neq 0> |
|---|
| 35 | <cfset data.originalusername = url.id> |
|---|
| 36 | <cfset application.user.updateUser(argumentCollection=data)> |
|---|
| 37 | <cfelse> |
|---|
| 38 | <cfset application.user.addUser(argumentCollection=data)> |
|---|
| 39 | </cfif> |
|---|
| 40 | <cfset msg = "User, #form.username#, has been updated."> |
|---|
| 41 | <cflocation url="users.cfm?msg=#urlEncodedFormat(msg)#"> |
|---|
| 42 | <cfcatch> |
|---|
| 43 | <cfset errors = cfcatch.message> |
|---|
| 44 | </cfcatch> |
|---|
| 45 | </cftry> |
|---|
| 46 | |
|---|
| 47 | </cfif> |
|---|
| 48 | </cfif> |
|---|
| 49 | |
|---|
| 50 | <!--- get survey if not new ---> |
|---|
| 51 | <cfif url.id neq 0> |
|---|
| 52 | <cfset user = application.user.getUser(url.id)> |
|---|
| 53 | <cfparam name="form.username" default="#user.username#"> |
|---|
| 54 | <cfelse> |
|---|
| 55 | <cfparam name="form.username" default=""> |
|---|
| 56 | </cfif> |
|---|
| 57 | |
|---|
| 58 | <tags:layout templatename="admin" title="User Editor"> |
|---|
| 59 | |
|---|
| 60 | <cfoutput> |
|---|
| 61 | <p> |
|---|
| 62 | Please use the form below to enter details about the user. All required fields are marked (*). |
|---|
| 63 | Because passwords are hashed in the database, you cannot set the current password. If you enter |
|---|
| 64 | a new password it will overwrite the old one. |
|---|
| 65 | </p> |
|---|
| 66 | |
|---|
| 67 | <p> |
|---|
| 68 | <cfif isDefined("errors")><ul><b>#errors#</b></ul></cfif> |
|---|
| 69 | <form action="#cgi.script_name#?#cgi.query_string#" method="post" autocomplete="off"> |
|---|
| 70 | <table cellspacing=0 cellpadding=5 class="adminEditTable" width="100%"> |
|---|
| 71 | <tr valign="top"> |
|---|
| 72 | <td width="200"><b>(*) Username:</b></td> |
|---|
| 73 | <td><input type="text" name="username" value="#form.username#" size="50"></td> |
|---|
| 74 | </tr> |
|---|
| 75 | <tr valign="top"> |
|---|
| 76 | <td width="200"><b>New Password:</b></td> |
|---|
| 77 | <td><input type="password" name="password" value="" size="50"></td> |
|---|
| 78 | </tr> |
|---|
| 79 | <tr> |
|---|
| 80 | <td> </td> |
|---|
| 81 | <td><input type="submit" name="save" value="Save"> |
|---|
| 82 | <input type="submit" name="cancel" value="Cancel"></td> |
|---|
| 83 | </tr> |
|---|
| 84 | </table> |
|---|
| 85 | </form> |
|---|
| 86 | </p> |
|---|
| 87 | </cfoutput> |
|---|
| 88 | |
|---|
| 89 | </tags:layout> |
|---|
| 90 | |
|---|
| 91 | <cfsetting enablecfoutputonly=false> |
|---|