diff options
author | Dries Buytaert <dries@buytaert.net> | 2002-05-05 19:02:02 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2002-05-05 19:02:02 +0000 |
commit | 8c69c3a912a1a2ed6cfd9ff1942b5ce1ba5be036 (patch) | |
tree | f09126eb90c6dfa871664073febc02d480d4d754 /modules | |
parent | 921e6bc19a69a28d1ac435bb125adee51b985bd6 (diff) | |
download | brdo-8c69c3a912a1a2ed6cfd9ff1942b5ce1ba5be036.tar.gz brdo-8c69c3a912a1a2ed6cfd9ff1942b5ce1ba5be036.tar.bz2 |
- Improved viewing of individual comments.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/comment.module | 143 | ||||
-rw-r--r-- | modules/comment/comment.module | 143 |
2 files changed, 160 insertions, 126 deletions
diff --git a/modules/comment.module b/modules/comment.module index 4cb0bae90..e692b9d02 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -388,9 +388,12 @@ function comment_links($comment, $return = 1) { $links[] = la("<span style=\"color: $theme->type;\">". t("administer") ."</span>", array("mod" => "comment", "op" => "edit", "id" => $comment->cid)); } - // here we should check if this node has read-only comments, but we already check on submit - // and this way we save a query. it's just a cosmetic issue. otherwise just uncomment next - // line and related bracket some lines below + /* + ** Here we should check if this node has read-only comments, but we + ** already check on submit and this way we save a query. It's just + ** a cosmetic issue. otherwise just uncomment the next line and + ** related bracket some lines below. + */ //if (node_comment_mode($comment->nid)) { if (user_access("post comments")) { @@ -403,7 +406,6 @@ function comment_links($comment, $return = 1) { } //} - return $theme->links($links); } @@ -476,10 +478,6 @@ function comment_render($nid, $cid) { $nid = 0; } - if (empty($cid)) { - $cid = 0; - } - if (empty($mode)) { $mode = $user->uid ? $user->mode : variable_get("default_comment_mode", 4); } @@ -503,15 +501,22 @@ function comment_render($nid, $cid) { $theme->box(t("Control panel"), $theme->comment_controls($threshold, $mode, $order)); - if ($cid > 0) { + if (isset($cid)) { $result = db_query("SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '$cid' GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name"); if ($comment = db_fetch_object($result)) { comment_view($comment, comment_links($comment)); } } + + if ($cid) { + $result = comment_query($nid, $order, $cid); + } else { - if ($mode == 1) { - $result = comment_query($nid, $order); + $result = comment_query($nid, $order); + } + + if ($mode == 1) { + if (db_result($result)) { print "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n"; print " <tr><th>Subject</th><th>Author</th><th>Date</th><th>Score</th></tr>\n"; while ($comment = db_fetch_object($result)) { @@ -521,30 +526,37 @@ function comment_render($nid, $cid) { } print "</table>\n"; } - else if ($mode == 2) { - $result = comment_query($nid, $order); - while ($comment = db_fetch_object($result)) { - comment_view($comment, (comment_visible($comment, $threshold) ? comment_links($comment, 0) : 0)); - } + } + else if ($mode == 2) { + while ($comment = db_fetch_object($result)) { + comment_view($comment, (comment_visible($comment, $threshold) ? comment_links($comment, 0) : 0)); + } + } + else if ($mode == 3) { + while ($comment = db_fetch_object($result)) { + $comments[] = $comment; } - else if ($mode == 3) { - $result = comment_query($nid, $order); - while ($comment = db_fetch_object($result)) { - $comments[] = $comment; - } - if ($comments) { + if ($comments) { + if (isset($cid)) { + comment_thread_min($comments, $threshold, $cid, 1); + } + else { comment_thread_min($comments, $threshold); } } - else { - $result = comment_query($nid, $order); - while ($comment = db_fetch_object($result)) { - $comments[] = $comment; - } + } + else { + while ($comment = db_fetch_object($result)) { + $comments[] = $comment; + } - if ($comments) { - comment_thread_max($comments, $threshold); + if ($comments) { + if ($cid) { + comment_thread_max($comments, $threshold, $cid, 1); + } + else { + comment_thread_max($comments, $threshold, (isset($cid) ? $cid : 0), isset($cid)); } } } @@ -562,27 +574,29 @@ function comment_render($nid, $cid) { function comment_search($keys) { global $PHP_SELF; - // Return the results of performing a search using the indexed search - // for this particular type of node. - // - // Pass an array to the "do_search" function which dictates what it - // will search through, and what it will search for - // - // "keys"'s value is the keywords entered by the user - // - // "type"'s value is used to identify the node type in the search - // index. - // - // "select"'s value is used to relate the data from the specific nodes - // table to the data that the search_index table has in it, and the the - // do_search functino will rank it. - // - // The select must always provide the following fields - lno, title, - // created, uid, name, count - // - // The select statement may optionally provide "nid", which is a secondary - // identifier which is currently used byt the comment module. - // + /* + ** Return the results of performing a search using the indexed search + ** for this particular type of node. + ** + ** Pass an array to the "do_search" function which dictates what it + ** will search through, and what it will search for + ** + ** "keys"'s value is the keywords entered by the user + ** + ** "type"'s value is used to identify the node type in the search + ** index. + ** + ** "select"'s value is used to relate the data from the specific nodes + ** table to the data that the search_index table has in it, and the the + ** do_search functino will rank it. + ** + ** The select must always provide the following fields - lno, title, + ** created, uid, name, count + ** + ** The select statement may optionally provide "nid", which is a secondary + ** identifier which is currently used byt the comment module. + */ + $find = do_search(array("keys" => $keys, "type" => "comment", "select" => "select s.lno as lno, c.nid as nid, c.subject as title, c.timestamp as created, u.uid as uid, u.name as name, s.count as count FROM search_index s, comments c LEFT JOIN users u ON c.uid = u.uid WHERE s.lno = c.cid AND s.type = 'comment' AND s.word like '%'")); return $find; @@ -774,19 +788,22 @@ function comment_admin() { function comment_update_index() { - // Return an array of values to dictate how to update the search index - // for this particular type of node. - // - // "last_update"'s value is used with variable_set to set the - // last time this node type (comment) had an index update run. - // - // "node_type"'s value is used to identify the node type in the search - // index (commentt in this case). - // - // "select"'s value is used to select the node id and text fields from - // the table we are indexing. In this case, we also check against the - // last run date for the comments update. + /* + ** Return an array of values to dictate how to update the search index + ** for this particular type of node. + ** + ** "last_update"'s value is used with variable_set to set the + ** last time this node type (comment) had an index update run. + ** + ** "node_type"'s value is used to identify the node type in the search + ** index (commentt in this case). + ** + ** "select"'s value is used to select the node id and text fields from + ** the table we are indexing. In this case, we also check against the + ** last run date for the comments update. + */ + return array("last_update" => "comment_cron_last", "node_type" => "comment", "select" => "SELECT c.cid as lno, c.subject as text1, c.comment as text2 FROM comments c WHERE timestamp > ". variable_get("comment_cron_last", 1)); } -?> +?>
\ No newline at end of file diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 4cb0bae90..e692b9d02 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -388,9 +388,12 @@ function comment_links($comment, $return = 1) { $links[] = la("<span style=\"color: $theme->type;\">". t("administer") ."</span>", array("mod" => "comment", "op" => "edit", "id" => $comment->cid)); } - // here we should check if this node has read-only comments, but we already check on submit - // and this way we save a query. it's just a cosmetic issue. otherwise just uncomment next - // line and related bracket some lines below + /* + ** Here we should check if this node has read-only comments, but we + ** already check on submit and this way we save a query. It's just + ** a cosmetic issue. otherwise just uncomment the next line and + ** related bracket some lines below. + */ //if (node_comment_mode($comment->nid)) { if (user_access("post comments")) { @@ -403,7 +406,6 @@ function comment_links($comment, $return = 1) { } //} - return $theme->links($links); } @@ -476,10 +478,6 @@ function comment_render($nid, $cid) { $nid = 0; } - if (empty($cid)) { - $cid = 0; - } - if (empty($mode)) { $mode = $user->uid ? $user->mode : variable_get("default_comment_mode", 4); } @@ -503,15 +501,22 @@ function comment_render($nid, $cid) { $theme->box(t("Control panel"), $theme->comment_controls($threshold, $mode, $order)); - if ($cid > 0) { + if (isset($cid)) { $result = db_query("SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '$cid' GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name"); if ($comment = db_fetch_object($result)) { comment_view($comment, comment_links($comment)); } } + + if ($cid) { + $result = comment_query($nid, $order, $cid); + } else { - if ($mode == 1) { - $result = comment_query($nid, $order); + $result = comment_query($nid, $order); + } + + if ($mode == 1) { + if (db_result($result)) { print "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n"; print " <tr><th>Subject</th><th>Author</th><th>Date</th><th>Score</th></tr>\n"; while ($comment = db_fetch_object($result)) { @@ -521,30 +526,37 @@ function comment_render($nid, $cid) { } print "</table>\n"; } - else if ($mode == 2) { - $result = comment_query($nid, $order); - while ($comment = db_fetch_object($result)) { - comment_view($comment, (comment_visible($comment, $threshold) ? comment_links($comment, 0) : 0)); - } + } + else if ($mode == 2) { + while ($comment = db_fetch_object($result)) { + comment_view($comment, (comment_visible($comment, $threshold) ? comment_links($comment, 0) : 0)); + } + } + else if ($mode == 3) { + while ($comment = db_fetch_object($result)) { + $comments[] = $comment; } - else if ($mode == 3) { - $result = comment_query($nid, $order); - while ($comment = db_fetch_object($result)) { - $comments[] = $comment; - } - if ($comments) { + if ($comments) { + if (isset($cid)) { + comment_thread_min($comments, $threshold, $cid, 1); + } + else { comment_thread_min($comments, $threshold); } } - else { - $result = comment_query($nid, $order); - while ($comment = db_fetch_object($result)) { - $comments[] = $comment; - } + } + else { + while ($comment = db_fetch_object($result)) { + $comments[] = $comment; + } - if ($comments) { - comment_thread_max($comments, $threshold); + if ($comments) { + if ($cid) { + comment_thread_max($comments, $threshold, $cid, 1); + } + else { + comment_thread_max($comments, $threshold, (isset($cid) ? $cid : 0), isset($cid)); } } } @@ -562,27 +574,29 @@ function comment_render($nid, $cid) { function comment_search($keys) { global $PHP_SELF; - // Return the results of performing a search using the indexed search - // for this particular type of node. - // - // Pass an array to the "do_search" function which dictates what it - // will search through, and what it will search for - // - // "keys"'s value is the keywords entered by the user - // - // "type"'s value is used to identify the node type in the search - // index. - // - // "select"'s value is used to relate the data from the specific nodes - // table to the data that the search_index table has in it, and the the - // do_search functino will rank it. - // - // The select must always provide the following fields - lno, title, - // created, uid, name, count - // - // The select statement may optionally provide "nid", which is a secondary - // identifier which is currently used byt the comment module. - // + /* + ** Return the results of performing a search using the indexed search + ** for this particular type of node. + ** + ** Pass an array to the "do_search" function which dictates what it + ** will search through, and what it will search for + ** + ** "keys"'s value is the keywords entered by the user + ** + ** "type"'s value is used to identify the node type in the search + ** index. + ** + ** "select"'s value is used to relate the data from the specific nodes + ** table to the data that the search_index table has in it, and the the + ** do_search functino will rank it. + ** + ** The select must always provide the following fields - lno, title, + ** created, uid, name, count + ** + ** The select statement may optionally provide "nid", which is a secondary + ** identifier which is currently used byt the comment module. + */ + $find = do_search(array("keys" => $keys, "type" => "comment", "select" => "select s.lno as lno, c.nid as nid, c.subject as title, c.timestamp as created, u.uid as uid, u.name as name, s.count as count FROM search_index s, comments c LEFT JOIN users u ON c.uid = u.uid WHERE s.lno = c.cid AND s.type = 'comment' AND s.word like '%'")); return $find; @@ -774,19 +788,22 @@ function comment_admin() { function comment_update_index() { - // Return an array of values to dictate how to update the search index - // for this particular type of node. - // - // "last_update"'s value is used with variable_set to set the - // last time this node type (comment) had an index update run. - // - // "node_type"'s value is used to identify the node type in the search - // index (commentt in this case). - // - // "select"'s value is used to select the node id and text fields from - // the table we are indexing. In this case, we also check against the - // last run date for the comments update. + /* + ** Return an array of values to dictate how to update the search index + ** for this particular type of node. + ** + ** "last_update"'s value is used with variable_set to set the + ** last time this node type (comment) had an index update run. + ** + ** "node_type"'s value is used to identify the node type in the search + ** index (commentt in this case). + ** + ** "select"'s value is used to select the node id and text fields from + ** the table we are indexing. In this case, we also check against the + ** last run date for the comments update. + */ + return array("last_update" => "comment_cron_last", "node_type" => "comment", "select" => "SELECT c.cid as lno, c.subject as text1, c.comment as text2 FROM comments c WHERE timestamp > ". variable_get("comment_cron_last", 1)); } -?> +?>
\ No newline at end of file |