public function ajaxProcessUpdatePositions() { if ($this->tabAccess['edit'] === '1') { $way = (int) Tools::getValue('way'); $id = (int) Tools::getValue('id'); $table = 'feature'; $positions = Tools::getValue($table); if (empty($positions)) { $table = 'feature_value'; $positions = Tools::getValue($table); } $new_positions = array(); foreach ($positions as $v) { if (!empty($v)) { $new_positions[] = $v; } } foreach ($new_positions as $position => $value) { $pos = explode('_', $value); if (isset($pos[2]) && (int) $pos[2] === $id) { if ($table == 'feature') { if ($feature = new Feature((int) $pos[2])) { if (isset($position) && $feature->updatePosition($way, $position, $id)) { echo 'ok position ' . (int) $position . ' for feature ' . (int) $pos[1] . '\\r\\n'; } else { echo '{"hasError" : true, "errors" : "Can not update feature ' . (int) $id . ' to position ' . (int) $position . ' "}'; } } else { echo '{"hasError" : true, "errors" : "This feature (' . (int) $id . ') can t be loaded"}'; } break; } elseif ($table == 'feature_value') { if ($feature_value = new FeatureValue((int) $pos[2])) { if (isset($position) && $feature_value->updatePosition($way, $position, $id)) { echo 'ok position ' . (int) $position . ' for feature value ' . (int) $pos[2] . '\\r\\n'; } else { echo '{"hasError" : true, "errors" : "Can not update feature value ' . (int) $id . ' to position ' . (int) $position . ' "}'; } } else { echo '{"hasError" : true, "errors" : "This feature value (' . (int) $id . ') can t be loaded"}'; } break; } } } } }