[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 3 // This file is part of Moodle - http://moodle.org/ 4 // 5 // Moodle is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // Moodle is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 17 18 /** 19 * Defines various element classes used in specific areas 20 * 21 * @package core_backup 22 * @subpackage moodle2 23 * @category backup 24 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} 25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 26 */ 27 28 defined('MOODLE_INTERNAL') || die(); 29 30 /** 31 * Implementation of backup_final_element that provides one interceptor for anonymization of data 32 * 33 * This class overwrites the standard set_value() method, in order to get (by name) 34 * functions from backup_anonymizer_helper executed, producing anonymization of information 35 * to happen in a clean way 36 * 37 * TODO: Finish phpdocs 38 */ 39 class anonymizer_final_element extends backup_final_element { 40 41 public function set_value($value) { 42 // Get parent name 43 $pname = $this->get_parent()->get_name(); 44 // Get my name 45 $myname = $this->get_name(); 46 // Define class and function name 47 $classname = 'backup_anonymizer_helper'; 48 $methodname= 'process_' . $pname . '_' . $myname; 49 // Invoke the interception method 50 $result = call_user_func(array($classname, $methodname), $value); 51 // Finally set it 52 parent::set_value($result); 53 } 54 } 55 56 /** 57 * Implementation of backup_final_element that provides special handling of mnethosturl 58 * 59 * This class overwrites the standard set_value() method, in order to decide, 60 * based on various config options, what to do with the field. 61 * 62 * TODO: Finish phpdocs 63 */ 64 class mnethosturl_final_element extends backup_final_element { 65 66 public function set_value($value) { 67 global $CFG; 68 69 $localhostwwwroot = backup_plan_dbops::get_mnet_localhost_wwwroot(); 70 71 // If user wwwroot matches mnet local host one or if 72 // there isn't associated wwwroot, skip sending it to file 73 if ($localhostwwwroot == $value || empty($value)) { 74 // Do nothing 75 } else { 76 parent::set_value($value); 77 } 78 } 79 } 80 81 /** 82 * Implementation of backup_nested_element that provides special handling of files 83 * 84 * This class overwrites the standard fill_values() method, so it gets intercepted 85 * for each file record being set to xml, in order to copy, at the same file, the 86 * physical file from moodle file storage to backup file storage 87 * 88 * TODO: Finish phpdocs 89 */ 90 class file_nested_element extends backup_nested_element { 91 92 protected $backupid; 93 94 public function process($processor) { 95 // Get current backupid from processor, we'll need later 96 if (is_null($this->backupid)) { 97 $this->backupid = $processor->get_var(backup::VAR_BACKUPID); 98 } 99 return parent::process($processor); 100 } 101 102 public function fill_values($values) { 103 // Fill values 104 parent::fill_values($values); 105 // Do our own tasks (copy file from moodle to backup) 106 try { 107 backup_file_manager::copy_file_moodle2backup($this->backupid, $values); 108 } catch (file_exception $e) { 109 $this->add_result(array('missing_files_in_pool' => true)); 110 111 // Build helpful log message with all information necessary to identify 112 // file location. 113 $context = context::instance_by_id($values->contextid, IGNORE_MISSING); 114 $contextname = ''; 115 if ($context) { 116 $contextname = ' \'' . $context->get_context_name() . '\''; 117 } 118 $message = 'Missing file in pool: ' . $values->filepath . $values->filename . 119 ' (context ' . $values->contextid . $contextname . ', component ' . 120 $values->component . ', filearea ' . $values->filearea . ', itemid ' . 121 $values->itemid . ') [' . $e->debuginfo . ']'; 122 $this->add_log($message, backup::LOG_WARNING); 123 } 124 } 125 } 126 127 /** 128 * Implementation of backup_optigroup_element to be used by plugins stuff. 129 * Split just for better separation and future specialisation 130 */ 131 class backup_plugin_element extends backup_optigroup_element { } 132 133 /** 134 * Implementation of backup_optigroup_element to be used by subplugins stuff. 135 * Split just for better separation and future specialisation 136 */ 137 class backup_subplugin_element extends backup_optigroup_element { }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |