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.module58
1 files changed, 54 insertions, 4 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 0aa467989..234990611 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -191,6 +191,15 @@ function comment_preview($edit) {
comment_view($comment, t("reply to this comment"));
$theme->box(t("Reply"), comment_form($edit));
+
+ if ($edit["pid"]) {
+ $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '$edit[pid]'"));
+ comment_view($comment, t("reply to this comment"));
+ }
+ else {
+ node_view(node_load(array("nid" => $edit["nid"])));
+ $edit["pid"] = 0;
+ }
}
function comment_post($edit) {
@@ -531,10 +540,32 @@ function comment_render($nid, $cid) {
function comment_search($keys) {
global $PHP_SELF;
- $result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20");
- while ($comment = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($comment->subject), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->nid&cid=$comment->cid"), "user" => $comment->name, "date" => $comment->timestamp);
- }
+
+ // 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;
}
@@ -715,4 +746,23 @@ 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 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));
+}
+
?>