/**
  * Define the common setting that any restore section will have
  */
 protected function define_settings()
 {
     // All the settings related to this activity will include this prefix
     $settingprefix = 'section_' . $this->info->sectionid . '_';
     // All these are common settings to be shared by all sections
     // Define section_included (to decide if the whole task must be really executed)
     $settingname = $settingprefix . 'included';
     $section_included = new restore_section_included_setting($settingname, base_setting::IS_BOOLEAN, true);
     if (is_number($this->info->title)) {
         $label = get_string('includesection', 'backup', $this->info->title);
     } else {
         $label = $this->info->title;
     }
     $section_included->get_ui()->set_label($label);
     $this->add_setting($section_included);
     // Define section_userinfo. Dependent of:
     // - users root setting
     // - section_included setting
     $settingname = $settingprefix . 'userinfo';
     $selectvalues = array(0 => get_string('no'));
     // Safer options
     $defaultvalue = false;
     // Safer default
     if (isset($this->info->settings[$settingname]) && $this->info->settings[$settingname]) {
         // Only enabled when available
         $selectvalues = array(1 => get_string('yes'), 0 => get_string('no'));
         $defaultvalue = true;
     }
     $section_userinfo = new restore_section_userinfo_setting($settingname, base_setting::IS_BOOLEAN, $defaultvalue);
     $section_userinfo->set_ui(new backup_setting_ui_select($section_userinfo, get_string('includeuserinfo', 'backup'), $selectvalues));
     $this->add_setting($section_userinfo);
     // Look for "users" root setting
     $users = $this->plan->get_setting('users');
     $users->add_dependency($section_userinfo);
     // Look for "section_included" section setting
     $section_included->add_dependency($section_userinfo);
 }
 /**
  * Define the common setting that any restore section will have
  */
 protected function define_settings()
 {
     // All the settings related to this activity will include this prefix
     $settingprefix = 'section_' . $this->info->sectionid . '_';
     // All these are common settings to be shared by all sections
     // Define section_included (to decide if the whole task must be really executed)
     $settingname = $settingprefix . 'included';
     $section_included = new restore_section_included_setting($settingname, base_setting::IS_BOOLEAN, true);
     if (is_number($this->info->title)) {
         $label = get_string('includesection', 'backup', $this->info->title);
     } elseif (empty($this->info->title)) {
         // Don't throw error if title is empty, gracefully continue restore.
         $this->log('Section title missing in backup for section id ' . $this->info->sectionid, backup::LOG_WARNING, $this->name);
         $label = get_string('unnamedsection', 'backup');
     } else {
         $label = $this->info->title;
     }
     $section_included->get_ui()->set_label($label);
     $this->add_setting($section_included);
     // Define section_userinfo. Dependent of:
     // - users root setting
     // - section_included setting.
     $settingname = $settingprefix . 'userinfo';
     $defaultvalue = false;
     if (isset($this->info->settings[$settingname]) && $this->info->settings[$settingname]) {
         // Only enabled when available
         $defaultvalue = true;
     }
     $section_userinfo = new restore_section_userinfo_setting($settingname, base_setting::IS_BOOLEAN, $defaultvalue);
     if (!$defaultvalue) {
         // This is a bit hacky, but if there is no user data to restore, then
         // we replace the standard check-box with a select menu with the
         // single choice 'No', and the select menu is clever enough that if
         // there is only one choice, it just displays a static string.
         //
         // It would probably be better design to have a special UI class
         // setting_ui_checkbox_or_no, rather than this hack, but I am not
         // going to do that today.
         $section_userinfo->set_ui(new backup_setting_ui_select($section_userinfo, get_string('includeuserinfo', 'backup'), array(0 => get_string('no'))));
     } else {
         $section_userinfo->get_ui()->set_label(get_string('includeuserinfo', 'backup'));
     }
     $this->add_setting($section_userinfo);
     // Look for "users" root setting.
     $users = $this->plan->get_setting('users');
     $users->add_dependency($section_userinfo);
     // Look for "section_included" section setting.
     $section_included->add_dependency($section_userinfo);
 }