cheesegrits
Support Gopher
Code:
If I've missed something obvious and there is already a way of doing this, my apologies.
I needed to be able to provide the last insert id as part of the submit feedback. Specifically, as the 'ticket id' I hand the customer when they submit feedback. No point maintaining my own unique, indexed, auto incrementing, numeric ID for a record when it already has one. :)
I couldn't find any way of doing this as-is, so I did this.
In fabrik.class.php, around line 1030 in processForm(), I added one line:
[code] $insertId = $oTable->_lastInsertId;
# $$$ hugh
$this->insertId = $insertId;
In fabrik_parent.class.php, around line 268, in _replaceWithGlobals(), I added one line:
function _replaceWithGlobals( $msg ){
global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_offset, $Itemid, $mosConfig_sitename, $my;
# $$$ hugh
$msg = str_replace('{fabrik_internal_id}',$this->insertId, $msg)
[/code]
So I can now use {fabrik_internal_id} in my feedback forms and (I'm assuming, I haven't tested it yet) emails.
I tried just global'ing $insertId into _replaceWithGlobals() rather than copying it to $this in processForm() 'cos it'd be one less file edit, but it always showed up as NULL and I was too tired to work out why. Probably a Class Thang.
Anyway, I'd be Ever So Grateful if you could include this little patch into the svn head, so I don't have to keep patching my version. Unless of course I've spaced and there is already some way of doing this!
-- hugh