From 89eebd98fcb611047b40f318651651e54cbd4fce Mon Sep 17 00:00:00 2001 From: avl Date: Wed, 25 Mar 2009 12:12:44 +0200 Subject: [PATCH] reorder customizable --- ipf/admin/views.php | 8 +------- ipf/orm/record.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ipf/admin/views.php b/ipf/admin/views.php index ee214f6..16720ac 100644 --- a/ipf/admin/views.php +++ b/ipf/admin/views.php @@ -102,13 +102,7 @@ function IPF_Admin_Views_Reorder($request, $match){ $o = new $m(); $ids = split(',',(string)$request->POST['ids']); - $ord = 1; - foreach($ids as $id){ - $item = $o->getTable()->find($id); - $item[$ord_field] = $ord; - $item->save(); - $ord++; - } + $o->_reorder($ids, $ord_field); return new IPF_HTTP_Response_Json("Ok"); } } diff --git a/ipf/orm/record.php b/ipf/orm/record.php index 9eeb8f1..42a86fb 100644 --- a/ipf/orm/record.php +++ b/ipf/orm/record.php @@ -1295,4 +1295,15 @@ abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countab return $this->_custom[$name]; return null; } + + public function _reorder($ids, $ord_field){ + $ord = 1; + foreach($ids as $id){ + $item = $this->getTable()->find($id); + $item[$ord_field] = $ord; + $item->save(); + $ord++; + } + } + } \ No newline at end of file -- 2.49.0