Permalink
Browse files

Merge branch 'MDL-28221-resource-conversion_21_STABLE' of git://githu…

…b.com/mudrd8mz/moodle into MOODLE_21_STABLE
  • Loading branch information...
2 parents 6f09ed8 + 665120d commit fe97a3dc7acb328d0dc7cafa62b39159b966117a @stronk7 stronk7 committed Jul 12, 2011
Showing with 23 additions and 9 deletions.
  1. +12 −2 mod/resource/backup/moodle1/lib.php
  2. +1 −1 mod/resource/lib.php
  3. +8 −4 mod/resource/locallib.php
  4. +2 −2 mod/resource/mod_form.php
@@ -185,13 +185,17 @@ public function process_resource(array $data, array $raw) {
$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 @@ protected function get_successor($type, $reference) {
$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';
View
@@ -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;
View
@@ -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;
}
@@ -39,8 +39,8 @@ function definition() {
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;

0 comments on commit fe97a3d

Please sign in to comment.