You are here

function comment_alter_get_alterable_fields in Comment Alter 7

Same name and namespace in other branches
  1. 8 comment_alter.module \comment_alter_get_alterable_fields()

Returns the comment-alterable fields for a content type.

Parameters

string $content_type: Node object, at least with the type property.

Return value

array Array of the comment-alterable fields for that content type.

5 calls to comment_alter_get_alterable_fields()
CommentAlterAdminTestCase::testNodeFieldInstanceSettings in ./comment_alter.test
comment_alter_field_extra_fields in ./comment_alter.module
Implements hook_field_extra_fields().
comment_alter_form_comment_form_alter in ./comment_alter.module
Implements hook_form_BASE_FORM_ID_alter().
comment_alter_form_field_ui_field_overview_form_alter in ./comment_alter.module
Implements hook_form_FORM_ID_alter().
comment_alter_get_changed_fields in ./comment_alter.module
Returns the differences committed with a particular comment.
1 string reference to 'comment_alter_get_alterable_fields'
CommentAlterAdminTestCase::testNodeFieldInstanceSettings in ./comment_alter.test

File

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

Code

function comment_alter_get_alterable_fields($content_type) {
  $comment_alter_fields =& drupal_static(__FUNCTION__);
  if (!isset($comment_alter_fields[$content_type])) {
    $field_infos = field_info_instances('node', $content_type);
    $comment_fields = field_info_instances('comment', 'comment_node_' . $content_type);
    $comment_alter_fields[$content_type] = array();
    foreach ($field_infos as $field_name => $value) {
      if (!empty($value['comment_alter']) && empty($comment_fields[$field_name])) {
        $comment_alter_fields[$content_type][] = $field_name;
      }
    }
  }
  return $comment_alter_fields[$content_type];
}