Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/backup/util/helper/restore_users_parser_processor.class.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 
00025 require_once($CFG->dirroot.'/backup/util/xml/parser/processors/grouped_parser_processor.class.php');
00026 
00039 class restore_users_parser_processor extends grouped_parser_processor {
00040 
00041     protected $restoreid;
00042 
00043     public function __construct($restoreid) {
00044         $this->restoreid = $restoreid;
00045         parent::__construct(array());
00046         // Set the paths we are interested on, returning all them grouped under user
00047         $this->add_path('/users/user', true);
00048         $this->add_path('/users/user/custom_fields/custom_field');
00049         $this->add_path('/users/user/tags/tag');
00050         $this->add_path('/users/user/preferences/preference');
00051         // As noted above, we skip user context ras and caps
00052         // $this->add_path('/users/user/roles/role_overrides/override');
00053         // $this->add_path('/users/user/roles/role_assignments/assignment');
00054     }
00055 
00056     protected function dispatch_chunk($data) {
00057         // Received one user chunck, we are going to store it into backup_ids
00058         // table, with name = user and parentid = contextid for later use
00059         $itemname = 'user';
00060         $itemid   = $data['tags']['id'];
00061         $parentitemid = $data['tags']['contextid'];
00062         $info = $data['tags'];
00063         // Only load it if needed (exist same userref itemid in table)
00064         if (restore_dbops::get_backup_ids_record($this->restoreid, 'userref', $itemid)) {
00065             restore_dbops::set_backup_ids_record($this->restoreid, $itemname, $itemid, 0, $parentitemid, $info);
00066         }
00067     }
00068 
00069     protected function notify_path_start($path) {
00070         // nothing to do
00071     }
00072 
00073     protected function notify_path_end($path) {
00074         // nothing to do
00075     }
00076 
00080     public function process_cdata($cdata) {
00081         if ($cdata === '$@NULL@$') {
00082             return null;
00083         }
00084         return $cdata;
00085     }
00086 }
 All Data Structures Namespaces Files Functions Variables Enumerations