function comment_node_update_index
Same name in other branches
- 9 core/modules/comment/comment.module \comment_node_update_index()
- 8.9.x core/modules/comment/comment.module \comment_node_update_index()
- 10 core/modules/comment/comment.module \comment_node_update_index()
- 11.x core/modules/comment/comment.module \comment_node_update_index()
Implements hook_node_update_index().
File
-
modules/
comment/ comment.module, line 1342
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);
if ($comments) {
comment_prepare_thread($comments);
$build = comment_view_multiple($comments, $node);
return drupal_render($build);
}
}
}
return '';
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.