From fc2d17ace5d2dd818947b9d61fbc96ce31e6d4ea Mon Sep 17 00:00:00 2001 From: Ed Date: Sat, 25 May 2013 20:28:46 -0300 Subject: [PATCH] Improved how the last edit table is found using ClassInfo::baseDataClass() --- code/forms/GridFieldSortableRows.php | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/code/forms/GridFieldSortableRows.php b/code/forms/GridFieldSortableRows.php index 40095e8..024e619 100644 --- a/code/forms/GridFieldSortableRows.php +++ b/code/forms/GridFieldSortableRows.php @@ -183,12 +183,6 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP user_error('Sort column '.$this->sortColumn.' could not be found in '.$gridField->getModelClass().'\'s ancestry', E_USER_ERROR); exit; } - - //Find table containing the last edited column - $lastEditTable=false; - $class=$gridField->getModelClass(); - $classes=array_keys(ClassInfo::ancestry($class, true)); - $lastEditTable=$classes[0]; } @@ -208,7 +202,7 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP . '" SET "' . $sortColumn . '" = ' . ($max + $i) . ' WHERE "ID" = '. $obj->ID); - DB::query('UPDATE "' . $lastEditTable + DB::query('UPDATE "' . ClassInfo::baseDataClass($gridField->getModelClass()) . '" SET "LastEdited" = \'' . date('Y-m-d H:i:s') . '\'' . ' WHERE "ID" = '. $obj->ID); } @@ -318,12 +312,6 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP user_error('Sort column '.$this->sortColumn.' could not be found in '.$gridField->getModelClass().'\'s ancestry', E_USER_ERROR); exit; } - - //Find table containing the last edited column - $lastEditTable=false; - $class=$gridField->getModelClass(); - $classes=array_keys(ClassInfo::ancestry($class, true)); - $lastEditTable=$classes[0]; } @@ -345,7 +333,7 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP . '" SET "' . $sortColumn . '" = ' . (($sort + 1) + $pageOffset) . ' WHERE "ID" = '. $id); - DB::query('UPDATE "' . $lastEditTable + DB::query('UPDATE "' . ClassInfo::baseDataClass($gridField->getModelClass()) . '" SET "LastEdited" = \'' . date('Y-m-d H:i:s') . '\'' . ' WHERE "ID" = '. $id); }