| Package: machii_info_sample.controllers |
| Inherits from: MachII.framework.Listener |
| I am the listener for the application |
| Method Summary | |
|---|---|
| public void |
configure()
I initialize this listener as part of the framework startup. |
| public void | recoverPassword(Event event) |
| public void | sendDownloadNotification(Event event) |
| public void | sendNewCommentNotification(Event event) |
| public void | sendNewQuestionNotification(Event event) |
| public void | sendPassword(Event event) |
| public void | sendRegistrationConfirmation(Event event) |
| Method Detail |
|---|
| configure |
|---|
public void configure( )
I initialize this listener as part of the framework startup.
Parameters:
Code:
<cffunction name="configure" access="public" returntype="void" output="true" displayname="Listener Constructor" hint="I initialize this listener as part of the framework startup.">
<cfscript>
var appConstants = getAppManager().getPropertyManager().getProperty("appConstants");
variables.dsn = appConstants.getDsn();
variables.administratorEmail = appConstants.getAdministratorEmail();
variables.smtp_server = appConstants.getSmtp_server();
variables.smtp_username = appConstants.getSmtp_username();
variables.smtp_password = appConstants.getSmtp_password();
variables.userService = createObject("component", "machii_info_sample.model.user.userService").init();
</cfscript>
</cffunction>
| recoverPassword |
|---|
public void recoverPassword( Event event )
Parameters:
| Event event |
Code:
<cffunction name="recoverPassword" access="public" returntype="void" output="false" displayname="Get session user.isAdmin" hint="">
<cfargument name="event" type="MachII.framework.Event" required="yes" displayname="Event" hint="I am the current event" />
<cfscript>
var email = arguments.event.getArg("email");
var userData = 0;
var qry_users = 0;
if (arguments.event.isArgDefined("email")){
qry_users = variables.userService.getUsers(dsn=variables.dsn,username="",email=email);
if (qry_users.recordCount) {
userData = CreateObject("component", "machii_info_sample.model.user.userTO").init(email=email, username=qry_users["username"][1], password=qry_users["password"][1]);
arguments.event.setArg("userData", userData);
announceEvent("recoverPassword.success", arguments.event.getArgs());
} else {
arguments.event.setArg("errorMessage", "A user with that email was not found.");
announceEvent("recoverPassword.emailNotFound", arguments.event.getArgs());
}
} else {
announceEvent("forgotPassword");
}
</cfscript>
</cffunction>
| sendDownloadNotification |
|---|
public void sendDownloadNotification( Event event )
Parameters:
| Event event |
Code:
<cffunction name="sendDownloadNotification" returntype="void" output="false" >
<cfargument name="event" type="MachII.framework.Event" required="yes" displayname="Event" hint="I am the current event" />
<cfset var uf = getAppManager().getPropertyManager().getProperty("userFacade") />
<cfset var sessionUser = uf.getUser() />
<cfset var userData = sessionUser.getUserTO() />
<cfset var theFile = arguments.event.getArg("fileid") />
<cfif arguments.event.isArgDefined("fileid")>
<cfmail from="admin@mach-ii.info" to="#variables.administratorEmail#" subject="#theFile# Downloaded by #userData.username# " type="html" server="#variables.smtp_server#" username="#variables.smtp_username#" password="#variables.smtp_password#">
#theFile# was downloaded by #userData.username# on #dateFormat(now(),'mm/dd/yyyy')# at #timeFormat(now(),'hh:mm tt')#
</cfmail>
<cfelse>
<cflocation url="/index.cfm?event=resources" addtoken="no" >
</cfif>
</cffunction>
| sendNewCommentNotification |
|---|
public void sendNewCommentNotification( Event event )
Parameters:
| Event event |
Code:
<cffunction name="sendNewCommentNotification" returntype="void" output="false" >
<cfargument name="event" type="MachII.framework.Event" required="yes" displayname="Event" hint="I am the current event" />
<cfset var comment = arguments.event.getArg("comment") >
<cfmail from="admin@mach-ii.info" to="#variables.administratorEmail#" subject="New Comment" type="html" server="#variables.smtp_server#" username="#variables.smtp_username#" password="#variables.smtp_password#">
<a href="http://mach-ii.info/index.cfm?event=faq.viewqa&faqid=#comment.getFaqID()#">FAQ #comment.getFaqID()#</a>
<br/>
<br/>
comment: #comment.getComment()#<br>
</cfmail>
</cffunction>
| sendNewQuestionNotification |
|---|
public void sendNewQuestionNotification( Event event )
Parameters:
| Event event |
Code:
<cffunction name="sendNewQuestionNotification" returntype="void" output="false" >
<cfargument name="event" type="MachII.framework.Event" required="yes" displayname="Event" hint="I am the current event" />
<cfset var faq = arguments.event.getArg("faq") >
<cfmail from="admin@mach-ii.info" to="#variables.administratorEmail#" subject="New Faq" type="html" server="#variables.smtp_server#" username="#variables.smtp_username#" password="#variables.smtp_password#">
<a href="http://mach-ii.info/index.cfm?event=faq.viewqa&faqid=#faq.getFaqID()#">FAQ #faq.getFaqID()#</a>
<br/>
<br/>
<strong>#faq.getQuestion()#</strong><hr/>
#faq.getAnswer()#<br>
</cfmail>
</cffunction>
| sendPassword |
|---|
public void sendPassword( Event event )
Parameters:
| Event event |
Code:
<cffunction name="sendPassword" returntype="void" output="false" >
<cfargument name="event" type="MachII.framework.Event" required="yes" displayname="Event" hint="I am the current event" />
<cfset var userData = arguments.event.getArg("userData") >
<cfmail from="admin@mach-ii.info" to="#userData.email#" subject="Login information for Mach-II.info" type="html" server="#variables.smtp_server#" username="#variables.smtp_username#" password="#variables.smtp_password#">
username: #userData.username#<br/>
password: #userData.password#<br/>
<a href="http://#cgi.server_name#/index.cfm?event=attemptlogin">Click here to login</a>
<br/>
<br/>
</cfmail>
</cffunction>
| sendRegistrationConfirmation |
|---|
public void sendRegistrationConfirmation( Event event )
Parameters:
| Event event |
Code:
<cffunction name="sendRegistrationConfirmation" returntype="void" output="false" >
<cfargument name="event" type="MachII.framework.Event" required="yes" displayname="Event" hint="I am the current event" />
<cfset var user = arguments.event.getArg("user") />
<cfset var userData = user.getUserTO() />
<cfmail from="admin@mach-ii.info" to="#variables.administratorEmail#" subject="Registration confirmation" type="html" server="#variables.smtp_server#" username="#variables.smtp_username#" password="#variables.smtp_password#">
username: #userData.username#<br />
Name: #userData.firstName# #userData.lastName#<br />
Company: #userData.company#
</cfmail>
</cffunction>