RSS

(root)/drupal/6 : 11 : modules/comment/comment.module

Ā« back to all changes in this revision

Viewing changes to modules/comment/comment.module

David Strauss
2010-03-04 01:32:05
Revision ID: david@fourkitchens.com-20100304013205-rzm7nzx405tybf1o
Tags: DRUPAL-6-16
DrupalĀ 6.16

Show diffs side-by-side

added added

removed removed

1
1
<?php
2
 
// $Id: comment.module,v 1.617.2.10 2009/09/14 10:36:42 goba Exp $
 
2
// $Id: comment.module,v 1.617.2.14 2010/03/01 09:44:31 goba Exp $
3
3
 
4
4
/**
5
5
 * @file
363
363
      // Threaded comments. See the documentation for comment_render().
364
364
      if ($order == COMMENT_ORDER_NEWEST_FIRST) {
365
365
        // Newest first: find the last thread with new comment
366
 
        $result = db_query('(SELECT thread FROM {comments} WHERE nid = %d  AND status = 0 ORDER BY timestamp DESC LIMIT %d) ORDER BY thread DESC LIMIT 1', $node->nid, $new_replies);
 
366
        $result = db_query('SELECT thread FROM (SELECT thread FROM {comments} WHERE nid = %d AND status = 0 ORDER BY timestamp DESC LIMIT %d) AS thread ORDER BY thread DESC LIMIT 1', $node->nid, $new_replies);
367
367
        $thread = db_result($result);
368
368
        $result_count = db_query("SELECT COUNT(*) FROM {comments} WHERE nid = %d AND status = 0 AND thread > '". $thread ."'", $node->nid);
369
369
      }
370
370
      else {
371
371
        // Oldest first: find the first thread with new comment
372
 
        $result = db_query('(SELECT thread FROM {comments} WHERE nid = %d  AND status = 0 ORDER BY timestamp DESC LIMIT %d) ORDER BY SUBSTRING(thread, 1, (LENGTH(thread) - 1)) LIMIT 1', $node->nid, $new_replies);
 
372
        $result = db_query('SELECT thread FROM (SELECT thread FROM {comments} WHERE nid = %d AND status = 0 ORDER BY timestamp DESC LIMIT %d) AS thread ORDER BY SUBSTRING(thread, 1, (LENGTH(thread) - 1)) LIMIT 1', $node->nid, $new_replies);
373
373
        $thread = substr(db_result($result), 0, -1);
374
374
        $result_count = db_query("SELECT COUNT(*) FROM {comments} WHERE nid = %d AND status = 0 AND SUBSTRING(thread, 1, (LENGTH(thread) - 1)) < '". $thread ."'", $node->nid);
375
375
      }
1072
1072
  if ($action == 'publish') {
1073
1073
    $operations = array(
1074
1074
      'publish' => array(t('Publish the selected comments'), 'UPDATE {comments} SET status = '. COMMENT_PUBLISHED .' WHERE cid = %d'),
1075
 
      'delete' => array(t('Delete the selected comments'), '')
 
1075
      'delete' => array(t('Delete the selected comments'), ''),
1076
1076
    );
1077
1077
  }
1078
1078
  else if ($action == 'unpublish') {
1079
1079
    $operations = array(
1080
1080
      'unpublish' => array(t('Unpublish the selected comments'), 'UPDATE {comments} SET status = '. COMMENT_NOT_PUBLISHED .' WHERE cid = %d'),
1081
 
      'delete' => array(t('Delete the selected comments'), '')
 
1081
      'delete' => array(t('Delete the selected comments'), ''),
1082
1082
    );
1083
1083
  }
1084
1084
  else {
1085
1085
    $operations = array(
1086
1086
      'publish' => array(t('Publish the selected comments'), 'UPDATE {comments} SET status = '. COMMENT_PUBLISHED .' WHERE cid = %d'),
1087
1087
      'unpublish' => array(t('Unpublish the selected comments'), 'UPDATE {comments} SET status = '. COMMENT_NOT_PUBLISHED .' WHERE cid = %d'),
1088
 
      'delete' => array(t('Delete the selected comments'), '')
 
1088
      'delete' => array(t('Delete the selected comments'), ''),
1089
1089
    );
1090
1090
  }
1091
1091
  return $operations;
1550
1550
}
1551
1551
 
1552
1552
/**
1553
 
 * Theme a single comment block.
 
1553
 * Themes a single comment and related items.
1554
1554
 *
1555
1555
 * @param $comment
1556
1556
 *   The comment object.
1557
1557
 * @param $node
1558
1558
 *   The comment node.
1559
1559
 * @param $links
1560
 
 *   An associative array containing control links.
 
1560
 *   An associative array containing control links suitable for passing into
 
1561
 *   theme_links(). These are generated by modules implementing hook_link() with
 
1562
 *   $type='comment'. Typical examples are links for editing and deleting
 
1563
 *   comments.
1561
1564
 * @param $visible
1562
 
 *   Switches between folded/unfolded view.
 
1565
 *   Switches between folded/unfolded view. If TRUE the comments are visible, if
 
1566
 *   FALSE the comments are folded.
1563
1567
 * @ingroup themeable
1564
1568
 */
1565
1569
function theme_comment_view($comment, $node, $links = array(), $visible = TRUE) {
1739
1743
 * @ingroup themeable
1740
1744
 */
1741
1745
function theme_comment_flat_expanded($comment, $node) {
1742
 
  return theme('comment_view', $comment, $node, module_invoke_all('link', 'comment', $comment, 0));
 
1746
  $links = module_invoke_all('link', 'comment', $comment, 0);
 
1747
  drupal_alter('link', $links, $node);
 
1748
  return theme('comment_view', $comment, $node, $links);
1743
1749
}
1744
1750
 
1745
1751
/**
1765
1771
 * @ingroup themeable
1766
1772
 */
1767
1773
function theme_comment_thread_expanded($comment, $node) {
1768
 
  return theme('comment_view', $comment, $node, module_invoke_all('link', 'comment', $comment, 0));
 
1774
  $links = module_invoke_all('link', 'comment', $comment, 0);
 
1775
  drupal_alter('link', $links, $node);
 
1776
  return theme('comment_view', $comment, $node, $links);
1769
1777
}
1770
1778
 
1771
1779
/**

Loggerhead 1.17 is a web-based interface for Bazaar branches