Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/folder/backup/moodle1/lib.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00027 defined('MOODLE_INTERNAL') || die();
00028 
00032 class moodle1_mod_folder_handler extends moodle1_resource_successor_handler {
00033 
00035     protected $fileman = null;
00036 
00041     public function process_legacy_resource($data) {
00042         // get the course module id and context id
00043         $instanceid     = $data['id'];
00044         $currentcminfo  = $this->get_cminfo($instanceid);
00045         $moduleid       = $currentcminfo['id'];
00046         $contextid      = $this->converter->get_contextid(CONTEXT_MODULE, $moduleid);
00047 
00048         // convert legacy data into the new folder record
00049         $folder                 = array();
00050         $folder['id']           = $data['id'];
00051         $folder['name']         = $data['name'];
00052         $folder['intro']        = $data['intro'];
00053         $folder['introformat']  = $data['introformat'];
00054         $folder['revision']     = 1;
00055         $folder['timemodified'] = $data['timemodified'];
00056 
00057         // get a fresh new file manager for this instance
00058         $this->fileman = $this->converter->get_file_manager($contextid, 'mod_folder');
00059 
00060         // migrate the files embedded into the intro field
00061         $this->fileman->filearea = 'intro';
00062         $this->fileman->itemid   = 0;
00063         $folder['intro'] = moodle1_converter::migrate_referenced_files($folder['intro'], $this->fileman);
00064 
00065         // migrate the folder files
00066         $this->fileman->filearea = 'content';
00067         $this->fileman->itemid   = 0;
00068         $this->fileman->migrate_directory('course_files/'.$data['reference']);
00069 
00070         // write folder.xml
00071         $this->open_xml_writer("activities/folder_{$moduleid}/folder.xml");
00072         $this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $moduleid,
00073             'modulename' => 'folder', 'contextid' => $contextid));
00074         $this->write_xml('folder', $folder, array('/folder/id'));
00075         $this->xmlwriter->end_tag('activity');
00076         $this->close_xml_writer();
00077 
00078         // write inforef.xml
00079         $this->open_xml_writer("activities/folder_{$moduleid}/inforef.xml");
00080         $this->xmlwriter->begin_tag('inforef');
00081         $this->xmlwriter->begin_tag('fileref');
00082         foreach ($this->fileman->get_fileids() as $fileid) {
00083             $this->write_xml('file', array('id' => $fileid));
00084         }
00085         $this->xmlwriter->end_tag('fileref');
00086         $this->xmlwriter->end_tag('inforef');
00087         $this->close_xml_writer();
00088     }
00089 }
 All Data Structures Namespaces Files Functions Variables Enumerations