root/trunk/website/soundings/cfcs/utils.cfc @ 30

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

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

Line 
1<cfcomponent displayName="Utils" hint="Set of common methods." output="false">
2
3        <cffunction name="getQueryParamType" access="public" returnType="string" output="false"
4                                hint="Based on sql type and query param returns a db specific type. It's main purpose is to handle mysql differences.">
5                <cfargument name="dbtype" type="string" required="true" hint="The db type.">
6                <cfargument name="qptype" type="string" required="true" hint="The queryparam type.">
7                <cfset var result = arguments.qptype>
8               
9                <cfif arguments.qptype is "CF_SQL_BIT">
10                        <cfif arguments.dbtype is "mysql">
11                                <cfset result = "CF_SQL_TINYINT">
12                        </cfif>
13                </cfif>
14
15                <cfreturn result>
16        </cffunction>
17       
18        <cffunction name="isUserInAnyRole2" access="public" returnType="boolean" output="false"
19                                hint="isUserInRole only does AND checks. This method allows for OR checks.">
20               
21                <cfargument name="rolelist" type="string" required="true">
22                <cfset var role = "">
23               
24                <cfloop index="role" list="#rolelist#">
25                        <cfif isUserInRole(role)>
26                                <cfreturn true>
27                        </cfif>
28                </cfloop>
29               
30                <cfreturn false>
31               
32        </cffunction>
33       
34        <cffunction name="queryToStruct" access="public" returnType="struct" output="false"
35                                hint="Transforms a query to a struct.">
36                <cfargument name="theQuery" type="query" required="true">
37                <cfset var s = structNew()>
38                <cfset var q ="">
39               
40                <cfloop index="q" list="#theQuery.columnList#">
41                        <cfset s[q] = theQuery[q][1]>
42                </cfloop>
43               
44                <cfreturn s>
45               
46        </cffunction>
47       
48        <cffunction name="searchSafe" access="public" returnType="string" output="false"
49                                hint="Removes any non a-z, 0-9 characters.">
50                <cfargument name="string" type="string" required="true">
51               
52                <cfreturn reReplace(arguments.string,"[^a-zA-Z0-9[:space:]]+","","all")>
53        </cffunction>
54       
55        <cffunction name="throw" access="public" returnType="void" output="false"
56                                hint="Handles exception throwing.">
57                               
58                <cfargument name="type" type="string" required="true">         
59                <cfargument name="message" type="string" required="true">
60               
61                <cfthrow type="#arguments.type#" message="#arguments.message#">
62               
63        </cffunction>
64
65</cfcomponent>
Note: See TracBrowser for help on using the browser.