/** * constructor */ public function __construct(&$assignmentitem, $assignment_module_id, $itemtype, $course_id, $owner_id, $context_id, $submissionoffset = null) { // generic information; required $doc->docid = $assignmentitem['id']; $doc->documenttype = SEARCH_TYPE_ASSIGNMENT; $doc->itemtype = $itemtype; $doc->contextid = $context_id; // we cannot call userdate with relevant locale at indexing time. $doc->title = "{$itemtype}: {$assignmentitem['name']}"; $doc->date = $assignmentitem['date']; //remove '(ip.ip.ip.ip)' from chat author list $doc->author = $assignmentitem['authors']; if ($itemtype == 'intro') { $doc->contents = $assignmentitem['intro']; $doc->url = assignment_make_link($assignment_module_id, $itemtype, $owner_id); } else { $doc->contents = $assignmentitem['data1']; $doc->url = assignment_make_link($assignment_module_id, $itemtype, $owner_id, $submissionoffset); } // module specific information; optional $data->assignment = $assignment_module_id; $data->assignmenttype = $assignmentitem['assignmenttype']; // construct the parent class parent::__construct($doc, $data, $course_id, 0, 0, 'mod/' . SEARCH_TYPE_ASSIGNMENT); }
public function __construct(&$customlabel, &$class, $context_id) { // generic information; required $doc->docid = $customlabel['course']; $doc->documenttype = X_SEARCH_TYPE_CUSTOMLABEL; $doc->itemtype = 'customlabel'; $doc->contextid = $context_id; $doc->title = strip_tags($customlabel['title']); $doc->date = $customlabel['timemodified']; $doc->author = ''; $doc->contents = strip_tags($customlabel['name']); // echo "indexing ".strip_tags($customlabel['name']); $doc->url = customlabel_make_link($customlabel['course']); // module specific information : extract fields from serialized content. Add those who are // lists as keyfields $content = json_decode(base64_decode($customlabel['safecontent'])); $additionalKeys = NULL; // scan field and get as much searchable fields foreach ($class->fields as $afield) { if (preg_match("/list\$/", $afield->type)) { if (!isset($afield->multiple)) { $fieldname = $afield->name; if (!empty($content->{$fieldname})) { $additionalKeys[$fieldname] = $content->{$fieldname}; } } } } // construct the parent class parent::__construct($doc, $data, $customlabel['course'], 0, 0, 'mod/' . X_SEARCH_TYPE_CUSTOMLABEL, $additionalKeys); }
/** * constructor * */ public function __construct(&$page, $lessonmodule_id, $course_id, $itemtype, $context_id) { // generic information $doc->docid = $page['id']; $doc->documenttype = SEARCH_TYPE_LESSON; $doc->itemtype = $itemtype; $doc->contextid = $context_id; $doc->title = $page['title']; $doc->author = ''; $doc->contents = $page['contents']; $doc->date = $page['timecreated']; $doc->url = lesson_make_link($lessonmodule_id, $page['id'], $itemtype); // module specific information $data->lesson = $page['lessonid']; parent::__construct($doc, $data, $course_id, 0, 0, PATH_FOR_SEARCH_TYPE_LESSON); }
/** * constructor * */ public function __construct(&$entry, $course_id, $context_id) { // generic information $doc->docid = $entry['id']; $doc->documenttype = SEARCH_TYPE_TECHPROJECT; $doc->itemtype = $entry['entry_type']; $doc->contextid = $context_id; $doc->title = $entry['abstract']; $doc->author = $entry['userid'] ? $entry['author'] : ''; $doc->contents = strip_tags($entry['description']); $doc->date = ''; $doc->url = techproject_make_link($entry['projectid'], $entry['id'], $entry['entry_type'], $entry['groupid']); // module specific information $data->techproject = $entry['projectid']; parent::__construct($doc, $data, $course_id, $entry['groupid'], $entry['userid'], PATH_FOR_SEARCH_TYPE_TECHPROJECT); }
public function __construct(&$resource, $context_id) { // generic information; required $doc->docid = $resource['trueid']; $doc->documenttype = SEARCH_TYPE_RESOURCE; $doc->itemtype = $resource['type']; $doc->contextid = $context_id; $doc->title = strip_tags($resource['name']); $doc->date = $resource['timemodified']; $doc->author = ''; $doc->contents = strip_tags($resource['summary']) . ' ' . strip_tags($resource['alltext']); $doc->url = resource_make_link($resource['id']); // module specific information; optional $data = array(); // construct the parent class parent::__construct($doc, $data, $resource['course'], 0, 0, 'mod/' . SEARCH_TYPE_RESOURCE); }
/** * constructor * */ public function __construct(&$post, $forum_id, $course_id, $itemtype, $context_id) { // generic information $doc->docid = $post['id']; $doc->documenttype = SEARCH_TYPE_FORUM; $doc->itemtype = $itemtype; $doc->contextid = $context_id; $doc->title = $post['subject']; $doc->author = $post['firstname'] . " " . $post['lastname']; $doc->contents = $post['message']; $doc->date = $post['created']; $doc->url = forum_make_link($post['discussion'], $post['id']); // module specific information $data->forum = $forum_id; $data->discussion = $post['discussion']; parent::__construct($doc, $data, $course_id, $post['groupid'], $post['userid'], PATH_FOR_SEARCH_TYPE_FORUM); }
public function __construct(&$label, $context_id) { // generic information; required $doc->docid = $label['id']; $doc->documenttype = SEARCH_TYPE_LABEL; $doc->itemtype = 'label'; $doc->contextid = $context_id; $doc->title = strip_tags($label['name']); $doc->date = $label['timemodified']; $doc->author = ''; $doc->contents = strip_tags($label['intro']); $doc->url = label_make_link($label['course']); // module specific information; optional $data = array(); // construct the parent class parent::__construct($doc, $data, $label['course'], 0, 0, 'mod/' . SEARCH_TYPE_LABEL); }
/** * constructor */ public function __construct(&$comment, $course_id, $context_id) { // generic information; required $doc->docid = $comment['id']; $doc->documenttype = SEARCH_TYPE_DATA; $doc->itemtype = 'comment'; $doc->contextid = $context_id; $doc->title = get_string('commenton', 'search') . ' ' . $comment['title']; $doc->date = $comment['modified']; //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($comment['dataid'], $comment['recordid']); // module specific information; optional $data->database = $comment['dataid']; // construct the parent class parent::__construct($doc, $data, $course_id, $comment['groupid'], $comment['userid'], 'mod/' . SEARCH_TYPE_DATA); }
public function __construct(&$page, $wiki_id, $course_id, $group_id, $user_id, $context_id) { // generic information; required $doc->docid = $page['id']; $doc->documenttype = SEARCH_TYPE_WIKI; $doc->itemtype = 'standard'; $doc->contextid = $context_id; $doc->title = $page['pagename']; $doc->date = $page['lastmodified']; //remove '(ip.ip.ip.ip)' from wiki author field $doc->author = preg_replace('/\\(.*?\\)/', '', $page['author']); $doc->contents = $page['content']; $doc->url = wiki_make_link($wiki_id, $page['pagename'], $page['version']); // module specific information; optional $data->version = $page['version']; $data->wiki = $wiki_id; // construct the parent class parent::__construct($doc, $data, $course_id, $group_id, $user_id, 'mod/' . SEARCH_TYPE_WIKI); }
/** * constructor * @uses $DB; */ public function __construct(&$post, $forum_id, $course_id, $itemtype, $context_id) { global $DB; // generic information $doc->docid = $post['id']; $doc->documenttype = SEARCH_TYPE_FORUM; $doc->itemtype = $itemtype; $doc->contextid = $context_id; $doc->title = $post['subject']; $user = $DB->get_record('user', array('id' => $post['userid'])); $doc->author = fullname($user); $doc->contents = $post['message']; $doc->date = $post['created']; $doc->url = forum_make_link($post['discussion'], $post['id']); // module specific information $data->forum = $forum_id; $data->discussion = $post['discussion']; parent::__construct($doc, $data, $course_id, $post['groupid'], $post['userid'], 'mod/' . SEARCH_TYPE_FORUM); }
/** * document constructor */ public function __construct(&$entry, $glossary_id, $course_id, $context_id) { // generic information; required $doc->docid = $entry['id']; $doc->documenttype = SEARCH_TYPE_GLOSSARY; $doc->itemtype = 'comment'; $doc->contextid = $context_id; $doc->title = get_string('commenton', 'search') . ' ' . $entry['concept']; $doc->date = $entry['timemodified']; if ($entry['userid']) { $user = get_record('user', 'id', $entry['userid']); } $doc->author = $user ? $user->firstname . ' ' . $user->lastname : ''; $doc->contents = strip_tags($entry['entrycomment']); $doc->url = glossary_make_link($entry['entryid']); // module specific information; optional $data->glossary = $glossary_id; // construct the parent class parent::__construct($doc, $data, $course_id, -1, $entry['userid'], 'mod/' . SEARCH_TYPE_GLOSSARY); }
/** * constructor */ public function __construct(&$chatsession, $chat_id, $chat_module_id, $course_id, $group_id, $context_id) { // generic information; required $doc->docid = $chat_id . '-' . $chatsession['sessionstart'] . '-' . $chatsession['sessionend']; $doc->documenttype = SEARCH_TYPE_CHAT; $doc->itemtype = 'session'; $doc->contextid = $context_id; $duration = $chatsession['sessionend'] - $chatsession['sessionstart']; // we cannot call userdate with relevant locale at indexing time. $doc->title = get_string('chatreport', 'chat') . ' ' . get_string('openedon', 'search') . ' TT_' . $chatsession['sessionstart'] . '_TT (' . get_string('duration', 'search') . ' : ' . get_string('numseconds', '', $duration) . ')'; $doc->date = $chatsession['sessionend']; //remove '(ip.ip.ip.ip)' from chat author list $doc->author = preg_replace('/\\(.*?\\)/', '', $chatsession['authors']); $doc->contents = $chatsession['content']; $doc->url = chat_make_link($chat_module_id, $chatsession['sessionstart'], $chatsession['sessionend']); // module specific information; optional $data->chat = $chat_id; // construct the parent class parent::__construct($doc, $data, $course_id, $group_id, 0, 'mod/' . SEARCH_TYPE_CHAT); }
/** * constructor * @uses $DB */ public function __construct(&$post, $context_id) { global $DB; // generic information; required $doc->docid = $post['id']; $doc->documenttype = SEARCH_TYPE_USER; $doc->itemtype = 'attachment'; $doc->contextid = $context_id; $user = $DB->get_record('user', 'id', $post['userid']); // we cannot call userdate with relevant locale at indexing time. $doc->title = get_string('file') . ' : ' . $post['subject']; $doc->date = $post['created']; //remove '(ip.ip.ip.ip)' from chat author list $doc->author = fullname($user); $doc->contents = $post['alltext']; $doc->url = user_make_link($post['id'], 'attachment'); // module specific information; optional // construct the parent class parent::__construct($doc, $data, 0, 0, 0, PATH_FOR_SEARCH_TYPE_USER); }