comment_node_update_index
function comment_node_update_index
comment_node_update_index($node)
Implements hook_node_update_index().
File
- modules/comment/comment.module, line 1336
- Enables users to comment on published content.
Code
function comment_node_update_index($node) { $index_comments = &drupal_static(__FUNCTION__); if ($index_comments === NULL) { // Find and save roles that can 'access comments' or 'search content'. $perms = array('access comments' => array(), 'search content' => array()); $result = db_query("SELECT rid, permission FROM {role_permission} WHERE permission IN ('access comments', 'search content')"); foreach ($result as $record) { $perms[$record->permission][$record->rid] = $record->rid; } // Prevent indexing of comments if there are any roles that can search but // not view comments. $index_comments = TRUE; foreach ($perms['search content'] as $rid) { if (!isset($perms['access comments'][$rid]) && ($rid <= DRUPAL_AUTHENTICATED_RID || !isset($perms['access comments'][DRUPAL_AUTHENTICATED_RID]))) { $index_comments = FALSE; break; } } } if ($index_comments) { $mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED); $comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50); if ($node->comment && $cids = comment_get_thread($node, $mode, $comments_per_page)) { $comments = comment_load_multiple($cids); comment_prepare_thread($comments); $build = comment_view_multiple($comments, $node); return drupal_render($build); } } return ''; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!comment!comment.module/function/comment_node_update_index/7.x