File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -270,6 +270,8 @@ public function duplicate(array $options = []) {
270
270
public function moveUp () {
271
271
global $ DB ;
272
272
273
+ $ this ->fixOrder ();
274
+
273
275
$ order = $ this ->fields ['order ' ];
274
276
$ formId = $ this ->fields ['plugin_formcreator_forms_id ' ];
275
277
$ otherItem = new static ();
@@ -313,6 +315,8 @@ public function moveUp() {
313
315
public function moveDown () {
314
316
global $ DB ;
315
317
318
+ $ this ->fixOrder ();
319
+
316
320
$ order = $ this ->fields ['order ' ];
317
321
$ formId = $ this ->fields ['plugin_formcreator_forms_id ' ];
318
322
$ otherItem = new static ();
@@ -349,6 +353,34 @@ public function moveDown() {
349
353
return $ success ;
350
354
}
351
355
356
+ public function fixOrder (): void
357
+ {
358
+ global $ DB ;
359
+
360
+ $ formId = $ this ->fields ['plugin_formcreator_forms_id ' ];
361
+
362
+ $ iterator = $ DB ->request ([
363
+ 'FROM ' => static ::getTable (),
364
+ 'WHERE ' => [
365
+ 'AND ' => [
366
+ 'plugin_formcreator_forms_id ' => $ formId ,
367
+ ]
368
+ ],
369
+ 'ORDER ' => ['order ASC ' ]
370
+ ]);
371
+ $ order = 1 ;
372
+ foreach ($ iterator as $ row ) {
373
+ if ($ row ['order ' ] !== $ order ) {
374
+ $ DB ->update (static ::getTable (), [
375
+ 'order ' => $ order
376
+ ], [
377
+ 'id ' => $ row ['id ' ]
378
+ ]);
379
+ }
380
+ $ order ++;
381
+ }
382
+ }
383
+
352
384
public static function import (PluginFormcreatorLinker $ linker , $ input = [], $ containerId = 0 ) {
353
385
global $ DB ;
354
386
You can’t perform that action at this time.
0 commit comments