/** * Test that when a custom field is configured, then deleted, the field is removed from configuration. */ public function test_rlipexport_version1elis_extrafieldsetcustomfieldbase_handledeleted() { $this->load_csv_data(); $fieldid1 = $this->create_custom_field('testcf1', 0, false, CONTEXT_ELIS_USER, 'text'); $this->create_field_mapping('testcustomfields', 'field_' . $fieldid1, 'Field One'); $this->create_field_data($fieldid1, 'Test Text One'); $field = new field($fieldid1); $field->load(); $field->delete(); $enabledfields = rlipexport_version1elis_extrafields::get_enabled_fields(); $fieldset = new rlipexport_version1elis_extrafieldset_testcustomfields($enabledfields['testcustomfields']); $columns = $fieldset->get_columns(); $this->assertInternalType('array', $columns); $this->assertEmpty($columns); $record = new stdClass(); $data = $fieldset->get_data($record); $this->assertInternalType('array', $data); $this->assertEmpty($data); }
function display_deletefield() { global $OUTPUT; $level = $this->required_param('level', PARAM_ACTION); $id = $this->required_param('id', PARAM_INT); $field = new field($id); if (!$field->id) { print_error('invalid_field_id', 'local_elisprogram'); } $confirm = $this->optional_param('confirm', 0, PARAM_INT); if ($confirm) { $field->delete(); $tmppage = new customfieldpage(array('level' => $level)); redirect($tmppage->url, get_string('field_deleted', 'local_elisprogram', $field)); } else { $optionsyes = array('s' => $this->pagename, 'action' => 'deletefield', 'id' => $id, 'confirm' => 1, 'level' => $level); $optionsno = array('s' => $this->pagename, 'level' => $level); $buttoncontinue = new single_button(new moodle_url('index.php', $optionsyes), get_string('yes'), 'POST'); $buttoncancel = new single_button(new moodle_url('index.php', $optionsno), get_string('no'), 'GET'); echo $OUTPUT->confirm(get_string('confirm_delete_field', 'local_elisprogram', array('datatype' => $field->datatype, 'name' => $field->name)), $buttoncontinue, $buttoncancel); } }
function delete() { global $CURMAN; $fields = $CURMAN->db->get_records(FIELDTABLE, 'categoryid', $this->id); if (!empty($fields)) { foreach ($fields as $field) { $fieldobj = new field($field); $fieldobj->delete(); } } // delete category context data $CURMAN->db->delete_records(FIELDCATEGORYCONTEXTTABLE, 'categoryid', $this->id); // delete field $CURMAN->db->delete_records(FIELDTABLE, 'categoryid', $this->id); // delete category parent::delete(); }
function action_deletefield() { $level = $this->required_param('level', PARAM_ACTION); $id = $this->required_param('id', PARAM_INT); $field = new field($id); if (!$field->id) { print_error('invalidfieldid', 'block_curr_admin'); } $confirm = $this->optional_param('confirm', 0, PARAM_INT); if ($confirm) { $field->delete(); $tmppage = new customfieldpage(array('level' => $level)); redirect($tmppage->get_url(), get_string('field_deleted', 'block_curr_admin', $field)); } else { notice_yesno(get_string('confirm_delete_field', 'block_curr_admin', $field), 'index.php', 'index.php', array('s' => $this->pagename, 'action' => 'deletefield', 'id' => $id, 'confirm' => 1, 'level' => $level), array('s' => $this->pagename, 'level' => $level), 'POST', 'GET'); } }