Index: modules/comment/comment.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.admin.inc,v
retrieving revision 1.31
diff -u -p -r1.31 comment.admin.inc
--- modules/comment/comment.admin.inc 25 Aug 2009 10:27:14 -0000 1.31
+++ modules/comment/comment.admin.inc 3 Sep 2009 11:26:03 -0000
@@ -59,7 +59,6 @@ function comment_admin_overview($type =
// Load the comments that need to be displayed.
$status = ($arg == 'approval') ? COMMENT_NOT_PUBLISHED : COMMENT_PUBLISHED;
$header = array(
- 'subject' => array('data' => t('Subject'), 'field' => 'subject'),
'author' => array('data' => t('Author'), 'field' => 'name'),
'posted_in' => array('data' => t('Posted in'), 'field' => 'node_title'),
'time' => array('data' => t('Time'), 'field' => 'timestamp', 'sort' => 'desc'),
@@ -86,9 +85,8 @@ function comment_admin_overview($type =
foreach ($result as $comment) {
$options[$comment->cid] = array(
- 'subject' => l($comment->subject, 'comment/' . $comment->cid, array('attributes' => array('title' => truncate_utf8($comment->comment, 128)), 'fragment' => 'comment-' . $comment->cid)),
'author' => theme('username', $comment),
- 'posted_in' => l($comment->node_title, 'node/' . $comment->nid),
+ 'posted_in' => l($comment->node_title, 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid)),
'time' => format_date($comment->timestamp, 'short'),
'operations' => l(t('edit'), 'comment/edit/' . $comment->cid, array('query' => $destination)),
);
@@ -140,7 +138,7 @@ function comment_admin_overview_submit($
// Allow modules to respond to the updating of a comment.
module_invoke_all('comment_' . $form_state['values']['operation'], $comment);
// Add an entry to the watchdog log.
- watchdog('content', 'Comment: updated %subject.', array('%subject' => $comment->subject), WATCHDOG_NOTICE, l(t('view'), 'node/' . $comment->nid, array('fragment' => 'comment-' . $comment->cid)));
+ watchdog('content', 'Comment: updated %cid.', array('%cid' => $comment->cid), WATCHDOG_NOTICE, l(t('view'), 'node/' . $comment->nid, array('fragment' => 'comment-' . $comment->cid)));
}
}
cache_clear_all();
@@ -237,7 +235,7 @@ function comment_confirm_delete(&$form_s
$form['#comment'] = $comment;
return confirm_form(
$form,
- t('Are you sure you want to delete the comment %title?', array('%title' => $comment->subject)),
+ t('Are you sure you want to delete the comment by %name', array('%name' => $comment->name)),
'node/' . $comment->nid,
t('Any replies to this comment will be lost. This action cannot be undone.'),
t('Delete'),
Index: modules/comment/comment.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.install,v
retrieving revision 1.44
diff -u -p -r1.44 comment.install
--- modules/comment/comment.install 9 Aug 2009 02:46:27 -0000 1.44
+++ modules/comment/comment.install 3 Sep 2009 11:26:03 -0000
@@ -12,6 +12,31 @@
function comment_install() {
// Create tables.
drupal_install_schema('comment');
+
+ // Create comment body field.
+ $field = array(
+ 'field_name' => 'comment_body',
+ 'type' => 'text_long',
+ );
+ field_create_field($field);
+
+ // Attach the body field to all existing comment bundles.
+ $instance = array(
+ 'label' => 'Body',
+ 'field_name' => 'comment_body',
+ 'settings' => array('text_processing' => 1),
+ );
+ foreach (node_type_get_types() as $info) {
+ $instance['bundle'] = 'comment_node_' . $info->type;
+ field_create_instance($instance);
+ }
+
+ // Create comment subject field.
+ $field = array(
+ 'field_name' => 'comment_subject',
+ 'type' => 'text',
+ );
+ field_create_field($field);
}
/**
@@ -21,6 +46,15 @@ function comment_uninstall() {
// Remove tables.
drupal_uninstall_schema('comment');
+ // @TODO do we need to check if any non-comment bundle has these fields
+ // assigned before deleting? If so, what happens then?
+
+ // Delete comment_body field.
+ field_delete_field('comment_body');
+
+ // Delete comment_subject field.
+ field_delete_field('comment_subject');
+
// Remove variables.
variable_del('comment_block_count');
$node_types = array_keys(node_type_get_types());
@@ -160,6 +194,55 @@ function comment_update_7006() {
}
/**
+ * Create the comment_body and comment_subject fields.
+ */
+function comment_update_7007() {
+ // Create comment body field.
+ $field = array(
+ 'field_name' => 'comment_body',
+ 'type' => 'text_long',
+ );
+ field_create_field($field);
+
+ // Create comment_subject field.
+ $field = array(
+ 'field_name' => 'comment_subject',
+ 'type' => 'text',
+ );
+ field_create_field($field);
+
+ // Add the fields to comments for all existing bundles.
+ $body_instance = array(
+ 'field_name' => 'comment_body',
+ 'label' => 'Body',
+ 'settings' => array('text_processing' => 1),
+ );
+ $subject_instance = array(
+ 'field_name' => 'comment_subject',
+ 'label' => 'Subject',
+ );
+ foreach (node_type_get_types() as $info) {
+ $body_instance['bundle'] = 'comment_node_' . $info->type;
+ field_create_instance($body_instance);
+
+ // Only create the subject field if it is enabled for this content type.
+ if (variable_get('comment_subject_field_' . $info->type, TRUE)) {
+ $subject_instance['bundle'] = 'comment_node_' . $info->type;
+ field_create_instance($subject_instance);
+ variable_del('comment_subject_field_' . $info->type);
+ }
+ }
+ return array();
+}
+
+/**
+ * Migrate comment body and subject data to field tables.
+ */
+function comment_update_7008() {
+ // @todo- probably an INSERT INTO SELECT FROM.
+}
+
+/**
* @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000.
*/
@@ -194,19 +277,6 @@ function comment_schema() {
'default' => 0,
'description' => 'The {users}.uid who authored the comment. If set to 0, this comment was created by an anonymous user.',
),
- 'subject' => array(
- 'type' => 'varchar',
- 'length' => 64,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'The comment title.',
- ),
- 'comment' => array(
- 'type' => 'text',
- 'not null' => TRUE,
- 'size' => 'big',
- 'description' => 'The comment body.',
- ),
'hostname' => array(
'type' => 'varchar',
'length' => 128,
@@ -228,13 +298,6 @@ function comment_schema() {
'size' => 'tiny',
'description' => 'The published status of a comment. (0 = Not Published, 1 = Published)',
),
- 'format' => array(
- 'type' => 'int',
- 'size' => 'small',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'The {filter_format}.format of the comment body.',
- ),
'thread' => array(
'type' => 'varchar',
'length' => 255,
@@ -321,4 +384,4 @@ function comment_schema() {
);
return $schema;
-}
\ No newline at end of file
+}
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.765
diff -u -p -r1.765 comment.module
--- modules/comment/comment.module 29 Aug 2009 10:46:40 -0000 1.765
+++ modules/comment/comment.module 3 Sep 2009 11:26:04 -0000
@@ -223,6 +223,15 @@ function comment_menu() {
*/
function comment_node_type_insert($info) {
field_attach_create_bundle('comment_node_' . $info->type);
+
+ // Attach the body field by default.
+ $instance = array(
+ 'field_name' => 'comment_body',
+ 'label' =>'body',
+ 'bundle' => 'comment_node_' . $info->type,
+ 'settings' => array('text_processing' => 1),
+ );
+ field_create_instance($instance);
}
/**
@@ -244,7 +253,6 @@ function comment_node_type_delete($info)
'comment_default_mode',
'comment_default_per_page',
'comment_anonymous',
- 'comment_subject_field',
'comment_preview',
'comment_form_location',
);
@@ -387,11 +395,14 @@ function comment_get_recent($number = 10
// Using Query Builder here for the IN-Statement.
$query = db_select('comment', 'c');
$query->innerJoin('node', 'n', 'n.nid = c.nid');
+ $query->innerJoin('users', 'u', 'u.uid = c.uid');
+ $query->addField('n', 'title', 'node_title');
return $query
- ->fields('c', array('nid', 'subject', 'cid', 'timestamp'))
+ ->fields('c', array('nid', 'cid', 'uid', 'timestamp'))
->condition('c.nid', $nids, 'IN')
->condition('c.status', COMMENT_PUBLISHED)
->condition('n.status', 1)
+ ->addExpression('IF(c.uid != 0, u.name, c.name)', 'name')
->orderBy('c.cid', 'DESC')
->range(0, $number)
->execute()
@@ -461,8 +472,9 @@ function comment_new_page_count($num_com
function theme_comment_block() {
$items = array();
$number = variable_get('comment_block_count', 10);
+
foreach (comment_get_recent($number) as $comment) {
- $items[] = l($comment->subject, 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid)) . '
' . t('@time ago', array('@time' => format_interval(REQUEST_TIME - $comment->timestamp)));
+ $items[] = theme('username', $comment) . t('on') . l($comment->node_title, 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid)). '
' . t('@time ago', array('@time' => format_interval(REQUEST_TIME, $comment->timestamp)));
}
if ($items) {
@@ -821,11 +833,6 @@ function comment_build_content($comment,
$comment->content = array();
}
- // Build comment body.
- $comment->content['comment_body'] = array(
- '#markup' => check_markup($comment->comment, $comment->format),
- );
-
$comment->content += field_attach_view('comment', $comment, $build_mode);
if (empty($comment->in_preview)) {
@@ -975,11 +982,6 @@ function comment_form_node_type_form_alt
$form['comment']['comment_anonymous']['#access'] = FALSE;
}
- $form['comment']['comment_subject_field'] = array(
- '#type' => 'checkbox',
- '#title' => t('Allow comment title'),
- '#default_value' => variable_get('comment_subject_field_' . $form['#node_type']->type, 1),
- );
$form['comment']['comment_form_location'] = array(
'#type' => 'checkbox',
'#title' => t('Show reply form on the same page as comments'),
@@ -1128,17 +1130,7 @@ function comment_node_delete($node) {
* Implement hook_node_update_index().
*/
function comment_node_update_index($node) {
- $text = '';
- if ($node->comment != COMMENT_NODE_HIDDEN) {
- $comments = db_query('SELECT subject, comment, format FROM {comment} WHERE nid = :nid AND status = :status', array(
- ':nid' => $node->nid,
- ':status' => COMMENT_PUBLISHED
- ));
- foreach ($comments as $comment) {
- $text .= '