/** * Link to the course. * * @param \core_search\document $doc * @return \moodle_url */ public function get_context_url(\core_search\document $doc) { return new \moodle_url('/course/view.php', array('id' => $doc->get('courseid'))); }
/** * Link to the glossary. * * @param \core_search\document $doc * @return \moodle_url */ public function get_context_url(\core_search\document $doc) { $contextmodule = \context::instance_by_id($doc->get('contextid')); return new \moodle_url('/mod/glossary/view.php', array('id' => $contextmodule->instanceid)); }
/** * Returns a url to the document context. * * @param \core_search\document $doc * @return moodle_url */ public function get_context_url(\core_search\document $doc) { return new \moodle_url('/user/profile.php', array('id' => $doc->get('itemid'))); }
/** * Link to the module instance. * * @param \core_search\document $doc * @return \moodle_url */ public function get_context_url(\core_search\document $doc) { $cminfo = $this->get_cm($this->get_module_name(), strval($doc->get('itemid')), $doc->get('courseid')); return new \moodle_url('/mod/' . $this->get_module_name() . '/view.php', array('id' => $cminfo->id)); }
public function get_doc_url(\core_search\document $doc) { // This is just an example, can vary a lot depending on what are you indexing. return new \moodle_url('/local/courseblog/view.php', array('post' => $doc->get('contextid'))); }
/** * Add the database entries attachments. * * @param \core_search\document $doc * @return void */ public function attach_files($doc) { global $DB; $entryid = $doc->get('itemid'); try { $entry = $this->get_entry($entryid); } catch (\dml_missing_record_exception $e) { debugging('Could not get record to attach files to ' . $doc->get('id'), DEBUG_DEVELOPER); return; } $cm = $this->get_cm('data', $entry->dataid, $doc->get('courseid')); $context = \context_module::instance($cm->id); // Get the files and attach them. $fs = get_file_storage(); $files = $fs->get_area_files($context->id, 'mod_data', 'content', $entryid, 'filename', false); foreach ($files as $file) { $doc->add_stored_file($file); } }
/** * Sorting the current(user1) and other(user2) user in the conversation. * * @param \core_search\document $doc * @return array() */ protected function get_current_other_users($doc) { global $USER; $users = array(); if ($USER->id == $doc->get('owneruserid') || get_class($this) === 'message_sent') { $users['currentuserid'] = $doc->get('owneruserid'); $users['otheruserid'] = $doc->get('userid'); } else { $users['currentuserid'] = $doc->get('userid'); $users['otheruserid'] = $doc->get('owneruserid'); } return $users; }