commit 51f9bc4c238c6b27b50a54b1144ee0d93842d9d9 Author: Lee Rowlands Date: Tue Nov 20 07:58:01 2012 +1000 Comments from #169 diff --git a/core/modules/comment/comment.field.inc b/core/modules/comment/comment.field.inc index 666b2c7..9160484 100644 --- a/core/modules/comment/comment.field.inc +++ b/core/modules/comment/comment.field.inc @@ -182,13 +182,12 @@ function comment_field_widget_form(&$form, &$form_state, $field, $instance, $lan $values = reset($items); if (empty($values)) { $values = array( - // More here from $instance['settings']; + // Default taken from instance settings. 'comment' => $settings['comment'], - 'comment_count' => 0 ); } $entity_id = $entity->id(); - $comment_count = empty($values['comment_count']) ? 0 : $values['comment_count']; + $comment_count = empty($entity->comment_statistics[$field['field_name']]->comment_count) ? 0 : $entity->comment_statistics[$field['field_name']]->comment_count; $comment_settings = ($values['comment'] == COMMENT_ENTITY_HIDDEN && empty($comment_count)) ? COMMENT_CLOSED : $values['comment']; $element['comment'] = array( '#type' => 'radios', diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 06cf125..7aa3d59 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -453,13 +453,21 @@ function comment_reply_access(\Drupal\Core\Entity\EntityInterface $entity) { // @todo replace this with entity access controls once generic access // controller lands. // @see http://drupal.org/node/1696660 - if (function_exists($function) && $function != 'user_access') { - return $function('view', $entity); - } - elseif ($function == 'user_access') { - // User access is a special case. - return user_view_access($entity); + if (function_exists($function)) { + switch ($function) { + case 'user_access': + return user_view_access($entity); + break; + + case 'taxonomy_term_access': + return user_access('access content'); + break; + + default: + return $function('view', $entity); + } } + // We can't know how to control access to this entity, invoke // hook_comment_access and if no other modules object, grant access. $access = module_invoke_all('comment_access', $entity); @@ -1061,9 +1069,15 @@ function comment_view_multiple($comments, $view_mode = 'full', $langcode = NULL) * Implements hook_form_FORM_ID_alter() for field_ui_field_edit_form(). */ function comment_form_field_ui_field_edit_form_alter(&$form, $form_state) { + // Collect translation settings. if (module_exists('translation_entity')) { array_unshift($form['#submit'], 'comment_translation_configuration_element_submit'); } + // Hide required checkbox. + $form['instance']['required']['#access'] = FALSE; + + // Force cardinality to one. + $form['field']['cardinality']['#options'] = drupal_map_assoc(array(1)); } /**