From 9146b979fea827f78aa69c7a2792dc1bfecdabd1 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Tue, 18 Aug 2009 05:14:39 +0000 Subject: [PATCH] MDL-19808 Upgraded calls to helpbutton, print_simple_box* and notify --- mod/forum/db/upgrade.php | 8 ++++---- mod/forum/discuss.php | 10 +++++----- mod/forum/lib.php | 32 ++++++++++++++++---------------- mod/forum/post.php | 2 +- mod/forum/search.php | 6 +++--- mod/forum/subscribers.php | 4 ++-- mod/forum/unsubscribeall.php | 4 ++-- mod/forum/view.php | 12 ++++++------ 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/mod/forum/db/upgrade.php b/mod/forum/db/upgrade.php index 325740bdc4..57582082dd 100644 --- a/mod/forum/db/upgrade.php +++ b/mod/forum/db/upgrade.php @@ -21,7 +21,7 @@ // 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; @@ -38,7 +38,7 @@ function xmldb_forum_upgrade($oldversion) { 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); @@ -125,7 +125,7 @@ function xmldb_forum_upgrade($oldversion) { $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; @@ -135,7 +135,7 @@ function xmldb_forum_upgrade($oldversion) { $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; diff --git a/mod/forum/discuss.php b/mod/forum/discuss.php index 4604edcdfe..4e4cdd69d0 100644 --- a/mod/forum/discuss.php +++ b/mod/forum/discuss.php @@ -21,7 +21,7 @@ } 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)) { @@ -76,7 +76,7 @@ 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)); @@ -229,16 +229,16 @@ $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); diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 3cc92d299b..5a8f753f66 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -127,7 +127,7 @@ function forum_add_instance($forum) { * @return bool success */ function forum_update_instance($forum) { - global $DB; + global $DB, $OUTPUT; $forum->timemodified = time(); $forum->id = $forum->instance; @@ -153,7 +153,7 @@ function forum_update_instance($forum) { 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 @@ -2985,7 +2985,7 @@ function forum_subscribed_users($course, $forum, $groupid=0, $context = NULL) { */ 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 @@ -3016,7 +3016,7 @@ function forum_get_course_forum($courseid, $type) { $forum->forcesubscribe = 0; break; default: - notify("That forum type doesn't exist!"); + echo $OUTPUT->notification("That forum type doesn't exist!"); return false; break; } @@ -3025,7 +3025,7 @@ function forum_get_course_forum($courseid, $type) { $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(); @@ -3034,15 +3034,15 @@ function forum_get_course_forum($courseid, $type) { $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"); @@ -4154,12 +4154,12 @@ function forum_print_mode_form($id, $mode, $forumtype='') { * @return string */ function forum_search_form($course, $search='') { - global $CFG; + global $CFG, $OUTPUT; $output = '
'; $output .= '
'; $output .= '
'; - $output .= helpbutton('search', get_string('search'), 'moodle', true, false, '', true); + $output .= $OUTPUT->help_icon(moodle_help_icon::make('search', get_string('search'))); $output .= ''; $output .= ''; $output .= ''; @@ -5502,9 +5502,9 @@ function forum_print_latest_discussions($course, $forum, $maxdiscussions=-1, $di } 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')); } } @@ -7351,7 +7351,7 @@ function forum_get_separate_modules($courseid) { * @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)); @@ -7397,7 +7397,7 @@ function forum_check_throttling($forum, $cm=null) { 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)); } @@ -7616,7 +7616,7 @@ function forum_reset_course_form_defaults($course) { 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 @@ -7712,7 +7712,7 @@ function forum_convert_to_roles($forum, $forummodid, $teacherroles=array(), 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; diff --git a/mod/forum/post.php b/mod/forum/post.php index 8bdd8b5415..27797cbad6 100644 --- a/mod/forum/post.php +++ b/mod/forum/post.php @@ -775,7 +775,7 @@ && !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); diff --git a/mod/forum/search.php b/mod/forum/search.php index afb09e0269..d237e904a4 100644 --- a/mod/forum/search.php +++ b/mod/forum/search.php @@ -249,9 +249,9 @@ 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(); @@ -358,7 +358,7 @@ function forum_print_big_search_form($course) { 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(); } /** diff --git a/mod/forum/subscribers.php b/mod/forum/subscribers.php index 2819ff162a..465c1e9381 100644 --- a/mod/forum/subscribers.php +++ b/mod/forum/subscribers.php @@ -145,11 +145,11 @@ } } - 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(); diff --git a/mod/forum/unsubscribeall.php b/mod/forum/unsubscribeall.php index a723869515..a5ab1447ce 100644 --- a/mod/forum/unsubscribeall.php +++ b/mod/forum/unsubscribeall.php @@ -25,7 +25,7 @@ if (data_submitted() and $confirm and confirm_sesskey()) { $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; @@ -40,7 +40,7 @@ if (data_submitted() and $confirm and confirm_sesskey()) { } else { echo $OUTPUT->box(get_string('unsubscribeallempty', 'forum')); - print_continue($return); + echo $OUTPUT->continue_button($return); echo $OUTPUT->footer(); die; } diff --git a/mod/forum/view.php b/mod/forum/view.php index 218862d7d3..fb6b79557e 100644 --- a/mod/forum/view.php +++ b/mod/forum/view.php @@ -135,7 +135,7 @@ $streveryoneisnowsubscribed = get_string('everyoneisnowsubscribed', 'forum'); $strallowchoice = get_string('allowchoice', 'forum'); echo '' . get_string("forcessubscribe", 'forum') . '
'; - helpbutton("subscription", $strallowchoice, "forum"); + echo $OUTPUT->help_icon(moodle_help_icon::make("subscription", $strallowchoice, "forum")); echo ' '; if (has_capability('mod/forum:managesubscriptions', $context)) { echo "id&force=no\">$strallowchoice"; @@ -147,13 +147,13 @@ } 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 '' . get_string("allowsallsubscribe", 'forum') . '
'; - helpbutton("subscription", $strforcesubscribe, "forum"); + echo $OUTPUT->help_icon(moodle_help_icon::make("subscription", $strforcesubscribe, "forum")); echo ' '; if (has_capability('mod/forum:managesubscriptions', $context)) { @@ -209,18 +209,18 @@ 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'); -- 2.39.5