$metadatavalue->code = clean_param($data->code, PARAM_ALPHANUM);
    $metadatavalue->value = clean_param('value', PARAM_CLEANHTML);
    if (!$DB->update_record($CFG->classification_value_table, $metadatavalue)) {
        print_error('errorupdatevalue', 'customlabel');
    }
    redirect($url . "?view=qualifiers&typeid={$data->typeid}");
}
/*********************************** get a value for editing ************************/
if ($action == 'edit') {
    $valueid = required_param('valueid', PARAM_INT);
    $data = $DB->get_record($CFG->classification_value_table, array('id' => $valueid));
}
/*********************************** moves up ************************/
if ($action == 'up') {
    $id = required_param('valueid', PARAM_INT);
    classification_tree_up($id, $type);
    classification_tree_updateordering(0, $type);
}
/*********************************** moves down ************************/
if ($action == 'down') {
    $id = required_param('valueid', PARAM_INT);
    classification_tree_down($id, $type);
    classification_tree_updateordering(0, $type);
}
/************************************* Delete safe (only if not used) ******************/
if ($action == 'delete') {
    // todo check if there is no instances working with such type.
    // if not, bounce to forcedelete
    $action = 'forcedelete';
}
/************************************* Delete unsafe ******************/
    $metadatatype->name = clean_param($data->name, PARAM_CLEANHTML);
    $metadatatype->description = clean_param($data->description, PARAM_CLEANHTML);
    if (!$DB->update_record($CFG->classification_type_table, $metadatatype)) {
        error('Could not insert a new type');
    }
    redirect($url . '?view=classifiers');
}
/*********************************** get a type for editing ************************/
if ($action == 'edit') {
    $typeid = required_param('typeid', PARAM_INT);
    $data = $DB->get_record($CFG->classification_type_table, array('id' => $typeid));
}
/*********************************** moves up ************************/
if ($action == 'up') {
    $id = required_param('typeid', PARAM_INT);
    classification_tree_up($id);
}
/*********************************** moves down ************************/
if ($action == 'down') {
    $id = required_param('typeid', PARAM_INT);
    classification_tree_down($id);
}
/************************************* Delete safe (only if not used) ******************/
if ($action == 'delete') {
    $id = required_param('typeid', PARAM_INT);
    $typeorder = $DB->get_field($CFG->classification_type_table, 'sortorder', array('id' => $id));
    if (!$DB->delete_records($CFG->classification_type_table, array('id' => $id))) {
        print_error('could not delete classifier');
    }
    // clear all sub values
    if ($valueids = $DB->get_records_menu($CFG->classification_type_table, array('type' => $id), 'id,id')) {