summaryrefslogtreecommitdiff
path: root/modules/comment/comment.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/comment/comment.module')
-rw-r--r--modules/comment/comment.module180
1 files changed, 90 insertions, 90 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 7aba64229..66667bf68 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -4,71 +4,76 @@
$GLOBALS["cmodes"] = array(1 => t("Flat list - collapsed"), 2 => t("Flat list - expanded"), 3 => t("Threaded list - collapsed"), 4 => t("Threaded list - expanded"));
$GLOBALS["corder"] = array(1 => t("Date - newest first"), 2 => t("Date - oldest first"));
-function comment_help() {
- $output .= t("<p>When enabled, the Drupal comment module creates a discussion board for each Drupal node. Users can post comments to discuss a forum topic, weblog post, collaborative book page, etc.</p>
-
-<h3>User control of comment display</h3>
-<p>Attached to each comment board is a control panel for customizing the way that comments are displayed. Users can control the chronological ordering of posts (newest or oldest first) and the number of posts to display on each page. Additional settings include:</p>
-<ul>
- <li><b>Threaded </b>-- Comment posts are displayed much like the subject view of an email client: the posts are grouped according to the conversations and subconversations.</li>
- <li><b>Flat </b>-- Displays the posts in chronological order, in the order in which they are posted.</li>
- <li><b>Expanded </b>-- Displays the title and text for each post.</li>
- <li><b>Collapsed</b> -- Displays only the title for each post.</li>
-</ul>
-<p>When users choose <i>save settings</i>, the comments are then redisplayed with the user's choices. Know that administrators can set the default settings for the control panel, along with other comment configuration defaults, in <i>site configuration &raquo; modules &raquo; comment</i>.</p>
-<p>NOTE: When comment moderation is enabled, users will have another control panel option to control thresholds (see below).</p>
-
-<h3>Additional comment configurations</h3>
-<p>Comments behave like other user submissions in Drupal. Filters, smileys and HTML that work in nodes will also work with content. To prevent a single user from spamming the web site with too many comments, administrators can set a comment throttle in <i>site configuration</i> under <i>Submission settings</i>.</p>
-<p>Administrators can control access to various comment module functions through <i>user management &raquo; user permissions</i>. Know that in a new Drupal installation, all comment permissions are disabled by default. The choice of which permissions to grant to which roles (groups of users) is left up to the site administrator.</p>
-<p>The following permissions can be enabled for anonymous users, authenticated users, or any other roles that the administrator chooses to define:</p>
-<ul>
- <li><b>Access comments</b> -- Necessary for users to view comments.</li>
- <li><b>Administrate comments</b> -- Gives the user complete control over configuring, editing and deleting all comments on the site. Best reserved for very trusted users.</li>
- <li><b>Moderate comments</b> -- Users with this permission can rate comment postings (see more on moderation below).</li>
- <li><b>Post comments</b> -- Allows users to post comments into an administrator moderation queue. Administrators then post the comment to the site. </li>
- <li><b>Post comments without approval</b> -- Bypasses the administrator moderation queue and comments are posted directly.</li>
-</ul>
-
-<h3>Notification of new comments</h3>
-<p>Drupal provides specific features to inform site members when new comments have been posted:</p>
-<ul>
- <li>On the home page, Drupal displays the total number of comments along with each node. Drupal also tracks comments read by individual site members. Logged in members will see a notice accompanying nodes containing comments which they have not read.</li>
- <li>The <i>tracker</i> module displays all recent posts on the site (note that the tracker module is disabled by default). When logged in, members will find a <i>view recent posts </i>in their user information block with a link to the <i>Recent activity</i> page. This page is a useful way to browse new or updated nodes and comments. Content which the user has not yet read is tagged with a red star (this graphic may depend on the current theme). Visit the comment board for any node, and Drupal will display a red <i>new</i> label beside the text of unread comments.</li>
- <li>Some administrators may want to <a href=\"http://drupal.org/node/view/68\">download</a>, install and configure the notify module. Users can then request that Drupal send them an email when new comments are posted (the notify module requires that cron.php be configured properly).</li>
-</ul>
-
-<h3>Comment moderation</h3>
-<p>On sites with active commenting from users, the administrator can turn over comment moderation to the community. </p>
-<p>With comment moderation, each comment is automatically assigned an initial rating. As users read comments, they can apply a vote which affects the comment rating. At the same time, users have an additional option in the control panel which allows them to set a threshold for comment display. Those comments with ratings lower than the set threshold will not appear.</p>
-<p>To enable moderation, the administrator must grant <i>moderate comments</i> permissions. Then, a number of options in <i>comment management &raquo; comment moderation</i> must be configured.</p>
-
-<h4>Moderation votes</h4>
-<p>The first step is to create moderation labels which allow users to rate a comment. Go to <i>comment management &raquo; comment moderation &raquo; votes</i>. In the <i>vote</i> field, enter the textual labels which users will see when casting their votes. Some examples might be</p>
-<ul>
- <li>Excellent +3</li>
- <li>Insightful +2</li>
- <li>Caught My Attention +1</li>
- <li>Useful +1</li>
- <li>Redundant -1</li>
- <li>Flame -3</li>
-</ul>
-<p>So that users know how there votes affect the comment, these examples include the vote value as part of the label, although that is optional.</p>
-<p>Using the weight option, you can control the order in which the votes appear to users. Setting the weight heavier (positive numbers) will make the vote label appear at the bottom of the list. Lighter (a negative number) will push it to the top. To encourage positive voting, a useful order might be higher values, positive votes, at the top, with negative votes at the bottom.</p>
-
-<h4>Moderators/vote values matrix</h4>
-
-<p> Next go to <i>comment management &raquo; comment moderation &raquo; matrix</i>. Enter vote values for each of the labels in the matrix with each permission role. The values entered here will be used to create the rating for each comment.</p>
-<p>NOTE: Comment ratings are calculated by averaging user votes with the initial rating.</p>
-<h4>Creating comment thresholds</h4>
+function comment_help($section = "admin/comment/help") {
+ $output = "";
+
+ switch ($section) {
+ case 'admin/help':
+ case 'admin/comment/help':
+ $output .= "<p>When enabled, the Drupal comment module creates a discussion board for each Drupal node. Users can post comments to discuss a forum topic, weblog post, collaborative book page, etc.</p>";
+ $output .= "<h3>User control of comment display</h3>";
+ $output .= "<p>Attached to each comment board is a control panel for customizing the way that comments are displayed. Users can control the chronological ordering of posts (newest or oldest first) and the number of posts to display on each page. Additional settings include:</p>";
+ $output .= "<ul>";
+ $output .= "<li><b>Threaded</b> -- Displays the posts grouped according to conversations and subconversations, much like the subject view of an email client.</li>";
+ $output .= "<li><b>Flat</b> -- Displays the posts in chronological order, in the order in which they are posted.</li>";
+ $output .= "<li><b>Expanded</b> -- Displays the title and text for each post.</li>";
+ $output .= "<li><b>Collapsed</b> -- Displays only the title for each post.</li>";
+ $output .= "</ul>";
+ $output .= strtr("<p>When a user chooses <i>save settings</i>, the comments are then redisplayed using the user's new choices. Administrators can set the default settings for the comment control panel, along with other comment defaults, in %comment-config.</p>",array("%comment-config" => l(t("site configuration &raquo; modules &raquo; comment"), "admin/system/modules/comment") ));
+ $output .= "<p>NOTE: When comment moderation is enabled, users will have another control panel option to control thresholds (see below).</p>";
+
+ $output .= "<h3>Additional comment configurations</h3>";
+ $output .= strtr("<p>Comments behave like other user submissions in Drupal. Filters, smileys and HTML that work in nodes will also work with content. To prevent a single user from spamming the web site with too many comments, administrators can set a comment throttle in %site-config under <i>Submission settings</i>.</p>", array("%site-config" => l(t("site configuration"), "admin/system") ));
+ $output .= strtr("<p>Administrators can control access to various comment module functions through %user-permissions. Know that in a new Drupal installation, all comment permissions are disabled by default. The choice of which permissions to grant to which roles (groups of users) is left up to the site administrator.</p>", array("%user-permissions" => l(t("user management &raquo; user permissions"), "admin/user/permission") ));
+ $output .= "<p>The following permissions can be enabled for anonymous users, authenticated users, or any other user roles that the administrator chooses to define:</p>";
+ $output .= "<ul>";
+ $output .= "<li><b>Access comments</b> -- Allows users to view comments.</li>";
+ $output .= "<li><b>Administrate comments</b> -- Allows users complete control over configuring, editing and deleting all comments on the site. Best reserved for <b>very</b> trusted users.</li>";
+ $output .= "<li><b>Moderate comments</b> -- Allows users to rate comment postings (see more on moderation below).</li>";
+ $output .= "<li><b>Post comments</b> -- Allows users to post comments into an administrator moderation queue. Administrators then post the comment to the site.</li>";
+ $output .= "<li><b>Post comments without approval</b> -- Allows users to directly post comments. This bypasses the administrator moderation queue.</li>";
+ $output .= "</ul>";
+
+ $output .= "<h3>Notification of new comments</h3>";
+ $output .= "<p>Drupal provides specific features to inform site members when new comments have been posted:</p>";
+ $output .= "<ul>";
+ $output .= "<li>On the home page, Drupal displays the total number of comments attached to each node, and tracks comments read by individual site members. Members which have logged in will see a notice accompanying nodes which contain comments that they have not read.</li>";
+ $output .= strtr("<li>The <i>tracker</i> module, disabled by default, displays all the site's recent posts. When logged in, members will find a %tracker in their user information block with a link to the %tracker-recent page. This page is a useful way to browse new or updated nodes and comments. Content which the user has not yet read is tagged with a red star (this graphic depends on the current theme). Visit the comment board for any node, and Drupal will display a red <i>new</i> label beside the text of unread comments.</li>",array("%tracker" => l(t("view recent posts"), "tracker"), "%tracker-recent" => l(t("Recent activity"), "tracker") ));
+ $output .= strtr("<li>Some administrators may want to %download-notify, install and configure the notify module. Users can then request that Drupal send them an email when new comments are posted (the notify module requires that cron.php be configured properly).</li>", array("%download-notify" => l(t("download"), "drupal.org/node/view/68", array("location" => "global")) ));
+ $output .= "</ul>";
+
+ $output .= "<h3>Comment moderation</h3>";
+ $output .= "<p>On sites with active commenting from users, the administrator can turn over comment moderation to the community. </p>";
+ $output .= "<p>With comment moderation, each comment is automatically assigned an initial rating. As users read comments, they can apply a vote which affects the comment rating. At the same time, users have an additional option in the control panel which allows them to set a threshold for the comments they wish to view. Those comments with ratings lower than the set threshold will not be shown.</p>";
+ $output .= strtr("<p>To enable moderation, the administrator must grant %permission permissions. Then, a number of options in %comment-moderation must be configured.</p>", array("%permission" => l(t("moderate comments"), "admin/user/permissions"), "%comment-moderation" => l(t("comment management &raquo; comment moderation"), "admin/comment/moderation") ));
+
+ $output .= "<h4>Moderation votes</h4>";
+ $output .= strtr("<p>The first step is to create moderation labels which allow users to rate a comment. Go to %comment-votes. In the <i>vote</i> field, enter the textual labels which users will see when casting their votes. Some examples are</p>", array("%comment-votes" => l(t("comment management &raquo; comment moderation &raquo; votes"), "admin/comment/moderation/votes") ));
+ $output .= "<ul>";
+ $output .= "<li>Excellent +3</li>";
+ $output .= "<li>Insightful +2</li>";
+ $output .= "<li>Caught My Attention +1</li>";
+ $output .= "<li>Useful +1</li>";
+ $output .= "<li>Redundant -1</li>";
+ $output .= "<li>Flame -3</li>";
+ $output .= "</ul>";
+ $output .= "<p>So that users know how their votes affect the comment, these examples include the vote value as part of the label, although that is optional.</p>";
+ $output .= "<p>Using the weight option, you can control the order in which the votes appear to users. Setting the weight heavier (positive numbers) will make the vote label appear at the bottom of the list. Lighter (a negative number) will push it to the top. To encourage positive voting, a useful order might be higher values, positive votes, at the top, with negative votes at the bottom.</p>";
+
+ $output .= "<h4>Moderators/vote values matrix</h4>";
+
+ $output .= strtr("<p>Next go to %comment-matrix. Enter the values for the vote labels for each permission role in the vote matrix. The values entered here will be used to create the rating for each comment.</p>", array("%comment-matrix" => l(t("comment management &raquo; comment moderation &raquo; matrix"), "admin/comment/moderation/,atrix") ));
+ $output .= "<p>NOTE: Comment ratings are calculated by averaging user votes with the initial rating.</p>";
+ $output .= "<h4>Creating comment thresholds</h4>
<p>In <i>comment management &raquo; comment moderation &raquo; thresholds</i>, you'll have to create some comment thresholds to make the comment rating system useful. When comment moderation is enabled and the thresholds are created, users will find another comment control panel option for selecting thresholds. They'll use the thresholds you enter here to filter out comments with low ratings. Consequently, you'll probably want to create more than one threshold to give users some flexibility in filtering comments.</p>
<p>When creating the thresholds, note that the <i>Minimum score</i> is asking you for the lowest rating that a comment can have in order to be displayed.</p>
<p>To see a common example of how thresholds work, you might visit <a href=\"http://slashdot.org/\">Slashdot</a> and view one of their comment boards associated with a story. You can reset the thresholds in their comment control panel.</p>
<h4>Initial comment scores</h4>
-<p>Finally, you may want to enter some <i>initial comment scores</i>. In <i>comment management &raquo; initial comment scores </i>you can assign a beginning rating for all comments posted by a particular permission role. If you do not assign any initial scores, Drupal will assign a rating of <b>0</b> as the default.</p>");
-
- return $output;
+<p>Finally, you may want to enter some <i>initial comment scores</i>. In <i>comment management &raquo; initial comment scores </i>you can assign a beginning rating for all comments posted by a particular permission role. If you do not assign any initial scores, Drupal will assign a rating of <b>0</b> as the default.</p>";
+ break;
+ }
+ return t($output);
}
function comment_system($field) {
@@ -1226,6 +1231,11 @@ function comment_moderation_form($comment) {
}
}
+ if (user_access("administer comments")) {
+ $options .= " <option value=\"\">". t("---") ."</option>\n";
+ $options .= " <option value=\"offline\">". t("unpublish") ."</option>\n";
+ }
+
$output .= "<select name=\"moderation[$comment->cid]\">$options</select>\n";
}
@@ -1325,7 +1335,9 @@ function comment_visible($comment, $threshold = 0) {
}
function comment_moderate() {
- global $moderation, $user;
+ global $user;
+
+ $moderation = $_POST["moderation"];
if ($moderation) {
$result = db_query("SELECT mid, value FROM {moderation_roles} WHERE rid = %d", $user->rid);
@@ -1338,40 +1350,28 @@ function comment_moderate() {
if (user_access("administer comments") || comment_user_can_moderate($node)) {
foreach ($moderation as $cid => $vote) {
if ($vote) {
- if (($vote == 'offline') && (user_access("administer comments"))) {
- db_query("UPDATE {comments} SET status = 1 WHERE cid = %d", $cid);
- watchdog("special", "comment: unpublished comment #". $cid);
+ $comment = db_fetch_object(db_query("SELECT * FROM {comments} WHERE cid = %d", $cid));
+ $users = unserialize($comment->users);
+ if ($user->uid != $comment->uid && !(comment_already_moderated($user->uid, $comment->users))) {
+ $users[$user->uid] = $vote;
+ $tot_score = 0;
+ foreach ($users as $uid => $vote) {
+ if ($uid) {
+ $tot_score = $tot_score + $votes[$vote];
+ }
+ else {
+ // vote 0 is the start value
+ $tot_score = $tot_score + $vote;
+ }
+ }
+ $new_score = round($tot_score / count($users));
+ db_query("UPDATE {comments} SET score = '$new_score', users = '%s' WHERE cid = %d", serialize($users), $cid);
/*
** Fire a hook
*/
- module_invoke_all("comment", "unpublish", $cid);
- }
- else {
- $comment = db_fetch_object(db_query("SELECT * FROM {comments} WHERE cid = %d", $cid));
- $users = unserialize($comment->users);
- if ($user->uid != $comment->uid && !(comment_already_moderated($user->uid, $comment->users))) {
- $users[$user->uid] = $vote;
- $tot_score = 0;
- foreach ($users as $uid => $vote) {
- if ($uid) {
- $tot_score = $tot_score + $votes[$vote];
- }
- else {
- // vote 0 is the start value
- $tot_score = $tot_score + $vote;
- }
- }
- $new_score = round($tot_score / count($users));
- db_query("UPDATE {comments} SET score = '$new_score', users = '%s' WHERE cid = %d", serialize($users), $cid);
-
- /*
- ** Fire a hook
- */
-
- module_invoke_all("comment", "moderate", $cid, $vote);
- }
+ module_invoke_all("comment", "moderate", $cid, $vote);
}
}
}