From d8342231421cb76475fc42820249603ea7f388c4 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 14 Sep 2009 05:15:49 +0000 Subject: [PATCH] ENHANCEMENT Supporting full parameter signature in Versioned->Versions(), allVersions() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@86216 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/Versioned.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/model/Versioned.php b/core/model/Versioned.php index 2f75332ae..ad038e2bd 100755 --- a/core/model/Versioned.php +++ b/core/model/Versioned.php @@ -506,20 +506,20 @@ class Versioned extends DataObjectDecorator { return !$stagesAreEqual; } - function Versions($filter = "") { - return $this->allVersions($filter); + function Versions($filter = "", $sort = "", $limit = "", $join = "", $having = "") { + return $this->allVersions($filter, $sort, $limit, $join, $having); } /** * Return a list of all the versions available. * @param string $filter */ - function allVersions($filter = "") { - $query = $this->owner->extendedSQL($filter,""); + function allVersions($filter = "", $sort = "", $limit = "", $join = "", $having = "") { + $query = $this->owner->extendedSQL($filter, $sort, $limit, $join, $having); - foreach($query->from as $table => $join) { - if($join[0] == '"') $baseTable = str_replace('"','',$join); - else if (substr($join,0,5) != 'INNER') $query->from[$table] = "LEFT JOIN \"$table\" ON \"$table\".\"RecordID\" = \"{$baseTable}_versions\".\"RecordID\" AND \"$table\".\"Version\" = \"{$baseTable}_versions\".\"Version\""; + foreach($query->from as $table => $tableJoin) { + if($tableJoin[0] == '"') $baseTable = str_replace('"','',$tableJoin); + else if (substr($tableJoin,0,5) != 'INNER') $query->from[$table] = "LEFT JOIN \"$table\" ON \"$table\".\"RecordID\" = \"{$baseTable}_versions\".\"RecordID\" AND \"$table\".\"Version\" = \"{$baseTable}_versions\".\"Version\""; $query->renameTable($table, $table . '_versions'); } @@ -529,7 +529,7 @@ class Versioned extends DataObjectDecorator { } $query->where[] = "\"{$baseTable}_versions\".\"RecordID\" = '{$this->owner->ID}'"; - $query->orderby = "\"{$baseTable}_versions\".\"LastEdited\" DESC, \"{$baseTable}_versions\".\"Version\" DESC"; + $query->orderby = ($sort) ? $sort : "\"{$baseTable}_versions\".\"LastEdited\" DESC, \"{$baseTable}_versions\".\"Version\" DESC"; $records = $query->execute();