Merge branch 'MDL-28221-resource-conversion' of git://github.com/mudrd8mz/moodle

This commit is contained in:
Eloy Lafuente (stronk7)
2011-07-12 16:57:54 +02:00
4 changed files with 23 additions and 9 deletions
+12 -2
View File
@@ -185,13 +185,17 @@ class moodle1_mod_resource_handler extends moodle1_mod_handler {
$resource['intro'] = moodle1_converter::migrate_referenced_files($resource['intro'], $this->fileman);
// convert the referenced file itself as a main file in the content area
$reference = $data['reference'];
if (strpos($reference, '$@FILEPHP@$') === 0) {
$reference = str_replace(array('$@FILEPHP@$', '$@SLASH@$', '$@FORCEDOWNLOAD@$'), array('', '/', ''), $reference);
}
$this->fileman->filearea = 'content';
$this->fileman->itemid = 0;
try {
$this->fileman->migrate_file('course_files/'.$data['reference'], '/', null, 1);
$this->fileman->migrate_file('course_files/'.$reference, '/', null, 1);
} catch (moodle1_convert_exception $e) {
// the file probably does not exist
$this->log('error migrating the resource main file', backup::LOG_WARNING, 'course_files/'.$data['reference']);
$this->log('error migrating the resource main file', backup::LOG_WARNING, 'course_files/'.$reference);
}
// write resource.xml
@@ -247,6 +251,12 @@ class moodle1_mod_resource_handler extends moodle1_mod_handler {
$name = 'imscp';
break;
case 'file':
// if starts with $@FILEPHP@$ then it is URL link to a local course file
// to be migrated to the new resource module
if (strpos($reference, '$@FILEPHP@$') === 0) {
$name = null;
break;
}
// if http:// https:// ftp:// OR starts with slash need to be converted to URL
if (strpos($reference, '://') or strpos($reference, '/') === 0) {
$name = 'url';
+1 -1
View File
@@ -82,7 +82,7 @@ function resource_get_post_actions() {
* Add resource instance.
* @param object $data
* @param object $mform
* @return int new resoruce instance id
* @return int new resource instance id
*/
function resource_add_instance($data, $mform) {
global $CFG, $DB;
+8 -4
View File
@@ -322,11 +322,11 @@ function resource_print_intro($resource, $cm, $course, $ignoresettings=false) {
function resource_print_tobemigrated($resource, $cm, $course) {
global $DB, $OUTPUT;
$resoruce_old = $DB->get_record('resource_old', array('oldid'=>$resource->id));
$resource_old = $DB->get_record('resource_old', array('oldid'=>$resource->id));
resource_print_header($resource, $cm, $course);
resource_print_heading($resource, $cm, $course);
resource_print_intro($resource, $cm, $course);
echo $OUTPUT->notification(get_string('notmigrated', 'resource', $resoruce_old->type));
echo $OUTPUT->notification(get_string('notmigrated', 'resource', $resource_old->type));
echo $OUTPUT->footer();
die;
}
@@ -341,11 +341,15 @@ function resource_print_tobemigrated($resource, $cm, $course) {
function resource_print_filenotfound($resource, $cm, $course) {
global $DB, $OUTPUT;
$resoruce_old = $DB->get_record('resource_old', array('oldid'=>$resource->id));
$resource_old = $DB->get_record('resource_old', array('oldid'=>$resource->id));
resource_print_header($resource, $cm, $course);
resource_print_heading($resource, $cm, $course);
resource_print_intro($resource, $cm, $course);
echo $OUTPUT->notification(get_string('notmigrated', 'resource', $resoruce_old->type));
if ($resource_old) {
echo $OUTPUT->notification(get_string('notmigrated', 'resource', $resource_old->type));
} else {
echo $OUTPUT->notification(get_string('filenotfound', 'resource'));
}
echo $OUTPUT->footer();
die;
}
+2 -2
View File
@@ -39,8 +39,8 @@ class mod_resource_mod_form extends moodleform_mod {
if ($this->current->instance and $this->current->tobemigrated) {
// resource not migrated yet
$resoruce_old = $DB->get_record('resource_old', array('oldid'=>$this->current->instance));
$mform->addElement('static', 'warning', '', get_string('notmigrated', 'resource', $resoruce_old->type));
$resource_old = $DB->get_record('resource_old', array('oldid'=>$this->current->instance));
$mform->addElement('static', 'warning', '', get_string('notmigrated', 'resource', $resource_old->type));
$mform->addElement('cancel');
$this->standard_hidden_coursemodule_elements();
return;