From: mchampan Date: Wed, 16 Aug 2006 13:31:55 +0000 (+0000) Subject: Date field added to documents. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=ecebdf0e6e6ae98fccb49fe0c41a88b49778c592;p=moodle.git Date field added to documents. --- diff --git a/search/db/mysql.sql b/search/db/mysql.sql index 2507a495bb..a8e78e7506 100644 --- a/search/db/mysql.sql +++ b/search/db/mysql.sql @@ -1,10 +1,12 @@ CREATE TABLE IF NOT EXISTS `prefix_search_documents` ( `id` int(11) NOT NULL auto_increment, + `docid` int(11) NOT NULL, `doctype` varchar(12) NOT NULL default 'none', `title` varchar(100) NOT NULL default '', `url` varchar(100) NOT NULL default '', + `docdate` timestamp NOT NULL default '0', `updated` timestamp NOT NULL default CURRENT_TIMESTAMP, `courseid` int(11) NOT NULL default '0', `groupid` int(11) NOT NULL default '0', PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=1; \ No newline at end of file +) ENGINE=MyISAM AUTO_INCREMENT=1; diff --git a/search/db/postgres7.sql b/search/db/postgres7.sql index 3903a65c32..7a2d7a5643 100644 --- a/search/db/postgres7.sql +++ b/search/db/postgres7.sql @@ -1,9 +1,11 @@ CREATE TABLE prefix_search_documents ( id SERIAL8 PRIMARY KEY, + docid int4 NOT NULL, doctype varchar(12) NOT NULL DEFAULT 'none', title varchar(100) NOT NULL default '', url varchar(100) NOT NULL default '', + docdate timestamp NOT NULL, updated timestamp NOT NULL DEFAULT NOW(), courseid int4, groupid int4 -); \ No newline at end of file +); diff --git a/search/documents/document.php b/search/documents/document.php index c5fbe3028e..fdb741afa1 100644 --- a/search/documents/document.php +++ b/search/documents/document.php @@ -10,6 +10,7 @@ $this->addField(Zend_Search_Lucene_Field::Text('author', $doc->author)); $this->addField(Zend_Search_Lucene_Field::UnStored('contents', $doc->contents)); $this->addField(Zend_Search_Lucene_Field::UnIndexed('url', $doc->url)); + $this->addField(Zend_Search_Lucene_Field::UnIndexed('date', $doc->date)); $this->addField(Zend_Search_Lucene_Field::Binary('data', serialize($data))); diff --git a/search/documents/forum_document.php b/search/documents/forum_document.php index c3e0da140c..92786f4b49 100644 --- a/search/documents/forum_document.php +++ b/search/documents/forum_document.php @@ -12,6 +12,7 @@ $doc->title = $post['subject']; $doc->author = $post['firstname']." ".$post['lastname']; $doc->contents = $post['message']; + $doc->date = $post['created']; $doc->url = forum_make_link($post['discussion'], $post['id']); diff --git a/search/documents/glossary_document.php b/search/documents/glossary_document.php index 7d9db6b599..6ce87eb11a 100644 --- a/search/documents/glossary_document.php +++ b/search/documents/glossary_document.php @@ -14,6 +14,7 @@ // generic information; required $doc->docid = $entry['id']; $doc->title = $entry['concept']; + $doc->date = $entry['timecreated']; $user = get_recordset('user', 'id', $entry['userid'])->fields; @@ -38,7 +39,7 @@ //preserve glossary pop-up, be careful where you place your ' and "s //this function is meant to return a url that is placed between href='[url here]' return "$CFG->wwwroot/mod/glossary/showentry.php?eid=$entry_id' onclick='return openpopup(\"/mod/glossary/showentry.php?eid=$entry_id\", \"entry\", \"menubar=0,location=0,scrollbars,resizable,width=600,height=450\", 0);"; - } //glossary_make_link + } //glossary_make_link function glossary_iterator() { return get_all_instances_in_courses("glossary", get_courses()); @@ -61,9 +62,23 @@ return $documents; } //glossary_get_content_for_index + + function glossary_single_document($id) { + $entries = get_recordset('glossary_entries', 'id', $id); + $entry = $entries->fields; + + $glossaries = get_recordset('glossary', 'id', $entry['glossaryid']); + $glossary = $glossaries->fields; + + return new GlossarySearchDocument($entry, $entry['glossaryid'], $glossary['course'], -1); + } //glossary_single_document function glossary_delete($info) { return $info; - } //glossary_delete + } //glossary_delete + + function glossary_db_names() { + return array('id', 'glossary_entries', 'timemodified'); + } //glossary_db_names ?> \ No newline at end of file diff --git a/search/documents/resource_document.php b/search/documents/resource_document.php index ee5b6f21c5..204efc8e72 100644 --- a/search/documents/resource_document.php +++ b/search/documents/resource_document.php @@ -7,6 +7,7 @@ // generic information; required $doc->docid = $resource['id']; $doc->title = strip_tags($resource['name']); + $doc->date = $resource['timemodified']; $doc->author = ''; $doc->contents = strip_tags($resource['summary']).' '.strip_tags($resource['alltext']); diff --git a/search/documents/wiki_document.php b/search/documents/wiki_document.php index 408c38f69e..6bdf0ad470 100644 --- a/search/documents/wiki_document.php +++ b/search/documents/wiki_document.php @@ -21,6 +21,7 @@ // generic information; required $doc->docid = $page->id; $doc->title = $page->pagename; + $doc->date = $page->timemodified; //remove '(ip.ip.ip.ip)' from wiki author field $doc->author = preg_replace('/\(.*?\)/', '', $page->author);