public static function apply_config_defaults(backup_controller $controller) {
        // Based on the mode of the backup (general, automated, import, hub...)
        // decide the action to perform to get defaults loaded
        $mode = $controller->get_mode();

        switch ($mode) {
            case backup::MODE_GENERAL:
                // Load the general defaults
                $settings = array(
                        'backup_general_users'              => 'users',
                        'backup_general_anonymize'          => 'anonymize',
                        'backup_general_role_assignments'   => 'role_assignments',
                        'backup_general_activities'         => 'activities',
                        'backup_general_blocks'             => 'blocks',
                        'backup_general_filters'            => 'filters',
                        'backup_general_comments'           => 'comments',
                        'backup_general_badges'             => 'badges',
                        'backup_general_calendarevents'     => 'calendarevents',
                        'backup_general_userscompletion'    => 'userscompletion',
                        'backup_general_logs'               => 'logs',
                        'backup_general_histories'          => 'grade_histories',
                        'backup_general_questionbank'       => 'questionbank',
                        'backup_general_groups'             => 'groups',
                        'backup_general_competencies'       => 'competencies'
                );
                self::apply_admin_config_defaults($controller, $settings, true);
                break;
            case backup::MODE_IMPORT:
                // Load the import defaults.
                $settings = array(
                        'backup_import_activities'         => 'activities',
                        'backup_import_blocks'             => 'blocks',
                        'backup_import_filters'            => 'filters',
                        'backup_import_calendarevents'     => 'calendarevents',
                        'backup_import_questionbank'       => 'questionbank',
                        'backup_import_groups'             => 'groups',
                        'backup_import_competencies'       => 'competencies'
                );
                self::apply_admin_config_defaults($controller, $settings, true);
                if ((!$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);
                }
                break;
            case backup::MODE_AUTOMATED:
                // Load the automated defaults.
                $settings = array(
                        'backup_auto_users'              => 'users',
                        'backup_auto_role_assignments'   => 'role_assignments',
                        'backup_auto_activities'         => 'activities',
                        'backup_auto_blocks'             => 'blocks',
                        'backup_auto_filters'            => 'filters',
                        'backup_auto_comments'           => 'comments',
                        'backup_auto_badges'             => 'badges',
                        'backup_auto_calendarevents'     => 'calendarevents',
                        'backup_auto_userscompletion'    => 'userscompletion',
                        'backup_auto_logs'               => 'logs',
                        'backup_auto_histories'          => 'grade_histories',
                        'backup_auto_questionbank'       => 'questionbank',
                        'backup_auto_groups'             => 'groups',
                        'backup_auto_competencies'       => 'competencies'
                );
                self::apply_admin_config_defaults($controller, $settings, false);
                break;
            default:
                // Nothing to do for other modes (HUB...). Some day we
                // can define defaults (admin UI...) for them if we want to
        }
    }