? .project ? sites/all/modules/devel ? sites/default/files ? sites/default/settings.php Index: modules/comment/comment.install =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.install,v retrieving revision 1.36 diff -u -p -r1.36 comment.install --- modules/comment/comment.install 4 Jun 2009 03:33:27 -0000 1.36 +++ modules/comment/comment.install 5 Jun 2009 18:00:15 -0000 @@ -87,7 +87,7 @@ function comment_update_6002() { 'comment_controls' => COMMENT_CONTROLS_HIDDEN, 'comment_anonymous' => COMMENT_ANONYMOUS_MAYNOT_CONTACT, 'comment_subject_field' => 1, - 'comment_preview' => COMMENT_PREVIEW_REQUIRED, + 'comment_preview' => 1, // WAS: deleted constant COMMENT_PREVIEW_REQUIRED = 1. 'comment_form_location' => COMMENT_FORM_SEPARATE_PAGE, ); $types = node_type_get_types(); @@ -152,6 +152,25 @@ function comment_update_7002() { db_rename_table($ret, 'comments', 'comment'); return $ret; } +/** + * Update preview setting variable to use new constants + */ +function comment_update_7003() { + $ret = array(); + $type_list = node_type_get_types(); + + /** + * Upgrade variable on all types. + * 0 used to equal optional + * 1 used to equal required + */ + foreach ($type_list as $type => $object) { + $original_preview = variable_get('comment_preview_' . $type, DRUPAL_REQUIRED); + $original_preview ? $preview = DRUPAL_REQUIRED : $preview = DRUPAL_OPTIONAL; + variable_set('comment_preview_' . $type, $preview); + } + return $ret; +} /** * @} End of "defgroup updates-6.x-to-7.x" Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.719 diff -u -p -r1.719 comment.module --- modules/comment/comment.module 3 Jun 2009 06:52:29 -0000 1.719 +++ modules/comment/comment.module 5 Jun 2009 18:00:16 -0000 @@ -81,16 +81,6 @@ define('COMMENT_NODE_CLOSED', 1); define('COMMENT_NODE_OPEN', 2); /** - * Comment preview is optional. - */ -define('COMMENT_PREVIEW_OPTIONAL', 0); - -/** - * Comment preview is required. - */ -define('COMMENT_PREVIEW_REQUIRED', 1); - -/** * Implement hook_help(). */ function comment_help($path, $arg) { @@ -567,8 +557,12 @@ function comment_form_node_type_form_alt $form['comment']['comment_preview'] = array( '#type' => 'radios', '#title' => t('Preview comment'), - '#default_value' => variable_get('comment_preview_' . $form['#node_type']->type, COMMENT_PREVIEW_REQUIRED), - '#options' => array(t('Optional'), t('Required')), + '#default_value' => variable_get('comment_preview_' . $form['#node_type']->type, DRUPAL_REQUIRED), + '#options' => array( + DRUPAL_DISABLED => t('Disabled'), + DRUPAL_OPTIONAL => t('Optional'), + DRUPAL_REQUIRED => 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( @@ -1629,18 +1623,21 @@ function comment_form(&$form_state, $edi // already previewing the submission. However, if there are form errors, // we hide the save button no matter what, so that optional form elements // (e.g., captchas) can be updated. - if (!form_get_errors() && ((variable_get('comment_preview_' . $node->type, COMMENT_PREVIEW_REQUIRED) == COMMENT_PREVIEW_OPTIONAL) || ($op == t('Preview')) || ($op == t('Save')))) { + if (!form_get_errors() && ((variable_get('comment_preview_' . $node->type, DRUPAL_REQUIRED) != DRUPAL_REQUIRED) || ($op == t('Preview')) || ($op == t('Save')))) { $form['submit'] = array( '#type' => 'submit', '#value' => t('Save'), '#weight' => 19, ); } - $form['preview'] = array( - '#type' => 'button', - '#value' => t('Preview'), - '#weight' => 20, - ); + // Show if not specifically disabled in content type admin. + if (variable_get('comment_preview_' . $node->type, DRUPAL_REQUIRED) != DRUPAL_DISABLED) { + $form['preview'] = array( + '#type' => 'button', + '#value' => t('Preview'), + '#weight' => 20, + ); + } $form['#token'] = 'comment' . $edit['nid'] . (isset($edit['pid']) ? $edit['pid'] : ''); if ($op == t('Preview')) { @@ -1928,7 +1925,7 @@ function template_preprocess_comment_fol $variables['classes_array'][] = 'comment-new'; } } - + } /** Index: modules/search/search.test =================================================================== RCS file: /cvs/drupal/drupal/modules/search/search.test,v retrieving revision 1.21 diff -u -p -r1.21 search.test --- modules/search/search.test 25 May 2009 15:43:38 -0000 1.21 +++ modules/search/search.test 5 Jun 2009 18:00:16 -0000 @@ -458,7 +458,7 @@ class SearchCommentTestCase extends Drup function testSearchResultsComment() { $comment_body = $this->randomName(5); - variable_set('comment_preview_article', COMMENT_PREVIEW_OPTIONAL); + variable_set('comment_preview_article', DRUPAL_OPTIONAL); // Enable check_plain() for 'Filtered HTML' text format. $edit = array( 'filters[filter/4]' => 1,