diff --git a/mod/data/add.php b/mod/data/add.php
index 1e863bc8396..4118576244f 100755
--- a/mod/data/add.php
+++ b/mod/data/add.php
@@ -27,10 +27,11 @@
require_login();
- $mode ='addtemplate'; //define the mode for this page, only 1 mode available
$id = optional_param('id', 0, PARAM_INT); // course module id
$d = optional_param('d', 0, PARAM_INT); // database id
$rid = optional_param('rid', 0, PARAM_INT); //record id
+ $import = optional_param('import', 0, PARAM_INT); // show import form
+ $mode ='addtemplate'; //define the mode for this page, only 1 mode available
if ($id) {
if (! $cm = get_record('course_modules', 'id', $id)) {
@@ -255,36 +256,40 @@
/// Upload records section. Only for teachers and the admin.
if (isteacher($course->id)) {
- echo "\n\n";
- print_simple_box_start('center','80%');
- print_heading(get_string('uploadrecords', 'data'), '', 3);
-
- $maxuploadsize = get_max_upload_file_size();
- echo '
';
- print_simple_box_end();
+ if ($import) {
+ print_simple_box_start('center','80%');
+ print_heading(get_string('uploadrecords', 'data'), '', 3);
+
+ $maxuploadsize = get_max_upload_file_size();
+ echo '';
+ print_simple_box_end();
+ } else {
+ echo '';
+ }
}
diff --git a/mod/data/lib.php b/mod/data/lib.php
index cb504c6557e..c7e4dc26c3c 100755
--- a/mod/data/lib.php
+++ b/mod/data/lib.php
@@ -212,6 +212,7 @@ class data_field_base { /// Base class for Database Field Types (see field/*
/// Display the content of the field in browse mode
function display_browse_field($recordid, $template) {
if ($content = get_record('data_content','fieldid', $this->field->id, 'recordid', $recordid)) {
+ print_object($content);
if (isset($content->content)) {
$options->para = false;
$str = format_text($content->content, $content->content1, $options);
diff --git a/mod/data/view.php b/mod/data/view.php
index b994f5a7b11..2aa2eb8a664 100755
--- a/mod/data/view.php
+++ b/mod/data/view.php
@@ -165,44 +165,28 @@
/***************************
* code to delete a record *
***************************/
- if (($delete = optional_param('delete',0,PARAM_INT)) && confirm_sesskey()){
+ if (($delete = optional_param('delete',0,PARAM_INT)) && confirm_sesskey()) {
if (isteacheredit($course) or data_isowner($delete)){
- if ($confirm = optional_param('confirm',0,PARAM_INT)){
- //find all contents in this record?
- if ($contents = get_records('data_content','recordid',$delete)){
-
- //for each content, delete the file associated
- foreach ($contents as $content){
- $field = get_record('data_fields','id',$content->fieldid);
-
- if ($g = data_get_field($field, $data)){ //it is possible that the field is deleted by teacher
- $g->delete_content($data->id, $delete, $content->content);
+ if ($confirm = optional_param('confirm',0,PARAM_INT)) {
+ if ($contents = get_records('data_content','recordid', $delete)) {
+ foreach ($contents as $content) { // Delete files or whatever else this field allows
+ if ($field = data_get_field_from_id($content->fieldid, $data)) { // Might not be there
+ $field->delete_content($content->recordid);
}
}
- delete_records('data_records','id',$delete);
- delete_records('data_content','recordid',$delete);
-
- add_to_log($course->id, 'data', 'record delete', "view.php?id=$cm->id", $data->id, $cm->id);
-
- notify (get_string('recorddeleted','data'));
}
- }
- else { //prints annoying confirmation dialogue
- $field = get_record('data_records','id',$delete);
- print_simple_box_start('center', '60%');
- echo '';
- print_simple_box_end();
- echo '';
+ delete_records('data_content','recordid',$delete);
+ delete_records('data_records','id',$delete);
+
+ add_to_log($course->id, 'data', 'record delete', "view.php?id=$cm->id", $data->id, $cm->id);
+
+ notify(get_string('recorddeleted','data'));
+
+ } else { // Print a confirmation page
+ notice_yesno(get_string('confirmdeleterecord','data'),
+ 'view.php?d='.$data->id.'&delete='.$delete.'&confirm=1&sesskey='.sesskey(),
+ 'view.php?d='.$data->id);
+
print_footer($course);
exit;
}