Beispiel #1
0
 /**
  * Test course_searched event.
  */
 public function test_course_searched()
 {
     // Setup test data.
     $course = $this->getDataGenerator()->create_course();
     $coursectx = context_course::instance($course->id);
     $searchterm = 'testing123';
     $params = array('context' => $coursectx, 'other' => array('searchterm' => $searchterm));
     // Create event.
     $event = \mod_forum\event\course_searched::create($params);
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     $event->trigger();
     $events = $sink->get_events();
     $this->assertCount(1, $events);
     $event = reset($events);
     // Checking that the event contains the expected values.
     $this->assertInstanceOf('\\mod_forum\\event\\course_searched', $event);
     $this->assertEquals($coursectx, $event->get_context());
     $expected = array($course->id, 'forum', 'search', "search.php?id={$course->id}&search={$searchterm}", $searchterm);
     $this->assertEventLegacyLogData($expected, $event);
     $this->assertEventContextNotUsed($event);
     $this->assertNotEmpty($event->get_name());
 }
Beispiel #2
0
    if (!empty($dateto)) {
        $search .= ' dateto:' . $dateto;
    }
    $individualparams = true;
} else {
    $individualparams = false;
}
if ($search) {
    $search = forum_clean_search_terms($search);
}
if (!($course = $DB->get_record('course', array('id' => $id)))) {
    print_error('invalidcourseid');
}
require_course_login($course);
$params = array('context' => $PAGE->context, 'other' => array('searchterm' => $search));
$event = \mod_forum\event\course_searched::create($params);
$event->trigger();
$strforums = get_string("modulenameplural", "forum");
$strsearch = get_string("search", "forum");
$strsearchresults = get_string("searchresults", "forum");
$strpage = get_string("page");
if (!$search || $showform) {
    $PAGE->navbar->add($strforums, new moodle_url('/mod/forum/index.php', array('id' => $course->id)));
    $PAGE->navbar->add(get_string('advancedsearch', 'forum'));
    $PAGE->set_title($strsearch);
    $PAGE->set_heading($course->fullname);
    echo $OUTPUT->header();
    forum_print_big_search_form($course);
    echo $OUTPUT->footer();
    exit;
}