63c63,72 < --- > if(module_exist("comment")) { > $form[$set][FLAG_CONTENT_NODE_TYPE . "comment"] = array( > '#type' => 'checkbox', > '#title' => t('comment'), > '#return_value' => 1, > '#default_value' => variable_get(FLAG_CONTENT_NODE_TYPE . "comment", 0), > ); > } > > 87,107c96,144 < if ($type == 'node') { < if (variable_get(FLAG_CONTENT_NODE_TYPE . $node->type, 0)) { < if ($user->uid) { < if (user_access(FLAG_CONTENT_PERM_ADD)) { < if (!_flag_content_check($node->nid)) { < // Not already flagged, flag it for admin < $links[] = l(t('flag as offensive'), "flag_content/add/$node->nid"); < } < else { < // If has admin privileges, show an unflag link < if (user_access(FLAG_CONTENT_PERM_MANAGE)) { < $links[] = l(t('unflag'), "flag_content/unflag/$node->nid"); < } < else { < // Otherwise just show it as flagged < $links[] = t('flagged as offensive'); < } < } < } < } < } --- > switch ($type) { > case 'node': > if (variable_get(FLAG_CONTENT_NODE_TYPE . $node->type, 0)) { > if ($user->uid) { > if (user_access(FLAG_CONTENT_PERM_ADD)) { > if (!_flag_content_check($node->nid)) { > // Not already flagged, flag it for admin > $links[] = l(t('flag as offensive'), "flag_content/add/$node->nid"); > > } > else { > // If has admin privileges, show an unflag link > if (user_access(FLAG_CONTENT_PERM_MANAGE)) { > $links[] = l(t('unflag'), "flag_content/unflag/$node->nid"); > } > else { > // Otherwise just show it as flagged > $links[] = t('flagged as offensive'); > } > } > } > } > } > break; > case 'comment': > if (variable_get(FLAG_CONTENT_NODE_TYPE . "comment", 0)) { > if ($user->uid) { > if (user_access(FLAG_CONTENT_PERM_ADD)) { > if (!_flag_content_check($node->nid, $node->cid)) { > // Not already flagged, flag it for admin > $links[]=l(t('flag as offensive'), "flag_content/add/$node->nid/$node->cid"); > } > else { > // If has admin privileges, show an unflag link > if (user_access(FLAG_CONTENT_PERM_MANAGE)) { > $links[] = l(t('unflag'), "flag_content/unflag/$node->nid/$node->cid"); > } > else { > // Otherwise just show it as flagged > $links[] = t('flagged as offensive'); > } > } > } > } > } > > break; > default: > break; 112a150 > global $user; 113a152 > $cid = (int)arg(3); 116c155 < db_query("INSERT INTO {flag_content} (nid, timestamp) VALUES (%d, %d)", $nid, time()); --- > db_query("INSERT INTO {flag_content} (nid, timestamp, cid, uid, flagmsg) VALUES (%d, %d, %d, %d, '')", $nid, time(), $cid, $user->uid); 126a166 > 128a169 > $cid = (int)arg(3); 130c171 < _flag_content_unflag($nid); --- > _flag_content_unflag($nid, $cid); 142c183,188 < $header = array(t('Title'), t('Author'), t('Date'), t('Operations')); --- > if (variable_get(FLAG_CONTENT_NODE_TYPE . "comment", 0)) { > $header = array(t('Title'), t('Comment'), t('Subject'), t('Author'), t('Flagged by'), t('Date'), t('Operations')); > } > else { > $header = array(t('Title'), t('Author'), t('Flagged by'), t('Date'), t('Operations')); > } 144,145c190,193 < foreach($list as $nid => $data) { < $title = l($data['title'], "node/$nid"); --- > foreach($list as $nidcid => $data) { > $title = l($data['title'], "node/$data[nid]"); > $comment=$data['comment']; > $subject=l($data['subject'], "node/$data[nid]#comment-$data[cid]"); 147a196 > $flaguser = theme('username', $data['flaguser']); 149,157c198,225 < $ops = l(t('edit'), "node/$nid/edit"); < $ops .= ' ' . l(t('unflag'), "flag_content/unflag/$nid"); < $ops .= ' ' . l(t('delete'), "node/$nid/delete"); < < $rows[] = array('data' => array_merge( < array($title), < array($user), < array($timestamp), < array($ops))); --- > if(empty($data[cid])) { > $ops = l(t('edit'), "node/$data[nid]/edit"); > $ops .= ' ' . l(t('unflag'), "flag_content/unflag/$data[nid]"); > $ops .= ' ' . l(t('delete'), "node/$data[nid]/delete"); > } else { > $ops = l(t('edit'), "comment/edit/$data[cid]"); > $ops .= ' ' . l(t('unflag'), "flag_content/unflag/$data[nid]/$data[cid]"); > $ops .= ' ' . l(t('delete'), "comment/delete/$data[cid]"); > } > > > if (variable_get(FLAG_CONTENT_NODE_TYPE . "comment", 0)) { > $rows[] = array('data' => array_merge( > array($title), > array($comment), > array($subject), > array($user), > array($flaguser), > array($timestamp), > array($ops))); > } else { > $rows[] = array('data' => array_merge( > array($title), > array($user), > array($flaguser), > array($timestamp), > array($ops))); > } 175,176c243,244 < function _flag_content_unflag($nid) { < db_query("DELETE FROM {flag_content} WHERE nid = %d", $nid); --- > function _flag_content_unflag($nid, $cid=0) { > db_query("DELETE FROM {flag_content} WHERE nid = %d AND cid = %d", $nid, $cid); 181,182c249,250 < $sql = "SELECT n.nid, n.title, n.uid, f.timestamp < FROM {node} n INNER JOIN {flag_content} f USING(nid) --- > $sql = "SELECT f.nid, f.cid, f.uid as flaguser, f.timestamp, n.title, n.uid as nodeuser, c.subject, c.uid as comuser > FROM {flag_content} f INNER JOIN {node} n USING(nid) LEFT JOIN {comments} c USING(cid) 186c254,265 < $rows[$data->nid] = array( --- > if(!empty($data->cid)) { > $author=$data->comuser; > $comment=t("Y"); > } > else { > $author=$data->nodeuser; > $comment=t("N"); > } > > $rows[$data->nid."_".$data->cid] = array( > 'nid' => $data->nid, > 'cid' => $data->cid, 188c267,270 < 'author' => user_load(array('uid' => $data->uid)), --- > 'comment' => $comment, > 'subject' => $data->subject, > 'author' => user_load(array('uid' => $author)), > 'flaguser' => user_load(array('uid' => $data->flaguser)), 195,197c277,279 < function _flag_content_check($nid) { < $sql = "SELECT COUNT(*) FROM {flag_content} WHERE nid = %d"; < return db_result(db_query($sql, $nid)); --- > function _flag_content_check($nid, $cid=0) { > $sql = "SELECT COUNT(*) FROM {flag_content} WHERE nid = %d AND cid= %d"; > return db_result(db_query($sql, $nid, $cid));