You are here

function signature_forum_comment in Signatures for Forums 5

Same name and namespace in other branches
  1. 5.2 signature_forum.module \signature_forum_comment()
  2. 6 signature_forum.module \signature_forum_comment()

Implementation of hook_comment().

File

./signature_forum.module, line 272

Code

function signature_forum_comment(&$comment, $op) {
  static $node_type;
  $settings = variable_get('signature_forum_settings', signature_forum_defaults());
  if (!isset($node_type)) {
    $node_type = db_result(db_query('SELECT type FROM {node} WHERE nid = %d', $comment->nid));
  }
  if ($op == 'view' && $settings['signature_forum_show_for_' . $node_type]) {
    static $cache;
    if (!isset($cache)) {
      $result = db_query("SELECT u.uid, u.signature FROM {comments} c\n                            INNER JOIN {users_signature} u ON c.uid=u.uid\n                            WHERE c.nid=%d AND c.status=0 AND u.signature<>''\n                            GROUP BY u.uid, u.signature", $comment->nid);
      $cache = array();
      while ($row = db_fetch_object($result)) {
        $cache[$row->uid] = $row->signature;
      }
    }
    if (isset($cache[$comment->uid])) {

      // Make implicit copy of signature (signature_forum_logic() alters variable)
      $signature = (string) $cache[$comment->uid];
      signature_forum_logic($signature, $comment->uid, strlen(strip_tags($comment->comment)));
      $comment->comment .= theme('signature_forum', $signature);
    }
  }
}