MDL-19342 - small fixes from Tatsuva Shirai + UTF-8 global straighten up

This commit is contained in:
diml
2009-05-30 22:16:28 +00:00
parent 902ec3ccc2
commit 29dc93d1cd
14 changed files with 112 additions and 27 deletions
+10 -6
View File
@@ -6,6 +6,7 @@
* @category core
* @subpackage document_wrappers
* @author Valery Fremaux [[email protected]] > 1.8
* @contributor Tatsuva Shirai 20090530
* @date 2008/03/31
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
@@ -79,7 +80,7 @@ class DataCommentSearchDocument extends SearchDocument {
//remove '(ip.ip.ip.ip)' from data record author field
$doc->author = preg_replace('/\(.*?\)/', '', $comment['author']);
$doc->contents = $comment['content'];
$doc->url = data_make_link($data_id, $comment['recordid']);
$doc->url = data_make_link($comment['dataid'], $comment['recordid']);
// module specific information; optional
$data->database = $comment['dataid'];
@@ -196,7 +197,7 @@ function data_get_content_for_index(&$database) {
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
// getting records for indexing
$records_content = data_get_records($database->id, 'text');
$records_content = data_get_records($database->id, 'text,textarea');
if ($records_content){
foreach(array_keys($records_content) as $aRecordId) {
@@ -222,7 +223,9 @@ function data_get_content_for_index(&$database) {
$records_comments = data_get_comments($database->id);
if ($records_comments){
foreach($records_comments as $aComment){
$aComment->title = $recordsTitles[$aComment->recordid];
$aComment->title = $recordTitles[$aComment->recordid];
$authoruser = get_record('user', 'id', $aComment->userid);
$aComment->author = fullname($authoruser);
$documents[] = new DataCommentSearchDocument(get_object_vars($aComment), $database->course, $context->id);
}
}
@@ -247,7 +250,7 @@ function data_single_document($id, $itemtype) {
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
// get text fields ids in this data (computable fields)
// compute text
$recordData = data_get_records($recordMetaData->dataid, 'text', $id);
$recordData = data_get_records($recordMetaData->dataid, 'text,textarea', $id);
if ($recordData){
$dataArray = array_values($recordData);
$record_content = $dataArray[0]; // We cannot have more than one record here
@@ -280,6 +283,8 @@ function data_single_document($id, $itemtype) {
$comment->title = get_field('search_document', 'title', 'docid', $record->id, 'itemtype', 'record');
$comment->dataid = $record->dataid;
$comment->groupid = $record->groupid;
$authoruser = get_record('user', 'id', $comment->userid);
$comment->author = fullname($authoruser);
// make document
return new DataCommentSearchDocument(get_object_vars($comment), $record_course, $context->id);
} else {
@@ -345,8 +350,7 @@ function data_check_text_access($path, $itemtype, $this_id, $user, $group_id, $c
$data = get_record('data', 'id', $record->dataid);
$context = get_record('context', 'id', $context_id);
$cm = get_record('course_modules', 'id', $context->instanceid);
// $cm = get_coursemodule_from_instance('data', $data->id, $data->course);
// $context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (empty($cm)) return false; // Shirai 20093005 - MDL19342 - course module might have been delete
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $context)) {
if (!empty($CFG->search_access_debug)) echo "search reject : hidden database ";