From e6db30260fe97a90a3c6f2d9b321db2e02081170 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Tue, 18 Aug 2009 04:58:26 +0000 Subject: [PATCH] MDL-19794 Upgraded calls to helpbutton, print_simple_box* and notify --- course/delete.php | 2 +- course/format/scorm/format.php | 2 +- course/format/social/format.php | 2 +- course/import/activities/mod.php | 2 +- course/import/groups/index.php | 12 ++++----- course/import/groups/mod.php | 4 +-- course/importstudents.php | 6 ++--- course/index.php | 6 ++--- course/lib.php | 38 +++++++++++++-------------- course/mod.php | 11 ++++---- course/recent.php | 8 +++--- course/report/log/index.php | 6 ++--- course/report/participation/index.php | 4 +-- course/report/stats/report.php | 2 +- course/reset.php | 4 +-- course/scales.php | 14 +++++----- course/search.php | 6 ++--- course/user.php | 2 +- course/view.php | 2 +- 19 files changed, 67 insertions(+), 66 deletions(-) diff --git a/course/delete.php b/course/delete.php index bfc3acf33e9..843fe3a6cc7 100644 --- a/course/delete.php +++ b/course/delete.php @@ -79,7 +79,7 @@ echo $OUTPUT->heading( get_string("deletedcourse", "", format_string($course->shortname)) ); - print_continue("category.php?id=$course->category"); + echo $OUTPUT->continue_button("category.php?id=$course->category"); echo $OUTPUT->footer(); diff --git a/course/format/scorm/format.php b/course/format/scorm/format.php index 37032b5eefa..d92ea4f2f2c 100644 --- a/course/format/scorm/format.php +++ b/course/format/scorm/format.php @@ -13,5 +13,5 @@ if (function_exists($moduleformat)) { $moduleformat($USER,$course); } else { - notify('The module '. $module. ' does not support single activity course format'); + echo $OUTPUT->notification('The module '. $module. ' does not support single activity course format'); } diff --git a/course/format/social/format.php b/course/format/social/format.php index b3ab1faf2a6..659ae065b64 100644 --- a/course/format/social/format.php +++ b/course/format/social/format.php @@ -21,5 +21,5 @@ forum_print_latest_discussions($course, $forum, 10, 'plain', '', false); } else { - notify('Could not find or create a social forum here'); + echo $OUTPUT->notification('Could not find or create a social forum here'); } diff --git a/course/import/activities/mod.php b/course/import/activities/mod.php index 944aa1a2a47..36d5cc13866 100644 --- a/course/import/activities/mod.php +++ b/course/import/activities/mod.php @@ -47,7 +47,7 @@ } if (empty($options) && empty($creator)) { - notify(get_string('courseimportnotaught')); + echo $OUTPUT->notification(get_string('courseimportnotaught')); return; // yay , this will pass control back to the file that included or required us. } diff --git a/course/import/groups/index.php b/course/import/groups/index.php index 0c2d9798019..478e12f4fc6 100755 --- a/course/import/groups/index.php +++ b/course/import/groups/index.php @@ -137,7 +137,7 @@ //unset invalid courseid if (isset($newgroup->idnumber)){ if (!$mycourse = $DB->get_record('course', array('idnumber'=>$newgroup->idnumber))) { - notify(get_string('unknowncourseidnumber', 'error', $newgroup->idnumber)); + echo $OUTPUT->notification(get_string('unknowncourseidnumber', 'error', $newgroup->idnumber)); unset($newgroup->courseid);//unset so 0 doesnt' get written to database } $newgroup->courseid = $mycourse->id; @@ -147,7 +147,7 @@ else if (isset($newgroup->coursename)){ if (!$mycourse = $DB->get_record('course', array('shortname', $newgroup->coursename))) { - notify(get_string('unknowncourse', 'error', $newgroup->coursename)); + echo $OUTPUT->notification(get_string('unknowncourse', 'error', $newgroup->coursename)); unset($newgroup->courseid);//unset so 0 doesnt' get written to database } $newgroup->courseid = $mycourse->id; @@ -168,7 +168,7 @@ ///Users cannot upload groups in courses they cannot update. if (!has_capability('moodle/course:managegroups', $newgrpcoursecontext)){ - notify(get_string('nopermissionforcreation','group',$groupname)); + echo $OUTPUT->notification(get_string('nopermissionforcreation','group',$groupname)); } else { if ( $groupid = groups_get_group_by_name($newgroup->courseid, $groupname) || !($newgroup->id = groups_create_group($newgroup)) ) { @@ -176,13 +176,13 @@ //Record not added - probably because group is already registered //In this case, output groupname from previous registration if ($groupid) { - notify("$groupname :".get_string('groupexistforcourse', 'error', $groupname)); + echo $OUTPUT->notification("$groupname :".get_string('groupexistforcourse', 'error', $groupname)); } else { - notify(get_string('groupnotaddederror', 'error', $groupname)); + echo $OUTPUT->notification(get_string('groupnotaddederror', 'error', $groupname)); } } else { - notify(get_string('groupaddedsuccesfully', 'group', $groupname)); + echo $OUTPUT->notification(get_string('groupaddedsuccesfully', 'group', $groupname)); } } } //close courseid validity check diff --git a/course/import/groups/mod.php b/course/import/groups/mod.php index 141a639a9b9..df47c707d83 100644 --- a/course/import/groups/mod.php +++ b/course/import/groups/mod.php @@ -14,14 +14,14 @@ print_heading_with_help($strimportgroups, 'uploadgroups'); $maxuploadsize = get_max_upload_file_size(); echo '

'; - print_simple_box_start('center','80%'); + echo $OUTPUT->box_start(); // use formslib include_once('import_form.php'); $mform_post = new course_import_groups_form($CFG->wwwroot.'/course/import/groups/index.php?id='.$id, array('maxuploadsize'=>$maxuploadsize)); $mform_post ->display(); - print_simple_box_end(); + echo $OUTPUT->box_end(); echo '

'; diff --git a/course/importstudents.php b/course/importstudents.php index dc56aa2f072..9ac1efd2c84 100644 --- a/course/importstudents.php +++ b/course/importstudents.php @@ -54,7 +54,7 @@ if (!$frm = data_submitted()) { $note = get_string("importmetacoursenote"); - print_simple_box($note, "center", "50%"); + echo $OUTPUT->box($note); /// A form was submitted so process the input @@ -120,11 +120,11 @@ } } - print_simple_box_start("center"); + echo $OUTPUT->box_start(); include('importstudents.html'); - print_simple_box_end(); + echo $OUTPUT->box_end(); echo $OUTPUT->footer(); diff --git a/course/index.php b/course/index.php index 48fcba31605..da44a214b46 100644 --- a/course/index.php +++ b/course/index.php @@ -125,9 +125,9 @@ $deletedcourses = category_delete_full($deletecat, true); foreach($deletedcourses as $course) { - notify(get_string('coursedeleted', '', $course->shortname), 'notifysuccess'); + echo $OUTPUT->notification(get_string('coursedeleted', '', $course->shortname), 'notifysuccess'); } - notify(get_string('coursecategorydeleted', '', format_string($deletecat->name)), 'notifysuccess'); + echo $OUTPUT->notification(get_string('coursecategorydeleted', '', format_string($deletecat->name)), 'notifysuccess'); } else { category_delete_move($deletecat, $data->newparent, true); @@ -138,7 +138,7 @@ set_config('defaultrequestcategory', $DB->get_field('course_categories', 'MIN(id)', array('parent'=>0))); } - print_continue('index.php'); + echo $OUTPUT->continue_button('index.php'); echo $OUTPUT->footer(); die; diff --git a/course/lib.php b/course/lib.php index 71c1fb057fd..8b15ab81152 100644 --- a/course/lib.php +++ b/course/lib.php @@ -274,7 +274,7 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per if (!$logs = build_logs_array($course, $user, $date, $order, $page*$perpage, $perpage, $modname, $modid, $modaction, $groupid)) { - notify("No logs found!"); + echo $OUTPUT->notification("No logs found!"); echo $OUTPUT->footer(); exit; } @@ -395,7 +395,7 @@ function print_mnet_log($hostid, $course, $user=0, $date=0, $order="l.time ASC", if (!$logs = build_mnet_logs_array($hostid, $course, $user, $date, $order, $page*$perpage, $perpage, $modname, $modid, $modaction, $groupid)) { - notify("No logs found!"); + echo $OUTPUT->notification("No logs found!"); echo $OUTPUT->footer(); exit; } @@ -824,7 +824,7 @@ function print_overview($courses) { } } foreach ($courses as $course) { - print_simple_box_start('center', '100%', '', 5, "coursebox"); + echo $OUTPUT->box_start("coursebox"); $linkcss = ''; if (empty($course->visible)) { $linkcss = 'class="dimmed"'; @@ -835,7 +835,7 @@ function print_overview($courses) { echo $html; } } - print_simple_box_end(); + echo $OUTPUT->box_end(); } } @@ -1655,7 +1655,7 @@ function get_category_or_system_context($categoryid) { * @param boolean $clearonly - only clear the modinfo fields, gets rebuild automatically on the fly */ function rebuild_course_cache($courseid=0, $clearonly=false) { - global $COURSE, $DB; + global $COURSE, $DB, $OUTPUT; if ($clearonly) { if (empty($courseid)) { @@ -1685,7 +1685,7 @@ function rebuild_course_cache($courseid=0, $clearonly=false) { foreach ($rs as $course) { $modinfo = serialize(get_array_of_activities($course->id)); if (!$DB->set_field("course", "modinfo", $modinfo, array("id"=>$course->id))) { - notify("Could not cache module information for course '" . format_string($course->fullname) . "'!"); + echo $OUTPUT->notification("Could not cache module information for course '" . format_string($course->fullname) . "'!"); } // update cached global COURSE too ;-) if ($course->id == $COURSE->id) { @@ -2230,7 +2230,7 @@ function print_course($course, $highlightterms = '') { * Over time this can include all sorts of information */ function print_my_moodle() { - global $USER, $CFG, $DB; + global $USER, $CFG, $DB, $OUTPUT; if (empty($USER->id)) { print_error('nopermissions', '', '', 'See My Moodle'); @@ -2284,9 +2284,9 @@ function print_my_moodle() { } else { if ($DB->count_records("course_categories") > 1) { - print_simple_box_start("center", "100%", "#FFFFFF", 5, "categorybox"); + echo $OUTPUT->box_start("categorybox"); print_whole_category_list(); - print_simple_box_end(); + echo $OUTPUT->box_end(); } else { print_courses(0); } @@ -2726,11 +2726,11 @@ function reorder_sections($sections, $origin_position, $target_position) { * All parameters are objects */ function moveto_module($mod, $section, $beforemod=NULL) { - global $DB; + global $DB, $OUTPUT; /// Remove original module from original section if (! delete_mod_from_section($mod->id, $mod->section)) { - notify("Could not delete module from existing section"); + echo $OUTPUT->notification("Could not delete module from existing section"); } /// Update module itself if necessary @@ -2979,7 +2979,7 @@ function print_groupmode_setting($form, $course=NULL) { $select = html_select::make($choices, 'groupmode', $groupmode, false); $select->disabled = $course->groupmodeforce; echo $OUTPUT->select($select); - helpbutton('groupmode', get_string('groupmode')); + echo $OUTPUT->help_icon(moodle_help_icon::make('groupmode', get_string('groupmode'))); echo ''; } } @@ -3162,7 +3162,7 @@ function category_delete_full($category, $showfeedback=true) { * @return bool status */ function category_delete_move($category, $newparentid, $showfeedback=true) { - global $CFG, $DB; + global $CFG, $DB, $OUTPUT; require_once($CFG->libdir.'/gradelib.php'); require_once($CFG->libdir.'/questionlib.php'); @@ -3178,16 +3178,16 @@ function category_delete_move($category, $newparentid, $showfeedback=true) { if ($courses = $DB->get_records('course', array('category'=>$category->id), 'sortorder ASC', 'id')) { if (!move_courses(array_keys($courses), $newparentid)) { - notify("Error moving courses"); + echo $OUTPUT->notification("Error moving courses"); return false; } - notify(get_string('coursesmovedout', '', format_string($category->name)), 'notifysuccess'); + echo $OUTPUT->notification(get_string('coursesmovedout', '', format_string($category->name)), 'notifysuccess'); } // now delete anything that may depend on course category context grade_course_category_delete($category->id, $newparentid, $showfeedback); if (!question_delete_course_category($category, $newparentcat, $showfeedback)) { - notify(get_string('errordeletingquestionsfromcategory', 'question', $category), 'notifysuccess'); + echo $OUTPUT->notification(get_string('errordeletingquestionsfromcategory', 'question', $category), 'notifysuccess'); return false; } @@ -3197,7 +3197,7 @@ function category_delete_move($category, $newparentid, $showfeedback=true) { events_trigger('course_category_deleted', $category); - notify(get_string('coursecategorydeleted', '', format_string($category->name)), 'notifysuccess'); + echo $OUTPUT->notification(get_string('coursecategorydeleted', '', format_string($category->name)), 'notifysuccess'); return true; } @@ -3209,7 +3209,7 @@ function category_delete_move($category, $newparentid, $showfeedback=true) { * @param $courseids is an array of course ids */ function move_courses($courseids, $categoryid) { - global $CFG, $DB; + global $CFG, $DB, $OUTPUT; if (!empty($courseids) and $category = $DB->get_record('course_categories', array('id'=>$categoryid))) { $courseids = array_reverse($courseids); @@ -3217,7 +3217,7 @@ function move_courses($courseids, $categoryid) { foreach ($courseids as $courseid) { if (!$course = $DB->get_record("course", array("id"=>$courseid))) { - notify("Error finding course $courseid"); + echo $OUTPUT->notification("Error finding course $courseid"); } else { $course->category = $categoryid; $course->sortorder = $category->sortorder + MAX_COURSES_IN_CATEGORY - $i++; diff --git a/course/mod.php b/course/mod.php index e73795613d6..efb582e8e80 100644 --- a/course/mod.php +++ b/course/mod.php @@ -67,9 +67,10 @@ print_header_simple($strdeletecheck, '', build_navigation(array(array('name'=>$strdeletecheck, 'link'=>'', 'type'=>'misc')))); - print_simple_box_start('center', '60%', '#FFAAAA', 20, 'noticebox'); + // print_simple_box_start('center', '60%', '#FFAAAA', 20, 'noticebox'); + echo $OUTPUT->box_start('noticebox'); notice_yesno($strdeletecheckfull, 'mod.php', $return, $optionsyes, $optionsno, 'post', 'get'); - print_simple_box_end(); + echo $OUTPUT->box_end(); echo $OUTPUT->footer(); exit; @@ -86,7 +87,7 @@ $deleteinstancefunction = $cm->modname."_delete_instance"; if (!$deleteinstancefunction($cm->instance)) { - notify("Could not delete the $cm->modname (instance)"); + echo $OUTPUT->notification("Could not delete the $cm->modname (instance)"); } // remove all module files in case modules forget to do that @@ -94,10 +95,10 @@ $fs->delete_area_files($modcontext->id); if (!delete_course_module($cm->id)) { - notify("Could not delete the $cm->modname (coursemodule)"); + echo $OUTPUT->notification("Could not delete the $cm->modname (coursemodule)"); } if (!delete_mod_from_section($cm->id, $cm->section)) { - notify("Could not delete the $cm->modname from that section"); + echo $OUTPUT->notification("Could not delete the $cm->modname from that section"); } add_to_log($course->id, 'course', "delete mod", diff --git a/course/recent.php b/course/recent.php index dd1af297e38..ced879bf652 100644 --- a/course/recent.php +++ b/course/recent.php @@ -203,12 +203,12 @@ if (($activity->type == 'section') && ($param->sortby == 'default')) { if ($inbox) { - print_simple_box_end(); + echo $OUTPUT->box_end(); $spacer = new html_image(); $spacer->height = 30; echo $OUTPUT->spacer($spacer) . '
'; } - print_simple_box_start('center', '90%'); + echo $OUTPUT->box_start(); echo "

$activity->name

"; $inbox = true; @@ -238,7 +238,7 @@ } if (!$inbox) { - print_simple_box_start('center', '90%'); + echo $OUTPUT->box_start(); $inbox = true; } @@ -251,7 +251,7 @@ } if ($inbox) { - print_simple_box_end(); + echo $OUTPUT->box_end(); } diff --git a/course/report/log/index.php b/course/report/log/index.php index 299f8c5713a..9b5c2839bbf 100644 --- a/course/report/log/index.php +++ b/course/report/log/index.php @@ -102,21 +102,21 @@ case 'downloadascsv': if (!print_log_csv($course, $user, $date, 'l.time DESC', $modname, $modid, $modaction, $group)) { - notify("No logs found!"); + echo $OUTPUT->notification("No logs found!"); echo $OUTPUT->footer(); } exit; case 'downloadasods': if (!print_log_ods($course, $user, $date, 'l.time DESC', $modname, $modid, $modaction, $group)) { - notify("No logs found!"); + echo $OUTPUT->notification("No logs found!"); echo $OUTPUT->footer(); } exit; case 'downloadasexcel': if (!print_log_xls($course, $user, $date, 'l.time DESC', $modname, $modid, $modaction, $group)) { - notify("No logs found!"); + echo $OUTPUT->notification("No logs found!"); echo $OUTPUT->footer(); } exit; diff --git a/course/report/participation/index.php b/course/report/participation/index.php index 846376df8ff..b01ffbc37d8 100644 --- a/course/report/participation/index.php +++ b/course/report/participation/index.php @@ -126,7 +126,7 @@ echo $OUTPUT->select(html_select::make($roleoptions,'roleid',$roleid,false)); echo ''."\n"; echo $OUTPUT->select(html_select::make($actionoptions,'action',$action,false)); - helpbutton('participationreport',get_string('participationreport')); + echo $OUTPUT->help_icon(moodle_help_icon::make('participationreport',get_string('participationreport'))); echo ''."\n\n"; $baseurl = $CFG->wwwroot.'/course/report/participation/index.php?id='.$course->id.'&roleid=' @@ -281,7 +281,7 @@ $select->label = get_string("withselectedusers"); $select->add_action('change', 'conditionalsubmit', array('formid' => 'studentsform')); echo $OUTPUT->select($select); - helpbutton("participantswithselectedusers", get_string("withselectedusers")); + echo $OUTPUT->help_icon(moodle_help_icon::make("participantswithselectedusers", get_string("withselectedusers"))); echo ''."\n"; echo ''."\n"; echo ''."\n"; diff --git a/course/report/stats/report.php b/course/report/stats/report.php index 274039c36b4..6ec63ca0b70 100644 --- a/course/report/stats/report.php +++ b/course/report/stats/report.php @@ -100,7 +100,7 @@ $stats = $DB->get_records_sql($sql, $params); if (empty($stats)) { - notify(get_string('statsnodata')); + echo $OUTPUT->notification(get_string('statsnodata')); } else { diff --git a/course/reset.php b/course/reset.php index c91e09846bb..460252e09b8 100755 --- a/course/reset.php +++ b/course/reset.php @@ -67,7 +67,7 @@ if ($mform->is_cancelled()) { $table->data = $data; print_table($table); - print_continue('view.php?id='.$course->id); // Back to course page + echo $OUTPUT->continue_button('view.php?id='.$course->id); // Back to course page echo $OUTPUT->footer(); exit; } @@ -76,7 +76,7 @@ if ($mform->is_cancelled()) { print_header($course->fullname.': '.$strresetcourse, $course->fullname.': '.$strresetcourse, $navigation); echo $OUTPUT->heading($strresetcourse); -print_simple_box(get_string('resetinfo'), 'center', '60%'); +echo $OUTPUT->box(get_string('resetinfo')); $mform->display(); echo $OUTPUT->footer(); diff --git a/course/scales.php b/course/scales.php index adbcba7868c..8c44d7daf6f 100644 --- a/course/scales.php +++ b/course/scales.php @@ -34,13 +34,13 @@ $scalemenu = make_menu_from_list($scale->scale); - print_simple_box_start("center"); + echo $OUTPUT->box_start(); echo $OUTPUT->heading($scale->name); echo "
"; echo $OUTPUT->select(html_select::make($scalemenu)); echo "
"; echo text_to_html($scale->description); - print_simple_box_end(); + echo $OUTPUT->box_end(); echo $OUTPUT->close_window_button(); echo $OUTPUT->footer(); exit; @@ -60,13 +60,13 @@ foreach ($scales as $scale) { $scalemenu = make_menu_from_list($scale->scale); - print_simple_box_start("center"); + echo $OUTPUT->box_start(); echo $OUTPUT->heading($scale->name); echo "
"; echo $OUTPUT->select(html_select::make($scalemenu)); echo "
"; echo text_to_html($scale->description); - print_simple_box_end(); + echo $OUTPUT->box_end(); echo "
"; } @@ -83,13 +83,13 @@ foreach ($scales as $scale) { $scalemenu = make_menu_from_list($scale->scale); - print_simple_box_start("center"); + echo $OUTPUT->box_start(); echo $OUTPUT->heading($scale->name); echo "
"; - echo $OUTPUT->select(html_select::make($scalemenu)); + echo $OUTPUT->select(html_select::make($scalemenu, '')); echo "
"; echo text_to_html($scale->description); - print_simple_box_end(); + echo $OUTPUT->box_end(); echo "
"; } } diff --git a/course/search.php b/course/search.php index 780cc961756..e9f82b0d9e8 100644 --- a/course/search.php +++ b/course/search.php @@ -69,7 +69,7 @@ } if ($course) { if (! $DB->set_field("course", "visible", $visible, array("id"=>$course->id))) { - notify("Could not update that course!"); + echo $OUTPUT->notification("Could not update that course!"); } } } @@ -101,7 +101,7 @@ $navigation = build_navigation($navlinks); print_header("$site->fullname : $strsearch", $site->fullname, $navigation, "", ""); - print_simple_box_start("center"); + echo $OUTPUT->box_start(); echo "
"; echo "
"; print_course_search("", false, "plain"); @@ -109,7 +109,7 @@ print_string("searchhelp"); echo "

"; echo "
"; - print_simple_box_end(); + echo $OUTPUT->box_end(); echo $OUTPUT->footer(); exit; } diff --git a/course/user.php b/course/user.php index 82267b738cf..3f7d2655783 100644 --- a/course/user.php +++ b/course/user.php @@ -164,7 +164,7 @@ $statsstatus = stats_check_uptodate($course->id); if ($statsstatus !== NULL) { - notify ($statsstatus); + echo $OUTPUT->notification($statsstatus); } $earliestday = $DB->get_field_sql('SELECT timeend FROM {stats_user_daily} ORDER BY timeend'); diff --git a/course/view.php b/course/view.php index 72936683ccf..a17f966a08f 100644 --- a/course/view.php +++ b/course/view.php @@ -123,7 +123,7 @@ if (!empty($section)) { if (!empty($move) and confirm_sesskey()) { if (!move_section($course, $section, $move)) { - notify('An error occurred while moving a section'); + echo $OUTPUT->notification('An error occurred while moving a section'); } } }