]> git.andy128k.dev Git - ipf.git/commitdiff
reorder customizable
authoravl <alex.litovchenko@gmail.com>
Wed, 25 Mar 2009 10:12:44 +0000 (12:12 +0200)
committeravl <alex.litovchenko@gmail.com>
Wed, 25 Mar 2009 10:12:44 +0000 (12:12 +0200)
ipf/admin/views.php
ipf/orm/record.php

index ee214f62588939a3fadea860cd03d9dc31c6b77f..16720ac95331d737562e6424041ee2842bc79620 100644 (file)
@@ -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");
             }
         }
index 9eeb8f154ef641ad39b3a5f810169a23d14a2ff7..42a86fb24e5010a385cd39faf098f2b846646e46 100644 (file)
@@ -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