[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * @package mod_feedback 19 * @subpackage backup-moodle2 20 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} 21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 22 */ 23 24 /** 25 * Define all the restore steps that will be used by the restore_feedback_activity_task 26 */ 27 28 /** 29 * Structure step to restore one feedback activity 30 */ 31 class restore_feedback_activity_structure_step extends restore_activity_structure_step { 32 33 protected function define_structure() { 34 35 $paths = array(); 36 $userinfo = $this->get_setting_value('userinfo'); 37 38 $paths[] = new restore_path_element('feedback', '/activity/feedback'); 39 $paths[] = new restore_path_element('feedback_item', '/activity/feedback/items/item'); 40 if ($userinfo) { 41 $paths[] = new restore_path_element('feedback_completed', '/activity/feedback/completeds/completed'); 42 $paths[] = new restore_path_element('feedback_value', '/activity/feedback/completeds/completed/values/value'); 43 } 44 45 // Return the paths wrapped into standard activity structure 46 return $this->prepare_activity_structure($paths); 47 } 48 49 protected function process_feedback($data) { 50 global $DB; 51 52 $data = (object)$data; 53 $oldid = $data->id; 54 $data->course = $this->get_courseid(); 55 56 $data->timeopen = $this->apply_date_offset($data->timeopen); 57 $data->timeclose = $this->apply_date_offset($data->timeclose); 58 $data->timemodified = $this->apply_date_offset($data->timemodified); 59 60 // insert the feedback record 61 $newitemid = $DB->insert_record('feedback', $data); 62 // immediately after inserting "activity" record, call this 63 $this->apply_activity_instance($newitemid); 64 } 65 66 protected function process_feedback_item($data) { 67 global $DB; 68 69 $data = (object)$data; 70 $oldid = $data->id; 71 $data->feedback = $this->get_new_parentid('feedback'); 72 73 //dependitem 74 $data->dependitem = $this->get_mappingid('feedback_item', $data->dependitem); 75 76 $newitemid = $DB->insert_record('feedback_item', $data); 77 $this->set_mapping('feedback_item', $oldid, $newitemid, true); // Can have files 78 } 79 80 protected function process_feedback_completed($data) { 81 global $DB; 82 83 $data = (object)$data; 84 $oldid = $data->id; 85 $data->feedback = $this->get_new_parentid('feedback'); 86 $data->userid = $this->get_mappingid('user', $data->userid); 87 $data->timemodified = $this->apply_date_offset($data->timemodified); 88 if ($this->task->is_samesite() && !empty($data->courseid)) { 89 $data->courseid = $data->courseid; 90 } else if ($this->get_courseid() == SITEID) { 91 $data->courseid = SITEID; 92 } else { 93 $data->courseid = 0; 94 } 95 96 $newitemid = $DB->insert_record('feedback_completed', $data); 97 $this->set_mapping('feedback_completed', $oldid, $newitemid); 98 } 99 100 protected function process_feedback_value($data) { 101 global $DB; 102 103 $data = (object)$data; 104 $oldid = $data->id; 105 $data->completed = $this->get_new_parentid('feedback_completed'); 106 $data->item = $this->get_mappingid('feedback_item', $data->item); 107 if ($this->task->is_samesite() && !empty($data->course_id)) { 108 $data->course_id = $data->course_id; 109 } else if ($this->get_courseid() == SITEID) { 110 $data->course_id = SITEID; 111 } else { 112 $data->course_id = 0; 113 } 114 115 $newitemid = $DB->insert_record('feedback_value', $data); 116 $this->set_mapping('feedback_value', $oldid, $newitemid); 117 } 118 119 protected function after_execute() { 120 // Add feedback related files, no need to match by itemname (just internally handled context) 121 $this->add_related_files('mod_feedback', 'intro', null); 122 $this->add_related_files('mod_feedback', 'page_after_submit', null); 123 $this->add_related_files('mod_feedback', 'item', 'feedback_item'); 124 } 125 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |