summaryrefslogtreecommitdiff
path: root/core/models
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-04-09 18:17:53 +0000
committerTim Almdal <tnalmdal@shaw.ca>2009-04-09 18:17:53 +0000
commit25237205619cdbd02a47535a9a7cc2882f372a8f (patch)
treec4751eb4dfc592df7cce3d0a86c769a46fe3eb62 /core/models
parente692868e8a968d652092a3b85898ff1be74d7a1f (diff)
Change the weight for albums from zero, which could give us
indeterminate ordering, so that ablums are initially shown first.
Diffstat (limited to 'core/models')
-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;
}
}
}