From: moodler Date: Wed, 22 Mar 2006 14:31:32 +0000 (+0000) Subject: Various cleanups X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f0497d6ff06cc077a00c54bf1b2dd91c5abc8793;p=moodle.git Various cleanups --- diff --git a/mod/data/add.php b/mod/data/add.php index 1e863bc839..4118576244 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 '
'; - echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
'.get_string('csvfile', 'data').''; - helpbutton('', get_string('csvimporthelptitle', 'data'), 'data', true, false, - get_string('csvimporthelptext', 'data'), false); - echo '
'.get_string('fielddelimiter', 'data').''; - echo get_string('defaultfielddelimiter', 'data').'
'.get_string('fieldenclosure', 'data').''; - echo get_string('defaultfieldenclosure', 'data').'
'; - echo ''; - echo '
'; - 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 '
'; + echo '
'; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
'.get_string('csvfile', 'data').':'; + helpbutton('importcvs', get_string('csvimport', 'data'), 'data', true, false); + echo '
'.get_string('fielddelimiter', 'data').':'; + echo get_string('defaultfielddelimiter', 'data').'
'.get_string('fieldenclosure', 'data').':'; + echo get_string('defaultfieldenclosure', 'data').'
'; + echo ''; + echo '
'; + echo '
'; + print_simple_box_end(); + } else { + echo '
'; + echo ''.get_string('uploadrecords', 'data').''; + echo '
'; + } } diff --git a/mod/data/lib.php b/mod/data/lib.php index cb504c6557..c7e4dc26c3 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 b994f5a7b1..2aa2eb8a66 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); + } + 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); + 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 '
'; - echo '
'; - //add sesskey - echo get_string('confirmdeleterecord','data'); - echo '

'; - echo ''; - echo ' '; - echo ''; - echo ''; - echo '

'; - echo '
'; - print_simple_box_end(); - echo ''; + 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; }