919 - 926 - 9847

FarCry 5 maintain state using browser cookies

So, I've got a new site rolling out that we're using FarCry 5.0 (soon to be 5.1, when it's no longer beta). This particular site has a members area that's styled like facebook/myspace. In keeping with the vein of keeping the users happy, it's become apparent that most people don't want log into their social sites every time they visit them. Hmm... that's not currently built into FarCry, so it's time to dive in and play!

First up, let's extend the FarCryUD to include our new method for cookie detection. You need to make a copy of /farcry/core/packages/security/FarcryUD.cfc and copy it to /farcry/projects/{myproject}/packages/security/FarcryUD.cfc. You'll want to change the top line of the file to the following (the extends being the most important):


<cfcomponent displayname="My User Directory" hint="Provides the interface for the FarCry user directory" extends="farcry.core.packages.security.FarcryUD" output="false" key="CLIENTUD" bEncrypted="false">

Next, let's add the new cookie code detection. This adds a cfelseif into the mix. This is in the authenticate function.


<cfif structkeyexists(form,"userlogin") and structkeyexists(form,"password")>
            <!--- If password encryption is enabled, hash the password --->
            <cfif this.bEncrypted>
                <cfset form.password = hash(form.password) />
            </cfif>
            
            <!--- Find the user --->
            <cfquery datasource="#application.dsn#" name="qUser">
                select    *
                from    #application.dbowner#farUser
                where    userid=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.userlogin#" />
                        and password=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.password#" />
            </cfquery>
            <cfset stResult.userid = form.userlogin />
        <cfelseif isdefined("cookie.my_memberid") AND isdefined("cookie.my_password")>
        
            <!--- Find the user --->
            <cfquery datasource="#application.dsn#" name="qUser">
                select    *
                from    #application.dbowner#farUser
                where    userid=<cfqueryparam cfsqltype="cf_sql_varchar" value="#cookie.my_memberid#" />
                        and password=<cfqueryparam cfsqltype="cf_sql_varchar" value="#decrypt(cookie.my_password,'saltmebaby')#" />
            </cfquery>
            <cfset stResult.userid = cookie.burton_memberid />
        <cfelse>
            <ft:processform>
                <ft:processformObjects typename="#getLoginForm()#">
                    <!--- If password encryption is enabled, hash the password --->
                    <cfif this.bEncrypted>
                        <cfset stProperties.password = hash(stLogin.password) />
                    </cfif>
                    
                    <!--- Find the user --->
                    <cfquery datasource="#application.dsn#" name="qUser">
                        select    *
                        from    #application.dbowner#farUser
                        where    userid=<cfqueryparam cfsqltype="cf_sql_varchar" value="#stProperties.username#" />
                                and password=<cfqueryparam cfsqltype="cf_sql_varchar" value="#stProperties.password#" />
                    </cfquery>
                    
                    <cfset stResult.userid = stProperties.username />
                </ft:processformObjects>
            </ft:processform>
        </cfif>

Lastly, we need to modify our login process to create a cookie when the user logs in... only if there isn't already a cookie set. You would want to create a custom login for this, so copy /farcry/core/webtop/login.cfm to /farcry/projects/{myproject}/customadmin/login/login.cfm. You'll want to change the block of code that's in the final cfelse that relocates the user based on a successful login.


<cfelse>
        <!--- relocate to original location --->
        <cfif not isdefined("cookie.my_memberid")>
            <cfset stUser = createObject("component", application.stcoapi["farUser"].packagePath).getByUserID(listfirst(application.security.getCurrentUserID(),"_")) />
            <cfcookie name="my_memberid" value="#stUser.userid#" expires="30" >
            <cfcookie name="my_password" value="#encrypt(stUser.password,'saltmebaby')#" expires="30">
        </cfif>
        <cflocation url="#stResult.returnUrl#" addtoken="No">
        <cfabort>
    </cfif>

FarCry 4 formtools issues

Here's a strange one that I came across yesterday. I was working on making a new site available for some community type work (www.fouroakskidskampus.com), when I found an issue with the default FarCrycms plugin. I'll post the code, see if you can spot the error.


<!--- wiz: General Details --->
<cfproperty ftseq="1" ftfieldset="Event Overview" ftwizardStep="General Details" name="title" type="string" hint="Title of object." required="no" default="" ftLabel="Title" ftvalidation="required" />
<cfproperty ftseq="2" ftfieldset="Event Overview" ftwizardStep="General Details" name="startDate" type="date" hint="The start date of the event" required="no" default=""ftDefaultType="Evaluate" ftDefault="now()" ftType="datetime" ftDateFormatMask="dd mmm yyyy" ftTimeFormatMask="hh:mm tt" ftToggleOffDateTime="false" ftlabel="Start Date" />
<cfproperty ftseq="3" ftfieldset="Event Overview" ftwizardStep="General Details" name="endDate" type="date" hint="The end date of the event" required="no" default=""ftDefaultType="Evaluate" ftDefault="DateAdd('d', 5, now())" ftType="datetime" ftDateFormatMask="dd mmm yyyy" ftTimeFormatMask="hh:mm tt" ftToggleOffDateTime="false" ftlabel="End Date" />
<cfproperty ftseq="5" ftfieldset="Event Overview" ftwizardStep="General Details" name="displayMethod" type="string" hint="Display method to render." required="yes" default="display" fttype="webskin" ftprefix="displayPage" ftlabel="Content Template" />

The above was pulled from plugins/farcrycms/packages/types/dmEvent.cfc. It was not displaying any webskins, even though they were in the correct path. Placing new webskins in the project folder failed as well. It's only when the webskins existed in the core folders that you actually were able to see them.


<cfproperty ftseq="1" ftfieldset="General Details" ftwizardStep="General Details" name="title" type="string" hint="News title." required="no" default="" ftlabel="Title" ftvalidation="required" />
<cfproperty ftseq="2" ftfieldset="General Details" ftwizardStep="General Details" name="source" type="string" hint="source of the information contained in the content" required="no" default="" ftlabel="Source" />
<cfproperty ftseq="3" ftfieldset="General Details" ftwizardStep="General Details" name="displayMethod" type="string" hint="Display method to render." required="yes" default="display" fttype="webskin" ftprefix="displayPage" ftlabel="Content Template" />
<cfproperty ftseq="4" ftfieldset="Categorisation" ftwizardStep="General Details" name="catNews" type="string" hint="News categorisation." required="no" default="" fttype="category" ftalias="dmnews" ftlabel="News Category" />

This next was pulled from plugins/farcrycms/packages/types/dmNews.cfc. Did you see it? It's not real blatant. Alright, this is where it's at, if you notice that ftseq in dmNews does not skip a sequence. The sequence in dmEvent DOES have a gap. Odd, but that's what seemed to break it. Renaming "ftseq=5" to "ftseq=4" fixed the issue. Groovy, baby.

Good bye LLC, we hardly knew ye

Tis a sad, sad day. I've been informed by the banker lady that in order to not exceed financial limits placed on a mortgage I'm seeking, I'm going to be required to dissolve my LLC. Bugger.

However, on a happier note, our house hunting is over. An offer has been made, and if it's accepted, we'll be moving in somewhere in March. At the very least with the weather being what it is in NC, it should be fairly mild, if not downright pleasant.

So, on to work. I'm thinking my next post is going to be about creating *. CERTs and using them in IIS, or maybe the start of my next FarCry library. I'm thinking of doing a webstore and seeing how that flies. Should be fun! I'm also preparing to take my CF exam to become "Certified" and all that.

FarCry plugin breakdown - Part III

Let's finish this up with Part 3. We only have two things to look at yet, and that's our Rule and webskin.

The Rule


<cfcomponent displayname="Mass Mailer Rule" extends="farcry.core.packages.rules.rules" hint="Allows you to select a list for user to sign up for">
    <cfproperty ftSeq="1" ftFieldSet="List" name="intro" type="longchar" hint="Introduction HTML for list." ftLabel="Intro" ftType="longchar" />
    <cfproperty ftSeq="2" ftFieldSet="List" name="ListID" type="UUID" hint="ID of the List to be displayed" ftLabel="List" ftType="UUID" ftJoin="massMailerList" />
    <cfproperty ftseq="3" ftFieldset="List" name="displayMethod" type="string" hint="Display method to render." required="yes" default="display" fttype="webskin" ftprefix="displayList" ftTypename="massMailerList" ftlabel="Content Template" />
    
<cffunction name="execute" hint="Displays the text rule on the page." output="true" returntype="void" access="public">
    <cfargument name="objectID" required="Yes" type="uuid" default="">
    
    <cfset var stObj = getData(arguments.objectid) />
    <cfset var oList = createObject("component","farcry.plugins.massMailer.packages.types.massMailerList") />
    <cfset var stData = oList.getData(stObj.ListID) />
    <cfset var stInvoke = structNew() />    
    <cfscript>
        if (len(stobj.intro))
            arrayAppend(request.aInvocations,stobj.intro);
        stInvoke.objectID = stData.ObjectID;
        stInvoke.typename = application.types.massMailerList.typepath;
        stInvoke.method = stObj.displayMethod;
        arrayAppend(request.aInvocations,stInvoke);
    
</cfscript>
</cffunction>
</cfcomponent>

Not too complicated, and once again, formtools comes to our rescue! To get a real breadth of what can be done with rules, you really should take a look at the existing core and farcrycms rules. Some of them have much more functionality than what was required for this rule.

Basically, if you want to have something displayed on the screen, you need to make a cfproperty for it. The usual formtools ideas apply. The items I required were the ID of the list, and the name of the webskin to display it. Formtools can grab this list of webskins for you with the fttype="webskin".

The real magic is in the execute fucntion. It will create our stObj (which the webskin will use), and also invoke the webskin to be used. To be frank, I've not dug into the internals much within rules. This one will get the job done, but I don't have the greatest of knowledge of this piece of FarCry.

The webskin

The essence of the skin is to display two form fields, name and address, and submit this information as a aObjectID into the massMailerList. The nifty drag-n-drop display does this for us, so I simply "borrowed" those pieces to pull this of.


<cfsetting enablecfoutputonly="true">
<!--- @@displayname: Display Mass Mailer Signup Form --->
<!--- @@author: Matthew Williams --->
<cfif isdefined('form.FARCRYFORMSUBMITBUTTON')>

<cfimport taglib="/farcry/core/tags/formtools/" prefix="ft" >
<cfinclude template="/farcry/core/admin/includes/utilityFunctions.cfm">

<cfparam name="form.primaryObjectID" default="">
<cfparam name="form.primaryTypeName" default="">
<cfparam name="form.primaryFieldName" default="">
<cfparam name="form.primaryFormFieldName" default="">
<cfparam name="form.ftJoin" default="">
<cfparam name="form.wizardID" default="">
<cfparam name="form.LibraryType" default="array">
<cfparam name="form.ftLibraryAddNewWebskin" default="libraryAdd"><!--- Method to Add New Object --->
<cfparam name="form.ftLibraryPickWebskin" default="libraryPick"><!--- Method to Pick Existing Objects --->
<cfparam name="form.ftLibraryPickListClass" default="thumbNailsWrap">
<cfparam name="form.ftLibraryPickListStyle" default="">
<cfparam name="form.ftLibrarySelectedWebskin" default="librarySelected"><!--- Method to Pick Existing Objects --->
<cfparam name="form.ftLibrarySelectedListClass" default="thumbNailsWrap">
<cfparam name="form.ftLibrarySelectedListStyle" default="">
<cfparam name="form.ftAllowLibraryAddNew" default=""><!--- Method to Add New Object --->
<cfparam name="form.ftAllowLibraryEdit" default=""><!--- Method to Edit Object --->
<cfparam name="form.PackageType" default="types"><!--- Could be types or rules.. --->
<cfparam name="form.currentpage" default="1">


    
<cfif form.PackageType EQ "rules">
    <cfset PrimaryPackage = application.rules[form.primaryTypeName] />
    <cfset PrimaryPackagePath = application.rules[form.primaryTypeName].rulepath />
<cfelse>
    <cfset PrimaryPackage = application.types[form.primaryTypeName] />
    <cfset PrimaryPackagePath = application.types[form.primaryTypeName].typepath />
</cfif>

<!--- TODO: dynamically determine the typename to join. --->
<cfset request.ftJoin = listFirst(form.ftJoin) />
<cfif NOT listContainsNoCase(PrimaryPackage.stProps[form.primaryFieldname].metadata.ftJoin,request.ftJoin)>
    <cfset request.ftJoin = listFirst(PrimaryPackage.stProps[form.primaryFieldname].metadata.ftJoin) />
</cfif>


<ft:processForm action="Attach,Attach & Add Another">    
    <ft:processFormObjects typename="#request.ftJoin#" /><!--- Returns variables.lSavedObjectIDs --->
    <cfset oPrimary = createObject("component",PrimaryPackagePath)>
    <cfset oData = createObject("component",application.types[request.ftJoin].typepath)>
    <cfloop list="#lSavedObjectIDs#" index="DataObjectID">
        <cfif len(form.wizardID)>                    
            <cfset owizard = createObject("component",application.types['dmWizard'].typepath)>
            <cfset stwizard = owizard.Read(wizardID=form.wizardID)>
            
            <cfif form.LibraryType EQ "UUID">
                <cfset stwizard.Data[form.PrimaryObjectID][form.PrimaryFieldname] = DataObjectID>
            <cfelse><!--- Array --->
                <cfset arrayAppend(stwizard.Data[form.PrimaryObjectID][form.PrimaryFieldname],DataObjectID)>    
                <cfset variables.tableMetadata = createobject('component','farcry.core.packages.fourq.TableMetadata').init() />
                <cfset tableMetadata.parseMetadata(md=getMetadata(oPrimary)) />        
                <cfset stFields = variables.tableMetadata.getTableDefinition() />
                <cfset o = createObject("component","farcry.core.packages.fourq.gateway.dbGateway").init(dsn=application.dsn,dbowner="")>
                <cfset aProps = o.createArrayTableData(tableName=form.PrimaryTypename & "_" & form.PrimaryFieldName,objectid=form.PrimaryObjectID,tabledef=stFields[PrimaryFieldName].Fields,aprops=stwizard.Data[PrimaryObjectID][form.PrimaryFieldname])>
                <cfset stwizard.Data[form.PrimaryObjectID][form.PrimaryFieldname] = aProps>
            </cfif>
            
            <cfset stwizard = owizard.Write(ObjectID=form.wizardID,Data=stwizard.Data)>
            <cfset st = stwizard.Data[form.PrimaryObjectID]>
        <cfelse>
            <cfset stPrimary = oPrimary.getData(objectid=form.PrimaryObjectID)>
            
            <cfif form.LibraryType EQ "UUID">
                <cfset stPrimary[form.PrimaryFieldname] = DataObjectID>        
            <cfelse><!--- Array --->
                <cfset arrayAppend(stPrimary[form.PrimaryFieldname],DataObjectID)>                        
            </cfif>        
            
            <cfparam name="session.dmSec.authentication.userlogin" default="anonymous" />
            <cfset oPrimary.setData(objectID=stPrimary.ObjectID,stProperties="#stPrimary#",user="#session.dmSec.authentication.userlogin#")>
            
        </cfif>
    </cfloop>
    
</ft:processForm>
</cfif>

<cfscript>
    formObj.primaryHash = stObj.objectid;
    formObj.primaryNoHash = replace(formObj.primaryHash,'-','','all');
    formObj.userObjHash = createuuid();
    formObj.userObjNoHash = replace(formObj.userObjHash,'-','','all');
</cfscript>

<cfoutput>
<cfif isdefined('form.FARCRYFORMSUBMITBUTTON')>
    <p>Your email address has been added to the list!</p>
</cfif>
<form action="" method="post" id="farcryForm936443538" name="farcryForm936443538" target="" enctype="multipart/form-data" onsubmit="" class="formtool" style=""><input type="hidden" name="phpMyAdmin" value="6ffe8b831e4bded08a42997de2b6eeaa" />
    <p>Name: <input type="Text" name="#formObj.userObjHash#Title" id="#formObj.userObjHash#Title" value="" class="" style="" /></p>
    <p>Email:<input type="Text" name="#formObj.userObjHash#Email" id="#formObj.userObjHash#Email" value="" class="" style="" /></p>
    <input type="hidden" name="#formObj.userObjHash#DateAddedinclude" id="#formObj.userObjHash#DateAddedinclude" value="1">
<input type="hidden" name="#formObj.userObjHash#DateAdded" id="#formObj.userObjHash#DateAdded" value="#now()#" style="" /></p>
    <input type="hidden" name="#formObj.userObjHash#ObjectID" value="#formObj.userObjHash#">
    <input type="hidden" name="#formObj.userObjHash#Typename" value="massMailerUser">
    <input type="submit" name="FarcryFormSubmitButton" value="Attach" onclick=";$('FarcryFormSubmitButtonClickedfarcryForm936443538').value = 'Attach';;return realeasyvalidation.validate();" class="formButton " style="" />
    <input type="hidden" name="FarcryFormPrefixes" id="FarcryFormPrefixes" value="#formObj.userObjHash#" />
    <input type="hidden" name="FarcryFormSubmitButton" id="FarcryFormSubmitButton" value="" />
    <input type="hidden" name="FarcryFormSubmitButtonClickedfarcryForm936443538" id="FarcryFormSubmitButtonClickedfarcryForm936443538" value="" />
    <input type="hidden" name="FarcryFormSubmitted" id="FarcryFormSubmitted" value="farcryForm936443538" />
    <input type="hidden" name="SelectedObjectID" id="SelectedObjectIDfarcryForm936443538" value="" />
    <input type="hidden" name="PRIMARYFORMFIELDNAME" value="#formObj.primaryNoHash#aObjectIDs" />
    <input type="hidden" name="FTALLOWLIBRARYADDNEW" value="massMailerUser" />
    <input type="hidden" name="CURRENTPAGE" value="1" />
    <input type="hidden" name="FTLIBRARYPICKLISTSTYLE" value="" />
    <input type="hidden" name="FTLIBRARYSELECTEDLISTCLASS" value="arrayDetail" />
    <input type="hidden" name="FTLIBRARYADDNEWWEBSKIN" value="libraryAdd" />
    <input type="hidden" name="FTLIBRARYPICKWEBSKIN" value="libraryPick" />
    <input type="hidden" name="FTLIBRARYSELECTEDWEBSKIN" value="LibrarySelected" />
    <input type="hidden" name="PACKAGETYPE" value="types" />
    <input type="hidden" name="PRIMARYOBJECTID" value="#formObj.primaryHash#" />
    <input type="hidden" name="FTALLOWLIBRARYEDIT" value="massMailerUser" />
    <input type="hidden" name="WIZARDID" value="" />
    <input type="hidden" name="LIBRARYTYPE" value="array" />
    <input type="hidden" name="PRIMARYTYPENAME" value="massMailerList" />
    <input type="hidden" name="FTLIBRARYPICKLISTCLASS" value="thumbNailsWrap" />
    <input type="hidden" name="PRIMARYFIELDNAME" value="aObjectIDs" />
    <input type="hidden" name="FTJOIN" value="massMailerUser" />
    <input type="hidden" name="FTLIBRARYSELECTEDLISTSTYLE" value="" />
    <input type="hidden" name="librarySection" value="addnew" />
</form>
        
        
            <script type="text/javascript">
                var realeasyvalidation = new Validation('farcryForm936443538', {onSubmit:false});
            </script>
</cfoutput>
<cfsetting enablecfoutputonly="false">

What we have is a call to formtools, supplied with our main object (massMailerList) and our attachment (massMailerUser). This code was wrought from within library.cfm. If you haven't already looked, it would be a great place to learn more about how the open library function works. I don't have any validation for the email field, yet. That's comming down the line.

Hopefully this makes this a little bit clearer. Or, at the very least, steers someone in the right direction.

FarCry plugin breakdown - Part II

First, an addendum. Matthew Bryant pointed out that I had forgetton wrap my objectAdmin tag within an <admin> call. This would explain why my wizzardStep and CSS formating wasn't happening correctly. The updated zip can be found at this location

Let's begin Part II by looking at the customadmin files. These files are responsible for generating the menu at the top of the FarCry administrator, and for providing the links on the left hand pane.

First up, the massMailer.xml:


<?xml version="1.0" encoding="utf-8"?>
<webtop>
    <section mergetype="merge" id="massMailerSection" label="Mass Mailer" labeltype="value">
        <subsection mergetype="merge" id="massMailerSubSection" label="Mass Mailer" labeltype="value">
            <menu mergeType="merge" id="massMailerMenu" label="Mass Mailer" labelType="value">
                <menuitem mergeType="merge" id="massMailer" label="Mass Mailer" link="/admin/customadmin.cfm?module=customlists/massMailer.cfm&plugin=massMailer" />
                <menuitem mergeType="merge" id="massMailerList" label="Mass Mailer List" link="/admin/customadmin.cfm?module=customlists/massMailerList.cfm&plugin=massMailer" />
                <menuitem mergeType="merge" id="massMailerUser" label="Mass Mailer User" link="/admin/customadmin.cfm?module=customlists/massMailerUser.cfm&plugin=massMailer" />
            </menu>
        </subsection>
    </section>
</webtop>

FarCry gives you the ability merge changes to the look and feel of the webtop via XML files. The above should be fairly straightforward to follow.

  • Section - Creates a new tab within the webtop
  • Subsection - Creates the subsection within the specified tab. More than one subsection may be created, and a drop down list of choices will be presented if more than one subsection exists.
  • Menu - The navigation for the subsection
  • Menuitem - Navigation links within the subsection
    • Link - The FarCry custom admin parser
    • Module - The location of your customadmin files. In this case, customadmin/massMailerxxx.cfm
    • Plugin - The name of the plugin for the module

Now, let's look at the files behind the link from above:


<cfsetting enablecfoutputonly="true">

<cfimport taglib="/farcry/core/tags/formtools" prefix="tags">
<cfimport taglib="/farcry/core/tags/admin/" prefix="admin" />

<!--- set up page header --->
<admin:header title="Mass Mailer Admin" />

<tags:objectAdmin
    title="Mass Mailer User"
    typename="massMailerUser"
    ColumnList="label"
    SortableColumns="label"
    lFilterFields="label"
    plugin="massMailer"
    sqlorderby="datetimelastUpdated desc" />


<admin:footer />

<cfsetting enablecfoutputonly="false">

Let's start our simplest object, the massMailerUser. We need to first import the formtools and admin tags. The <admin></admin> tags allows to setup nifty things like pagination, and also bring along page styling. The formtools tags will automagically style the inputs on our pages based on the CFCs we created before. Neat, huh?

We need a call to objectAdmin to display our main menu details. The arguments are:

  • Title - The title displayed at the top of the details page
  • Typename - Very important! This is the type we plan to display
  • Columnlist - Comma seperated list of list columns to display. This could be any column within the type specific database table. Label, action, and datetimecreated are the default
  • SortableColumns - Uh... no further explanation required
  • lFilterFields - Fields on which to allow filters (restrict results)
  • plugin - Plugin to use as a base
  • sqlorderby - Order in which records are displayed in the details page

This set of options should see us through most of what we need to get done. The massMailerList uses much the same call, just a different typename. Things get different for massMailer however.


<cfsetting enablecfoutputonly="true">

<cfimport taglib="/farcry/core/tags/formtools" prefix="tags">
<cfimport taglib="/farcry/core/tags/admin/" prefix="admin" />

<!--- set up page header --->
<admin:header title="Mass Mailer Admin" />

<tags:objectAdmin
    title="Mass Mailer User"
    typename="massMailerUser"
    ColumnList="label"
    SortableColumns="label"
    lFilterFields="label"
    plugin="massMailer"
    sqlorderby="datetimelastUpdated desc" />


<admin:footer />

<cfsetting enablecfoutputonly="false">

There is two things of note here. One is the array of buttons. You can override most of the default behavior of FarCry, and in this case, we need to add the "Send" email functionality. You will need to delve into objectAdmin and typeAdmin to sort out what values are expected here.

The other thing to note is our send functionality. It waits for the form to submit with our "Send" value, then calls to our plugins/massMailer/packages/types/massMailer.cfc with the objectID of the particular massMailer. If you recall from part one, there's a function within our CFC to handle this call, along with the send.cfm file.

FarCry plugin breakdown - Part I

I promised a breakdown, and so it shall be writ. This first segment is going to analyze the newly created objects. If I have wherewithal to finish tonight, we'll move along to the administrator addon.

Let's start with our objects then:

  • massMailer - This object will hold all the information about our email. Things like message body, subject, from, to, and the massMailerList objects.
  • massMailerList - This object contains the name of the list, and holds massMailerUser objects.
  • massMailerUser - This object contains the name, email address, and dateTime stamp when the object was created.

Now let's look at the code. We'll start with the massMailerUser.


<cfcomponent extends="farcry.core.packages.types.types" displayname="Mass Mailer Users" bFriendly="1" hint="Mass mailer object to hold the users" bobjectbroker="true" objectbrokermaxobjects="1000">
<!------------------------------------------------------------------------
type properties
------------------------------------------------------------------------->
    
<cfproperty ftSeq="11" ftFieldset="User Details" ftWizzardStep="General Details" name="Title" ftLabel="Name" type="string" hint="Users Name" required="no" default="">
<cfproperty ftSeq="12" ftFieldset="User Details" ftWizzardStep="General Details" name="Email" ftLabel="Email" type="string" hint="Email Address" required="no" default="">
<cfproperty ftseq="13" ftFieldset="User Details" ftWizzardStep="General Details" name="DateAdded" type="date" hint="The date user was added" required="yes" default=""ftDefaultType="Evaluate" ftDefault="now()" ftType="datetime" ftDateFormatMask="mm dd yyyy" ftTimeFormatMask="hh:mm tt" ftToggleOffDateTime="false" ftlabel="Date Added" />

<!------------------------------------------------------------------------
object methods
------------------------------------------------------------------------->
    
</cfcomponent>

Hmm... so what does THAT mean?? Let's break this object down. Formtools will generate our object administration page for us, but it needs some help to get along.

  • ftSeq - Numeric sequence that you wish the fields to be displayed in
  • ftFieldset - Gives "groups" within a given page. Usually denoted by a horizontal line
  • ftwizardSet - Should give pagination, but it isn't working (for me) at this time
  • name - Name for the object to be created in the database
  • ftLabel - Label to displayed in the admin
  • type - Type for database creation
  • hint - Typical component hint. Although I think there's a way to give context sensitive help, I just haven't explored it yet.
  • required - No need for explanation, right?
  • other ft types - Not going to into these in detail. There are several examples in the core for working with date/time types with the supplied date/time picker.

Next up, our massMailerList object


<cfcomponent extends="farcry.core.packages.types.types" displayname="Mass Mailer List" bFriendly="1" hint="Mass mailer object to create the lists" bobjectbroker="true" objectbrokermaxobjects="1000">
<!------------------------------------------------------------------------
type properties
------------------------------------------------------------------------->
    
<cfproperty ftSeq="11" ftFieldset="List Details" ftWizzardStep="General Details" name="Title" type="string" hint="Title of object." required="no" default="">
<cfproperty ftSeq="12" ftFieldset="List Details" ftWizzardStep="General Details" name="aObjectIDs" type="array" hint="Holds objects to be displayed at this particular node. Can be of mixed types." required="no" default="" ftLabel="Users" ftJoin="massMailerUser">

<!------------------------------------------------------------------------
object methods
------------------------------------------------------------------------->
    


</cfcomponent>

Pretty much more of the same, EXCEPT, for this little gem. Notice that my aObjectIDs is of type array. This type MUST have an ftJoin attribute applied. You would specify a component here that you would like to have data populated from. In our case it is massMailerUser. But it could easily be dmImage (default supplied image library) or dmFile (default supplied file library). Heck, it can even be a comma separated list of any of these things.

So what happens when you add this type of field? Formtools will generate a button for you to click, called open library. This will pop open a window, and you will be given a choice of various tabs. In the main view, you can drag the massMailerUser (or image, or file, or whatever) objects from the right hand pane to the left hand pane. And that's it, you're done. You've now attached objects as an array to your massMailerList object. And you didn't even have to write any code!

This leaves us with massMailer


<cfcomponent extends="farcry.core.packages.types.types" displayname="Mass Mailer" bFriendly="1" hint="Mass mailer object to send to lists created by Mass Mailer List" bobjectbroker="true" objectbrokermaxobjects="1000">
<!------------------------------------------------------------------------
type properties
------------------------------------------------------------------------->
    
<cfproperty ftSeq="11" ftfieldset="Mailer Details" ftWizzardStep="General Details" name="Title" type="string" hint="Title of object." required="Yes" default="">
<cfproperty ftSeq="12" ftfieldset="Mailer Details" ftWizzardStep="General Details" name="aObjectIDs" type="array" hint="FarCry Groups to send email to" required="Yes" default="" ftLabel="Lists" ftJoin="massMailerList">
<cfproperty ftSeq="13" ftfieldset="Mailer Details" ftWizzardStep="General Details" name="fromEmail" type="string" hint="From email address" required="Yes" default="">
<cfproperty ftSeq="14" ftfieldset="Mailer Details" ftWizzardStep="General Details" name="replyTo" type="string" hint="Address(es) to which the recipient is directed to send replies" required="no" default="">
<cfproperty ftSeq="15" ftfieldset="Mailer Details" ftWizzardStep="General Details" name="wraptext" type="string" hint="Specifies the maximum line length, in characters of the mail text." required="no" default="">
<cfproperty ftSeq="16" ftfieldset="Mailer Details" ftWizzardStep="General Details" name="failTo" type="string" hint="Address to which mailing systems should send delivery failure notifications. Sets the mail envelope reverse path value" required="no" default="">
<cfproperty ftSeq="17" ftfieldset="Mailer Details" ftWizzardStep="General Details" name="charset" type="string" hint="Character encoding of the mail message, including the headers" required="no" default="UTF-8">

<cfproperty ftSeq="21" ftfieldset="Text Body" ftWizzardStep="Text Body" name="Body" type="longchar" hint="Main body of content, text only." required="no" default="">
<cfproperty ftSeq="31" ftfieldset="HTML Body" ftWizzardStep="HTML Body" name="htmlBody" type="longchar" hint="Main body of content, to be sent to users as HTML" ftType="richtext"
    ftImageArrayField="aObjectIDs" ftImageTypename="dmImage" ftImageField="StandardImage" required="no" default=""
    ftTemplateTypeList="dmImage,dmFile" ftTemplateWebskinPrefixList="insertHTML"
    ftTemplateSnippetWebskinPrefix="insertSnippet">


<cfproperty name="bSent" type="boolean" hint="Flag for email being sent" required="yes" default="0">


<!------------------------------------------------------------------------
object methods
------------------------------------------------------------------------->
    

<cffunction name="send" access="public" output="true" hint="Prepares and sends email to members">
    <cfargument name="objectid" required="yes" type="UUID">
    <cfset stObjMail = createobject("component", application.types.massMailer.packagepath)>
    <cfset massObj = stObjMail.getData(objectid=arguments.objectid)>        
    <cfinclude template="send.cfm">
    
</cffunction>

</cfcomponent>

Again, more of the same. Except we also used a rich text for generation of our "Pretty" email body. Examples of such types exist in the core. Two things worth noting is the send function and the array of massMailerList(s). I plan to fully expound upon this in part II or III, but for now, know that it's there for us when it comes time to send out our mass mail!

Oh, and thank the heavens for FireFox's built in spell checker... it at least keeps these posts from being slightly more legible than I could manage without it.

My First Farcry Plugin... it's done, and here it is

Alrighty. I've created a zip of the plugin, and it will be available from here to download.

Installation instructions:

1) Install the latest version of FarCry Beta from either Jeff Coughlin's site or from the FarCry CMS page. Pertinent installation information can be found at their respective sites.

