|
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 00035 class restore_roles_parser_processor extends grouped_parser_processor { 00036 00037 protected $restoreid; 00038 00039 public function __construct($restoreid) { 00040 $this->restoreid = $restoreid; 00041 parent::__construct(array()); 00042 // Set the paths we are interested on, returning all them grouped under user 00043 $this->add_path('/roles_definition/role'); 00044 } 00045 00046 protected function dispatch_chunk($data) { 00047 // Received one role chunck, we are going to store it into backup_ids 00048 // table, with name = role 00049 $itemname = 'role'; 00050 $itemid = $data['tags']['id']; 00051 $info = $data['tags']; 00052 // Only load it if needed (exist same roleref itemid in table) 00053 if (restore_dbops::get_backup_ids_record($this->restoreid, 'roleref', $itemid)) { 00054 restore_dbops::set_backup_ids_record($this->restoreid, $itemname, $itemid, 0, null, $info); 00055 } 00056 } 00057 00058 protected function notify_path_start($path) { 00059 // nothing to do 00060 } 00061 00062 protected function notify_path_end($path) { 00063 // nothing to do 00064 } 00065 00069 public function process_cdata($cdata) { 00070 if ($cdata === '$@NULL@$') { 00071 return null; 00072 } 00073 return $cdata; 00074 } 00075 }