public function define_plugin_structure($connectionpoint)
 {
     global $CFG;
     if (!$connectionpoint instanceof restore_path_element) {
         throw new restore_step_exception('restore_path_element_required', $connectionpoint);
     }
     //check if enabled at site level and plugin is enabled.
     require_once $CFG->libdir . '/plagiarismlib.php';
     $enabledplugins = plagiarism_load_available_plugins();
     if (!array_key_exists($this->pluginname, $enabledplugins)) {
         return array();
     }
     return parent::define_plugin_structure($connectionpoint);
 }
 /**
  * Adds all the course/section/activity/block contents and rules
  */
 public static function register_link_decoders($processor)
 {
     $tasks = array();
     // To get the list of tasks having decoders
     // Add the course task
     $tasks[] = 'restore_course_task';
     // Add the section task
     $tasks[] = 'restore_section_task';
     // Add the module tasks
     $mods = get_plugin_list('mod');
     foreach ($mods as $mod => $moddir) {
         if (class_exists('restore_' . $mod . '_activity_task')) {
             $tasks[] = 'restore_' . $mod . '_activity_task';
         }
     }
     // Add the default block task
     $tasks[] = 'restore_default_block_task';
     // Add the custom block tasks
     $blocks = get_plugin_list('block');
     foreach ($blocks as $block => $blockdir) {
         if (class_exists('restore_' . $block . '_block_task')) {
             $tasks[] = 'restore_' . $block . '_block_task';
         }
     }
     // We have all the tasks registered, let's iterate over them, getting
     // contents and rules and adding them to the processor
     foreach ($tasks as $classname) {
         // Get restore_decode_content array and add to processor
         $contents = call_user_func(array($classname, 'define_decode_contents'));
         if (!is_array($contents)) {
             throw new restore_decode_processor_exception('define_decode_contents_not_array', $classname);
         }
         foreach ($contents as $content) {
             $processor->add_content($content);
         }
         // Get restore_decode_rule array and add to processor
         $rules = call_user_func(array($classname, 'define_decode_rules'));
         if (!is_array($rules)) {
             throw new restore_decode_processor_exception('define_decode_rules_not_array', $classname);
         }
         foreach ($rules as $rule) {
             $processor->add_rule($rule);
         }
     }
     // Now process all the plugins contents (note plugins don't have support for rules)
     // TODO: Add other plugin types (course formats, local...) here if we add them to backup/restore
     $plugins = array('qtype');
     foreach ($plugins as $plugin) {
         $contents = restore_plugin::get_restore_decode_contents($plugin);
         if (!is_array($contents)) {
             throw new restore_decode_processor_exception('get_restore_decode_contents_not_array', $plugin);
         }
         foreach ($contents as $content) {
             $processor->add_content($content);
         }
     }
 }