Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/chat/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 
00028 defined('MOODLE_INTERNAL') || die();
00029 
00033 class moodle1_mod_chat_handler extends moodle1_mod_handler {
00034 
00036     protected $fileman = null;
00037 
00039     protected $moduleid = null;
00040 
00054     public function get_paths() {
00055         return array(
00056             new convert_path(
00057                 'chat', '/MOODLE_BACKUP/COURSE/MODULES/MOD/CHAT',
00058                 array(
00059                     'newfields' => array(
00060                         'introformat' => 0
00061                     )
00062                 )
00063             )
00064         );
00065     }
00066 
00071     public function process_chat($data) {
00072         global $CFG;
00073 
00074         // get the course module id and context id
00075         $instanceid     = $data['id'];
00076         $cminfo         = $this->get_cminfo($instanceid);
00077         $this->moduleid = $cminfo['id'];
00078         $contextid      = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
00079 
00080         // replay the upgrade step 2010050101
00081         if ($CFG->texteditors !== 'textarea') {
00082             $data['intro']       = text_to_html($data['intro'], false, false, true);
00083             $data['introformat'] = FORMAT_HTML;
00084         }
00085 
00086         // get a fresh new file manager for this instance
00087         $this->fileman = $this->converter->get_file_manager($contextid, 'mod_chat');
00088 
00089         // convert course files embedded into the intro
00090         $this->fileman->filearea = 'intro';
00091         $this->fileman->itemid   = 0;
00092         $data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
00093 
00094         // start writing chat.xml
00095         $this->open_xml_writer("activities/chat_{$this->moduleid}/chat.xml");
00096         $this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid,
00097             'modulename' => 'chat', 'contextid' => $contextid));
00098         $this->xmlwriter->begin_tag('chat', array('id' => $instanceid));
00099 
00100         foreach ($data as $field => $value) {
00101             if ($field <> 'id') {
00102                 $this->xmlwriter->full_tag($field, $value);
00103             }
00104         }
00105 
00106         $this->xmlwriter->begin_tag('messages');
00107 
00108         return $data;
00109     }
00110 
00115     public function process_chat_message($data) {
00116         //@todo process user data
00117         //$this->write_xml('message', $data, array('/message/id'));
00118     }
00119 
00123     public function on_chat_end() {
00124         // close chat.xml
00125         $this->xmlwriter->end_tag('messages');
00126         $this->xmlwriter->end_tag('chat');
00127         $this->xmlwriter->end_tag('activity');
00128         $this->close_xml_writer();
00129 
00130         // write inforef.xml
00131         $this->open_xml_writer("activities/chat_{$this->moduleid}/inforef.xml");
00132         $this->xmlwriter->begin_tag('inforef');
00133         $this->xmlwriter->begin_tag('fileref');
00134         foreach ($this->fileman->get_fileids() as $fileid) {
00135             $this->write_xml('file', array('id' => $fileid));
00136         }
00137         $this->xmlwriter->end_tag('fileref');
00138         $this->xmlwriter->end_tag('inforef');
00139         $this->close_xml_writer();
00140     }
00141 }
 All Data Structures Namespaces Files Functions Variables Enumerations