]> git.mjollnir.org Git - moodle.git/commitdiff
Only show page errors when debugging is on (in case we can recover)
authormoodler <moodler>
Fri, 28 Jan 2005 17:03:57 +0000 (17:03 +0000)
committermoodler <moodler>
Fri, 28 Jan 2005 17:03:57 +0000 (17:03 +0000)
lib/pagelib.php

index 8fcfa1a0c5522353ec79b0e8fa2a0a6d20005ae6..1c30ed9349da30b52fb40133c7eb2089d5778380 100644 (file)
@@ -25,6 +25,8 @@ define('MOODLE_PAGE_COURSE',    'course');
  */
 
 function page_create_object($type, $id = NULL) {
+    global $CFG;
+
     $data = new stdClass;
     $data->pagetype = $type;
     $data->pageid   = $id;
@@ -34,9 +36,11 @@ function page_create_object($type, $id = NULL) {
     $object = &new $classname;
     // TODO: subclassing check here
 
-    if($object->get_type() !== $type) {
+    if ($object->get_type() !== $type) {
         // Somehow somewhere someone made a mistake
-        error('Page object\'s type ('. $object->get_type() .') does not match requested type ('. $type .')');
+        if ($CFG->debug > 7) {
+            error('Page object\'s type ('. $object->get_type() .') does not match requested type ('. $type .')');
+        }
     }
 
     $object->init_quick($data);
@@ -49,23 +53,30 @@ function page_create_object($type, $id = NULL) {
  */
 
 function page_map_class($type, $classname = NULL) {
+    global $CFG;
+
     static $mappings = NULL;
     
-    if($mappings === NULL) {
+    if ($mappings === NULL) {
         $mappings = array(
             MOODLE_PAGE_COURSE => 'page_course'
         );
     }
 
-    if(!empty($type) && !empty($classname)) {
+    if (!empty($type) && !empty($classname)) {
         $mappings[$type] = $classname;
     }
-    if(!isset($mappings[$type])) {
-        error('Page class mapping requested for unknown type: '.$type);
+
+    if (!isset($mappings[$type])) {
+        if ($CFG->debug > 7) {
+            error('Page class mapping requested for unknown type: '.$type);
+        }
     }
 
-    if(!class_exists($mappings[$type])) {
-        error('Page class mapping for id "'.$type.'" exists but class "'.$mappings[$type].'" is not defined');
+    if (!class_exists($mappings[$type])) {
+        if ($CFG->debug > 7) {
+            error('Page class mapping for id "'.$type.'" exists but class "'.$mappings[$type].'" is not defined');
+        }
     }
 
     return $mappings[$type];
@@ -485,4 +496,4 @@ class page_course extends page_base {
     }
 }
 
-?>
\ No newline at end of file
+?>