original_string: public static function apply_config_defaults(restore_controller $controller) {
  
          $settings = array(
              'restore_general_users'              => 'users',
              'restore_general_enrolments'         => 'enrolments',
              'restore_general_role_assignments'   => 'role_assignments',
              'restore_general_activities'         => 'activities',
              'restore_general_blocks'             => 'blocks',
              'restore_general_filters'            => 'filters',
              'restore_general_comments'           => 'comments',
              'restore_general_badges'             => 'badges',
              'restore_general_calendarevents'     => 'calendarevents',
              'restore_general_userscompletion'    => 'userscompletion',
              'restore_general_logs'               => 'logs',
              'restore_general_histories'          => 'grade_histories',
              'restore_general_questionbank'       => 'questionbank',
              'restore_general_groups'             => 'groups',
              'restore_general_competencies'       => 'competencies'
          );
          self::apply_admin_config_defaults($controller, $settings, true);
  
          $target = $controller->get_target();
          if ($target == backup::TARGET_EXISTING_ADDING || $target == backup::TARGET_CURRENT_ADDING) {
              $settings = array(
                  'restore_merge_overwrite_conf'  => 'overwrite_conf',
                  'restore_merge_course_fullname'  => 'course_fullname',
                  'restore_merge_course_shortname' => 'course_shortname',
                  'restore_merge_course_startdate' => 'course_startdate',
              );
              self::apply_admin_config_defaults($controller, $settings, true);
          }
  
          if ($target == backup::TARGET_EXISTING_DELETING || $target == backup::TARGET_CURRENT_DELETING) {
              $settings = array(
                  'restore_replace_overwrite_conf'  => 'overwrite_conf',
                  'restore_replace_course_fullname'  => 'course_fullname',
                  'restore_replace_course_shortname' => 'course_shortname',
                  'restore_replace_course_startdate' => 'course_startdate',
                  'restore_replace_keep_roles_and_enrolments' => 'keep_roles_and_enrolments',
                  'restore_replace_keep_groups_and_groupings' => 'keep_groups_and_groupings',
              );
              self::apply_admin_config_defaults($controller, $settings, true);
          }
          if ($controller->get_mode() == backup::MODE_IMPORT &&
                  (!$controller->get_interactive()) &&
                  $controller->get_type() == backup::TYPE_1ACTIVITY) {
              // This is duplicate - there is no concept of defaults - these settings must be on.
              $settings = array(
                      'activities',
                      'blocks',
                      'filters',
                      'questionbank'
              );
              self::force_enable_settings($controller, $settings);
          };
  
          // Add some dependencies.
          $plan = $controller->get_plan();
          if ($plan->setting_exists('overwrite_conf')) {
              /** @var restore_course_overwrite_conf_setting $overwriteconf */
              $overwriteconf = $plan->get_setting('overwrite_conf');
              if ($overwriteconf->get_visibility()) {
                  foreach (['course_fullname', 'course_shortname', 'course_startdate'] as $settingname) {
                      if ($plan->setting_exists($settingname)) {
                          $setting = $plan->get_setting($settingname);
                          $overwriteconf->add_dependency($setting, setting_dependency::DISABLED_FALSE,
                              array('defaultvalue' => $setting->get_value()));
                      }
                  }
              }
          }
      }
code: public static function apply_config_defaults(restore_controller $controller) {
  
          $settings = array(
              'restore_general_users'              => 'users',
              'restore_general_enrolments'         => 'enrolments',
              'restore_general_role_assignments'   => 'role_assignments',
              'restore_general_activities'         => 'activities',
              'restore_general_blocks'             => 'blocks',
              'restore_general_filters'            => 'filters',
              'restore_general_comments'           => 'comments',
              'restore_general_badges'             => 'badges',
              'restore_general_calendarevents'     => 'calendarevents',
              'restore_general_userscompletion'    => 'userscompletion',
              'restore_general_logs'               => 'logs',
              'restore_general_histories'          => 'grade_histories',
              'restore_general_questionbank'       => 'questionbank',
              'restore_general_groups'             => 'groups',
              'restore_general_competencies'       => 'competencies'
          );
          self::apply_admin_config_defaults($controller, $settings, true);
  
          $target = $controller->get_target();
          if ($target == backup::TARGET_EXISTING_ADDING || $target == backup::TARGET_CURRENT_ADDING) {
              $settings = array(
                  'restore_merge_overwrite_conf'  => 'overwrite_conf',
                  'restore_merge_course_fullname'  => 'course_fullname',
                  'restore_merge_course_shortname' => 'course_shortname',
                  'restore_merge_course_startdate' => 'course_startdate',
              );
              self::apply_admin_config_defaults($controller, $settings, true);
          }
  
          if ($target == backup::TARGET_EXISTING_DELETING || $target == backup::TARGET_CURRENT_DELETING) {
              $settings = array(
                  'restore_replace_overwrite_conf'  => 'overwrite_conf',
                  'restore_replace_course_fullname'  => 'course_fullname',
                  'restore_replace_course_shortname' => 'course_shortname',
                  'restore_replace_course_startdate' => 'course_startdate',
                  'restore_replace_keep_roles_and_enrolments' => 'keep_roles_and_enrolments',
                  'restore_replace_keep_groups_and_groupings' => 'keep_groups_and_groupings',
              );
              self::apply_admin_config_defaults($controller, $settings, true);
          }
          if ($controller->get_mode() == backup::MODE_IMPORT &&
                  (!$controller->get_interactive()) &&
                  $controller->get_type() == backup::TYPE_1ACTIVITY) {
              // This is duplicate - there is no concept of defaults - these settings must be on.
              $settings = array(
                      'activities',
                      'blocks',
                      'filters',
                      'questionbank'
              );
              self::force_enable_settings($controller, $settings);
          };
  
          // Add some dependencies.
          $plan = $controller->get_plan();
          if ($plan->setting_exists('overwrite_conf')) {
              /** @var restore_course_overwrite_conf_setting $overwriteconf */
              $overwriteconf = $plan->get_setting('overwrite_conf');
              if ($overwriteconf->get_visibility()) {
                  foreach (['course_fullname', 'course_shortname', 'course_startdate'] as $settingname) {
                      if ($plan->setting_exists($settingname)) {
                          $setting = $plan->get_setting($settingname);
                          $overwriteconf->add_dependency($setting, setting_dependency::DISABLED_FALSE,
                              array('defaultvalue' => $setting->get_value()));
                      }
                  }
              }
          }
      }
