abuse_link($type, $object = null, $teaser = false)
abuse/abuse.module, line 421
Implementation of hook_link
$type the type of object to act on
$object the object (can be user, comment, node)
$teaser
array of links to display for object
<?php
function abuse_link($type, $object = null, $teaser = false) {
global $user;
$links = array();
if ($object && $user && ($user->uid != 0 && $user->uid == $object->uid)) {
// Don't want user to flag their own content
return $links;
}
if ($type == 'node' && !$teaser) {
if (variable_get(ABUSE_CONTENT_NODE_TYPE . $object->type, 0) && (user_access('report abuse') || user_access('direct flag'))) {
$node_link = array(
'title' => t('Flag as offensive'),
'href' => 'abuse/report/node/'. $object->nid,
'attributes' => array(
'class' => 'flag-content',
'title' => t('Notify administrators of problematic content'),
),
);
if ($user->uid && ($user->uid != $object->uid)) {
$already_reported_check = db_result(db_query("SELECT COUNT(*) FROM {abuse} WHERE type = '%s' AND oid = %d AND uid = %d", $type, $object->nid, $user->uid));
//if ($already_reported_check > 0) {
// $links['abuse_already_flagged'] = array(
// 'title' => t('This content is currently under review'),
// );
//}
if ($already_reported_check == 0) {
$links['abuse_flag_node'] = $node_link;
}
}
else {
$links['abuse_flag_node'] = $node_link;
}
}
}
elseif ($type == 'comment' && (user_access('report abuse') || user_access('direct flag'))) {
$comment_link = array(
'title' => t('Flag as offensive'),
'href' => 'abuse/report/comment/'. $object->cid,
'attributes' => array(
'class' => 'flag-content',
'title' => t('Notify administrators of problematic comment'),
)
);
if ($user->uid && ($user->uid != $object->uid)) {
$already_reported_check = db_result(db_query("SELECT COUNT(*) FROM {abuse} WHERE type = '%s' AND oid = %d AND uid = %d", $type, $object->cid, $user->uid));
//if ($already_reported_check > 0) {
// $links['abuse_already_flagged'] = array(
// 'title' => t('This comment is currently under review'),
// );
//}
if ($already_reported_check == 0) {
$links['abuse_flag_comment'] = $comment_link;
}
}
else {
$links['abuse_flag_comment'] = $comment_link;
}
}
return $links;
}
?>