| 1 | 
           efrain | 
           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 | 
            * restore_edusharing_activity_task
  | 
        
        
            | 
            | 
           19 | 
            *
  | 
        
        
            | 
            | 
           20 | 
            * edusharing restore task that provides all the settings and steps to perform one
  | 
        
        
            | 
            | 
           21 | 
            * complete restore of the activity
  | 
        
        
            | 
            | 
           22 | 
            *
  | 
        
        
            | 
            | 
           23 | 
            * @package    mod_edusharing
  | 
        
        
            | 
            | 
           24 | 
            * @copyright  metaVentis GmbH — http://metaventis.com
  | 
        
        
            | 
            | 
           25 | 
            * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  | 
        
        
            | 
            | 
           26 | 
            */
  | 
        
        
            | 
            | 
           27 | 
              | 
        
        
            | 
            | 
           28 | 
           defined('MOODLE_INTERNAL') || die();
  | 
        
        
            | 
            | 
           29 | 
              | 
        
        
            | 
            | 
           30 | 
           global $CFG;
  | 
        
        
            | 
            | 
           31 | 
              | 
        
        
            | 
            | 
           32 | 
           require_once($CFG->dirroot . '/mod/edusharing/backup/moodle2/restore_edusharing_stepslib.php');
  | 
        
        
            | 
            | 
           33 | 
              | 
        
        
            | 
            | 
           34 | 
           /**
  | 
        
        
            | 
            | 
           35 | 
            * class restore_edusharing_activity_task
  | 
        
        
            | 
            | 
           36 | 
            */
  | 
        
        
            | 
            | 
           37 | 
           class restore_edusharing_activity_task extends restore_activity_task {
  | 
        
        
            | 
            | 
           38 | 
              | 
        
        
            | 
            | 
           39 | 
               /**
  | 
        
        
            | 
            | 
           40 | 
                * Define (add) particular settings this activity can have
  | 
        
        
            | 
            | 
           41 | 
                */
  | 
        
        
            | 
            | 
           42 | 
               protected function define_my_settings() {
  | 
        
        
            | 
            | 
           43 | 
                   // No particular settings for this activity.
  | 
        
        
            | 
            | 
           44 | 
               }
  | 
        
        
            | 
            | 
           45 | 
              | 
        
        
            | 
            | 
           46 | 
               /**
  | 
        
        
            | 
            | 
           47 | 
                * Define (add) particular steps this activity can have
  | 
        
        
            | 
            | 
           48 | 
                */
  | 
        
        
            | 
            | 
           49 | 
               protected function define_my_steps() {
  | 
        
        
            | 
            | 
           50 | 
                   // Edusharing only has one structure step.
  | 
        
        
            | 
            | 
           51 | 
                   $this->add_step(new restore_edusharing_activity_structure_step('edusharing_structure', 'edusharing.xml'));
  | 
        
        
            | 
            | 
           52 | 
               }
  | 
        
        
            | 
            | 
           53 | 
              | 
        
        
            | 
            | 
           54 | 
               /**
  | 
        
        
            | 
            | 
           55 | 
                * Define the contents in the activity that must be
  | 
        
        
            | 
            | 
           56 | 
                * processed by the link decoder
  | 
        
        
            | 
            | 
           57 | 
                */
  | 
        
        
            | 
            | 
           58 | 
               public static function define_decode_contents() {
  | 
        
        
            | 
            | 
           59 | 
                   $contents = [];
  | 
        
        
            | 
            | 
           60 | 
              | 
        
        
            | 
            | 
           61 | 
                   $contents[] = new restore_decode_content('edusharing', ['intro'], 'edusharing');
  | 
        
        
            | 
            | 
           62 | 
              | 
        
        
            | 
            | 
           63 | 
                   return $contents;
  | 
        
        
            | 
            | 
           64 | 
               }
  | 
        
        
            | 
            | 
           65 | 
              | 
        
        
            | 
            | 
           66 | 
               /**
  | 
        
        
            | 
            | 
           67 | 
                * Define the decoding rules for links belonging
  | 
        
        
            | 
            | 
           68 | 
                * to the activity to be executed by the link decoder
  | 
        
        
            | 
            | 
           69 | 
                */
  | 
        
        
            | 
            | 
           70 | 
               public static function define_decode_rules() {
  | 
        
        
            | 
            | 
           71 | 
                   $rules = [];
  | 
        
        
            | 
            | 
           72 | 
              | 
        
        
            | 
            | 
           73 | 
                   $rules[] = new restore_decode_rule('EDUSHARINGVIEWBYID', '/mod/edusharing/view.php?id=$1', 'course_module');
  | 
        
        
            | 
            | 
           74 | 
                   $rules[] = new restore_decode_rule('EDUSHARINGINDEX', '/mod/edusharing/index.php?id=$1', 'course');
  | 
        
        
            | 
            | 
           75 | 
              | 
        
        
            | 
            | 
           76 | 
                   return $rules;
  | 
        
        
            | 
            | 
           77 | 
               }
  | 
        
        
            | 
            | 
           78 | 
              | 
        
        
            | 
            | 
           79 | 
               /**
  | 
        
        
            | 
            | 
           80 | 
                * Function define_restore_log_rules
  | 
        
        
            | 
            | 
           81 | 
                *
  | 
        
        
            | 
            | 
           82 | 
                * Define the restore log rules that will be applied
  | 
        
        
            | 
            | 
           83 | 
                *
  | 
        
        
            | 
            | 
           84 | 
                */
  | 
        
        
            | 
            | 
           85 | 
               public static function define_restore_log_rules() {
  | 
        
        
            | 
            | 
           86 | 
                   $rules = [];
  | 
        
        
            | 
            | 
           87 | 
              | 
        
        
            | 
            | 
           88 | 
                   $rules[] = new restore_log_rule('edusharing', 'add', 'view.php?id={course_module}', '{edusharing}');
  | 
        
        
            | 
            | 
           89 | 
                   $rules[] = new restore_log_rule('edusharing', 'update', 'view.php?id={course_module}', '{edusharing}');
  | 
        
        
            | 
            | 
           90 | 
                   $rules[] = new restore_log_rule('edusharing', 'view', 'view.php?id={course_module}', '{edusharing}');
  | 
        
        
            | 
            | 
           91 | 
                   $rules[] = new restore_log_rule('edusharing', 'choose', 'view.php?id={course_module}', '{edusharing}');
  | 
        
        
            | 
            | 
           92 | 
                   $rules[] = new restore_log_rule('edusharing', 'choose again', 'view.php?id={course_module}', '{edusharing}');
  | 
        
        
            | 
            | 
           93 | 
                   $rules[] = new restore_log_rule('edusharing', 'report', 'report.php?id={course_module}', '{edusharing}');
  | 
        
        
            | 
            | 
           94 | 
              | 
        
        
            | 
            | 
           95 | 
                   return $rules;
  | 
        
        
            | 
            | 
           96 | 
               }
  | 
        
        
            | 
            | 
           97 | 
              | 
        
        
            | 
            | 
           98 | 
               /**
  | 
        
        
            | 
            | 
           99 | 
                * Define the restore log rules that will be applied
  | 
        
        
            | 
            | 
           100 | 
                *
  | 
        
        
            | 
            | 
           101 | 
                * Note this rules are applied when restoring course logs
  | 
        
        
            | 
            | 
           102 | 
                * by the restore final task, but are defined here at
  | 
        
        
            | 
            | 
           103 | 
                * activity level. All them are rules not linked to any module instance (cmid = 0)
  | 
        
        
            | 
            | 
           104 | 
                */
  | 
        
        
            | 
            | 
           105 | 
               public static function define_restore_log_rules_for_course() {
  | 
        
        
            | 
            | 
           106 | 
                   $rules = [];
  | 
        
        
            | 
            | 
           107 | 
              | 
        
        
            | 
            | 
           108 | 
                   // Fix old wrong uses (missing extension).
  | 
        
        
            | 
            | 
           109 | 
                   $rules[] = new restore_log_rule('edusharing', 'view all', 'index?id={course}', null,
  | 
        
        
            | 
            | 
           110 | 
                       null, null, 'index.php?id={course}');
  | 
        
        
            | 
            | 
           111 | 
                   $rules[] = new restore_log_rule('edusharing', 'view all', 'index.php?id={course}', null);
  | 
        
        
            | 
            | 
           112 | 
              | 
        
        
            | 
            | 
           113 | 
                   return $rules;
  | 
        
        
            | 
            | 
           114 | 
               }
  | 
        
        
            | 
            | 
           115 | 
              | 
        
        
            | 
            | 
           116 | 
               /**
  | 
        
        
            | 
            | 
           117 | 
                * Function after_restore
  | 
        
        
            | 
            | 
           118 | 
                *
  | 
        
        
            | 
            | 
           119 | 
                * @return void
  | 
        
        
            | 
            | 
           120 | 
                */
  | 
        
        
            | 
            | 
           121 | 
               public function after_restore() {
  | 
        
        
            | 
            | 
           122 | 
                   // Do something at end of restore.
  | 
        
        
            | 
            | 
           123 | 
               }
  | 
        
        
            | 
            | 
           124 | 
           }
  |