~spreadubuntu/spreadubuntu/devel-drupal6

« back to all changes in this revision

Viewing changes to modules/views/modules/comment/views_plugin_row_comment_view.inc

  • Committer: ruben
  • Date: 2009-06-08 09:38:49 UTC
  • Revision ID: ruben@captive-20090608093849-s1qtsyctv2vwp1x1
SpreadUbuntu moving to Drupal6. Based on ubuntu-drupal theme and adding our modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
// $Id: views_plugin_row_comment_view.inc,v 1.1 2008/09/03 19:21:29 merlinofchaos Exp $
 
3
/**
 
4
 * @file
 
5
 * Contains the node RSS row style plugin.
 
6
 */
 
7
 
 
8
/**
 
9
 * Plugin which performs a comment_view on the resulting object.
 
10
 */
 
11
class views_plugin_row_comment_view extends views_plugin_row {
 
12
  function option_definition() {
 
13
    $options = parent::option_definition();
 
14
    $options['links'] = array('default' => TRUE);
 
15
    return $options;
 
16
  }
 
17
 
 
18
  function options_form(&$form, &$form_state) {
 
19
    $form['links'] = array(
 
20
      '#type' => 'checkbox',
 
21
      '#title' => t('Display links'),
 
22
      '#default_value' => $this->options['links'],
 
23
    );
 
24
  }
 
25
 
 
26
  function pre_render($result) {
 
27
    $cids = array();
 
28
    $this->comments = array();
 
29
 
 
30
    foreach ($result as $row) {
 
31
      $cids[] = $row->cid;
 
32
    }
 
33
 
 
34
    if (count($cids) > 1) {
 
35
      $placeholder = " IN (" . implode(', ', array_fill(0, sizeof($cids), '%d')) . ")";
 
36
    }
 
37
    else {
 
38
      $placeholder = " = %d";
 
39
    }
 
40
 
 
41
    $cresult = db_query("SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid $placeholder", $cids);
 
42
    while ($comment = db_fetch_object($cresult)) {
 
43
      $comment = drupal_unpack($comment);
 
44
      $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
 
45
      $comment->depth = count(explode('.', $comment->thread)) - 1;
 
46
      $this->comments[$comment->cid] = $comment;
 
47
    }
 
48
  }
 
49
}
 
50