public function get_document($record, $options = array()) {

        try {
            $cm = $this->get_cm('forum', $record->forumid, $record->courseid);
            $context = \context_module::instance($cm->id);
        } catch (\dml_missing_record_exception $ex) {
            // Notify it as we run here as admin, we should see everything.
            debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document, not all required data is available: ' .
                $ex->getMessage(), DEBUG_DEVELOPER);
            return false;
        } catch (\dml_exception $ex) {
            // Notify it as we run here as admin, we should see everything.
            debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
            return false;
        }

        // Prepare associative array with data from DB.
        $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
        $doc->set('title', content_to_text($record->subject, false));
        $doc->set('content', content_to_text($record->message, $record->messageformat));
        $doc->set('contextid', $context->id);
        $doc->set('courseid', $record->courseid);
        $doc->set('userid', $record->userid);
        $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
        $doc->set('modified', $record->modified);

        // Store group id if there is one. (0 and -1 both mean not restricted to group.)
        if ($record->groupid > 0) {
            $doc->set('groupid', $record->groupid);
        }

        // Check if this document should be considered new.
        if (isset($options['lastindexedtime']) && ($options['lastindexedtime'] < $record->created)) {
            // If the document was created after the last index time, it must be new.
            $doc->set_is_new(true);
        }

        return $doc;
    }
public function get_document($record, $options = array()) {

        try {
            $cm = $this->get_cm('forum', $record->forumid, $record->courseid);
            $context = \context_module::instance($cm->id);
        } catch (\dml_missing_record_exception $ex) {
            // Notify it as we run here as admin, we should see everything.
            debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document, not all required data is available: ' .
                $ex->getMessage(), DEBUG_DEVELOPER);
            return false;
        } catch (\dml_exception $ex) {
            // Notify it as we run here as admin, we should see everything.
            debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
            return false;
        }

        // Prepare associative array with data from DB.
        $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
        $doc->set('title', content_to_text($record->subject, false));
        $doc->set('content', content_to_text($record->message, $record->messageformat));
        $doc->set('contextid', $context->id);
        $doc->set('courseid', $record->courseid);
        $doc->set('userid', $record->userid);
        $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
        $doc->set('modified', $record->modified);

        // Store group id if there is one. (0 and -1 both mean not restricted to group.)
        if ($record->groupid > 0) {
            $doc->set('groupid', $record->groupid);
        }

        // Check if this document should be considered new.
        if (isset($options['lastindexedtime']) && ($options['lastindexedtime'] < $record->created)) {
            // If the document was created after the last index time, it must be new.
            $doc->set_is_new(true);
        }

        return $doc;
    }
public function get_document ( $ record , $ options = array ( ) ) { try { $ cm = $ this -> get_cm ( 'forum' , $ record -> forumid , $ record -> courseid ) ; $ context = \ context_module :: instance ( $ cm -> id ) ; } catch ( \ dml_missing_record_exception $ ex ) { // Notify it as we run here as admin, we should see everything. debugging ( 'Error retrieving ' . $ this -> areaid . ' ' . $ record -> id . ' document, not all required data is available: ' . $ ex -> getMessage ( ) , DEBUG_DEVELOPER ) ; return false ; } catch ( \ dml_exception $ ex ) { // Notify it as we run here as admin, we should see everything. debugging ( 'Error retrieving ' . $ this -> areaid . ' ' . $ record -> id . ' document: ' . $ ex -> getMessage ( ) , DEBUG_DEVELOPER ) ; return false ; } // Prepare associative array with data from DB. $ doc = \ core_search \ document_factory :: instance ( $ record -> id , $ this -> componentname , $ this -> areaname ) ; $ doc -> set ( 'title' , content_to_text ( $ record -> subject , false ) ) ; $ doc -> set ( 'content' , content_to_text ( $ record -> message , $ record -> messageformat ) ) ; $ doc -> set ( 'contextid' , $ context -> id ) ; $ doc -> set ( 'courseid' , $ record -> courseid ) ; $ doc -> set ( 'userid' , $ record -> userid ) ; $ doc -> set ( 'owneruserid' , \ core_search \ manager :: NO_OWNER_ID ) ; $ doc -> set ( 'modified' , $ record -> modified ) ; // Store group id if there is one. (0 and -1 both mean not restricted to group.) if ( $ record -> groupid > 0 ) { $ doc -> set ( 'groupid' , $ record -> groupid ) ; } // Check if this document should be considered new. if ( isset ( $ options [ 'lastindexedtime' ] ) && ( $ options [ 'lastindexedtime' ] < $ record -> created ) ) { // If the document was created after the last index time, it must be new. $ doc -> set_is_new ( true ) ; } return $ doc ; }
Returns the document associated with this post id.

@param stdClass $record Post info.
@param array    $options
@return \core_search\document
Returns the document associated with this post id .