]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19799 Upgraded calls to helpbutton, print_simple_box* and notify
authornicolasconnault <nicolasconnault>
Tue, 18 Aug 2009 05:20:12 +0000 (05:20 +0000)
committernicolasconnault <nicolasconnault>
Tue, 18 Aug 2009 05:20:12 +0000 (05:20 +0000)
27 files changed:
error/index.php
files/draftfiles.php
files/index.php
help.php
lib/accesslib.php
lib/completionlib.php
lib/db/upgrade.php
lib/db/upgradelib.php
lib/environmentlib.php
lib/form/editorhelp.php
lib/form/warning.php
lib/gdlib.php
lib/gradelib.php
lib/moodlelib.php
lib/outputcomponents.php
lib/portfolio/exporter.php
lib/portfoliolib.php
lib/questionlib.php
lib/simpletest/filtersettingsperformancetester.php
lib/simpletest/getstringperformancetester.php
lib/tablelib.php
lib/upgradelib.php
lib/uploadlib.php
lib/weblib.php
message/edit.php
message/lib.php
sso/hive/expired.php

index 629d5d8b93b40330bac1f2dfc28c0bfed0bb2736..450f4b54b7992ff55d5cdb18cd3e2211f8146dae 100644 (file)
@@ -47,7 +47,7 @@
 
     print_header($site->fullname .':Error', $site->fullname .': Error 404', 'Error 404 - File not Found', '');
 
-    print_simple_box('<p align="center">'. get_string('pagenotexist', 'error'). '<br />'.s($requesturi).'</p>', 'center');
+    echo $OUTPUT->box(get_string('pagenotexist', 'error'). '<br />'.s($requesturi), 'generalbox boxaligncenter');
 
     if (isloggedin()) {
 ?>
@@ -61,7 +61,7 @@
            </form>
 <?php
     } else {
-        print_continue($CFG->wwwroot);
+        echo $OUTPUT->continue_button($CFG->wwwroot);
     }
     echo $OUTPUT->footer();
 ?>
