Example #1
0
 /**
  * Constructor.
  *
  * @param object $course The course.
  * @param object $user The user.
  */
 public function __construct($course)
 {
     global $DB;
     $this->course = $course;
     $this->scripturl = new moodle_url('/mod/forum/forum.js');
     $this->showfullwords = $DB->get_dbfamily() == 'mysql' || $DB->get_dbfamily() == 'postgres';
     $forumoptions = ['' => get_string('allforums', 'forum')] + forum_menu_list($course);
     $this->forumoptions = array_map(function ($option) use($forumoptions) {
         return ['value' => $option, 'name' => $forumoptions[$option]];
     }, array_keys($forumoptions));
 }
Example #2
0
/**
 * @todo Document this function
 */
function forum_print_big_search_form($course)
{
    global $CFG, $DB, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto, $PAGE, $OUTPUT;
    echo $OUTPUT->box(get_string('searchforumintro', 'forum'), 'searchbox boxaligncenter', 'intro');
    echo $OUTPUT->box_start('generalbox boxaligncenter');
    echo html_writer::script('', $CFG->wwwroot . '/mod/forum/forum.js');
    echo '<form id="searchform" action="search.php" method="get">';
    echo '<table cellpadding="10" class="searchbox" id="form">';
    echo '<tr>';
    echo '<td class="c0"><label for="words">' . get_string('searchwords', 'forum') . '</label>';
    echo '<input type="hidden" value="' . $course->id . '" name="id" alt="" /></td>';
    echo '<td class="c1"><input type="text" size="35" name="words" id="words"value="' . s($words, true) . '" alt="" /></td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0"><label for="phrase">' . get_string('searchphrase', 'forum') . '</label></td>';
    echo '<td class="c1"><input type="text" size="35" name="phrase" id="phrase" value="' . s($phrase, true) . '" alt="" /></td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0"><label for="notwords">' . get_string('searchnotwords', 'forum') . '</label></td>';
    echo '<td class="c1"><input type="text" size="35" name="notwords" id="notwords" value="' . s($notwords, true) . '" alt="" /></td>';
    echo '</tr>';
    if ($DB->get_dbfamily() == 'mysql' || $DB->get_dbfamily() == 'postgres') {
        echo '<tr>';
        echo '<td class="c0"><label for="fullwords">' . get_string('searchfullwords', 'forum') . '</label></td>';
        echo '<td class="c1"><input type="text" size="35" name="fullwords" id="fullwords" value="' . s($fullwords, true) . '" alt="" /></td>';
        echo '</tr>';
    }
    echo '<tr>';
    echo '<td class="c0">' . get_string('searchdatefrom', 'forum') . '</td>';
    echo '<td class="c1">';
    if (empty($datefrom)) {
        $datefromchecked = '';
        $datefrom = make_timestamp(2000, 1, 1, 0, 0, 0);
    } else {
        $datefromchecked = 'checked="checked"';
    }
    echo '<input name="timefromrestrict" type="checkbox" value="1" alt="' . get_string('searchdatefrom', 'forum') . '" onclick="return lockoptions(\'searchform\', \'timefromrestrict\', timefromitems)" ' . $datefromchecked . ' /> ';
    $selectors = html_writer::select_time('days', 'fromday', $datefrom) . html_writer::select_time('months', 'frommonth', $datefrom) . html_writer::select_time('years', 'fromyear', $datefrom) . html_writer::select_time('hours', 'fromhour', $datefrom) . html_writer::select_time('minutes', 'fromminute', $datefrom);
    echo $selectors;
    echo '<input type="hidden" name="hfromday" value="0" />';
    echo '<input type="hidden" name="hfrommonth" value="0" />';
    echo '<input type="hidden" name="hfromyear" value="0" />';
    echo '<input type="hidden" name="hfromhour" value="0" />';
    echo '<input type="hidden" name="hfromminute" value="0" />';
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0">' . get_string('searchdateto', 'forum') . '</td>';
    echo '<td class="c1">';
    if (empty($dateto)) {
        $datetochecked = '';
        $dateto = time() + 3600;
    } else {
        $datetochecked = 'checked="checked"';
    }
    echo '<input name="timetorestrict" type="checkbox" value="1" alt="' . get_string('searchdateto', 'forum') . '" onclick="return lockoptions(\'searchform\', \'timetorestrict\', timetoitems)" ' . $datetochecked . ' /> ';
    $selectors = html_writer::select_time('days', 'today', $dateto) . html_writer::select_time('months', 'tomonth', $dateto) . html_writer::select_time('years', 'toyear', $dateto) . html_writer::select_time('hours', 'tohour', $dateto) . html_writer::select_time('minutes', 'tominute', $dateto);
    echo $selectors;
    echo '<input type="hidden" name="htoday" value="0" />';
    echo '<input type="hidden" name="htomonth" value="0" />';
    echo '<input type="hidden" name="htoyear" value="0" />';
    echo '<input type="hidden" name="htohour" value="0" />';
    echo '<input type="hidden" name="htominute" value="0" />';
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0"><label for="menuforumid">' . get_string('searchwhichforums', 'forum') . '</label></td>';
    echo '<td class="c1">';
    echo html_writer::select(forum_menu_list($course), 'forumid', '', array('' => get_string('allforums', 'forum')));
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0"><label for="subject">' . get_string('searchsubject', 'forum') . '</label></td>';
    echo '<td class="c1"><input type="text" size="35" name="subject" id="subject" value="' . s($subject, true) . '" alt="" /></td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0"><label for="user">' . get_string('searchuser', 'forum') . '</label></td>';
    echo '<td class="c1"><input type="text" size="35" name="user" id="user" value="' . s($user, true) . '" alt="" /></td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="submit" colspan="2" align="center">';
    echo '<input type="submit" value="' . get_string('searchforums', 'forum') . '" alt="" /></td>';
    echo '</tr>';
    echo '</table>';
    echo '</form>';
    echo html_writer::script(js_writer::function_call('lockoptions_timetoitems'));
    echo html_writer::script(js_writer::function_call('lockoptions_timefromitems'));
    echo $OUTPUT->box_end();
}
Example #3
0
/**
 * @todo Document this function
 */