2) Modify your project//www/Application.cfm so that the plugins list includes massMailer in the list. This is a comma delimited list.

3) Open the FarCry admin and click on the Admin tab. Select COAPI from the dropdown list, and then click types. Deploy the three massMailer types. Next click rules, and deploy the massMailer rule.

Usage

Example 1: You want to have a form add a user to an email distribution list.

1) Open the FarCry admin and click on the Mass Mailer tab.

2) Click (in the left hand pane) the Mass Mailer List to create a new list.

3) Click Add to create a new List. Each List has two properties, a name, and a list of emails. We'll only worry about the name for now. Give the List a name, and Save.

4) Open a window to view your FarCry site. Switch to Design Mode, and click on a container where you'd like the new form to reside.

5) Choose the Mass Mailer Rule from the list, and add it to the container using the Commit button. This should take you to the next step. From here, select the Display Method (one is supplied for you), and use the Open Library to add a list. You can add only one list per rule! I'm thinking of modifying this in the future, but for now it stays. Save the results.

6) Refresh the page, and you should now see a form containing the Name and Email fields. Complete the form, and once submitted, it will add a new entry to your list (as well as create a new massMailerUser object). To verify, open the FarCry admin/Mass Mailer Tab and edit the Mass Mailer List you just created.

Example 2:

