You are here

function nfsmigrate_migrate_nodeformsettings in Node and Comments Form Settings 6.2

Same name and namespace in other branches
  1. 6.3 nfsmigrate/nfsmigrate.module \nfsmigrate_migrate_nodeformsettings()
1 string reference to 'nfsmigrate_migrate_nodeformsettings'
nfsmigrate_settings in nfsmigrate/nfsmigrate.module

File

nfsmigrate/nfsmigrate.module, line 52

Code

function nfsmigrate_migrate_nodeformsettings($form, &$form_state) {
  foreach (node_get_types('names') as $type => $type_name) {

    // Build the import array filled with old values
    $old_cancel = variable_get('nodeformsettings_cancel_' . $type, '');
    $old_hide_node_title = variable_get('hidetitle_' . $type, '');
    $old_inputformat = variable_get("nodeformsettings_inputformat_" . $type, '');
    $old_preview = variable_get("nodeformsettings_preview_" . $type, '');
    $old_revisionlog = variable_get("nodeformsettings_revisionlog_" . $type, '');
    $old_splitsummary = variable_get("nodeformsettings_splitsummary_" . $type, '');
    $old_submission_body_rows = variable_get("submission_body_rows_" . $type, '');
    $old_submit = variable_get("nodeformsettings_submit_" . $type, '');
    $old_nfs_title_create = variable_get("nodeformsettings_title_create_" . $type, '');
    $old_nfs_title_edit = variable_get("nodeformsettings_title_edit_" . $type, '');
    $import = array(
      'nfs_cancel' => array(
        'nfs_cancel_status' => isset($old_cancel) ? $old_cancel : 1,
        'nfs_cancel_behaviour' => 1,
      ),
      'nfs_hide_node_title' => isset($old_hide_node_title) ? $old_hide_node_title : 0,
      'nfs_inputformat' => isset($old_inputformat) ? $old_inputformat : 0,
      'nfs_preview' => isset($old_preview) ? $old_preview : 0,
      'nfs_revisionlog' => isset($old_revisionlog) ? $old_revisionlog : 0,
      'nfs_splitsummary' => isset($old_splitsummary) ? $old_splitsummary : 0,
      'nfs_submission_body_rows' => isset($old_submission_body_rows) ? $old_submission_body_rows : 20,
      'nfs_submit' => isset($old_submit) ? $old_submit : t("Submit"),
      'nfs_title_create' => isset($old_nfs_title_create) ? $old_nfs_title_create : t("Create !node_type"),
      'nfs_title_edit' => isset($old_nfs_title_edit) ? $old_nfs_title_edit : t("!node_title"),
    );

    // Set the new variable
    variable_set('nodeformsettings_' . $type, $import);

    // Delete all old variables
    variable_del('nodeformsettings_cancel_' . $type);
    variable_del('hidetitle_' . $type);
    variable_del("nodeformsettings_inputformat_" . $type);
    variable_del("nodeformsettings_preview_" . $type);
    variable_del("nodeformsettings_revisionlog_" . $type);
    variable_del("nodeformsettings_splitsummary_" . $type);
    variable_del("submission_body_rows_" . $type);
    variable_del("nodeformsettings_submit_" . $type);
    variable_del("nodeformsettings_title_create_" . $type);
    variable_del("nodeformsettings_title_edit_" . $type);
  }
  $out .= "<p>This is the new result of the conversion process. Please review the array values and fix if necessary</p><p></p>";
  drupal_set_message($out);
  foreach (node_get_types('names') as $type => $type_name) {

    // Return the final result
    $val[$type] = variable_get('nodeformsettings_' . $type, '');
  }
  drupal_set_message('<pre>' . htmlentities(print_r($val, 1)) . '</pre>');
}