function commentaccess_access_check in Comment Access 7
This function checks comment access permissions.
Parameters
object $comment: The object to check
string: $op delete or approve
Return value
boolean TRUE or FALSE dependent from the $op
1 call to commentaccess_access_check()
- commentaccess_comment_view in ./
commentaccess.module - Implementation of hook_comment_view().
1 string reference to 'commentaccess_access_check'
- commentaccess_menu_alter in ./
commentaccess.module - Implementation of hook_menu_alter()
File
- ./
commentaccess.module, line 386 - Provides users with permissions for comments on nodes they own.
Code
function commentaccess_access_check($comment, $op = '') {
global $user;
// Menu system sometimes sends just cid
if (!is_object($comment)) {
$comment = comment_load($comment);
}
$node = node_load($comment->nid);
switch ($op) {
case 'delete':
if (!$user->uid) {
return FALSE;
}
if (user_access('administer comments')) {
return TRUE;
}
elseif (user_access("administer comments on own {$node->type}") && $user->uid == $node->uid) {
return TRUE;
}
elseif (user_access("delete comments on own {$node->type}") && $user->uid == $node->uid) {
return TRUE;
}
break;
case 'approve':
if (!$user->uid) {
return FALSE;
}
if ($comment->status == COMMENT_NOT_PUBLISHED) {
if (user_access('administer comments')) {
return TRUE;
}
elseif (user_access("administer comments on own {$node->type}") && $user->uid == $node->uid) {
return TRUE;
}
elseif (user_access("approve comments on own {$node->type}") && $user->uid == $node->uid) {
return TRUE;
}
}
break;
default:
return FALSE;
}
// end switch $op
}