1) Follow steps 1-3 above. While still in the open library, you can choose to attach a new object.

2) Otherwise, click Mass Mailer User, add the new user, and then attach using the open library from Mass Mailer List.

Sending Mail

1) Open the FarCry admin, and click the Mass Mailer tab.

2) Click on the Mass Mailer link in the left hand pane. And then click Add from the top navigation.

3) Fill out the form fields as required. You need, at minimum, the Subject and List (open library). You can add as many lists as you like to the email.

4) There is a plan to add an attachment to the emails, but that's slated for the next release.

5) Save the object. Then select the object, and from the top/central navigation buttons, click Send.

The end! Tomorrow (or as time permits) I'll break down the objects and the "Why" of it.

My First Farcry... well, plugin is the term now, take 3.1

Alright. We have successful email creation in place. You can also assign a rule and a webskin to the rule. The final piece is adding the massMailerUser object to the massMailerList object via an online form. This should be completed tonight, family willing, and I'll start the break down/analysis of what each file does, and why. Thank you ray for the use of code tags, which ya'll will see extensive use of tomorrow ;).

Update: so close to the finish I can almost taste it... however, it's late. I need to sit in on performance tests tomorrow morning, so it will need to wait until tomorrow afternoon to finish up. The good news, though, is it works! I need to cull the deadwood of copied functions from the core/admin/facade/library.cfm that will not be used, but it appears that everything is working as it should. Yay!

