|
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 00031 class restore_glossary_random_block_task extends restore_block_task { 00032 00033 protected function define_my_settings() { 00034 } 00035 00036 protected function define_my_steps() { 00037 } 00038 00039 public function get_fileareas() { 00040 return array(); // No associated fileareas 00041 } 00042 00043 public function get_configdata_encoded_attributes() { 00044 return array(); // No special handling of configdata 00045 } 00046 00054 public function after_restore() { 00055 global $DB; 00056 00057 // Get the blockid 00058 $blockid = $this->get_blockid(); 00059 00060 // Extract block configdata and update it to point to the new glossary 00061 if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) { 00062 $config = unserialize(base64_decode($configdata)); 00063 if (!empty($config->glossary)) { 00064 // Get glossary mapping and replace it in config 00065 if ($glossarymap = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'glossary', $config->glossary)) { 00066 $config->glossary = $glossarymap->newitemid; 00067 $configdata = base64_encode(serialize($config)); 00068 $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $blockid)); 00069 } 00070 } 00071 } 00072 } 00073 00074 static public function define_decode_contents() { 00075 return array(); 00076 } 00077 00078 static public function define_decode_rules() { 00079 return array(); 00080 } 00081 }