// before any action that may take longer time to finish.
function xmldb_forum_upgrade($oldversion) {
- global $CFG, $DB;
+ global $CFG, $DB, $OUTPUT;
$dbman = $DB->get_manager(); // loads ddl manager and xmldb classes
$result = true;
if ($result && $oldversion < 2007101512) {
/// Cleanup the forum subscriptions
- notify('Removing stale forum subscriptions', 'notifysuccess');
+ echo $OUTPUT->notification('Removing stale forum subscriptions', 'notifysuccess');
$roles = get_roles_with_capability('moodle/course:view', CAP_ALLOW);
$roles = array_keys($roles);
$filepath = "$CFG->dataroot/$post->course/$CFG->moddata/forum/$post->forum/$post->id/$post->attachment";
if (!is_readable($filepath)) {
//file missing??
- notify("File not readable, skipping: ".$filepath);
+ echo $OUTPUT->notification("File not readable, skipping: ".$filepath);
$post->attachment = '';
$DB->update_record('forum_posts', $post);
continue;
$filearea = 'forum_attachment';
$filename = clean_param($post->attachment, PARAM_FILE);
if ($filename === '') {
- notify("Unsupported post filename, skipping: ".$filepath);
+ echo $OUTPUT->notification("Unsupported post filename, skipping: ".$filepath);
$post->attachment = '';
$DB->update_record('forum_posts', $post);
continue;
}
if (!$forum = $DB->get_record('forum', array('id' => $discussion->forum))) {
- notify("Bad forum ID stored in this discussion");
+ echo $OUTPUT->notification("Bad forum ID stored in this discussion");
}
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
get_context_instance(CONTEXT_MODULE,$cmto->id));
if (!forum_move_attachments($discussion, $forum->id, $forumto->id)) {
- notify("Errors occurred while moving attachment directories - check your file permissions");
+ echo $OUTPUT->notification("Errors occurred while moving attachment directories - check your file permissions");
}
$DB->set_field('forum_discussions', 'forum', $forumto->id, array('id' => $discussion->id));
$DB->set_field('forum_read', 'forumid', $forumto->id, array('discussionid' => $discussion->id));
$a = new object();
$a->blockafter = $forum->blockafter;
$a->blockperiod = get_string('secondstotime'.$forum->blockperiod);
- notify(get_string('thisforumisthrottled','forum',$a));
+ echo $OUTPUT->notification(get_string('thisforumisthrottled','forum',$a));
}
if ($forum->type == 'qanda' && !has_capability('mod/forum:viewqandawithoutposting', $modcontext) &&
!forum_user_has_posted($forum->id,$discussion->id,$USER->id)) {
- notify(get_string('qandanotify','forum'));
+ echo $OUTPUT->notification(get_string('qandanotify','forum'));
}
if ($move == -1 and confirm_sesskey()) {
- notify(get_string('discussionmoved', 'forum', format_string($forum->name,true)));
+ echo $OUTPUT->notification(get_string('discussionmoved', 'forum', format_string($forum->name,true)));
}
$canrate = has_capability('mod/forum:rate', $modcontext);
* @return bool success
*/
function forum_update_instance($forum) {
- global $DB;
+ global $DB, $OUTPUT;
$forum->timemodified = time();
$forum->id = $forum->instance;
if ($forum->type == 'single') { // Update related discussion and post.
if (! $discussion = $DB->get_record('forum_discussions', array('forum'=>$forum->id))) {
if ($discussions = $DB->get_records('forum_discussions', array('forum'=>$forum->id), 'timemodified ASC')) {
- notify('Warning! There is more than one discussion in this forum - using the most recent');
+ echo $OUTPUT->notification('Warning! There is more than one discussion in this forum - using the most recent');
$discussion = array_pop($discussions);
} else {
// try to recover by creating initial discussion - MDL-16262
*/
function forum_get_course_forum($courseid, $type) {
// How to set up special 1-per-course forums
- global $CFG, $DB;
+ global $CFG, $DB, $OUTPUT;
if ($forums = $DB->get_records_select("forum", "course = ? AND type = ?", array($courseid, $type), "id ASC")) {
// There should always only be ONE, but with the right combination of
$forum->forcesubscribe = 0;
break;
default:
- notify("That forum type doesn't exist!");
+ echo $OUTPUT->notification("That forum type doesn't exist!");
return false;
break;
}
$forum->id = $DB->insert_record("forum", $forum);
if (! $module = $DB->get_record("modules", array("name" => "forum"))) {
- notify("Could not find forum module!!");
+ echo $OUTPUT->notification("Could not find forum module!!");
return false;
}
$mod = new object();
$mod->instance = $forum->id;
$mod->section = 0;
if (! $mod->coursemodule = add_course_module($mod) ) { // assumes course/lib.php is loaded
- notify("Could not add a new course module to the course '" . format_string($course->fullname) . "'");
+ echo $OUTPUT->notification("Could not add a new course module to the course '" . format_string($course->fullname) . "'");
return false;
}
if (! $sectionid = add_mod_to_section($mod) ) { // assumes course/lib.php is loaded
- notify("Could not add the new course module to that section");
+ echo $OUTPUT->notification("Could not add the new course module to that section");
return false;
}
if (! $DB->set_field("course_modules", "section", $sectionid, array("id" => $mod->coursemodule))) {
- notify("Could not update the course module with the correct section");
+ echo $OUTPUT->notification("Could not update the course module with the correct section");
return false;
}
include_once("$CFG->dirroot/course/lib.php");
* @return string
*/
function forum_search_form($course, $search='') {
- global $CFG;
+ global $CFG, $OUTPUT;
$output = '<div class="forumsearch">';
$output .= '<form action="'.$CFG->wwwroot.'/mod/forum/search.php" style="display:inline">';
$output .= '<fieldset class="invisiblefieldset">';
- $output .= helpbutton('search', get_string('search'), 'moodle', true, false, '', true);
+ $output .= $OUTPUT->help_icon(moodle_help_icon::make('search', get_string('search')));
$output .= '<input name="search" type="text" size="18" value="'.s($search, true).'" alt="search" />';
$output .= '<input value="'.get_string('searchforums', 'forum').'" type="submit" />';
$output .= '<input name="id" type="hidden" value="'.$course->id.'" />';
} else if ($groupmode and has_capability('mod/forum:startdiscussion', $context)) {
// inform users why they can not post new discussion
if ($currentgroup) {
- notify(get_string('cannotadddiscussion', 'forum'));
+ echo $OUTPUT->notification(get_string('cannotadddiscussion', 'forum'));
} else {
- notify(get_string('cannotadddiscussionall', 'forum'));
+ echo $OUTPUT->notification(get_string('cannotadddiscussionall', 'forum'));
}
}
* @return bool
*/
function forum_check_throttling($forum, $cm=null) {
- global $USER, $CFG, $DB;
+ global $USER, $CFG, $DB, $OUTPUT;
if (is_numeric($forum)) {
$forum = $DB->get_record('forum',array('id'=>$forum));
print_error('forumblockingtoomanyposts', 'error', $CFG->wwwroot.'/mod/forum/view.php?f='.$forum->id, $a);
}
if ($forum->warnafter <= $numposts) {
- notify(get_string('forumblockingalmosttoomanyposts','forum',$a));
+ echo $OUTPUT->notification(get_string('forumblockingalmosttoomanyposts','forum',$a));
}
function forum_convert_to_roles($forum, $forummodid, $teacherroles=array(),
$studentroles=array(), $guestroles=array(), $cmid=NULL) {
- global $CFG, $DB;
+ global $CFG, $DB, $OUTPUT;
if (!isset($forum->open) && !isset($forum->assesspublic)) {
// We assume that this forum has already been converted to use the
if (empty($cmid)) {
// We were not given the course_module id. Try to find it.
if (!$cm = get_coursemodule_from_instance('forum', $forum->id)) {
- notify('Could not get the course module for the forum');
+ echo $OUTPUT->notification('Could not get the course module for the forum');
return false;
} else {
$cmid = $cm->id;
&& !has_capability('mod/forum:viewqandawithoutposting', $modcontext)
&& !empty($discussion->id)
&& !forum_user_has_posted($forum->id, $discussion->id, $USER->id)) {
- notify(get_string('qandanotify','forum'));
+ echo $OUTPUT->notification(get_string('qandanotify','forum'));
}
forum_check_throttling($forum, $cm);
function forum_print_big_search_form($course) {
global $CFG, $DB, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto, $PAGE, $OUTPUT;
- print_simple_box(get_string('searchforumintro', 'forum'), 'center', '', '', 'searchbox', 'intro');
+ echo $OUTPUT->box(get_string('searchforumintro', 'forum'), 'searchbox boxaligncenter', 'intro');
- print_simple_box_start("center");
+ echo $OUTPUT->box_start('generalbox boxaligncenter');
echo $PAGE->requires->js('mod/forum/forum.js')->asap();
echo $PAGE->requires->js_function_call('lockoptions_timetoitems')->asap();
echo $PAGE->requires->js_function_call('lockoptions_timefromitems')->asap();
- print_simple_box_end();
+ echo $OUTPUT->box_end();
}
/**
}
}
- print_simple_box_start('center');
+ echo $OUTPUT->box_start('generalbox boxaligncenter');
include('subscriber.html');
- print_simple_box_end();
+ echo $OUTPUT->box_end();
echo $OUTPUT->footer();
$DB->delete_records('forum_subscriptions', array('userid'=>$USER->id));
$DB->set_field('user', 'autosubscribe', 0, array('id'=>$USER->id));
echo $OUTPUT->box(get_string('unsubscribealldone', 'forum'));
- print_continue($return);
+ echo $OUTPUT->continue_button($return);
echo $OUTPUT->footer();
die;
} else {
echo $OUTPUT->box(get_string('unsubscribeallempty', 'forum'));
- print_continue($return);
+ echo $OUTPUT->continue_button($return);
echo $OUTPUT->footer();
die;
}
$streveryoneisnowsubscribed = get_string('everyoneisnowsubscribed', 'forum');
$strallowchoice = get_string('allowchoice', 'forum');
echo '<span class="helplink">' . get_string("forcessubscribe", 'forum') . '</span><br />';
- helpbutton("subscription", $strallowchoice, "forum");
+ echo $OUTPUT->help_icon(moodle_help_icon::make("subscription", $strallowchoice, "forum"));
echo ' <span class="helplink">';
if (has_capability('mod/forum:managesubscriptions', $context)) {
echo "<a title=\"$strallowchoice\" href=\"subscribe.php?id=$forum->id&force=no\">$strallowchoice</a>";
} else if ($forum->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) {
$strsubscriptionsoff = get_string('disallowsubscribe','forum');
echo $strsubscriptionsoff;
- helpbutton("subscription", $strsubscriptionsoff, "forum");
+ echo $OUTPUT->help_icon(moodle_help_icon::make("subscription", $strsubscriptionsoff, "forum"));
} else {
$streveryonecannowchoose = get_string("everyonecannowchoose", "forum");
$strforcesubscribe = get_string("forcesubscribe", "forum");
$strshowsubscribers = get_string("showsubscribers", "forum");
echo '<span class="helplink">' . get_string("allowsallsubscribe", 'forum') . '</span><br />';
- helpbutton("subscription", $strforcesubscribe, "forum");
+ echo $OUTPUT->help_icon(moodle_help_icon::make("subscription", $strforcesubscribe, "forum"));
echo ' ';
if (has_capability('mod/forum:managesubscriptions', $context)) {
if (!empty($forum->blockafter) && !empty($forum->blockperiod)) {
$a->blockafter = $forum->blockafter;
$a->blockperiod = get_string('secondstotime'.$forum->blockperiod);
- notify(get_string('thisforumisthrottled','forum',$a));
+ echo $OUTPUT->notification(get_string('thisforumisthrottled','forum',$a));
}
if ($forum->type == 'qanda' && !has_capability('moodle/course:manageactivities', $context)) {
- notify(get_string('qandanotify','forum'));
+ echo $OUTPUT->notification(get_string('qandanotify','forum'));
}
switch ($forum->type) {
case 'single':
if (! $discussion = $DB->get_record("forum_discussions", array("forum" => $forum->id))) {
if ($discussions = $DB->get_records("forum_discussions", array("forum" => $forum->id), "timemodified ASC")) {
- notify("Warning! There is more than one discussion in this forum - using the most recent");
+ echo $OUTPUT->notification("Warning! There is more than one discussion in this forum - using the most recent");
$discussion = array_pop($discussions);
} else {
print_error('nodiscussions', 'forum');