mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-54965 mod_data: removed unused code in display_add_field()
Since the refactoring towards using the filepicker for file and picture fields there are several variables, which are set but never read. Thus, I removed them.
This commit is contained in:
parent
bdf6753528
commit
3a133b3028
@ -26,13 +26,8 @@ class data_field_file extends data_field_base {
|
||||
var $type = 'file';
|
||||
|
||||
function display_add_field($recordid = 0, $formdata = null) {
|
||||
global $CFG, $DB, $OUTPUT, $PAGE, $USER;
|
||||
global $DB, $OUTPUT, $PAGE;
|
||||
|
||||
$file = false;
|
||||
$content = false;
|
||||
$displayname = '';
|
||||
$fs = get_file_storage();
|
||||
$context = $PAGE->context;
|
||||
$itemid = null;
|
||||
|
||||
// editing an existing database entry
|
||||
@ -50,22 +45,6 @@ class data_field_file extends data_field_base {
|
||||
}
|
||||
file_prepare_draft_area($itemid, $this->context->id, 'mod_data', 'content', $content->id);
|
||||
|
||||
if (!empty($content->content)) {
|
||||
if ($file = $fs->get_file($this->context->id, 'mod_data', 'content', $content->id, '/', $content->content)) {
|
||||
$usercontext = context_user::instance($USER->id);
|
||||
if (!$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $itemid, 'id DESC', false)) {
|
||||
return false;
|
||||
}
|
||||
if (empty($content->content1)) {
|
||||
// Print icon if file already exists
|
||||
$src = moodle_url::make_draftfile_url($itemid, '/', $file->get_filename());
|
||||
$displayname = $OUTPUT->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon')). '<a href="'.$src.'" >'.s($file->get_filename()).'</a>';
|
||||
|
||||
} else {
|
||||
$displayname = 'no file added';
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$itemid = file_get_unused_draft_itemid();
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ class data_field_picture extends data_field_base {
|
||||
|
||||
$file = false;
|
||||
$content = false;
|
||||
$displayname = '';
|
||||
$alttext = '';
|
||||
$itemid = null;
|
||||
$fs = get_file_storage();
|
||||
@ -57,20 +56,10 @@ class data_field_picture extends data_field_base {
|
||||
if (!empty($content->content)) {
|
||||
if ($file = $fs->get_file($this->context->id, 'mod_data', 'content', $content->id, '/', $content->content)) {
|
||||
$usercontext = context_user::instance($USER->id);
|
||||
if (!$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $itemid, 'id DESC', false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($thumbfile = $fs->get_file($usercontext->id, 'user', 'draft', $itemid, '/', 'thumb_'.$content->content)) {
|
||||
$thumbfile->delete();
|
||||
}
|
||||
if (empty($content->content1)) {
|
||||
// Print icon if file already exists
|
||||
$src = moodle_url::make_draftfile_url($itemid, '/', $file->get_filename());
|
||||
$displayname = $OUTPUT->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon')). '<a href="'.$src.'" >'.s($file->get_filename()).'</a>';
|
||||
|
||||
} else {
|
||||
$displayname = get_string('nofilesattached', 'repository');
|
||||
}
|
||||
}
|
||||
}
|
||||
$alttext = $content->content1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user