index 9b4db09b27e9c50346e1b1ee2f31860f276d2073..9f9fe292deb5b271b7c75d1b6d235b62373e6825 100644 (file)
@@ -99,7 +99,7 @@ if (isset($_FILES['newfile']) and data_submitted() and confirm_sesskey()) {
 if ($delete !== '' and $file = $fs->get_file($contextid, $filearea, $itemid, $filepath, $delete)) {
     if (!data_submitted() or !confirm_sesskey()) {
         print_header();
-        notify(get_string('deletecheckwarning').': '.s($file->get_filepath().$file->get_filename()));
+        echo $OUTPUT->notification(get_string('deletecheckwarning').': '.s($file->get_filepath().$file->get_filename()));
         $optionsno  = array('itemid'=>$itemid, 'filepath'=>$filepath, 'subdirs'=>$subdirs);
         $optionsyes = array('itemid'=>$itemid, 'filepath'=>$filepath, 'delete'=>$delete, 'sesskey'=>sesskey(), 'subdirs'=>$subdirs);
         notice_yesno (get_string('deletecheckfiles'), 'draftfiles.php', 'draftfiles.php', $optionsyes, $optionsno, 'post', 'get');
@@ -120,7 +120,7 @@ if ($delete !== '' and $file = $fs->get_file($contextid, $filearea, $itemid, $fi
 print_header();
 
 if ($notice !== '') {
-    notify($notice);
+    echo $OUTPUT->notification($notice);
 }
 
 echo '<div class="areafiles">';
index a3eba99b5ea27fc5214ad7ad0fd658f9f7d5cbb1..913b44449dd4e1f8b47d939cbdc6657a4f5fb53c 100644 (file)
@@ -109,7 +109,7 @@ if ($file_info and $file_info->is_directory() and $file_info->is_writable() and
 if ($file_info and $delete) {
     if (!data_submitted() or !confirm_sesskey()) {
         print_header();
-        notify(get_string('deletecheckwarning').': '.$file_info->get_visible_name());
+        echo $OUTPUT->notification(get_string('deletecheckwarning').': '.$file_info->get_visible_name());
         $parent_info = $file_info->get_parent();
 
         $optionsno  = $parent_info->get_params();
@@ -136,7 +136,7 @@ if ($file_info and $delete) {
 html_header($context, $file_info);
 
 if ($error !== '') {
-    notify($error);
+    echo $OUTPUT->notification($error);
 }
 
 displaydir($file_info);
index 36d9c22be094df50d0dfeb16a527f09a51e8749d..4fc66f050c7a22f0e7392c9d6c8a940a54f1db27 100644 (file)
--- a/help.php
+++ b/help.php
@@ -94,13 +94,13 @@ if(preg_match('~(##emoticons_html##)~', $output, $matches)) {
 
 // Do the main output.
 print_header($title);
-print_simple_box_start();
+echo $OUTPUT->box_start();
 print $output;
-print_simple_box_end();
+echo $OUTPUT->box_end();
 
 // Display an error if necessary.
 if (!$helpfound) {
-    notify('Help file "'. $file .'" could not be found!');
+    echo $OUTPUT->notification('Help file "'. $file .'" could not be found!');
 }
 
 // End of page.
index 25cb70f01896f1f68220956b1940e526d028074d..88bf5690e17149907dfa21b12a92b695d4da339a 100755 (executable)
@@ -3269,7 +3269,7 @@ function reset_role_capabilities($roleid) {
  * @return boolean true if success, exception in case of any problems
  */
 function update_capabilities($component='moodle') {
-    global $DB;
+    global $DB, $OUTPUT;
 
     $storedcaps = array();
 
@@ -3332,7 +3332,7 @@ function update_capabilities($component='moodle') {
                     //assign_capability will update rather than insert if capability exists
                     if (!assign_capability($capname, $rolecapability->permission,
                                             $rolecapability->roleid, $rolecapability->contextid, true)){
-                         notify('Could not clone capabilities for '.$capname);
+                         echo $OUTPUT->notification('Could not clone capabilities for '.$capname);
                     }
                 }
             }
@@ -3341,7 +3341,7 @@ function update_capabilities($component='moodle') {
         // we ignore legacy key if we have cloned permissions
         } else if (isset($capdef['legacy']) && is_array($capdef['legacy']) &&
                     !assign_legacy_capabilities($capname, $capdef['legacy'])) {
-            notify('Could not assign legacy capabilities for '.$capname);
+            echo $OUTPUT->notification('Could not assign legacy capabilities for '.$capname);
         }
     }
     // Are there any capabilities that have been removed from the file
index 2407a82eb05f8704967bd8033d384d3f47812490..715dce44b5548da06efdb6f3c9e78f988f0ed538 100644 (file)
@@ -166,10 +166,10 @@ class completion_info {
      * @return void
      */
     public function print_help_icon() {
-        global $PAGE;
+        global $PAGE, $OUTPUT;
         if ($this->is_enabled() && !$PAGE->user_is_editing() && isloggedin() && !isguestuser()) {
             echo '<span id = "completionprogressid" class="completionprogress">'.get_string('yourprogress','completion').' ';
-            helpbutton('completionicons',get_string('completionicons','completion'),'completion');
+            echo $OUTPUT->help_icon(moodle_help_icon::make('completionicons',get_string('completionicons','completion'),'completion'));
             echo '</span>';
         }
     }
index 494dc3c2c574e3f2040295bb812efac659237d83..24d91932f5fd0e843ad8a506a1e99f819529c0f8 100644 (file)
@@ -20,7 +20,7 @@
 // before any action that may take longer time to finish.
 
 function xmldb_main_upgrade($oldversion) {
-    global $CFG, $THEME, $USER, $DB;
+    global $CFG, $THEME, $USER, $DB, $OUTPUT;
 
     require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions
 
@@ -113,7 +113,7 @@ function xmldb_main_upgrade($oldversion) {
                 if ($guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) {
                     if (isset($guestroles[$role->id])) {
                         set_config('defaultuserroleid', null);
-                        notify('Guest role removed from "Default role for all users" setting, please select another role.', 'notifysuccess');
+                        echo $OUTPUT->notification('Guest role removed from "Default role for all users" setting, please select another role.', 'notifysuccess');
                     }
                 }
             } else {
@@ -125,7 +125,7 @@ function xmldb_main_upgrade($oldversion) {
     }
 
     if ($result && $oldversion < 2008051201) {
-        notify('Increasing size of user idnumber field, this may take a while...', 'notifysuccess');
+        echo $OUTPUT->notification('Increasing size of user idnumber field, this may take a while...', 'notifysuccess');
         upgrade_set_timeout(60*20); // this may take a while
 
     /// Under MySQL and Postgres... detect old NULL contents and change them by correct empty string. MDL-14859
@@ -2141,7 +2141,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
     if ($result && $oldversion < 2009051200) {
     /// Let's check the status of mandatory mnet_host records, fixing them
     /// and moving "orphan" users to default localhost record. MDL-16879
-        notify('Fixing mnet records, this may take a while...', 'notifysuccess');
+        echo $OUTPUT->notification('Fixing mnet records, this may take a while...', 'notifysuccess');
         upgrade_fix_incorrect_mnethostids();
 
     /// Main savepoint reached
index 2b1152361b92e0e1128ee2f3a67d549e40cf8936..81ad5a6887a3fba318c5110b3c523e7111ee1648 100644 (file)
@@ -83,7 +83,7 @@ function upgrade_migrate_files_courses() {
  * Internal function - do not use directly
  */
 function upgrade_migrate_files_course($context, $path, $delete) {
-    global $CFG;
+    global $CFG, $OUTPUT;
 
     $fullpathname = $CFG->dataroot.'/'.$context->instanceid.$path;
     if (!file_exists($fullpathname)) {
@@ -114,7 +114,7 @@ function upgrade_migrate_files_course($context, $path, $delete) {
 
         if ($item->isFile()) {
             if (!$item->isReadable()) {
-                notify(" File not readable, skipping: ".$fullpathname.$item->getFilename());
+                echo $OUTPUT->notification(" File not readable, skipping: ".$fullpathname.$item->getFilename());
                 continue;
             }
 
@@ -168,7 +168,7 @@ function upgrade_migrate_files_course($context, $path, $delete) {
  * Unfortunately this function uses core file related functions - it might be necessary to tweak it if something changes there :-(
  */
 function upgrade_migrate_files_blog() {
-    global $DB, $CFG;
+    global $DB, $CFG, $OUTPUT;
 
     $fs = get_file_storage();
 
@@ -199,7 +199,7 @@ function upgrade_migrate_files_blog() {
             }
 
             if (!is_readable($pathname)) {
-                notify(" File not readable, skipping: ".$pathname);
+                echo $OUTPUT->notification(" File not readable, skipping: ".$pathname);
                 continue;
             }
 
index 38bd06c5a52d1e228cc3788849cff761ba2f87b7..80ea1b89ed477d299337fbe5aea31f60dbb2be51 100644 (file)
@@ -317,7 +317,7 @@ function print_moodle_environment($result, $environment_results) {
 
 /// Finally, if any error has happened, print the summary box
     if (!$result) {
-        print_simple_box($strenvironmenterrortodo, 'center', '', '', '', 'environmentbox errorbox');
+        echo $OUTPUT->box($strenvironmenterrortodo, 'environmentbox errorbox');
     }
 }
 
index 07fbf29ab44a966edc4c0ef3f3b09cf772905926..9eafa7ae2ad7b7d5bbbd15a76bd4be1e4c6d2e04 100644 (file)
@@ -55,7 +55,7 @@ for ($i=1; ; $i++){
 
 }
 print_header();
-print_simple_box_start('center', '96%');
+echo $OUTPUT->box_start();
 echo $OUTPUT->heading(get_string('editorhelptopics'));
 
 
@@ -64,7 +64,7 @@ foreach ($topics as $i => $topic){
     echo('<li>'.$topics[$i].'</li>');
 }
 echo '</ul>';
-print_simple_box_end();
+echo $OUTPUT->box_end();
 // End of page.
 echo $OUTPUT->close_window_button();
 global $CFG;
index ad9d3a5e2f3770fe7ab8518ce52c88d36d506975..48e373c1f3de09b134a77069361cad5f53c4f157 100644 (file)
@@ -49,7 +49,8 @@ class MoodleQuickForm_warning extends HTML_QuickForm_static{
     }
 
     function toHtml() {
-        return notify($this->_text, $this->_class, 'center', true);
+        global $OUTPUT;
+        return $OUTPUT->notification($this->_text, $this->_class);
     }
 
     /**
index db8a2c2e6e6ff3b1d87b47afba4feac6df9443d1..e749a03a211c26cab0f2ab45363bb1e7d1f8af74 100644 (file)
@@ -175,7 +175,7 @@ function save_profile_image($id, $userform, $dir='user') {
  * @return boolean
  */
 function process_profile_image($originalfile, $destination) {
-    global $CFG;
+    global $CFG, $OUTPUT;
 
     if(!(is_file($originalfile) && is_dir($destination))) {
         return false;
@@ -263,7 +263,7 @@ function process_profile_image($originalfile, $destination) {
             return 1;
         }
     } else {
-        notify('PHP has not been configured to support JPEG images.  Please correct this.');
+        echo $OUTPUT->notification('PHP has not been configured to support JPEG images.  Please correct this.');
     }
     return 0;
 }
@@ -278,7 +278,7 @@ function process_profile_image($originalfile, $destination) {
  * @return boolean
  */
 function upgrade_profile_image($id, $dir='users') {
-    global $CFG;
+    global $CFG, $OUTPUT;
 
     $im = ImageCreateFromJPEG($CFG->dataroot .'/'. $dir .'/'. $id .'/f1.jpg');
 
@@ -333,7 +333,7 @@ function upgrade_profile_image($id, $dir='users') {
             return 1;
         }
     } else {
-        notify('PHP has not been configured to support JPEG images.  Please correct this.');
+        echo $OUTPUT->notification('PHP has not been configured to support JPEG images.  Please correct this.');
     }
     return 0;
 }
index db3d001e803d35a206ce139a27dc190e59532a7f..1d67131772e0c5178e87ed4fe7645068644fe9a4 100644 (file)
@@ -1112,13 +1112,13 @@ function grade_update_mod_grades($modinstance, $userid=0) {
  * @param bool $showfeedback
  */
 function remove_grade_letters($context, $showfeedback) {
-    global $DB;
+    global $DB, $OUTPUT;
 
     $strdeleted = get_string('deleted');
 
     $DB->delete_records('grade_letters', array('contextid'=>$context->id));
     if ($showfeedback) {
-        notify($strdeleted.' - '.get_string('letters', 'grades'));
+        echo $OUTPUT->notification($strdeleted.' - '.get_string('letters', 'grades'));
     }
 }
 /**
@@ -1129,14 +1129,14 @@ function remove_grade_letters($context, $showfeedback) {
  * @param bool $showfeedback print feedback
  */
 function remove_course_grades($courseid, $showfeedback) {
-    global $DB;
+    global $DB, $OUTPUT;
 
     $strdeleted = get_string('deleted');
 
     $course_category = grade_category::fetch_course_category($courseid);
     $course_category->delete('coursedelete');
     if ($showfeedback) {
-        notify($strdeleted.' - '.get_string('grades', 'grades').', '.get_string('items', 'grades').', '.get_string('categories', 'grades'));
+        echo $OUTPUT->notification($strdeleted.' - '.get_string('grades', 'grades').', '.get_string('items', 'grades').', '.get_string('categories', 'grades'));
     }
 
     if ($outcomes = grade_outcome::fetch_all(array('courseid'=>$courseid))) {
@@ -1146,7 +1146,7 @@ function remove_course_grades($courseid, $showfeedback) {
     }
     $DB->delete_records('grade_outcomes_courses', array('courseid'=>$courseid));
     if ($showfeedback) {
-        notify($strdeleted.' - '.get_string('outcomes', 'grades'));
+        echo $OUTPUT->notification($strdeleted.' - '.get_string('outcomes', 'grades'));
     }
 
     if ($scales = grade_scale::fetch_all(array('courseid'=>$courseid))) {
@@ -1155,12 +1155,12 @@ function remove_course_grades($courseid, $showfeedback) {
         }
     }
     if ($showfeedback) {
-        notify($strdeleted.' - '.get_string('scales'));
+        echo $OUTPUT->notification($strdeleted.' - '.get_string('scales'));
     }
 
     $DB->delete_records('grade_settings', array('courseid'=>$courseid));
     if ($showfeedback) {
-        notify($strdeleted.' - '.get_string('settings', 'grades'));
+        echo $OUTPUT->notification($strdeleted.' - '.get_string('settings', 'grades'));
     }
 }
 
index a1c2f6f9a1b6de4bb800aa18bf52e38bfd148c9b..d385ac0242c09cc6063d35ce3cc08b26a389777a 100644 (file)
@@ -2202,7 +2202,7 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null, $setwantsu
                     if (empty($USER->access['rsw'][$COURSE->context->path])) {  // Normal guest
                         notice(get_string('guestsnotallowed', '', format_string($COURSE->fullname)), get_login_url());
                     } else {
-                        notify(get_string('guestsnotallowed', '', format_string($COURSE->fullname)));
+                        echo $OUTPUT->notification(get_string('guestsnotallowed', '', format_string($COURSE->fullname)));
                         echo '<div class="notifyproblem">'.switchroles_form($COURSE->id).'</div>';
                         echo $OUTPUT->footer();
                         exit;
@@ -3403,7 +3403,7 @@ function guest_user() {
  * @return user|flase A {@link $USER} object or false if error
  */
 function authenticate_user_login($username, $password) {
-    global $CFG, $DB;
+    global $CFG, $DB, $OUTPUT;
 
     $authsenabled = get_enabled_auth_plugins();
 
@@ -3469,7 +3469,7 @@ function authenticate_user_login($username, $password) {
             include_once($CFG->dirroot .'/sso/'. $CFG->sso .'/lib.php');
             if (function_exists('sso_user_login')) {
                 if (!sso_user_login($username, $password)) {   // Perform the signon process
-                    notify('Second sign-on failed');
+                    echo $OUTPUT->notification('Second sign-on failed');
                 }
             }
         }
@@ -3813,7 +3813,7 @@ function set_login_session_preferences() {
  *             failed, but you have no way of knowing which.
  */
 function delete_course($courseorid, $showfeedback = true) {
-    global $CFG, $DB;
+    global $CFG, $DB, $OUTPUT;
     $result = true;
 
     if (is_object($courseorid)) {
@@ -3833,7 +3833,7 @@ function delete_course($courseorid, $showfeedback = true) {
 
     if (!remove_course_contents($courseid, $showfeedback)) {
         if ($showfeedback) {
-            notify("An error occurred while deleting some of the course contents.");
+            echo $OUTPUT->notification("An error occurred while deleting some of the course contents.");
         }
         $result = false;
     }
@@ -3843,14 +3843,14 @@ function delete_course($courseorid, $showfeedback = true) {
 /// Delete all roles and overiddes in the course context
     if (!delete_context(CONTEXT_COURSE, $courseid)) {
         if ($showfeedback) {
-            notify("An error occurred while deleting the main course context.");
+            echo $OUTPUT->notification("An error occurred while deleting the main course context.");
         }
         $result = false;
     }
 
     if (!fulldelete($CFG->dataroot.'/'.$courseid)) {
         if ($showfeedback) {
-            notify("An error occurred while deleting the course files.");
+            echo $OUTPUT->notification("An error occurred while deleting the course files.");
         }
         $result = false;
     }
@@ -3876,7 +3876,7 @@ function delete_course($courseorid, $showfeedback = true) {
  *             failed, but you have no way of knowing which.
  */
 function remove_course_contents($courseid, $showfeedback=true) {
-    global $CFG, $DB;
+    global $CFG, $DB, $OUTPUT;
     require_once($CFG->libdir.'/questionlib.php');
     require_once($CFG->libdir.'/gradelib.php');
 
@@ -3898,7 +3898,7 @@ function remove_course_contents($courseid, $showfeedback=true) {
             include_once($formatlib);
             if (function_exists($formatdelete)) {
                 if ($showfeedback) {
-                    notify($strdeleted.' '.$format);
+                    echo $OUTPUT->notification($strdeleted.' '.$format);
                 }
                 $formatdelete($course->id);
             }
@@ -3927,7 +3927,7 @@ function remove_course_contents($courseid, $showfeedback=true) {
                                 $count++;
 
                             } else {
-                                notify('Could not delete '. $modname .' instance '. $instance->id .' ('. format_string($instance->name) .')');
+                                echo $OUTPUT->notification('Could not delete '. $modname .' instance '. $instance->id .' ('. format_string($instance->name) .')');
                                 $result = false;
                             }
                             if ($cm) {
@@ -3938,7 +3938,7 @@ function remove_course_contents($courseid, $showfeedback=true) {
                         }
                     }
                 } else {
-                    notify('Function '.$moddelete.'() doesn\'t exist!');
+                    echo $OUTPUT->notification('Function '.$moddelete.'() doesn\'t exist!');
                     $result = false;
                 }
 
@@ -3947,7 +3947,7 @@ function remove_course_contents($courseid, $showfeedback=true) {
                 }
             }
             if ($showfeedback) {
-                notify($strdeleted .' '. $count .' x '. $modname);
+                echo $OUTPUT->notification($strdeleted .' '. $count .' x '. $modname);
             }
         }
     } else {
@@ -3978,7 +3978,7 @@ function remove_course_contents($courseid, $showfeedback=true) {
     foreach ($tablestoclear as $table => $col) {
         if ($DB->delete_records($table, array($col=>$course->id))) {
             if ($showfeedback) {
-                notify($strdeleted . ' ' . $table);
+                echo $OUTPUT->notification($strdeleted . ' ' . $table);
             }
         } else {
             $result = false;
@@ -3992,7 +3992,7 @@ function remove_course_contents($courseid, $showfeedback=true) {
         $DB->delete_records("course_meta", array("parent_course"=>$course->id));
         sync_metacourse($course->id); // have to do it here so the enrolments get nuked. sync_metacourses won't find it without the id.
         if ($showfeedback) {
-            notify("$strdeleted course_meta");
+            echo $OUTPUT->notification("$strdeleted course_meta");
         }
     } else {
         if ($parents = $DB->get_records("course_meta", array("child_course"=>$course->id))) {
@@ -4000,7 +4000,7 @@ function remove_course_contents($courseid, $showfeedback=true) {
                 remove_from_metacourse($parent->parent_course,$parent->child_course); // this will do the unenrolments as well.
             }
             if ($showfeedback) {
-                notify("$strdeleted course_meta");
+                echo $OUTPUT->notification("$strdeleted course_meta");
             }
         }
     }
@@ -5038,11 +5038,11 @@ function get_file_packer($mimetype='application/zip') {
  * @return string|false Returns full path to directory if successful, false if not
  */
 function make_user_directory($userid, $test=false) {
-    global $CFG;
+    global $CFG, $OUTPUT;
 
     if (is_bool($userid) || $userid < 0 || !preg_match('/^[0-9]{1,10}$/', $userid) || $userid > 2147483647) {
         if (!$test) {
-            notify("Given userid was not a valid integer! (" . gettype($userid) . " $userid)");
+            echo $OUTPUT->notification("Given userid was not a valid integer! (" . gettype($userid) . " $userid)");
         }
         return false;
     }
@@ -5067,7 +5067,7 @@ function make_user_directory($userid, $test=false) {
  * @return array An associative array: userid=>array(basedir => $basedir, userfolder => $userfolder)
  */
 function get_user_directories($only_non_empty=true, $legacy=false) {
-    global $CFG;
+    global $CFG, $OUTPUT;
 
     $rootdir = $CFG->dataroot."/user";
 
@@ -5084,7 +5084,7 @@ function get_user_directories($only_non_empty=true, $legacy=false) {
                     $dirlist[$userid] = array('basedir' => $rootdir, 'userfolder' => $userid);
                 }
             } else {
-                notify("no directories found under $rootdir");
+                echo $OUTPUT->notification("no directories found under $rootdir");
             }
         } else {
             if ($grouplist =get_directory_list($rootdir, '', true, true, false)) { // directories will be in the form 0, 1000, 2000 etc...
@@ -5098,7 +5098,7 @@ function get_user_directories($only_non_empty=true, $legacy=false) {
             }
         }
     } else {
-        notify("$rootdir does not exist!");
+        echo $OUTPUT->notification("$rootdir does not exist!");
         return false;
     }
     return $dirlist;
@@ -5231,7 +5231,7 @@ function get_max_upload_sizes($sitebytes=0, $coursebytes=0, $modulebytes=0) {
  * @return bool|string
  */
 function print_file_upload_error($filearray = '', $returnerror = false) {
-
+    global $OUTPUT;
     if ($filearray == '' or !isset($filearray['error'])) {
 
         if (empty($_FILES)) return false;
@@ -5273,7 +5273,7 @@ function print_file_upload_error($filearray = '', $returnerror = false) {
     if ($returnerror) {
         return $errmessage;
     } else {
-        notify($errmessage);
+        echo $OUTPUT->notification($errmessage);
         return true;
     }
 
@@ -7266,7 +7266,7 @@ function check_gd_version() {
  * @return bool
  */
 function moodle_needs_upgrading() {
-    global $CFG, $DB;
+    global $CFG, $DB, $OUTPUT;
 
     $version = null;
     include_once($CFG->dirroot .'/version.php');  # defines $version and upgrades
@@ -7278,7 +7278,7 @@ function moodle_needs_upgrading() {
         foreach ($mods as $mod => $fullmod) {
             $module = new object();
             if (!is_readable($fullmod .'/version.php')) {
-                notify('Module "'. $mod .'" is not readable - check permissions');
+                echo $OUTPUT->notification('Module "'. $mod .'" is not readable - check permissions');
                 continue;
             }
             include_once($fullmod .'/version.php');  # defines $module with version etc
@@ -7348,7 +7348,7 @@ function upgrade_set_timeout($max_execution_time=300) {
  * @uses HOURSECS
  */
 function notify_login_failures() {
-    global $CFG, $DB;
+    global $CFG, $DB, $OUTPUT;
 
     $recip = get_users_from_config($CFG->notifyloginfailures, 'moodle/site:config');
 
index 2a9364fceb7ac6b27462451f1d12f8398f2ff68b..48a475137060038152e723a61d2dbe2ec9a96885 100644 (file)
@@ -1963,6 +1963,21 @@ class moodle_help_icon extends labelled_html_component {
         parent::prepare();
     }
 
+    /**
+     * This is a shortcut for creating a help_icon with only the 2 required params
+     * @param string $page  The keyword that defines a help page
+     * @param string $text A descriptive text
+     * @return moodle_help_icon A moodle_help_icon object with the two common fields initialised.
+     */
+    public static function make($page, $text, $module='moodle', $linktext=false) {
+        $helpicon = new moodle_help_icon();
+        $helpicon->page = $page;
+        $helpicon->text = $text;
+        $helpicon->module = $module;
+        $helpicon->linktext = $linktext;
+        return $helpicon;
+    }
+
     public static function make_scale_menu($courseid, $scale) {
         $helpbutton = new moodle_help_icon();
         $strscales = get_string('scales');
index 657d727a8b1a85c4a3b260512e072df7224ff94c..cc761705401620011637bc4fbc2746cc45432566 100644 (file)
@@ -333,9 +333,9 @@ class portfolio_exporter {
                 return true;
             } else {
                 $this->print_header('configexport');
-                print_simple_box_start();
+                echo $OUTPUT->box_start();
                 $mform->display();
-                print_simple_box_end();
+                echo $OUTPUT->box_end();
                 echo $OUTPUT->footer();
                 return false;;
             }
@@ -382,7 +382,7 @@ class portfolio_exporter {
         $yesurl = $CFG->wwwroot . '/portfolio/add.php?stage=' . PORTFOLIO_STAGE_QUEUEORWAIT;
         $nourl  = $CFG->wwwroot . '/portfolio/add.php?cancel=1';
         $this->print_header('confirmexport');
-        print_simple_box_start();
+        echo $OUTPUT->box_start();
         echo $OUTPUT->heading(get_string('confirmsummary', 'portfolio'), 4);
         $mainsummary = array();
         if (!$this->instance->get_export_config('hideformat')) {
@@ -417,7 +417,7 @@ class portfolio_exporter {
         }
         print_table($table);
         notice_yesno($strconfirm, $yesurl, $nourl);
-        print_simple_box_end();
+        echo $OUTPUT->box_end();
         echo $OUTPUT->footer();
         return false;
     }
@@ -587,9 +587,9 @@ class portfolio_exporter {
             return;
         }
 
-        print_simple_box_start();
+        echo $OUTPUT->box_start();
         echo $this->caller->heading_summary();
-        print_simple_box_end();
+        echo $OUTPUT->box_end();
     }
 
     /**
@@ -791,8 +791,8 @@ class portfolio_exporter {
         global $CFG, $OUTPUT;
         $title = get_string('exportexpired', 'portfolio');
         print_header($title, $title, build_navigation(get_string('exportexpired', 'portfolio')));
-        notify(get_string('exportexpireddesc', 'portfolio'));
-        print_continue($CFG->wwwroot);
+        echo $OUTPUT->notification(get_string('exportexpireddesc', 'portfolio'));
+        echo $OUTPUT->continue_button($CFG->wwwroot);
         echo $OUTPUT->footer();
         exit;
     }
index e615e0db70f052d5a104c0d241af8abff4943aba..9e7117c80418f317c3db5ba0310a6749ca7b8426 100644 (file)
@@ -737,6 +737,7 @@ function portfolio_instance_sanity_check($instances=null) {
 *
 */
 function portfolio_report_insane($insane, $instances=false, $return=false) {
+    global $OUTPUT;
     if (empty($insane)) {
         return;
     }
@@ -751,7 +752,7 @@ function portfolio_report_insane($insane, $instances=false, $return=false) {
         $headerstr = get_string('somepluginsdisabled', 'portfolio');
     }
 
-    $output = notify($headerstr, 'notifyproblem', 'center', true);
+    $output = $OUTPUT->notification($headerstr, 'notifyproblem');
     $table = new StdClass;
     $table->head = array($pluginstr, '');
     $table->data = array();
index 78fcbe5a1624d551ebfcea365a834c29aac2a156..28fb0c26daf2e5fea9dc59561ab95593b61835d6 100644 (file)
@@ -690,7 +690,7 @@ function question_delete_course($course, $feedback=true) {
  * @return boolean
  */
 function question_delete_course_category($category, $newcategory, $feedback=true) {
-    global $DB;
+    global $DB, $OUTPUT;
 
     $context = get_context_instance(CONTEXT_COURSECAT, $category->id);
     if (empty($newcategory)) {
@@ -753,7 +753,7 @@ function question_delete_course_category($category, $newcategory, $feedback=true
             $a = new stdClass;
             $a->oldplace = print_context_name($context);
             $a->newplace = print_context_name($newcontext);
-            notify(get_string('movedquestionsandcategories', 'question', $a), 'notifysuccess');
+            echo $OUTPUT->notification(get_string('movedquestionsandcategories', 'question', $a), 'notifysuccess');
         }
     }
 
@@ -1508,7 +1508,7 @@ function question_get_feedback_class($fraction) {
 * or record that changes need to be made for a later regrade.
 */
 function regrade_question_in_attempt($question, $attempt, $cmoptions, $verbose=false, $dryrun=false) {
-    global $DB;
+    global $DB, $OUTPUT;
 
     // load all states for this question in this attempt, ordered in sequence
     if ($states = $DB->get_records('question_states',
@@ -1558,7 +1558,7 @@ function regrade_question_in_attempt($question, $attempt, $cmoptions, $verbose=f
                     $error = question_process_comment($question, $replaystate, $attempt,
                             $replaystate->manualcomment, $states[$j]->grade);
                     if (is_string($error)) {
-                         notify($error);
+                         echo $OUTPUT->notification($error);
                     }
                 } else {
                     $replaystate->grade = $states[$j]->grade;
@@ -1570,7 +1570,7 @@ function regrade_question_in_attempt($question, $attempt, $cmoptions, $verbose=f
                     $a = new stdClass;
                     $a->qid = $question->id;
                     $a->stateid = $states[$j]->id;
-                    notify(get_string('errorduringregrade', 'question', $a));
+                    echo $OUTPUT->notification(get_string('errorduringregrade', 'question', $a));
                 }
                 // We need rounding here because grades in the DB get truncated
                 // e.g. 0.33333 != 0.3333333, but we want them to be equal here
@@ -2928,10 +2928,11 @@ function get_filesdir_from_context($context){
  * error..
  */
 function question_get_real_state($state){
+    global $OUTPUT;
     $realstate = clone($state);
     $matches = array();
     if (!preg_match('|^random([0-9]+)-(.*)|', $state->answer, $matches)){
-        notify(get_string('errorrandom', 'quiz_statistics'));
+        echo $OUTPUT->notification(get_string('errorrandom', 'quiz_statistics'));
         return false;
     } else {
         $realstate->question = $matches[1];
index 57ea981fe5935f6f1b3311c9b5bd9e01483e4631..e079b5619024f6bdc3c2e1739cc6deb6e2617cb3 100644 (file)
@@ -70,11 +70,11 @@ switch (optional_param('action', '', PARAM_ACTION)) {
             }
             flush();
             populate_test_database($syscontext, 10, 100, 1000, 5000, 5000);
-            notify('Test tables created.', 'notifysuccess');
+            echo $OUTPUT->notification('Test tables created.', 'notifysuccess');
         } else if ($issetup == count($requiredtables)) {
-            notify('Test tables are already set up.', 'notifysuccess');
+            echo $OUTPUT->notification('Test tables are already set up.', 'notifysuccess');
         } else {
-            notify('Something is wrong, please delete the test tables and try again.');
+            echo $OUTPUT->notification('Something is wrong, please delete the test tables and try again.');
         }
         break;
 
@@ -86,12 +86,12 @@ switch (optional_param('action', '', PARAM_ACTION)) {
             }
         }
         $issetup = 0;
-        notify('Test tables dropped.', 'notifysuccess');
+        echo $OUTPUT->notification('Test tables dropped.', 'notifysuccess');
         break;
 
     case 'test':
         if ($issetup != count($requiredtables)) {
-            notify('Something is wrong, please delete the test tables and try again.');
+            echo $OUTPUT->notification('Something is wrong, please delete the test tables and try again.');
         } else {
             $contexts = $DB->get_records('context');
             $numcalls = 1000;
@@ -146,7 +146,7 @@ function print_result_line($duration, $basetime, $numcalls, $action1, $action2 =
 }
 
 function populate_test_database($syscontext, $numcategories, $numcourses, $nummodules, $numoverrides, $numconfigs) {
-    global $DB;
+    global $DB, $OUTPUT;
     set_time_limit(600);
     $syscontext->id = $DB->insert_record('context', $syscontext);
 
@@ -158,7 +158,7 @@ function populate_test_database($syscontext, $numcategories, $numcourses, $nummo
         $categoryparents[] = $context;
         $categories[$context->id] = $context;
     }
-    notify('Created ' . $numcategories . ' course category contexts.', 'notifysuccess'); flush();
+    echo $OUTPUT->notification('Created ' . $numcategories . ' course category contexts.', 'notifysuccess'); flush();
 
     // Course contexts.
     $courses = array();
@@ -166,7 +166,7 @@ function populate_test_database($syscontext, $numcategories, $numcourses, $nummo
         $context = insert_context(CONTEXT_COURSE, $i, $categories[array_rand($categories)]);
         $courses[$context->id] = $context;
     }
-    notify('Created ' . $numcourses . ' course contexts.', 'notifysuccess'); flush();
+    echo $OUTPUT->notification('Created ' . $numcourses . ' course contexts.', 'notifysuccess'); flush();
 
     // Activities contexts.
     $mods = array();
@@ -180,7 +180,7 @@ function populate_test_database($syscontext, $numcategories, $numcourses, $nummo
         }
     }
     $DB->commit_sql();
-    notify('Created ' . $nummodules . ' module contexts.', 'notifysuccess'); flush();
+    echo $OUTPUT->notification('Created ' . $nummodules . ' module contexts.', 'notifysuccess'); flush();
 
     $contexts = $categories + $courses + $mods;
 
@@ -192,7 +192,7 @@ function populate_test_database($syscontext, $numcategories, $numcourses, $nummo
         filter_set_global_state($filter, $state);
         $counts[$state]++;
     }
-    notify('Set global setting: ' . $counts[TEXTFILTER_DISABLED] . ' disabled, ' .
+    echo $OUTPUT->notification('Set global setting: ' . $counts[TEXTFILTER_DISABLED] . ' disabled, ' .
             $counts[TEXTFILTER_OFF] . ' off and ' . $counts[TEXTFILTER_ON] . ' on.', 'notifysuccess'); flush();
 
     // Local overrides.
@@ -206,7 +206,7 @@ function populate_test_database($syscontext, $numcategories, $numcourses, $nummo
         }
     }
     $DB->commit_sql();
-    notify('Set ' . $numoverrides . ' local overrides.', 'notifysuccess'); flush();
+    echo $OUTPUT->notification('Set ' . $numoverrides . ' local overrides.', 'notifysuccess'); flush();
 
     // Local config.
     $variablenames = array('frog' => 0, 'toad' => 0, 'elver' => 0, 'eft' => 0, 'tadpole' => 0);
@@ -220,7 +220,7 @@ function populate_test_database($syscontext, $numcategories, $numcourses, $nummo
         }
     }
     $DB->commit_sql();
-    notify('Set ' . $numconfigs . ' local configs.', 'notifysuccess'); flush();
+    echo $OUTPUT->notification('Set ' . $numconfigs . ' local configs.', 'notifysuccess'); flush();
 }
 
 function insert_context($contextlevel, $instanceid, $parent) {
index 378d356883ca19f2eafbbbb31a46983b493f8da8..8bd49987f21d2f1d6f8f6b718a80455389558285 100644 (file)
@@ -48,7 +48,7 @@ $requiredlangs = $TEST_LANGUAGES;
 array_pop($requiredlangs);
 foreach ($requiredlangs as $lang) {
     if (!isset($installedlangs[$lang])) {
-        notify('You must install the following language packs to run these test: ' . implode(', ', $requiredlangs));
+        echo $OUTPUT->notification('You must install the following language packs to run these test: ' . implode(', ', $requiredlangs));
         echo $OUTPUT->footer();
         die;
     }
index 68079c1225b3221ed78dbe449db089713c8abbd1..7d12d23f3f0e61e39b322afb14786249e2ac6285 100644 (file)
@@ -920,7 +920,7 @@ class flexible_table {
             $select = html_select::make($downloadoptions, 'download', $this->defaultdownloadformat, false);
             $select->nothingvalue = '';
             $html .= $OUTPUT->select($select);
-            $html .= helpbutton('tableexportformats', get_string('tableexportformats', 'table'), 'moodle', true, false, '', true);
+            $html .= $OUTPUT->help_icon(moodle_help_icon::make('tableexportformats', get_string('tableexportformats', 'table')));
             $html .= '</div></form>';
 
             return $html;
index 3952d62ce018b9ce290b0b376fb64fd8985b4d37..d0a89bd9ce42d452f33fe4f2cf8b665c504d1cfe 100644 (file)
@@ -822,7 +822,7 @@ function upgrade_finished($continueurl=null) {
         upgrade_setup_debug(false);
         ignore_user_abort(false);
         if ($continueurl) {
-            print_continue($continueurl);
+            echo $OUTPUT->continue_button($continueurl);
             echo $OUTPUT->footer();
             die;
         }
@@ -907,6 +907,7 @@ function print_upgrade_part_start($plugin, $installation, $verbose) {
  * @param bool $installation true if installation, false menas upgrade
  */
 function print_upgrade_part_end($plugin, $installation, $verbose) {
+    global $OUTPUT;
     upgrade_started();
     if ($installation) {
         if (empty($plugin) or $plugin == 'moodle') {
@@ -922,7 +923,7 @@ function print_upgrade_part_end($plugin, $installation, $verbose) {
         }
     }
     if ($verbose) {
-        notify(get_string('success'), 'notifysuccess');
+        echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
         print_upgrade_separator();
     }
 }
@@ -971,7 +972,7 @@ function upgrade_language_pack($lang='') {
                     $cd->install();
                 }
             }
-            notify(get_string('success'), 'notifysuccess');
+            echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
         }
     }
 
index 738fe55e14c0eb2c302d4ebf12bb72817e600c01..644b7dc7862bd188a9a7a311a2699165b5db35df 100644 (file)
@@ -119,7 +119,7 @@ class upload_manager {
      * @return boolean
      */
     function preprocess_files() {
-        global $CFG;
+        global $CFG, $OUTPUT;
 
         foreach ($_FILES as $name => $file) {
             $this->status = true; // only set it to true here so that we can check if this function has been called.
@@ -141,7 +141,7 @@ class upload_manager {
                         $a->name    = $this->files[$name]['originalname'];
                         $a->problem = $this->files[$name]['uploadlog'];
                         if (!$this->config->silent) {
-                            notify(get_string('uploadfailednotrecovering','moodle',$a));
+                            echo $OUTPUT->notification(get_string('uploadfailednotrecovering','moodle',$a));
                         }
                         else {
                             $this->notify .= '<br />'. get_string('uploadfailednotrecovering','moodle',$a);
@@ -152,7 +152,7 @@ class upload_manager {
                     } else if (count($this->files) == 1) {
 
                         if (!$this->config->silent and !$this->config->allownull) {
-                            notify($this->files[$name]['uploadlog']);
+                            echo $OUTPUT->notification($this->files[$name]['uploadlog']);
                         } else {
                             $this->notify .= '<br />'. $this->files[$name]['uploadlog'];
                         }
@@ -211,7 +211,7 @@ class upload_manager {
      * @return boolean status;
      */
     function save_files($destination) {
-        global $CFG, $USER;
+        global $CFG, $USER, $OUTPUT;
         
         if (!$this->status) { // preprocess_files hasn't been run
             $this->preprocess_files();
@@ -271,7 +271,7 @@ class upload_manager {
         if (empty($savedsomething)) {
             $this->status = false;
             if ((empty($this->config->allownull) && !empty($this->inputname)) || (empty($this->inputname) && empty($this->config->allownullmultiple))) {
-                notify(get_string('uploadnofilefound'));
+                echo $OUTPUT->notification(get_string('uploadnofilefound'));
             }
             return false;
         }
@@ -298,6 +298,7 @@ class upload_manager {
      * @param array $exceptions Full paths of files to KEEP.
      */
     function delete_other_files($destination, $exceptions=null) {
+        global $OUTPUT;
         $deletedsomething = false;
         if ($filestodel = get_directory_list($destination)) {
             foreach ($filestodel as $file) {
@@ -309,7 +310,7 @@ class upload_manager {
         }
         if ($deletedsomething) {
             if (!$this->config->silent) {
-                notify(get_string('uploadoldfilesdeleted'));
+                echo $OUTPUT->notification(get_string('uploadoldfilesdeleted'));
             }
             else {
                 $this->notify .= '<br />'. get_string('uploadoldfilesdeleted');
index 38c774546877b6ebc93658eb9c77e16ed49abd0d..d1c95af7feb1caf9a91f237205264eb07d87f12c 100644 (file)
@@ -3084,8 +3084,11 @@ function emoticonhelpbutton($form, $field, $return = false) {
 
     $SESSION->inserttextform = $form;
     $SESSION->inserttextfield = $field;
-    $imagetext = '<img src="' . $OUTPUT->old_icon_url('s/smiley') . '" alt="" class="emoticon" style="margin-left:3px; padding-right:1px;width:15px;height:15px;" />';
-    $help = helpbutton('emoticons2', get_string('helpemoticons'), 'moodle', true, true, '', true, $imagetext);
+    $helpicon = moodle_help_icon::make('emoticons2', get_string('helpemoticons'), 'moodle', true);
+    $helpicon->image->src = $OUTPUT->old_icon_url('s/smiley');
+    $helpicon->image->add_class('emoticon');
+    $helpicon->style = "margin-left:3px; padding-right:1px;width:15px;height:15px;";
+    $help = $OUTPUT->help_icon($helpicon);
     if (!$return){
         echo $help;
     } else {
@@ -3139,7 +3142,7 @@ function notice ($message, $link='', $course=NULL) {
     }
 
     echo $OUTPUT->box($message, 'generalbox', 'notice');
-    print_continue($link);
+    echo $OUTPUT->continue_button($link);
 
     echo $OUTPUT->footer();
     exit(1); // general error code
index 10ba691c4e4cbd225533f3988662c8ac5a6907cd..e81ba80b1fbe38749a3c5bdf143b51eb24d831dd 100644 (file)
 
     /// TODO XXX: This is only a quick hack ... helpfile locations should be provided as part of the provider definition
         if ($provider->component == 'moodle') {
-            $helpbtn = helpbutton('moodle_'.$provider->name, $providername, 'message', true, false, '', true);
+            $helpbtn = $OUTPUT->help_icon(moodle_help_icon::make('moodle_'.$provider->name, $providername, 'message'));
         } else {
-            $helpbtn = helpbutton('message_'.$provider->name, $providername, basename($provider->component), true, false, '', true);
+            $helpbtn = $OUTPUT->help_icon(moodle_help_icon::make('message_'.$provider->name, $providername, basename($provider->component)));
         }
 
         echo '<tr><th align="right">'.$providername.$helpbtn.'</th><td colspan="'.$number_procs.'"></td></tr>'."\n";
index f401f23fd19f4cbb38440f5038592fed348e8d3e..ddfb9b981b8a3c456e5111c8f706ba40abfd17c9 100644 (file)
@@ -293,7 +293,7 @@ function message_get_contact($contactid) {
 
 
 function message_print_search_results($frm) {
-    global $USER, $CFG, $DB;
+    global $USER, $CFG, $DB, $OUTPUT;
 
     echo '<div class="mdl-align">';
 
@@ -349,7 +349,7 @@ function message_print_search_results($frm) {
             echo '</table>';
 
         } else {
-            notify(get_string('nosearchresults', 'message'));
+            echo $OUTPUT->notification(get_string('nosearchresults', 'message'));
         }
 
 
@@ -476,13 +476,13 @@ function message_print_search_results($frm) {
             echo '</table>';
 
         } else {
-            notify(get_string('nosearchresults', 'message'));
+            echo $OUTPUT->notification(get_string('nosearchresults', 'message'));
         }
 
 
     /// what the ????, probably an empty search string, duh!
     } else {
-        notify(get_string('emptysearchstring', 'message'));
+        echo $OUTPUT->notification(get_string('emptysearchstring', 'message'));
     }
 
     echo '<br />';
index e67dc9d6a383bc77928b7ff3a2bc2aef1de8a01e..bd74315aaa594d24ee887d154311c7642291c6a4 100644 (file)
@@ -10,7 +10,7 @@
     //MW theres no easy way to log in seamlessly. We need the users unhashed password.
     // It's a security risk to carry that in $SESSION so we put up login form.
     print_header();
-    notify('Your session has expired. Please log in again.'); 
+    echo $OUTPUT->notification('Your session has expired. Please log in again.'); 
 ?>
       <form action="login.php" method="post" id="login">
         <table border="0" align="center">