From a31c32973531aa4a80c54d10e7dc1b0ebdaed148 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 10 May 2003 14:43:22 +0000 Subject: - Patch by Marco: + Fixed bug 1544: comment_mod_matrix() was broken. + Emit tables using the table rendering functions. + Fixed a typo in the documentation/comments. (Welcome back Marco!) --- modules/comment.module | 45 +++++++++++++++++++----------------------- modules/comment/comment.module | 45 +++++++++++++++++++----------------------- 2 files changed, 40 insertions(+), 50 deletions(-) (limited to 'modules') diff --git a/modules/comment.module b/modules/comment.module index 7d2dde4b9..b5b2dbe59 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -812,15 +812,14 @@ function comment_admin_overview($status = 0) { } function comment_mod_matrix($edit) { - global $rid; $output .= "

Moderators/vote values matrix

"; $output .= "

Note: you must assign the moderate comments permission to at least one role in order to use this page.

"; $output .= "

In order to use comment moderation, every textbox on this page should be populated with an integer. On this page, you also might wish to value the votes from some users more than others. For example, administrator votes might count twice as much as authenticated users.

"; - if ($rid) { + if ($edit) { db_query("DELETE FROM moderation_roles"); - foreach ($rid as $role_id => $votes) { + foreach ($edit as $role_id => $votes) { foreach ($votes as $mid => $value) { $sql[] = "('$mid', '$role_id', '$value')"; } @@ -839,18 +838,17 @@ function comment_mod_matrix($edit) { $mod_roles[$role->rid][$role->mid] = $role->value; } - $output .= ""; - $output .= " "; + $header = array_merge(array(t("votes")), array_values($role_names)); $result = db_query("SELECT mid, vote FROM moderation_votes ORDER BY weight"); while ($vote = db_fetch_object($result)) { - $output .= ""; + $row = array($vote->vote); foreach (array_keys($role_names) as $rid) { - $output .= ""; + $row[] = array("data" => form_textfield(NULL, "$rid][$vote->mid", $mod_roles[$rid][$vote->mid], 4, 3), "align" => "center"); } - $output .= ""; + $rows[] = $row; } - $output .= "
" . t("votes") . "". implode("", array_values($role_names)) ."
$vote->votemid]\" size=\"4\" value=\"". $mod_roles[$rid][$vote->mid] ."\" />
"; + $output .= table($header, $rows); $output .= "
". form_submit(t("Submit votes")); return form($output); @@ -859,7 +857,7 @@ function comment_mod_matrix($edit) { function comment_mod_roles($edit) { $output .= "

Initial comment scores

"; - $output .= "

Here is your opportunity to value comments from some users more than others. For example, administrator comments might count twice as much as authenticated users. Enter an integr into the initial score column.

"; + $output .= "

Here is your opportunity to value comments from some users more than others. For example, administrator comments might count twice as much as authenticated users. Enter an integer into the initial score column.

"; if ($edit) { variable_set("comment_roles", $edit); @@ -869,15 +867,13 @@ function comment_mod_roles($edit) { $result = db_query("SELECT r.rid, r.name FROM role r, permission p WHERE r.rid = p.rid AND p.perm LIKE '%post comments%'"); - $output .= ""; - $output .= " "; + $header = array(t("user role"), t("initial score")); while ($role = db_fetch_object($result)) { - $output .= ""; - $output .= ""; + $rows[] = array($role->name, array("data" => form_textfield(NULL, $role->rid, $start_values[$role->rid], 4, 3), "align" => "center")); } - $output .= "
" . t("user role") . "" . t("initial score") . "
$role->namerid]\" size=\"4\" value=\"". $start_values[$role->rid] ."\" />
"; + $output .= table($header, $rows); $output .= "
". form_submit(t("Save scores")); return form($output); @@ -903,20 +899,19 @@ function comment_mod_votes($edit) { } $output .= "

" . t("Moderation votes overview") . "

"; - $output .= ""; - $output .= " "; + $header = array(t("votes"), t("weight"), t("operations")); $result = db_query("SELECT mid, vote, weight FROM moderation_votes ORDER BY weight"); while ($vote = db_fetch_object($result)) { - $output .= " "; + $rows[] = array($vote->vote, array("data" => $vote->weight, "align" => "center"), array("data" => l(t("edit"), "admin/comment/votes/$vote->mid"), "align" => "center")); } - $output .= "
" . t("votes") . "" . t("weight") . "" . t("operations") . "
$vote->vote$vote->weight". l(t("edit"), "admin/comment/votes/$vote->mid") ."
"; + $output .= table($header, $rows); if ($mid) { $vote = db_fetch_object(db_query("SELECT vote, weight FROM moderation_votes WHERE mid = %d", $mid)); } - $output .= "

