1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Taxonomy\Vocabulary;
13
14 use ICanBoogie\Operation;
15
16 class OrderOperation extends Operation
17 {
18 protected function get_controls()
19 {
20 return array
21 (
22 self::CONTROL_OWNERSHIP => true
23 )
24
25 + parent::get_controls();
26 }
27
28 protected function validate(\ICanboogie\Errors $errors)
29 {
30 return !empty($this->request['terms']);
31 }
32
33 protected function process()
34 {
35 global $core;
36
37 $w = 0;
38 $weights = array();
39 $update = $core->models['taxonomy.terms']->prepare('UPDATE {self} SET weight = ? WHERE vtid = ?');
40
41 foreach ($this->request['terms'] as $vtid => $dummy)
42 {
43 $update->execute(array($w, $vtid));
44 $weights[$vtid] = $w++;
45 }
46
47 return true;
48 }
49 }