Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/data/backup/moodle2/backup_data_stepslib.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 
00032 class backup_data_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         $data = new backup_nested_element('data', array('id'), array(
00041             'name', 'intro', 'introformat', 'comments',
00042             'timeavailablefrom', 'timeavailableto', 'timeviewfrom', 'timeviewto',
00043             'requiredentries', 'requiredentriestoview', 'maxentries', 'rssarticles',
00044             'singletemplate', 'listtemplate', 'listtemplateheader', 'listtemplatefooter',
00045             'addtemplate', 'rsstemplate', 'rsstitletemplate', 'csstemplate',
00046             'jstemplate', 'asearchtemplate', 'approval', 'scale',
00047             'assessed', 'assesstimestart', 'assesstimefinish', 'defaultsort',
00048             'defaultsortdir', 'editany', 'notification'));
00049 
00050         $fields = new backup_nested_element('fields');
00051 
00052         $field = new backup_nested_element('field', array('id'), array(
00053             'type', 'name', 'description', 'param1', 'param2',
00054             'param3', 'param4', 'param5', 'param6',
00055             'param7', 'param8', 'param9', 'param10'));
00056 
00057         $records = new backup_nested_element('records');
00058 
00059         $record = new backup_nested_element('record', array('id'), array(
00060             'userid', 'groupid', 'timecreated', 'timemodified',
00061             'approved'));
00062 
00063         $contents = new backup_nested_element('contents');
00064 
00065         $content = new backup_nested_element('content', array('id'), array(
00066             'fieldid', 'content', 'content1', 'content2',
00067             'content3', 'content4'));
00068 
00069         $ratings = new backup_nested_element('ratings');
00070 
00071         $rating = new backup_nested_element('rating', array('id'), array(
00072             'component', 'ratingarea', 'scaleid', 'value', 'userid', 'timecreated', 'timemodified'));
00073 
00074         // Build the tree
00075         $data->add_child($fields);
00076         $fields->add_child($field);
00077 
00078         $data->add_child($records);
00079         $records->add_child($record);
00080 
00081         $record->add_child($contents);
00082         $contents->add_child($content);
00083 
00084         $record->add_child($ratings);
00085         $ratings->add_child($rating);
00086 
00087         // Define sources
00088         $data->set_source_table('data', array('id' => backup::VAR_ACTIVITYID));
00089 
00090         $field->set_source_sql('
00091             SELECT *
00092               FROM {data_fields}
00093              WHERE dataid = ?',
00094             array(backup::VAR_PARENTID));
00095 
00096         // All the rest of elements only happen if we are including user info
00097         if ($userinfo) {
00098             $record->set_source_table('data_records', array('dataid' => backup::VAR_PARENTID));
00099 
00100             $content->set_source_table('data_content', array('recordid' => backup::VAR_PARENTID));
00101 
00102             $rating->set_source_table('rating', array('contextid'  => backup::VAR_CONTEXTID,
00103                                                       'itemid'     => backup::VAR_PARENTID,
00104                                                       'component'  => backup_helper::is_sqlparam('mod_data'),
00105                                                       'ratingarea' => backup_helper::is_sqlparam('entry')));
00106             $rating->set_source_alias('rating', 'value');
00107         }
00108 
00109         // Define id annotations
00110         $data->annotate_ids('scale', 'scale');
00111 
00112         $record->annotate_ids('user', 'userid');
00113         $record->annotate_ids('group', 'groupid');
00114 
00115         $rating->annotate_ids('scale', 'scaleid');
00116         $rating->annotate_ids('user', 'userid');
00117 
00118         // Define file annotations
00119         $data->annotate_files('mod_data', 'intro', null); // This file area hasn't itemid
00120         $content->annotate_files('mod_data', 'content', 'id'); // By content->id
00121 
00122         // Return the root element (data), wrapped into standard activity structure
00123         return $this->prepare_activity_structure($data);
00124     }
00125 }
 All Data Structures Namespaces Files Functions Variables Enumerations