diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-04-05 16:57:51 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-04-05 16:57:51 +0000 |
commit | f1eec57221f9bca047ff8d422ade1e26df0fa233 (patch) | |
tree | 8d271693657c7383be277742caaeaa9a81ccde9d /core/models | |
parent | 15fc9b9399ede22879c5f5a6ff95d058986d0278 (diff) |
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.
Diffstat (limited to 'core/models')
-rw-r--r-- | core/models/item.php | 5 |
1 files changed, 5 insertions, 0 deletions
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(); |