/**
  * Define the common setting that any backup type will have
  */
 protected function define_settings()
 {
     global $CFG;
     require_once $CFG->dirroot . '/backup/util/helper/convert_helper.class.php';
     // Define filename setting
     $filename = new backup_filename_setting('filename', base_setting::IS_FILENAME, 'backup.mbz');
     $filename->set_ui_filename(get_string('filename', 'backup'), 'backup.mbz', array('size' => 50));
     $this->add_setting($filename);
     // Present converter settings only in type course and mode general backup operations.
     $converters = array();
     if ($this->plan->get_type() == backup::TYPE_1COURSE and $this->plan->get_mode() == backup::MODE_GENERAL) {
         $converters = convert_helper::available_converters(false);
         foreach ($converters as $cnv) {
             $formatcnv = new backup_users_setting($cnv, base_setting::IS_BOOLEAN, false);
             $formatcnv->set_ui(new backup_setting_ui_checkbox($formatcnv, get_string('backupformat' . $cnv, 'backup')));
             $this->add_setting($formatcnv);
         }
     }
     // Define users setting (keeping it on hand to define dependencies)
     $users = new backup_users_setting('users', base_setting::IS_BOOLEAN, true);
     $users->set_ui(new backup_setting_ui_checkbox($users, get_string('rootsettingusers', 'backup')));
     $this->add_setting($users);
     $this->converter_deps($users, $converters);
     // Define anonymize (dependent of users)
     $anonymize = new backup_anonymize_setting('anonymize', base_setting::IS_BOOLEAN, false);
     $anonymize->set_ui(new backup_setting_ui_checkbox($anonymize, get_string('rootsettinganonymize', 'backup')));
     $this->add_setting($anonymize);
     $users->add_dependency($anonymize);
     // Define role_assignments (dependent of users)
     $roleassignments = new backup_role_assignments_setting('role_assignments', base_setting::IS_BOOLEAN, true);
     $roleassignments->set_ui(new backup_setting_ui_checkbox($roleassignments, get_string('rootsettingroleassignments', 'backup')));
     $this->add_setting($roleassignments);
     $users->add_dependency($roleassignments);
     // Define activities
     $activities = new backup_activities_setting('activities', base_setting::IS_BOOLEAN, true);
     $activities->set_ui(new backup_setting_ui_checkbox($activities, get_string('rootsettingactivities', 'backup')));
     $this->add_setting($activities);
     // Define blocks
     $blocks = new backup_generic_setting('blocks', base_setting::IS_BOOLEAN, true);
     $blocks->set_ui(new backup_setting_ui_checkbox($blocks, get_string('rootsettingblocks', 'backup')));
     $this->add_setting($blocks);
     $this->converter_deps($blocks, $converters);
     // Define filters
     $filters = new backup_generic_setting('filters', base_setting::IS_BOOLEAN, true);
     $filters->set_ui(new backup_setting_ui_checkbox($filters, get_string('rootsettingfilters', 'backup')));
     $this->add_setting($filters);
     $this->converter_deps($filters, $converters);
     // Define comments (dependent of users)
     $comments = new backup_comments_setting('comments', base_setting::IS_BOOLEAN, true);
     $comments->set_ui(new backup_setting_ui_checkbox($comments, get_string('rootsettingcomments', 'backup')));
     $this->add_setting($comments);
     $users->add_dependency($comments);
     // Define badges (dependent of activities).
     $badges = new backup_badges_setting('badges', base_setting::IS_BOOLEAN, true);
     $badges->set_ui(new backup_setting_ui_checkbox($badges, get_string('rootsettingbadges', 'backup')));
     $this->add_setting($badges);
     $activities->add_dependency($badges);
     $users->add_dependency($badges);
     // Define calendar events.
     $events = new backup_calendarevents_setting('calendarevents', base_setting::IS_BOOLEAN, true);
     $events->set_ui(new backup_setting_ui_checkbox($events, get_string('rootsettingcalendarevents', 'backup')));
     $this->add_setting($events);
     // Define completion (dependent of users)
     $completion = new backup_userscompletion_setting('userscompletion', base_setting::IS_BOOLEAN, true);
     $completion->set_ui(new backup_setting_ui_checkbox($completion, get_string('rootsettinguserscompletion', 'backup')));
     $this->add_setting($completion);
     $users->add_dependency($completion);
     // Define logs (dependent of users)
     $logs = new backup_logs_setting('logs', base_setting::IS_BOOLEAN, true);
     $logs->set_ui(new backup_setting_ui_checkbox($logs, get_string('rootsettinglogs', 'backup')));
     $this->add_setting($logs);
     $users->add_dependency($logs);
     // Define grade_histories (dependent of users)
     $gradehistories = new backup_generic_setting('grade_histories', base_setting::IS_BOOLEAN, true);
     $gradehistories->set_ui(new backup_setting_ui_checkbox($gradehistories, get_string('rootsettinggradehistories', 'backup')));
     $this->add_setting($gradehistories);
     $users->add_dependency($gradehistories);
     // The restore does not process the grade histories when some activities are ignored.
     // So let's define a dependency to prevent false expectations from our users.
     $activities->add_dependency($gradehistories);
     // Define question bank inclusion setting.
     $questionbank = new backup_generic_setting('questionbank', base_setting::IS_BOOLEAN, true);
     $questionbank->set_ui(new backup_setting_ui_checkbox($questionbank, get_string('rootsettingquestionbank', 'backup')));
     $this->add_setting($questionbank);
 }
 /**
  * Define the common setting that any backup type will have
  */
 protected function define_settings()
 {
     global $CFG;
     require_once $CFG->dirroot . '/backup/util/helper/convert_helper.class.php';
     // Define filename setting
     $filename = new backup_filename_setting('filename', base_setting::IS_FILENAME, 'backup.mbz');
     $filename->set_ui(get_string('filename', 'backup'), 'backup.mbz', array('size' => 50));
     $this->add_setting($filename);
     //Sample custom settings
     $converters = convert_helper::available_converters(false);
     foreach ($converters as $cnv) {
         $formatcnv = new backup_users_setting($cnv, base_setting::IS_BOOLEAN, false);
         $formatcnv->set_ui(new backup_setting_ui_checkbox($formatcnv, get_string('backupformat' . $cnv, 'backup')));
         $this->add_setting($formatcnv);
     }
     // Define users setting (keeping it on hand to define dependencies)
     $users = new backup_users_setting('users', base_setting::IS_BOOLEAN, true);
     $users->set_ui(new backup_setting_ui_checkbox($users, get_string('rootsettingusers', 'backup')));
     $this->add_setting($users);
     $this->converter_deps($users, $converters);
     // Define anonymize (dependent of users)
     $anonymize = new backup_anonymize_setting('anonymize', base_setting::IS_BOOLEAN, false);
     $anonymize->set_ui(new backup_setting_ui_checkbox($anonymize, get_string('rootsettinganonymize', 'backup')));
     $this->add_setting($anonymize);
     $users->add_dependency($anonymize);
     // Define role_assignments (dependent of users)
     $roleassignments = new backup_role_assignments_setting('role_assignments', base_setting::IS_BOOLEAN, true);
     $roleassignments->set_ui(new backup_setting_ui_checkbox($roleassignments, get_string('rootsettingroleassignments', 'backup')));
     $this->add_setting($roleassignments);
     $users->add_dependency($roleassignments);
     // Define activities
     $activities = new backup_activities_setting('activities', base_setting::IS_BOOLEAN, true);
     $activities->set_ui(new backup_setting_ui_checkbox($activities, get_string('rootsettingactivities', 'backup')));
     $this->add_setting($activities);
     // Define blocks
     $blocks = new backup_generic_setting('blocks', base_setting::IS_BOOLEAN, true);
     $blocks->set_ui(new backup_setting_ui_checkbox($blocks, get_string('rootsettingblocks', 'backup')));
     $this->add_setting($blocks);
     $this->converter_deps($blocks, $converters);
     // Define filters
     $filters = new backup_generic_setting('filters', base_setting::IS_BOOLEAN, true);
     $filters->set_ui(new backup_setting_ui_checkbox($filters, get_string('rootsettingfilters', 'backup')));
     $this->add_setting($filters);
     $this->converter_deps($filters, $converters);
     // Define comments (dependent of users)
     $comments = new backup_comments_setting('comments', base_setting::IS_BOOLEAN, true);
     $comments->set_ui(new backup_setting_ui_checkbox($comments, get_string('rootsettingcomments', 'backup')));
     $this->add_setting($comments);
     $users->add_dependency($comments);
     // Define calendar events (dependent of users)
     $events = new backup_calendarevents_setting('calendarevents', base_setting::IS_BOOLEAN, true);
     $events->set_ui(new backup_setting_ui_checkbox($events, get_string('rootsettingcalendarevents', 'backup')));
     $this->add_setting($events);
     $users->add_dependency($events);
     // Define completion (dependent of users)
     $completion = new backup_userscompletion_setting('userscompletion', base_setting::IS_BOOLEAN, true);
     $completion->set_ui(new backup_setting_ui_checkbox($completion, get_string('rootsettinguserscompletion', 'backup')));
     $this->add_setting($completion);
     $users->add_dependency($completion);
     // Define logs (dependent of users)
     $logs = new backup_logs_setting('logs', base_setting::IS_BOOLEAN, true);
     $logs->set_ui(new backup_setting_ui_checkbox($logs, get_string('rootsettinglogs', 'backup')));
     $this->add_setting($logs);
     $users->add_dependency($logs);
     // Define grade_histories (dependent of users)
     $gradehistories = new backup_generic_setting('grade_histories', base_setting::IS_BOOLEAN, true);
     $gradehistories->set_ui(new backup_setting_ui_checkbox($gradehistories, get_string('rootsettinggradehistories', 'backup')));
     $this->add_setting($gradehistories);
     $users->add_dependency($gradehistories);
 }