Commit 3084cac8 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Change the name of a user's assessmentfiles folder when they change language pref

parent f1bc95b6
......@@ -841,6 +841,24 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
'_default' => $wwwroot . 'artefact/file/?folder=' . $id,
);
}
public static function change_language($userid, $oldlang, $newlang) {
$oldname = get_string_from_language($oldlang, 'feedbackattachdirname', 'view');
$artefact = ArtefactTypeFolder::get_folder_by_name($oldname, null, $userid);
if (empty($artefact)) {
return;
}
$name = get_string_from_language($newlang, 'feedbackattachdirname', 'view');
$description = get_string_from_language($newlang, 'feedbackattachdirdesc', 'view');
if (!empty($name)) {
$artefact = artefact_instance_from_id($artefact->id);
$artefact->set('title', $name);
$artefact->set('description', $description);
$artefact->commit();
}
}
}
class ArtefactTypeImage extends ArtefactTypeFile {
......
......@@ -115,8 +115,8 @@ function set_account_preference($userid, $field, $value) {
/**
* Change language-specific stuff in the db for a user. Currently
* just changes the name of the 'blogfiles' folder in the user's files
* area.
* just changes the name of the 'blogfiles' and 'assessmentfiles'
* folders in the user's files area.
*
* @param int $userid user id to set preference for
* @param string $oldlang old language
......@@ -127,6 +127,10 @@ function change_language($userid, $oldlang, $newlang) {
safe_require('artefact', 'blog');
ArtefactTypeBlogPost::change_language($userid, $oldlang, $newlang);
}
if (get_field('artefact_installed', 'active', 'name', 'file')) {
safe_require('artefact', 'file');
ArtefactTypeFolder::change_language($userid, $oldlang, $newlang);
}
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment