MDL-46768 core_badges: changed badge name type from FILE to TEXT
This commit is contained in:
@@ -48,8 +48,8 @@ class edit_details_form extends moodleform {
|
||||
|
||||
$mform->addElement('header', 'badgedetails', get_string('badgedetails', 'badges'));
|
||||
$mform->addElement('text', 'name', get_string('name'), array('size' => '70'));
|
||||
// Using PARAM_FILE to avoid problems later when downloading badge files.
|
||||
$mform->setType('name', PARAM_FILE);
|
||||
// When downloading badge, it will be necessary to clean the name as PARAM_FILE.
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
$mform->addRule('name', null, 'required');
|
||||
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ if ($hide) {
|
||||
require_sesskey();
|
||||
$badge = new badge($download);
|
||||
$name = str_replace(' ', '_', $badge->name) . '.png';
|
||||
$name = clean_param($name, PARAM_FILE);
|
||||
$filehash = badges_bake($hash, $download, $USER->id, true);
|
||||
$fs = get_file_storage();
|
||||
$file = $fs->get_file_by_hash($filehash);
|
||||
|
||||
@@ -1161,6 +1161,7 @@ function badges_download($userid) {
|
||||
// Need to make image name user-readable and unique using filename safe characters.
|
||||
$name = $badge->name . ' ' . userdate($issued->dateissued, '%d %b %Y') . ' ' . hash('crc32', $badge->id);
|
||||
$name = str_replace(' ', '_', $name);
|
||||
$name = clean_param($name, PARAM_FILE);
|
||||
if ($file = $fs->get_file($context->id, 'badges', 'userbadge', $issued->badgeid, '/', $issued->uniquehash . '.png')) {
|
||||
$filelist[$name . '.png'] = $file;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user