function forum_print_big_search_form($course)
{
    global $CFG, $DB, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto;
    print_simple_box(get_string('searchforumintro', 'forum'), 'center', '', '', 'searchbox', 'intro');
    print_simple_box_start("center");
    echo "<script type=\"text/javascript\">\n";
    echo "var timefromitems = ['fromday','frommonth','fromyear','fromhour', 'fromminute'];\n";
    echo "var timetoitems = ['today','tomonth','toyear','tohour','tominute'];\n";
    echo "</script>\n";
    echo '<form id="searchform" action="search.php" method="get">';
    echo '<table cellpadding="10" class="searchbox" id="form">';
    echo '<tr>';
    echo '<td class="c0"><label for="words">' . get_string('searchwords', 'forum') . '</label>';
    echo '<input type="hidden" value="' . $course->id . '" name="id" alt="" /></td>';
    echo '<td class="c1"><input type="text" size="35" name="words" id="words"value="' . s($words, true) . '" alt="" /></td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0"><label for="phrase">' . get_string('searchphrase', 'forum') . '</label></td>';
    echo '<td class="c1"><input type="text" size="35" name="phrase" id="phrase" value="' . s($phrase, true) . '" alt="" /></td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0"><label for="notwords">' . get_string('searchnotwords', 'forum') . '</label></td>';
    echo '<td class="c1"><input type="text" size="35" name="notwords" id="notwords" value="' . s($notwords, true) . '" alt="" /></td>';
    echo '</tr>';
    if ($DB->get_db_family() == 'mysql' || $DB->get_db_family() == 'postgres') {
        echo '<tr>';
        echo '<td class="c0"><label for="fullwords">' . get_string('searchfullwords', 'forum') . '</label></td>';
        echo '<td class="c1"><input type="text" size="35" name="fullwords" id="fullwords" value="' . s($fullwords, true) . '" alt="" /></td>';
        echo '</tr>';
    }
    echo '<tr>';
    echo '<td class="c0">' . get_string('searchdatefrom', 'forum') . '</td>';
    echo '<td class="c1">';
    if (empty($datefrom)) {
        $datefromchecked = '';
        $datefrom = make_timestamp(2000, 1, 1, 0, 0, 0);
    } else {
        $datefromchecked = 'checked="checked"';
    }
    echo '<input name="timefromrestrict" type="checkbox" value="1" alt="' . get_string('searchdatefrom', 'forum') . '" onclick="return lockoptions(\'searchform\', \'timefromrestrict\', timefromitems)" ' . $datefromchecked . ' /> ';
    print_date_selector('fromday', 'frommonth', 'fromyear', $datefrom);
    print_time_selector('fromhour', 'fromminute', $datefrom);
    echo '<input type="hidden" name="hfromday" value="0" />';
    echo '<input type="hidden" name="hfrommonth" value="0" />';
    echo '<input type="hidden" name="hfromyear" value="0" />';
    echo '<input type="hidden" name="hfromhour" value="0" />';
    echo '<input type="hidden" name="hfromminute" value="0" />';
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0">' . get_string('searchdateto', 'forum') . '</td>';
    echo '<td class="c1">';
    if (empty($dateto)) {
        $datetochecked = '';
        $dateto = time() + 3600;
    } else {
        $datetochecked = 'checked="checked"';
    }
    echo '<input name="timetorestrict" type="checkbox" value="1" alt="' . get_string('searchdateto', 'forum') . '" onclick="return lockoptions(\'searchform\', \'timetorestrict\', timetoitems)" ' . $datetochecked . ' /> ';
    print_date_selector('today', 'tomonth', 'toyear', $dateto);
    print_time_selector('tohour', 'tominute', $dateto);
    echo '<input type="hidden" name="htoday" value="0" />';
    echo '<input type="hidden" name="htomonth" value="0" />';
    echo '<input type="hidden" name="htoyear" value="0" />';
    echo '<input type="hidden" name="htohour" value="0" />';
    echo '<input type="hidden" name="htominute" value="0" />';
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0"><label for="menuforumid">' . get_string('searchwhichforums', 'forum') . '</label></td>';
    echo '<td class="c1">';
    choose_from_menu(forum_menu_list($course), 'forumid', '', get_string('allforums', 'forum'), '');
    echo '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0"><label for="subject">' . get_string('searchsubject', 'forum') . '</label></td>';
    echo '<td class="c1"><input type="text" size="35" name="subject" id="subject" value="' . s($subject, true) . '" alt="" /></td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="c0"><label for="user">' . get_string('searchuser', 'forum') . '</label></td>';
    echo '<td class="c1"><input type="text" size="35" name="user" id="user" value="' . s($user, true) . '" alt="" /></td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td class="submit" colspan="2" align="center">';
    echo '<input type="submit" value="' . get_string('searchforums', 'forum') . '" alt="" /></td>';
    echo '</tr>';
    echo '</table>';
    echo '</form>';
    echo "<script type=\"text/javascript\">";
    echo "lockoptions('searchform','timefromrestrict', timefromitems);";
    echo "lockoptions('searchform','timetorestrict', timetoitems);";
    echo "</script>\n";
    print_simple_box_end();
}