]> git.mjollnir.org Git - moodle.git/commitdiff
Fixes to make print_error more useful, suggested by Sam
authormoodler <moodler>
Thu, 13 Apr 2006 05:42:47 +0000 (05:42 +0000)
committermoodler <moodler>
Thu, 13 Apr 2006 05:42:47 +0000 (05:42 +0000)
It can now take a module argument, and can support different link locations

course/report/participation/index.php
course/report/participation/mod.php
lang/en_utf8/moodle.php
lib/weblib.php

index 0a2f55d3e7cfde78fc249385ae68201947062f5d..975f6fb4e40f54d4b371a999cd020bb0dfac163b 100644 (file)
@@ -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);
     }
 
 
index 710c0e399e3413969e9d1ab9d256490fd453511d..48560054d7dabb2796d0e6b8fe6149df450464ab 100644 (file)
@@ -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);
     }
 
 
index c3d62278f73c8c1425115866c586280e93c1b151..1f8986c6136b8039203dd282306963591584226b 100644 (file)
@@ -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:';
index 9b3482d9900edda4760b6458a541ae44582985dc..502736631997a71449e25a048c0033552556d527 100644 (file)
@@ -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);
 }