Skip to content

Instantly share code, notes, and snippets.

View howellcc's full-sized avatar

Clint howellcc

  • 01:46 (UTC -04:00)
View GitHub Profile
@howellcc
howellcc / [MuraCMS] Confirmation Email.cfm
Last active January 20, 2016 19:10
[MuraCMS] Confirmation email for a form builder form.
//Place this code in your theme-leve eventHandler.cfc.
public any function onAfterFormSubmitSave($) output="true"{
if(len($.event('CONFIRMATIONEMAIL')) and isValid('email',$.event('CONFIRMATIONEMAIL'))) {
local.formFields = deserializeJSON($.event('formbean').getbody()).form.fields;
local.mailSvc = new mail();
@howellcc
howellcc / muraCustomUI.cfm
Created February 3, 2016 18:25 — forked from stevewithington/muraCustomUI.cfm
Mura CMS: Example of how to use the 'Custom UI' container/tab assignment option when creating a class extension.
<!---
A brief example on how to use the 'CustomUI' option when creating a class extension in Mura CMS.
This example assumes you have an extended attribute called 'Page/Book'.
It also assumes you have an attribute set using the 'CustomUI' container/tab assignment.
Any extended attributes you assign to the attribute set, you are responsible for collecting
that data using your own form fields. Make sure the 'name' and 'id' attributes match the
names you've used when you created the extended attributes! For example, if you have an
extended attribute with a name of 'bookPublisher', make sure you have a form field with an
'id' and 'name' attribute of 'bookPublisher'. Check your casing too!
@howellcc
howellcc / OnDashboardReplacement-RedirectToPlugin.cfm
Created February 4, 2016 15:13
[MuraCMS] Redirect a user directly to a plugin upon logging into the administrator.
//Place this function in a plugin's eventHandler.cfc. It will redirect a member of "Plugin Users" to the plugin immediately upon logging in.
public any function onDashboardReplacement(required struct $){
var returnString = "";
//Does user have permission to the plugin?
if(application.permUtility.getModulePerm(application[variables.framework.applicationKey].pluginConfig.getModuleID(), session.siteid)){
if($.currentUser().isInGroup("Plugin Users") && ! $.currentUser().isInGroup("Admin")){
returnString = "<script>
location.href='#application.configBean.getContext()#/plugins/#variables.framework.package#/';
@howellcc
howellcc / EfficientNavCaching.js
Last active March 11, 2016 22:28
[MuraCMS] An efficient way to cache nav
/*Mura Nav Caching.
Set the nav caching to only cache 1 copy (no attaching an ID to the key)
Then put this in the javascript
*/
//Active class for mobile nav - This is done so that we can cache the mobile nav once and apply the active class after rendering
activeID = $('body').attr('class').replace(/^sys/,'nav');
$('#'+activeID).addClass('active');
$('#'+activeID).parents('li').addClass('active');
@howellcc
howellcc / Database Table Reorg.sql
Created April 8, 2016 17:36
[SQL] Reorganize every table in every schema in a database.
USE --DATABASE NAME
DECLARE @TableName varchar(255)
DECLARE @TableSchema varchar(255)
DECLARE @FULLNAME varchar(512)
DECLARE TableCursor CURSOR FOR
<cfscript>
var APIUtility = getBean('settingsManager').getSite({siteid}).getAPI('json', 'v1');
APIUtility.registerMethod(methodName='applyProperty', method=applyProperty);
public any function applyProperty() {
// do something
}
</cfscript>
@howellcc
howellcc / xmlToStruct.cfm
Last active November 9, 2016 19:38
This borrows heavily from the work by Ray Camden https://www.raymondcamden.com/2012/01/04/Converting-XML-to-JSON-My-exploration-into-madness https://gist.github.com/cfjedimaster/4580449 and redherring917 https://gist.github.com/redherring917/7929512 I had noticed that if the ending leaf was an array that the first element would be returned prope…
/*
This borrows heavily from the work by Ray Camden
https://www.raymondcamden.com/2012/01/04/Converting-XML-to-JSON-My-exploration-into-madness
https://gist.github.com/cfjedimaster/4580449
and redherring917 https://gist.github.com/redherring917/7929512
I had noticed that if the ending leaf was an array that the first element would be returned properly, but the subsequent values in the array would be return as a struct.
*/
@howellcc
howellcc / ParseLargeXMLFiles.cfc
Last active November 9, 2016 22:00 — forked from bennadel/code-1.cfm
Ask Ben: Parsing Very Large XML Documents In ColdFusion
component
output="false"
hint="I help to parse large XML files by matching patterns and then only parsing sub-nodes of the document." {
public any function Init(required string Nodes, required string XmlFilePath, numeric BufferSize=(1024*1024*5)) {
/*
Create the regular expression pattern based on the
node list. We have to match both standard nodes and
@howellcc
howellcc / comboFromEnumeration.cs
Created September 13, 2017 11:51
Populating a combobox from an enumeration
using LCS.Core.Extensions;
//define collection
private ObservableCollection<KeyValuePair<eApplicantType, string>> ApplicantTypes { get; set; }
//populate collection eg. initialize()
this.ApplicantTypes = new ObservableCollection<KeyValuePair<eApplicantType, string>>();
foreach (eApplicantType type in Enum.GetValues(typeof(eApplicantType)))
{
if (type == eApplicantType.NotSet) { continue; }
@howellcc
howellcc / loadtestdata.bat
Created June 29, 2018 19:25
Batch script for clearing and reloading test data
@echo off
REM This file relies on the existence of C:\my.ini with the following contents
REM [client]
REM user=[username]
REM password=[password]
REM Ask user for dbname
SET /p dbname="Database Name: "