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

@ -34,6 +34,7 @@ defined('MOODLE_INTERNAL') || die();
* @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.
*
@ -44,21 +45,14 @@ class activity extends \core_search\base_activity {
}
/**
* Add all the folder files to the index.
* 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', 'content'); // 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_folder', 'content', 0, 'sortorder DESC, id ASC', false);
foreach ($files as $file) {
$document->add_stored_file($file);
}
return $fileareas;
}
}