$xmlwriter->setHeaderMessage($l->g('error')); if (!empty($category_id) && $category->_db_getList('id = ' . $category_id)) { // Category exists $xmlwriter->setHeaderStatus(0); $xmlwriter->setHeaderMessage('OK'); $category_data = $category->_db_list[0]; $category->_db_freelist(); switch ($action) { case 'change_listpos': if (empty($dir)) { // Move up if ($category->_db_getList('id,listpos', 'parent_id = ' . $category_data['parent_id'], 'listpos < ' . $category_data['listpos'], 'listpos DESC', 1)) { $higher_cat_id = $category->_db_list[0]['id']; $higher_cat_listpos = $category->_db_list[0]['listpos']; // Update category $category->updateCategory($category_id, false, true, null, null, null, null, $higher_cat_listpos); // Update higher category $category->updateCategory($higher_cat_id, false, true, null, null, null, null, $category_data['listpos']); } } else { // Move down if ($category->_db_getList('id,listpos', 'parent_id = ' . $category_data['parent_id'], 'listpos > ' . $category_data['listpos'], 'listpos ASC', 1)) { $lower_cat_id = $category->_db_list[0]['id']; $lower_cat_listpos = $category->_db_list[0]['listpos']; // Update category $category->updateCategory($category_id, false, true, null, null, null, null, $lower_cat_listpos); // Update lower category $category->updateCategory($lower_cat_id, false, true, null, null, null, null, $category_data['listpos']); } } break;