From 87fa2e3f8a1a0c1d916359ab3d47ce28c4899b90 Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 13 Apr 2006 05:42:47 +0000 Subject: [PATCH] Fixes to make print_error more useful, suggested by Sam It can now take a module argument, and can support different link locations --- course/report/participation/index.php | 4 ++-- course/report/participation/mod.php | 4 ++-- lang/en_utf8/moodle.php | 1 + lib/weblib.php | 25 ++++++++++++++++++++++--- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/course/report/participation/index.php b/course/report/participation/index.php index 0a2f55d3e7..975f6fb4e4 100644 --- a/course/report/participation/index.php +++ b/course/report/participation/index.php @@ -30,7 +30,7 @@ require_login($course->id); if (!isteacher($course->id)) { - print_error('mustbeteacher',$CFG->wwwroot.'/course/view.php?id='.$course->id); + print_error('mustbeteacher', '', $CFG->wwwroot.'/course/view.php?id='.$course->id); } $strparticipation = get_string('participationreport'); @@ -52,7 +52,7 @@ if (!$modules = get_records_sql('SELECT DISTINCT module,name FROM '.$CFG->prefix.'course_modules cm JOIN '. $CFG->prefix.'modules m ON cm.module = m.id WHERE course = '.$course->id)) { - print_error('noparticipatorycms',$CFG->wwwroot.'/course/view.php?id='.$course->id); + print_error('noparticipatorycms', '', $CFG->wwwroot.'/course/view.php?id='.$course->id); } diff --git a/course/report/participation/mod.php b/course/report/participation/mod.php index 710c0e399e..48560054d7 100644 --- a/course/report/participation/mod.php +++ b/course/report/participation/mod.php @@ -1,4 +1,4 @@ -prefix.'course_modules cm JOIN '. $CFG->prefix.'modules m ON cm.module = m.id WHERE course = '.$course->id)) { - print_error('noparticipatorycms',$CFG->wwwroot.'/course/view.php?id='.$course->id); + print_error('noparticipatorycms','', $CFG->wwwroot.'/course/view.php?id='.$course->id); } diff --git a/lang/en_utf8/moodle.php b/lang/en_utf8/moodle.php index c3d62278f7..1f8986c613 100644 --- a/lang/en_utf8/moodle.php +++ b/lang/en_utf8/moodle.php @@ -807,6 +807,7 @@ $string['modulesuccess'] = '$a tables have been set up correctly'; $string['moodledocslink'] = 'Moodle Docs for this page'; $string['moodleversion'] = 'Moodle Version'; $string['more'] = 'more'; +$string['moreinformation'] = 'More information about this error'; $string['mostrecently'] = 'most recently'; $string['move'] = 'Move'; $string['movecategoryto'] = 'Move category to:'; diff --git a/lib/weblib.php b/lib/weblib.php index 9b3482d990..5027366319 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -4046,10 +4046,29 @@ function error ($message, $link='') { * @param string $errorcode The name of the string from error.php to print * @param string $link The url where the user will be prompted to continue. If no url is provided the user will be directed to the site index page. */ -function print_error ($errorcode, $link='') { +function print_error ($errorcode, $module='', $link='') { - $message = get_string($errorcode, 'error'). - '

('.$errorcode.')

'; + global $CFG; + + if (empty($module) || $module == 'moodle' || $module == 'core') { + $module = 'error'; + $modulelink = 'moodle'; + } else { + $modulelink = $module; + } + + if (!empty($CFG->errordocroot)) { + $errordocroot = $CFG->errordocroot; + } else if (!empty($CFG->docroot)) { + $errordocroot = $CFG->docroot; + } else { + $errordocroot = 'http://docs.moodle.org'; + } + + $message = '

'.get_string($errorcode, $module).'

'. + '

'. + ''. + get_string('moreinformation').'

'; error($message, $link); } -- 2.39.5