Index: modules/comment/comment.install =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.install,v retrieving revision 1.39 diff -u -p -r1.39 comment.install --- modules/comment/comment.install 22 Jun 2009 13:21:37 -0000 1.39 +++ modules/comment/comment.install 30 Jun 2009 13:22:24 -0000 @@ -110,6 +110,23 @@ function comment_update_7003() { } /** + * Rename comment display setting variables. + */ +function comment_update_7004() { + $types = node_type_get_types(); + foreach ($types as $type => $object) { + $setting = variable_get('comment_default_mode_' . $type, 4); + if ($setting == 3 || $setting == 4) { + variable_set('comment_default_mode_' . $type, 1); + } + else { + variable_set('comment_default_mode_' . $type, 0); + } + } + return array(); +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.730 diff -u -p -r1.730 comment.module --- modules/comment/comment.module 30 Jun 2009 09:57:57 -0000 1.730 +++ modules/comment/comment.module 30 Jun 2009 13:22:25 -0000 @@ -21,24 +21,14 @@ define('COMMENT_NOT_PUBLISHED', 0); define('COMMENT_PUBLISHED', 1); /** - * Comments are displayed in a flat list - collapsed. - */ -define('COMMENT_MODE_FLAT_COLLAPSED', 1); - -/** * Comments are displayed in a flat list - expanded. */ -define('COMMENT_MODE_FLAT_EXPANDED', 2); - -/** - * Comments are displayed as a threaded list - collapsed. - */ -define('COMMENT_MODE_THREADED_COLLAPSED', 3); +define('COMMENT_MODE_FLAT', 0); /** * Comments are displayed as a threaded list - expanded. */ -define('COMMENT_MODE_THREADED_EXPANDED', 4); +define('COMMENT_MODE_THREADED', 1); /** * Anonymous posters cannot enter their contact information. @@ -130,15 +120,9 @@ function comment_theme() { 'template' => 'comment-folded', 'arguments' => array('comment' => NULL, 'node' => NULL), ), - 'comment_flat_collapsed' => array( - 'arguments' => array('comment' => NULL, 'node' => NULL), - ), 'comment_flat_expanded' => array( 'arguments' => array('comment' => NULL, 'node' => NULL), ), - 'comment_thread_collapsed' => array( - 'arguments' => array('comment' => NULL, 'node' => NULL), - ), 'comment_thread_expanded' => array( 'arguments' => array('comment' => NULL, 'node' => NULL), ), @@ -404,7 +388,7 @@ function comment_new_page_count($num_com $comments_per_page = _comment_get_display_setting('comments_per_page', $node); $mode = _comment_get_display_setting('mode', $node); $pagenum = NULL; - $flat = in_array($mode, array(COMMENT_MODE_FLAT_COLLAPSED, COMMENT_MODE_FLAT_EXPANDED)); + $flat = $mode == COMMENT_MODE_FLAT ? TRUE : FALSE; if ($num_comments <= $comments_per_page) { // Only one page of comments. $pageno = 0; @@ -569,61 +553,54 @@ function comment_form_node_type_form_alt '#collapsible' => TRUE, '#collapsed' => TRUE, ); - $form['comment']['comment'] = array( - '#type' => 'radios', - '#title' => t('Default comment setting'), - '#default_value' => variable_get('comment_' . $form['#node_type']->type, COMMENT_NODE_OPEN), - '#options' => array(t('Hidden'), t('Closed'), t('Open')), - '#description' => t('Users with the administer comments permission will be able to override this setting.'), - ); $form['comment']['comment_default_mode'] = array( - '#type' => 'radios', - '#title' => t('Default display mode'), - '#default_value' => variable_get('comment_default_mode_' . $form['#node_type']->type, COMMENT_MODE_THREADED_EXPANDED), - '#options' => _comment_get_modes(), - '#description' => t('Expanded views display the body of the comment. Threaded views keep replies together.'), + '#type' => 'checkbox', + '#title' => t('Threading'), + '#default_value' => variable_get('comment_default_mode_' . $form['#node_type']->type, COMMENT_MODE_THREADED), + '#description' => t('Show comment replies in a threaded list.'), ); $form['comment']['comment_default_per_page'] = array( '#type' => 'select', '#title' => t('Comments per page'), '#default_value' => variable_get('comment_default_per_page_' . $form['#node_type']->type, 50), '#options' => _comment_per_page(), - '#description' => t('Additional comments will be displayed on separate pages.'), + ); + + $form['comment']['comment'] = array( + '#type' => 'select', + '#title' => t('Default comment setting'), + '#default_value' => variable_get('comment_' . $form['#node_type']->type, COMMENT_NODE_OPEN), + '#options' => array(t('Hidden'), t('Closed'), t('Open')), + '#description' => t('Users with the administer comments permission will be able to override this setting.'), ); $form['comment']['comment_anonymous'] = array( - '#type' => 'radios', + '#type' => 'select', '#title' => t('Anonymous commenting'), '#default_value' => variable_get('comment_anonymous_' . $form['#node_type']->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT), '#options' => array( COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'), COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'), COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information')), - '#description' => t('This option is enabled when anonymous users have permission to post comments on the permissions page.', array('@url' => url('admin/user/permissions', array('fragment' => 'module-comment')))), ); if (!user_access('post comments', drupal_anonymous_user())) { - $form['comment']['comment_anonymous']['#disabled'] = TRUE; + $form['comment']['comment_anonymous']['#access'] = FALSE; } $form['comment']['comment_subject_field'] = array( - '#type' => 'radios', + '#type' => 'checkbox', '#title' => t('Comment subject field'), '#default_value' => variable_get('comment_subject_field_' . $form['#node_type']->type, 1), - '#options' => array(t('Disabled'), t('Enabled')), - '#description' => t('Can users provide a unique subject for their comments?'), ); $form['comment']['comment_preview'] = array( - '#type' => 'radios', - '#title' => t('Preview comment'), + '#type' => 'checkbox', + '#title' => t('Require preview'), '#default_value' => variable_get('comment_preview_' . $form['#node_type']->type, COMMENT_PREVIEW_REQUIRED), - '#options' => array(t('Optional'), t('Required')), - '#description' => t("Forces a user to look at their comment by clicking on a 'Preview' button before they can actually add the comment"), ); $form['comment']['comment_form_location'] = array( - '#type' => 'radios', - '#title' => t('Location of comment submission form'), + '#type' => 'checkbox', + '#title' => t('Quick reply form'), '#default_value' => variable_get('comment_form_location_' . $form['#node_type']->type, COMMENT_FORM_SEPARATE_PAGE), - '#options' => array(t('Display on separate page'), t('Display below post or comments')), ); } } @@ -1196,7 +1173,7 @@ function comment_render($node, $cid = 0) $query->condition('c.status', COMMENT_PUBLISHED); $count_query->condition('c.status', COMMENT_PUBLISHED); } - if ($mode === COMMENT_MODE_FLAT_COLLAPSED || $mode === COMMENT_MODE_FLAT_EXPANDED) { + if ($mode === COMMENT_MODE_FLAT) { $query->orderBy('c.cid', 'ASC'); } else { @@ -1218,7 +1195,7 @@ function comment_render($node, $cid = 0) $comment->name = $comment->uid ? $comment->registered_name : $comment->name; $comment->depth = count(explode('.', $comment->thread)) - 1; - if ($mode == COMMENT_MODE_THREADED_COLLAPSED || $mode == COMMENT_MODE_THREADED_EXPANDED) { + if ($mode == COMMENT_MODE_THREADED) { if ($comment->depth > $divs) { $divs++; $comments .= '
'; @@ -1231,16 +1208,10 @@ function comment_render($node, $cid = 0) } } - if ($mode == COMMENT_MODE_FLAT_COLLAPSED) { - $comments .= theme('comment_flat_collapsed', $comment, $node); - } - elseif ($mode == COMMENT_MODE_FLAT_EXPANDED) { + if ($mode == COMMENT_MODE_FLAT) { $comments .= theme('comment_flat_expanded', $comment, $node); } - elseif ($mode == COMMENT_MODE_THREADED_COLLAPSED) { - $comments .= theme('comment_thread_collapsed', $comment, $node); - } - elseif ($mode == COMMENT_MODE_THREADED_EXPANDED) { + elseif ($mode == COMMENT_MODE_THREADED) { $comments .= theme('comment_thread_expanded', $comment, $node); } $num_rows = TRUE; @@ -1392,9 +1363,9 @@ function comment_get_display_ordinal($ci if (!user_access('administer comments')) { $query->condition('c1.status', COMMENT_PUBLISHED); } - $mode = variable_get('comment_default_mode_' . $node_type, COMMENT_MODE_THREADED_EXPANDED); + $mode = variable_get('comment_default_mode_' . $node_type, COMMENT_MODE_THREADED); - if ($mode == COMMENT_MODE_FLAT_EXPANDED || $mode == COMMENT_MODE_FLAT_COLLAPSED) { + if ($mode == COMMENT_MODE_FLAT) { // For flat comments, cid is used for ordering comments due to // unpredicatable behavior with timestamp, so we make the same assumption // here. @@ -2017,19 +1988,6 @@ function template_preprocess_comment_fol } /** - * Theme comment flat collapsed view. - * - * @param $comment - * The comment to be themed. - * @param $node - * The comment node. - * @ingroup themeable - */ -function theme_comment_flat_collapsed($comment, $node) { - return theme('comment_view', $comment, $node, '', 0); -} - -/** * Theme comment flat expanded view. * * @param $comment @@ -2043,19 +2001,6 @@ function theme_comment_flat_expanded($co } /** - * Theme comment thread collapsed view. - * - * @param $comment - * The comment to be themed. - * @param $node - * The comment node. - * @ingroup themeable - */ -function theme_comment_thread_collapsed($comment, $node) { - return theme('comment_view', $comment, $node, '', 0); -} - -/** * Theme comment thread expanded view. * * @param $comment @@ -2140,10 +2085,8 @@ function theme_comment_submitted($commen */ function _comment_get_modes() { return array( - COMMENT_MODE_FLAT_COLLAPSED => t('Flat list - collapsed'), - COMMENT_MODE_FLAT_EXPANDED => t('Flat list - expanded'), - COMMENT_MODE_THREADED_COLLAPSED => t('Threaded list - collapsed'), - COMMENT_MODE_THREADED_EXPANDED => t('Threaded list - expanded') + COMMENT_MODE_FLAT => t('Flat list'), + COMMENT_MODE_THREADED => t('Threaded list') ); } @@ -2166,7 +2109,7 @@ function _comment_per_page() { function _comment_get_display_setting($setting, $node) { switch ($setting) { case 'mode': - $value = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED_EXPANDED); + $value = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED); break; case 'comments_per_page': Index: modules/comment/comment.test =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.test,v retrieving revision 1.34 diff -u -p -r1.34 comment.test --- modules/comment/comment.test 27 Jun 2009 10:13:28 -0000 1.34 +++ modules/comment/comment.test 30 Jun 2009 13:22:26 -0000 @@ -248,7 +248,7 @@ class CommentInterfaceTest extends Comme $this->setCommentPreview(TRUE); $this->setCommentForm(TRUE); $this->setCommentSubject(FALSE); - $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED_EXPANDED, t('Comment paging changed.')); + $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.')); $this->drupalLogout(); // Post comment without subject. @@ -496,7 +496,7 @@ class CommentPagerTest extends CommentHe $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), FALSE, TRUE); $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), FALSE, TRUE); - $this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT_EXPANDED, t('Comment paging changed.')); + $this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, t('Comment paging changed.')); // Set comments to one per page so that we are able to test paging without // needing to insert large numbers of comments. @@ -537,7 +537,7 @@ class CommentPagerTest extends CommentHe // If we switch to threaded mode, the replies on the oldest comment // should be bumped to the first page and comment 6 should be bumped // to the second page. - $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED_EXPANDED, t('Switched to threaded mode.')); + $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Switched to threaded mode.')); $this->drupalGet('node/' . $node->nid, array('query' => 'page=0')); $this->assertTrue($this->commentExists($reply, TRUE), t('In threaded mode, reply appears on page 1.')); $this->assertFalse($this->commentExists($comments[1]), t('In threaded mode, comment 2 has been bumped off of page 1.'));