Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/forum/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_forum_handler extends moodle1_mod_handler {
00033 
00035     protected $fileman = null;
00036 
00038     protected $moduleid = null;
00039 
00053     public function get_paths() {
00054         return array(
00055             new convert_path('forum', '/MOODLE_BACKUP/COURSE/MODULES/MOD/FORUM',
00056                 array(
00057                     'renamefields' => array(
00058                         'format' => 'messageformat',
00059                     ),
00060                     'newfields' => array(
00061                         'completiondiscussions' => 0,
00062                         'completionreplies' => 0,
00063                         'completionpost' => 0,
00064                         'maxattachments' => 1,
00065                         'introformat' => 0,
00066                     ),
00067                 )
00068             ),
00069         );
00070     }
00071 
00075     public function process_forum($data) {
00076         // get the course module id and context id
00077         $instanceid     = $data['id'];
00078         $cminfo         = $this->get_cminfo($instanceid);
00079         $this->moduleid = $cminfo['id'];
00080         $contextid      = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
00081 
00082         // get a fresh new file manager for this instance
00083         $this->fileman = $this->converter->get_file_manager($contextid, 'mod_forum');
00084 
00085         // convert course files embedded into the intro
00086         $this->fileman->filearea = 'intro';
00087         $this->fileman->itemid   = 0;
00088         $data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
00089 
00090         // start writing forum.xml
00091         $this->open_xml_writer("activities/forum_{$this->moduleid}/forum.xml");
00092         $this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid,
00093             'modulename' => 'forum', 'contextid' => $contextid));
00094         $this->xmlwriter->begin_tag('forum', array('id' => $instanceid));
00095 
00096         foreach ($data as $field => $value) {
00097             if ($field <> 'id') {
00098                 $this->xmlwriter->full_tag($field, $value);
00099             }
00100         }
00101 
00102         $this->xmlwriter->begin_tag('discussions');
00103 
00104         return $data;
00105     }
00106 
00110     public function on_forum_end() {
00111         // finish writing forum.xml
00112         $this->xmlwriter->end_tag('discussions');
00113         $this->xmlwriter->end_tag('forum');
00114         $this->xmlwriter->end_tag('activity');
00115         $this->close_xml_writer();
00116 
00117         // write inforef.xml
00118         $this->open_xml_writer("activities/forum_{$this->moduleid}/inforef.xml");
00119         $this->xmlwriter->begin_tag('inforef');
00120         $this->xmlwriter->begin_tag('fileref');
00121         foreach ($this->fileman->get_fileids() as $fileid) {
00122             $this->write_xml('file', array('id' => $fileid));
00123         }
00124         $this->xmlwriter->end_tag('fileref');
00125         $this->xmlwriter->end_tag('inforef');
00126         $this->close_xml_writer();
00127     }
00128 }
 All Data Structures Namespaces Files Functions Variables Enumerations