summaryrefslogtreecommitdiff
path: root/core/models/item.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/models/item.php')
-rw-r--r--core/models/item.php9
1 files changed, 5 insertions, 4 deletions
diff --git a/core/models/item.php b/core/models/item.php
index b01e9e3d..1ab78878 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -289,10 +289,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;
+ $r = ORM::factory("item")->select("MAX(weight) as max_weight")->find();
+ $this->weight = $r->max_weight + 1;
+ // Let albums have a weight of based on the largest -ve number so they come first.
+ if ($this->is_album()) {
+ $this->weight = -(0x7FFFFFFF - $this->weight;
}
}
}