Plugin Hook for Bulk Save?

3 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: July 29, 2014   (RSS)

By gregThomas - July 29, 2014

Hi Perch,

The problem is that the inlineEditing plugin doesn't contain a plugin hook to access after the record is saved, but its actually fairly simple to add the record_postsave hook. 

If you go to line 54, you should see the following code:

    $query = "UPDATE {$TABLE_PREFIX}{$tableName} SET ";
    for ( $i=0; $i<count($q); $i++ ) {
      $query .= $q[$i];
      if ( $i+1 < count($q) ) $query .= ',';
    }
    $query .= " WHERE num='" . mysql_escape($num) . "'";
    mysql_query( $query ) or die( 'Could not execute bulk update: ' . mysql_error() );

Then just add the following lines:

    $query = "UPDATE {$TABLE_PREFIX}{$tableName} SET ";
    for ( $i=0; $i<count($q); $i++ ) {
      $query .= $q[$i];
      if ( $i+1 < count($q) ) $query .= ',';
    }
    $query .= " WHERE num='" . mysql_escape($num) . "'";
    $oldRecord = mysql_get($tableName, $num);
    mysql_query( $query ) or die( 'Could not execute bulk update: ' . mysql_error() );
    doAction('record_postsave', $tableName, false, $oldRecord, $num);

Adding these lines will make the inlineEditing plugin fire the record_postsave hook for each record that needs updating, and send it the record before it was edited in the $oldRecord variable.

These are custom changes, so we can't provide any official support for them.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Perchpole - July 29, 2014

Cheers, Greg -

That's great.

:0)
Perch