MDL-40061 mod_data: replaced 'fields delete' add_to_log call with an event

This commit is contained in:
Mark Nelson
2014-02-14 18:11:47 -08:00
parent 7ddb347cec
commit e37c413e87
5 changed files with 187 additions and 3 deletions
+16
View File
@@ -215,9 +215,25 @@ class data_field_base { // Base class for Database Field Types (see field/*/
global $DB;
if (!empty($this->field->id)) {
// Get the field before we delete it.
$field = $DB->get_record('data_fields', array('id' => $this->field->id));
$this->delete_content();
$DB->delete_records('data_fields', array('id'=>$this->field->id));
// Trigger an event for deleting this field.
$event = \mod_data\event\field_deleted::create(array(
'objectid' => $this->field->id,
'context' => $this->context,
'other' => array(
'fieldname' => $this->field->name,
'dataid' => $this->data->id
)
));
$event->add_record_snapshot('data_fields', $field);
$event->trigger();
}
return true;
}