summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-11-15 07:29:47 +0000
committerDries Buytaert <dries@buytaert.net>2005-11-15 07:29:47 +0000
commite900d28640ef030d53aec8c6524ac337e0872073 (patch)
tree51b47cfcd9d5904fb3d5e548e0da75b5cdb5bc10
parent3141d02c2fbbfb1d7684b0de9c3e7adb7f338f3a (diff)
downloadbrdo-e900d28640ef030d53aec8c6524ac337e0872073.tar.gz
brdo-e900d28640ef030d53aec8c6524ac337e0872073.tar.bz2
- Patch #34295 by assimonds: added missing defines to comment.module. Improves
readability of the code.
-rw-r--r--modules/comment.module16
-rw-r--r--modules/comment/comment.module16
2 files changed, 22 insertions, 10 deletions
diff --git a/modules/comment.module b/modules/comment.module
index e25c346de..4c2d65823 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -59,6 +59,12 @@ define('COMMENT_NODE_READ_ONLY', 1);
define('COMMENT_NODE_READ_WRITE', 2);
/**
+ * Constants to define if comment preview is optional or required
+ */
+define('COMMENT_PREVIEW_OPTIONAL', 0);
+define('COMMENT_PREVIEW_REQUIRED', 1);
+
+/**
* Implementation of hook_help().
*/
function comment_help($section) {
@@ -361,7 +367,7 @@ function comment_configure() {
'#description' => t('Can users provide a unique subject for their comments?')
);
- $form['posting_settings']['comment_preview'] = array('#type' => 'radios', '#title' => t('Preview comment'), '#default_value' => variable_get('comment_preview', 1), '#options' => array(t('Optional'), t('Required')));
+ $form['posting_settings']['comment_preview'] = array('#type' => 'radios', '#title' => t('Preview comment'), '#default_value' => variable_get('comment_preview', COMMENT_PREVIEW_REQUIRED), '#options' => array(t('Optional'), t('Required')));
$form['posting_settings']['comment_form_location'] = array(
'#type' => 'radios',
@@ -453,7 +459,7 @@ function comment_reply($nid, $pid = NULL) {
}
// should we show the reply box?
- if (node_comment_mode($nid) != 2) {
+ if (node_comment_mode($nid) != COMMENT_NODE_READ_WRITE) {
drupal_set_message(t("This discussion is closed: you can't post new comments."), 'error');
}
else if (user_access('post comments')) {
@@ -615,7 +621,7 @@ function comment_preview($edit) {
*/
function comment_save($edit) {
global $user;
- if (user_access('post comments') && (user_access('administer coments') || node_comment_mode($edit['nid']) == 2)) {
+ if (user_access('post comments') && (user_access('administer coments') || node_comment_mode($edit['nid']) == COMMENT_NODE_READ_WRITE)) {
if (!form_get_errors()) {
// Check for duplicate comments. Note that we have to use the
// validated/filtered data to perform such check.
@@ -771,7 +777,7 @@ function comment_links($comment, $return = 1) {
$links[] = l(t('parent'), comment_node_url(), NULL, NULL, "comment-$comment->cid");
}
- if (node_comment_mode($comment->nid) == 2) {
+ if (node_comment_mode($comment->nid) == COMMENT_NODE_READ_WRITE) {
if (user_access('administer comments') && user_access('access administration pages')) {
$links[] = l(t('delete'), "comment/delete/$comment->cid");
$links[] = l(t('edit'), "comment/edit/$comment->cid");
@@ -1205,7 +1211,7 @@ function comment_form($edit, $title = NULL) {
// Only show post button if preview is optional or if we are in preview mode.
// We show the post button in preview mode even if there are form errors so that
// optional form elements (e.g., captcha) can be updated in preview mode.
- if ((variable_get('comment_preview', 1) == 0) || ($_POST['op'] == t('Preview comment')) || ($_POST['op'] == t('Post comment'))) {
+ if ((variable_get('comment_preview', COMMENT_PREVIEW_REQUIRED) == COMMENT_PREVIEW_OPTIONAL) || ($_POST['op'] == t('Preview comment')) || ($_POST['op'] == t('Post comment'))) {
$form['submit'] = array('#type' => 'submit', '#value' => t('Post comment'), '#weight' => 20);
}
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index e25c346de..4c2d65823 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -59,6 +59,12 @@ define('COMMENT_NODE_READ_ONLY', 1);
define('COMMENT_NODE_READ_WRITE', 2);
/**
+ * Constants to define if comment preview is optional or required
+ */
+define('COMMENT_PREVIEW_OPTIONAL', 0);
+define('COMMENT_PREVIEW_REQUIRED', 1);
+
+/**
* Implementation of hook_help().
*/
function comment_help($section) {
@@ -361,7 +367,7 @@ function comment_configure() {
'#description' => t('Can users provide a unique subject for their comments?')
);
- $form['posting_settings']['comment_preview'] = array('#type' => 'radios', '#title' => t('Preview comment'), '#default_value' => variable_get('comment_preview', 1), '#options' => array(t('Optional'), t('Required')));
+ $form['posting_settings']['comment_preview'] = array('#type' => 'radios', '#title' => t('Preview comment'), '#default_value' => variable_get('comment_preview', COMMENT_PREVIEW_REQUIRED), '#options' => array(t('Optional'), t('Required')));
$form['posting_settings']['comment_form_location'] = array(
'#type' => 'radios',
@@ -453,7 +459,7 @@ function comment_reply($nid, $pid = NULL) {
}
// should we show the reply box?
- if (node_comment_mode($nid) != 2) {
+ if (node_comment_mode($nid) != COMMENT_NODE_READ_WRITE) {
drupal_set_message(t("This discussion is closed: you can't post new comments."), 'error');
}
else if (user_access('post comments')) {
@@ -615,7 +621,7 @@ function comment_preview($edit) {
*/
function comment_save($edit) {
global $user;
- if (user_access('post comments') && (user_access('administer coments') || node_comment_mode($edit['nid']) == 2)) {
+ if (user_access('post comments') && (user_access('administer coments') || node_comment_mode($edit['nid']) == COMMENT_NODE_READ_WRITE)) {
if (!form_get_errors()) {
// Check for duplicate comments. Note that we have to use the
// validated/filtered data to perform such check.
@@ -771,7 +777,7 @@ function comment_links($comment, $return = 1) {
$links[] = l(t('parent'), comment_node_url(), NULL, NULL, "comment-$comment->cid");
}
- if (node_comment_mode($comment->nid) == 2) {
+ if (node_comment_mode($comment->nid) == COMMENT_NODE_READ_WRITE) {
if (user_access('administer comments') && user_access('access administration pages')) {
$links[] = l(t('delete'), "comment/delete/$comment->cid");
$links[] = l(t('edit'), "comment/edit/$comment->cid");
@@ -1205,7 +1211,7 @@ function comment_form($edit, $title = NULL) {
// Only show post button if preview is optional or if we are in preview mode.
// We show the post button in preview mode even if there are form errors so that
// optional form elements (e.g., captcha) can be updated in preview mode.
- if ((variable_get('comment_preview', 1) == 0) || ($_POST['op'] == t('Preview comment')) || ($_POST['op'] == t('Post comment'))) {
+ if ((variable_get('comment_preview', COMMENT_PREVIEW_REQUIRED) == COMMENT_PREVIEW_OPTIONAL) || ($_POST['op'] == t('Preview comment')) || ($_POST['op'] == t('Post comment'))) {
$form['submit'] = array('#type' => 'submit', '#value' => t('Post comment'), '#weight' => 20);
}