Add new moderation option

"; + $output .= "

Add new moderation option

"; $form .= form_textfield(t("Vote"), "vote", $vote->vote, 32, 64, t("The name of this vote. Example: 'off topic', 'excellent', 'sucky'.")); $form .= form_textfield(t("Weight"), "weight", $vote->weight, 32, 64, t("Used to order votes in the comment control box; heavier sink.")); if ($mid) { @@ -952,20 +947,20 @@ function comment_mod_filters($edit) { $output .= "

Comment threshold overview

"; $output .= "

Optional. If your site gets lots of comments, you may offer your users thresholds, which are used to hide all comments whose moderation score is lower than the threshold. This cuts down on clutter while your readers view the site. These thresholds appear in the Comment Control Panel.

"; - $output .= ""; - $output .= " "; + + $header = array(t("name"), t("minimum score"), t("operations")); $result = db_query("SELECT fid, filter, minimum FROM moderation_filters ORDER BY minimum"); while ($filter = db_fetch_object($result)) { - $output .= " "; + $rows[] = array($filter->filter, array("data" => $filter->minimum, "align" => "center"), array("data" => l(t("edit"), "admin/comment/filters/$filter->fid"), "align" => "center")); } - $output .= "
" . t("name") . "" . t("minimum score") . "" . t("operations") . "
$filter->filter$filter->minimum". l(t("edit"), "admin/comment/filters/$filter->fid") ."
"; + $output .= table($header, $rows); if ($fid) { $filter = db_fetch_object(db_query("SELECT filter, fid, minimum FROM moderation_filters WHERE fid = %d", $fid)); } - $output .= "

Add new threshold

"; + $output .= "

Add new threshold

"; $form .= form_textfield(t("Threshhold name"), "filter", $filter->filter, 32, 64, t("The name of this threshold. Example: 'good comments', '+1 comments', 'everything'.")); $form .= form_textfield(t("Minimum score"), "minimum", $filter->minimum, 32, 64, t("Show all comments whose score is larger or equal to the provided minimal score. Range: -127 + 128")); if ($fid) { diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 7d2dde4b9..b5b2dbe59 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -812,15 +812,14 @@ function comment_admin_overview($status = 0) { } function comment_mod_matrix($edit) { - global $rid; $output .= "

Moderators/vote values matrix

"; $output .= "

Note: you must assign the moderate comments permission to at least one role in order to use this page.

"; $output .= "

In order to use comment moderation, every textbox on this page should be populated with an integer. On this page, you also might wish to value the votes from some users more than others. For example, administrator votes might count twice as much as authenticated users.

"; - if ($rid) { + if ($edit) { db_query("DELETE FROM moderation_roles"); - foreach ($rid as $role_id => $votes) { + foreach ($edit as $role_id => $votes) { foreach ($votes as $mid => $value) { $sql[] = "('$mid', '$role_id', '$value')"; } @@ -839,18 +838,17 @@ function comment_mod_matrix($edit) { $mod_roles[$role->rid][$role->mid] = $role->value; } - $output .= ""; - $output .= " "; + $header = array_merge(array(t("votes")), array_values($role_names)); $result = db_query("SELECT mid, vote FROM moderation_votes ORDER BY weight"); while ($vote = db_fetch_object($result)) { - $output .= ""; + $row = array($vote->vote); foreach (array_keys($role_names) as $rid) { - $output .= ""; + $row[] = array("data" => form_textfield(NULL, "$rid][$vote->mid", $mod_roles[$rid][$vote->mid], 4, 3), "align" => "center"); } - $output .= ""; + $rows[] = $row; } - $output .= "
" . t("votes") . "". implode("", array_values($role_names)) ."
$vote->votemid]\" size=\"4\" value=\"". $mod_roles[$rid][$vote->mid] ."\" />
"; + $output .= table($header, $rows); $output .= "
". form_submit(t("Submit votes")); return form($output); @@ -859,7 +857,7 @@ function comment_mod_matrix($edit) { function comment_mod_roles($edit) { $output .= "

