Extract reweighting logic out of Organize_Controller into

item::reweight_all_children as an API and write a test for it.  Work
in progress on #1914.
This commit is contained in:
Bharat Mediratta
2013-01-23 21:33:19 -05:00
parent de78d3bfca
commit aa8fffcd8f
3 changed files with 28 additions and 7 deletions

View File

@@ -128,13 +128,7 @@ class Organize_Controller extends Controller {
access::required("edit", $album);
if ($album->sort_column != "weight") {
// Force all the weights into the current order before changing the order to manual
$weight = 0;
foreach ($album->children() as $child) {
$child->weight = ++$weight;
$child->save();
}
item::resequence_child_weights($album);
$album->sort_column = "weight";
$album->sort_order = "ASC";
$album->save();