[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/glossary/backup/moodle2/ -> backup_glossary_stepslib.php (source)

   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   * @package mod_glossary
  20   * @subpackage backup-moodle2
  21   * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  /**
  26   * Define all the backup steps that will be used by the backup_glossary_activity_task
  27   */
  28  
  29  /**
  30   * Define the complete glossary structure for backup, with file and id annotations
  31   */
  32  class backup_glossary_activity_structure_step extends backup_activity_structure_step {
  33  
  34      protected function define_structure() {
  35  
  36          // To know if we are including userinfo
  37          $userinfo = $this->get_setting_value('userinfo');
  38  
  39          // Define each element separated
  40          $glossary = new backup_nested_element('glossary', array('id'), array(
  41              'name', 'intro', 'introformat', 'allowduplicatedentries', 'displayformat',
  42              'mainglossary', 'showspecial', 'showalphabet', 'showall',
  43              'allowcomments', 'allowprintview', 'usedynalink', 'defaultapproval',
  44              'globalglossary', 'entbypage', 'editalways', 'rsstype',
  45              'rssarticles', 'assessed', 'assesstimestart', 'assesstimefinish',
  46              'scale', 'timecreated', 'timemodified', 'completionentries'));
  47  
  48          $entries = new backup_nested_element('entries');
  49  
  50          $entry = new backup_nested_element('entry', array('id'), array(
  51              'userid', 'concept', 'definition', 'definitionformat',
  52              'definitiontrust', 'attachment', 'timecreated', 'timemodified',
  53              'teacherentry', 'sourceglossaryid', 'usedynalink', 'casesensitive',
  54              'fullmatch', 'approved'));
  55  
  56          $aliases = new backup_nested_element('aliases');
  57  
  58          $alias = new backup_nested_element('alias', array('id'), array(
  59              'alias_text'));
  60  
  61          $ratings = new backup_nested_element('ratings');
  62  
  63          $rating = new backup_nested_element('rating', array('id'), array(
  64              'component', 'ratingarea', 'scaleid', 'value', 'userid', 'timecreated', 'timemodified'));
  65  
  66          $categories = new backup_nested_element('categories');
  67  
  68          $category = new backup_nested_element('category', array('id'), array(
  69              'name', 'usedynalink'));
  70  
  71          $categoryentries = new backup_nested_element('category_entries');
  72  
  73          $categoryentry = new backup_nested_element('category_entry', array('id'), array(
  74              'entryid'));
  75  
  76          // Build the tree
  77          $glossary->add_child($entries);
  78          $entries->add_child($entry);
  79  
  80          $entry->add_child($aliases);
  81          $aliases->add_child($alias);
  82  
  83          $entry->add_child($ratings);
  84          $ratings->add_child($rating);
  85  
  86          $glossary->add_child($categories);
  87          $categories->add_child($category);
  88  
  89          $category->add_child($categoryentries);
  90          $categoryentries->add_child($categoryentry);
  91  
  92          // Define sources
  93          $glossary->set_source_table('glossary', array('id' => backup::VAR_ACTIVITYID));
  94  
  95          $category->set_source_table('glossary_categories', array('glossaryid' => backup::VAR_PARENTID));
  96  
  97          // All the rest of elements only happen if we are including user info
  98          if ($userinfo) {
  99              $entry->set_source_table('glossary_entries', array('glossaryid' => backup::VAR_PARENTID));
 100  
 101              $alias->set_source_table('glossary_alias', array('entryid' => backup::VAR_PARENTID));
 102              $alias->set_source_alias('alias', 'alias_text');
 103  
 104              $rating->set_source_table('rating', array('contextid'  => backup::VAR_CONTEXTID,
 105                                                        'itemid'     => backup::VAR_PARENTID,
 106                                                        'component'  => backup_helper::is_sqlparam('mod_glossary'),
 107                                                        'ratingarea' => backup_helper::is_sqlparam('entry')));
 108              $rating->set_source_alias('rating', 'value');
 109  
 110              $categoryentry->set_source_table('glossary_entries_categories', array('categoryid' => backup::VAR_PARENTID));
 111          }
 112  
 113          // Define id annotations
 114          $glossary->annotate_ids('scale', 'scale');
 115  
 116          $entry->annotate_ids('user', 'userid');
 117  
 118          $rating->annotate_ids('scale', 'scaleid');
 119  
 120          $rating->annotate_ids('user', 'userid');
 121  
 122          // Define file annotations
 123          $glossary->annotate_files('mod_glossary', 'intro', null); // This file area hasn't itemid
 124  
 125          $entry->annotate_files('mod_glossary', 'entry', 'id');
 126          $entry->annotate_files('mod_glossary', 'attachment', 'id');
 127  
 128          // Return the root element (glossary), wrapped into standard activity structure
 129          return $this->prepare_activity_structure($glossary);
 130      }
 131  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1