| Package: machii_info_sample.model.user |
| I model a single user. |
| Method Summary | |
|---|---|
| public user |
init([numeric userID="0"], [string username=""], [string email=""], [string password=""], [string password2=""], [string firstName=""], [string lastName=""], [string company=""], [numeric isAdmin="0"], [boolean isLoggedIn="false"])
I initialize a user. |
| public userTO | createUserTO() |
| public string |
getCompany()
I return the first name |
| public string |
getEmail()
I return the first name |
| public struct | getErrors() |
| public string |
getFirstName()
I return the first name |
| public numeric | getIsAdmin() |
| public boolean | getIsLoggedIn() |
| public string |
getLastName()
I return the first name |
| public struct |
getMemento()
I return a memento of this users instance data. |
| public string | getPassword() |
| public string | getPassword2() |
| public numeric |
getUserID()
I return userID |
| public string | getUsername() |
| public userTO | getUserTO() |
| public void |
setCompany(string company)
I return email |
| public void |
setEmail(string email)
I return email |
| public void | setErrors(struct errors) |
| public void |
setFirstName(string firstname)
I return userID |
| public void | setIsAdmin(numeric isAdmin) |
| public void | setIsLoggedIn(boolean isLoggedIn) |
| public void |
setLastName(string lastname)
I return userID |
| public user |
setMemento(struct memento)
I set this user's instance data from a new memento. |
| public void | setPassword(string password) |
| public void | setPassword2(string password2) |
| public void |
setUserFromTO([userTO userTO])
set the instance data from TO |
| public void |
setUserID(numeric userID)
I return userID |
| public void | setUsername(string username) |
| public boolean |
validate()
form validation method |
| Method Detail |
|---|
| createUserTO |
|---|
public userTO createUserTO( )
Parameters:
Code:
<cffunction name="createUserTO" access="public" returnType="machii_info_sample.model.user.userTO" output="false">
<cfscript>
var userTO = createObject("component", "machii_info_sample.model.user.userTO").init(argumentcollection=variables.instance,errors=variables.errors);
return userTO;
</cfscript>
</cffunction>
| getCompany |
|---|
public string getCompany( )
I return the first name
Parameters:
Code:
<cffunction name="getCompany" access="public" returntype="string" output="false" displayname="" hint="I return the first name"> <cfreturn variables.instance.company /> </cffunction>
| getEmail |
|---|
public string getEmail( )
I return the first name
Parameters:
Code:
<cffunction name="getEmail" access="public" returntype="string" output="false" displayname="" hint="I return the first name"> <cfreturn variables.instance.email /> </cffunction>
| getErrors |
|---|
public struct getErrors( )
Parameters:
Code:
<cffunction name="getErrors" access="public" returntype="struct" output="false"> <cfreturn variables.errors /> </cffunction>
| getFirstName |
|---|
public string getFirstName( )
I return the first name
Parameters:
Code:
<cffunction name="getFirstName" access="public" returntype="string" output="false" displayname="" hint="I return the first name"> <cfreturn variables.instance.firstName /> </cffunction>
| getIsAdmin |
|---|
public numeric getIsAdmin( )
Parameters:
Code:
<cffunction name="getIsAdmin" access="public" returntype="numeric" output="false" > <cfreturn variables.instance.isAdmin /> </cffunction>
| getIsLoggedIn |
|---|
public boolean getIsLoggedIn( )
Parameters:
Code:
<cffunction name="getIsLoggedIn" access="public" returntype="boolean" output="false" > <cfreturn variables.instance.isLoggedIn /> </cffunction>
| getLastName |
|---|
public string getLastName( )
I return the first name
Parameters:
Code:
<cffunction name="getLastName" access="public" returntype="string" output="false" displayname="" hint="I return the first name"> <cfreturn variables.instance.lastName /> </cffunction>
| getMemento |
|---|
public struct getMemento( )
I return a memento of this users instance data.
Parameters:
Code:
<cffunction name="getMemento" access="public" returntype="struct" output="false" hint="I return a memento of this users instance data."> <cfreturn variables.instance /> </cffunction>
| getPassword |
|---|
public string getPassword( )
Parameters:
Code:
<cffunction name="getPassword" access="public" returntype="string" output="false" > <cfreturn variables.instance.password /> </cffunction>
| getPassword2 |
|---|
public string getPassword2( )
Parameters:
Code:
<cffunction name="getPassword2" access="public" returntype="string" output="false" > <cfreturn variables.instance.password2 /> </cffunction>
| getUserID |
|---|
public numeric getUserID( )
I return userID
Parameters:
Code:
<cffunction name="getUserID" access="public" returntype="numeric" output="false" displayname="" hint="I return userID"> <cfreturn variables.instance.userID /> </cffunction>
| getUsername |
|---|
public string getUsername( )
Parameters:
Code:
<cffunction name="getUsername" access="public" returntype="string" output="false" > <cfreturn variables.instance.username /> </cffunction>
| getUserTO |
|---|
public userTO getUserTO( )
Parameters:
Code:
<cffunction name="getUserTO" access="public" returnType="machii_info_sample.model.user.userTO" output="false"> <cfreturn createUserTO() /> </cffunction>
| init |
|---|
public user init( [numeric userID="0"], [string username=""], [string email=""], [string password=""], [string password2=""], [string firstName=""], [string lastName=""], [string company=""], [numeric isAdmin="0"], [boolean isLoggedIn="false"] )
I initialize a user.
Parameters:
| [numeric userID="0"] |
| [string username=""] |
| [string email=""] |
| [string password=""] |
| [string password2=""] |
| [string firstName=""] |
| [string lastName=""] |
| [string company=""] |
| [numeric isAdmin="0"] |
| [boolean isLoggedIn="false"] |
Code:
<cffunction name="init" access="public" returntype="user" output="false" displayname="User Constructor" hint="I initialize a user."> <cfargument name="userID" type="numeric" required="false" default="0" displayname="" hint="" /> <cfargument name="username" type="string" required="false" default="" displayname="" hint="" /> <cfargument name="email" type="string" required="false" default="" displayname="" hint="" /> <cfargument name="password" type="string" required="false" default="" displayname="" hint="" /> <cfargument name="password2" type="string" required="false" default="" displayname="" hint="" /> <cfargument name="firstName" type="string" required="false" default="" displayname="" hint="" /> <cfargument name="lastName" type="string" required="false" default="" displayname="" hint="" /> <cfargument name="company" type="string" required="false" default="" displayname="" hint="" /> <cfargument name="isAdmin" type="numeric" required="false" default="0" /> <cfargument name="isLoggedIn" type="boolean" required="false" default="false" /> <cfscript> variables.instance = structNew(); setuserID(arguments.userID); setUsername(arguments.username); setFirstName(arguments.firstName); setLastName(arguments.lastName); setEmail(arguments.email); setPassword(arguments.password); setPassword2(arguments.password2); setCompany(arguments.company); setIsAdmin(arguments.isAdmin); setIsLoggedIn(arguments.isLoggedIn); variables.errors = structNew(); </cfscript> <cfreturn this /> </cffunction>
| setCompany |
|---|
public void setCompany( string company )
I return email
Parameters:
| string company |
Code:
<cffunction name="setCompany" access="public" returntype="void" output="false" displayname="" hint="I return email"> <cfargument name="company" type="string" required="true" /> <cfset variables.instance.company = arguments.company /> </cffunction>
| setEmail |
|---|
public void setEmail( string email )
I return email
Parameters:
| string email |
Code:
<cffunction name="setEmail" access="public" returntype="void" output="false" displayname="" hint="I return email"> <cfargument name="email" type="string" required="true" /> <cfset variables.instance.email = arguments.email /> </cffunction>
| setErrors |
|---|
public void setErrors( struct errors )
Parameters:
| struct errors |
Code:
<cffunction name="setErrors" access="public" returntype="void" output="false"> <cfargument name="errors" type="struct" required="true" /> <cfset variables.errors = arguments.errors /> </cffunction>
| setFirstName |
|---|
public void setFirstName( string firstname )
I return userID
Parameters:
| string firstname |
Code:
<cffunction name="setFirstName" access="public" returntype="void" output="false" displayname="" hint="I return userID"> <cfargument name="firstname" type="string" required="true" /> <cfset variables.instance.firstname = arguments.firstname /> </cffunction>
| setIsAdmin |
|---|
public void setIsAdmin( numeric isAdmin )
Parameters:
| numeric isAdmin |
Code:
<cffunction name="setIsAdmin" access="public" returntype="void" output="false" > <cfargument name="isAdmin" type="numeric" required="true" /> <cfset variables.instance.isAdmin = arguments.isAdmin > </cffunction>
| setIsLoggedIn |
|---|
public void setIsLoggedIn( boolean isLoggedIn )
Parameters:
| boolean isLoggedIn |
Code:
<cffunction name="setIsLoggedIn" access="public" returntype="void" output="false" > <cfargument name="isLoggedIn" type="boolean" required="true" /> <cfset variables.instance.isLoggedIn = arguments.isLoggedIn > </cffunction>
| setLastName |
|---|
public void setLastName( string lastname )
I return userID
Parameters:
| string lastname |
Code:
<cffunction name="setLastName" access="public" returntype="void" output="false" displayname="" hint="I return userID"> <cfargument name="lastname" type="string" required="true" /> <cfset variables.instance.lastname = arguments.lastname /> </cffunction>
| setMemento |
|---|
public user setMemento( struct memento )
I set this user's instance data from a new memento.
Parameters:
| struct memento |
Code:
<cffunction name="setMemento" access="public" returntype="machii_info_sample.model.user.user" output="false" hint="I set this user's instance data from a new memento."> <cfargument name="memento" type="struct" required="yes" displayname="Memento" hint="I am a memento - a struct containing data." /> <cfset variables.instance = arguments.memento /> <cfreturn this /> </cffunction>
| setPassword |
|---|
public void setPassword( string password )
Parameters:
| string password |
Code:
<cffunction name="setPassword" access="public" returntype="void" output="false" > <cfargument name="password" type="string" required="true" /> <cfset variables.instance.password = arguments.password /> </cffunction>
| setPassword2 |
|---|
public void setPassword2( string password2 )
Parameters:
| string password2 |
Code:
<cffunction name="setPassword2" access="public" returntype="void" output="false" > <cfargument name="password2" type="string" required="true" /> <cfset variables.instance.password2 = arguments.password2 /> </cffunction>
| setUserFromTO |
|---|
public void setUserFromTO( [userTO userTO] )
set the instance data from TO
Parameters:
| [userTO userTO] |
Code:
<cffunction name="setUserFromTO" access="public" returnType="void" output="false" hint="set the instance data from TO"> <cfargument name="userTO" type="machii_info_sample.model.user.userTO" /> <cfscript> setuserID(userTO.userID); setUsername(userTO.username); setFirstname(userTO.firstName); setLastname(userTO.lastName); setEmail(userTO.email); setPassword(userTO.password); setPassword2(userTO.password); setCompany(userTO.company); setIsAdmin(userTO.isAdmin); </cfscript> </cffunction>
| setUserID |
|---|
public void setUserID( numeric userID )
I return userID
Parameters:
| numeric userID |
Code:
<cffunction name="setUserID" access="public" returntype="void" output="false" displayname="" hint="I return userID"> <cfargument name="userID" type="numeric" required="true" /> <cfset variables.instance.userID = arguments.userID /> </cffunction>
| setUsername |
|---|
public void setUsername( string username )
Parameters:
| string username |
Code:
<cffunction name="setUsername" access="public" returntype="void" output="false" > <cfargument name="username" type="string" required="true" /> <cfset variables.instance.username = arguments.username /> </cffunction>
| validate |
|---|
public boolean validate( )
form validation method
Parameters:
Code:
<cffunction name="validate" returntype="boolean" output="false" hint="form validation method"> <cfset var isValid = true /> <cfset var formErrors = structNew() /> <cfif len(trim(variables.instance.username)) LT 4 > <cfset formErrors.username = "The username must be at least 4 characters." > </cfif> <cfif len(variables.instance.password)LT 4 > <cfset formErrors.password = "The password must be at least 4 characters." > </cfif> <cfif variables.instance.password NEQ variables.instance.password2 > <cfset formErrors.passwordmatch = "The password and confirm password do not match." > </cfif> <cfif structCount(formErrors) > <cfset setErrors(formErrors) /> <cfset isValid = false /> </cfif> <cfreturn isValid /> </cffunction>