]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19808 Upgraded calls to helpbutton, print_simple_box* and notify
authornicolasconnault <nicolasconnault>
Tue, 18 Aug 2009 05:14:39 +0000 (05:14 +0000)
committernicolasconnault <nicolasconnault>
Tue, 18 Aug 2009 05:14:39 +0000 (05:14 +0000)
mod/forum/db/upgrade.php
mod/forum/discuss.php
mod/forum/lib.php
mod/forum/post.php
mod/forum/search.php
mod/forum/subscribers.php
mod/forum/unsubscribeall.php
mod/forum/view.php

index 325740bdc4f55fae5347e679fcd22bf6cfc240f2..57582082ddeb5ca62ef18976120052b49cec5cd9 100644 (file)
@@ -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;
index 4604edcdfe5ed9d1e60efea3e8b653c974ea50aa..4e4cdd69d00a98c8f89850ae58132c8113abb2ff 100644 (file)
@@ -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));
         $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);
index 3cc92d299b5ef638ae3ca574a1760e2f07790601..5a8f753f666aa51e4b091ae716ea3ccfeb937b7e 100644 (file)
@@ -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  = '<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.'" />';
@@ -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;
index 8bdd8b541528997ca6657d9aef52de0347aa052e..27797cbad6e000122f42cec6f3c9f81b01703aed 100644 (file)
                 && !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);
index afb09e02692b5c9a3298050c1b7aed53409c54c5..d237e904a41ad2937cd3fdc4cfd34869b71cadc0 100644 (file)
 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();
 }
 
 /**
index 2819ff162af00741416af9e9f1e25b7d0335bb72..465c1e9381940c7d5b0052d9793254e7e80b4844 100644 (file)
         }
     }
 
-    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();
 
index a723869515e9d91b2cf990c357cc6bd9d14c853e..a5ab1447ce6f8037d34c381d8515005d432f356d 100644 (file)
@@ -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;
     }
index 218862d7d35ac12374463140d26c8acd85cf970a..fb6b79557e61cd140a089637b14e42803c07fa9c 100644 (file)
             $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 '&nbsp;<span class="helplink">';
             if (has_capability('mod/forum:managesubscriptions', $context)) {
                 echo "<a title=\"$strallowchoice\" href=\"subscribe.php?id=$forum->id&amp;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 '&nbsp;';
 
             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');