From e3d2c46f04b2d510e60a3266f2b3bc2e4550eb85 Mon Sep 17 00:00:00 2001 From: Kjartan Mannes Date: Tue, 5 Mar 2002 20:15:17 +0000 Subject: - applied search patch. - added who is online block. - made weblog module more configurable. - users may now delete their own accounts (Feature #8) - users may now request a password using email address *or* username. formerly required both items to match an account which was onerous. - the link to request a new password is now presented whenever a user fails login. - there is now a confirmation message after submitting edits to your user information. - error messages in user.module may now be stylized by themes. - _form has a $param setting you can fill with form parameters. - improved wording for a few config settings. - fixed various non-coding standard things. --- modules/node/node.module | 54 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 9 deletions(-) (limited to 'modules/node/node.module') diff --git a/modules/node/node.module b/modules/node/node.module index 2b49a090d..6dab1419d 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -48,7 +48,7 @@ function node_teaser($body) { function node_invoke($node, $name, $arg = 0) { if (is_array($node)) { - $function = $node[type] ."_$name"; + $function = $node["type"] ."_$name"; } else if (is_object($node)) { $function = $node->type ."_$name"; @@ -261,11 +261,28 @@ function node_perm() { function node_search($keys) { global $PHP_SELF; - $result = db_query("SELECT n.nid, n.title, n.created, u.uid, u.name FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.status = 1 AND (n.title LIKE '%$keys%' OR n.teaser LIKE '%$keys%' OR n.body LIKE '%$keys%') ORDER BY n.created DESC LIMIT 20"); - while ($node = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($node->title), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=node&type=node&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->name, "date" => $node->created); - } - + // 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 + // + $find = do_search(array("keys" => $keys, + "type" => "node", + "select" => "select s.lno as lno, n.title as title, n.created as created, u.uid as uid, u.name as name, s.count as count FROM search_index s, node n LEFT JOIN users u ON n.uid = u.uid WHERE s.lno = n.nid AND s.type = 'node' AND s.word like '%' AND n.status = 1")); + return $find; } @@ -316,7 +333,7 @@ function node_filter_line($text) { ** Replace '
', '
', '

' and '

' by '\n': */ - $text = eregi_replace("
", "\n", $text); + $text = eregi_replace("
", "\n", $text); $text = eregi_replace("
", "\n", $text); $text = eregi_replace("

", "\n", $text); $text = eregi_replace("

", "\n", $text); @@ -772,7 +789,7 @@ function node_form($edit) { $function = $edit->type ."_form"; if (function_exists($function)) { - $form .= $function($edit, $help, $error); + $form .= $function($edit, $help, $error, $param); } /* @@ -857,7 +874,7 @@ function node_form($edit) { $output .= " "; $output .= ""; - return form($output); + return form($output, ($param["method"] ? $param["method"] : "post"), $param["action"], $param["options"]); } function node_add($type) { @@ -1176,4 +1193,23 @@ function node_page() { $theme->footer(); } +function node_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 had an index update run. + // + // "node_type"'s value is used to identify the node type in the search + // index. + // + // "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 nodes update. + return array("last_update" => "node_cron_last", + "node_type" => "node", + "select" => "SELECT n.nid as lno, n.title as text1, n.body as text2 FROM node n WHERE n.status = 1 AND moderate = 0 and (created > " . variable_get("node_cron_last", 1) . " or changed > " . variable_get("node_cron_last", 1) . ")"); +} + ?> -- cgit v1.2.3