$category = new claroCategory(); $category->handleForm(); if ($category->validate()) { $category->save(); $dialogBox->success(get_lang('Category modified')); } else { if (claro_failure::get_last_failure() == 'category_duplicate_code') { $dialogBox->error(get_lang('This code already exists')); } elseif (claro_failure::get_last_failure() == 'category_self_linked') { $dialogBox->error(get_lang('Category can\'t be its own parent')); } elseif (claro_failure::get_last_failure() == 'category_child_linked') { $dialogBox->error(get_lang('Category can\'t be linked to one of its own children')); } elseif (claro_failure::get_last_failure() == 'category_missing_field') { $dialogBox->error(get_lang('Some fields are missing')); } $dialogBox->form($category->displayForm()); } break; // Delete an existing category // Delete an existing category case 'exDelete': $category = new claroCategory(); if ($category->load($id)) { if (ClaroCategory::countSubCategories($category->id) > 0) { $dialogBox->error(get_lang('You cannot delete a category having sub categories')); } else { $category->delete(); $dialogBox->success(get_lang('Category deleted. Courses linked to this category have been linked to the root category.')); } } else { $dialogBox->error(get_lang('Category not found'));