From f1eec57221f9bca047ff8d422ade1e26df0fa233 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 5 Apr 2009 16:57:51 +0000 Subject: Add a weight column to the items model. Change the album ordering to use this as the default instead of id. This prepares the way for manual reordering in the organize functionality. --- core/models/item.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'core/models') diff --git a/core/models/item.php b/core/models/item.php index 528752e8..b28f71fe 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -295,6 +295,11 @@ class Item_Model extends ORM_MPTT { $this->updated = time(); if (!$this->loaded) { $this->created = $this->updated; + // let albums have a weight of zero so they come first + if (!$this->is_album()) { + $r = ORM::factory("item")->select("MAX(weight) as max_weight")->find(); + $this->weight = $r->max_weight + 1; + } } } return parent::save(); -- cgit v1.2.3