You are here

function maxlength_update_7302 in Maxlength 7.3

Implements hook_update_N().

Migrate comment settings.

File

./maxlength.install, line 75
Install, update and uninstall functions for the Maxlength module.

Code

function maxlength_update_7302() {
  $ret = array();

  // Migrate node body.
  foreach (node_type_get_names() as $type => $name) {
    $maxlength = variable_get('maxlength_comment_comment_' . $type, 0);
    variable_del('maxlength_comment_comment_' . $type);
    $label = variable_get('maxlength_comment_comment_text_' . $type, 0);
    variable_del('maxlength_comment_comment_text_' . $type);
    if ($maxlength) {
      $instance = field_read_instance('comment', 'comment_body', $type);

      // Body is a text_textarea_with_summary.
      $instance['widget']['settings']['maxlength_js'] = $maxlength;
      $instance['widget']['settings']['maxlength_js_label'] = $label;
      field_update_instance($instance);
    }
  }
}