Fixes to make print_error more useful, suggested by Sam
It can now take a module argument, and can support different link locations
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php // $Id$
|
||||
|
||||
$strparticipation = get_string('participationreport');
|
||||
$strviews = get_string('views');
|
||||
@@ -15,7 +15,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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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:';
|
||||
|
||||
+22
-3
@@ -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').
|
||||
'<p class="code">(<a href="http://docs.moodle.org/en/error/'.$errorcode.'">'.$errorcode.'</a>)</p>';
|
||||
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 = '<p class="errormessage">'.get_string($errorcode, $module).'</p>'.
|
||||
'<p class="errorcode">'.
|
||||
'<a href="'.$errordocroot.'/en/error/'.$modulelink.'/'.$errorcode.'">'.
|
||||
get_string('moreinformation').'</a></p>';
|
||||
error($message, $link);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user