|
Moodle
2.2.1
http://www.collinsharper.com
|
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 00025 require_once($CFG->dirroot.'/backup/util/xml/parser/processors/grouped_parser_processor.class.php'); 00026 00033 class restore_inforef_parser_processor extends grouped_parser_processor { 00034 00035 protected $restoreid; 00036 00037 public function __construct($restoreid) { 00038 $this->restoreid = $restoreid; 00039 parent::__construct(array()); 00040 // Get itemnames handled by inforef files 00041 $items = backup_helper::get_inforef_itemnames(); 00042 // Let's add all them as target paths for the processor 00043 foreach($items as $itemname) { 00044 $pathvalue = '/inforef/' . $itemname . 'ref/' . $itemname; 00045 $this->add_path($pathvalue); 00046 } 00047 } 00048 00049 protected function dispatch_chunk($data) { 00050 // Received one inforef chunck, we are going to store it into backup_ids 00051 // table, with name = itemname + "ref" for later use 00052 $itemname = basename($data['path']). 'ref'; 00053 $itemid = $data['tags']['id']; 00054 restore_dbops::set_backup_ids_record($this->restoreid, $itemname, $itemid); 00055 } 00056 00057 protected function notify_path_start($path) { 00058 // nothing to do 00059 } 00060 00061 protected function notify_path_end($path) { 00062 // nothing to do 00063 } 00064 }