| 1 | <cfsetting enablecfoutputonly=true> |
|---|
| 2 | <!--- |
|---|
| 3 | Name : handlers/matrix/save.cfm |
|---|
| 4 | Author : Raymond Camden |
|---|
| 5 | Created : October 7, 2005 |
|---|
| 6 | Last Updated : March 30, 2006 |
|---|
| 7 | History : tableprefix fix (rkc 3/30/06) |
|---|
| 8 | Purpose : Matrix save |
|---|
| 9 | ---> |
|---|
| 10 | |
|---|
| 11 | <cfscript> |
|---|
| 12 | /** |
|---|
| 13 | * Returns TRUE if the string is a valid CF UUID. |
|---|
| 14 | * |
|---|
| 15 | * @param str String to be checked. (Required) |
|---|
| 16 | * @return Returns a boolean. |
|---|
| 17 | * @author Jason Ellison (jgedev@hotmail.com) |
|---|
| 18 | * @version 1, November 24, 2003 |
|---|
| 19 | */ |
|---|
| 20 | function IsCFUUID(str) { |
|---|
| 21 | return REFindNoCase("^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{16}$", str); |
|---|
| 22 | } |
|---|
| 23 | </cfscript> |
|---|
| 24 | |
|---|
| 25 | <cfparam name="attributes.answer"> |
|---|
| 26 | <cfparam name="attributes.questionidfk"> |
|---|
| 27 | <cfparam name="attributes.owner"> |
|---|
| 28 | |
|---|
| 29 | <!--- Answer is a struct where each key is the item and it's value is the answer id fk ---> |
|---|
| 30 | |
|---|
| 31 | <cfloop item="item" collection="#attributes.answer#"> |
|---|
| 32 | <cfif isCFUUID(item)> |
|---|
| 33 | <cfif attributes.answer[item] is "" or isCFUUID(attributes.answer[item])> |
|---|
| 34 | <cfquery datasource="#application.settings.dsn#"> |
|---|
| 35 | insert into #application.settings.tableprefix#results(owneridfk, questionidfk, answeridfk, itemidfk) |
|---|
| 36 | values( |
|---|
| 37 | <cfqueryparam cfsqltype="CF_SQL_VARCHAR" maxlength="35" value="#attributes.owner#">, |
|---|
| 38 | <cfqueryparam cfsqltype="CF_SQL_VARCHAR" maxlength="35" value="#attributes.questionidfk#">, |
|---|
| 39 | <cfqueryparam cfsqltype="CF_SQL_VARCHAR" maxlength="35" value="#attributes.answer[item]#">, |
|---|
| 40 | <cfqueryparam cfsqltype="CF_SQL_VARCHAR" maxlength="35" value="#item#"> |
|---|
| 41 | ) |
|---|
| 42 | </cfquery> |
|---|
| 43 | </cfif> |
|---|
| 44 | </cfif> |
|---|
| 45 | </cfloop> |
|---|
| 46 | |
|---|
| 47 | <cfsetting enablecfoutputonly=false> |
|---|
| 48 | |
|---|
| 49 | <cfexit method="exittag"> |
|---|