Merge branch 'MDL-59459_Increase_file_indexing_coverage' of https://github.com/mattporritt/moodle

This commit is contained in:
Dan Poltawski 2017-09-11 14:01:40 +01:00
commit 743c937dae
33 changed files with 765 additions and 68 deletions

View file

@ -36,6 +36,7 @@ require_once($CFG->dirroot . '/mod/assign/locallib.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class activity extends \core_search\base_activity {
/**
* Returns true if this area uses file indexing.
*
@ -46,22 +47,14 @@ class activity extends \core_search\base_activity {
}
/**
* Add the attached description files.
* Return the context info required to index files for
* this search area.
*
* @param document $document The current document
* @return null
* @return array
*/
public function attach_files($document) {
$fs = get_file_storage();
public function get_search_fileareas() {
$fileareas = array('intro', ASSIGN_INTROATTACHMENT_FILEAREA); // Fileareas.
$cm = $this->get_cm($this->get_module_name(), $document->get('itemid'), $document->get('courseid'));
$context = \context_module::instance($cm->id);
$files = $fs->get_area_files($context->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, 0,
'sortorder DESC, id ASC', false);
foreach ($files as $file) {
$document->add_stored_file($file);
}
return $fileareas;
}
}