} /*********************************** 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 ******************/ if ($action == 'forcedelete') { $id = required_param('valueid', PARAM_INT); $value = $DB->get_record($CFG->classification_value_table, array('id' => $id)); if ($value) { // delete related constraints $DB->delete_records($CFG->classification_constraint_table, array('value1' => $id));
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')) { $DB->delete_records($CFG->classification_value_table, array($CFG->classification_value_type_key => $id)); // clear constraint records $valueidslist = implode("','", array_keys($valueids)); $DB->delete_records_select($CFG->classification_constraint_table, "value1 IN ('{$valueidslist}') "); $DB->delete_records_select($CFG->classification_constraint_table, "value2 IN ('{$valueidslist}') ");