From 9549b9865945fb728e5d580bc7261e6e0027be74 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Tue, 18 Aug 2009 04:29:16 +0000 Subject: [PATCH] MDL-19789 Upgraded calls to helpbutton, print_simple_box* and notify --- backup/backup.php | 10 ++--- backup/backup_check.html | 2 +- backup/backup_execute.html | 8 ++-- backup/backup_form.html | 2 +- backup/backuplib.php | 62 +++++++++++++-------------- backup/bb/restore_bb.php | 8 ++-- backup/restore.php | 8 ++-- backup/restore_check.html | 6 +-- backup/restore_execute.html | 6 +-- backup/restore_form.html | 8 ++-- backup/restorelib.php | 84 ++++++++++++++++++------------------- 11 files changed, 102 insertions(+), 102 deletions(-) diff --git a/backup/backup.php b/backup/backup.php index d0d36901c6..94a72c1c1a 100644 --- a/backup/backup.php +++ b/backup/backup.php @@ -73,14 +73,14 @@ if ($courses = get_courses('all','c.shortname','c.id,c.shortname,c.fullname')) { echo $OUTPUT->heading(get_string("choosecourse")); - print_simple_box_start("center"); + echo $OUTPUT->box_start(); foreach ($courses as $course) { echo ''.format_string($course->fullname).' ('.format_string($course->shortname).')
'."\n"; } - print_simple_box_end(); + echo $OUTPUT->box_end(); } else { echo $OUTPUT->heading(get_string("nocoursesyet")); - print_continue("$CFG->wwwroot/$CFG->admin/index.php"); + echo $OUTPUT->continue_button("$CFG->wwwroot/$CFG->admin/index.php"); } echo $OUTPUT->footer(); exit; @@ -108,7 +108,7 @@ //Print form echo $OUTPUT->heading(format_string("$strcoursebackup: $course->fullname ($course->shortname)")); - print_simple_box_start("center"); + echo $OUTPUT->box_start(); //Adjust some php variables to the execution of this script @ini_set("max_execution_time","3000"); @@ -126,7 +126,7 @@ } else if ($launch == "execute") { include_once("backup_execute.html"); } - print_simple_box_end(); + echo $OUTPUT->box_end(); //Print footer echo $OUTPUT->footer(); diff --git a/backup/backup_check.html b/backup/backup_check.html index 94d92b6236..51d46763fc 100644 --- a/backup/backup_check.html +++ b/backup/backup_check.html @@ -119,7 +119,7 @@ $backupprefs->backup_blogs = 0; $backupprefs->backuproleassignments = array(); - print_simple_box("".get_string("backupnoneusersinfo")."","center", "70%", '', "20", "noticebox"); + echo $OUTPUT->box(get_string("backupnoneusersinfo"), "noticebox"); echo "
"; } diff --git a/backup/backup_execute.html b/backup/backup_execute.html index 1ca0344b41..fd16937f50 100644 --- a/backup/backup_execute.html +++ b/backup/backup_execute.html @@ -76,11 +76,11 @@ if (empty($to)) { //Print final message - print_simple_box(get_string("backupfinished"),"center"); + echo $OUTPUT->box(get_string("backupfinished")); $context = get_context_instance(CONTEXT_COURSE, $course->id); - print_continue("$CFG->wwwroot/files/index.php?contextid=".$context->id."&filearea=course_backup&itemid=0"); + echo $OUTPUT->continue_button("$CFG->wwwroot/files/index.php?contextid=".$context->id."&filearea=course_backup&itemid=0"); } else { - print_simple_box(get_string('importdataexported'),"CENTER"); + echo $OUTPUT->box(get_string('importdataexported')); if (!empty($preferences->backup_destination)) { $filename = $preferences->backup_destination."/".$preferences->backup_name; } else { @@ -88,7 +88,7 @@ } error_log($filename); $SESSION->import_preferences = $preferences; - print_continue($CFG->wwwroot.'/course/import/activities/index.php?id='.$to.'&fromcourse='.$id.'&filename='.$filename); + echo $OUTPUT->continue_button($CFG->wwwroot.'/course/import/activities/index.php?id='.$to.'&fromcourse='.$id.'&filename='.$filename); } $SESSION->backupprefs[$course->id] = null; // unset it so we're clear next time. diff --git a/backup/backup_form.html b/backup/backup_form.html index 45d8854ab2..e3ab9507dd 100644 --- a/backup/backup_form.html +++ b/backup/backup_form.html @@ -270,7 +270,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) { echo ""; echo ""; echo ''; - helpbutton('sitefilesused', get_string('sitefilesused')); + echo $OUTPUT->help_icon(moodle_help_icon::make('sitefilesused', get_string('sitefilesused'))); echo ""; $course_file_options[0] = get_string("no"); $course_file_options[1] = get_string("yes"); diff --git a/backup/backuplib.php b/backup/backuplib.php index 97a79ad62c..a0f0ae1968 100644 --- a/backup/backuplib.php +++ b/backup/backuplib.php @@ -2267,7 +2267,7 @@ //This function makes all the necesary calls to every mod //to export itself and its files !!! function backup_module($bf,$preferences,$module) { - global $CFG, $DB; + global $CFG, $DB, $OUTPUT; $status = true; $statusm = true; @@ -2285,7 +2285,7 @@ $errorstr = 'backup of '.$module.'-'.$object->name.' failed.'; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } $status = false; } @@ -2970,7 +2970,7 @@ } function backup_execute(&$preferences, &$errorstr) { - global $CFG, $DB; + global $CFG, $DB, $OUTPUT; $status = true; //Check for temp and backup and backup_unique_code directory @@ -2994,7 +2994,7 @@ $errorstr = "An error occurred deleting old backup data"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify ($errorstr); + echo $OUTPUT->notification($errorstr); } } @@ -3017,7 +3017,7 @@ $errorstr = "An error occurred while backing up general info"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3035,7 +3035,7 @@ $errorstr = "An error occurred while backing up course start"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3050,7 +3050,7 @@ $errorstr = "An error occurred while backing up metacourse info"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3065,7 +3065,7 @@ $errorstr = "An error occurred while backing up course blocks"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3080,7 +3080,7 @@ $errorstr = "An error occurred while backing up course sections"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3101,7 +3101,7 @@ $errorstr = "An error occurred while backing up user info"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3118,7 +3118,7 @@ $errorstr = "An error occurred while backing up messages"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3135,7 +3135,7 @@ $errorstr = "An error occurred while backing up blogs"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3153,7 +3153,7 @@ $errorstr = "An error occurred while backing up quiz categories"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3170,7 +3170,7 @@ $errorstr = "An error occurred while backing up log info"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3187,7 +3187,7 @@ $errorstr = "An error occurred while backing up scales"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3203,7 +3203,7 @@ $errostr = "An error occurred while backing up groups"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errostr); + echo $OUTPUT->notification($errostr); } else { return false; } @@ -3219,7 +3219,7 @@ $errorstr = "An error occurred while backing up groupings"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3235,7 +3235,7 @@ $errorstr = "An error occurred while backing up groupings groups"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3251,7 +3251,7 @@ $errorstr = "An error occurred while backing up events"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3267,7 +3267,7 @@ $errorstr = "An error occurred while backing up gradebook"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3294,7 +3294,7 @@ $errorstr = "An error occurred while backing up module info"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3313,7 +3313,7 @@ $errorstr = "An error occurred while backing up '$module->name'"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3329,7 +3329,7 @@ $errorstr = "An error occurred while finishing the module backups"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3346,7 +3346,7 @@ $errorstr = "An error occurred while backing up the course format data"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3359,7 +3359,7 @@ $errorstr = "An error occurred while closing the course backup"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3386,7 +3386,7 @@ $errorstr = "An error occurred while copying user files"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3404,7 +3404,7 @@ $errorstr = "An error occurred while copying course files"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3421,7 +3421,7 @@ $errorstr = "An error occurred while copying site files"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3437,7 +3437,7 @@ $errorstr = "An error occurred while zipping the backup"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3453,7 +3453,7 @@ $errorstr = "An error occurred while copying the zip file to the course directory"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -3469,7 +3469,7 @@ $errorstr = "An error occurred while cleaning up temporary data"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'manual'); if (!defined('BACKUP_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } diff --git a/backup/bb/restore_bb.php b/backup/bb/restore_bb.php index b55780c516..f22361734f 100644 --- a/backup/bb/restore_bb.php +++ b/backup/bb/restore_bb.php @@ -32,14 +32,14 @@ function choose_bb_xsl($manifest){ function blackboard_convert($dir){ - global $CFG; + global $CFG, $OUTPUT; // Check for a Blackboard manifest file if (is_readable($dir.'/imsmanifest.xml') && !is_readable($dir.'/moodle.xml')){ if (!function_exists('xslt_create')) { // XSLT MUST be installed for this to work - notify('You need the XSLT library installed in PHP to open this Blackboard file'); + echo $OUTPUT->notification('You need the XSLT library installed in PHP to open this Blackboard file'); return false; } @@ -52,7 +52,7 @@ function blackboard_convert($dir){ // The XSL file must be in the same directory as the Blackboard files when it is processed if (!copy($CFG->dirroot."/backup/bb/$xslt_file", "$dir/$xslt_file")) { - notify('Could not copy the XSLT file to '."$dir/$xslt_file"); + echo $OUTPUT->notification('Could not copy the XSLT file to '."$dir/$xslt_file"); return false; } @@ -66,7 +66,7 @@ function blackboard_convert($dir){ // The XSL processor will open them as needed. $xsltproc = xslt_create(); if (!xslt_process($xsltproc, 'imsmanifest.xml', "$dir/$xslt_file", "$dir/moodle.xml")) { - notify('Failed writing xml file'); + echo $OUTPUT->notification('Failed writing xml file'); chdir($startdir); return false; } diff --git a/backup/restore.php b/backup/restore.php index a2386a245a..f4ba4db397 100644 --- a/backup/restore.php +++ b/backup/restore.php @@ -105,7 +105,7 @@ if (!$file) { print_header("$site->shortname: $strcourserestore", $site->fullname, $navigation); echo $OUTPUT->heading(get_string("nofilesselected")); - print_continue("$CFG->wwwroot/$CFG->admin/index.php"); + echo $OUTPUT->continue_button("$CFG->wwwroot/$CFG->admin/index.php"); echo $OUTPUT->footer(); exit; } @@ -114,7 +114,7 @@ if ($cancel) { print_header("$site->shortname: $strcourserestore", $site->fullname, $navigation); echo $OUTPUT->heading(get_string("restorecancelled")); - print_continue("$CFG->wwwroot/course/view.php?id=".$id); + echo $OUTPUT->continue_button("$CFG->wwwroot/course/view.php?id=".$id); echo $OUTPUT->footer(); exit; } @@ -136,7 +136,7 @@ } //Print form echo $OUTPUT->heading("$strcourserestore".((empty($to) ? ': '.basename($file) : ''))); - print_simple_box_start('center'); + echo $OUTPUT->box_start(); //Adjust some php variables to the execution of this script @ini_set("max_execution_time","3000"); @@ -171,7 +171,7 @@ unset($SESSION->cancontinue); include_once("restore_execute.html"); } - print_simple_box_end(); + echo $OUTPUT->box_end(); //Print footer echo $OUTPUT->footer(); diff --git a/backup/restore_check.html b/backup/restore_check.html index 7cc1293087..deb4aaf380 100644 --- a/backup/restore_check.html +++ b/backup/restore_check.html @@ -238,7 +238,7 @@ if ($courses = $mycourses) { echo $OUTPUT->heading(get_string("choosecourse")); - print_simple_box_start("center"); + echo $OUTPUT->box_start(); foreach ($courses as $course) { if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $course->id))) { continue; @@ -250,10 +250,10 @@ } echo "id&launch=check&id=$id&file=$file\">".format_string($course->fullname).' ('.format_string($course->shortname).')
'."\n"; } - print_simple_box_end(); + echo $OUTPUT->box_end(); } else { echo $OUTPUT->heading(get_string("nocoursesyet")); - print_continue("$CFG->wwwroot/$CFG->admin/index.php"); + echo $OUTPUT->continue_button("$CFG->wwwroot/$CFG->admin/index.php"); } //Checks everything and execute restore } else if (($restore->restoreto != RESTORETO_NEW_COURSE and !empty($restore->course_id)) or ($restore->restoreto == RESTORETO_NEW_COURSE)) { diff --git a/backup/restore_execute.html b/backup/restore_execute.html index e80b29e297..6fd307e369 100644 --- a/backup/restore_execute.html +++ b/backup/restore_execute.html @@ -58,9 +58,9 @@ if (empty($restore->importing)) { //Print final message - print_simple_box(get_string("restorefinished"),"center"); + echo $OUTPUT->box(get_string("restorefinished")); } else { - print_simple_box(get_string("importdatafinished"),"center"); + echo $OUTPUT->box(get_string("importdatafinished")); $file = $CFG->dataroot . '/' . $SESSION->import_preferences->backup_course . '/backupdata/' . $SESSION->import_preferences->backup_name; @@ -72,6 +72,6 @@ } unset($SESSION->restore); } - print_continue("$CFG->wwwroot/course/view.php?id=".$restore->course_id); + echo $OUTPUT->continue_button("$CFG->wwwroot/course/view.php?id=".$restore->course_id); ?> diff --git a/backup/restore_form.html b/backup/restore_form.html index 0278661643..320af388c2 100644 --- a/backup/restore_form.html +++ b/backup/restore_form.html @@ -264,7 +264,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) { echo ''; echo ""; echo "shortname)."\" alt=\"".get_string("shortname")."\" />" ; - helpbutton("courseshortname", get_string("shortname")) ; + echo $OUTPUT->help_icon(moodle_help_icon::make("courseshortname", get_string("shortname"))) ; if (isset($err["shortname"])) formerr($err["shortname"]); echo ""; echo ""; @@ -273,7 +273,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) { echo ''; echo ""; echo "fullname)."\" alt=\" ".get_string("fullname")."\" />" ; - helpbutton("coursefullname", get_string("fullname")) ; + echo $OUTPUT->help_icon(moodle_help_icon::make("coursefullname", get_string("fullname"))) ; if (isset($err["fullname"])) formerr($err["fullname"]); echo""; echo " "; @@ -289,7 +289,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) { $yearselector = html_select::make_time_selector('years', "startyear", $form1->startdate); echo $OUTPUT->select($dayselector) . $OUTPUT->select($monthselector) . $OUTPUT->select($yearselector); - helpbutton("coursestartdate", get_string("startdate")); + echo $OUTPUT->help_icon(moodle_help_icon::make("coursestartdate", get_string("startdate"))); } else { print_string('notavailable'); echo ''; @@ -445,7 +445,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) { //Now print the Groups tr (assume there is no $info->backup_groups) echo ""; echo ""; - $helplink = helpbutton('grouprestore', get_string('groups'), '', true, false, '', true); + $helplink = $OUTPUT->help_icon(moodle_help_icon::make('grouprestore', get_string('groups'))); if (empty($CFG->enablegroupings)) { echo ''.$helplink; echo ""; diff --git a/backup/restorelib.php b/backup/restorelib.php index e64358129c..82382814b0 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -536,7 +536,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); print_table($table); if ($info->backup_backup_version <= 2005070500) { - notify(get_string('backupnonisowarning')); // Message informing that this backup may not work! + echo $OUTPUT->notification(get_string('backupnonisowarning')); // Message informing that this backup may not work! } //Now backup contents in another table @@ -7784,7 +7784,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); */ function restore_precheck($id,$file,&$errorstr,$noredirect=false) { - global $CFG, $SESSION; + global $CFG, $SESSION, $OUTPUT; //Prepend dataroot to variable to have the absolute path $file = $CFG->dataroot."/".$file; @@ -7840,7 +7840,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); $errorstr = "An error occurred deleting old data"; add_to_backup_log(time(),$preferences->backup_course,$errorstr,'restoreprecheck'); if (!defined('RESTORE_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } } } @@ -7852,7 +7852,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (! $status = backup_copy_file($file,$CFG->dataroot."/temp/backup/".$backup_unique_code."/".basename($file))) { if (!defined('RESTORE_SILENTLY')) { - notify("Error copying backup file. Invalid name or bad perms."); + echo $OUTPUT->notification("Error copying backup file. Invalid name or bad perms."); } else { $errorstr = "Error copying backup file. Invalid name or bad perms"; return false; @@ -7867,7 +7867,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (! $status = restore_unzip ($CFG->dataroot."/temp/backup/".$backup_unique_code."/".basename($file))) { if (!defined('RESTORE_SILENTLY')) { - notify("Error unzipping backup file. Invalid zip file."); + echo $OUTPUT->notification("Error unzipping backup file. Invalid zip file."); } else { $errorstr = "Error unzipping backup file. Invalid zip file."; return false; @@ -7897,7 +7897,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); $errorstr = 'Error checking backup file. moodle.xml is incorrect or corrupted.'; } if (!defined('RESTORE_SILENTLY')) { - notify($errorstr); + echo $OUTPUT->notification($errorstr); } else { return false; } @@ -7939,7 +7939,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); $message->serverrelease = $CFG->release; $message->backupversion = $info->backup_moodle_version; $message->backuprelease = $info->backup_moodle_release; - print_simple_box(get_string('noticenewerbackup','',$message), "center", "70%", '', "20", "noticebox"); + echo $OUTPUT->box(get_string('noticenewerbackup','',$message), "noticebox"); } @@ -8057,7 +8057,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } function restore_execute(&$restore,$info,$course_header,&$errorstr) { - global $CFG, $USER, $DB; + global $CFG, $USER, $DB, $OUTPUT; $status = true; @@ -8095,7 +8095,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); //First of all, split moodle.xml into handy files if (!restore_split_xml ($xml_file, $restore)) { if (!defined('RESTORE_SILENTLY')) { - notify("Error proccessing moodle.xml file. Process ended."); + echo $OUTPUT->notification("Error proccessing moodle.xml file. Process ended."); } else { $errorstr = "Error proccessing moodle.xml file. Process ended."; } @@ -8113,7 +8113,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); $oldidnumber = $course_header->course_idnumber; if (!$status = restore_create_new_course($restore,$course_header)) { if (!defined('RESTORE_SILENTLY')) { - notify("Error while creating the new empty course."); + echo $OUTPUT->notification("Error while creating the new empty course."); } else { $errorstr = "Error while creating the new empty course."; return false; @@ -8169,7 +8169,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); $restore->restoreto = RESTORETO_NEW_COURSE; } else { if (!defined('RESTORE_SILENTLY')) { - notify("An error occurred while deleting some of the course contents."); + echo $OUTPUT->notification("An error occurred while deleting some of the course contents."); } else { $errrostr = "An error occurred while deleting some of the course contents."; return false; @@ -8178,7 +8178,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } } else { if (!defined('RESTORE_SILENTLY')) { - notify("Error opening existing course."); + echo $OUTPUT->notification("Error opening existing course."); $status = false; } else { $errorstr = "Error opening existing course."; @@ -8194,7 +8194,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_create_users($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not restore users."); + echo $OUTPUT->notification("Could not restore users."); } else { $errorstr = "Could not restore users."; return false; @@ -8250,7 +8250,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } } else { if (!defined('RESTORE_SILENTLY')) { - notify("No users were found!"); + echo $OUTPUT->notification("No users were found!"); } // no need to return false here, it's recoverable. } } @@ -8268,7 +8268,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_create_groups($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not restore groups!"); + echo $OUTPUT->notification("Could not restore groups!"); } else { $errorstr = "Could not restore groups!"; return false; @@ -8286,7 +8286,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_create_groupings($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not restore groupings!"); + echo $OUTPUT->notification("Could not restore groupings!"); } else { $errorstr = "Could not restore groupings!"; return false; @@ -8304,7 +8304,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_create_groupings_groups($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not restore groups in groupings!"); + echo $OUTPUT->notification("Could not restore groups in groupings!"); } else { $errorstr = "Could not restore groups in groupings!"; return false; @@ -8326,7 +8326,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_create_sections($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Error creating sections in the existing course."); + echo $OUTPUT->notification("Error creating sections in the existing course."); } else { $errorstr = "Error creating sections in the existing course."; return false; @@ -8342,7 +8342,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_create_sections($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Error creating sections in the existing course."); + echo $OUTPUT->notification("Error creating sections in the existing course."); } else { $errorstr = "Error creating sections in the existing course."; return false; @@ -8354,7 +8354,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); //Error } else { if (!defined('RESTORE_SILENTLY')) { - notify("Neither a new course or an existing one was specified."); + echo $OUTPUT->notification("Neither a new course or an existing one was specified."); $status = false; } else { $errorstr = "Neither a new course or an existing one was specified."; @@ -8372,7 +8372,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_create_metacourse($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Error creating metacourse in the course."); + echo $OUTPUT->notification("Error creating metacourse in the course."); } else { $errorstr = "Error creating metacourse in the course."; return false; @@ -8394,7 +8394,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_create_questions($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not restore categories and questions!"); + echo $OUTPUT->notification("Could not restore categories and questions!"); } else { $errorstr = "Could not restore categories and questions!"; return false; @@ -8412,7 +8412,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_user_files($restore)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not restore user files!"); + echo $OUTPUT->notification("Could not restore user files!"); } else { $errorstr = "Could not restore user files!"; return false; @@ -8439,7 +8439,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_course_files($restore)) { if (empty($status)) { - notify("Could not restore course files!"); + echo $OUTPUT->notification("Could not restore course files!"); } else { $errorstr = "Could not restore course files!"; return false; @@ -8467,7 +8467,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_site_files($restore)) { if (empty($status)) { - notify("Could not restore site files!"); + echo $OUTPUT->notification("Could not restore site files!"); } else { $errorstr = "Could not restore site files!"; return false; @@ -8494,7 +8494,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_create_messages($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not restore messages!"); + echo $OUTPUT->notification("Could not restore messages!"); } else { $errorstr = "Could not restore messages!"; return false; @@ -8512,7 +8512,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_create_blogs($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not restore blogs!"); + echo $OUTPUT->notification("Could not restore blogs!"); } else { $errorstr = "Could not restore blogs!"; return false; @@ -8530,7 +8530,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_create_scales($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not restore custom scales!"); + echo $OUTPUT->notification("Could not restore custom scales!"); } else { $errorstr = "Could not restore custom scales!"; return false; @@ -8548,7 +8548,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_create_events($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not restore course events!"); + echo $OUTPUT->notification("Could not restore course events!"); } else { $errorstr = "Could not restore course events!"; return false; @@ -8566,7 +8566,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_create_modules($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not restore modules!"); + echo $OUTPUT->notification("Could not restore modules!"); } else { $errorstr = "Could not restore modules!"; return false; @@ -8589,7 +8589,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); $course_header->blockinfo = !empty($course_header->blockinfo) ? $course_header->blockinfo : NULL; if (!$status = restore_create_blocks($restore, $info->backup_block_format, $course_header->blockinfo, $xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify('Error while creating the course blocks'); + echo $OUTPUT->notification('Error while creating the course blocks'); } else { $errorstr = "Error while creating the course blocks"; return false; @@ -8612,7 +8612,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); if (!$status = restore_set_format_data($restore, $xml_file)) { $error = "Error while setting the course format data"; if (!defined('RESTORE_SILENTLY')) { - notify($error); + echo $OUTPUT->notification($error); } else { $errorstr=$error; return false; @@ -8631,7 +8631,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_create_logs($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not restore logs!"); + echo $OUTPUT->notification("Could not restore logs!"); } else { $errorstr = "Could not restore logs!"; return false; @@ -8651,7 +8651,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_check_instances($restore)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not adjust instances in course_modules!"); + echo $OUTPUT->notification("Could not adjust instances in course_modules!"); } else { $errorstr = "Could not adjust instances in course_modules!"; return false; @@ -8669,7 +8669,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_refresh_events($restore)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not refresh events for activities!"); + echo $OUTPUT->notification("Could not refresh events for activities!"); } else { $errorstr = "Could not refresh events for activities!"; return false; @@ -8687,7 +8687,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_decode_content_links($restore)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not decode content links!"); + echo $OUTPUT->notification("Could not decode content links!"); } else { $errorstr = "Could not decode content links!"; return false; @@ -8706,7 +8706,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_convert_wiki2markdown($restore)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not convert wiki texts to markdown!"); + echo $OUTPUT->notification("Could not convert wiki texts to markdown!"); } else { $errorstr = "Could not convert wiki texts to markdown!"; return false; @@ -8725,7 +8725,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } if (!$status = restore_create_gradebook($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not restore gradebook!"); + echo $OUTPUT->notification("Could not restore gradebook!"); } else { $errorstr = "Could not restore gradebook!"; return false; @@ -8746,7 +8746,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); /// force full refresh of grading data before migration == crete all items first if (!$status = restore_migrate_old_gradebook($restore,$xml_file)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not migrate gradebook!"); + echo $OUTPUT->notification("Could not migrate gradebook!"); } else { $errorstr = "Could not migrade gradebook!"; return false; @@ -8795,7 +8795,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); role_assign($legacyteacher->id, $USER->id, 0, $newcontext->id); } } else { - notify('Could not find a legacy teacher role. You might need your moodle admin to assign a role with editing privilages to this course.'); + echo $OUTPUT->notification('Could not find a legacy teacher role. You might need your moodle admin to assign a role with editing privilages to this course.'); } } } @@ -8839,7 +8839,7 @@ WHERE } if (!$status = clean_temp_data ($restore)) { if (!defined('RESTORE_SILENTLY')) { - notify("Could not clean up temporary data from files and database"); + echo $OUTPUT->notification("Could not clean up temporary data from files and database"); } else { $errorstr = "Could not clean up temporary data from files and database"; return false; @@ -8858,7 +8858,7 @@ WHERE } else { if (!defined('RESTORE_SILENTLY')) { - notify("Could not close the restorelog.html file"); + echo $OUTPUT->notification("Could not close the restorelog.html file"); } } -- 2.39.5