Initial comment scores

"; - $output .= "

Here is your opportunity to value comments from some users more than others. For example, administrator comments might count twice as much as authenticated users. Enter an integr into the initial score column.

"; + $output .= "

Here is your opportunity to value comments from some users more than others. For example, administrator comments might count twice as much as authenticated users. Enter an integer into the initial score column.

"; if ($edit) { variable_set("comment_roles", $edit); @@ -869,15 +867,13 @@ function comment_mod_roles($edit) { $result = db_query("SELECT r.rid, r.name FROM role r, permission p WHERE r.rid = p.rid AND p.perm LIKE '%post comments%'"); - $output .= ""; - $output .= " "; + $header = array(t("user role"), t("initial score")); while ($role = db_fetch_object($result)) { - $output .= ""; - $output .= ""; + $rows[] = array($role->name, array("data" => form_textfield(NULL, $role->rid, $start_values[$role->rid], 4, 3), "align" => "center")); } - $output .= "
" . t("user role") . "" . t("initial score") . "
$role->namerid]\" size=\"4\" value=\"". $start_values[$role->rid] ."\" />
"; + $output .= table($header, $rows); $output .= "
". form_submit(t("Save scores")); return form($output); @@ -903,20 +899,19 @@ function comment_mod_votes($edit) { } $output .= "

" . t("Moderation votes overview") . "

"; - $output .= ""; - $output .= " "; + $header = array(t("votes"), t("weight"), t("operations")); $result = db_query("SELECT mid, vote, weight FROM moderation_votes ORDER BY weight"); while ($vote = db_fetch_object($result)) { - $output .= " "; + $rows[] = array($vote->vote, array("data" => $vote->weight, "align" => "center"), array("data" => l(t("edit"), "admin/comment/votes/$vote->mid"), "align" => "center")); } - $output .= "
" . t("votes") . "" . t("weight") . "" . t("operations") . "
$vote->vote$vote->weight". l(t("edit"), "admin/comment/votes/$vote->mid") ."
"; + $output .= table($header, $rows); if ($mid) { $vote = db_fetch_object(db_query("SELECT vote, weight FROM moderation_votes WHERE mid = %d", $mid)); } - $output .= "

Add new moderation option

"; + $output .= "

Add new moderation option

"; $form .= form_textfield(t("Vote"), "vote", $vote->vote, 32, 64, t("The name of this vote. Example: 'off topic', 'excellent', 'sucky'.")); $form .= form_textfield(t("Weight"), "weight", $vote->weight, 32, 64, t("Used to order votes in the comment control box; heavier sink.")); if ($mid) { @@ -952,20 +947,20 @@ function comment_mod_filters($edit) { $output .= "

Comment threshold overview

"; $output .= "

Optional. If your site gets lots of comments, you may offer your users thresholds, which are used to hide all comments whose moderation score is lower than the threshold. This cuts down on clutter while your readers view the site. These thresholds appear in the Comment Control Panel.

"; - $output .= ""; - $output .= " "; + + $header = array(t("name"), t("minimum score"), t("operations")); $result = db_query("SELECT fid, filter, minimum FROM moderation_filters ORDER BY minimum"); while ($filter = db_fetch_object($result)) { - $output .= " "; + $rows[] = array($filter->filter, array("data" => $filter->minimum, "align" => "center"), array("data" => l(t("edit"), "admin/comment/filters/$filter->fid"), "align" => "center")); } - $output .= "
" . t("name") . "" . t("minimum score") . "" . t("operations") . "
$filter->filter$filter->minimum". l(t("edit"), "admin/comment/filters/$filter->fid") ."
"; + $output .= table($header, $rows); if ($fid) { $filter = db_fetch_object(db_query("SELECT filter, fid, minimum FROM moderation_filters WHERE fid = %d", $fid)); } - $output .= "

Add new threshold

"; + $output .= "

Add new threshold

"; $form .= form_textfield(t("Threshhold name"), "filter", $filter->filter, 32, 64, t("The name of this threshold. Example: 'good comments', '+1 comments', 'everything'.")); $form .= form_textfield(t("Minimum score"), "minimum", $filter->minimum, 32, 64, t("Show all comments whose score is larger or equal to the provided minimal score. Range: -127 + 128")); if ($fid) { -- cgit v1.2.3