mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Various cleanups
This commit is contained in:
parent
6c74c1da70
commit
f0497d6ff0
3 changed files with 55 additions and 65 deletions
|
@ -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,7 +256,7 @@
|
|||
/// Upload records section. Only for teachers and the admin.
|
||||
|
||||
if (isteacher($course->id)) {
|
||||
echo "\n\n";
|
||||
if ($import) {
|
||||
print_simple_box_start('center','80%');
|
||||
print_heading(get_string('uploadrecords', 'data'), '', 3);
|
||||
|
||||
|
@ -267,16 +268,15 @@
|
|||
echo '<input name="sesskey" value="'.sesskey().'" type="hidden" />';
|
||||
echo '<table align="center" cellspacing="0" cellpadding="2" border="0">';
|
||||
echo '<tr>';
|
||||
echo '<td align="right">'.get_string('csvfile', 'data').'</td>';
|
||||
echo '<td align="right">'.get_string('csvfile', 'data').':</td>';
|
||||
echo '<td><input type="file" name="recordsfile" size="30">';
|
||||
helpbutton('', get_string('csvimporthelptitle', 'data'), 'data', true, false,
|
||||
get_string('csvimporthelptext', 'data'), false);
|
||||
helpbutton('importcvs', get_string('csvimport', 'data'), 'data', true, false);
|
||||
echo '</td><tr>';
|
||||
echo '<td align="right">'.get_string('fielddelimiter', 'data').'</td>';
|
||||
echo '<td align="right">'.get_string('fielddelimiter', 'data').':</td>';
|
||||
echo '<td><input type="text" name="fielddelimiter" size="6">';
|
||||
echo get_string('defaultfielddelimiter', 'data').'</td>';
|
||||
echo '</tr>';
|
||||
echo '<td align="right">'.get_string('fieldenclosure', 'data').'</td>';
|
||||
echo '<td align="right">'.get_string('fieldenclosure', 'data').':</td>';
|
||||
echo '<td><input type="text" name="fieldenclosure" size="6">';
|
||||
echo get_string('defaultfieldenclosure', 'data').'</td>';
|
||||
echo '</tr>';
|
||||
|
@ -285,6 +285,11 @@
|
|||
echo '</form>';
|
||||
echo '</div>';
|
||||
print_simple_box_end();
|
||||
} else {
|
||||
echo '<div align="center">';
|
||||
echo '<a href="add.php?d='.$data->id.'&import=1">'.get_string('uploadrecords', 'data').'</a>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -168,41 +168,25 @@
|
|||
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);
|
||||
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_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 { //prints annoying confirmation dialogue
|
||||
$field = get_record('data_records','id',$delete);
|
||||
print_simple_box_start('center', '60%');
|
||||
echo '<div align="center">';
|
||||
echo '<form action = "view.php?d='.$data->id.'&delete='.$delete.'" method="post">';
|
||||
//add sesskey
|
||||
echo get_string('confirmdeleterecord','data');
|
||||
echo '<p />';
|
||||
echo '<input type="hidden" value="'.sesskey().'" name="sesskey">';
|
||||
echo '<input type="submit" value="'.get_string('ok').'"> ';
|
||||
echo '<input type="hidden" name="confirm" value="1">';
|
||||
echo '<input type="button" value="'.get_string('cancel').'" onclick="javascript:history.go(-1);" />';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
print_simple_box_end();
|
||||
echo '</td></tr></table>';
|
||||
|
||||
} 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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue