From: avl Date: Wed, 25 Mar 2009 10:12:44 +0000 (+0200) Subject: reorder customizable X-Git-Tag: 0.5~409 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=89eebd98fcb611047b40f318651651e54cbd4fce;p=ipf.git reorder customizable --- 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