[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/book/backup/moodle2/ -> restore_book_stepslib.php (source)

   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   * Define all the restore steps that will be used by the restore_book_activity_task
  19   *
  20   * @package    mod_book
  21   * @copyright  2010 Petr Skoda {@link http://skodak.org}
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die;
  26  
  27  /**
  28   * Structure step to restore one book activity
  29   */
  30  class restore_book_activity_structure_step extends restore_activity_structure_step {
  31  
  32      protected function define_structure() {
  33  
  34          $paths = array();
  35  
  36          $paths[] = new restore_path_element('book', '/activity/book');
  37          $paths[] = new restore_path_element('book_chapter', '/activity/book/chapters/chapter');
  38  
  39          // Return the paths wrapped into standard activity structure
  40          return $this->prepare_activity_structure($paths);
  41      }
  42  
  43      /**
  44       * Process book tag information
  45       * @param array $data information
  46       */
  47      protected function process_book($data) {
  48          global $DB;
  49  
  50          $data = (object)$data;
  51          $oldid = $data->id;
  52          $data->course = $this->get_courseid();
  53  
  54          $newitemid = $DB->insert_record('book', $data);
  55          $this->apply_activity_instance($newitemid);
  56      }
  57  
  58      /**
  59       * Process chapter tag information
  60       * @param array $data information
  61       */
  62      protected function process_book_chapter($data) {
  63          global $DB;
  64  
  65          $data = (object)$data;
  66          $oldid = $data->id;
  67          $data->course = $this->get_courseid();
  68  
  69          $data->bookid = $this->get_new_parentid('book');
  70  
  71          $newitemid = $DB->insert_record('book_chapters', $data);
  72          $this->set_mapping('book_chapter', $oldid, $newitemid, true);
  73      }
  74  
  75      protected function after_execute() {
  76          global $DB;
  77  
  78          // Add book related files
  79          $this->add_related_files('mod_book', 'intro', null);
  80          $this->add_related_files('mod_book', 'chapter', 'book_chapter');
  81      }
  82  }


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