/** Zend_Search_Lucene_LockManager */
require_once "Zend/Search/Lucene/LockManager.php";
+//require_once "Zend/Search/Lucene/SoftLockManager.php";
Zend_Search_Lucene_LockManager::obtainReadLock($this->_directory);
// Escalate read lock to prevent current generation index files to be deleted while opening process is not done
-// Zend_Search_Lucene_LockManager::escalateReadLock($this->_directory);
+ Zend_Search_Lucene_LockManager::escalateReadLock($this->_directory);
$this->_generation = self::getActualGeneration($this->_directory);
}
// De-escalate read lock to prevent current generation index files to be deleted while opening process is not done
-// Zend_Search_Lucene_LockManager::escalateReadLock($this->_directory);
+ Zend_Search_Lucene_LockManager::deEscalateReadLock($this->_directory);
}
/**
* @category core
* @subpackage document_wrappers
* @author Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @contributor Tatsuva Shirai 20090530
* @date 2008/03/31
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @version Moodle 2.0
}
} elseif ($itemtype == 'submission') {
if ($submission = $DB->get_record('assignment_submissions', array('id' => $id))){
- $assignment = $DB->get_record('assignment', array('id' => $submission->assignment));
+ if (!$assignment = $DB->get_record('assignment', array('id' => $submission->assignment))){
+ return null;
+ }
} else {
return null;
}
$context = $DB->get_record('context', array('id' => $context_id));
$cm = $DB->get_record('course_modules', array('id' => $context->instanceid));
+ if (empty($cm)) return false; // Shirai 20090530 - 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 assignment ";
return false;
* @category core
* @subpackage document_wrappers
* @author Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @contributor Tatsuva Shirai 20090530
* @date 2008/03/31
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @version Moodle 2.0
$context = $DB->get_record('context', array('id' => $context_id));
$cm = $DB->get_record('course_modules', array('id' => $context->instanceid));
+ if (empty($cm)) return false; // Shirai 20090530 - 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 chat ";
return false;
* @category core
* @subpackage document_wrappers
* @author Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @contributor Tatsuva Shirai 20090530
* @date 2008/03/31
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @version Moodle 2.0
//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'];
$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) {
if ($records_comments){
foreach($records_comments as $aComment){
$aComment->title = $recordsTitle[$aComment->recordid];
+ $authoruser = $DB->get_record('user', array('id' => $aComment->userid));
+ $aComment->author = fullname($authoruser);
$documents[] = new DataCommentSearchDocument(get_object_vars($aComment), $database->course, $context->id);
}
}
$cm = $DB->get_record('course_modules', array('course' => $record_course, 'module' => $coursemodule, 'instance' => $recordMetaData->dataid));
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
// 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
$comment->title = $DB->get_field('search_document', 'title', array('docid' => $record->id, 'itemtype' => 'record'));
$comment->dataid = $record->dataid;
$comment->groupid = $record->groupid;
+ $authoruser = $DB->get_record('user', array('id' => $comment->userid));
+ $comment->author = fullname($authoruser);
// make document
return new DataCommentSearchDocument(get_object_vars($comment), $record_course, $context->id);
} else {
$context = $DB->get_record('context', array('id' => $context_id));
$cm = $DB->get_record('course_modules', array('id' => $context->instanceid));
+ if (empty($cm)) return false; // Shirai 20090530 - MDL19342 - course module might have been delete
+
if (!$cm->visible && !has_capability('moodle/course:viewhiddenactivities', $context)) {
if (!empty($CFG->search_access_debug)) echo "search reject : hidden database ";
return false;
* @category core
* @subpackage document_wrappers
* @author Michael Campanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @contributor Tatsuva Shirai 20090530
* @date 2008/03/31
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @version Moodle 2.0
$discussion = $DB->get_record('forum_discussions', array('id' => $post->discussion));
$context = $DB->get_record('context', array('id' => $context_id));
$cm = $DB->get_record('course_modules', array('id' => $context->instanceid));
- // $cm = get_coursemodule_from_instance('forum', $discussion->forum, $discussion->course);
- // $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+
+ if (empty($cm)) return false; // Shirai 20090530 - 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 forum resource ";
return false;
* @category core
* @subpackage document_wrappers
* @author Michael Campanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @contributor Tatsuva Shirai 20090530
* @date 2008/03/31
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @version Moodle 2.0
$context = $DB->get_record('context', array('id' => $context_id));
$cm = $DB->get_record('course_modules', array('id' => $context->instanceid));
+ if (empty($cm)) return false; // Shirai 20090530 - MDL19342 - course module might have been delete
+
if (!$cm->visible && !has_capability('moodle/course:viewhiddenactivities', $context)) {
return false;
}
* @category core
* @subpackage document_wrappers
* @author Valery Fremaux [valery.fremaux@club-internet.fr] > 1.9
+* @contributor Tatsuva Shirai 20090530
* @date 2008/03/31
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @version Moodle 2.0
$r = $DB->get_record('label', array('id' => $this_id));
$module_context = $DB->get_record('context', array('id' => $context_id));
$cm = $DB->get_record('course_modules', array('id' => $module_context->instanceid));
+
+ if (empty($cm)) return false; // Shirai 20090530 - MDL19342 - course module might have been delete
+
$course_context = get_context_instance(CONTEXT_COURSE, $r->course);
//check if englobing course is visible
* @category core
* @subpackage document_wrappers
* @author Michael Campanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @contributor Tatsuva Shirai 20090530
* @date 2008/03/31
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @version Moodle 2.0
$context = $DB->get_record('context', array('id' => $context_id));
$cm = $DB->get_record('course_modules', array('id' => $context->instanceid));
+ if (empty($cm)) return false; // Shirai 20090530 - 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 lesson ";
return false;
// 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.');
+ mtrace('Error with MSWord to text converter command : executable not found at '.$moodleroot.$CFG->block_search_word_to_text_cmd);
} else {
if ($directfile == ''){
$file = escapeshellarg("{$CFG->dataroot}/{$resource->course}/{$resource->reference}");
// 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.');
+ mtrace('Error with OpenOffice ODT to text converter command : exectuable not found at '.$moodleroot.$CFG->block_search_odt_to_text_cmd);
} else {
if ($directfile == ''){
$file = escapeshellarg("{$CFG->dataroot}/{$resource->course}/{$resource->reference}");
$indextext = shorten($text, $CFG->block_search_limit_index_body);
}
- $indextext = mb_convert_encoding($indextext, 'UTF8', 'auto');
+ $indextext = mb_convert_encoding($indextext, 'UTF-8', 'auto');
return $indextext;
}
?>
\ No newline at end of file
* @category core
* @subpackage document_wrappers
* @author Michael Campanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @contributor Tatsuva Shirai 20090530
* @date 2008/03/31
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @version Moodle 2.0
id as trueid,
r.*
FROM
- {resource} r
+ {resource} as r
WHERE
alltext != '' AND
alltext != ' ' AND
r.type as type,
r.timemodified as timemodified
FROM
- {resource} r,
- {course_modules} cm,
- {modules} m
+ {resource} as r,
+ {course_modules} as cm,
+ {modules} as m
WHERE
r.type = 'file' AND
cm.instance = r.id AND
r.type as type,
r.timemodified as timemodified
FROM
- {resource} r,
- {course_modules} cm,
- {modules} m
+ {resource} as r,
+ {course_modules} as cm,
+ {modules} as m
WHERE
cm.instance = r.id AND
cm.course = r.course AND
$r = $DB->get_record('resource', array('id' => $this_id));
$module_context = $DB->get_record('context', array('id' => $context_id));
$cm = $DB->get_record('course_modules', array('id' => $module_context->instanceid));
+
+ if (empty($cm)) return false; // Shirai 20090530 - MDL19342 - course module might have been delete
+
$course = $DB->get_record('course', array('id' => $r->course));
$course_context = get_context_instance(CONTEXT_COURSE, $r->course);
// module specific information; optional
// construct the parent class
- 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);
}
}
$user = $DB->get_record('user', array('id' => $user_id));
// we cannot call userdate with relevant locale at indexing time.
- $doc->title = get_string('post').': '.fullname($user);
+ //$doc->title = get_string('post').': '.fullname($user);
+ $doc->title = $post['subject'];
$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');
+ // $doc->url = user_make_link($user_id, 'post');
+ $doc->url = user_make_link($post['id'], 'post');
// module specific information; optional
// construct the parent class
- 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);
}
}
// module specific information; optional
// construct the parent class
- 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);
}
}
if ($itemtype == 'user'){
return $CFG->wwwroot.'/user/view.php?id='.$itemid;
} elseif ($itemtype == 'post') {
- return $CFG->wwwroot.'/blog/index.php?userid='.$itemid;
+ return $CFG->wwwroot.'/blog/index.php?postid='.$itemid;
} elseif ($itemtype == 'attachment') {
$post = $DB->get_record('post', array('id' => $itemid));
if (!$CFG->slasharguments){
* @category core
* @subpackage document_wrappers
* @author Michael Campanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @contributor Tatsuva Shirai 20090530
* @date 2008/03/31
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @version Moodle 2.0
$course = $DB->get_record('course', array('id' => $entry->course));
$context = $DB->get_record('context', array('id' => $context_id));
$cm = $DB->get_record('course_modules', array('id' => $context->instanceid));
+
+ if (empty($cm)) return false; // Shirai 20090530 - MDL19342 - course module might have been delete
+
if (!$cm->visible && !has_capability('moodle/course:viewhiddenactivities', $context)) {
if (!empty($CFG->search_access_debug)) echo "search reject : hidden wiki ";
return false;
* @subpackage search_engine
* @author Michael Champanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
* @date 2008/03/31
- * @version prepared for 2.0
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* The query page - accepts a user-entered query string and returns results.
}
// add module restriction
- $doctypestr = get_string('doctype', 'search');
- $titlestr = get_string('title', 'search');
- $authorstr = get_string('author', 'search');
+ $doctypestr = 'doctype';
+ $titlestr = 'title';
+ $authorstr = 'author';
if ($adv->module != 'all') {
$query_string .= " +{$doctypestr}:".$adv->module;
}
?>
</form>
<br/>
- <div class="mdl-align">
+
+ <div align="center">
<?php
print_string('searching', 'search') . ': ';
foreach ($hits as $listing) {
if ($listing->doctype == 'user'){ // A special handle for users
- $icon = print_user_picture ($listing->author, 0, true, 0, true, false) ;
+ $icon = print_user_picture ($listing->userid, 0, true, 0, true, false) ;
} else {
$iconpath = $CFG->modpixpath.'/'.$listing->doctype.'/icon.gif';
$icon = "<img align=\"top\" src=\"".$iconpath."\" class=\"activityicon\" alt=\"\"/>";
}
print_box_end();
?>
- <div class="mdl-align">
+ <div align="center">
<?php
print_string('ittook', 'search');
search_stopwatch();
* @subpackage search_engine
* @author Michael Champanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
* @date 2008/03/31
-* @version prepared for 2.0
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
$resultdoc->doctype = $hit->doctype;
$resultdoc->author = $hit->author;
$resultdoc->courseid = $hit->course_id;
+ $resultdoc->userid = $hit->user_id;
//and store it
$resultdocs[] = clone($resultdoc);
*/
public function page_numbers() {
$pages = $this->total_pages();
- $query = htmlentities($this->term);
+ $query = htmlentities($this->term,ENT_NOQUOTES,'utf-8');
$page = $this->pagenumber;
$next = get_string('next', 'search');
$back = get_string('back', 'search');
- $ret = "<div class='mdl-align' id='search_page_links'>";
+ $ret = "<div align='center' id='search_page_links'>";
//Back is disabled if we're on page 1
if ($page > 1) {
return $this->results_per_page;
}
}
-?>
+?>
\ No newline at end of file