|
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 00032 class backup_glossary_activity_structure_step extends backup_activity_structure_step { 00033 00034 protected function define_structure() { 00035 00036 // To know if we are including userinfo 00037 $userinfo = $this->get_setting_value('userinfo'); 00038 00039 // Define each element separated 00040 $glossary = new backup_nested_element('glossary', array('id'), array( 00041 'name', 'intro', 'introformat', 'allowduplicatedentries', 'displayformat', 00042 'mainglossary', 'showspecial', 'showalphabet', 'showall', 00043 'allowcomments', 'allowprintview', 'usedynalink', 'defaultapproval', 00044 'globalglossary', 'entbypage', 'editalways', 'rsstype', 00045 'rssarticles', 'assessed', 'assesstimestart', 'assesstimefinish', 00046 'scale', 'timecreated', 'timemodified', 'completionentries')); 00047 00048 $entries = new backup_nested_element('entries'); 00049 00050 $entry = new backup_nested_element('entry', array('id'), array( 00051 'userid', 'concept', 'definition', 'definitionformat', 00052 'definitiontrust', 'attachment', 'timecreated', 'timemodified', 00053 'teacherentry', 'sourceglossaryid', 'usedynalink', 'casesensitive', 00054 'fullmatch', 'approved')); 00055 00056 $aliases = new backup_nested_element('aliases'); 00057 00058 $alias = new backup_nested_element('alias', array('id'), array( 00059 'alias_text')); 00060 00061 $ratings = new backup_nested_element('ratings'); 00062 00063 $rating = new backup_nested_element('rating', array('id'), array( 00064 'component', 'ratingarea', 'scaleid', 'value', 'userid', 'timecreated', 'timemodified')); 00065 00066 $categories = new backup_nested_element('categories'); 00067 00068 $category = new backup_nested_element('category', array('id'), array( 00069 'name', 'usedynalink')); 00070 00071 $categoryentries = new backup_nested_element('category_entries'); 00072 00073 $categoryentry = new backup_nested_element('category_entry', array('id'), array( 00074 'entryid')); 00075 00076 // Build the tree 00077 $glossary->add_child($entries); 00078 $entries->add_child($entry); 00079 00080 $entry->add_child($aliases); 00081 $aliases->add_child($alias); 00082 00083 $entry->add_child($ratings); 00084 $ratings->add_child($rating); 00085 00086 $glossary->add_child($categories); 00087 $categories->add_child($category); 00088 00089 $category->add_child($categoryentries); 00090 $categoryentries->add_child($categoryentry); 00091 00092 // Define sources 00093 $glossary->set_source_table('glossary', array('id' => backup::VAR_ACTIVITYID)); 00094 00095 $category->set_source_table('glossary_categories', array('glossaryid' => backup::VAR_PARENTID)); 00096 00097 // All the rest of elements only happen if we are including user info 00098 if ($userinfo) { 00099 $entry->set_source_table('glossary_entries', array('glossaryid' => backup::VAR_PARENTID)); 00100 00101 $alias->set_source_table('glossary_alias', array('entryid' => backup::VAR_PARENTID)); 00102 $alias->set_source_alias('alias', 'alias_text'); 00103 00104 $rating->set_source_table('rating', array('contextid' => backup::VAR_CONTEXTID, 00105 'itemid' => backup::VAR_PARENTID, 00106 'component' => backup_helper::is_sqlparam('mod_glossary'), 00107 'ratingarea' => backup_helper::is_sqlparam('entry'))); 00108 $rating->set_source_alias('rating', 'value'); 00109 00110 $categoryentry->set_source_table('glossary_entries_categories', array('categoryid' => backup::VAR_PARENTID)); 00111 } 00112 00113 // Define id annotations 00114 $glossary->annotate_ids('scale', 'scale'); 00115 00116 $entry->annotate_ids('user', 'userid'); 00117 00118 $rating->annotate_ids('scale', 'scaleid'); 00119 00120 $rating->annotate_ids('user', 'userid'); 00121 00122 // Define file annotations 00123 $glossary->annotate_files('mod_glossary', 'intro', null); // This file area hasn't itemid 00124 00125 $entry->annotate_files('mod_glossary', 'entry', 'id'); 00126 $entry->annotate_files('mod_glossary', 'attachment', 'id'); 00127 00128 // Return the root element (glossary), wrapped into standard activity structure 00129 return $this->prepare_activity_structure($glossary); 00130 } 00131 }