My First FarCry library take 3

I finally got some free time to move this project towards completion. And then things went to heck in a handbasket when Daemon decided to change around the code base ;). So, what has changed is that farcry_core is now just core. Projects have moved to a projects folder. And farcry_lib is now plugins. That last is what really affected me. I had to change my customadmin and customlists to reflect this change.

As Stephen mentioned in previous comments, Formtools is just too sexy for itself. I went the easy route for the time being, but will climb the hard road in time.

My three objects still exist, one calling the other using the open library feature of Formtools. The only drawback I can fore see is there is no way to select multiple objects at a time. I'll see if anyone has extended this yet. This is now working smashingly.

Next up, setup the special columns required to send mail through the admin. Then, finally, adding users to lists via the web signup form.

Update: And we have success! You now create a user. Assign the user to a list(s). Assign that list to an email to be distributed, and then send. Full source to be fourth coming as soon as the rule (which can be dropped into a page) and webskin templates are setup. Maybe tonight, maybe tomorrow.

Update 2: The rule for adding the massMailer to a page has been created (which was pretty simple). Now the tough part... adding the formtools functionality to the webskin. Since we're attaching a new objectid into the massMailerList object, seems to be the most practical way of doing so. Of course, we could do it by straight database manipulation, but where's the fun in that ;).

My First FarCry library take 2

So, I'm going to need three different objects to accomplish this task. One massMailer, massMailerList and massMailerUser. The massMailer object is the main object, and it contains fields for From, Body, To (shown as a dropdown, but really a link to the massMailerList object), etc. The massMailerList object contains a title, and an array of massMailerUser objects. The massMailerUser object contains things like name, email, date added. Whew. These objects have been deployed, and their associated table data has been created.

Next up, creating the display methods and tweaking code so that Formtools displays the object properties correctly. However, given the lateness of the hour, it's not happening tonight.

Update: Sorry to those who are watching in anticipation of an early completion. Due to sick family members, I can't really finish this up until tomorrow night. On that note... sleep awaits.

More Entries