function comment_update_7000

Rename comment display setting variables.

Related topics

File

modules/comment/comment.install, line 108

Code

function comment_update_7000() {
    $types = _update_7000_node_get_types();
    foreach ($types as $type => $type_object) {
        variable_del('comment_default_order' . $type);
        // Drupal 6 had four display modes:
        // - COMMENT_MODE_FLAT_COLLAPSED = 1
        // - COMMENT_MODE_FLAT_EXPANDED = 2
        // - COMMENT_MODE_THREADED_COLLAPSED = 3
        // - COMMENT_MODE_THREADED_EXPANDED = 4
        //
        // Drupal 7 doesn't support collapsed/expanded modes anymore, so we
        // migrate all the flat modes to COMMENT_MODE_FLAT (0) and all the threaded
        // modes to COMMENT_MODE_THREADED (1).
        $setting = variable_get('comment_default_mode_' . $type, 4);
        if ($setting == 3 || $setting == 4) {
            variable_set('comment_default_mode_' . $type, 1);
        }
        else {
            variable_set('comment_default_mode_' . $type, 0);
        }
        // There were only two comment modes in the past:
        // - 1 was 'required' previously, convert into DRUPAL_REQUIRED (2).
        // - 0 was 'optional' previously, convert into DRUPAL_OPTIONAL (1).
        $preview = variable_get('comment_preview_' . $type, 1) ? 2 : 1;
        variable_set('comment_preview_' . $type, $preview);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.