code_tokens: public static function apply_config_defaults ( restore_controller $ controller ) { $ settings = array ( 'restore_general_users' => 'users' , 'restore_general_enrolments' => 'enrolments' , 'restore_general_role_assignments' => 'role_assignments' , 'restore_general_activities' => 'activities' , 'restore_general_blocks' => 'blocks' , 'restore_general_filters' => 'filters' , 'restore_general_comments' => 'comments' , 'restore_general_badges' => 'badges' , 'restore_general_calendarevents' => 'calendarevents' , 'restore_general_userscompletion' => 'userscompletion' , 'restore_general_logs' => 'logs' , 'restore_general_histories' => 'grade_histories' , 'restore_general_questionbank' => 'questionbank' , 'restore_general_groups' => 'groups' , 'restore_general_competencies' => 'competencies' ) ; self :: apply_admin_config_defaults ( $ controller , $ settings , true ) ; $ target = $ controller -> get_target ( ) ; if ( $ target == backup :: TARGET_EXISTING_ADDING || $ target == backup :: TARGET_CURRENT_ADDING ) { $ settings = array ( 'restore_merge_overwrite_conf' => 'overwrite_conf' , 'restore_merge_course_fullname' => 'course_fullname' , 'restore_merge_course_shortname' => 'course_shortname' , 'restore_merge_course_startdate' => 'course_startdate' , ) ; self :: apply_admin_config_defaults ( $ controller , $ settings , true ) ; } if ( $ target == backup :: TARGET_EXISTING_DELETING || $ target == backup :: TARGET_CURRENT_DELETING ) { $ settings = array ( 'restore_replace_overwrite_conf' => 'overwrite_conf' , 'restore_replace_course_fullname' => 'course_fullname' , 'restore_replace_course_shortname' => 'course_shortname' , 'restore_replace_course_startdate' => 'course_startdate' , 'restore_replace_keep_roles_and_enrolments' => 'keep_roles_and_enrolments' , 'restore_replace_keep_groups_and_groupings' => 'keep_groups_and_groupings' , ) ; self :: apply_admin_config_defaults ( $ controller , $ settings , true ) ; } if ( $ controller -> get_mode ( ) == backup :: MODE_IMPORT && ( ! $ controller -> get_interactive ( ) ) && $ controller -> get_type ( ) == backup :: TYPE_1ACTIVITY ) { // This is duplicate - there is no concept of defaults - these settings must be on. $ settings = array ( 'activities' , 'blocks' , 'filters' , 'questionbank' ) ; self :: force_enable_settings ( $ controller , $ settings ) ; } ; // Add some dependencies. $ plan = $ controller -> get_plan ( ) ; if ( $ plan -> setting_exists ( 'overwrite_conf' ) ) { /** @var restore_course_overwrite_conf_setting $overwriteconf */ $ overwriteconf = $ plan -> get_setting ( 'overwrite_conf' ) ; if ( $ overwriteconf -> get_visibility ( ) ) { foreach ( [ 'course_fullname' , 'course_shortname' , 'course_startdate' ] as $ settingname ) { if ( $ plan -> setting_exists ( $ settingname ) ) { $ setting = $ plan -> get_setting ( $ settingname ) ; $ overwriteconf -> add_dependency ( $ setting , setting_dependency :: DISABLED_FALSE , array ( 'defaultvalue' => $ setting -> get_value ( ) ) ) ; } } } } }
docstring: Sets the default values for the settings in a restore operation
  
  @param restore_controller $controller
docstring_tokens: Sets the default values for the settings in a restore operation