function _forum_access_preprocess_comment in Forum Access 6
Recreate comment links (they've already been themed), and remove those that aren't accessible to the user (pre-D6.17).
1 call to _forum_access_preprocess_comment()
File
- ./
forum_access.node.inc, line 196 - forum_access.node.inc
Code
function _forum_access_preprocess_comment(&$variables) {
global $user;
if (!empty($user->_forum_access_moderator)) {
_forum_access_enable_moderator();
// this allows us to retrieve the comment links (without setting precedent!)
}
$tid = $variables['node']->tid;
$links = module_invoke_all('link', 'comment', $variables['comment'], 0);
if (!empty($user->_forum_access_moderator) && arg(0) == 'node' && arg(2) == NULL) {
_forum_access_disable_moderator();
}
if (isset($links['comment_reply']) && (!preg_match('#<li class="[^"]*comment_reply[^"]*".*</li>#U', $variables['links']) || !user_access('post comments') || !forum_access_access($tid, 'create', NULL, FALSE))) {
unset($links['comment_reply']);
}
if (isset($links['comment_edit']) && !forum_access_access($tid, 'update', NULL, FALSE) && !comment_access('edit', $variables['comment'])) {
unset($links['comment_edit']);
}
if (isset($links['comment_delete']) && !forum_access_access($tid, 'delete', NULL, FALSE) && !user_access('administer comments')) {
unset($links['comment_delete']);
}
foreach (array_keys($links) as $link) {
if (!in_array($link, array(
'comment_reply',
'comment_edit',
'comment_delete',
))) {
$link_preg_quote = preg_quote($link, '#');
if (!preg_match('#<li class="[^"]*' . $link_preg_quote . '[^"]*"(.|\\n)*</li>#U', $variables['links'])) {
unset($links[$link]);
// eliminate possible additional unknown links that came in for 'administer_comments'
}
}
}
drupal_alter('link', $links, $variables['node'], $variables['comment']);
if (empty($links)) {
$links['comment_forbidden'] = array(
'title' => theme('comment_post_forbidden', $variables['node']),
'html' => TRUE,
);
}
$variables['links'] = theme('links', $links);
}