You are here

function comment_alter_field_extra_fields in Comment Alter 7

Implements hook_field_extra_fields().

File

./comment_alter.module, line 614
Provides UI to alter nodes' parameters from comment forms.

Code

function comment_alter_field_extra_fields() {
  $return = array();
  foreach (node_type_get_types() as $type) {
    $comment_alter_fields = comment_alter_get_alterable_fields($type->type);
    $weight = 0;
    foreach ($comment_alter_fields as $field_name) {
      $field = field_info_instance('node', $field_name, $type->type);

      // Comment_alterable node fields must be amongst the comment fields
      // themselves in order to be able to properly weight/reorder them, put
      // them into a field_group, etc. on the manage comment fields form.
      $return['comment']['comment_node_' . $type->type]['form'][$field_name] = array(
        'label' => $field['label'],
        'description' => $field['description'],
        'weight' => $weight,
      );
      $weight++;
    }
    if (!empty($comment_alter_fields)) {
      $return['comment']['comment_node_' . $type->type]['display']['comment_alter'] = array(
        'label' => t('Comment changes'),
        'description' => t('Changes made to the parent node\'s fields in this comment.'),
        'weight' => -1,
      );
    }
  }
  return $return;
}