diff -Naru search_original/documents/assignment_document.php search/documents/assignment_document.php --- search_original/documents/assignment_document.php 2009-01-08 17:04:10.127375000 +0900 +++ search/documents/assignment_document.php 2009-05-30 19:09:25.874207200 +0900 @@ -300,6 +300,10 @@ } $context = get_record('context', 'id', $context_id); $cm = get_record('course_modules', 'id', $context->instanceid); +// (Shirai136): When the course module does not exist in mdl_course_modules, SQL syntax error will occur (2009/05/29) +// (Shirai136): Add from here + if (empty($cm)) return false; +// (Shirai136): Add to here if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $context)){ if (!empty($CFG->search_access_debug)) echo "search reject : hidden assignment "; diff -Naru search_original/documents/chat_document.php search/documents/chat_document.php --- search_original/documents/chat_document.php 2009-01-08 17:04:10.127375000 +0900 +++ search/documents/chat_document.php 2009-05-30 19:10:31.473993600 +0900 @@ -89,6 +89,13 @@ $course = get_record('course', 'id', $chat->course); $coursemodule = get_field('modules', 'id', 'name', 'data'); $cm = get_record('course_modules', 'course', $course->id, 'module', $coursemodule, 'instance', $chat->id); +// (Shirai136): When the course module does not exist in mdl_course_modules, SQL syntax error will occur (2009/05/29) +// (Shirai136): Add from here + if (empty($cm)) { + mtrace("Missing this chat: Course=".$chat->course."/ ChatID=".$chat_id); + return array(); + } +// (Shirai136): Add to here $groupmode = groupmode($course, $cm); $fromtimeclause = ($fromtime) ? "AND timestamp >= {$fromtime}" : ''; @@ -262,6 +269,13 @@ $cm = get_record('course_modules', 'id', $context->instanceid); // $cm = get_coursemodule_from_instance('chat', $chat->id, $chat->course); // $context = get_context_instance(CONTEXT_MODULE, $cm->id); +// (Shirai136): When the course module does not exist in mdl_course_modules, SQL syntax error will occur (2009/05/29) +// (Shirai136): Add from here + if (empty($cm)) { + mtrace("Missing this chat: ChatID=".$chat_id); + return false; + } +// (Shirai136): Add to here if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $context)){ if (!empty($CFG->search_access_debug)) echo "search reject : hidden chat "; diff -Naru search_original/documents/document.php search/documents/document.php --- search_original/documents/document.php 2009-01-08 17:04:10.127375000 +0900 +++ search/documents/document.php 2009-05-30 19:16:04.021314000 +0900 @@ -18,29 +18,51 @@ */ abstract class SearchDocument extends Zend_Search_Lucene_Document { public function __construct(&$doc, &$data, $course_id, $group_id, $user_id, $path, $additional_keyset = null) { +// (Shirai135): The multibyte strings in index files will be broken (2009/05/28) +// (Shirai135): Add from here + $encoding = 'UTF-8'; +// (Shirai135): Add to here //document identification and indexing - $this->addField(Zend_Search_Lucene_Field::Keyword('docid', $doc->docid)); +// (Shirai135): Modify from here +// $this->addField(Zend_Search_Lucene_Field::Keyword('docid', $doc->docid)); + $this->addField(Zend_Search_Lucene_Field::Keyword('docid', $doc->docid, $encoding)); //document type : the name of the Moodle element that manages it - $this->addField(Zend_Search_Lucene_Field::Keyword('doctype', $doc->documenttype)); +// $this->addField(Zend_Search_Lucene_Field::Keyword('doctype', $doc->documenttype)); + $this->addField(Zend_Search_Lucene_Field::Keyword('doctype', $doc->documenttype, $encoding)); //allows subclassing information from complex modules. - $this->addField(Zend_Search_Lucene_Field::Keyword('itemtype', $doc->itemtype)); +// $this->addField(Zend_Search_Lucene_Field::Keyword('itemtype', $doc->itemtype)); + $this->addField(Zend_Search_Lucene_Field::Keyword('itemtype', $doc->itemtype, $encoding)); //caches the course context. - $this->addField(Zend_Search_Lucene_Field::Keyword('course_id', $course_id)); +// $this->addField(Zend_Search_Lucene_Field::Keyword('course_id', $course_id)); + $this->addField(Zend_Search_Lucene_Field::Keyword('course_id', $course_id, $encoding)); //caches the originator's group. - $this->addField(Zend_Search_Lucene_Field::Keyword('group_id', $group_id)); +// $this->addField(Zend_Search_Lucene_Field::Keyword('group_id', $group_id)); + $this->addField(Zend_Search_Lucene_Field::Keyword('group_id', $group_id, $encoding)); //caches the originator if any - $this->addField(Zend_Search_Lucene_Field::Keyword('user_id', $user_id)); +// $this->addField(Zend_Search_Lucene_Field::Keyword('user_id', $user_id)); + $this->addField(Zend_Search_Lucene_Field::Keyword('user_id', $user_id, $encoding)); +// (Shirai135): Modify to here // caches the context of this information. i-e, the context in which this information // is being produced/attached. Speeds up the "check for access" process as context in // which the information resides (a course, a module, a block, the site) is stable. - $this->addField(Zend_Search_Lucene_Field::UnIndexed('context_id', $doc->contextid)); +// (Shirai135): Modify from here +// $this->addField(Zend_Search_Lucene_Field::UnIndexed('context_id', $doc->contextid)); + $this->addField(Zend_Search_Lucene_Field::UnIndexed('context_id', $doc->contextid, $encoding)); +// (Shirai135): Modify to here //data for document - $this->addField(Zend_Search_Lucene_Field::Text('title', $doc->title)); - $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)); +// (Shirai135): Modify from here +// $this->addField(Zend_Search_Lucene_Field::Text('title', $doc->title)); + $this->addField(Zend_Search_Lucene_Field::Text('title', $doc->title, $encoding)); +// $this->addField(Zend_Search_Lucene_Field::Text('author', $doc->author)); + $this->addField(Zend_Search_Lucene_Field::Text('author', $doc->author, $encoding)); +// $this->addField(Zend_Search_Lucene_Field::UnStored('contents', $doc->contents)); + $this->addField(Zend_Search_Lucene_Field::UnStored('contents', $doc->contents, $encoding)); +// $this->addField(Zend_Search_Lucene_Field::UnIndexed('url', $doc->url)); + $this->addField(Zend_Search_Lucene_Field::UnIndexed('url', $doc->url, $encoding)); +// $this->addField(Zend_Search_Lucene_Field::UnIndexed('date', $doc->date)); + $this->addField(Zend_Search_Lucene_Field::UnIndexed('date', $doc->date, $encoding)); +// (Shirai135): Modify to here //additional data added on a per-module basis $this->addField(Zend_Search_Lucene_Field::Binary('data', serialize($data))); @@ -49,7 +71,10 @@ // for checking access to a module or block content. The Lucene records should only // be responsible to bring back to that call sufficient and consistent information // in order to perform the check. - $this->addField(Zend_Search_Lucene_Field::UnIndexed('path', $path)); +// (Shirai135): Modify from here +// $this->addField(Zend_Search_Lucene_Field::UnIndexed('path', $path)); + $this->addField(Zend_Search_Lucene_Field::UnIndexed('path', $path, $encoding)); +// (Shirai135): Modify to here /* // adding a capability set required for viewing. -1 if no capability required. // the capability required for viewing is depending on the local situation @@ -66,7 +91,10 @@ */ if (!empty($additional_keyset)){ foreach($additional_keyset as $keyname => $keyvalue){ - $this->addField(Zend_Search_Lucene_Field::Keyword($keyname, $keyvalue)); +// (Shirai135): Modify from here +// $this->addField(Zend_Search_Lucene_Field::Keyword($keyname, $keyvalue)); + $this->addField(Zend_Search_Lucene_Field::Keyword($keyname, $keyvalue, $encoding)); +// (Shirai135): Modify to here } } } diff -Naru search_original/documents/forum_document.php search/documents/forum_document.php --- search_original/documents/forum_document.php 2009-01-08 17:04:10.127375000 +0900 +++ search/documents/forum_document.php 2009-05-30 19:16:47.948778000 +0900 @@ -92,6 +92,13 @@ $coursemodule = get_field('modules', 'id', 'name', 'forum'); $cm = get_record('course_modules', 'course', $forum->course, 'module', $coursemodule, 'instance', $forum->id); +// (Shirai136): When the course module does not exist in mdl_course_modules, SQL syntax error will occur (2009/05/29) +// (Shirai136): Add from here + if (empty($cm)) { + mtrace("Missing this forum: Course=".$forum->course."/ ForumID=".$forum->id); + return $documents; + } +// (Shirai136): Add to here $context = get_context_instance(CONTEXT_MODULE, $cm->id); foreach($posts as $aPost) { diff -Naru search_original/documents/label_document.php search/documents/label_document.php --- search_original/documents/label_document.php 2009-01-08 17:04:10.127375000 +0900 +++ search/documents/label_document.php 2009-05-30 19:21:00.325304100 +0900 @@ -87,6 +87,13 @@ $coursemodule = get_field('modules', 'id', 'name', 'label'); $cm = get_record('course_modules', 'course', $label->course, 'module', $coursemodule, 'instance', $label->id); +// (Shirai136): When the course module does not exist in mdl_course_modules, SQL syntax error will occur (2009/05/29) +// (Shirai136): Add from here + if (empty($cm)) { + mtrace("Missing this label: Course=".$label->course."/ LabelID=".$label->id); + return $documents; + } +// (Shirai136): Add to here $context = get_context_instance(CONTEXT_MODULE, $cm->id); $documents[] = new LabelSearchDocument(get_object_vars($label), $context->id); diff -Naru search_original/documents/physical_doc.php search/documents/physical_doc.php --- search_original/documents/physical_doc.php 2009-01-08 17:04:10.127375000 +0900 +++ search/documents/physical_doc.php 2009-05-30 19:19:01.611090000 +0900 @@ -29,7 +29,11 @@ // just call pdftotext over stdout and capture the output if (!empty($CFG->block_search_word_to_text_cmd)){ if (!file_exists("{$moodleroot}{$CFG->block_search_word_to_text_cmd}")){ - mtrace('Error with MSWord to text converter command : exectuable not found.'); +// (Shirai145): Adding path for external converter and modifying "exectuable" -> "executable" (2009/05/30) +// (Shirai145): Modify from here +// mtrace('Error with MSWord to text converter command : exectuable not found.'); + mtrace('Error with MSWord to text converter command : executable not found at '.$moodleroot.$CFG->block_search_word_to_text_cmd); +// (Shirai145): Modify to here } else { if ($directfile == ''){ $file = escapeshellarg("{$CFG->dataroot}/{$resource->course}/{$resource->reference}"); diff -Naru search_original/documents/physical_odt.php search/documents/physical_odt.php --- search_original/documents/physical_odt.php 2009-01-08 17:04:10.127375000 +0900 +++ search/documents/physical_odt.php 2009-05-30 19:19:45.491556000 +0900 @@ -29,7 +29,11 @@ // just call pdftotext over stdout and capture the output if (!empty($CFG->block_search_odt_to_text_cmd)){ if (!file_exists("{$moodleroot}{$CFG->block_search_odt_to_text_cmd}")){ - mtrace('Error with OpenOffice ODT to text converter command : exectuable not found.'); +// (Shirai145): Adding path for external converter and modifying "exectuable" -> "executable" (2009/05/30) +// (Shirai145): Modify from here +// mtrace('Error with OpenOffice ODT to text converter command : exectuable not found.'); + mtrace('Error with OpenOffice ODT to text converter command : executable not found at '.$moodleroot.$CFG->block_search_word_to_text_cmd); +// (Shirai145): Modify to here } else { if ($directfile == ''){ $file = escapeshellarg("{$CFG->dataroot}/{$resource->course}/{$resource->reference}"); diff -Naru search_original/documents/physical_ppt.php search/documents/physical_ppt.php --- search_original/documents/physical_ppt.php 2009-01-08 17:04:10.127375000 +0900 +++ search/documents/physical_ppt.php 2009-05-30 19:32:14.710235500 +0900 @@ -88,7 +88,11 @@ $indextext = shorten($text, $CFG->block_search_limit_index_body); } - $indextext = mb_convert_encoding($indextext, 'UTF8', 'auto'); +// (Debug004): 'UTF8' is not right encoding name (2009/05/29) +// (Debug004): Modify from here +// $indextext = mb_convert_encoding($indextext, 'UTF8', 'auto'); + $indextext = mb_convert_encoding($indextext, 'UTF-8', 'auto'); +// (Debug004): Modify to here return $indextext; } ?> \ No newline at end of file diff -Naru search_original/documents/resource_document.php search/documents/resource_document.php --- search_original/documents/resource_document.php 2009-03-27 18:56:53.477875000 +0900 +++ search/documents/resource_document.php 2009-05-30 19:20:15.664272000 +0900 @@ -99,6 +99,13 @@ foreach($resources as $aResource){ $coursemodule = get_field('modules', 'id', 'name', 'resource'); $cm = get_record('course_modules', 'course', $aResource->course, 'module', $coursemodule, 'instance', $aResource->id); +// (Shirai136): When the course module does not exist in mdl_course_modules, SQL syntax error will occur (2009/05/29) +// (Shirai136): Add from here + if (empty($cm)) { + mtrace("Missing this resource: Course=".$aResource->course."/ ResourceID=".$aResource->id); + return $documents; + } +// (Shirai136): Add to here $context = get_context_instance(CONTEXT_MODULE, $cm->id); $aResource->id = $cm->id; $documents[] = new ResourceSearchDocument(get_object_vars($aResource), $context->id); diff -Naru search_original/documents/user_document.php search/documents/user_document.php --- search_original/documents/user_document.php 2009-01-08 17:04:10.127375000 +0900 +++ search/documents/user_document.php 2009-05-30 19:26:51.071484200 +0900 @@ -48,7 +48,11 @@ // module specific information; optional // construct the parent class - parent::__construct($doc, $data, 0, 0, 0, PATH_FOR_SEARCH_TYPE_USER); +// (Shirai137): User pictures are not displayed in results of blogs (2009/05/29) +// (Shirai137): Modify from here +// parent::__construct($doc, $data, 0, 0, 0, PATH_FOR_SEARCH_TYPE_USER); + parent::__construct($doc, $data, 0, 0, $user_id, PATH_FOR_SEARCH_TYPE_USER); +// (Shirai137): Modify to here } } @@ -71,18 +75,30 @@ $user = get_record('user', 'id', $user_id); // we cannot call userdate with relevant locale at indexing time. - $doc->title = get_string('post').': '.fullname($user); +// (Shirai138): Change Title from Author to Posted title when the search result is blog (2009/05/29) +// (Shirai138): Modify from here +// $doc->title = get_string('post').': '.fullname($user); + $doc->title = $post['subject']; +// (Shirai138): Modify to here $doc->date = $post['created']; //remove '(ip.ip.ip.ip)' from chat author list $doc->author = fullname($user); $doc->contents = $post['description']; - $doc->url = user_make_link($user_id, 'post'); +// (Shirai139): Change link address from blog entry to posted blog when the search result is blog (2009/05/29) +// (Shirai139): Modify from here +// $doc->url = user_make_link($user_id, 'post'); + $doc->url = user_make_link($post['id'], 'post'); +// (Shirai139): Modify to here // module specific information; optional // construct the parent class - parent::__construct($doc, $data, 0, 0, 0, PATH_FOR_SEARCH_TYPE_USER); +// (Shirai137): User pictures are not displayed in results of blogs (2009/05/29) +// (Shirai137): Modify from here +// parent::__construct($doc, $data, 0, 0, 0, PATH_FOR_SEARCH_TYPE_USER); + parent::__construct($doc, $data, 0, 0, $user_id, PATH_FOR_SEARCH_TYPE_USER); +// (Shirai137): Modify to here } } @@ -116,7 +132,11 @@ // module specific information; optional // construct the parent class - parent::__construct($doc, $data, 0, 0, 0, PATH_FOR_SEARCH_TYPE_USER); +// (Shirai137): User pictures are not displayed in results of blogs (2009/05/29) +// (Shirai137): Modify from here +// parent::__construct($doc, $data, 0, 0, 0, PATH_FOR_SEARCH_TYPE_USER); + parent::__construct($doc, $data, 0, 0, $post['userid'], PATH_FOR_SEARCH_TYPE_USER); +// (Shirai137): Modify to here } } @@ -134,7 +154,11 @@ if ($itemtype == 'user'){ return $CFG->wwwroot.'/user/view.php?id='.$itemid; } elseif ($itemtype == 'post') { - return $CFG->wwwroot.'/blog/index.php?userid='.$itemid; +// (Shirai139): Change link address from blog entry to posted blog when the search result is blog (2009/05/29) +// (Shirai139): Modify from here +// return $CFG->wwwroot.'/blog/index.php?userid='.$itemid; + return $CFG->wwwroot.'/blog/index.php?postid='.$itemid; +// (Shirai139): Modify to here } elseif ($itemtype == 'attachment') { $post = get_record('post', 'id', $itemid); if (!$CFG->slasharguments){ diff -Naru search_original/documents/wiki_document.php search/documents/wiki_document.php --- search_original/documents/wiki_document.php 2009-01-08 17:04:10.127375000 +0900 +++ search/documents/wiki_document.php 2009-05-30 19:28:52.328830500 +0900 @@ -168,6 +168,13 @@ if ($entries){ $coursemodule = get_field('modules', 'id', 'name', 'wiki'); $cm = get_record('course_modules', 'course', $wiki->course, 'module', $coursemodule, 'instance', $wiki->id); +// (Shirai136): When the course module does not exist in mdl_course_modules, SQL syntax error will occur (2009/05/29) +// (Shirai136): Add from here + if (empty($cm)) { + mtrace("Missing this wiki: Course=".$wiki->course."/ WikiID=".$wiki->id); + return $documents; + } +// (Shirai136): Add to here $context = get_context_instance(CONTEXT_MODULE, $cm->id); foreach($entries as $entry) { @@ -179,7 +186,11 @@ if (is_array($pages)) { foreach($pages as $page) { if (strlen($page->content) > 0) { - $documents[] = new WikiSearchDocument(get_object_vars($page), $entry->wikiid, $entry->course, $entry->groupid, $page->userid, $context->id); +// (Shirai140): The course name is not displayed when the search result is wiki (2009/05/29) +// (Shirai140): Modify from here +// $documents[] = new WikiSearchDocument(get_object_vars($page), $entry->wikiid, $entry->course, $entry->groupid, $page->userid, $context->id); + $documents[] = new WikiSearchDocument(get_object_vars($page), $entry->wikiid, $wiki->course, $entry->groupid, $page->userid, $context->id); +// (Shirai140): Modify to here } } } @@ -199,6 +210,13 @@ $entry = get_record('wiki_entries', 'id', $page->wiki); $coursemodule = get_field('modules', 'id', 'name', 'wiki'); $cm = get_record('course_modules', 'course', $entry->course, 'module', $coursemodule, 'instance', $entry->wikiid); +// (Shirai136): When the course module does not exist in mdl_course_modules, SQL syntax error will occur (2009/05/29) +// (Shirai136): Add from here + if (empty($cm)) { + mtrace("Missing this wiki: Course=".$entry->course."/ WikiID=".$entry->wikiid); + return array(); + } +// (Shirai136): Add to here $context = get_context_instance(CONTEXT_MODULE, $cm->id); return new WikiSearchDocument(get_object_vars($page), $entry->wikiid, $entry->course, $entry->groupid, $page->userid, $context->id); } @@ -245,6 +263,13 @@ $course = get_record('course', 'id', $entry->course); $context = get_record('context', 'id', $context_id); $cm = get_record('course_modules', 'id', $context->instanceid); +// (Shirai136): When the course module does not exist in mdl_course_modules, SQL syntax error will occur (2009/05/29) +// (Shirai136): Add from here + if (empty($cm)) { + mtrace("Missing this wiki: Course=".$entry->course."/ WikiID=".$context->instanceid); + return false; + } +// (Shirai136): Add to here // $cm = get_coursemodule_from_instance('wiki', $wiki->id, $wiki->course); // $context = get_record('context', 'id', $cm->id); if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $context)) { diff -Naru search_original/query.php search/query.php --- search_original/query.php 2009-01-08 17:04:10.127375000 +0900 +++ search/query.php 2009-05-30 19:04:03.295889600 +0900 @@ -119,9 +119,16 @@ } // add module restriction - $doctypestr = get_string('doctype', 'search'); - $titlestr = get_string('title', 'search'); - $authorstr = get_string('author', 'search'); +// (Shirai141): Search option does not work (2009/05/29) +// (Shirai141): Comment out from here +// $doctypestr = get_string('doctype', 'search'); +// $titlestr = get_string('title', 'search'); +// $authorstr = get_string('author', 'search'); +// (Shirai141): Add from here + $doctypestr = 'doctype'; + $titlestr = 'title'; + $authorstr = 'author'; +// (Shirai141): Add to here if ($adv->module != 'all') { $query_string .= " +{$doctypestr}:".$adv->module; } @@ -342,7 +349,11 @@ if ($listing->doctype == 'user'){ // A special handle for users - $icon = print_user_picture ($listing->author, 0, true, 0, true, false) ; +// (Shirai137): User pictures are not displayed in results of blogs (2009/05/29) +// (Shirai137): Modify from hre +// $icon = print_user_picture ($listing->author, 0, true, 0, true, false) ; + $icon = print_user_picture ($listing->user_id, 0, true, 0, true, false) ; +// (Shirai137): Modify to here } else { $iconpath = $CFG->modpixpath.'/'.$listing->doctype.'/icon.gif'; $icon = "\"\"/"; diff -Naru search_original/querylib.php search/querylib.php --- search_original/querylib.php 2009-01-08 17:04:10.127375000 +0900 +++ search/querylib.php 2009-05-30 19:06:19.773034800 +0900 @@ -276,6 +276,10 @@ $resultdoc->doctype = $hit->doctype; $resultdoc->author = $hit->author; $resultdoc->courseid = $hit->course_id; +// (Shirai143): user_id is not returned (2009/05/29) c.f.(Shirai137) +// (Shirai143): Add from here + $resultdoc->user_id = $hit->user_id; +// (Shirai143): Add to here //and store it $resultdocs[] = clone($resultdoc); @@ -324,7 +328,11 @@ */ public function page_numbers() { $pages = $this->total_pages(); - $query = htmlentities($this->term); +// (Shirai142): Search keyword parameter(Multibyte character) is broken at direct link to the pages (2009/05/29) +// (Shirai142): Modify from here +// $query = htmlentities($this->term); + $query = htmlentities(rawurlencode($this->term)); +// (Shirai142): Modify to here $page = $this->pagenumber; $next = get_string('next', 'search'); $back = get_string('back', 'search'); diff -Naru search_original/Zend/Search/Lucene.php search/Zend/Search/Lucene.php --- search_original/Zend/Search/Lucene.php 2009-01-08 17:04:10.127375000 +0900 +++ search/Zend/Search/Lucene.php 2009-05-30 19:31:16.314470700 +0900 @@ -779,7 +779,11 @@ public function find($query) { if (is_string($query)) { - $query = Zend_Search_Lucene_Search_QueryParser::parse($query); +// (Shirai144): When input multibyte characters as search key, iconv library does not work and the search process halt by the error (2009/05/29) +// (Shirai144): Modify from here +// $query = Zend_Search_Lucene_Search_QueryParser::parse($query); + $query = Zend_Search_Lucene_Search_QueryParser::parse($query, 'UTF-8'); +// (Shirai144): Modify to here } if (!$query instanceof Zend_Search_Lucene_Search_Query) {